1250963Sachim/*-
2250963Sachim * Copyright (c) 2000 Michael Smith
3250963Sachim * Copyright (c) 2000-2001 Scott Long
4250963Sachim * Copyright (c) 2000 BSDi
5250963Sachim * Copyright (c) 2001-2010 Adaptec, Inc.
6250963Sachim * Copyright (c) 2010-2012 PMC-Sierra, Inc.
7250963Sachim * All rights reserved.
8250963Sachim *
9250963Sachim * Redistribution and use in source and binary forms, with or without
10250963Sachim * modification, are permitted provided that the following conditions
11250963Sachim * are met:
12250963Sachim * 1. Redistributions of source code must retain the above copyright
13250963Sachim *    notice, this list of conditions and the following disclaimer.
14250963Sachim * 2. Redistributions in binary form must reproduce the above copyright
15250963Sachim *    notice, this list of conditions and the following disclaimer in the
16250963Sachim *    documentation and/or other materials provided with the distribution.
17250963Sachim *
18250963Sachim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19250963Sachim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20250963Sachim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21250963Sachim * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22250963Sachim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23250963Sachim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24250963Sachim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25250963Sachim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26250963Sachim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27250963Sachim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28250963Sachim * SUCH DAMAGE.
29250963Sachim *
30250963Sachim *	$FreeBSD$
31250963Sachim */
32250963Sachim
33250963Sachim/*
34250963Sachim * Data structures defining the interface between the driver and the Adaptec
35250963Sachim * 'FSA' adapters.  Note that many field names and comments here are taken
36250963Sachim * verbatim from the Adaptec driver source in order to make comparing the
37250963Sachim * two slightly easier.
38250963Sachim */
39250963Sachim
40250963Sachim/*
41250963Sachim * Misc. magic numbers.
42250963Sachim */
43250963Sachim#define AAC_MAX_CONTAINERS	64
44250963Sachim#define AAC_BLOCK_SIZE		512
45250963Sachim
46250963Sachim/*
47250963Sachim * Communications interface.
48250963Sachim *
49250963Sachim * Where datastructure layouts are closely parallel to the Adaptec sample code,
50250963Sachim * retain their naming conventions (for now) to aid in cross-referencing.
51250963Sachim */
52250963Sachim
53250963Sachim/* transport FIB header (PMC) */
54250963Sachimstruct aac_fib_xporthdr {
55250963Sachim	u_int64_t	HostAddress;	/* FIB host address w/o xport header */
56250963Sachim	u_int32_t	Size;			/* FIB size excluding xport header */
57250963Sachim	u_int32_t	Handle;			/* driver handle to reference the FIB */
58250963Sachim	u_int64_t	Reserved[2];
59250963Sachim} __packed;
60250963Sachim
61250963Sachim/*
62250963Sachim * List structure used to chain FIBs (used by the adapter - we hang FIBs off
63250963Sachim * our private command structure and don't touch these)
64250963Sachim */
65250963Sachimstruct aac_fib_list_entry {
66250963Sachim	u_int32_t	Flink;
67250963Sachim	u_int32_t	Blink;
68250963Sachim} __packed;
69250963Sachim
70250963Sachim/*
71250963Sachim * FIB (FSA Interface Block?); this is the datastructure passed between the host
72250963Sachim * and adapter.
73250963Sachim */
74250963Sachimstruct aac_fib_header {
75250963Sachim	u_int32_t		XferState;
76250963Sachim	u_int16_t		Command;
77250963Sachim	u_int8_t		StructType;
78250963Sachim	u_int8_t		Unused;
79250963Sachim	u_int16_t		Size;
80250963Sachim	u_int16_t		SenderSize;
81250963Sachim	u_int32_t		SenderFibAddress;
82250963Sachim	union {
83250963Sachim		u_int32_t	ReceiverFibAddress;
84250963Sachim		u_int32_t	SenderFibAddressHigh;
85250963Sachim		u_int32_t	TimeStamp;
86250963Sachim	} u;
87250963Sachim	u_int32_t		Handle;
88250963Sachim	u_int32_t		Previous;
89250963Sachim	u_int32_t		Next;
90250963Sachim} __packed;
91250963Sachim
92250963Sachim#define AAC_FIB_DATASIZE	(512 - sizeof(struct aac_fib_header))
93250963Sachim
94250963Sachimstruct aac_fib {
95250963Sachim	struct aac_fib_header	Header;
96250963Sachim	u_int8_t	data[AAC_FIB_DATASIZE];
97250963Sachim} __packed;
98250963Sachim
99250963Sachim/*
100250963Sachim * FIB commands
101250963Sachim */
102250963Sachimtypedef enum {
103250963Sachim	TestCommandResponse =		1,
104250963Sachim	TestAdapterCommand =		2,
105250963Sachim
106250963Sachim	/* lowlevel and comm commands */
107250963Sachim	LastTestCommand =		100,
108250963Sachim	ReinitHostNormCommandQueue =	101,
109250963Sachim	ReinitHostHighCommandQueue =	102,
110250963Sachim	ReinitHostHighRespQueue =	103,
111250963Sachim	ReinitHostNormRespQueue =	104,
112250963Sachim	ReinitAdapNormCommandQueue =	105,
113250963Sachim	ReinitAdapHighCommandQueue =	107,
114250963Sachim	ReinitAdapHighRespQueue =	108,
115250963Sachim	ReinitAdapNormRespQueue =	109,
116250963Sachim	InterfaceShutdown =		110,
117250963Sachim	DmaCommandFib =			120,
118250963Sachim	StartProfile =			121,
119250963Sachim	TermProfile =			122,
120250963Sachim	SpeedTest =			123,
121250963Sachim	TakeABreakPt =			124,
122250963Sachim	RequestPerfData =		125,
123250963Sachim	SetInterruptDefTimer=		126,
124250963Sachim	SetInterruptDefCount=		127,
125250963Sachim	GetInterruptDefStatus=		128,
126250963Sachim	LastCommCommand =		129,
127250963Sachim
128250963Sachim	/* filesystem commands */
129250963Sachim	NuFileSystem =			300,
130250963Sachim	UFS =				301,
131250963Sachim	HostFileSystem =		302,
132250963Sachim	LastFileSystemCommand =		303,
133250963Sachim
134250963Sachim	/* Container Commands */
135250963Sachim	ContainerCommand =		500,
136250963Sachim	ContainerCommand64 =		501,
137250963Sachim	RawIo = 			502,
138250963Sachim	RawIo2 = 			503,
139250963Sachim
140250963Sachim	/* Cluster Commands */
141250963Sachim	ClusterCommand =		550,
142250963Sachim
143250963Sachim	/* Scsi Port commands (scsi passthrough) */
144250963Sachim	ScsiPortCommand =		600,
145250963Sachim	ScsiPortCommandU64 =		601,
146250963Sachim	SataPortCommandU64 =		602,
147250963Sachim	SasSmpPassThrough =		603,
148250963Sachim	SasRequestPhyInfo =		612,
149250963Sachim
150250963Sachim	/* misc house keeping and generic adapter initiated commands */
151250963Sachim	AifRequest =			700,
152250963Sachim	CheckRevision =			701,
153250963Sachim	FsaHostShutdown =		702,
154250963Sachim	RequestAdapterInfo =		703,
155250963Sachim	IsAdapterPaused =		704,
156250963Sachim	SendHostTime =			705,
157250963Sachim	RequestSupplementAdapterInfo =	706,	/* Supp. Info for set in UCC
158250963Sachim						 * use only if supported
159250963Sachim						 * (RequestAdapterInfo first) */
160250963Sachim	LastMiscCommand =		707,
161250963Sachim
162250963Sachim	OnLineDiagnostic =		800,
163250963Sachim	FduAdapterTest =		801,
164250963Sachim	RequestCompatibilityId =	802,
165250963Sachim	AdapterEnvironmentInfo =	803,	/* temp. sensors */
166250963Sachim	NvsramEventLog =		900,
167250963Sachim	ResetNvsramEventLogPointers =	901,
168250963Sachim	EnableEventLog =		902,
169250963Sachim	DisableEventLog =		903,
170250963Sachim	EncryptedKeyTransportFIB=	904,
171250963Sachim	KeyableFeaturesFIB=		905
172250963Sachim} AAC_FibCommands;
173250963Sachim
174250963Sachim/*
175250963Sachim * FIB types
176250963Sachim */
177250963Sachim#define AAC_FIBTYPE_TFIB		1
178250963Sachim#define AAC_FIBTYPE_TQE			2
179250963Sachim#define AAC_FIBTYPE_TCTPERF		3
180250963Sachim#define AAC_FIBTYPE_TFIB2		4
181250963Sachim#define AAC_FIBTYPE_TFIB2_64	5
182250963Sachim
183250963Sachim/*
184250963Sachim * FIB transfer state
185250963Sachim */
186250963Sachim#define AAC_FIBSTATE_HOSTOWNED		(1<<0)	/* owned by the host */
187250963Sachim#define AAC_FIBSTATE_ADAPTEROWNED	(1<<1)	/* owned by the adapter */
188250963Sachim#define AAC_FIBSTATE_INITIALISED	(1<<2)	/* initialised */
189250963Sachim#define AAC_FIBSTATE_EMPTY		(1<<3)	/* empty */
190250963Sachim#define AAC_FIBSTATE_FROMPOOL		(1<<4)	/* allocated from pool */
191250963Sachim#define AAC_FIBSTATE_FROMHOST		(1<<5)	/* sent from the host */
192250963Sachim#define AAC_FIBSTATE_FROMADAP		(1<<6)	/* sent from the adapter */
193250963Sachim#define AAC_FIBSTATE_REXPECTED		(1<<7)	/* response is expected */
194250963Sachim#define AAC_FIBSTATE_RNOTEXPECTED	(1<<8)	/* response is not expected */
195250963Sachim#define AAC_FIBSTATE_DONEADAP		(1<<9)	/* processed by the adapter */
196250963Sachim#define AAC_FIBSTATE_DONEHOST		(1<<10)	/* processed by the host */
197250963Sachim#define AAC_FIBSTATE_HIGH		(1<<11)	/* high priority */
198250963Sachim#define AAC_FIBSTATE_NORM		(1<<12)	/* normal priority */
199250963Sachim#define AAC_FIBSTATE_ASYNC		(1<<13)
200250963Sachim#define AAC_FIBSTATE_ASYNCIO		(1<<13)	/* to be removed */
201250963Sachim#define AAC_FIBSTATE_PAGEFILEIO		(1<<14)	/* to be removed */
202250963Sachim#define AAC_FIBSTATE_SHUTDOWN		(1<<15)
203250963Sachim#define AAC_FIBSTATE_LAZYWRITE		(1<<16)	/* to be removed */
204250963Sachim#define AAC_FIBSTATE_ADAPMICROFIB	(1<<17)
205250963Sachim#define	AAC_FIBSTATE_BIOSFIB		(1<<18)
206250963Sachim#define AAC_FIBSTATE_FAST_RESPONSE	(1<<19)	/* fast response capable */
207250963Sachim#define AAC_FIBSTATE_APIFIB		(1<<20)
208250963Sachim#define AAC_FIBSTATE_NOMOREAIF		(1<<21)
209250963Sachim
210250963Sachim/*
211250963Sachim * FIB error values
212250963Sachim */
213250963Sachim#define AAC_ERROR_NORMAL			0x00
214250963Sachim#define AAC_ERROR_PENDING			0x01
215250963Sachim#define AAC_ERROR_FATAL				0x02
216250963Sachim#define AAC_ERROR_INVALID_QUEUE			0x03
217250963Sachim#define AAC_ERROR_NOENTRIES			0x04
218250963Sachim#define AAC_ERROR_SENDFAILED			0x05
219250963Sachim#define AAC_ERROR_INVALID_QUEUE_PRIORITY	0x06
220250963Sachim#define AAC_ERROR_FIB_ALLOCATION_FAILED		0x07
221250963Sachim#define AAC_ERROR_FIB_DEALLOCATION_FAILED	0x08
222250963Sachim
223250963Sachim/*
224250963Sachim * Adapter Init Structure: this is passed to the adapter with the
225250963Sachim * AAC_MONKER_INITSTRUCT command to point it at our control structures.
226250963Sachim */
227250963Sachimstruct aac_adapter_init {
228250963Sachim	u_int32_t	InitStructRevision;
229250963Sachim#define AAC_INIT_STRUCT_REVISION		3
230250963Sachim#define AAC_INIT_STRUCT_REVISION_4		4
231250963Sachim#define AAC_INIT_STRUCT_REVISION_6		6
232250963Sachim#define AAC_INIT_STRUCT_REVISION_7		7
233250963Sachim	u_int32_t	MiniPortRevision;
234250963Sachim#define AAC_INIT_STRUCT_MINIPORT_REVISION	1
235250963Sachim	u_int32_t	FilesystemRevision;
236250963Sachim	u_int32_t	CommHeaderAddress;
237250963Sachim	u_int32_t	FastIoCommAreaAddress;
238250963Sachim	u_int32_t	AdapterFibsPhysicalAddress;
239250963Sachim	u_int32_t 	AdapterFibsVirtualAddress;
240250963Sachim	u_int32_t	AdapterFibsSize;
241250963Sachim	u_int32_t	AdapterFibAlign;
242250963Sachim	u_int32_t	PrintfBufferAddress;
243250963Sachim	u_int32_t	PrintfBufferSize;
244250963Sachim#define	AAC_PAGE_SIZE				4096
245250963Sachim	u_int32_t	HostPhysMemPages;
246250963Sachim	u_int32_t	HostElapsedSeconds;
247250963Sachim	/* ADAPTER_INIT_STRUCT_REVISION_4 begins here */
248250963Sachim	u_int32_t	InitFlags;			/* flags for supported features */
249250963Sachim#define AAC_INITFLAGS_NEW_COMM_SUPPORTED	1
250250963Sachim#define AAC_INITFLAGS_DRIVER_USES_UTC_TIME	0x10
251250963Sachim#define AAC_INITFLAGS_DRIVER_SUPPORTS_PM	0x20
252250963Sachim#define AAC_INITFLAGS_NEW_COMM_TYPE1_SUPPORTED	0x40
253250963Sachim#define AAC_INITFLAGS_FAST_JBOD_SUPPORTED	0x80
254250963Sachim#define AAC_INITFLAGS_NEW_COMM_TYPE2_SUPPORTED	0x100
255250963Sachim	u_int32_t	MaxIoCommands;		/* max outstanding commands */
256250963Sachim	u_int32_t	MaxIoSize;			/* largest I/O command */
257250963Sachim	u_int32_t	MaxFibSize;			/* largest FIB to adapter */
258250963Sachim	/* ADAPTER_INIT_STRUCT_REVISION_5 begins here */
259250963Sachim	u_int32_t	MaxNumAif;	        /* max number of aif */
260250963Sachim	/* ADAPTER_INIT_STRUCT_REVISION_6 begins here */
261250963Sachim	u_int32_t	HostRRQ_AddrLow;
262250963Sachim	u_int32_t	HostRRQ_AddrHigh;	/* Host RRQ (response queue) for SRC */
263250963Sachim} __packed;
264250963Sachim
265250963Sachim/*
266250963Sachim * Shared data types
267250963Sachim */
268250963Sachim/*
269250963Sachim * Container types
270250963Sachim */
271250963Sachimtypedef enum {
272250963Sachim	CT_NONE = 0,
273250963Sachim	CT_VOLUME,
274250963Sachim	CT_MIRROR,
275250963Sachim	CT_STRIPE,
276250963Sachim	CT_RAID5,
277250963Sachim	CT_SSRW,
278250963Sachim	CT_SSRO,
279250963Sachim	CT_MORPH,
280250963Sachim	CT_PASSTHRU,
281250963Sachim	CT_RAID4,
282250963Sachim	CT_RAID10,                  /* stripe of mirror */
283250963Sachim	CT_RAID00,                  /* stripe of stripe */
284250963Sachim	CT_VOLUME_OF_MIRRORS,       /* volume of mirror */
285250963Sachim	CT_PSEUDO_RAID3,            /* really raid4 */
286250963Sachim	CT_RAID50,		    /* stripe of raid5 */
287250963Sachim	CT_RAID5D,		    /* raid5 distributed hot-sparing */
288250963Sachim	CT_RAID5D0,
289250963Sachim	CT_RAID1E,		    /* extended raid1 mirroring */
290250963Sachim	CT_RAID6,
291250963Sachim	CT_RAID60,
292250963Sachim} AAC_FSAVolType;
293250963Sachim
294250963Sachim/*
295250963Sachim * Host-addressable object types
296250963Sachim */
297250963Sachimtypedef enum {
298250963Sachim	FT_REG = 1,     /* regular file */
299250963Sachim	FT_DIR,         /* directory */
300250963Sachim	FT_BLK,         /* "block" device - reserved */
301250963Sachim	FT_CHR,         /* "character special" device - reserved */
302250963Sachim	FT_LNK,         /* symbolic link */
303250963Sachim	FT_SOCK,        /* socket */
304250963Sachim	FT_FIFO,        /* fifo */
305250963Sachim	FT_FILESYS,     /* ADAPTEC's "FSA"(tm) filesystem */
306250963Sachim	FT_DRIVE,       /* physical disk - addressable in scsi by b/t/l */
307250963Sachim	FT_SLICE,       /* virtual disk - raw volume - slice */
308250963Sachim	FT_PARTITION,   /* FSA partition - carved out of a slice - building
309250963Sachim			 * block for containers */
310250963Sachim	FT_VOLUME,      /* Container - Volume Set */
311250963Sachim	FT_STRIPE,      /* Container - Stripe Set */
312250963Sachim	FT_MIRROR,      /* Container - Mirror Set */
313250963Sachim	FT_RAID5,       /* Container - Raid 5 Set */
314250963Sachim	FT_DATABASE     /* Storage object with "foreign" content manager */
315250963Sachim} AAC_FType;
316250963Sachim
317250963Sachim/*
318250963Sachim * Host-side scatter/gather list for 32-bit commands.
319250963Sachim */
320250963Sachimstruct aac_sg_entry {
321250963Sachim	u_int32_t	SgAddress;
322250963Sachim	u_int32_t	SgByteCount;
323250963Sachim} __packed;
324250963Sachim
325250963Sachimstruct aac_sg_entry64 {
326250963Sachim	u_int64_t	SgAddress;
327250963Sachim	u_int32_t	SgByteCount;
328250963Sachim} __packed;
329250963Sachim
330250963Sachimstruct aac_sg_entryraw {
331250963Sachim	u_int32_t	Next;		/* reserved for FW use */
332250963Sachim	u_int32_t	Prev;		/* reserved for FW use */
333250963Sachim	u_int64_t	SgAddress;
334250963Sachim	u_int32_t	SgByteCount;
335250963Sachim	u_int32_t	Flags;		/* reserved for FW use */
336250963Sachim} __packed;
337250963Sachim
338250963Sachimstruct aac_sg_table {
339250963Sachim	u_int32_t		SgCount;
340250963Sachim	struct aac_sg_entry	SgEntry[0];
341250963Sachim} __packed;
342250963Sachim
343250963Sachim/*
344250963Sachim * Host-side scatter/gather list for 64-bit commands.
345250963Sachim */
346250963Sachimstruct aac_sg_table64 {
347250963Sachim	u_int32_t	SgCount;
348250963Sachim	struct aac_sg_entry64	SgEntry64[0];
349250963Sachim} __packed;
350250963Sachim
351250963Sachim/*
352250963Sachim * s/g list for raw commands
353250963Sachim */
354250963Sachimstruct aac_sg_tableraw {
355250963Sachim	u_int32_t	SgCount;
356250963Sachim	struct aac_sg_entryraw	SgEntryRaw[0];
357250963Sachim} __packed;
358250963Sachim
359250963Sachim/*
360250963Sachim * new ieee1212 s/g element
361250963Sachim */
362250963Sachimstruct aac_sge_ieee1212 {
363250963Sachim	u_int32_t	addrLow;
364250963Sachim	u_int32_t	addrHigh;
365250963Sachim	u_int32_t	length;
366250963Sachim	u_int32_t	flags;	/* always 0 from host side */
367250963Sachim} __packed;
368250963Sachim
369250963Sachim/*
370250963Sachim * Container creation data
371250963Sachim */
372250963Sachimstruct aac_container_creation {
373250963Sachim	u_int8_t	ViaBuildNumber;
374250963Sachim	u_int8_t	MicroSecond;
375250963Sachim	u_int8_t	Via;		/* 1 = FSU, 2 = API, etc. */
376250963Sachim	u_int8_t	YearsSince1900;
377250963Sachim	u_int32_t	Month:4;	/* 1-12 */
378250963Sachim	u_int32_t	Day:6;		/* 1-32 */
379250963Sachim	u_int32_t	Hour:6;		/* 0-23 */
380250963Sachim	u_int32_t	Minute:6;	/* 0-59 */
381250963Sachim	u_int32_t	Second:6;	/* 0-59 */
382250963Sachim	u_int64_t	ViaAdapterSerialNumber;
383250963Sachim} __packed;
384250963Sachim
385250963Sachim/*
386250963Sachim * Revision number handling
387250963Sachim */
388250963Sachim
389250963Sachimtypedef enum {
390250963Sachim	RevApplication = 1,
391250963Sachim	RevDkiCli,
392250963Sachim	RevNetService,
393250963Sachim	RevApi,
394250963Sachim	RevFileSysDriver,
395250963Sachim	RevMiniportDriver,
396250963Sachim	RevAdapterSW,
397250963Sachim	RevMonitor,
398250963Sachim	RevRemoteApi
399250963Sachim} RevComponent;
400250963Sachim
401250963Sachimstruct FsaRevision {
402250963Sachim	union {
403250963Sachim		struct {
404250963Sachim			u_int8_t	dash;
405250963Sachim			u_int8_t	type;
406250963Sachim			u_int8_t	minor;
407250963Sachim			u_int8_t	major;
408250963Sachim		} comp;
409250963Sachim		u_int32_t	ul;
410250963Sachim	} external;
411250963Sachim	u_int32_t	buildNumber;
412250963Sachim}  __packed;
413250963Sachim
414250963Sachim/*
415250963Sachim * Adapter Information
416250963Sachim */
417250963Sachim
418250963Sachimtypedef enum {
419250963Sachim	CPU_NTSIM = 1,
420250963Sachim	CPU_I960,
421250963Sachim	CPU_ARM,
422250963Sachim	CPU_SPARC,
423250963Sachim	CPU_POWERPC,
424250963Sachim	CPU_ALPHA,
425250963Sachim	CPU_P7,
426250963Sachim	CPU_I960_RX,
427250963Sachim	CPU_MIPS,
428250963Sachim	CPU_XSCALE,
429250963Sachim	CPU__last
430250963Sachim} AAC_CpuType;
431250963Sachim
432250963Sachimtypedef enum {
433250963Sachim	CPUI960_JX = 1,
434250963Sachim	CPUI960_CX,
435250963Sachim	CPUI960_HX,
436250963Sachim	CPUI960_RX,
437250963Sachim	CPUARM_SA110,
438250963Sachim	CPUARM_xxx,
439250963Sachim	CPUPPC_603e,
440250963Sachim	CPUPPC_xxx,
441250963Sachim	CPUI960_80303,
442250963Sachim	CPU_XSCALE_80321,
443250963Sachim	CPU_MIPS_4KC,
444250963Sachim	CPU_MIPS_5KC,
445250963Sachim	CPUSUBTYPE__last
446250963Sachim} AAC_CpuSubType;
447250963Sachim
448250963Sachimtypedef enum {
449250963Sachim	PLAT_NTSIM = 1,
450250963Sachim	PLAT_V3ADU,
451250963Sachim	PLAT_CYCLONE,
452250963Sachim	PLAT_CYCLONE_HD,
453250963Sachim	PLAT_BATBOARD,
454250963Sachim	PLAT_BATBOARD_HD,
455250963Sachim	PLAT_YOLO,
456250963Sachim	PLAT_COBRA,
457250963Sachim	PLAT_ANAHEIM,
458250963Sachim	PLAT_JALAPENO,
459250963Sachim	PLAT_QUEENS,
460250963Sachim	PLAT_JALAPENO_DELL,
461250963Sachim	PLAT_POBLANO,
462250963Sachim	PLAT_POBLANO_OPAL,
463250963Sachim	PLAT_POBLANO_SL0,
464250963Sachim	PLAT_POBLANO_SL1,
465250963Sachim	PLAT_POBLANO_SL2,
466250963Sachim	PLAT_POBLANO_XXX,
467250963Sachim	PLAT_JALAPENO_P2,
468250963Sachim	PLAT_HABANERO,
469250963Sachim	PLAT_VULCAN,
470250963Sachim	PLAT_CRUSADER,
471250963Sachim	PLAT_LANCER,
472250963Sachim	PLAT_HARRIER,
473250963Sachim	PLAT_TERMINATOR,
474250963Sachim	PLAT_SKYHAWK,
475250963Sachim	PLAT_CORSAIR,
476250963Sachim	PLAT_JAGUAR,
477250963Sachim	PLAT_SATAHAWK,
478250963Sachim	PLAT_SATANATOR,
479250963Sachim	PLAT_PROWLER,
480250963Sachim	PLAT_BLACKBIRD,
481250963Sachim	PLAT_SABREEXPRESS,
482250963Sachim	PLAT_INTRUDER,
483250963Sachim	PLAT__last
484250963Sachim} AAC_Platform;
485250963Sachim
486250963Sachimtypedef enum {
487250963Sachim	OEM_FLAVOR_ADAPTEC = 1,
488250963Sachim	OEM_FLAVOR_DELL,
489250963Sachim	OEM_FLAVOR_HP,
490250963Sachim	OEM_FLAVOR_IBM,
491250963Sachim	OEM_FLAVOR_CPQ,
492250963Sachim	OEM_FLAVOR_FSC,
493250963Sachim	OEM_FLAVOR_DWS,
494250963Sachim	OEM_FLAVOR_BRAND_Z,
495250963Sachim	OEM_FLAVOR_LEGEND,
496250963Sachim	OEM_FLAVOR_HITACHI,
497250963Sachim	OEM_FLAVOR_ESG,
498250963Sachim	OEM_FLAVOR_ICP,
499250963Sachim	OEM_FLAVOR_SCM,
500250963Sachim	OEM_FLAVOR__last
501250963Sachim} AAC_OemFlavor;
502250963Sachim
503250963Sachim/*
504250963Sachim * XXX the aac-2622 with no battery present reports PLATFORM_BAT_OPT_PRESENT
505250963Sachim */
506250963Sachimtypedef enum
507250963Sachim{
508250963Sachim	PLATFORM_BAT_REQ_PRESENT = 1,	/* BATTERY REQUIRED AND PRESENT */
509250963Sachim	PLATFORM_BAT_REQ_NOTPRESENT,	/* BATTERY REQUIRED AND NOT PRESENT */
510250963Sachim	PLATFORM_BAT_OPT_PRESENT,	/* BATTERY OPTIONAL AND PRESENT */
511250963Sachim	PLATFORM_BAT_OPT_NOTPRESENT,	/* BATTERY OPTIONAL AND NOT PRESENT */
512250963Sachim	PLATFORM_BAT_NOT_SUPPORTED	/* BATTERY NOT SUPPORTED */
513250963Sachim} AAC_BatteryPlatform;
514250963Sachim
515250963Sachim/*
516250963Sachim * options supported by this board
517250963Sachim * there has to be a one to one mapping of these defines and the ones in
518250963Sachim * fsaapi.h, search for FSA_SUPPORT_SNAPSHOT
519250963Sachim */
520250963Sachim#define AAC_SUPPORTED_SNAPSHOT		0x01
521250963Sachim#define AAC_SUPPORTED_CLUSTERS		0x02
522250963Sachim#define AAC_SUPPORTED_WRITE_CACHE	0x04
523250963Sachim#define AAC_SUPPORTED_64BIT_DATA	0x08
524250963Sachim#define AAC_SUPPORTED_HOST_TIME_FIB	0x10
525250963Sachim#define AAC_SUPPORTED_RAID50		0x20
526250963Sachim#define AAC_SUPPORTED_4GB_WINDOW	0x40
527250963Sachim#define AAC_SUPPORTED_SCSI_UPGRADEABLE	0x80
528250963Sachim#define AAC_SUPPORTED_SOFT_ERR_REPORT	0x100
529250963Sachim#define AAC_SUPPORTED_NOT_RECONDITION	0x200
530250963Sachim#define AAC_SUPPORTED_SGMAP_HOST64	0x400
531250963Sachim#define AAC_SUPPORTED_ALARM		0x800
532250963Sachim#define AAC_SUPPORTED_NONDASD		0x1000
533250963Sachim#define AAC_SUPPORTED_SCSI_MANAGED	0x2000
534250963Sachim#define AAC_SUPPORTED_RAID_SCSI_MODE	0x4000
535250963Sachim#define AAC_SUPPORTED_SUPPLEMENT_ADAPTER_INFO	0x10000
536250963Sachim#define AAC_SUPPORTED_NEW_COMM		0x20000
537250963Sachim#define AAC_SUPPORTED_64BIT_ARRAYSIZE	0x40000
538250963Sachim#define AAC_SUPPORTED_HEAT_SENSOR	0x80000
539250963Sachim#define AAC_SUPPORTED_NEW_COMM_TYPE1	0x10000000  /* Tupelo new comm */
540250963Sachim#define AAC_SUPPORTED_NEW_COMM_TYPE2	0x20000000  /* Denali new comm */
541250963Sachim#define AAC_SUPPORTED_NEW_COMM_TYPE3	0x40000000  /* Series 8 new comm */
542250963Sachim#define AAC_SUPPORTED_NEW_COMM_TYPE4	0x80000000  /* Series 9 new comm */
543250963Sachim
544250963Sachim/*
545250963Sachim * Structure used to respond to a RequestAdapterInfo fib.
546250963Sachim */
547250963Sachimstruct aac_adapter_info {
548250963Sachim	AAC_Platform		PlatformBase;    /* adapter type */
549250963Sachim	AAC_CpuType		CpuArchitecture; /* adapter CPU type */
550250963Sachim	AAC_CpuSubType		CpuVariant;      /* adapter CPU subtype */
551250963Sachim	u_int32_t		ClockSpeed;      /* adapter CPU clockspeed */
552250963Sachim	u_int32_t		ExecutionMem;    /* adapter Execution Memory
553250963Sachim						  * size */
554250963Sachim	u_int32_t		BufferMem;       /* adapter Data Memory */
555250963Sachim	u_int32_t		TotalMem;        /* adapter Total Memory */
556250963Sachim	struct FsaRevision	KernelRevision;  /* adapter Kernel Software
557250963Sachim						  * Revision */
558250963Sachim	struct FsaRevision	MonitorRevision; /* adapter Monitor/Diagnostic
559250963Sachim						  * Software Revision */
560250963Sachim	struct FsaRevision	HardwareRevision;/* TBD */
561250963Sachim	struct FsaRevision	BIOSRevision;    /* adapter BIOS Revision */
562250963Sachim	u_int32_t		ClusteringEnabled;
563250963Sachim	u_int32_t		ClusterChannelMask;
564250963Sachim	u_int64_t		SerialNumber;
565250963Sachim	AAC_BatteryPlatform	batteryPlatform;
566250963Sachim	u_int32_t		SupportedOptions; /* supported features of this
567250963Sachim						   * controller */
568250963Sachim	AAC_OemFlavor	OemVariant;
569250963Sachim} __packed;
570250963Sachim
571250963Sachim/*
572250963Sachim * More options from supplement info - SupportedOptions2
573250963Sachim */
574250963Sachim#define AAC_SUPPORTED_MU_RESET			0x01
575250963Sachim#define AAC_SUPPORTED_IGNORE_RESET		0x02
576250963Sachim#define AAC_SUPPORTED_POWER_MANAGEMENT		0x04
577250963Sachim#define AAC_SUPPORTED_ARCIO_PHYDEV		0x08
578250963Sachim#define AAC_SUPPORTED_DOORBELL_RESET		0x4000
579250963Sachim#define AAC_SUPPORTED_VARIABLE_BLOCK_SIZE	0x40000	/* 4KB sector size */
580250963Sachim
581250963Sachim/*
582250963Sachim * FeatureBits of RequestSupplementAdapterInfo used in the driver
583250963Sachim */
584250963Sachim#define AAC_SUPPL_SUPPORTED_JBOD	0x08000000
585250963Sachim
586250963Sachim/*
587250963Sachim * Structure used to respond to a RequestSupplementAdapterInfo fib.
588250963Sachim */
589250963Sachimstruct vpd_info {
590250963Sachim	u_int8_t		AssemblyPn[8];
591250963Sachim	u_int8_t		FruPn[8];
592250963Sachim	u_int8_t		BatteryFruPn[8];
593250963Sachim	u_int8_t		EcVersionString[8];
594250963Sachim	u_int8_t		Tsid[12];
595250963Sachim} __packed;
596250963Sachim
597250963Sachim#define	MFG_PCBA_SERIAL_NUMBER_WIDTH	12
598250963Sachim#define	MFG_WWN_WIDTH			8
599250963Sachim
600250963Sachimstruct aac_supplement_adapter_info {
601250963Sachim	/* The assigned Adapter Type Text, extra byte for null termination */
602250963Sachim	int8_t		AdapterTypeText[17+1];
603250963Sachim	/* Pad for the text above */
604250963Sachim	int8_t		Pad[2];
605250963Sachim	/* Size in bytes of the memory that is flashed */
606250963Sachim	u_int32_t	FlashMemoryByteSize;
607250963Sachim	/* The assigned IMAGEID_xxx for this adapter */
608250963Sachim	u_int32_t	FlashImageId;
609250963Sachim	/*
610250963Sachim	 * The maximum number of Phys available on a SATA/SAS
611250963Sachim	 * Controller, 0 otherwise
612250963Sachim	 */
613250963Sachim	u_int32_t	MaxNumberPorts;
614250963Sachim	/* Version of expansion area */
615250963Sachim	u_int32_t	Version;
616250963Sachim	u_int32_t	FeatureBits;
617250963Sachim	u_int8_t		SlotNumber;
618250963Sachim	u_int8_t		ReservedPad0[3];
619250963Sachim	u_int8_t		BuildDate[12];
620250963Sachim	/* The current number of Ports on a SAS controller, 0 otherwise */
621250963Sachim	u_int32_t	CurrentNumberPorts;
622250963Sachim
623250963Sachim	struct vpd_info VpdInfo;
624250963Sachim
625250963Sachim	/* Firmware Revision (Vmaj.min-dash.) */
626250963Sachim	struct FsaRevision	FlashFirmwareRevision;
627250963Sachim	u_int32_t	RaidTypeMorphOptions;
628250963Sachim	/* Firmware's boot code Revision (Vmaj.min-dash.) */
629250963Sachim	struct FsaRevision	FlashFirmwareBootRevision;
630250963Sachim	/* PCBA serial no. from th MFG sector */
631250963Sachim	u_int8_t		MfgPcbaSerialNo[MFG_PCBA_SERIAL_NUMBER_WIDTH];
632250963Sachim	/* WWN from the MFG sector */
633250963Sachim	u_int8_t		MfgWWNName[MFG_WWN_WIDTH];
634250963Sachim	u_int32_t	SupportedOptions2;		/* more supported features */
635250963Sachim	u_int32_t	ExpansionFlag;			/* 1 - following fields are valid */
636250963Sachim	u_int32_t	FeatureBits3;
637250963Sachim	u_int32_t	SupportedPerformanceMode;
638250963Sachim	/* Growth Area for future expansion */
639250963Sachim	u_int32_t	ReservedGrowth[80];
640250963Sachim} __packed;
641250963Sachim
642250963Sachim/*
643250963Sachim * Monitor/Kernel interface.
644250963Sachim */
645250963Sachim
646250963Sachim/*
647250963Sachim * Synchronous commands to the monitor/kernel.
648250963Sachim */
649250963Sachim#define AAC_MONKER_BREAKPOINT	0x04
650250963Sachim#define AAC_MONKER_INITSTRUCT	0x05
651250963Sachim#define AAC_MONKER_SYNCFIB	0x0c
652250963Sachim#define AAC_MONKER_GETKERNVER	0x11
653250963Sachim#define AAC_MONKER_POSTRESULTS	0x14
654250963Sachim#define AAC_MONKER_GETINFO	0x19
655250963Sachim#define AAC_MONKER_GETDRVPROP	0x23
656250963Sachim#define AAC_MONKER_RCVTEMP	0x25
657250963Sachim#define AAC_MONKER_GETCOMMPREF	0x26
658250963Sachim#define AAC_MONKER_REINIT	0xee
659250963Sachim#define	AAC_IOP_RESET		0x1000
660250963Sachim#define	AAC_IOP_RESET_ALWAYS	0x1001
661250963Sachim
662250963Sachim/*
663250963Sachim *  Adapter Status Register
664250963Sachim *
665250963Sachim *  Phase Staus mailbox is 32bits:
666250963Sachim *  <31:16> = Phase Status
667250963Sachim *  <15:0>  = Phase
668250963Sachim *
669250963Sachim *  The adapter reports its present state through the phase.  Only
670250963Sachim *  a single phase should be ever be set.  Each phase can have multiple
671250963Sachim *  phase status bits to provide more detailed information about the
672250963Sachim *  state of the adapter.
673250963Sachim */
674250963Sachim#define AAC_SELF_TEST_FAILED	0x00000004
675250963Sachim#define AAC_MONITOR_PANIC	0x00000020
676250963Sachim#define AAC_UP_AND_RUNNING	0x00000080
677250963Sachim#define AAC_KERNEL_PANIC	0x00000100
678250963Sachim
679250963Sachim/*
680250963Sachim * Data types relating to control and monitoring of the NVRAM/WriteCache
681250963Sachim * subsystem.
682250963Sachim */
683250963Sachim
684250963Sachim#define AAC_NFILESYS	24	/* maximum number of filesystems */
685250963Sachim
686250963Sachim/*
687250963Sachim * NVRAM/Write Cache subsystem states
688250963Sachim */
689250963Sachimtypedef enum {
690250963Sachim	NVSTATUS_DISABLED = 0,	/* present, clean, not being used */
691250963Sachim	NVSTATUS_ENABLED,	/* present, possibly dirty, ready for use */
692250963Sachim	NVSTATUS_ERROR,		/* present, dirty, contains dirty data */
693250963Sachim	NVSTATUS_BATTERY,	/* present, bad or low battery, may contain
694250963Sachim				 * dirty data */
695250963Sachim	NVSTATUS_UNKNOWN	/* for bad/missing device */
696250963Sachim} AAC_NVSTATUS;
697250963Sachim
698250963Sachim/*
699250963Sachim * NVRAM/Write Cache subsystem battery component states
700250963Sachim *
701250963Sachim */
702250963Sachimtypedef enum {
703250963Sachim	NVBATTSTATUS_NONE = 0,	/* battery has no power or is not present */
704250963Sachim	NVBATTSTATUS_LOW,	/* battery is low on power */
705250963Sachim	NVBATTSTATUS_OK,	/* battery is okay - normal operation possible
706250963Sachim				 * only in this state */
707250963Sachim	NVBATTSTATUS_RECONDITIONING	/* no battery present - reconditioning
708250963Sachim					 * in process */
709250963Sachim} AAC_NVBATTSTATUS;
710250963Sachim
711250963Sachim/*
712250963Sachim * Battery transition type
713250963Sachim */
714250963Sachimtypedef enum {
715250963Sachim	NVBATT_TRANSITION_NONE = 0,	/* battery now has no power or is not
716250963Sachim					 * present */
717250963Sachim	NVBATT_TRANSITION_LOW,		/* battery is now low on power */
718250963Sachim	NVBATT_TRANSITION_OK		/* battery is now okay - normal
719250963Sachim					 * operation possible only in this
720250963Sachim					 * state */
721250963Sachim} AAC_NVBATT_TRANSITION;
722250963Sachim
723250963Sachim/*
724250963Sachim * NVRAM Info structure returned for NVRAM_GetInfo call
725250963Sachim */
726250963Sachimstruct aac_nvramdevinfo {
727250963Sachim	u_int32_t	NV_Enabled;	/* write caching enabled */
728250963Sachim	u_int32_t	NV_Error;	/* device in error state */
729250963Sachim	u_int32_t	NV_NDirty;	/* count of dirty NVRAM buffers */
730250963Sachim	u_int32_t	NV_NActive;	/* count of NVRAM buffers being
731250963Sachim					 * written */
732250963Sachim} __packed;
733250963Sachim
734250963Sachimstruct aac_nvraminfo {
735250963Sachim	AAC_NVSTATUS		NV_Status;	/* nvram subsystem status */
736250963Sachim	AAC_NVBATTSTATUS	NV_BattStatus;	/* battery status */
737250963Sachim	u_int32_t		NV_Size;	/* size of WriteCache NVRAM in
738250963Sachim						 * bytes */
739250963Sachim	u_int32_t		NV_BufSize;	/* size of NVRAM buffers in
740250963Sachim						 * bytes */
741250963Sachim	u_int32_t		NV_NBufs;	/* number of NVRAM buffers */
742250963Sachim	u_int32_t		NV_NDirty;	/* Num dirty NVRAM buffers */
743250963Sachim	u_int32_t		NV_NClean;	/* Num clean NVRAM buffers */
744250963Sachim	u_int32_t		NV_NActive;	/* Num NVRAM buffers being
745250963Sachim						 * written */
746250963Sachim	u_int32_t		NV_NBrokered;	/* Num brokered NVRAM buffers */
747250963Sachim	struct aac_nvramdevinfo	NV_DevInfo[AAC_NFILESYS];	/* per device
748250963Sachim								 * info */
749250963Sachim	u_int32_t		NV_BattNeedsReconditioning;	/* boolean */
750250963Sachim	u_int32_t		NV_TotalSize;	/* size of all non-volatile
751250963Sachim						 * memories in bytes */
752250963Sachim} __packed;
753250963Sachim
754250963Sachim/*
755250963Sachim * Data types relating to adapter-initiated FIBs
756250963Sachim *
757250963Sachim * Based on types and structures in <aifstruc.h>
758250963Sachim */
759250963Sachim
760250963Sachim/*
761250963Sachim * Progress Reports
762250963Sachim */
763250963Sachimtypedef enum {
764250963Sachim	AifJobStsSuccess = 1,
765250963Sachim	AifJobStsFinished,
766250963Sachim	AifJobStsAborted,
767250963Sachim	AifJobStsFailed,
768250963Sachim	AifJobStsLastReportMarker = 100,	/* All prior mean last report */
769250963Sachim	AifJobStsSuspended,
770250963Sachim	AifJobStsRunning
771250963Sachim} AAC_AifJobStatus;
772250963Sachim
773250963Sachimtypedef enum {
774250963Sachim	AifJobScsiMin = 1,		/* Minimum value for Scsi operation */
775250963Sachim	AifJobScsiZero,			/* SCSI device clear operation */
776250963Sachim	AifJobScsiVerify,		/* SCSI device Verify operation NO
777250963Sachim					 * REPAIR */
778250963Sachim	AifJobScsiExercise,		/* SCSI device Exercise operation */
779250963Sachim	AifJobScsiVerifyRepair,		/* SCSI device Verify operation WITH
780250963Sachim					 * repair */
781250963Sachim	AifJobScsiWritePattern,		/* write pattern */
782250963Sachim	AifJobScsiMax = 99,		/* Max Scsi value */
783250963Sachim	AifJobCtrMin,			/* Min Ctr op value */
784250963Sachim	AifJobCtrZero,			/* Container clear operation */
785250963Sachim	AifJobCtrCopy,			/* Container copy operation */
786250963Sachim	AifJobCtrCreateMirror,		/* Container Create Mirror operation */
787250963Sachim	AifJobCtrMergeMirror,		/* Container Merge Mirror operation */
788250963Sachim	AifJobCtrScrubMirror,		/* Container Scrub Mirror operation */
789250963Sachim	AifJobCtrRebuildRaid5,		/* Container Rebuild Raid5 operation */
790250963Sachim	AifJobCtrScrubRaid5,		/* Container Scrub Raid5 operation */
791250963Sachim	AifJobCtrMorph,			/* Container morph operation */
792250963Sachim	AifJobCtrPartCopy,		/* Container Partition copy operation */
793250963Sachim	AifJobCtrRebuildMirror,		/* Container Rebuild Mirror operation */
794250963Sachim	AifJobCtrCrazyCache,		/* crazy cache */
795250963Sachim	AifJobCtrCopyback,		/* Container Copyback operation */
796250963Sachim	AifJobCtrCompactRaid5D,		/* Container Compaction operation */
797250963Sachim	AifJobCtrExpandRaid5D,		/* Container Expansion operation */
798250963Sachim	AifJobCtrRebuildRaid6,		/* Container Rebuild Raid6 operation */
799250963Sachim	AifJobCtrScrubRaid6,		/* Container Scrub Raid6 operation */
800250963Sachim	AifJobCtrSSBackup,		/* Container snapshot backup task */
801250963Sachim	AifJobCtrMax = 199,		/* Max Ctr type operation */
802250963Sachim	AifJobFsMin,			/* Min Fs type operation */
803250963Sachim	AifJobFsCreate,			/* File System Create operation */
804250963Sachim	AifJobFsVerify,			/* File System Verify operation */
805250963Sachim	AifJobFsExtend,			/* File System Extend operation */
806250963Sachim	AifJobFsMax = 299,		/* Max Fs type operation */
807250963Sachim	AifJobApiFormatNTFS,		/* Format a drive to NTFS */
808250963Sachim	AifJobApiFormatFAT,		/* Format a drive to FAT */
809250963Sachim	AifJobApiUpdateSnapshot,	/* update the read/write half of a
810250963Sachim					 * snapshot */
811250963Sachim	AifJobApiFormatFAT32,		/* Format a drive to FAT32 */
812250963Sachim	AifJobApiMax = 399,		/* Max API type operation */
813250963Sachim	AifJobCtlContinuousCtrVerify,	/* Adapter operation */
814250963Sachim	AifJobCtlMax = 499		/* Max Adapter type operation */
815250963Sachim} AAC_AifJobType;
816250963Sachim
817250963Sachimstruct aac_AifContainers {
818250963Sachim	u_int32_t	src;		/* from/master */
819250963Sachim	u_int32_t	dst;		/* to/slave */
820250963Sachim} __packed;
821250963Sachim
822250963Sachimunion aac_AifJobClient {
823250963Sachim	struct aac_AifContainers	container;	/* For Container and
824250963Sachim							 * filesystem progress
825250963Sachim							 * ops; */
826250963Sachim	int32_t				scsi_dh;	/* For SCSI progress
827250963Sachim							 * ops */
828250963Sachim};
829250963Sachim
830250963Sachimstruct aac_AifJobDesc {
831250963Sachim	u_int32_t		jobID;		/* DO NOT FILL IN! Will be
832250963Sachim						 * filled in by AIF */
833250963Sachim	AAC_AifJobType		type;		/* Operation that is being
834250963Sachim						 * performed */
835250963Sachim	union aac_AifJobClient	client;		/* Details */
836250963Sachim} __packed;
837250963Sachim
838250963Sachimstruct aac_AifJobProgressReport {
839250963Sachim	struct aac_AifJobDesc	jd;
840250963Sachim	AAC_AifJobStatus	status;
841250963Sachim	u_int32_t		finalTick;
842250963Sachim	u_int32_t		currentTick;
843250963Sachim	u_int32_t		jobSpecificData1;
844250963Sachim	u_int32_t		jobSpecificData2;
845250963Sachim} __packed;
846250963Sachim
847250963Sachim/*
848250963Sachim * Event Notification
849250963Sachim */
850250963Sachimtypedef enum {
851250963Sachim	/* General application notifies start here */
852250963Sachim	AifEnGeneric = 1,		/* Generic notification */
853250963Sachim	AifEnTaskComplete,		/* Task has completed */
854250963Sachim	AifEnConfigChange,		/* Adapter config change occurred */
855250963Sachim	AifEnContainerChange,		/* Adapter specific container
856250963Sachim					 * configuration change */
857250963Sachim	AifEnDeviceFailure,		/* SCSI device failed */
858250963Sachim	AifEnMirrorFailover,		/* Mirror failover started */
859250963Sachim	AifEnContainerEvent,		/* Significant container event */
860250963Sachim	AifEnFileSystemChange,		/* File system changed */
861250963Sachim	AifEnConfigPause,		/* Container pause event */
862250963Sachim	AifEnConfigResume,		/* Container resume event */
863250963Sachim	AifEnFailoverChange,		/* Failover space assignment changed */
864250963Sachim	AifEnRAID5RebuildDone,		/* RAID5 rebuild finished */
865250963Sachim	AifEnEnclosureManagement,	/* Enclosure management event */
866250963Sachim	AifEnBatteryEvent,		/* Significant NV battery event */
867250963Sachim	AifEnAddContainer,		/* A new container was created. */
868250963Sachim	AifEnDeleteContainer,		/* A container was deleted. */
869250963Sachim	AifEnSMARTEvent, 	       	/* SMART Event */
870250963Sachim	AifEnBatteryNeedsRecond,	/* The battery needs reconditioning */
871250963Sachim	AifEnClusterEvent,		/* Some cluster event */
872250963Sachim	AifEnDiskSetEvent,		/* A disk set event occured. */
873250963Sachim	AifEnContainerScsiEvent,	/* a container event with no. and scsi id */
874250963Sachim	AifEnPicBatteryEvent,	/* An event gen. by pic_battery.c for an ABM */
875250963Sachim	AifEnExpEvent,		/* Exp. Event Type to replace CTPopUp messages */
876250963Sachim	AifEnRAID6RebuildDone,	/* RAID6 rebuild finished */
877250963Sachim	AifEnSensorOverHeat,	/* Heat Sensor indicate overheat */
878250963Sachim	AifEnSensorCoolDown,	/* Heat Sensor ind. cooled down after overheat */
879250963Sachim	AifFeatureKeysModified,	/* notif. of updated feature keys */
880250963Sachim	AifApplicationExpirationEvent,	/* notif. on app. expiration status */
881250963Sachim	AifEnBackgroundConsistencyCheck,/* BCC notif. for NEC - DDTS 94700 */
882250963Sachim	AifEnAddJBOD,		/* A new JBOD type drive was created (30) */
883250963Sachim	AifEnDeleteJBOD,	/* A JBOD type drive was deleted (31) */
884250963Sachim	AifDriverNotifyStart=199,	/* Notifies for host driver go here */
885250963Sachim	/* Host driver notifications start here */
886250963Sachim	AifDenMorphComplete, 		/* A morph operation completed */
887250963Sachim	AifDenVolumeExtendComplete, 	/* Volume expand operation completed */
888250963Sachim	AifDriverNotifyDelay,
889250963Sachim	AifRawDeviceRemove			/* Raw device Failure event */
890250963Sachim} AAC_AifEventNotifyType;
891250963Sachim
892250963Sachimstruct aac_AifEnsGeneric {
893250963Sachim	char	text[132];		/* Generic text */
894250963Sachim} __packed;
895250963Sachim
896250963Sachimstruct aac_AifEnsDeviceFailure {
897250963Sachim	u_int32_t	deviceHandle;	/* SCSI device handle */
898250963Sachim} __packed;
899250963Sachim
900250963Sachimstruct aac_AifEnsMirrorFailover {
901250963Sachim	u_int32_t	container;	/* Container with failed element */
902250963Sachim	u_int32_t	failedSlice;	/* Old slice which failed */
903250963Sachim	u_int32_t	creatingSlice;	/* New slice used for auto-create */
904250963Sachim} __packed;
905250963Sachim
906250963Sachimstruct aac_AifEnsContainerChange {
907250963Sachim	u_int32_t	container[2];	/* container that changed, -1 if no
908250963Sachim					 * container */
909250963Sachim} __packed;
910250963Sachim
911250963Sachimstruct aac_AifEnsContainerEvent {
912250963Sachim	u_int32_t	container;	/* container number  */
913250963Sachim	u_int32_t	eventType;	/* event type */
914250963Sachim} __packed;
915250963Sachim
916250963Sachimstruct aac_AifEnsEnclosureEvent {
917250963Sachim	u_int32_t	empID;		/* enclosure management proc number  */
918250963Sachim	u_int32_t	unitID;		/* unitId, fan id, power supply id,
919250963Sachim					 * slot id, tempsensor id.  */
920250963Sachim	u_int32_t	eventType;	/* event type */
921250963Sachim} __packed;
922250963Sachim
923250963Sachimtypedef enum {
924250963Sachim	AIF_EM_DRIVE_INSERTION=31,
925250963Sachim	AIF_EM_DRIVE_REMOVAL
926250963Sachim} aac_AifEMEventType;
927250963Sachim
928250963Sachimstruct aac_AifEnsBatteryEvent {
929250963Sachim	AAC_NVBATT_TRANSITION	transition_type;	/* eg from low to ok */
930250963Sachim	AAC_NVBATTSTATUS	current_state;		/* current batt state */
931250963Sachim	AAC_NVBATTSTATUS	prior_state;		/* prev batt state */
932250963Sachim} __packed;
933250963Sachim
934250963Sachimstruct aac_AifEnsDiskSetEvent {
935250963Sachim	u_int32_t	eventType;
936250963Sachim	u_int64_t	DsNum;
937250963Sachim	u_int64_t	CreatorId;
938250963Sachim} __packed;
939250963Sachim
940250963Sachimtypedef enum {
941250963Sachim	CLUSTER_NULL_EVENT = 0,
942250963Sachim	CLUSTER_PARTNER_NAME_EVENT,	/* change in partner hostname or
943250963Sachim					 * adaptername from NULL to non-NULL */
944250963Sachim	/* (partner's agent may be up) */
945250963Sachim	CLUSTER_PARTNER_NULL_NAME_EVENT	/* change in partner hostname or
946250963Sachim					 * adaptername from non-null to NULL */
947250963Sachim	/* (partner has rebooted) */
948250963Sachim} AAC_ClusterAifEvent;
949250963Sachim
950250963Sachimstruct aac_AifEnsClusterEvent {
951250963Sachim	AAC_ClusterAifEvent	eventType;
952250963Sachim} __packed;
953250963Sachim
954250963Sachimstruct aac_AifEventNotify {
955250963Sachim	AAC_AifEventNotifyType	type;
956250963Sachim	union {
957250963Sachim		struct aac_AifEnsGeneric		EG;
958250963Sachim		struct aac_AifEnsDeviceFailure		EDF;
959250963Sachim		struct aac_AifEnsMirrorFailover		EMF;
960250963Sachim		struct aac_AifEnsContainerChange	ECC;
961250963Sachim		struct aac_AifEnsContainerEvent		ECE;
962250963Sachim		struct aac_AifEnsEnclosureEvent		EEE;
963250963Sachim		struct aac_AifEnsBatteryEvent		EBE;
964250963Sachim		struct aac_AifEnsDiskSetEvent		EDS;
965250963Sachim/*		struct aac_AifEnsSMARTEvent		ES;*/
966250963Sachim		struct aac_AifEnsClusterEvent		ECLE;
967250963Sachim	} data;
968250963Sachim} __packed;
969250963Sachim
970250963Sachim/*
971250963Sachim * Adapter Initiated FIB command structures. Start with the adapter
972250963Sachim * initiated FIBs that really come from the adapter, and get responded
973250963Sachim * to by the host.
974250963Sachim */
975250963Sachim#define AAC_AIF_REPORT_MAX_SIZE 64
976250963Sachim
977250963Sachimtypedef enum {
978250963Sachim	AifCmdEventNotify = 1,	/* Notify of event */
979250963Sachim	AifCmdJobProgress,	/* Progress report */
980250963Sachim	AifCmdAPIReport,	/* Report from other user of API */
981250963Sachim	AifCmdDriverNotify,	/* Notify host driver of event */
982250963Sachim	AifReqJobList = 100,	/* Gets back complete job list */
983250963Sachim	AifReqJobsForCtr,	/* Gets back jobs for specific container */
984250963Sachim	AifReqJobsForScsi,	/* Gets back jobs for specific SCSI device */
985250963Sachim	AifReqJobReport,	/* Gets back a specific job report or list */
986250963Sachim	AifReqTerminateJob,	/* Terminates job */
987250963Sachim	AifReqSuspendJob,	/* Suspends a job */
988250963Sachim	AifReqResumeJob,	/* Resumes a job */
989250963Sachim	AifReqSendAPIReport,	/* API generic report requests */
990250963Sachim	AifReqAPIJobStart,	/* Start a job from the API */
991250963Sachim	AifReqAPIJobUpdate,	/* Update a job report from the API */
992250963Sachim	AifReqAPIJobFinish,	/* Finish a job from the API */
993250963Sachim	AifReqEvent = 200	/* PMC NEW COMM: Request the event data */
994250963Sachim} AAC_AifCommand;
995250963Sachim
996250963Sachimstruct aac_aif_command {
997250963Sachim	AAC_AifCommand	command;	/* Tell host what type of
998250963Sachim					 * notify this is */
999250963Sachim	u_int32_t	seqNumber;	/* To allow ordering of
1000250963Sachim					 * reports (if necessary) */
1001250963Sachim	union {
1002250963Sachim		struct aac_AifEventNotify	EN;	/* Event notify */
1003250963Sachim		struct aac_AifJobProgressReport	PR[1];	/* Progress report */
1004250963Sachim		u_int8_t			AR[AAC_AIF_REPORT_MAX_SIZE];
1005250963Sachim		u_int8_t			data[AAC_FIB_DATASIZE - 8];
1006250963Sachim	} data;
1007250963Sachim} __packed;
1008250963Sachim
1009250963Sachim/*
1010250963Sachim * Filesystem commands/data
1011250963Sachim *
1012250963Sachim * The adapter has a very complex filesystem interface, most of which we ignore.
1013250963Sachim * (And which seems not to be implemented, anyway.)
1014250963Sachim */
1015250963Sachim
1016250963Sachim/*
1017250963Sachim * FSA commands
1018250963Sachim * (not used?)
1019250963Sachim */
1020250963Sachimtypedef enum {
1021250963Sachim	Null = 0,
1022250963Sachim	GetAttributes,
1023250963Sachim	SetAttributes,
1024250963Sachim	Lookup,
1025250963Sachim	ReadLink,
1026250963Sachim	Read,
1027250963Sachim	Write,
1028250963Sachim	Create,
1029250963Sachim	MakeDirectory,
1030250963Sachim	SymbolicLink,
1031250963Sachim	MakeNode,
1032250963Sachim	Removex,
1033250963Sachim	RemoveDirectory,
1034250963Sachim	Rename,
1035250963Sachim	Link,
1036250963Sachim	ReadDirectory,
1037250963Sachim	ReadDirectoryPlus,
1038250963Sachim	FileSystemStatus,
1039250963Sachim	FileSystemInfo,
1040250963Sachim	PathConfigure,
1041250963Sachim	Commit,
1042250963Sachim	Mount,
1043250963Sachim	UnMount,
1044250963Sachim	Newfs,
1045250963Sachim	FsCheck,
1046250963Sachim	FsSync,
1047250963Sachim	SimReadWrite,
1048250963Sachim	SetFileSystemStatus,
1049250963Sachim	BlockRead,
1050250963Sachim	BlockWrite,
1051250963Sachim	NvramIoctl,
1052250963Sachim	FsSyncWait,
1053250963Sachim	ClearArchiveBit,
1054250963Sachim	SetAcl,
1055250963Sachim	GetAcl,
1056250963Sachim	AssignAcl,
1057250963Sachim	FaultInsertion,
1058250963Sachim	CrazyCache
1059250963Sachim} AAC_FSACommand;
1060250963Sachim
1061250963Sachim/*
1062250963Sachim * Command status values
1063250963Sachim */
1064250963Sachimtypedef enum {
1065250963Sachim	ST_OK = 0,
1066250963Sachim	ST_PERM = 1,
1067250963Sachim	ST_NOENT = 2,
1068250963Sachim	ST_IO = 5,
1069250963Sachim	ST_NXIO = 6,
1070250963Sachim	ST_E2BIG = 7,
1071250963Sachim	ST_ACCES = 13,
1072250963Sachim	ST_EXIST = 17,
1073250963Sachim	ST_XDEV = 18,
1074250963Sachim	ST_NODEV = 19,
1075250963Sachim	ST_NOTDIR = 20,
1076250963Sachim	ST_ISDIR = 21,
1077250963Sachim	ST_INVAL = 22,
1078250963Sachim	ST_FBIG = 27,
1079250963Sachim	ST_NOSPC = 28,
1080250963Sachim	ST_ROFS = 30,
1081250963Sachim	ST_MLINK = 31,
1082250963Sachim	ST_WOULDBLOCK = 35,
1083250963Sachim	ST_NAMETOOLONG = 63,
1084250963Sachim	ST_NOTEMPTY = 66,
1085250963Sachim	ST_DQUOT = 69,
1086250963Sachim	ST_STALE = 70,
1087250963Sachim	ST_REMOTE = 71,
1088250963Sachim	ST_NOT_READY = 72,
1089250963Sachim	ST_BADHANDLE = 10001,
1090250963Sachim	ST_NOT_SYNC = 10002,
1091250963Sachim	ST_BAD_COOKIE = 10003,
1092250963Sachim	ST_NOTSUPP = 10004,
1093250963Sachim	ST_TOOSMALL = 10005,
1094250963Sachim	ST_SERVERFAULT = 10006,
1095250963Sachim	ST_BADTYPE = 10007,
1096250963Sachim	ST_JUKEBOX = 10008,
1097250963Sachim	ST_NOTMOUNTED = 10009,
1098250963Sachim	ST_MAINTMODE = 10010,
1099250963Sachim	ST_STALEACL = 10011,
1100250963Sachim	ST_BUS_RESET = 20001
1101250963Sachim} AAC_FSAStatus;
1102250963Sachim
1103250963Sachim/*
1104250963Sachim * Volume manager commands
1105250963Sachim */
1106250963Sachimtypedef enum _VM_COMMANDS {
1107250963Sachim	VM_Null = 0,
1108250963Sachim	VM_NameServe,        /* query for mountable objects (containers) */
1109250963Sachim	VM_ContainerConfig,
1110250963Sachim	VM_Ioctl,
1111250963Sachim	VM_FilesystemIoctl,
1112250963Sachim	VM_CloseAll,
1113250963Sachim	VM_CtBlockRead,
1114250963Sachim	VM_CtBlockWrite,
1115250963Sachim	VM_SliceBlockRead,   /* raw access to configured "storage objects" */
1116250963Sachim	VM_SliceBlockWrite,
1117250963Sachim	VM_DriveBlockRead,   /* raw access to physical devices */
1118250963Sachim	VM_DriveBlockWrite,
1119250963Sachim	VM_EnclosureMgt,     /* enclosure management */
1120250963Sachim	VM_Unused,           /* used to be diskset management */
1121250963Sachim	VM_CtBlockVerify,
1122250963Sachim	VM_CtPerf,           /* performance test */
1123250963Sachim	VM_CtBlockRead64,
1124250963Sachim	VM_CtBlockWrite64,
1125250963Sachim	VM_CtBlockVerify64,
1126250963Sachim	VM_CtHostRead64,
1127250963Sachim	VM_CtHostWrite64,
1128250963Sachim	VM_DrvErrTblLog,     /* drive error table/log type of command */
1129250963Sachim	VM_NameServe64,      /* query also for containers >2TB */
1130250963Sachim	VM_SasNvsramAccess,  /* for sas nvsram layout function */
1131250963Sachim	VM_HandleExpiration, /* handles application expiration, internal use! */
1132250963Sachim	VM_GetDynAdapProps,  /* retrieves dynamic adapter properties */
1133250963Sachim	VM_SetDynAdapProps,  /* sets a dynamic adapter property */
1134250963Sachim	VM_UpdateSSDODM,     /* updates the on-disk metadata for SSD caching */
1135250963Sachim	VM_GetSPMParameters, /* get SPM parameters for one of the perf. modes */
1136250963Sachim	VM_SetSPMParameters, /* set SPM parameters for user defined perf. mode */
1137250963Sachim	VM_NameServeAllBlk,  /* query also for containers with 4KB sector size */
1138250963Sachim	MAX_VMCOMMAND_NUM    /* used for sizing stats array - leave last */
1139250963Sachim} AAC_VMCommand;
1140250963Sachim
1141250963Sachim/* Container Configuration Sub-Commands */
1142250963Sachim#define CT_GET_SCSI_METHOD	64
1143250963Sachim#define	CT_PAUSE_IO			65
1144250963Sachim#define	CT_RELEASE_IO			66
1145250963Sachim#define	CT_GET_CONFIG_STATUS		147
1146250963Sachim#define	CT_COMMIT_CONFIG		152
1147250963Sachim#define	CT_CID_TO_32BITS_UID		165
1148250963Sachim#define CT_PM_DRIVER_SUPPORT		245
1149250963Sachim
1150250963Sachim/* CT_PM_DRIVER_SUPPORT parameter */
1151250963Sachimtypedef enum {
1152250963Sachim	AAC_PM_DRIVERSUP_GET_STATUS = 1,
1153250963Sachim	AAC_PM_DRIVERSUP_START_UNIT,
1154250963Sachim	AAC_PM_DRIVERSUP_STOP_UNIT
1155250963Sachim} AAC_CT_PM_DRIVER_SUPPORT_SUB_COM;
1156250963Sachim
1157250963Sachim/*
1158250963Sachim * CT_PAUSE_IO is immediate minimal runtime command that is used
1159250963Sachim * to restart the applications and cache.
1160250963Sachim */
1161250963Sachimstruct aac_pause_command {
1162250963Sachim	u_int32_t	Command;
1163250963Sachim	u_int32_t	Type;
1164250963Sachim	u_int32_t	Timeout;
1165250963Sachim	u_int32_t	Min;
1166250963Sachim	u_int32_t	NoRescan;
1167250963Sachim	u_int32_t	Parm3;
1168250963Sachim	u_int32_t	Parm4;
1169250963Sachim	u_int32_t	Count;
1170250963Sachim} __packed;
1171250963Sachim
1172250963Sachim/* Flag values for ContentState */
1173250963Sachim#define AAC_FSCS_NOTCLEAN	0x1	/* fscheck is necessary before mounting */
1174250963Sachim#define AAC_FSCS_READONLY	0x2	/* possible result of broken mirror */
1175250963Sachim#define AAC_FSCS_HIDDEN		0x4	/* container should be ignored by driver */
1176250963Sachim#define AAC_FSCS_NOT_READY	0x8	/* cnt is in spinn. state, not rdy for IO's */
1177250963Sachim
1178250963Sachim/*
1179250963Sachim * "mountable object"
1180250963Sachim */
1181250963Sachimstruct aac_mntobj {
1182250963Sachim	u_int32_t			ObjectId;
1183250963Sachim	char				FileSystemName[16];
1184250963Sachim	struct aac_container_creation	CreateInfo;
1185250963Sachim	u_int32_t			Capacity;
1186250963Sachim	u_int32_t			VolType;
1187250963Sachim	u_int32_t			ObjType;
1188250963Sachim	u_int32_t			ContentState;
1189250963Sachim	union {
1190250963Sachim		u_int32_t	pad[8];
1191250963Sachim		u_int32_t	BlockSize;
1192250963Sachim	} ObjExtension;
1193250963Sachim	u_int32_t			AlterEgoId;
1194250963Sachim	u_int32_t			CapacityHigh;
1195250963Sachim} __packed;
1196250963Sachim
1197250963Sachimstruct aac_mntinfo {
1198250963Sachim	u_int32_t		Command;
1199250963Sachim	u_int32_t		MntType;
1200250963Sachim	u_int32_t		MntCount;
1201250963Sachim} __packed;
1202250963Sachim
1203250963Sachimstruct aac_mntinforesp {
1204250963Sachim	u_int32_t		Status;
1205250963Sachim	u_int32_t		MntType;
1206250963Sachim	u_int32_t		MntRespCount;
1207250963Sachim	struct aac_mntobj	MntTable[1];
1208250963Sachim} __packed;
1209250963Sachim
1210250963Sachim/*
1211250963Sachim * Container shutdown command.
1212250963Sachim */
1213250963Sachimstruct aac_closecommand {
1214250963Sachim	u_int32_t	Command;
1215250963Sachim	u_int32_t	ContainerId;
1216250963Sachim} __packed;
1217250963Sachim
1218250963Sachim/*
1219250963Sachim * Container Config Command
1220250963Sachim */
1221250963Sachimstruct aac_ctcfg {
1222250963Sachim	u_int32_t		Command;
1223250963Sachim	u_int32_t		cmd;
1224250963Sachim	u_int32_t		param;
1225250963Sachim} __packed;
1226250963Sachim
1227250963Sachimstruct aac_ctcfg_resp {
1228250963Sachim	u_int32_t		Status;
1229250963Sachim	u_int32_t		resp;
1230250963Sachim	u_int32_t		param;
1231250963Sachim} __packed;
1232250963Sachim
1233250963Sachim/*
1234250963Sachim * 'Ioctl' commads
1235250963Sachim */
1236250963Sachim#define AAC_SCSI_MAX_PORTS	10
1237250963Sachim#define AAC_BUS_NO_EXIST	0
1238250963Sachim#define AAC_BUS_VALID		1
1239250963Sachim#define AAC_BUS_FAULTED		2
1240250963Sachim#define AAC_BUS_DISABLED	3
1241250963Sachim#define GetBusInfo		0x9
1242250963Sachim
1243250963Sachimstruct aac_getbusinf {
1244250963Sachim	u_int32_t		ProbeComplete;
1245250963Sachim	u_int32_t		BusCount;
1246250963Sachim	u_int32_t		TargetsPerBus;
1247250963Sachim	u_int8_t		InitiatorBusId[AAC_SCSI_MAX_PORTS];
1248250963Sachim	u_int8_t		BusValid[AAC_SCSI_MAX_PORTS];
1249250963Sachim} __packed;
1250250963Sachim
1251250963Sachimstruct aac_vmioctl {
1252250963Sachim	u_int32_t		Command;
1253250963Sachim	u_int32_t		ObjType;
1254250963Sachim	u_int32_t		MethId;
1255250963Sachim	u_int32_t		ObjId;
1256250963Sachim	u_int32_t		IoctlCmd;
1257250963Sachim	u_int32_t		IoctlBuf[1];	/* Placeholder? */
1258250963Sachim} __packed;
1259250963Sachim
1260250963Sachimstruct aac_vmi_businf_resp {
1261250963Sachim	u_int32_t		Status;
1262250963Sachim	u_int32_t		ObjType;
1263250963Sachim	u_int32_t		MethId;
1264250963Sachim	u_int32_t		ObjId;
1265250963Sachim	u_int32_t		IoctlCmd;
1266250963Sachim	struct aac_getbusinf	BusInf;
1267250963Sachim} __packed;
1268250963Sachim
1269250963Sachimstruct aac_vmi_devinfo_resp {
1270250963Sachim	u_int32_t		Status;
1271250963Sachim	u_int32_t		ObjType;
1272250963Sachim	u_int32_t		MethId;
1273250963Sachim	u_int32_t		ObjId;
1274250963Sachim	u_int32_t		IoctlCmd;
1275250963Sachim	u_int8_t		VendorId[8];
1276250963Sachim	u_int8_t		ProductId[16];
1277250963Sachim	u_int8_t		ProductRev[4];
1278250963Sachim	u_int32_t		Inquiry7;
1279250963Sachim	u_int32_t		align1;
1280250963Sachim	u_int32_t		Inquiry0;
1281250963Sachim	u_int32_t		align2;
1282250963Sachim	u_int32_t		Inquiry1;
1283250963Sachim	u_int32_t		align3;
1284250963Sachim	u_int32_t		reserved[2];
1285250963Sachim	u_int8_t		VendorSpecific[20];
1286250963Sachim	u_int32_t		Smart:1;
1287250963Sachim	u_int32_t		AAC_Managed:1;
1288250963Sachim	u_int32_t		align4;
1289250963Sachim	u_int32_t		reserved2:6;
1290250963Sachim	u_int32_t		Bus;
1291250963Sachim	u_int32_t		Target;
1292250963Sachim	u_int32_t		Lun;
1293250963Sachim	u_int32_t		ultraEnable:1,
1294250963Sachim				disconnectEnable:1,
1295250963Sachim				fast20EnabledW:1,
1296250963Sachim				scamDevice:1,
1297250963Sachim				scamTolerant:1,
1298250963Sachim				setForSync:1,
1299250963Sachim				setForWide:1,
1300250963Sachim				syncDevice:1,
1301250963Sachim				wideDevice:1,
1302250963Sachim				reserved1:7,
1303250963Sachim				ScsiRate:8,
1304250963Sachim				ScsiOffset:8;
1305250963Sachim}; /* Do not pack */
1306250963Sachim
1307250963Sachim#define ResetBus 0x16
1308250963Sachimstruct aac_resetbus {
1309250963Sachim	u_int32_t		BusNumber;
1310250963Sachim};
1311250963Sachim
1312250963Sachim/*
1313250963Sachim * Write 'stability' options.
1314250963Sachim */
1315250963Sachimtypedef enum {
1316250963Sachim	CSTABLE = 1,
1317250963Sachim	CUNSTABLE
1318250963Sachim} AAC_CacheLevel;
1319250963Sachim
1320250963Sachim/*
1321250963Sachim * Commit level response for a write request.
1322250963Sachim */
1323250963Sachimtypedef enum {
1324250963Sachim	CMFILE_SYNC_NVRAM = 1,
1325250963Sachim	CMDATA_SYNC_NVRAM,
1326250963Sachim	CMFILE_SYNC,
1327250963Sachim	CMDATA_SYNC,
1328250963Sachim	CMUNSTABLE
1329250963Sachim} AAC_CommitLevel;
1330250963Sachim
1331250963Sachim
1332250963Sachim#define	CT_FIB_PARAMS			6
1333250963Sachim#define	MAX_FIB_PARAMS			10
1334250963Sachim#define	CT_PACKET_SIZE \
1335250963Sachim	(AAC_FIB_DATASIZE - sizeof (u_int32_t) - \
1336250963Sachim	((sizeof (u_int32_t)) * (MAX_FIB_PARAMS + 1)))
1337250963Sachim
1338250963Sachimstruct aac_fsa_ctm {
1339250963Sachim	u_int32_t	command;
1340250963Sachim	u_int32_t	param[CT_FIB_PARAMS];
1341250963Sachim	int8_t		data[CT_PACKET_SIZE];
1342250963Sachim};
1343250963Sachim
1344250963Sachimstruct aac_cnt_config {
1345250963Sachim	u_int32_t		Command;
1346250963Sachim	struct aac_fsa_ctm	CTCommand;
1347250963Sachim};
1348250963Sachim
1349250963Sachim/*
1350250963Sachim * Block read/write operations.
1351250963Sachim * These structures are packed into the 'data' area in the FIB.
1352250963Sachim */
1353250963Sachim
1354250963Sachimstruct aac_blockread {
1355250963Sachim	u_int32_t		Command;	/* not FSACommand! */
1356250963Sachim	u_int32_t		ContainerId;
1357250963Sachim	u_int32_t		BlockNumber;
1358250963Sachim	u_int32_t		ByteCount;
1359250963Sachim	struct aac_sg_table	SgMap;		/* variable size */
1360250963Sachim} __packed;
1361250963Sachim
1362250963Sachimstruct aac_blockread64 {
1363250963Sachim	u_int32_t		Command;
1364250963Sachim	u_int16_t		ContainerId;
1365250963Sachim	u_int16_t		SectorCount;
1366250963Sachim	u_int32_t		BlockNumber;
1367250963Sachim	u_int16_t		Pad;
1368250963Sachim	u_int16_t		Flags;
1369250963Sachim	struct aac_sg_table64	SgMap64;
1370250963Sachim} __packed;
1371250963Sachim
1372250963Sachimstruct aac_blockread_response {
1373250963Sachim	u_int32_t		Status;
1374250963Sachim	u_int32_t		ByteCount;
1375250963Sachim} __packed;
1376250963Sachim
1377250963Sachimstruct aac_blockwrite {
1378250963Sachim	u_int32_t		Command;	/* not FSACommand! */
1379250963Sachim	u_int32_t		ContainerId;
1380250963Sachim	u_int32_t		BlockNumber;
1381250963Sachim	u_int32_t		ByteCount;
1382250963Sachim	u_int32_t		Stable;
1383250963Sachim	struct aac_sg_table	SgMap;		/* variable size */
1384250963Sachim} __packed;
1385250963Sachim
1386250963Sachimstruct aac_blockwrite64 {
1387250963Sachim	u_int32_t		Command;	/* not FSACommand! */
1388250963Sachim	u_int16_t		ContainerId;
1389250963Sachim	u_int16_t		SectorCount;
1390250963Sachim	u_int32_t		BlockNumber;
1391250963Sachim	u_int16_t		Pad;
1392250963Sachim	u_int16_t		Flags;
1393250963Sachim	struct aac_sg_table64	SgMap64;	/* variable size */
1394250963Sachim} __packed;
1395250963Sachim
1396250963Sachimstruct aac_blockwrite_response {
1397250963Sachim	u_int32_t		Status;
1398250963Sachim	u_int32_t		ByteCount;
1399250963Sachim	u_int32_t		Committed;
1400250963Sachim} __packed;
1401250963Sachim
1402250963Sachimstruct aac_raw_io {
1403250963Sachim	u_int64_t		BlockNumber;
1404250963Sachim	u_int32_t		ByteCount;
1405250963Sachim	u_int16_t		ContainerId;
1406250963Sachim	u_int16_t		Flags;				/* 0: W, 1: R */
1407250963Sachim	u_int16_t		BpTotal;			/* reserved for FW use */
1408250963Sachim	u_int16_t		BpComplete;			/* reserved for FW use */
1409250963Sachim	struct aac_sg_tableraw	SgMapRaw;	/* variable size */
1410250963Sachim} __packed;
1411250963Sachim
1412250963Sachim#define RIO2_IO_TYPE		0x0003
1413250963Sachim#define RIO2_IO_TYPE_WRITE	0x0000
1414250963Sachim#define RIO2_IO_TYPE_READ	0x0001
1415250963Sachim#define RIO2_IO_TYPE_VERIFY	0x0002
1416250963Sachim#define RIO2_IO_ERROR		0x0004
1417250963Sachim#define RIO2_IO_SUREWRITE	0x0008
1418250963Sachim#define RIO2_SGL_CONFORMANT	0x0010
1419250963Sachim#define RIO2_SG_FORMAT		0xF000
1420250963Sachim#define RIO2_SG_FORMAT_ARC	0x0000
1421250963Sachim#define RIO2_SG_FORMAT_SRL	0x1000
1422250963Sachim#define RIO2_SG_FORMAT_IEEE1212	0x2000
1423250963Sachimstruct aac_raw_io2 {
1424250963Sachim	u_int32_t		strtBlkLow;
1425250963Sachim	u_int32_t		strtBlkHigh;
1426250963Sachim	u_int32_t		byteCnt;
1427250963Sachim	u_int16_t		ldNum;
1428250963Sachim	u_int16_t		flags;				/* RIO2_xxx */
1429250963Sachim	u_int32_t		sgeFirstSize;		/* size of first SG element */
1430250963Sachim	u_int32_t		sgeNominalSize;		/* size of 2nd SG element */
1431250963Sachim	u_int8_t		sgeCnt;
1432250963Sachim	u_int8_t		bpTotal;			/* reserved for FW use */
1433250963Sachim	u_int8_t		bpComplete;			/* reserved for FW use */
1434250963Sachim	u_int8_t		sgeFirstIndex;		/* reserved for FW use */
1435250963Sachim	u_int8_t		unused[4];
1436250963Sachim	struct aac_sge_ieee1212	sge[0];		/* variable size */
1437250963Sachim} __packed;
1438250963Sachim
1439250963Sachim/*
1440250963Sachim * Container shutdown command.
1441250963Sachim */
1442250963Sachimstruct aac_close_command {
1443250963Sachim	u_int32_t		Command;
1444250963Sachim	u_int32_t		ContainerId;
1445250963Sachim} __packed;
1446250963Sachim
1447250963Sachim/*
1448250963Sachim * SCSI Passthrough structures
1449250963Sachim */
1450250963Sachimstruct aac_srb {
1451250963Sachim	u_int32_t		function;
1452250963Sachim	u_int32_t		bus;
1453250963Sachim	u_int32_t		target;
1454250963Sachim	u_int32_t		lun;
1455250963Sachim	u_int32_t		timeout;
1456250963Sachim	u_int32_t		flags;
1457250963Sachim	u_int32_t		data_len;
1458250963Sachim	u_int32_t		retry_limit;
1459250963Sachim	u_int32_t		cdb_len;
1460250963Sachim	u_int8_t		cdb[16];
1461250963Sachim	struct aac_sg_table	sg_map;
1462250963Sachim} __packed;
1463250963Sachim
1464250963Sachimenum {
1465250963Sachim	AAC_SRB_FUNC_EXECUTE_SCSI	= 0x00,
1466250963Sachim	AAC_SRB_FUNC_CLAIM_DEVICE,
1467250963Sachim	AAC_SRB_FUNC_IO_CONTROL,
1468250963Sachim	AAC_SRB_FUNC_RECEIVE_EVENT,
1469250963Sachim	AAC_SRB_FUNC_RELEASE_QUEUE,
1470250963Sachim	AAC_SRB_FUNC_ATTACH_DEVICE,
1471250963Sachim	AAC_SRB_FUNC_RELEASE_DEVICE,
1472250963Sachim	AAC_SRB_FUNC_SHUTDOWN,
1473250963Sachim	AAC_SRB_FUNC_FLUSH,
1474250963Sachim	AAC_SRB_FUNC_ABORT_COMMAND	= 0x10,
1475250963Sachim	AAC_SRB_FUNC_RELEASE_RECOVERY,
1476250963Sachim	AAC_SRB_FUNC_RESET_BUS,
1477250963Sachim	AAC_SRB_FUNC_RESET_DEVICE,
1478250963Sachim	AAC_SRB_FUNC_TERMINATE_IO,
1479250963Sachim	AAC_SRB_FUNC_FLUSH_QUEUE,
1480250963Sachim	AAC_SRB_FUNC_REMOVE_DEVICE,
1481250963Sachim	AAC_SRB_FUNC_DOMAIN_VALIDATION
1482250963Sachim};
1483250963Sachim
1484250963Sachim#define AAC_SRB_FLAGS_NO_DATA_XFER		0x0000
1485250963Sachim#define	AAC_SRB_FLAGS_DISABLE_DISCONNECT	0x0004
1486250963Sachim#define	AAC_SRB_FLAGS_DISABLE_SYNC_TRANSFER	0x0008
1487250963Sachim#define AAC_SRB_FLAGS_BYPASS_FROZEN_QUEUE	0x0010
1488250963Sachim#define	AAC_SRB_FLAGS_DISABLE_AUTOSENSE		0x0020
1489250963Sachim#define	AAC_SRB_FLAGS_DATA_IN			0x0040
1490250963Sachim#define AAC_SRB_FLAGS_DATA_OUT			0x0080
1491250963Sachim#define	AAC_SRB_FLAGS_UNSPECIFIED_DIRECTION \
1492250963Sachim			(AAC_SRB_FLAGS_DATA_IN | AAC_SRB_FLAGS_DATA_OUT)
1493250963Sachim
1494250963Sachim#define AAC_HOST_SENSE_DATA_MAX			30
1495250963Sachim
1496250963Sachimstruct aac_srb_response {
1497250963Sachim	u_int32_t	fib_status;
1498250963Sachim	u_int32_t	srb_status;
1499250963Sachim	u_int32_t	scsi_status;
1500250963Sachim	u_int32_t	data_len;
1501250963Sachim	u_int32_t	sense_len;
1502250963Sachim	u_int8_t	sense[AAC_HOST_SENSE_DATA_MAX];
1503250963Sachim} __packed;
1504250963Sachim
1505250963Sachim/*
1506250963Sachim * Status codes for SCSI passthrough commands.  Since they are based on ASPI,
1507250963Sachim * they also exactly match CAM status codes in both enumeration and meaning.
1508250963Sachim * They seem to also be used as status codes for synchronous FIBs.
1509250963Sachim */
1510250963Sachimenum {
1511250963Sachim	AAC_SRB_STS_PENDING			= 0x00,
1512250963Sachim	AAC_SRB_STS_SUCCESS,
1513250963Sachim	AAC_SRB_STS_ABORTED,
1514250963Sachim	AAC_SRB_STS_ABORT_FAILED,
1515250963Sachim	AAC_SRB_STS_ERROR,
1516250963Sachim	AAC_SRB_STS_BUSY,
1517250963Sachim	AAC_SRB_STS_INVALID_REQUEST,
1518250963Sachim	AAC_SRB_STS_INVALID_PATH_ID,
1519250963Sachim	AAC_SRB_STS_NO_DEVICE,
1520250963Sachim	AAC_SRB_STS_TIMEOUT,
1521250963Sachim	AAC_SRB_STS_SELECTION_TIMEOUT,
1522250963Sachim	AAC_SRB_STS_COMMAND_TIMEOUT,
1523250963Sachim	AAC_SRB_STS_MESSAGE_REJECTED		= 0x0D,
1524250963Sachim	AAC_SRB_STS_BUS_RESET,
1525250963Sachim	AAC_SRB_STS_PARITY_ERROR,
1526250963Sachim	AAC_SRB_STS_REQUEST_SENSE_FAILED,
1527250963Sachim	AAC_SRB_STS_NO_HBA,
1528250963Sachim	AAC_SRB_STS_DATA_OVERRUN,
1529250963Sachim	AAC_SRB_STS_UNEXPECTED_BUS_FREE,
1530250963Sachim	AAC_SRB_STS_PHASE_SEQUENCE_FAILURE,
1531250963Sachim	AAC_SRB_STS_BAD_SRB_BLOCK_LENGTH,
1532250963Sachim	AAC_SRB_STS_REQUEST_FLUSHED,
1533250963Sachim	AAC_SRB_STS_INVALID_LUN			= 0x20,
1534250963Sachim	AAC_SRB_STS_INVALID_TARGET_ID,
1535250963Sachim	AAC_SRB_STS_BAD_FUNCTION,
1536250963Sachim	AAC_SRB_STS_ERROR_RECOVERY
1537250963Sachim};
1538250963Sachim
1539250963Sachim/*
1540250963Sachim * Register definitions for the Adaptec PMC SRC/SRCv adapters.
1541250963Sachim */
1542250963Sachim/* accessible via BAR0 */
1543250963Sachim#define AAC_SRC_OMR			0xbc	/* outbound message register */
1544250963Sachim#define AAC_SRC_IDBR		0x20	/* inbound doorbell register */
1545250963Sachim#define AAC_SRC_IISR		0x24	/* inbound interrupt status register */
1546250963Sachim#define AAC_SRC_ODBR_R		0x9c	/* outbound doorbell register read */
1547250963Sachim#define AAC_SRC_ODBR_C		0xa0	/* outbound doorbell register clear */
1548250963Sachim#define AAC_SRC_OIMR		0x34	/* outbound interrupt mask register */
1549250963Sachim#define AAC_SRC_IQUE32		0x40	/* inbound queue address 32-bit */
1550250963Sachim#define AAC_SRC_IQUE64_L	0xc0	/* inbound queue address 64-bit (low) */
1551250963Sachim#define AAC_SRC_IQUE64_H	0xc4	/* inbound queue address 64-bit (high) */
1552250963Sachim
1553250963Sachim#define AAC_SRC_MAILBOX		0x7fc60	/* mailbox (20 bytes) */
1554250963Sachim#define AAC_SRCV_MAILBOX	0x1000	/* mailbox (20 bytes) */
1555250963Sachim
1556250963Sachim#define AAC_SRC_ODR_SHIFT 	12		/* outbound doorbell shift */
1557250963Sachim#define AAC_SRC_IDR_SHIFT 	9		/* inbound doorbell shift */
1558250963Sachim
1559250963Sachim/* Sunrise Lake dual core reset */
1560250963Sachim#define AAC_IRCSR		0x38	/* inbound dual cores reset */
1561250963Sachim#define AAC_IRCSR_CORES_RST	3
1562250963Sachim
1563250963Sachim
1564250963Sachim/*
1565250963Sachim * Common bit definitions for the doorbell registers.
1566250963Sachim */
1567250963Sachim
1568250963Sachim/*
1569250963Sachim * Status bits in the doorbell registers.
1570250963Sachim */
1571250963Sachim#define AAC_DB_SYNC_COMMAND	(1<<0)	/* send/completed synchronous FIB */
1572250963Sachim#define AAC_DB_COMMAND_READY	(1<<1)	/* posted one or more commands */
1573250963Sachim#define AAC_DB_RESPONSE_READY	(1<<2)	/* one or more commands complete */
1574250963Sachim#define AAC_DB_COMMAND_NOT_FULL	(1<<3)	/* command queue not full */
1575250963Sachim#define AAC_DB_RESPONSE_NOT_FULL (1<<4)	/* response queue not full */
1576250963Sachim#define AAC_DB_AIF_PENDING		(1<<6)	/* pending AIF (new comm. type1) */
1577250963Sachim/* PMC specific outbound doorbell bits */
1578250963Sachim#define AAC_DB_RESPONSE_SENT_NS		(1<<1)	/* response sent (not shifted) */
1579250963Sachim
1580250963Sachim/*
1581250963Sachim * The adapter can request the host print a message by setting the
1582250963Sachim * DB_PRINTF flag in DOORBELL0.  The driver responds by collecting the
1583250963Sachim * message from the printf buffer, clearing the DB_PRINTF flag in
1584250963Sachim * DOORBELL0 and setting it in DOORBELL1.
1585250963Sachim * (ODBR and IDBR respectively for the i960Rx adapters)
1586250963Sachim */
1587250963Sachim#define AAC_DB_PRINTF		(1<<5)	/* adapter requests host printf */
1588250963Sachim#define AAC_PRINTF_DONE		(1<<5)	/* Host completed printf processing */
1589250963Sachim
1590250963Sachim/*
1591250963Sachim * Mask containing the interrupt bits we care about.  We don't anticipate (or
1592250963Sachim * want) interrupts not in this mask.
1593250963Sachim */
1594250963Sachim#define AAC_DB_INTERRUPTS	(AAC_DB_COMMAND_READY  |	\
1595250963Sachim				 AAC_DB_RESPONSE_READY |	\
1596250963Sachim				 AAC_DB_PRINTF)
1597250963Sachim#define AAC_DB_INT_NEW_COMM		0x08
1598250963Sachim#define AAC_DB_INT_NEW_COMM_TYPE1	0x04
1599