xref: /freebsd/sys/dev/smartpqi/smartpqi_structures.h (revision 734e82fe33aa764367791a7d603b383996c6b40b)
1 /*-
2  * Copyright 2016-2021 Microchip Technology, Inc. and/or its subsidiaries.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23  * SUCH DAMAGE.
24  */
25 
26 
27 #ifndef _PQI_STRUCTURES_H
28 #define _PQI_STRUCTURES_H
29 
30 struct bmic_host_wellness_driver_version {
31 	uint8_t		start_tag[4];
32 	uint8_t		driver_version_tag[2];
33 	uint16_t	driver_version_length;
34 	char		driver_version[32];
35 	uint8_t		end_tag[2];
36 
37 }OS_ATTRIBUTE_PACKED;
38 
39 struct bmic_host_wellness_time {
40 	uint8_t		start_tag[4];
41 	uint8_t		time_tag[2];
42 	uint16_t	time_length;
43 	uint8_t		hour;
44 	uint8_t		min;
45 	uint8_t		sec;
46 	uint8_t		reserved;
47 	uint8_t		month;
48 	uint8_t		day;
49 	uint8_t		century;
50 	uint8_t		year;
51 	uint8_t		dont_write_tag[2];
52 	uint8_t		end_tag[2];
53 
54 }OS_ATTRIBUTE_PACKED;
55 
56 /* As per PQI Spec pqi-2r00a , 6.2.2. */
57 
58 /* device capability register , for admin q table 24 */
59 struct pqi_dev_adminq_cap {
60 	uint8_t		max_admin_ibq_elem;
61 	uint8_t		max_admin_obq_elem;
62 	uint8_t		admin_ibq_elem_len;
63 	uint8_t		admin_obq_elem_len;
64 	uint16_t	max_pqi_dev_reset_tmo;
65 	uint8_t		res[2];
66 }OS_ATTRIBUTE_PACKED;
67 
68 /* admin q parameter reg , table 36 */
69 struct admin_q_param {
70 	uint8_t		num_iq_elements;
71 	uint8_t		num_oq_elements;
72 	uint8_t		intr_msg_num;
73 	uint8_t		msix_disable;
74 }OS_ATTRIBUTE_PACKED;
75 
76 struct pqi_registers {
77 	uint64_t		signature;
78 	uint64_t		admin_q_config;
79 	uint64_t	 	pqi_dev_adminq_cap;
80 	uint32_t		legacy_intr_status;
81 	uint32_t		legacy_intr_mask_set;
82 	uint32_t		legacy_intr_mask_clr;
83 	uint8_t			res1[28];
84 	uint32_t		pqi_dev_status;
85 	uint8_t			res2[4];
86 	uint64_t		admin_ibq_pi_offset;
87 	uint64_t		admin_obq_ci_offset;
88 	uint64_t		admin_ibq_elem_array_addr;
89 	uint64_t		admin_obq_elem_array_addr;
90 	uint64_t		admin_ibq_ci_addr;
91 	uint64_t		admin_obq_pi_addr;
92 	uint32_t	 	admin_q_param;
93 	uint8_t			res3[4];
94 	uint32_t		pqi_dev_err;
95 	uint8_t			res4[4];
96 	uint64_t		error_details;
97 	uint32_t		dev_reset;
98 	uint32_t		power_action;
99 	uint8_t			res5[104];
100 }OS_ATTRIBUTE_PACKED;
101 
102 /*
103  * IOA controller registers
104  * Mapped in PCIe BAR 0.
105  */
106 
107 struct ioa_registers {
108 	uint8_t		res1[0x18];
109 	uint32_t	host_to_ioa_db_mask_clr; 	/* 18h */
110 	uint8_t		res2[4];
111 	uint32_t	host_to_ioa_db;			/* 20h */
112 	uint8_t		res3[4];
113 	uint32_t	host_to_ioa_db_clr;		/* 28h */
114 	uint8_t		res4[8];
115 	uint32_t	ioa_to_host_glob_int_mask;	/* 34h */
116 	uint8_t		res5[0x64];
117 	uint32_t	ioa_to_host_db;			/* 9Ch */
118 	uint32_t	ioa_to_host_db_clr;		/* A0h */
119 	uint8_t		res6[4];
120 	uint32_t	ioa_to_host_db_mask;		/* A8h */
121 	uint32_t	ioa_to_host_db_mask_clr;	/* ACh */
122 	uint32_t	scratchpad0;			/* B0h */
123 	uint32_t	scratchpad1;			/* B4h */
124 	uint32_t	scratchpad2;			/* B8h */
125 	uint32_t	scratchpad3_fw_status;		/* BCh */
126 	uint8_t		res7[8];
127 	uint32_t	scratchpad4;			/* C8h */
128 	uint8_t		res8[0xf34];			/* 0xC8 + 4 + 0xf34 = 1000h */
129 	uint32_t	mb[8];				/* 1000h */
130 }OS_ATTRIBUTE_PACKED;
131 
132 
133 /* PQI Preferred settings */
134 struct pqi_pref_settings {
135 	uint16_t	max_cmd_size;
136 	uint16_t	max_fib_size;
137 }OS_ATTRIBUTE_PACKED;
138 
139 /* pqi capability by sis interface */
140 struct pqi_cap {
141 	uint32_t	max_sg_elem;
142 	uint32_t	max_transfer_size;
143 	uint32_t	max_outstanding_io;
144 	uint32_t	conf_tab_off;
145 	uint32_t	conf_tab_sz;
146 }OS_ATTRIBUTE_PACKED;
147 
148 struct pqi_conf_table {
149 	uint8_t		sign[8];		/* "CFGTABLE" */
150 	uint32_t	first_section_off;
151 };
152 
153 struct pqi_conf_table_section_header {
154 	uint16_t	section_id;
155 	uint16_t	next_section_off;
156 };
157 
158 struct pqi_conf_table_general_info {
159 	struct pqi_conf_table_section_header header;
160 	uint32_t	section_len;
161 	uint32_t	max_outstanding_req;
162 	uint32_t	max_sg_size;
163 	uint32_t	max_sg_per_req;
164 };
165 
166 struct pqi_conf_table_debug {
167 	struct pqi_conf_table_section_header header;
168 	uint32_t	scratchpad;
169 };
170 
171 struct pqi_conf_table_heartbeat {
172 	struct pqi_conf_table_section_header header;
173 	uint32_t	heartbeat_counter;
174 };
175 
176 typedef union pqi_reset_reg {
177 	struct {
178 		uint32_t reset_type : 3;
179 		uint32_t reserved : 2;
180 		uint32_t reset_action : 3;
181 		uint32_t hold_in_pd1 : 1;
182 		uint32_t reserved2 : 23;
183 	} bits;
184 	uint32_t all_bits;
185 }pqi_reset_reg_t;
186 
187 /* Memory descriptor for DMA memory allocation */
188 typedef struct dma_mem {
189 	void			*virt_addr;
190     dma_addr_t 		dma_addr;
191 	uint32_t 		size;
192 	uint32_t 		align;
193 	char 			*tag;
194         bus_dma_tag_t dma_tag;
195         bus_dmamap_t dma_map;
196 }dma_mem_t;
197 
198 /* Lock should be 8 byte aligned  */
199 
200 #ifndef LOCKFREE_STACK
201 
202 typedef struct pqi_taglist {
203         uint32_t        max_elem;
204         uint32_t        num_elem;
205         uint32_t        head;
206         uint32_t        tail;
207         uint32_t       	*elem_array;
208 	boolean_t       lockcreated;
209 	char            lockname[LOCKNAME_SIZE];
210 	OS_LOCK_T       lock	OS_ATTRIBUTE_ALIGNED(8);
211 }pqi_taglist_t;
212 
213 #else	/* LOCKFREE_STACK */
214 
215 union head_list {
216         struct {
217                 uint32_t        seq_no; /* To avoid aba problem */
218                 uint32_t        index;  /* Index at the top of the stack */
219         }top;
220         uint64_t        data;
221 };
222 /* lock-free stack used to push and pop the tag used for IO request */
223 typedef struct  lockless_stack {
224 	uint32_t	*next_index_array;
225 	uint32_t	max_elem;/*No.of total elements*/
226 	uint32_t	num_elem;/*No.of present elements*/
227 	volatile union	head_list      head	OS_ATTRIBUTE_ALIGNED(8);
228 }lockless_stack_t;
229 
230 #endif /* LOCKFREE_STACK */
231 
232 /*
233  * PQI SGL descriptor layouts.
234  */
235 /*
236  * SGL (Scatter Gather List) descriptor Codes
237  */
238 
239 #define SGL_DESCRIPTOR_CODE_DATA_BLOCK                     0x0
240 #define SGL_DESCRIPTOR_CODE_BIT_BUCKET                     0x1
241 #define SGL_DESCRIPTOR_CODE_STANDARD_SEGMENT               0x2
242 #define SGL_DESCRIPTOR_CODE_LAST_STANDARD_SEGMENT          0x3
243 #define SGL_DESCRIPTOR_CODE_LAST_ALTERNATIVE_SGL_SEGMENT   0x4
244 #define SGL_DESCRIPTOR_CODE_VENDOR_SPECIFIC                0xF
245 
246 typedef struct sgl_descriptor
247 {
248 	uint64_t	addr;	/* !< Bytes 0-7.  The starting 64-bit memory byte address of the data block. */
249 	uint32_t	length;	/* !< Bytes 8-11.  The length in bytes of the data block.  Set to 0x00000000 specifies that no data be transferred. */
250 	uint8_t		res[3];	/* !< Bytes 12-14. */
251 	uint8_t     zero : 4; /* !< Byte 15, Bits 0-3. */
252 	uint8_t     type : 4; /* !< Byte 15, Bits 4-7. sgl descriptor type */
253 } sg_desc_t;
254 
255 /* PQI IUs */
256 typedef struct iu_header
257 {
258 	uint8_t		iu_type;
259 	uint8_t		comp_feature;
260 	uint16_t	iu_length;
261 }OS_ATTRIBUTE_PACKED iu_header_t;
262 
263 
264 typedef struct general_admin_request /* REPORT_PQI_DEVICE_CAPABILITY, REPORT_MANUFACTURER_INFO,  REPORT_OPERATIONAL_IQ,  REPORT_OPERATIONAL_OQ all same layout. */
265 {
266 	iu_header_t	header;		/* !< Bytes 0-3. */
267 	uint16_t	res1;
268 	uint16_t	work;
269 	uint16_t	req_id;		/* !< Bytes 8-9. request identifier */
270 	uint8_t		fn_code;	/* !< Byte 10. which administrator function */
271 	union {
272 		struct {
273 			uint8_t		res2[33];	/* !< Bytes 11-43. function specific */
274 			uint32_t	buf_size;	/* !< Bytes 44-47. size in bytes of the Data-In/Out Buffer */
275 			sg_desc_t	sg_desc;	/* !< Bytes 48-63. SGL */
276         } OS_ATTRIBUTE_PACKED general_func;
277 
278 		struct {
279 			uint8_t		res1;
280 			uint16_t	qid;
281 			uint8_t		res2[2];
282 			uint64_t	elem_arr_addr;
283 			uint64_t	iq_ci_addr;
284 			uint16_t	num_elem;
285 			uint16_t	elem_len;
286 			uint8_t		queue_proto;
287 			uint8_t		arb_prio;
288 			uint8_t		res3[22];
289 			uint32_t	vend_specific;
290         } OS_ATTRIBUTE_PACKED create_op_iq;
291 
292 		struct {
293 			uint8_t		res1;
294 			uint16_t	qid;
295 			uint8_t		res2[2];
296 			uint64_t	elem_arr_addr;
297 			uint64_t	ob_pi_addr;
298 			uint16_t	num_elem;
299 			uint16_t	elem_len;
300 			uint8_t		queue_proto;
301 			uint8_t		res3[3];
302 			uint16_t	intr_msg_num;
303 			uint16_t	coales_count;
304 			uint32_t	min_coales_time;
305 			uint32_t	max_coales_time;
306 			uint8_t		res4[8];
307 			uint32_t	vend_specific;
308         } OS_ATTRIBUTE_PACKED create_op_oq;
309 
310 		struct {
311 			uint8_t		res1;
312 			uint16_t	qid;
313 			uint8_t		res2[50];
314         } OS_ATTRIBUTE_PACKED delete_op_queue;
315 
316 		struct {
317 			uint8_t		res1;
318 			uint16_t	qid;
319 			uint8_t		res2[46];
320 			uint32_t	vend_specific;
321         } OS_ATTRIBUTE_PACKED change_op_iq_prop;
322 
323     } OS_ATTRIBUTE_PACKED req_type;
324 
325 }OS_ATTRIBUTE_PACKED gen_adm_req_iu_t;
326 
327 
328 typedef struct general_admin_response {
329 	iu_header_t 	header;
330 	uint16_t	res1;
331 	uint16_t	work;
332 	uint16_t	req_id;
333 	uint8_t		fn_code;
334 	uint8_t		status;
335 	union {
336 		struct {
337 			uint8_t		status_desc[4];
338 			uint64_t	pi_offset;
339 			uint8_t		res[40];
340         }  OS_ATTRIBUTE_PACKED  create_op_iq;
341 
342 		struct {
343 			uint8_t		status_desc[4];
344 			uint64_t	ci_offset;
345 			uint8_t		res[40];
346         }  OS_ATTRIBUTE_PACKED  create_op_oq;
347     }  OS_ATTRIBUTE_PACKED  resp_type;
348 } OS_ATTRIBUTE_PACKED gen_adm_resp_iu_t ;
349 
350 /*report and set Event config IU*/
351 
352 typedef struct pqi_event_config_request {
353 	iu_header_t   	header;
354 	uint16_t	 	response_queue_id;	/* specifies the OQ where the response
355 					                              IU is to be delivered */
356 	uint8_t	    	work_area[2];	/* reserved for driver use */
357 	uint16_t	    request_id;
358 	union {
359 		uint16_t  	reserved;           /* Report event config iu */
360 		uint16_t  	global_event_oq_id; /* Set event config iu */
361 	}iu_specific;
362 	uint32_t	    buffer_length;
363 	sg_desc_t     	sg_desc;
364 }pqi_event_config_request_t;
365 #if 0
366 typedef struct pqi_set_event_config_request {
367 	iu_header_t  header;
368 	uint16_t  	response_queue_id;  /* specifies the OQ where the response
369 													IU is to be delivered */
370 	uint8_t   	work_area[2];   /* reserved for driver use */
371 	uint16_t	request_id;
372 	uint16_t	global_event_oq_id;
373 	uint32_t	buffer_length;
374 	sg_desc_t 	sg_desc;
375 }pqi_set_event_config_request_t;
376 #endif
377 
378  /* Report/Set event config data-in/data-out buffer structure */
379 
380 #define PQI_MAX_EVENT_DESCRIPTORS 255
381 
382 struct pqi_event_descriptor {
383 	uint8_t  	event_type;
384 	uint8_t  	reserved;
385 	uint16_t	oq_id;
386 };
387 
388 typedef struct pqi_event_config {
389 	uint8_t  	reserved[2];
390 	uint8_t  	num_event_descriptors;
391 	uint8_t  	reserved1;
392 	struct		pqi_event_descriptor descriptors[PQI_MAX_EVENT_DESCRIPTORS];
393 }pqi_event_config_t;
394 
395 /*management response IUs */
396 typedef struct pqi_management_response{
397    	iu_header_t		header;
398 	uint16_t 		reserved1;
399 	uint8_t 		work_area[2];
400 	uint16_t		req_id;
401 	uint8_t 		result;
402 	uint8_t			reserved[5];
403 	uint64_t		result_data;
404 }pqi_management_response_t;
405   /*Event response IU*/
406 typedef struct pqi_event_response {
407 	iu_header_t 	header;
408 	uint16_t 		reserved1;
409 	uint8_t 		work_area[2];
410 	uint8_t 		event_type;
411 	uint8_t 		reserved2 : 7;
412 	uint8_t 		request_acknowledge : 1;
413 	uint16_t	  	event_id;
414 	uint32_t	  	additional_event_id;
415 	uint8_t 		data[16];
416 }pqi_event_response_t;
417 
418   /*event acknowledge IU*/
419 typedef struct pqi_event_acknowledge_request {
420 	iu_header_t 	header;
421 	uint16_t 		reserved1;
422 	uint8_t 		work_area[2];
423 	uint8_t 		event_type;
424 	uint8_t 		reserved2;
425 	uint16_t	  	event_id;
426 	uint32_t	  	additional_event_id;
427 }pqi_event_acknowledge_request_t;
428 
429 struct pqi_event {
430 	boolean_t	pending;
431 	uint8_t	  	event_type;
432 	uint16_t	event_id;
433 	uint32_t	additional_event_id;
434 };
435 
436 typedef struct pqi_vendor_general_request {
437 	iu_header_t	header;
438 	uint16_t	response_queue_id;
439 	uint8_t		work_area[2];
440 	uint16_t	request_id;
441 	uint16_t	function_code;
442 	union {
443 		struct {
444 			uint16_t	first_section;
445 			uint16_t	last_section;
446 			uint8_t		reserved1[48];
447 		} OS_ATTRIBUTE_PACKED config_table_update;
448 
449 		struct {
450 			uint64_t	buffer_address;
451 			uint32_t	buffer_length;
452 			uint8_t		reserved2[40];
453 		} OS_ATTRIBUTE_PACKED ofa_memory_allocation;
454 	} data;
455 } OS_ATTRIBUTE_PACKED pqi_vendor_general_request_t;
456 
457 typedef struct pqi_vendor_general_response {
458 	iu_header_t	header;
459 	uint16_t	reserved1;
460 	uint8_t		work_area[2];
461 	uint16_t	request_id;
462 	uint16_t	function_code;
463 	uint16_t	status;
464 	uint8_t		reserved2[2];
465 } OS_ATTRIBUTE_PACKED pqi_vendor_general_response_t;
466 
467 typedef struct op_q_params
468 {
469 	uint8_t		fn_code;
470 	uint16_t        qid;
471 	uint16_t	num_elem;
472 	uint16_t	elem_len;
473 	uint16_t	int_msg_num;
474 
475 } OS_ATTRIBUTE_PACKED op_q_params;
476 
477 /* "Fixed Format Sense Data" (0x70 or 0x71)  (Table 45 in SPC5) */
478 typedef struct sense_data_fixed {
479 	uint8_t  response_code : 7;      // Byte 0, 0x70 or 0x71
480 	uint8_t  valid : 1;              // Byte 0, bit 7
481 	uint8_t  byte_1;                 // Byte 1
482 	uint8_t  sense_key : 4;          // Byte 2, bit 0-3 (Key)
483 	uint8_t  byte_2_other : 4;       // Byte 2, bit 4-7
484 	uint32_t information;            // Byte 3-6, big-endian like block # in CDB
485 	uint8_t  addtnl_length;          // Byte 7
486 	uint8_t  cmd_specific[4];        // Byte 8-11
487 	uint8_t  sense_code;             // Byte 12 (ASC)
488 	uint8_t  sense_qual;             // Byte 13 (ASCQ)
489 	uint8_t  fru_code;               // Byte 14
490 	uint8_t  sense_key_specific[3];  // Byte 15-17
491 	uint8_t  addtnl_sense[1];        // Byte 18+
492 } OS_ATTRIBUTE_PACKED sense_data_fixed_t;
493 
494 
495 /* Generic Sense Data Descriptor (Table 29 in SPC5) */
496 typedef struct descriptor_entry
497 {
498 	uint8_t  desc_type;              // Byte 9/0
499 	uint8_t  desc_type_length;       // Byte 10/1
500 	union
501 	{
502 		/* Sense data descriptor specific */
503 		uint8_t bytes[1];
504 
505 		/* Information (Type 0) (Table 31 is SPC5) */
506 		struct {
507 			uint8_t  byte_2_rsvd : 7;  // Byte 11/2
508 			uint8_t  valid : 1;        // Byte 11/2, bit 7
509 			uint8_t  byte_3;           // Byte 12/3
510 			uint8_t  information[8];   // Byte 13-20/4-11
511 		} OS_ATTRIBUTE_PACKED type_0;
512 
513 	}u;
514 } OS_ATTRIBUTE_PACKED descriptor_entry_t;
515 
516 /* "Descriptor Format Sense Data" (0x72 or 0x73) (Table 28 in SPC5) */
517 typedef struct sense_data_descriptor {
518 	uint8_t  response_code : 7;      // Byte 0, 0x72 or 0x73
519 	uint8_t  byte_0_rsvd: 1;         // Byte 0, bit 7
520 	uint8_t  sense_key : 4;          // Byte 1, bit 0-3 (Key)
521 	uint8_t  byte_1_other : 4;       // Byte 1, bit 4-7
522 	uint8_t  sense_code;             // Byte 2 (ASC)
523 	uint8_t  sense_qual;             // Byte 3 (ASCQ)
524 	uint8_t  byte4_6[3];             // Byte 4-6
525 	uint8_t  more_length;            // Byte 7
526 	descriptor_entry_t descriptor_list; // Bytes 8+
527 
528 } OS_ATTRIBUTE_PACKED sense_data_descriptor_t;
529 
530 typedef union sense_data_u
531 {
532 	sense_data_fixed_t      fixed_format;
533 	sense_data_descriptor_t descriptor_format;
534 	uint8_t                 data[256];
535 } sense_data_u_t;
536 
537 
538 
539 
540 /* Driver will use this structure to interpret the error
541    info element returned from a failed requests */
542 typedef struct raid_path_error_info_elem {
543 	uint8_t		data_in_result;		/* !< Byte 0.  See SOP spec Table 77. */
544 	uint8_t		data_out_result;	/* !< Byte 1.  See SOP spec Table 78. */
545 	uint8_t		reserved[3];		/* !< Bytes 2-4. */
546 	uint8_t		status;			/* !< Byte 5. See SAM-5 specification "Status" codes Table 40. Defined in Storport.h */
547 	uint16_t	status_qual;		/* !< Bytes 6-7. See SAM-5 specification Table 43. */
548 	uint16_t	sense_data_len;		/* !< Bytes 8-9. See SOP specification table 79. */
549 	uint16_t	resp_data_len;		/* !< Bytes 10-11. See SOP specification table 79. */
550 	uint32_t	data_in_transferred;	/* !< Bytes 12-15. If "dada_in_result = 0x01 (DATA_IN BUFFER UNDERFLOW)", Indicates the number of contiguous bytes starting with offset zero in Data-In buffer else Ignored. */
551 	uint32_t	data_out_transferred;	/* !< Bytes 16-19. If "data_out_result = 0x01 (DATA_OUT BUFFER UNDERFLOW)", Indicates the number of contiguous bytes starting with offset zero in Data-Out buffer else Ignored. */
552 	union
553 	{
554 		sense_data_u_t sense_data;
555 		uint8_t        data[256];              /* !< Bytes 20-275. Response Data buffer or Sense Data buffer but not both. */
556 	};
557 }OS_ATTRIBUTE_PACKED raid_path_error_info_elem_t;
558 
559 #define PQI_ERROR_BUFFER_ELEMENT_LENGTH sizeof(raid_path_error_info_elem_t)
560 
561 typedef enum error_data_present
562 {
563    DATA_PRESENT_NO_DATA       = 0,   /* !< No data present in Data buffer. */
564    DATA_PRESENT_RESPONSE_DATA = 1,   /* !< Response data is present in Data buffer. */
565    DATA_PRESENT_SENSE_DATA    = 2    /* !< Sense data is present in Data buffer. */
566 } error_data_present_t;
567 
568 typedef struct aio_path_error_info_elem
569 {
570 	uint8_t		status;			/* !< Byte 0.  See SAM-5 specification "SCSI Status" codes Table 40. Defined in Storport.h */
571 	uint8_t		service_resp;		/* !< Byte 1.  SCSI Service Response.  */
572 	uint8_t		data_pres;		/* !< Byte 2.  Bits [7:2] reserved. Bits [1:0] - 0=No data, 1=Response data, 2=Sense data. */
573 	uint8_t		reserved1;		/* !< Byte 3.  Reserved. */
574 	uint32_t	resd_count;		/* !< Bytes 4-7.  The residual data length in bytes. Need the original transfer size and if Status is OverRun or UnderRun. */
575 	uint16_t	data_len;		/* !< Bytes 8-9.  The amount of Sense data or Response data returned in Response/Sense Data buffer. */
576 	uint16_t	reserved2;		/* !< Bytes 10.  Reserved. */
577 	uint8_t		data[256];		/* !< Bytes 11-267. Response data buffer or Sense data buffer but not both. */
578 	uint8_t		padding[8];		/* !< Bytes 268-275.  Padding to make AIO_PATH_ERROR_INFO_ELEMENT = RAID_PATH_ERROR_INFO_ELEMENT */
579 }OS_ATTRIBUTE_PACKED aio_path_error_info_elem_t;
580 
581 struct init_base_struct {
582 	uint32_t	revision;		/* revision of init structure */
583 	uint32_t	flags;			/* reserved */
584 	uint32_t	err_buf_paddr_l;	/* lower 32 bits of physical address of error buffer */
585 	uint32_t	err_buf_paddr_h;	/* upper 32 bits of physical address of error buffer */
586 	uint32_t	err_buf_elem_len;	/* length of each element in error buffer (in bytes) */
587 	uint32_t	err_buf_num_elem;	/* number of elements in error buffer */
588 }OS_ATTRIBUTE_PACKED;
589 
590 /* Queue details */
591 typedef struct ib_queue {
592 	uint32_t	q_id;
593 	uint32_t	num_elem;
594 	uint32_t	elem_size;
595 	char 		*array_virt_addr;
596 	dma_addr_t	array_dma_addr;
597 	uint32_t	pi_local;
598 	uint32_t	pi_register_offset;
599 	uint32_t	*pi_register_abs;
600 	uint32_t	*ci_virt_addr;
601 	dma_addr_t	ci_dma_addr;
602 	boolean_t	created;
603 	boolean_t	lockcreated;
604 	char		lockname[LOCKNAME_SIZE];
605 	OS_PQILOCK_T	lock	OS_ATTRIBUTE_ALIGNED(8);
606 }ib_queue_t;
607 
608 typedef struct ob_queue {
609 	uint32_t	q_id;
610 	uint32_t	num_elem;
611 	uint32_t	elem_size;
612 	uint32_t	intr_msg_num;
613 	char		*array_virt_addr;
614 	dma_addr_t	array_dma_addr;
615 	uint32_t	ci_local;
616 	uint32_t	ci_register_offset;
617 	uint32_t	*ci_register_abs;
618 	uint32_t	*pi_virt_addr;
619 	dma_addr_t	pi_dma_addr;
620 	boolean_t	created;
621 }ob_queue_t;
622 
623 typedef struct pqisrc_sg_desc{
624 	uint64_t	addr;
625 	uint32_t	len;
626 	uint32_t	flags;
627 }sgt_t;
628 
629 
630 typedef struct pqi_iu_layer_desc {
631 	uint8_t		ib_spanning_supported : 1;
632 	uint8_t		res1 : 7;
633 	uint8_t		res2[5];
634 	uint16_t	max_ib_iu_len;
635 	uint8_t		ob_spanning_supported : 1;
636 	uint8_t		res3 : 7;
637 	uint8_t		res4[5];
638 	uint16_t	max_ob_iu_len;
639 }OS_ATTRIBUTE_PACKED pqi_iu_layer_desc_t;
640 
641 
642 /* Response IU data */
643 typedef struct pqi_device_capabilities {
644 	uint16_t	length;
645 	uint8_t		res1[6];
646 	uint8_t		ibq_arb_priority_support_bitmask;
647 	uint8_t		max_aw_a;
648 	uint8_t		max_aw_b;
649 	uint8_t		max_aw_c;
650 	uint8_t		max_arb_burst : 3;
651 	uint8_t		res2 : 4;
652 	uint8_t		iqa : 1;
653 	uint8_t		res3[2];
654 	uint8_t		iq_freeze : 1;
655 	uint8_t		res4 : 7;
656 	uint16_t	max_iqs;
657 	uint16_t	max_iq_elements;
658 	uint8_t		res5[4];
659 	uint16_t	max_iq_elem_len;
660 	uint16_t	min_iq_elem_len;
661 	uint8_t		res6[2];
662 	uint16_t	max_oqs;
663 	uint16_t	max_oq_elements;
664 	uint16_t	intr_coales_time_granularity;
665 	uint16_t	max_oq_elem_len;
666 	uint16_t	min_oq_elem_len;
667 	uint8_t		res7[24];
668 	pqi_iu_layer_desc_t iu_layer_desc[32];
669 }OS_ATTRIBUTE_PACKED pqi_dev_cap_t;
670 
671 /* IO path */
672 
673 typedef struct pqi_aio_req {
674 	iu_header_t	header;
675 	uint16_t	response_queue_id;
676 	uint8_t		work_area[2];
677 	uint16_t	req_id;
678 	uint8_t		res1[2];
679 	uint32_t	nexus;
680 	uint32_t	buf_len;
681 	uint8_t		data_dir : 2;
682 	uint8_t		partial : 1;
683 	uint8_t		mem_type : 1;
684 	uint8_t		fence : 1;
685 	uint8_t		encrypt_enable : 1;
686 	uint8_t		res2 : 2;
687 	uint8_t		task_attr : 3;
688 	uint8_t		cmd_prio : 4;
689 	uint8_t		res3 : 1;
690 	uint16_t	encrypt_key_index;
691 	uint32_t	encrypt_twk_low;
692 	uint32_t	encrypt_twk_high;
693 	uint8_t		cdb[16];
694 	uint16_t	err_idx;
695 	uint8_t		num_sg;
696 	uint8_t		cdb_len;
697 	uint8_t		lun[8];
698 	uint8_t		res4[4];
699 	sgt_t		sg_desc[4];
700 }OS_ATTRIBUTE_PACKED pqi_aio_req_t;
701 
702 
703 typedef struct pqisrc_raid_request {
704 	iu_header_t header;
705 	uint16_t response_queue_id;	/* specifies the OQ where the response
706 					   IU is to be delivered */
707 	uint8_t	work_area[2];	/* reserved for driver use */
708 	uint16_t request_id;
709 	uint16_t nexus_id;
710 	uint32_t buffer_length;
711 	uint8_t	lun_number[8];
712 	uint16_t protocol_spec;
713 	uint8_t	data_direction : 2;
714 	uint8_t	partial : 1;
715 	uint8_t	reserved1 : 4;
716 	uint8_t	fence : 1;
717 	uint16_t error_index;
718 	uint8_t	reserved2;
719 	uint8_t	task_attribute : 3;
720 	uint8_t	command_priority : 4;
721 	uint8_t	reserved3 : 1;
722 	uint8_t	reserved4 : 2;
723 	uint8_t	additional_cdb_bytes_usage : 3;
724 	uint8_t	reserved5 : 3;
725 	uint8_t	cdb[16];
726 	uint8_t	reserved[12];
727 	uint32_t timeout_in_sec;
728 	sgt_t	sg_descriptors[4];
729 } OS_ATTRIBUTE_PACKED pqisrc_raid_req_t;
730 
731 
732 typedef struct pqi_raid_tmf_req {
733         iu_header_t     header;
734         uint16_t        resp_qid;
735         uint8_t         work_area[2];
736         uint16_t        req_id;
737         uint16_t        nexus;
738         uint8_t         res1[2];
739         uint16_t        timeout_in_sec;
740         uint8_t         lun[8];
741         uint16_t        protocol_spec;
742         uint16_t        obq_id_to_manage;
743         uint16_t        req_id_to_manage;
744         uint8_t         tmf;
745         uint8_t         res2 : 7;
746         uint8_t         fence : 1;
747 } OS_ATTRIBUTE_PACKED pqi_raid_tmf_req_t;
748 
749 typedef struct pqi_aio_tmf_req {
750 	iu_header_t     header;
751 	uint16_t        resp_qid;
752 	uint8_t         work_area[2];
753 	uint16_t        req_id;
754 	uint16_t        res1;
755 	uint32_t        nexus;
756 	uint8_t         lun[8];
757 	uint32_t        req_id_to_manage;
758 	uint8_t         tmf;
759 	uint8_t         res2 : 7;
760 	uint8_t         fence : 1;
761 	uint16_t        error_idx;
762 }OS_ATTRIBUTE_PACKED pqi_aio_tmf_req_t;
763 
764 typedef struct pqi_tmf_resp {
765         iu_header_t     header;
766         uint16_t        resp_qid;
767         uint8_t         work_area[2];
768         uint16_t        req_id;
769         uint16_t        nexus;
770         uint8_t         add_resp_info[3];
771         uint8_t         resp_code;
772 }pqi_tmf_resp_t;
773 
774 
775 struct pqi_io_response {
776 	iu_header_t	header;
777 	uint16_t	queue_id;
778 	uint8_t		work_area[2];
779 	uint16_t	request_id;
780 	uint16_t	error_index;
781 	uint8_t		reserved[4];
782 }OS_ATTRIBUTE_PACKED;
783 
784 
785 struct pqi_enc_info {
786 	uint16_t	data_enc_key_index;
787 	uint32_t	encrypt_tweak_lower;
788 	uint32_t	encrypt_tweak_upper;
789 };
790 
791 
792 typedef struct pqi_scsi_device {
793 	device_type_t	devtype;		/* as reported by INQUIRY command */
794 	uint8_t	device_type;		/* as reported by
795 					   BMIC_IDENTIFY_PHYSICAL_DEVICE - only
796 					   valid for devtype = TYPE_DISK */
797 	int	bus;
798 	int	target;
799 	int	lun;
800 	uint8_t flags;
801 	uint8_t	scsi3addr[8];
802 	uint64_t	wwid;
803 	uint8_t	is_physical_device : 1;
804 	uint8_t	is_external_raid_device : 1;
805 	uint8_t target_lun_valid : 1;
806 	uint8_t	expose_device : 1;
807 	uint8_t	no_uld_attach : 1;
808 	uint8_t	is_obdr_device : 1;
809 	uint8_t aio_enabled : 1;
810 	uint8_t	device_gone : 1;
811 	uint8_t	new_device : 1;
812 	uint8_t	volume_offline : 1;
813 	uint8_t scsi_rescan : 1;
814 	uint8_t	vendor[8];		/* bytes 8-15 of inquiry data */
815 	uint8_t	model[16];		/* bytes 16-31 of inquiry data */
816 	uint64_t	sas_address;
817 	uint8_t	raid_level;
818 	uint16_t	queue_depth;		/* max. queue_depth for this device */
819 	uint16_t	advertised_queue_depth;
820 	uint32_t	ioaccel_handle;
821 	uint8_t	volume_status;
822 	uint8_t	active_path_index;
823 	uint8_t	path_map;
824 	uint8_t	bay;
825 	uint8_t	box[8];
826 	uint16_t	phys_connector[8];
827 	int	offload_config;		/* I/O accel RAID offload configured */
828 	int	offload_enabled;	/* I/O accel RAID offload enabled */
829 	int	offload_enabled_pending;
830 	int	offload_to_mirror;	/* Send next I/O accelerator RAID
831 					   offload request to mirror drive. */
832 	struct raid_map *raid_map;	/* I/O accelerator RAID map */
833 
834 	int 	reset_in_progress;
835 	int 	logical_unit_number;
836 	os_dev_info_t	*dip;			/*os specific scsi device information*/
837 	boolean_t	invalid;
838 	boolean_t	path_destroyed;
839 	boolean_t	firmware_queue_depth_set;
840 	OS_ATOMIC64_T   active_requests;
841 }pqi_scsi_dev_t;
842 
843 typedef struct pqisrc_softstate pqisrc_softstate_t;
844 typedef struct pqi_firmware_feature pqi_firmware_feature_t;
845 typedef void (*feature_status_fn)(pqisrc_softstate_t *softs,
846 	pqi_firmware_feature_t *firmware_feature);
847 
848 struct pqi_firmware_feature {
849 	char			*feature_name;
850 	unsigned int		feature_bit;
851 	boolean_t		supported;
852 	boolean_t		enabled;
853 	feature_status_fn	feature_status;
854 };
855 
856 struct pqi_conf_table_firmware_features {
857 	struct		pqi_conf_table_section_header header;
858 	uint16_t	num_elements;
859 	uint8_t		features_supported[];
860 };
861 
862 struct pqi_conf_table_section_info {
863 	struct 		pqisrc_softstate *softs;
864 	void		*section;
865 	uint32_t	section_offset;
866 	void 		*section_addr;
867 };
868 
869 struct sense_header_scsi {		/* See SPC-3 section 4.5 */
870 	uint8_t response_code;		/* permit: 0x0, 0x70, 0x71, 0x72, 0x73 */
871 	uint8_t sense_key;
872 	uint8_t asc;
873 	uint8_t ascq;
874 	uint8_t byte4;
875 	uint8_t byte5;
876 	uint8_t byte6;
877 	uint8_t additional_length;	/* always 0 for fixed sense format */
878 }OS_ATTRIBUTE_PACKED;
879 
880 
881 
882 typedef struct report_lun_header {
883 	uint32_t list_length;
884 	uint8_t	extended_response;
885 	uint8_t	reserved[3];
886 }OS_ATTRIBUTE_PACKED reportlun_header_t;
887 
888 
889 typedef struct report_lun_ext_entry {
890 	uint8_t	lunid[8];
891 	uint64_t wwid;
892 	uint8_t	device_type;
893 	uint8_t	device_flags;
894 	uint8_t	lun_count;	/* number of LUNs in a multi-LUN device */
895 	uint8_t	redundant_paths;
896 	uint32_t ioaccel_handle;
897 }OS_ATTRIBUTE_PACKED reportlun_ext_entry_t;
898 
899 
900 typedef struct report_lun_data_ext {
901 	reportlun_header_t header;
902 	reportlun_ext_entry_t lun_entries[1];
903 }OS_ATTRIBUTE_PACKED reportlun_data_ext_t;
904 
905 typedef struct reportlun_queue_depth_entry {
906         uint8_t logical_unit_num;
907         uint8_t reserved_1:6;
908         uint8_t address:2;
909         uint8_t box_bus_num;
910         uint8_t reserved_2:6;
911         uint8_t mode:2;
912         uint8_t bus_ident;
913 
914         /* Byte 5 */
915         uint8_t queue_depth:7;
916         uint8_t multiplier:1;
917 
918         /* Byte 6 */
919         uint8_t drive_type_mix_flags;
920         uint8_t level_2_bus:6;
921         uint8_t level_2_mode:2;
922         uint8_t unused_bytes[16];
923 }OS_ATTRIBUTE_PACKED reportlun_queue_depth_entry_t;
924 
925 typedef struct reportlun_queue_depth_data {
926         reportlun_header_t header;
927 	reportlun_queue_depth_entry_t lun_entries[1]; /* lun list with Queue Depth values for each lun */
928 }OS_ATTRIBUTE_PACKED reportlun_queue_depth_data_t;
929 
930 typedef struct raidmap_data {
931 	uint32_t ioaccel_handle;
932 	uint8_t	xor_mult[2];
933 	uint8_t	reserved[2];
934 }OS_ATTRIBUTE_PACKED raidmap_data_t;
935 
936 typedef struct raid_map {
937 	uint32_t	structure_size;		/* size of entire structure in bytes */
938 	uint32_t	volume_blk_size;	/* bytes / block in the volume */
939 	uint64_t	volume_blk_cnt;		/* logical blocks on the volume */
940 	uint8_t	phys_blk_shift;		/* shift factor to convert between
941 					   units of logical blocks and physical
942 					   disk blocks */
943 	uint8_t	parity_rotation_shift;	/* shift factor to convert between units
944 					   of logical stripes and physical
945 					   stripes */
946 	uint16_t	strip_size;		/* blocks used on each disk / stripe */
947 	uint64_t	disk_starting_blk;	/* first disk block used in volume */
948 	uint64_t	disk_blk_cnt;		/* disk blocks used by volume / disk */
949 	uint16_t	data_disks_per_row;	/* data disk entries / row in the map */
950 	uint16_t	metadata_disks_per_row;	/* mirror/parity disk entries / row
951 					   in the map */
952 	uint16_t	row_cnt;		/* rows in each layout map */
953 	uint16_t	layout_map_count;	/* layout maps (1 map per mirror/parity
954 					   group) */
955 	uint16_t	flags;
956 	uint16_t	data_encryption_key_index;
957 	uint8_t	reserved[16];
958 	raidmap_data_t dev_data[RAID_MAP_MAX_ENTRIES];
959 }OS_ATTRIBUTE_PACKED pqisrc_raid_map_t;
960 
961 
962 typedef struct bmic_ident_ctrl {
963 	uint8_t		conf_ld_count;
964 	uint32_t	conf_sign;
965 	uint8_t		fw_version[4];
966 	uint8_t		rom_fw_rev[4];
967 	uint8_t		hw_rev;
968 	uint8_t		reserved[140];
969 	uint16_t	extended_lun_count;
970 	uint8_t		reserved1[34];
971 	uint16_t	fw_build_number;
972 	uint8_t		reserved2[100];
973 	uint8_t		ctrl_mode;
974 	uint8_t		reserved3[32];
975 }OS_ATTRIBUTE_PACKED bmic_ident_ctrl_t;
976 
977 typedef struct bmic_identify_physical_device {
978 	uint8_t	scsi_bus;		/* SCSI Bus number on controller */
979 	uint8_t	scsi_id;		/* SCSI ID on this bus */
980 	uint16_t	block_size;		/* sector size in bytes */
981 	uint32_t	total_blocks;		/* number for sectors on drive */
982 	uint32_t	reserved_blocks;	/* controller reserved (RIS) */
983 	uint8_t	model[40];		/* Physical Drive Model */
984 	uint8_t	serial_number[40];	/* Drive Serial Number */
985 	uint8_t	firmware_revision[8];	/* drive firmware revision */
986 	uint8_t	scsi_inquiry_bits;	/* inquiry byte 7 bits */
987 	uint8_t	compaq_drive_stamp;	/* 0 means drive not stamped */
988 	uint8_t	last_failure_reason;
989 	uint8_t	flags;
990 	uint8_t	more_flags;
991 	uint8_t	scsi_lun;		/* SCSI LUN for phys drive */
992 	uint8_t	yet_more_flags;
993 	uint8_t	even_more_flags;
994 	uint32_t	spi_speed_rules;
995 	uint8_t	phys_connector[2];	/* connector number on controller */
996 	uint8_t	phys_box_on_bus;	/* phys enclosure this drive resides */
997 	uint8_t	phys_bay_in_box;	/* phys drv bay this drive resides */
998 	uint32_t	rpm;			/* drive rotational speed in RPM */
999 	uint8_t	device_type;		/* type of drive */
1000 	uint8_t	sata_version;		/* only valid when device_type =
1001 					   BMIC_DEVICE_TYPE_SATA */
1002 	uint64_t	big_total_block_count;
1003 	uint64_t	ris_starting_lba;
1004 	uint32_t	ris_size;
1005 	uint8_t	wwid[20];
1006 	uint8_t	controller_phy_map[32];
1007 	uint16_t	phy_count;
1008 	uint8_t	phy_connected_dev_type[256];
1009 	uint8_t	phy_to_drive_bay_num[256];
1010 	uint16_t	phy_to_attached_dev_index[256];
1011 	uint8_t	box_index;
1012 	uint8_t	reserved;
1013 	uint16_t	extra_physical_drive_flags;
1014 	uint8_t	negotiated_link_rate[256];
1015 	uint8_t	phy_to_phy_map[256];
1016 	uint8_t	redundant_path_present_map;
1017 	uint8_t	redundant_path_failure_map;
1018 	uint8_t	active_path_number;
1019 	uint16_t	alternate_paths_phys_connector[8];
1020 	uint8_t	alternate_paths_phys_box_on_port[8];
1021 	uint8_t	multi_lun_device_lun_count;
1022 	uint8_t	minimum_good_fw_revision[8];
1023 	uint8_t	unique_inquiry_bytes[20];
1024 	uint8_t	current_temperature_degreesC;
1025 	uint8_t	temperature_threshold_degreesC;
1026 	uint8_t	max_temperature_degreesC;
1027 	uint8_t	logical_blocks_per_phys_block_exp;
1028 	uint16_t	current_queue_depth_limit;
1029 	uint8_t	switch_name[10];
1030 	uint16_t	switch_port;
1031 	uint8_t	alternate_paths_switch_name[40];
1032 	uint8_t	alternate_paths_switch_port[8];
1033 	uint16_t	power_on_hours;
1034 	uint16_t	percent_endurance_used;
1035 	uint8_t	drive_authentication;
1036 	uint8_t	smart_carrier_authentication;
1037 	uint8_t	smart_carrier_app_fw_version;
1038 	uint8_t	smart_carrier_bootloader_fw_version;
1039 	uint8_t	encryption_key_name[64];
1040 	uint32_t	misc_drive_flags;
1041 	uint16_t	dek_index;
1042 	uint8_t		padding[112];
1043 }OS_ATTRIBUTE_PACKED bmic_ident_physdev_t;
1044 
1045 typedef struct pqisrc_bmic_flush_cache {
1046 	uint8_t	disable_cache;
1047 	uint8_t	power_action;
1048 	uint8_t	ndu_flush_cache;
1049 	uint8_t	halt_event;
1050 	uint8_t	reserved[28];
1051 } OS_ATTRIBUTE_PACKED pqisrc_bmic_flush_cache_t;
1052 
1053 /* for halt_event member of pqisrc_bmic_flush_cache_t */
1054 enum pqisrc_flush_cache_event_type {
1055 	PQISRC_NONE_CACHE_FLUSH_ONLY = 0,
1056 	PQISRC_SHUTDOWN = 1,
1057 	PQISRC_HIBERNATE = 2,
1058 	PQISRC_SUSPEND = 3,
1059 	PQISRC_RESTART = 4
1060 };
1061 
1062 struct request_container_block;
1063 typedef void (*success_callback)(struct pqisrc_softstate *, struct request_container_block *);
1064 typedef void (*error_callback)(struct pqisrc_softstate *, struct request_container_block *, uint16_t);
1065 
1066 /* Request container block */
1067 typedef struct request_container_block {
1068 	void			*req;
1069 	void			*error_info;
1070 	REQUEST_STATUS_T	status;
1071 	uint32_t		tag;
1072 	sgt_t			*sg_chain_virt;
1073 	dma_addr_t		sg_chain_dma;
1074 	uint32_t		data_dir;
1075 	pqi_scsi_dev_t		*dvp;
1076 	struct pqisrc_softstate	*softs;
1077 	success_callback	success_cmp_callback;
1078 	error_callback		error_cmp_callback;
1079 	uint8_t			*cdbp;
1080 	int			cmdlen;
1081 	uint32_t		bcount;	/* buffer size in byte */
1082 	uint32_t		ioaccel_handle;
1083 	boolean_t 		encrypt_enable;
1084 	struct pqi_enc_info 	enc_info;
1085 	ib_queue_t		*req_q;
1086 	int 			path;
1087 	int 			resp_qid;
1088 	boolean_t		req_pending;
1089 	boolean_t		timedout;
1090 	int			tm_req;
1091 	int			aio_retry;
1092 	int			cm_flags;
1093 	void			*cm_data; /* pointer to data in kernel space */
1094 	bus_dmamap_t		cm_datamap;
1095 	uint32_t		nseg;
1096 	union ccb		*cm_ccb;
1097 	sgt_t			*sgt;	/* sg table */
1098 
1099 }rcb_t;
1100 
1101 typedef struct tid_pool {
1102 	int 			tid[PQI_MAX_PHYSICALS];
1103 	int			index;
1104 }tid_pool_t;
1105 
1106 struct pqisrc_softstate {
1107 	OS_SPECIFIC_T			os_specific;
1108 	struct ioa_registers		*ioa_reg;
1109 	struct pqi_registers		*pqi_reg;
1110 	uint8_t				*pci_mem_base_vaddr;
1111 	PCI_ACC_HANDLE_T		pci_mem_handle;
1112 	struct pqi_cap			pqi_cap;
1113 	struct pqi_pref_settings	pref_settings;
1114 	char				fw_version[11];
1115 	uint16_t			fw_build_number;
1116 	uint32_t			card;		/* index to aac_cards */
1117 	uint16_t			vendid;		/* vendor id */
1118 	uint16_t			subvendid;	/* sub vendor id */
1119 	uint16_t			devid;		/* device id */
1120 	uint16_t			subsysid;	/* sub system id */
1121 	controller_state_t		ctlr_state;
1122 	struct dma_mem			err_buf_dma_mem;
1123 	struct dma_mem			admin_queue_dma_mem;
1124 	struct dma_mem			op_ibq_dma_mem;
1125 	struct dma_mem			op_obq_dma_mem;
1126 	struct dma_mem			event_q_dma_mem;
1127 	struct dma_mem			sg_dma_desc[PQISRC_MAX_OUTSTANDING_REQ];
1128 	ib_queue_t			admin_ib_queue;
1129 	ob_queue_t			admin_ob_queue;
1130 	ob_queue_t			event_q;
1131 	ob_queue_t			op_ob_q[PQISRC_MAX_SUPPORTED_OP_OB_Q - 1];/* 1 event queue */
1132 	ib_queue_t			op_raid_ib_q[PQISRC_MAX_SUPPORTED_OP_RAID_IB_Q];
1133 	ib_queue_t			op_aio_ib_q[PQISRC_MAX_SUPPORTED_OP_AIO_IB_Q];
1134 	uint32_t			max_outstanding_io;
1135 	uint32_t			max_io_for_scsi_ml;
1136 	uint32_t			num_op_raid_ibq;
1137 	uint32_t			num_op_aio_ibq;
1138 	uint32_t			num_op_obq;
1139 	uint32_t			num_elem_per_op_ibq;
1140 	uint32_t			num_elem_per_op_obq;
1141 	uint32_t			ibq_elem_size;
1142 	uint32_t			obq_elem_size;
1143 	pqi_dev_cap_t			pqi_dev_cap;
1144 	uint16_t			max_ib_iu_length_per_fw;
1145 	uint16_t			max_ib_iu_length;
1146 	unsigned			max_sg_per_iu;
1147 	uint8_t				ib_spanning_supported : 1;
1148 	uint8_t				ob_spanning_supported : 1;
1149 	pqi_event_config_t		event_config;
1150 	struct pqi_event		pending_events[PQI_NUM_SUPPORTED_EVENTS];
1151 	int				intr_type;
1152 	int				intr_count;
1153 	int				num_cpus_online;
1154 	boolean_t			share_opq_and_eventq;
1155 	rcb_t				*rcb;
1156 #ifndef LOCKFREE_STACK
1157 	pqi_taglist_t			taglist;
1158 #else
1159 	lockless_stack_t		taglist;
1160 #endif /* LOCKFREE_STACK */
1161 	boolean_t			devlist_lockcreated;
1162 	OS_LOCK_T			devlist_lock	OS_ATTRIBUTE_ALIGNED(8);
1163 	char				devlist_lock_name[LOCKNAME_SIZE];
1164 	pqi_scsi_dev_t			*device_list[PQI_MAX_DEVICES][PQI_MAX_MULTILUN];
1165 	OS_SEMA_LOCK_T			scan_lock;
1166 	uint8_t				lun_count[PQI_MAX_DEVICES];
1167 	uint64_t     		target_sas_addr[PQI_MAX_EXT_TARGETS];
1168 	uint64_t			prev_heartbeat_count;
1169 	uint64_t			*heartbeat_counter_abs_addr;
1170 	uint64_t			heartbeat_counter_off;
1171 	uint8_t			*fw_features_section_abs_addr;
1172 	uint64_t			fw_features_section_off;
1173 	uint32_t			bus_id;
1174 	uint32_t			device_id;
1175 	uint32_t			func_id;
1176 	char 				*os_name;
1177 	boolean_t			ctrl_online;
1178 	uint8_t				pqi_reset_quiesce_allowed : 1;
1179 	boolean_t 			ctrl_in_pqi_mode;
1180 	tid_pool_t			tid_pool;
1181 	uint32_t			adapterQDepth;
1182 	uint32_t 			dma_mem_consumed;
1183 	boolean_t			timeout_in_passthrough;
1184 	boolean_t			timeout_in_tmf;
1185 };
1186 
1187 typedef struct vpd_logical_volume_status {
1188 	uint8_t         peripheral_info;
1189 	uint8_t         page_code;
1190 	uint8_t         reserved;
1191 	uint8_t         page_length;
1192 	uint8_t         volume_status;
1193 	uint8_t         reserved2[3];
1194 	uint32_t        flags;
1195 }vpd_volume_status;
1196 
1197 #endif
1198