16c223761SKevin Barnett /* 26c223761SKevin Barnett * driver for Microsemi PQI-based storage controllers 3b805dbfeSKevin Barnett * Copyright (c) 2016-2017 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 * 64061ef06aSKevin 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 105061ef06aSKevin Barnett enum pqi_irq_mode { 106061ef06aSKevin Barnett IRQ_MODE_NONE, 107061ef06aSKevin Barnett IRQ_MODE_INTX, 108061ef06aSKevin Barnett IRQ_MODE_MSIX 109061ef06aSKevin Barnett }; 110061ef06aSKevin 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 4946c223761SKevin Barnett #pragma pack() 4956c223761SKevin Barnett 4966c223761SKevin Barnett #define PQI_ERROR_BUFFER_ELEMENT_LENGTH \ 4976c223761SKevin Barnett sizeof(struct pqi_raid_error_info) 4986c223761SKevin Barnett 4996c223761SKevin Barnett /* these values are based on our implementation */ 5006c223761SKevin Barnett #define PQI_ADMIN_IQ_NUM_ELEMENTS 8 5016c223761SKevin Barnett #define PQI_ADMIN_OQ_NUM_ELEMENTS 20 5026c223761SKevin Barnett #define PQI_ADMIN_IQ_ELEMENT_LENGTH 64 5036c223761SKevin Barnett #define PQI_ADMIN_OQ_ELEMENT_LENGTH 64 5046c223761SKevin Barnett 5056c223761SKevin Barnett #define PQI_OPERATIONAL_IQ_ELEMENT_LENGTH 128 5066c223761SKevin Barnett #define PQI_OPERATIONAL_OQ_ELEMENT_LENGTH 16 5076c223761SKevin Barnett 5086c223761SKevin Barnett #define PQI_MIN_MSIX_VECTORS 1 5096c223761SKevin Barnett #define PQI_MAX_MSIX_VECTORS 64 5106c223761SKevin Barnett 5116c223761SKevin Barnett /* these values are defined by the PQI spec */ 5126c223761SKevin Barnett #define PQI_MAX_NUM_ELEMENTS_ADMIN_QUEUE 255 5136c223761SKevin Barnett #define PQI_MAX_NUM_ELEMENTS_OPERATIONAL_QUEUE 65535 5146c223761SKevin Barnett #define PQI_QUEUE_ELEMENT_ARRAY_ALIGNMENT 64 5156c223761SKevin Barnett #define PQI_QUEUE_ELEMENT_LENGTH_ALIGNMENT 16 5166c223761SKevin Barnett #define PQI_ADMIN_INDEX_ALIGNMENT 64 5176c223761SKevin Barnett #define PQI_OPERATIONAL_INDEX_ALIGNMENT 4 5186c223761SKevin Barnett 5196c223761SKevin Barnett #define PQI_MIN_OPERATIONAL_QUEUE_ID 1 5206c223761SKevin Barnett #define PQI_MAX_OPERATIONAL_QUEUE_ID 65535 5216c223761SKevin Barnett 5226c223761SKevin Barnett #define PQI_AIO_SERV_RESPONSE_COMPLETE 0 5236c223761SKevin Barnett #define PQI_AIO_SERV_RESPONSE_FAILURE 1 5246c223761SKevin Barnett #define PQI_AIO_SERV_RESPONSE_TMF_COMPLETE 2 5256c223761SKevin Barnett #define PQI_AIO_SERV_RESPONSE_TMF_SUCCEEDED 3 5266c223761SKevin Barnett #define PQI_AIO_SERV_RESPONSE_TMF_REJECTED 4 5276c223761SKevin Barnett #define PQI_AIO_SERV_RESPONSE_TMF_INCORRECT_LUN 5 5286c223761SKevin Barnett 5296c223761SKevin Barnett #define PQI_AIO_STATUS_IO_ERROR 0x1 5306c223761SKevin Barnett #define PQI_AIO_STATUS_IO_ABORTED 0x2 5316c223761SKevin Barnett #define PQI_AIO_STATUS_NO_PATH_TO_DEVICE 0x3 5326c223761SKevin Barnett #define PQI_AIO_STATUS_INVALID_DEVICE 0x4 5336c223761SKevin Barnett #define PQI_AIO_STATUS_AIO_PATH_DISABLED 0xe 5346c223761SKevin Barnett #define PQI_AIO_STATUS_UNDERRUN 0x51 5356c223761SKevin Barnett #define PQI_AIO_STATUS_OVERRUN 0x75 5366c223761SKevin Barnett 5376c223761SKevin Barnett typedef u32 pqi_index_t; 5386c223761SKevin Barnett 5396c223761SKevin Barnett /* SOP data direction flags */ 5406c223761SKevin Barnett #define SOP_NO_DIRECTION_FLAG 0 5416c223761SKevin Barnett #define SOP_WRITE_FLAG 1 /* host writes data to Data-Out */ 5426c223761SKevin Barnett /* buffer */ 5436c223761SKevin Barnett #define SOP_READ_FLAG 2 /* host receives data from Data-In */ 5446c223761SKevin Barnett /* buffer */ 5456c223761SKevin Barnett #define SOP_BIDIRECTIONAL 3 /* data is transferred from the */ 5466c223761SKevin Barnett /* Data-Out buffer and data is */ 5476c223761SKevin Barnett /* transferred to the Data-In buffer */ 5486c223761SKevin Barnett 5496c223761SKevin Barnett #define SOP_TASK_ATTRIBUTE_SIMPLE 0 5506c223761SKevin Barnett #define SOP_TASK_ATTRIBUTE_HEAD_OF_QUEUE 1 5516c223761SKevin Barnett #define SOP_TASK_ATTRIBUTE_ORDERED 2 5526c223761SKevin Barnett #define SOP_TASK_ATTRIBUTE_ACA 4 5536c223761SKevin Barnett 554b17f0486SKevin Barnett #define SOP_TMF_COMPLETE 0x0 555b17f0486SKevin Barnett #define SOP_TMF_FUNCTION_SUCCEEDED 0x8 5566c223761SKevin Barnett 5576c223761SKevin Barnett /* additional CDB bytes usage field codes */ 5586c223761SKevin Barnett #define SOP_ADDITIONAL_CDB_BYTES_0 0 /* 16-byte CDB */ 5596c223761SKevin Barnett #define SOP_ADDITIONAL_CDB_BYTES_4 1 /* 20-byte CDB */ 5606c223761SKevin Barnett #define SOP_ADDITIONAL_CDB_BYTES_8 2 /* 24-byte CDB */ 5616c223761SKevin Barnett #define SOP_ADDITIONAL_CDB_BYTES_12 3 /* 28-byte CDB */ 5626c223761SKevin Barnett #define SOP_ADDITIONAL_CDB_BYTES_16 4 /* 32-byte CDB */ 5636c223761SKevin Barnett 5646c223761SKevin Barnett /* 5656c223761SKevin Barnett * The purpose of this structure is to obtain proper alignment of objects in 5666c223761SKevin Barnett * an admin queue pair. 5676c223761SKevin Barnett */ 5686c223761SKevin Barnett struct pqi_admin_queues_aligned { 5696c223761SKevin Barnett __aligned(PQI_QUEUE_ELEMENT_ARRAY_ALIGNMENT) 5706c223761SKevin Barnett u8 iq_element_array[PQI_ADMIN_IQ_ELEMENT_LENGTH] 5716c223761SKevin Barnett [PQI_ADMIN_IQ_NUM_ELEMENTS]; 5726c223761SKevin Barnett __aligned(PQI_QUEUE_ELEMENT_ARRAY_ALIGNMENT) 5736c223761SKevin Barnett u8 oq_element_array[PQI_ADMIN_OQ_ELEMENT_LENGTH] 5746c223761SKevin Barnett [PQI_ADMIN_OQ_NUM_ELEMENTS]; 5756c223761SKevin Barnett __aligned(PQI_ADMIN_INDEX_ALIGNMENT) pqi_index_t iq_ci; 5766c223761SKevin Barnett __aligned(PQI_ADMIN_INDEX_ALIGNMENT) pqi_index_t oq_pi; 5776c223761SKevin Barnett }; 5786c223761SKevin Barnett 5796c223761SKevin Barnett struct pqi_admin_queues { 5806c223761SKevin Barnett void *iq_element_array; 5816c223761SKevin Barnett void *oq_element_array; 5826c223761SKevin Barnett volatile pqi_index_t *iq_ci; 5836c223761SKevin Barnett volatile pqi_index_t *oq_pi; 5846c223761SKevin Barnett dma_addr_t iq_element_array_bus_addr; 5856c223761SKevin Barnett dma_addr_t oq_element_array_bus_addr; 5866c223761SKevin Barnett dma_addr_t iq_ci_bus_addr; 5876c223761SKevin Barnett dma_addr_t oq_pi_bus_addr; 5886c223761SKevin Barnett __le32 __iomem *iq_pi; 5896c223761SKevin Barnett pqi_index_t iq_pi_copy; 5906c223761SKevin Barnett __le32 __iomem *oq_ci; 5916c223761SKevin Barnett pqi_index_t oq_ci_copy; 5926c223761SKevin Barnett struct task_struct *task; 5936c223761SKevin Barnett u16 int_msg_num; 5946c223761SKevin Barnett }; 5956c223761SKevin Barnett 5966c223761SKevin Barnett struct pqi_queue_group { 5976c223761SKevin Barnett struct pqi_ctrl_info *ctrl_info; /* backpointer */ 5986c223761SKevin Barnett u16 iq_id[2]; 5996c223761SKevin Barnett u16 oq_id; 6006c223761SKevin Barnett u16 int_msg_num; 6016c223761SKevin Barnett void *iq_element_array[2]; 6026c223761SKevin Barnett void *oq_element_array; 6036c223761SKevin Barnett dma_addr_t iq_element_array_bus_addr[2]; 6046c223761SKevin Barnett dma_addr_t oq_element_array_bus_addr; 6056c223761SKevin Barnett __le32 __iomem *iq_pi[2]; 6066c223761SKevin Barnett pqi_index_t iq_pi_copy[2]; 6076c223761SKevin Barnett volatile pqi_index_t *iq_ci[2]; 6086c223761SKevin Barnett volatile pqi_index_t *oq_pi; 6096c223761SKevin Barnett dma_addr_t iq_ci_bus_addr[2]; 6106c223761SKevin Barnett dma_addr_t oq_pi_bus_addr; 6116c223761SKevin Barnett __le32 __iomem *oq_ci; 6126c223761SKevin Barnett pqi_index_t oq_ci_copy; 6136c223761SKevin Barnett spinlock_t submit_lock[2]; /* protect submission queue */ 6146c223761SKevin Barnett struct list_head request_list[2]; 6156c223761SKevin Barnett }; 6166c223761SKevin Barnett 6176c223761SKevin Barnett struct pqi_event_queue { 6186c223761SKevin Barnett u16 oq_id; 6196c223761SKevin Barnett u16 int_msg_num; 6206c223761SKevin Barnett void *oq_element_array; 6216c223761SKevin Barnett volatile pqi_index_t *oq_pi; 6226c223761SKevin Barnett dma_addr_t oq_element_array_bus_addr; 6236c223761SKevin Barnett dma_addr_t oq_pi_bus_addr; 6246c223761SKevin Barnett __le32 __iomem *oq_ci; 6256c223761SKevin Barnett pqi_index_t oq_ci_copy; 6266c223761SKevin Barnett }; 6276c223761SKevin Barnett 6286c223761SKevin Barnett #define PQI_DEFAULT_QUEUE_GROUP 0 6296c223761SKevin Barnett #define PQI_MAX_QUEUE_GROUPS PQI_MAX_MSIX_VECTORS 6306c223761SKevin Barnett 6316c223761SKevin Barnett struct pqi_encryption_info { 6326c223761SKevin Barnett u16 data_encryption_key_index; 6336c223761SKevin Barnett u32 encrypt_tweak_lower; 6346c223761SKevin Barnett u32 encrypt_tweak_upper; 6356c223761SKevin Barnett }; 6366c223761SKevin Barnett 63798f87667SKevin Barnett #pragma pack(1) 63898f87667SKevin Barnett 63998f87667SKevin Barnett #define PQI_CONFIG_TABLE_SIGNATURE "CFGTABLE" 64098f87667SKevin Barnett #define PQI_CONFIG_TABLE_MAX_LENGTH ((u16)~0) 64198f87667SKevin Barnett 64298f87667SKevin Barnett /* configuration table section IDs */ 64398f87667SKevin Barnett #define PQI_CONFIG_TABLE_SECTION_GENERAL_INFO 0 64498f87667SKevin Barnett #define PQI_CONFIG_TABLE_SECTION_FIRMWARE_FEATURES 1 64598f87667SKevin Barnett #define PQI_CONFIG_TABLE_SECTION_FIRMWARE_ERRATA 2 64698f87667SKevin Barnett #define PQI_CONFIG_TABLE_SECTION_DEBUG 3 64798f87667SKevin Barnett #define PQI_CONFIG_TABLE_SECTION_HEARTBEAT 4 64898f87667SKevin Barnett 64998f87667SKevin Barnett struct pqi_config_table { 65098f87667SKevin Barnett u8 signature[8]; /* "CFGTABLE" */ 65198f87667SKevin Barnett __le32 first_section_offset; /* offset in bytes from the base */ 65298f87667SKevin Barnett /* address of this table to the */ 65398f87667SKevin Barnett /* first section */ 65498f87667SKevin Barnett }; 65598f87667SKevin Barnett 65698f87667SKevin Barnett struct pqi_config_table_section_header { 65798f87667SKevin Barnett __le16 section_id; /* as defined by the */ 65898f87667SKevin Barnett /* PQI_CONFIG_TABLE_SECTION_* */ 65998f87667SKevin Barnett /* manifest constants above */ 66098f87667SKevin Barnett __le16 next_section_offset; /* offset in bytes from base */ 66198f87667SKevin Barnett /* address of the table of the */ 66298f87667SKevin Barnett /* next section or 0 if last entry */ 66398f87667SKevin Barnett }; 66498f87667SKevin Barnett 66598f87667SKevin Barnett struct pqi_config_table_general_info { 66698f87667SKevin Barnett struct pqi_config_table_section_header header; 66798f87667SKevin Barnett __le32 section_length; /* size of this section in bytes */ 66898f87667SKevin Barnett /* including the section header */ 66998f87667SKevin Barnett __le32 max_outstanding_requests; /* max. outstanding */ 67098f87667SKevin Barnett /* commands supported by */ 67198f87667SKevin Barnett /* the controller */ 67298f87667SKevin Barnett __le32 max_sg_size; /* max. transfer size of a single */ 67398f87667SKevin Barnett /* command */ 67498f87667SKevin Barnett __le32 max_sg_per_request; /* max. number of scatter-gather */ 67598f87667SKevin Barnett /* entries supported in a single */ 67698f87667SKevin Barnett /* command */ 67798f87667SKevin Barnett }; 67898f87667SKevin Barnett 67998f87667SKevin Barnett struct pqi_config_table_debug { 68098f87667SKevin Barnett struct pqi_config_table_section_header header; 68198f87667SKevin Barnett __le32 scratchpad; 68298f87667SKevin Barnett }; 68398f87667SKevin Barnett 68498f87667SKevin Barnett struct pqi_config_table_heartbeat { 68598f87667SKevin Barnett struct pqi_config_table_section_header header; 68698f87667SKevin Barnett __le32 heartbeat_counter; 68798f87667SKevin Barnett }; 68898f87667SKevin Barnett 6896c223761SKevin Barnett #define PQI_MAX_OUTSTANDING_REQUESTS ((u32)~0) 690d727a776SKevin Barnett #define PQI_MAX_OUTSTANDING_REQUESTS_KDUMP 32 6916c223761SKevin Barnett #define PQI_MAX_TRANSFER_SIZE (4 * 1024U * 1024U) 692d727a776SKevin Barnett #define PQI_MAX_TRANSFER_SIZE_KDUMP (512 * 1024U) 6936c223761SKevin Barnett 6946c223761SKevin Barnett #define RAID_MAP_MAX_ENTRIES 1024 6956c223761SKevin Barnett 6966c223761SKevin Barnett #define PQI_PHYSICAL_DEVICE_BUS 0 6976c223761SKevin Barnett #define PQI_RAID_VOLUME_BUS 1 6986c223761SKevin Barnett #define PQI_HBA_BUS 2 699bd10cf0bSKevin Barnett #define PQI_EXTERNAL_RAID_VOLUME_BUS 3 700bd10cf0bSKevin Barnett #define PQI_MAX_BUS PQI_EXTERNAL_RAID_VOLUME_BUS 7016c223761SKevin Barnett 7026c223761SKevin Barnett struct report_lun_header { 7036c223761SKevin Barnett __be32 list_length; 7046c223761SKevin Barnett u8 extended_response; 7056c223761SKevin Barnett u8 reserved[3]; 7066c223761SKevin Barnett }; 7076c223761SKevin Barnett 7086c223761SKevin Barnett struct report_log_lun_extended_entry { 7096c223761SKevin Barnett u8 lunid[8]; 7106c223761SKevin Barnett u8 volume_id[16]; 7116c223761SKevin Barnett }; 7126c223761SKevin Barnett 7136c223761SKevin Barnett struct report_log_lun_extended { 7146c223761SKevin Barnett struct report_lun_header header; 7156c223761SKevin Barnett struct report_log_lun_extended_entry lun_entries[1]; 7166c223761SKevin Barnett }; 7176c223761SKevin Barnett 7186c223761SKevin Barnett struct report_phys_lun_extended_entry { 7196c223761SKevin Barnett u8 lunid[8]; 7206c223761SKevin Barnett __be64 wwid; 7216c223761SKevin Barnett u8 device_type; 7226c223761SKevin Barnett u8 device_flags; 7236c223761SKevin Barnett u8 lun_count; /* number of LUNs in a multi-LUN device */ 7246c223761SKevin Barnett u8 redundant_paths; 7256c223761SKevin Barnett u32 aio_handle; 7266c223761SKevin Barnett }; 7276c223761SKevin Barnett 7286c223761SKevin Barnett /* for device_flags field of struct report_phys_lun_extended_entry */ 7296c223761SKevin Barnett #define REPORT_PHYS_LUN_DEV_FLAG_AIO_ENABLED 0x8 7306c223761SKevin Barnett 7316c223761SKevin Barnett struct report_phys_lun_extended { 7326c223761SKevin Barnett struct report_lun_header header; 7336c223761SKevin Barnett struct report_phys_lun_extended_entry lun_entries[1]; 7346c223761SKevin Barnett }; 7356c223761SKevin Barnett 7366c223761SKevin Barnett struct raid_map_disk_data { 7376c223761SKevin Barnett u32 aio_handle; 7386c223761SKevin Barnett u8 xor_mult[2]; 7396c223761SKevin Barnett u8 reserved[2]; 7406c223761SKevin Barnett }; 7416c223761SKevin Barnett 7426c223761SKevin Barnett /* constants for flags field of RAID map */ 7436c223761SKevin Barnett #define RAID_MAP_ENCRYPTION_ENABLED 0x1 7446c223761SKevin Barnett 7456c223761SKevin Barnett struct raid_map { 7466c223761SKevin Barnett __le32 structure_size; /* size of entire structure in bytes */ 7476c223761SKevin Barnett __le32 volume_blk_size; /* bytes / block in the volume */ 7486c223761SKevin Barnett __le64 volume_blk_cnt; /* logical blocks on the volume */ 7496c223761SKevin Barnett u8 phys_blk_shift; /* shift factor to convert between */ 7506c223761SKevin Barnett /* units of logical blocks and */ 7516c223761SKevin Barnett /* physical disk blocks */ 7526c223761SKevin Barnett u8 parity_rotation_shift; /* shift factor to convert between */ 7536c223761SKevin Barnett /* units of logical stripes and */ 7546c223761SKevin Barnett /* physical stripes */ 7556c223761SKevin Barnett __le16 strip_size; /* blocks used on each disk / stripe */ 7566c223761SKevin Barnett __le64 disk_starting_blk; /* first disk block used in volume */ 7576c223761SKevin Barnett __le64 disk_blk_cnt; /* disk blocks used by volume / disk */ 7586c223761SKevin Barnett __le16 data_disks_per_row; /* data disk entries / row in the map */ 7596c223761SKevin Barnett __le16 metadata_disks_per_row; /* mirror/parity disk entries / row */ 7606c223761SKevin Barnett /* in the map */ 7616c223761SKevin Barnett __le16 row_cnt; /* rows in each layout map */ 7626c223761SKevin Barnett __le16 layout_map_count; /* layout maps (1 map per */ 7636c223761SKevin Barnett /* mirror parity group) */ 7646c223761SKevin Barnett __le16 flags; 7656c223761SKevin Barnett __le16 data_encryption_key_index; 7666c223761SKevin Barnett u8 reserved[16]; 7676c223761SKevin Barnett struct raid_map_disk_data disk_data[RAID_MAP_MAX_ENTRIES]; 7686c223761SKevin Barnett }; 7696c223761SKevin Barnett 7706c223761SKevin Barnett #pragma pack() 7716c223761SKevin Barnett 7726c223761SKevin Barnett #define RAID_CTLR_LUNID "\0\0\0\0\0\0\0\0" 7736c223761SKevin Barnett 7746c223761SKevin Barnett struct pqi_scsi_dev { 7756c223761SKevin Barnett int devtype; /* as reported by INQUIRY commmand */ 7766c223761SKevin Barnett u8 device_type; /* as reported by */ 7776c223761SKevin Barnett /* BMIC_IDENTIFY_PHYSICAL_DEVICE */ 7786c223761SKevin Barnett /* only valid for devtype = TYPE_DISK */ 7796c223761SKevin Barnett int bus; 7806c223761SKevin Barnett int target; 7816c223761SKevin Barnett int lun; 7826c223761SKevin Barnett u8 scsi3addr[8]; 7836c223761SKevin Barnett __be64 wwid; 7846c223761SKevin Barnett u8 volume_id[16]; 7856c223761SKevin Barnett u8 is_physical_device : 1; 786bd10cf0bSKevin Barnett u8 is_external_raid_device : 1; 7876c223761SKevin Barnett u8 target_lun_valid : 1; 7886c223761SKevin Barnett u8 device_gone : 1; 7896c223761SKevin Barnett u8 new_device : 1; 7906c223761SKevin Barnett u8 keep_device : 1; 7916c223761SKevin Barnett u8 volume_offline : 1; 792*376fb880SKevin Barnett bool aio_enabled; /* only valid for physical disks */ 7937561a7e4SKevin Barnett bool in_reset; 7947561a7e4SKevin Barnett bool device_offline; 7956c223761SKevin Barnett u8 vendor[8]; /* bytes 8-15 of inquiry data */ 7966c223761SKevin Barnett u8 model[16]; /* bytes 16-31 of inquiry data */ 7976c223761SKevin Barnett u64 sas_address; 7986c223761SKevin Barnett u8 raid_level; 7996c223761SKevin Barnett u16 queue_depth; /* max. queue_depth for this device */ 8006c223761SKevin Barnett u16 advertised_queue_depth; 8016c223761SKevin Barnett u32 aio_handle; 8026c223761SKevin Barnett u8 volume_status; 8036c223761SKevin Barnett u8 active_path_index; 8046c223761SKevin Barnett u8 path_map; 8056c223761SKevin Barnett u8 bay; 8066c223761SKevin Barnett u8 box[8]; 8076c223761SKevin Barnett u16 phys_connector[8]; 8086c223761SKevin Barnett int offload_configured; /* I/O accel RAID offload configured */ 8096c223761SKevin Barnett int offload_enabled; /* I/O accel RAID offload enabled */ 8106c223761SKevin Barnett int offload_enabled_pending; 8116c223761SKevin Barnett int offload_to_mirror; /* Send next I/O accelerator RAID */ 8126c223761SKevin Barnett /* offload request to mirror drive. */ 8136c223761SKevin Barnett struct raid_map *raid_map; /* I/O accelerator RAID map */ 8146c223761SKevin Barnett 8156c223761SKevin Barnett struct pqi_sas_port *sas_port; 8166c223761SKevin Barnett struct scsi_device *sdev; 8176c223761SKevin Barnett 8186c223761SKevin Barnett struct list_head scsi_device_list_entry; 8196c223761SKevin Barnett struct list_head new_device_list_entry; 8206c223761SKevin Barnett struct list_head add_list_entry; 8216c223761SKevin Barnett struct list_head delete_list_entry; 8227561a7e4SKevin Barnett 8237561a7e4SKevin Barnett atomic_t scsi_cmds_outstanding; 8246c223761SKevin Barnett }; 8256c223761SKevin Barnett 8266c223761SKevin Barnett /* VPD inquiry pages */ 8276c223761SKevin Barnett #define SCSI_VPD_SUPPORTED_PAGES 0x0 /* standard page */ 8286c223761SKevin Barnett #define SCSI_VPD_DEVICE_ID 0x83 /* standard page */ 8296c223761SKevin Barnett #define CISS_VPD_LV_DEVICE_GEOMETRY 0xc1 /* vendor-specific page */ 8306c223761SKevin Barnett #define CISS_VPD_LV_OFFLOAD_STATUS 0xc2 /* vendor-specific page */ 8316c223761SKevin Barnett #define CISS_VPD_LV_STATUS 0xc3 /* vendor-specific page */ 8326c223761SKevin Barnett 8336c223761SKevin Barnett #define VPD_PAGE (1 << 8) 8346c223761SKevin Barnett 8356c223761SKevin Barnett #pragma pack(1) 8366c223761SKevin Barnett 8376c223761SKevin Barnett /* structure for CISS_VPD_LV_STATUS */ 8386c223761SKevin Barnett struct ciss_vpd_logical_volume_status { 8396c223761SKevin Barnett u8 peripheral_info; 8406c223761SKevin Barnett u8 page_code; 8416c223761SKevin Barnett u8 reserved; 8426c223761SKevin Barnett u8 page_length; 8436c223761SKevin Barnett u8 volume_status; 8446c223761SKevin Barnett u8 reserved2[3]; 8456c223761SKevin Barnett __be32 flags; 8466c223761SKevin Barnett }; 8476c223761SKevin Barnett 8486c223761SKevin Barnett #pragma pack() 8496c223761SKevin Barnett 8506c223761SKevin Barnett /* constants for volume_status field of ciss_vpd_logical_volume_status */ 8516c223761SKevin Barnett #define CISS_LV_OK 0 8526c223761SKevin Barnett #define CISS_LV_FAILED 1 8536c223761SKevin Barnett #define CISS_LV_NOT_CONFIGURED 2 8546c223761SKevin Barnett #define CISS_LV_DEGRADED 3 8556c223761SKevin Barnett #define CISS_LV_READY_FOR_RECOVERY 4 8566c223761SKevin Barnett #define CISS_LV_UNDERGOING_RECOVERY 5 8576c223761SKevin Barnett #define CISS_LV_WRONG_PHYSICAL_DRIVE_REPLACED 6 8586c223761SKevin Barnett #define CISS_LV_PHYSICAL_DRIVE_CONNECTION_PROBLEM 7 8596c223761SKevin Barnett #define CISS_LV_HARDWARE_OVERHEATING 8 8606c223761SKevin Barnett #define CISS_LV_HARDWARE_HAS_OVERHEATED 9 8616c223761SKevin Barnett #define CISS_LV_UNDERGOING_EXPANSION 10 8626c223761SKevin Barnett #define CISS_LV_NOT_AVAILABLE 11 8636c223761SKevin Barnett #define CISS_LV_QUEUED_FOR_EXPANSION 12 8646c223761SKevin Barnett #define CISS_LV_DISABLED_SCSI_ID_CONFLICT 13 8656c223761SKevin Barnett #define CISS_LV_EJECTED 14 8666c223761SKevin Barnett #define CISS_LV_UNDERGOING_ERASE 15 8676c223761SKevin Barnett /* state 16 not used */ 8686c223761SKevin Barnett #define CISS_LV_READY_FOR_PREDICTIVE_SPARE_REBUILD 17 8696c223761SKevin Barnett #define CISS_LV_UNDERGOING_RPI 18 8706c223761SKevin Barnett #define CISS_LV_PENDING_RPI 19 8716c223761SKevin Barnett #define CISS_LV_ENCRYPTED_NO_KEY 20 8726c223761SKevin Barnett /* state 21 not used */ 8736c223761SKevin Barnett #define CISS_LV_UNDERGOING_ENCRYPTION 22 8746c223761SKevin Barnett #define CISS_LV_UNDERGOING_ENCRYPTION_REKEYING 23 8756c223761SKevin Barnett #define CISS_LV_ENCRYPTED_IN_NON_ENCRYPTED_CONTROLLER 24 8766c223761SKevin Barnett #define CISS_LV_PENDING_ENCRYPTION 25 8776c223761SKevin Barnett #define CISS_LV_PENDING_ENCRYPTION_REKEYING 26 8786c223761SKevin Barnett #define CISS_LV_NOT_SUPPORTED 27 8796c223761SKevin Barnett #define CISS_LV_STATUS_UNAVAILABLE 255 8806c223761SKevin Barnett 8816c223761SKevin Barnett /* constants for flags field of ciss_vpd_logical_volume_status */ 8826c223761SKevin Barnett #define CISS_LV_FLAGS_NO_HOST_IO 0x1 /* volume not available for */ 8836c223761SKevin Barnett /* host I/O */ 8846c223761SKevin Barnett 8856c223761SKevin Barnett /* for SAS hosts and SAS expanders */ 8866c223761SKevin Barnett struct pqi_sas_node { 8876c223761SKevin Barnett struct device *parent_dev; 8886c223761SKevin Barnett struct list_head port_list_head; 8896c223761SKevin Barnett }; 8906c223761SKevin Barnett 8916c223761SKevin Barnett struct pqi_sas_port { 8926c223761SKevin Barnett struct list_head port_list_entry; 8936c223761SKevin Barnett u64 sas_address; 8946c223761SKevin Barnett struct sas_port *port; 8956c223761SKevin Barnett int next_phy_index; 8966c223761SKevin Barnett struct list_head phy_list_head; 8976c223761SKevin Barnett struct pqi_sas_node *parent_node; 8986c223761SKevin Barnett struct sas_rphy *rphy; 8996c223761SKevin Barnett }; 9006c223761SKevin Barnett 9016c223761SKevin Barnett struct pqi_sas_phy { 9026c223761SKevin Barnett struct list_head phy_list_entry; 9036c223761SKevin Barnett struct sas_phy *phy; 9046c223761SKevin Barnett struct pqi_sas_port *parent_port; 9056c223761SKevin Barnett bool added_to_port; 9066c223761SKevin Barnett }; 9076c223761SKevin Barnett 9086c223761SKevin Barnett struct pqi_io_request { 9096c223761SKevin Barnett atomic_t refcount; 9106c223761SKevin Barnett u16 index; 9116c223761SKevin Barnett void (*io_complete_callback)(struct pqi_io_request *io_request, 9126c223761SKevin Barnett void *context); 9136c223761SKevin Barnett void *context; 914*376fb880SKevin Barnett u8 raid_bypass : 1; 9156c223761SKevin Barnett int status; 916*376fb880SKevin Barnett struct pqi_queue_group *queue_group; 9176c223761SKevin Barnett struct scsi_cmnd *scmd; 9186c223761SKevin Barnett void *error_info; 9196c223761SKevin Barnett struct pqi_sg_descriptor *sg_chain_buffer; 9206c223761SKevin Barnett dma_addr_t sg_chain_buffer_dma_handle; 9216c223761SKevin Barnett void *iu; 9226c223761SKevin Barnett struct list_head request_list_entry; 9236c223761SKevin Barnett }; 9246c223761SKevin Barnett 9256a50d6adSKevin Barnett #define PQI_NUM_SUPPORTED_EVENTS 6 9266c223761SKevin Barnett 9276c223761SKevin Barnett struct pqi_event { 9286c223761SKevin Barnett bool pending; 9296c223761SKevin Barnett u8 event_type; 9306c223761SKevin Barnett __le16 event_id; 9316c223761SKevin Barnett __le32 additional_event_id; 9326c223761SKevin Barnett }; 9336c223761SKevin Barnett 9345e6429dfSKevin Barnett #define PQI_RESERVED_IO_SLOTS_LUN_RESET 1 9355e6429dfSKevin Barnett #define PQI_RESERVED_IO_SLOTS_EVENT_ACK PQI_NUM_SUPPORTED_EVENTS 9365e6429dfSKevin Barnett #define PQI_RESERVED_IO_SLOTS_SYNCHRONOUS_REQUESTS 3 9375e6429dfSKevin Barnett #define PQI_RESERVED_IO_SLOTS \ 9385e6429dfSKevin Barnett (PQI_RESERVED_IO_SLOTS_LUN_RESET + PQI_RESERVED_IO_SLOTS_EVENT_ACK + \ 9395e6429dfSKevin Barnett PQI_RESERVED_IO_SLOTS_SYNCHRONOUS_REQUESTS) 9405e6429dfSKevin Barnett 9416c223761SKevin Barnett struct pqi_ctrl_info { 9426c223761SKevin Barnett unsigned int ctrl_id; 9436c223761SKevin Barnett struct pci_dev *pci_dev; 9446c223761SKevin Barnett char firmware_version[11]; 9456c223761SKevin Barnett void __iomem *iomem_base; 9466c223761SKevin Barnett struct pqi_ctrl_registers __iomem *registers; 9476c223761SKevin Barnett struct pqi_device_registers __iomem *pqi_registers; 9486c223761SKevin Barnett u32 max_sg_entries; 9496c223761SKevin Barnett u32 config_table_offset; 9506c223761SKevin Barnett u32 config_table_length; 9516c223761SKevin Barnett u16 max_inbound_queues; 9526c223761SKevin Barnett u16 max_elements_per_iq; 9536c223761SKevin Barnett u16 max_iq_element_length; 9546c223761SKevin Barnett u16 max_outbound_queues; 9556c223761SKevin Barnett u16 max_elements_per_oq; 9566c223761SKevin Barnett u16 max_oq_element_length; 9576c223761SKevin Barnett u32 max_transfer_size; 9586c223761SKevin Barnett u32 max_outstanding_requests; 9596c223761SKevin Barnett u32 max_io_slots; 9606c223761SKevin Barnett unsigned int scsi_ml_can_queue; 9616c223761SKevin Barnett unsigned short sg_tablesize; 9626c223761SKevin Barnett unsigned int max_sectors; 9636c223761SKevin Barnett u32 error_buffer_length; 9646c223761SKevin Barnett void *error_buffer; 9656c223761SKevin Barnett dma_addr_t error_buffer_dma_handle; 9666c223761SKevin Barnett size_t sg_chain_buffer_length; 9676c223761SKevin Barnett unsigned int num_queue_groups; 968061ef06aSKevin Barnett u16 max_hw_queue_index; 9696c223761SKevin Barnett u16 num_elements_per_iq; 9706c223761SKevin Barnett u16 num_elements_per_oq; 9716c223761SKevin Barnett u16 max_inbound_iu_length_per_firmware; 9726c223761SKevin Barnett u16 max_inbound_iu_length; 9736c223761SKevin Barnett unsigned int max_sg_per_iu; 9746c223761SKevin Barnett void *admin_queue_memory_base; 9756c223761SKevin Barnett u32 admin_queue_memory_length; 9766c223761SKevin Barnett dma_addr_t admin_queue_memory_base_dma_handle; 9776c223761SKevin Barnett void *queue_memory_base; 9786c223761SKevin Barnett u32 queue_memory_length; 9796c223761SKevin Barnett dma_addr_t queue_memory_base_dma_handle; 9806c223761SKevin Barnett struct pqi_admin_queues admin_queues; 9816c223761SKevin Barnett struct pqi_queue_group queue_groups[PQI_MAX_QUEUE_GROUPS]; 9826c223761SKevin Barnett struct pqi_event_queue event_queue; 983061ef06aSKevin Barnett enum pqi_irq_mode irq_mode; 9846c223761SKevin Barnett int max_msix_vectors; 9856c223761SKevin Barnett int num_msix_vectors_enabled; 9866c223761SKevin Barnett int num_msix_vectors_initialized; 9876c223761SKevin Barnett int event_irq; 9886c223761SKevin Barnett struct Scsi_Host *scsi_host; 9896c223761SKevin Barnett 9906c223761SKevin Barnett struct mutex scan_mutex; 9917561a7e4SKevin Barnett struct mutex lun_reset_mutex; 9927561a7e4SKevin Barnett bool controller_online; 9937561a7e4SKevin Barnett bool block_requests; 9946c223761SKevin Barnett u8 inbound_spanning_supported : 1; 9956c223761SKevin Barnett u8 outbound_spanning_supported : 1; 9966c223761SKevin Barnett u8 pqi_mode_enabled : 1; 997061ef06aSKevin Barnett u8 update_time_worker_scheduled : 1; 9986c223761SKevin Barnett 9996c223761SKevin Barnett struct list_head scsi_device_list; 10006c223761SKevin Barnett spinlock_t scsi_device_list_lock; 10016c223761SKevin Barnett 10026c223761SKevin Barnett struct delayed_work rescan_work; 10036c223761SKevin Barnett struct delayed_work update_time_work; 10046c223761SKevin Barnett 10056c223761SKevin Barnett struct pqi_sas_node *sas_host; 10066c223761SKevin Barnett u64 sas_address; 10076c223761SKevin Barnett 10086c223761SKevin Barnett struct pqi_io_request *io_request_pool; 10096c223761SKevin Barnett u16 next_io_request_slot; 10106c223761SKevin Barnett 10116a50d6adSKevin Barnett struct pqi_event events[PQI_NUM_SUPPORTED_EVENTS]; 10126c223761SKevin Barnett struct work_struct event_work; 10136c223761SKevin Barnett 10146c223761SKevin Barnett atomic_t num_interrupts; 10156c223761SKevin Barnett int previous_num_interrupts; 101698f87667SKevin Barnett u32 previous_heartbeat_count; 101798f87667SKevin Barnett __le32 __iomem *heartbeat_counter; 10186c223761SKevin Barnett struct timer_list heartbeat_timer; 10196c223761SKevin Barnett 10206c223761SKevin Barnett struct semaphore sync_request_sem; 10217561a7e4SKevin Barnett atomic_t num_busy_threads; 10227561a7e4SKevin Barnett atomic_t num_blocked_threads; 10237561a7e4SKevin Barnett wait_queue_head_t block_requests_wait; 1024*376fb880SKevin Barnett 1025*376fb880SKevin Barnett struct list_head raid_bypass_retry_list; 1026*376fb880SKevin Barnett spinlock_t raid_bypass_retry_list_lock; 1027*376fb880SKevin Barnett struct work_struct raid_bypass_retry_work; 10286c223761SKevin Barnett }; 10296c223761SKevin Barnett 1030ff6abb73SKevin Barnett enum pqi_ctrl_mode { 1031162d7753SKevin Barnett SIS_MODE = 0, 1032ff6abb73SKevin Barnett PQI_MODE 1033ff6abb73SKevin Barnett }; 1034ff6abb73SKevin Barnett 10356c223761SKevin Barnett /* 10366c223761SKevin Barnett * assume worst case: SATA queue depth of 31 minus 4 internal firmware commands 10376c223761SKevin Barnett */ 10386c223761SKevin Barnett #define PQI_PHYSICAL_DISK_DEFAULT_MAX_QUEUE_DEPTH 27 10396c223761SKevin Barnett 10406c223761SKevin Barnett /* CISS commands */ 10416c223761SKevin Barnett #define CISS_READ 0xc0 10426c223761SKevin Barnett #define CISS_REPORT_LOG 0xc2 /* Report Logical LUNs */ 10436c223761SKevin Barnett #define CISS_REPORT_PHYS 0xc3 /* Report Physical LUNs */ 10446c223761SKevin Barnett #define CISS_GET_RAID_MAP 0xc8 10456c223761SKevin Barnett 10466c223761SKevin Barnett /* constants for CISS_REPORT_LOG/CISS_REPORT_PHYS commands */ 10476c223761SKevin Barnett #define CISS_REPORT_LOG_EXTENDED 0x1 10486c223761SKevin Barnett #define CISS_REPORT_PHYS_EXTENDED 0x2 10496c223761SKevin Barnett 10506c223761SKevin Barnett /* BMIC commands */ 10516c223761SKevin Barnett #define BMIC_IDENTIFY_CONTROLLER 0x11 10526c223761SKevin Barnett #define BMIC_IDENTIFY_PHYSICAL_DEVICE 0x15 10536c223761SKevin Barnett #define BMIC_READ 0x26 10546c223761SKevin Barnett #define BMIC_WRITE 0x27 10556c223761SKevin Barnett #define BMIC_SENSE_CONTROLLER_PARAMETERS 0x64 10566c223761SKevin Barnett #define BMIC_SENSE_SUBSYSTEM_INFORMATION 0x66 10576c223761SKevin Barnett #define BMIC_WRITE_HOST_WELLNESS 0xa5 10586c223761SKevin Barnett #define BMIC_CACHE_FLUSH 0xc2 10596c223761SKevin Barnett 1060cbe0c7b1SKevin Barnett #define SA_CACHE_FLUSH 0x1 10616c223761SKevin Barnett 10626c223761SKevin Barnett #define MASKED_DEVICE(lunid) ((lunid)[3] & 0xc0) 1063bd10cf0bSKevin Barnett #define CISS_GET_LEVEL_2_BUS(lunid) ((lunid)[7] & 0x3f) 10646c223761SKevin Barnett #define CISS_GET_LEVEL_2_TARGET(lunid) ((lunid)[6]) 10656c223761SKevin Barnett #define CISS_GET_DRIVE_NUMBER(lunid) \ 1066bd10cf0bSKevin Barnett (((CISS_GET_LEVEL_2_BUS((lunid)) - 1) << 8) + \ 10676c223761SKevin Barnett CISS_GET_LEVEL_2_TARGET((lunid))) 10686c223761SKevin Barnett 10696c223761SKevin Barnett #define NO_TIMEOUT ((unsigned long) -1) 10706c223761SKevin Barnett 10716c223761SKevin Barnett #pragma pack(1) 10726c223761SKevin Barnett 10736c223761SKevin Barnett struct bmic_identify_controller { 10746c223761SKevin Barnett u8 configured_logical_drive_count; 10756c223761SKevin Barnett __le32 configuration_signature; 10766c223761SKevin Barnett u8 firmware_version[4]; 10776c223761SKevin Barnett u8 reserved[145]; 10786c223761SKevin Barnett __le16 extended_logical_unit_count; 10796c223761SKevin Barnett u8 reserved1[34]; 10806c223761SKevin Barnett __le16 firmware_build_number; 10816c223761SKevin Barnett u8 reserved2[100]; 10826c223761SKevin Barnett u8 controller_mode; 10836c223761SKevin Barnett u8 reserved3[32]; 10846c223761SKevin Barnett }; 10856c223761SKevin Barnett 10866c223761SKevin Barnett struct bmic_identify_physical_device { 10876c223761SKevin Barnett u8 scsi_bus; /* SCSI Bus number on controller */ 10886c223761SKevin Barnett u8 scsi_id; /* SCSI ID on this bus */ 10896c223761SKevin Barnett __le16 block_size; /* sector size in bytes */ 10906c223761SKevin Barnett __le32 total_blocks; /* number for sectors on drive */ 10916c223761SKevin Barnett __le32 reserved_blocks; /* controller reserved (RIS) */ 10926c223761SKevin Barnett u8 model[40]; /* Physical Drive Model */ 10936c223761SKevin Barnett u8 serial_number[40]; /* Drive Serial Number */ 10946c223761SKevin Barnett u8 firmware_revision[8]; /* drive firmware revision */ 10956c223761SKevin Barnett u8 scsi_inquiry_bits; /* inquiry byte 7 bits */ 10966c223761SKevin Barnett u8 compaq_drive_stamp; /* 0 means drive not stamped */ 10976c223761SKevin Barnett u8 last_failure_reason; 10986c223761SKevin Barnett u8 flags; 10996c223761SKevin Barnett u8 more_flags; 11006c223761SKevin Barnett u8 scsi_lun; /* SCSI LUN for phys drive */ 11016c223761SKevin Barnett u8 yet_more_flags; 11026c223761SKevin Barnett u8 even_more_flags; 11036c223761SKevin Barnett __le32 spi_speed_rules; 11046c223761SKevin Barnett u8 phys_connector[2]; /* connector number on controller */ 11056c223761SKevin Barnett u8 phys_box_on_bus; /* phys enclosure this drive resides */ 11066c223761SKevin Barnett u8 phys_bay_in_box; /* phys drv bay this drive resides */ 11076c223761SKevin Barnett __le32 rpm; /* drive rotational speed in RPM */ 11086c223761SKevin Barnett u8 device_type; /* type of drive */ 11096c223761SKevin Barnett u8 sata_version; /* only valid when device_type = */ 11106c223761SKevin Barnett /* BMIC_DEVICE_TYPE_SATA */ 11116c223761SKevin Barnett __le64 big_total_block_count; 11126c223761SKevin Barnett __le64 ris_starting_lba; 11136c223761SKevin Barnett __le32 ris_size; 11146c223761SKevin Barnett u8 wwid[20]; 11156c223761SKevin Barnett u8 controller_phy_map[32]; 11166c223761SKevin Barnett __le16 phy_count; 11176c223761SKevin Barnett u8 phy_connected_dev_type[256]; 11186c223761SKevin Barnett u8 phy_to_drive_bay_num[256]; 11196c223761SKevin Barnett __le16 phy_to_attached_dev_index[256]; 11206c223761SKevin Barnett u8 box_index; 11216c223761SKevin Barnett u8 reserved; 11226c223761SKevin Barnett __le16 extra_physical_drive_flags; 11236c223761SKevin Barnett u8 negotiated_link_rate[256]; 11246c223761SKevin Barnett u8 phy_to_phy_map[256]; 11256c223761SKevin Barnett u8 redundant_path_present_map; 11266c223761SKevin Barnett u8 redundant_path_failure_map; 11276c223761SKevin Barnett u8 active_path_number; 11286c223761SKevin Barnett __le16 alternate_paths_phys_connector[8]; 11296c223761SKevin Barnett u8 alternate_paths_phys_box_on_port[8]; 11306c223761SKevin Barnett u8 multi_lun_device_lun_count; 11316c223761SKevin Barnett u8 minimum_good_fw_revision[8]; 11326c223761SKevin Barnett u8 unique_inquiry_bytes[20]; 11331be42f46SKevin Barnett u8 current_temperature_degrees; 11341be42f46SKevin Barnett u8 temperature_threshold_degrees; 11351be42f46SKevin Barnett u8 max_temperature_degrees; 11366c223761SKevin Barnett u8 logical_blocks_per_phys_block_exp; 11376c223761SKevin Barnett __le16 current_queue_depth_limit; 11386c223761SKevin Barnett u8 switch_name[10]; 11396c223761SKevin Barnett __le16 switch_port; 11406c223761SKevin Barnett u8 alternate_paths_switch_name[40]; 11416c223761SKevin Barnett u8 alternate_paths_switch_port[8]; 11426c223761SKevin Barnett __le16 power_on_hours; 11436c223761SKevin Barnett __le16 percent_endurance_used; 11446c223761SKevin Barnett u8 drive_authentication; 11456c223761SKevin Barnett u8 smart_carrier_authentication; 11466c223761SKevin Barnett u8 smart_carrier_app_fw_version; 11476c223761SKevin Barnett u8 smart_carrier_bootloader_fw_version; 11481be42f46SKevin Barnett u8 sanitize_flags; 11491be42f46SKevin Barnett u8 encryption_key_flags; 11506c223761SKevin Barnett u8 encryption_key_name[64]; 11516c223761SKevin Barnett __le32 misc_drive_flags; 11526c223761SKevin Barnett __le16 dek_index; 11531be42f46SKevin Barnett __le16 hba_drive_encryption_flags; 11541be42f46SKevin Barnett __le16 max_overwrite_time; 11551be42f46SKevin Barnett __le16 max_block_erase_time; 11561be42f46SKevin Barnett __le16 max_crypto_erase_time; 11571be42f46SKevin Barnett u8 connector_info[5]; 11581be42f46SKevin Barnett u8 connector_name[8][8]; 11591be42f46SKevin Barnett u8 page_83_identifier[16]; 11601be42f46SKevin Barnett u8 maximum_link_rate[256]; 11611be42f46SKevin Barnett u8 negotiated_physical_link_rate[256]; 11621be42f46SKevin Barnett u8 box_connector_name[8]; 11631be42f46SKevin Barnett u8 padding_to_multiple_of_512[9]; 11646c223761SKevin Barnett }; 11656c223761SKevin Barnett 11666c223761SKevin Barnett #pragma pack() 11676c223761SKevin Barnett 11686c223761SKevin Barnett int pqi_add_sas_host(struct Scsi_Host *shost, struct pqi_ctrl_info *ctrl_info); 11696c223761SKevin Barnett void pqi_delete_sas_host(struct pqi_ctrl_info *ctrl_info); 11706c223761SKevin Barnett int pqi_add_sas_device(struct pqi_sas_node *pqi_sas_node, 11716c223761SKevin Barnett struct pqi_scsi_dev *device); 11726c223761SKevin Barnett void pqi_remove_sas_device(struct pqi_scsi_dev *device); 11736c223761SKevin Barnett struct pqi_scsi_dev *pqi_find_device_by_sas_rphy( 11746c223761SKevin Barnett struct pqi_ctrl_info *ctrl_info, struct sas_rphy *rphy); 11757561a7e4SKevin Barnett void pqi_prep_for_scsi_done(struct scsi_cmnd *scmd); 11766c223761SKevin Barnett 11776c223761SKevin Barnett extern struct sas_function_template pqi_sas_transport_functions; 11786c223761SKevin Barnett 11796c223761SKevin Barnett #if !defined(readq) 11806c223761SKevin Barnett #define readq readq 11816c223761SKevin Barnett static inline u64 readq(const volatile void __iomem *addr) 11826c223761SKevin Barnett { 11836c223761SKevin Barnett u32 lower32; 11846c223761SKevin Barnett u32 upper32; 11856c223761SKevin Barnett 11866c223761SKevin Barnett lower32 = readl(addr); 11876c223761SKevin Barnett upper32 = readl(addr + 4); 11886c223761SKevin Barnett 11896c223761SKevin Barnett return ((u64)upper32 << 32) | lower32; 11906c223761SKevin Barnett } 11916c223761SKevin Barnett #endif 11926c223761SKevin Barnett 11936c223761SKevin Barnett #if !defined(writeq) 11946c223761SKevin Barnett #define writeq writeq 11956c223761SKevin Barnett static inline void writeq(u64 value, volatile void __iomem *addr) 11966c223761SKevin Barnett { 11976c223761SKevin Barnett u32 lower32; 11986c223761SKevin Barnett u32 upper32; 11996c223761SKevin Barnett 12006c223761SKevin Barnett lower32 = lower_32_bits(value); 12016c223761SKevin Barnett upper32 = upper_32_bits(value); 12026c223761SKevin Barnett 12036c223761SKevin Barnett writel(lower32, addr); 12046c223761SKevin Barnett writel(upper32, addr + 4); 12056c223761SKevin Barnett } 12066c223761SKevin Barnett #endif 12076c223761SKevin Barnett 12086c223761SKevin Barnett #endif /* _SMARTPQI_H */ 1209