2 * Copyright 2016-2021 Microchip Technology, Inc. and/or its subsidiaries.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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
28 #ifndef _PQI_STRUCTURES_H
29 #define _PQI_STRUCTURES_H
31 struct bmic_host_wellness_driver_version {
33 uint8_t driver_version_tag[2];
34 uint16_t driver_version_length;
35 char driver_version[32];
40 struct bmic_host_wellness_time {
52 uint8_t dont_write_tag[2];
57 /* As per PQI Spec pqi-2r00a , 6.2.2. */
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;
69 /* admin q parameter reg , table 36 */
70 struct admin_q_param {
71 uint8_t num_iq_elements;
72 uint8_t num_oq_elements;
77 struct pqi_registers {
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;
85 uint32_t pqi_dev_status;
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;
97 uint64_t error_details;
99 uint32_t power_action;
101 }OS_ATTRIBUTE_PACKED;
104 * IOA controller registers
105 * Mapped in PCIe BAR 0.
108 struct ioa_registers {
110 uint32_t host_to_ioa_db_mask_clr; /* 18h */
112 uint32_t host_to_ioa_db; /* 20h */
114 uint32_t host_to_ioa_db_clr; /* 28h */
116 uint32_t ioa_to_host_glob_int_mask; /* 34h */
118 uint32_t ioa_to_host_db; /* 9Ch */
119 uint32_t ioa_to_host_db_clr; /* A0h */
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 */
128 uint32_t scratchpad4; /* C8h */
129 uint8_t res8[0xf34]; /* 0xC8 + 4 + 0xf34 = 1000h */
130 uint32_t mb[8]; /* 1000h */
131 }OS_ATTRIBUTE_PACKED;
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;
140 /* pqi capability by sis interface */
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;
149 struct pqi_conf_table {
150 uint8_t sign[8]; /* "CFGTABLE" */
151 uint32_t first_section_off;
154 struct pqi_conf_table_section_header {
156 uint16_t next_section_off;
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;
167 struct pqi_conf_table_debug {
168 struct pqi_conf_table_section_header header;
172 struct pqi_conf_table_heartbeat {
173 struct pqi_conf_table_section_header header;
174 uint32_t heartbeat_counter;
177 typedef union pqi_reset_reg {
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;
188 /* Memory descriptor for DMA memory allocation */
189 typedef struct dma_mem {
195 bus_dma_tag_t dma_tag;
196 bus_dmamap_t dma_map;
199 /* Lock should be 8 byte aligned */
201 #ifndef LOCKFREE_STACK
203 typedef struct pqi_taglist {
208 uint32_t *elem_array;
209 boolean_t lockcreated;
210 char lockname[LOCKNAME_SIZE];
211 OS_LOCK_T lock OS_ATTRIBUTE_ALIGNED(8);
214 #else /* LOCKFREE_STACK */
218 uint32_t seq_no; /* To avoid aba problem */
219 uint32_t index; /* Index at the top of the stack */
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);
231 #endif /* LOCKFREE_STACK */
234 * PQI SGL descriptor layouts.
237 * SGL (Scatter Gather List) descriptor Codes
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
247 typedef struct sgl_descriptor
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 */
257 typedef struct iu_header
260 uint8_t comp_feature;
262 }OS_ATTRIBUTE_PACKED iu_header_t;
265 typedef struct general_admin_request /* REPORT_PQI_DEVICE_CAPABILITY, REPORT_MANUFACTURER_INFO, REPORT_OPERATIONAL_IQ, REPORT_OPERATIONAL_OQ all same layout. */
267 iu_header_t header; /* !< Bytes 0-3. */
270 uint16_t req_id; /* !< Bytes 8-9. request identifier */
271 uint8_t fn_code; /* !< Byte 10. which administrator function */
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;
283 uint64_t elem_arr_addr;
290 uint32_t vend_specific;
291 } OS_ATTRIBUTE_PACKED create_op_iq;
297 uint64_t elem_arr_addr;
303 uint16_t intr_msg_num;
304 uint16_t coales_count;
305 uint32_t min_coales_time;
306 uint32_t max_coales_time;
308 uint32_t vend_specific;
309 } OS_ATTRIBUTE_PACKED create_op_oq;
315 } OS_ATTRIBUTE_PACKED delete_op_queue;
321 uint32_t vend_specific;
322 } OS_ATTRIBUTE_PACKED change_op_iq_prop;
324 } OS_ATTRIBUTE_PACKED req_type;
326 }OS_ATTRIBUTE_PACKED gen_adm_req_iu_t;
329 typedef struct general_admin_response {
338 uint8_t status_desc[4];
341 } OS_ATTRIBUTE_PACKED create_op_iq;
344 uint8_t status_desc[4];
347 } OS_ATTRIBUTE_PACKED create_op_oq;
348 } OS_ATTRIBUTE_PACKED resp_type;
349 } OS_ATTRIBUTE_PACKED gen_adm_resp_iu_t ;
351 /*report and set Event config IU*/
353 typedef struct pqi_event_config_request {
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 */
360 uint16_t reserved; /* Report event config iu */
361 uint16_t global_event_oq_id; /* Set event config iu */
363 uint32_t buffer_length;
365 }pqi_event_config_request_t;
367 typedef struct pqi_set_event_config_request {
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 */
373 uint16_t global_event_oq_id;
374 uint32_t buffer_length;
376 }pqi_set_event_config_request_t;
379 /* Report/Set event config data-in/data-out buffer structure */
381 #define PQI_MAX_EVENT_DESCRIPTORS 255
383 struct pqi_event_descriptor {
389 typedef struct pqi_event_config {
391 uint8_t num_event_descriptors;
393 struct pqi_event_descriptor descriptors[PQI_MAX_EVENT_DESCRIPTORS];
396 /*management response IUs */
397 typedef struct pqi_management_response{
400 uint8_t work_area[2];
404 uint64_t result_data;
405 }pqi_management_response_t;
406 /*Event response IU*/
407 typedef struct pqi_event_response {
410 uint8_t work_area[2];
412 uint8_t reserved2 : 7;
413 uint8_t request_acknowledge : 1;
415 uint32_t additional_event_id;
417 }pqi_event_response_t;
419 /*event acknowledge IU*/
420 typedef struct pqi_event_acknowledge_request {
423 uint8_t work_area[2];
427 uint32_t additional_event_id;
428 }pqi_event_acknowledge_request_t;
434 uint32_t additional_event_id;
437 typedef struct pqi_vendor_general_request {
439 uint16_t response_queue_id;
440 uint8_t work_area[2];
442 uint16_t function_code;
445 uint16_t first_section;
446 uint16_t last_section;
447 uint8_t reserved1[48];
448 } OS_ATTRIBUTE_PACKED config_table_update;
451 uint64_t buffer_address;
452 uint32_t buffer_length;
453 uint8_t reserved2[40];
454 } OS_ATTRIBUTE_PACKED ofa_memory_allocation;
456 } OS_ATTRIBUTE_PACKED pqi_vendor_general_request_t;
458 typedef struct pqi_vendor_general_response {
461 uint8_t work_area[2];
463 uint16_t function_code;
465 uint8_t reserved2[2];
466 } OS_ATTRIBUTE_PACKED pqi_vendor_general_response_t;
468 typedef struct op_q_params
474 uint16_t int_msg_num;
476 } OS_ATTRIBUTE_PACKED op_q_params;
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;
496 /* Generic Sense Data Descriptor (Table 29 in SPC5) */
497 typedef struct descriptor_entry
499 uint8_t desc_type; // Byte 9/0
500 uint8_t desc_type_length; // Byte 10/1
503 /* Sense data descriptor specific */
506 /* Information (Type 0) (Table 31 is SPC5) */
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;
515 } OS_ATTRIBUTE_PACKED descriptor_entry_t;
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+
529 } OS_ATTRIBUTE_PACKED sense_data_descriptor_t;
531 typedef union sense_data_u
533 sense_data_fixed_t fixed_format;
534 sense_data_descriptor_t descriptor_format;
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. */
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. */
558 }OS_ATTRIBUTE_PACKED raid_path_error_info_elem_t;
560 #define PQI_ERROR_BUFFER_ELEMENT_LENGTH sizeof(raid_path_error_info_elem_t)
562 typedef enum error_data_present
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;
569 typedef struct aio_path_error_info_elem
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;
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;
592 typedef struct ib_queue {
596 char *array_virt_addr;
597 dma_addr_t array_dma_addr;
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;
604 boolean_t lockcreated;
605 char lockname[LOCKNAME_SIZE];
606 OS_PQILOCK_T lock OS_ATTRIBUTE_ALIGNED(8);
609 typedef struct ob_queue {
613 uint32_t intr_msg_num;
614 char *array_virt_addr;
615 dma_addr_t array_dma_addr;
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;
624 typedef struct pqisrc_sg_desc{
631 typedef struct pqi_iu_layer_desc {
632 uint8_t ib_spanning_supported : 1;
635 uint16_t max_ib_iu_len;
636 uint8_t ob_spanning_supported : 1;
639 uint16_t max_ob_iu_len;
640 }OS_ATTRIBUTE_PACKED pqi_iu_layer_desc_t;
643 /* Response IU data */
644 typedef struct pqi_device_capabilities {
647 uint8_t ibq_arb_priority_support_bitmask;
651 uint8_t max_arb_burst : 3;
655 uint8_t iq_freeze : 1;
658 uint16_t max_iq_elements;
660 uint16_t max_iq_elem_len;
661 uint16_t min_iq_elem_len;
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;
669 pqi_iu_layer_desc_t iu_layer_desc[32];
670 }OS_ATTRIBUTE_PACKED pqi_dev_cap_t;
674 typedef struct pqi_aio_req {
676 uint16_t response_queue_id;
677 uint8_t work_area[2];
682 uint8_t data_dir : 2;
684 uint8_t mem_type : 1;
686 uint8_t encrypt_enable : 1;
688 uint8_t task_attr : 3;
689 uint8_t cmd_prio : 4;
691 uint16_t encrypt_key_index;
692 uint32_t encrypt_twk_low;
693 uint32_t encrypt_twk_high;
701 }OS_ATTRIBUTE_PACKED pqi_aio_req_t;
704 typedef struct pqisrc_raid_request {
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 */
711 uint32_t buffer_length;
712 uint8_t lun_number[8];
713 uint16_t protocol_spec;
714 uint8_t data_direction : 2;
716 uint8_t reserved1 : 4;
718 uint16_t error_index;
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;
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;
733 typedef struct pqi_raid_tmf_req {
736 uint8_t work_area[2];
740 uint16_t timeout_in_sec;
742 uint16_t protocol_spec;
743 uint16_t obq_id_to_manage;
744 uint16_t req_id_to_manage;
748 } OS_ATTRIBUTE_PACKED pqi_raid_tmf_req_t;
750 typedef struct pqi_aio_tmf_req {
753 uint8_t work_area[2];
758 uint32_t req_id_to_manage;
763 }OS_ATTRIBUTE_PACKED pqi_aio_tmf_req_t;
765 typedef struct pqi_tmf_resp {
768 uint8_t work_area[2];
771 uint8_t add_resp_info[3];
776 struct pqi_io_response {
779 uint8_t work_area[2];
781 uint16_t error_index;
783 }OS_ATTRIBUTE_PACKED;
786 struct pqi_enc_info {
787 uint16_t data_enc_key_index;
788 uint32_t encrypt_tweak_lower;
789 uint32_t encrypt_tweak_upper;
793 typedef struct pqi_scsi_device {
794 device_type_t devtype; /* as reported by INQUIRY commmand */
795 uint8_t device_type; /* as reported by
796 BMIC_IDENTIFY_PHYSICAL_DEVICE - only
797 valid for devtype = TYPE_DISK */
802 uint8_t scsi3addr[8];
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;
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;
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 */
835 int reset_in_progress;
836 int logical_unit_number;
837 os_dev_info_t *dip; /*os specific scsi device information*/
839 boolean_t path_destroyed;
840 boolean_t firmware_queue_depth_set;
841 OS_ATOMIC64_T active_requests;
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);
849 struct pqi_firmware_feature {
851 unsigned int feature_bit;
854 feature_status_fn feature_status;
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[];
863 struct pqi_conf_table_section_info {
864 struct pqisrc_softstate *softs;
866 uint32_t section_offset;
870 struct sense_header_scsi { /* See SPC-3 section 4.5 */
871 uint8_t response_code; /* permit: 0x0, 0x70, 0x71, 0x72, 0x73 */
878 uint8_t additional_length; /* always 0 for fixed sense format */
879 }OS_ATTRIBUTE_PACKED;
883 typedef struct report_lun_header {
884 uint32_t list_length;
885 uint8_t extended_response;
887 }OS_ATTRIBUTE_PACKED reportlun_header_t;
890 typedef struct report_lun_ext_entry {
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;
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;
906 typedef struct reportlun_queue_depth_entry {
907 uint8_t logical_unit_num;
908 uint8_t reserved_1:6;
911 uint8_t reserved_2:6;
916 uint8_t queue_depth:7;
917 uint8_t multiplier:1;
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;
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;
931 typedef struct raidmap_data {
932 uint32_t ioaccel_handle;
935 }OS_ATTRIBUTE_PACKED raidmap_data_t;
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
944 uint8_t parity_rotation_shift; /* shift factor to convert between units
945 of logical stripes and physical
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
953 uint16_t row_cnt; /* rows in each layout map */
954 uint16_t layout_map_count; /* layout maps (1 map per mirror/parity
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;
963 typedef struct bmic_ident_ctrl {
964 uint8_t conf_ld_count;
966 uint8_t fw_version[4];
967 uint8_t rom_fw_rev[4];
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];
975 uint8_t reserved3[32];
976 }OS_ATTRIBUTE_PACKED bmic_ident_ctrl_t;
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;
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;
1007 uint8_t controller_phy_map[32];
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];
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;
1043 uint8_t padding[112];
1044 }OS_ATTRIBUTE_PACKED bmic_ident_physdev_t;
1046 typedef struct pqisrc_bmic_flush_cache {
1047 uint8_t disable_cache;
1048 uint8_t power_action;
1049 uint8_t ndu_flush_cache;
1051 uint8_t reserved[28];
1052 } OS_ATTRIBUTE_PACKED pqisrc_bmic_flush_cache_t;
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,
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);
1067 /* Request container block */
1068 typedef struct request_container_block {
1071 REQUEST_STATUS_T status;
1073 sgt_t *sg_chain_virt;
1074 dma_addr_t sg_chain_dma;
1076 pqi_scsi_dev_t *dvp;
1077 struct pqisrc_softstate *softs;
1078 success_callback success_cmp_callback;
1079 error_callback error_cmp_callback;
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;
1089 boolean_t req_pending;
1094 void *cm_data; /* pointer to data in kernel space */
1095 bus_dmamap_t cm_datamap;
1098 sgt_t *sgt; /* sg table */
1102 typedef struct tid_pool {
1103 int tid[PQI_MAX_PHYSICALS];
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;
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];
1154 int num_cpus_online;
1155 boolean_t share_opq_and_eventq;
1157 #ifndef LOCKFREE_STACK
1158 pqi_taglist_t taglist;
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;
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;
1188 typedef struct vpd_logical_volume_status {
1189 uint8_t peripheral_info;
1192 uint8_t page_length;
1193 uint8_t volume_status;
1194 uint8_t reserved2[3];