0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef _PMCRAID_H
0012 #define _PMCRAID_H
0013
0014 #include <linux/types.h>
0015 #include <linux/completion.h>
0016 #include <linux/list.h>
0017 #include <scsi/scsi.h>
0018 #include <scsi/scsi_cmnd.h>
0019 #include <linux/cdev.h>
0020 #include <net/netlink.h>
0021 #include <net/genetlink.h>
0022 #include <linux/connector.h>
0023
0024
0025
0026
0027
0028
0029 #define PMCRAID_DRIVER_NAME "PMC MaxRAID"
0030 #define PMCRAID_DEVFILE "pmcsas"
0031 #define PMCRAID_DRIVER_VERSION "1.0.3"
0032
0033 #define PMCRAID_FW_VERSION_1 0x002
0034
0035
0036 #define PMCRAID_MAX_ADAPTERS 1024
0037
0038
0039 #define PMC_BIT8(n) (1 << (7-n))
0040 #define PMC_BIT16(n) (1 << (15-n))
0041 #define PMC_BIT32(n) (1 << (31-n))
0042
0043
0044 #define PCI_VENDOR_ID_PMC 0x11F8
0045 #define PCI_DEVICE_ID_PMC_MAXRAID 0x5220
0046
0047
0048
0049
0050
0051
0052
0053 #define PMCRAID_MAX_CMD 1024
0054 #define PMCRAID_MAX_IO_CMD 1020
0055 #define PMCRAID_MAX_HCAM_CMD 2
0056 #define PMCRAID_MAX_INTERNAL_CMD 2
0057
0058
0059
0060
0061
0062 #define PMCRAID_IOADLS_INTERNAL 27
0063 #define PMCRAID_IOADLS_EXTERNAL 37
0064 #define PMCRAID_MAX_IOADLS PMCRAID_IOADLS_INTERNAL
0065
0066
0067
0068
0069
0070
0071 #define HRRQ_ENTRY_SIZE sizeof(__le32)
0072 #define PMCRAID_IOARCB_ALIGNMENT 32
0073 #define PMCRAID_IOADL_ALIGNMENT 16
0074 #define PMCRAID_IOASA_ALIGNMENT 4
0075 #define PMCRAID_NUM_MSIX_VECTORS 16
0076
0077
0078 #define PMCRAID_VENDOR_ID_LEN 8
0079 #define PMCRAID_PRODUCT_ID_LEN 16
0080 #define PMCRAID_SERIAL_NUM_LEN 8
0081 #define PMCRAID_LUN_LEN 8
0082 #define PMCRAID_MAX_CDB_LEN 16
0083 #define PMCRAID_DEVICE_ID_LEN 8
0084 #define PMCRAID_SENSE_DATA_LEN 256
0085 #define PMCRAID_ADD_CMD_PARAM_LEN 48
0086
0087 #define PMCRAID_MAX_BUS_TO_SCAN 1
0088 #define PMCRAID_MAX_NUM_TARGETS_PER_BUS 256
0089 #define PMCRAID_MAX_NUM_LUNS_PER_TARGET 8
0090
0091
0092 #define PMCRAID_IOA_BUS_ID 0xfe
0093 #define PMCRAID_IOA_TARGET_ID 0xff
0094 #define PMCRAID_IOA_LUN_ID 0xff
0095 #define PMCRAID_VSET_BUS_ID 0x1
0096 #define PMCRAID_VSET_LUN_ID 0x0
0097 #define PMCRAID_PHYS_BUS_ID 0x0
0098 #define PMCRAID_VIRTUAL_ENCL_BUS_ID 0x8
0099 #define PMCRAID_MAX_VSET_TARGETS 0x7F
0100 #define PMCRAID_MAX_VSET_LUNS_PER_TARGET 8
0101
0102 #define PMCRAID_IOA_MAX_SECTORS 32767
0103 #define PMCRAID_VSET_MAX_SECTORS 512
0104 #define PMCRAID_MAX_CMD_PER_LUN 254
0105
0106
0107
0108
0109 #define PMCRAID_MAX_RESOURCES 256
0110
0111
0112 #define PMCRAID_QUERY_RESOURCE_STATE 0xC2
0113 #define PMCRAID_RESET_DEVICE 0xC3
0114
0115 #define ENABLE_RESET_MODIFIER 0x80
0116 #define RESET_DEVICE_LUN 0x40
0117 #define RESET_DEVICE_TARGET 0x20
0118 #define RESET_DEVICE_BUS 0x10
0119
0120 #define PMCRAID_IDENTIFY_HRRQ 0xC4
0121 #define PMCRAID_QUERY_IOA_CONFIG 0xC5
0122 #define PMCRAID_QUERY_CMD_STATUS 0xCB
0123 #define PMCRAID_ABORT_CMD 0xC7
0124
0125
0126
0127
0128 #define PMCRAID_CANCEL_ALL_REQUESTS 0xCE
0129 #define PMCRAID_SYNC_COMPLETE_AFTER_CANCEL PMC_BIT8(0)
0130
0131
0132 #define PMCRAID_HOST_CONTROLLED_ASYNC 0xCF
0133 #define PMCRAID_HCAM_CODE_CONFIG_CHANGE 0x01
0134 #define PMCRAID_HCAM_CODE_LOG_DATA 0x02
0135
0136
0137 #define PMCRAID_IOA_SHUTDOWN 0xF7
0138 #define PMCRAID_SHUTDOWN_NORMAL 0x00
0139 #define PMCRAID_SHUTDOWN_PREPARE_FOR_NORMAL 0x40
0140 #define PMCRAID_SHUTDOWN_NONE 0x100
0141 #define PMCRAID_SHUTDOWN_ABBREV 0x80
0142
0143
0144
0145
0146 #define PMCRAID_SET_SUPPORTED_DEVICES 0xFB
0147 #define ALL_DEVICES_SUPPORTED PMC_BIT8(0)
0148
0149
0150 #define PMCRAID_WR_BUF_DOWNLOAD_AND_SAVE 0x05
0151
0152
0153 #define PMCRAID_IOASC_SENSE_MASK 0xFFFFFF00
0154 #define PMCRAID_IOASC_SENSE_KEY(ioasc) ((ioasc) >> 24)
0155 #define PMCRAID_IOASC_SENSE_CODE(ioasc) (((ioasc) & 0x00ff0000) >> 16)
0156 #define PMCRAID_IOASC_SENSE_QUAL(ioasc) (((ioasc) & 0x0000ff00) >> 8)
0157 #define PMCRAID_IOASC_SENSE_STATUS(ioasc) ((ioasc) & 0x000000ff)
0158
0159 #define PMCRAID_IOASC_GOOD_COMPLETION 0x00000000
0160 #define PMCRAID_IOASC_GC_IOARCB_NOTFOUND 0x005A0000
0161 #define PMCRAID_IOASC_NR_INIT_CMD_REQUIRED 0x02040200
0162 #define PMCRAID_IOASC_NR_IOA_RESET_REQUIRED 0x02048000
0163 #define PMCRAID_IOASC_NR_SYNC_REQUIRED 0x023F0000
0164 #define PMCRAID_IOASC_ME_READ_ERROR_NO_REALLOC 0x03110C00
0165 #define PMCRAID_IOASC_HW_CANNOT_COMMUNICATE 0x04050000
0166 #define PMCRAID_IOASC_HW_DEVICE_TIMEOUT 0x04080100
0167 #define PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR 0x04448500
0168 #define PMCRAID_IOASC_HW_IOA_RESET_REQUIRED 0x04448600
0169 #define PMCRAID_IOASC_IR_INVALID_RESOURCE_HANDLE 0x05250000
0170 #define PMCRAID_IOASC_AC_TERMINATED_BY_HOST 0x0B5A0000
0171 #define PMCRAID_IOASC_UA_BUS_WAS_RESET 0x06290000
0172 #define PMCRAID_IOASC_TIME_STAMP_OUT_OF_SYNC 0x06908B00
0173 #define PMCRAID_IOASC_UA_BUS_WAS_RESET_BY_OTHER 0x06298000
0174
0175
0176 #define PMCRAID_IOASC_IOA_WAS_RESET 0x10000001
0177 #define PMCRAID_IOASC_PCI_ACCESS_ERROR 0x10000002
0178
0179
0180
0181
0182 #define PMCRAID_PCI_DEASSERT_TIMEOUT 2000
0183 #define PMCRAID_BIST_TIMEOUT 2000
0184 #define PMCRAID_AENWAIT_TIMEOUT 5000
0185 #define PMCRAID_TRANSOP_TIMEOUT 60000
0186
0187 #define PMCRAID_RESET_TIMEOUT (2 * HZ)
0188 #define PMCRAID_CHECK_FOR_RESET_TIMEOUT ((HZ / 10))
0189 #define PMCRAID_VSET_IO_TIMEOUT (60 * HZ)
0190 #define PMCRAID_INTERNAL_TIMEOUT (60 * HZ)
0191 #define PMCRAID_SHUTDOWN_TIMEOUT (150 * HZ)
0192 #define PMCRAID_RESET_BUS_TIMEOUT (60 * HZ)
0193 #define PMCRAID_RESET_HOST_TIMEOUT (150 * HZ)
0194 #define PMCRAID_REQUEST_SENSE_TIMEOUT (30 * HZ)
0195 #define PMCRAID_SET_SUP_DEV_TIMEOUT (2 * 60 * HZ)
0196
0197
0198 struct pmcraid_ioadl_desc {
0199 __le64 address;
0200 __le32 data_len;
0201 __u8 reserved[3];
0202 __u8 flags;
0203 } __attribute__((packed, aligned(PMCRAID_IOADL_ALIGNMENT)));
0204
0205
0206 #define IOADL_FLAGS_CHAINED PMC_BIT8(0)
0207 #define IOADL_FLAGS_LAST_DESC PMC_BIT8(1)
0208 #define IOADL_FLAGS_READ_LAST PMC_BIT8(1)
0209 #define IOADL_FLAGS_WRITE_LAST PMC_BIT8(1)
0210
0211
0212
0213
0214
0215
0216
0217 struct pmcraid_ioarcb_add_data {
0218 union {
0219 struct pmcraid_ioadl_desc ioadl[PMCRAID_IOADLS_INTERNAL];
0220 __u8 add_cmd_params[PMCRAID_ADD_CMD_PARAM_LEN];
0221 } u;
0222 };
0223
0224
0225
0226
0227 struct pmcraid_ioarcb {
0228 __le64 ioarcb_bus_addr;
0229 __le32 resource_handle;
0230 __le32 response_handle;
0231 __le64 ioadl_bus_addr;
0232 __le32 ioadl_length;
0233 __le32 data_transfer_length;
0234 __le64 ioasa_bus_addr;
0235 __le16 ioasa_len;
0236 __le16 cmd_timeout;
0237 __le16 add_cmd_param_offset;
0238 __le16 add_cmd_param_length;
0239 __le32 reserved1[2];
0240 __le32 reserved2;
0241 __u8 request_type;
0242 __u8 request_flags0;
0243 __u8 request_flags1;
0244 __u8 hrrq_id;
0245 __u8 cdb[PMCRAID_MAX_CDB_LEN];
0246 struct pmcraid_ioarcb_add_data add_data;
0247 };
0248
0249
0250 #define PMCRAID_IOA_RES_HANDLE 0xffffffff
0251 #define PMCRAID_INVALID_RES_HANDLE 0
0252
0253
0254 #define REQ_TYPE_SCSI 0x00
0255 #define REQ_TYPE_IOACMD 0x01
0256 #define REQ_TYPE_HCAM 0x02
0257
0258
0259 #define TRANSFER_DIR_WRITE PMC_BIT8(0)
0260 #define INHIBIT_UL_CHECK PMC_BIT8(2)
0261 #define SYNC_OVERRIDE PMC_BIT8(3)
0262 #define SYNC_COMPLETE PMC_BIT8(4)
0263 #define NO_LINK_DESCS PMC_BIT8(5)
0264
0265
0266 #define DELAY_AFTER_RESET PMC_BIT8(0)
0267 #define TASK_TAG_SIMPLE 0x10
0268 #define TASK_TAG_ORDERED 0x20
0269 #define TASK_TAG_QUEUE_HEAD 0x30
0270
0271
0272 #define HRRQ_TOGGLE_BIT 0x01
0273 #define HRRQ_RESPONSE_BIT 0x02
0274
0275
0276 struct pmcraid_ioasa_vset {
0277 __le32 failing_lba_hi;
0278 __le32 failing_lba_lo;
0279 __le32 reserved;
0280 } __attribute__((packed, aligned(4)));
0281
0282 struct pmcraid_ioasa {
0283 __le32 ioasc;
0284 __le16 returned_status_length;
0285 __le16 available_status_length;
0286 __le32 residual_data_length;
0287 __le32 ilid;
0288 __le32 fd_ioasc;
0289 __le32 fd_res_address;
0290 __le32 fd_res_handle;
0291 __le32 reserved;
0292
0293
0294 union {
0295 struct pmcraid_ioasa_vset vset;
0296 } u;
0297
0298
0299 __le16 auto_sense_length;
0300 __le16 error_data_length;
0301 __u8 sense_data[PMCRAID_SENSE_DATA_LEN];
0302 } __attribute__((packed, aligned(4)));
0303
0304 #define PMCRAID_DRIVER_ILID 0xffffffff
0305
0306
0307 struct pmcraid_config_table_entry {
0308 __u8 resource_type;
0309 __u8 bus_protocol;
0310 __le16 array_id;
0311 __u8 common_flags0;
0312 __u8 common_flags1;
0313 __u8 unique_flags0;
0314 __u8 unique_flags1;
0315 __le32 resource_handle;
0316 __le32 resource_address;
0317 __u8 device_id[PMCRAID_DEVICE_ID_LEN];
0318 __u8 lun[PMCRAID_LUN_LEN];
0319 } __attribute__((packed, aligned(4)));
0320
0321
0322 struct pmcraid_config_table_entry_ext {
0323 struct pmcraid_config_table_entry cfgte;
0324 };
0325
0326
0327 #define RES_TYPE_AF_DASD 0x00
0328 #define RES_TYPE_GSCSI 0x01
0329 #define RES_TYPE_VSET 0x02
0330 #define RES_TYPE_IOA_FP 0xFF
0331
0332 #define RES_IS_IOA(res) ((res).resource_type == RES_TYPE_IOA_FP)
0333 #define RES_IS_GSCSI(res) ((res).resource_type == RES_TYPE_GSCSI)
0334 #define RES_IS_VSET(res) ((res).resource_type == RES_TYPE_VSET)
0335 #define RES_IS_AFDASD(res) ((res).resource_type == RES_TYPE_AF_DASD)
0336
0337
0338 #define RES_TYPE_VENCLOSURE 0x8
0339
0340
0341 #define MULTIPATH_RESOURCE PMC_BIT32(0)
0342
0343
0344 #define IMPORT_MODE_MANUAL PMC_BIT8(0)
0345
0346
0347 #define RES_HANDLE_IOA 0xFFFFFFFF
0348 #define RES_HANDLE_NONE 0x00000000
0349
0350
0351 #define RES_ADDRESS_IOAFP 0xFEFFFFFF
0352 #define RES_ADDRESS_INVALID 0xFFFFFFFF
0353
0354
0355 #define RES_BUS(res_addr) (le32_to_cpu(res_addr) & 0xFF)
0356 #define RES_TARGET(res_addr) ((le32_to_cpu(res_addr) >> 16) & 0xFF)
0357 #define RES_LUN(res_addr) 0x0
0358
0359
0360 struct pmcraid_config_table {
0361 __le16 num_entries;
0362 __u8 table_format;
0363 __u8 reserved1;
0364 __u8 flags;
0365 __u8 reserved2[11];
0366 union {
0367 struct pmcraid_config_table_entry
0368 entries[PMCRAID_MAX_RESOURCES];
0369 struct pmcraid_config_table_entry_ext
0370 entries_ext[PMCRAID_MAX_RESOURCES];
0371 };
0372 } __attribute__((packed, aligned(4)));
0373
0374
0375 #define MICROCODE_UPDATE_REQUIRED PMC_BIT32(0)
0376
0377
0378
0379
0380 #define PMCRAID_HOSTRCB_LDNSIZE 4056
0381
0382
0383 struct pmcraid_hostrcb_error {
0384 __le32 fd_ioasc;
0385 __le32 fd_ra;
0386 __le32 fd_rh;
0387 __le32 prc;
0388 union {
0389 __u8 data[PMCRAID_HOSTRCB_LDNSIZE];
0390 } u;
0391 } __attribute__ ((packed, aligned(4)));
0392
0393 struct pmcraid_hcam_hdr {
0394 __u8 op_code;
0395 __u8 notification_type;
0396 __u8 notification_lost;
0397 __u8 flags;
0398 __u8 overlay_id;
0399 __u8 reserved1[3];
0400 __le32 ilid;
0401 __le32 timestamp1;
0402 __le32 timestamp2;
0403 __le32 data_len;
0404 } __attribute__((packed, aligned(4)));
0405
0406 #define PMCRAID_AEN_GROUP 0x3
0407
0408 struct pmcraid_hcam_ccn {
0409 struct pmcraid_hcam_hdr header;
0410 struct pmcraid_config_table_entry cfg_entry;
0411 struct pmcraid_config_table_entry cfg_entry_old;
0412 } __attribute__((packed, aligned(4)));
0413
0414 #define PMCRAID_CCN_EXT_SIZE 3944
0415 struct pmcraid_hcam_ccn_ext {
0416 struct pmcraid_hcam_hdr header;
0417 struct pmcraid_config_table_entry_ext cfg_entry;
0418 struct pmcraid_config_table_entry_ext cfg_entry_old;
0419 __u8 reserved[PMCRAID_CCN_EXT_SIZE];
0420 } __attribute__((packed, aligned(4)));
0421
0422 struct pmcraid_hcam_ldn {
0423 struct pmcraid_hcam_hdr header;
0424 struct pmcraid_hostrcb_error error_log;
0425 } __attribute__((packed, aligned(4)));
0426
0427
0428 #define HOSTRCB_TYPE_CCN 0xE1
0429 #define HOSTRCB_TYPE_LDN 0xE2
0430
0431
0432 #define NOTIFICATION_TYPE_ENTRY_CHANGED 0x0
0433 #define NOTIFICATION_TYPE_ENTRY_NEW 0x1
0434 #define NOTIFICATION_TYPE_ENTRY_DELETED 0x2
0435 #define NOTIFICATION_TYPE_STATE_CHANGE 0x3
0436 #define NOTIFICATION_TYPE_ENTRY_STATECHANGED 0x4
0437 #define NOTIFICATION_TYPE_ERROR_LOG 0x10
0438 #define NOTIFICATION_TYPE_INFORMATION_LOG 0x11
0439
0440 #define HOSTRCB_NOTIFICATIONS_LOST PMC_BIT8(0)
0441
0442
0443 #define HOSTRCB_INTERNAL_OP_ERROR PMC_BIT8(0)
0444 #define HOSTRCB_ERROR_RESPONSE_SENT PMC_BIT8(1)
0445
0446
0447 #define HOSTRCB_OVERLAY_ID_08 0x08
0448 #define HOSTRCB_OVERLAY_ID_09 0x09
0449 #define HOSTRCB_OVERLAY_ID_11 0x11
0450 #define HOSTRCB_OVERLAY_ID_12 0x12
0451 #define HOSTRCB_OVERLAY_ID_13 0x13
0452 #define HOSTRCB_OVERLAY_ID_14 0x14
0453 #define HOSTRCB_OVERLAY_ID_16 0x16
0454 #define HOSTRCB_OVERLAY_ID_17 0x17
0455 #define HOSTRCB_OVERLAY_ID_20 0x20
0456 #define HOSTRCB_OVERLAY_ID_FF 0xFF
0457
0458
0459 struct pmcraid_chip_details {
0460
0461 unsigned long ioastatus;
0462 unsigned long ioarrin;
0463 unsigned long mailbox;
0464 unsigned long global_intr_mask;
0465 unsigned long ioa_host_intr;
0466 unsigned long ioa_host_msix_intr;
0467 unsigned long ioa_host_intr_clr;
0468 unsigned long ioa_host_mask;
0469 unsigned long ioa_host_mask_clr;
0470 unsigned long host_ioa_intr;
0471 unsigned long host_ioa_intr_clr;
0472
0473
0474 unsigned long transop_timeout;
0475 };
0476
0477
0478 #define INTRS_TRANSITION_TO_OPERATIONAL PMC_BIT32(0)
0479 #define INTRS_IOARCB_TRANSFER_FAILED PMC_BIT32(3)
0480 #define INTRS_IOA_UNIT_CHECK PMC_BIT32(4)
0481 #define INTRS_NO_HRRQ_FOR_CMD_RESPONSE PMC_BIT32(5)
0482 #define INTRS_CRITICAL_OP_IN_PROGRESS PMC_BIT32(6)
0483 #define INTRS_IO_DEBUG_ACK PMC_BIT32(7)
0484 #define INTRS_IOARRIN_LOST PMC_BIT32(27)
0485 #define INTRS_SYSTEM_BUS_MMIO_ERROR PMC_BIT32(28)
0486 #define INTRS_IOA_PROCESSOR_ERROR PMC_BIT32(29)
0487 #define INTRS_HRRQ_VALID PMC_BIT32(30)
0488 #define INTRS_OPERATIONAL_STATUS PMC_BIT32(0)
0489 #define INTRS_ALLOW_MSIX_VECTOR0 PMC_BIT32(31)
0490
0491
0492 #define DOORBELL_RUNTIME_RESET PMC_BIT32(1)
0493 #define DOORBELL_IOA_RESET_ALERT PMC_BIT32(7)
0494 #define DOORBELL_IOA_DEBUG_ALERT PMC_BIT32(9)
0495 #define DOORBELL_ENABLE_DESTRUCTIVE_DIAGS PMC_BIT32(8)
0496 #define DOORBELL_IOA_START_BIST PMC_BIT32(23)
0497 #define DOORBELL_INTR_MODE_MSIX PMC_BIT32(25)
0498 #define DOORBELL_INTR_MSIX_CLR PMC_BIT32(26)
0499 #define DOORBELL_RESET_IOA PMC_BIT32(31)
0500
0501
0502 #define GLOBAL_INTERRUPT_MASK 0x5ULL
0503
0504 #define PMCRAID_ERROR_INTERRUPTS (INTRS_IOARCB_TRANSFER_FAILED | \
0505 INTRS_IOA_UNIT_CHECK | \
0506 INTRS_NO_HRRQ_FOR_CMD_RESPONSE | \
0507 INTRS_IOARRIN_LOST | \
0508 INTRS_SYSTEM_BUS_MMIO_ERROR | \
0509 INTRS_IOA_PROCESSOR_ERROR)
0510
0511 #define PMCRAID_PCI_INTERRUPTS (PMCRAID_ERROR_INTERRUPTS | \
0512 INTRS_HRRQ_VALID | \
0513 INTRS_TRANSITION_TO_OPERATIONAL |\
0514 INTRS_ALLOW_MSIX_VECTOR0)
0515
0516
0517
0518
0519
0520 struct pmcraid_control_block {
0521 struct pmcraid_ioarcb ioarcb;
0522 struct pmcraid_ioadl_desc ioadl[PMCRAID_IOADLS_EXTERNAL + 3];
0523 struct pmcraid_ioasa ioasa;
0524 } __attribute__ ((packed, aligned(PMCRAID_IOARCB_ALIGNMENT)));
0525
0526
0527
0528 struct pmcraid_sglist {
0529 u32 order;
0530 u32 num_sg;
0531 u32 num_dma_sg;
0532 struct scatterlist *scatterlist;
0533 };
0534
0535
0536 struct pmcraid_inquiry_data {
0537 __u8 ph_dev_type;
0538 __u8 page_code;
0539 __u8 reserved1;
0540 __u8 add_page_len;
0541 __u8 length;
0542 __u8 reserved2;
0543 __be16 fw_version;
0544 __u8 reserved3[16];
0545 };
0546
0547 #define PMCRAID_TIMESTAMP_LEN 12
0548 #define PMCRAID_REQ_TM_STR_LEN 6
0549 #define PMCRAID_SCSI_SET_TIMESTAMP 0xA4
0550 #define PMCRAID_SCSI_SERVICE_ACTION 0x0F
0551
0552 struct pmcraid_timestamp_data {
0553 __u8 reserved1[4];
0554 __u8 timestamp[PMCRAID_REQ_TM_STR_LEN];
0555 __u8 reserved2[2];
0556 };
0557
0558
0559 struct pmcraid_cmd {
0560
0561
0562 struct pmcraid_control_block *ioa_cb;
0563 dma_addr_t ioa_cb_bus_addr;
0564 dma_addr_t dma_handle;
0565
0566
0567 struct scsi_cmnd *scsi_cmd;
0568
0569 struct list_head free_list;
0570 struct completion wait_for_completion;
0571 struct timer_list timer;
0572 u32 timeout;
0573 u32 index;
0574 u8 completion_req;
0575 u8 release;
0576
0577 void (*cmd_done) (struct pmcraid_cmd *);
0578 struct pmcraid_instance *drv_inst;
0579
0580 struct pmcraid_sglist *sglist;
0581
0582
0583 union {
0584
0585 unsigned long time_left;
0586 struct pmcraid_resource_entry *res;
0587 int hrrq_index;
0588
0589
0590
0591
0592
0593 struct {
0594 u8 *sense_buffer;
0595 dma_addr_t sense_buffer_dma;
0596 };
0597 };
0598 };
0599
0600
0601
0602
0603 struct pmcraid_interrupts {
0604 void __iomem *ioa_host_interrupt_reg;
0605 void __iomem *ioa_host_msix_interrupt_reg;
0606 void __iomem *ioa_host_interrupt_clr_reg;
0607 void __iomem *ioa_host_interrupt_mask_reg;
0608 void __iomem *ioa_host_interrupt_mask_clr_reg;
0609 void __iomem *global_interrupt_mask_reg;
0610 void __iomem *host_ioa_interrupt_reg;
0611 void __iomem *host_ioa_interrupt_clr_reg;
0612 };
0613
0614
0615 struct pmcraid_isr_param {
0616 struct pmcraid_instance *drv_inst;
0617 u8 hrrq_id;
0618 };
0619
0620
0621
0622 struct pmcraid_aen_msg {
0623 u32 hostno;
0624 u32 length;
0625 u8 reserved[8];
0626 u8 data[];
0627 };
0628
0629
0630 struct pmcraid_state_msg {
0631 struct pmcraid_aen_msg msg;
0632 u32 ioa_state;
0633 };
0634
0635 #define PMC_DEVICE_EVENT_RESET_START 0x11000000
0636 #define PMC_DEVICE_EVENT_RESET_SUCCESS 0x11000001
0637 #define PMC_DEVICE_EVENT_RESET_FAILED 0x11000002
0638 #define PMC_DEVICE_EVENT_SHUTDOWN_START 0x11000003
0639 #define PMC_DEVICE_EVENT_SHUTDOWN_SUCCESS 0x11000004
0640 #define PMC_DEVICE_EVENT_SHUTDOWN_FAILED 0x11000005
0641
0642 struct pmcraid_hostrcb {
0643 struct pmcraid_instance *drv_inst;
0644 struct pmcraid_aen_msg *msg;
0645 struct pmcraid_hcam_hdr *hcam;
0646 struct pmcraid_cmd *cmd;
0647 dma_addr_t baddr;
0648 atomic_t ignore;
0649 };
0650
0651 #define PMCRAID_AEN_HDR_SIZE sizeof(struct pmcraid_aen_msg)
0652
0653
0654
0655
0656
0657
0658 struct pmcraid_instance {
0659
0660
0661
0662 struct pmcraid_resource_entry *res_entries;
0663
0664 struct list_head free_res_q;
0665 struct list_head used_res_q;
0666 spinlock_t resource_lock;
0667
0668 void __iomem *mapped_dma_addr;
0669 void __iomem *ioa_status;
0670 void __iomem *mailbox;
0671 void __iomem *ioarrin;
0672
0673 struct pmcraid_interrupts int_regs;
0674 struct pmcraid_chip_details *chip_cfg;
0675
0676
0677 struct pmcraid_hostrcb ldn;
0678 struct pmcraid_hostrcb ccn;
0679 struct pmcraid_state_msg scn;
0680
0681
0682
0683 dma_addr_t hrrq_start_bus_addr[PMCRAID_NUM_MSIX_VECTORS];
0684
0685
0686 __le32 *hrrq_start[PMCRAID_NUM_MSIX_VECTORS];
0687
0688
0689 __le32 *hrrq_end[PMCRAID_NUM_MSIX_VECTORS];
0690
0691
0692 __le32 *hrrq_curr[PMCRAID_NUM_MSIX_VECTORS];
0693
0694
0695 spinlock_t hrrq_lock[PMCRAID_NUM_MSIX_VECTORS];
0696
0697 struct pmcraid_inquiry_data *inq_data;
0698 dma_addr_t inq_data_baddr;
0699
0700 struct pmcraid_timestamp_data *timestamp_data;
0701 dma_addr_t timestamp_data_baddr;
0702
0703
0704 u32 config_table_entry_size;
0705
0706
0707 u8 host_toggle_bit[PMCRAID_NUM_MSIX_VECTORS];
0708
0709
0710
0711 wait_queue_head_t reset_wait_q;
0712 struct pmcraid_cmd *reset_cmd;
0713
0714
0715 struct fasync_struct *aen_queue;
0716 struct mutex aen_queue_lock;
0717 struct cdev cdev;
0718
0719 struct Scsi_Host *host;
0720 struct pci_dev *pdev;
0721
0722
0723 u8 ioa_reset_attempts;
0724 #define PMCRAID_RESET_ATTEMPTS 3
0725
0726 u8 current_log_level;
0727
0728 u8 num_hrrq;
0729 u8 interrupt_mode;
0730 dev_t dev;
0731
0732
0733 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
0734
0735
0736 atomic_t last_message_id;
0737
0738
0739 struct pmcraid_config_table *cfg_table;
0740 dma_addr_t cfg_table_bus_addr;
0741
0742
0743 struct kmem_cache *cmd_cachep;
0744 struct dma_pool *control_pool;
0745 char cmd_pool_name[64];
0746 char ctl_pool_name[64];
0747
0748 struct pmcraid_cmd *cmd_list[PMCRAID_MAX_CMD];
0749
0750 struct list_head free_cmd_pool;
0751 struct list_head pending_cmd_pool;
0752 spinlock_t free_pool_lock;
0753 spinlock_t pending_pool_lock;
0754
0755
0756 struct tasklet_struct isr_tasklet[PMCRAID_NUM_MSIX_VECTORS];
0757
0758
0759 struct work_struct worker_q;
0760
0761
0762 atomic_t outstanding_cmds;
0763
0764
0765 atomic_t expose_resources;
0766
0767
0768
0769 u32 ioa_state:4;
0770 #define IOA_STATE_OPERATIONAL 0x0
0771 #define IOA_STATE_UNKNOWN 0x1
0772 #define IOA_STATE_DEAD 0x2
0773 #define IOA_STATE_IN_SOFT_RESET 0x3
0774 #define IOA_STATE_IN_HARD_RESET 0x4
0775 #define IOA_STATE_IN_RESET_ALERT 0x5
0776 #define IOA_STATE_IN_BRINGDOWN 0x6
0777 #define IOA_STATE_IN_BRINGUP 0x7
0778
0779 u32 ioa_reset_in_progress:1;
0780 u32 ioa_hard_reset:1;
0781 u32 ioa_unit_check:1;
0782 u32 ioa_bringdown:1;
0783 u32 force_ioa_reset:1;
0784 u32 reinit_cfg_table:1;
0785 u32 ioa_shutdown_type:2;
0786 #define SHUTDOWN_NONE 0x0
0787 #define SHUTDOWN_NORMAL 0x1
0788 #define SHUTDOWN_ABBREV 0x2
0789 u32 timestamp_error:1;
0790
0791 };
0792
0793
0794 struct pmcraid_resource_entry {
0795 struct list_head queue;
0796 union {
0797 struct pmcraid_config_table_entry cfg_entry;
0798 struct pmcraid_config_table_entry_ext cfg_entry_ext;
0799 };
0800 struct scsi_device *scsi_dev;
0801 atomic_t read_failures;
0802 atomic_t write_failures;
0803
0804
0805 u8 change_detected;
0806 #define RES_CHANGE_ADD 0x1
0807 #define RES_CHANGE_DEL 0x2
0808
0809 u8 reset_progress;
0810
0811
0812
0813
0814
0815
0816
0817 u8 sync_reqd;
0818
0819
0820
0821
0822
0823 u8 target;
0824 };
0825
0826
0827 struct pmcraid_ioasc_error {
0828 u32 ioasc_code;
0829 u8 log_level;
0830 char *error_string;
0831 };
0832
0833
0834 #define IOASC_LOG_LEVEL_NONE 0x0
0835 #define IOASC_LOG_LEVEL_MUST 0x1
0836 #define IOASC_LOG_LEVEL_HARD 0x2
0837
0838
0839
0840
0841 static struct pmcraid_ioasc_error pmcraid_ioasc_error_table[] = {
0842 {0x01180600, IOASC_LOG_LEVEL_HARD,
0843 "Recovered Error, soft media error, sector reassignment suggested"},
0844 {0x015D0000, IOASC_LOG_LEVEL_HARD,
0845 "Recovered Error, failure prediction threshold exceeded"},
0846 {0x015D9200, IOASC_LOG_LEVEL_HARD,
0847 "Recovered Error, soft Cache Card Battery error threshold"},
0848 {0x015D9200, IOASC_LOG_LEVEL_HARD,
0849 "Recovered Error, soft Cache Card Battery error threshold"},
0850 {0x02048000, IOASC_LOG_LEVEL_HARD,
0851 "Not Ready, IOA Reset Required"},
0852 {0x02408500, IOASC_LOG_LEVEL_HARD,
0853 "Not Ready, IOA microcode download required"},
0854 {0x03110B00, IOASC_LOG_LEVEL_HARD,
0855 "Medium Error, data unreadable, reassignment suggested"},
0856 {0x03110C00, IOASC_LOG_LEVEL_MUST,
0857 "Medium Error, data unreadable do not reassign"},
0858 {0x03310000, IOASC_LOG_LEVEL_HARD,
0859 "Medium Error, media corrupted"},
0860 {0x04050000, IOASC_LOG_LEVEL_HARD,
0861 "Hardware Error, IOA can't communicate with device"},
0862 {0x04080000, IOASC_LOG_LEVEL_MUST,
0863 "Hardware Error, device bus error"},
0864 {0x04088000, IOASC_LOG_LEVEL_MUST,
0865 "Hardware Error, device bus is not functioning"},
0866 {0x04118000, IOASC_LOG_LEVEL_HARD,
0867 "Hardware Error, IOA reserved area data check"},
0868 {0x04118100, IOASC_LOG_LEVEL_HARD,
0869 "Hardware Error, IOA reserved area invalid data pattern"},
0870 {0x04118200, IOASC_LOG_LEVEL_HARD,
0871 "Hardware Error, IOA reserved area LRC error"},
0872 {0x04320000, IOASC_LOG_LEVEL_HARD,
0873 "Hardware Error, reassignment space exhausted"},
0874 {0x04330000, IOASC_LOG_LEVEL_HARD,
0875 "Hardware Error, data transfer underlength error"},
0876 {0x04330000, IOASC_LOG_LEVEL_HARD,
0877 "Hardware Error, data transfer overlength error"},
0878 {0x04418000, IOASC_LOG_LEVEL_MUST,
0879 "Hardware Error, PCI bus error"},
0880 {0x04440000, IOASC_LOG_LEVEL_HARD,
0881 "Hardware Error, device error"},
0882 {0x04448200, IOASC_LOG_LEVEL_MUST,
0883 "Hardware Error, IOA error"},
0884 {0x04448300, IOASC_LOG_LEVEL_HARD,
0885 "Hardware Error, undefined device response"},
0886 {0x04448400, IOASC_LOG_LEVEL_HARD,
0887 "Hardware Error, IOA microcode error"},
0888 {0x04448600, IOASC_LOG_LEVEL_HARD,
0889 "Hardware Error, IOA reset required"},
0890 {0x04449200, IOASC_LOG_LEVEL_HARD,
0891 "Hardware Error, hard Cache Fearuee Card Battery error"},
0892 {0x0444A000, IOASC_LOG_LEVEL_HARD,
0893 "Hardware Error, failed device altered"},
0894 {0x0444A200, IOASC_LOG_LEVEL_HARD,
0895 "Hardware Error, data check after reassignment"},
0896 {0x0444A300, IOASC_LOG_LEVEL_HARD,
0897 "Hardware Error, LRC error after reassignment"},
0898 {0x044A0000, IOASC_LOG_LEVEL_HARD,
0899 "Hardware Error, device bus error (msg/cmd phase)"},
0900 {0x04670400, IOASC_LOG_LEVEL_HARD,
0901 "Hardware Error, new device can't be used"},
0902 {0x04678000, IOASC_LOG_LEVEL_HARD,
0903 "Hardware Error, invalid multiadapter configuration"},
0904 {0x04678100, IOASC_LOG_LEVEL_HARD,
0905 "Hardware Error, incorrect connection between enclosures"},
0906 {0x04678200, IOASC_LOG_LEVEL_HARD,
0907 "Hardware Error, connections exceed IOA design limits"},
0908 {0x04678300, IOASC_LOG_LEVEL_HARD,
0909 "Hardware Error, incorrect multipath connection"},
0910 {0x04679000, IOASC_LOG_LEVEL_HARD,
0911 "Hardware Error, command to LUN failed"},
0912 {0x064C8000, IOASC_LOG_LEVEL_HARD,
0913 "Unit Attention, cache exists for missing/failed device"},
0914 {0x06670100, IOASC_LOG_LEVEL_HARD,
0915 "Unit Attention, incompatible exposed mode device"},
0916 {0x06670600, IOASC_LOG_LEVEL_HARD,
0917 "Unit Attention, attachment of logical unit failed"},
0918 {0x06678000, IOASC_LOG_LEVEL_HARD,
0919 "Unit Attention, cables exceed connective design limit"},
0920 {0x06678300, IOASC_LOG_LEVEL_HARD,
0921 "Unit Attention, incomplete multipath connection between" \
0922 "IOA and enclosure"},
0923 {0x06678400, IOASC_LOG_LEVEL_HARD,
0924 "Unit Attention, incomplete multipath connection between" \
0925 "device and enclosure"},
0926 {0x06678500, IOASC_LOG_LEVEL_HARD,
0927 "Unit Attention, incomplete multipath connection between" \
0928 "IOA and remote IOA"},
0929 {0x06678600, IOASC_LOG_LEVEL_HARD,
0930 "Unit Attention, missing remote IOA"},
0931 {0x06679100, IOASC_LOG_LEVEL_HARD,
0932 "Unit Attention, enclosure doesn't support required multipath" \
0933 "function"},
0934 {0x06698200, IOASC_LOG_LEVEL_HARD,
0935 "Unit Attention, corrupt array parity detected on device"},
0936 {0x066B0200, IOASC_LOG_LEVEL_HARD,
0937 "Unit Attention, array exposed"},
0938 {0x066B8200, IOASC_LOG_LEVEL_HARD,
0939 "Unit Attention, exposed array is still protected"},
0940 {0x066B9200, IOASC_LOG_LEVEL_HARD,
0941 "Unit Attention, Multipath redundancy level got worse"},
0942 {0x07270000, IOASC_LOG_LEVEL_HARD,
0943 "Data Protect, device is read/write protected by IOA"},
0944 {0x07278000, IOASC_LOG_LEVEL_HARD,
0945 "Data Protect, IOA doesn't support device attribute"},
0946 {0x07278100, IOASC_LOG_LEVEL_HARD,
0947 "Data Protect, NVRAM mirroring prohibited"},
0948 {0x07278400, IOASC_LOG_LEVEL_HARD,
0949 "Data Protect, array is short 2 or more devices"},
0950 {0x07278600, IOASC_LOG_LEVEL_HARD,
0951 "Data Protect, exposed array is short a required device"},
0952 {0x07278700, IOASC_LOG_LEVEL_HARD,
0953 "Data Protect, array members not at required addresses"},
0954 {0x07278800, IOASC_LOG_LEVEL_HARD,
0955 "Data Protect, exposed mode device resource address conflict"},
0956 {0x07278900, IOASC_LOG_LEVEL_HARD,
0957 "Data Protect, incorrect resource address of exposed mode device"},
0958 {0x07278A00, IOASC_LOG_LEVEL_HARD,
0959 "Data Protect, Array is missing a device and parity is out of sync"},
0960 {0x07278B00, IOASC_LOG_LEVEL_HARD,
0961 "Data Protect, maximum number of arrays already exist"},
0962 {0x07278C00, IOASC_LOG_LEVEL_HARD,
0963 "Data Protect, cannot locate cache data for device"},
0964 {0x07278D00, IOASC_LOG_LEVEL_HARD,
0965 "Data Protect, cache data exits for a changed device"},
0966 {0x07279100, IOASC_LOG_LEVEL_HARD,
0967 "Data Protect, detection of a device requiring format"},
0968 {0x07279200, IOASC_LOG_LEVEL_HARD,
0969 "Data Protect, IOA exceeds maximum number of devices"},
0970 {0x07279600, IOASC_LOG_LEVEL_HARD,
0971 "Data Protect, missing array, volume set is not functional"},
0972 {0x07279700, IOASC_LOG_LEVEL_HARD,
0973 "Data Protect, single device for a volume set"},
0974 {0x07279800, IOASC_LOG_LEVEL_HARD,
0975 "Data Protect, missing multiple devices for a volume set"},
0976 {0x07279900, IOASC_LOG_LEVEL_HARD,
0977 "Data Protect, maximum number of volument sets already exists"},
0978 {0x07279A00, IOASC_LOG_LEVEL_HARD,
0979 "Data Protect, other volume set problem"},
0980 };
0981
0982
0983 #define pmcraid_err(...) \
0984 printk(KERN_ERR "MaxRAID: "__VA_ARGS__)
0985
0986 #define pmcraid_info(...) \
0987 if (pmcraid_debug_log) \
0988 printk(KERN_INFO "MaxRAID: "__VA_ARGS__)
0989
0990
0991 #define SCSI_READ_CMD 0x1
0992 #define SCSI_WRITE_CMD 0x2
0993 #define SCSI_CMD_TYPE(opcode) \
0994 ({ u8 op = opcode; u8 __type = 0;\
0995 if (op == READ_6 || op == READ_10 || op == READ_12 || op == READ_16)\
0996 __type = SCSI_READ_CMD;\
0997 else if (op == WRITE_6 || op == WRITE_10 || op == WRITE_12 || \
0998 op == WRITE_16)\
0999 __type = SCSI_WRITE_CMD;\
1000 __type;\
1001 })
1002
1003 #define IS_SCSI_READ_WRITE(opcode) \
1004 ({ u8 __type = SCSI_CMD_TYPE(opcode); \
1005 (__type == SCSI_READ_CMD || __type == SCSI_WRITE_CMD) ? 1 : 0;\
1006 })
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017 struct pmcraid_ioctl_header {
1018 u8 signature[8];
1019 u32 reserved;
1020 u32 buffer_length;
1021 };
1022
1023 #define PMCRAID_IOCTL_SIGNATURE "PMCRAID"
1024
1025
1026
1027
1028
1029
1030 #define PMCRAID_DRIVER_IOCTL 'D'
1031
1032 #define DRV_IOCTL(n, size) \
1033 _IOC(_IOC_READ|_IOC_WRITE, PMCRAID_DRIVER_IOCTL, (n), (size))
1034
1035
1036
1037
1038
1039
1040 #define _ARGSIZE(arg) (sizeof(struct pmcraid_ioctl_header) + sizeof(arg))
1041
1042
1043
1044 #define PMCRAID_IOCTL_RESET_ADAPTER \
1045 DRV_IOCTL(5, sizeof(struct pmcraid_ioctl_header))
1046
1047 #endif