Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 1 | /* |
| 2 | * driver for Microsemi PQI-based storage controllers |
Kevin Barnett | b805dbf | 2017-05-03 18:54:06 -0500 | [diff] [blame] | 3 | * Copyright (c) 2016-2017 Microsemi Corporation |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 4 | * Copyright (c) 2016 PMC-Sierra, Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or |
| 13 | * NON INFRINGEMENT. See the GNU General Public License for more details. |
| 14 | * |
| 15 | * Questions/Comments/Bugfixes to esc.storagedev@microsemi.com |
| 16 | * |
| 17 | */ |
| 18 | |
| 19 | #if !defined(_SMARTPQI_H) |
| 20 | #define _SMARTPQI_H |
| 21 | |
| 22 | #pragma pack(1) |
| 23 | |
| 24 | #define PQI_DEVICE_SIGNATURE "PQI DREG" |
| 25 | |
| 26 | /* This structure is defined by the PQI specification. */ |
| 27 | struct pqi_device_registers { |
| 28 | __le64 signature; |
| 29 | u8 function_and_status_code; |
| 30 | u8 reserved[7]; |
| 31 | u8 max_admin_iq_elements; |
| 32 | u8 max_admin_oq_elements; |
| 33 | u8 admin_iq_element_length; /* in 16-byte units */ |
| 34 | u8 admin_oq_element_length; /* in 16-byte units */ |
| 35 | __le16 max_reset_timeout; /* in 100-millisecond units */ |
| 36 | u8 reserved1[2]; |
| 37 | __le32 legacy_intx_status; |
| 38 | __le32 legacy_intx_mask_set; |
| 39 | __le32 legacy_intx_mask_clear; |
| 40 | u8 reserved2[28]; |
| 41 | __le32 device_status; |
| 42 | u8 reserved3[4]; |
| 43 | __le64 admin_iq_pi_offset; |
| 44 | __le64 admin_oq_ci_offset; |
| 45 | __le64 admin_iq_element_array_addr; |
| 46 | __le64 admin_oq_element_array_addr; |
| 47 | __le64 admin_iq_ci_addr; |
| 48 | __le64 admin_oq_pi_addr; |
| 49 | u8 admin_iq_num_elements; |
| 50 | u8 admin_oq_num_elements; |
| 51 | __le16 admin_queue_int_msg_num; |
| 52 | u8 reserved4[4]; |
| 53 | __le32 device_error; |
| 54 | u8 reserved5[4]; |
| 55 | __le64 error_details; |
| 56 | __le32 device_reset; |
| 57 | __le32 power_action; |
| 58 | u8 reserved6[104]; |
| 59 | }; |
| 60 | |
| 61 | /* |
| 62 | * controller registers |
| 63 | * |
Kevin Barnett | 061ef06 | 2017-05-03 18:53:05 -0500 | [diff] [blame] | 64 | * These are defined by the Microsemi implementation. |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 65 | * |
| 66 | * Some registers (those named sis_*) are only used when in |
| 67 | * legacy SIS mode before we transition the controller into |
| 68 | * PQI mode. There are a number of other SIS mode registers, |
| 69 | * but we don't use them, so only the SIS registers that we |
| 70 | * care about are defined here. The offsets mentioned in the |
| 71 | * comments are the offsets from the PCIe BAR 0. |
| 72 | */ |
| 73 | struct pqi_ctrl_registers { |
| 74 | u8 reserved[0x20]; |
| 75 | __le32 sis_host_to_ctrl_doorbell; /* 20h */ |
| 76 | u8 reserved1[0x34 - (0x20 + sizeof(__le32))]; |
| 77 | __le32 sis_interrupt_mask; /* 34h */ |
| 78 | u8 reserved2[0x9c - (0x34 + sizeof(__le32))]; |
| 79 | __le32 sis_ctrl_to_host_doorbell; /* 9Ch */ |
| 80 | u8 reserved3[0xa0 - (0x9c + sizeof(__le32))]; |
| 81 | __le32 sis_ctrl_to_host_doorbell_clear; /* A0h */ |
Kevin Barnett | ff6abb7 | 2016-08-31 14:54:41 -0500 | [diff] [blame] | 82 | u8 reserved4[0xb0 - (0xa0 + sizeof(__le32))]; |
| 83 | __le32 sis_driver_scratch; /* B0h */ |
| 84 | u8 reserved5[0xbc - (0xb0 + sizeof(__le32))]; |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 85 | __le32 sis_firmware_status; /* BCh */ |
Kevin Barnett | ff6abb7 | 2016-08-31 14:54:41 -0500 | [diff] [blame] | 86 | u8 reserved6[0x1000 - (0xbc + sizeof(__le32))]; |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 87 | __le32 sis_mailbox[8]; /* 1000h */ |
Kevin Barnett | ff6abb7 | 2016-08-31 14:54:41 -0500 | [diff] [blame] | 88 | u8 reserved7[0x4000 - (0x1000 + (sizeof(__le32) * 8))]; |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 89 | /* |
| 90 | * The PQI spec states that the PQI registers should be at |
| 91 | * offset 0 from the PCIe BAR 0. However, we can't map |
| 92 | * them at offset 0 because that would break compatibility |
| 93 | * with the SIS registers. So we map them at offset 4000h. |
| 94 | */ |
| 95 | struct pqi_device_registers pqi_registers; /* 4000h */ |
| 96 | }; |
| 97 | |
| 98 | #define PQI_DEVICE_REGISTERS_OFFSET 0x4000 |
| 99 | |
| 100 | enum pqi_io_path { |
| 101 | RAID_PATH = 0, |
| 102 | AIO_PATH = 1 |
| 103 | }; |
| 104 | |
Kevin Barnett | 061ef06 | 2017-05-03 18:53:05 -0500 | [diff] [blame] | 105 | enum pqi_irq_mode { |
| 106 | IRQ_MODE_NONE, |
| 107 | IRQ_MODE_INTX, |
| 108 | IRQ_MODE_MSIX |
| 109 | }; |
| 110 | |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 111 | struct pqi_sg_descriptor { |
| 112 | __le64 address; |
| 113 | __le32 length; |
| 114 | __le32 flags; |
| 115 | }; |
| 116 | |
| 117 | /* manifest constants for the flags field of pqi_sg_descriptor */ |
| 118 | #define CISS_SG_LAST 0x40000000 |
| 119 | #define CISS_SG_CHAIN 0x80000000 |
| 120 | |
| 121 | struct pqi_iu_header { |
| 122 | u8 iu_type; |
| 123 | u8 reserved; |
| 124 | __le16 iu_length; /* in bytes - does not include the length */ |
| 125 | /* of this header */ |
| 126 | __le16 response_queue_id; /* specifies the OQ where the */ |
| 127 | /* response IU is to be delivered */ |
| 128 | u8 work_area[2]; /* reserved for driver use */ |
| 129 | }; |
| 130 | |
| 131 | /* |
| 132 | * According to the PQI spec, the IU header is only the first 4 bytes of our |
| 133 | * pqi_iu_header structure. |
| 134 | */ |
| 135 | #define PQI_REQUEST_HEADER_LENGTH 4 |
| 136 | |
| 137 | struct pqi_general_admin_request { |
| 138 | struct pqi_iu_header header; |
| 139 | __le16 request_id; |
| 140 | u8 function_code; |
| 141 | union { |
| 142 | struct { |
| 143 | u8 reserved[33]; |
| 144 | __le32 buffer_length; |
| 145 | struct pqi_sg_descriptor sg_descriptor; |
| 146 | } report_device_capability; |
| 147 | |
| 148 | struct { |
| 149 | u8 reserved; |
| 150 | __le16 queue_id; |
| 151 | u8 reserved1[2]; |
| 152 | __le64 element_array_addr; |
| 153 | __le64 ci_addr; |
| 154 | __le16 num_elements; |
| 155 | __le16 element_length; |
| 156 | u8 queue_protocol; |
| 157 | u8 reserved2[23]; |
| 158 | __le32 vendor_specific; |
| 159 | } create_operational_iq; |
| 160 | |
| 161 | struct { |
| 162 | u8 reserved; |
| 163 | __le16 queue_id; |
| 164 | u8 reserved1[2]; |
| 165 | __le64 element_array_addr; |
| 166 | __le64 pi_addr; |
| 167 | __le16 num_elements; |
| 168 | __le16 element_length; |
| 169 | u8 queue_protocol; |
| 170 | u8 reserved2[3]; |
| 171 | __le16 int_msg_num; |
| 172 | __le16 coalescing_count; |
| 173 | __le32 min_coalescing_time; |
| 174 | __le32 max_coalescing_time; |
| 175 | u8 reserved3[8]; |
| 176 | __le32 vendor_specific; |
| 177 | } create_operational_oq; |
| 178 | |
| 179 | struct { |
| 180 | u8 reserved; |
| 181 | __le16 queue_id; |
| 182 | u8 reserved1[50]; |
| 183 | } delete_operational_queue; |
| 184 | |
| 185 | struct { |
| 186 | u8 reserved; |
| 187 | __le16 queue_id; |
| 188 | u8 reserved1[46]; |
| 189 | __le32 vendor_specific; |
| 190 | } change_operational_iq_properties; |
| 191 | |
| 192 | } data; |
| 193 | }; |
| 194 | |
| 195 | struct pqi_general_admin_response { |
| 196 | struct pqi_iu_header header; |
| 197 | __le16 request_id; |
| 198 | u8 function_code; |
| 199 | u8 status; |
| 200 | union { |
| 201 | struct { |
| 202 | u8 status_descriptor[4]; |
| 203 | __le64 iq_pi_offset; |
| 204 | u8 reserved[40]; |
| 205 | } create_operational_iq; |
| 206 | |
| 207 | struct { |
| 208 | u8 status_descriptor[4]; |
| 209 | __le64 oq_ci_offset; |
| 210 | u8 reserved[40]; |
| 211 | } create_operational_oq; |
| 212 | } data; |
| 213 | }; |
| 214 | |
| 215 | struct pqi_iu_layer_descriptor { |
| 216 | u8 inbound_spanning_supported : 1; |
| 217 | u8 reserved : 7; |
| 218 | u8 reserved1[5]; |
| 219 | __le16 max_inbound_iu_length; |
| 220 | u8 outbound_spanning_supported : 1; |
| 221 | u8 reserved2 : 7; |
| 222 | u8 reserved3[5]; |
| 223 | __le16 max_outbound_iu_length; |
| 224 | }; |
| 225 | |
| 226 | struct pqi_device_capability { |
| 227 | __le16 data_length; |
| 228 | u8 reserved[6]; |
| 229 | u8 iq_arbitration_priority_support_bitmask; |
| 230 | u8 maximum_aw_a; |
| 231 | u8 maximum_aw_b; |
| 232 | u8 maximum_aw_c; |
| 233 | u8 max_arbitration_burst : 3; |
| 234 | u8 reserved1 : 4; |
| 235 | u8 iqa : 1; |
| 236 | u8 reserved2[2]; |
| 237 | u8 iq_freeze : 1; |
| 238 | u8 reserved3 : 7; |
| 239 | __le16 max_inbound_queues; |
| 240 | __le16 max_elements_per_iq; |
| 241 | u8 reserved4[4]; |
| 242 | __le16 max_iq_element_length; |
| 243 | __le16 min_iq_element_length; |
| 244 | u8 reserved5[2]; |
| 245 | __le16 max_outbound_queues; |
| 246 | __le16 max_elements_per_oq; |
| 247 | __le16 intr_coalescing_time_granularity; |
| 248 | __le16 max_oq_element_length; |
| 249 | __le16 min_oq_element_length; |
| 250 | u8 reserved6[24]; |
| 251 | struct pqi_iu_layer_descriptor iu_layer_descriptors[32]; |
| 252 | }; |
| 253 | |
| 254 | #define PQI_MAX_EMBEDDED_SG_DESCRIPTORS 4 |
| 255 | |
| 256 | struct pqi_raid_path_request { |
| 257 | struct pqi_iu_header header; |
| 258 | __le16 request_id; |
| 259 | __le16 nexus_id; |
| 260 | __le32 buffer_length; |
| 261 | u8 lun_number[8]; |
| 262 | __le16 protocol_specific; |
| 263 | u8 data_direction : 2; |
| 264 | u8 partial : 1; |
| 265 | u8 reserved1 : 4; |
| 266 | u8 fence : 1; |
| 267 | __le16 error_index; |
| 268 | u8 reserved2; |
| 269 | u8 task_attribute : 3; |
| 270 | u8 command_priority : 4; |
| 271 | u8 reserved3 : 1; |
| 272 | u8 reserved4 : 2; |
| 273 | u8 additional_cdb_bytes_usage : 3; |
| 274 | u8 reserved5 : 3; |
| 275 | u8 cdb[32]; |
| 276 | struct pqi_sg_descriptor |
| 277 | sg_descriptors[PQI_MAX_EMBEDDED_SG_DESCRIPTORS]; |
| 278 | }; |
| 279 | |
| 280 | struct pqi_aio_path_request { |
| 281 | struct pqi_iu_header header; |
| 282 | __le16 request_id; |
| 283 | u8 reserved1[2]; |
| 284 | __le32 nexus_id; |
| 285 | __le32 buffer_length; |
| 286 | u8 data_direction : 2; |
| 287 | u8 partial : 1; |
| 288 | u8 memory_type : 1; |
| 289 | u8 fence : 1; |
| 290 | u8 encryption_enable : 1; |
| 291 | u8 reserved2 : 2; |
| 292 | u8 task_attribute : 3; |
| 293 | u8 command_priority : 4; |
| 294 | u8 reserved3 : 1; |
| 295 | __le16 data_encryption_key_index; |
| 296 | __le32 encrypt_tweak_lower; |
| 297 | __le32 encrypt_tweak_upper; |
| 298 | u8 cdb[16]; |
| 299 | __le16 error_index; |
| 300 | u8 num_sg_descriptors; |
| 301 | u8 cdb_length; |
| 302 | u8 lun_number[8]; |
| 303 | u8 reserved4[4]; |
| 304 | struct pqi_sg_descriptor |
| 305 | sg_descriptors[PQI_MAX_EMBEDDED_SG_DESCRIPTORS]; |
| 306 | }; |
| 307 | |
| 308 | struct pqi_io_response { |
| 309 | struct pqi_iu_header header; |
| 310 | __le16 request_id; |
| 311 | __le16 error_index; |
| 312 | u8 reserved2[4]; |
| 313 | }; |
| 314 | |
| 315 | struct pqi_general_management_request { |
| 316 | struct pqi_iu_header header; |
| 317 | __le16 request_id; |
| 318 | union { |
| 319 | struct { |
| 320 | u8 reserved[2]; |
| 321 | __le32 buffer_length; |
| 322 | struct pqi_sg_descriptor sg_descriptors[3]; |
| 323 | } report_event_configuration; |
| 324 | |
| 325 | struct { |
| 326 | __le16 global_event_oq_id; |
| 327 | __le32 buffer_length; |
| 328 | struct pqi_sg_descriptor sg_descriptors[3]; |
| 329 | } set_event_configuration; |
| 330 | } data; |
| 331 | }; |
| 332 | |
| 333 | struct pqi_event_descriptor { |
| 334 | u8 event_type; |
| 335 | u8 reserved; |
| 336 | __le16 oq_id; |
| 337 | }; |
| 338 | |
| 339 | struct pqi_event_config { |
| 340 | u8 reserved[2]; |
| 341 | u8 num_event_descriptors; |
| 342 | u8 reserved1; |
| 343 | struct pqi_event_descriptor descriptors[1]; |
| 344 | }; |
| 345 | |
| 346 | #define PQI_MAX_EVENT_DESCRIPTORS 255 |
| 347 | |
| 348 | struct pqi_event_response { |
| 349 | struct pqi_iu_header header; |
| 350 | u8 event_type; |
| 351 | u8 reserved2 : 7; |
| 352 | u8 request_acknowlege : 1; |
| 353 | __le16 event_id; |
| 354 | __le32 additional_event_id; |
| 355 | u8 data[16]; |
| 356 | }; |
| 357 | |
| 358 | struct pqi_event_acknowledge_request { |
| 359 | struct pqi_iu_header header; |
| 360 | u8 event_type; |
| 361 | u8 reserved2; |
| 362 | __le16 event_id; |
| 363 | __le32 additional_event_id; |
| 364 | }; |
| 365 | |
| 366 | struct pqi_task_management_request { |
| 367 | struct pqi_iu_header header; |
| 368 | __le16 request_id; |
| 369 | __le16 nexus_id; |
| 370 | u8 reserved[4]; |
| 371 | u8 lun_number[8]; |
| 372 | __le16 protocol_specific; |
| 373 | __le16 outbound_queue_id_to_manage; |
| 374 | __le16 request_id_to_manage; |
| 375 | u8 task_management_function; |
| 376 | u8 reserved2 : 7; |
| 377 | u8 fence : 1; |
| 378 | }; |
| 379 | |
| 380 | #define SOP_TASK_MANAGEMENT_LUN_RESET 0x8 |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 381 | |
| 382 | struct pqi_task_management_response { |
| 383 | struct pqi_iu_header header; |
| 384 | __le16 request_id; |
| 385 | __le16 nexus_id; |
| 386 | u8 additional_response_info[3]; |
| 387 | u8 response_code; |
| 388 | }; |
| 389 | |
| 390 | struct pqi_aio_error_info { |
| 391 | u8 status; |
| 392 | u8 service_response; |
| 393 | u8 data_present; |
| 394 | u8 reserved; |
| 395 | __le32 residual_count; |
| 396 | __le16 data_length; |
| 397 | __le16 reserved1; |
| 398 | u8 data[256]; |
| 399 | }; |
| 400 | |
| 401 | struct pqi_raid_error_info { |
| 402 | u8 data_in_result; |
| 403 | u8 data_out_result; |
| 404 | u8 reserved[3]; |
| 405 | u8 status; |
| 406 | __le16 status_qualifier; |
| 407 | __le16 sense_data_length; |
| 408 | __le16 response_data_length; |
| 409 | __le32 data_in_transferred; |
| 410 | __le32 data_out_transferred; |
| 411 | u8 data[256]; |
| 412 | }; |
| 413 | |
| 414 | #define PQI_REQUEST_IU_TASK_MANAGEMENT 0x13 |
| 415 | #define PQI_REQUEST_IU_RAID_PATH_IO 0x14 |
| 416 | #define PQI_REQUEST_IU_AIO_PATH_IO 0x15 |
| 417 | #define PQI_REQUEST_IU_GENERAL_ADMIN 0x60 |
| 418 | #define PQI_REQUEST_IU_REPORT_VENDOR_EVENT_CONFIG 0x72 |
| 419 | #define PQI_REQUEST_IU_SET_VENDOR_EVENT_CONFIG 0x73 |
| 420 | #define PQI_REQUEST_IU_ACKNOWLEDGE_VENDOR_EVENT 0xf6 |
| 421 | |
| 422 | #define PQI_RESPONSE_IU_GENERAL_MANAGEMENT 0x81 |
| 423 | #define PQI_RESPONSE_IU_TASK_MANAGEMENT 0x93 |
| 424 | #define PQI_RESPONSE_IU_GENERAL_ADMIN 0xe0 |
| 425 | #define PQI_RESPONSE_IU_RAID_PATH_IO_SUCCESS 0xf0 |
| 426 | #define PQI_RESPONSE_IU_AIO_PATH_IO_SUCCESS 0xf1 |
| 427 | #define PQI_RESPONSE_IU_RAID_PATH_IO_ERROR 0xf2 |
| 428 | #define PQI_RESPONSE_IU_AIO_PATH_IO_ERROR 0xf3 |
| 429 | #define PQI_RESPONSE_IU_AIO_PATH_DISABLED 0xf4 |
| 430 | #define PQI_RESPONSE_IU_VENDOR_EVENT 0xf5 |
| 431 | |
| 432 | #define PQI_GENERAL_ADMIN_FUNCTION_REPORT_DEVICE_CAPABILITY 0x0 |
| 433 | #define PQI_GENERAL_ADMIN_FUNCTION_CREATE_IQ 0x10 |
| 434 | #define PQI_GENERAL_ADMIN_FUNCTION_CREATE_OQ 0x11 |
| 435 | #define PQI_GENERAL_ADMIN_FUNCTION_DELETE_IQ 0x12 |
| 436 | #define PQI_GENERAL_ADMIN_FUNCTION_DELETE_OQ 0x13 |
| 437 | #define PQI_GENERAL_ADMIN_FUNCTION_CHANGE_IQ_PROPERTY 0x14 |
| 438 | |
| 439 | #define PQI_GENERAL_ADMIN_STATUS_SUCCESS 0x0 |
| 440 | |
| 441 | #define PQI_IQ_PROPERTY_IS_AIO_QUEUE 0x1 |
| 442 | |
| 443 | #define PQI_GENERAL_ADMIN_IU_LENGTH 0x3c |
| 444 | #define PQI_PROTOCOL_SOP 0x0 |
| 445 | |
| 446 | #define PQI_DATA_IN_OUT_GOOD 0x0 |
| 447 | #define PQI_DATA_IN_OUT_UNDERFLOW 0x1 |
| 448 | #define PQI_DATA_IN_OUT_BUFFER_ERROR 0x40 |
| 449 | #define PQI_DATA_IN_OUT_BUFFER_OVERFLOW 0x41 |
| 450 | #define PQI_DATA_IN_OUT_BUFFER_OVERFLOW_DESCRIPTOR_AREA 0x42 |
| 451 | #define PQI_DATA_IN_OUT_BUFFER_OVERFLOW_BRIDGE 0x43 |
| 452 | #define PQI_DATA_IN_OUT_PCIE_FABRIC_ERROR 0x60 |
| 453 | #define PQI_DATA_IN_OUT_PCIE_COMPLETION_TIMEOUT 0x61 |
| 454 | #define PQI_DATA_IN_OUT_PCIE_COMPLETER_ABORT_RECEIVED 0x62 |
| 455 | #define PQI_DATA_IN_OUT_PCIE_UNSUPPORTED_REQUEST_RECEIVED 0x63 |
| 456 | #define PQI_DATA_IN_OUT_PCIE_ECRC_CHECK_FAILED 0x64 |
| 457 | #define PQI_DATA_IN_OUT_PCIE_UNSUPPORTED_REQUEST 0x65 |
| 458 | #define PQI_DATA_IN_OUT_PCIE_ACS_VIOLATION 0x66 |
| 459 | #define PQI_DATA_IN_OUT_PCIE_TLP_PREFIX_BLOCKED 0x67 |
| 460 | #define PQI_DATA_IN_OUT_PCIE_POISONED_MEMORY_READ 0x6F |
| 461 | #define PQI_DATA_IN_OUT_ERROR 0xf0 |
| 462 | #define PQI_DATA_IN_OUT_PROTOCOL_ERROR 0xf1 |
| 463 | #define PQI_DATA_IN_OUT_HARDWARE_ERROR 0xf2 |
| 464 | #define PQI_DATA_IN_OUT_UNSOLICITED_ABORT 0xf3 |
| 465 | #define PQI_DATA_IN_OUT_ABORTED 0xf4 |
| 466 | #define PQI_DATA_IN_OUT_TIMEOUT 0xf5 |
| 467 | |
| 468 | #define CISS_CMD_STATUS_SUCCESS 0x0 |
| 469 | #define CISS_CMD_STATUS_TARGET_STATUS 0x1 |
| 470 | #define CISS_CMD_STATUS_DATA_UNDERRUN 0x2 |
| 471 | #define CISS_CMD_STATUS_DATA_OVERRUN 0x3 |
| 472 | #define CISS_CMD_STATUS_INVALID 0x4 |
| 473 | #define CISS_CMD_STATUS_PROTOCOL_ERROR 0x5 |
| 474 | #define CISS_CMD_STATUS_HARDWARE_ERROR 0x6 |
| 475 | #define CISS_CMD_STATUS_CONNECTION_LOST 0x7 |
| 476 | #define CISS_CMD_STATUS_ABORTED 0x8 |
| 477 | #define CISS_CMD_STATUS_ABORT_FAILED 0x9 |
| 478 | #define CISS_CMD_STATUS_UNSOLICITED_ABORT 0xa |
| 479 | #define CISS_CMD_STATUS_TIMEOUT 0xb |
| 480 | #define CISS_CMD_STATUS_UNABORTABLE 0xc |
| 481 | #define CISS_CMD_STATUS_TMF 0xd |
| 482 | #define CISS_CMD_STATUS_AIO_DISABLED 0xe |
| 483 | |
| 484 | #define PQI_NUM_EVENT_QUEUE_ELEMENTS 32 |
| 485 | #define PQI_EVENT_OQ_ELEMENT_LENGTH sizeof(struct pqi_event_response) |
| 486 | |
| 487 | #define PQI_EVENT_TYPE_HOTPLUG 0x1 |
| 488 | #define PQI_EVENT_TYPE_HARDWARE 0x2 |
| 489 | #define PQI_EVENT_TYPE_PHYSICAL_DEVICE 0x4 |
| 490 | #define PQI_EVENT_TYPE_LOGICAL_DEVICE 0x5 |
| 491 | #define PQI_EVENT_TYPE_AIO_STATE_CHANGE 0xfd |
| 492 | #define PQI_EVENT_TYPE_AIO_CONFIG_CHANGE 0xfe |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 493 | |
| 494 | #pragma pack() |
| 495 | |
| 496 | #define PQI_ERROR_BUFFER_ELEMENT_LENGTH \ |
| 497 | sizeof(struct pqi_raid_error_info) |
| 498 | |
| 499 | /* these values are based on our implementation */ |
| 500 | #define PQI_ADMIN_IQ_NUM_ELEMENTS 8 |
| 501 | #define PQI_ADMIN_OQ_NUM_ELEMENTS 20 |
| 502 | #define PQI_ADMIN_IQ_ELEMENT_LENGTH 64 |
| 503 | #define PQI_ADMIN_OQ_ELEMENT_LENGTH 64 |
| 504 | |
| 505 | #define PQI_OPERATIONAL_IQ_ELEMENT_LENGTH 128 |
| 506 | #define PQI_OPERATIONAL_OQ_ELEMENT_LENGTH 16 |
| 507 | |
| 508 | #define PQI_MIN_MSIX_VECTORS 1 |
| 509 | #define PQI_MAX_MSIX_VECTORS 64 |
| 510 | |
| 511 | /* these values are defined by the PQI spec */ |
| 512 | #define PQI_MAX_NUM_ELEMENTS_ADMIN_QUEUE 255 |
| 513 | #define PQI_MAX_NUM_ELEMENTS_OPERATIONAL_QUEUE 65535 |
| 514 | #define PQI_QUEUE_ELEMENT_ARRAY_ALIGNMENT 64 |
| 515 | #define PQI_QUEUE_ELEMENT_LENGTH_ALIGNMENT 16 |
| 516 | #define PQI_ADMIN_INDEX_ALIGNMENT 64 |
| 517 | #define PQI_OPERATIONAL_INDEX_ALIGNMENT 4 |
| 518 | |
| 519 | #define PQI_MIN_OPERATIONAL_QUEUE_ID 1 |
| 520 | #define PQI_MAX_OPERATIONAL_QUEUE_ID 65535 |
| 521 | |
| 522 | #define PQI_AIO_SERV_RESPONSE_COMPLETE 0 |
| 523 | #define PQI_AIO_SERV_RESPONSE_FAILURE 1 |
| 524 | #define PQI_AIO_SERV_RESPONSE_TMF_COMPLETE 2 |
| 525 | #define PQI_AIO_SERV_RESPONSE_TMF_SUCCEEDED 3 |
| 526 | #define PQI_AIO_SERV_RESPONSE_TMF_REJECTED 4 |
| 527 | #define PQI_AIO_SERV_RESPONSE_TMF_INCORRECT_LUN 5 |
| 528 | |
| 529 | #define PQI_AIO_STATUS_IO_ERROR 0x1 |
| 530 | #define PQI_AIO_STATUS_IO_ABORTED 0x2 |
| 531 | #define PQI_AIO_STATUS_NO_PATH_TO_DEVICE 0x3 |
| 532 | #define PQI_AIO_STATUS_INVALID_DEVICE 0x4 |
| 533 | #define PQI_AIO_STATUS_AIO_PATH_DISABLED 0xe |
| 534 | #define PQI_AIO_STATUS_UNDERRUN 0x51 |
| 535 | #define PQI_AIO_STATUS_OVERRUN 0x75 |
| 536 | |
| 537 | typedef u32 pqi_index_t; |
| 538 | |
| 539 | /* SOP data direction flags */ |
| 540 | #define SOP_NO_DIRECTION_FLAG 0 |
| 541 | #define SOP_WRITE_FLAG 1 /* host writes data to Data-Out */ |
| 542 | /* buffer */ |
| 543 | #define SOP_READ_FLAG 2 /* host receives data from Data-In */ |
| 544 | /* buffer */ |
| 545 | #define SOP_BIDIRECTIONAL 3 /* data is transferred from the */ |
| 546 | /* Data-Out buffer and data is */ |
| 547 | /* transferred to the Data-In buffer */ |
| 548 | |
| 549 | #define SOP_TASK_ATTRIBUTE_SIMPLE 0 |
| 550 | #define SOP_TASK_ATTRIBUTE_HEAD_OF_QUEUE 1 |
| 551 | #define SOP_TASK_ATTRIBUTE_ORDERED 2 |
| 552 | #define SOP_TASK_ATTRIBUTE_ACA 4 |
| 553 | |
Kevin Barnett | b17f048 | 2016-08-31 14:54:17 -0500 | [diff] [blame] | 554 | #define SOP_TMF_COMPLETE 0x0 |
| 555 | #define SOP_TMF_FUNCTION_SUCCEEDED 0x8 |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 556 | |
| 557 | /* additional CDB bytes usage field codes */ |
| 558 | #define SOP_ADDITIONAL_CDB_BYTES_0 0 /* 16-byte CDB */ |
| 559 | #define SOP_ADDITIONAL_CDB_BYTES_4 1 /* 20-byte CDB */ |
| 560 | #define SOP_ADDITIONAL_CDB_BYTES_8 2 /* 24-byte CDB */ |
| 561 | #define SOP_ADDITIONAL_CDB_BYTES_12 3 /* 28-byte CDB */ |
| 562 | #define SOP_ADDITIONAL_CDB_BYTES_16 4 /* 32-byte CDB */ |
| 563 | |
| 564 | /* |
| 565 | * The purpose of this structure is to obtain proper alignment of objects in |
| 566 | * an admin queue pair. |
| 567 | */ |
| 568 | struct pqi_admin_queues_aligned { |
| 569 | __aligned(PQI_QUEUE_ELEMENT_ARRAY_ALIGNMENT) |
| 570 | u8 iq_element_array[PQI_ADMIN_IQ_ELEMENT_LENGTH] |
| 571 | [PQI_ADMIN_IQ_NUM_ELEMENTS]; |
| 572 | __aligned(PQI_QUEUE_ELEMENT_ARRAY_ALIGNMENT) |
| 573 | u8 oq_element_array[PQI_ADMIN_OQ_ELEMENT_LENGTH] |
| 574 | [PQI_ADMIN_OQ_NUM_ELEMENTS]; |
| 575 | __aligned(PQI_ADMIN_INDEX_ALIGNMENT) pqi_index_t iq_ci; |
| 576 | __aligned(PQI_ADMIN_INDEX_ALIGNMENT) pqi_index_t oq_pi; |
| 577 | }; |
| 578 | |
| 579 | struct pqi_admin_queues { |
| 580 | void *iq_element_array; |
| 581 | void *oq_element_array; |
| 582 | volatile pqi_index_t *iq_ci; |
| 583 | volatile pqi_index_t *oq_pi; |
| 584 | dma_addr_t iq_element_array_bus_addr; |
| 585 | dma_addr_t oq_element_array_bus_addr; |
| 586 | dma_addr_t iq_ci_bus_addr; |
| 587 | dma_addr_t oq_pi_bus_addr; |
| 588 | __le32 __iomem *iq_pi; |
| 589 | pqi_index_t iq_pi_copy; |
| 590 | __le32 __iomem *oq_ci; |
| 591 | pqi_index_t oq_ci_copy; |
| 592 | struct task_struct *task; |
| 593 | u16 int_msg_num; |
| 594 | }; |
| 595 | |
| 596 | struct pqi_queue_group { |
| 597 | struct pqi_ctrl_info *ctrl_info; /* backpointer */ |
| 598 | u16 iq_id[2]; |
| 599 | u16 oq_id; |
| 600 | u16 int_msg_num; |
| 601 | void *iq_element_array[2]; |
| 602 | void *oq_element_array; |
| 603 | dma_addr_t iq_element_array_bus_addr[2]; |
| 604 | dma_addr_t oq_element_array_bus_addr; |
| 605 | __le32 __iomem *iq_pi[2]; |
| 606 | pqi_index_t iq_pi_copy[2]; |
| 607 | volatile pqi_index_t *iq_ci[2]; |
| 608 | volatile pqi_index_t *oq_pi; |
| 609 | dma_addr_t iq_ci_bus_addr[2]; |
| 610 | dma_addr_t oq_pi_bus_addr; |
| 611 | __le32 __iomem *oq_ci; |
| 612 | pqi_index_t oq_ci_copy; |
| 613 | spinlock_t submit_lock[2]; /* protect submission queue */ |
| 614 | struct list_head request_list[2]; |
| 615 | }; |
| 616 | |
| 617 | struct pqi_event_queue { |
| 618 | u16 oq_id; |
| 619 | u16 int_msg_num; |
| 620 | void *oq_element_array; |
| 621 | volatile pqi_index_t *oq_pi; |
| 622 | dma_addr_t oq_element_array_bus_addr; |
| 623 | dma_addr_t oq_pi_bus_addr; |
| 624 | __le32 __iomem *oq_ci; |
| 625 | pqi_index_t oq_ci_copy; |
| 626 | }; |
| 627 | |
| 628 | #define PQI_DEFAULT_QUEUE_GROUP 0 |
| 629 | #define PQI_MAX_QUEUE_GROUPS PQI_MAX_MSIX_VECTORS |
| 630 | |
| 631 | struct pqi_encryption_info { |
| 632 | u16 data_encryption_key_index; |
| 633 | u32 encrypt_tweak_lower; |
| 634 | u32 encrypt_tweak_upper; |
| 635 | }; |
| 636 | |
Kevin Barnett | 98f8766 | 2017-05-03 18:53:11 -0500 | [diff] [blame] | 637 | #pragma pack(1) |
| 638 | |
| 639 | #define PQI_CONFIG_TABLE_SIGNATURE "CFGTABLE" |
| 640 | #define PQI_CONFIG_TABLE_MAX_LENGTH ((u16)~0) |
| 641 | |
| 642 | /* configuration table section IDs */ |
| 643 | #define PQI_CONFIG_TABLE_SECTION_GENERAL_INFO 0 |
| 644 | #define PQI_CONFIG_TABLE_SECTION_FIRMWARE_FEATURES 1 |
| 645 | #define PQI_CONFIG_TABLE_SECTION_FIRMWARE_ERRATA 2 |
| 646 | #define PQI_CONFIG_TABLE_SECTION_DEBUG 3 |
| 647 | #define PQI_CONFIG_TABLE_SECTION_HEARTBEAT 4 |
| 648 | |
| 649 | struct pqi_config_table { |
| 650 | u8 signature[8]; /* "CFGTABLE" */ |
| 651 | __le32 first_section_offset; /* offset in bytes from the base */ |
| 652 | /* address of this table to the */ |
| 653 | /* first section */ |
| 654 | }; |
| 655 | |
| 656 | struct pqi_config_table_section_header { |
| 657 | __le16 section_id; /* as defined by the */ |
| 658 | /* PQI_CONFIG_TABLE_SECTION_* */ |
| 659 | /* manifest constants above */ |
| 660 | __le16 next_section_offset; /* offset in bytes from base */ |
| 661 | /* address of the table of the */ |
| 662 | /* next section or 0 if last entry */ |
| 663 | }; |
| 664 | |
| 665 | struct pqi_config_table_general_info { |
| 666 | struct pqi_config_table_section_header header; |
| 667 | __le32 section_length; /* size of this section in bytes */ |
| 668 | /* including the section header */ |
| 669 | __le32 max_outstanding_requests; /* max. outstanding */ |
| 670 | /* commands supported by */ |
| 671 | /* the controller */ |
| 672 | __le32 max_sg_size; /* max. transfer size of a single */ |
| 673 | /* command */ |
| 674 | __le32 max_sg_per_request; /* max. number of scatter-gather */ |
| 675 | /* entries supported in a single */ |
| 676 | /* command */ |
| 677 | }; |
| 678 | |
| 679 | struct pqi_config_table_debug { |
| 680 | struct pqi_config_table_section_header header; |
| 681 | __le32 scratchpad; |
| 682 | }; |
| 683 | |
| 684 | struct pqi_config_table_heartbeat { |
| 685 | struct pqi_config_table_section_header header; |
| 686 | __le32 heartbeat_counter; |
| 687 | }; |
| 688 | |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 689 | #define PQI_MAX_OUTSTANDING_REQUESTS ((u32)~0) |
| 690 | #define PQI_MAX_TRANSFER_SIZE (4 * 1024U * 1024U) |
| 691 | |
| 692 | #define RAID_MAP_MAX_ENTRIES 1024 |
| 693 | |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 694 | #define PQI_PHYSICAL_DEVICE_BUS 0 |
| 695 | #define PQI_RAID_VOLUME_BUS 1 |
| 696 | #define PQI_HBA_BUS 2 |
Kevin Barnett | bd10cf0 | 2017-05-03 18:54:12 -0500 | [diff] [blame^] | 697 | #define PQI_EXTERNAL_RAID_VOLUME_BUS 3 |
| 698 | #define PQI_MAX_BUS PQI_EXTERNAL_RAID_VOLUME_BUS |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 699 | |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 700 | struct report_lun_header { |
| 701 | __be32 list_length; |
| 702 | u8 extended_response; |
| 703 | u8 reserved[3]; |
| 704 | }; |
| 705 | |
| 706 | struct report_log_lun_extended_entry { |
| 707 | u8 lunid[8]; |
| 708 | u8 volume_id[16]; |
| 709 | }; |
| 710 | |
| 711 | struct report_log_lun_extended { |
| 712 | struct report_lun_header header; |
| 713 | struct report_log_lun_extended_entry lun_entries[1]; |
| 714 | }; |
| 715 | |
| 716 | struct report_phys_lun_extended_entry { |
| 717 | u8 lunid[8]; |
| 718 | __be64 wwid; |
| 719 | u8 device_type; |
| 720 | u8 device_flags; |
| 721 | u8 lun_count; /* number of LUNs in a multi-LUN device */ |
| 722 | u8 redundant_paths; |
| 723 | u32 aio_handle; |
| 724 | }; |
| 725 | |
| 726 | /* for device_flags field of struct report_phys_lun_extended_entry */ |
| 727 | #define REPORT_PHYS_LUN_DEV_FLAG_NON_DISK 0x1 |
| 728 | #define REPORT_PHYS_LUN_DEV_FLAG_AIO_ENABLED 0x8 |
| 729 | |
| 730 | struct report_phys_lun_extended { |
| 731 | struct report_lun_header header; |
| 732 | struct report_phys_lun_extended_entry lun_entries[1]; |
| 733 | }; |
| 734 | |
| 735 | struct raid_map_disk_data { |
| 736 | u32 aio_handle; |
| 737 | u8 xor_mult[2]; |
| 738 | u8 reserved[2]; |
| 739 | }; |
| 740 | |
| 741 | /* constants for flags field of RAID map */ |
| 742 | #define RAID_MAP_ENCRYPTION_ENABLED 0x1 |
| 743 | |
| 744 | struct raid_map { |
| 745 | __le32 structure_size; /* size of entire structure in bytes */ |
| 746 | __le32 volume_blk_size; /* bytes / block in the volume */ |
| 747 | __le64 volume_blk_cnt; /* logical blocks on the volume */ |
| 748 | u8 phys_blk_shift; /* shift factor to convert between */ |
| 749 | /* units of logical blocks and */ |
| 750 | /* physical disk blocks */ |
| 751 | u8 parity_rotation_shift; /* shift factor to convert between */ |
| 752 | /* units of logical stripes and */ |
| 753 | /* physical stripes */ |
| 754 | __le16 strip_size; /* blocks used on each disk / stripe */ |
| 755 | __le64 disk_starting_blk; /* first disk block used in volume */ |
| 756 | __le64 disk_blk_cnt; /* disk blocks used by volume / disk */ |
| 757 | __le16 data_disks_per_row; /* data disk entries / row in the map */ |
| 758 | __le16 metadata_disks_per_row; /* mirror/parity disk entries / row */ |
| 759 | /* in the map */ |
| 760 | __le16 row_cnt; /* rows in each layout map */ |
| 761 | __le16 layout_map_count; /* layout maps (1 map per */ |
| 762 | /* mirror parity group) */ |
| 763 | __le16 flags; |
| 764 | __le16 data_encryption_key_index; |
| 765 | u8 reserved[16]; |
| 766 | struct raid_map_disk_data disk_data[RAID_MAP_MAX_ENTRIES]; |
| 767 | }; |
| 768 | |
| 769 | #pragma pack() |
| 770 | |
| 771 | #define RAID_CTLR_LUNID "\0\0\0\0\0\0\0\0" |
| 772 | |
| 773 | struct pqi_scsi_dev { |
| 774 | int devtype; /* as reported by INQUIRY commmand */ |
| 775 | u8 device_type; /* as reported by */ |
| 776 | /* BMIC_IDENTIFY_PHYSICAL_DEVICE */ |
| 777 | /* only valid for devtype = TYPE_DISK */ |
| 778 | int bus; |
| 779 | int target; |
| 780 | int lun; |
| 781 | u8 scsi3addr[8]; |
| 782 | __be64 wwid; |
| 783 | u8 volume_id[16]; |
| 784 | u8 is_physical_device : 1; |
Kevin Barnett | bd10cf0 | 2017-05-03 18:54:12 -0500 | [diff] [blame^] | 785 | u8 is_external_raid_device : 1; |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 786 | u8 target_lun_valid : 1; |
| 787 | u8 expose_device : 1; |
| 788 | u8 no_uld_attach : 1; |
| 789 | u8 aio_enabled : 1; /* only valid for physical disks */ |
| 790 | u8 device_gone : 1; |
| 791 | u8 new_device : 1; |
| 792 | u8 keep_device : 1; |
| 793 | u8 volume_offline : 1; |
Kevin Barnett | 7561a7e | 2017-05-03 18:52:58 -0500 | [diff] [blame] | 794 | bool in_reset; |
| 795 | bool device_offline; |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 796 | u8 vendor[8]; /* bytes 8-15 of inquiry data */ |
| 797 | u8 model[16]; /* bytes 16-31 of inquiry data */ |
| 798 | u64 sas_address; |
| 799 | u8 raid_level; |
| 800 | u16 queue_depth; /* max. queue_depth for this device */ |
| 801 | u16 advertised_queue_depth; |
| 802 | u32 aio_handle; |
| 803 | u8 volume_status; |
| 804 | u8 active_path_index; |
| 805 | u8 path_map; |
| 806 | u8 bay; |
| 807 | u8 box[8]; |
| 808 | u16 phys_connector[8]; |
| 809 | int offload_configured; /* I/O accel RAID offload configured */ |
| 810 | int offload_enabled; /* I/O accel RAID offload enabled */ |
| 811 | int offload_enabled_pending; |
| 812 | int offload_to_mirror; /* Send next I/O accelerator RAID */ |
| 813 | /* offload request to mirror drive. */ |
| 814 | struct raid_map *raid_map; /* I/O accelerator RAID map */ |
| 815 | |
| 816 | struct pqi_sas_port *sas_port; |
| 817 | struct scsi_device *sdev; |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 818 | |
| 819 | struct list_head scsi_device_list_entry; |
| 820 | struct list_head new_device_list_entry; |
| 821 | struct list_head add_list_entry; |
| 822 | struct list_head delete_list_entry; |
Kevin Barnett | 7561a7e | 2017-05-03 18:52:58 -0500 | [diff] [blame] | 823 | |
| 824 | atomic_t scsi_cmds_outstanding; |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 825 | }; |
| 826 | |
| 827 | /* VPD inquiry pages */ |
| 828 | #define SCSI_VPD_SUPPORTED_PAGES 0x0 /* standard page */ |
| 829 | #define SCSI_VPD_DEVICE_ID 0x83 /* standard page */ |
| 830 | #define CISS_VPD_LV_DEVICE_GEOMETRY 0xc1 /* vendor-specific page */ |
| 831 | #define CISS_VPD_LV_OFFLOAD_STATUS 0xc2 /* vendor-specific page */ |
| 832 | #define CISS_VPD_LV_STATUS 0xc3 /* vendor-specific page */ |
| 833 | |
| 834 | #define VPD_PAGE (1 << 8) |
| 835 | |
| 836 | #pragma pack(1) |
| 837 | |
| 838 | /* structure for CISS_VPD_LV_STATUS */ |
| 839 | struct ciss_vpd_logical_volume_status { |
| 840 | u8 peripheral_info; |
| 841 | u8 page_code; |
| 842 | u8 reserved; |
| 843 | u8 page_length; |
| 844 | u8 volume_status; |
| 845 | u8 reserved2[3]; |
| 846 | __be32 flags; |
| 847 | }; |
| 848 | |
| 849 | #pragma pack() |
| 850 | |
| 851 | /* constants for volume_status field of ciss_vpd_logical_volume_status */ |
| 852 | #define CISS_LV_OK 0 |
| 853 | #define CISS_LV_FAILED 1 |
| 854 | #define CISS_LV_NOT_CONFIGURED 2 |
| 855 | #define CISS_LV_DEGRADED 3 |
| 856 | #define CISS_LV_READY_FOR_RECOVERY 4 |
| 857 | #define CISS_LV_UNDERGOING_RECOVERY 5 |
| 858 | #define CISS_LV_WRONG_PHYSICAL_DRIVE_REPLACED 6 |
| 859 | #define CISS_LV_PHYSICAL_DRIVE_CONNECTION_PROBLEM 7 |
| 860 | #define CISS_LV_HARDWARE_OVERHEATING 8 |
| 861 | #define CISS_LV_HARDWARE_HAS_OVERHEATED 9 |
| 862 | #define CISS_LV_UNDERGOING_EXPANSION 10 |
| 863 | #define CISS_LV_NOT_AVAILABLE 11 |
| 864 | #define CISS_LV_QUEUED_FOR_EXPANSION 12 |
| 865 | #define CISS_LV_DISABLED_SCSI_ID_CONFLICT 13 |
| 866 | #define CISS_LV_EJECTED 14 |
| 867 | #define CISS_LV_UNDERGOING_ERASE 15 |
| 868 | /* state 16 not used */ |
| 869 | #define CISS_LV_READY_FOR_PREDICTIVE_SPARE_REBUILD 17 |
| 870 | #define CISS_LV_UNDERGOING_RPI 18 |
| 871 | #define CISS_LV_PENDING_RPI 19 |
| 872 | #define CISS_LV_ENCRYPTED_NO_KEY 20 |
| 873 | /* state 21 not used */ |
| 874 | #define CISS_LV_UNDERGOING_ENCRYPTION 22 |
| 875 | #define CISS_LV_UNDERGOING_ENCRYPTION_REKEYING 23 |
| 876 | #define CISS_LV_ENCRYPTED_IN_NON_ENCRYPTED_CONTROLLER 24 |
| 877 | #define CISS_LV_PENDING_ENCRYPTION 25 |
| 878 | #define CISS_LV_PENDING_ENCRYPTION_REKEYING 26 |
| 879 | #define CISS_LV_NOT_SUPPORTED 27 |
| 880 | #define CISS_LV_STATUS_UNAVAILABLE 255 |
| 881 | |
| 882 | /* constants for flags field of ciss_vpd_logical_volume_status */ |
| 883 | #define CISS_LV_FLAGS_NO_HOST_IO 0x1 /* volume not available for */ |
| 884 | /* host I/O */ |
| 885 | |
| 886 | /* for SAS hosts and SAS expanders */ |
| 887 | struct pqi_sas_node { |
| 888 | struct device *parent_dev; |
| 889 | struct list_head port_list_head; |
| 890 | }; |
| 891 | |
| 892 | struct pqi_sas_port { |
| 893 | struct list_head port_list_entry; |
| 894 | u64 sas_address; |
| 895 | struct sas_port *port; |
| 896 | int next_phy_index; |
| 897 | struct list_head phy_list_head; |
| 898 | struct pqi_sas_node *parent_node; |
| 899 | struct sas_rphy *rphy; |
| 900 | }; |
| 901 | |
| 902 | struct pqi_sas_phy { |
| 903 | struct list_head phy_list_entry; |
| 904 | struct sas_phy *phy; |
| 905 | struct pqi_sas_port *parent_port; |
| 906 | bool added_to_port; |
| 907 | }; |
| 908 | |
| 909 | struct pqi_io_request { |
| 910 | atomic_t refcount; |
| 911 | u16 index; |
| 912 | void (*io_complete_callback)(struct pqi_io_request *io_request, |
| 913 | void *context); |
| 914 | void *context; |
| 915 | int status; |
| 916 | struct scsi_cmnd *scmd; |
| 917 | void *error_info; |
| 918 | struct pqi_sg_descriptor *sg_chain_buffer; |
| 919 | dma_addr_t sg_chain_buffer_dma_handle; |
| 920 | void *iu; |
| 921 | struct list_head request_list_entry; |
| 922 | }; |
| 923 | |
Kevin Barnett | 6a50d6a | 2017-05-03 18:52:52 -0500 | [diff] [blame] | 924 | #define PQI_NUM_SUPPORTED_EVENTS 6 |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 925 | |
| 926 | struct pqi_event { |
| 927 | bool pending; |
| 928 | u8 event_type; |
| 929 | __le16 event_id; |
| 930 | __le32 additional_event_id; |
| 931 | }; |
| 932 | |
Kevin Barnett | 5e6429df | 2016-08-31 14:54:53 -0500 | [diff] [blame] | 933 | #define PQI_RESERVED_IO_SLOTS_LUN_RESET 1 |
| 934 | #define PQI_RESERVED_IO_SLOTS_EVENT_ACK PQI_NUM_SUPPORTED_EVENTS |
| 935 | #define PQI_RESERVED_IO_SLOTS_SYNCHRONOUS_REQUESTS 3 |
| 936 | #define PQI_RESERVED_IO_SLOTS \ |
| 937 | (PQI_RESERVED_IO_SLOTS_LUN_RESET + PQI_RESERVED_IO_SLOTS_EVENT_ACK + \ |
| 938 | PQI_RESERVED_IO_SLOTS_SYNCHRONOUS_REQUESTS) |
| 939 | |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 940 | struct pqi_ctrl_info { |
| 941 | unsigned int ctrl_id; |
| 942 | struct pci_dev *pci_dev; |
| 943 | char firmware_version[11]; |
| 944 | void __iomem *iomem_base; |
| 945 | struct pqi_ctrl_registers __iomem *registers; |
| 946 | struct pqi_device_registers __iomem *pqi_registers; |
| 947 | u32 max_sg_entries; |
| 948 | u32 config_table_offset; |
| 949 | u32 config_table_length; |
| 950 | u16 max_inbound_queues; |
| 951 | u16 max_elements_per_iq; |
| 952 | u16 max_iq_element_length; |
| 953 | u16 max_outbound_queues; |
| 954 | u16 max_elements_per_oq; |
| 955 | u16 max_oq_element_length; |
| 956 | u32 max_transfer_size; |
| 957 | u32 max_outstanding_requests; |
| 958 | u32 max_io_slots; |
| 959 | unsigned int scsi_ml_can_queue; |
| 960 | unsigned short sg_tablesize; |
| 961 | unsigned int max_sectors; |
| 962 | u32 error_buffer_length; |
| 963 | void *error_buffer; |
| 964 | dma_addr_t error_buffer_dma_handle; |
| 965 | size_t sg_chain_buffer_length; |
| 966 | unsigned int num_queue_groups; |
Kevin Barnett | 061ef06 | 2017-05-03 18:53:05 -0500 | [diff] [blame] | 967 | u16 max_hw_queue_index; |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 968 | u16 num_elements_per_iq; |
| 969 | u16 num_elements_per_oq; |
| 970 | u16 max_inbound_iu_length_per_firmware; |
| 971 | u16 max_inbound_iu_length; |
| 972 | unsigned int max_sg_per_iu; |
| 973 | void *admin_queue_memory_base; |
| 974 | u32 admin_queue_memory_length; |
| 975 | dma_addr_t admin_queue_memory_base_dma_handle; |
| 976 | void *queue_memory_base; |
| 977 | u32 queue_memory_length; |
| 978 | dma_addr_t queue_memory_base_dma_handle; |
| 979 | struct pqi_admin_queues admin_queues; |
| 980 | struct pqi_queue_group queue_groups[PQI_MAX_QUEUE_GROUPS]; |
| 981 | struct pqi_event_queue event_queue; |
Kevin Barnett | 061ef06 | 2017-05-03 18:53:05 -0500 | [diff] [blame] | 982 | enum pqi_irq_mode irq_mode; |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 983 | int max_msix_vectors; |
| 984 | int num_msix_vectors_enabled; |
| 985 | int num_msix_vectors_initialized; |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 986 | int event_irq; |
| 987 | struct Scsi_Host *scsi_host; |
| 988 | |
| 989 | struct mutex scan_mutex; |
Kevin Barnett | 7561a7e | 2017-05-03 18:52:58 -0500 | [diff] [blame] | 990 | struct mutex lun_reset_mutex; |
| 991 | bool controller_online; |
| 992 | bool block_requests; |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 993 | u8 inbound_spanning_supported : 1; |
| 994 | u8 outbound_spanning_supported : 1; |
| 995 | u8 pqi_mode_enabled : 1; |
Kevin Barnett | 061ef06 | 2017-05-03 18:53:05 -0500 | [diff] [blame] | 996 | u8 update_time_worker_scheduled : 1; |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 997 | |
| 998 | struct list_head scsi_device_list; |
| 999 | spinlock_t scsi_device_list_lock; |
| 1000 | |
| 1001 | struct delayed_work rescan_work; |
| 1002 | struct delayed_work update_time_work; |
| 1003 | |
| 1004 | struct pqi_sas_node *sas_host; |
| 1005 | u64 sas_address; |
| 1006 | |
| 1007 | struct pqi_io_request *io_request_pool; |
| 1008 | u16 next_io_request_slot; |
| 1009 | |
Kevin Barnett | 6a50d6a | 2017-05-03 18:52:52 -0500 | [diff] [blame] | 1010 | struct pqi_event events[PQI_NUM_SUPPORTED_EVENTS]; |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 1011 | struct work_struct event_work; |
| 1012 | |
| 1013 | atomic_t num_interrupts; |
| 1014 | int previous_num_interrupts; |
Kevin Barnett | 98f8766 | 2017-05-03 18:53:11 -0500 | [diff] [blame] | 1015 | u32 previous_heartbeat_count; |
| 1016 | __le32 __iomem *heartbeat_counter; |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 1017 | struct timer_list heartbeat_timer; |
| 1018 | |
| 1019 | struct semaphore sync_request_sem; |
Kevin Barnett | 7561a7e | 2017-05-03 18:52:58 -0500 | [diff] [blame] | 1020 | atomic_t num_busy_threads; |
| 1021 | atomic_t num_blocked_threads; |
| 1022 | wait_queue_head_t block_requests_wait; |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 1023 | }; |
| 1024 | |
Kevin Barnett | ff6abb7 | 2016-08-31 14:54:41 -0500 | [diff] [blame] | 1025 | enum pqi_ctrl_mode { |
Kevin Barnett | 162d775 | 2017-05-03 18:52:46 -0500 | [diff] [blame] | 1026 | SIS_MODE = 0, |
Kevin Barnett | ff6abb7 | 2016-08-31 14:54:41 -0500 | [diff] [blame] | 1027 | PQI_MODE |
| 1028 | }; |
| 1029 | |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 1030 | /* |
| 1031 | * assume worst case: SATA queue depth of 31 minus 4 internal firmware commands |
| 1032 | */ |
| 1033 | #define PQI_PHYSICAL_DISK_DEFAULT_MAX_QUEUE_DEPTH 27 |
| 1034 | |
| 1035 | /* 0 = no limit */ |
| 1036 | #define PQI_LOGICAL_DRIVE_DEFAULT_MAX_QUEUE_DEPTH 0 |
| 1037 | |
| 1038 | /* CISS commands */ |
| 1039 | #define CISS_READ 0xc0 |
| 1040 | #define CISS_REPORT_LOG 0xc2 /* Report Logical LUNs */ |
| 1041 | #define CISS_REPORT_PHYS 0xc3 /* Report Physical LUNs */ |
| 1042 | #define CISS_GET_RAID_MAP 0xc8 |
| 1043 | |
| 1044 | /* constants for CISS_REPORT_LOG/CISS_REPORT_PHYS commands */ |
| 1045 | #define CISS_REPORT_LOG_EXTENDED 0x1 |
| 1046 | #define CISS_REPORT_PHYS_EXTENDED 0x2 |
| 1047 | |
| 1048 | /* BMIC commands */ |
| 1049 | #define BMIC_IDENTIFY_CONTROLLER 0x11 |
| 1050 | #define BMIC_IDENTIFY_PHYSICAL_DEVICE 0x15 |
| 1051 | #define BMIC_READ 0x26 |
| 1052 | #define BMIC_WRITE 0x27 |
| 1053 | #define BMIC_SENSE_CONTROLLER_PARAMETERS 0x64 |
| 1054 | #define BMIC_SENSE_SUBSYSTEM_INFORMATION 0x66 |
| 1055 | #define BMIC_WRITE_HOST_WELLNESS 0xa5 |
| 1056 | #define BMIC_CACHE_FLUSH 0xc2 |
| 1057 | |
Kevin Barnett | cbe0c7b | 2017-05-03 18:53:48 -0500 | [diff] [blame] | 1058 | #define SA_CACHE_FLUSH 0x1 |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 1059 | |
| 1060 | #define MASKED_DEVICE(lunid) ((lunid)[3] & 0xc0) |
Kevin Barnett | bd10cf0 | 2017-05-03 18:54:12 -0500 | [diff] [blame^] | 1061 | #define CISS_GET_LEVEL_2_BUS(lunid) ((lunid)[7] & 0x3f) |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 1062 | #define CISS_GET_LEVEL_2_TARGET(lunid) ((lunid)[6]) |
| 1063 | #define CISS_GET_DRIVE_NUMBER(lunid) \ |
Kevin Barnett | bd10cf0 | 2017-05-03 18:54:12 -0500 | [diff] [blame^] | 1064 | (((CISS_GET_LEVEL_2_BUS((lunid)) - 1) << 8) + \ |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 1065 | CISS_GET_LEVEL_2_TARGET((lunid))) |
| 1066 | |
| 1067 | #define NO_TIMEOUT ((unsigned long) -1) |
| 1068 | |
| 1069 | #pragma pack(1) |
| 1070 | |
| 1071 | struct bmic_identify_controller { |
| 1072 | u8 configured_logical_drive_count; |
| 1073 | __le32 configuration_signature; |
| 1074 | u8 firmware_version[4]; |
| 1075 | u8 reserved[145]; |
| 1076 | __le16 extended_logical_unit_count; |
| 1077 | u8 reserved1[34]; |
| 1078 | __le16 firmware_build_number; |
| 1079 | u8 reserved2[100]; |
| 1080 | u8 controller_mode; |
| 1081 | u8 reserved3[32]; |
| 1082 | }; |
| 1083 | |
| 1084 | struct bmic_identify_physical_device { |
| 1085 | u8 scsi_bus; /* SCSI Bus number on controller */ |
| 1086 | u8 scsi_id; /* SCSI ID on this bus */ |
| 1087 | __le16 block_size; /* sector size in bytes */ |
| 1088 | __le32 total_blocks; /* number for sectors on drive */ |
| 1089 | __le32 reserved_blocks; /* controller reserved (RIS) */ |
| 1090 | u8 model[40]; /* Physical Drive Model */ |
| 1091 | u8 serial_number[40]; /* Drive Serial Number */ |
| 1092 | u8 firmware_revision[8]; /* drive firmware revision */ |
| 1093 | u8 scsi_inquiry_bits; /* inquiry byte 7 bits */ |
| 1094 | u8 compaq_drive_stamp; /* 0 means drive not stamped */ |
| 1095 | u8 last_failure_reason; |
| 1096 | u8 flags; |
| 1097 | u8 more_flags; |
| 1098 | u8 scsi_lun; /* SCSI LUN for phys drive */ |
| 1099 | u8 yet_more_flags; |
| 1100 | u8 even_more_flags; |
| 1101 | __le32 spi_speed_rules; |
| 1102 | u8 phys_connector[2]; /* connector number on controller */ |
| 1103 | u8 phys_box_on_bus; /* phys enclosure this drive resides */ |
| 1104 | u8 phys_bay_in_box; /* phys drv bay this drive resides */ |
| 1105 | __le32 rpm; /* drive rotational speed in RPM */ |
| 1106 | u8 device_type; /* type of drive */ |
| 1107 | u8 sata_version; /* only valid when device_type = */ |
| 1108 | /* BMIC_DEVICE_TYPE_SATA */ |
| 1109 | __le64 big_total_block_count; |
| 1110 | __le64 ris_starting_lba; |
| 1111 | __le32 ris_size; |
| 1112 | u8 wwid[20]; |
| 1113 | u8 controller_phy_map[32]; |
| 1114 | __le16 phy_count; |
| 1115 | u8 phy_connected_dev_type[256]; |
| 1116 | u8 phy_to_drive_bay_num[256]; |
| 1117 | __le16 phy_to_attached_dev_index[256]; |
| 1118 | u8 box_index; |
| 1119 | u8 reserved; |
| 1120 | __le16 extra_physical_drive_flags; |
| 1121 | u8 negotiated_link_rate[256]; |
| 1122 | u8 phy_to_phy_map[256]; |
| 1123 | u8 redundant_path_present_map; |
| 1124 | u8 redundant_path_failure_map; |
| 1125 | u8 active_path_number; |
| 1126 | __le16 alternate_paths_phys_connector[8]; |
| 1127 | u8 alternate_paths_phys_box_on_port[8]; |
| 1128 | u8 multi_lun_device_lun_count; |
| 1129 | u8 minimum_good_fw_revision[8]; |
| 1130 | u8 unique_inquiry_bytes[20]; |
Kevin Barnett | 1be42f4 | 2017-05-03 18:53:42 -0500 | [diff] [blame] | 1131 | u8 current_temperature_degrees; |
| 1132 | u8 temperature_threshold_degrees; |
| 1133 | u8 max_temperature_degrees; |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 1134 | u8 logical_blocks_per_phys_block_exp; |
| 1135 | __le16 current_queue_depth_limit; |
| 1136 | u8 switch_name[10]; |
| 1137 | __le16 switch_port; |
| 1138 | u8 alternate_paths_switch_name[40]; |
| 1139 | u8 alternate_paths_switch_port[8]; |
| 1140 | __le16 power_on_hours; |
| 1141 | __le16 percent_endurance_used; |
| 1142 | u8 drive_authentication; |
| 1143 | u8 smart_carrier_authentication; |
| 1144 | u8 smart_carrier_app_fw_version; |
| 1145 | u8 smart_carrier_bootloader_fw_version; |
Kevin Barnett | 1be42f4 | 2017-05-03 18:53:42 -0500 | [diff] [blame] | 1146 | u8 sanitize_flags; |
| 1147 | u8 encryption_key_flags; |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 1148 | u8 encryption_key_name[64]; |
| 1149 | __le32 misc_drive_flags; |
| 1150 | __le16 dek_index; |
Kevin Barnett | 1be42f4 | 2017-05-03 18:53:42 -0500 | [diff] [blame] | 1151 | __le16 hba_drive_encryption_flags; |
| 1152 | __le16 max_overwrite_time; |
| 1153 | __le16 max_block_erase_time; |
| 1154 | __le16 max_crypto_erase_time; |
| 1155 | u8 connector_info[5]; |
| 1156 | u8 connector_name[8][8]; |
| 1157 | u8 page_83_identifier[16]; |
| 1158 | u8 maximum_link_rate[256]; |
| 1159 | u8 negotiated_physical_link_rate[256]; |
| 1160 | u8 box_connector_name[8]; |
| 1161 | u8 padding_to_multiple_of_512[9]; |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 1162 | }; |
| 1163 | |
| 1164 | #pragma pack() |
| 1165 | |
| 1166 | int pqi_add_sas_host(struct Scsi_Host *shost, struct pqi_ctrl_info *ctrl_info); |
| 1167 | void pqi_delete_sas_host(struct pqi_ctrl_info *ctrl_info); |
| 1168 | int pqi_add_sas_device(struct pqi_sas_node *pqi_sas_node, |
| 1169 | struct pqi_scsi_dev *device); |
| 1170 | void pqi_remove_sas_device(struct pqi_scsi_dev *device); |
| 1171 | struct pqi_scsi_dev *pqi_find_device_by_sas_rphy( |
| 1172 | struct pqi_ctrl_info *ctrl_info, struct sas_rphy *rphy); |
Kevin Barnett | 7561a7e | 2017-05-03 18:52:58 -0500 | [diff] [blame] | 1173 | void pqi_prep_for_scsi_done(struct scsi_cmnd *scmd); |
Kevin Barnett | 6c22376 | 2016-06-27 16:41:00 -0500 | [diff] [blame] | 1174 | |
| 1175 | extern struct sas_function_template pqi_sas_transport_functions; |
| 1176 | |
| 1177 | #if !defined(readq) |
| 1178 | #define readq readq |
| 1179 | static inline u64 readq(const volatile void __iomem *addr) |
| 1180 | { |
| 1181 | u32 lower32; |
| 1182 | u32 upper32; |
| 1183 | |
| 1184 | lower32 = readl(addr); |
| 1185 | upper32 = readl(addr + 4); |
| 1186 | |
| 1187 | return ((u64)upper32 << 32) | lower32; |
| 1188 | } |
| 1189 | #endif |
| 1190 | |
| 1191 | #if !defined(writeq) |
| 1192 | #define writeq writeq |
| 1193 | static inline void writeq(u64 value, volatile void __iomem *addr) |
| 1194 | { |
| 1195 | u32 lower32; |
| 1196 | u32 upper32; |
| 1197 | |
| 1198 | lower32 = lower_32_bits(value); |
| 1199 | upper32 = upper_32_bits(value); |
| 1200 | |
| 1201 | writel(lower32, addr); |
| 1202 | writel(upper32, addr + 4); |
| 1203 | } |
| 1204 | #endif |
| 1205 | |
| 1206 | #endif /* _SMARTPQI_H */ |