aacreg.h revision 1.7 1 /* $NetBSD: aacreg.h,v 1.7 2007/05/26 02:09:40 briggs Exp $ */
2
3 /*-
4 * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Andrew Doran.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 /*-
40 * Copyright (c) 2000 Michael Smith
41 * Copyright (c) 2000-2001 Scott Long
42 * Copyright (c) 2000 BSDi
43 * Copyright (c) 2000 Niklas Hallqvist
44 * All rights reserved.
45 *
46 * Redistribution and use in source and binary forms, with or without
47 * modification, are permitted provided that the following conditions
48 * are met:
49 * 1. Redistributions of source code must retain the above copyright
50 * notice, this list of conditions and the following disclaimer.
51 * 2. Redistributions in binary form must reproduce the above copyright
52 * notice, this list of conditions and the following disclaimer in the
53 * documentation and/or other materials provided with the distribution.
54 *
55 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
56 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
58 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
59 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
60 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
61 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
62 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
63 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
64 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
65 * SUCH DAMAGE.
66 *
67 * from FreeBSD: aacreg.h,v 1.1 2000/09/13 03:20:34 msmith Exp
68 * via OpenBSD: aacreg.h,v 1.3 2001/06/12 15:40:29 niklas Exp
69 * incorporating some of: aacreg.h,v 1.23 2005/10/14 16:22:45 scottl Exp
70 */
71
72 /*
73 * Data structures defining the interface between the driver and the Adaptec
74 * 'FSA' adapters. Note that many field names and comments here are taken
75 * verbatim from the Adaptec driver source in order to make comparing the
76 * two slightly easier.
77 */
78
79 #ifndef _PCI_AACREG_H_
80 #define _PCI_AACREG_H_
81
82 /*
83 * Misc. magic numbers.
84 */
85 #define AAC_MAX_CONTAINERS 64
86 #define AAC_BLOCK_SIZE 512
87
88 /*
89 * Communications interface.
90 *
91 * Where datastructure layouts are closely parallel to the Adaptec sample code,
92 * retain their naming conventions (for now) to aid in cross-referencing.
93 */
94
95 /*
96 * We establish 4 command queues and matching response queues. Queues must
97 * be 16-byte aligned, and are sized as follows:
98 */
99 #define AAC_HOST_NORM_CMD_ENTRIES 8 /* cmd adapter->host, normal pri */
100 #define AAC_HOST_HIGH_CMD_ENTRIES 4 /* cmd adapter->host, high pri */
101 #define AAC_ADAP_NORM_CMD_ENTRIES 512 /* cmd host->adapter, normal pri */
102 #define AAC_ADAP_HIGH_CMD_ENTRIES 4 /* cmd host->adapter, high pri */
103 #define AAC_HOST_NORM_RESP_ENTRIES 512 /* resp, adapter->host, normal pri */
104 #define AAC_HOST_HIGH_RESP_ENTRIES 4 /* resp, adapter->host, high pri */
105 #define AAC_ADAP_NORM_RESP_ENTRIES 8 /* resp, host->adapter, normal pri */
106 #define AAC_ADAP_HIGH_RESP_ENTRIES 4 /* resp, host->adapter, high pri */
107
108 #define AAC_TOTALQ_LENGTH \
109 (AAC_HOST_HIGH_CMD_ENTRIES + AAC_HOST_NORM_CMD_ENTRIES + \
110 AAC_ADAP_HIGH_CMD_ENTRIES + AAC_ADAP_NORM_CMD_ENTRIES + \
111 AAC_HOST_HIGH_RESP_ENTRIES + AAC_HOST_NORM_RESP_ENTRIES + \
112 AAC_ADAP_HIGH_RESP_ENTRIES + AAC_ADAP_NORM_RESP_ENTRIES)
113
114 #define AAC_QUEUE_COUNT 8
115 #define AAC_QUEUE_ALIGN 16
116
117 struct aac_queue_entry {
118 u_int32_t aq_fib_size; /* FIB size in bytes */
119 u_int32_t aq_fib_addr; /* receiver-space address of the FIB */
120 } __attribute__ ((__packed__));
121
122 #define AAC_PRODUCER_INDEX 0
123 #define AAC_CONSUMER_INDEX 1
124
125 /*
126 * Table of queue indices and queues used to communicate with the
127 * controller. This structure must be aligned to AAC_QUEUE_ALIGN
128 */
129 struct aac_queue_table {
130 /* queue consumer/producer indexes (layout mandated by adapter) */
131 u_int32_t qt_qindex[AAC_QUEUE_COUNT][2];
132
133 /* queue entry structures (layout mandated by adapter) */
134 struct aac_queue_entry qt_HostNormCmdQueue[AAC_HOST_NORM_CMD_ENTRIES];
135 struct aac_queue_entry qt_HostHighCmdQueue[AAC_HOST_HIGH_CMD_ENTRIES];
136 struct aac_queue_entry qt_AdapNormCmdQueue[AAC_ADAP_NORM_CMD_ENTRIES];
137 struct aac_queue_entry qt_AdapHighCmdQueue[AAC_ADAP_HIGH_CMD_ENTRIES];
138 struct aac_queue_entry
139 qt_HostNormRespQueue[AAC_HOST_NORM_RESP_ENTRIES];
140 struct aac_queue_entry
141 qt_HostHighRespQueue[AAC_HOST_HIGH_RESP_ENTRIES];
142 struct aac_queue_entry
143 qt_AdapNormRespQueue[AAC_ADAP_NORM_RESP_ENTRIES];
144 struct aac_queue_entry
145 qt_AdapHighRespQueue[AAC_ADAP_HIGH_RESP_ENTRIES];
146 } __attribute__ ((__packed__));
147
148 /*
149 * Adapter Init Structure: this is passed to the adapter with the
150 * AAC_MONKER_INITSTRUCT command to point it at our control structures.
151 */
152 struct aac_adapter_init {
153 u_int32_t InitStructRevision;
154 #define AAC_INIT_STRUCT_REVISION 3
155 #define AAC_INIT_STRUCT_REVISION_4 4
156 u_int32_t MiniPortRevision;
157 #define AAC_INIT_STRUCT_MINIPORT_REVISION 1
158 u_int32_t FilesystemRevision;
159 u_int32_t CommHeaderAddress;
160 u_int32_t FastIoCommAreaAddress;
161 u_int32_t AdapterFibsPhysicalAddress;
162 u_int32_t AdapterFibsVirtualAddress;
163 u_int32_t AdapterFibsSize;
164 u_int32_t AdapterFibAlign;
165 u_int32_t PrintfBufferAddress;
166 u_int32_t PrintfBufferSize;
167 u_int32_t HostPhysMemPages;
168 u_int32_t HostElapsedSeconds;
169 /* ADAPTER_INIT_STRUCT_REVISION_4 begins here */
170 u_int32_t InitFlags; /* flags for supported features */
171 #define AAC_INITFLAGS_NEW_COMM_SUPPORTED 1
172 u_int32_t MaxIoCommands; /* max outstanding commands */
173 u_int32_t MaxIoSize; /* largest I/O command */
174 u_int32_t MaxFibSize; /* largest FIB to adapter */
175 } __attribute__((__packed__));
176
177 /*
178 * Shared data types
179 */
180
181 /*
182 * Container types
183 */
184 #define CT_NONE 0
185 #define CT_VOLUME 1
186 #define CT_MIRROR 2
187 #define CT_STRIPE 3
188 #define CT_RAID5 4
189 #define CT_SSRW 5
190 #define CT_SSRO 6
191 #define CT_MORPH 7
192 #define CT_PASSTHRU 8
193 #define CT_RAID4 9
194 #define CT_RAID10 10 /* stripe of mirror */
195 #define CT_RAID00 11 /* stripe of stripe */
196 #define CT_VOLUME_OF_MIRRORS 12 /* volume of mirror */
197 #define CT_PSEUDO_RAID3 13 /* really raid4 */
198
199 /*
200 * Host-addressable object types
201 */
202 #define FT_REG 1 /* regular file */
203 #define FT_DIR 2 /* directory */
204 #define FT_BLK 3 /* "block" device - reserved */
205 #define FT_CHR 4 /* "character special" device - reserved */
206 #define FT_LNK 5 /* symbolic link */
207 #define FT_SOCK 6 /* socket */
208 #define FT_FIFO 7 /* fifo */
209 #define FT_FILESYS 8 /* ADAPTEC's "FSA"(tm) filesystem */
210 #define FT_DRIVE 9 /* phys disk - addressable in scsi by bus/target/lun */
211 #define FT_SLICE 10 /* virtual disk - raw volume - slice */
212 #define FT_PARTITION 11 /* FSA part, inside slice, container building block */
213 #define FT_VOLUME 12 /* Container - Volume Set */
214 #define FT_STRIPE 13 /* Container - Stripe Set */
215 #define FT_MIRROR 14 /* Container - Mirror Set */
216 #define FT_RAID5 15 /* Container - Raid 5 Set */
217 #define FT_DATABASE 16 /* Storage object with "foreign" content manager */
218
219 /*
220 * Host-side scatter/gather list for 32-bit commands.
221 */
222 struct aac_sg_entry {
223 u_int32_t SgAddress;
224 u_int32_t SgByteCount;
225 } __attribute__ ((__packed__));
226
227 struct aac_sg_table {
228 u_int32_t SgCount;
229 struct aac_sg_entry SgEntry[0]; /* XXX */
230 } __attribute__ ((__packed__));
231
232 /*
233 * Host-side scatter/gather list for 64-bit commands.
234 */
235 struct aac_sg_table64 {
236 u_int8_t SgCount;
237 u_int8_t SgSectorsPerPage;
238 u_int16_t SgByteOffset;
239 u_int64_t SgEntry[0];
240 } __attribute__ ((__packed__));
241
242 /*
243 * Container creation data
244 */
245 struct aac_container_creation {
246 u_int8_t ViaBuildNumber;
247 u_int8_t MicroSecond;
248 u_int8_t Via; /* 1 = FSU, 2 = API, etc. */
249 u_int8_t YearsSince1900;
250 u_int32_t Month:4; /* 1-12 */
251 u_int32_t Day:6; /* 1-32 */
252 u_int32_t Hour:6; /* 0-23 */
253 u_int32_t Minute:6; /* 0-59 */
254 u_int32_t Second:6; /* 0-59 */
255 u_int64_t ViaAdapterSerialNumber;
256 } __attribute__ ((__packed__));
257
258 struct FsaRevision {
259 union {
260 struct {
261 u_int8_t dash;
262 u_int8_t type;
263 u_int8_t minor;
264 u_int8_t major;
265 } comp;
266 u_int32_t ul;
267 } external;
268 u_int32_t buildNumber;
269 } __attribute__((__packed__));
270
271 /*
272 * Adapter Information
273 */
274
275 #define CPU_NTSIM 1
276 #define CPU_I960 2
277 #define CPU_ARM 3
278 #define CPU_SPARC 4
279 #define CPU_POWERPC 5
280 #define CPU_ALPHA 6
281 #define CPU_P7 7
282 #define CPU_I960_RX 8
283 #define CPU__last 9
284
285 #define CPUI960_JX 1
286 #define CPUI960_CX 2
287 #define CPUI960_HX 3
288 #define CPUI960_RX 4
289 #define CPUARM_SA110 5
290 #define CPUARM_xxx 6
291 #define CPUPPC_603e 7
292 #define CPUPPC_xxx 8
293 #define CPUI80303 9
294 #define CPUSUBTYPE__last 10
295
296 #define PLAT_NTSIM 1
297 #define PLAT_V3ADU 2
298 #define PLAT_CYCLONE 3
299 #define PLAT_CYCLONE_HD 4
300 #define PLAT_BATBOARD 5
301 #define PLAT_BATBOARD_HD 6
302 #define PLAT_YOLO 7
303 #define PLAT_COBRA 8
304 #define PLAT_ANAHEIM 9
305 #define PLAT_JALAPENO 10
306 #define PLAT_QUEENS 11
307 #define PLAT_JALAPENO_DELL 12
308 #define PLAT_POBLANO 13
309 #define PLAT_POBLANO_OPAL 14
310 #define PLAT_POBLANO_SL0 15
311 #define PLAT_POBLANO_SL1 16
312 #define PLAT_POBLANO_SL2 17
313 #define PLAT_POBLANO_XXX 18
314 #define PLAT_JALAPENO_P2 19
315 #define PLAT_HABANERO 20
316 #define PLAT__last 21
317
318 #define OEM_FLAVOR_ADAPTEC 1
319 #define OEM_FLAVOR_DELL 2
320 #define OEM_FLAVOR_HP 3
321 #define OEM_FLAVOR_IBM 4
322 #define OEM_FLAVOR_CPQ 5
323 #define OEM_FLAVOR_BRAND_X 6
324 #define OEM_FLAVOR_BRAND_Y 7
325 #define OEM_FLAVOR_BRAND_Z 8
326 #define OEM_FLAVOR__last 9
327
328 /*
329 * XXX the aac-2622 with no battery present reports PLATFORM_BAT_OPT_PRESENT
330 */
331 #define PLATFORM_BAT_REQ_PRESENT 1 /* BATTERY REQUIRED AND PRESENT */
332 #define PLATFORM_BAT_REQ_NOTPRESENT 2 /* BATTERY REQUIRED AND NOT PRESENT */
333 #define PLATFORM_BAT_OPT_PRESENT 3 /* BATTERY OPTIONAL AND PRESENT */
334 #define PLATFORM_BAT_OPT_NOTPRESENT 4 /* BATTERY OPTIONAL AND NOT PRESENT */
335 #define PLATFORM_BAT_NOT_SUPPORTED 5 /* BATTERY NOT SUPPORTED */
336
337 /*
338 * Structure used to respond to a RequestAdapterInfo fib.
339 */
340 struct aac_adapter_info {
341 u_int32_t PlatformBase; /* adapter type */
342 u_int32_t CpuArchitecture; /* adapter CPU type */
343 u_int32_t CpuVariant; /* adapter CPU subtype */
344 u_int32_t ClockSpeed; /* adapter CPU clockspeed */
345 u_int32_t ExecutionMem; /* adapter Execution Memory size */
346 u_int32_t BufferMem; /* adapter Data Memory */
347 u_int32_t TotalMem; /* adapter Total Memory */
348 struct FsaRevision KernelRevision; /* adapter Kernel SW Revision */
349 struct FsaRevision MonitorRevision; /* adapter Monitor/Diag SW Rev */
350 struct FsaRevision HardwareRevision; /* TDB */
351 struct FsaRevision BIOSRevision; /* adapter BIOS Revision */
352 u_int32_t ClusteringEnabled;
353 u_int32_t ClusterChannelMask;
354 u_int64_t SerialNumber;
355 u_int32_t batteryPlatform;
356 u_int32_t SupportedOptions; /* supported features of this ctrlr */
357 u_int32_t OemVariant;
358 } __attribute__((__packed__));
359
360 /*
361 * Monitor/Kernel interface.
362 */
363
364 /*
365 * Synchronous commands to the monitor/kernel.
366 */
367 #define AAC_MONKER_INITSTRUCT 0x05
368 #define AAC_MONKER_SYNCFIB 0x0c
369 #define AAC_MONKER_GETKERNVER 0x11
370 #define AAC_MONKER_GETINFO 0x19
371
372 /*
373 * Command status values
374 */
375 #define ST_OK 0
376 #define ST_PERM 1
377 #define ST_NOENT 2
378 #define ST_IO 5
379 #define ST_NXIO 6
380 #define ST_E2BIG 7
381 #define ST_ACCES 13
382 #define ST_EXIST 17
383 #define ST_XDEV 18
384 #define ST_NODEV 19
385 #define ST_NOTDIR 20
386 #define ST_ISDIR 21
387 #define ST_INVAL 22
388 #define ST_FBIG 27
389 #define ST_NOSPC 28
390 #define ST_ROFS 30
391 #define ST_MLINK 31
392 #define ST_WOULDBLOCK 35
393 #define ST_NAMETOOLONG 63
394 #define ST_NOTEMPTY 66
395 #define ST_DQUOT 69
396 #define ST_STALE 70
397 #define ST_REMOTE 71
398 #define ST_BADHANDLE 10001
399 #define ST_NOT_SYNC 10002
400 #define ST_BAD_COOKIE 10003
401 #define ST_NOTSUPP 10004
402 #define ST_TOOSMALL 10005
403 #define ST_SERVERFAULT 10006
404 #define ST_BADTYPE 10007
405 #define ST_JUKEBOX 10008
406 #define ST_NOTMOUNTED 10009
407 #define ST_MAINTMODE 10010
408 #define ST_STALEACL 10011
409
410 /*
411 * Volume manager commands
412 */
413 #define VM_Null 0
414 #define VM_NameServe 1
415 #define VM_ContainerConfig 2
416 #define VM_Ioctl 3
417 #define VM_FilesystemIoctl 4
418 #define VM_CloseAll 5
419 #define VM_CtBlockRead 6
420 #define VM_CtBlockWrite 7
421 #define VM_SliceBlockRead 8 /* raw access to configured "storage objects" */
422 #define VM_SliceBlockWrite 9
423 #define VM_DriveBlockRead 10 /* raw access to physical devices */
424 #define VM_DriveBlockWrite 11
425 #define VM_EnclosureMgt 12 /* enclosure management */
426 #define VM_Unused 13 /* used to be diskset management */
427 #define VM_CtBlockVerify 14
428 #define VM_CtPerf 15 /* performance test */
429 #define VM_CtBlockRead64 16
430 #define VM_CtBlockWrite64 17
431 #define VM_CtBlockVerify64 18
432
433 /*
434 * "Mountable object"
435 */
436 struct aac_mntobj {
437 u_int32_t ObjectId;
438 char FileSystemName[16];
439 struct aac_container_creation CreateInfo;
440 u_int32_t Capacity;
441 u_int32_t VolType;
442 u_int32_t ObjType;
443 u_int32_t ContentState;
444 #define AAC_FSCS_READONLY 0x0002 /* XXX need more information than this */
445 union {
446 u_int32_t pad[8];
447 } ObjExtension;
448 u_int32_t AlterEgoId;
449 } __attribute__ ((__packed__));
450
451 struct aac_mntinfo {
452 u_int32_t Command;
453 u_int32_t MntType;
454 u_int32_t MntCount;
455 } __attribute__ ((__packed__));
456
457 struct aac_mntinforesponse {
458 u_int32_t Status;
459 u_int32_t MntType;
460 u_int32_t MntRespCount;
461 struct aac_mntobj MntTable[1];
462 } __attribute__ ((__packed__));
463
464 /*
465 * Write 'stability' options.
466 */
467 #define CSTABLE 1
468 #define CUNSTABLE 2
469
470 /*
471 * Commit level response for a write request.
472 */
473 #define CMFILE_SYNC_NVRAM 1
474 #define CMDATA_SYNC_NVRAM 2
475 #define CMFILE_SYNC 3
476 #define CMDATA_SYNC 4
477 #define CMUNSTABLE 5
478
479 /*
480 * Block read/write operations. These structures are packed into the 'data'
481 * area in the FIB.
482 */
483 struct aac_blockread {
484 u_int32_t Command; /* not FSACommand! */
485 u_int32_t ContainerId;
486 u_int32_t BlockNumber;
487 u_int32_t ByteCount;
488 struct aac_sg_table SgMap; /* variable size */
489 } __attribute__ ((__packed__));
490
491 struct aac_blockread_response {
492 u_int32_t Status;
493 u_int32_t ByteCount;
494 } __attribute__ ((__packed__));
495
496 struct aac_blockwrite {
497 u_int32_t Command; /* not FSACommand! */
498 u_int32_t ContainerId;
499 u_int32_t BlockNumber;
500 u_int32_t ByteCount;
501 u_int32_t Stable;
502 struct aac_sg_table SgMap; /* variable size */
503 } __attribute__ ((__packed__));
504
505 struct aac_blockwrite_response {
506 u_int32_t Status;
507 u_int32_t ByteCount;
508 u_int32_t Committed;
509 } __attribute__ ((__packed__));
510
511 struct aac_close_command {
512 u_int32_t Command;
513 u_int32_t ContainerId;
514 } __attribute__ ((__packed__));
515
516 /*
517 * Register definitions for the Adaptec AAC-364 'Jalapeno I/II' adapters, based
518 * on the SA110 'StrongArm'.
519 */
520
521 #define AAC_REGSIZE 0x100
522
523 /* doorbell 0 (adapter->host) */
524 #define AAC_SA_DOORBELL0_CLEAR 0x98
525 #define AAC_SA_DOORBELL0_SET 0x9c
526 #define AAC_SA_DOORBELL0 0x9c
527 #define AAC_SA_MASK0_CLEAR 0xa0
528 #define AAC_SA_MASK0_SET 0xa4
529
530 /* doorbell 1 (host->adapter) */
531 #define AAC_SA_DOORBELL1_CLEAR 0x9a
532 #define AAC_SA_DOORBELL1_SET 0x9e
533 #define AAC_SA_MASK1_CLEAR 0xa2
534 #define AAC_SA_MASK1_SET 0xa6
535
536 /* mailbox (20 bytes) */
537 #define AAC_SA_MAILBOX 0xa8
538 #define AAC_SA_FWSTATUS 0xc4
539
540 /*
541 * Register definitions for the Adaptec 'Pablano' adapters, based on the
542 * i960Rx, and other related adapters.
543 */
544
545 #define AAC_RX_IDBR 0x20 /* inbound doorbell */
546 #define AAC_RX_IISR 0x24 /* inbound interrupt status */
547 #define AAC_RX_IIMR 0x28 /* inbound interrupt mask */
548 #define AAC_RX_ODBR 0x2c /* outbound doorbell */
549 #define AAC_RX_OISR 0x30 /* outbound interrupt status */
550 #define AAC_RX_OIMR 0x34 /* outbound interrupt mask */
551
552 #define AAC_RX_MAILBOX 0x50 /* mailbox (20 bytes) */
553 #define AAC_RX_FWSTATUS 0x6c
554
555 /*
556 * Common bit definitions for the doorbell registers.
557 */
558
559 /*
560 * Status bits in the doorbell registers.
561 */
562 #define AAC_DB_SYNC_COMMAND (1<<0) /* send/completed synchronous FIB */
563 #define AAC_DB_COMMAND_READY (1<<1) /* posted one or more commands */
564 #define AAC_DB_RESPONSE_READY (1<<2) /* one or more commands complete */
565 #define AAC_DB_COMMAND_NOT_FULL (1<<3) /* command queue not full */
566 #define AAC_DB_RESPONSE_NOT_FULL (1<<4) /* response queue not full */
567
568 /*
569 * The adapter can request the host print a message by setting the
570 * DB_PRINTF flag in DOORBELL0. The driver responds by collecting the
571 * message from the printf buffer, clearing the DB_PRINTF flag in
572 * DOORBELL0 and setting it in DOORBELL1.
573 * (ODBR and IDBR respectively for the i960Rx adapters)
574 */
575 #define AAC_DB_PRINTF (1<<5)
576
577 /*
578 * Mask containing the interrupt bits we care about. We don't anticipate
579 * (or want) interrupts not in this mask.
580 */
581 #define AAC_DB_INTERRUPTS \
582 (AAC_DB_COMMAND_READY | AAC_DB_RESPONSE_READY | AAC_DB_PRINTF)
583
584 /*
585 * Queue names
586 *
587 * Note that we base these at 0 in order to use them as array indices. Adaptec
588 * used base 1 for some unknown reason, and sorted them in a different order.
589 */
590 #define AAC_HOST_NORM_CMD_QUEUE 0
591 #define AAC_HOST_HIGH_CMD_QUEUE 1
592 #define AAC_ADAP_NORM_CMD_QUEUE 2
593 #define AAC_ADAP_HIGH_CMD_QUEUE 3
594 #define AAC_HOST_NORM_RESP_QUEUE 4
595 #define AAC_HOST_HIGH_RESP_QUEUE 5
596 #define AAC_ADAP_NORM_RESP_QUEUE 6
597 #define AAC_ADAP_HIGH_RESP_QUEUE 7
598
599 /*
600 * List structure used to chain FIBs (used by the adapter - we hang FIBs off
601 * our private command structure and don't touch these)
602 */
603 struct aac_fib_list_entry {
604 u_int32_t Flink;
605 u_int32_t Blink;
606 } __attribute__((__packed__));
607
608 /*
609 * FIB (FSA Interface Block?); this is the datastructure passed between the
610 * host and adapter.
611 */
612 struct aac_fib_header {
613 u_int32_t XferState;
614 u_int16_t Command;
615 u_int8_t StructType;
616 u_int8_t Flags;
617 u_int16_t Size;
618 u_int16_t SenderSize;
619 u_int32_t SenderFibAddress;
620 u_int32_t ReceiverFibAddress;
621 u_int32_t SenderData;
622 union {
623 struct {
624 u_int32_t ReceiverTimeStart;
625 u_int32_t ReceiverTimeDone;
626 } _s;
627 struct aac_fib_list_entry FibLinks;
628 } _u;
629 } __attribute__((__packed__));
630
631 #define AAC_FIB_DATASIZE (512 - sizeof(struct aac_fib_header))
632
633 struct aac_fib {
634 struct aac_fib_header Header;
635 u_int8_t data[AAC_FIB_DATASIZE];
636 } __attribute__((__packed__));
637
638 /*
639 * FIB commands
640 */
641 #define TestCommandResponse 1
642 #define TestAdapterCommand 2
643
644 /* Lowlevel and comm commands */
645 #define LastTestCommand 100
646 #define ReinitHostNormCommandQueue 101
647 #define ReinitHostHighCommandQueue 102
648 #define ReinitHostHighRespQueue 103
649 #define ReinitHostNormRespQueue 104
650 #define ReinitAdapNormCommandQueue 105
651 #define ReinitAdapHighCommandQueue 107
652 #define ReinitAdapHighRespQueue 108
653 #define ReinitAdapNormRespQueue 109
654 #define InterfaceShutdown 110
655 #define DmaCommandFib 120
656 #define StartProfile 121
657 #define TermProfile 122
658 #define SpeedTest 123
659 #define TakeABreakPt 124
660 #define RequestPerfData 125
661 #define SetInterruptDefTimer 126
662 #define SetInterruptDefCount 127
663 #define GetInterruptDefStatus 128
664 #define LastCommCommand 129
665
666 /* filesystem commands */
667 #define NuFileSystem 300
668 #define UFS 301
669 #define HostFileSystem 302
670 #define LastFileSystemCommand 303
671
672 /* Container Commands */
673 #define ContainerCommand 500
674 #define ContainerCommand64 501
675
676 /* Cluster Commands */
677 #define ClusterCommand 550
678
679 /* Scsi Port commands (scsi passthrough) */
680 #define ScsiPortCommand 600
681
682 /* Misc house keeping and generic adapter initiated commands */
683 #define AifRequest 700
684 #define CheckRevision 701
685 #define FsaHostShutdown 702
686 #define RequestAdapterInfo 703
687 #define IsAdapterPaused 704
688 #define SendHostTime 705
689 #define LastMiscCommand 706
690
691 /*
692 * FIB types
693 */
694 #define AAC_FIBTYPE_TFIB 1
695 #define AAC_FIBTYPE_TQE 2
696 #define AAC_FIBTYPE_TCTPERF 3
697
698 /*
699 * FIB transfer state
700 */
701 #define AAC_FIBSTATE_HOSTOWNED (1<<0) /* owned by the host */
702 #define AAC_FIBSTATE_ADAPTEROWNED (1<<1) /* owned by the adapter */
703 #define AAC_FIBSTATE_INITIALISED (1<<2) /* initialised */
704 #define AAC_FIBSTATE_EMPTY (1<<3) /* empty */
705 #define AAC_FIBSTATE_FROMPOOL (1<<4) /* allocated from pool */
706 #define AAC_FIBSTATE_FROMHOST (1<<5) /* sent from the host */
707 #define AAC_FIBSTATE_FROMADAP (1<<6) /* sent from the adapter */
708 #define AAC_FIBSTATE_REXPECTED (1<<7) /* response is expected */
709 #define AAC_FIBSTATE_RNOTEXPECTED (1<<8) /* response is not expected */
710 #define AAC_FIBSTATE_DONEADAP (1<<9) /* processed by the adapter */
711 #define AAC_FIBSTATE_DONEHOST (1<<10) /* processed by the host */
712 #define AAC_FIBSTATE_HIGH (1<<11) /* high priority */
713 #define AAC_FIBSTATE_NORM (1<<12) /* normal priority */
714 #define AAC_FIBSTATE_ASYNC (1<<13)
715 #define AAC_FIBSTATE_ASYNCIO (1<<13) /* to be removed */
716 #define AAC_FIBSTATE_PAGEFILEIO (1<<14) /* to be removed */
717 #define AAC_FIBSTATE_SHUTDOWN (1<<15)
718 #define AAC_FIBSTATE_LAZYWRITE (1<<16) /* to be removed */
719 #define AAC_FIBSTATE_ADAPMICROFIB (1<<17)
720 #define AAC_FIBSTATE_BIOSFIB (1<<18)
721 #define AAC_FIBSTATE_FAST_RESPONSE (1<<19) /* fast response capable */
722 #define AAC_FIBSTATE_APIFIB (1<<20)
723
724 /*
725 * FIB error values
726 */
727 #define AAC_ERROR_NORMAL 0x00
728 #define AAC_ERROR_PENDING 0x01
729 #define AAC_ERROR_FATAL 0x02
730 #define AAC_ERROR_INVALID_QUEUE 0x03
731 #define AAC_ERROR_NOENTRIES 0x04
732 #define AAC_ERROR_SENDFAILED 0x05
733 #define AAC_ERROR_INVALID_QUEUE_PRIORITY 0x06
734 #define AAC_ERROR_FIB_ALLOCATION_FAILED 0x07
735 #define AAC_ERROR_FIB_DEALLOCATION_FAILED 0x08
736
737 /*
738 * Adapter Status Register
739 *
740 * Phase Staus mailbox is 32bits:
741 * <31:16> = Phase Status
742 * <15:0> = Phase
743 *
744 * The adapter reports its present state through the phase. Only
745 * a single phase should be ever be set. Each phase can have multiple
746 * phase status bits to provide more detailed information about the
747 * state of the adapter.
748 */
749 #define AAC_SELF_TEST_FAILED 0x00000004
750 #define AAC_UP_AND_RUNNING 0x00000080
751 #define AAC_KERNEL_PANIC 0x00000100
752
753 /*
754 * Data types relating to control and monitoring of the NVRAM/WriteCache
755 * subsystem.
756 */
757
758 #define AAC_NFILESYS 24 /* maximum number of filesystems */
759
760 /*
761 * NVRAM/Write Cache subsystem states
762 */
763 typedef enum {
764 NVSTATUS_DISABLED = 0, /* present, clean, not being used */
765 NVSTATUS_ENABLED, /* present, possibly dirty, ready for use */
766 NVSTATUS_ERROR, /* present, dirty, contains dirty data */
767 NVSTATUS_BATTERY, /* present, bad or low battery, may contain
768 * dirty data */
769 NVSTATUS_UNKNOWN /* for bad/missing device */
770 } AAC_NVSTATUS;
771
772 /*
773 * NVRAM/Write Cache subsystem battery component states
774 *
775 */
776 typedef enum {
777 NVBATTSTATUS_NONE = 0, /* battery has no power or is not present */
778 NVBATTSTATUS_LOW, /* battery is low on power */
779 NVBATTSTATUS_OK, /* battery is okay - normal operation possible
780 * only in this state */
781 NVBATTSTATUS_RECONDITIONING /* no battery present - reconditioning
782 * in process */
783 } AAC_NVBATTSTATUS;
784
785 /*
786 * Battery transition type
787 */
788 typedef enum {
789 NVBATT_TRANSITION_NONE = 0, /* battery now has no power or is not
790 * present */
791 NVBATT_TRANSITION_LOW, /* battery is now low on power */
792 NVBATT_TRANSITION_OK /* battery is now okay - normal
793 * operation possible only in this
794 * state */
795 } AAC_NVBATT_TRANSITION;
796
797 /*
798 * NVRAM Info structure returned for NVRAM_GetInfo call
799 */
800 struct aac_nvramdevinfo {
801 u_int32_t NV_Enabled; /* write caching enabled */
802 u_int32_t NV_Error; /* device in error state */
803 u_int32_t NV_NDirty; /* count of dirty NVRAM buffers */
804 u_int32_t NV_NActive; /* count of NVRAM buffers being
805 * written */
806 } __packed;
807
808 struct aac_nvraminfo {
809 AAC_NVSTATUS NV_Status; /* nvram subsystem status */
810 AAC_NVBATTSTATUS NV_BattStatus; /* battery status */
811 u_int32_t NV_Size; /* size of WriteCache NVRAM in
812 * bytes */
813 u_int32_t NV_BufSize; /* size of NVRAM buffers in
814 * bytes */
815 u_int32_t NV_NBufs; /* number of NVRAM buffers */
816 u_int32_t NV_NDirty; /* Num dirty NVRAM buffers */
817 u_int32_t NV_NClean; /* Num clean NVRAM buffers */
818 u_int32_t NV_NActive; /* Num NVRAM buffers being
819 * written */
820 u_int32_t NV_NBrokered; /* Num brokered NVRAM buffers */
821 struct aac_nvramdevinfo NV_DevInfo[AAC_NFILESYS]; /* per device
822 * info */
823 u_int32_t NV_BattNeedsReconditioning; /* boolean */
824 u_int32_t NV_TotalSize; /* size of all non-volatile
825 * memories in bytes */
826 } __packed;
827
828 /*
829 * Data types relating to adapter-initiated FIBs
830 *
831 * Based on types and structures in <aifstruc.h>
832 */
833
834 /*
835 * Progress Reports
836 */
837 typedef enum {
838 AifJobStsSuccess = 1,
839 AifJobStsFinished,
840 AifJobStsAborted,
841 AifJobStsFailed,
842 AifJobStsLastReportMarker = 100, /* All prior mean last report */
843 AifJobStsSuspended,
844 AifJobStsRunning
845 } AAC_AifJobStatus;
846
847 typedef enum {
848 AifJobScsiMin = 1, /* Minimum value for Scsi operation */
849 AifJobScsiZero, /* SCSI device clear operation */
850 AifJobScsiVerify, /* SCSI device Verify operation NO
851 * REPAIR */
852 AifJobScsiExercise, /* SCSI device Exercise operation */
853 AifJobScsiVerifyRepair, /* SCSI device Verify operation WITH
854 * repair */
855 AifJobScsiWritePattern, /* write pattern */
856 AifJobScsiMax = 99, /* Max Scsi value */
857 AifJobCtrMin, /* Min Ctr op value */
858 AifJobCtrZero, /* Container clear operation */
859 AifJobCtrCopy, /* Container copy operation */
860 AifJobCtrCreateMirror, /* Container Create Mirror operation */
861 AifJobCtrMergeMirror, /* Container Merge Mirror operation */
862 AifJobCtrScrubMirror, /* Container Scrub Mirror operation */
863 AifJobCtrRebuildRaid5, /* Container Rebuild Raid5 operation */
864 AifJobCtrScrubRaid5, /* Container Scrub Raid5 operation */
865 AifJobCtrMorph, /* Container morph operation */
866 AifJobCtrPartCopy, /* Container Partition copy operation */
867 AifJobCtrRebuildMirror, /* Container Rebuild Mirror operation */
868 AifJobCtrCrazyCache, /* crazy cache */
869 AifJobCtrCopyback, /* Container Copyback operation */
870 AifJobCtrCompactRaid5D, /* Container Compaction operation */
871 AifJobCtrExpandRaid5D, /* Container Expansion operation */
872 AifJobCtrRebuildRaid6, /* Container Rebuild Raid6 operation */
873 AifJobCtrScrubRaid6, /* Container Scrub Raid6 operation */
874 AifJobCtrSSBackup, /* Container snapshot backup task */
875 AifJobCtrMax = 199, /* Max Ctr type operation */
876 AifJobFsMin, /* Min Fs type operation */
877 AifJobFsCreate, /* File System Create operation */
878 AifJobFsVerify, /* File System Verify operation */
879 AifJobFsExtend, /* File System Extend operation */
880 AifJobFsMax = 299, /* Max Fs type operation */
881 AifJobApiFormatNTFS, /* Format a drive to NTFS */
882 AifJobApiFormatFAT, /* Format a drive to FAT */
883 AifJobApiUpdateSnapshot, /* update the read/write half of a
884 * snapshot */
885 AifJobApiFormatFAT32, /* Format a drive to FAT32 */
886 AifJobApiMax = 399, /* Max API type operation */
887 AifJobCtlContinuousCtrVerify, /* Adapter operation */
888 AifJobCtlMax = 499 /* Max Adapter type operation */
889 } AAC_AifJobType;
890
891 struct aac_AifContainers {
892 u_int32_t src; /* from/master */
893 u_int32_t dst; /* to/slave */
894 } __packed;
895
896 union aac_AifJobClient {
897 struct aac_AifContainers container; /* For Container and
898 * filesystem progress
899 * ops; */
900 int32_t scsi_dh; /* For SCSI progress
901 * ops */
902 };
903
904 struct aac_AifJobDesc {
905 u_int32_t jobID; /* DO NOT FILL IN! Will be
906 * filled in by AIF */
907 AAC_AifJobType type; /* Operation that is being
908 * performed */
909 union aac_AifJobClient client; /* Details */
910 } __packed;
911
912 struct aac_AifJobProgressReport {
913 struct aac_AifJobDesc jd;
914 AAC_AifJobStatus status;
915 u_int32_t finalTick;
916 u_int32_t currentTick;
917 u_int32_t jobSpecificData1;
918 u_int32_t jobSpecificData2;
919 } __packed;
920
921 /*
922 * Event Notification
923 */
924 typedef enum {
925 /* General application notifies start here */
926 AifEnGeneric = 1, /* Generic notification */
927 AifEnTaskComplete, /* Task has completed */
928 AifEnConfigChange, /* Adapter config change occurred */
929 AifEnContainerChange, /* Adapter specific container
930 * configuration change */
931 AifEnDeviceFailure, /* SCSI device failed */
932 AifEnMirrorFailover, /* Mirror failover started */
933 AifEnContainerEvent, /* Significant container event */
934 AifEnFileSystemChange, /* File system changed */
935 AifEnConfigPause, /* Container pause event */
936 AifEnConfigResume, /* Container resume event */
937 AifEnFailoverChange, /* Failover space assignment changed */
938 AifEnRAID5RebuildDone, /* RAID5 rebuild finished */
939 AifEnEnclosureManagement, /* Enclosure management event */
940 AifEnBatteryEvent, /* Significant NV battery event */
941 AifEnAddContainer, /* A new container was created. */
942 AifEnDeleteContainer, /* A container was deleted. */
943 AifEnSMARTEvent, /* SMART Event */
944 AifEnBatteryNeedsRecond, /* The battery needs reconditioning */
945 AifEnClusterEvent, /* Some cluster event */
946 AifEnDiskSetEvent, /* A disk set event occured. */
947 AifDriverNotifyStart=199, /* Notifies for host driver go here */
948 /* Host driver notifications start here */
949 AifDenMorphComplete, /* A morph operation completed */
950 AifDenVolumeExtendComplete /* Volume expand operation completed */
951 } AAC_AifEventNotifyType;
952
953 struct aac_AifEnsGeneric {
954 char text[132]; /* Generic text */
955 } __packed;
956
957 struct aac_AifEnsDeviceFailure {
958 u_int32_t deviceHandle; /* SCSI device handle */
959 } __packed;
960
961 struct aac_AifEnsMirrorFailover {
962 u_int32_t container; /* Container with failed element */
963 u_int32_t failedSlice; /* Old slice which failed */
964 u_int32_t creatingSlice; /* New slice used for auto-create */
965 } __packed;
966
967 struct aac_AifEnsContainerChange {
968 u_int32_t container[2]; /* container that changed, -1 if no
969 * container */
970 } __packed;
971
972 struct aac_AifEnsContainerEvent {
973 u_int32_t container; /* container number */
974 u_int32_t eventType; /* event type */
975 } __packed;
976
977 struct aac_AifEnsEnclosureEvent {
978 u_int32_t empID; /* enclosure management proc number */
979 u_int32_t unitID; /* unitId, fan id, power supply id,
980 * slot id, tempsensor id. */
981 u_int32_t eventType; /* event type */
982 } __packed;
983
984 struct aac_AifEnsBatteryEvent {
985 AAC_NVBATT_TRANSITION transition_type; /* eg from low to ok */
986 AAC_NVBATTSTATUS current_state; /* current batt state */
987 AAC_NVBATTSTATUS prior_state; /* prev batt state */
988 } __packed;
989
990 struct aac_AifEnsDiskSetEvent {
991 u_int32_t eventType;
992 u_int64_t DsNum;
993 u_int64_t CreatorId;
994 } __packed;
995
996 typedef enum {
997 CLUSTER_NULL_EVENT = 0,
998 CLUSTER_PARTNER_NAME_EVENT, /* change in partner hostname or
999 * adaptername from NULL to non-NULL */
1000 /* (partner's agent may be up) */
1001 CLUSTER_PARTNER_NULL_NAME_EVENT /* change in partner hostname or
1002 * adaptername from non-null to NULL */
1003 /* (partner has rebooted) */
1004 } AAC_ClusterAifEvent;
1005
1006 struct aac_AifEnsClusterEvent {
1007 AAC_ClusterAifEvent eventType;
1008 } __packed;
1009
1010 struct aac_AifEventNotify {
1011 AAC_AifEventNotifyType type;
1012 union {
1013 struct aac_AifEnsGeneric EG;
1014 struct aac_AifEnsDeviceFailure EDF;
1015 struct aac_AifEnsMirrorFailover EMF;
1016 struct aac_AifEnsContainerChange ECC;
1017 struct aac_AifEnsContainerEvent ECE;
1018 struct aac_AifEnsEnclosureEvent EEE;
1019 struct aac_AifEnsBatteryEvent EBE;
1020 struct aac_AifEnsDiskSetEvent EDS;
1021 /* struct aac_AifEnsSMARTEvent ES;*/
1022 struct aac_AifEnsClusterEvent ECLE;
1023 } data;
1024 } __packed;
1025
1026 /*
1027 * Adapter Initiated FIB command structures. Start with the adapter
1028 * initiated FIBs that really come from the adapter, and get responded
1029 * to by the host.
1030 */
1031 #define AAC_AIF_REPORT_MAX_SIZE 64
1032
1033 typedef enum {
1034 AifCmdEventNotify = 1, /* Notify of event */
1035 AifCmdJobProgress, /* Progress report */
1036 AifCmdAPIReport, /* Report from other user of API */
1037 AifCmdDriverNotify, /* Notify host driver of event */
1038 AifReqJobList = 100, /* Gets back complete job list */
1039 AifReqJobsForCtr, /* Gets back jobs for specific container */
1040 AifReqJobsForScsi, /* Gets back jobs for specific SCSI device */
1041 AifReqJobReport, /* Gets back a specific job report or list */
1042 AifReqTerminateJob, /* Terminates job */
1043 AifReqSuspendJob, /* Suspends a job */
1044 AifReqResumeJob, /* Resumes a job */
1045 AifReqSendAPIReport, /* API generic report requests */
1046 AifReqAPIJobStart, /* Start a job from the API */
1047 AifReqAPIJobUpdate, /* Update a job report from the API */
1048 AifReqAPIJobFinish /* Finish a job from the API */
1049 } AAC_AifCommand;
1050
1051 struct aac_aif_command {
1052 AAC_AifCommand command; /* Tell host what type of
1053 * notify this is */
1054 u_int32_t seqNumber; /* To allow ordering of
1055 * reports (if necessary) */
1056 union {
1057 struct aac_AifEventNotify EN; /* Event notify */
1058 struct aac_AifJobProgressReport PR[1]; /* Progress report */
1059 u_int8_t AR[AAC_AIF_REPORT_MAX_SIZE];
1060 u_int8_t data[AAC_FIB_DATASIZE - 8];
1061 } data;
1062 } __packed;
1063
1064 #endif /* !_PCI_AACREG_H_ */
1065