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