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