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