aacreg.h revision 81082
1238104Sdes/*-
2238104Sdes * Copyright (c) 2000 Michael Smith
3238104Sdes * Copyright (c) 2001 Scott Long
4238104Sdes * Copyright (c) 2000 BSDi
5238104Sdes * Copyright (c) 2001 Adaptec, Inc.
6238104Sdes * All rights reserved.
7238104Sdes *
8238104Sdes * Redistribution and use in source and binary forms, with or without
9238104Sdes * modification, are permitted provided that the following conditions
10238104Sdes * are met:
11238104Sdes * 1. Redistributions of source code must retain the above copyright
12238104Sdes *    notice, this list of conditions and the following disclaimer.
13238104Sdes * 2. Redistributions in binary form must reproduce the above copyright
14238104Sdes *    notice, this list of conditions and the following disclaimer in the
15238104Sdes *    documentation and/or other materials provided with the distribution.
16238104Sdes *
17238104Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18238104Sdes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19238104Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20238104Sdes * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21238104Sdes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22238104Sdes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23238104Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24238104Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25238104Sdes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26238104Sdes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27238104Sdes * SUCH DAMAGE.
28238104Sdes *
29238104Sdes *	$FreeBSD: head/sys/dev/aac/aacreg.h 81082 2001-08-03 00:50:30Z scottl $
30238104Sdes */
31238104Sdes
32238104Sdes/*
33238104Sdes * Data structures defining the interface between the driver and the Adaptec
34238104Sdes * 'FSA' adapters.  Note that many field names and comments here are taken
35238104Sdes * verbatim from the Adaptec driver source in order to make comparing the
36238104Sdes * two slightly easier.
37238104Sdes */
38238104Sdes
39238104Sdes/******************************************************************************
40238104Sdes * Misc. magic numbers.
41238104Sdes */
42238104Sdes#define AAC_MAX_CONTAINERS	64
43238104Sdes#define AAC_BLOCK_SIZE		512
44238104Sdes
45238104Sdes/******************************************************************************
46238104Sdes * Communications interface.
47238104Sdes *
48238104Sdes * Where datastructure layouts are closely parallel to the Adaptec sample code,
49238104Sdes * retain their naming conventions (for now) to aid in cross-referencing.
50238104Sdes */
51238104Sdes
52238104Sdes/*
53238104Sdes * We establish 4 command queues and matching response queues.  Queues must
54238104Sdes * be 16-byte aligned, and are sized as follows:
55238104Sdes */
56238104Sdes#define AAC_HOST_NORM_CMD_ENTRIES	8	/* command adapter->host,
57238104Sdes						 * normal priority */
58238104Sdes#define AAC_HOST_HIGH_CMD_ENTRIES	4	/* command adapter->host,
59238104Sdes						 * high priority */
60238104Sdes#define AAC_ADAP_NORM_CMD_ENTRIES	512	/* command host->adapter,
61238104Sdes						 * normal priority */
62238104Sdes#define AAC_ADAP_HIGH_CMD_ENTRIES	4	/* command host->adapter,
63238104Sdes						 * high priority */
64238104Sdes#define AAC_HOST_NORM_RESP_ENTRIES	512	/* response, adapter->host,
65238104Sdes						 * normal priority */
66238104Sdes#define AAC_HOST_HIGH_RESP_ENTRIES	4	/* response, adapter->host,
67238104Sdes						 * high priority */
68238104Sdes#define AAC_ADAP_NORM_RESP_ENTRIES	8	/* response, host->adapter,
69238104Sdes						 * normal priority */
70238104Sdes#define AAC_ADAP_HIGH_RESP_ENTRIES	4	/* response, host->adapter,
71238104Sdes						 * high priority */
72238104Sdes
73238104Sdes#define AAC_TOTALQ_LENGTH	(AAC_HOST_HIGH_CMD_ENTRIES +	\
74238104Sdes				 AAC_HOST_NORM_CMD_ENTRIES +	\
75238104Sdes				 AAC_ADAP_HIGH_CMD_ENTRIES +	\
76238104Sdes				 AAC_ADAP_NORM_CMD_ENTRIES +	\
77238104Sdes				 AAC_HOST_HIGH_RESP_ENTRIES +	\
78238104Sdes				 AAC_HOST_NORM_RESP_ENTRIES +	\
79238104Sdes				 AAC_ADAP_HIGH_RESP_ENTRIES +	\
80238104Sdes				 AAC_ADAP_NORM_RESP_ENTRIES)
81238104Sdes#define AAC_QUEUE_COUNT		8
82238104Sdes#define AAC_QUEUE_ALIGN		16
83238104Sdes
84238104Sdesstruct aac_queue_entry {
85238104Sdes    u_int32_t	aq_fib_size;		/* FIB size in bytes */
86238104Sdes    u_int32_t	aq_fib_addr;		/* receiver-space address of the FIB */
87238104Sdes} __attribute__ ((packed));
88238104Sdes
89238104Sdes#define AAC_PRODUCER_INDEX	0
90238104Sdes#define AAC_CONSUMER_INDEX	1
91238104Sdes
92238104Sdes/*
93238104Sdes * Table of queue indices and queues used to communicate with the
94238104Sdes * controller.  This structure must be aligned to AAC_QUEUE_ALIGN
95238104Sdes */
96238104Sdesstruct aac_queue_table {
97238104Sdes    /* queue consumer/producer indexes (layout mandated by adapter) */
98238104Sdes    u_int32_t			qt_qindex[AAC_QUEUE_COUNT][2];
99238104Sdes
100238104Sdes    /* queue entry structures (layout mandated by adapter) */
101238104Sdes    struct aac_queue_entry     qt_HostNormCmdQueue [AAC_HOST_NORM_CMD_ENTRIES];
102238104Sdes    struct aac_queue_entry     qt_HostHighCmdQueue [AAC_HOST_HIGH_CMD_ENTRIES];
103238104Sdes    struct aac_queue_entry     qt_AdapNormCmdQueue [AAC_ADAP_NORM_CMD_ENTRIES];
104238104Sdes    struct aac_queue_entry     qt_AdapHighCmdQueue [AAC_ADAP_HIGH_CMD_ENTRIES];
105238104Sdes    struct aac_queue_entry     qt_HostNormRespQueue[AAC_HOST_NORM_RESP_ENTRIES];
106238104Sdes    struct aac_queue_entry     qt_HostHighRespQueue[AAC_HOST_HIGH_RESP_ENTRIES];
107238104Sdes    struct aac_queue_entry     qt_AdapNormRespQueue[AAC_ADAP_NORM_RESP_ENTRIES];
108238104Sdes    struct aac_queue_entry     qt_AdapHighRespQueue[AAC_ADAP_HIGH_RESP_ENTRIES];
109238104Sdes} __attribute__ ((packed));
110238104Sdes
111238104Sdes/*
112238104Sdes * Queue names
113238104Sdes *
114238104Sdes * Note that we base these at 0 in order to use them as array indices.  Adaptec
115238104Sdes * used base 1 for some unknown reason, and sorted them in a different order.
116238104Sdes */
117238104Sdes#define AAC_HOST_NORM_CMD_QUEUE		0
118238104Sdes#define AAC_HOST_HIGH_CMD_QUEUE		1
119238104Sdes#define AAC_ADAP_NORM_CMD_QUEUE		2
120238104Sdes#define AAC_ADAP_HIGH_CMD_QUEUE		3
121238104Sdes#define AAC_HOST_NORM_RESP_QUEUE	4
122246854Sdes#define AAC_HOST_HIGH_RESP_QUEUE	5
123238104Sdes#define AAC_ADAP_NORM_RESP_QUEUE	6
124238104Sdes#define AAC_ADAP_HIGH_RESP_QUEUE	7
125238104Sdes
126238104Sdes/*
127238104Sdes * List structure used to chain FIBs (used by the adapter - we hang FIBs off
128238104Sdes * our private command structure and don't touch these)
129238104Sdes */
130238104Sdesstruct aac_fib_list_entry {
131238104Sdes    struct fib_list_entry	*Flink;
132238104Sdes    struct fib_list_entry	*Blink;
133238104Sdes} __attribute__ ((packed));
134238104Sdes
135238104Sdes/*
136238104Sdes * FIB (FSA Interface Block?); this is the datastructure passed between the host
137238104Sdes * and adapter.
138238104Sdes */
139238104Sdesstruct aac_fib_header {
140238104Sdes    u_int32_t		XferState;
141238104Sdes    u_int16_t		Command;
142238104Sdes    u_int8_t		StructType;
143238104Sdes    u_int8_t		Flags;
144238104Sdes    u_int16_t		Size;
145238104Sdes    u_int16_t		SenderSize;
146238104Sdes    u_int32_t		SenderFibAddress;
147238104Sdes    u_int32_t		ReceiverFibAddress;
148238104Sdes    u_int32_t		SenderData;
149238104Sdes    union {
150238104Sdes	struct {
151238104Sdes	    u_int32_t	ReceiverTimeStart;
152238104Sdes	    u_int32_t	ReceiverTimeDone;
153238104Sdes	} _s;
154238104Sdes	struct aac_fib_list_entry FibLinks;
155238104Sdes    } _u;
156238104Sdes} __attribute__ ((packed));
157238104Sdes
158238104Sdes#define AAC_FIB_DATASIZE	(512 - sizeof(struct aac_fib_header))
159238104Sdes
160238104Sdesstruct aac_fib {
161238104Sdes    struct aac_fib_header	Header;
162238104Sdes    u_int8_t			data[AAC_FIB_DATASIZE];
163238104Sdes} __attribute__ ((packed));
164238104Sdes
165238104Sdes/*
166238104Sdes * FIB commands
167238104Sdes */
168238104Sdestypedef enum {
169238104Sdes    TestCommandResponse =		1,
170238104Sdes    TestAdapterCommand =		2,
171238104Sdes
172238104Sdes    /* lowlevel and comm commands */
173238104Sdes    LastTestCommand =			100,
174238104Sdes    ReinitHostNormCommandQueue =	101,
175238104Sdes    ReinitHostHighCommandQueue =	102,
176238104Sdes    ReinitHostHighRespQueue =		103,
177238104Sdes    ReinitHostNormRespQueue =		104,
178238104Sdes    ReinitAdapNormCommandQueue =	105,
179238104Sdes    ReinitAdapHighCommandQueue =	107,
180238104Sdes    ReinitAdapHighRespQueue =		108,
181238104Sdes    ReinitAdapNormRespQueue =		109,
182238104Sdes    InterfaceShutdown =			110,
183238104Sdes    DmaCommandFib =			120,
184238104Sdes    StartProfile =			121,
185238104Sdes    TermProfile =			122,
186238104Sdes    SpeedTest =				123,
187238104Sdes    TakeABreakPt =			124,
188238104Sdes    RequestPerfData =			125,
189238104Sdes    SetInterruptDefTimer=		126,
190238104Sdes    SetInterruptDefCount=		127,
191238104Sdes    GetInterruptDefStatus=		128,
192238104Sdes    LastCommCommand =			129,
193238104Sdes
194238104Sdes    /* filesystem commands */
195238104Sdes    NuFileSystem =			300,
196238104Sdes    UFS =				301,
197238104Sdes    HostFileSystem =			302,
198238104Sdes    LastFileSystemCommand =		303,
199238104Sdes
200238104Sdes    /* Container Commands */
201238104Sdes    ContainerCommand =			500,
202238104Sdes    ContainerCommand64 =		501,
203238104Sdes
204238104Sdes    /* Cluster Commands */
205238104Sdes    ClusterCommand =			550,
206238104Sdes
207238104Sdes    /* Scsi Port commands (scsi passthrough) */
208238104Sdes    ScsiPortCommand =			600,
209238104Sdes
210238104Sdes    /* misc house keeping and generic adapter initiated commands */
211238104Sdes    AifRequest =			700,
212238104Sdes    CheckRevision =			701,
213238104Sdes    FsaHostShutdown =			702,
214238104Sdes    RequestAdapterInfo =		703,
215238104Sdes    IsAdapterPaused =			704,
216238104Sdes    SendHostTime =			705,
217238104Sdes    LastMiscCommand =			706
218238104Sdes} AAC_FibCommands;
219238104Sdes
220238104Sdes/*
221238104Sdes * FIB types
222238104Sdes */
223238104Sdes#define AAC_FIBTYPE_TFIB	1
224238104Sdes#define AAC_FIBTYPE_TQE		2
225238104Sdes#define AAC_FIBTYPE_TCTPERF	3
226238104Sdes
227238104Sdes/*
228238104Sdes * FIB transfer state
229238104Sdes */
230238104Sdes#define AAC_FIBSTATE_HOSTOWNED		(1<<0)	/* owned by the host */
231238104Sdes#define AAC_FIBSTATE_ADAPTEROWNED	(1<<1)	/* owned by the adapter */
232238104Sdes#define AAC_FIBSTATE_INITIALISED	(1<<2)	/* initialised */
233238104Sdes#define AAC_FIBSTATE_EMPTY		(1<<3)	/* empty */
234238104Sdes#define AAC_FIBSTATE_FROMPOOL		(1<<4)	/* allocated from pool */
235238104Sdes#define AAC_FIBSTATE_FROMHOST		(1<<5)	/* sent from the host */
236238104Sdes#define AAC_FIBSTATE_FROMADAP		(1<<6)	/* sent from the adapter */
237238104Sdes#define AAC_FIBSTATE_REXPECTED		(1<<7)	/* response is expected */
238238104Sdes#define AAC_FIBSTATE_RNOTEXPECTED	(1<<8)	/* response is not expected */
239238104Sdes#define AAC_FIBSTATE_DONEADAP		(1<<9)	/* processed by the adapter */
240238104Sdes#define AAC_FIBSTATE_DONEHOST		(1<<10)	/* processed by the host */
241238104Sdes#define AAC_FIBSTATE_HIGH		(1<<11)	/* high priority */
242238104Sdes#define AAC_FIBSTATE_NORM		(1<<12)	/* normal priority */
243238104Sdes#define AAC_FIBSTATE_ASYNC		(1<<13)
244238104Sdes#define AAC_FIBSTATE_ASYNCIO		(1<<13)	/* to be removed */
245238104Sdes#define AAC_FIBSTATE_PAGEFILEIO		(1<<14)	/* to be removed */
246238104Sdes#define AAC_FIBSTATE_SHUTDOWN		(1<<15)
247238104Sdes#define AAC_FIBSTATE_LAZYWRITE		(1<<16)	/* to be removed */
248238104Sdes#define AAC_FIBSTATE_ADAPMICROFIB	(1<<17)
249238104Sdes#define AAC_FIBSTATE_BIOSFIB		(1<<18)
250238104Sdes#define AAC_FIBSTATE_FAST_RESPONSE	(1<<19)	/* fast response capable */
251238104Sdes#define AAC_FIBSTATE_APIFIB		(1<<20)
252238104Sdes
253238104Sdes/*
254238104Sdes * FIB error values
255238104Sdes */
256238104Sdes#define AAC_ERROR_NORMAL			0x00
257238104Sdes#define AAC_ERROR_PENDING			0x01
258238104Sdes#define AAC_ERROR_FATAL				0x02
259238104Sdes#define AAC_ERROR_INVALID_QUEUE			0x03
260238104Sdes#define AAC_ERROR_NOENTRIES			0x04
261238104Sdes#define AAC_ERROR_SENDFAILED			0x05
262238104Sdes#define AAC_ERROR_INVALID_QUEUE_PRIORITY	0x06
263238104Sdes#define AAC_ERROR_FIB_ALLOCATION_FAILED		0x07
264238104Sdes#define AAC_ERROR_FIB_DEALLOCATION_FAILED	0x08
265238104Sdes
266238104Sdes/*
267238104Sdes * Adapter Init Structure: this is passed to the adapter with the
268238104Sdes * AAC_MONKER_INITSTRUCT command to point it at our control structures.
269238104Sdes */
270238104Sdesstruct aac_adapter_init {
271238104Sdes    u_int32_t	InitStructRevision;
272238104Sdes#define AAC_INIT_STRUCT_REVISION	3
273238104Sdes    u_int32_t	MiniPortRevision;
274238104Sdes    u_int32_t	FilesystemRevision;
275238104Sdes    u_int32_t	CommHeaderAddress;
276238104Sdes    u_int32_t	FastIoCommAreaAddress;
277238104Sdes    u_int32_t	AdapterFibsPhysicalAddress;
278238104Sdes    void	*AdapterFibsVirtualAddress;
279238104Sdes    u_int32_t	AdapterFibsSize;
280238104Sdes    u_int32_t	AdapterFibAlign;
281238104Sdes    u_int32_t	PrintfBufferAddress;
282238104Sdes    u_int32_t	PrintfBufferSize;
283238104Sdes    u_int32_t	HostPhysMemPages;
284238104Sdes    u_int32_t	HostElapsedSeconds;
285238104Sdes} __attribute__ ((packed));
286238104Sdes
287238104Sdes/******************************************************************************
288238104Sdes * Shared data types
289238104Sdes */
290238104Sdes/*
291238104Sdes * Container types
292238104Sdes */
293238104Sdestypedef enum {
294238104Sdes    CT_NONE = 0,
295238104Sdes    CT_VOLUME,
296238104Sdes    CT_MIRROR,
297238104Sdes    CT_STRIPE,
298238104Sdes    CT_RAID5,
299238104Sdes    CT_SSRW,
300238104Sdes    CT_SSRO,
301238104Sdes    CT_MORPH,
302238104Sdes    CT_PASSTHRU,
303238104Sdes    CT_RAID4,
304238104Sdes    CT_RAID10,                  /* stripe of mirror */
305238104Sdes    CT_RAID00,                  /* stripe of stripe */
306238104Sdes    CT_VOLUME_OF_MIRRORS,       /* volume of mirror */
307238104Sdes    CT_PSEUDO_RAID3,            /* really raid4 */
308238104Sdes} AAC_FSAVolType;
309238104Sdes
310238104Sdes/*
311238104Sdes * Host-addressable object types
312238104Sdes */
313238104Sdestypedef enum {
314238104Sdes    FT_REG = 1,     /* regular file */
315238104Sdes    FT_DIR,         /* directory */
316238104Sdes    FT_BLK,         /* "block" device - reserved */
317238104Sdes    FT_CHR,         /* "character special" device - reserved */
318238104Sdes    FT_LNK,         /* symbolic link */
319238104Sdes    FT_SOCK,        /* socket */
320238104Sdes    FT_FIFO,        /* fifo */
321238104Sdes    FT_FILESYS,     /* ADAPTEC's "FSA"(tm) filesystem */
322238104Sdes    FT_DRIVE,       /* physical disk - addressable in scsi by bus/target/lun */
323238104Sdes    FT_SLICE,       /* virtual disk - raw volume - slice */
324238104Sdes    FT_PARTITION,   /* FSA partition - carved out of a slice - building block
325238104Sdes		     * for containers */
326238104Sdes    FT_VOLUME,      /* Container - Volume Set */
327238104Sdes    FT_STRIPE,      /* Container - Stripe Set */
328238104Sdes    FT_MIRROR,      /* Container - Mirror Set */
329238104Sdes    FT_RAID5,       /* Container - Raid 5 Set */
330238104Sdes    FT_DATABASE     /* Storage object with "foreign" content manager */
331238104Sdes} AAC_FType;
332238104Sdes
333238104Sdes/*
334238104Sdes * Host-side scatter/gather list for 32-bit commands.
335238104Sdes */
336238104Sdesstruct aac_sg_entry {
337238104Sdes    u_int32_t	SgAddress;
338238104Sdes    u_int32_t	SgByteCount;
339238104Sdes} __attribute__ ((packed));
340238104Sdes
341238104Sdesstruct aac_sg_table {
342238104Sdes    u_int32_t		SgCount;
343238104Sdes    struct aac_sg_entry	SgEntry[0];
344238104Sdes} __attribute__ ((packed));
345238104Sdes
346238104Sdes/*
347238104Sdes * Host-side scatter/gather list for 64-bit commands.
348238104Sdes */
349238104Sdesstruct aac_sg_table64 {
350238104Sdes    u_int8_t	SgCount;
351238104Sdes    u_int8_t	SgSectorsPerPage;
352238104Sdes    u_int16_t	SgByteOffset;
353238104Sdes    u_int64_t	SgEntry[0];
354238104Sdes} __attribute__ ((packed));
355238104Sdes
356238104Sdes/*
357238104Sdes * Container creation data
358238104Sdes */
359238104Sdesstruct aac_container_creation {
360238104Sdes    u_int8_t	ViaBuildNumber;
361238104Sdes    u_int8_t	MicroSecond;
362238104Sdes    u_int8_t	Via;		/* 1 = FSU, 2 = API, etc. */
363238104Sdes    u_int8_t	YearsSince1900;
364238104Sdes    u_int32_t	Month:4;	/* 1-12 */
365238104Sdes    u_int32_t	Day:6;		/* 1-32 */
366238104Sdes    u_int32_t	Hour:6;		/* 0-23 */
367238104Sdes    u_int32_t	Minute:6;	/* 0-59 */
368238104Sdes    u_int32_t	Second:6;	/* 0-59 */
369238104Sdes    u_int64_t	ViaAdapterSerialNumber;
370238104Sdes} __attribute__ ((packed));
371238104Sdes
372238104Sdes/******************************************************************************
373238104Sdes * Revision number handling
374238104Sdes */
375238104Sdes
376238104Sdestypedef enum {
377238104Sdes    RevApplication = 1,
378238104Sdes    RevDkiCli,
379238104Sdes    RevNetService,
380238104Sdes    RevApi,
381238104Sdes    RevFileSysDriver,
382238104Sdes    RevMiniportDriver,
383238104Sdes    RevAdapterSW,
384238104Sdes    RevMonitor,
385238104Sdes    RevRemoteApi
386238104Sdes} RevComponent;
387238104Sdes
388238104Sdesstruct FsaRevision {
389238104Sdes    union {
390238104Sdes        struct {
391238104Sdes            u_int8_t	dash;
392238104Sdes            u_int8_t	type;
393238104Sdes            u_int8_t	minor;
394238104Sdes            u_int8_t	major;
395238104Sdes        } comp;
396238104Sdes        u_int32_t	ul;
397238104Sdes    } external;
398238104Sdes    u_int32_t	buildNumber;
399238104Sdes}  __attribute__ ((packed));
400238104Sdes
401238104Sdes/******************************************************************************
402238104Sdes * Adapter Information
403238104Sdes */
404238104Sdes
405238104Sdestypedef enum {
406238104Sdes    CPU_NTSIM = 1,
407238104Sdes    CPU_I960,
408238104Sdes    CPU_ARM,
409238104Sdes    CPU_SPARC,
410238104Sdes    CPU_POWERPC,
411238104Sdes    CPU_ALPHA,
412238104Sdes    CPU_P7,
413238104Sdes    CPU_I960_RX,
414238104Sdes    CPU__last
415238104Sdes} AAC_CpuType;
416238104Sdes
417238104Sdestypedef enum {
418238104Sdes    CPUI960_JX = 1,
419238104Sdes    CPUI960_CX,
420238104Sdes    CPUI960_HX,
421238104Sdes    CPUI960_RX,
422238104Sdes    CPUARM_SA110,
423238104Sdes    CPUARM_xxx,
424238104Sdes    CPUPPC_603e,
425238104Sdes    CPUPPC_xxx,
426238104Sdes    CPUSUBTYPE__last
427238104Sdes} AAC_CpuSubType;
428238104Sdes
429238104Sdestypedef enum {
430238104Sdes    PLAT_NTSIM = 1,
431238104Sdes    PLAT_V3ADU,
432238104Sdes    PLAT_CYCLONE,
433238104Sdes    PLAT_CYCLONE_HD,
434238104Sdes    PLAT_BATBOARD,
435238104Sdes    PLAT_BATBOARD_HD,
436238104Sdes    PLAT_YOLO,
437238104Sdes    PLAT_COBRA,
438238104Sdes    PLAT_ANAHEIM,
439238104Sdes    PLAT_JALAPENO,
440238104Sdes    PLAT_QUEENS,
441238104Sdes    PLAT_JALAPENO_DELL,
442238104Sdes    PLAT_POBLANO,
443238104Sdes    PLAT_POBLANO_OPAL,
444238104Sdes    PLAT_POBLANO_SL0,
445238104Sdes    PLAT_POBLANO_SL1,
446238104Sdes    PLAT_POBLANO_SL2,
447238104Sdes    PLAT_POBLANO_XXX,
448238104Sdes    PLAT_JALAPENO_P2,
449238104Sdes    PLAT_HABANERO,
450238104Sdes    PLAT__last
451238104Sdes} AAC_Platform;
452238104Sdes
453238104Sdestypedef enum {
454238104Sdes    OEM_FLAVOR_ADAPTEC = 1,
455238104Sdes    OEM_FLAVOR_DELL,
456238104Sdes    OEM_FLAVOR_HP,
457238104Sdes    OEM_FLAVOR_IBM,
458238104Sdes    OEM_FLAVOR_CPQ,
459238104Sdes    OEM_FLAVOR_BRAND_X,
460238104Sdes    OEM_FLAVOR_BRAND_Y,
461238104Sdes    OEM_FLAVOR_BRAND_Z,
462238104Sdes    OEM_FLAVOR__last
463238104Sdes} AAC_OemFlavor;
464238104Sdes
465238104Sdes/*
466238104Sdes * XXX the aac-2622 with no battery present reports PLATFORM_BAT_OPT_PRESENT
467238104Sdes */
468238104Sdestypedef enum
469238104Sdes{
470238104Sdes    PLATFORM_BAT_REQ_PRESENT = 1,	/* BATTERY REQUIRED AND PRESENT */
471238104Sdes    PLATFORM_BAT_REQ_NOTPRESENT,	/* BATTERY REQUIRED AND NOT PRESENT */
472238104Sdes    PLATFORM_BAT_OPT_PRESENT,		/* BATTERY OPTIONAL AND PRESENT */
473238104Sdes    PLATFORM_BAT_OPT_NOTPRESENT,	/* BATTERY OPTIONAL AND NOT PRESENT */
474238104Sdes    PLATFORM_BAT_NOT_SUPPORTED		/* BATTERY NOT SUPPORTED */
475238104Sdes} AAC_BatteryPlatform;
476238104Sdes
477238104Sdes/*
478238104Sdes * options supported by this board
479238104Sdes * there has to be a one to one mapping of these defines and the ones in
480246854Sdes * fsaapi.h, search for FSA_SUPPORT_SNAPSHOT
481238104Sdes */
482238104Sdes#define AAC_SUPPORTED_SNAPSHOT		0x01
483238104Sdes#define AAC_SUPPORTED_CLUSTERS		0x02
484238104Sdes#define AAC_SUPPORTED_WRITE_CACHE	0x04
485238104Sdes#define AAC_SUPPORTED_64BIT_DATA	0x08
486238104Sdes#define AAC_SUPPORTED_HOST_TIME_FIB	0x10
487238104Sdes#define AAC_SUPPORTED_RAID50		0x20
488238104Sdes
489238104Sdes/*
490238104Sdes * Structure used to respond to a RequestAdapterInfo fib.
491238104Sdes */
492238104Sdesstruct aac_adapter_info {
493238104Sdes    AAC_Platform	PlatformBase;    /* adapter type */
494238104Sdes    AAC_CpuType		CpuArchitecture; /* adapter CPU type */
495238104Sdes    AAC_CpuSubType	CpuVariant;      /* adapter CPU subtype */
496238104Sdes    u_int32_t		ClockSpeed;      /* adapter CPU clockspeed */
497238104Sdes    u_int32_t		ExecutionMem;    /* adapter Execution Memory size */
498238104Sdes    u_int32_t		BufferMem;       /* adapter Data Memory */
499238104Sdes    u_int32_t		TotalMem;        /* adapter Total Memory */
500238104Sdes    struct FsaRevision	KernelRevision;  /* adapter Kernel Software Revision */
501238104Sdes    struct FsaRevision	MonitorRevision; /* adapter Monitor/Diagnostic
502238104Sdes					  * Software Revision */
503238104Sdes    struct FsaRevision	HardwareRevision;/* TBD */
504238104Sdes    struct FsaRevision	BIOSRevision;    /* adapter BIOS Revision */
505238104Sdes    u_int32_t		ClusteringEnabled;
506238104Sdes    u_int32_t		ClusterChannelMask;
507238104Sdes    u_int64_t		SerialNumber;
508238104Sdes    AAC_BatteryPlatform	batteryPlatform;
509238104Sdes    u_int32_t		SupportedOptions; /* supported features of this
510238104Sdes					   * controller */
511238104Sdes    AAC_OemFlavor	OemVariant;
512238104Sdes} __attribute__ ((packed));
513238104Sdes
514238104Sdes/******************************************************************************
515238104Sdes * Monitor/Kernel interface.
516238104Sdes */
517238104Sdes
518238104Sdes/*
519238104Sdes * Synchronous commands to the monitor/kernel.
520238104Sdes */
521238104Sdes#define AAC_MONKER_INITSTRUCT	0x05
522238104Sdes#define AAC_MONKER_SYNCFIB	0x0c
523238104Sdes
524238104Sdes/*
525238104Sdes *  Adapter Status Register
526238104Sdes *
527238104Sdes *  Phase Staus mailbox is 32bits:
528238104Sdes *  <31:16> = Phase Status
529238104Sdes *  <15:0>  = Phase
530238104Sdes *
531238104Sdes *  The adapter reports its present state through the phase.  Only
532238104Sdes *  a single phase should be ever be set.  Each phase can have multiple
533238104Sdes *  phase status bits to provide more detailed information about the
534238104Sdes *  state of the adapter.
535238104Sdes */
536238104Sdes#define AAC_SELF_TEST_FAILED	0x00000004
537238104Sdes#define AAC_UP_AND_RUNNING	0x00000080
538238104Sdes#define AAC_KERNEL_PANIC	0x00000100
539238104Sdes
540238104Sdes/******************************************************************************
541238104Sdes * Data types relating to control and monitoring of the NVRAM/WriteCache
542238104Sdes * subsystem.
543238104Sdes */
544238104Sdes
545238104Sdes#define AAC_NFILESYS	24	/* maximum number of filesystems */
546238104Sdes
547238104Sdes/*
548238104Sdes * NVRAM/Write Cache subsystem states
549238104Sdes */
550238104Sdestypedef enum {
551238104Sdes    NVSTATUS_DISABLED = 0,	/* present, clean, not being used */
552238104Sdes    NVSTATUS_ENABLED,		/* present, possibly dirty, ready for use */
553238104Sdes    NVSTATUS_ERROR,		/* present, dirty, contains dirty data */
554238104Sdes    /* for bad/missing device */
555238104Sdes    NVSTATUS_BATTERY,		/* present, bad or low battery, may contain dirty data */
556238104Sdes    /* for bad/missing device */
557238104Sdes    NVSTATUS_UNKNOWN
558238104Sdes} AAC_NVSTATUS;
559238104Sdes
560238104Sdes/*
561238104Sdes * NVRAM/Write Cache subsystem battery component states
562238104Sdes *
563238104Sdes */
564238104Sdestypedef enum {
565238104Sdes    NVBATTSTATUS_NONE = 0,	/* battery has no power or is not present */
566238104Sdes    NVBATTSTATUS_LOW,		/* battery is low on power */
567238104Sdes    NVBATTSTATUS_OK,		/* battery is okay - normal operation possible only in this state */
568238104Sdes    NVBATTSTATUS_RECONDITIONING	/* no battery present - reconditioning in process */
569238104Sdes} AAC_NVBATTSTATUS;
570238104Sdes
571238104Sdes/*
572238104Sdes * Battery transition type
573238104Sdes */
574238104Sdestypedef enum {
575238104Sdes    NVBATT_TRANSITION_NONE = 0,	/* battery now has no power or is not present */
576238104Sdes    NVBATT_TRANSITION_LOW,	/* battery is now low on power */
577238104Sdes    NVBATT_TRANSITION_OK	/* battery is now okay - normal operation possible only in this state */
578238104Sdes} AAC_NVBATT_TRANSITION;
579238104Sdes
580238104Sdes/*
581238104Sdes * NVRAM Info structure returned for NVRAM_GetInfo call
582238104Sdes */
583238104Sdesstruct aac_nvramdevinfo {
584238104Sdes    u_int32_t	NV_Enabled;	/* write caching enabled */
585238104Sdes    u_int32_t	NV_Error;	/* device in error state */
586238104Sdes    u_int32_t	NV_NDirty;	/* count of dirty NVRAM buffers */
587238104Sdes    u_int32_t	NV_NActive;	/* count of NVRAM buffers being written */
588238104Sdes} __attribute__ ((packed));
589238104Sdes
590238104Sdesstruct aac_nvraminfo {
591238104Sdes    AAC_NVSTATUS		NV_Status;	/* nvram subsystem status */
592238104Sdes    AAC_NVBATTSTATUS		NV_BattStatus;	/* battery status */
593238104Sdes    u_int32_t			NV_Size;	/* size of WriteCache NVRAM in
594238104Sdes						 * bytes */
595238104Sdes    u_int32_t			NV_BufSize;	/* size of NVRAM buffers in
596238104Sdes						 * bytes */
597238104Sdes    u_int32_t			NV_NBufs;	/* number of NVRAM buffers */
598238104Sdes    u_int32_t			NV_NDirty;	/* Num dirty NVRAM buffers */
599238104Sdes    u_int32_t			NV_NClean;	/* Num clean NVRAM buffers */
600238104Sdes    u_int32_t			NV_NActive;	/* Num NVRAM buffers being
601238104Sdes						 * written */
602238104Sdes    u_int32_t			NV_NBrokered;	/* Num brokered NVRAM buffers */
603238104Sdes    struct aac_nvramdevinfo	NV_DevInfo[AAC_NFILESYS];	/* per device
604246854Sdes								 * info */
605246854Sdes    u_int32_t			NV_BattNeedsReconditioning;	/* boolean */
606246854Sdes    u_int32_t			NV_TotalSize;	/* size of all non-volatile
607238104Sdes						 * memories in bytes */
608238104Sdes} __attribute__ ((packed));
609238104Sdes
610238104Sdes/******************************************************************************
611238104Sdes * Data types relating to adapter-initiated FIBs
612238104Sdes *
613238104Sdes * Based on types and structures in <aifstruc.h>
614238104Sdes */
615238104Sdes
616238104Sdes/*
617238104Sdes * Progress Reports
618238104Sdes */
619238104Sdestypedef enum {
620238104Sdes    AifJobStsSuccess = 1,
621238104Sdes    AifJobStsFinished,
622238104Sdes    AifJobStsAborted,
623238104Sdes    AifJobStsFailed,
624238104Sdes    AifJobStsLastReportMarker = 100,	/* All before mean last report */
625238104Sdes    AifJobStsSuspended,
626238104Sdes    AifJobStsRunning
627238104Sdes} AAC_AifJobStatus;
628238104Sdes
629238104Sdestypedef enum {
630238104Sdes    AifJobScsiMin = 1,			/* Minimum value for Scsi operation */
631238104Sdes    AifJobScsiZero,			/* SCSI device clear operation */
632238104Sdes    AifJobScsiVerify,			/* SCSI device Verify operation NO
633238104Sdes					 * REPAIR */
634238104Sdes    AifJobScsiExercise,			/* SCSI device Exercise operation */
635238104Sdes    AifJobScsiVerifyRepair,		/* SCSI device Verify operation WITH
636238104Sdes					 * repair */
637238104Sdes    AifJobScsiMax = 99,			/* Max Scsi value */
638238104Sdes    AifJobCtrMin,			/* Min Ctr op value */
639238104Sdes    AifJobCtrZero,			/* Container clear operation */
640238104Sdes    AifJobCtrCopy,			/* Container copy operation */
641238104Sdes    AifJobCtrCreateMirror,		/* Container Create Mirror operation */
642238104Sdes    AifJobCtrMergeMirror,		/* Container Merge Mirror operation */
643238104Sdes    AifJobCtrScrubMirror,		/* Container Scrub Mirror operation */
644238104Sdes    AifJobCtrRebuildRaid5,		/* Container Rebuild Raid5 operation */
645238104Sdes    AifJobCtrScrubRaid5,		/* Container Scrub Raid5 operation */
646238104Sdes    AifJobCtrMorph,			/* Container morph operation */
647238104Sdes    AifJobCtrPartCopy,			/* Container Partition copy operation */
648238104Sdes    AifJobCtrRebuildMirror,		/* Container Rebuild Mirror operation */
649238104Sdes    AifJobCtrCrazyCache,		/* crazy cache */
650238104Sdes    AifJobCtrMax = 199,			/* Max Ctr type operation */
651238104Sdes    AifJobFsMin,			/* Min Fs type operation */
652238104Sdes    AifJobFsCreate,			/* File System Create operation */
653238104Sdes    AifJobFsVerify,			/* File System Verify operation */
654238104Sdes    AifJobFsExtend,			/* File System Extend operation */
655238104Sdes    AifJobFsMax = 299,			/* Max Fs type operation */
656238104Sdes    AifJobApiFormatNTFS,		/* Format a drive to NTFS */
657238104Sdes    AifJobApiFormatFAT,			/* Format a drive to FAT */
658238104Sdes    AifJobApiUpdateSnapshot,		/* update the read/write half of a
659238104Sdes					 * snapshot */
660238104Sdes    AifJobApiFormatFAT32,		/* Format a drive to FAT32 */
661238104Sdes    AifJobApiMax = 399,			/* Max API type operation */
662238104Sdes    AifJobCtlContinuousCtrVerify,	/* Adapter operation */
663238104Sdes    AifJobCtlMax = 499			/* Max Adapter type operation */
664238104Sdes} AAC_AifJobType;
665238104Sdes
666238104Sdesstruct aac_AifContainers {
667238104Sdes    u_int32_t	src;			/* from/master */
668238104Sdes    u_int32_t	dst;			/* to/slave */
669238104Sdes} __attribute__ ((packed));
670238104Sdes
671238104Sdesunion aac_AifJobClient {
672238104Sdes    struct aac_AifContainers	container;	/* For Container and file
673238104Sdes						 * system progress ops; */
674238104Sdes    int32_t			scsi_dh;	/* For SCSI progress ops */
675238104Sdes};
676238104Sdes
677238104Sdesstruct aac_AifJobDesc {
678238104Sdes    u_int32_t			jobID;		/* DO NOT FILL IN! Will be
679238104Sdes						 * filled in by AIF */
680238104Sdes    AAC_AifJobType		type;		/* Operation that is being
681238104Sdes						 * performed */
682238104Sdes    union aac_AifJobClient	client;		/* Details */
683238104Sdes} __attribute__ ((packed));
684238104Sdes
685238104Sdesstruct aac_AifJobProgressReport {
686238104Sdes    struct aac_AifJobDesc	jd;
687238104Sdes    AAC_AifJobStatus		status;
688238104Sdes    u_int32_t			finalTick;
689238104Sdes    u_int32_t			currentTick;
690238104Sdes    u_int32_t			jobSpecificData1;
691238104Sdes    u_int32_t			jobSpecificData2;
692238104Sdes} __attribute__ ((packed));
693238104Sdes
694238104Sdes/*
695238104Sdes * Event Notification
696238104Sdes */
697238104Sdestypedef enum {
698238104Sdes    /* General application notifies start here */
699238104Sdes    AifEnGeneric = 1,			/* Generic notification */
700238104Sdes    AifEnTaskComplete,			/* Task has completed */
701238104Sdes    AifEnConfigChange,			/* Adapter config change occurred */
702238104Sdes    AifEnContainerChange,		/* Adapter specific container
703238104Sdes					 * configuration change */
704238104Sdes    AifEnDeviceFailure,			/* SCSI device failed */
705238104Sdes    AifEnMirrorFailover,		/* Mirror failover started */
706238104Sdes    AifEnContainerEvent,		/* Significant container event */
707238104Sdes    AifEnFileSystemChange,		/* File system changed */
708238104Sdes    AifEnConfigPause,			/* Container pause event */
709238104Sdes    AifEnConfigResume,			/* Container resume event */
710238104Sdes    AifEnFailoverChange,		/* Failover space assignment changed */
711238104Sdes    AifEnRAID5RebuildDone,		/* RAID5 rebuild finished */
712238104Sdes    AifEnEnclosureManagement,		/* Enclosure management event */
713238104Sdes    AifEnBatteryEvent,			/* Significant NV battery event */
714238104Sdes    AifEnAddContainer,			/* A new container was created. */
715238104Sdes    AifEnDeleteContainer,		/* A container was deleted. */
716238104Sdes    AifEnSMARTEvent, 	         	/* SMART Event */
717238104Sdes    AifEnBatteryNeedsRecond,		/* The battery needs reconditioning */
718238104Sdes    AifEnClusterEvent,			/* Some cluster event */
719238104Sdes    AifEnDiskSetEvent,			/* A disk set event occured. */
720238104Sdes    AifDriverNotifyStart=199,		/* Notifies for host driver go here */
721238104Sdes    /* Host driver notifications start here */
722238104Sdes    AifDenMorphComplete, 		/* A morph operation completed */
723238104Sdes    AifDenVolumeExtendComplete 		/* A volume expand operation completed */
724238104Sdes} AAC_AifEventNotifyType;
725238104Sdes
726238104Sdesstruct aac_AifEnsGeneric {
727238104Sdes    char	text[132];			/* Generic text */
728238104Sdes} __attribute__ ((packed));
729238104Sdes
730238104Sdesstruct aac_AifEnsDeviceFailure {
731246854Sdes    u_int32_t	deviceHandle;		/* SCSI device handle */
732246854Sdes} __attribute__ ((packed));
733246854Sdes
734246854Sdesstruct aac_AifEnsMirrorFailover {
735246854Sdes    u_int32_t	container;		/* Container with failed element */
736246854Sdes    u_int32_t	failedSlice;		/* Old slice which failed */
737246854Sdes    u_int32_t	creatingSlice;		/* New slice used for auto-create */
738238104Sdes} __attribute__ ((packed));
739238104Sdes
740238104Sdesstruct aac_AifEnsContainerChange {
741238104Sdes    u_int32_t	container[2];		/* container that changed, -1 if no
742238104Sdes					 * container */
743238104Sdes} __attribute__ ((packed));
744238104Sdes
745238104Sdesstruct aac_AifEnsContainerEvent {
746238104Sdes    u_int32_t	container;		/* container number  */
747238104Sdes    u_int32_t	eventType;		/* event type */
748238104Sdes} __attribute__ ((packed));
749238104Sdes
750238104Sdesstruct aac_AifEnsEnclosureEvent {
751238104Sdes    u_int32_t	empID;			/* enclosure management proc number  */
752238104Sdes    u_int32_t	unitID;			/* unitId, fan id, power supply id,
753238104Sdes					 * slot id, tempsensor id.  */
754238104Sdes    u_int32_t	eventType;		/* event type */
755238104Sdes} __attribute__ ((packed));
756238104Sdes
757238104Sdesstruct aac_AifEnsBatteryEvent {
758238104Sdes    AAC_NVBATT_TRANSITION	transition_type;	/* eg from low to ok */
759238104Sdes    AAC_NVBATTSTATUS		current_state;		/* current batt state */
760238104Sdes    AAC_NVBATTSTATUS		prior_state;		/* prev batt state */
761238104Sdes} __attribute__ ((packed));
762238104Sdes
763238104Sdesstruct aac_AifEnsDiskSetEvent {
764238104Sdes    u_int32_t	eventType;
765238104Sdes    u_int64_t	DsNum;
766238104Sdes    u_int64_t	CreatorId;
767238104Sdes} __attribute__ ((packed));
768238104Sdes
769238104Sdestypedef enum {
770238104Sdes    CLUSTER_NULL_EVENT = 0,
771238104Sdes    CLUSTER_PARTNER_NAME_EVENT,		/* change in partner hostname or
772238104Sdes					 * adaptername from NULL to non-NULL */
773238104Sdes    /* (partner's agent may be up) */
774238104Sdes    CLUSTER_PARTNER_NULL_NAME_EVENT	/* change in partner hostname or
775238104Sdes					 * adaptername from non-null to NULL */
776238104Sdes    /* (partner has rebooted) */
777238104Sdes} AAC_ClusterAifEvent;
778238104Sdes
779238104Sdesstruct aac_AifEnsClusterEvent {
780238104Sdes    AAC_ClusterAifEvent	eventType;
781238104Sdes} __attribute__ ((packed));
782238104Sdes
783238104Sdesstruct aac_AifEventNotify {
784238104Sdes    AAC_AifEventNotifyType	type;
785238104Sdes    union {
786238104Sdes	struct aac_AifEnsGeneric		EG;
787238104Sdes	struct aac_AifEnsDeviceFailure		EDF;
788238104Sdes	struct aac_AifEnsMirrorFailover		EMF;
789238104Sdes	struct aac_AifEnsContainerChange	ECC;
790238104Sdes	struct aac_AifEnsContainerEvent		ECE;
791238104Sdes	struct aac_AifEnsEnclosureEvent		EEE;
792238104Sdes	struct aac_AifEnsBatteryEvent		EBE;
793238104Sdes	struct aac_AifEnsDiskSetEvent		EDS;
794238104Sdes/*	struct aac_AifEnsSMARTEvent		ES;*/
795238104Sdes	struct aac_AifEnsClusterEvent		ECLE;
796238104Sdes    } data;
797238104Sdes} __attribute__ ((packed));
798238104Sdes
799238104Sdes/*
800238104Sdes * Adapter Initiated FIB command structures. Start with the adapter
801238104Sdes * initiated FIBs that really come from the adapter, and get responded
802238104Sdes * to by the host.
803238104Sdes */
804238104Sdes#define AAC_AIF_REPORT_MAX_SIZE 64
805238104Sdes
806238104Sdestypedef enum {
807238104Sdes    AifCmdEventNotify = 1,	/* Notify of event */
808238104Sdes    AifCmdJobProgress,		/* Progress report */
809238104Sdes    AifCmdAPIReport,		/* Report from other user of API */
810238104Sdes    AifCmdDriverNotify,		/* Notify host driver of event */
811238104Sdes    AifReqJobList = 100,	/* Gets back complete job list */
812238104Sdes    AifReqJobsForCtr,		/* Gets back jobs for specific container */
813238104Sdes    AifReqJobsForScsi,		/* Gets back jobs for specific SCSI device */
814238104Sdes    AifReqJobReport,		/* Gets back a specific job report or list */
815238104Sdes    AifReqTerminateJob,		/* Terminates job */
816238104Sdes    AifReqSuspendJob,		/* Suspends a job */
817238104Sdes    AifReqResumeJob,		/* Resumes a job */
818238104Sdes    AifReqSendAPIReport,	/* API generic report requests */
819238104Sdes    AifReqAPIJobStart,		/* Start a job from the API */
820238104Sdes    AifReqAPIJobUpdate,		/* Update a job report from the API */
821238104Sdes    AifReqAPIJobFinish		/* Finish a job from the API */
822238104Sdes} AAC_AifCommand;
823238104Sdes
824238104Sdesstruct aac_aif_command {
825238104Sdes    AAC_AifCommand	command;		/* Tell host what type of
826238104Sdes						 * notify this is */
827238104Sdes    u_int32_t		seqNumber;		/* To allow ordering of
828238104Sdes						 * reports (if necessary) */
829238104Sdes    union {
830238104Sdes	struct aac_AifEventNotify	EN;	/* Event notify structure */
831238104Sdes	struct aac_AifJobProgressReport	PR[1];	/* Progress report */
832238104Sdes	u_int8_t			AR[AAC_AIF_REPORT_MAX_SIZE];
833238104Sdes    } data;
834238104Sdes} __attribute__ ((packed));
835238104Sdes
836238104Sdes/******************************************************************************
837238104Sdes * Filesystem commands/data
838238104Sdes *
839238104Sdes * The adapter has a very complex filesystem interface, most of which we ignore.
840238104Sdes * (And which seems not to be implemented, anyway.)
841238104Sdes */
842238104Sdes
843238104Sdes/*
844238104Sdes * FSA commands
845238104Sdes * (not used?)
846238104Sdes */
847238104Sdestypedef enum {
848238104Sdes    Null = 0,
849238104Sdes    GetAttributes,
850238104Sdes    SetAttributes,
851238104Sdes    Lookup,
852238104Sdes    ReadLink,
853238104Sdes    Read,
854238104Sdes    Write,
855238104Sdes    Create,
856238104Sdes    MakeDirectory,
857238104Sdes    SymbolicLink,
858238104Sdes    MakeNode,
859238104Sdes    Removex,
860238104Sdes    RemoveDirectory,
861238104Sdes    Rename,
862238104Sdes    Link,
863238104Sdes    ReadDirectory,
864238104Sdes    ReadDirectoryPlus,
865238104Sdes    FileSystemStatus,
866238104Sdes    FileSystemInfo,
867238104Sdes    PathConfigure,
868238104Sdes    Commit,
869238104Sdes    Mount,
870238104Sdes    UnMount,
871238104Sdes    Newfs,
872238104Sdes    FsCheck,
873238104Sdes    FsSync,
874238104Sdes    SimReadWrite,
875238104Sdes    SetFileSystemStatus,
876238104Sdes    BlockRead,
877238104Sdes    BlockWrite,
878238104Sdes    NvramIoctl,
879238104Sdes    FsSyncWait,
880238104Sdes    ClearArchiveBit,
881238104Sdes    SetAcl,
882238104Sdes    GetAcl,
883238104Sdes    AssignAcl,
884238104Sdes    FaultInsertion,
885238104Sdes    CrazyCache
886238104Sdes} AAC_FSACommand;
887238104Sdes
888238104Sdes/*
889238104Sdes * Command status values
890238104Sdes */
891238104Sdestypedef enum {
892238104Sdes    ST_OK = 0,
893238104Sdes    ST_PERM = 1,
894238104Sdes    ST_NOENT = 2,
895238104Sdes    ST_IO = 5,
896238104Sdes    ST_NXIO = 6,
897238104Sdes    ST_E2BIG = 7,
898238104Sdes    ST_ACCES = 13,
899238104Sdes    ST_EXIST = 17,
900238104Sdes    ST_XDEV = 18,
901238104Sdes    ST_NODEV = 19,
902238104Sdes    ST_NOTDIR = 20,
903238104Sdes    ST_ISDIR = 21,
904238104Sdes    ST_INVAL = 22,
905238104Sdes    ST_FBIG = 27,
906238104Sdes    ST_NOSPC = 28,
907238104Sdes    ST_ROFS = 30,
908238104Sdes    ST_MLINK = 31,
909238104Sdes    ST_WOULDBLOCK = 35,
910238104Sdes    ST_NAMETOOLONG = 63,
911238104Sdes    ST_NOTEMPTY = 66,
912238104Sdes    ST_DQUOT = 69,
913238104Sdes    ST_STALE = 70,
914238104Sdes    ST_REMOTE = 71,
915238104Sdes    ST_BADHANDLE = 10001,
916238104Sdes    ST_NOT_SYNC = 10002,
917238104Sdes    ST_BAD_COOKIE = 10003,
918238104Sdes    ST_NOTSUPP = 10004,
919238104Sdes    ST_TOOSMALL = 10005,
920238104Sdes    ST_SERVERFAULT = 10006,
921238104Sdes    ST_BADTYPE = 10007,
922238104Sdes    ST_JUKEBOX = 10008,
923238104Sdes    ST_NOTMOUNTED = 10009,
924238104Sdes    ST_MAINTMODE = 10010,
925238104Sdes    ST_STALEACL = 10011
926238104Sdes} AAC_FSAStatus;
927238104Sdes
928238104Sdes/*
929238104Sdes * Volume manager commands
930238104Sdes */
931238104Sdestypedef enum _VM_COMMANDS {
932238104Sdes    VM_Null = 0,
933238104Sdes    VM_NameServe,
934238104Sdes    VM_ContainerConfig,
935238104Sdes    VM_Ioctl,
936238104Sdes    VM_FilesystemIoctl,
937238104Sdes    VM_CloseAll,
938238104Sdes    VM_CtBlockRead,
939246827Sdes    VM_CtBlockWrite,
940238104Sdes    VM_SliceBlockRead,	 /* raw access to configured "storage objects" */
941238104Sdes    VM_SliceBlockWrite,
942238104Sdes    VM_DriveBlockRead,	 /* raw access to physical devices */
943238104Sdes    VM_DriveBlockWrite,
944238104Sdes    VM_EnclosureMgt,	 /* enclosure management */
945238104Sdes    VM_Unused,		 /* used to be diskset management */
946238104Sdes    VM_CtBlockVerify,
947238104Sdes    VM_CtPerf,		 /* performance test */
948238104Sdes    VM_CtBlockRead64,
949238104Sdes    VM_CtBlockWrite64,
950238104Sdes    VM_CtBlockVerify64,
951238104Sdes} AAC_VMCommand;
952238104Sdes
953238104Sdes/*
954238104Sdes * "mountable object"
955238104Sdes */
956238104Sdesstruct aac_mntobj {
957238104Sdes    u_int32_t				ObjectId;
958238104Sdes    char				FileSystemName[16];
959238104Sdes    struct aac_container_creation	CreateInfo;
960238104Sdes    u_int32_t				Capacity;
961238104Sdes    AAC_FSAVolType			VolType;
962238104Sdes    AAC_FType				ObjType;
963238104Sdes    u_int32_t				ContentState;
964238104Sdes#define FSCS_READONLY		0x0002		/* XXX need more information
965238104Sdes						 * than this */
966238104Sdes    union {
967238104Sdes	u_int32_t	pad[8];
968238104Sdes    } ObjExtension;
969238104Sdes    u_int32_t				AlterEgoId;
970238104Sdes} __attribute__ ((packed));
971238104Sdes
972238104Sdesstruct aac_mntinfo {
973238104Sdes    AAC_VMCommand	Command;
974238104Sdes    AAC_FType		MntType;
975238104Sdes    u_int32_t		MntCount;
976238104Sdes} __attribute__ ((packed));
977238104Sdes
978238104Sdesstruct aac_mntinforesponse {
979238104Sdes    AAC_FSAStatus	Status;
980238104Sdes    AAC_FType		MntType;
981238104Sdes    u_int32_t		MntRespCount;
982238104Sdes    struct aac_mntobj	MntTable[1];
983238104Sdes} __attribute__ ((packed));
984238104Sdes
985238104Sdes/*
986238104Sdes * Container shutdown command.
987238104Sdes */
988238104Sdesstruct aac_closecommand {
989238104Sdes    u_int32_t	Command;
990238104Sdes    u_int32_t	ComainerId;
991238104Sdes} __attribute__ ((packed));
992238104Sdes
993238104Sdes/*
994238104Sdes * Write 'stability' options.
995238104Sdes */
996238104Sdestypedef enum {
997238104Sdes    CSTABLE = 1,
998238104Sdes    CUNSTABLE
999238104Sdes} AAC_CacheLevel;
1000238104Sdes
1001238104Sdes/*
1002238104Sdes * Commit level response for a write request.
1003238104Sdes */
1004238104Sdestypedef enum {
1005238104Sdes    CMFILE_SYNC_NVRAM = 1,
1006238104Sdes    CMDATA_SYNC_NVRAM,
1007238104Sdes    CMFILE_SYNC,
1008238104Sdes    CMDATA_SYNC,
1009238104Sdes    CMUNSTABLE
1010238104Sdes} AAC_CommitLevel;
1011238104Sdes
1012238104Sdes/*
1013238104Sdes * Block read/write operations.
1014238104Sdes * These structures are packed into the 'data' area in the FIB.
1015238104Sdes */
1016238104Sdes
1017238104Sdesstruct aac_blockread {
1018238104Sdes    AAC_VMCommand	Command;	/* not FSACommand! */
1019238104Sdes    u_int32_t		ContainerId;
1020238104Sdes    u_int32_t		BlockNumber;
1021238104Sdes    u_int32_t		ByteCount;
1022238104Sdes    struct aac_sg_table	SgMap;		/* variable size */
1023238104Sdes} __attribute__ ((packed));
1024238104Sdes
1025238104Sdesstruct aac_blockread_response {
1026238104Sdes    AAC_FSAStatus	Status;
1027238104Sdes    u_int32_t		ByteCount;
1028238104Sdes} __attribute__ ((packed));
1029238104Sdes
1030238104Sdesstruct aac_blockwrite {
1031238104Sdes    AAC_VMCommand	Command;	/* not FSACommand! */
1032238104Sdes    u_int32_t		ContainerId;
1033238104Sdes    u_int32_t		BlockNumber;
1034238104Sdes    u_int32_t		ByteCount;
1035238104Sdes    AAC_CacheLevel	Stable;
1036238104Sdes    struct aac_sg_table	SgMap;		/* variable size */
1037238104Sdes} __attribute__ ((packed));
1038238104Sdes
1039238104Sdesstruct aac_blockwrite_response {
1040238104Sdes    AAC_FSAStatus	Status;
1041238104Sdes    u_int32_t		ByteCount;
1042238104Sdes    AAC_CommitLevel	Committed;
1043238104Sdes} __attribute__ ((packed));
1044238104Sdes
1045238104Sdes/*
1046238104Sdes * Container shutdown command.
1047238104Sdes */
1048238104Sdesstruct aac_close_command {
1049238104Sdes    AAC_VMCommand      Command;
1050238104Sdes    u_int32_t          ContainerId;
1051238104Sdes};
1052238104Sdes
1053238104Sdes/******************************************************************************
1054238104Sdes * Register definitions for the Adaptec AAC-364 'Jalapeno I/II' adapters, based
1055238104Sdes * on the SA110 'StrongArm'.
1056238104Sdes */
1057238104Sdes
1058238104Sdes#define AAC_SA_DOORBELL0_CLEAR		0x98	/* doorbell 0 (adapter->host) */
1059238104Sdes#define AAC_SA_DOORBELL0_SET		0x9c
1060238104Sdes#define AAC_SA_DOORBELL0		0x9c
1061238104Sdes#define AAC_SA_MASK0_CLEAR		0xa0
1062238104Sdes#define AAC_SA_MASK0_SET		0xa4
1063238104Sdes
1064238104Sdes#define AAC_SA_DOORBELL1_CLEAR		0x9a	/* doorbell 1 (host->adapter) */
1065238104Sdes#define AAC_SA_DOORBELL1_SET		0x9e
1066238104Sdes#define AAC_SA_MASK1_CLEAR		0xa2
1067238104Sdes#define AAC_SA_MASK1_SET		0xa6
1068238104Sdes
1069238104Sdes#define AAC_SA_MAILBOX			0xa8	/* mailbox (20 bytes) */
1070238104Sdes#define AAC_SA_FWSTATUS			0xc4
1071238104Sdes
1072238104Sdes/******************************************************************************
1073238104Sdes * Register definitions for the Adaptec 'Pablano' adapters, based on the i960Rx,
1074238104Sdes * and other related adapters.
1075238104Sdes */
1076238104Sdes
1077238104Sdes#define AAC_RX_IDBR		0x20	/* inbound doorbell register */
1078238104Sdes#define AAC_RX_IISR		0x24	/* inbound interrupt status register */
1079238104Sdes#define AAC_RX_IIMR		0x28	/* inbound interrupt mask register */
1080238104Sdes#define AAC_RX_ODBR		0x2c	/* outbound doorbell register */
1081238104Sdes#define AAC_RX_OISR		0x30	/* outbound interrupt status register */
1082238104Sdes#define AAC_RX_OIMR		0x34	/* outbound interrupt mask register */
1083238104Sdes
1084238104Sdes#define AAC_RX_MAILBOX		0x50	/* mailbox (20 bytes) */
1085238104Sdes#define AAC_RX_FWSTATUS		0x6c
1086238104Sdes
1087238104Sdes/******************************************************************************
1088238104Sdes * Common bit definitions for the doorbell registers.
1089238104Sdes */
1090238104Sdes
1091238104Sdes/*
1092238104Sdes * Status bits in the doorbell registers.
1093238104Sdes */
1094238104Sdes#define AAC_DB_SYNC_COMMAND	(1<<0)	/* send/completed synchronous FIB */
1095238104Sdes#define AAC_DB_COMMAND_READY	(1<<1)	/* posted one or more commands */
1096238104Sdes#define AAC_DB_RESPONSE_READY	(1<<2)	/* one or more commands complete */
1097238104Sdes#define AAC_DB_COMMAND_NOT_FULL	(1<<3)	/* command queue not full */
1098238104Sdes#define AAC_DB_RESPONSE_NOT_FULL (1<<4)	/* response queue not full */
1099238104Sdes
1100238104Sdes/*
1101238104Sdes * The adapter can request the host print a message by setting the
1102238104Sdes * DB_PRINTF flag in DOORBELL0.  The driver responds by collecting the
1103238104Sdes * message from the printf buffer, clearing the DB_PRINTF flag in
1104238104Sdes * DOORBELL0 and setting it in DOORBELL1.
1105238104Sdes * (ODBR and IDBR respectively for the i960Rx adapters)
1106238104Sdes */
1107238104Sdes#define AAC_DB_PRINTF		(1<<5)	/* adapter requests host printf */
1108238104Sdes
1109238104Sdes/*
1110238104Sdes * Mask containing the interrupt bits we care about.  We don't anticipate (or
1111238104Sdes * want) interrupts not in this mask.
1112238104Sdes */
1113238104Sdes#define AAC_DB_INTERRUPTS	(AAC_DB_COMMAND_READY | AAC_DB_RESPONSE_READY | AAC_DB_PRINTF)
1114238104Sdes