1/*	$OpenBSD: amireg.h,v 1.30 2008/10/22 18:42:29 marco Exp $	*/
2
3/*
4 * Copyright (c) 2000 Michael Shalayeff
5 * Copyright (c) 2005 Marco Peereboom
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 ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
26 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 * THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#define	AMI_MAX_PDRIVES		(75)
31#define	AMI_MAX_LDRIVES		8
32#define	AMI_MAX_SPANDEPTH	4
33#define	AMI_MAX_DEVDEPTH	8
34#define	AMI_MAX_TARGET		16
35
36#define	AMI_BIG_MAX_PDRIVES	(256)
37#define	AMI_BIG_MAX_LDRIVES	40
38#define	AMI_BIG_MAX_SPANDEPTH	8
39#define	AMI_BIG_MAX_DEVDEPTH	32
40
41#define	AMI_MAXCMDS	126		/* theoretical limit is 250 */
42#define	AMI_SECTOR_SIZE	512
43#define	AMI_MAXOFFSETS	26
44#define	AMI_SGEPERCMD	32		/* to prevent page boundary crossing */
45#define AMI_MAX_BUSYWAIT 10		/* wait up to 10 usecs */
46#define AMI_MAX_POLLWAIT 1000000	/* wait up to 1000 000 usecs */
47#define AMI_MAXIOCTLCMDS 1		/* number of parallel ioctl calls */
48#define AMI_MAXPROCS	 2		/* number of processors on a channel */
49#define AMI_MAXRAWCMDS	 2		/* number of parallel processor cmds */
50
51#define	AMI_MAXFER	(AMI_MAXOFFSETS * PAGE_SIZE)
52
53#define	AMI_QIDB	0x20
54#define		AMI_QIDB_EXEC	0x01
55#define		AMI_QIDB_ACK	0x02
56#define	AMI_QODB	0x2c
57#define		AMI_QODB_READY	0x10001234
58
59#define	AMI_SCMD	0x10
60#define		AMI_SCMD_EXEC	0x10
61#define		AMI_SCMD_ACK	0x08
62#define	AMI_SMBSTAT	0x10
63#define		AMI_SMBST_BUSY	0x10
64#define	AMI_SIEM	0x11
65#define		AMI_SEIM_ENA	0xc0
66#define	AMI_SMBADDR	0x14
67#define	AMI_SMBENA	0x18
68#define	AMI_ISTAT	0x1a
69#define		AMI_ISTAT_PEND	0x40
70
71/* commands */
72#define	AMI_READ	0x01
73#define	AMI_WRITE	0x02
74#define	AMI_PASSTHRU	0x03	/* pass scsi cdb to the device */
75#define	AMI_EINQUIRY	0x04	/* extended inquiry */
76#define	AMI_INQUIRY	0x05	/* inquiry */
77#define	AMI_CHSTATE	0x06	/* pad[0] -- state */
78#define		AMI_STATE_ON	3
79#define		AMI_STATE_FAIL	4
80#define		AMI_STATE_SPARE	6
81#define	AMI_RCONFIG	0x07	/* read configuration up to 4 spans */
82#define	AMI_REBUILDPD	0x08	/* rebuild physical drive */
83#define	AMI_CHECK	0x09	/* check consistency */
84#define	AMI_FLUSH	0x0a
85#define	AMI_ILDRIVE	0x0b	/* init logical drive */
86#define	AMI_EINQUIRY3	0x0c
87#define	AMI_DCHDR	0x14	/* get/set dedicated channel/drives */
88#define	AMI_GRBLDPROGR	0x18	/* get rebuild progress */
89#define	AMI_GCHECKPROGR	0x19	/* get check consistency progress */
90#define	AMI_GILDRPROGR	0x1b	/* get init logical drive progress */
91#define	AMI_WRCONFIG	0x20	/* write configuration up to 4 spans */
92#define	AMI_RWRCONFIG	0x21	/* raid write config */
93#define	AMI_RRDCONFIG	0x22	/* raid read config */
94#define	AMI_GRBLDRATE	0x23	/* get rebuild rate */
95#define	AMI_SRBLDRATE	0x24	/* set rebuild rate */
96#define	AMI_UPLDCFGUT	0x25	/* upload config utility */
97#define	AMI_UPLDRVPROP	0x26	/* update logical drive property */
98#define	AMI_ABRTREBLD	0x28	/* abort rebuild */
99#define	AMI_ABRTCHECK	0x29	/* abort check consistency */
100#define	AMI_ABRTILDRV	0x2b	/* abort init logical drive */
101#define	AMI_WRBLOCK	0x2c	/* flash write block */
102#define	AMI_PRGFLASH	0x2d	/* flash program */
103#define	AMI_SFLUSHINTV	0x2e	/* channel == cache flush interval */
104#define	AMI_PCHIPSETVAL	0x2f	/* program chipset values */
105#define		AMI_CS_NEPTUNE	0x61
106#define		AMI_CS_OTHER	0xe1
107#define		AMI_CS_TRITON	0xe2
108#define	AMI_SNEG	0x30	/* scsi sync negotiation get/ena/dis */
109#define		AMI_SNEG_GET	1
110#define		AMI_SNEG_SET	2
111#define	AMI_QTAG	0x31	/* scsi queue tag get/set */
112#define		AMI_QTAG_GET	1
113#define		AMI_QTAG_SET	2
114#define	AMI_GSUPARAM	0x32	/* get spinup parameters */
115#define	AMI_SSUPARAM	0x33	/* set spinup parameters */
116#define	AMI_GDROAMINFO	0x34
117#define	AMI_GMACHID	0x36	/* get machine id */
118#define	AMI_BIOSPDATA	0x40	/* get bios private data */
119#define	AMI_I2OCFGDLG	0x41	/* I2O config dialog */
120#define	AMI_GCACHESTAT	0x50	/* get cache statistics */
121#define	AMI_SPEAKER	0x51	/* speaker control */
122#define		AMI_SPKR_OFF	0
123#define		AMI_SPKR_ON	1
124#define		AMI_SPKR_SHUT	2
125#define		AMI_SPKR_GVAL	3
126#define		AMI_SPKR_TEST	4
127#define	AMI_GDUMP	0x52	/* get error condition in text */
128#define	AMI_SENSEDUMPA	0x53	/* get SCSI sense dump area */
129#define	AMI_STDIAG	0x54	/* start diagnostics -- 2.1 */
130#define	AMI_FRAID_PF	0x55	/* get/set flexraid power fail */
131#define		AMI_GFRAIDPF	1
132#define		AMI_SFRAIDPF	2
133#define	AMI_FRAIDVS	0x56	/* get/set flexraid virtual sizing */
134#define		AMI_GFRAIDVS	1
135#define		AMI_SFRAIDVS	2
136#define	AMI_BBMANAGE	0x57	/* bad block manage */
137#define	AMI_RECONSTRUCT	0x60	/* begin reconstruction */
138#define	AMI_GRECONSTRUCT 0x61	/* get reconstruction progress */
139#define	AMI_BIOSSTAT	0x62	/* enable/disable bios */
140#define	AMI_RDCFGDSK	0x63	/* read configuration from disk */
141#define	AMI_AREBUILD	0x64	/* get/set autorebuild/battery charge */
142#define		AMI_GUCAP	1	/* get ultra capabilities */
143#define		AMI_SUCAP	2	/* set ultra capability */
144#define		AMI_GARBLD	3
145#define		AMI_SARBLD	4
146#define		AMI_GFCC	5	/* get fast charge counter */
147#define		AMI_SFCC	6	/* set fast charge counter */
148#define		AMI_GCUCAP	7	/* get channel ultra capabilities */
149#define		AMI_SCUCAP	8	/* set channel ultra capabilities */
150#define	AMI_SFD		0x66	/* set factory defaults */
151#define	AMI_RDCONFIG8	0x67	/* read configuration up to 8 spans */
152#define	AMI_WRCONFIG8	0x68	/* write config up to 8 spans */
153#define	AMI_ESENSEDUMPA	0x69	/* extended scsi dump area */
154#define	AMI_RERRC	0x6a	/* reset error counter */
155#define	AMI_BOOTUP	0x6b	/* ena/dis physical drive boot up */
156#define	AMI_ENCLOSURE	0x6c	/* get/set enclosure type */
157#define	AMI_WRCFGD	0x6c	/* write config disk -- 2.1 */
158#define	AMI_HAPIRRLD	0x6e
159#define	AMI_LDRVRIGHTS	0x6f
160#define	AMI_CLUSTERING	0x70
161#define	AMI_GCHPROP	0x71	/* get channel properties */
162#define	AMI_SCHTERM	0x72	/* set channel termination */
163#define		AMI_TERM_DISABLE 0
164#define		AMI_TERM_ENABLE	1
165#define		AMI_TERM_HIGH	2
166#define		AMI_TERM_WIDE	3
167#define		AMI_TERM_DFLT	16
168#define	AMI_QUIETCH	0x73	/* quiet channel */
169#define	AMI_ACTIVATECH	0x74	/* activate channel */
170#define	AMI_STARTU	0x75	/* start unit, pad[0] -- sync/async */
171#define		AMI_STARTU_SYNC	1
172#define		AMI_STARTU_ASYN	2
173#define	AMI_STOPU	0x76	/* stop unit */
174#define	AMI_GERRC	0x77	/* get error counter */
175#define	AMI_GBTDS	0x78	/* get boot time drive status */
176#define	AMI_FMTPROG	0x79
177#define	AMI_RCAPCMD	0x7a	/* read capacity */
178#define	AMI_WRCRX	0x7b
179#define	AMI_RDCRX	0x7c
180#define	AMI_GINID	0x7d	/* get initiator id */
181#define	AMI_HAPICMD	0x7e
182#define	AMI_SINID	0x7f	/* set initiator id */
183#define	AMI_SMARTMSEL	0x80
184#define	AMI_SPSTARTU	0x85	/* special start unit command */
185#define	AMI_NVFAILHIST	0x90
186#define	AMI_DCMDABRT	0x91
187#define	AMI_GDRIVEHIST	0x92	/* get drive history */
188#define	AMI_GESENSE	0x93	/* get extended sense data dump */
189#define	AMI_ADAPTER	0x95	/* save/restore adapter params */
190#define		AMI_ADP_SAVE	0
191#define		AMI_ADP_LOAD	1
192#define	AMI_RESET	0x96	/* adapter reset */
193#define	AMI_PRGCLASS	0x97	/* program class code */
194#define	AMI_UPHTML	0x98	/* upload html utility */
195#define	AMI_NEWCFG	0x99
196#define	AMI_NEWOP	0xa0
197#define	AMI_FCOP	0xa1
198#define		AMI_FC_PROCEED	0x02
199#define		AMI_FC_DELLDRV	0x03
200#define		AMI_FC_RDCONF	0x04
201#define		AMI_FC_RDFCONF	0x05
202#define		AMI_FC_GCONFDSK	0x06
203#define		AMI_FC_CHLDNO	0x07
204#define		AMI_FC_CMPCTCFG	0x08
205#define		AMI_FC_DRVGRP	0x09
206#define		AMI_FC_GLOOPINF	0x0a
207#define		AMI_FC_CHLOOPID	0x0b
208#define		AMI_FC_GNSCH	0x0c
209#define		AMI_FC_WRCONF	0x0d
210#define		AMI_FC_PRODINF	0x0e
211#define		AMI_FC_EINQ3	0x0f
212#define		AMI_FC_EINQ4	0x1f
213#define			AMI_FC_EINQ3_SOLICITED_NOTIFY	0x01
214#define			AMI_FC_EINQ3_SOLICITED_FULL	0x02
215#define			AMI_FC_EINQ3_UNSOLICITED	0x03
216#define	AMI_MISC	0xa4
217#define		AMI_GET_BGI	0x13
218#define		AMI_GET_IO_CMPL	0x5b
219#define		AMI_SET_IO_CMPL	0x5c
220#define	AMI_CHFUNC	0xa9
221#define	AMI_MANAGE	0xb0	/* manage functions */
222#define		AMI_MGR_LUN	0x00
223#define		AMI_MGR_THERM	0x01
224#define		AMI_MGR_EEPROM	0x02
225#define		AMI_MGR_LDNAMES	0x03
226#define		AMI_MGR_FCWWN	0x04
227#define		AMI_MGR_CFGACC	0x05
228#define	AMI_HSPDIAG	0xb1
229#define	AMI_GESENSEINFO	0xb2	/* get extended sense info */
230#define	AMI_SYSFLUSH	0xfe	/* flush system */
231
232/* command structures */
233struct ami_iocmd {
234	u_int8_t	acc_cmd;
235	u_int8_t	acc_id;
236	union {
237#define	acc_mbox	_._ami_mbox
238		struct {
239			u_int16_t	amb_nsect;
240			u_int32_t	amb_lba;
241			u_int32_t	amb_data;
242			u_int8_t	amb_ldn;	/* logical drive no */
243			u_int8_t	amb_nsge;
244			u_int8_t	amb_reserved;
245		} __packed _ami_mbox;
246
247#define	acc_io		_._ami_io
248		struct {
249			u_int8_t	aio_channel;
250			u_int8_t	aio_param;
251			u_int8_t	aio_pad[4];
252			u_int32_t	aio_data;
253			u_int8_t	aio_pad1[3];
254		} __packed _ami_io;
255
256#define	acc_passthru	_._ami_passthru
257		struct {
258			u_int16_t	apt_dummy0;
259			u_int32_t	apt_dummy1;
260			u_int32_t	apt_data;
261			u_int8_t	apt_dummy2;
262			u_int8_t	apt_dummy3;
263			u_int8_t	apt_reserved;
264		} __packed _ami_passthru;
265
266#define	acc_ldrv	_._ami_ldrv
267		struct {
268			u_int16_t	ald_dummy0;
269			u_int32_t	ald_dummy1;
270			u_int32_t	ald_data;
271			u_int8_t	ald_ldrv;
272			u_int8_t	ald_dummy2;
273			u_int8_t	ald_reserved;
274		} __packed _ami_ldrv;
275	} __packed _;
276	u_int8_t	acc_busy;
277	u_int8_t	acc_nstat;
278	u_int8_t	acc_status;
279#define	AMI_MAXSTATACK	0x2e
280	u_int8_t	acc_cmplidl[AMI_MAXSTATACK];
281	u_int8_t	acc_poll;
282	u_int8_t	acc_ack;
283	u_int8_t	acc_pad[0x3e];	/* pad to 128 bytes */
284} __packed;
285
286struct ami_sgent {
287	u_int32_t	asg_addr;
288	u_int32_t	asg_len;
289} __packed;
290
291struct ami_iocmd64 {
292	u_int8_t	acc_cmd;
293	u_int8_t	acc_id;
294	union {
295		struct {
296			u_int16_t	amb_nsect;
297			u_int32_t	amb_lba;
298			u_int32_t	amb_reserved1;
299			u_int8_t	amb_ldn;	/* logical drive no */
300			u_int8_t	amb_nsge;	/* high bit == 1 */
301			u_int8_t	amb_reserved;
302		} __packed _ami_mbox;
303
304		struct {
305			u_int8_t	aio_channel;
306			u_int8_t	aio_param;
307			u_int8_t	aio_pad[4];
308			u_int32_t	aio_data;
309			u_int8_t	aio_pad1[3];
310		} __packed _ami_io;
311
312		struct {
313			u_int16_t	apt_dummy0;
314			u_int32_t	apt_dummy1;
315			u_int32_t	apt_data;
316			u_int8_t	apt_dummy2;
317			u_int8_t	apt_dummy3;
318			u_int8_t	apt_reserved;
319		} __packed _ami_passthru;
320
321		struct {
322			u_int16_t	ald_dummy0;
323			u_int32_t	ald_dummy1;
324			u_int32_t	ald_data;
325			u_int8_t	ald_ldrv;
326			u_int8_t	ald_dummy2;
327			u_int8_t	ald_reserved;
328		} __packed _ami_ldrv;
329	} __packed _;
330	u_int8_t	acc_busy;
331	u_int32_t	acc_data_l;
332	u_int32_t	acc_data_h;
333	u_int32_t	acc_reserved;
334	u_int8_t	acc_nstat;
335	u_int8_t	acc_status;
336	u_int8_t	acc_cmplidl[AMI_MAXSTATACK];
337	u_int8_t	acc_poll;
338	u_int8_t	acc_ack;
339	u_int8_t	acc_pad[0x32];	/* pad to 128 bytes */
340} __packed;
341
342struct ami_sgent64 {
343	u_int32_t	asg_addr_l;
344	u_int32_t	asg_addr_h;
345	u_int32_t	asg_len;
346} __packed;
347
348struct ami_passthrough {
349	u_int8_t	apt_param;
350#define	AMI_PTPARAM(t,a,l)	(((l) << 7) | (((a) & 1) << 3) | ((t) & 3))
351#define	AMI_TIMEOUT_6	0
352#define	AMI_TIMEOUT_60	1
353#define	AMI_TIMEOUT_10m	2
354#define	AMI_TIMEOUT_3h	3
355	u_int8_t	apt_ldn;
356	u_int8_t	apt_channel;
357	u_int8_t	apt_target;
358	u_int8_t	apt_qtag;
359	u_int8_t	apt_qact;
360#define	AMI_MAX_CDB	10
361	u_int8_t	apt_cdb[AMI_MAX_CDB];
362	u_int8_t	apt_ncdb;
363	u_int8_t	apt_nsense;
364#define	AMI_MAX_SENSE	32
365	u_int8_t	apt_sense[AMI_MAX_SENSE];
366	u_int8_t	apt_nsge;
367	u_int8_t	apt_scsistat;
368	u_int32_t	apt_data;
369	u_int32_t	apt_datalen;
370} __packed;
371
372struct ami_inquiry {
373	u_int8_t	ain_maxcmd;
374	u_int8_t	ain_rbldrate;	/* rebuild rate %% */
375	u_int8_t	ain_targets;	/* max targets per channel */
376	u_int8_t	ain_channels;
377	u_int8_t	ain_fwver[4];
378	u_int16_t	ain_flashage;
379	u_int8_t	ain_chipset;	/* parity generation policy */
380	u_int8_t	ain_ramsize;
381	u_int8_t	ain_flushintv;
382	u_int8_t	ain_biosver[4];
383	u_int8_t	ain_brdtype;
384	u_int8_t	ain_scsisensealert;
385	u_int8_t	ain_wrcfgcnt;	/* write config count */
386	u_int8_t	ain_drvinscnt;	/* drive insertion count */
387	u_int8_t	ain_insdrv;	/* inserted drive */
388	u_int8_t	ain_battery;	/* battery status */
389	u_int8_t	ain_reserved;
390
391	u_int8_t	ain_nlogdrv;
392	u_int8_t	ain_reserved1[3];
393	u_int32_t	ain_ldsize[AMI_MAX_LDRIVES];
394	u_int8_t	ain_ldprop[AMI_MAX_LDRIVES];
395	u_int8_t	ain_ldstat[AMI_MAX_LDRIVES];
396
397	u_int8_t	ain_pdstat[AMI_MAX_PDRIVES];
398	u_int8_t	ain_predictivefailure;
399
400	u_int8_t	ain_pdfmtinp[AMI_MAX_PDRIVES];
401	u_int8_t	ain_reserved2[AMI_MAX_PDRIVES];
402
403	u_int32_t	ain_esize;	/* extended data size */
404	u_int16_t	ain_ssid;	/* subsystem id */
405	u_int16_t	ain_ssvid;	/* subsystem vendor id */
406	u_int32_t	ain_signature;
407#define	AMI_SIGN431	0xfffe0001
408#define	AMI_SIGN438	0xfffd0002
409#define	AMI_SIGN762	0xfffc0003
410#define	AMI_SIGNT5	0xfffb0004
411#define	AMI_SIGN466	0xfffa0005
412} __packed;
413
414#define MAX_NOTIFY_SIZE	0x80
415#define CUR_NOTIFY_SIZE (sizeof(struct ami_notify))
416struct ami_notify {
417	u_int32_t	ano_eventcounter;	/* incremented for changes */
418
419	u_int8_t	ano_paramcounter;	/* param change */
420	u_int8_t	ano_paramid;		/* param modified */
421#define AMI_PARAM_RBLD_RATE		0x01 /* new rebuild rate */
422#define AMI_PARAM_CACHE_FLUSH_INTERVAL	0x02 /* new cache flush interval */
423#define AMI_PARAM_SENSE_ALERT		0x03 /* pd caused check condition */
424#define AMI_PARAM_DRIVE_INSERTED	0x04 /* pd inserted */
425#define AMI_PARAM_BATTERY_STATUS	0x05 /* battery status */
426#define AMI_PARAM_NVRAM_EVENT_ALERT	0x06 /* NVRAM # of entries */
427#define AMI_PARAM_PATROL_READ_UPDATE	0x07 /* # pd done with patrol read */
428#define AMI_PARAM_PATROL_READ_STATUS	0x08 /* 0 stopped
429					      * 2 aborted
430					      * 4 started */
431
432	u_int16_t	ano_paramval;		/* new val modified param */
433
434	u_int8_t	ano_writeconfcounter;	/* write config */
435	u_int8_t	ano_writeconfrsvd[3];
436
437	u_int8_t	ano_ldopcounter;	/* ld op started/completed */
438	u_int8_t	ano_ldopid;		/* ld modified */
439	u_int8_t	ano_ldopcmd;		/* ld operation */
440#define AMI_LDCMD_CHKCONSISTANCY	0x01
441#define AMI_LDCMD_INITIALIZE		0x02
442#define AMI_LDCMD_RECONSTRUCTION	0x03
443	u_int8_t	ano_ldopstatus;		/* status of the operation */
444#define AMI_LDOP_SUCCESS		0x00
445#define AMI_LDOP_FAILED			0x01
446#define AMI_LDOP_ABORTED		0x02
447#define AMI_LDOP_CORRECTED		0x03
448#define AMI_LDOP_STARTED		0x04
449
450	u_int8_t	ano_ldstatecounter;	/* change of ld state */
451	u_int8_t	ano_ldstateid;		/* ld state changed */
452	u_int8_t	ano_ldstatenew;		/* new state */
453	u_int8_t	ano_ldstateold;		/* old state */
454#define AMI_RDRV_OFFLINE		0
455#define AMI_RDRV_DEGRADED		1
456#define AMI_RDRV_OPTIMAL		2
457#define AMI_RDRV_DELETED		3
458
459	u_int8_t	ano_pdstatecounter;	/* change of pd state */
460	u_int8_t	ano_pdstateid;		/* pd state changed */
461	u_int8_t	ano_pdstatenew;		/* new state */
462	u_int8_t	ano_pdstateold;		/* old state */
463#define AMI_PD_UNCNF			0
464#define AMI_PD_ONLINE			3
465#define AMI_PD_FAILED			4
466#define AMI_PD_RBLD			5
467#define AMI_PD_HOTSPARE			6
468
469	u_int8_t	ano_pdfmtcounter;	/* pd format started/over */
470	u_int8_t	ano_pdfmtid;		/* pd id */
471	u_int8_t	ano_pdfmtval;		/* format started/over */
472#define AMI_PDFMT_START			0x01
473#define AMI_PDFMT_OVER			0x02
474	u_int8_t	ano_pdfmtrsvd;
475
476	u_int8_t	ano_targxfercounter;	/* SCSI-2 Xfer rate change */
477	u_int8_t	ano_targxferid;		/* pd that changed  */
478	u_int8_t	ano_targxferval;	/* new xfer parameters */
479	u_int8_t	ano_targxferrsvd;
480
481	u_int8_t	ano_fclidchgcounter;	/* loop id changed */
482	u_int8_t	ano_fclidpdid;		/* pd id */
483	u_int8_t	ano_fclid0;		/* loop id on fc loop 0 */
484	u_int8_t	ano_fclid1;		/* loop id on fc loop 1 */
485
486	u_int8_t	ano_fclstatecounter;	/* loop state changed */
487	u_int8_t	ano_fclstate0;		/* state of fc loop 0 */
488	u_int8_t	ano_fclstate1;		/* state of fc loop 1 */
489#define AMI_FCLOOP_FAILED		0
490#define AMI_FCLOOP_ACTIVE		1
491#define AMI_FCLOOP_TRANSIENT		2
492	u_int8_t	ano_fclstatersvd;
493} __packed;
494
495struct ami_fc_einquiry {
496	u_int32_t	ain_size;	/* size of this structure */
497
498	/* notify */
499	struct	ami_notify ain_notify;
500	u_int8_t	ain_notifyrsvd[MAX_NOTIFY_SIZE - CUR_NOTIFY_SIZE];
501
502	u_int8_t	ain_rbldrate;	/* rebuild rate %% */
503	u_int8_t	ain_flushintvl;
504	u_int8_t	ain_sensealert;
505	u_int8_t	ain_drvinscnt;	/* drive insertion count */
506	u_int8_t	ain_battery;	/* battery status */
507
508	u_int8_t	ain_nlogdrv;
509	u_int8_t	ain_recon[AMI_BIG_MAX_LDRIVES / 8];
510	u_int16_t	ain_stat[AMI_BIG_MAX_LDRIVES / 8];
511
512	u_int32_t	ain_ldsize[AMI_BIG_MAX_LDRIVES];
513	u_int8_t	ain_ldprop[AMI_BIG_MAX_LDRIVES];
514	u_int8_t	ain_ldstat[AMI_BIG_MAX_LDRIVES];
515
516	u_int8_t	ain_pdstat[AMI_BIG_MAX_PDRIVES];
517	u_int16_t	ain_pdfmtinp[AMI_BIG_MAX_PDRIVES / 16];
518	u_int8_t	ain_pdrates[80];	/* pdrv xfer rates */
519	u_int8_t	ain_pad[263];		/* pad to 1k */
520} __packed;
521
522struct ami_fc_prodinfo {
523	u_int32_t	api_size;	/* size of this structure */
524	u_int32_t	api_config;
525	u_int8_t	api_fwver[16];
526	u_int8_t	api_biosver[16];
527	u_int8_t	api_product[80];
528	u_int8_t	api_maxcmd;
529	u_int8_t	api_channels;
530	u_int8_t	api_fcloops;
531	u_int8_t	api_memtype;
532	u_int32_t	api_signature;
533	u_int16_t	api_ramsize;
534	u_int16_t	api_ssid;
535	u_int16_t	api_ssvid;
536	u_int8_t	api_nnotify;
537} __packed;
538
539struct ami_diskarray {
540	u_int8_t	ada_nld;
541	u_int8_t	ada_pad[3];
542	struct {
543		u_int8_t	adl_spandepth;
544		u_int8_t	adl_raidlvl;
545		u_int8_t	adl_rdahead;
546		u_int8_t	adl_stripesz;
547		u_int8_t	adl_status;
548		u_int8_t	adl_wrpolicy;
549		u_int8_t	adl_directio;
550		u_int8_t	adl_nstripes;
551		struct {
552			u_int32_t	ads_start;
553			u_int32_t	ads_length;	/* blocks */
554			struct {
555				u_int8_t	add_channel;
556				u_int8_t	add_target;
557			} __packed ads_devs[AMI_MAX_DEVDEPTH];
558		} __packed adl_spans[AMI_MAX_SPANDEPTH];
559	} __packed ada_ldrv[AMI_MAX_LDRIVES];
560	struct {
561		u_int8_t	adp_type;	/* SCSI device type */
562		u_int8_t	adp_ostatus;	/* status during config */
563		u_int8_t	adp_tagdepth;	/* level of tagging */
564		u_int8_t	adp_sneg;	/* sync negotiation */
565		u_int32_t	adp_size;
566	} __packed ada_pdrv[AMI_MAX_PDRIVES];
567} __packed;
568
569struct ami_big_diskarray {
570	u_int8_t	ada_nld;
571	u_int8_t	ada_pad[3];
572#define ald ada_ldrv
573	struct {
574		u_int8_t	adl_spandepth;
575		u_int8_t	adl_raidlvl;
576		u_int8_t	adl_rdahead;
577		u_int8_t	adl_stripesz;
578		u_int8_t	adl_status;
579		u_int8_t	adl_wrpolicy;
580		u_int8_t	adl_directio;
581		u_int8_t	adl_nstripes;
582#define 	asp adl_spans
583		struct {
584			u_int32_t	ads_start;
585			u_int32_t	ads_length;	/* blocks */
586#define 		adv ads_devs
587			struct {
588				u_int8_t	add_channel;
589				u_int8_t	add_target;
590			} __packed ads_devs[AMI_BIG_MAX_DEVDEPTH];
591		} __packed adl_spans[AMI_BIG_MAX_SPANDEPTH];
592	} __packed ada_ldrv[AMI_BIG_MAX_LDRIVES];
593#define apd ada_pdrv
594	struct {
595		u_int8_t	adp_type;	/* SCSI device type */
596		u_int8_t	adp_ostatus;	/* status during config */
597		u_int8_t	adp_tagdepth;	/* level of tagging */
598		u_int8_t	adp_sneg;	/* sync negotiation */
599		u_int32_t	adp_size;
600	} __packed ada_pdrv[AMI_BIG_MAX_PDRIVES];
601} __packed;
602
603struct ami_scsisense {
604	u_int8_t	ase_end;
605	struct {
606		u_int8_t	asd_channel;
607		u_int8_t	asd_target;
608		u_int16_t	asd_errcode;
609		u_int16_t	asd_sense;
610		u_int16_t	asd_addarea1;
611		u_int16_t	asd_addarea2;
612		u_int16_t	asd_cmdspec0;
613		u_int16_t	asd_cmdspec1;
614		u_int16_t	asd_asc_ascq;
615	} __packed ase_dump[5];
616} __packed;
617
618struct ami_escsisense {
619	u_int8_t	ase_end;
620	struct {
621		u_int8_t	asd_channel;
622		u_int8_t	asd_target;
623		u_int16_t	asd_errcode;
624		u_int16_t	asd_sense;
625		u_int16_t	asd_addarea1;
626		u_int16_t	asd_addarea2;
627		u_int16_t	asd_cmdspec0;
628		u_int16_t	asd_cmdspec1;
629		u_int16_t	asd_asc_ascq;
630		u_int16_t	asd_extarea;
631	} __packed ase_dump[5];
632} __packed;
633
634struct ami_cachestats {
635	u_int32_t	acs_total;
636	u_int32_t	acs_hits;
637} __packed;
638
639struct ami_drivehistory {
640	struct {
641		u_int8_t	adh_error;
642#define	AMI_ADHERR_TIMEOUT(e)	((e) & 15)
643#define	AMI_ADHERR_PARITY(e)	(((e) >> 4) & 15)
644		u_int8_t	adh_throttle;
645	} __packed adh_err[3][16];	/* channels * drives */
646	u_int8_t	adh_failidx;
647	struct {
648		u_int8_t	adh_tag;
649#define	AMI_ADHTAG_CH(t)	((t) & 7)
650#define	AMI_ADHTAG_TARG(t)	(((t) >> 3) & 15)
651#define	AMI_ADHTAG_VALID(t)	((t) & 0x80)
652		u_int8_t	reason;
653#define	AMI_ADHERR_MEDIA	1
654#define	AMI_ADHERR_NMEDIA	2
655#define	AMI_ADHERR_CMDTMO	3
656#define	AMI_ADHERR_SELTMO	4
657#define	AMI_ADHERR_HAFAIL	5
658#define	AMI_ADHERR_REASSIGN	6
659#define	AMI_ADHERR_CMDFAIL	7
660#define	AMI_ADHERR_OTHER	8
661
662#define	AMI_FAILHISTORY		10
663	} __packed adh_fail[AMI_FAILHISTORY];
664} __packed;
665
666struct ami_progress {
667	u_int32_t	apr_progress;
668} __packed;
669