xref: /openbsd-src/sys/dev/pci/mpiireg.h (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1 /*	$OpenBSD: mpiireg.h,v 1.10 2016/09/14 01:14:54 jmatthew Exp $	*/
2 /*
3  * Copyright (c) 2010 Mike Belopuhov
4  * Copyright (c) 2009 James Giannoules
5  * Copyright (c) 2005 - 2010 David Gwynne <dlg@openbsd.org>
6  * Copyright (c) 2005 - 2010 Marco Peereboom <marco@openbsd.org>
7  *
8  * Permission to use, copy, modify, and distribute this software for any
9  * purpose with or without fee is hereby granted, provided that the above
10  * copyright notice and this permission notice appear in all copies.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19  */
20 
21 #define MPII_DOORBELL			(0x00)
22 /* doorbell read bits */
23 #define MPII_DOORBELL_STATE		(0xf<<28) /* ioc state */
24 #define  MPII_DOORBELL_STATE_RESET	(0x0<<28)
25 #define  MPII_DOORBELL_STATE_READY	(0x1<<28)
26 #define  MPII_DOORBELL_STATE_OPER	(0x2<<28)
27 #define  MPII_DOORBELL_STATE_FAULT	(0x4<<28)
28 #define  MPII_DOORBELL_INUSE		(0x1<<27) /* doorbell used */
29 #define MPII_DOORBELL_WHOINIT		(0x7<<24) /* last to reset ioc */
30 #define  MPII_DOORBELL_WHOINIT_NOONE	(0x0<<24) /* not initialized */
31 #define  MPII_DOORBELL_WHOINIT_SYSBIOS	(0x1<<24) /* system bios */
32 #define  MPII_DOORBELL_WHOINIT_ROMBIOS	(0x2<<24) /* rom bios */
33 #define  MPII_DOORBELL_WHOINIT_PCIPEER	(0x3<<24) /* pci peer */
34 #define  MPII_DOORBELL_WHOINIT_DRIVER	(0x4<<24) /* host driver */
35 #define  MPII_DOORBELL_WHOINIT_MANUFACT	(0x5<<24) /* manufacturing */
36 #define MPII_DOORBELL_FAULT		(0xffff<<0) /* fault code */
37 /* doorbell write bits */
38 #define MPII_DOORBELL_FUNCTION_SHIFT	(24)
39 #define MPII_DOORBELL_FUNCTION_MASK	(0xff << MPII_DOORBELL_FUNCTION_SHIFT)
40 #define MPII_DOORBELL_FUNCTION(x)	\
41     (((x) << MPII_DOORBELL_FUNCTION_SHIFT) & MPII_DOORBELL_FUNCTION_MASK)
42 #define MPII_DOORBELL_DWORDS_SHIFT	16
43 #define MPII_DOORBELL_DWORDS_MASK	(0xff << MPII_DOORBELL_DWORDS_SHIFT)
44 #define MPII_DOORBELL_DWORDS(x)		\
45     (((x) << MPII_DOORBELL_DWORDS_SHIFT) & MPII_DOORBELL_DWORDS_MASK)
46 #define MPII_DOORBELL_DATA_MASK		(0xffff)
47 
48 #define MPII_WRITESEQ			(0x04)
49 #define  MPII_WRITESEQ_KEY_VALUE_MASK	(0x0000000f) /* key value */
50 #define  MPII_WRITESEQ_FLUSH		(0x00)
51 #define  MPII_WRITESEQ_1		(0x0f)
52 #define  MPII_WRITESEQ_2		(0x04)
53 #define  MPII_WRITESEQ_3		(0x0b)
54 #define  MPII_WRITESEQ_4		(0x02)
55 #define  MPII_WRITESEQ_5		(0x07)
56 #define  MPII_WRITESEQ_6		(0x0d)
57 
58 #define MPII_HOSTDIAG			(0x08)
59 #define  MPII_HOSTDIAG_BDS_MASK		(0x00001800) /* boot device select */
60 #define   MPII_HOSTDIAG_BDS_DEFAULT	(0<<11)	/* default address map, flash */
61 #define   MPII_HOSTDIAG_BDS_HCDW	(1<<11)	/* host code and data window */
62 #define  MPII_HOSTDIAG_CLEARFBS		(1<<10) /* clear flash bad sig */
63 #define  MPII_HOSTDIAG_FORCE_HCB_ONBOOT (1<<9)	/* force host controlled boot */
64 #define  MPII_HOSTDIAG_HCB_MODE		(1<<8)	/* host controlled boot mode */
65 #define  MPII_HOSTDIAG_DWRE		(1<<7)	/* diag reg write enabled */
66 #define  MPII_HOSTDIAG_FBS		(1<<6)	/* flash bad sig */
67 #define  MPII_HOSTDIAG_RESET_HIST	(1<<5)	/* reset history */
68 #define  MPII_HOSTDIAG_DIAGWR_EN	(1<<4)	/* diagnostic write enabled */
69 #define  MPII_HOSTDIAG_RESET_ADAPTER	(1<<2)	/* reset adapter */
70 #define  MPII_HOSTDIAG_HOLD_IOC_RESET	(1<<1)	/* hold ioc in reset */
71 #define  MPII_HOSTDIAG_DIAGMEM_EN	(1<<0)	/* diag mem enable */
72 
73 #define MPII_DIAGRWDATA			(0x10)
74 
75 #define MPII_DIAGRWADDRLOW		(0x14)
76 
77 #define MPII_DIAGRWADDRHIGH		(0x18)
78 
79 #define MPII_INTR_STATUS		(0x30)
80 #define  MPII_INTR_STATUS_SYS2IOCDB	(1<<31) /* ioc written to by host */
81 #define  MPII_INTR_STATUS_RESET		(1<<30) /* physical ioc reset */
82 #define  MPII_INTR_STATUS_REPLY		(1<<3)	/* reply message interrupt */
83 #define  MPII_INTR_STATUS_IOC2SYSDB	(1<<0)	/* ioc write to doorbell */
84 
85 #define MPII_INTR_MASK			(0x34)
86 #define  MPII_INTR_MASK_RESET		(1<<30) /* ioc reset intr mask */
87 #define  MPII_INTR_MASK_REPLY		(1<<3)	/* reply message intr mask */
88 #define  MPII_INTR_MASK_DOORBELL	(1<<0)	/* doorbell interrupt mask */
89 
90 #define MPII_DCR_DATA			(0x38)
91 
92 #define MPII_DCR_ADDRESS		(0x3c)
93 
94 #define MPII_REPLY_FREE_HOST_INDEX	(0x48)
95 
96 #define MPII_REPLY_POST_HOST_INDEX	(0x6c)
97 
98 #define MPII_HCB_SIZE			(0x74)
99 
100 #define MPII_HCB_ADDRESS_LOW		(0x78)
101 #define MPII_HCB_ADDRESS_HIGH		(0x7c)
102 
103 #define MPII_REQ_DESCR_POST_LOW		(0xc0)
104 #define MPII_REQ_DESCR_POST_HIGH	(0xc4)
105 
106 /*
107  * Scatter Gather Lists
108  */
109 
110 #define MPII_SGE_FL_LAST		(0x1<<31) /* last element in segment */
111 #define MPII_SGE_FL_EOB			(0x1<<30) /* last element of buffer */
112 #define MPII_SGE_FL_TYPE		(0x3<<28) /* element type */
113  #define MPII_SGE_FL_TYPE_SIMPLE	(0x1<<28) /* simple element */
114  #define MPII_SGE_FL_TYPE_CHAIN		(0x3<<28) /* chain element */
115  #define MPII_SGE_FL_TYPE_XACTCTX	(0x0<<28) /* transaction context */
116 #define MPII_SGE_FL_LOCAL		(0x1<<27) /* local address */
117 #define MPII_SGE_FL_DIR			(0x1<<26) /* direction */
118  #define MPII_SGE_FL_DIR_OUT		(0x1<<26)
119  #define MPII_SGE_FL_DIR_IN		(0x0<<26)
120 #define MPII_SGE_FL_SIZE		(0x1<<25) /* address size */
121  #define MPII_SGE_FL_SIZE_32		(0x0<<25)
122  #define MPII_SGE_FL_SIZE_64		(0x1<<25)
123 #define MPII_SGE_FL_EOL			(0x1<<24) /* end of list */
124 
125 struct mpii_sge {
126 	u_int32_t		sg_hdr;
127 	u_int32_t		sg_addr_lo;
128 	u_int32_t		sg_addr_hi;
129 } __packed __aligned(4);
130 
131 /*
132  * SAS3 (IEEE) Scatter Gather Lists
133  */
134 
135 #define MPII_IEEE_SGE_ADDR_MASK		(0x03)
136 #define MPII_IEEE_SGE_ADDR_SYSTEM	(0x00)
137 #define MPII_IEEE_SGE_ADDR_IOCDDR	(0x01)
138 #define MPII_IEEE_SGE_ADDR_IOCPLB	(0x02)
139 #define MPII_IEEE_SGE_ADDR_IOCPLBNTA	(0x03)
140 #define MPII_IEEE_SGE_END_OF_LIST	(0x40)
141 #define MPII_IEEE_SGE_CHAIN_ELEMENT	(0x80)
142 
143 struct mpii_ieee_sge {
144 	u_int64_t		sg_addr;
145 	u_int32_t		sg_len;
146 	u_int16_t		_reserved;
147 	u_int8_t		sg_next_chain_offset;
148 	u_int8_t		sg_flags;
149 } __packed __aligned(8);
150 
151 struct mpii_fw_tce {
152 	u_int8_t		reserved1;
153 	u_int8_t		context_size;
154 	u_int8_t		details_length;
155 	u_int8_t		flags;
156 
157 	u_int32_t		reserved2;
158 
159 	u_int32_t		image_offset;
160 
161 	u_int32_t		image_size;
162 } __packed __aligned(4);
163 
164 /*
165  * Messages
166  */
167 
168 /* functions */
169 #define MPII_FUNCTION_SCSI_IO_REQUEST			(0x00)
170 #define MPII_FUNCTION_SCSI_TASK_MGMT			(0x01)
171 #define MPII_FUNCTION_IOC_INIT				(0x02)
172 #define MPII_FUNCTION_IOC_FACTS				(0x03)
173 #define MPII_FUNCTION_CONFIG				(0x04)
174 #define MPII_FUNCTION_PORT_FACTS			(0x05)
175 #define MPII_FUNCTION_PORT_ENABLE			(0x06)
176 #define MPII_FUNCTION_EVENT_NOTIFICATION		(0x07)
177 #define MPII_FUNCTION_EVENT_ACK				(0x08)
178 #define MPII_FUNCTION_FW_DOWNLOAD			(0x09)
179 #define MPII_FUNCTION_TARGET_CMD_BUFFER_POST		(0x0a)
180 #define MPII_FUNCTION_TARGET_ASSIST			(0x0b)
181 #define MPII_FUNCTION_TARGET_STATUS_SEND		(0x0c)
182 #define MPII_FUNCTION_TARGET_MODE_ABORT			(0x0d)
183 #define MPII_FUNCTION_FW_UPLOAD				(0x12)
184 
185 #define MPII_FUNCTION_RAID_ACTION			(0x15)
186 #define MPII_FUNCTION_RAID_SCSI_IO_PASSTHROUGH		(0x16)
187 
188 #define MPII_FUNCTION_TOOLBOX				(0x17)
189 
190 #define MPII_FUNCTION_SCSI_ENCLOSURE_PROCESSOR		(0x18)
191 
192 #define MPII_FUNCTION_SMP_PASSTHROUGH			(0x1a)
193 #define MPII_FUNCTION_SAS_IO_UNIT_CONTROL		(0x1b)
194 #define MPII_FUNCTION_SATA_PASSTHROUGH			(0x1c)
195 
196 #define MPII_FUNCTION_DIAG_BUFFER_POST			(0x1d)
197 #define MPII_FUNCTION_DIAG_RELEASE			(0x1e)
198 
199 #define MPII_FUNCTION_TARGET_CMD_BUF_BASE_POST		(0x24)
200 #define MPII_FUNCTION_TARGET_CMD_BUF_LIST_POST		(0x25)
201 
202 #define MPII_FUNCTION_IOC_MESSAGE_UNIT_RESET		(0x40)
203 #define MPII_FUNCTION_IO_UNIT_RESET			(0x41)
204 #define MPII_FUNCTION_HANDSHAKE				(0x42)
205 
206 /* Common IOCStatus values for all replies */
207 #define MPII_IOCSTATUS_MASK				(0x7fff)
208 #define  MPII_IOCSTATUS_SUCCESS				(0x0000)
209 #define  MPII_IOCSTATUS_INVALID_FUNCTION		(0x0001)
210 #define  MPII_IOCSTATUS_BUSY				(0x0002)
211 #define  MPII_IOCSTATUS_INVALID_SGL			(0x0003)
212 #define  MPII_IOCSTATUS_INTERNAL_ERROR			(0x0004)
213 #define  MPII_IOCSTATUS_INVALID_VPID			(0x0005)
214 #define  MPII_IOCSTATUS_INSUFFICIENT_RESOURCES		(0x0006)
215 #define  MPII_IOCSTATUS_INVALID_FIELD			(0x0007)
216 #define  MPII_IOCSTATUS_INVALID_STATE			(0x0008)
217 #define  MPII_IOCSTATUS_OP_STATE_NOT_SUPPORTED		(0x0009)
218 /* Config IOCStatus values */
219 #define  MPII_IOCSTATUS_CONFIG_INVALID_ACTION		(0x0020)
220 #define  MPII_IOCSTATUS_CONFIG_INVALID_TYPE		(0x0021)
221 #define  MPII_IOCSTATUS_CONFIG_INVALID_PAGE		(0x0022)
222 #define  MPII_IOCSTATUS_CONFIG_INVALID_DATA		(0x0023)
223 #define  MPII_IOCSTATUS_CONFIG_NO_DEFAULTS		(0x0024)
224 #define  MPII_IOCSTATUS_CONFIG_CANT_COMMIT		(0x0025)
225 /* SCSIIO Reply initiator values */
226 #define  MPII_IOCSTATUS_SCSI_RECOVERED_ERROR		(0x0040)
227 #define  MPII_IOCSTATUS_SCSI_INVALID_DEVHANDLE		(0x0042)
228 #define  MPII_IOCSTATUS_SCSI_DEVICE_NOT_THERE		(0x0043)
229 #define  MPII_IOCSTATUS_SCSI_DATA_OVERRUN		(0x0044)
230 #define  MPII_IOCSTATUS_SCSI_DATA_UNDERRUN		(0x0045)
231 #define  MPII_IOCSTATUS_SCSI_IO_DATA_ERROR		(0x0046)
232 #define  MPII_IOCSTATUS_SCSI_PROTOCOL_ERROR		(0x0047)
233 #define  MPII_IOCSTATUS_SCSI_TASK_TERMINATED		(0x0048)
234 #define  MPII_IOCSTATUS_SCSI_RESIDUAL_MISMATCH		(0x0049)
235 #define  MPII_IOCSTATUS_SCSI_TASK_MGMT_FAILED		(0x004a)
236 #define  MPII_IOCSTATUS_SCSI_IOC_TERMINATED		(0x004b)
237 #define  MPII_IOCSTATUS_SCSI_EXT_TERMINATED		(0x004c)
238 /* For use by SCSI Initiator and SCSI Target end-to-end data protection */
239 #define  MPII_IOCSTATUS_EEDP_GUARD_ERROR		(0x004d)
240 #define  MPII_IOCSTATUS_EEDP_REF_TAG_ERROR		(0x004e)
241 #define  MPII_IOCSTATUS_EEDP_APP_TAG_ERROR		(0x004f)
242 /* SCSI (SPI & FCP) target values */
243 #define  MPII_IOCSTATUS_TARGET_INVALID_IO_INDEX		(0x0062)
244 #define  MPII_IOCSTATUS_TARGET_ABORTED			(0x0063)
245 #define  MPII_IOCSTATUS_TARGET_NO_CONN_RETRYABLE	(0x0064)
246 #define  MPII_IOCSTATUS_TARGET_NO_CONNECTION		(0x0065)
247 #define  MPII_IOCSTATUS_TARGET_XFER_COUNT_MISMATCH	(0x006a)
248 #define  MPII_IOCSTATUS_TARGET_DATA_OFFSET_ERROR	(0x006d)
249 #define  MPII_IOCSTATUS_TARGET_TOO_MUCH_WRITE_DATA	(0x006e)
250 #define  MPII_IOCSTATUS_TARGET_IU_TOO_SHORT		(0x006f)
251 #define  MPII_IOCSTATUS_TARGET_ACK_NAK_TIMEOUT		(0x0070)
252 #define  MPII_IOCSTATUS_TARGET_NAK_RECEIVED		(0x0071)
253 /* Serial Attached SCSI values */
254 #define  MPII_IOCSTATUS_SAS_SMP_REQUEST_FAILED		(0x0090)
255 #define  MPII_IOCSTATUS_SAS_SMP_DATA_OVERRUN		(0x0091)
256 /* Diagnostic Tools values */
257 #define  MPII_IOCSTATUS_DIAGNOSTIC_RELEASED		(0x00a0)
258 
259 #define MPII_REP_IOCLOGINFO_TYPE			(0xf<<28)
260 #define MPII_REP_IOCLOGINFO_TYPE_NONE			(0x0<<28)
261 #define MPII_REP_IOCLOGINFO_TYPE_SCSI			(0x1<<28)
262 #define MPII_REP_IOCLOGINFO_TYPE_FC			(0x2<<28)
263 #define MPII_REP_IOCLOGINFO_TYPE_SAS			(0x3<<28)
264 #define MPII_REP_IOCLOGINFO_TYPE_ISCSI			(0x4<<28)
265 #define MPII_REP_IOCLOGINFO_DATA			(0x0fffffff)
266 
267 /* event notification types */
268 #define MPII_EVENT_NONE					(0x00)
269 #define MPII_EVENT_LOG_DATA				(0x01)
270 #define MPII_EVENT_STATE_CHANGE				(0x02)
271 #define MPII_EVENT_HARD_RESET_RECEIVED			(0x05)
272 #define MPII_EVENT_EVENT_CHANGE				(0x0a)
273 #define MPII_EVENT_TASK_SET_FULL			(0x0e)
274 #define MPII_EVENT_SAS_DEVICE_STATUS_CHANGE		(0x0f)
275 #define MPII_EVENT_IR_OPERATION_STATUS			(0x14)
276 #define MPII_EVENT_SAS_DISCOVERY			(0x16)
277 #define MPII_EVENT_SAS_BROADCAST_PRIMITIVE		(0x17)
278 #define MPII_EVENT_SAS_INIT_DEVICE_STATUS_CHANGE	(0x18)
279 #define MPII_EVENT_SAS_INIT_TABLE_OVERFLOW		(0x19)
280 #define MPII_EVENT_SAS_TOPOLOGY_CHANGE_LIST		(0x1c)
281 #define MPII_EVENT_SAS_ENCL_DEVICE_STATUS_CHANGE	(0x1d)
282 #define MPII_EVENT_IR_VOLUME				(0x1e)
283 #define MPII_EVENT_IR_PHYSICAL_DISK			(0x1f)
284 #define MPII_EVENT_IR_CONFIGURATION_CHANGE_LIST		(0x20)
285 #define MPII_EVENT_LOG_ENTRY_ADDED			(0x21)
286 
287 /* messages */
288 
289 #define MPII_WHOINIT_NOONE				(0x00)
290 #define MPII_WHOINIT_SYSTEM_BIOS			(0x01)
291 #define MPII_WHOINIT_ROM_BIOS				(0x02)
292 #define MPII_WHOINIT_PCI_PEER				(0x03)
293 #define MPII_WHOINIT_HOST_DRIVER			(0x04)
294 #define MPII_WHOINIT_MANUFACTURER			(0x05)
295 
296 /* default messages */
297 
298 struct mpii_msg_request {
299 	u_int8_t		reserved1;
300 	u_int8_t		reserved2;
301 	u_int8_t		chain_offset;
302 	u_int8_t		function;
303 
304 	u_int8_t		reserved3;
305 	u_int8_t		reserved4;
306 	u_int8_t		reserved5;
307 	u_int8_t		msg_flags;
308 
309 	u_int8_t		vp_id;
310 	u_int8_t		vf_id;
311 	u_int16_t		reserved6;
312 } __packed __aligned(4);
313 
314 struct mpii_msg_reply {
315 	u_int16_t		reserved1;
316 	u_int8_t		msg_length;
317 	u_int8_t		function;
318 
319 	u_int16_t		reserved2;
320 	u_int8_t		reserved3;
321 	u_int8_t		msg_flags;
322 
323 	u_int8_t		vp_id;
324 	u_int8_t		vf_if;
325 	u_int16_t		reserved4;
326 
327 	u_int16_t		reserved5;
328 	u_int16_t		ioc_status;
329 
330 	u_int32_t		ioc_loginfo;
331 } __packed __aligned(4);
332 
333 /* ioc init */
334 
335 struct mpii_msg_iocinit_request {
336 	u_int8_t		whoinit;
337 	u_int8_t		reserved1;
338 	u_int8_t		chain_offset;
339 	u_int8_t		function;
340 
341 	u_int16_t		reserved2;
342 	u_int8_t		reserved3;
343 	u_int8_t		msg_flags;
344 
345 	u_int8_t		vp_id;
346 	u_int8_t		vf_id;
347 	u_int16_t		reserved4;
348 
349 	u_int8_t		msg_version_min;
350 	u_int8_t		msg_version_maj;
351 	u_int8_t		hdr_version_unit;
352 	u_int8_t		hdr_version_dev;
353 
354 	u_int32_t		reserved5;
355 
356 	u_int32_t		reserved6;
357 
358 	u_int16_t		reserved7;
359 	u_int16_t		system_request_frame_size;
360 
361 	u_int16_t		reply_descriptor_post_queue_depth;
362 	u_int16_t		reply_free_queue_depth;
363 
364 	u_int32_t		sense_buffer_address_high;
365 
366 	u_int32_t		system_reply_address_high;
367 
368 	u_int32_t		system_request_frame_base_address_lo;
369 	u_int32_t		system_request_frame_base_address_hi;
370 
371 	u_int32_t		reply_descriptor_post_queue_address_lo;
372 	u_int32_t		reply_descriptor_post_queue_address_hi;
373 
374 	u_int32_t		reply_free_queue_address_lo;
375 	u_int32_t		reply_free_queue_address_hi;
376 
377 	u_int64_t		timestamp;
378 } __packed __aligned(4);
379 
380 struct mpii_msg_iocinit_reply {
381 	u_int8_t		whoinit;
382 	u_int8_t		reserved1;
383 	u_int8_t		msg_length;
384 	u_int8_t		function;
385 
386 	u_int16_t		reserved2;
387 	u_int8_t		reserved3;
388 	u_int8_t		msg_flags;
389 
390 	u_int8_t		vp_id;
391 	u_int8_t		vf_id;
392 	u_int16_t		reserved4;
393 
394 	u_int16_t		reserved5;
395 	u_int16_t		ioc_status;
396 
397 	u_int32_t		ioc_loginfo;
398 } __packed __aligned(4);
399 
400 struct mpii_msg_iocfacts_request {
401 	u_int16_t		reserved1;
402 	u_int8_t		chain_offset;
403 	u_int8_t		function;
404 
405 	u_int16_t		reserved2;
406 	u_int8_t		reserved3;
407 	u_int8_t		msg_flags;
408 
409 	u_int8_t		vp_id;
410 	u_int8_t		vf_id;
411 	u_int16_t		reserved4;
412 } __packed __aligned(4);
413 
414 struct mpii_msg_iocfacts_reply {
415 	u_int8_t		msg_version_min;
416 	u_int8_t		msg_version_maj;
417 	u_int8_t		msg_length;
418 	u_int8_t		function;
419 
420 	u_int8_t		header_version_dev;
421 	u_int8_t		header_version_unit;
422 	u_int8_t		ioc_number;
423 	u_int8_t		msg_flags;
424 
425 	u_int8_t		vp_id;
426 	u_int8_t		vf_id;
427 	u_int16_t		reserved1;
428 
429 	u_int16_t		ioc_exceptions;
430 #define MPII_IOCFACTS_EXCEPT_CONFIG_CHECKSUM_FAIL	(1<<0)
431 #define MPII_IOCFACTS_EXCEPT_RAID_CONFIG_INVALID	(1<<1)
432 #define MPII_IOCFACTS_EXCEPT_FW_CHECKSUM_FAIL		(1<<2)
433 #define MPII_IOCFACTS_EXCEPT_MANUFACT_CHECKSUM_FAIL	(1<<3)
434 #define MPII_IOCFACTS_EXCEPT_METADATA_UNSUPPORTED	(1<<4)
435 #define MPII_IOCFACTS_EXCEPT_IR_FOREIGN_CONFIG_MAC	(1<<8)
436 	/* XXX JPG BOOT_STATUS in bits[7:5] */
437 	/* XXX JPG all these #defines need to be fixed up */
438 	u_int16_t		ioc_status;
439 
440 	u_int32_t		ioc_loginfo;
441 
442 	u_int8_t		max_chain_depth;
443 	u_int8_t		whoinit;
444 	u_int8_t		number_of_ports;
445 	u_int8_t		reserved2;
446 
447 	u_int16_t		request_credit;
448 	u_int16_t		product_id;
449 
450 	u_int32_t		ioc_capabilities;
451 #define MPII_IOCFACTS_CAPABILITY_EVENT_REPLAY           (1<<13)
452 #define MPII_IOCFACTS_CAPABILITY_INTEGRATED_RAID        (1<<12)
453 #define MPII_IOCFACTS_CAPABILITY_TLR                    (1<<11)
454 #define MPII_IOCFACTS_CAPABILITY_MULTICAST              (1<<8)
455 #define MPII_IOCFACTS_CAPABILITY_BIDIRECTIONAL_TARGET   (1<<7)
456 #define MPII_IOCFACTS_CAPABILITY_EEDP                   (1<<6)
457 #define MPII_IOCFACTS_CAPABILITY_SNAPSHOT_BUFFER        (1<<4)
458 #define MPII_IOCFACTS_CAPABILITY_DIAG_TRACE_BUFFER      (1<<3)
459 #define MPII_IOCFACTS_CAPABILITY_TASK_SET_FULL_HANDLING (1<<2)
460 
461 	u_int8_t		fw_version_dev;
462 	u_int8_t		fw_version_unit;
463 	u_int8_t		fw_version_min;
464 	u_int8_t		fw_version_maj;
465 
466 	u_int16_t		ioc_request_frame_size;
467 	u_int16_t		reserved3;
468 
469 	u_int16_t		max_initiators;
470 	u_int16_t		max_targets;
471 
472 	u_int16_t		max_sas_expanders;
473 	u_int16_t		max_enclosures;
474 
475 	u_int16_t		protocol_flags;
476 	u_int16_t		high_priority_credit;
477 
478 	u_int16_t		max_reply_descriptor_post_queue_depth;
479 	u_int8_t		reply_frame_size;
480 	u_int8_t		max_volumes;
481 
482 	u_int16_t		max_dev_handle;
483 	u_int16_t		max_persistent_entries;
484 
485 	u_int32_t		reserved4;
486 } __packed __aligned(4);
487 
488 struct mpii_msg_portfacts_request {
489 	u_int16_t		reserved1;
490 	u_int8_t		chain_offset;
491 	u_int8_t		function;
492 
493 	u_int16_t		reserved2;
494 	u_int8_t		port_number;
495 	u_int8_t		msg_flags;
496 
497 	u_int8_t		vp_id;
498 	u_int8_t		vf_id;
499 	u_int16_t		reserved3;
500 } __packed __aligned(4);
501 
502 struct mpii_msg_portfacts_reply {
503 	u_int16_t		reserved1;
504 	u_int8_t		msg_length;
505 	u_int8_t		function;
506 
507 	u_int16_t		reserved2;
508 	u_int8_t		port_number;
509 	u_int8_t		msg_flags;
510 
511 	u_int8_t		vp_id;
512 	u_int8_t		vf_id;
513 	u_int16_t		reserved3;
514 
515 	u_int16_t		reserved4;
516 	u_int16_t		ioc_status;
517 
518 	u_int32_t		ioc_loginfo;
519 
520 	u_int8_t		reserved5;
521 	u_int8_t		port_type;
522 #define MPII_PORTFACTS_PORTTYPE_INACTIVE		(0x00)
523 #define MPII_PORTFACTS_PORTTYPE_FC			(0x10)
524 #define MPII_PORTFACTS_PORTTYPE_ISCSI			(0x20)
525 #define MPII_PORTFACTS_PORTTYPE_SAS_PHYSICAL		(0x30)
526 #define MPII_PORTFACTS_PORTTYPE_SAS_VIRTUAL		(0x31)
527 	u_int16_t		reserved6;
528 
529 	u_int16_t		max_posted_cmd_buffers;
530 	u_int16_t		reserved7;
531 } __packed __aligned(4);
532 
533 struct mpii_msg_portenable_request {
534 	u_int16_t		reserved1;
535 	u_int8_t		chain_offset;
536 	u_int8_t		function;
537 
538 	u_int8_t		reserved2;
539 	u_int8_t		port_flags;
540 	u_int8_t		reserved3;
541 	u_int8_t		msg_flags;
542 
543 	u_int8_t		vp_id;
544 	u_int8_t		vf_id;
545 	u_int16_t		reserved4;
546 } __packed __aligned(4);
547 
548 struct mpii_msg_portenable_reply {
549 	u_int16_t		reserved1;
550 	u_int8_t		msg_length;
551 	u_int8_t		function;
552 
553 	u_int8_t		reserved2;
554 	u_int8_t		port_flags;
555 	u_int8_t		reserved3;
556 	u_int8_t		msg_flags;
557 
558 	u_int8_t		vp_id;
559 	u_int8_t		vf_id;
560 	u_int16_t		reserved4;
561 
562 	u_int16_t		reserved5;
563 	u_int16_t		ioc_status;
564 
565 	u_int32_t		ioc_loginfo;
566 } __packed __aligned(4);
567 
568 struct mpii_msg_event_request {
569 	u_int16_t		reserved1;
570 	u_int8_t		chain_offset;
571 	u_int8_t		function;
572 
573 	u_int16_t		reserved2;
574 	u_int8_t		reserved3;
575 	u_int8_t		msg_flags;
576 
577 	u_int8_t		vp_id;
578 	u_int8_t		vf_id;
579 	u_int16_t		reserved4;
580 
581 	u_int32_t		reserved5;
582 
583 	u_int32_t		reserved6;
584 
585 	u_int32_t		event_masks[4];
586 
587 	u_int16_t		sas_broadcase_primitive_masks;
588 	u_int16_t		reserved7;
589 
590 	u_int32_t		reserved8;
591 } __packed __aligned(4);
592 
593 struct mpii_msg_event_reply {
594 	u_int16_t		event_data_length;
595 	u_int8_t		msg_length;
596 	u_int8_t		function;
597 
598 	u_int16_t		reserved1;
599 	u_int8_t		ack_required;
600 #define MPII_EVENT_ACK_REQUIRED				(0x01)
601 	u_int8_t		msg_flags;
602 #define MPII_EVENT_FLAGS_REPLY_KEPT			(1<<7)
603 
604 	u_int8_t		vp_id;
605 	u_int8_t		vf_id;
606 	u_int16_t		reserved2;
607 
608 	u_int16_t		reserved3;
609 	u_int16_t		ioc_status;
610 
611 	u_int32_t		ioc_loginfo;
612 
613 	u_int16_t		event;
614 	u_int16_t		reserved4;
615 
616 	u_int32_t		event_context;
617 
618 	/* event data follows */
619 } __packed __aligned(4);
620 
621 struct mpii_msg_eventack_request {
622 	u_int16_t		reserved1;
623 	u_int8_t		chain_offset;
624 	u_int8_t		function;
625 
626 	u_int8_t		reserved2[3];
627 	u_int8_t		msg_flags;
628 
629 	u_int8_t		vp_id;
630 	u_int8_t		vf_id;
631 	u_int16_t		reserved3;
632 
633 	u_int16_t		event;
634 	u_int16_t		reserved4;
635 
636 	u_int32_t		event_context;
637 } __packed __aligned(4);
638 
639 struct mpii_msg_eventack_reply {
640 	u_int16_t		reserved1;
641 	u_int8_t		msg_length;
642 	u_int8_t		function;
643 
644 	u_int8_t		reserved2[3];
645 	u_int8_t		msg_flags;
646 
647 	u_int8_t		vp_id;
648 	u_int8_t		vf_id;
649 	u_int16_t		reserved3;
650 
651 	u_int16_t		reserved4;
652 	u_int16_t		ioc_status;
653 
654 	u_int32_t		ioc_loginfo;
655 } __packed __aligned(4);
656 
657 struct mpii_msg_fwupload_request {
658 	u_int8_t		image_type;
659 #define MPII_FWUPLOAD_IMAGETYPE_IOC_FW			(0x00)
660 #define MPII_FWUPLOAD_IMAGETYPE_NV_FW			(0x01)
661 #define MPII_FWUPLOAD_IMAGETYPE_NV_BACKUP		(0x05)
662 #define MPII_FWUPLOAD_IMAGETYPE_NV_MANUFACTURING	(0x06)
663 #define MPII_FWUPLOAD_IMAGETYPE_NV_CONFIG_1		(0x07)
664 #define MPII_FWUPLOAD_IMAGETYPE_NV_CONFIG_2		(0x08)
665 #define MPII_FWUPLOAD_IMAGETYPE_NV_MEGARAID		(0x09)
666 #define MPII_FWUPLOAD_IMAGETYPE_NV_COMPLETE		(0x0a)
667 #define MPII_FWUPLOAD_IMAGETYPE_COMMON_BOOT_BLOCK	(0x0b)
668 	u_int8_t		reserved1;
669 	u_int8_t		chain_offset;
670 	u_int8_t		function;
671 
672 	u_int8_t		reserved2[3];
673 	u_int8_t		msg_flags;
674 
675 	u_int8_t		vp_id;
676 	u_int8_t		vf_id;
677 	u_int16_t		reserved3;
678 
679 	u_int32_t		reserved4;
680 
681 	u_int32_t		reserved5;
682 
683 	struct mpii_fw_tce	tce;
684 
685 	/* followed by an sgl */
686 } __packed __aligned(4);
687 
688 struct mpii_msg_fwupload_reply {
689 	u_int8_t		image_type;
690 	u_int8_t		reserved1;
691 	u_int8_t		msg_length;
692 	u_int8_t		function;
693 
694 	u_int8_t		reserved2[3];
695 	u_int8_t		msg_flags;
696 
697 	u_int8_t		vp_id;
698 	u_int8_t		vf_id;
699 	u_int16_t		reserved3;
700 
701 	u_int16_t		reserved4;
702 	u_int16_t		ioc_status;
703 
704 	u_int32_t		ioc_loginfo;
705 
706 	u_int32_t		actual_image_size;
707 } __packed __aligned(4);
708 
709 struct mpii_msg_scsi_io {
710 	u_int16_t		dev_handle;
711 	u_int8_t		chain_offset;
712 	u_int8_t		function;
713 
714 	u_int16_t		reserved1;
715 	u_int8_t		reserved2;
716 	u_int8_t		msg_flags;
717 
718 	u_int8_t		vp_id;
719 	u_int8_t		vf_id;
720 	u_int16_t		reserved3;
721 
722 	u_int32_t		sense_buffer_low_address;
723 
724 	u_int16_t		sgl_flags;
725 	u_int8_t		sense_buffer_length;
726 	u_int8_t		reserved4;
727 
728 	u_int8_t		sgl_offset0;
729 	u_int8_t		sgl_offset1;
730 	u_int8_t		sgl_offset2;
731 	u_int8_t		sgl_offset3;
732 
733 	u_int32_t		skip_count;
734 
735 	u_int32_t		data_length;
736 
737 	u_int32_t		bidirectional_data_length;
738 
739 	u_int16_t		io_flags;
740 	u_int16_t		eedp_flags;
741 
742 	u_int32_t		eedp_block_size;
743 
744 	u_int32_t		secondary_reference_tag;
745 
746 	u_int16_t		secondary_application_tag;
747 	u_int16_t		application_tag_translation_mask;
748 
749 	u_int16_t		lun[4];
750 
751 /* the following 16 bits are defined in MPI2 as the control field */
752 	u_int8_t		reserved5;
753 	u_int8_t		tagging;
754 #define MPII_SCSIIO_ATTR_SIMPLE_Q			(0x0)
755 #define MPII_SCSIIO_ATTR_HEAD_OF_Q			(0x1)
756 #define MPII_SCSIIO_ATTR_ORDERED_Q			(0x2)
757 #define MPII_SCSIIO_ATTR_ACA_Q				(0x4)
758 #define MPII_SCSIIO_ATTR_UNTAGGED			(0x5)
759 #define MPII_SCSIIO_ATTR_NO_DISCONNECT			(0x7)
760 	u_int8_t		reserved6;
761 	u_int8_t		direction;
762 #define MPII_SCSIIO_DIR_NONE				(0x0)
763 #define MPII_SCSIIO_DIR_WRITE				(0x1)
764 #define MPII_SCSIIO_DIR_READ				(0x2)
765 
766 #define	MPII_CDB_LEN					(32)
767 	u_int8_t		cdb[MPII_CDB_LEN];
768 
769 	/* followed by an sgl */
770 } __packed __aligned(4);
771 
772 struct mpii_msg_scsi_io_error {
773 	u_int16_t		dev_handle;
774 	u_int8_t		msg_length;
775 	u_int8_t		function;
776 
777 	u_int16_t		reserved1;
778 	u_int8_t		reserved2;
779 	u_int8_t		msg_flags;
780 
781 	u_int8_t		vp_id;
782 	u_int8_t		vf_id;
783 	u_int16_t		reserved3;
784 
785 	u_int8_t		scsi_status;
786 	/* XXX JPG validate this */
787 #if notyet
788 #define MPII_SCSIIO_ERR_STATUS_SUCCESS
789 #define MPII_SCSIIO_ERR_STATUS_CHECK_COND
790 #define MPII_SCSIIO_ERR_STATUS_BUSY
791 #define MPII_SCSIIO_ERR_STATUS_INTERMEDIATE
792 #define MPII_SCSIIO_ERR_STATUS_INTERMEDIATE_CONDMET
793 #define MPII_SCSIIO_ERR_STATUS_RESERVATION_CONFLICT
794 #define MPII_SCSIIO_ERR_STATUS_CMD_TERM
795 #define MPII_SCSIIO_ERR_STATUS_TASK_SET_FULL
796 #define MPII_SCSIIO_ERR_STATUS_ACA_ACTIVE
797 #endif
798 	u_int8_t		scsi_state;
799 #define MPII_SCSIIO_ERR_STATE_AUTOSENSE_VALID		(1<<0)
800 #define MPII_SCSIIO_ERR_STATE_AUTOSENSE_FAILED		(1<<1)
801 #define MPII_SCSIIO_ERR_STATE_NO_SCSI_STATUS		(1<<2)
802 #define MPII_SCSIIO_ERR_STATE_TERMINATED		(1<<3)
803 #define MPII_SCSIIO_ERR_STATE_RESPONSE_INFO_VALID	(1<<4)
804 #define MPII_SCSIIO_ERR_STATE_QUEUE_TAG_REJECTED	(0xffff)
805 	u_int16_t		ioc_status;
806 
807 	u_int32_t		ioc_loginfo;
808 
809 	u_int32_t		transfer_count;
810 
811 	u_int32_t		sense_count;
812 
813 	u_int32_t		response_info;
814 
815 	u_int16_t		task_tag;
816 	u_int16_t		reserved4;
817 
818 	u_int32_t		bidirectional_transfer_count;
819 
820 	u_int32_t		reserved5;
821 
822 	u_int32_t		reserved6;
823 } __packed __aligned(4);
824 
825 struct mpii_request_descr {
826 	u_int8_t		request_flags;
827 #define MPII_REQ_DESCR_TYPE_MASK			(0x0e)
828 #define MPII_REQ_DESCR_SCSI_IO				(0x00)
829 #define MPII_REQ_DESCR_SCSI_TARGET			(0x02)
830 #define MPII_REQ_DESCR_HIGH_PRIORITY			(0x06)
831 #define MPII_REQ_DESCR_DEFAULT				(0x08)
832 	u_int8_t		vf_id;
833 	u_int16_t		smid;
834 
835 	u_int16_t		lmid;
836 	u_int16_t		dev_handle;
837 } __packed __aligned(8);
838 
839 struct mpii_reply_descr {
840 	u_int8_t		reply_flags;
841 #define MPII_REPLY_DESCR_TYPE_MASK			(0x0f)
842 #define MPII_REPLY_DESCR_SCSI_IO_SUCCESS		(0x00)
843 #define MPII_REPLY_DESCR_ADDRESS_REPLY			(0x01)
844 #define MPII_REPLY_DESCR_TARGET_ASSIST_SUCCESS		(0x02)
845 #define MPII_REPLY_DESCR_TARGET_COMMAND_BUFFER		(0x03)
846 #define MPII_REPLY_DESCR_UNUSED				(0x0f)
847 	u_int8_t		vf_id;
848 	u_int16_t		smid;
849 
850 	union {
851 		u_int32_t	data;
852 		u_int32_t	frame_addr;	/* Address Reply */
853 	};
854 } __packed __aligned(8);
855 
856 struct mpii_request_header {
857 	u_int16_t		function_dependent1;
858 	u_int8_t		chain_offset;
859 	u_int8_t		function;
860 
861 	u_int16_t		function_dependent2;
862 	u_int8_t		function_dependent3;
863 	u_int8_t		message_flags;
864 
865 	u_int8_t		vp_id;
866 	u_int8_t		vf_id;
867 	u_int16_t		reserved;
868 } __packed __aligned(4);
869 
870 struct mpii_msg_scsi_task_request {
871 	u_int16_t		dev_handle;
872 	u_int8_t		chain_offset;
873 	u_int8_t		function;
874 
875 	u_int8_t		reserved1;
876 	u_int8_t		task_type;
877 #define MPII_SCSI_TASK_ABORT_TASK			(0x01)
878 #define MPII_SCSI_TASK_ABRT_TASK_SET			(0x02)
879 #define MPII_SCSI_TASK_TARGET_RESET			(0x03)
880 #define MPII_SCSI_TASK_RESET_BUS			(0x04)
881 #define MPII_SCSI_TASK_LOGICAL_UNIT_RESET		(0x05)
882 	u_int8_t		reserved2;
883 	u_int8_t		msg_flags;
884 
885 	u_int8_t		vp_id;
886 	u_int8_t		vf_id;
887 	u_int16_t		reserved3;
888 
889 	u_int16_t		lun[4];
890 
891 	u_int32_t		reserved4[7];
892 
893 	u_int16_t		task_mid;
894 	u_int16_t		reserved5;
895 } __packed __aligned(4);
896 
897 struct mpii_msg_scsi_task_reply {
898 	u_int16_t		dev_handle;
899 	u_int8_t		msg_length;
900 	u_int8_t		function;
901 
902 	u_int8_t		response_code;
903 	u_int8_t		task_type;
904 	u_int8_t		reserved1;
905 	u_int8_t		msg_flags;
906 
907 	u_int8_t		vp_id;
908 	u_int8_t		vf_id;
909 	u_int16_t		reserved2;
910 
911 	u_int16_t		reserved3;
912 	u_int16_t		ioc_status;
913 
914 	u_int32_t		ioc_loginfo;
915 
916 	u_int32_t		termination_count;
917 } __packed __aligned(4);
918 
919 struct mpii_msg_sas_oper_request {
920 	u_int8_t		operation;
921 #define MPII_SAS_OP_CLEAR_PERSISTENT		(0x02)
922 #define MPII_SAS_OP_PHY_LINK_RESET		(0x06)
923 #define MPII_SAS_OP_PHY_HARD_RESET		(0x07)
924 #define MPII_SAS_OP_PHY_CLEAR_ERROR_LOG		(0x08)
925 #define MPII_SAS_OP_SEND_PRIMITIVE		(0x0a)
926 #define MPII_SAS_OP_FORCE_FULL_DISCOVERY	(0x0b)
927 #define MPII_SAS_OP_TRANSMIT_PORT_SELECT	(0x0c)
928 #define MPII_SAS_OP_REMOVE_DEVICE		(0x0d)
929 #define MPII_SAS_OP_LOOKUP_MAPPING		(0x0e)
930 #define MPII_SAS_OP_SET_IOC_PARAM		(0x0f)
931 	u_int8_t		reserved1;
932 	u_int8_t		chain_offset;
933 	u_int8_t		function;
934 
935 	u_int16_t		dev_handle;
936 	u_int8_t		ioc_param;
937 	u_int8_t		msg_flags;
938 
939 	u_int8_t		vp_id;
940 	u_int8_t		vf_id;
941 	u_int16_t		reserved2;
942 
943 	u_int16_t		reserved3;
944 	u_int8_t		phy_num;
945 	u_int8_t		prim_flags;
946 
947 	u_int32_t		primitive;
948 
949 	u_int8_t		lookup_method;
950 #define MPII_SAS_LOOKUP_METHOD_SAS_ADDR		(0x01)
951 #define MPII_SAS_LOOKUP_METHOD_SAS_ENCL		(0x02)
952 #define MPII_SAS_LOOKUP_METHOD_SAS_DEVNAME	(0x03)
953 	u_int8_t		reserved4;
954 	u_int16_t		slot_num;
955 
956 	u_int64_t		lookup_addr;
957 
958 	u_int32_t		ioc_param_value;
959 
960 	u_int64_t		reserved5;
961 } __packed __aligned(4);
962 
963 struct mpii_msg_sas_oper_reply {
964 	u_int8_t		operation;
965 	u_int8_t		reserved1;
966 	u_int8_t		chain_offset;
967 	u_int8_t		function;
968 
969 	u_int16_t		dev_handle;
970 	u_int8_t		ioc_param;
971 	u_int8_t		msg_flags;
972 
973 	u_int8_t		vp_id;
974 	u_int8_t		vf_id;
975 	u_int16_t		reserved2;
976 
977 	u_int16_t		reserved3;
978 	u_int16_t		ioc_status;
979 
980 	u_int32_t		ioc_loginfo;
981 } __packed __aligned(4);
982 
983 struct mpii_msg_raid_action_request {
984 	u_int8_t	action;
985 #define MPII_RAID_ACTION_CHANGE_VOL_WRITE_CACHE	(0x17)
986 	u_int8_t	reserved1;
987 	u_int8_t	chain_offset;
988 	u_int8_t	function;
989 
990 	u_int16_t	vol_dev_handle;
991 	u_int8_t	phys_disk_num;
992 	u_int8_t	msg_flags;
993 
994 	u_int8_t	vp_id;
995 	u_int8_t	vf_if;
996 	u_int16_t	reserved2;
997 
998 	u_int32_t	reserved3;
999 
1000 	u_int32_t	action_data;
1001 #define MPII_RAID_VOL_WRITE_CACHE_MASK			(0x03)
1002 #define MPII_RAID_VOL_WRITE_CACHE_DISABLE		(0x01)
1003 #define MPII_RAID_VOL_WRITE_CACHE_ENABLE		(0x02)
1004 
1005 	struct mpii_sge	action_sge;
1006 } __packed __aligned(4);
1007 
1008 struct mpii_msg_raid_action_reply {
1009 	u_int8_t	action;
1010 	u_int8_t	reserved1;
1011 	u_int8_t	chain_offset;
1012 	u_int8_t	function;
1013 
1014 	u_int16_t	vol_dev_handle;
1015 	u_int8_t	phys_disk_num;
1016 	u_int8_t	msg_flags;
1017 
1018 	u_int8_t	vp_id;
1019 	u_int8_t	vf_if;
1020 	u_int16_t	reserved2;
1021 
1022 	u_int16_t	reserved3;
1023 	u_int16_t	ioc_status;
1024 
1025 	u_int32_t	action_data[5];
1026 } __packed __aligned(4);
1027 
1028 struct mpii_cfg_hdr {
1029 	u_int8_t		page_version;
1030 	u_int8_t		page_length;
1031 	u_int8_t		page_number;
1032 	u_int8_t		page_type;
1033 #define MPII_CONFIG_REQ_PAGE_TYPE_ATTRIBUTE		(0xf0)
1034 #define MPI2_CONFIG_PAGEATTR_READ_ONLY			(0x00)
1035 #define MPI2_CONFIG_PAGEATTR_CHANGEABLE			(0x10)
1036 #define MPI2_CONFIG_PAGEATTR_PERSISTENT			(0x20)
1037 
1038 #define MPII_CONFIG_REQ_PAGE_TYPE_MASK			(0x0f)
1039 #define MPII_CONFIG_REQ_PAGE_TYPE_IO_UNIT		(0x00)
1040 #define MPII_CONFIG_REQ_PAGE_TYPE_IOC			(0x01)
1041 #define MPII_CONFIG_REQ_PAGE_TYPE_BIOS			(0x02)
1042 #define MPII_CONFIG_REQ_PAGE_TYPE_RAID_VOL		(0x08)
1043 #define MPII_CONFIG_REQ_PAGE_TYPE_MANUFACTURING		(0x09)
1044 #define MPII_CONFIG_REQ_PAGE_TYPE_RAID_PD		(0x0a)
1045 #define MPII_CONFIG_REQ_PAGE_TYPE_EXTENDED		(0x0f)
1046 } __packed __aligned(4);
1047 
1048 struct mpii_ecfg_hdr {
1049 	u_int8_t		page_version;
1050 	u_int8_t		reserved1;
1051 	u_int8_t		page_number;
1052 	u_int8_t		page_type;
1053 
1054 	u_int16_t		ext_page_length;
1055 	u_int8_t		ext_page_type;
1056 #define MPII_CONFIG_REQ_PAGE_TYPE_SAS_DEVICE		(0x12)
1057 #define MPII_CONFIG_REQ_PAGE_TYPE_RAID_CONFIG		(0x16)
1058 #define MPII_CONFIG_REQ_PAGE_TYPE_DRIVER_MAPPING	(0x17)
1059 	u_int8_t		reserved2;
1060 } __packed __aligned(4);
1061 
1062 struct mpii_msg_config_request {
1063 	u_int8_t		action;
1064 #define MPII_CONFIG_REQ_ACTION_PAGE_HEADER		(0x00)
1065 #define MPII_CONFIG_REQ_ACTION_PAGE_READ_CURRENT	(0x01)
1066 #define MPII_CONFIG_REQ_ACTION_PAGE_WRITE_CURRENT	(0x02)
1067 #define MPII_CONFIG_REQ_ACTION_PAGE_DEFAULT		(0x03)
1068 #define MPII_CONFIG_REQ_ACTION_PAGE_WRITE_NVRAM		(0x04)
1069 #define MPII_CONFIG_REQ_ACTION_PAGE_READ_DEFAULT	(0x05)
1070 #define MPII_CONFIG_REQ_ACTION_PAGE_READ_NVRAM		(0x06)
1071 	u_int8_t		sgl_flags;
1072 	u_int8_t		chain_offset;
1073 	u_int8_t		function;
1074 
1075 	u_int16_t		ext_page_len;
1076 	u_int8_t		ext_page_type;
1077 #define MPII_CONFIG_REQ_EXTPAGE_TYPE_SAS_IO_UNIT	(0x10)
1078 #define MPII_CONFIG_REQ_EXTPAGE_TYPE_SAS_EXPANDER	(0x11)
1079 #define MPII_CONFIG_REQ_EXTPAGE_TYPE_SAS_DEVICE		(0x12)
1080 #define MPII_CONFIG_REQ_EXTPAGE_TYPE_SAS_PHY		(0x13)
1081 #define MPII_CONFIG_REQ_EXTPAGE_TYPE_LOG		(0x14)
1082 #define MPI2_CONFIG_EXTPAGETYPE_ENCLOSURE		(0x15)
1083 #define MPI2_CONFIG_EXTPAGETYPE_RAID_CONFIG		(0x16)
1084 #define MPI2_CONFIG_EXTPAGETYPE_DRIVER_MAPPING		(0x17)
1085 #define MPI2_CONFIG_EXTPAGETYPE_SAS_PORT		(0x18)
1086 	u_int8_t		msg_flags;
1087 
1088 	u_int8_t		vp_id;
1089 	u_int8_t		vf_id;
1090 	u_int16_t		reserved1;
1091 
1092 	u_int32_t		reserved2[2];
1093 
1094 	struct mpii_cfg_hdr	config_header;
1095 
1096 	u_int32_t		page_address;
1097 /* XXX lots of defns here */
1098 
1099 	struct mpii_sge		page_buffer;
1100 } __packed __aligned(4);
1101 
1102 struct mpii_msg_config_reply {
1103 	u_int8_t		action;
1104 	u_int8_t		sgl_flags;
1105 	u_int8_t		msg_length;
1106 	u_int8_t		function;
1107 
1108 	u_int16_t		ext_page_length;
1109 	u_int8_t		ext_page_type;
1110 	u_int8_t		msg_flags;
1111 
1112 	u_int8_t		vp_id;
1113 	u_int8_t		vf_id;
1114 	u_int16_t		reserved1;
1115 
1116 	u_int16_t		reserved2;
1117 	u_int16_t		ioc_status;
1118 
1119 	u_int32_t		ioc_loginfo;
1120 
1121 	struct mpii_cfg_hdr	config_header;
1122 } __packed __aligned(4);
1123 
1124 struct mpii_cfg_manufacturing_pg0 {
1125 	struct mpii_cfg_hdr	config_header;
1126 
1127 	char			chip_name[16];
1128 	char			chip_revision[8];
1129 	char			board_name[16];
1130 	char			board_assembly[16];
1131 	char			board_tracer_number[16];
1132 } __packed __aligned(4);
1133 
1134 struct mpii_cfg_ioc_pg1 {
1135 	struct mpii_cfg_hdr     config_header;
1136 
1137 	u_int32_t       flags;
1138 
1139 	u_int32_t       coalescing_timeout;
1140 #define	MPII_CFG_IOC_1_REPLY_COALESCING			(1<<0)
1141 
1142 	u_int8_t        coalescing_depth;
1143 	u_int8_t        pci_slot_num;
1144 	u_int8_t        pci_bus_num;
1145 	u_int8_t        pci_domain_segment;
1146 
1147 	u_int32_t       reserved1;
1148 
1149 	u_int32_t       reserved2;
1150 } __packed __aligned(4);
1151 
1152 struct mpii_cfg_ioc_pg3 {
1153 	struct mpii_cfg_hdr	config_header;
1154 
1155 	u_int8_t		no_phys_disks;
1156 	u_int8_t		reserved[3];
1157 
1158 	/* followed by a list of mpii_cfg_raid_physdisk structs */
1159 } __packed __aligned(4);
1160 
1161 struct mpii_cfg_ioc_pg8 {
1162 	struct mpii_cfg_hdr	config_header;
1163 
1164 	u_int8_t		num_devs_per_enclosure;
1165 	u_int8_t		reserved1;
1166 	u_int16_t		reserved2;
1167 
1168 	u_int16_t		max_persistent_entries;
1169 	u_int16_t		max_num_physical_mapped_ids;
1170 
1171 	u_int16_t		flags;
1172 #define	MPII_IOC_PG8_FLAGS_DA_START_SLOT_1		(1<<5)
1173 #define MPII_IOC_PG8_FLAGS_RESERVED_TARGETID_0		(1<<4)
1174 #define MPII_IOC_PG8_FLAGS_MAPPING_MODE_MASK		(0x0000000e)
1175 #define MPII_IOC_PG8_FLAGS_DEVICE_PERSISTENCE_MAPPING	(0<<1)
1176 #define MPII_IOC_PG8_FLAGS_ENCLOSURE_SLOT_MAPPING	(1<<1)
1177 #define MPII_IOC_PG8_FLAGS_DISABLE_PERSISTENT_MAPPING	(1<<0)
1178 #define	MPII_IOC_PG8_FLAGS_ENABLE_PERSISTENT_MAPPING	(0<<0)
1179 	u_int16_t		reserved3;
1180 
1181 	u_int16_t		ir_volume_mapping_flags;
1182 #define	MPII_IOC_PG8_IRFLAGS_VOLUME_MAPPING_MODE_MASK	(0x00000003)
1183 #define	MPII_IOC_PG8_IRFLAGS_LOW_VOLUME_MAPPING		(0<<0)
1184 #define	MPII_IOC_PG8_IRFLAGS_HIGH_VOLUME_MAPPING	(1<<0)
1185 	u_int16_t		reserved4;
1186 
1187 	u_int32_t		reserved5;
1188 } __packed __aligned(4);
1189 
1190 struct mpii_cfg_raid_physdisk {
1191 	u_int8_t		phys_disk_id;
1192 	u_int8_t		phys_disk_bus;
1193 	u_int8_t		phys_disk_ioc;
1194 	u_int8_t		phys_disk_num;
1195 } __packed __aligned(4);
1196 
1197 struct mpii_cfg_fc_port_pg0 {
1198 	struct mpii_cfg_hdr	config_header;
1199 
1200 	u_int32_t		flags;
1201 
1202 	u_int8_t		mpii_port_nr;
1203 	u_int8_t		link_type;
1204 	u_int8_t		port_state;
1205 	u_int8_t		reserved1;
1206 
1207 	u_int32_t		port_id;
1208 
1209 	u_int64_t		wwnn;
1210 
1211 	u_int64_t		wwpn;
1212 
1213 	u_int32_t		supported_service_class;
1214 
1215 	u_int32_t		supported_speeds;
1216 
1217 	u_int32_t		current_speed;
1218 
1219 	u_int32_t		max_frame_size;
1220 
1221 	u_int64_t		fabric_wwnn;
1222 
1223 	u_int64_t		fabric_wwpn;
1224 
1225 	u_int32_t		discovered_port_count;
1226 
1227 	u_int32_t		max_initiators;
1228 
1229 	u_int8_t		max_aliases_supported;
1230 	u_int8_t		max_hard_aliases_supported;
1231 	u_int8_t		num_current_aliases;
1232 	u_int8_t		reserved2;
1233 } __packed __aligned(4);
1234 
1235 struct mpii_cfg_fc_port_pg1 {
1236 	struct mpii_cfg_hdr	config_header;
1237 
1238 	u_int32_t		flags;
1239 
1240 	u_int64_t		noseepromwwnn;
1241 
1242 	u_int64_t		noseepromwwpn;
1243 
1244 	u_int8_t		hard_alpa;
1245 	u_int8_t		link_config;
1246 	u_int8_t		topology_config;
1247 	u_int8_t		alt_connector;
1248 
1249 	u_int8_t		num_req_aliases;
1250 	u_int8_t		rr_tov;
1251 	u_int8_t		initiator_dev_to;
1252 	u_int8_t		initiator_lo_pend_to;
1253 } __packed __aligned(4);
1254 
1255 struct mpii_cfg_fc_device_pg0 {
1256 	struct mpii_cfg_hdr	config_header;
1257 
1258 	u_int64_t		wwnn;
1259 
1260 	u_int64_t		wwpn;
1261 
1262 	u_int32_t		port_id;
1263 
1264 	u_int8_t		protocol;
1265 	u_int8_t		flags;
1266 	u_int16_t		bb_credit;
1267 
1268 	u_int16_t		max_rx_frame_size;
1269 	u_int8_t		adisc_hard_alpa;
1270 	u_int8_t		port_nr;
1271 
1272 	u_int8_t		fc_ph_low_version;
1273 	u_int8_t		fc_ph_high_version;
1274 	u_int8_t		current_target_id;
1275 	u_int8_t		current_bus;
1276 } __packed __aligned(4);
1277 
1278 #define MPII_CFG_RAID_VOL_ADDR_HANDLE		(1<<28)
1279 
1280 struct mpii_cfg_raid_vol_pg0 {
1281 	struct mpii_cfg_hdr	config_header;
1282 
1283 	u_int16_t		volume_handle;
1284 	u_int8_t		volume_state;
1285 #define MPII_CFG_RAID_VOL_0_STATE_MISSING		(0x00)
1286 #define MPII_CFG_RAID_VOL_0_STATE_FAILED		(0x01)
1287 #define MPII_CFG_RAID_VOL_0_STATE_INITIALIZING		(0x02)
1288 #define MPII_CFG_RAID_VOL_0_STATE_ONLINE		(0x03)
1289 #define MPII_CFG_RAID_VOL_0_STATE_DEGRADED		(0x04)
1290 #define MPII_CFG_RAID_VOL_0_STATE_OPTIMAL		(0x05)
1291 	u_int8_t		volume_type;
1292 #define MPII_CFG_RAID_VOL_0_TYPE_RAID0			(0x00)
1293 #define MPII_CFG_RAID_VOL_0_TYPE_RAID1E			(0x01)
1294 #define MPII_CFG_RAID_VOL_0_TYPE_RAID1			(0x02)
1295 #define MPII_CFG_RAID_VOL_0_TYPE_RAID10			(0x05)
1296 #define MPII_CFG_RAID_VOL_0_TYPE_UNKNOWN		(0xff)
1297 
1298 	u_int32_t		volume_status;
1299 #define MPII_CFG_RAID_VOL_0_STATUS_SCRUB		(1<<20)
1300 #define MPII_CFG_RAID_VOL_0_STATUS_RESYNC		(1<<16)
1301 
1302 	u_int16_t		volume_settings;
1303 #define MPII_CFG_RAID_VOL_0_SETTINGS_CACHE_MASK		(0x3<<0)
1304 #define MPII_CFG_RAID_VOL_0_SETTINGS_CACHE_UNCHANGED	(0x0<<0)
1305 #define MPII_CFG_RAID_VOL_0_SETTINGS_CACHE_DISABLED	(0x1<<0)
1306 #define MPII_CFG_RAID_VOL_0_SETTINGS_CACHE_ENABLED	(0x2<<0)
1307 
1308 	u_int8_t		hot_spare_pool;
1309 	u_int8_t		reserved1;
1310 
1311 	u_int64_t		max_lba;
1312 
1313 	u_int32_t		stripe_size;
1314 
1315 	u_int16_t		block_size;
1316 	u_int16_t		reserved2;
1317 
1318 	u_int8_t		phys_disk_types;
1319 	u_int8_t		resync_rate;
1320 	u_int16_t		data_scrub_rate;
1321 
1322 	u_int8_t		num_phys_disks;
1323 	u_int16_t		reserved3;
1324 	u_int8_t		inactive_status;
1325 #define MPII_CFG_RAID_VOL_0_INACTIVE_UNKNOWN		(0x00)
1326 #define MPII_CFG_RAID_VOL_0_INACTIVE_STALE_META		(0x01)
1327 #define MPII_CFG_RAID_VOL_0_INACTIVE_FOREIGN_VOL	(0x02)
1328 #define MPII_CFG_RAID_VOL_0_INACTIVE_NO_RESOURCES	(0x03)
1329 #define MPII_CFG_RAID_VOL_0_INACTIVE_CLONED_VOL		(0x04)
1330 #define MPII_CFG_RAID_VOL_0_INACTIVE_INSUF_META		(0x05)
1331 
1332 	/* followed by a list of mpii_cfg_raid_vol_pg0_physdisk structs */
1333 } __packed __aligned(4);
1334 
1335 struct mpii_cfg_raid_vol_pg0_physdisk {
1336 	u_int8_t		raid_set_num;
1337 	u_int8_t		phys_disk_map;
1338 	u_int8_t		phys_disk_num;
1339 	u_int8_t		reserved;
1340 } __packed __aligned(4);
1341 
1342 struct mpii_cfg_raid_vol_pg1 {
1343 	struct mpii_cfg_hdr	config_header;
1344 
1345 	u_int8_t		volume_id;
1346 	u_int8_t		volume_bus;
1347 	u_int8_t		volume_ioc;
1348 	u_int8_t		reserved1;
1349 
1350 	u_int8_t		guid[24];
1351 
1352 	u_int8_t		name[32];
1353 
1354 	u_int64_t		wwid;
1355 
1356 	u_int32_t		reserved2;
1357 
1358 	u_int32_t		reserved3;
1359 } __packed __aligned(4);
1360 
1361 #define MPII_CFG_RAID_PHYS_DISK_ADDR_NUMBER		(1<<28)
1362 
1363 struct mpii_cfg_raid_physdisk_pg0 {
1364 	struct mpii_cfg_hdr	config_header;
1365 
1366 	u_int16_t		dev_handle;
1367 	u_int8_t		reserved1;
1368 	u_int8_t		phys_disk_num;
1369 
1370 	u_int8_t		enc_id;
1371 	u_int8_t		enc_bus;
1372 	u_int8_t		hot_spare_pool;
1373 	u_int8_t		enc_type;
1374 #define MPII_CFG_RAID_PHYDISK_0_ENCTYPE_NONE		(0x0)
1375 #define MPII_CFG_RAID_PHYDISK_0_ENCTYPE_SAFTE		(0x1)
1376 #define MPII_CFG_RAID_PHYDISK_0_ENCTYPE_SES		(0x2)
1377 
1378 	u_int32_t		reserved2;
1379 
1380 	u_int8_t		vendor_id[8];
1381 
1382 	u_int8_t		product_id[16];
1383 
1384 	u_int8_t		product_rev[4];
1385 
1386 	u_int8_t		serial[32];
1387 
1388 	u_int32_t		reserved3;
1389 
1390 	u_int8_t		phys_disk_state;
1391 #define MPII_CFG_RAID_PHYDISK_0_STATE_NOTCONFIGURED	(0x00)
1392 #define MPII_CFG_RAID_PHYDISK_0_STATE_NOTCOMPATIBLE	(0x01)
1393 #define MPII_CFG_RAID_PHYDISK_0_STATE_OFFLINE		(0x02)
1394 #define MPII_CFG_RAID_PHYDISK_0_STATE_ONLINE		(0x03)
1395 #define MPII_CFG_RAID_PHYDISK_0_STATE_HOTSPARE		(0x04)
1396 #define MPII_CFG_RAID_PHYDISK_0_STATE_DEGRADED		(0x05)
1397 #define MPII_CFG_RAID_PHYDISK_0_STATE_REBUILDING	(0x06)
1398 #define MPII_CFG_RAID_PHYDISK_0_STATE_OPTIMAL		(0x07)
1399 	u_int8_t		offline_reason;
1400 #define MPII_CFG_RAID_PHYDISK_0_OFFLINE_MISSING		(0x01)
1401 #define MPII_CFG_RAID_PHYDISK_0_OFFLINE_FAILED		(0x03)
1402 #define MPII_CFG_RAID_PHYDISK_0_OFFLINE_INITIALIZING	(0x04)
1403 #define MPII_CFG_RAID_PHYDISK_0_OFFLINE_REQUESTED	(0x05)
1404 #define MPII_CFG_RAID_PHYDISK_0_OFFLINE_FAILEDREQ	(0x06)
1405 #define MPII_CFG_RAID_PHYDISK_0_OFFLINE_OTHER		(0xff)
1406 
1407 	u_int8_t		incompat_reason;
1408 	u_int8_t		phys_disk_attrs;
1409 
1410 	u_int32_t		phys_disk_status;
1411 #define MPII_CFG_RAID_PHYDISK_0_STATUS_OUTOFSYNC	(1<<0)
1412 #define MPII_CFG_RAID_PHYDISK_0_STATUS_QUIESCED		(1<<1)
1413 
1414 	u_int64_t		dev_max_lba;
1415 
1416 	u_int64_t		host_max_lba;
1417 
1418 	u_int64_t		coerced_max_lba;
1419 
1420 	u_int16_t		block_size;
1421 	u_int16_t		reserved4;
1422 
1423 	u_int32_t		reserved5;
1424 } __packed __aligned(4);
1425 
1426 struct mpii_cfg_raid_physdisk_pg1 {
1427 	struct mpii_cfg_hdr	config_header;
1428 
1429 	u_int8_t		num_phys_disk_paths;
1430 	u_int8_t		phys_disk_num;
1431 	u_int16_t		reserved1;
1432 
1433 	u_int32_t		reserved2;
1434 
1435 	/* followed by mpii_cfg_raid_physdisk_path structs */
1436 } __packed __aligned(4);
1437 
1438 struct mpii_cfg_raid_physdisk_path {
1439 	u_int8_t		phys_disk_id;
1440 	u_int8_t		phys_disk_bus;
1441 	u_int16_t		reserved1;
1442 
1443 	u_int64_t		wwwid;
1444 
1445 	u_int64_t		owner_wwid;
1446 
1447 	u_int8_t		ownder_id;
1448 	u_int8_t		reserved2;
1449 	u_int16_t		flags;
1450 #define MPII_CFG_RAID_PHYDISK_PATH_INVALID	(1<<0)
1451 #define MPII_CFG_RAID_PHYDISK_PATH_BROKEN	(1<<1)
1452 } __packed __aligned(4);
1453 
1454 #define MPII_CFG_SAS_DEV_ADDR_NEXT		(0<<28)
1455 #define MPII_CFG_SAS_DEV_ADDR_BUS		(1<<28)
1456 #define MPII_CFG_SAS_DEV_ADDR_HANDLE		(2<<28)
1457 
1458 struct mpii_cfg_sas_dev_pg0 {
1459 	struct mpii_ecfg_hdr	config_header;
1460 
1461 	u_int16_t		slot;
1462 	u_int16_t		enc_handle;
1463 
1464 	u_int64_t		sas_addr;
1465 
1466 	u_int16_t		parent_dev_handle;
1467 	u_int8_t		phy_num;
1468 	u_int8_t		access_status;
1469 
1470 	u_int16_t		dev_handle;
1471 	u_int8_t		target;
1472 	u_int8_t		bus;
1473 
1474 	u_int32_t		device_info;
1475 #define MPII_CFG_SAS_DEV_0_DEVINFO_TYPE			(0x7)
1476 #define MPII_CFG_SAS_DEV_0_DEVINFO_TYPE_NONE		(0x0)
1477 #define MPII_CFG_SAS_DEV_0_DEVINFO_TYPE_END		(0x1)
1478 #define MPII_CFG_SAS_DEV_0_DEVINFO_TYPE_EDGE_EXPANDER	(0x2)
1479 #define MPII_CFG_SAS_DEV_0_DEVINFO_TYPE_FANOUT_EXPANDER	(0x3)
1480 #define MPII_CFG_SAS_DEV_0_DEVINFO_SATA_HOST		(1<<3)
1481 #define MPII_CFG_SAS_DEV_0_DEVINFO_SMP_INITIATOR	(1<<4)
1482 #define MPII_CFG_SAS_DEV_0_DEVINFO_STP_INITIATOR	(1<<5)
1483 #define MPII_CFG_SAS_DEV_0_DEVINFO_SSP_INITIATOR	(1<<6)
1484 #define MPII_CFG_SAS_DEV_0_DEVINFO_SATA_DEVICE		(1<<7)
1485 #define MPII_CFG_SAS_DEV_0_DEVINFO_SMP_TARGET		(1<<8)
1486 #define MPII_CFG_SAS_DEV_0_DEVINFO_STP_TARGET		(1<<9)
1487 #define MPII_CFG_SAS_DEV_0_DEVINFO_SSP_TARGET		(1<<10)
1488 #define MPII_CFG_SAS_DEV_0_DEVINFO_DIRECT_ATTACHED	(1<<11)
1489 #define MPII_CFG_SAS_DEV_0_DEVINFO_LSI_DEVICE		(1<<12)
1490 #define MPII_CFG_SAS_DEV_0_DEVINFO_ATAPI_DEVICE		(1<<13)
1491 #define MPII_CFG_SAS_DEV_0_DEVINFO_SEP_DEVICE		(1<<14)
1492 
1493 	u_int16_t		flags;
1494 #define MPII_CFG_SAS_DEV_0_FLAGS_DEV_PRESENT		(1<<0)
1495 #define MPII_CFG_SAS_DEV_0_FLAGS_DEV_MAPPED		(1<<1)
1496 #define MPII_CFG_SAS_DEV_0_FLAGS_DEV_MAPPED_PERSISTENT	(1<<2)
1497 #define MPII_CFG_SAS_DEV_0_FLAGS_SATA_PORT_SELECTOR	(1<<3)
1498 #define MPII_CFG_SAS_DEV_0_FLAGS_SATA_FUA		(1<<4)
1499 #define MPII_CFG_SAS_DEV_0_FLAGS_SATA_NCQ		(1<<5)
1500 #define MPII_CFG_SAS_DEV_0_FLAGS_SATA_SMART		(1<<6)
1501 #define MPII_CFG_SAS_DEV_0_FLAGS_SATA_LBA48		(1<<7)
1502 #define MPII_CFG_SAS_DEV_0_FLAGS_UNSUPPORTED		(1<<8)
1503 #define MPII_CFG_SAS_DEV_0_FLAGS_SATA_SETTINGS		(1<<9)
1504 	u_int8_t		physical_port;
1505 	u_int8_t		max_port_conn;
1506 
1507 	u_int64_t		device_name;
1508 
1509 	u_int8_t		port_groups;
1510 	u_int8_t		dma_group;
1511 	u_int8_t		ctrl_group;
1512 	u_int8_t		reserved1;
1513 
1514 	u_int64_t		reserved2;
1515 } __packed __aligned(4);
1516 
1517 #define MPII_CFG_RAID_CONFIG_ACTIVE_CONFIG		(2<<28)
1518 
1519 struct mpii_cfg_raid_config_pg0 {
1520 	struct	mpii_ecfg_hdr	config_header;
1521 
1522 	u_int8_t		num_hot_spares;
1523 	u_int8_t		num_phys_disks;
1524 	u_int8_t		num_volumes;
1525 	u_int8_t		config_num;
1526 
1527 	u_int32_t		flags;
1528 #define MPII_CFG_RAID_CONFIG_0_FLAGS_NATIVE		(0<<0)
1529 #define MPII_CFG_RAID_CONFIG_0_FLAGS_FOREIGN		(1<<0)
1530 
1531 	u_int32_t		config_guid[6];
1532 
1533 	u_int32_t		reserved1;
1534 
1535 	u_int8_t		num_elements;
1536 	u_int8_t		reserved2[3];
1537 
1538 	/* followed by struct mpii_raid_config_element structs */
1539 } __packed __aligned(4);
1540 
1541 struct mpii_raid_config_element {
1542 	u_int16_t		element_flags;
1543 #define MPII_RAID_CONFIG_ELEMENT_FLAG_VOLUME		(0x0)
1544 #define MPII_RAID_CONFIG_ELEMENT_FLAG_VOLUME_PHYS_DISK	(0x1)
1545 #define	MPII_RAID_CONFIG_ELEMENT_FLAG_HSP_PHYS_DISK	(0x2)
1546 #define MPII_RAID_CONFIG_ELEMENT_ONLINE_CE_PHYS_DISK	(0x3)
1547 	u_int16_t		vol_dev_handle;
1548 
1549 	u_int8_t		hot_spare_pool;
1550 	u_int8_t		phys_disk_num;
1551 	u_int16_t		phys_disk_dev_handle;
1552 } __packed __aligned(4);
1553 
1554 struct mpii_cfg_dpm_pg0 {
1555 	struct mpii_ecfg_hdr	config_header;
1556 #define MPII_DPM_ADDRESS_FORM_MASK			(0xf0000000)
1557 #define MPII_DPM_ADDRESS_FORM_ENTRY_RANGE		(0x00000000)
1558 #define MPII_DPM_ADDRESS_ENTRY_COUNT_MASK		(0x0fff0000)
1559 #define MPII_DPM_ADDRESS_ENTRY_COUNT_SHIFT		(16)
1560 #define MPII_DPM_ADDRESS_START_ENTRY_MASK		(0x0000ffff)
1561 
1562 	/* followed by struct mpii_dpm_entry structs */
1563 } __packed __aligned(4);
1564 
1565 struct mpii_dpm_entry {
1566 	u_int64_t		physical_identifier;
1567 
1568 	u_int16_t		mapping_information;
1569 	u_int16_t		device_index;
1570 
1571 	u_int32_t		physical_bits_mapping;
1572 
1573 	u_int32_t		reserved1;
1574 } __packed __aligned(4);
1575 
1576 struct mpii_evt_sas_discovery {
1577 	u_int8_t		flags;
1578 #define	MPII_EVENT_SAS_DISC_FLAGS_DEV_CHANGE_MASK	(1<<1)
1579 #define MPII_EVENT_SAS_DISC_FLAGS_DEV_CHANGE_NO_CHANGE	(0<<1)
1580 #define MPII_EVENT_SAS_DISC_FLAGS_DEV_CHANGE_CHANGE	(1<<1)
1581 #define MPII_EVENT_SAS_DISC_FLAGS_DISC_IN_PROG_MASK	(1<<0)
1582 #define MPII_EVENT_SAS_DISC_FLAGS_DISC_NOT_IN_PROGRESS	(1<<0)
1583 #define MPII_EVENT_SAS_DISC_FLAGS_DISC_IN_PROGRESS	(0<<0)
1584 	u_int8_t		reason_code;
1585 #define MPII_EVENT_SAS_DISC_REASON_CODE_STARTED		(0x01)
1586 #define	MPII_EVENT_SAS_DISC_REASON_CODE_COMPLETED	(0x02)
1587 	u_int8_t		physical_port;
1588 	u_int8_t		reserved1;
1589 
1590 	u_int32_t		discovery_status;
1591 } __packed __aligned(4);
1592 
1593 struct mpii_evt_ir_status {
1594 	u_int16_t		vol_dev_handle;
1595 	u_int16_t		reserved1;
1596 
1597 	u_int8_t		operation;
1598 #define MPII_EVENT_IR_RAIDOP_RESYNC			(0x00)
1599 #define MPII_EVENT_IR_RAIDOP_OCE			(0x01)
1600 #define MPII_EVENT_IR_RAIDOP_CONS_CHECK			(0x02)
1601 #define MPII_EVENT_IR_RAIDOP_BG_INIT			(0x03)
1602 #define MPII_EVENT_IR_RAIDOP_MAKE_CONS			(0x04)
1603 	u_int8_t		percent;
1604 	u_int16_t		reserved2;
1605 
1606 	u_int32_t		reserved3;
1607 };
1608 
1609 struct mpii_evt_ir_volume {
1610 	u_int16_t		vol_dev_handle;
1611 	u_int8_t		reason_code;
1612 #define MPII_EVENT_IR_VOL_RC_SETTINGS_CHANGED		(0x01)
1613 #define MPII_EVENT_IR_VOL_RC_STATUS_CHANGED		(0x02)
1614 #define MPII_EVENT_IR_VOL_RC_STATE_CHANGED		(0x03)
1615 	u_int8_t		reserved1;
1616 
1617 	u_int32_t		new_value;
1618 	u_int32_t		prev_value;
1619 } __packed __aligned(4);
1620 
1621 struct mpii_evt_ir_physical_disk {
1622 	u_int16_t		reserved1;
1623 	u_int8_t		reason_code;
1624 #define MPII_EVENT_IR_PD_RC_SETTINGS_CHANGED		(0x01)
1625 #define MPII_EVENT_IR_PD_RC_STATUS_FLAGS_CHANGED	(0x02)
1626 #define MPII_EVENT_IR_PD_RC_STATUS_CHANGED		(0x03)
1627 	u_int8_t		phys_disk_num;
1628 
1629 	u_int16_t		phys_disk_dev_handle;
1630 	u_int16_t		reserved2;
1631 
1632 	u_int16_t		slot;
1633 	u_int16_t		enclosure_handle;
1634 
1635 	u_int32_t		new_value;
1636 	u_int32_t		previous_value;
1637 } __packed __aligned(4);
1638 
1639 struct mpii_evt_sas_tcl {
1640 	u_int16_t		enclosure_handle;
1641 	u_int16_t		expander_handle;
1642 
1643 	u_int8_t		num_phys;
1644 	u_int8_t		reserved1[3];
1645 
1646 	u_int8_t		num_entries;
1647 	u_int8_t		start_phy_num;
1648 	u_int8_t		expn_status;
1649 #define	MPII_EVENT_SAS_TOPO_ES_ADDED			(0x01)
1650 #define MPII_EVENT_SAS_TOPO_ES_NOT_RESPONDING		(0x02)
1651 #define MPII_EVENT_SAS_TOPO_ES_RESPONDING		(0x03)
1652 #define MPII_EVENT_SAS_TOPO_ES_DELAY_NOT_RESPONDING	(0x04)
1653 	u_int8_t		physical_port;
1654 
1655 	/* followed by num_entries number of struct mpii_evt_phy_entry */
1656 } __packed __aligned(4);
1657 
1658 struct mpii_evt_phy_entry {
1659 	u_int16_t		dev_handle;
1660 	u_int8_t		link_rate;
1661 	u_int8_t		phy_status;
1662 #define MPII_EVENT_SAS_TOPO_PS_RC_MASK			(0x0f)
1663 #define MPII_EVENT_SAS_TOPO_PS_RC_ADDED			(0x01)
1664 #define MPII_EVENT_SAS_TOPO_PS_RC_MISSING		(0x02)
1665 } __packed __aligned(4);
1666 
1667 struct mpii_evt_ir_cfg_change_list {
1668 	u_int8_t		num_elements;
1669 	u_int16_t		reserved;
1670 	u_int8_t		config_num;
1671 
1672 	u_int32_t		flags;
1673 #define MPII_EVT_IR_CFG_CHANGE_LIST_FOREIGN		(0x1)
1674 
1675 	/* followed by num_elements struct mpii_evt_ir_cfg_elements */
1676 } __packed __aligned(4);
1677 
1678 struct mpii_evt_ir_cfg_element {
1679 	u_int16_t		element_flags;
1680 #define MPII_EVT_IR_CFG_ELEMENT_TYPE_MASK		(0xf)
1681 #define MPII_EVT_IR_CFG_ELEMENT_TYPE_VOLUME		(0x0)
1682 #define MPII_EVT_IR_CFG_ELEMENT_TYPE_VOLUME_DISK	(0x1)
1683 #define MPII_EVT_IR_CFG_ELEMENT_TYPE_HOT_SPARE		(0x2)
1684 	u_int16_t		vol_dev_handle;
1685 
1686 	u_int8_t		reason_code;
1687 #define MPII_EVT_IR_CFG_ELEMENT_RC_ADDED		(0x01)
1688 #define MPII_EVT_IR_CFG_ELEMENT_RC_REMOVED		(0x02)
1689 #define MPII_EVT_IR_CFG_ELEMENT_RC_NO_CHANGE		(0x03)
1690 #define MPII_EVT_IR_CFG_ELEMENT_RC_HIDE			(0x04)
1691 #define MPII_EVT_IR_CFG_ELEMENT_RC_UNHIDE		(0x05)
1692 #define MPII_EVT_IR_CFG_ELEMENT_RC_VOLUME_CREATED	(0x06)
1693 #define MPII_EVT_IR_CFG_ELEMENT_RC_VOLUME_DELETED	(0x07)
1694 #define MPII_EVT_IR_CFG_ELEMENT_RC_PD_CREATED		(0x08)
1695 #define MPII_EVT_IR_CFG_ELEMENT_RC_PD_DELETED		(0x09)
1696 	u_int8_t		phys_disk_num;
1697 	u_int16_t		phys_disk_dev_handle;
1698 } __packed __aligned(4);
1699