aacreg.h revision 87183
1/*-
2 * Copyright (c) 2000 Michael Smith
3 * Copyright (c) 2000-2001 Scott Long
4 * Copyright (c) 2000 BSDi
5 * Copyright (c) 2001 Adaptec, Inc.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 *	$FreeBSD: head/sys/dev/aac/aacreg.h 87183 2001-12-02 03:47:33Z scottl $
30 */
31
32/*
33 * Data structures defining the interface between the driver and the Adaptec
34 * 'FSA' adapters.  Note that many field names and comments here are taken
35 * verbatim from the Adaptec driver source in order to make comparing the
36 * two slightly easier.
37 */
38
39/*
40 * Misc. magic numbers.
41 */
42#define AAC_MAX_CONTAINERS	64
43#define AAC_BLOCK_SIZE		512
44
45/*
46 * Communications interface.
47 *
48 * Where datastructure layouts are closely parallel to the Adaptec sample code,
49 * retain their naming conventions (for now) to aid in cross-referencing.
50 */
51
52/*
53 * We establish 4 command queues and matching response queues.  Queues must
54 * be 16-byte aligned, and are sized as follows:
55 */
56#define AAC_HOST_NORM_CMD_ENTRIES	8	/* command adapter->host,
57						 * normal priority */
58#define AAC_HOST_HIGH_CMD_ENTRIES	4	/* command adapter->host,
59						 * high priority */
60#define AAC_ADAP_NORM_CMD_ENTRIES	512	/* command host->adapter,
61						 * normal priority */
62#define AAC_ADAP_HIGH_CMD_ENTRIES	4	/* command host->adapter,
63						 * high priority */
64#define AAC_HOST_NORM_RESP_ENTRIES	512	/* response, adapter->host,
65						 * normal priority */
66#define AAC_HOST_HIGH_RESP_ENTRIES	4	/* response, adapter->host,
67						 * high priority */
68#define AAC_ADAP_NORM_RESP_ENTRIES	8	/* response, host->adapter,
69						 * normal priority */
70#define AAC_ADAP_HIGH_RESP_ENTRIES	4	/* response, host->adapter,
71						 * high priority */
72
73#define AAC_TOTALQ_LENGTH	(AAC_HOST_HIGH_CMD_ENTRIES +	\
74				 AAC_HOST_NORM_CMD_ENTRIES +	\
75				 AAC_ADAP_HIGH_CMD_ENTRIES +	\
76				 AAC_ADAP_NORM_CMD_ENTRIES +	\
77				 AAC_HOST_HIGH_RESP_ENTRIES +	\
78				 AAC_HOST_NORM_RESP_ENTRIES +	\
79				 AAC_ADAP_HIGH_RESP_ENTRIES +	\
80				 AAC_ADAP_NORM_RESP_ENTRIES)
81#define AAC_QUEUE_COUNT		8
82#define AAC_QUEUE_ALIGN		16
83
84struct aac_queue_entry {
85	u_int32_t	aq_fib_size;	/* FIB size in bytes */
86	u_int32_t	aq_fib_addr;	/* receiver-space address of the FIB */
87} __attribute__ ((packed));
88
89#define AAC_PRODUCER_INDEX	0
90#define AAC_CONSUMER_INDEX	1
91
92/*
93 * Table of queue indices and queues used to communicate with the
94 * controller.  This structure must be aligned to AAC_QUEUE_ALIGN
95 */
96struct aac_queue_table {
97	/* queue consumer/producer indexes (layout mandated by adapter) */
98	u_int32_t			qt_qindex[AAC_QUEUE_COUNT][2];
99
100	/* queue entry structures (layout mandated by adapter) */
101	struct aac_queue_entry qt_HostNormCmdQueue [AAC_HOST_NORM_CMD_ENTRIES];
102	struct aac_queue_entry qt_HostHighCmdQueue [AAC_HOST_HIGH_CMD_ENTRIES];
103	struct aac_queue_entry qt_AdapNormCmdQueue [AAC_ADAP_NORM_CMD_ENTRIES];
104	struct aac_queue_entry qt_AdapHighCmdQueue [AAC_ADAP_HIGH_CMD_ENTRIES];
105	struct aac_queue_entry qt_HostNormRespQueue[AAC_HOST_NORM_RESP_ENTRIES];
106	struct aac_queue_entry qt_HostHighRespQueue[AAC_HOST_HIGH_RESP_ENTRIES];
107	struct aac_queue_entry qt_AdapNormRespQueue[AAC_ADAP_NORM_RESP_ENTRIES];
108	struct aac_queue_entry qt_AdapHighRespQueue[AAC_ADAP_HIGH_RESP_ENTRIES];
109} __attribute__ ((packed));
110
111/*
112 * Queue names
113 *
114 * Note that we base these at 0 in order to use them as array indices.  Adaptec
115 * used base 1 for some unknown reason, and sorted them in a different order.
116 */
117#define AAC_HOST_NORM_CMD_QUEUE		0
118#define AAC_HOST_HIGH_CMD_QUEUE		1
119#define AAC_ADAP_NORM_CMD_QUEUE		2
120#define AAC_ADAP_HIGH_CMD_QUEUE		3
121#define AAC_HOST_NORM_RESP_QUEUE	4
122#define AAC_HOST_HIGH_RESP_QUEUE	5
123#define AAC_ADAP_NORM_RESP_QUEUE	6
124#define AAC_ADAP_HIGH_RESP_QUEUE	7
125
126/*
127 * List structure used to chain FIBs (used by the adapter - we hang FIBs off
128 * our private command structure and don't touch these)
129 */
130struct aac_fib_list_entry {
131	struct fib_list_entry	*Flink;
132	struct fib_list_entry	*Blink;
133} __attribute__ ((packed));
134
135/*
136 * FIB (FSA Interface Block?); this is the datastructure passed between the host
137 * and adapter.
138 */
139struct aac_fib_header {
140	u_int32_t		XferState;
141	u_int16_t		Command;
142	u_int8_t		StructType;
143	u_int8_t		Flags;
144	u_int16_t		Size;
145	u_int16_t		SenderSize;
146	u_int32_t		SenderFibAddress;
147	u_int32_t		ReceiverFibAddress;
148	u_int32_t		SenderData;
149	union {
150		struct {
151			u_int32_t	ReceiverTimeStart;
152			u_int32_t	ReceiverTimeDone;
153		} _s;
154		struct aac_fib_list_entry FibLinks;
155	} _u;
156} __attribute__ ((packed));
157
158#define AAC_FIB_DATASIZE	(512 - sizeof(struct aac_fib_header))
159
160struct aac_fib {
161	struct aac_fib_header	Header;
162	u_int8_t			data[AAC_FIB_DATASIZE];
163} __attribute__ ((packed));
164
165/*
166 * FIB commands
167 */
168typedef enum {
169	TestCommandResponse =		1,
170	TestAdapterCommand =		2,
171
172	/* lowlevel and comm commands */
173	LastTestCommand =		100,
174	ReinitHostNormCommandQueue =	101,
175	ReinitHostHighCommandQueue =	102,
176	ReinitHostHighRespQueue =	103,
177	ReinitHostNormRespQueue =	104,
178	ReinitAdapNormCommandQueue =	105,
179	ReinitAdapHighCommandQueue =	107,
180	ReinitAdapHighRespQueue =	108,
181	ReinitAdapNormRespQueue =	109,
182	InterfaceShutdown =		110,
183	DmaCommandFib =			120,
184	StartProfile =			121,
185	TermProfile =			122,
186	SpeedTest =			123,
187	TakeABreakPt =			124,
188	RequestPerfData =		125,
189	SetInterruptDefTimer=		126,
190	SetInterruptDefCount=		127,
191	GetInterruptDefStatus=		128,
192	LastCommCommand =		129,
193
194	/* filesystem commands */
195	NuFileSystem =			300,
196	UFS =				301,
197	HostFileSystem =		302,
198	LastFileSystemCommand =		303,
199
200	/* Container Commands */
201	ContainerCommand =		500,
202	ContainerCommand64 =		501,
203
204	/* Cluster Commands */
205	ClusterCommand =		550,
206
207	/* Scsi Port commands (scsi passthrough) */
208	ScsiPortCommand =		600,
209
210	/* misc house keeping and generic adapter initiated commands */
211	AifRequest =			700,
212	CheckRevision =			701,
213	FsaHostShutdown =		702,
214	RequestAdapterInfo =		703,
215	IsAdapterPaused =		704,
216	SendHostTime =			705,
217	LastMiscCommand =		706
218} AAC_FibCommands;
219
220/*
221 * FIB types
222 */
223#define AAC_FIBTYPE_TFIB	1
224#define AAC_FIBTYPE_TQE		2
225#define AAC_FIBTYPE_TCTPERF	3
226
227/*
228 * FIB transfer state
229 */
230#define AAC_FIBSTATE_HOSTOWNED		(1<<0)	/* owned by the host */
231#define AAC_FIBSTATE_ADAPTEROWNED	(1<<1)	/* owned by the adapter */
232#define AAC_FIBSTATE_INITIALISED	(1<<2)	/* initialised */
233#define AAC_FIBSTATE_EMPTY		(1<<3)	/* empty */
234#define AAC_FIBSTATE_FROMPOOL		(1<<4)	/* allocated from pool */
235#define AAC_FIBSTATE_FROMHOST		(1<<5)	/* sent from the host */
236#define AAC_FIBSTATE_FROMADAP		(1<<6)	/* sent from the adapter */
237#define AAC_FIBSTATE_REXPECTED		(1<<7)	/* response is expected */
238#define AAC_FIBSTATE_RNOTEXPECTED	(1<<8)	/* response is not expected */
239#define AAC_FIBSTATE_DONEADAP		(1<<9)	/* processed by the adapter */
240#define AAC_FIBSTATE_DONEHOST		(1<<10)	/* processed by the host */
241#define AAC_FIBSTATE_HIGH		(1<<11)	/* high priority */
242#define AAC_FIBSTATE_NORM		(1<<12)	/* normal priority */
243#define AAC_FIBSTATE_ASYNC		(1<<13)
244#define AAC_FIBSTATE_ASYNCIO		(1<<13)	/* to be removed */
245#define AAC_FIBSTATE_PAGEFILEIO		(1<<14)	/* to be removed */
246#define AAC_FIBSTATE_SHUTDOWN		(1<<15)
247#define AAC_FIBSTATE_LAZYWRITE		(1<<16)	/* to be removed */
248#define AAC_FIBSTATE_ADAPMICROFIB	(1<<17)
249#define AAC_FIBSTATE_BIOSFIB		(1<<18)
250#define AAC_FIBSTATE_FAST_RESPONSE	(1<<19)	/* fast response capable */
251#define AAC_FIBSTATE_APIFIB		(1<<20)
252
253/*
254 * FIB error values
255 */
256#define AAC_ERROR_NORMAL			0x00
257#define AAC_ERROR_PENDING			0x01
258#define AAC_ERROR_FATAL				0x02
259#define AAC_ERROR_INVALID_QUEUE			0x03
260#define AAC_ERROR_NOENTRIES			0x04
261#define AAC_ERROR_SENDFAILED			0x05
262#define AAC_ERROR_INVALID_QUEUE_PRIORITY	0x06
263#define AAC_ERROR_FIB_ALLOCATION_FAILED		0x07
264#define AAC_ERROR_FIB_DEALLOCATION_FAILED	0x08
265
266/*
267 * Adapter Init Structure: this is passed to the adapter with the
268 * AAC_MONKER_INITSTRUCT command to point it at our control structures.
269 */
270struct aac_adapter_init {
271	u_int32_t	InitStructRevision;
272#define AAC_INIT_STRUCT_REVISION	3
273	u_int32_t	MiniPortRevision;
274	u_int32_t	FilesystemRevision;
275	u_int32_t	CommHeaderAddress;
276	u_int32_t	FastIoCommAreaAddress;
277	u_int32_t	AdapterFibsPhysicalAddress;
278	void		*AdapterFibsVirtualAddress;
279	u_int32_t	AdapterFibsSize;
280	u_int32_t	AdapterFibAlign;
281	u_int32_t	PrintfBufferAddress;
282	u_int32_t	PrintfBufferSize;
283	u_int32_t	HostPhysMemPages;
284	u_int32_t	HostElapsedSeconds;
285} __attribute__ ((packed));
286
287/*
288 * Shared data types
289 */
290/*
291 * Container types
292 */
293typedef enum {
294	CT_NONE = 0,
295	CT_VOLUME,
296	CT_MIRROR,
297	CT_STRIPE,
298	CT_RAID5,
299	CT_SSRW,
300	CT_SSRO,
301	CT_MORPH,
302	CT_PASSTHRU,
303	CT_RAID4,
304	CT_RAID10,                  /* stripe of mirror */
305	CT_RAID00,                  /* stripe of stripe */
306	CT_VOLUME_OF_MIRRORS,       /* volume of mirror */
307	CT_PSEUDO_RAID3,            /* really raid4 */
308	CT_RAID50,		    /* stripe of raid5 */
309} AAC_FSAVolType;
310
311/*
312 * Host-addressable object types
313 */
314typedef enum {
315	FT_REG = 1,     /* regular file */
316	FT_DIR,         /* directory */
317	FT_BLK,         /* "block" device - reserved */
318	FT_CHR,         /* "character special" device - reserved */
319	FT_LNK,         /* symbolic link */
320	FT_SOCK,        /* socket */
321	FT_FIFO,        /* fifo */
322	FT_FILESYS,     /* ADAPTEC's "FSA"(tm) filesystem */
323	FT_DRIVE,       /* physical disk - addressable in scsi by b/t/l */
324	FT_SLICE,       /* virtual disk - raw volume - slice */
325	FT_PARTITION,   /* FSA partition - carved out of a slice - building
326			 * block for containers */
327	FT_VOLUME,      /* Container - Volume Set */
328	FT_STRIPE,      /* Container - Stripe Set */
329	FT_MIRROR,      /* Container - Mirror Set */
330	FT_RAID5,       /* Container - Raid 5 Set */
331	FT_DATABASE     /* Storage object with "foreign" content manager */
332} AAC_FType;
333
334/*
335 * Host-side scatter/gather list for 32-bit commands.
336 */
337struct aac_sg_entry {
338	u_int32_t	SgAddress;
339	u_int32_t	SgByteCount;
340} __attribute__ ((packed));
341
342struct aac_sg_table {
343	u_int32_t		SgCount;
344	struct aac_sg_entry	SgEntry[0];
345} __attribute__ ((packed));
346
347/*
348 * Host-side scatter/gather list for 64-bit commands.
349 */
350struct aac_sg_table64 {
351	u_int8_t	SgCount;
352	u_int8_t	SgSectorsPerPage;
353	u_int16_t	SgByteOffset;
354	u_int64_t	SgEntry[0];
355} __attribute__ ((packed));
356
357/*
358 * Container creation data
359 */
360struct aac_container_creation {
361	u_int8_t	ViaBuildNumber;
362	u_int8_t	MicroSecond;
363	u_int8_t	Via;		/* 1 = FSU, 2 = API, etc. */
364	u_int8_t	YearsSince1900;
365	u_int32_t	Month:4;	/* 1-12 */
366	u_int32_t	Day:6;		/* 1-32 */
367	u_int32_t	Hour:6;		/* 0-23 */
368	u_int32_t	Minute:6;	/* 0-59 */
369	u_int32_t	Second:6;	/* 0-59 */
370	u_int64_t	ViaAdapterSerialNumber;
371} __attribute__ ((packed));
372
373/*
374 * Revision number handling
375 */
376
377typedef enum {
378	RevApplication = 1,
379	RevDkiCli,
380	RevNetService,
381	RevApi,
382	RevFileSysDriver,
383	RevMiniportDriver,
384	RevAdapterSW,
385	RevMonitor,
386	RevRemoteApi
387} RevComponent;
388
389struct FsaRevision {
390	union {
391		struct {
392			u_int8_t	dash;
393			u_int8_t	type;
394			u_int8_t	minor;
395			u_int8_t	major;
396		} comp;
397		u_int32_t	ul;
398	} external;
399	u_int32_t	buildNumber;
400}  __attribute__ ((packed));
401
402/*
403 * Adapter Information
404 */
405
406typedef enum {
407	CPU_NTSIM = 1,
408	CPU_I960,
409	CPU_ARM,
410	CPU_SPARC,
411	CPU_POWERPC,
412	CPU_ALPHA,
413	CPU_P7,
414	CPU_I960_RX,
415	CPU__last
416} AAC_CpuType;
417
418typedef enum {
419	CPUI960_JX = 1,
420	CPUI960_CX,
421	CPUI960_HX,
422	CPUI960_RX,
423	CPUARM_SA110,
424	CPUARM_xxx,
425	CPUMPC_824x,
426	CPUPPC_xxx,
427	CPUSUBTYPE__last
428} AAC_CpuSubType;
429
430typedef enum {
431	PLAT_NTSIM = 1,
432	PLAT_V3ADU,
433	PLAT_CYCLONE,
434	PLAT_CYCLONE_HD,
435	PLAT_BATBOARD,
436	PLAT_BATBOARD_HD,
437	PLAT_YOLO,
438	PLAT_COBRA,
439	PLAT_ANAHEIM,
440	PLAT_JALAPENO,
441	PLAT_QUEENS,
442	PLAT_JALAPENO_DELL,
443	PLAT_POBLANO,
444	PLAT_POBLANO_OPAL,
445	PLAT_POBLANO_SL0,
446	PLAT_POBLANO_SL1,
447	PLAT_POBLANO_SL2,
448	PLAT_POBLANO_XXX,
449	PLAT_JALAPENO_P2,
450	PLAT_HABANERO,
451	PLAT__last
452} AAC_Platform;
453
454typedef enum {
455	OEM_FLAVOR_ADAPTEC = 1,
456	OEM_FLAVOR_DELL,
457	OEM_FLAVOR_HP,
458	OEM_FLAVOR_IBM,
459	OEM_FLAVOR_CPQ,
460	OEM_FLAVOR_BRAND_X,
461	OEM_FLAVOR_BRAND_Y,
462	OEM_FLAVOR_BRAND_Z,
463	OEM_FLAVOR__last
464} AAC_OemFlavor;
465
466/*
467 * XXX the aac-2622 with no battery present reports PLATFORM_BAT_OPT_PRESENT
468 */
469typedef enum
470{
471	PLATFORM_BAT_REQ_PRESENT = 1,	/* BATTERY REQUIRED AND PRESENT */
472	PLATFORM_BAT_REQ_NOTPRESENT,	/* BATTERY REQUIRED AND NOT PRESENT */
473	PLATFORM_BAT_OPT_PRESENT,	/* BATTERY OPTIONAL AND PRESENT */
474	PLATFORM_BAT_OPT_NOTPRESENT,	/* BATTERY OPTIONAL AND NOT PRESENT */
475	PLATFORM_BAT_NOT_SUPPORTED	/* BATTERY NOT SUPPORTED */
476} AAC_BatteryPlatform;
477
478/*
479 * options supported by this board
480 * there has to be a one to one mapping of these defines and the ones in
481 * fsaapi.h, search for FSA_SUPPORT_SNAPSHOT
482 */
483#define AAC_SUPPORTED_SNAPSHOT		0x01
484#define AAC_SUPPORTED_CLUSTERS		0x02
485#define AAC_SUPPORTED_WRITE_CACHE	0x04
486#define AAC_SUPPORTED_64BIT_DATA	0x08
487#define AAC_SUPPORTED_HOST_TIME_FIB	0x10
488#define AAC_SUPPORTED_RAID50		0x20
489
490/*
491 * Structure used to respond to a RequestAdapterInfo fib.
492 */
493struct aac_adapter_info {
494	AAC_Platform		PlatformBase;    /* adapter type */
495	AAC_CpuType		CpuArchitecture; /* adapter CPU type */
496	AAC_CpuSubType		CpuVariant;      /* adapter CPU subtype */
497	u_int32_t		ClockSpeed;      /* adapter CPU clockspeed */
498	u_int32_t		ExecutionMem;    /* adapter Execution Memory
499						  * size */
500	u_int32_t		BufferMem;       /* adapter Data Memory */
501	u_int32_t		TotalMem;        /* adapter Total Memory */
502	struct FsaRevision	KernelRevision;  /* adapter Kernel Software
503						  * Revision */
504	struct FsaRevision	MonitorRevision; /* adapter Monitor/Diagnostic
505						  * Software Revision */
506	struct FsaRevision	HardwareRevision;/* TBD */
507	struct FsaRevision	BIOSRevision;    /* adapter BIOS Revision */
508	u_int32_t		ClusteringEnabled;
509	u_int32_t		ClusterChannelMask;
510	u_int64_t		SerialNumber;
511	AAC_BatteryPlatform	batteryPlatform;
512	u_int32_t		SupportedOptions; /* supported features of this
513						   * controller */
514	AAC_OemFlavor	OemVariant;
515} __attribute__ ((packed));
516
517/*
518 * Monitor/Kernel interface.
519 */
520
521/*
522 * Synchronous commands to the monitor/kernel.
523 */
524#define AAC_MONKER_INITSTRUCT	0x05
525#define AAC_MONKER_SYNCFIB	0x0c
526
527/*
528 *  Adapter Status Register
529 *
530 *  Phase Staus mailbox is 32bits:
531 *  <31:16> = Phase Status
532 *  <15:0>  = Phase
533 *
534 *  The adapter reports its present state through the phase.  Only
535 *  a single phase should be ever be set.  Each phase can have multiple
536 *  phase status bits to provide more detailed information about the
537 *  state of the adapter.
538 */
539#define AAC_SELF_TEST_FAILED	0x00000004
540#define AAC_UP_AND_RUNNING	0x00000080
541#define AAC_KERNEL_PANIC	0x00000100
542
543/*
544 * Data types relating to control and monitoring of the NVRAM/WriteCache
545 * subsystem.
546 */
547
548#define AAC_NFILESYS	24	/* maximum number of filesystems */
549
550/*
551 * NVRAM/Write Cache subsystem states
552 */
553typedef enum {
554	NVSTATUS_DISABLED = 0,	/* present, clean, not being used */
555	NVSTATUS_ENABLED,	/* present, possibly dirty, ready for use */
556	NVSTATUS_ERROR,		/* present, dirty, contains dirty data */
557	NVSTATUS_BATTERY,	/* present, bad or low battery, may contain
558				 * dirty data */
559	NVSTATUS_UNKNOWN	/* for bad/missing device */
560} AAC_NVSTATUS;
561
562/*
563 * NVRAM/Write Cache subsystem battery component states
564 *
565 */
566typedef enum {
567	NVBATTSTATUS_NONE = 0,	/* battery has no power or is not present */
568	NVBATTSTATUS_LOW,	/* battery is low on power */
569	NVBATTSTATUS_OK,	/* battery is okay - normal operation possible
570				 * only in this state */
571	NVBATTSTATUS_RECONDITIONING	/* no battery present - reconditioning
572					 * in process */
573} AAC_NVBATTSTATUS;
574
575/*
576 * Battery transition type
577 */
578typedef enum {
579	NVBATT_TRANSITION_NONE = 0,	/* battery now has no power or is not
580					 * present */
581	NVBATT_TRANSITION_LOW,		/* battery is now low on power */
582	NVBATT_TRANSITION_OK		/* battery is now okay - normal
583					 * operation possible only in this
584					 * state */
585} AAC_NVBATT_TRANSITION;
586
587/*
588 * NVRAM Info structure returned for NVRAM_GetInfo call
589 */
590struct aac_nvramdevinfo {
591	u_int32_t	NV_Enabled;	/* write caching enabled */
592	u_int32_t	NV_Error;	/* device in error state */
593	u_int32_t	NV_NDirty;	/* count of dirty NVRAM buffers */
594	u_int32_t	NV_NActive;	/* count of NVRAM buffers being
595					 * written */
596} __attribute__ ((packed));
597
598struct aac_nvraminfo {
599	AAC_NVSTATUS		NV_Status;	/* nvram subsystem status */
600	AAC_NVBATTSTATUS	NV_BattStatus;	/* battery status */
601	u_int32_t		NV_Size;	/* size of WriteCache NVRAM in
602						 * bytes */
603	u_int32_t		NV_BufSize;	/* size of NVRAM buffers in
604						 * bytes */
605	u_int32_t		NV_NBufs;	/* number of NVRAM buffers */
606	u_int32_t		NV_NDirty;	/* Num dirty NVRAM buffers */
607	u_int32_t		NV_NClean;	/* Num clean NVRAM buffers */
608	u_int32_t		NV_NActive;	/* Num NVRAM buffers being
609						 * written */
610	u_int32_t		NV_NBrokered;	/* Num brokered NVRAM buffers */
611	struct aac_nvramdevinfo	NV_DevInfo[AAC_NFILESYS];	/* per device
612								 * info */
613	u_int32_t		NV_BattNeedsReconditioning;	/* boolean */
614	u_int32_t		NV_TotalSize;	/* size of all non-volatile
615						 * memories in bytes */
616} __attribute__ ((packed));
617
618/*
619 * Data types relating to adapter-initiated FIBs
620 *
621 * Based on types and structures in <aifstruc.h>
622 */
623
624/*
625 * Progress Reports
626 */
627typedef enum {
628	AifJobStsSuccess = 1,
629	AifJobStsFinished,
630	AifJobStsAborted,
631	AifJobStsFailed,
632	AifJobStsLastReportMarker = 100,	/* All prior mean last report */
633	AifJobStsSuspended,
634	AifJobStsRunning
635} AAC_AifJobStatus;
636
637typedef enum {
638	AifJobScsiMin = 1,		/* Minimum value for Scsi operation */
639	AifJobScsiZero,			/* SCSI device clear operation */
640	AifJobScsiVerify,		/* SCSI device Verify operation NO
641					 * REPAIR */
642	AifJobScsiExercise,		/* SCSI device Exercise operation */
643	AifJobScsiVerifyRepair,		/* SCSI device Verify operation WITH
644					 * repair */
645	AifJobScsiMax = 99,		/* Max Scsi value */
646	AifJobCtrMin,			/* Min Ctr op value */
647	AifJobCtrZero,			/* Container clear operation */
648	AifJobCtrCopy,			/* Container copy operation */
649	AifJobCtrCreateMirror,		/* Container Create Mirror operation */
650	AifJobCtrMergeMirror,		/* Container Merge Mirror operation */
651	AifJobCtrScrubMirror,		/* Container Scrub Mirror operation */
652	AifJobCtrRebuildRaid5,		/* Container Rebuild Raid5 operation */
653	AifJobCtrScrubRaid5,		/* Container Scrub Raid5 operation */
654	AifJobCtrMorph,			/* Container morph operation */
655	AifJobCtrPartCopy,		/* Container Partition copy operation */
656	AifJobCtrRebuildMirror,		/* Container Rebuild Mirror operation */
657	AifJobCtrCrazyCache,		/* crazy cache */
658	AifJobCtrMax = 199,		/* Max Ctr type operation */
659	AifJobFsMin,			/* Min Fs type operation */
660	AifJobFsCreate,			/* File System Create operation */
661	AifJobFsVerify,			/* File System Verify operation */
662	AifJobFsExtend,			/* File System Extend operation */
663	AifJobFsMax = 299,		/* Max Fs type operation */
664	AifJobApiFormatNTFS,		/* Format a drive to NTFS */
665	AifJobApiFormatFAT,		/* Format a drive to FAT */
666	AifJobApiUpdateSnapshot,	/* update the read/write half of a
667					 * snapshot */
668	AifJobApiFormatFAT32,		/* Format a drive to FAT32 */
669	AifJobApiMax = 399,		/* Max API type operation */
670	AifJobCtlContinuousCtrVerify,	/* Adapter operation */
671	AifJobCtlMax = 499		/* Max Adapter type operation */
672} AAC_AifJobType;
673
674struct aac_AifContainers {
675	u_int32_t	src;		/* from/master */
676	u_int32_t	dst;		/* to/slave */
677} __attribute__ ((packed));
678
679union aac_AifJobClient {
680	struct aac_AifContainers	container;	/* For Container and
681							 * file system progress
682							 * ops; */
683	int32_t				scsi_dh;	/* For SCSI progress
684							 * ops */
685};
686
687struct aac_AifJobDesc {
688	u_int32_t		jobID;		/* DO NOT FILL IN! Will be
689						 * filled in by AIF */
690	AAC_AifJobType		type;		/* Operation that is being
691						 * performed */
692	union aac_AifJobClient	client;		/* Details */
693} __attribute__ ((packed));
694
695struct aac_AifJobProgressReport {
696	struct aac_AifJobDesc	jd;
697	AAC_AifJobStatus	status;
698	u_int32_t		finalTick;
699	u_int32_t		currentTick;
700	u_int32_t		jobSpecificData1;
701	u_int32_t		jobSpecificData2;
702} __attribute__ ((packed));
703
704/*
705 * Event Notification
706 */
707typedef enum {
708	/* General application notifies start here */
709	AifEnGeneric = 1,		/* Generic notification */
710	AifEnTaskComplete,		/* Task has completed */
711	AifEnConfigChange,		/* Adapter config change occurred */
712	AifEnContainerChange,		/* Adapter specific container
713					 * configuration change */
714	AifEnDeviceFailure,		/* SCSI device failed */
715	AifEnMirrorFailover,		/* Mirror failover started */
716	AifEnContainerEvent,		/* Significant container event */
717	AifEnFileSystemChange,		/* File system changed */
718	AifEnConfigPause,		/* Container pause event */
719	AifEnConfigResume,		/* Container resume event */
720	AifEnFailoverChange,		/* Failover space assignment changed */
721	AifEnRAID5RebuildDone,		/* RAID5 rebuild finished */
722	AifEnEnclosureManagement,	/* Enclosure management event */
723	AifEnBatteryEvent,		/* Significant NV battery event */
724	AifEnAddContainer,		/* A new container was created. */
725	AifEnDeleteContainer,		/* A container was deleted. */
726	AifEnSMARTEvent, 	       	/* SMART Event */
727	AifEnBatteryNeedsRecond,	/* The battery needs reconditioning */
728	AifEnClusterEvent,		/* Some cluster event */
729	AifEnDiskSetEvent,		/* A disk set event occured. */
730	AifDriverNotifyStart=199,	/* Notifies for host driver go here */
731	/* Host driver notifications start here */
732	AifDenMorphComplete, 		/* A morph operation completed */
733	AifDenVolumeExtendComplete 	/* Volume expand operation completed */
734} AAC_AifEventNotifyType;
735
736struct aac_AifEnsGeneric {
737	char	text[132];		/* Generic text */
738} __attribute__ ((packed));
739
740struct aac_AifEnsDeviceFailure {
741	u_int32_t	deviceHandle;	/* SCSI device handle */
742} __attribute__ ((packed));
743
744struct aac_AifEnsMirrorFailover {
745	u_int32_t	container;	/* Container with failed element */
746	u_int32_t	failedSlice;	/* Old slice which failed */
747	u_int32_t	creatingSlice;	/* New slice used for auto-create */
748} __attribute__ ((packed));
749
750struct aac_AifEnsContainerChange {
751	u_int32_t	container[2];	/* container that changed, -1 if no
752					 * container */
753} __attribute__ ((packed));
754
755struct aac_AifEnsContainerEvent {
756	u_int32_t	container;	/* container number  */
757	u_int32_t	eventType;	/* event type */
758} __attribute__ ((packed));
759
760struct aac_AifEnsEnclosureEvent {
761	u_int32_t	empID;		/* enclosure management proc number  */
762	u_int32_t	unitID;		/* unitId, fan id, power supply id,
763					 * slot id, tempsensor id.  */
764	u_int32_t	eventType;	/* event type */
765} __attribute__ ((packed));
766
767struct aac_AifEnsBatteryEvent {
768	AAC_NVBATT_TRANSITION	transition_type;	/* eg from low to ok */
769	AAC_NVBATTSTATUS	current_state;		/* current batt state */
770	AAC_NVBATTSTATUS	prior_state;		/* prev batt state */
771} __attribute__ ((packed));
772
773struct aac_AifEnsDiskSetEvent {
774	u_int32_t	eventType;
775	u_int64_t	DsNum;
776	u_int64_t	CreatorId;
777} __attribute__ ((packed));
778
779typedef enum {
780	CLUSTER_NULL_EVENT = 0,
781	CLUSTER_PARTNER_NAME_EVENT,	/* change in partner hostname or
782					 * adaptername from NULL to non-NULL */
783	/* (partner's agent may be up) */
784	CLUSTER_PARTNER_NULL_NAME_EVENT	/* change in partner hostname or
785					 * adaptername from non-null to NULL */
786	/* (partner has rebooted) */
787} AAC_ClusterAifEvent;
788
789struct aac_AifEnsClusterEvent {
790	AAC_ClusterAifEvent	eventType;
791} __attribute__ ((packed));
792
793struct aac_AifEventNotify {
794	AAC_AifEventNotifyType	type;
795	union {
796		struct aac_AifEnsGeneric		EG;
797		struct aac_AifEnsDeviceFailure		EDF;
798		struct aac_AifEnsMirrorFailover		EMF;
799		struct aac_AifEnsContainerChange	ECC;
800		struct aac_AifEnsContainerEvent		ECE;
801		struct aac_AifEnsEnclosureEvent		EEE;
802		struct aac_AifEnsBatteryEvent		EBE;
803		struct aac_AifEnsDiskSetEvent		EDS;
804/*		struct aac_AifEnsSMARTEvent		ES;*/
805		struct aac_AifEnsClusterEvent		ECLE;
806	} data;
807} __attribute__ ((packed));
808
809/*
810 * Adapter Initiated FIB command structures. Start with the adapter
811 * initiated FIBs that really come from the adapter, and get responded
812 * to by the host.
813 */
814#define AAC_AIF_REPORT_MAX_SIZE 64
815
816typedef enum {
817	AifCmdEventNotify = 1,	/* Notify of event */
818	AifCmdJobProgress,	/* Progress report */
819	AifCmdAPIReport,	/* Report from other user of API */
820	AifCmdDriverNotify,	/* Notify host driver of event */
821	AifReqJobList = 100,	/* Gets back complete job list */
822	AifReqJobsForCtr,	/* Gets back jobs for specific container */
823	AifReqJobsForScsi,	/* Gets back jobs for specific SCSI device */
824	AifReqJobReport,	/* Gets back a specific job report or list */
825	AifReqTerminateJob,	/* Terminates job */
826	AifReqSuspendJob,	/* Suspends a job */
827	AifReqResumeJob,	/* Resumes a job */
828	AifReqSendAPIReport,	/* API generic report requests */
829	AifReqAPIJobStart,	/* Start a job from the API */
830	AifReqAPIJobUpdate,	/* Update a job report from the API */
831	AifReqAPIJobFinish	/* Finish a job from the API */
832} AAC_AifCommand;
833
834struct aac_aif_command {
835	AAC_AifCommand	command;	/* Tell host what type of
836					 * notify this is */
837	u_int32_t	seqNumber;	/* To allow ordering of
838					 * reports (if necessary) */
839	union {
840	struct aac_AifEventNotify	EN;	/* Event notify structure */
841	struct aac_AifJobProgressReport	PR[1];	/* Progress report */
842	u_int8_t			AR[AAC_AIF_REPORT_MAX_SIZE];
843	} data;
844} __attribute__ ((packed));
845
846/*
847 * Filesystem commands/data
848 *
849 * The adapter has a very complex filesystem interface, most of which we ignore.
850 * (And which seems not to be implemented, anyway.)
851 */
852
853/*
854 * FSA commands
855 * (not used?)
856 */
857typedef enum {
858	Null = 0,
859	GetAttributes,
860	SetAttributes,
861	Lookup,
862	ReadLink,
863	Read,
864	Write,
865	Create,
866	MakeDirectory,
867	SymbolicLink,
868	MakeNode,
869	Removex,
870	RemoveDirectory,
871	Rename,
872	Link,
873	ReadDirectory,
874	ReadDirectoryPlus,
875	FileSystemStatus,
876	FileSystemInfo,
877	PathConfigure,
878	Commit,
879	Mount,
880	UnMount,
881	Newfs,
882	FsCheck,
883	FsSync,
884	SimReadWrite,
885	SetFileSystemStatus,
886	BlockRead,
887	BlockWrite,
888	NvramIoctl,
889	FsSyncWait,
890	ClearArchiveBit,
891	SetAcl,
892	GetAcl,
893	AssignAcl,
894	FaultInsertion,
895	CrazyCache
896} AAC_FSACommand;
897
898/*
899 * Command status values
900 */
901typedef enum {
902	ST_OK = 0,
903	ST_PERM = 1,
904	ST_NOENT = 2,
905	ST_IO = 5,
906	ST_NXIO = 6,
907	ST_E2BIG = 7,
908	ST_ACCES = 13,
909	ST_EXIST = 17,
910	ST_XDEV = 18,
911	ST_NODEV = 19,
912	ST_NOTDIR = 20,
913	ST_ISDIR = 21,
914	ST_INVAL = 22,
915	ST_FBIG = 27,
916	ST_NOSPC = 28,
917	ST_ROFS = 30,
918	ST_MLINK = 31,
919	ST_WOULDBLOCK = 35,
920	ST_NAMETOOLONG = 63,
921	ST_NOTEMPTY = 66,
922	ST_DQUOT = 69,
923	ST_STALE = 70,
924	ST_REMOTE = 71,
925	ST_BADHANDLE = 10001,
926	ST_NOT_SYNC = 10002,
927	ST_BAD_COOKIE = 10003,
928	ST_NOTSUPP = 10004,
929	ST_TOOSMALL = 10005,
930	ST_SERVERFAULT = 10006,
931	ST_BADTYPE = 10007,
932	ST_JUKEBOX = 10008,
933	ST_NOTMOUNTED = 10009,
934	ST_MAINTMODE = 10010,
935	ST_STALEACL = 10011
936} AAC_FSAStatus;
937
938/*
939 * Volume manager commands
940 */
941typedef enum _VM_COMMANDS {
942	VM_Null = 0,
943	VM_NameServe,
944	VM_ContainerConfig,
945	VM_Ioctl,
946	VM_FilesystemIoctl,
947	VM_CloseAll,
948	VM_CtBlockRead,
949	VM_CtBlockWrite,
950	VM_SliceBlockRead,	 /* raw access to configured storage objects */
951	VM_SliceBlockWrite,
952	VM_DriveBlockRead,	 /* raw access to physical devices */
953	VM_DriveBlockWrite,
954	VM_EnclosureMgt,	 /* enclosure management */
955	VM_Unused,		 /* used to be diskset management */
956	VM_CtBlockVerify,
957	VM_CtPerf,		 /* performance test */
958	VM_CtBlockRead64,
959	VM_CtBlockWrite64,
960	VM_CtBlockVerify64,
961} AAC_VMCommand;
962
963/*
964 * "mountable object"
965 */
966struct aac_mntobj {
967	u_int32_t			ObjectId;
968	char				FileSystemName[16];
969	struct aac_container_creation	CreateInfo;
970	u_int32_t			Capacity;
971	AAC_FSAVolType			VolType;
972	AAC_FType			ObjType;
973	u_int32_t			ContentState;
974#define FSCS_READONLY		0x0002		/* XXX need more information
975						 * than this */
976	union {
977		u_int32_t	pad[8];
978	} ObjExtension;
979	u_int32_t			AlterEgoId;
980} __attribute__ ((packed));
981
982struct aac_mntinfo {
983	AAC_VMCommand		Command;
984	AAC_FType		MntType;
985	u_int32_t		MntCount;
986} __attribute__ ((packed));
987
988struct aac_mntinforesponse {
989	AAC_FSAStatus		Status;
990	AAC_FType		MntType;
991	u_int32_t		MntRespCount;
992	struct aac_mntobj	MntTable[1];
993} __attribute__ ((packed));
994
995/*
996 * Container shutdown command.
997 */
998struct aac_closecommand {
999	u_int32_t	Command;
1000	u_int32_t	ContainerId;
1001} __attribute__ ((packed));
1002
1003/*
1004 * Write 'stability' options.
1005 */
1006typedef enum {
1007	CSTABLE = 1,
1008	CUNSTABLE
1009} AAC_CacheLevel;
1010
1011/*
1012 * Commit level response for a write request.
1013 */
1014typedef enum {
1015	CMFILE_SYNC_NVRAM = 1,
1016	CMDATA_SYNC_NVRAM,
1017	CMFILE_SYNC,
1018	CMDATA_SYNC,
1019	CMUNSTABLE
1020} AAC_CommitLevel;
1021
1022/*
1023 * Block read/write operations.
1024 * These structures are packed into the 'data' area in the FIB.
1025 */
1026
1027struct aac_blockread {
1028	AAC_VMCommand		Command;	/* not FSACommand! */
1029	u_int32_t		ContainerId;
1030	u_int32_t		BlockNumber;
1031	u_int32_t		ByteCount;
1032	struct aac_sg_table	SgMap;		/* variable size */
1033} __attribute__ ((packed));
1034
1035struct aac_blockread_response {
1036	AAC_FSAStatus		Status;
1037	u_int32_t		ByteCount;
1038} __attribute__ ((packed));
1039
1040struct aac_blockwrite {
1041	AAC_VMCommand		Command;	/* not FSACommand! */
1042	u_int32_t		ContainerId;
1043	u_int32_t		BlockNumber;
1044	u_int32_t		ByteCount;
1045	AAC_CacheLevel	Stable;
1046	struct aac_sg_table	SgMap;		/* variable size */
1047} __attribute__ ((packed));
1048
1049struct aac_blockwrite_response {
1050	AAC_FSAStatus	Status;
1051	u_int32_t		ByteCount;
1052	AAC_CommitLevel	Committed;
1053} __attribute__ ((packed));
1054
1055/*
1056 * Container shutdown command.
1057 */
1058struct aac_close_command {
1059	AAC_VMCommand      Command;
1060	u_int32_t          ContainerId;
1061};
1062
1063/*
1064 * Register set for adapters based on the Falcon bridge and PPC core
1065 */
1066
1067#define AAC_FA_DOORBELL0_CLEAR		0x00
1068#define AAC_FA_DOORBELL1_CLEAR		0x02
1069#define AAC_FA_DOORBELL0		0x04
1070#define AAC_FA_DOORBELL1		0x06
1071#define AAC_FA_MASK0_CLEAR		0x08
1072#define AAC_FA_MASK1_CLEAR		0x0a
1073#define	AAC_FA_MASK0			0x0c
1074#define AAC_FA_MASK1			0x0e
1075#define AAC_FA_MAILBOX			0x10
1076#define	AAC_FA_FWSTATUS			0x2c	/* Mailbox 7 */
1077#define	AAC_FA_INTSRC			0x900
1078
1079#define AAC_FA_HACK(sc)	(void)AAC_GETREG4(sc, AAC_FA_INTSRC)
1080
1081/*
1082 * Register definitions for the Adaptec AAC-364 'Jalapeno I/II' adapters, based
1083 * on the SA110 'StrongArm'.
1084 */
1085
1086#define AAC_SA_DOORBELL0_CLEAR		0x98	/* doorbell 0 (adapter->host) */
1087#define AAC_SA_DOORBELL0_SET		0x9c
1088#define AAC_SA_DOORBELL0		0x9c
1089#define AAC_SA_MASK0_CLEAR		0xa0
1090#define AAC_SA_MASK0_SET		0xa4
1091
1092#define AAC_SA_DOORBELL1_CLEAR		0x9a	/* doorbell 1 (host->adapter) */
1093#define AAC_SA_DOORBELL1_SET		0x9e
1094#define AAC_SA_DOORBELL1		0x9e
1095#define AAC_SA_MASK1_CLEAR		0xa2
1096#define AAC_SA_MASK1_SET		0xa6
1097
1098#define AAC_SA_MAILBOX			0xa8	/* mailbox (20 bytes) */
1099#define AAC_SA_FWSTATUS			0xc4
1100
1101/*
1102 * Register definitions for the Adaptec 'Pablano' adapters, based on the i960Rx,
1103 * and other related adapters.
1104 */
1105
1106#define AAC_RX_IDBR		0x20	/* inbound doorbell register */
1107#define AAC_RX_IISR		0x24	/* inbound interrupt status register */
1108#define AAC_RX_IIMR		0x28	/* inbound interrupt mask register */
1109#define AAC_RX_ODBR		0x2c	/* outbound doorbell register */
1110#define AAC_RX_OISR		0x30	/* outbound interrupt status register */
1111#define AAC_RX_OIMR		0x34	/* outbound interrupt mask register */
1112
1113#define AAC_RX_MAILBOX		0x50	/* mailbox (20 bytes) */
1114#define AAC_RX_FWSTATUS		0x6c
1115
1116/*
1117 * Common bit definitions for the doorbell registers.
1118 */
1119
1120/*
1121 * Status bits in the doorbell registers.
1122 */
1123#define AAC_DB_SYNC_COMMAND	(1<<0)	/* send/completed synchronous FIB */
1124#define AAC_DB_COMMAND_READY	(1<<1)	/* posted one or more commands */
1125#define AAC_DB_RESPONSE_READY	(1<<2)	/* one or more commands complete */
1126#define AAC_DB_COMMAND_NOT_FULL	(1<<3)	/* command queue not full */
1127#define AAC_DB_RESPONSE_NOT_FULL (1<<4)	/* response queue not full */
1128
1129/*
1130 * The adapter can request the host print a message by setting the
1131 * DB_PRINTF flag in DOORBELL0.  The driver responds by collecting the
1132 * message from the printf buffer, clearing the DB_PRINTF flag in
1133 * DOORBELL0 and setting it in DOORBELL1.
1134 * (ODBR and IDBR respectively for the i960Rx adapters)
1135 */
1136#define AAC_DB_PRINTF		(1<<5)	/* adapter requests host printf */
1137#define AAC_PRINTF_DONE		(1<<5)	/* Host completed printf processing */
1138
1139/*
1140 * Mask containing the interrupt bits we care about.  We don't anticipate (or
1141 * want) interrupts not in this mask.
1142 */
1143#define AAC_DB_INTERRUPTS	(AAC_DB_COMMAND_READY  |	\
1144				 AAC_DB_RESPONSE_READY |	\
1145				 AAC_DB_PRINTF)
1146