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