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