2 * Copyright (c) 2000 Michael Smith
3 * Copyright (c) 2000-2001 Scott Long
4 * Copyright (c) 2000 BSDi
5 * Copyright (c) 2001 Adaptec, Inc.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
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.
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
29 * $FreeBSD: src/sys/dev/aac/aacreg.h,v 1.4.2.7 2003/04/08 13:22:08 scottl Exp $
33 * Data structures defining the interface between the driver and the Adaptec
34 * 'FSA' adapters. Note that many field names and comments here are taken
35 * verbatim from the Adaptec driver source in order to make comparing the
36 * two slightly easier.
40 * Misc. magic numbers.
42 #define AAC_MAX_CONTAINERS 64
43 #define AAC_BLOCK_SIZE 512
46 * Communications interface.
48 * Where datastructure layouts are closely parallel to the Adaptec sample code,
49 * retain their naming conventions (for now) to aid in cross-referencing.
53 * We establish 4 command queues and matching response queues. Queues must
54 * be 16-byte aligned, and are sized as follows:
56 #define AAC_HOST_NORM_CMD_ENTRIES 8 /* command adapter->host,
58 #define AAC_HOST_HIGH_CMD_ENTRIES 4 /* command adapter->host,
60 #define AAC_ADAP_NORM_CMD_ENTRIES 512 /* command host->adapter,
62 #define AAC_ADAP_HIGH_CMD_ENTRIES 4 /* command host->adapter,
64 #define AAC_HOST_NORM_RESP_ENTRIES 512 /* response, adapter->host,
66 #define AAC_HOST_HIGH_RESP_ENTRIES 4 /* response, adapter->host,
68 #define AAC_ADAP_NORM_RESP_ENTRIES 8 /* response, host->adapter,
70 #define AAC_ADAP_HIGH_RESP_ENTRIES 4 /* response, host->adapter,
73 #define AAC_TOTALQ_LENGTH (AAC_HOST_HIGH_CMD_ENTRIES + \
74 AAC_HOST_NORM_CMD_ENTRIES + \
75 AAC_ADAP_HIGH_CMD_ENTRIES + \
76 AAC_ADAP_NORM_CMD_ENTRIES + \
77 AAC_HOST_HIGH_RESP_ENTRIES + \
78 AAC_HOST_NORM_RESP_ENTRIES + \
79 AAC_ADAP_HIGH_RESP_ENTRIES + \
80 AAC_ADAP_NORM_RESP_ENTRIES)
81 #define AAC_QUEUE_COUNT 8
82 #define AAC_QUEUE_ALIGN 16
84 struct aac_queue_entry {
85 u_int32_t aq_fib_size; /* FIB size in bytes */
86 u_int32_t aq_fib_addr; /* receiver-space address of the FIB */
87 } __attribute__ ((packed));
89 #define AAC_PRODUCER_INDEX 0
90 #define AAC_CONSUMER_INDEX 1
93 * Table of queue indices and queues used to communicate with the
94 * controller. This structure must be aligned to AAC_QUEUE_ALIGN
96 struct aac_queue_table {
97 /* queue consumer/producer indexes (layout mandated by adapter) */
98 u_int32_t qt_qindex[AAC_QUEUE_COUNT][2];
100 /* queue entry structures (layout mandated by adapter) */
101 struct aac_queue_entry qt_HostNormCmdQueue [AAC_HOST_NORM_CMD_ENTRIES];
102 struct aac_queue_entry qt_HostHighCmdQueue [AAC_HOST_HIGH_CMD_ENTRIES];
103 struct aac_queue_entry qt_AdapNormCmdQueue [AAC_ADAP_NORM_CMD_ENTRIES];
104 struct aac_queue_entry qt_AdapHighCmdQueue [AAC_ADAP_HIGH_CMD_ENTRIES];
105 struct aac_queue_entry qt_HostNormRespQueue[AAC_HOST_NORM_RESP_ENTRIES];
106 struct aac_queue_entry qt_HostHighRespQueue[AAC_HOST_HIGH_RESP_ENTRIES];
107 struct aac_queue_entry qt_AdapNormRespQueue[AAC_ADAP_NORM_RESP_ENTRIES];
108 struct aac_queue_entry qt_AdapHighRespQueue[AAC_ADAP_HIGH_RESP_ENTRIES];
109 } __attribute__ ((packed));
114 * Note that we base these at 0 in order to use them as array indices. Adaptec
115 * used base 1 for some unknown reason, and sorted them in a different order.
117 #define AAC_HOST_NORM_CMD_QUEUE 0
118 #define AAC_HOST_HIGH_CMD_QUEUE 1
119 #define AAC_ADAP_NORM_CMD_QUEUE 2
120 #define AAC_ADAP_HIGH_CMD_QUEUE 3
121 #define AAC_HOST_NORM_RESP_QUEUE 4
122 #define AAC_HOST_HIGH_RESP_QUEUE 5
123 #define AAC_ADAP_NORM_RESP_QUEUE 6
124 #define AAC_ADAP_HIGH_RESP_QUEUE 7
127 * List structure used to chain FIBs (used by the adapter - we hang FIBs off
128 * our private command structure and don't touch these)
130 struct aac_fib_list_entry {
133 } __attribute__ ((packed));
136 * FIB (FSA Interface Block?); this is the datastructure passed between the host
139 struct aac_fib_header {
145 u_int16_t SenderSize;
146 u_int32_t SenderFibAddress;
147 u_int32_t ReceiverFibAddress;
148 u_int32_t SenderData;
151 u_int32_t ReceiverTimeStart;
152 u_int32_t ReceiverTimeDone;
154 struct aac_fib_list_entry FibLinks;
156 } __attribute__ ((packed));
158 #define AAC_FIB_DATASIZE (512 - sizeof(struct aac_fib_header))
161 struct aac_fib_header Header;
162 u_int8_t data[AAC_FIB_DATASIZE];
163 } __attribute__ ((packed));
169 TestCommandResponse = 1,
170 TestAdapterCommand = 2,
172 /* lowlevel and comm commands */
173 LastTestCommand = 100,
174 ReinitHostNormCommandQueue = 101,
175 ReinitHostHighCommandQueue = 102,
176 ReinitHostHighRespQueue = 103,
177 ReinitHostNormRespQueue = 104,
178 ReinitAdapNormCommandQueue = 105,
179 ReinitAdapHighCommandQueue = 107,
180 ReinitAdapHighRespQueue = 108,
181 ReinitAdapNormRespQueue = 109,
182 InterfaceShutdown = 110,
188 RequestPerfData = 125,
189 SetInterruptDefTimer= 126,
190 SetInterruptDefCount= 127,
191 GetInterruptDefStatus= 128,
192 LastCommCommand = 129,
194 /* filesystem commands */
197 HostFileSystem = 302,
198 LastFileSystemCommand = 303,
200 /* Container Commands */
201 ContainerCommand = 500,
202 ContainerCommand64 = 501,
204 /* Cluster Commands */
205 ClusterCommand = 550,
207 /* Scsi Port commands (scsi passthrough) */
208 ScsiPortCommand = 600,
210 /* misc house keeping and generic adapter initiated commands */
213 FsaHostShutdown = 702,
214 RequestAdapterInfo = 703,
215 IsAdapterPaused = 704,
217 LastMiscCommand = 706
223 #define AAC_FIBTYPE_TFIB 1
224 #define AAC_FIBTYPE_TQE 2
225 #define AAC_FIBTYPE_TCTPERF 3
230 #define AAC_FIBSTATE_HOSTOWNED (1<<0) /* owned by the host */
231 #define AAC_FIBSTATE_ADAPTEROWNED (1<<1) /* owned by the adapter */
232 #define AAC_FIBSTATE_INITIALISED (1<<2) /* initialised */
233 #define AAC_FIBSTATE_EMPTY (1<<3) /* empty */
234 #define AAC_FIBSTATE_FROMPOOL (1<<4) /* allocated from pool */
235 #define AAC_FIBSTATE_FROMHOST (1<<5) /* sent from the host */
236 #define AAC_FIBSTATE_FROMADAP (1<<6) /* sent from the adapter */
237 #define AAC_FIBSTATE_REXPECTED (1<<7) /* response is expected */
238 #define AAC_FIBSTATE_RNOTEXPECTED (1<<8) /* response is not expected */
239 #define AAC_FIBSTATE_DONEADAP (1<<9) /* processed by the adapter */
240 #define AAC_FIBSTATE_DONEHOST (1<<10) /* processed by the host */
241 #define AAC_FIBSTATE_HIGH (1<<11) /* high priority */
242 #define AAC_FIBSTATE_NORM (1<<12) /* normal priority */
243 #define AAC_FIBSTATE_ASYNC (1<<13)
244 #define AAC_FIBSTATE_ASYNCIO (1<<13) /* to be removed */
245 #define AAC_FIBSTATE_PAGEFILEIO (1<<14) /* to be removed */
246 #define AAC_FIBSTATE_SHUTDOWN (1<<15)
247 #define AAC_FIBSTATE_LAZYWRITE (1<<16) /* to be removed */
248 #define AAC_FIBSTATE_ADAPMICROFIB (1<<17)
249 #define AAC_FIBSTATE_BIOSFIB (1<<18)
250 #define AAC_FIBSTATE_FAST_RESPONSE (1<<19) /* fast response capable */
251 #define AAC_FIBSTATE_APIFIB (1<<20)
256 #define AAC_ERROR_NORMAL 0x00
257 #define AAC_ERROR_PENDING 0x01
258 #define AAC_ERROR_FATAL 0x02
259 #define AAC_ERROR_INVALID_QUEUE 0x03
260 #define AAC_ERROR_NOENTRIES 0x04
261 #define AAC_ERROR_SENDFAILED 0x05
262 #define AAC_ERROR_INVALID_QUEUE_PRIORITY 0x06
263 #define AAC_ERROR_FIB_ALLOCATION_FAILED 0x07
264 #define AAC_ERROR_FIB_DEALLOCATION_FAILED 0x08
267 * Adapter Init Structure: this is passed to the adapter with the
268 * AAC_MONKER_INITSTRUCT command to point it at our control structures.
270 struct aac_adapter_init {
271 u_int32_t InitStructRevision;
272 #define AAC_INIT_STRUCT_REVISION 3
273 u_int32_t MiniPortRevision;
274 #define AAC_INIT_STRUCT_MINIPORT_REVISION 1
275 u_int32_t FilesystemRevision;
276 u_int32_t CommHeaderAddress;
277 u_int32_t FastIoCommAreaAddress;
278 u_int32_t AdapterFibsPhysicalAddress;
279 u_int32_t AdapterFibsVirtualAddress;
280 u_int32_t AdapterFibsSize;
281 u_int32_t AdapterFibAlign;
282 u_int32_t PrintfBufferAddress;
283 u_int32_t PrintfBufferSize;
284 #define AAC_PAGE_SIZE 4096
285 u_int32_t HostPhysMemPages;
286 u_int32_t HostElapsedSeconds;
287 } __attribute__ ((packed));
306 CT_RAID10, /* stripe of mirror */
307 CT_RAID00, /* stripe of stripe */
308 CT_VOLUME_OF_MIRRORS, /* volume of mirror */
309 CT_PSEUDO_RAID3, /* really raid4 */
310 CT_RAID50, /* stripe of raid5 */
314 * Host-addressable object types
317 FT_REG = 1, /* regular file */
318 FT_DIR, /* directory */
319 FT_BLK, /* "block" device - reserved */
320 FT_CHR, /* "character special" device - reserved */
321 FT_LNK, /* symbolic link */
322 FT_SOCK, /* socket */
324 FT_FILESYS, /* ADAPTEC's "FSA"(tm) filesystem */
325 FT_DRIVE, /* physical disk - addressable in scsi by b/t/l */
326 FT_SLICE, /* virtual disk - raw volume - slice */
327 FT_PARTITION, /* FSA partition - carved out of a slice - building
328 * block for containers */
329 FT_VOLUME, /* Container - Volume Set */
330 FT_STRIPE, /* Container - Stripe Set */
331 FT_MIRROR, /* Container - Mirror Set */
332 FT_RAID5, /* Container - Raid 5 Set */
333 FT_DATABASE /* Storage object with "foreign" content manager */
337 * Host-side scatter/gather list for 32-bit commands.
339 struct aac_sg_entry {
341 u_int32_t SgByteCount;
342 } __attribute__ ((packed));
344 struct aac_sg_table {
346 struct aac_sg_entry SgEntry[0];
347 } __attribute__ ((packed));
350 * Host-side scatter/gather list for 64-bit commands.
352 struct aac_sg_table64 {
354 u_int8_t SgSectorsPerPage;
355 u_int16_t SgByteOffset;
356 u_int64_t SgEntry[0];
357 } __attribute__ ((packed));
360 * Container creation data
362 struct aac_container_creation {
363 u_int8_t ViaBuildNumber;
364 u_int8_t MicroSecond;
365 u_int8_t Via; /* 1 = FSU, 2 = API, etc. */
366 u_int8_t YearsSince1900;
367 u_int32_t Month:4; /* 1-12 */
368 u_int32_t Day:6; /* 1-32 */
369 u_int32_t Hour:6; /* 0-23 */
370 u_int32_t Minute:6; /* 0-59 */
371 u_int32_t Second:6; /* 0-59 */
372 u_int64_t ViaAdapterSerialNumber;
373 } __attribute__ ((packed));
376 * Revision number handling
401 u_int32_t buildNumber;
402 } __attribute__ ((packed));
405 * Adapter Information
457 OEM_FLAVOR_ADAPTEC = 1,
469 * XXX the aac-2622 with no battery present reports PLATFORM_BAT_OPT_PRESENT
473 PLATFORM_BAT_REQ_PRESENT = 1, /* BATTERY REQUIRED AND PRESENT */
474 PLATFORM_BAT_REQ_NOTPRESENT, /* BATTERY REQUIRED AND NOT PRESENT */
475 PLATFORM_BAT_OPT_PRESENT, /* BATTERY OPTIONAL AND PRESENT */
476 PLATFORM_BAT_OPT_NOTPRESENT, /* BATTERY OPTIONAL AND NOT PRESENT */
477 PLATFORM_BAT_NOT_SUPPORTED /* BATTERY NOT SUPPORTED */
478 } AAC_BatteryPlatform;
481 * options supported by this board
482 * there has to be a one to one mapping of these defines and the ones in
483 * fsaapi.h, search for FSA_SUPPORT_SNAPSHOT
485 #define AAC_SUPPORTED_SNAPSHOT 0x01
486 #define AAC_SUPPORTED_CLUSTERS 0x02
487 #define AAC_SUPPORTED_WRITE_CACHE 0x04
488 #define AAC_SUPPORTED_64BIT_DATA 0x08
489 #define AAC_SUPPORTED_HOST_TIME_FIB 0x10
490 #define AAC_SUPPORTED_RAID50 0x20
491 #define AAC_SUPPORTED_4GB_WINDOW 0x40
492 #define AAC_SUPPORTED_SCSI_UPGRADEABLE 0x80
493 #define AAC_SUPPORTED_SOFT_ERR_REPORT 0x100
494 #define AAC_SUPPORTED_NOT_RECONDITION 0x200
495 #define AAC_SUPPORTED_SGMAP_HOST64 0x400
496 #define AAC_SUPPORTED_ALARM 0x800
497 #define AAC_SUPPORTED_NONDASD 0x1000
500 * Structure used to respond to a RequestAdapterInfo fib.
502 struct aac_adapter_info {
503 AAC_Platform PlatformBase; /* adapter type */
504 AAC_CpuType CpuArchitecture; /* adapter CPU type */
505 AAC_CpuSubType CpuVariant; /* adapter CPU subtype */
506 u_int32_t ClockSpeed; /* adapter CPU clockspeed */
507 u_int32_t ExecutionMem; /* adapter Execution Memory
509 u_int32_t BufferMem; /* adapter Data Memory */
510 u_int32_t TotalMem; /* adapter Total Memory */
511 struct FsaRevision KernelRevision; /* adapter Kernel Software
513 struct FsaRevision MonitorRevision; /* adapter Monitor/Diagnostic
514 * Software Revision */
515 struct FsaRevision HardwareRevision;/* TBD */
516 struct FsaRevision BIOSRevision; /* adapter BIOS Revision */
517 u_int32_t ClusteringEnabled;
518 u_int32_t ClusterChannelMask;
519 u_int64_t SerialNumber;
520 AAC_BatteryPlatform batteryPlatform;
521 u_int32_t SupportedOptions; /* supported features of this
523 AAC_OemFlavor OemVariant;
524 } __attribute__ ((packed));
527 * Monitor/Kernel interface.
531 * Synchronous commands to the monitor/kernel.
533 #define AAC_MONKER_INITSTRUCT 0x05
534 #define AAC_MONKER_SYNCFIB 0x0c
535 #define AAC_MONKER_GETKERNVER 0x11
536 #define AAC_MONKER_GETINFO 0x19
539 * Adapter Status Register
541 * Phase Staus mailbox is 32bits:
542 * <31:16> = Phase Status
545 * The adapter reports its present state through the phase. Only
546 * a single phase should be ever be set. Each phase can have multiple
547 * phase status bits to provide more detailed information about the
548 * state of the adapter.
550 #define AAC_SELF_TEST_FAILED 0x00000004
551 #define AAC_UP_AND_RUNNING 0x00000080
552 #define AAC_KERNEL_PANIC 0x00000100
555 * Data types relating to control and monitoring of the NVRAM/WriteCache
559 #define AAC_NFILESYS 24 /* maximum number of filesystems */
562 * NVRAM/Write Cache subsystem states
565 NVSTATUS_DISABLED = 0, /* present, clean, not being used */
566 NVSTATUS_ENABLED, /* present, possibly dirty, ready for use */
567 NVSTATUS_ERROR, /* present, dirty, contains dirty data */
568 NVSTATUS_BATTERY, /* present, bad or low battery, may contain
570 NVSTATUS_UNKNOWN /* for bad/missing device */
574 * NVRAM/Write Cache subsystem battery component states
578 NVBATTSTATUS_NONE = 0, /* battery has no power or is not present */
579 NVBATTSTATUS_LOW, /* battery is low on power */
580 NVBATTSTATUS_OK, /* battery is okay - normal operation possible
581 * only in this state */
582 NVBATTSTATUS_RECONDITIONING /* no battery present - reconditioning
587 * Battery transition type
590 NVBATT_TRANSITION_NONE = 0, /* battery now has no power or is not
592 NVBATT_TRANSITION_LOW, /* battery is now low on power */
593 NVBATT_TRANSITION_OK /* battery is now okay - normal
594 * operation possible only in this
596 } AAC_NVBATT_TRANSITION;
599 * NVRAM Info structure returned for NVRAM_GetInfo call
601 struct aac_nvramdevinfo {
602 u_int32_t NV_Enabled; /* write caching enabled */
603 u_int32_t NV_Error; /* device in error state */
604 u_int32_t NV_NDirty; /* count of dirty NVRAM buffers */
605 u_int32_t NV_NActive; /* count of NVRAM buffers being
607 } __attribute__ ((packed));
609 struct aac_nvraminfo {
610 AAC_NVSTATUS NV_Status; /* nvram subsystem status */
611 AAC_NVBATTSTATUS NV_BattStatus; /* battery status */
612 u_int32_t NV_Size; /* size of WriteCache NVRAM in
614 u_int32_t NV_BufSize; /* size of NVRAM buffers in
616 u_int32_t NV_NBufs; /* number of NVRAM buffers */
617 u_int32_t NV_NDirty; /* Num dirty NVRAM buffers */
618 u_int32_t NV_NClean; /* Num clean NVRAM buffers */
619 u_int32_t NV_NActive; /* Num NVRAM buffers being
621 u_int32_t NV_NBrokered; /* Num brokered NVRAM buffers */
622 struct aac_nvramdevinfo NV_DevInfo[AAC_NFILESYS]; /* per device
624 u_int32_t NV_BattNeedsReconditioning; /* boolean */
625 u_int32_t NV_TotalSize; /* size of all non-volatile
626 * memories in bytes */
627 } __attribute__ ((packed));
630 * Data types relating to adapter-initiated FIBs
632 * Based on types and structures in <aifstruc.h>
639 AifJobStsSuccess = 1,
643 AifJobStsLastReportMarker = 100, /* All prior mean last report */
649 AifJobScsiMin = 1, /* Minimum value for Scsi operation */
650 AifJobScsiZero, /* SCSI device clear operation */
651 AifJobScsiVerify, /* SCSI device Verify operation NO
653 AifJobScsiExercise, /* SCSI device Exercise operation */
654 AifJobScsiVerifyRepair, /* SCSI device Verify operation WITH
656 AifJobScsiMax = 99, /* Max Scsi value */
657 AifJobCtrMin, /* Min Ctr op value */
658 AifJobCtrZero, /* Container clear operation */
659 AifJobCtrCopy, /* Container copy operation */
660 AifJobCtrCreateMirror, /* Container Create Mirror operation */
661 AifJobCtrMergeMirror, /* Container Merge Mirror operation */
662 AifJobCtrScrubMirror, /* Container Scrub Mirror operation */
663 AifJobCtrRebuildRaid5, /* Container Rebuild Raid5 operation */
664 AifJobCtrScrubRaid5, /* Container Scrub Raid5 operation */
665 AifJobCtrMorph, /* Container morph operation */
666 AifJobCtrPartCopy, /* Container Partition copy operation */
667 AifJobCtrRebuildMirror, /* Container Rebuild Mirror operation */
668 AifJobCtrCrazyCache, /* crazy cache */
669 AifJobCtrMax = 199, /* Max Ctr type operation */
670 AifJobFsMin, /* Min Fs type operation */
671 AifJobFsCreate, /* File System Create operation */
672 AifJobFsVerify, /* File System Verify operation */
673 AifJobFsExtend, /* File System Extend operation */
674 AifJobFsMax = 299, /* Max Fs type operation */
675 AifJobApiFormatNTFS, /* Format a drive to NTFS */
676 AifJobApiFormatFAT, /* Format a drive to FAT */
677 AifJobApiUpdateSnapshot, /* update the read/write half of a
679 AifJobApiFormatFAT32, /* Format a drive to FAT32 */
680 AifJobApiMax = 399, /* Max API type operation */
681 AifJobCtlContinuousCtrVerify, /* Adapter operation */
682 AifJobCtlMax = 499 /* Max Adapter type operation */
685 struct aac_AifContainers {
686 u_int32_t src; /* from/master */
687 u_int32_t dst; /* to/slave */
688 } __attribute__ ((packed));
690 union aac_AifJobClient {
691 struct aac_AifContainers container; /* For Container and
692 * file system progress
694 int32_t scsi_dh; /* For SCSI progress
698 struct aac_AifJobDesc {
699 u_int32_t jobID; /* DO NOT FILL IN! Will be
700 * filled in by AIF */
701 AAC_AifJobType type; /* Operation that is being
703 union aac_AifJobClient client; /* Details */
704 } __attribute__ ((packed));
706 struct aac_AifJobProgressReport {
707 struct aac_AifJobDesc jd;
708 AAC_AifJobStatus status;
710 u_int32_t currentTick;
711 u_int32_t jobSpecificData1;
712 u_int32_t jobSpecificData2;
713 } __attribute__ ((packed));
719 /* General application notifies start here */
720 AifEnGeneric = 1, /* Generic notification */
721 AifEnTaskComplete, /* Task has completed */
722 AifEnConfigChange, /* Adapter config change occurred */
723 AifEnContainerChange, /* Adapter specific container
724 * configuration change */
725 AifEnDeviceFailure, /* SCSI device failed */
726 AifEnMirrorFailover, /* Mirror failover started */
727 AifEnContainerEvent, /* Significant container event */
728 AifEnFileSystemChange, /* File system changed */
729 AifEnConfigPause, /* Container pause event */
730 AifEnConfigResume, /* Container resume event */
731 AifEnFailoverChange, /* Failover space assignment changed */
732 AifEnRAID5RebuildDone, /* RAID5 rebuild finished */
733 AifEnEnclosureManagement, /* Enclosure management event */
734 AifEnBatteryEvent, /* Significant NV battery event */
735 AifEnAddContainer, /* A new container was created. */
736 AifEnDeleteContainer, /* A container was deleted. */
737 AifEnSMARTEvent, /* SMART Event */
738 AifEnBatteryNeedsRecond, /* The battery needs reconditioning */
739 AifEnClusterEvent, /* Some cluster event */
740 AifEnDiskSetEvent, /* A disk set event occured. */
741 AifDriverNotifyStart=199, /* Notifies for host driver go here */
742 /* Host driver notifications start here */
743 AifDenMorphComplete, /* A morph operation completed */
744 AifDenVolumeExtendComplete /* Volume expand operation completed */
745 } AAC_AifEventNotifyType;
747 struct aac_AifEnsGeneric {
748 char text[132]; /* Generic text */
749 } __attribute__ ((packed));
751 struct aac_AifEnsDeviceFailure {
752 u_int32_t deviceHandle; /* SCSI device handle */
753 } __attribute__ ((packed));
755 struct aac_AifEnsMirrorFailover {
756 u_int32_t container; /* Container with failed element */
757 u_int32_t failedSlice; /* Old slice which failed */
758 u_int32_t creatingSlice; /* New slice used for auto-create */
759 } __attribute__ ((packed));
761 struct aac_AifEnsContainerChange {
762 u_int32_t container[2]; /* container that changed, -1 if no
764 } __attribute__ ((packed));
766 struct aac_AifEnsContainerEvent {
767 u_int32_t container; /* container number */
768 u_int32_t eventType; /* event type */
769 } __attribute__ ((packed));
771 struct aac_AifEnsEnclosureEvent {
772 u_int32_t empID; /* enclosure management proc number */
773 u_int32_t unitID; /* unitId, fan id, power supply id,
774 * slot id, tempsensor id. */
775 u_int32_t eventType; /* event type */
776 } __attribute__ ((packed));
778 struct aac_AifEnsBatteryEvent {
779 AAC_NVBATT_TRANSITION transition_type; /* eg from low to ok */
780 AAC_NVBATTSTATUS current_state; /* current batt state */
781 AAC_NVBATTSTATUS prior_state; /* prev batt state */
782 } __attribute__ ((packed));
784 struct aac_AifEnsDiskSetEvent {
788 } __attribute__ ((packed));
791 CLUSTER_NULL_EVENT = 0,
792 CLUSTER_PARTNER_NAME_EVENT, /* change in partner hostname or
793 * adaptername from NULL to non-NULL */
794 /* (partner's agent may be up) */
795 CLUSTER_PARTNER_NULL_NAME_EVENT /* change in partner hostname or
796 * adaptername from non-null to NULL */
797 /* (partner has rebooted) */
798 } AAC_ClusterAifEvent;
800 struct aac_AifEnsClusterEvent {
801 AAC_ClusterAifEvent eventType;
802 } __attribute__ ((packed));
804 struct aac_AifEventNotify {
805 AAC_AifEventNotifyType type;
807 struct aac_AifEnsGeneric EG;
808 struct aac_AifEnsDeviceFailure EDF;
809 struct aac_AifEnsMirrorFailover EMF;
810 struct aac_AifEnsContainerChange ECC;
811 struct aac_AifEnsContainerEvent ECE;
812 struct aac_AifEnsEnclosureEvent EEE;
813 struct aac_AifEnsBatteryEvent EBE;
814 struct aac_AifEnsDiskSetEvent EDS;
815 /* struct aac_AifEnsSMARTEvent ES;*/
816 struct aac_AifEnsClusterEvent ECLE;
818 } __attribute__ ((packed));
821 * Adapter Initiated FIB command structures. Start with the adapter
822 * initiated FIBs that really come from the adapter, and get responded
825 #define AAC_AIF_REPORT_MAX_SIZE 64
828 AifCmdEventNotify = 1, /* Notify of event */
829 AifCmdJobProgress, /* Progress report */
830 AifCmdAPIReport, /* Report from other user of API */
831 AifCmdDriverNotify, /* Notify host driver of event */
832 AifReqJobList = 100, /* Gets back complete job list */
833 AifReqJobsForCtr, /* Gets back jobs for specific container */
834 AifReqJobsForScsi, /* Gets back jobs for specific SCSI device */
835 AifReqJobReport, /* Gets back a specific job report or list */
836 AifReqTerminateJob, /* Terminates job */
837 AifReqSuspendJob, /* Suspends a job */
838 AifReqResumeJob, /* Resumes a job */
839 AifReqSendAPIReport, /* API generic report requests */
840 AifReqAPIJobStart, /* Start a job from the API */
841 AifReqAPIJobUpdate, /* Update a job report from the API */
842 AifReqAPIJobFinish /* Finish a job from the API */
845 struct aac_aif_command {
846 AAC_AifCommand command; /* Tell host what type of
848 u_int32_t seqNumber; /* To allow ordering of
849 * reports (if necessary) */
851 struct aac_AifEventNotify EN; /* Event notify structure */
852 struct aac_AifJobProgressReport PR[1]; /* Progress report */
853 u_int8_t AR[AAC_AIF_REPORT_MAX_SIZE];
855 } __attribute__ ((packed));
858 * Filesystem commands/data
860 * The adapter has a very complex filesystem interface, most of which we ignore.
861 * (And which seems not to be implemented, anyway.)
910 * Command status values
936 ST_BADHANDLE = 10001,
938 ST_BAD_COOKIE = 10003,
941 ST_SERVERFAULT = 10006,
944 ST_NOTMOUNTED = 10009,
945 ST_MAINTMODE = 10010,
950 * Volume manager commands
952 typedef enum _VM_COMMANDS {
961 VM_SliceBlockRead, /* raw access to configured storage objects */
963 VM_DriveBlockRead, /* raw access to physical devices */
965 VM_EnclosureMgt, /* enclosure management */
966 VM_Unused, /* used to be diskset management */
968 VM_CtPerf, /* performance test */
979 char FileSystemName[16];
980 struct aac_container_creation CreateInfo;
984 u_int32_t ContentState;
985 #define FSCS_READONLY 0x0002 /* XXX need more information
990 u_int32_t AlterEgoId;
991 } __attribute__ ((packed));
997 } __attribute__ ((packed));
999 struct aac_mntinforesp {
1002 u_int32_t MntRespCount;
1003 struct aac_mntobj MntTable[1];
1004 } __attribute__ ((packed));
1007 * Container shutdown command.
1009 struct aac_closecommand {
1011 u_int32_t ContainerId;
1012 } __attribute__ ((packed));
1015 * Container Config Command
1017 #define CT_GET_SCSI_METHOD 64
1022 } __attribute__ ((packed));
1024 struct aac_ctcfg_resp {
1028 } __attribute__ ((packed));
1033 #define AAC_SCSI_MAX_PORTS 10
1034 #define AAC_BUS_NO_EXIST 0
1035 #define AAC_BUS_VALID 1
1036 #define AAC_BUS_FAULTED 2
1037 #define AAC_BUS_DISABLED 3
1038 #define GetBusInfo 0x9
1040 struct aac_getbusinf {
1041 u_int32_t ProbeComplete;
1043 u_int32_t TargetsPerBus;
1044 u_int8_t InitiatorBusId[AAC_SCSI_MAX_PORTS];
1045 u_int8_t BusValid[AAC_SCSI_MAX_PORTS];
1046 } __attribute__ ((packed));
1048 struct aac_vmioctl {
1054 u_int32_t IoctlBuf[1]; /* Placeholder? */
1055 } __attribute__ ((packed));
1057 struct aac_vmi_businf_resp {
1063 struct aac_getbusinf BusInf;
1064 } __attribute__ ((packed));
1066 #define AAC_BTL_TO_HANDLE(b, t, l) \
1067 (((b & 0x3f) << 7) | ((l & 0x7) << 4) | (t & 0xf))
1068 #define GetDeviceProbeInfo 0x5
1070 struct aac_vmi_devinfo_resp {
1076 u_int8_t VendorId[8];
1077 u_int8_t ProductId[16];
1078 u_int8_t ProductRev[4];
1085 u_int32_t reserved[2];
1086 u_int8_t VendorSpecific[20];
1088 u_int32_t AAC_Managed:1;
1090 u_int32_t reserved2:6;
1094 u_int32_t ultraEnable:1,
1106 }; /* Do not pack */
1108 #define ResetBus 0x16
1109 struct aac_resetbus {
1110 u_int32_t BusNumber;
1114 * Write 'stability' options.
1122 * Commit level response for a write request.
1125 CMFILE_SYNC_NVRAM = 1,
1133 * Block read/write operations.
1134 * These structures are packed into the 'data' area in the FIB.
1137 struct aac_blockread {
1138 u_int32_t Command; /* not FSACommand! */
1139 u_int32_t ContainerId;
1140 u_int32_t BlockNumber;
1141 u_int32_t ByteCount;
1142 struct aac_sg_table SgMap; /* variable size */
1143 } __attribute__ ((packed));
1145 struct aac_blockread_response {
1147 u_int32_t ByteCount;
1148 } __attribute__ ((packed));
1150 struct aac_blockwrite {
1151 u_int32_t Command; /* not FSACommand! */
1152 u_int32_t ContainerId;
1153 u_int32_t BlockNumber;
1154 u_int32_t ByteCount;
1156 struct aac_sg_table SgMap; /* variable size */
1157 } __attribute__ ((packed));
1159 struct aac_blockwrite_response {
1161 u_int32_t ByteCount;
1162 u_int32_t Committed;
1163 } __attribute__ ((packed));
1166 * Container shutdown command.
1168 struct aac_close_command {
1170 u_int32_t ContainerId;
1174 * SCSI Passthrough structures
1184 u_int32_t retry_limit;
1187 struct aac_sg_table sg_map32;
1191 AAC_SRB_FUNC_EXECUTE_SCSI = 0x00,
1192 AAC_SRB_FUNC_CLAIM_DEVICE,
1193 AAC_SRB_FUNC_IO_CONTROL,
1194 AAC_SRB_FUNC_RECEIVE_EVENT,
1195 AAC_SRB_FUNC_RELEASE_QUEUE,
1196 AAC_SRB_FUNC_ATTACH_DEVICE,
1197 AAC_SRB_FUNC_RELEASE_DEVICE,
1198 AAC_SRB_FUNC_SHUTDOWN,
1200 AAC_SRB_FUNC_ABORT_COMMAND = 0x10,
1201 AAC_SRB_FUNC_RELEASE_RECOVERY,
1202 AAC_SRB_FUNC_RESET_BUS,
1203 AAC_SRB_FUNC_RESET_DEVICE,
1204 AAC_SRB_FUNC_TERMINATE_IO,
1205 AAC_SRB_FUNC_FLUSH_QUEUE,
1206 AAC_SRB_FUNC_REMOVE_DEVICE,
1207 AAC_SRB_FUNC_DOMAIN_VALIDATION
1210 #define AAC_SRB_FLAGS_NO_DATA_XFER 0x0000
1211 #define AAC_SRB_FLAGS_DISABLE_DISCONNECT 0x0004
1212 #define AAC_SRB_FLAGS_DISABLE_SYNC_TRANSFER 0x0008
1213 #define AAC_SRB_FLAGS_BYPASS_FROZEN_QUEUE 0x0010
1214 #define AAC_SRB_FLAGS_DISABLE_AUTOSENSE 0x0020
1215 #define AAC_SRB_FLAGS_DATA_IN 0x0040
1216 #define AAC_SRB_FLAGS_DATA_OUT 0x0080
1217 #define AAC_SRB_FLAGS_UNSPECIFIED_DIRECTION \
1218 (AAC_SRB_FLAGS_DATA_IN | AAC_SRB_FLAGS_DATA_OUT)
1220 #define AAC_HOST_SENSE_DATA_MAX 30
1222 struct aac_srb_response {
1223 u_int32_t fib_status;
1224 u_int32_t srb_status;
1225 u_int32_t scsi_status;
1227 u_int32_t sense_len;
1228 u_int8_t sense[AAC_HOST_SENSE_DATA_MAX];
1232 AAC_SRB_STS_PENDING = 0x00,
1233 AAC_SRB_STS_SUCCESS,
1234 AAC_SRB_STS_ABORTED,
1235 AAC_SRB_STS_ABORT_FAILED,
1238 AAC_SRB_STS_INVALID_REQUEST,
1239 AAC_SRB_STS_INVALID_PATH_ID,
1240 AAC_SRB_STS_NO_DEVICE,
1241 AAC_SRB_STS_TIMEOUT,
1242 AAC_SRB_STS_SELECTION_TIMEOUT,
1243 AAC_SRB_STS_COMMAND_TIMEOUT,
1244 AAC_SRB_STS_MESSAGE_REJECTED = 0x0D,
1245 AAC_SRB_STS_BUS_RESET,
1246 AAC_SRB_STS_PARITY_ERROR,
1247 AAC_SRB_STS_REQUEST_SENSE_FAILED,
1249 AAC_SRB_STS_DATA_OVERRUN,
1250 AAC_SRB_STS_UNEXPECTED_BUS_FREE,
1251 AAC_SRB_STS_PHASE_SEQUENCE_FAILURE,
1252 AAC_SRB_STS_BAD_SRB_BLOCK_LENGTH,
1253 AAC_SRB_STS_REQUEST_FLUSHED,
1254 AAC_SRB_STS_INVALID_LUN = 0x20,
1255 AAC_SRB_STS_INVALID_TARGET_ID,
1256 AAC_SRB_STS_BAD_FUNCTION,
1257 AAC_SRB_STS_ERROR_RECOVERY
1261 * Register set for adapters based on the Falcon bridge and PPC core
1264 #define AAC_FA_DOORBELL0_CLEAR 0x00
1265 #define AAC_FA_DOORBELL1_CLEAR 0x02
1266 #define AAC_FA_DOORBELL0 0x04
1267 #define AAC_FA_DOORBELL1 0x06
1268 #define AAC_FA_MASK0_CLEAR 0x08
1269 #define AAC_FA_MASK1_CLEAR 0x0a
1270 #define AAC_FA_MASK0 0x0c
1271 #define AAC_FA_MASK1 0x0e
1272 #define AAC_FA_MAILBOX 0x10
1273 #define AAC_FA_FWSTATUS 0x2c /* Mailbox 7 */
1274 #define AAC_FA_INTSRC 0x900
1276 #define AAC_FA_HACK(sc) (void)AAC_GETREG4(sc, AAC_FA_INTSRC)
1279 * Register definitions for the Adaptec AAC-364 'Jalapeno I/II' adapters, based
1280 * on the SA110 'StrongArm'.
1283 #define AAC_SA_DOORBELL0_CLEAR 0x98 /* doorbell 0 (adapter->host) */
1284 #define AAC_SA_DOORBELL0_SET 0x9c
1285 #define AAC_SA_DOORBELL0 0x9c
1286 #define AAC_SA_MASK0_CLEAR 0xa0
1287 #define AAC_SA_MASK0_SET 0xa4
1289 #define AAC_SA_DOORBELL1_CLEAR 0x9a /* doorbell 1 (host->adapter) */
1290 #define AAC_SA_DOORBELL1_SET 0x9e
1291 #define AAC_SA_DOORBELL1 0x9e
1292 #define AAC_SA_MASK1_CLEAR 0xa2
1293 #define AAC_SA_MASK1_SET 0xa6
1295 #define AAC_SA_MAILBOX 0xa8 /* mailbox (20 bytes) */
1296 #define AAC_SA_FWSTATUS 0xc4
1299 * Register definitions for the Adaptec 'Pablano' adapters, based on the i960Rx,
1300 * and other related adapters.
1303 #define AAC_RX_IDBR 0x20 /* inbound doorbell register */
1304 #define AAC_RX_IISR 0x24 /* inbound interrupt status register */
1305 #define AAC_RX_IIMR 0x28 /* inbound interrupt mask register */
1306 #define AAC_RX_ODBR 0x2c /* outbound doorbell register */
1307 #define AAC_RX_OISR 0x30 /* outbound interrupt status register */
1308 #define AAC_RX_OIMR 0x34 /* outbound interrupt mask register */
1310 #define AAC_RX_MAILBOX 0x50 /* mailbox (20 bytes) */
1311 #define AAC_RX_FWSTATUS 0x6c
1314 * Common bit definitions for the doorbell registers.
1318 * Status bits in the doorbell registers.
1320 #define AAC_DB_SYNC_COMMAND (1<<0) /* send/completed synchronous FIB */
1321 #define AAC_DB_COMMAND_READY (1<<1) /* posted one or more commands */
1322 #define AAC_DB_RESPONSE_READY (1<<2) /* one or more commands complete */
1323 #define AAC_DB_COMMAND_NOT_FULL (1<<3) /* command queue not full */
1324 #define AAC_DB_RESPONSE_NOT_FULL (1<<4) /* response queue not full */
1327 * The adapter can request the host print a message by setting the
1328 * DB_PRINTF flag in DOORBELL0. The driver responds by collecting the
1329 * message from the printf buffer, clearing the DB_PRINTF flag in
1330 * DOORBELL0 and setting it in DOORBELL1.
1331 * (ODBR and IDBR respectively for the i960Rx adapters)
1333 #define AAC_DB_PRINTF (1<<5) /* adapter requests host printf */
1334 #define AAC_PRINTF_DONE (1<<5) /* Host completed printf processing */
1337 * Mask containing the interrupt bits we care about. We don't anticipate (or
1338 * want) interrupts not in this mask.
1340 #define AAC_DB_INTERRUPTS (AAC_DB_COMMAND_READY | \
1341 AAC_DB_RESPONSE_READY | \