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