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