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