16c223761SKevin Barnett /* 26c223761SKevin Barnett * driver for Microsemi PQI-based storage controllers 36c223761SKevin Barnett * Copyright (c) 2016 Microsemi Corporation 46c223761SKevin Barnett * Copyright (c) 2016 PMC-Sierra, Inc. 56c223761SKevin Barnett * 66c223761SKevin Barnett * This program is free software; you can redistribute it and/or modify 76c223761SKevin Barnett * it under the terms of the GNU General Public License as published by 86c223761SKevin Barnett * the Free Software Foundation; version 2 of the License. 96c223761SKevin Barnett * 106c223761SKevin Barnett * This program is distributed in the hope that it will be useful, 116c223761SKevin Barnett * but WITHOUT ANY WARRANTY; without even the implied warranty of 126c223761SKevin Barnett * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 136c223761SKevin Barnett * NON INFRINGEMENT. See the GNU General Public License for more details. 146c223761SKevin Barnett * 156c223761SKevin Barnett * Questions/Comments/Bugfixes to esc.storagedev@microsemi.com 166c223761SKevin Barnett * 176c223761SKevin Barnett */ 186c223761SKevin Barnett 196c223761SKevin Barnett #if !defined(_SMARTPQI_H) 206c223761SKevin Barnett #define _SMARTPQI_H 216c223761SKevin Barnett 226c223761SKevin Barnett #pragma pack(1) 236c223761SKevin Barnett 246c223761SKevin Barnett #define PQI_DEVICE_SIGNATURE "PQI DREG" 256c223761SKevin Barnett 266c223761SKevin Barnett /* This structure is defined by the PQI specification. */ 276c223761SKevin Barnett struct pqi_device_registers { 286c223761SKevin Barnett __le64 signature; 296c223761SKevin Barnett u8 function_and_status_code; 306c223761SKevin Barnett u8 reserved[7]; 316c223761SKevin Barnett u8 max_admin_iq_elements; 326c223761SKevin Barnett u8 max_admin_oq_elements; 336c223761SKevin Barnett u8 admin_iq_element_length; /* in 16-byte units */ 346c223761SKevin Barnett u8 admin_oq_element_length; /* in 16-byte units */ 356c223761SKevin Barnett __le16 max_reset_timeout; /* in 100-millisecond units */ 366c223761SKevin Barnett u8 reserved1[2]; 376c223761SKevin Barnett __le32 legacy_intx_status; 386c223761SKevin Barnett __le32 legacy_intx_mask_set; 396c223761SKevin Barnett __le32 legacy_intx_mask_clear; 406c223761SKevin Barnett u8 reserved2[28]; 416c223761SKevin Barnett __le32 device_status; 426c223761SKevin Barnett u8 reserved3[4]; 436c223761SKevin Barnett __le64 admin_iq_pi_offset; 446c223761SKevin Barnett __le64 admin_oq_ci_offset; 456c223761SKevin Barnett __le64 admin_iq_element_array_addr; 466c223761SKevin Barnett __le64 admin_oq_element_array_addr; 476c223761SKevin Barnett __le64 admin_iq_ci_addr; 486c223761SKevin Barnett __le64 admin_oq_pi_addr; 496c223761SKevin Barnett u8 admin_iq_num_elements; 506c223761SKevin Barnett u8 admin_oq_num_elements; 516c223761SKevin Barnett __le16 admin_queue_int_msg_num; 526c223761SKevin Barnett u8 reserved4[4]; 536c223761SKevin Barnett __le32 device_error; 546c223761SKevin Barnett u8 reserved5[4]; 556c223761SKevin Barnett __le64 error_details; 566c223761SKevin Barnett __le32 device_reset; 576c223761SKevin Barnett __le32 power_action; 586c223761SKevin Barnett u8 reserved6[104]; 596c223761SKevin Barnett }; 606c223761SKevin Barnett 616c223761SKevin Barnett /* 626c223761SKevin Barnett * controller registers 636c223761SKevin Barnett * 646c223761SKevin Barnett * These are defined by the PMC implementation. 656c223761SKevin Barnett * 666c223761SKevin Barnett * Some registers (those named sis_*) are only used when in 676c223761SKevin Barnett * legacy SIS mode before we transition the controller into 686c223761SKevin Barnett * PQI mode. There are a number of other SIS mode registers, 696c223761SKevin Barnett * but we don't use them, so only the SIS registers that we 706c223761SKevin Barnett * care about are defined here. The offsets mentioned in the 716c223761SKevin Barnett * comments are the offsets from the PCIe BAR 0. 726c223761SKevin Barnett */ 736c223761SKevin Barnett struct pqi_ctrl_registers { 746c223761SKevin Barnett u8 reserved[0x20]; 756c223761SKevin Barnett __le32 sis_host_to_ctrl_doorbell; /* 20h */ 766c223761SKevin Barnett u8 reserved1[0x34 - (0x20 + sizeof(__le32))]; 776c223761SKevin Barnett __le32 sis_interrupt_mask; /* 34h */ 786c223761SKevin Barnett u8 reserved2[0x9c - (0x34 + sizeof(__le32))]; 796c223761SKevin Barnett __le32 sis_ctrl_to_host_doorbell; /* 9Ch */ 806c223761SKevin Barnett u8 reserved3[0xa0 - (0x9c + sizeof(__le32))]; 816c223761SKevin Barnett __le32 sis_ctrl_to_host_doorbell_clear; /* A0h */ 82ff6abb73SKevin Barnett u8 reserved4[0xb0 - (0xa0 + sizeof(__le32))]; 83ff6abb73SKevin Barnett __le32 sis_driver_scratch; /* B0h */ 84ff6abb73SKevin Barnett u8 reserved5[0xbc - (0xb0 + sizeof(__le32))]; 856c223761SKevin Barnett __le32 sis_firmware_status; /* BCh */ 86ff6abb73SKevin Barnett u8 reserved6[0x1000 - (0xbc + sizeof(__le32))]; 876c223761SKevin Barnett __le32 sis_mailbox[8]; /* 1000h */ 88ff6abb73SKevin Barnett u8 reserved7[0x4000 - (0x1000 + (sizeof(__le32) * 8))]; 896c223761SKevin Barnett /* 906c223761SKevin Barnett * The PQI spec states that the PQI registers should be at 916c223761SKevin Barnett * offset 0 from the PCIe BAR 0. However, we can't map 926c223761SKevin Barnett * them at offset 0 because that would break compatibility 936c223761SKevin Barnett * with the SIS registers. So we map them at offset 4000h. 946c223761SKevin Barnett */ 956c223761SKevin Barnett struct pqi_device_registers pqi_registers; /* 4000h */ 966c223761SKevin Barnett }; 976c223761SKevin Barnett 986c223761SKevin Barnett #define PQI_DEVICE_REGISTERS_OFFSET 0x4000 996c223761SKevin Barnett 1006c223761SKevin Barnett enum pqi_io_path { 1016c223761SKevin Barnett RAID_PATH = 0, 1026c223761SKevin Barnett AIO_PATH = 1 1036c223761SKevin Barnett }; 1046c223761SKevin Barnett 1056c223761SKevin Barnett struct pqi_sg_descriptor { 1066c223761SKevin Barnett __le64 address; 1076c223761SKevin Barnett __le32 length; 1086c223761SKevin Barnett __le32 flags; 1096c223761SKevin Barnett }; 1106c223761SKevin Barnett 1116c223761SKevin Barnett /* manifest constants for the flags field of pqi_sg_descriptor */ 1126c223761SKevin Barnett #define CISS_SG_LAST 0x40000000 1136c223761SKevin Barnett #define CISS_SG_CHAIN 0x80000000 1146c223761SKevin Barnett 1156c223761SKevin Barnett struct pqi_iu_header { 1166c223761SKevin Barnett u8 iu_type; 1176c223761SKevin Barnett u8 reserved; 1186c223761SKevin Barnett __le16 iu_length; /* in bytes - does not include the length */ 1196c223761SKevin Barnett /* of this header */ 1206c223761SKevin Barnett __le16 response_queue_id; /* specifies the OQ where the */ 1216c223761SKevin Barnett /* response IU is to be delivered */ 1226c223761SKevin Barnett u8 work_area[2]; /* reserved for driver use */ 1236c223761SKevin Barnett }; 1246c223761SKevin Barnett 1256c223761SKevin Barnett /* 1266c223761SKevin Barnett * According to the PQI spec, the IU header is only the first 4 bytes of our 1276c223761SKevin Barnett * pqi_iu_header structure. 1286c223761SKevin Barnett */ 1296c223761SKevin Barnett #define PQI_REQUEST_HEADER_LENGTH 4 1306c223761SKevin Barnett 1316c223761SKevin Barnett struct pqi_general_admin_request { 1326c223761SKevin Barnett struct pqi_iu_header header; 1336c223761SKevin Barnett __le16 request_id; 1346c223761SKevin Barnett u8 function_code; 1356c223761SKevin Barnett union { 1366c223761SKevin Barnett struct { 1376c223761SKevin Barnett u8 reserved[33]; 1386c223761SKevin Barnett __le32 buffer_length; 1396c223761SKevin Barnett struct pqi_sg_descriptor sg_descriptor; 1406c223761SKevin Barnett } report_device_capability; 1416c223761SKevin Barnett 1426c223761SKevin Barnett struct { 1436c223761SKevin Barnett u8 reserved; 1446c223761SKevin Barnett __le16 queue_id; 1456c223761SKevin Barnett u8 reserved1[2]; 1466c223761SKevin Barnett __le64 element_array_addr; 1476c223761SKevin Barnett __le64 ci_addr; 1486c223761SKevin Barnett __le16 num_elements; 1496c223761SKevin Barnett __le16 element_length; 1506c223761SKevin Barnett u8 queue_protocol; 1516c223761SKevin Barnett u8 reserved2[23]; 1526c223761SKevin Barnett __le32 vendor_specific; 1536c223761SKevin Barnett } create_operational_iq; 1546c223761SKevin Barnett 1556c223761SKevin Barnett struct { 1566c223761SKevin Barnett u8 reserved; 1576c223761SKevin Barnett __le16 queue_id; 1586c223761SKevin Barnett u8 reserved1[2]; 1596c223761SKevin Barnett __le64 element_array_addr; 1606c223761SKevin Barnett __le64 pi_addr; 1616c223761SKevin Barnett __le16 num_elements; 1626c223761SKevin Barnett __le16 element_length; 1636c223761SKevin Barnett u8 queue_protocol; 1646c223761SKevin Barnett u8 reserved2[3]; 1656c223761SKevin Barnett __le16 int_msg_num; 1666c223761SKevin Barnett __le16 coalescing_count; 1676c223761SKevin Barnett __le32 min_coalescing_time; 1686c223761SKevin Barnett __le32 max_coalescing_time; 1696c223761SKevin Barnett u8 reserved3[8]; 1706c223761SKevin Barnett __le32 vendor_specific; 1716c223761SKevin Barnett } create_operational_oq; 1726c223761SKevin Barnett 1736c223761SKevin Barnett struct { 1746c223761SKevin Barnett u8 reserved; 1756c223761SKevin Barnett __le16 queue_id; 1766c223761SKevin Barnett u8 reserved1[50]; 1776c223761SKevin Barnett } delete_operational_queue; 1786c223761SKevin Barnett 1796c223761SKevin Barnett struct { 1806c223761SKevin Barnett u8 reserved; 1816c223761SKevin Barnett __le16 queue_id; 1826c223761SKevin Barnett u8 reserved1[46]; 1836c223761SKevin Barnett __le32 vendor_specific; 1846c223761SKevin Barnett } change_operational_iq_properties; 1856c223761SKevin Barnett 1866c223761SKevin Barnett } data; 1876c223761SKevin Barnett }; 1886c223761SKevin Barnett 1896c223761SKevin Barnett struct pqi_general_admin_response { 1906c223761SKevin Barnett struct pqi_iu_header header; 1916c223761SKevin Barnett __le16 request_id; 1926c223761SKevin Barnett u8 function_code; 1936c223761SKevin Barnett u8 status; 1946c223761SKevin Barnett union { 1956c223761SKevin Barnett struct { 1966c223761SKevin Barnett u8 status_descriptor[4]; 1976c223761SKevin Barnett __le64 iq_pi_offset; 1986c223761SKevin Barnett u8 reserved[40]; 1996c223761SKevin Barnett } create_operational_iq; 2006c223761SKevin Barnett 2016c223761SKevin Barnett struct { 2026c223761SKevin Barnett u8 status_descriptor[4]; 2036c223761SKevin Barnett __le64 oq_ci_offset; 2046c223761SKevin Barnett u8 reserved[40]; 2056c223761SKevin Barnett } create_operational_oq; 2066c223761SKevin Barnett } data; 2076c223761SKevin Barnett }; 2086c223761SKevin Barnett 2096c223761SKevin Barnett struct pqi_iu_layer_descriptor { 2106c223761SKevin Barnett u8 inbound_spanning_supported : 1; 2116c223761SKevin Barnett u8 reserved : 7; 2126c223761SKevin Barnett u8 reserved1[5]; 2136c223761SKevin Barnett __le16 max_inbound_iu_length; 2146c223761SKevin Barnett u8 outbound_spanning_supported : 1; 2156c223761SKevin Barnett u8 reserved2 : 7; 2166c223761SKevin Barnett u8 reserved3[5]; 2176c223761SKevin Barnett __le16 max_outbound_iu_length; 2186c223761SKevin Barnett }; 2196c223761SKevin Barnett 2206c223761SKevin Barnett struct pqi_device_capability { 2216c223761SKevin Barnett __le16 data_length; 2226c223761SKevin Barnett u8 reserved[6]; 2236c223761SKevin Barnett u8 iq_arbitration_priority_support_bitmask; 2246c223761SKevin Barnett u8 maximum_aw_a; 2256c223761SKevin Barnett u8 maximum_aw_b; 2266c223761SKevin Barnett u8 maximum_aw_c; 2276c223761SKevin Barnett u8 max_arbitration_burst : 3; 2286c223761SKevin Barnett u8 reserved1 : 4; 2296c223761SKevin Barnett u8 iqa : 1; 2306c223761SKevin Barnett u8 reserved2[2]; 2316c223761SKevin Barnett u8 iq_freeze : 1; 2326c223761SKevin Barnett u8 reserved3 : 7; 2336c223761SKevin Barnett __le16 max_inbound_queues; 2346c223761SKevin Barnett __le16 max_elements_per_iq; 2356c223761SKevin Barnett u8 reserved4[4]; 2366c223761SKevin Barnett __le16 max_iq_element_length; 2376c223761SKevin Barnett __le16 min_iq_element_length; 2386c223761SKevin Barnett u8 reserved5[2]; 2396c223761SKevin Barnett __le16 max_outbound_queues; 2406c223761SKevin Barnett __le16 max_elements_per_oq; 2416c223761SKevin Barnett __le16 intr_coalescing_time_granularity; 2426c223761SKevin Barnett __le16 max_oq_element_length; 2436c223761SKevin Barnett __le16 min_oq_element_length; 2446c223761SKevin Barnett u8 reserved6[24]; 2456c223761SKevin Barnett struct pqi_iu_layer_descriptor iu_layer_descriptors[32]; 2466c223761SKevin Barnett }; 2476c223761SKevin Barnett 2486c223761SKevin Barnett #define PQI_MAX_EMBEDDED_SG_DESCRIPTORS 4 2496c223761SKevin Barnett 2506c223761SKevin Barnett struct pqi_raid_path_request { 2516c223761SKevin Barnett struct pqi_iu_header header; 2526c223761SKevin Barnett __le16 request_id; 2536c223761SKevin Barnett __le16 nexus_id; 2546c223761SKevin Barnett __le32 buffer_length; 2556c223761SKevin Barnett u8 lun_number[8]; 2566c223761SKevin Barnett __le16 protocol_specific; 2576c223761SKevin Barnett u8 data_direction : 2; 2586c223761SKevin Barnett u8 partial : 1; 2596c223761SKevin Barnett u8 reserved1 : 4; 2606c223761SKevin Barnett u8 fence : 1; 2616c223761SKevin Barnett __le16 error_index; 2626c223761SKevin Barnett u8 reserved2; 2636c223761SKevin Barnett u8 task_attribute : 3; 2646c223761SKevin Barnett u8 command_priority : 4; 2656c223761SKevin Barnett u8 reserved3 : 1; 2666c223761SKevin Barnett u8 reserved4 : 2; 2676c223761SKevin Barnett u8 additional_cdb_bytes_usage : 3; 2686c223761SKevin Barnett u8 reserved5 : 3; 2696c223761SKevin Barnett u8 cdb[32]; 2706c223761SKevin Barnett struct pqi_sg_descriptor 2716c223761SKevin Barnett sg_descriptors[PQI_MAX_EMBEDDED_SG_DESCRIPTORS]; 2726c223761SKevin Barnett }; 2736c223761SKevin Barnett 2746c223761SKevin Barnett struct pqi_aio_path_request { 2756c223761SKevin Barnett struct pqi_iu_header header; 2766c223761SKevin Barnett __le16 request_id; 2776c223761SKevin Barnett u8 reserved1[2]; 2786c223761SKevin Barnett __le32 nexus_id; 2796c223761SKevin Barnett __le32 buffer_length; 2806c223761SKevin Barnett u8 data_direction : 2; 2816c223761SKevin Barnett u8 partial : 1; 2826c223761SKevin Barnett u8 memory_type : 1; 2836c223761SKevin Barnett u8 fence : 1; 2846c223761SKevin Barnett u8 encryption_enable : 1; 2856c223761SKevin Barnett u8 reserved2 : 2; 2866c223761SKevin Barnett u8 task_attribute : 3; 2876c223761SKevin Barnett u8 command_priority : 4; 2886c223761SKevin Barnett u8 reserved3 : 1; 2896c223761SKevin Barnett __le16 data_encryption_key_index; 2906c223761SKevin Barnett __le32 encrypt_tweak_lower; 2916c223761SKevin Barnett __le32 encrypt_tweak_upper; 2926c223761SKevin Barnett u8 cdb[16]; 2936c223761SKevin Barnett __le16 error_index; 2946c223761SKevin Barnett u8 num_sg_descriptors; 2956c223761SKevin Barnett u8 cdb_length; 2966c223761SKevin Barnett u8 lun_number[8]; 2976c223761SKevin Barnett u8 reserved4[4]; 2986c223761SKevin Barnett struct pqi_sg_descriptor 2996c223761SKevin Barnett sg_descriptors[PQI_MAX_EMBEDDED_SG_DESCRIPTORS]; 3006c223761SKevin Barnett }; 3016c223761SKevin Barnett 3026c223761SKevin Barnett struct pqi_io_response { 3036c223761SKevin Barnett struct pqi_iu_header header; 3046c223761SKevin Barnett __le16 request_id; 3056c223761SKevin Barnett __le16 error_index; 3066c223761SKevin Barnett u8 reserved2[4]; 3076c223761SKevin Barnett }; 3086c223761SKevin Barnett 3096c223761SKevin Barnett struct pqi_general_management_request { 3106c223761SKevin Barnett struct pqi_iu_header header; 3116c223761SKevin Barnett __le16 request_id; 3126c223761SKevin Barnett union { 3136c223761SKevin Barnett struct { 3146c223761SKevin Barnett u8 reserved[2]; 3156c223761SKevin Barnett __le32 buffer_length; 3166c223761SKevin Barnett struct pqi_sg_descriptor sg_descriptors[3]; 3176c223761SKevin Barnett } report_event_configuration; 3186c223761SKevin Barnett 3196c223761SKevin Barnett struct { 3206c223761SKevin Barnett __le16 global_event_oq_id; 3216c223761SKevin Barnett __le32 buffer_length; 3226c223761SKevin Barnett struct pqi_sg_descriptor sg_descriptors[3]; 3236c223761SKevin Barnett } set_event_configuration; 3246c223761SKevin Barnett } data; 3256c223761SKevin Barnett }; 3266c223761SKevin Barnett 3276c223761SKevin Barnett struct pqi_event_descriptor { 3286c223761SKevin Barnett u8 event_type; 3296c223761SKevin Barnett u8 reserved; 3306c223761SKevin Barnett __le16 oq_id; 3316c223761SKevin Barnett }; 3326c223761SKevin Barnett 3336c223761SKevin Barnett struct pqi_event_config { 3346c223761SKevin Barnett u8 reserved[2]; 3356c223761SKevin Barnett u8 num_event_descriptors; 3366c223761SKevin Barnett u8 reserved1; 3376c223761SKevin Barnett struct pqi_event_descriptor descriptors[1]; 3386c223761SKevin Barnett }; 3396c223761SKevin Barnett 3406c223761SKevin Barnett #define PQI_MAX_EVENT_DESCRIPTORS 255 3416c223761SKevin Barnett 3426c223761SKevin Barnett struct pqi_event_response { 3436c223761SKevin Barnett struct pqi_iu_header header; 3446c223761SKevin Barnett u8 event_type; 3456c223761SKevin Barnett u8 reserved2 : 7; 3466c223761SKevin Barnett u8 request_acknowlege : 1; 3476c223761SKevin Barnett __le16 event_id; 3486c223761SKevin Barnett __le32 additional_event_id; 3496c223761SKevin Barnett u8 data[16]; 3506c223761SKevin Barnett }; 3516c223761SKevin Barnett 3526c223761SKevin Barnett struct pqi_event_acknowledge_request { 3536c223761SKevin Barnett struct pqi_iu_header header; 3546c223761SKevin Barnett u8 event_type; 3556c223761SKevin Barnett u8 reserved2; 3566c223761SKevin Barnett __le16 event_id; 3576c223761SKevin Barnett __le32 additional_event_id; 3586c223761SKevin Barnett }; 3596c223761SKevin Barnett 3606c223761SKevin Barnett struct pqi_task_management_request { 3616c223761SKevin Barnett struct pqi_iu_header header; 3626c223761SKevin Barnett __le16 request_id; 3636c223761SKevin Barnett __le16 nexus_id; 3646c223761SKevin Barnett u8 reserved[4]; 3656c223761SKevin Barnett u8 lun_number[8]; 3666c223761SKevin Barnett __le16 protocol_specific; 3676c223761SKevin Barnett __le16 outbound_queue_id_to_manage; 3686c223761SKevin Barnett __le16 request_id_to_manage; 3696c223761SKevin Barnett u8 task_management_function; 3706c223761SKevin Barnett u8 reserved2 : 7; 3716c223761SKevin Barnett u8 fence : 1; 3726c223761SKevin Barnett }; 3736c223761SKevin Barnett 3746c223761SKevin Barnett #define SOP_TASK_MANAGEMENT_LUN_RESET 0x8 3756c223761SKevin Barnett 3766c223761SKevin Barnett struct pqi_task_management_response { 3776c223761SKevin Barnett struct pqi_iu_header header; 3786c223761SKevin Barnett __le16 request_id; 3796c223761SKevin Barnett __le16 nexus_id; 3806c223761SKevin Barnett u8 additional_response_info[3]; 3816c223761SKevin Barnett u8 response_code; 3826c223761SKevin Barnett }; 3836c223761SKevin Barnett 3846c223761SKevin Barnett struct pqi_aio_error_info { 3856c223761SKevin Barnett u8 status; 3866c223761SKevin Barnett u8 service_response; 3876c223761SKevin Barnett u8 data_present; 3886c223761SKevin Barnett u8 reserved; 3896c223761SKevin Barnett __le32 residual_count; 3906c223761SKevin Barnett __le16 data_length; 3916c223761SKevin Barnett __le16 reserved1; 3926c223761SKevin Barnett u8 data[256]; 3936c223761SKevin Barnett }; 3946c223761SKevin Barnett 3956c223761SKevin Barnett struct pqi_raid_error_info { 3966c223761SKevin Barnett u8 data_in_result; 3976c223761SKevin Barnett u8 data_out_result; 3986c223761SKevin Barnett u8 reserved[3]; 3996c223761SKevin Barnett u8 status; 4006c223761SKevin Barnett __le16 status_qualifier; 4016c223761SKevin Barnett __le16 sense_data_length; 4026c223761SKevin Barnett __le16 response_data_length; 4036c223761SKevin Barnett __le32 data_in_transferred; 4046c223761SKevin Barnett __le32 data_out_transferred; 4056c223761SKevin Barnett u8 data[256]; 4066c223761SKevin Barnett }; 4076c223761SKevin Barnett 4086c223761SKevin Barnett #define PQI_REQUEST_IU_TASK_MANAGEMENT 0x13 4096c223761SKevin Barnett #define PQI_REQUEST_IU_RAID_PATH_IO 0x14 4106c223761SKevin Barnett #define PQI_REQUEST_IU_AIO_PATH_IO 0x15 4116c223761SKevin Barnett #define PQI_REQUEST_IU_GENERAL_ADMIN 0x60 4126c223761SKevin Barnett #define PQI_REQUEST_IU_REPORT_VENDOR_EVENT_CONFIG 0x72 4136c223761SKevin Barnett #define PQI_REQUEST_IU_SET_VENDOR_EVENT_CONFIG 0x73 4146c223761SKevin Barnett #define PQI_REQUEST_IU_ACKNOWLEDGE_VENDOR_EVENT 0xf6 4156c223761SKevin Barnett 4166c223761SKevin Barnett #define PQI_RESPONSE_IU_GENERAL_MANAGEMENT 0x81 4176c223761SKevin Barnett #define PQI_RESPONSE_IU_TASK_MANAGEMENT 0x93 4186c223761SKevin Barnett #define PQI_RESPONSE_IU_GENERAL_ADMIN 0xe0 4196c223761SKevin Barnett #define PQI_RESPONSE_IU_RAID_PATH_IO_SUCCESS 0xf0 4206c223761SKevin Barnett #define PQI_RESPONSE_IU_AIO_PATH_IO_SUCCESS 0xf1 4216c223761SKevin Barnett #define PQI_RESPONSE_IU_RAID_PATH_IO_ERROR 0xf2 4226c223761SKevin Barnett #define PQI_RESPONSE_IU_AIO_PATH_IO_ERROR 0xf3 4236c223761SKevin Barnett #define PQI_RESPONSE_IU_AIO_PATH_DISABLED 0xf4 4246c223761SKevin Barnett #define PQI_RESPONSE_IU_VENDOR_EVENT 0xf5 4256c223761SKevin Barnett 4266c223761SKevin Barnett #define PQI_GENERAL_ADMIN_FUNCTION_REPORT_DEVICE_CAPABILITY 0x0 4276c223761SKevin Barnett #define PQI_GENERAL_ADMIN_FUNCTION_CREATE_IQ 0x10 4286c223761SKevin Barnett #define PQI_GENERAL_ADMIN_FUNCTION_CREATE_OQ 0x11 4296c223761SKevin Barnett #define PQI_GENERAL_ADMIN_FUNCTION_DELETE_IQ 0x12 4306c223761SKevin Barnett #define PQI_GENERAL_ADMIN_FUNCTION_DELETE_OQ 0x13 4316c223761SKevin Barnett #define PQI_GENERAL_ADMIN_FUNCTION_CHANGE_IQ_PROPERTY 0x14 4326c223761SKevin Barnett 4336c223761SKevin Barnett #define PQI_GENERAL_ADMIN_STATUS_SUCCESS 0x0 4346c223761SKevin Barnett 4356c223761SKevin Barnett #define PQI_IQ_PROPERTY_IS_AIO_QUEUE 0x1 4366c223761SKevin Barnett 4376c223761SKevin Barnett #define PQI_GENERAL_ADMIN_IU_LENGTH 0x3c 4386c223761SKevin Barnett #define PQI_PROTOCOL_SOP 0x0 4396c223761SKevin Barnett 4406c223761SKevin Barnett #define PQI_DATA_IN_OUT_GOOD 0x0 4416c223761SKevin Barnett #define PQI_DATA_IN_OUT_UNDERFLOW 0x1 4426c223761SKevin Barnett #define PQI_DATA_IN_OUT_BUFFER_ERROR 0x40 4436c223761SKevin Barnett #define PQI_DATA_IN_OUT_BUFFER_OVERFLOW 0x41 4446c223761SKevin Barnett #define PQI_DATA_IN_OUT_BUFFER_OVERFLOW_DESCRIPTOR_AREA 0x42 4456c223761SKevin Barnett #define PQI_DATA_IN_OUT_BUFFER_OVERFLOW_BRIDGE 0x43 4466c223761SKevin Barnett #define PQI_DATA_IN_OUT_PCIE_FABRIC_ERROR 0x60 4476c223761SKevin Barnett #define PQI_DATA_IN_OUT_PCIE_COMPLETION_TIMEOUT 0x61 4486c223761SKevin Barnett #define PQI_DATA_IN_OUT_PCIE_COMPLETER_ABORT_RECEIVED 0x62 4496c223761SKevin Barnett #define PQI_DATA_IN_OUT_PCIE_UNSUPPORTED_REQUEST_RECEIVED 0x63 4506c223761SKevin Barnett #define PQI_DATA_IN_OUT_PCIE_ECRC_CHECK_FAILED 0x64 4516c223761SKevin Barnett #define PQI_DATA_IN_OUT_PCIE_UNSUPPORTED_REQUEST 0x65 4526c223761SKevin Barnett #define PQI_DATA_IN_OUT_PCIE_ACS_VIOLATION 0x66 4536c223761SKevin Barnett #define PQI_DATA_IN_OUT_PCIE_TLP_PREFIX_BLOCKED 0x67 4546c223761SKevin Barnett #define PQI_DATA_IN_OUT_PCIE_POISONED_MEMORY_READ 0x6F 4556c223761SKevin Barnett #define PQI_DATA_IN_OUT_ERROR 0xf0 4566c223761SKevin Barnett #define PQI_DATA_IN_OUT_PROTOCOL_ERROR 0xf1 4576c223761SKevin Barnett #define PQI_DATA_IN_OUT_HARDWARE_ERROR 0xf2 4586c223761SKevin Barnett #define PQI_DATA_IN_OUT_UNSOLICITED_ABORT 0xf3 4596c223761SKevin Barnett #define PQI_DATA_IN_OUT_ABORTED 0xf4 4606c223761SKevin Barnett #define PQI_DATA_IN_OUT_TIMEOUT 0xf5 4616c223761SKevin Barnett 4626c223761SKevin Barnett #define CISS_CMD_STATUS_SUCCESS 0x0 4636c223761SKevin Barnett #define CISS_CMD_STATUS_TARGET_STATUS 0x1 4646c223761SKevin Barnett #define CISS_CMD_STATUS_DATA_UNDERRUN 0x2 4656c223761SKevin Barnett #define CISS_CMD_STATUS_DATA_OVERRUN 0x3 4666c223761SKevin Barnett #define CISS_CMD_STATUS_INVALID 0x4 4676c223761SKevin Barnett #define CISS_CMD_STATUS_PROTOCOL_ERROR 0x5 4686c223761SKevin Barnett #define CISS_CMD_STATUS_HARDWARE_ERROR 0x6 4696c223761SKevin Barnett #define CISS_CMD_STATUS_CONNECTION_LOST 0x7 4706c223761SKevin Barnett #define CISS_CMD_STATUS_ABORTED 0x8 4716c223761SKevin Barnett #define CISS_CMD_STATUS_ABORT_FAILED 0x9 4726c223761SKevin Barnett #define CISS_CMD_STATUS_UNSOLICITED_ABORT 0xa 4736c223761SKevin Barnett #define CISS_CMD_STATUS_TIMEOUT 0xb 4746c223761SKevin Barnett #define CISS_CMD_STATUS_UNABORTABLE 0xc 4756c223761SKevin Barnett #define CISS_CMD_STATUS_TMF 0xd 4766c223761SKevin Barnett #define CISS_CMD_STATUS_AIO_DISABLED 0xe 4776c223761SKevin Barnett 4786c223761SKevin Barnett #define PQI_NUM_EVENT_QUEUE_ELEMENTS 32 4796c223761SKevin Barnett #define PQI_EVENT_OQ_ELEMENT_LENGTH sizeof(struct pqi_event_response) 4806c223761SKevin Barnett 4816c223761SKevin Barnett #define PQI_EVENT_TYPE_HOTPLUG 0x1 4826c223761SKevin Barnett #define PQI_EVENT_TYPE_HARDWARE 0x2 4836c223761SKevin Barnett #define PQI_EVENT_TYPE_PHYSICAL_DEVICE 0x4 4846c223761SKevin Barnett #define PQI_EVENT_TYPE_LOGICAL_DEVICE 0x5 4856c223761SKevin Barnett #define PQI_EVENT_TYPE_AIO_STATE_CHANGE 0xfd 4866c223761SKevin Barnett #define PQI_EVENT_TYPE_AIO_CONFIG_CHANGE 0xfe 4876c223761SKevin Barnett #define PQI_EVENT_TYPE_HEARTBEAT 0xff 4886c223761SKevin Barnett 4896c223761SKevin Barnett #pragma pack() 4906c223761SKevin Barnett 4916c223761SKevin Barnett #define PQI_ERROR_BUFFER_ELEMENT_LENGTH \ 4926c223761SKevin Barnett sizeof(struct pqi_raid_error_info) 4936c223761SKevin Barnett 4946c223761SKevin Barnett /* these values are based on our implementation */ 4956c223761SKevin Barnett #define PQI_ADMIN_IQ_NUM_ELEMENTS 8 4966c223761SKevin Barnett #define PQI_ADMIN_OQ_NUM_ELEMENTS 20 4976c223761SKevin Barnett #define PQI_ADMIN_IQ_ELEMENT_LENGTH 64 4986c223761SKevin Barnett #define PQI_ADMIN_OQ_ELEMENT_LENGTH 64 4996c223761SKevin Barnett 5006c223761SKevin Barnett #define PQI_OPERATIONAL_IQ_ELEMENT_LENGTH 128 5016c223761SKevin Barnett #define PQI_OPERATIONAL_OQ_ELEMENT_LENGTH 16 5026c223761SKevin Barnett 5036c223761SKevin Barnett #define PQI_MIN_MSIX_VECTORS 1 5046c223761SKevin Barnett #define PQI_MAX_MSIX_VECTORS 64 5056c223761SKevin Barnett 5066c223761SKevin Barnett /* these values are defined by the PQI spec */ 5076c223761SKevin Barnett #define PQI_MAX_NUM_ELEMENTS_ADMIN_QUEUE 255 5086c223761SKevin Barnett #define PQI_MAX_NUM_ELEMENTS_OPERATIONAL_QUEUE 65535 5096c223761SKevin Barnett #define PQI_QUEUE_ELEMENT_ARRAY_ALIGNMENT 64 5106c223761SKevin Barnett #define PQI_QUEUE_ELEMENT_LENGTH_ALIGNMENT 16 5116c223761SKevin Barnett #define PQI_ADMIN_INDEX_ALIGNMENT 64 5126c223761SKevin Barnett #define PQI_OPERATIONAL_INDEX_ALIGNMENT 4 5136c223761SKevin Barnett 5146c223761SKevin Barnett #define PQI_MIN_OPERATIONAL_QUEUE_ID 1 5156c223761SKevin Barnett #define PQI_MAX_OPERATIONAL_QUEUE_ID 65535 5166c223761SKevin Barnett 5176c223761SKevin Barnett #define PQI_AIO_SERV_RESPONSE_COMPLETE 0 5186c223761SKevin Barnett #define PQI_AIO_SERV_RESPONSE_FAILURE 1 5196c223761SKevin Barnett #define PQI_AIO_SERV_RESPONSE_TMF_COMPLETE 2 5206c223761SKevin Barnett #define PQI_AIO_SERV_RESPONSE_TMF_SUCCEEDED 3 5216c223761SKevin Barnett #define PQI_AIO_SERV_RESPONSE_TMF_REJECTED 4 5226c223761SKevin Barnett #define PQI_AIO_SERV_RESPONSE_TMF_INCORRECT_LUN 5 5236c223761SKevin Barnett 5246c223761SKevin Barnett #define PQI_AIO_STATUS_IO_ERROR 0x1 5256c223761SKevin Barnett #define PQI_AIO_STATUS_IO_ABORTED 0x2 5266c223761SKevin Barnett #define PQI_AIO_STATUS_NO_PATH_TO_DEVICE 0x3 5276c223761SKevin Barnett #define PQI_AIO_STATUS_INVALID_DEVICE 0x4 5286c223761SKevin Barnett #define PQI_AIO_STATUS_AIO_PATH_DISABLED 0xe 5296c223761SKevin Barnett #define PQI_AIO_STATUS_UNDERRUN 0x51 5306c223761SKevin Barnett #define PQI_AIO_STATUS_OVERRUN 0x75 5316c223761SKevin Barnett 5326c223761SKevin Barnett typedef u32 pqi_index_t; 5336c223761SKevin Barnett 5346c223761SKevin Barnett /* SOP data direction flags */ 5356c223761SKevin Barnett #define SOP_NO_DIRECTION_FLAG 0 5366c223761SKevin Barnett #define SOP_WRITE_FLAG 1 /* host writes data to Data-Out */ 5376c223761SKevin Barnett /* buffer */ 5386c223761SKevin Barnett #define SOP_READ_FLAG 2 /* host receives data from Data-In */ 5396c223761SKevin Barnett /* buffer */ 5406c223761SKevin Barnett #define SOP_BIDIRECTIONAL 3 /* data is transferred from the */ 5416c223761SKevin Barnett /* Data-Out buffer and data is */ 5426c223761SKevin Barnett /* transferred to the Data-In buffer */ 5436c223761SKevin Barnett 5446c223761SKevin Barnett #define SOP_TASK_ATTRIBUTE_SIMPLE 0 5456c223761SKevin Barnett #define SOP_TASK_ATTRIBUTE_HEAD_OF_QUEUE 1 5466c223761SKevin Barnett #define SOP_TASK_ATTRIBUTE_ORDERED 2 5476c223761SKevin Barnett #define SOP_TASK_ATTRIBUTE_ACA 4 5486c223761SKevin Barnett 549b17f0486SKevin Barnett #define SOP_TMF_COMPLETE 0x0 550b17f0486SKevin Barnett #define SOP_TMF_FUNCTION_SUCCEEDED 0x8 5516c223761SKevin Barnett 5526c223761SKevin Barnett /* additional CDB bytes usage field codes */ 5536c223761SKevin Barnett #define SOP_ADDITIONAL_CDB_BYTES_0 0 /* 16-byte CDB */ 5546c223761SKevin Barnett #define SOP_ADDITIONAL_CDB_BYTES_4 1 /* 20-byte CDB */ 5556c223761SKevin Barnett #define SOP_ADDITIONAL_CDB_BYTES_8 2 /* 24-byte CDB */ 5566c223761SKevin Barnett #define SOP_ADDITIONAL_CDB_BYTES_12 3 /* 28-byte CDB */ 5576c223761SKevin Barnett #define SOP_ADDITIONAL_CDB_BYTES_16 4 /* 32-byte CDB */ 5586c223761SKevin Barnett 5596c223761SKevin Barnett /* 5606c223761SKevin Barnett * The purpose of this structure is to obtain proper alignment of objects in 5616c223761SKevin Barnett * an admin queue pair. 5626c223761SKevin Barnett */ 5636c223761SKevin Barnett struct pqi_admin_queues_aligned { 5646c223761SKevin Barnett __aligned(PQI_QUEUE_ELEMENT_ARRAY_ALIGNMENT) 5656c223761SKevin Barnett u8 iq_element_array[PQI_ADMIN_IQ_ELEMENT_LENGTH] 5666c223761SKevin Barnett [PQI_ADMIN_IQ_NUM_ELEMENTS]; 5676c223761SKevin Barnett __aligned(PQI_QUEUE_ELEMENT_ARRAY_ALIGNMENT) 5686c223761SKevin Barnett u8 oq_element_array[PQI_ADMIN_OQ_ELEMENT_LENGTH] 5696c223761SKevin Barnett [PQI_ADMIN_OQ_NUM_ELEMENTS]; 5706c223761SKevin Barnett __aligned(PQI_ADMIN_INDEX_ALIGNMENT) pqi_index_t iq_ci; 5716c223761SKevin Barnett __aligned(PQI_ADMIN_INDEX_ALIGNMENT) pqi_index_t oq_pi; 5726c223761SKevin Barnett }; 5736c223761SKevin Barnett 5746c223761SKevin Barnett struct pqi_admin_queues { 5756c223761SKevin Barnett void *iq_element_array; 5766c223761SKevin Barnett void *oq_element_array; 5776c223761SKevin Barnett volatile pqi_index_t *iq_ci; 5786c223761SKevin Barnett volatile pqi_index_t *oq_pi; 5796c223761SKevin Barnett dma_addr_t iq_element_array_bus_addr; 5806c223761SKevin Barnett dma_addr_t oq_element_array_bus_addr; 5816c223761SKevin Barnett dma_addr_t iq_ci_bus_addr; 5826c223761SKevin Barnett dma_addr_t oq_pi_bus_addr; 5836c223761SKevin Barnett __le32 __iomem *iq_pi; 5846c223761SKevin Barnett pqi_index_t iq_pi_copy; 5856c223761SKevin Barnett __le32 __iomem *oq_ci; 5866c223761SKevin Barnett pqi_index_t oq_ci_copy; 5876c223761SKevin Barnett struct task_struct *task; 5886c223761SKevin Barnett u16 int_msg_num; 5896c223761SKevin Barnett }; 5906c223761SKevin Barnett 5916c223761SKevin Barnett struct pqi_queue_group { 5926c223761SKevin Barnett struct pqi_ctrl_info *ctrl_info; /* backpointer */ 5936c223761SKevin Barnett u16 iq_id[2]; 5946c223761SKevin Barnett u16 oq_id; 5956c223761SKevin Barnett u16 int_msg_num; 5966c223761SKevin Barnett void *iq_element_array[2]; 5976c223761SKevin Barnett void *oq_element_array; 5986c223761SKevin Barnett dma_addr_t iq_element_array_bus_addr[2]; 5996c223761SKevin Barnett dma_addr_t oq_element_array_bus_addr; 6006c223761SKevin Barnett __le32 __iomem *iq_pi[2]; 6016c223761SKevin Barnett pqi_index_t iq_pi_copy[2]; 6026c223761SKevin Barnett volatile pqi_index_t *iq_ci[2]; 6036c223761SKevin Barnett volatile pqi_index_t *oq_pi; 6046c223761SKevin Barnett dma_addr_t iq_ci_bus_addr[2]; 6056c223761SKevin Barnett dma_addr_t oq_pi_bus_addr; 6066c223761SKevin Barnett __le32 __iomem *oq_ci; 6076c223761SKevin Barnett pqi_index_t oq_ci_copy; 6086c223761SKevin Barnett spinlock_t submit_lock[2]; /* protect submission queue */ 6096c223761SKevin Barnett struct list_head request_list[2]; 6106c223761SKevin Barnett }; 6116c223761SKevin Barnett 6126c223761SKevin Barnett struct pqi_event_queue { 6136c223761SKevin Barnett u16 oq_id; 6146c223761SKevin Barnett u16 int_msg_num; 6156c223761SKevin Barnett void *oq_element_array; 6166c223761SKevin Barnett volatile pqi_index_t *oq_pi; 6176c223761SKevin Barnett dma_addr_t oq_element_array_bus_addr; 6186c223761SKevin Barnett dma_addr_t oq_pi_bus_addr; 6196c223761SKevin Barnett __le32 __iomem *oq_ci; 6206c223761SKevin Barnett pqi_index_t oq_ci_copy; 6216c223761SKevin Barnett }; 6226c223761SKevin Barnett 6236c223761SKevin Barnett #define PQI_DEFAULT_QUEUE_GROUP 0 6246c223761SKevin Barnett #define PQI_MAX_QUEUE_GROUPS PQI_MAX_MSIX_VECTORS 6256c223761SKevin Barnett 6266c223761SKevin Barnett struct pqi_encryption_info { 6276c223761SKevin Barnett u16 data_encryption_key_index; 6286c223761SKevin Barnett u32 encrypt_tweak_lower; 6296c223761SKevin Barnett u32 encrypt_tweak_upper; 6306c223761SKevin Barnett }; 6316c223761SKevin Barnett 6326c223761SKevin Barnett #define PQI_MAX_OUTSTANDING_REQUESTS ((u32)~0) 6336c223761SKevin Barnett #define PQI_MAX_TRANSFER_SIZE (4 * 1024U * 1024U) 6346c223761SKevin Barnett 6356c223761SKevin Barnett #define RAID_MAP_MAX_ENTRIES 1024 6366c223761SKevin Barnett 6376c223761SKevin Barnett #define PQI_PHYSICAL_DEVICE_BUS 0 6386c223761SKevin Barnett #define PQI_RAID_VOLUME_BUS 1 6396c223761SKevin Barnett #define PQI_HBA_BUS 2 6406c223761SKevin Barnett #define PQI_MAX_BUS PQI_HBA_BUS 6416c223761SKevin Barnett 6426c223761SKevin Barnett #pragma pack(1) 6436c223761SKevin Barnett 6446c223761SKevin Barnett struct report_lun_header { 6456c223761SKevin Barnett __be32 list_length; 6466c223761SKevin Barnett u8 extended_response; 6476c223761SKevin Barnett u8 reserved[3]; 6486c223761SKevin Barnett }; 6496c223761SKevin Barnett 6506c223761SKevin Barnett struct report_log_lun_extended_entry { 6516c223761SKevin Barnett u8 lunid[8]; 6526c223761SKevin Barnett u8 volume_id[16]; 6536c223761SKevin Barnett }; 6546c223761SKevin Barnett 6556c223761SKevin Barnett struct report_log_lun_extended { 6566c223761SKevin Barnett struct report_lun_header header; 6576c223761SKevin Barnett struct report_log_lun_extended_entry lun_entries[1]; 6586c223761SKevin Barnett }; 6596c223761SKevin Barnett 6606c223761SKevin Barnett struct report_phys_lun_extended_entry { 6616c223761SKevin Barnett u8 lunid[8]; 6626c223761SKevin Barnett __be64 wwid; 6636c223761SKevin Barnett u8 device_type; 6646c223761SKevin Barnett u8 device_flags; 6656c223761SKevin Barnett u8 lun_count; /* number of LUNs in a multi-LUN device */ 6666c223761SKevin Barnett u8 redundant_paths; 6676c223761SKevin Barnett u32 aio_handle; 6686c223761SKevin Barnett }; 6696c223761SKevin Barnett 6706c223761SKevin Barnett /* for device_flags field of struct report_phys_lun_extended_entry */ 6716c223761SKevin Barnett #define REPORT_PHYS_LUN_DEV_FLAG_NON_DISK 0x1 6726c223761SKevin Barnett #define REPORT_PHYS_LUN_DEV_FLAG_AIO_ENABLED 0x8 6736c223761SKevin Barnett 6746c223761SKevin Barnett struct report_phys_lun_extended { 6756c223761SKevin Barnett struct report_lun_header header; 6766c223761SKevin Barnett struct report_phys_lun_extended_entry lun_entries[1]; 6776c223761SKevin Barnett }; 6786c223761SKevin Barnett 6796c223761SKevin Barnett struct raid_map_disk_data { 6806c223761SKevin Barnett u32 aio_handle; 6816c223761SKevin Barnett u8 xor_mult[2]; 6826c223761SKevin Barnett u8 reserved[2]; 6836c223761SKevin Barnett }; 6846c223761SKevin Barnett 6856c223761SKevin Barnett /* constants for flags field of RAID map */ 6866c223761SKevin Barnett #define RAID_MAP_ENCRYPTION_ENABLED 0x1 6876c223761SKevin Barnett 6886c223761SKevin Barnett struct raid_map { 6896c223761SKevin Barnett __le32 structure_size; /* size of entire structure in bytes */ 6906c223761SKevin Barnett __le32 volume_blk_size; /* bytes / block in the volume */ 6916c223761SKevin Barnett __le64 volume_blk_cnt; /* logical blocks on the volume */ 6926c223761SKevin Barnett u8 phys_blk_shift; /* shift factor to convert between */ 6936c223761SKevin Barnett /* units of logical blocks and */ 6946c223761SKevin Barnett /* physical disk blocks */ 6956c223761SKevin Barnett u8 parity_rotation_shift; /* shift factor to convert between */ 6966c223761SKevin Barnett /* units of logical stripes and */ 6976c223761SKevin Barnett /* physical stripes */ 6986c223761SKevin Barnett __le16 strip_size; /* blocks used on each disk / stripe */ 6996c223761SKevin Barnett __le64 disk_starting_blk; /* first disk block used in volume */ 7006c223761SKevin Barnett __le64 disk_blk_cnt; /* disk blocks used by volume / disk */ 7016c223761SKevin Barnett __le16 data_disks_per_row; /* data disk entries / row in the map */ 7026c223761SKevin Barnett __le16 metadata_disks_per_row; /* mirror/parity disk entries / row */ 7036c223761SKevin Barnett /* in the map */ 7046c223761SKevin Barnett __le16 row_cnt; /* rows in each layout map */ 7056c223761SKevin Barnett __le16 layout_map_count; /* layout maps (1 map per */ 7066c223761SKevin Barnett /* mirror parity group) */ 7076c223761SKevin Barnett __le16 flags; 7086c223761SKevin Barnett __le16 data_encryption_key_index; 7096c223761SKevin Barnett u8 reserved[16]; 7106c223761SKevin Barnett struct raid_map_disk_data disk_data[RAID_MAP_MAX_ENTRIES]; 7116c223761SKevin Barnett }; 7126c223761SKevin Barnett 7136c223761SKevin Barnett #pragma pack() 7146c223761SKevin Barnett 7156c223761SKevin Barnett #define RAID_CTLR_LUNID "\0\0\0\0\0\0\0\0" 7166c223761SKevin Barnett 7176c223761SKevin Barnett struct pqi_scsi_dev { 7186c223761SKevin Barnett int devtype; /* as reported by INQUIRY commmand */ 7196c223761SKevin Barnett u8 device_type; /* as reported by */ 7206c223761SKevin Barnett /* BMIC_IDENTIFY_PHYSICAL_DEVICE */ 7216c223761SKevin Barnett /* only valid for devtype = TYPE_DISK */ 7226c223761SKevin Barnett int bus; 7236c223761SKevin Barnett int target; 7246c223761SKevin Barnett int lun; 7256c223761SKevin Barnett u8 scsi3addr[8]; 7266c223761SKevin Barnett __be64 wwid; 7276c223761SKevin Barnett u8 volume_id[16]; 7286c223761SKevin Barnett u8 is_physical_device : 1; 7296c223761SKevin Barnett u8 target_lun_valid : 1; 7306c223761SKevin Barnett u8 expose_device : 1; 7316c223761SKevin Barnett u8 no_uld_attach : 1; 7326c223761SKevin Barnett u8 aio_enabled : 1; /* only valid for physical disks */ 7336c223761SKevin Barnett u8 device_gone : 1; 7346c223761SKevin Barnett u8 new_device : 1; 7356c223761SKevin Barnett u8 keep_device : 1; 7366c223761SKevin Barnett u8 volume_offline : 1; 7376c223761SKevin Barnett u8 vendor[8]; /* bytes 8-15 of inquiry data */ 7386c223761SKevin Barnett u8 model[16]; /* bytes 16-31 of inquiry data */ 7396c223761SKevin Barnett u64 sas_address; 7406c223761SKevin Barnett u8 raid_level; 7416c223761SKevin Barnett u16 queue_depth; /* max. queue_depth for this device */ 7426c223761SKevin Barnett u16 advertised_queue_depth; 7436c223761SKevin Barnett u32 aio_handle; 7446c223761SKevin Barnett u8 volume_status; 7456c223761SKevin Barnett u8 active_path_index; 7466c223761SKevin Barnett u8 path_map; 7476c223761SKevin Barnett u8 bay; 7486c223761SKevin Barnett u8 box[8]; 7496c223761SKevin Barnett u16 phys_connector[8]; 7506c223761SKevin Barnett int offload_configured; /* I/O accel RAID offload configured */ 7516c223761SKevin Barnett int offload_enabled; /* I/O accel RAID offload enabled */ 7526c223761SKevin Barnett int offload_enabled_pending; 7536c223761SKevin Barnett int offload_to_mirror; /* Send next I/O accelerator RAID */ 7546c223761SKevin Barnett /* offload request to mirror drive. */ 7556c223761SKevin Barnett struct raid_map *raid_map; /* I/O accelerator RAID map */ 7566c223761SKevin Barnett 7576c223761SKevin Barnett struct pqi_sas_port *sas_port; 7586c223761SKevin Barnett struct scsi_device *sdev; 7596c223761SKevin Barnett 7606c223761SKevin Barnett struct list_head scsi_device_list_entry; 7616c223761SKevin Barnett struct list_head new_device_list_entry; 7626c223761SKevin Barnett struct list_head add_list_entry; 7636c223761SKevin Barnett struct list_head delete_list_entry; 7646c223761SKevin Barnett }; 7656c223761SKevin Barnett 7666c223761SKevin Barnett /* VPD inquiry pages */ 7676c223761SKevin Barnett #define SCSI_VPD_SUPPORTED_PAGES 0x0 /* standard page */ 7686c223761SKevin Barnett #define SCSI_VPD_DEVICE_ID 0x83 /* standard page */ 7696c223761SKevin Barnett #define CISS_VPD_LV_DEVICE_GEOMETRY 0xc1 /* vendor-specific page */ 7706c223761SKevin Barnett #define CISS_VPD_LV_OFFLOAD_STATUS 0xc2 /* vendor-specific page */ 7716c223761SKevin Barnett #define CISS_VPD_LV_STATUS 0xc3 /* vendor-specific page */ 7726c223761SKevin Barnett 7736c223761SKevin Barnett #define VPD_PAGE (1 << 8) 7746c223761SKevin Barnett 7756c223761SKevin Barnett #pragma pack(1) 7766c223761SKevin Barnett 7776c223761SKevin Barnett /* structure for CISS_VPD_LV_STATUS */ 7786c223761SKevin Barnett struct ciss_vpd_logical_volume_status { 7796c223761SKevin Barnett u8 peripheral_info; 7806c223761SKevin Barnett u8 page_code; 7816c223761SKevin Barnett u8 reserved; 7826c223761SKevin Barnett u8 page_length; 7836c223761SKevin Barnett u8 volume_status; 7846c223761SKevin Barnett u8 reserved2[3]; 7856c223761SKevin Barnett __be32 flags; 7866c223761SKevin Barnett }; 7876c223761SKevin Barnett 7886c223761SKevin Barnett #pragma pack() 7896c223761SKevin Barnett 7906c223761SKevin Barnett /* constants for volume_status field of ciss_vpd_logical_volume_status */ 7916c223761SKevin Barnett #define CISS_LV_OK 0 7926c223761SKevin Barnett #define CISS_LV_FAILED 1 7936c223761SKevin Barnett #define CISS_LV_NOT_CONFIGURED 2 7946c223761SKevin Barnett #define CISS_LV_DEGRADED 3 7956c223761SKevin Barnett #define CISS_LV_READY_FOR_RECOVERY 4 7966c223761SKevin Barnett #define CISS_LV_UNDERGOING_RECOVERY 5 7976c223761SKevin Barnett #define CISS_LV_WRONG_PHYSICAL_DRIVE_REPLACED 6 7986c223761SKevin Barnett #define CISS_LV_PHYSICAL_DRIVE_CONNECTION_PROBLEM 7 7996c223761SKevin Barnett #define CISS_LV_HARDWARE_OVERHEATING 8 8006c223761SKevin Barnett #define CISS_LV_HARDWARE_HAS_OVERHEATED 9 8016c223761SKevin Barnett #define CISS_LV_UNDERGOING_EXPANSION 10 8026c223761SKevin Barnett #define CISS_LV_NOT_AVAILABLE 11 8036c223761SKevin Barnett #define CISS_LV_QUEUED_FOR_EXPANSION 12 8046c223761SKevin Barnett #define CISS_LV_DISABLED_SCSI_ID_CONFLICT 13 8056c223761SKevin Barnett #define CISS_LV_EJECTED 14 8066c223761SKevin Barnett #define CISS_LV_UNDERGOING_ERASE 15 8076c223761SKevin Barnett /* state 16 not used */ 8086c223761SKevin Barnett #define CISS_LV_READY_FOR_PREDICTIVE_SPARE_REBUILD 17 8096c223761SKevin Barnett #define CISS_LV_UNDERGOING_RPI 18 8106c223761SKevin Barnett #define CISS_LV_PENDING_RPI 19 8116c223761SKevin Barnett #define CISS_LV_ENCRYPTED_NO_KEY 20 8126c223761SKevin Barnett /* state 21 not used */ 8136c223761SKevin Barnett #define CISS_LV_UNDERGOING_ENCRYPTION 22 8146c223761SKevin Barnett #define CISS_LV_UNDERGOING_ENCRYPTION_REKEYING 23 8156c223761SKevin Barnett #define CISS_LV_ENCRYPTED_IN_NON_ENCRYPTED_CONTROLLER 24 8166c223761SKevin Barnett #define CISS_LV_PENDING_ENCRYPTION 25 8176c223761SKevin Barnett #define CISS_LV_PENDING_ENCRYPTION_REKEYING 26 8186c223761SKevin Barnett #define CISS_LV_NOT_SUPPORTED 27 8196c223761SKevin Barnett #define CISS_LV_STATUS_UNAVAILABLE 255 8206c223761SKevin Barnett 8216c223761SKevin Barnett /* constants for flags field of ciss_vpd_logical_volume_status */ 8226c223761SKevin Barnett #define CISS_LV_FLAGS_NO_HOST_IO 0x1 /* volume not available for */ 8236c223761SKevin Barnett /* host I/O */ 8246c223761SKevin Barnett 8256c223761SKevin Barnett /* for SAS hosts and SAS expanders */ 8266c223761SKevin Barnett struct pqi_sas_node { 8276c223761SKevin Barnett struct device *parent_dev; 8286c223761SKevin Barnett struct list_head port_list_head; 8296c223761SKevin Barnett }; 8306c223761SKevin Barnett 8316c223761SKevin Barnett struct pqi_sas_port { 8326c223761SKevin Barnett struct list_head port_list_entry; 8336c223761SKevin Barnett u64 sas_address; 8346c223761SKevin Barnett struct sas_port *port; 8356c223761SKevin Barnett int next_phy_index; 8366c223761SKevin Barnett struct list_head phy_list_head; 8376c223761SKevin Barnett struct pqi_sas_node *parent_node; 8386c223761SKevin Barnett struct sas_rphy *rphy; 8396c223761SKevin Barnett }; 8406c223761SKevin Barnett 8416c223761SKevin Barnett struct pqi_sas_phy { 8426c223761SKevin Barnett struct list_head phy_list_entry; 8436c223761SKevin Barnett struct sas_phy *phy; 8446c223761SKevin Barnett struct pqi_sas_port *parent_port; 8456c223761SKevin Barnett bool added_to_port; 8466c223761SKevin Barnett }; 8476c223761SKevin Barnett 8486c223761SKevin Barnett struct pqi_io_request { 8496c223761SKevin Barnett atomic_t refcount; 8506c223761SKevin Barnett u16 index; 8516c223761SKevin Barnett void (*io_complete_callback)(struct pqi_io_request *io_request, 8526c223761SKevin Barnett void *context); 8536c223761SKevin Barnett void *context; 8546c223761SKevin Barnett int status; 8556c223761SKevin Barnett struct scsi_cmnd *scmd; 8566c223761SKevin Barnett void *error_info; 8576c223761SKevin Barnett struct pqi_sg_descriptor *sg_chain_buffer; 8586c223761SKevin Barnett dma_addr_t sg_chain_buffer_dma_handle; 8596c223761SKevin Barnett void *iu; 8606c223761SKevin Barnett struct list_head request_list_entry; 8616c223761SKevin Barnett }; 8626c223761SKevin Barnett 8636c223761SKevin Barnett /* for indexing into the pending_events[] field of struct pqi_ctrl_info */ 8646c223761SKevin Barnett #define PQI_EVENT_HEARTBEAT 0 8656c223761SKevin Barnett #define PQI_EVENT_HOTPLUG 1 8666c223761SKevin Barnett #define PQI_EVENT_HARDWARE 2 8676c223761SKevin Barnett #define PQI_EVENT_PHYSICAL_DEVICE 3 8686c223761SKevin Barnett #define PQI_EVENT_LOGICAL_DEVICE 4 8696c223761SKevin Barnett #define PQI_EVENT_AIO_STATE_CHANGE 5 8706c223761SKevin Barnett #define PQI_EVENT_AIO_CONFIG_CHANGE 6 8716c223761SKevin Barnett #define PQI_NUM_SUPPORTED_EVENTS 7 8726c223761SKevin Barnett 8736c223761SKevin Barnett struct pqi_event { 8746c223761SKevin Barnett bool pending; 8756c223761SKevin Barnett u8 event_type; 8766c223761SKevin Barnett __le16 event_id; 8776c223761SKevin Barnett __le32 additional_event_id; 8786c223761SKevin Barnett }; 8796c223761SKevin Barnett 8805e6429dfSKevin Barnett #define PQI_RESERVED_IO_SLOTS_LUN_RESET 1 8815e6429dfSKevin Barnett #define PQI_RESERVED_IO_SLOTS_EVENT_ACK PQI_NUM_SUPPORTED_EVENTS 8825e6429dfSKevin Barnett #define PQI_RESERVED_IO_SLOTS_SYNCHRONOUS_REQUESTS 3 8835e6429dfSKevin Barnett #define PQI_RESERVED_IO_SLOTS \ 8845e6429dfSKevin Barnett (PQI_RESERVED_IO_SLOTS_LUN_RESET + PQI_RESERVED_IO_SLOTS_EVENT_ACK + \ 8855e6429dfSKevin Barnett PQI_RESERVED_IO_SLOTS_SYNCHRONOUS_REQUESTS) 8865e6429dfSKevin Barnett 8876c223761SKevin Barnett struct pqi_ctrl_info { 8886c223761SKevin Barnett unsigned int ctrl_id; 8896c223761SKevin Barnett struct pci_dev *pci_dev; 8906c223761SKevin Barnett char firmware_version[11]; 8916c223761SKevin Barnett void __iomem *iomem_base; 8926c223761SKevin Barnett struct pqi_ctrl_registers __iomem *registers; 8936c223761SKevin Barnett struct pqi_device_registers __iomem *pqi_registers; 8946c223761SKevin Barnett u32 max_sg_entries; 8956c223761SKevin Barnett u32 config_table_offset; 8966c223761SKevin Barnett u32 config_table_length; 8976c223761SKevin Barnett u16 max_inbound_queues; 8986c223761SKevin Barnett u16 max_elements_per_iq; 8996c223761SKevin Barnett u16 max_iq_element_length; 9006c223761SKevin Barnett u16 max_outbound_queues; 9016c223761SKevin Barnett u16 max_elements_per_oq; 9026c223761SKevin Barnett u16 max_oq_element_length; 9036c223761SKevin Barnett u32 max_transfer_size; 9046c223761SKevin Barnett u32 max_outstanding_requests; 9056c223761SKevin Barnett u32 max_io_slots; 9066c223761SKevin Barnett unsigned int scsi_ml_can_queue; 9076c223761SKevin Barnett unsigned short sg_tablesize; 9086c223761SKevin Barnett unsigned int max_sectors; 9096c223761SKevin Barnett u32 error_buffer_length; 9106c223761SKevin Barnett void *error_buffer; 9116c223761SKevin Barnett dma_addr_t error_buffer_dma_handle; 9126c223761SKevin Barnett size_t sg_chain_buffer_length; 9136c223761SKevin Barnett unsigned int num_queue_groups; 9146c223761SKevin Barnett unsigned int num_active_queue_groups; 9156c223761SKevin Barnett u16 num_elements_per_iq; 9166c223761SKevin Barnett u16 num_elements_per_oq; 9176c223761SKevin Barnett u16 max_inbound_iu_length_per_firmware; 9186c223761SKevin Barnett u16 max_inbound_iu_length; 9196c223761SKevin Barnett unsigned int max_sg_per_iu; 9206c223761SKevin Barnett void *admin_queue_memory_base; 9216c223761SKevin Barnett u32 admin_queue_memory_length; 9226c223761SKevin Barnett dma_addr_t admin_queue_memory_base_dma_handle; 9236c223761SKevin Barnett void *queue_memory_base; 9246c223761SKevin Barnett u32 queue_memory_length; 9256c223761SKevin Barnett dma_addr_t queue_memory_base_dma_handle; 9266c223761SKevin Barnett struct pqi_admin_queues admin_queues; 9276c223761SKevin Barnett struct pqi_queue_group queue_groups[PQI_MAX_QUEUE_GROUPS]; 9286c223761SKevin Barnett struct pqi_event_queue event_queue; 9296c223761SKevin Barnett int max_msix_vectors; 9306c223761SKevin Barnett int num_msix_vectors_enabled; 9316c223761SKevin Barnett int num_msix_vectors_initialized; 9326c223761SKevin Barnett int event_irq; 9336c223761SKevin Barnett struct Scsi_Host *scsi_host; 9346c223761SKevin Barnett 9356c223761SKevin Barnett struct mutex scan_mutex; 9365b0fba0fSKevin Barnett bool controller_online : 1; 9376c223761SKevin Barnett u8 inbound_spanning_supported : 1; 9386c223761SKevin Barnett u8 outbound_spanning_supported : 1; 9396c223761SKevin Barnett u8 pqi_mode_enabled : 1; 9406c223761SKevin Barnett u8 heartbeat_timer_started : 1; 9416c223761SKevin Barnett 9426c223761SKevin Barnett struct list_head scsi_device_list; 9436c223761SKevin Barnett spinlock_t scsi_device_list_lock; 9446c223761SKevin Barnett 9456c223761SKevin Barnett struct delayed_work rescan_work; 9466c223761SKevin Barnett struct delayed_work update_time_work; 9476c223761SKevin Barnett 9486c223761SKevin Barnett struct pqi_sas_node *sas_host; 9496c223761SKevin Barnett u64 sas_address; 9506c223761SKevin Barnett 9516c223761SKevin Barnett struct pqi_io_request *io_request_pool; 9526c223761SKevin Barnett u16 next_io_request_slot; 9536c223761SKevin Barnett 9546c223761SKevin Barnett struct pqi_event pending_events[PQI_NUM_SUPPORTED_EVENTS]; 9556c223761SKevin Barnett struct work_struct event_work; 9566c223761SKevin Barnett 9576c223761SKevin Barnett atomic_t num_interrupts; 9586c223761SKevin Barnett int previous_num_interrupts; 9596c223761SKevin Barnett unsigned int num_heartbeats_requested; 9606c223761SKevin Barnett struct timer_list heartbeat_timer; 9616c223761SKevin Barnett 9626c223761SKevin Barnett struct semaphore sync_request_sem; 9636c223761SKevin Barnett struct semaphore lun_reset_sem; 9646c223761SKevin Barnett }; 9656c223761SKevin Barnett 966ff6abb73SKevin Barnett enum pqi_ctrl_mode { 967*162d7753SKevin Barnett SIS_MODE = 0, 968ff6abb73SKevin Barnett PQI_MODE 969ff6abb73SKevin Barnett }; 970ff6abb73SKevin Barnett 9716c223761SKevin Barnett /* 9726c223761SKevin Barnett * assume worst case: SATA queue depth of 31 minus 4 internal firmware commands 9736c223761SKevin Barnett */ 9746c223761SKevin Barnett #define PQI_PHYSICAL_DISK_DEFAULT_MAX_QUEUE_DEPTH 27 9756c223761SKevin Barnett 9766c223761SKevin Barnett /* 0 = no limit */ 9776c223761SKevin Barnett #define PQI_LOGICAL_DRIVE_DEFAULT_MAX_QUEUE_DEPTH 0 9786c223761SKevin Barnett 9796c223761SKevin Barnett /* CISS commands */ 9806c223761SKevin Barnett #define CISS_READ 0xc0 9816c223761SKevin Barnett #define CISS_REPORT_LOG 0xc2 /* Report Logical LUNs */ 9826c223761SKevin Barnett #define CISS_REPORT_PHYS 0xc3 /* Report Physical LUNs */ 9836c223761SKevin Barnett #define CISS_GET_RAID_MAP 0xc8 9846c223761SKevin Barnett 9856c223761SKevin Barnett /* constants for CISS_REPORT_LOG/CISS_REPORT_PHYS commands */ 9866c223761SKevin Barnett #define CISS_REPORT_LOG_EXTENDED 0x1 9876c223761SKevin Barnett #define CISS_REPORT_PHYS_EXTENDED 0x2 9886c223761SKevin Barnett 9896c223761SKevin Barnett /* BMIC commands */ 9906c223761SKevin Barnett #define BMIC_IDENTIFY_CONTROLLER 0x11 9916c223761SKevin Barnett #define BMIC_IDENTIFY_PHYSICAL_DEVICE 0x15 9926c223761SKevin Barnett #define BMIC_READ 0x26 9936c223761SKevin Barnett #define BMIC_WRITE 0x27 9946c223761SKevin Barnett #define BMIC_SENSE_CONTROLLER_PARAMETERS 0x64 9956c223761SKevin Barnett #define BMIC_SENSE_SUBSYSTEM_INFORMATION 0x66 9966c223761SKevin Barnett #define BMIC_WRITE_HOST_WELLNESS 0xa5 9976c223761SKevin Barnett #define BMIC_CACHE_FLUSH 0xc2 9986c223761SKevin Barnett 9996c223761SKevin Barnett #define SA_CACHE_FLUSH 0x01 10006c223761SKevin Barnett 10016c223761SKevin Barnett #define MASKED_DEVICE(lunid) ((lunid)[3] & 0xc0) 10026c223761SKevin Barnett #define CISS_GET_BUS(lunid) ((lunid)[7] & 0x3f) 10036c223761SKevin Barnett #define CISS_GET_LEVEL_2_TARGET(lunid) ((lunid)[6]) 10046c223761SKevin Barnett #define CISS_GET_DRIVE_NUMBER(lunid) \ 10056c223761SKevin Barnett (((CISS_GET_BUS((lunid)) - 1) << 8) + \ 10066c223761SKevin Barnett CISS_GET_LEVEL_2_TARGET((lunid))) 10076c223761SKevin Barnett 10086c223761SKevin Barnett #define NO_TIMEOUT ((unsigned long) -1) 10096c223761SKevin Barnett 10106c223761SKevin Barnett #pragma pack(1) 10116c223761SKevin Barnett 10126c223761SKevin Barnett struct bmic_identify_controller { 10136c223761SKevin Barnett u8 configured_logical_drive_count; 10146c223761SKevin Barnett __le32 configuration_signature; 10156c223761SKevin Barnett u8 firmware_version[4]; 10166c223761SKevin Barnett u8 reserved[145]; 10176c223761SKevin Barnett __le16 extended_logical_unit_count; 10186c223761SKevin Barnett u8 reserved1[34]; 10196c223761SKevin Barnett __le16 firmware_build_number; 10206c223761SKevin Barnett u8 reserved2[100]; 10216c223761SKevin Barnett u8 controller_mode; 10226c223761SKevin Barnett u8 reserved3[32]; 10236c223761SKevin Barnett }; 10246c223761SKevin Barnett 10256c223761SKevin Barnett struct bmic_identify_physical_device { 10266c223761SKevin Barnett u8 scsi_bus; /* SCSI Bus number on controller */ 10276c223761SKevin Barnett u8 scsi_id; /* SCSI ID on this bus */ 10286c223761SKevin Barnett __le16 block_size; /* sector size in bytes */ 10296c223761SKevin Barnett __le32 total_blocks; /* number for sectors on drive */ 10306c223761SKevin Barnett __le32 reserved_blocks; /* controller reserved (RIS) */ 10316c223761SKevin Barnett u8 model[40]; /* Physical Drive Model */ 10326c223761SKevin Barnett u8 serial_number[40]; /* Drive Serial Number */ 10336c223761SKevin Barnett u8 firmware_revision[8]; /* drive firmware revision */ 10346c223761SKevin Barnett u8 scsi_inquiry_bits; /* inquiry byte 7 bits */ 10356c223761SKevin Barnett u8 compaq_drive_stamp; /* 0 means drive not stamped */ 10366c223761SKevin Barnett u8 last_failure_reason; 10376c223761SKevin Barnett u8 flags; 10386c223761SKevin Barnett u8 more_flags; 10396c223761SKevin Barnett u8 scsi_lun; /* SCSI LUN for phys drive */ 10406c223761SKevin Barnett u8 yet_more_flags; 10416c223761SKevin Barnett u8 even_more_flags; 10426c223761SKevin Barnett __le32 spi_speed_rules; 10436c223761SKevin Barnett u8 phys_connector[2]; /* connector number on controller */ 10446c223761SKevin Barnett u8 phys_box_on_bus; /* phys enclosure this drive resides */ 10456c223761SKevin Barnett u8 phys_bay_in_box; /* phys drv bay this drive resides */ 10466c223761SKevin Barnett __le32 rpm; /* drive rotational speed in RPM */ 10476c223761SKevin Barnett u8 device_type; /* type of drive */ 10486c223761SKevin Barnett u8 sata_version; /* only valid when device_type = */ 10496c223761SKevin Barnett /* BMIC_DEVICE_TYPE_SATA */ 10506c223761SKevin Barnett __le64 big_total_block_count; 10516c223761SKevin Barnett __le64 ris_starting_lba; 10526c223761SKevin Barnett __le32 ris_size; 10536c223761SKevin Barnett u8 wwid[20]; 10546c223761SKevin Barnett u8 controller_phy_map[32]; 10556c223761SKevin Barnett __le16 phy_count; 10566c223761SKevin Barnett u8 phy_connected_dev_type[256]; 10576c223761SKevin Barnett u8 phy_to_drive_bay_num[256]; 10586c223761SKevin Barnett __le16 phy_to_attached_dev_index[256]; 10596c223761SKevin Barnett u8 box_index; 10606c223761SKevin Barnett u8 reserved; 10616c223761SKevin Barnett __le16 extra_physical_drive_flags; 10626c223761SKevin Barnett u8 negotiated_link_rate[256]; 10636c223761SKevin Barnett u8 phy_to_phy_map[256]; 10646c223761SKevin Barnett u8 redundant_path_present_map; 10656c223761SKevin Barnett u8 redundant_path_failure_map; 10666c223761SKevin Barnett u8 active_path_number; 10676c223761SKevin Barnett __le16 alternate_paths_phys_connector[8]; 10686c223761SKevin Barnett u8 alternate_paths_phys_box_on_port[8]; 10696c223761SKevin Barnett u8 multi_lun_device_lun_count; 10706c223761SKevin Barnett u8 minimum_good_fw_revision[8]; 10716c223761SKevin Barnett u8 unique_inquiry_bytes[20]; 10726c223761SKevin Barnett u8 current_temperature_degreesC; 10736c223761SKevin Barnett u8 temperature_threshold_degreesC; 10746c223761SKevin Barnett u8 max_temperature_degreesC; 10756c223761SKevin Barnett u8 logical_blocks_per_phys_block_exp; 10766c223761SKevin Barnett __le16 current_queue_depth_limit; 10776c223761SKevin Barnett u8 switch_name[10]; 10786c223761SKevin Barnett __le16 switch_port; 10796c223761SKevin Barnett u8 alternate_paths_switch_name[40]; 10806c223761SKevin Barnett u8 alternate_paths_switch_port[8]; 10816c223761SKevin Barnett __le16 power_on_hours; 10826c223761SKevin Barnett __le16 percent_endurance_used; 10836c223761SKevin Barnett u8 drive_authentication; 10846c223761SKevin Barnett u8 smart_carrier_authentication; 10856c223761SKevin Barnett u8 smart_carrier_app_fw_version; 10866c223761SKevin Barnett u8 smart_carrier_bootloader_fw_version; 10876c223761SKevin Barnett u8 encryption_key_name[64]; 10886c223761SKevin Barnett __le32 misc_drive_flags; 10896c223761SKevin Barnett __le16 dek_index; 10906c223761SKevin Barnett u8 padding[112]; 10916c223761SKevin Barnett }; 10926c223761SKevin Barnett 10936c223761SKevin Barnett #pragma pack() 10946c223761SKevin Barnett 10956c223761SKevin Barnett int pqi_add_sas_host(struct Scsi_Host *shost, struct pqi_ctrl_info *ctrl_info); 10966c223761SKevin Barnett void pqi_delete_sas_host(struct pqi_ctrl_info *ctrl_info); 10976c223761SKevin Barnett int pqi_add_sas_device(struct pqi_sas_node *pqi_sas_node, 10986c223761SKevin Barnett struct pqi_scsi_dev *device); 10996c223761SKevin Barnett void pqi_remove_sas_device(struct pqi_scsi_dev *device); 11006c223761SKevin Barnett struct pqi_scsi_dev *pqi_find_device_by_sas_rphy( 11016c223761SKevin Barnett struct pqi_ctrl_info *ctrl_info, struct sas_rphy *rphy); 11026c223761SKevin Barnett 11036c223761SKevin Barnett extern struct sas_function_template pqi_sas_transport_functions; 11046c223761SKevin Barnett 11056c223761SKevin Barnett #if !defined(readq) 11066c223761SKevin Barnett #define readq readq 11076c223761SKevin Barnett static inline u64 readq(const volatile void __iomem *addr) 11086c223761SKevin Barnett { 11096c223761SKevin Barnett u32 lower32; 11106c223761SKevin Barnett u32 upper32; 11116c223761SKevin Barnett 11126c223761SKevin Barnett lower32 = readl(addr); 11136c223761SKevin Barnett upper32 = readl(addr + 4); 11146c223761SKevin Barnett 11156c223761SKevin Barnett return ((u64)upper32 << 32) | lower32; 11166c223761SKevin Barnett } 11176c223761SKevin Barnett #endif 11186c223761SKevin Barnett 11196c223761SKevin Barnett #if !defined(writeq) 11206c223761SKevin Barnett #define writeq writeq 11216c223761SKevin Barnett static inline void writeq(u64 value, volatile void __iomem *addr) 11226c223761SKevin Barnett { 11236c223761SKevin Barnett u32 lower32; 11246c223761SKevin Barnett u32 upper32; 11256c223761SKevin Barnett 11266c223761SKevin Barnett lower32 = lower_32_bits(value); 11276c223761SKevin Barnett upper32 = upper_32_bits(value); 11286c223761SKevin Barnett 11296c223761SKevin Barnett writel(lower32, addr); 11306c223761SKevin Barnett writel(upper32, addr + 4); 11316c223761SKevin Barnett } 11326c223761SKevin Barnett #endif 11336c223761SKevin Barnett 11346c223761SKevin Barnett #endif /* _SMARTPQI_H */ 1135