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