459081dda93c06f88d3739352eaf368e56345f56
[dragonfly.git] / sys / dev / raid / aac / aacreg.h
1 /*-
2  * Copyright (c) 2000 Michael Smith
3  * Copyright (c) 2000-2001 Scott Long
4  * Copyright (c) 2000 BSDi
5  * Copyright (c) 2001 Adaptec, Inc.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  *      $FreeBSD: src/sys/dev/aac/aacreg.h,v 1.4.2.7 2003/04/08 13:22:08 scottl Exp $
30  *      $DragonFly: src/sys/dev/raid/aac/aacreg.h,v 1.2 2003/06/17 04:28:21 dillon Exp $
31  */
32
33 /*
34  * Data structures defining the interface between the driver and the Adaptec
35  * 'FSA' adapters.  Note that many field names and comments here are taken
36  * verbatim from the Adaptec driver source in order to make comparing the
37  * two slightly easier.
38  */
39
40 /*
41  * Misc. magic numbers.
42  */
43 #define AAC_MAX_CONTAINERS      64
44 #define AAC_BLOCK_SIZE          512
45
46 /*
47  * Communications interface.
48  *
49  * Where datastructure layouts are closely parallel to the Adaptec sample code,
50  * retain their naming conventions (for now) to aid in cross-referencing.
51  */
52
53 /*
54  * We establish 4 command queues and matching response queues.  Queues must
55  * be 16-byte aligned, and are sized as follows:
56  */
57 #define AAC_HOST_NORM_CMD_ENTRIES       8       /* command adapter->host,
58                                                  * normal priority */
59 #define AAC_HOST_HIGH_CMD_ENTRIES       4       /* command adapter->host,
60                                                  * high priority */
61 #define AAC_ADAP_NORM_CMD_ENTRIES       512     /* command host->adapter,
62                                                  * normal priority */
63 #define AAC_ADAP_HIGH_CMD_ENTRIES       4       /* command host->adapter,
64                                                  * high priority */
65 #define AAC_HOST_NORM_RESP_ENTRIES      512     /* response, adapter->host,
66                                                  * normal priority */
67 #define AAC_HOST_HIGH_RESP_ENTRIES      4       /* response, adapter->host,
68                                                  * high priority */
69 #define AAC_ADAP_NORM_RESP_ENTRIES      8       /* response, host->adapter,
70                                                  * normal priority */
71 #define AAC_ADAP_HIGH_RESP_ENTRIES      4       /* response, host->adapter,
72                                                  * high priority */
73
74 #define AAC_TOTALQ_LENGTH       (AAC_HOST_HIGH_CMD_ENTRIES +    \
75                                  AAC_HOST_NORM_CMD_ENTRIES +    \
76                                  AAC_ADAP_HIGH_CMD_ENTRIES +    \
77                                  AAC_ADAP_NORM_CMD_ENTRIES +    \
78                                  AAC_HOST_HIGH_RESP_ENTRIES +   \
79                                  AAC_HOST_NORM_RESP_ENTRIES +   \
80                                  AAC_ADAP_HIGH_RESP_ENTRIES +   \
81                                  AAC_ADAP_NORM_RESP_ENTRIES)
82 #define AAC_QUEUE_COUNT         8
83 #define AAC_QUEUE_ALIGN         16
84
85 struct aac_queue_entry {
86         u_int32_t       aq_fib_size;    /* FIB size in bytes */
87         u_int32_t       aq_fib_addr;    /* receiver-space address of the FIB */
88 } __attribute__ ((packed));
89
90 #define AAC_PRODUCER_INDEX      0
91 #define AAC_CONSUMER_INDEX      1
92
93 /*
94  * Table of queue indices and queues used to communicate with the
95  * controller.  This structure must be aligned to AAC_QUEUE_ALIGN
96  */
97 struct aac_queue_table {
98         /* queue consumer/producer indexes (layout mandated by adapter) */
99         u_int32_t                       qt_qindex[AAC_QUEUE_COUNT][2];
100
101         /* queue entry structures (layout mandated by adapter) */
102         struct aac_queue_entry qt_HostNormCmdQueue [AAC_HOST_NORM_CMD_ENTRIES];
103         struct aac_queue_entry qt_HostHighCmdQueue [AAC_HOST_HIGH_CMD_ENTRIES];
104         struct aac_queue_entry qt_AdapNormCmdQueue [AAC_ADAP_NORM_CMD_ENTRIES];
105         struct aac_queue_entry qt_AdapHighCmdQueue [AAC_ADAP_HIGH_CMD_ENTRIES];
106         struct aac_queue_entry qt_HostNormRespQueue[AAC_HOST_NORM_RESP_ENTRIES];
107         struct aac_queue_entry qt_HostHighRespQueue[AAC_HOST_HIGH_RESP_ENTRIES];
108         struct aac_queue_entry qt_AdapNormRespQueue[AAC_ADAP_NORM_RESP_ENTRIES];
109         struct aac_queue_entry qt_AdapHighRespQueue[AAC_ADAP_HIGH_RESP_ENTRIES];
110 } __attribute__ ((packed));
111
112 /*
113  * Queue names
114  *
115  * Note that we base these at 0 in order to use them as array indices.  Adaptec
116  * used base 1 for some unknown reason, and sorted them in a different order.
117  */
118 #define AAC_HOST_NORM_CMD_QUEUE         0
119 #define AAC_HOST_HIGH_CMD_QUEUE         1
120 #define AAC_ADAP_NORM_CMD_QUEUE         2
121 #define AAC_ADAP_HIGH_CMD_QUEUE         3
122 #define AAC_HOST_NORM_RESP_QUEUE        4
123 #define AAC_HOST_HIGH_RESP_QUEUE        5
124 #define AAC_ADAP_NORM_RESP_QUEUE        6
125 #define AAC_ADAP_HIGH_RESP_QUEUE        7
126
127 /*
128  * List structure used to chain FIBs (used by the adapter - we hang FIBs off
129  * our private command structure and don't touch these)
130  */
131 struct aac_fib_list_entry {
132         u_int32_t Flink;
133         u_int32_t Blink;
134 } __attribute__ ((packed));
135
136 /*
137  * FIB (FSA Interface Block?); this is the datastructure passed between the host
138  * and adapter.
139  */
140 struct aac_fib_header {
141         u_int32_t               XferState;
142         u_int16_t               Command;
143         u_int8_t                StructType;
144         u_int8_t                Flags;
145         u_int16_t               Size;
146         u_int16_t               SenderSize;
147         u_int32_t               SenderFibAddress;
148         u_int32_t               ReceiverFibAddress;
149         u_int32_t               SenderData;
150         union {
151                 struct {
152                         u_int32_t       ReceiverTimeStart;
153                         u_int32_t       ReceiverTimeDone;
154                 } _s;
155                 struct aac_fib_list_entry FibLinks;
156         } _u;
157 } __attribute__ ((packed));
158
159 #define AAC_FIB_DATASIZE        (512 - sizeof(struct aac_fib_header))
160
161 struct aac_fib {
162         struct aac_fib_header   Header;
163         u_int8_t                        data[AAC_FIB_DATASIZE];
164 } __attribute__ ((packed));
165
166 /*
167  * FIB commands
168  */
169 typedef enum {
170         TestCommandResponse =           1,
171         TestAdapterCommand =            2,
172
173         /* lowlevel and comm commands */
174         LastTestCommand =               100,
175         ReinitHostNormCommandQueue =    101,
176         ReinitHostHighCommandQueue =    102,
177         ReinitHostHighRespQueue =       103,
178         ReinitHostNormRespQueue =       104,
179         ReinitAdapNormCommandQueue =    105,
180         ReinitAdapHighCommandQueue =    107,
181         ReinitAdapHighRespQueue =       108,
182         ReinitAdapNormRespQueue =       109,
183         InterfaceShutdown =             110,
184         DmaCommandFib =                 120,
185         StartProfile =                  121,
186         TermProfile =                   122,
187         SpeedTest =                     123,
188         TakeABreakPt =                  124,
189         RequestPerfData =               125,
190         SetInterruptDefTimer=           126,
191         SetInterruptDefCount=           127,
192         GetInterruptDefStatus=          128,
193         LastCommCommand =               129,
194
195         /* filesystem commands */
196         NuFileSystem =                  300,
197         UFS =                           301,
198         HostFileSystem =                302,
199         LastFileSystemCommand =         303,
200
201         /* Container Commands */
202         ContainerCommand =              500,
203         ContainerCommand64 =            501,
204
205         /* Cluster Commands */
206         ClusterCommand =                550,
207
208         /* Scsi Port commands (scsi passthrough) */
209         ScsiPortCommand =               600,
210
211         /* misc house keeping and generic adapter initiated commands */
212         AifRequest =                    700,
213         CheckRevision =                 701,
214         FsaHostShutdown =               702,
215         RequestAdapterInfo =            703,
216         IsAdapterPaused =               704,
217         SendHostTime =                  705,
218         LastMiscCommand =               706
219 } AAC_FibCommands;
220
221 /*
222  * FIB types
223  */
224 #define AAC_FIBTYPE_TFIB        1
225 #define AAC_FIBTYPE_TQE         2
226 #define AAC_FIBTYPE_TCTPERF     3
227
228 /*
229  * FIB transfer state
230  */
231 #define AAC_FIBSTATE_HOSTOWNED          (1<<0)  /* owned by the host */
232 #define AAC_FIBSTATE_ADAPTEROWNED       (1<<1)  /* owned by the adapter */
233 #define AAC_FIBSTATE_INITIALISED        (1<<2)  /* initialised */
234 #define AAC_FIBSTATE_EMPTY              (1<<3)  /* empty */
235 #define AAC_FIBSTATE_FROMPOOL           (1<<4)  /* allocated from pool */
236 #define AAC_FIBSTATE_FROMHOST           (1<<5)  /* sent from the host */
237 #define AAC_FIBSTATE_FROMADAP           (1<<6)  /* sent from the adapter */
238 #define AAC_FIBSTATE_REXPECTED          (1<<7)  /* response is expected */
239 #define AAC_FIBSTATE_RNOTEXPECTED       (1<<8)  /* response is not expected */
240 #define AAC_FIBSTATE_DONEADAP           (1<<9)  /* processed by the adapter */
241 #define AAC_FIBSTATE_DONEHOST           (1<<10) /* processed by the host */
242 #define AAC_FIBSTATE_HIGH               (1<<11) /* high priority */
243 #define AAC_FIBSTATE_NORM               (1<<12) /* normal priority */
244 #define AAC_FIBSTATE_ASYNC              (1<<13)
245 #define AAC_FIBSTATE_ASYNCIO            (1<<13) /* to be removed */
246 #define AAC_FIBSTATE_PAGEFILEIO         (1<<14) /* to be removed */
247 #define AAC_FIBSTATE_SHUTDOWN           (1<<15)
248 #define AAC_FIBSTATE_LAZYWRITE          (1<<16) /* to be removed */
249 #define AAC_FIBSTATE_ADAPMICROFIB       (1<<17)
250 #define AAC_FIBSTATE_BIOSFIB            (1<<18)
251 #define AAC_FIBSTATE_FAST_RESPONSE      (1<<19) /* fast response capable */
252 #define AAC_FIBSTATE_APIFIB             (1<<20)
253
254 /*
255  * FIB error values
256  */
257 #define AAC_ERROR_NORMAL                        0x00
258 #define AAC_ERROR_PENDING                       0x01
259 #define AAC_ERROR_FATAL                         0x02
260 #define AAC_ERROR_INVALID_QUEUE                 0x03
261 #define AAC_ERROR_NOENTRIES                     0x04
262 #define AAC_ERROR_SENDFAILED                    0x05
263 #define AAC_ERROR_INVALID_QUEUE_PRIORITY        0x06
264 #define AAC_ERROR_FIB_ALLOCATION_FAILED         0x07
265 #define AAC_ERROR_FIB_DEALLOCATION_FAILED       0x08
266
267 /*
268  * Adapter Init Structure: this is passed to the adapter with the 
269  * AAC_MONKER_INITSTRUCT command to point it at our control structures.
270  */
271 struct aac_adapter_init {
272         u_int32_t       InitStructRevision;
273 #define AAC_INIT_STRUCT_REVISION                3
274         u_int32_t       MiniPortRevision;
275 #define AAC_INIT_STRUCT_MINIPORT_REVISION       1
276         u_int32_t       FilesystemRevision;
277         u_int32_t       CommHeaderAddress;
278         u_int32_t       FastIoCommAreaAddress;
279         u_int32_t       AdapterFibsPhysicalAddress;
280         u_int32_t       AdapterFibsVirtualAddress;
281         u_int32_t       AdapterFibsSize;
282         u_int32_t       AdapterFibAlign;
283         u_int32_t       PrintfBufferAddress;
284         u_int32_t       PrintfBufferSize;
285 #define AAC_PAGE_SIZE                           4096
286         u_int32_t       HostPhysMemPages;
287         u_int32_t       HostElapsedSeconds;
288 } __attribute__ ((packed));
289
290 /*
291  * Shared data types
292  */
293 /*
294  * Container types
295  */
296 typedef enum {
297         CT_NONE = 0,
298         CT_VOLUME,
299         CT_MIRROR,
300         CT_STRIPE,
301         CT_RAID5,
302         CT_SSRW,
303         CT_SSRO,
304         CT_MORPH,
305         CT_PASSTHRU,
306         CT_RAID4,
307         CT_RAID10,                  /* stripe of mirror */
308         CT_RAID00,                  /* stripe of stripe */
309         CT_VOLUME_OF_MIRRORS,       /* volume of mirror */
310         CT_PSEUDO_RAID3,            /* really raid4 */
311         CT_RAID50,                  /* stripe of raid5 */
312 } AAC_FSAVolType;
313
314 /*
315  * Host-addressable object types
316  */
317 typedef enum {
318         FT_REG = 1,     /* regular file */
319         FT_DIR,         /* directory */
320         FT_BLK,         /* "block" device - reserved */
321         FT_CHR,         /* "character special" device - reserved */
322         FT_LNK,         /* symbolic link */
323         FT_SOCK,        /* socket */
324         FT_FIFO,        /* fifo */
325         FT_FILESYS,     /* ADAPTEC's "FSA"(tm) filesystem */
326         FT_DRIVE,       /* physical disk - addressable in scsi by b/t/l */
327         FT_SLICE,       /* virtual disk - raw volume - slice */
328         FT_PARTITION,   /* FSA partition - carved out of a slice - building
329                          * block for containers */
330         FT_VOLUME,      /* Container - Volume Set */
331         FT_STRIPE,      /* Container - Stripe Set */
332         FT_MIRROR,      /* Container - Mirror Set */
333         FT_RAID5,       /* Container - Raid 5 Set */
334         FT_DATABASE     /* Storage object with "foreign" content manager */
335 } AAC_FType;
336
337 /*
338  * Host-side scatter/gather list for 32-bit commands.
339  */
340 struct aac_sg_entry {
341         u_int32_t       SgAddress;
342         u_int32_t       SgByteCount;
343 } __attribute__ ((packed));
344
345 struct aac_sg_table {
346         u_int32_t               SgCount;
347         struct aac_sg_entry     SgEntry[0];
348 } __attribute__ ((packed));
349
350 /*
351  * Host-side scatter/gather list for 64-bit commands.
352  */
353 struct aac_sg_table64 {
354         u_int8_t        SgCount;
355         u_int8_t        SgSectorsPerPage;
356         u_int16_t       SgByteOffset;
357         u_int64_t       SgEntry[0];
358 } __attribute__ ((packed));
359
360 /*
361  * Container creation data
362  */
363 struct aac_container_creation {
364         u_int8_t        ViaBuildNumber;
365         u_int8_t        MicroSecond;
366         u_int8_t        Via;            /* 1 = FSU, 2 = API, etc. */
367         u_int8_t        YearsSince1900;
368         u_int32_t       Month:4;        /* 1-12 */
369         u_int32_t       Day:6;          /* 1-32 */
370         u_int32_t       Hour:6;         /* 0-23 */
371         u_int32_t       Minute:6;       /* 0-59 */
372         u_int32_t       Second:6;       /* 0-59 */
373         u_int64_t       ViaAdapterSerialNumber;
374 } __attribute__ ((packed));
375
376 /*
377  * Revision number handling
378  */
379
380 typedef enum {
381         RevApplication = 1,
382         RevDkiCli,
383         RevNetService,
384         RevApi,
385         RevFileSysDriver,
386         RevMiniportDriver,
387         RevAdapterSW,
388         RevMonitor,
389         RevRemoteApi
390 } RevComponent;
391
392 struct FsaRevision {
393         union {
394                 struct {
395                         u_int8_t        dash;
396                         u_int8_t        type;
397                         u_int8_t        minor;
398                         u_int8_t        major;
399                 } comp;
400                 u_int32_t       ul;
401         } external;
402         u_int32_t       buildNumber;
403 }  __attribute__ ((packed));
404
405 /*
406  * Adapter Information
407  */
408
409 typedef enum {
410         CPU_NTSIM = 1,
411         CPU_I960,
412         CPU_ARM,
413         CPU_SPARC,
414         CPU_POWERPC,
415         CPU_ALPHA,
416         CPU_P7,
417         CPU_I960_RX,
418         CPU__last
419 } AAC_CpuType;  
420
421 typedef enum {
422         CPUI960_JX = 1,
423         CPUI960_CX,
424         CPUI960_HX,
425         CPUI960_RX,
426         CPUARM_SA110,
427         CPUARM_xxx,
428         CPUMPC_824x,
429         CPUPPC_xxx,
430         CPUSUBTYPE__last
431 } AAC_CpuSubType;
432
433 typedef enum {
434         PLAT_NTSIM = 1,
435         PLAT_V3ADU,
436         PLAT_CYCLONE,
437         PLAT_CYCLONE_HD,
438         PLAT_BATBOARD,
439         PLAT_BATBOARD_HD,
440         PLAT_YOLO,
441         PLAT_COBRA,
442         PLAT_ANAHEIM,
443         PLAT_JALAPENO,
444         PLAT_QUEENS,
445         PLAT_JALAPENO_DELL,
446         PLAT_POBLANO,
447         PLAT_POBLANO_OPAL,
448         PLAT_POBLANO_SL0,
449         PLAT_POBLANO_SL1,
450         PLAT_POBLANO_SL2,
451         PLAT_POBLANO_XXX,
452         PLAT_JALAPENO_P2,
453         PLAT_HABANERO,
454         PLAT__last
455 } AAC_Platform;
456
457 typedef enum {
458         OEM_FLAVOR_ADAPTEC = 1,
459         OEM_FLAVOR_DELL,
460         OEM_FLAVOR_HP,
461         OEM_FLAVOR_IBM,
462         OEM_FLAVOR_CPQ,
463         OEM_FLAVOR_BRAND_X,
464         OEM_FLAVOR_BRAND_Y,
465         OEM_FLAVOR_BRAND_Z,
466         OEM_FLAVOR__last
467 } AAC_OemFlavor;
468
469 /*
470  * XXX the aac-2622 with no battery present reports PLATFORM_BAT_OPT_PRESENT
471  */
472 typedef enum
473
474         PLATFORM_BAT_REQ_PRESENT = 1,   /* BATTERY REQUIRED AND PRESENT */
475         PLATFORM_BAT_REQ_NOTPRESENT,    /* BATTERY REQUIRED AND NOT PRESENT */
476         PLATFORM_BAT_OPT_PRESENT,       /* BATTERY OPTIONAL AND PRESENT */
477         PLATFORM_BAT_OPT_NOTPRESENT,    /* BATTERY OPTIONAL AND NOT PRESENT */
478         PLATFORM_BAT_NOT_SUPPORTED      /* BATTERY NOT SUPPORTED */
479 } AAC_BatteryPlatform;
480
481 /* 
482  * options supported by this board
483  * there has to be a one to one mapping of these defines and the ones in 
484  * fsaapi.h, search for FSA_SUPPORT_SNAPSHOT
485  */
486 #define AAC_SUPPORTED_SNAPSHOT          0x01
487 #define AAC_SUPPORTED_CLUSTERS          0x02
488 #define AAC_SUPPORTED_WRITE_CACHE       0x04
489 #define AAC_SUPPORTED_64BIT_DATA        0x08
490 #define AAC_SUPPORTED_HOST_TIME_FIB     0x10
491 #define AAC_SUPPORTED_RAID50            0x20
492 #define AAC_SUPPORTED_4GB_WINDOW        0x40
493 #define AAC_SUPPORTED_SCSI_UPGRADEABLE  0x80
494 #define AAC_SUPPORTED_SOFT_ERR_REPORT   0x100
495 #define AAC_SUPPORTED_NOT_RECONDITION   0x200
496 #define AAC_SUPPORTED_SGMAP_HOST64      0x400
497 #define AAC_SUPPORTED_ALARM             0x800
498 #define AAC_SUPPORTED_NONDASD           0x1000
499
500 /* 
501  * Structure used to respond to a RequestAdapterInfo fib.
502  */
503 struct aac_adapter_info {
504         AAC_Platform            PlatformBase;    /* adapter type */
505         AAC_CpuType             CpuArchitecture; /* adapter CPU type */
506         AAC_CpuSubType          CpuVariant;      /* adapter CPU subtype */
507         u_int32_t               ClockSpeed;      /* adapter CPU clockspeed */
508         u_int32_t               ExecutionMem;    /* adapter Execution Memory
509                                                   * size */
510         u_int32_t               BufferMem;       /* adapter Data Memory */
511         u_int32_t               TotalMem;        /* adapter Total Memory */
512         struct FsaRevision      KernelRevision;  /* adapter Kernel Software
513                                                   * Revision */
514         struct FsaRevision      MonitorRevision; /* adapter Monitor/Diagnostic
515                                                   * Software Revision */
516         struct FsaRevision      HardwareRevision;/* TBD */
517         struct FsaRevision      BIOSRevision;    /* adapter BIOS Revision */
518         u_int32_t               ClusteringEnabled;
519         u_int32_t               ClusterChannelMask;
520         u_int64_t               SerialNumber;
521         AAC_BatteryPlatform     batteryPlatform;
522         u_int32_t               SupportedOptions; /* supported features of this
523                                                    * controller */
524         AAC_OemFlavor   OemVariant;
525 } __attribute__ ((packed));
526
527 /*
528  * Monitor/Kernel interface.
529  */
530
531 /*
532  * Synchronous commands to the monitor/kernel.
533  */
534 #define AAC_MONKER_INITSTRUCT   0x05
535 #define AAC_MONKER_SYNCFIB      0x0c
536 #define AAC_MONKER_GETKERNVER   0x11
537 #define AAC_MONKER_GETINFO      0x19
538
539 /*
540  *  Adapter Status Register
541  *
542  *  Phase Staus mailbox is 32bits:
543  *  <31:16> = Phase Status
544  *  <15:0>  = Phase
545  *
546  *  The adapter reports its present state through the phase.  Only
547  *  a single phase should be ever be set.  Each phase can have multiple
548  *  phase status bits to provide more detailed information about the
549  *  state of the adapter.
550  */
551 #define AAC_SELF_TEST_FAILED    0x00000004
552 #define AAC_UP_AND_RUNNING      0x00000080
553 #define AAC_KERNEL_PANIC        0x00000100
554
555 /*
556  * Data types relating to control and monitoring of the NVRAM/WriteCache 
557  * subsystem.
558  */
559
560 #define AAC_NFILESYS    24      /* maximum number of filesystems */
561
562 /*
563  * NVRAM/Write Cache subsystem states
564  */
565 typedef enum {
566         NVSTATUS_DISABLED = 0,  /* present, clean, not being used */
567         NVSTATUS_ENABLED,       /* present, possibly dirty, ready for use */
568         NVSTATUS_ERROR,         /* present, dirty, contains dirty data */
569         NVSTATUS_BATTERY,       /* present, bad or low battery, may contain
570                                  * dirty data */
571         NVSTATUS_UNKNOWN        /* for bad/missing device */
572 } AAC_NVSTATUS;
573
574 /*
575  * NVRAM/Write Cache subsystem battery component states
576  *
577  */
578 typedef enum {
579         NVBATTSTATUS_NONE = 0,  /* battery has no power or is not present */
580         NVBATTSTATUS_LOW,       /* battery is low on power */
581         NVBATTSTATUS_OK,        /* battery is okay - normal operation possible
582                                  * only in this state */
583         NVBATTSTATUS_RECONDITIONING     /* no battery present - reconditioning
584                                          * in process */
585 } AAC_NVBATTSTATUS;
586
587 /*
588  * Battery transition type
589  */
590 typedef enum {
591         NVBATT_TRANSITION_NONE = 0,     /* battery now has no power or is not
592                                          * present */
593         NVBATT_TRANSITION_LOW,          /* battery is now low on power */
594         NVBATT_TRANSITION_OK            /* battery is now okay - normal
595                                          * operation possible only in this
596                                          * state */
597 } AAC_NVBATT_TRANSITION;
598
599 /*
600  * NVRAM Info structure returned for NVRAM_GetInfo call
601  */
602 struct aac_nvramdevinfo {
603         u_int32_t       NV_Enabled;     /* write caching enabled */
604         u_int32_t       NV_Error;       /* device in error state */
605         u_int32_t       NV_NDirty;      /* count of dirty NVRAM buffers */
606         u_int32_t       NV_NActive;     /* count of NVRAM buffers being
607                                          * written */
608 } __attribute__ ((packed));
609
610 struct aac_nvraminfo {
611         AAC_NVSTATUS            NV_Status;      /* nvram subsystem status */
612         AAC_NVBATTSTATUS        NV_BattStatus;  /* battery status */
613         u_int32_t               NV_Size;        /* size of WriteCache NVRAM in
614                                                  * bytes */
615         u_int32_t               NV_BufSize;     /* size of NVRAM buffers in
616                                                  * bytes */
617         u_int32_t               NV_NBufs;       /* number of NVRAM buffers */
618         u_int32_t               NV_NDirty;      /* Num dirty NVRAM buffers */
619         u_int32_t               NV_NClean;      /* Num clean NVRAM buffers */
620         u_int32_t               NV_NActive;     /* Num NVRAM buffers being
621                                                  * written */
622         u_int32_t               NV_NBrokered;   /* Num brokered NVRAM buffers */
623         struct aac_nvramdevinfo NV_DevInfo[AAC_NFILESYS];       /* per device
624                                                                  * info */
625         u_int32_t               NV_BattNeedsReconditioning;     /* boolean */
626         u_int32_t               NV_TotalSize;   /* size of all non-volatile
627                                                  * memories in bytes */
628 } __attribute__ ((packed));
629
630 /*
631  * Data types relating to adapter-initiated FIBs
632  *
633  * Based on types and structures in <aifstruc.h>
634  */
635
636 /*
637  * Progress Reports
638  */
639 typedef enum {
640         AifJobStsSuccess = 1,
641         AifJobStsFinished,
642         AifJobStsAborted,
643         AifJobStsFailed,
644         AifJobStsLastReportMarker = 100,        /* All prior mean last report */
645         AifJobStsSuspended,
646         AifJobStsRunning
647 } AAC_AifJobStatus;
648
649 typedef enum {
650         AifJobScsiMin = 1,              /* Minimum value for Scsi operation */
651         AifJobScsiZero,                 /* SCSI device clear operation */
652         AifJobScsiVerify,               /* SCSI device Verify operation NO
653                                          * REPAIR */
654         AifJobScsiExercise,             /* SCSI device Exercise operation */
655         AifJobScsiVerifyRepair,         /* SCSI device Verify operation WITH
656                                          * repair */
657         AifJobScsiMax = 99,             /* Max Scsi value */
658         AifJobCtrMin,                   /* Min Ctr op value */
659         AifJobCtrZero,                  /* Container clear operation */
660         AifJobCtrCopy,                  /* Container copy operation */
661         AifJobCtrCreateMirror,          /* Container Create Mirror operation */
662         AifJobCtrMergeMirror,           /* Container Merge Mirror operation */
663         AifJobCtrScrubMirror,           /* Container Scrub Mirror operation */
664         AifJobCtrRebuildRaid5,          /* Container Rebuild Raid5 operation */
665         AifJobCtrScrubRaid5,            /* Container Scrub Raid5 operation */
666         AifJobCtrMorph,                 /* Container morph operation */
667         AifJobCtrPartCopy,              /* Container Partition copy operation */
668         AifJobCtrRebuildMirror,         /* Container Rebuild Mirror operation */
669         AifJobCtrCrazyCache,            /* crazy cache */
670         AifJobCtrMax = 199,             /* Max Ctr type operation */
671         AifJobFsMin,                    /* Min Fs type operation */
672         AifJobFsCreate,                 /* File System Create operation */
673         AifJobFsVerify,                 /* File System Verify operation */
674         AifJobFsExtend,                 /* File System Extend operation */
675         AifJobFsMax = 299,              /* Max Fs type operation */
676         AifJobApiFormatNTFS,            /* Format a drive to NTFS */
677         AifJobApiFormatFAT,             /* Format a drive to FAT */
678         AifJobApiUpdateSnapshot,        /* update the read/write half of a
679                                          * snapshot */
680         AifJobApiFormatFAT32,           /* Format a drive to FAT32 */
681         AifJobApiMax = 399,             /* Max API type operation */
682         AifJobCtlContinuousCtrVerify,   /* Adapter operation */
683         AifJobCtlMax = 499              /* Max Adapter type operation */
684 } AAC_AifJobType;
685
686 struct aac_AifContainers {
687         u_int32_t       src;            /* from/master */
688         u_int32_t       dst;            /* to/slave */
689 } __attribute__ ((packed));
690
691 union aac_AifJobClient {
692         struct aac_AifContainers        container;      /* For Container and
693                                                          * file system progress
694                                                          * ops; */
695         int32_t                         scsi_dh;        /* For SCSI progress
696                                                          * ops */
697 };
698
699 struct aac_AifJobDesc {
700         u_int32_t               jobID;          /* DO NOT FILL IN! Will be
701                                                  * filled in by AIF */
702         AAC_AifJobType          type;           /* Operation that is being
703                                                  * performed */
704         union aac_AifJobClient  client;         /* Details */
705 } __attribute__ ((packed));
706
707 struct aac_AifJobProgressReport {
708         struct aac_AifJobDesc   jd;
709         AAC_AifJobStatus        status;
710         u_int32_t               finalTick;
711         u_int32_t               currentTick;
712         u_int32_t               jobSpecificData1;
713         u_int32_t               jobSpecificData2;
714 } __attribute__ ((packed));
715
716 /*
717  * Event Notification
718  */
719 typedef enum {
720         /* General application notifies start here */
721         AifEnGeneric = 1,               /* Generic notification */
722         AifEnTaskComplete,              /* Task has completed */
723         AifEnConfigChange,              /* Adapter config change occurred */
724         AifEnContainerChange,           /* Adapter specific container 
725                                          * configuration change */
726         AifEnDeviceFailure,             /* SCSI device failed */
727         AifEnMirrorFailover,            /* Mirror failover started */
728         AifEnContainerEvent,            /* Significant container event */
729         AifEnFileSystemChange,          /* File system changed */
730         AifEnConfigPause,               /* Container pause event */
731         AifEnConfigResume,              /* Container resume event */
732         AifEnFailoverChange,            /* Failover space assignment changed */
733         AifEnRAID5RebuildDone,          /* RAID5 rebuild finished */
734         AifEnEnclosureManagement,       /* Enclosure management event */
735         AifEnBatteryEvent,              /* Significant NV battery event */
736         AifEnAddContainer,              /* A new container was created. */
737         AifEnDeleteContainer,           /* A container was deleted. */
738         AifEnSMARTEvent,                /* SMART Event */
739         AifEnBatteryNeedsRecond,        /* The battery needs reconditioning */
740         AifEnClusterEvent,              /* Some cluster event */
741         AifEnDiskSetEvent,              /* A disk set event occured. */
742         AifDriverNotifyStart=199,       /* Notifies for host driver go here */
743         /* Host driver notifications start here */
744         AifDenMorphComplete,            /* A morph operation completed */
745         AifDenVolumeExtendComplete      /* Volume expand operation completed */
746 } AAC_AifEventNotifyType;
747
748 struct aac_AifEnsGeneric {
749         char    text[132];              /* Generic text */
750 } __attribute__ ((packed));
751
752 struct aac_AifEnsDeviceFailure {
753         u_int32_t       deviceHandle;   /* SCSI device handle */
754 } __attribute__ ((packed));
755
756 struct aac_AifEnsMirrorFailover {
757         u_int32_t       container;      /* Container with failed element */
758         u_int32_t       failedSlice;    /* Old slice which failed */
759         u_int32_t       creatingSlice;  /* New slice used for auto-create */
760 } __attribute__ ((packed));
761
762 struct aac_AifEnsContainerChange {
763         u_int32_t       container[2];   /* container that changed, -1 if no
764                                          * container */
765 } __attribute__ ((packed));
766
767 struct aac_AifEnsContainerEvent {
768         u_int32_t       container;      /* container number  */
769         u_int32_t       eventType;      /* event type */
770 } __attribute__ ((packed));
771
772 struct aac_AifEnsEnclosureEvent {
773         u_int32_t       empID;          /* enclosure management proc number  */
774         u_int32_t       unitID;         /* unitId, fan id, power supply id,
775                                          * slot id, tempsensor id.  */
776         u_int32_t       eventType;      /* event type */
777 } __attribute__ ((packed));
778
779 struct aac_AifEnsBatteryEvent {
780         AAC_NVBATT_TRANSITION   transition_type;        /* eg from low to ok */
781         AAC_NVBATTSTATUS        current_state;          /* current batt state */
782         AAC_NVBATTSTATUS        prior_state;            /* prev batt state */
783 } __attribute__ ((packed));
784
785 struct aac_AifEnsDiskSetEvent {
786         u_int32_t       eventType;
787         u_int64_t       DsNum;
788         u_int64_t       CreatorId;
789 } __attribute__ ((packed));
790
791 typedef enum {
792         CLUSTER_NULL_EVENT = 0,
793         CLUSTER_PARTNER_NAME_EVENT,     /* change in partner hostname or
794                                          * adaptername from NULL to non-NULL */
795         /* (partner's agent may be up) */
796         CLUSTER_PARTNER_NULL_NAME_EVENT /* change in partner hostname or
797                                          * adaptername from non-null to NULL */
798         /* (partner has rebooted) */
799 } AAC_ClusterAifEvent;
800
801 struct aac_AifEnsClusterEvent {
802         AAC_ClusterAifEvent     eventType;
803 } __attribute__ ((packed));
804
805 struct aac_AifEventNotify {
806         AAC_AifEventNotifyType  type;
807         union {
808                 struct aac_AifEnsGeneric                EG;
809                 struct aac_AifEnsDeviceFailure          EDF;
810                 struct aac_AifEnsMirrorFailover         EMF;
811                 struct aac_AifEnsContainerChange        ECC;
812                 struct aac_AifEnsContainerEvent         ECE;
813                 struct aac_AifEnsEnclosureEvent         EEE;
814                 struct aac_AifEnsBatteryEvent           EBE;
815                 struct aac_AifEnsDiskSetEvent           EDS;
816 /*              struct aac_AifEnsSMARTEvent             ES;*/
817                 struct aac_AifEnsClusterEvent           ECLE;
818         } data;
819 } __attribute__ ((packed));
820
821 /*
822  * Adapter Initiated FIB command structures. Start with the adapter
823  * initiated FIBs that really come from the adapter, and get responded
824  * to by the host. 
825  */
826 #define AAC_AIF_REPORT_MAX_SIZE 64
827
828 typedef enum {
829         AifCmdEventNotify = 1,  /* Notify of event */
830         AifCmdJobProgress,      /* Progress report */
831         AifCmdAPIReport,        /* Report from other user of API */
832         AifCmdDriverNotify,     /* Notify host driver of event */
833         AifReqJobList = 100,    /* Gets back complete job list */
834         AifReqJobsForCtr,       /* Gets back jobs for specific container */
835         AifReqJobsForScsi,      /* Gets back jobs for specific SCSI device */
836         AifReqJobReport,        /* Gets back a specific job report or list */
837         AifReqTerminateJob,     /* Terminates job */
838         AifReqSuspendJob,       /* Suspends a job */
839         AifReqResumeJob,        /* Resumes a job */
840         AifReqSendAPIReport,    /* API generic report requests */
841         AifReqAPIJobStart,      /* Start a job from the API */
842         AifReqAPIJobUpdate,     /* Update a job report from the API */
843         AifReqAPIJobFinish      /* Finish a job from the API */
844 } AAC_AifCommand;
845
846 struct aac_aif_command {
847         AAC_AifCommand  command;        /* Tell host what type of
848                                          * notify this is */
849         u_int32_t       seqNumber;      /* To allow ordering of
850                                          * reports (if necessary) */
851         union {
852         struct aac_AifEventNotify       EN;     /* Event notify structure */
853         struct aac_AifJobProgressReport PR[1];  /* Progress report */
854         u_int8_t                        AR[AAC_AIF_REPORT_MAX_SIZE];
855         } data;
856 } __attribute__ ((packed));
857
858 /*
859  * Filesystem commands/data
860  *
861  * The adapter has a very complex filesystem interface, most of which we ignore.
862  * (And which seems not to be implemented, anyway.)
863  */
864
865 /*
866  * FSA commands
867  * (not used?)
868  */
869 typedef enum {
870         Null = 0,
871         GetAttributes,
872         SetAttributes,
873         Lookup,
874         ReadLink,
875         Read,
876         Write,
877         Create,
878         MakeDirectory,
879         SymbolicLink,
880         MakeNode,
881         Removex,
882         RemoveDirectory,
883         Rename,
884         Link,
885         ReadDirectory,
886         ReadDirectoryPlus,
887         FileSystemStatus,
888         FileSystemInfo,
889         PathConfigure,
890         Commit,
891         Mount,
892         UnMount,
893         Newfs,
894         FsCheck,
895         FsSync,
896         SimReadWrite,
897         SetFileSystemStatus,
898         BlockRead,
899         BlockWrite,
900         NvramIoctl,
901         FsSyncWait,
902         ClearArchiveBit,
903         SetAcl,
904         GetAcl,
905         AssignAcl,
906         FaultInsertion,
907         CrazyCache
908 } AAC_FSACommand;
909
910 /*
911  * Command status values
912  */
913 typedef enum {
914         ST_OK = 0,
915         ST_PERM = 1,
916         ST_NOENT = 2,
917         ST_IO = 5,
918         ST_NXIO = 6,
919         ST_E2BIG = 7,
920         ST_ACCES = 13,
921         ST_EXIST = 17,
922         ST_XDEV = 18,
923         ST_NODEV = 19,
924         ST_NOTDIR = 20,
925         ST_ISDIR = 21,
926         ST_INVAL = 22,
927         ST_FBIG = 27,
928         ST_NOSPC = 28,
929         ST_ROFS = 30,
930         ST_MLINK = 31,
931         ST_WOULDBLOCK = 35,
932         ST_NAMETOOLONG = 63,
933         ST_NOTEMPTY = 66,
934         ST_DQUOT = 69,
935         ST_STALE = 70,
936         ST_REMOTE = 71,
937         ST_BADHANDLE = 10001,
938         ST_NOT_SYNC = 10002,
939         ST_BAD_COOKIE = 10003,
940         ST_NOTSUPP = 10004,
941         ST_TOOSMALL = 10005,
942         ST_SERVERFAULT = 10006,
943         ST_BADTYPE = 10007,
944         ST_JUKEBOX = 10008,
945         ST_NOTMOUNTED = 10009,
946         ST_MAINTMODE = 10010,
947         ST_STALEACL = 10011
948 } AAC_FSAStatus;
949
950 /*
951  * Volume manager commands
952  */
953 typedef enum _VM_COMMANDS {
954         VM_Null = 0,
955         VM_NameServe,
956         VM_ContainerConfig,
957         VM_Ioctl,
958         VM_FilesystemIoctl,
959         VM_CloseAll,
960         VM_CtBlockRead,
961         VM_CtBlockWrite,
962         VM_SliceBlockRead,       /* raw access to configured storage objects */
963         VM_SliceBlockWrite,
964         VM_DriveBlockRead,       /* raw access to physical devices */
965         VM_DriveBlockWrite,
966         VM_EnclosureMgt,         /* enclosure management */
967         VM_Unused,               /* used to be diskset management */
968         VM_CtBlockVerify,
969         VM_CtPerf,               /* performance test */
970         VM_CtBlockRead64,
971         VM_CtBlockWrite64,
972         VM_CtBlockVerify64,
973 } AAC_VMCommand;
974
975 /*
976  * "mountable object"
977  */
978 struct aac_mntobj {
979         u_int32_t                       ObjectId;
980         char                            FileSystemName[16];
981         struct aac_container_creation   CreateInfo;
982         u_int32_t                       Capacity;
983         u_int32_t                       VolType;
984         u_int32_t                       ObjType;
985         u_int32_t                       ContentState;
986 #define FSCS_READONLY           0x0002          /* XXX need more information
987                                                  * than this */
988         union {
989                 u_int32_t       pad[8];
990         } ObjExtension;
991         u_int32_t                       AlterEgoId;
992 } __attribute__ ((packed));
993
994 struct aac_mntinfo {
995         u_int32_t               Command;
996         u_int32_t               MntType;
997         u_int32_t               MntCount;
998 } __attribute__ ((packed));
999
1000 struct aac_mntinforesp {
1001         u_int32_t               Status;
1002         u_int32_t               MntType;
1003         u_int32_t               MntRespCount;
1004         struct aac_mntobj       MntTable[1];
1005 } __attribute__ ((packed));
1006
1007 /*
1008  * Container shutdown command.
1009  */
1010 struct aac_closecommand {
1011         u_int32_t       Command;
1012         u_int32_t       ContainerId;
1013 } __attribute__ ((packed));
1014
1015 /*
1016  * Container Config Command
1017  */
1018 #define CT_GET_SCSI_METHOD      64
1019 struct aac_ctcfg {
1020         u_int32_t               Command;
1021         u_int32_t               cmd;
1022         u_int32_t               param;
1023 } __attribute__ ((packed));
1024
1025 struct aac_ctcfg_resp {
1026         u_int32_t               Status;
1027         u_int32_t               resp;
1028         u_int32_t               param;
1029 } __attribute__ ((packed));
1030
1031 /*
1032  * 'Ioctl' commads
1033  */
1034 #define AAC_SCSI_MAX_PORTS      10
1035 #define AAC_BUS_NO_EXIST        0
1036 #define AAC_BUS_VALID           1
1037 #define AAC_BUS_FAULTED         2
1038 #define AAC_BUS_DISABLED        3
1039 #define GetBusInfo              0x9
1040
1041 struct aac_getbusinf {
1042         u_int32_t               ProbeComplete;
1043         u_int32_t               BusCount;
1044         u_int32_t               TargetsPerBus;
1045         u_int8_t                InitiatorBusId[AAC_SCSI_MAX_PORTS];
1046         u_int8_t                BusValid[AAC_SCSI_MAX_PORTS];
1047 } __attribute__ ((packed));
1048
1049 struct aac_vmioctl {
1050         u_int32_t               Command;
1051         u_int32_t               ObjType;
1052         u_int32_t               MethId;
1053         u_int32_t               ObjId;
1054         u_int32_t               IoctlCmd;
1055         u_int32_t               IoctlBuf[1];    /* Placeholder? */
1056 } __attribute__ ((packed));
1057
1058 struct aac_vmi_businf_resp {
1059         u_int32_t               Status;
1060         u_int32_t               ObjType;
1061         u_int32_t               MethId;
1062         u_int32_t               ObjId;
1063         u_int32_t               IoctlCmd;
1064         struct aac_getbusinf    BusInf;
1065 } __attribute__ ((packed));
1066
1067 #define AAC_BTL_TO_HANDLE(b, t, l) \
1068     (((b & 0x3f) << 7) | ((l & 0x7) << 4) | (t & 0xf))
1069 #define GetDeviceProbeInfo 0x5
1070
1071 struct aac_vmi_devinfo_resp {
1072         u_int32_t               Status;
1073         u_int32_t               ObjType;
1074         u_int32_t               MethId;
1075         u_int32_t               ObjId;
1076         u_int32_t               IoctlCmd;
1077         u_int8_t                VendorId[8];
1078         u_int8_t                ProductId[16];
1079         u_int8_t                ProductRev[4];
1080         u_int32_t               Inquiry7;
1081         u_int32_t               align1;
1082         u_int32_t               Inquiry0;
1083         u_int32_t               align2;
1084         u_int32_t               Inquiry1;
1085         u_int32_t               align3;
1086         u_int32_t               reserved[2];
1087         u_int8_t                VendorSpecific[20];
1088         u_int32_t               Smart:1;
1089         u_int32_t               AAC_Managed:1;
1090         u_int32_t               align4;
1091         u_int32_t               reserved2:6;
1092         u_int32_t               Bus;
1093         u_int32_t               Target;
1094         u_int32_t               Lun;
1095         u_int32_t               ultraEnable:1,
1096                                 disconnectEnable:1,
1097                                 fast20EnabledW:1,
1098                                 scamDevice:1,
1099                                 scamTolerant:1,
1100                                 setForSync:1,
1101                                 setForWide:1,
1102                                 syncDevice:1,
1103                                 wideDevice:1,
1104                                 reserved1:7,
1105                                 ScsiRate:8,
1106                                 ScsiOffset:8;
1107 }; /* Do not pack */
1108
1109 #define ResetBus 0x16
1110 struct aac_resetbus {
1111         u_int32_t               BusNumber;
1112 };
1113
1114 /*
1115  * Write 'stability' options.
1116  */
1117 typedef enum {
1118         CSTABLE = 1,
1119         CUNSTABLE
1120 } AAC_CacheLevel;
1121
1122 /*
1123  * Commit level response for a write request.
1124  */
1125 typedef enum {
1126         CMFILE_SYNC_NVRAM = 1,
1127         CMDATA_SYNC_NVRAM,
1128         CMFILE_SYNC,
1129         CMDATA_SYNC,
1130         CMUNSTABLE
1131 } AAC_CommitLevel;
1132
1133 /*
1134  * Block read/write operations.
1135  * These structures are packed into the 'data' area in the FIB.
1136  */
1137
1138 struct aac_blockread {
1139         u_int32_t               Command;        /* not FSACommand! */
1140         u_int32_t               ContainerId;
1141         u_int32_t               BlockNumber;
1142         u_int32_t               ByteCount;
1143         struct aac_sg_table     SgMap;          /* variable size */
1144 } __attribute__ ((packed));
1145
1146 struct aac_blockread_response {
1147         u_int32_t               Status;
1148         u_int32_t               ByteCount;
1149 } __attribute__ ((packed));
1150
1151 struct aac_blockwrite {
1152         u_int32_t               Command;        /* not FSACommand! */
1153         u_int32_t               ContainerId;
1154         u_int32_t               BlockNumber;
1155         u_int32_t               ByteCount;
1156         u_int32_t               Stable;
1157         struct aac_sg_table     SgMap;          /* variable size */
1158 } __attribute__ ((packed));
1159
1160 struct aac_blockwrite_response {
1161         u_int32_t               Status;
1162         u_int32_t               ByteCount;
1163         u_int32_t               Committed;
1164 } __attribute__ ((packed));
1165
1166 /*
1167  * Container shutdown command.
1168  */
1169 struct aac_close_command {
1170         u_int32_t          Command;
1171         u_int32_t          ContainerId;
1172 };
1173
1174 /*
1175  * SCSI Passthrough structures
1176  */
1177 struct aac_srb32 {
1178         u_int32_t               function;
1179         u_int32_t               bus;
1180         u_int32_t               target;
1181         u_int32_t               lun;
1182         u_int32_t               timeout;
1183         u_int32_t               flags;
1184         u_int32_t               data_len;
1185         u_int32_t               retry_limit;
1186         u_int32_t               cdb_len;
1187         u_int8_t                cdb[16];
1188         struct aac_sg_table     sg_map32;
1189 };
1190
1191 enum {
1192         AAC_SRB_FUNC_EXECUTE_SCSI       = 0x00,
1193         AAC_SRB_FUNC_CLAIM_DEVICE,
1194         AAC_SRB_FUNC_IO_CONTROL,
1195         AAC_SRB_FUNC_RECEIVE_EVENT,
1196         AAC_SRB_FUNC_RELEASE_QUEUE,
1197         AAC_SRB_FUNC_ATTACH_DEVICE,
1198         AAC_SRB_FUNC_RELEASE_DEVICE,
1199         AAC_SRB_FUNC_SHUTDOWN,
1200         AAC_SRB_FUNC_FLUSH,
1201         AAC_SRB_FUNC_ABORT_COMMAND      = 0x10,
1202         AAC_SRB_FUNC_RELEASE_RECOVERY,
1203         AAC_SRB_FUNC_RESET_BUS,
1204         AAC_SRB_FUNC_RESET_DEVICE,
1205         AAC_SRB_FUNC_TERMINATE_IO,
1206         AAC_SRB_FUNC_FLUSH_QUEUE,
1207         AAC_SRB_FUNC_REMOVE_DEVICE,
1208         AAC_SRB_FUNC_DOMAIN_VALIDATION
1209 };
1210
1211 #define AAC_SRB_FLAGS_NO_DATA_XFER              0x0000
1212 #define AAC_SRB_FLAGS_DISABLE_DISCONNECT        0x0004
1213 #define AAC_SRB_FLAGS_DISABLE_SYNC_TRANSFER     0x0008
1214 #define AAC_SRB_FLAGS_BYPASS_FROZEN_QUEUE       0x0010
1215 #define AAC_SRB_FLAGS_DISABLE_AUTOSENSE         0x0020
1216 #define AAC_SRB_FLAGS_DATA_IN                   0x0040
1217 #define AAC_SRB_FLAGS_DATA_OUT                  0x0080
1218 #define AAC_SRB_FLAGS_UNSPECIFIED_DIRECTION \
1219                         (AAC_SRB_FLAGS_DATA_IN | AAC_SRB_FLAGS_DATA_OUT)
1220
1221 #define AAC_HOST_SENSE_DATA_MAX                 30
1222
1223 struct aac_srb_response {
1224         u_int32_t       fib_status;
1225         u_int32_t       srb_status;
1226         u_int32_t       scsi_status;
1227         u_int32_t       data_len;
1228         u_int32_t       sense_len;
1229         u_int8_t        sense[AAC_HOST_SENSE_DATA_MAX];
1230 };
1231
1232 enum {
1233         AAC_SRB_STS_PENDING                     = 0x00,
1234         AAC_SRB_STS_SUCCESS,
1235         AAC_SRB_STS_ABORTED,
1236         AAC_SRB_STS_ABORT_FAILED,
1237         AAC_SRB_STS_ERROR,
1238         AAC_SRB_STS_BUSY,
1239         AAC_SRB_STS_INVALID_REQUEST,
1240         AAC_SRB_STS_INVALID_PATH_ID,
1241         AAC_SRB_STS_NO_DEVICE,
1242         AAC_SRB_STS_TIMEOUT,
1243         AAC_SRB_STS_SELECTION_TIMEOUT,
1244         AAC_SRB_STS_COMMAND_TIMEOUT,
1245         AAC_SRB_STS_MESSAGE_REJECTED            = 0x0D,
1246         AAC_SRB_STS_BUS_RESET,
1247         AAC_SRB_STS_PARITY_ERROR,
1248         AAC_SRB_STS_REQUEST_SENSE_FAILED,
1249         AAC_SRB_STS_NO_HBA,
1250         AAC_SRB_STS_DATA_OVERRUN,
1251         AAC_SRB_STS_UNEXPECTED_BUS_FREE,
1252         AAC_SRB_STS_PHASE_SEQUENCE_FAILURE,
1253         AAC_SRB_STS_BAD_SRB_BLOCK_LENGTH,
1254         AAC_SRB_STS_REQUEST_FLUSHED,
1255         AAC_SRB_STS_INVALID_LUN                 = 0x20,
1256         AAC_SRB_STS_INVALID_TARGET_ID,
1257         AAC_SRB_STS_BAD_FUNCTION,
1258         AAC_SRB_STS_ERROR_RECOVERY
1259 };
1260
1261 /*
1262  * Register set for adapters based on the Falcon bridge and PPC core
1263  */
1264
1265 #define AAC_FA_DOORBELL0_CLEAR          0x00
1266 #define AAC_FA_DOORBELL1_CLEAR          0x02
1267 #define AAC_FA_DOORBELL0                0x04
1268 #define AAC_FA_DOORBELL1                0x06
1269 #define AAC_FA_MASK0_CLEAR              0x08
1270 #define AAC_FA_MASK1_CLEAR              0x0a
1271 #define AAC_FA_MASK0                    0x0c
1272 #define AAC_FA_MASK1                    0x0e
1273 #define AAC_FA_MAILBOX                  0x10
1274 #define AAC_FA_FWSTATUS                 0x2c    /* Mailbox 7 */
1275 #define AAC_FA_INTSRC                   0x900
1276
1277 #define AAC_FA_HACK(sc) (void)AAC_GETREG4(sc, AAC_FA_INTSRC)
1278
1279 /*
1280  * Register definitions for the Adaptec AAC-364 'Jalapeno I/II' adapters, based
1281  * on the SA110 'StrongArm'.
1282  */
1283
1284 #define AAC_SA_DOORBELL0_CLEAR          0x98    /* doorbell 0 (adapter->host) */
1285 #define AAC_SA_DOORBELL0_SET            0x9c
1286 #define AAC_SA_DOORBELL0                0x9c
1287 #define AAC_SA_MASK0_CLEAR              0xa0
1288 #define AAC_SA_MASK0_SET                0xa4
1289
1290 #define AAC_SA_DOORBELL1_CLEAR          0x9a    /* doorbell 1 (host->adapter) */
1291 #define AAC_SA_DOORBELL1_SET            0x9e
1292 #define AAC_SA_DOORBELL1                0x9e
1293 #define AAC_SA_MASK1_CLEAR              0xa2
1294 #define AAC_SA_MASK1_SET                0xa6
1295
1296 #define AAC_SA_MAILBOX                  0xa8    /* mailbox (20 bytes) */
1297 #define AAC_SA_FWSTATUS                 0xc4
1298
1299 /*
1300  * Register definitions for the Adaptec 'Pablano' adapters, based on the i960Rx,
1301  * and other related adapters.
1302  */
1303
1304 #define AAC_RX_IDBR             0x20    /* inbound doorbell register */
1305 #define AAC_RX_IISR             0x24    /* inbound interrupt status register */
1306 #define AAC_RX_IIMR             0x28    /* inbound interrupt mask register */
1307 #define AAC_RX_ODBR             0x2c    /* outbound doorbell register */
1308 #define AAC_RX_OISR             0x30    /* outbound interrupt status register */
1309 #define AAC_RX_OIMR             0x34    /* outbound interrupt mask register */
1310
1311 #define AAC_RX_MAILBOX          0x50    /* mailbox (20 bytes) */
1312 #define AAC_RX_FWSTATUS         0x6c
1313
1314 /*
1315  * Common bit definitions for the doorbell registers.
1316  */
1317
1318 /*
1319  * Status bits in the doorbell registers.
1320  */
1321 #define AAC_DB_SYNC_COMMAND     (1<<0)  /* send/completed synchronous FIB */
1322 #define AAC_DB_COMMAND_READY    (1<<1)  /* posted one or more commands */
1323 #define AAC_DB_RESPONSE_READY   (1<<2)  /* one or more commands complete */
1324 #define AAC_DB_COMMAND_NOT_FULL (1<<3)  /* command queue not full */
1325 #define AAC_DB_RESPONSE_NOT_FULL (1<<4) /* response queue not full */
1326
1327 /*
1328  * The adapter can request the host print a message by setting the
1329  * DB_PRINTF flag in DOORBELL0.  The driver responds by collecting the
1330  * message from the printf buffer, clearing the DB_PRINTF flag in 
1331  * DOORBELL0 and setting it in DOORBELL1.
1332  * (ODBR and IDBR respectively for the i960Rx adapters)
1333  */
1334 #define AAC_DB_PRINTF           (1<<5)  /* adapter requests host printf */
1335 #define AAC_PRINTF_DONE         (1<<5)  /* Host completed printf processing */
1336
1337 /*
1338  * Mask containing the interrupt bits we care about.  We don't anticipate (or
1339  * want) interrupts not in this mask.
1340  */
1341 #define AAC_DB_INTERRUPTS       (AAC_DB_COMMAND_READY  |        \
1342                                  AAC_DB_RESPONSE_READY |        \
1343                                  AAC_DB_PRINTF)