xref: /freebsd/sys/dev/aac/aacreg.h (revision 7bd6fde3)
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$
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 
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 } __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  */
96 struct 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  */
130 struct 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  */
139 struct 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 
160 struct aac_fib {
161 	struct aac_fib_header	Header;
162 	u_int8_t			data[AAC_FIB_DATASIZE];
163 } __packed;
164 
165 /*
166  * FIB commands
167  */
168 typedef 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 	RawIo = 			502,
204 
205 	/* Cluster Commands */
206 	ClusterCommand =		550,
207 
208 	/* Scsi Port commands (scsi passthrough) */
209 	ScsiPortCommand =		600,
210 	ScsiPortCommandU64 =		601,
211 	SataPortCommandU64 =		602,
212 	SasSmpPassThrough =		603,
213 	SasRequestPhyInfo =		612,
214 
215 	/* misc house keeping and generic adapter initiated commands */
216 	AifRequest =			700,
217 	CheckRevision =			701,
218 	FsaHostShutdown =		702,
219 	RequestAdapterInfo =		703,
220 	IsAdapterPaused =		704,
221 	SendHostTime =			705,
222 	RequestSupplementAdapterInfo =	706,	/* Supp. Info for set in UCC
223 						 * use only if supported
224 						 * (RequestAdapterInfo first) */
225 	LastMiscCommand =		707,
226 
227 	OnLineDiagnostic =		800,
228 	FduAdapterTest =		801,
229 	RequestCompatibilityId =	802,
230 	AdapterEnvironmentInfo =	803,	/* temp. sensors */
231 	NvsramEventLog =		900,
232 	ResetNvsramEventLogPointers =	901,
233 	EnableEventLog =		902,
234 	DisableEventLog =		903,
235 	EncryptedKeyTransportFIB=	904,
236 	KeyableFeaturesFIB=		905
237 } AAC_FibCommands;
238 
239 /*
240  * FIB types
241  */
242 #define AAC_FIBTYPE_TFIB	1
243 #define AAC_FIBTYPE_TQE		2
244 #define AAC_FIBTYPE_TCTPERF	3
245 
246 /*
247  * FIB transfer state
248  */
249 #define AAC_FIBSTATE_HOSTOWNED		(1<<0)	/* owned by the host */
250 #define AAC_FIBSTATE_ADAPTEROWNED	(1<<1)	/* owned by the adapter */
251 #define AAC_FIBSTATE_INITIALISED	(1<<2)	/* initialised */
252 #define AAC_FIBSTATE_EMPTY		(1<<3)	/* empty */
253 #define AAC_FIBSTATE_FROMPOOL		(1<<4)	/* allocated from pool */
254 #define AAC_FIBSTATE_FROMHOST		(1<<5)	/* sent from the host */
255 #define AAC_FIBSTATE_FROMADAP		(1<<6)	/* sent from the adapter */
256 #define AAC_FIBSTATE_REXPECTED		(1<<7)	/* response is expected */
257 #define AAC_FIBSTATE_RNOTEXPECTED	(1<<8)	/* response is not expected */
258 #define AAC_FIBSTATE_DONEADAP		(1<<9)	/* processed by the adapter */
259 #define AAC_FIBSTATE_DONEHOST		(1<<10)	/* processed by the host */
260 #define AAC_FIBSTATE_HIGH		(1<<11)	/* high priority */
261 #define AAC_FIBSTATE_NORM		(1<<12)	/* normal priority */
262 #define AAC_FIBSTATE_ASYNC		(1<<13)
263 #define AAC_FIBSTATE_ASYNCIO		(1<<13)	/* to be removed */
264 #define AAC_FIBSTATE_PAGEFILEIO		(1<<14)	/* to be removed */
265 #define AAC_FIBSTATE_SHUTDOWN		(1<<15)
266 #define AAC_FIBSTATE_LAZYWRITE		(1<<16)	/* to be removed */
267 #define AAC_FIBSTATE_ADAPMICROFIB	(1<<17)
268 #define AAC_FIBSTATE_BIOSFIB		(1<<18)
269 #define AAC_FIBSTATE_FAST_RESPONSE	(1<<19)	/* fast response capable */
270 #define AAC_FIBSTATE_APIFIB		(1<<20)
271 
272 /*
273  * FIB error values
274  */
275 #define AAC_ERROR_NORMAL			0x00
276 #define AAC_ERROR_PENDING			0x01
277 #define AAC_ERROR_FATAL				0x02
278 #define AAC_ERROR_INVALID_QUEUE			0x03
279 #define AAC_ERROR_NOENTRIES			0x04
280 #define AAC_ERROR_SENDFAILED			0x05
281 #define AAC_ERROR_INVALID_QUEUE_PRIORITY	0x06
282 #define AAC_ERROR_FIB_ALLOCATION_FAILED		0x07
283 #define AAC_ERROR_FIB_DEALLOCATION_FAILED	0x08
284 
285 /*
286  * Adapter Init Structure: this is passed to the adapter with the
287  * AAC_MONKER_INITSTRUCT command to point it at our control structures.
288  */
289 struct aac_adapter_init {
290 	u_int32_t	InitStructRevision;
291 #define AAC_INIT_STRUCT_REVISION		3
292 #define AAC_INIT_STRUCT_REVISION_4		4
293 	u_int32_t	MiniPortRevision;
294 #define AAC_INIT_STRUCT_MINIPORT_REVISION	1
295 	u_int32_t	FilesystemRevision;
296 	u_int32_t	CommHeaderAddress;
297 	u_int32_t	FastIoCommAreaAddress;
298 	u_int32_t	AdapterFibsPhysicalAddress;
299 	u_int32_t 	AdapterFibsVirtualAddress;
300 	u_int32_t	AdapterFibsSize;
301 	u_int32_t	AdapterFibAlign;
302 	u_int32_t	PrintfBufferAddress;
303 	u_int32_t	PrintfBufferSize;
304 #define	AAC_PAGE_SIZE				4096
305 	u_int32_t	HostPhysMemPages;
306 	u_int32_t	HostElapsedSeconds;
307 	/* ADAPTER_INIT_STRUCT_REVISION_4 begins here */
308 	u_int32_t	InitFlags;			/* flags for supported features */
309 #define INITFLAGS_NEW_COMM_SUPPORTED	1
310 	u_int32_t	MaxIoCommands;		/* max outstanding commands */
311 	u_int32_t	MaxIoSize;			/* largest I/O command */
312 	u_int32_t	MaxFibSize;			/* largest FIB to adapter */
313 } __packed;
314 
315 /*
316  * Shared data types
317  */
318 /*
319  * Container types
320  */
321 typedef enum {
322 	CT_NONE = 0,
323 	CT_VOLUME,
324 	CT_MIRROR,
325 	CT_STRIPE,
326 	CT_RAID5,
327 	CT_SSRW,
328 	CT_SSRO,
329 	CT_MORPH,
330 	CT_PASSTHRU,
331 	CT_RAID4,
332 	CT_RAID10,                  /* stripe of mirror */
333 	CT_RAID00,                  /* stripe of stripe */
334 	CT_VOLUME_OF_MIRRORS,       /* volume of mirror */
335 	CT_PSEUDO_RAID3,            /* really raid4 */
336 	CT_RAID50,		    /* stripe of raid5 */
337 	CT_RAID5D,		    /* raid5 distributed hot-sparing */
338 	CT_RAID5D0,
339 	CT_RAID1E,		    /* extended raid1 mirroring */
340 	CT_RAID6,
341 	CT_RAID60,
342 } AAC_FSAVolType;
343 
344 /*
345  * Host-addressable object types
346  */
347 typedef enum {
348 	FT_REG = 1,     /* regular file */
349 	FT_DIR,         /* directory */
350 	FT_BLK,         /* "block" device - reserved */
351 	FT_CHR,         /* "character special" device - reserved */
352 	FT_LNK,         /* symbolic link */
353 	FT_SOCK,        /* socket */
354 	FT_FIFO,        /* fifo */
355 	FT_FILESYS,     /* ADAPTEC's "FSA"(tm) filesystem */
356 	FT_DRIVE,       /* physical disk - addressable in scsi by b/t/l */
357 	FT_SLICE,       /* virtual disk - raw volume - slice */
358 	FT_PARTITION,   /* FSA partition - carved out of a slice - building
359 			 * block for containers */
360 	FT_VOLUME,      /* Container - Volume Set */
361 	FT_STRIPE,      /* Container - Stripe Set */
362 	FT_MIRROR,      /* Container - Mirror Set */
363 	FT_RAID5,       /* Container - Raid 5 Set */
364 	FT_DATABASE     /* Storage object with "foreign" content manager */
365 } AAC_FType;
366 
367 /*
368  * Host-side scatter/gather list for 32-bit commands.
369  */
370 struct aac_sg_entry {
371 	u_int32_t	SgAddress;
372 	u_int32_t	SgByteCount;
373 } __packed;
374 
375 struct aac_sg_entry64 {
376 	u_int64_t	SgAddress;
377 	u_int32_t	SgByteCount;
378 } __packed;
379 
380 struct aac_sg_entryraw {
381 	u_int32_t	Next;		/* reserved for FW use */
382 	u_int32_t	Prev;		/* reserved for FW use */
383 	u_int64_t	SgAddress;
384 	u_int32_t	SgByteCount;
385 	u_int32_t	Flags;		/* reserved for FW use */
386 } __packed;
387 
388 struct aac_sg_table {
389 	u_int32_t		SgCount;
390 	struct aac_sg_entry	SgEntry[0];
391 } __packed;
392 
393 /*
394  * Host-side scatter/gather list for 64-bit commands.
395  */
396 struct aac_sg_table64 {
397 	u_int32_t	SgCount;
398 	struct aac_sg_entry64	SgEntry64[0];
399 } __packed;
400 
401 /*
402  * s/g list for raw commands
403  */
404 struct aac_sg_tableraw {
405 	u_int32_t	SgCount;
406 	struct aac_sg_entryraw	SgEntryRaw[0];
407 } __packed;
408 
409 /*
410  * Container creation data
411  */
412 struct aac_container_creation {
413 	u_int8_t	ViaBuildNumber;
414 	u_int8_t	MicroSecond;
415 	u_int8_t	Via;		/* 1 = FSU, 2 = API, etc. */
416 	u_int8_t	YearsSince1900;
417 	u_int32_t	Month:4;	/* 1-12 */
418 	u_int32_t	Day:6;		/* 1-32 */
419 	u_int32_t	Hour:6;		/* 0-23 */
420 	u_int32_t	Minute:6;	/* 0-59 */
421 	u_int32_t	Second:6;	/* 0-59 */
422 	u_int64_t	ViaAdapterSerialNumber;
423 } __packed;
424 
425 /*
426  * Revision number handling
427  */
428 
429 typedef enum {
430 	RevApplication = 1,
431 	RevDkiCli,
432 	RevNetService,
433 	RevApi,
434 	RevFileSysDriver,
435 	RevMiniportDriver,
436 	RevAdapterSW,
437 	RevMonitor,
438 	RevRemoteApi
439 } RevComponent;
440 
441 struct FsaRevision {
442 	union {
443 		struct {
444 			u_int8_t	dash;
445 			u_int8_t	type;
446 			u_int8_t	minor;
447 			u_int8_t	major;
448 		} comp;
449 		u_int32_t	ul;
450 	} external;
451 	u_int32_t	buildNumber;
452 }  __packed;
453 
454 /*
455  * Adapter Information
456  */
457 
458 typedef enum {
459 	CPU_NTSIM = 1,
460 	CPU_I960,
461 	CPU_ARM,
462 	CPU_SPARC,
463 	CPU_POWERPC,
464 	CPU_ALPHA,
465 	CPU_P7,
466 	CPU_I960_RX,
467 	CPU_MIPS,
468 	CPU_XSCALE,
469 	CPU__last
470 } AAC_CpuType;
471 
472 typedef enum {
473 	CPUI960_JX = 1,
474 	CPUI960_CX,
475 	CPUI960_HX,
476 	CPUI960_RX,
477 	CPUARM_SA110,
478 	CPUARM_xxx,
479 	CPUPPC_603e,
480 	CPUPPC_xxx,
481 	CPUI960_80303,
482 	CPU_XSCALE_80321,
483 	CPU_MIPS_4KC,
484 	CPU_MIPS_5KC,
485 	CPUSUBTYPE__last
486 } AAC_CpuSubType;
487 
488 typedef enum {
489 	PLAT_NTSIM = 1,
490 	PLAT_V3ADU,
491 	PLAT_CYCLONE,
492 	PLAT_CYCLONE_HD,
493 	PLAT_BATBOARD,
494 	PLAT_BATBOARD_HD,
495 	PLAT_YOLO,
496 	PLAT_COBRA,
497 	PLAT_ANAHEIM,
498 	PLAT_JALAPENO,
499 	PLAT_QUEENS,
500 	PLAT_JALAPENO_DELL,
501 	PLAT_POBLANO,
502 	PLAT_POBLANO_OPAL,
503 	PLAT_POBLANO_SL0,
504 	PLAT_POBLANO_SL1,
505 	PLAT_POBLANO_SL2,
506 	PLAT_POBLANO_XXX,
507 	PLAT_JALAPENO_P2,
508 	PLAT_HABANERO,
509 	PLAT_VULCAN,
510 	PLAT_CRUSADER,
511 	PLAT_LANCER,
512 	PLAT_HARRIER,
513 	PLAT_TERMINATOR,
514 	PLAT_SKYHAWK,
515 	PLAT_CORSAIR,
516 	PLAT_JAGUAR,
517 	PLAT_SATAHAWK,
518 	PLAT_SATANATOR,
519 	PLAT_PROWLER,
520 	PLAT_BLACKBIRD,
521 	PLAT_SABREEXPRESS,
522 	PLAT_INTRUDER,
523 	PLAT__last
524 } AAC_Platform;
525 
526 typedef enum {
527 	OEM_FLAVOR_ADAPTEC = 1,
528 	OEM_FLAVOR_DELL,
529 	OEM_FLAVOR_HP,
530 	OEM_FLAVOR_IBM,
531 	OEM_FLAVOR_CPQ,
532 	OEM_FLAVOR_FSC,
533 	OEM_FLAVOR_DWS,
534 	OEM_FLAVOR_BRAND_Z,
535 	OEM_FLAVOR_LEGEND,
536 	OEM_FLAVOR_HITACHI,
537 	OEM_FLAVOR_ESG,
538 	OEM_FLAVOR_ICP,
539 	OEM_FLAVOR_SCM,
540 	OEM_FLAVOR__last
541 } AAC_OemFlavor;
542 
543 /*
544  * XXX the aac-2622 with no battery present reports PLATFORM_BAT_OPT_PRESENT
545  */
546 typedef enum
547 {
548 	PLATFORM_BAT_REQ_PRESENT = 1,	/* BATTERY REQUIRED AND PRESENT */
549 	PLATFORM_BAT_REQ_NOTPRESENT,	/* BATTERY REQUIRED AND NOT PRESENT */
550 	PLATFORM_BAT_OPT_PRESENT,	/* BATTERY OPTIONAL AND PRESENT */
551 	PLATFORM_BAT_OPT_NOTPRESENT,	/* BATTERY OPTIONAL AND NOT PRESENT */
552 	PLATFORM_BAT_NOT_SUPPORTED	/* BATTERY NOT SUPPORTED */
553 } AAC_BatteryPlatform;
554 
555 /*
556  * options supported by this board
557  * there has to be a one to one mapping of these defines and the ones in
558  * fsaapi.h, search for FSA_SUPPORT_SNAPSHOT
559  */
560 #define AAC_SUPPORTED_SNAPSHOT		0x01
561 #define AAC_SUPPORTED_CLUSTERS		0x02
562 #define AAC_SUPPORTED_WRITE_CACHE	0x04
563 #define AAC_SUPPORTED_64BIT_DATA	0x08
564 #define AAC_SUPPORTED_HOST_TIME_FIB	0x10
565 #define AAC_SUPPORTED_RAID50		0x20
566 #define AAC_SUPPORTED_4GB_WINDOW	0x40
567 #define AAC_SUPPORTED_SCSI_UPGRADEABLE	0x80
568 #define AAC_SUPPORTED_SOFT_ERR_REPORT	0x100
569 #define AAC_SUPPORTED_NOT_RECONDITION	0x200
570 #define AAC_SUPPORTED_SGMAP_HOST64	0x400
571 #define AAC_SUPPORTED_ALARM		0x800
572 #define AAC_SUPPORTED_NONDASD		0x1000
573 #define AAC_SUPPORTED_SCSI_MANAGED	0x2000
574 #define AAC_SUPPORTED_RAID_SCSI_MODE	0x4000
575 #define AAC_SUPPORTED_SUPPLEMENT_ADAPTER_INFO	0x10000
576 #define AAC_SUPPORTED_NEW_COMM		0x20000
577 #define AAC_SUPPORTED_64BIT_ARRAYSIZE	0x40000
578 #define AAC_SUPPORTED_HEAT_SENSOR	0x80000
579 
580 /*
581  * Structure used to respond to a RequestAdapterInfo fib.
582  */
583 struct aac_adapter_info {
584 	AAC_Platform		PlatformBase;    /* adapter type */
585 	AAC_CpuType		CpuArchitecture; /* adapter CPU type */
586 	AAC_CpuSubType		CpuVariant;      /* adapter CPU subtype */
587 	u_int32_t		ClockSpeed;      /* adapter CPU clockspeed */
588 	u_int32_t		ExecutionMem;    /* adapter Execution Memory
589 						  * size */
590 	u_int32_t		BufferMem;       /* adapter Data Memory */
591 	u_int32_t		TotalMem;        /* adapter Total Memory */
592 	struct FsaRevision	KernelRevision;  /* adapter Kernel Software
593 						  * Revision */
594 	struct FsaRevision	MonitorRevision; /* adapter Monitor/Diagnostic
595 						  * Software Revision */
596 	struct FsaRevision	HardwareRevision;/* TBD */
597 	struct FsaRevision	BIOSRevision;    /* adapter BIOS Revision */
598 	u_int32_t		ClusteringEnabled;
599 	u_int32_t		ClusterChannelMask;
600 	u_int64_t		SerialNumber;
601 	AAC_BatteryPlatform	batteryPlatform;
602 	u_int32_t		SupportedOptions; /* supported features of this
603 						   * controller */
604 	AAC_OemFlavor	OemVariant;
605 } __packed;
606 
607 /*
608  * Monitor/Kernel interface.
609  */
610 
611 /*
612  * Synchronous commands to the monitor/kernel.
613  */
614 #define AAC_MONKER_BREAKPOINT	0x04
615 #define AAC_MONKER_INITSTRUCT	0x05
616 #define AAC_MONKER_SYNCFIB	0x0c
617 #define AAC_MONKER_GETKERNVER	0x11
618 #define AAC_MONKER_POSTRESULTS	0x14
619 #define AAC_MONKER_GETINFO	0x19
620 #define AAC_MONKER_GETDRVPROP	0x23
621 #define AAC_MONKER_RCVTEMP	0x25
622 #define AAC_MONKER_GETCOMMPREF	0x26
623 #define AAC_MONKER_REINIT	0xee
624 
625 /*
626  *  Adapter Status Register
627  *
628  *  Phase Staus mailbox is 32bits:
629  *  <31:16> = Phase Status
630  *  <15:0>  = Phase
631  *
632  *  The adapter reports its present state through the phase.  Only
633  *  a single phase should be ever be set.  Each phase can have multiple
634  *  phase status bits to provide more detailed information about the
635  *  state of the adapter.
636  */
637 #define AAC_SELF_TEST_FAILED	0x00000004
638 #define AAC_MONITOR_PANIC	0x00000020
639 #define AAC_UP_AND_RUNNING	0x00000080
640 #define AAC_KERNEL_PANIC	0x00000100
641 
642 /*
643  * Data types relating to control and monitoring of the NVRAM/WriteCache
644  * subsystem.
645  */
646 
647 #define AAC_NFILESYS	24	/* maximum number of filesystems */
648 
649 /*
650  * NVRAM/Write Cache subsystem states
651  */
652 typedef enum {
653 	NVSTATUS_DISABLED = 0,	/* present, clean, not being used */
654 	NVSTATUS_ENABLED,	/* present, possibly dirty, ready for use */
655 	NVSTATUS_ERROR,		/* present, dirty, contains dirty data */
656 	NVSTATUS_BATTERY,	/* present, bad or low battery, may contain
657 				 * dirty data */
658 	NVSTATUS_UNKNOWN	/* for bad/missing device */
659 } AAC_NVSTATUS;
660 
661 /*
662  * NVRAM/Write Cache subsystem battery component states
663  *
664  */
665 typedef enum {
666 	NVBATTSTATUS_NONE = 0,	/* battery has no power or is not present */
667 	NVBATTSTATUS_LOW,	/* battery is low on power */
668 	NVBATTSTATUS_OK,	/* battery is okay - normal operation possible
669 				 * only in this state */
670 	NVBATTSTATUS_RECONDITIONING	/* no battery present - reconditioning
671 					 * in process */
672 } AAC_NVBATTSTATUS;
673 
674 /*
675  * Battery transition type
676  */
677 typedef enum {
678 	NVBATT_TRANSITION_NONE = 0,	/* battery now has no power or is not
679 					 * present */
680 	NVBATT_TRANSITION_LOW,		/* battery is now low on power */
681 	NVBATT_TRANSITION_OK		/* battery is now okay - normal
682 					 * operation possible only in this
683 					 * state */
684 } AAC_NVBATT_TRANSITION;
685 
686 /*
687  * NVRAM Info structure returned for NVRAM_GetInfo call
688  */
689 struct aac_nvramdevinfo {
690 	u_int32_t	NV_Enabled;	/* write caching enabled */
691 	u_int32_t	NV_Error;	/* device in error state */
692 	u_int32_t	NV_NDirty;	/* count of dirty NVRAM buffers */
693 	u_int32_t	NV_NActive;	/* count of NVRAM buffers being
694 					 * written */
695 } __packed;
696 
697 struct aac_nvraminfo {
698 	AAC_NVSTATUS		NV_Status;	/* nvram subsystem status */
699 	AAC_NVBATTSTATUS	NV_BattStatus;	/* battery status */
700 	u_int32_t		NV_Size;	/* size of WriteCache NVRAM in
701 						 * bytes */
702 	u_int32_t		NV_BufSize;	/* size of NVRAM buffers in
703 						 * bytes */
704 	u_int32_t		NV_NBufs;	/* number of NVRAM buffers */
705 	u_int32_t		NV_NDirty;	/* Num dirty NVRAM buffers */
706 	u_int32_t		NV_NClean;	/* Num clean NVRAM buffers */
707 	u_int32_t		NV_NActive;	/* Num NVRAM buffers being
708 						 * written */
709 	u_int32_t		NV_NBrokered;	/* Num brokered NVRAM buffers */
710 	struct aac_nvramdevinfo	NV_DevInfo[AAC_NFILESYS];	/* per device
711 								 * info */
712 	u_int32_t		NV_BattNeedsReconditioning;	/* boolean */
713 	u_int32_t		NV_TotalSize;	/* size of all non-volatile
714 						 * memories in bytes */
715 } __packed;
716 
717 /*
718  * Data types relating to adapter-initiated FIBs
719  *
720  * Based on types and structures in <aifstruc.h>
721  */
722 
723 /*
724  * Progress Reports
725  */
726 typedef enum {
727 	AifJobStsSuccess = 1,
728 	AifJobStsFinished,
729 	AifJobStsAborted,
730 	AifJobStsFailed,
731 	AifJobStsLastReportMarker = 100,	/* All prior mean last report */
732 	AifJobStsSuspended,
733 	AifJobStsRunning
734 } AAC_AifJobStatus;
735 
736 typedef enum {
737 	AifJobScsiMin = 1,		/* Minimum value for Scsi operation */
738 	AifJobScsiZero,			/* SCSI device clear operation */
739 	AifJobScsiVerify,		/* SCSI device Verify operation NO
740 					 * REPAIR */
741 	AifJobScsiExercise,		/* SCSI device Exercise operation */
742 	AifJobScsiVerifyRepair,		/* SCSI device Verify operation WITH
743 					 * repair */
744 	AifJobScsiWritePattern,		/* write pattern */
745 	AifJobScsiMax = 99,		/* Max Scsi value */
746 	AifJobCtrMin,			/* Min Ctr op value */
747 	AifJobCtrZero,			/* Container clear operation */
748 	AifJobCtrCopy,			/* Container copy operation */
749 	AifJobCtrCreateMirror,		/* Container Create Mirror operation */
750 	AifJobCtrMergeMirror,		/* Container Merge Mirror operation */
751 	AifJobCtrScrubMirror,		/* Container Scrub Mirror operation */
752 	AifJobCtrRebuildRaid5,		/* Container Rebuild Raid5 operation */
753 	AifJobCtrScrubRaid5,		/* Container Scrub Raid5 operation */
754 	AifJobCtrMorph,			/* Container morph operation */
755 	AifJobCtrPartCopy,		/* Container Partition copy operation */
756 	AifJobCtrRebuildMirror,		/* Container Rebuild Mirror operation */
757 	AifJobCtrCrazyCache,		/* crazy cache */
758 	AifJobCtrCopyback,		/* Container Copyback operation */
759 	AifJobCtrCompactRaid5D,		/* Container Compaction operation */
760 	AifJobCtrExpandRaid5D,		/* Container Expansion operation */
761 	AifJobCtrRebuildRaid6,		/* Container Rebuild Raid6 operation */
762 	AifJobCtrScrubRaid6,		/* Container Scrub Raid6 operation */
763 	AifJobCtrSSBackup,		/* Container snapshot backup task */
764 	AifJobCtrMax = 199,		/* Max Ctr type operation */
765 	AifJobFsMin,			/* Min Fs type operation */
766 	AifJobFsCreate,			/* File System Create operation */
767 	AifJobFsVerify,			/* File System Verify operation */
768 	AifJobFsExtend,			/* File System Extend operation */
769 	AifJobFsMax = 299,		/* Max Fs type operation */
770 	AifJobApiFormatNTFS,		/* Format a drive to NTFS */
771 	AifJobApiFormatFAT,		/* Format a drive to FAT */
772 	AifJobApiUpdateSnapshot,	/* update the read/write half of a
773 					 * snapshot */
774 	AifJobApiFormatFAT32,		/* Format a drive to FAT32 */
775 	AifJobApiMax = 399,		/* Max API type operation */
776 	AifJobCtlContinuousCtrVerify,	/* Adapter operation */
777 	AifJobCtlMax = 499		/* Max Adapter type operation */
778 } AAC_AifJobType;
779 
780 struct aac_AifContainers {
781 	u_int32_t	src;		/* from/master */
782 	u_int32_t	dst;		/* to/slave */
783 } __packed;
784 
785 union aac_AifJobClient {
786 	struct aac_AifContainers	container;	/* For Container and
787 							 * filesystem progress
788 							 * ops; */
789 	int32_t				scsi_dh;	/* For SCSI progress
790 							 * ops */
791 };
792 
793 struct aac_AifJobDesc {
794 	u_int32_t		jobID;		/* DO NOT FILL IN! Will be
795 						 * filled in by AIF */
796 	AAC_AifJobType		type;		/* Operation that is being
797 						 * performed */
798 	union aac_AifJobClient	client;		/* Details */
799 } __packed;
800 
801 struct aac_AifJobProgressReport {
802 	struct aac_AifJobDesc	jd;
803 	AAC_AifJobStatus	status;
804 	u_int32_t		finalTick;
805 	u_int32_t		currentTick;
806 	u_int32_t		jobSpecificData1;
807 	u_int32_t		jobSpecificData2;
808 } __packed;
809 
810 /*
811  * Event Notification
812  */
813 typedef enum {
814 	/* General application notifies start here */
815 	AifEnGeneric = 1,		/* Generic notification */
816 	AifEnTaskComplete,		/* Task has completed */
817 	AifEnConfigChange,		/* Adapter config change occurred */
818 	AifEnContainerChange,		/* Adapter specific container
819 					 * configuration change */
820 	AifEnDeviceFailure,		/* SCSI device failed */
821 	AifEnMirrorFailover,		/* Mirror failover started */
822 	AifEnContainerEvent,		/* Significant container event */
823 	AifEnFileSystemChange,		/* File system changed */
824 	AifEnConfigPause,		/* Container pause event */
825 	AifEnConfigResume,		/* Container resume event */
826 	AifEnFailoverChange,		/* Failover space assignment changed */
827 	AifEnRAID5RebuildDone,		/* RAID5 rebuild finished */
828 	AifEnEnclosureManagement,	/* Enclosure management event */
829 	AifEnBatteryEvent,		/* Significant NV battery event */
830 	AifEnAddContainer,		/* A new container was created. */
831 	AifEnDeleteContainer,		/* A container was deleted. */
832 	AifEnSMARTEvent, 	       	/* SMART Event */
833 	AifEnBatteryNeedsRecond,	/* The battery needs reconditioning */
834 	AifEnClusterEvent,		/* Some cluster event */
835 	AifEnDiskSetEvent,		/* A disk set event occured. */
836 	AifDriverNotifyStart=199,	/* Notifies for host driver go here */
837 	/* Host driver notifications start here */
838 	AifDenMorphComplete, 		/* A morph operation completed */
839 	AifDenVolumeExtendComplete 	/* Volume expand operation completed */
840 } AAC_AifEventNotifyType;
841 
842 struct aac_AifEnsGeneric {
843 	char	text[132];		/* Generic text */
844 } __packed;
845 
846 struct aac_AifEnsDeviceFailure {
847 	u_int32_t	deviceHandle;	/* SCSI device handle */
848 } __packed;
849 
850 struct aac_AifEnsMirrorFailover {
851 	u_int32_t	container;	/* Container with failed element */
852 	u_int32_t	failedSlice;	/* Old slice which failed */
853 	u_int32_t	creatingSlice;	/* New slice used for auto-create */
854 } __packed;
855 
856 struct aac_AifEnsContainerChange {
857 	u_int32_t	container[2];	/* container that changed, -1 if no
858 					 * container */
859 } __packed;
860 
861 struct aac_AifEnsContainerEvent {
862 	u_int32_t	container;	/* container number  */
863 	u_int32_t	eventType;	/* event type */
864 } __packed;
865 
866 struct aac_AifEnsEnclosureEvent {
867 	u_int32_t	empID;		/* enclosure management proc number  */
868 	u_int32_t	unitID;		/* unitId, fan id, power supply id,
869 					 * slot id, tempsensor id.  */
870 	u_int32_t	eventType;	/* event type */
871 } __packed;
872 
873 struct aac_AifEnsBatteryEvent {
874 	AAC_NVBATT_TRANSITION	transition_type;	/* eg from low to ok */
875 	AAC_NVBATTSTATUS	current_state;		/* current batt state */
876 	AAC_NVBATTSTATUS	prior_state;		/* prev batt state */
877 } __packed;
878 
879 struct aac_AifEnsDiskSetEvent {
880 	u_int32_t	eventType;
881 	u_int64_t	DsNum;
882 	u_int64_t	CreatorId;
883 } __packed;
884 
885 typedef enum {
886 	CLUSTER_NULL_EVENT = 0,
887 	CLUSTER_PARTNER_NAME_EVENT,	/* change in partner hostname or
888 					 * adaptername from NULL to non-NULL */
889 	/* (partner's agent may be up) */
890 	CLUSTER_PARTNER_NULL_NAME_EVENT	/* change in partner hostname or
891 					 * adaptername from non-null to NULL */
892 	/* (partner has rebooted) */
893 } AAC_ClusterAifEvent;
894 
895 struct aac_AifEnsClusterEvent {
896 	AAC_ClusterAifEvent	eventType;
897 } __packed;
898 
899 struct aac_AifEventNotify {
900 	AAC_AifEventNotifyType	type;
901 	union {
902 		struct aac_AifEnsGeneric		EG;
903 		struct aac_AifEnsDeviceFailure		EDF;
904 		struct aac_AifEnsMirrorFailover		EMF;
905 		struct aac_AifEnsContainerChange	ECC;
906 		struct aac_AifEnsContainerEvent		ECE;
907 		struct aac_AifEnsEnclosureEvent		EEE;
908 		struct aac_AifEnsBatteryEvent		EBE;
909 		struct aac_AifEnsDiskSetEvent		EDS;
910 /*		struct aac_AifEnsSMARTEvent		ES;*/
911 		struct aac_AifEnsClusterEvent		ECLE;
912 	} data;
913 } __packed;
914 
915 /*
916  * Adapter Initiated FIB command structures. Start with the adapter
917  * initiated FIBs that really come from the adapter, and get responded
918  * to by the host.
919  */
920 #define AAC_AIF_REPORT_MAX_SIZE 64
921 
922 typedef enum {
923 	AifCmdEventNotify = 1,	/* Notify of event */
924 	AifCmdJobProgress,	/* Progress report */
925 	AifCmdAPIReport,	/* Report from other user of API */
926 	AifCmdDriverNotify,	/* Notify host driver of event */
927 	AifReqJobList = 100,	/* Gets back complete job list */
928 	AifReqJobsForCtr,	/* Gets back jobs for specific container */
929 	AifReqJobsForScsi,	/* Gets back jobs for specific SCSI device */
930 	AifReqJobReport,	/* Gets back a specific job report or list */
931 	AifReqTerminateJob,	/* Terminates job */
932 	AifReqSuspendJob,	/* Suspends a job */
933 	AifReqResumeJob,	/* Resumes a job */
934 	AifReqSendAPIReport,	/* API generic report requests */
935 	AifReqAPIJobStart,	/* Start a job from the API */
936 	AifReqAPIJobUpdate,	/* Update a job report from the API */
937 	AifReqAPIJobFinish	/* Finish a job from the API */
938 } AAC_AifCommand;
939 
940 struct aac_aif_command {
941 	AAC_AifCommand	command;	/* Tell host what type of
942 					 * notify this is */
943 	u_int32_t	seqNumber;	/* To allow ordering of
944 					 * reports (if necessary) */
945 	union {
946 		struct aac_AifEventNotify	EN;	/* Event notify */
947 		struct aac_AifJobProgressReport	PR[1];	/* Progress report */
948 		u_int8_t			AR[AAC_AIF_REPORT_MAX_SIZE];
949 		u_int8_t			data[AAC_FIB_DATASIZE - 8];
950 	} data;
951 } __packed;
952 
953 /*
954  * Filesystem commands/data
955  *
956  * The adapter has a very complex filesystem interface, most of which we ignore.
957  * (And which seems not to be implemented, anyway.)
958  */
959 
960 /*
961  * FSA commands
962  * (not used?)
963  */
964 typedef enum {
965 	Null = 0,
966 	GetAttributes,
967 	SetAttributes,
968 	Lookup,
969 	ReadLink,
970 	Read,
971 	Write,
972 	Create,
973 	MakeDirectory,
974 	SymbolicLink,
975 	MakeNode,
976 	Removex,
977 	RemoveDirectory,
978 	Rename,
979 	Link,
980 	ReadDirectory,
981 	ReadDirectoryPlus,
982 	FileSystemStatus,
983 	FileSystemInfo,
984 	PathConfigure,
985 	Commit,
986 	Mount,
987 	UnMount,
988 	Newfs,
989 	FsCheck,
990 	FsSync,
991 	SimReadWrite,
992 	SetFileSystemStatus,
993 	BlockRead,
994 	BlockWrite,
995 	NvramIoctl,
996 	FsSyncWait,
997 	ClearArchiveBit,
998 	SetAcl,
999 	GetAcl,
1000 	AssignAcl,
1001 	FaultInsertion,
1002 	CrazyCache
1003 } AAC_FSACommand;
1004 
1005 /*
1006  * Command status values
1007  */
1008 typedef enum {
1009 	ST_OK = 0,
1010 	ST_PERM = 1,
1011 	ST_NOENT = 2,
1012 	ST_IO = 5,
1013 	ST_NXIO = 6,
1014 	ST_E2BIG = 7,
1015 	ST_ACCES = 13,
1016 	ST_EXIST = 17,
1017 	ST_XDEV = 18,
1018 	ST_NODEV = 19,
1019 	ST_NOTDIR = 20,
1020 	ST_ISDIR = 21,
1021 	ST_INVAL = 22,
1022 	ST_FBIG = 27,
1023 	ST_NOSPC = 28,
1024 	ST_ROFS = 30,
1025 	ST_MLINK = 31,
1026 	ST_WOULDBLOCK = 35,
1027 	ST_NAMETOOLONG = 63,
1028 	ST_NOTEMPTY = 66,
1029 	ST_DQUOT = 69,
1030 	ST_STALE = 70,
1031 	ST_REMOTE = 71,
1032 	ST_BADHANDLE = 10001,
1033 	ST_NOT_SYNC = 10002,
1034 	ST_BAD_COOKIE = 10003,
1035 	ST_NOTSUPP = 10004,
1036 	ST_TOOSMALL = 10005,
1037 	ST_SERVERFAULT = 10006,
1038 	ST_BADTYPE = 10007,
1039 	ST_JUKEBOX = 10008,
1040 	ST_NOTMOUNTED = 10009,
1041 	ST_MAINTMODE = 10010,
1042 	ST_STALEACL = 10011
1043 } AAC_FSAStatus;
1044 
1045 /*
1046  * Volume manager commands
1047  */
1048 typedef enum _VM_COMMANDS {
1049 	VM_Null = 0,
1050 	VM_NameServe,
1051 	VM_ContainerConfig,
1052 	VM_Ioctl,
1053 	VM_FilesystemIoctl,
1054 	VM_CloseAll,
1055 	VM_CtBlockRead,
1056 	VM_CtBlockWrite,
1057 	VM_SliceBlockRead,	 /* raw access to configured storage objects */
1058 	VM_SliceBlockWrite,
1059 	VM_DriveBlockRead,	 /* raw access to physical devices */
1060 	VM_DriveBlockWrite,
1061 	VM_EnclosureMgt,	 /* enclosure management */
1062 	VM_Unused,		 /* used to be diskset management */
1063 	VM_CtBlockVerify,
1064 	VM_CtPerf,		 /* performance test */
1065 	VM_CtBlockRead64,
1066 	VM_CtBlockWrite64,
1067 	VM_CtBlockVerify64,
1068 	VM_CtHostRead64,
1069 	VM_CtHostWrite64,
1070 	VM_DrvErrTblLog,	/* drive error table/log type of command */
1071 	VM_NameServe64
1072 } AAC_VMCommand;
1073 
1074 /*
1075  * "mountable object"
1076  */
1077 struct aac_mntobj {
1078 	u_int32_t			ObjectId;
1079 	char				FileSystemName[16];
1080 	struct aac_container_creation	CreateInfo;
1081 	u_int32_t			Capacity;
1082 	u_int32_t			VolType;
1083 	u_int32_t			ObjType;
1084 	u_int32_t			ContentState;
1085 #define FSCS_READONLY		0x0002		/* XXX need more information
1086 						 * than this */
1087 	union {
1088 		u_int32_t	pad[8];
1089 	} ObjExtension;
1090 	u_int32_t			AlterEgoId;
1091 } __packed;
1092 
1093 struct aac_mntinfo {
1094 	u_int32_t		Command;
1095 	u_int32_t		MntType;
1096 	u_int32_t		MntCount;
1097 } __packed;
1098 
1099 struct aac_mntinforesp {
1100 	u_int32_t		Status;
1101 	u_int32_t		MntType;
1102 	u_int32_t		MntRespCount;
1103 	struct aac_mntobj	MntTable[1];
1104 } __packed;
1105 
1106 /*
1107  * Container shutdown command.
1108  */
1109 struct aac_closecommand {
1110 	u_int32_t	Command;
1111 	u_int32_t	ContainerId;
1112 } __packed;
1113 
1114 /*
1115  * Container Config Command
1116  */
1117 #define CT_GET_SCSI_METHOD	64
1118 struct aac_ctcfg {
1119 	u_int32_t		Command;
1120 	u_int32_t		cmd;
1121 	u_int32_t		param;
1122 } __packed;
1123 
1124 struct aac_ctcfg_resp {
1125 	u_int32_t		Status;
1126 	u_int32_t		resp;
1127 	u_int32_t		param;
1128 } __packed;
1129 
1130 /*
1131  * 'Ioctl' commads
1132  */
1133 #define AAC_SCSI_MAX_PORTS	10
1134 #define AAC_BUS_NO_EXIST	0
1135 #define AAC_BUS_VALID		1
1136 #define AAC_BUS_FAULTED		2
1137 #define AAC_BUS_DISABLED	3
1138 #define GetBusInfo		0x9
1139 
1140 struct aac_getbusinf {
1141 	u_int32_t		ProbeComplete;
1142 	u_int32_t		BusCount;
1143 	u_int32_t		TargetsPerBus;
1144 	u_int8_t		InitiatorBusId[AAC_SCSI_MAX_PORTS];
1145 	u_int8_t		BusValid[AAC_SCSI_MAX_PORTS];
1146 } __packed;
1147 
1148 struct aac_vmioctl {
1149 	u_int32_t		Command;
1150 	u_int32_t		ObjType;
1151 	u_int32_t		MethId;
1152 	u_int32_t		ObjId;
1153 	u_int32_t		IoctlCmd;
1154 	u_int32_t		IoctlBuf[1];	/* Placeholder? */
1155 } __packed;
1156 
1157 struct aac_vmi_businf_resp {
1158 	u_int32_t		Status;
1159 	u_int32_t		ObjType;
1160 	u_int32_t		MethId;
1161 	u_int32_t		ObjId;
1162 	u_int32_t		IoctlCmd;
1163 	struct aac_getbusinf	BusInf;
1164 } __packed;
1165 
1166 #if 0
1167 #define AAC_BTL_TO_HANDLE(b, t, l) \
1168     (((b & 0x3f) << 7) | ((l & 0x7) << 4) | (t & 0xf))
1169 #else
1170 #define AAC_BTL_TO_HANDLE(b, t, l) \
1171     ((((u_int32_t)b & 0x0f) << 24) | \
1172      (((u_int32_t)l & 0xff) << 16) | \
1173      ((u_int32_t)t & 0xffff))
1174 #endif
1175 #define GetDeviceProbeInfo 0x5
1176 
1177 struct aac_vmi_devinfo_resp {
1178 	u_int32_t		Status;
1179 	u_int32_t		ObjType;
1180 	u_int32_t		MethId;
1181 	u_int32_t		ObjId;
1182 	u_int32_t		IoctlCmd;
1183 	u_int8_t		VendorId[8];
1184 	u_int8_t		ProductId[16];
1185 	u_int8_t		ProductRev[4];
1186 	u_int32_t		Inquiry7;
1187 	u_int32_t		align1;
1188 	u_int32_t		Inquiry0;
1189 	u_int32_t		align2;
1190 	u_int32_t		Inquiry1;
1191 	u_int32_t		align3;
1192 	u_int32_t		reserved[2];
1193 	u_int8_t		VendorSpecific[20];
1194 	u_int32_t		Smart:1;
1195 	u_int32_t		AAC_Managed:1;
1196 	u_int32_t		align4;
1197 	u_int32_t		reserved2:6;
1198 	u_int32_t		Bus;
1199 	u_int32_t		Target;
1200 	u_int32_t		Lun;
1201 	u_int32_t		ultraEnable:1,
1202 				disconnectEnable:1,
1203 				fast20EnabledW:1,
1204 				scamDevice:1,
1205 				scamTolerant:1,
1206 				setForSync:1,
1207 				setForWide:1,
1208 				syncDevice:1,
1209 				wideDevice:1,
1210 				reserved1:7,
1211 				ScsiRate:8,
1212 				ScsiOffset:8;
1213 }; /* Do not pack */
1214 
1215 #define ResetBus 0x16
1216 struct aac_resetbus {
1217 	u_int32_t		BusNumber;
1218 };
1219 
1220 /*
1221  * Write 'stability' options.
1222  */
1223 typedef enum {
1224 	CSTABLE = 1,
1225 	CUNSTABLE
1226 } AAC_CacheLevel;
1227 
1228 /*
1229  * Commit level response for a write request.
1230  */
1231 typedef enum {
1232 	CMFILE_SYNC_NVRAM = 1,
1233 	CMDATA_SYNC_NVRAM,
1234 	CMFILE_SYNC,
1235 	CMDATA_SYNC,
1236 	CMUNSTABLE
1237 } AAC_CommitLevel;
1238 
1239 /*
1240  * Block read/write operations.
1241  * These structures are packed into the 'data' area in the FIB.
1242  */
1243 
1244 struct aac_blockread {
1245 	u_int32_t		Command;	/* not FSACommand! */
1246 	u_int32_t		ContainerId;
1247 	u_int32_t		BlockNumber;
1248 	u_int32_t		ByteCount;
1249 	struct aac_sg_table	SgMap;		/* variable size */
1250 } __packed;
1251 
1252 struct aac_blockread64 {
1253 	u_int32_t		Command;
1254 	u_int16_t		ContainerId;
1255 	u_int16_t		SectorCount;
1256 	u_int32_t		BlockNumber;
1257 	u_int16_t		Pad;
1258 	u_int16_t		Flags;
1259 	struct aac_sg_table64	SgMap64;
1260 } __packed;
1261 
1262 struct aac_blockread_response {
1263 	u_int32_t		Status;
1264 	u_int32_t		ByteCount;
1265 } __packed;
1266 
1267 struct aac_blockwrite {
1268 	u_int32_t		Command;	/* not FSACommand! */
1269 	u_int32_t		ContainerId;
1270 	u_int32_t		BlockNumber;
1271 	u_int32_t		ByteCount;
1272 	u_int32_t		Stable;
1273 	struct aac_sg_table	SgMap;		/* variable size */
1274 } __packed;
1275 
1276 struct aac_blockwrite64 {
1277 	u_int32_t		Command;	/* not FSACommand! */
1278 	u_int16_t		ContainerId;
1279 	u_int16_t		SectorCount;
1280 	u_int32_t		BlockNumber;
1281 	u_int16_t		Pad;
1282 	u_int16_t		Flags;
1283 	struct aac_sg_table64	SgMap64;	/* variable size */
1284 } __packed;
1285 
1286 struct aac_blockwrite_response {
1287 	u_int32_t		Status;
1288 	u_int32_t		ByteCount;
1289 	u_int32_t		Committed;
1290 } __packed;
1291 
1292 struct aac_raw_io {
1293 	u_int64_t		BlockNumber;
1294 	u_int32_t		ByteCount;
1295 	u_int16_t		ContainerId;
1296 	u_int16_t		Flags;				/* 0: W, 1: R */
1297 	u_int16_t		BpTotal;			/* reserved for FW use */
1298 	u_int16_t		BpComplete;			/* reserved for FW use */
1299 	struct aac_sg_tableraw	SgMapRaw;	/* variable size */
1300 } __packed;
1301 
1302 /*
1303  * Container shutdown command.
1304  */
1305 struct aac_close_command {
1306 	u_int32_t		Command;
1307 	u_int32_t		ContainerId;
1308 };
1309 
1310 /*
1311  * SCSI Passthrough structures
1312  */
1313 struct aac_srb32 {
1314 	u_int32_t		function;
1315 	u_int32_t		bus;
1316 	u_int32_t		target;
1317 	u_int32_t		lun;
1318 	u_int32_t		timeout;
1319 	u_int32_t		flags;
1320 	u_int32_t		data_len;
1321 	u_int32_t		retry_limit;
1322 	u_int32_t		cdb_len;
1323 	u_int8_t		cdb[16];
1324 	struct aac_sg_table	sg_map32;
1325 };
1326 
1327 enum {
1328 	AAC_SRB_FUNC_EXECUTE_SCSI	= 0x00,
1329 	AAC_SRB_FUNC_CLAIM_DEVICE,
1330 	AAC_SRB_FUNC_IO_CONTROL,
1331 	AAC_SRB_FUNC_RECEIVE_EVENT,
1332 	AAC_SRB_FUNC_RELEASE_QUEUE,
1333 	AAC_SRB_FUNC_ATTACH_DEVICE,
1334 	AAC_SRB_FUNC_RELEASE_DEVICE,
1335 	AAC_SRB_FUNC_SHUTDOWN,
1336 	AAC_SRB_FUNC_FLUSH,
1337 	AAC_SRB_FUNC_ABORT_COMMAND	= 0x10,
1338 	AAC_SRB_FUNC_RELEASE_RECOVERY,
1339 	AAC_SRB_FUNC_RESET_BUS,
1340 	AAC_SRB_FUNC_RESET_DEVICE,
1341 	AAC_SRB_FUNC_TERMINATE_IO,
1342 	AAC_SRB_FUNC_FLUSH_QUEUE,
1343 	AAC_SRB_FUNC_REMOVE_DEVICE,
1344 	AAC_SRB_FUNC_DOMAIN_VALIDATION
1345 };
1346 
1347 #define AAC_SRB_FLAGS_NO_DATA_XFER		0x0000
1348 #define	AAC_SRB_FLAGS_DISABLE_DISCONNECT	0x0004
1349 #define	AAC_SRB_FLAGS_DISABLE_SYNC_TRANSFER	0x0008
1350 #define AAC_SRB_FLAGS_BYPASS_FROZEN_QUEUE	0x0010
1351 #define	AAC_SRB_FLAGS_DISABLE_AUTOSENSE		0x0020
1352 #define	AAC_SRB_FLAGS_DATA_IN			0x0040
1353 #define AAC_SRB_FLAGS_DATA_OUT			0x0080
1354 #define	AAC_SRB_FLAGS_UNSPECIFIED_DIRECTION \
1355 			(AAC_SRB_FLAGS_DATA_IN | AAC_SRB_FLAGS_DATA_OUT)
1356 
1357 #define AAC_HOST_SENSE_DATA_MAX			30
1358 
1359 struct aac_srb_response {
1360 	u_int32_t	fib_status;
1361 	u_int32_t	srb_status;
1362 	u_int32_t	scsi_status;
1363 	u_int32_t	data_len;
1364 	u_int32_t	sense_len;
1365 	u_int8_t	sense[AAC_HOST_SENSE_DATA_MAX];
1366 };
1367 
1368 /*
1369  * Status codes for SCSI passthrough commands.  Since they are based on ASPI,
1370  * they also exactly match CAM status codes in both enumeration and meaning.
1371  * They seem to also be used as status codes for synchronous FIBs.
1372  */
1373 enum {
1374 	AAC_SRB_STS_PENDING			= 0x00,
1375 	AAC_SRB_STS_SUCCESS,
1376 	AAC_SRB_STS_ABORTED,
1377 	AAC_SRB_STS_ABORT_FAILED,
1378 	AAC_SRB_STS_ERROR,
1379 	AAC_SRB_STS_BUSY,
1380 	AAC_SRB_STS_INVALID_REQUEST,
1381 	AAC_SRB_STS_INVALID_PATH_ID,
1382 	AAC_SRB_STS_NO_DEVICE,
1383 	AAC_SRB_STS_TIMEOUT,
1384 	AAC_SRB_STS_SELECTION_TIMEOUT,
1385 	AAC_SRB_STS_COMMAND_TIMEOUT,
1386 	AAC_SRB_STS_MESSAGE_REJECTED		= 0x0D,
1387 	AAC_SRB_STS_BUS_RESET,
1388 	AAC_SRB_STS_PARITY_ERROR,
1389 	AAC_SRB_STS_REQUEST_SENSE_FAILED,
1390 	AAC_SRB_STS_NO_HBA,
1391 	AAC_SRB_STS_DATA_OVERRUN,
1392 	AAC_SRB_STS_UNEXPECTED_BUS_FREE,
1393 	AAC_SRB_STS_PHASE_SEQUENCE_FAILURE,
1394 	AAC_SRB_STS_BAD_SRB_BLOCK_LENGTH,
1395 	AAC_SRB_STS_REQUEST_FLUSHED,
1396 	AAC_SRB_STS_INVALID_LUN			= 0x20,
1397 	AAC_SRB_STS_INVALID_TARGET_ID,
1398 	AAC_SRB_STS_BAD_FUNCTION,
1399 	AAC_SRB_STS_ERROR_RECOVERY
1400 };
1401 
1402 /*
1403  * Register set for adapters based on the Falcon bridge and PPC core
1404  */
1405 
1406 #define AAC_FA_DOORBELL0_CLEAR		0x00
1407 #define AAC_FA_DOORBELL1_CLEAR		0x02
1408 #define AAC_FA_DOORBELL0		0x04
1409 #define AAC_FA_DOORBELL1		0x06
1410 #define AAC_FA_MASK0_CLEAR		0x08
1411 #define AAC_FA_MASK1_CLEAR		0x0a
1412 #define	AAC_FA_MASK0			0x0c
1413 #define AAC_FA_MASK1			0x0e
1414 #define AAC_FA_MAILBOX			0x10
1415 #define	AAC_FA_FWSTATUS			0x2c	/* Mailbox 7 */
1416 #define	AAC_FA_INTSRC			0x900
1417 
1418 #define AAC_FA_HACK(sc)	(void)AAC_GETREG4(sc, AAC_FA_INTSRC)
1419 
1420 /*
1421  * Register definitions for the Adaptec AAC-364 'Jalapeno I/II' adapters, based
1422  * on the SA110 'StrongArm'.
1423  */
1424 
1425 #define AAC_SA_DOORBELL0_CLEAR		0x98	/* doorbell 0 (adapter->host) */
1426 #define AAC_SA_DOORBELL0_SET		0x9c
1427 #define AAC_SA_DOORBELL0		0x9c
1428 #define AAC_SA_MASK0_CLEAR		0xa0
1429 #define AAC_SA_MASK0_SET		0xa4
1430 
1431 #define AAC_SA_DOORBELL1_CLEAR		0x9a	/* doorbell 1 (host->adapter) */
1432 #define AAC_SA_DOORBELL1_SET		0x9e
1433 #define AAC_SA_DOORBELL1		0x9e
1434 #define AAC_SA_MASK1_CLEAR		0xa2
1435 #define AAC_SA_MASK1_SET		0xa6
1436 
1437 #define AAC_SA_MAILBOX			0xa8	/* mailbox (20 bytes) */
1438 #define AAC_SA_FWSTATUS			0xc4
1439 
1440 /*
1441  * Register definitions for the Adaptec 'Pablano' adapters, based on the i960Rx,
1442  * and other related adapters.
1443  */
1444 
1445 #define AAC_RX_IDBR		0x20	/* inbound doorbell register */
1446 #define AAC_RX_IISR		0x24	/* inbound interrupt status register */
1447 #define AAC_RX_IIMR		0x28	/* inbound interrupt mask register */
1448 #define AAC_RX_ODBR		0x2c	/* outbound doorbell register */
1449 #define AAC_RX_OISR		0x30	/* outbound interrupt status register */
1450 #define AAC_RX_OIMR		0x34	/* outbound interrupt mask register */
1451 #define AAC_RX_IQUE		0x40	/* inbound queue */
1452 #define AAC_RX_OQUE		0x44	/* outbound queue */
1453 
1454 #define AAC_RX_MAILBOX		0x50	/* mailbox (20 bytes) */
1455 #define AAC_RX_FWSTATUS		0x6c
1456 
1457 /*
1458  * Register definitions for the Adaptec 'Rocket' RAID-On-Chip adapters.
1459  * Unsurprisingly, it's quite similar to the i960!
1460  */
1461 
1462 #define AAC_RKT_IDBR		0x20	/* inbound doorbell register */
1463 #define AAC_RKT_IISR		0x24	/* inbound interrupt status register */
1464 #define AAC_RKT_IIMR		0x28	/* inbound interrupt mask register */
1465 #define AAC_RKT_ODBR		0x2c	/* outbound doorbell register */
1466 #define AAC_RKT_OISR		0x30	/* outbound interrupt status register */
1467 #define AAC_RKT_OIMR		0x34	/* outbound interrupt mask register */
1468 #define AAC_RKT_IQUE		0x40	/* inbound queue */
1469 #define AAC_RKT_OQUE		0x44	/* outbound queue */
1470 
1471 #define AAC_RKT_MAILBOX		0x1000	/* mailbox */
1472 #define AAC_RKT_FWSTATUS	0x101c	/* Firmware Status (mailbox 7) */
1473 
1474 /*
1475  * Common bit definitions for the doorbell registers.
1476  */
1477 
1478 /*
1479  * Status bits in the doorbell registers.
1480  */
1481 #define AAC_DB_SYNC_COMMAND	(1<<0)	/* send/completed synchronous FIB */
1482 #define AAC_DB_COMMAND_READY	(1<<1)	/* posted one or more commands */
1483 #define AAC_DB_RESPONSE_READY	(1<<2)	/* one or more commands complete */
1484 #define AAC_DB_COMMAND_NOT_FULL	(1<<3)	/* command queue not full */
1485 #define AAC_DB_RESPONSE_NOT_FULL (1<<4)	/* response queue not full */
1486 
1487 /*
1488  * The adapter can request the host print a message by setting the
1489  * DB_PRINTF flag in DOORBELL0.  The driver responds by collecting the
1490  * message from the printf buffer, clearing the DB_PRINTF flag in
1491  * DOORBELL0 and setting it in DOORBELL1.
1492  * (ODBR and IDBR respectively for the i960Rx adapters)
1493  */
1494 #define AAC_DB_PRINTF		(1<<5)	/* adapter requests host printf */
1495 #define AAC_PRINTF_DONE		(1<<5)	/* Host completed printf processing */
1496 
1497 /*
1498  * Mask containing the interrupt bits we care about.  We don't anticipate (or
1499  * want) interrupts not in this mask.
1500  */
1501 #define AAC_DB_INTERRUPTS	(AAC_DB_COMMAND_READY  |	\
1502 				 AAC_DB_RESPONSE_READY |	\
1503 				 AAC_DB_PRINTF)
1504 #define AAC_DB_INT_NEW_COMM		0x08
1505 
1506