| 1 | /* |
| 2 | * QLogic Fibre Channel HBA Driver |
| 3 | * Copyright (c) 2003-2014 QLogic Corporation |
| 4 | * |
| 5 | * See LICENSE.qla2xxx for copyright and licensing details. |
| 6 | */ |
| 7 | #include "qla_def.h" |
| 8 | #include "qla_target.h" |
| 9 | |
| 10 | #include <linux/delay.h> |
| 11 | #include <linux/slab.h> |
| 12 | #include <linux/cpu.h> |
| 13 | #include <linux/t10-pi.h> |
| 14 | #include <scsi/scsi_tcq.h> |
| 15 | #include <scsi/scsi_bsg_fc.h> |
| 16 | #include <scsi/scsi_eh.h> |
| 17 | #include <scsi/fc/fc_fs.h> |
| 18 | #include <linux/nvme-fc-driver.h> |
| 19 | |
| 20 | static void qla2x00_mbx_completion(scsi_qla_host_t *, uint16_t); |
| 21 | static void qla2x00_status_entry(scsi_qla_host_t *, struct rsp_que *, void *); |
| 22 | static void qla2x00_status_cont_entry(struct rsp_que *, sts_cont_entry_t *); |
| 23 | static int qla2x00_error_entry(scsi_qla_host_t *, struct rsp_que *, |
| 24 | sts_entry_t *); |
| 25 | |
| 26 | const char *const port_state_str[] = { |
| 27 | "Unknown", |
| 28 | "UNCONFIGURED", |
| 29 | "DEAD", |
| 30 | "LOST", |
| 31 | "ONLINE" |
| 32 | }; |
| 33 | |
| 34 | /** |
| 35 | * qla2100_intr_handler() - Process interrupts for the ISP2100 and ISP2200. |
| 36 | * @irq: interrupt number |
| 37 | * @dev_id: SCSI driver HA context |
| 38 | * |
| 39 | * Called by system whenever the host adapter generates an interrupt. |
| 40 | * |
| 41 | * Returns handled flag. |
| 42 | */ |
| 43 | irqreturn_t |
| 44 | qla2100_intr_handler(int irq, void *dev_id) |
| 45 | { |
| 46 | scsi_qla_host_t *vha; |
| 47 | struct qla_hw_data *ha; |
| 48 | struct device_reg_2xxx __iomem *reg; |
| 49 | int status; |
| 50 | unsigned long iter; |
| 51 | uint16_t hccr; |
| 52 | uint16_t mb[8]; |
| 53 | struct rsp_que *rsp; |
| 54 | unsigned long flags; |
| 55 | |
| 56 | rsp = (struct rsp_que *) dev_id; |
| 57 | if (!rsp) { |
| 58 | ql_log(ql_log_info, NULL, 0x505d, |
| 59 | "%s: NULL response queue pointer.\n", __func__); |
| 60 | return (IRQ_NONE); |
| 61 | } |
| 62 | |
| 63 | ha = rsp->hw; |
| 64 | reg = &ha->iobase->isp; |
| 65 | status = 0; |
| 66 | |
| 67 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 68 | vha = pci_get_drvdata(ha->pdev); |
| 69 | for (iter = 50; iter--; ) { |
| 70 | hccr = RD_REG_WORD(®->hccr); |
| 71 | if (qla2x00_check_reg16_for_disconnect(vha, hccr)) |
| 72 | break; |
| 73 | if (hccr & HCCR_RISC_PAUSE) { |
| 74 | if (pci_channel_offline(ha->pdev)) |
| 75 | break; |
| 76 | |
| 77 | /* |
| 78 | * Issue a "HARD" reset in order for the RISC interrupt |
| 79 | * bit to be cleared. Schedule a big hammer to get |
| 80 | * out of the RISC PAUSED state. |
| 81 | */ |
| 82 | WRT_REG_WORD(®->hccr, HCCR_RESET_RISC); |
| 83 | RD_REG_WORD(®->hccr); |
| 84 | |
| 85 | ha->isp_ops->fw_dump(vha, 1); |
| 86 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 87 | break; |
| 88 | } else if ((RD_REG_WORD(®->istatus) & ISR_RISC_INT) == 0) |
| 89 | break; |
| 90 | |
| 91 | if (RD_REG_WORD(®->semaphore) & BIT_0) { |
| 92 | WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT); |
| 93 | RD_REG_WORD(®->hccr); |
| 94 | |
| 95 | /* Get mailbox data. */ |
| 96 | mb[0] = RD_MAILBOX_REG(ha, reg, 0); |
| 97 | if (mb[0] > 0x3fff && mb[0] < 0x8000) { |
| 98 | qla2x00_mbx_completion(vha, mb[0]); |
| 99 | status |= MBX_INTERRUPT; |
| 100 | } else if (mb[0] > 0x7fff && mb[0] < 0xc000) { |
| 101 | mb[1] = RD_MAILBOX_REG(ha, reg, 1); |
| 102 | mb[2] = RD_MAILBOX_REG(ha, reg, 2); |
| 103 | mb[3] = RD_MAILBOX_REG(ha, reg, 3); |
| 104 | qla2x00_async_event(vha, rsp, mb); |
| 105 | } else { |
| 106 | /*EMPTY*/ |
| 107 | ql_dbg(ql_dbg_async, vha, 0x5025, |
| 108 | "Unrecognized interrupt type (%d).\n", |
| 109 | mb[0]); |
| 110 | } |
| 111 | /* Release mailbox registers. */ |
| 112 | WRT_REG_WORD(®->semaphore, 0); |
| 113 | RD_REG_WORD(®->semaphore); |
| 114 | } else { |
| 115 | qla2x00_process_response_queue(rsp); |
| 116 | |
| 117 | WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT); |
| 118 | RD_REG_WORD(®->hccr); |
| 119 | } |
| 120 | } |
| 121 | qla2x00_handle_mbx_completion(ha, status); |
| 122 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 123 | |
| 124 | return (IRQ_HANDLED); |
| 125 | } |
| 126 | |
| 127 | bool |
| 128 | qla2x00_check_reg32_for_disconnect(scsi_qla_host_t *vha, uint32_t reg) |
| 129 | { |
| 130 | /* Check for PCI disconnection */ |
| 131 | if (reg == 0xffffffff && !pci_channel_offline(vha->hw->pdev)) { |
| 132 | if (!test_and_set_bit(PFLG_DISCONNECTED, &vha->pci_flags) && |
| 133 | !test_bit(PFLG_DRIVER_REMOVING, &vha->pci_flags) && |
| 134 | !test_bit(PFLG_DRIVER_PROBING, &vha->pci_flags)) { |
| 135 | /* |
| 136 | * Schedule this (only once) on the default system |
| 137 | * workqueue so that all the adapter workqueues and the |
| 138 | * DPC thread can be shutdown cleanly. |
| 139 | */ |
| 140 | schedule_work(&vha->hw->board_disable); |
| 141 | } |
| 142 | return true; |
| 143 | } else |
| 144 | return false; |
| 145 | } |
| 146 | |
| 147 | bool |
| 148 | qla2x00_check_reg16_for_disconnect(scsi_qla_host_t *vha, uint16_t reg) |
| 149 | { |
| 150 | return qla2x00_check_reg32_for_disconnect(vha, 0xffff0000 | reg); |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * qla2300_intr_handler() - Process interrupts for the ISP23xx and ISP63xx. |
| 155 | * @irq: interrupt number |
| 156 | * @dev_id: SCSI driver HA context |
| 157 | * |
| 158 | * Called by system whenever the host adapter generates an interrupt. |
| 159 | * |
| 160 | * Returns handled flag. |
| 161 | */ |
| 162 | irqreturn_t |
| 163 | qla2300_intr_handler(int irq, void *dev_id) |
| 164 | { |
| 165 | scsi_qla_host_t *vha; |
| 166 | struct device_reg_2xxx __iomem *reg; |
| 167 | int status; |
| 168 | unsigned long iter; |
| 169 | uint32_t stat; |
| 170 | uint16_t hccr; |
| 171 | uint16_t mb[8]; |
| 172 | struct rsp_que *rsp; |
| 173 | struct qla_hw_data *ha; |
| 174 | unsigned long flags; |
| 175 | |
| 176 | rsp = (struct rsp_que *) dev_id; |
| 177 | if (!rsp) { |
| 178 | ql_log(ql_log_info, NULL, 0x5058, |
| 179 | "%s: NULL response queue pointer.\n", __func__); |
| 180 | return (IRQ_NONE); |
| 181 | } |
| 182 | |
| 183 | ha = rsp->hw; |
| 184 | reg = &ha->iobase->isp; |
| 185 | status = 0; |
| 186 | |
| 187 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 188 | vha = pci_get_drvdata(ha->pdev); |
| 189 | for (iter = 50; iter--; ) { |
| 190 | stat = RD_REG_DWORD(®->u.isp2300.host_status); |
| 191 | if (qla2x00_check_reg32_for_disconnect(vha, stat)) |
| 192 | break; |
| 193 | if (stat & HSR_RISC_PAUSED) { |
| 194 | if (unlikely(pci_channel_offline(ha->pdev))) |
| 195 | break; |
| 196 | |
| 197 | hccr = RD_REG_WORD(®->hccr); |
| 198 | |
| 199 | if (hccr & (BIT_15 | BIT_13 | BIT_11 | BIT_8)) |
| 200 | ql_log(ql_log_warn, vha, 0x5026, |
| 201 | "Parity error -- HCCR=%x, Dumping " |
| 202 | "firmware.\n", hccr); |
| 203 | else |
| 204 | ql_log(ql_log_warn, vha, 0x5027, |
| 205 | "RISC paused -- HCCR=%x, Dumping " |
| 206 | "firmware.\n", hccr); |
| 207 | |
| 208 | /* |
| 209 | * Issue a "HARD" reset in order for the RISC |
| 210 | * interrupt bit to be cleared. Schedule a big |
| 211 | * hammer to get out of the RISC PAUSED state. |
| 212 | */ |
| 213 | WRT_REG_WORD(®->hccr, HCCR_RESET_RISC); |
| 214 | RD_REG_WORD(®->hccr); |
| 215 | |
| 216 | ha->isp_ops->fw_dump(vha, 1); |
| 217 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 218 | break; |
| 219 | } else if ((stat & HSR_RISC_INT) == 0) |
| 220 | break; |
| 221 | |
| 222 | switch (stat & 0xff) { |
| 223 | case 0x1: |
| 224 | case 0x2: |
| 225 | case 0x10: |
| 226 | case 0x11: |
| 227 | qla2x00_mbx_completion(vha, MSW(stat)); |
| 228 | status |= MBX_INTERRUPT; |
| 229 | |
| 230 | /* Release mailbox registers. */ |
| 231 | WRT_REG_WORD(®->semaphore, 0); |
| 232 | break; |
| 233 | case 0x12: |
| 234 | mb[0] = MSW(stat); |
| 235 | mb[1] = RD_MAILBOX_REG(ha, reg, 1); |
| 236 | mb[2] = RD_MAILBOX_REG(ha, reg, 2); |
| 237 | mb[3] = RD_MAILBOX_REG(ha, reg, 3); |
| 238 | qla2x00_async_event(vha, rsp, mb); |
| 239 | break; |
| 240 | case 0x13: |
| 241 | qla2x00_process_response_queue(rsp); |
| 242 | break; |
| 243 | case 0x15: |
| 244 | mb[0] = MBA_CMPLT_1_16BIT; |
| 245 | mb[1] = MSW(stat); |
| 246 | qla2x00_async_event(vha, rsp, mb); |
| 247 | break; |
| 248 | case 0x16: |
| 249 | mb[0] = MBA_SCSI_COMPLETION; |
| 250 | mb[1] = MSW(stat); |
| 251 | mb[2] = RD_MAILBOX_REG(ha, reg, 2); |
| 252 | qla2x00_async_event(vha, rsp, mb); |
| 253 | break; |
| 254 | default: |
| 255 | ql_dbg(ql_dbg_async, vha, 0x5028, |
| 256 | "Unrecognized interrupt type (%d).\n", stat & 0xff); |
| 257 | break; |
| 258 | } |
| 259 | WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT); |
| 260 | RD_REG_WORD_RELAXED(®->hccr); |
| 261 | } |
| 262 | qla2x00_handle_mbx_completion(ha, status); |
| 263 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 264 | |
| 265 | return (IRQ_HANDLED); |
| 266 | } |
| 267 | |
| 268 | /** |
| 269 | * qla2x00_mbx_completion() - Process mailbox command completions. |
| 270 | * @vha: SCSI driver HA context |
| 271 | * @mb0: Mailbox0 register |
| 272 | */ |
| 273 | static void |
| 274 | qla2x00_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0) |
| 275 | { |
| 276 | uint16_t cnt; |
| 277 | uint32_t mboxes; |
| 278 | uint16_t __iomem *wptr; |
| 279 | struct qla_hw_data *ha = vha->hw; |
| 280 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 281 | |
| 282 | /* Read all mbox registers? */ |
| 283 | WARN_ON_ONCE(ha->mbx_count > 32); |
| 284 | mboxes = (1ULL << ha->mbx_count) - 1; |
| 285 | if (!ha->mcp) |
| 286 | ql_dbg(ql_dbg_async, vha, 0x5001, "MBX pointer ERROR.\n"); |
| 287 | else |
| 288 | mboxes = ha->mcp->in_mb; |
| 289 | |
| 290 | /* Load return mailbox registers. */ |
| 291 | ha->flags.mbox_int = 1; |
| 292 | ha->mailbox_out[0] = mb0; |
| 293 | mboxes >>= 1; |
| 294 | wptr = (uint16_t __iomem *)MAILBOX_REG(ha, reg, 1); |
| 295 | |
| 296 | for (cnt = 1; cnt < ha->mbx_count; cnt++) { |
| 297 | if (IS_QLA2200(ha) && cnt == 8) |
| 298 | wptr = (uint16_t __iomem *)MAILBOX_REG(ha, reg, 8); |
| 299 | if ((cnt == 4 || cnt == 5) && (mboxes & BIT_0)) |
| 300 | ha->mailbox_out[cnt] = qla2x00_debounce_register(wptr); |
| 301 | else if (mboxes & BIT_0) |
| 302 | ha->mailbox_out[cnt] = RD_REG_WORD(wptr); |
| 303 | |
| 304 | wptr++; |
| 305 | mboxes >>= 1; |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | static void |
| 310 | qla81xx_idc_event(scsi_qla_host_t *vha, uint16_t aen, uint16_t descr) |
| 311 | { |
| 312 | static char *event[] = |
| 313 | { "Complete", "Request Notification", "Time Extension" }; |
| 314 | int rval; |
| 315 | struct device_reg_24xx __iomem *reg24 = &vha->hw->iobase->isp24; |
| 316 | struct device_reg_82xx __iomem *reg82 = &vha->hw->iobase->isp82; |
| 317 | uint16_t __iomem *wptr; |
| 318 | uint16_t cnt, timeout, mb[QLA_IDC_ACK_REGS]; |
| 319 | |
| 320 | /* Seed data -- mailbox1 -> mailbox7. */ |
| 321 | if (IS_QLA81XX(vha->hw) || IS_QLA83XX(vha->hw)) |
| 322 | wptr = (uint16_t __iomem *)®24->mailbox1; |
| 323 | else if (IS_QLA8044(vha->hw)) |
| 324 | wptr = (uint16_t __iomem *)®82->mailbox_out[1]; |
| 325 | else |
| 326 | return; |
| 327 | |
| 328 | for (cnt = 0; cnt < QLA_IDC_ACK_REGS; cnt++, wptr++) |
| 329 | mb[cnt] = RD_REG_WORD(wptr); |
| 330 | |
| 331 | ql_dbg(ql_dbg_async, vha, 0x5021, |
| 332 | "Inter-Driver Communication %s -- " |
| 333 | "%04x %04x %04x %04x %04x %04x %04x.\n", |
| 334 | event[aen & 0xff], mb[0], mb[1], mb[2], mb[3], |
| 335 | mb[4], mb[5], mb[6]); |
| 336 | switch (aen) { |
| 337 | /* Handle IDC Error completion case. */ |
| 338 | case MBA_IDC_COMPLETE: |
| 339 | if (mb[1] >> 15) { |
| 340 | vha->hw->flags.idc_compl_status = 1; |
| 341 | if (vha->hw->notify_dcbx_comp && !vha->vp_idx) |
| 342 | complete(&vha->hw->dcbx_comp); |
| 343 | } |
| 344 | break; |
| 345 | |
| 346 | case MBA_IDC_NOTIFY: |
| 347 | /* Acknowledgement needed? [Notify && non-zero timeout]. */ |
| 348 | timeout = (descr >> 8) & 0xf; |
| 349 | ql_dbg(ql_dbg_async, vha, 0x5022, |
| 350 | "%lu Inter-Driver Communication %s -- ACK timeout=%d.\n", |
| 351 | vha->host_no, event[aen & 0xff], timeout); |
| 352 | |
| 353 | if (!timeout) |
| 354 | return; |
| 355 | rval = qla2x00_post_idc_ack_work(vha, mb); |
| 356 | if (rval != QLA_SUCCESS) |
| 357 | ql_log(ql_log_warn, vha, 0x5023, |
| 358 | "IDC failed to post ACK.\n"); |
| 359 | break; |
| 360 | case MBA_IDC_TIME_EXT: |
| 361 | vha->hw->idc_extend_tmo = descr; |
| 362 | ql_dbg(ql_dbg_async, vha, 0x5087, |
| 363 | "%lu Inter-Driver Communication %s -- " |
| 364 | "Extend timeout by=%d.\n", |
| 365 | vha->host_no, event[aen & 0xff], vha->hw->idc_extend_tmo); |
| 366 | break; |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | #define LS_UNKNOWN 2 |
| 371 | const char * |
| 372 | qla2x00_get_link_speed_str(struct qla_hw_data *ha, uint16_t speed) |
| 373 | { |
| 374 | static const char *const link_speeds[] = { |
| 375 | "1", "2", "?", "4", "8", "16", "32", "10" |
| 376 | }; |
| 377 | #define QLA_LAST_SPEED (ARRAY_SIZE(link_speeds) - 1) |
| 378 | |
| 379 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) |
| 380 | return link_speeds[0]; |
| 381 | else if (speed == 0x13) |
| 382 | return link_speeds[QLA_LAST_SPEED]; |
| 383 | else if (speed < QLA_LAST_SPEED) |
| 384 | return link_speeds[speed]; |
| 385 | else |
| 386 | return link_speeds[LS_UNKNOWN]; |
| 387 | } |
| 388 | |
| 389 | static void |
| 390 | qla83xx_handle_8200_aen(scsi_qla_host_t *vha, uint16_t *mb) |
| 391 | { |
| 392 | struct qla_hw_data *ha = vha->hw; |
| 393 | |
| 394 | /* |
| 395 | * 8200 AEN Interpretation: |
| 396 | * mb[0] = AEN code |
| 397 | * mb[1] = AEN Reason code |
| 398 | * mb[2] = LSW of Peg-Halt Status-1 Register |
| 399 | * mb[6] = MSW of Peg-Halt Status-1 Register |
| 400 | * mb[3] = LSW of Peg-Halt Status-2 register |
| 401 | * mb[7] = MSW of Peg-Halt Status-2 register |
| 402 | * mb[4] = IDC Device-State Register value |
| 403 | * mb[5] = IDC Driver-Presence Register value |
| 404 | */ |
| 405 | ql_dbg(ql_dbg_async, vha, 0x506b, "AEN Code: mb[0] = 0x%x AEN reason: " |
| 406 | "mb[1] = 0x%x PH-status1: mb[2] = 0x%x PH-status1: mb[6] = 0x%x.\n", |
| 407 | mb[0], mb[1], mb[2], mb[6]); |
| 408 | ql_dbg(ql_dbg_async, vha, 0x506c, "PH-status2: mb[3] = 0x%x " |
| 409 | "PH-status2: mb[7] = 0x%x Device-State: mb[4] = 0x%x " |
| 410 | "Drv-Presence: mb[5] = 0x%x.\n", mb[3], mb[7], mb[4], mb[5]); |
| 411 | |
| 412 | if (mb[1] & (IDC_PEG_HALT_STATUS_CHANGE | IDC_NIC_FW_REPORTED_FAILURE | |
| 413 | IDC_HEARTBEAT_FAILURE)) { |
| 414 | ha->flags.nic_core_hung = 1; |
| 415 | ql_log(ql_log_warn, vha, 0x5060, |
| 416 | "83XX: F/W Error Reported: Check if reset required.\n"); |
| 417 | |
| 418 | if (mb[1] & IDC_PEG_HALT_STATUS_CHANGE) { |
| 419 | uint32_t protocol_engine_id, fw_err_code, err_level; |
| 420 | |
| 421 | /* |
| 422 | * IDC_PEG_HALT_STATUS_CHANGE interpretation: |
| 423 | * - PEG-Halt Status-1 Register: |
| 424 | * (LSW = mb[2], MSW = mb[6]) |
| 425 | * Bits 0-7 = protocol-engine ID |
| 426 | * Bits 8-28 = f/w error code |
| 427 | * Bits 29-31 = Error-level |
| 428 | * Error-level 0x1 = Non-Fatal error |
| 429 | * Error-level 0x2 = Recoverable Fatal error |
| 430 | * Error-level 0x4 = UnRecoverable Fatal error |
| 431 | * - PEG-Halt Status-2 Register: |
| 432 | * (LSW = mb[3], MSW = mb[7]) |
| 433 | */ |
| 434 | protocol_engine_id = (mb[2] & 0xff); |
| 435 | fw_err_code = (((mb[2] & 0xff00) >> 8) | |
| 436 | ((mb[6] & 0x1fff) << 8)); |
| 437 | err_level = ((mb[6] & 0xe000) >> 13); |
| 438 | ql_log(ql_log_warn, vha, 0x5061, "PegHalt Status-1 " |
| 439 | "Register: protocol_engine_id=0x%x " |
| 440 | "fw_err_code=0x%x err_level=0x%x.\n", |
| 441 | protocol_engine_id, fw_err_code, err_level); |
| 442 | ql_log(ql_log_warn, vha, 0x5062, "PegHalt Status-2 " |
| 443 | "Register: 0x%x%x.\n", mb[7], mb[3]); |
| 444 | if (err_level == ERR_LEVEL_NON_FATAL) { |
| 445 | ql_log(ql_log_warn, vha, 0x5063, |
| 446 | "Not a fatal error, f/w has recovered itself.\n"); |
| 447 | } else if (err_level == ERR_LEVEL_RECOVERABLE_FATAL) { |
| 448 | ql_log(ql_log_fatal, vha, 0x5064, |
| 449 | "Recoverable Fatal error: Chip reset " |
| 450 | "required.\n"); |
| 451 | qla83xx_schedule_work(vha, |
| 452 | QLA83XX_NIC_CORE_RESET); |
| 453 | } else if (err_level == ERR_LEVEL_UNRECOVERABLE_FATAL) { |
| 454 | ql_log(ql_log_fatal, vha, 0x5065, |
| 455 | "Unrecoverable Fatal error: Set FAILED " |
| 456 | "state, reboot required.\n"); |
| 457 | qla83xx_schedule_work(vha, |
| 458 | QLA83XX_NIC_CORE_UNRECOVERABLE); |
| 459 | } |
| 460 | } |
| 461 | |
| 462 | if (mb[1] & IDC_NIC_FW_REPORTED_FAILURE) { |
| 463 | uint16_t peg_fw_state, nw_interface_link_up; |
| 464 | uint16_t nw_interface_signal_detect, sfp_status; |
| 465 | uint16_t htbt_counter, htbt_monitor_enable; |
| 466 | uint16_t sfp_additional_info, sfp_multirate; |
| 467 | uint16_t sfp_tx_fault, link_speed, dcbx_status; |
| 468 | |
| 469 | /* |
| 470 | * IDC_NIC_FW_REPORTED_FAILURE interpretation: |
| 471 | * - PEG-to-FC Status Register: |
| 472 | * (LSW = mb[2], MSW = mb[6]) |
| 473 | * Bits 0-7 = Peg-Firmware state |
| 474 | * Bit 8 = N/W Interface Link-up |
| 475 | * Bit 9 = N/W Interface signal detected |
| 476 | * Bits 10-11 = SFP Status |
| 477 | * SFP Status 0x0 = SFP+ transceiver not expected |
| 478 | * SFP Status 0x1 = SFP+ transceiver not present |
| 479 | * SFP Status 0x2 = SFP+ transceiver invalid |
| 480 | * SFP Status 0x3 = SFP+ transceiver present and |
| 481 | * valid |
| 482 | * Bits 12-14 = Heartbeat Counter |
| 483 | * Bit 15 = Heartbeat Monitor Enable |
| 484 | * Bits 16-17 = SFP Additional Info |
| 485 | * SFP info 0x0 = Unregocnized transceiver for |
| 486 | * Ethernet |
| 487 | * SFP info 0x1 = SFP+ brand validation failed |
| 488 | * SFP info 0x2 = SFP+ speed validation failed |
| 489 | * SFP info 0x3 = SFP+ access error |
| 490 | * Bit 18 = SFP Multirate |
| 491 | * Bit 19 = SFP Tx Fault |
| 492 | * Bits 20-22 = Link Speed |
| 493 | * Bits 23-27 = Reserved |
| 494 | * Bits 28-30 = DCBX Status |
| 495 | * DCBX Status 0x0 = DCBX Disabled |
| 496 | * DCBX Status 0x1 = DCBX Enabled |
| 497 | * DCBX Status 0x2 = DCBX Exchange error |
| 498 | * Bit 31 = Reserved |
| 499 | */ |
| 500 | peg_fw_state = (mb[2] & 0x00ff); |
| 501 | nw_interface_link_up = ((mb[2] & 0x0100) >> 8); |
| 502 | nw_interface_signal_detect = ((mb[2] & 0x0200) >> 9); |
| 503 | sfp_status = ((mb[2] & 0x0c00) >> 10); |
| 504 | htbt_counter = ((mb[2] & 0x7000) >> 12); |
| 505 | htbt_monitor_enable = ((mb[2] & 0x8000) >> 15); |
| 506 | sfp_additional_info = (mb[6] & 0x0003); |
| 507 | sfp_multirate = ((mb[6] & 0x0004) >> 2); |
| 508 | sfp_tx_fault = ((mb[6] & 0x0008) >> 3); |
| 509 | link_speed = ((mb[6] & 0x0070) >> 4); |
| 510 | dcbx_status = ((mb[6] & 0x7000) >> 12); |
| 511 | |
| 512 | ql_log(ql_log_warn, vha, 0x5066, |
| 513 | "Peg-to-Fc Status Register:\n" |
| 514 | "peg_fw_state=0x%x, nw_interface_link_up=0x%x, " |
| 515 | "nw_interface_signal_detect=0x%x" |
| 516 | "\nsfp_statis=0x%x.\n ", peg_fw_state, |
| 517 | nw_interface_link_up, nw_interface_signal_detect, |
| 518 | sfp_status); |
| 519 | ql_log(ql_log_warn, vha, 0x5067, |
| 520 | "htbt_counter=0x%x, htbt_monitor_enable=0x%x, " |
| 521 | "sfp_additional_info=0x%x, sfp_multirate=0x%x.\n ", |
| 522 | htbt_counter, htbt_monitor_enable, |
| 523 | sfp_additional_info, sfp_multirate); |
| 524 | ql_log(ql_log_warn, vha, 0x5068, |
| 525 | "sfp_tx_fault=0x%x, link_state=0x%x, " |
| 526 | "dcbx_status=0x%x.\n", sfp_tx_fault, link_speed, |
| 527 | dcbx_status); |
| 528 | |
| 529 | qla83xx_schedule_work(vha, QLA83XX_NIC_CORE_RESET); |
| 530 | } |
| 531 | |
| 532 | if (mb[1] & IDC_HEARTBEAT_FAILURE) { |
| 533 | ql_log(ql_log_warn, vha, 0x5069, |
| 534 | "Heartbeat Failure encountered, chip reset " |
| 535 | "required.\n"); |
| 536 | |
| 537 | qla83xx_schedule_work(vha, QLA83XX_NIC_CORE_RESET); |
| 538 | } |
| 539 | } |
| 540 | |
| 541 | if (mb[1] & IDC_DEVICE_STATE_CHANGE) { |
| 542 | ql_log(ql_log_info, vha, 0x506a, |
| 543 | "IDC Device-State changed = 0x%x.\n", mb[4]); |
| 544 | if (ha->flags.nic_core_reset_owner) |
| 545 | return; |
| 546 | qla83xx_schedule_work(vha, MBA_IDC_AEN); |
| 547 | } |
| 548 | } |
| 549 | |
| 550 | int |
| 551 | qla2x00_is_a_vp_did(scsi_qla_host_t *vha, uint32_t rscn_entry) |
| 552 | { |
| 553 | struct qla_hw_data *ha = vha->hw; |
| 554 | scsi_qla_host_t *vp; |
| 555 | uint32_t vp_did; |
| 556 | unsigned long flags; |
| 557 | int ret = 0; |
| 558 | |
| 559 | if (!ha->num_vhosts) |
| 560 | return ret; |
| 561 | |
| 562 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 563 | list_for_each_entry(vp, &ha->vp_list, list) { |
| 564 | vp_did = vp->d_id.b24; |
| 565 | if (vp_did == rscn_entry) { |
| 566 | ret = 1; |
| 567 | break; |
| 568 | } |
| 569 | } |
| 570 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 571 | |
| 572 | return ret; |
| 573 | } |
| 574 | |
| 575 | fc_port_t * |
| 576 | qla2x00_find_fcport_by_loopid(scsi_qla_host_t *vha, uint16_t loop_id) |
| 577 | { |
| 578 | fc_port_t *f, *tf; |
| 579 | |
| 580 | f = tf = NULL; |
| 581 | list_for_each_entry_safe(f, tf, &vha->vp_fcports, list) |
| 582 | if (f->loop_id == loop_id) |
| 583 | return f; |
| 584 | return NULL; |
| 585 | } |
| 586 | |
| 587 | fc_port_t * |
| 588 | qla2x00_find_fcport_by_wwpn(scsi_qla_host_t *vha, u8 *wwpn, u8 incl_deleted) |
| 589 | { |
| 590 | fc_port_t *f, *tf; |
| 591 | |
| 592 | f = tf = NULL; |
| 593 | list_for_each_entry_safe(f, tf, &vha->vp_fcports, list) { |
| 594 | if (memcmp(f->port_name, wwpn, WWN_SIZE) == 0) { |
| 595 | if (incl_deleted) |
| 596 | return f; |
| 597 | else if (f->deleted == 0) |
| 598 | return f; |
| 599 | } |
| 600 | } |
| 601 | return NULL; |
| 602 | } |
| 603 | |
| 604 | fc_port_t * |
| 605 | qla2x00_find_fcport_by_nportid(scsi_qla_host_t *vha, port_id_t *id, |
| 606 | u8 incl_deleted) |
| 607 | { |
| 608 | fc_port_t *f, *tf; |
| 609 | |
| 610 | f = tf = NULL; |
| 611 | list_for_each_entry_safe(f, tf, &vha->vp_fcports, list) { |
| 612 | if (f->d_id.b24 == id->b24) { |
| 613 | if (incl_deleted) |
| 614 | return f; |
| 615 | else if (f->deleted == 0) |
| 616 | return f; |
| 617 | } |
| 618 | } |
| 619 | return NULL; |
| 620 | } |
| 621 | |
| 622 | /** |
| 623 | * qla2x00_async_event() - Process aynchronous events. |
| 624 | * @vha: SCSI driver HA context |
| 625 | * @rsp: response queue |
| 626 | * @mb: Mailbox registers (0 - 3) |
| 627 | */ |
| 628 | void |
| 629 | qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que *rsp, uint16_t *mb) |
| 630 | { |
| 631 | uint16_t handle_cnt; |
| 632 | uint16_t cnt, mbx; |
| 633 | uint32_t handles[5]; |
| 634 | struct qla_hw_data *ha = vha->hw; |
| 635 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 636 | struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24; |
| 637 | struct device_reg_82xx __iomem *reg82 = &ha->iobase->isp82; |
| 638 | uint32_t rscn_entry, host_pid; |
| 639 | unsigned long flags; |
| 640 | fc_port_t *fcport = NULL; |
| 641 | |
| 642 | if (!vha->hw->flags.fw_started) |
| 643 | return; |
| 644 | |
| 645 | /* Setup to process RIO completion. */ |
| 646 | handle_cnt = 0; |
| 647 | if (IS_CNA_CAPABLE(ha)) |
| 648 | goto skip_rio; |
| 649 | switch (mb[0]) { |
| 650 | case MBA_SCSI_COMPLETION: |
| 651 | handles[0] = le32_to_cpu((uint32_t)((mb[2] << 16) | mb[1])); |
| 652 | handle_cnt = 1; |
| 653 | break; |
| 654 | case MBA_CMPLT_1_16BIT: |
| 655 | handles[0] = mb[1]; |
| 656 | handle_cnt = 1; |
| 657 | mb[0] = MBA_SCSI_COMPLETION; |
| 658 | break; |
| 659 | case MBA_CMPLT_2_16BIT: |
| 660 | handles[0] = mb[1]; |
| 661 | handles[1] = mb[2]; |
| 662 | handle_cnt = 2; |
| 663 | mb[0] = MBA_SCSI_COMPLETION; |
| 664 | break; |
| 665 | case MBA_CMPLT_3_16BIT: |
| 666 | handles[0] = mb[1]; |
| 667 | handles[1] = mb[2]; |
| 668 | handles[2] = mb[3]; |
| 669 | handle_cnt = 3; |
| 670 | mb[0] = MBA_SCSI_COMPLETION; |
| 671 | break; |
| 672 | case MBA_CMPLT_4_16BIT: |
| 673 | handles[0] = mb[1]; |
| 674 | handles[1] = mb[2]; |
| 675 | handles[2] = mb[3]; |
| 676 | handles[3] = (uint32_t)RD_MAILBOX_REG(ha, reg, 6); |
| 677 | handle_cnt = 4; |
| 678 | mb[0] = MBA_SCSI_COMPLETION; |
| 679 | break; |
| 680 | case MBA_CMPLT_5_16BIT: |
| 681 | handles[0] = mb[1]; |
| 682 | handles[1] = mb[2]; |
| 683 | handles[2] = mb[3]; |
| 684 | handles[3] = (uint32_t)RD_MAILBOX_REG(ha, reg, 6); |
| 685 | handles[4] = (uint32_t)RD_MAILBOX_REG(ha, reg, 7); |
| 686 | handle_cnt = 5; |
| 687 | mb[0] = MBA_SCSI_COMPLETION; |
| 688 | break; |
| 689 | case MBA_CMPLT_2_32BIT: |
| 690 | handles[0] = le32_to_cpu((uint32_t)((mb[2] << 16) | mb[1])); |
| 691 | handles[1] = le32_to_cpu( |
| 692 | ((uint32_t)(RD_MAILBOX_REG(ha, reg, 7) << 16)) | |
| 693 | RD_MAILBOX_REG(ha, reg, 6)); |
| 694 | handle_cnt = 2; |
| 695 | mb[0] = MBA_SCSI_COMPLETION; |
| 696 | break; |
| 697 | default: |
| 698 | break; |
| 699 | } |
| 700 | skip_rio: |
| 701 | switch (mb[0]) { |
| 702 | case MBA_SCSI_COMPLETION: /* Fast Post */ |
| 703 | if (!vha->flags.online) |
| 704 | break; |
| 705 | |
| 706 | for (cnt = 0; cnt < handle_cnt; cnt++) |
| 707 | qla2x00_process_completed_request(vha, rsp->req, |
| 708 | handles[cnt]); |
| 709 | break; |
| 710 | |
| 711 | case MBA_RESET: /* Reset */ |
| 712 | ql_dbg(ql_dbg_async, vha, 0x5002, |
| 713 | "Asynchronous RESET.\n"); |
| 714 | |
| 715 | set_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
| 716 | break; |
| 717 | |
| 718 | case MBA_SYSTEM_ERR: /* System Error */ |
| 719 | mbx = (IS_QLA81XX(ha) || IS_QLA83XX(ha) || IS_QLA27XX(ha) || |
| 720 | IS_QLA28XX(ha)) ? |
| 721 | RD_REG_WORD(®24->mailbox7) : 0; |
| 722 | ql_log(ql_log_warn, vha, 0x5003, |
| 723 | "ISP System Error - mbx1=%xh mbx2=%xh mbx3=%xh " |
| 724 | "mbx7=%xh.\n", mb[1], mb[2], mb[3], mbx); |
| 725 | ha->fw_dump_mpi = |
| 726 | (IS_QLA27XX(ha) || IS_QLA28XX(ha)) && |
| 727 | RD_REG_WORD(®24->mailbox7) & BIT_8; |
| 728 | ha->isp_ops->fw_dump(vha, 1); |
| 729 | ha->flags.fw_init_done = 0; |
| 730 | QLA_FW_STOPPED(ha); |
| 731 | |
| 732 | if (IS_FWI2_CAPABLE(ha)) { |
| 733 | if (mb[1] == 0 && mb[2] == 0) { |
| 734 | ql_log(ql_log_fatal, vha, 0x5004, |
| 735 | "Unrecoverable Hardware Error: adapter " |
| 736 | "marked OFFLINE!\n"); |
| 737 | vha->flags.online = 0; |
| 738 | vha->device_flags |= DFLG_DEV_FAILED; |
| 739 | } else { |
| 740 | /* Check to see if MPI timeout occurred */ |
| 741 | if ((mbx & MBX_3) && (ha->port_no == 0)) |
| 742 | set_bit(MPI_RESET_NEEDED, |
| 743 | &vha->dpc_flags); |
| 744 | |
| 745 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 746 | } |
| 747 | } else if (mb[1] == 0) { |
| 748 | ql_log(ql_log_fatal, vha, 0x5005, |
| 749 | "Unrecoverable Hardware Error: adapter marked " |
| 750 | "OFFLINE!\n"); |
| 751 | vha->flags.online = 0; |
| 752 | vha->device_flags |= DFLG_DEV_FAILED; |
| 753 | } else |
| 754 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 755 | break; |
| 756 | |
| 757 | case MBA_REQ_TRANSFER_ERR: /* Request Transfer Error */ |
| 758 | ql_log(ql_log_warn, vha, 0x5006, |
| 759 | "ISP Request Transfer Error (%x).\n", mb[1]); |
| 760 | |
| 761 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 762 | break; |
| 763 | |
| 764 | case MBA_RSP_TRANSFER_ERR: /* Response Transfer Error */ |
| 765 | ql_log(ql_log_warn, vha, 0x5007, |
| 766 | "ISP Response Transfer Error (%x).\n", mb[1]); |
| 767 | |
| 768 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 769 | break; |
| 770 | |
| 771 | case MBA_WAKEUP_THRES: /* Request Queue Wake-up */ |
| 772 | ql_dbg(ql_dbg_async, vha, 0x5008, |
| 773 | "Asynchronous WAKEUP_THRES (%x).\n", mb[1]); |
| 774 | break; |
| 775 | |
| 776 | case MBA_LOOP_INIT_ERR: |
| 777 | ql_log(ql_log_warn, vha, 0x5090, |
| 778 | "LOOP INIT ERROR (%x).\n", mb[1]); |
| 779 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 780 | break; |
| 781 | |
| 782 | case MBA_LIP_OCCURRED: /* Loop Initialization Procedure */ |
| 783 | ha->flags.lip_ae = 1; |
| 784 | |
| 785 | ql_dbg(ql_dbg_async, vha, 0x5009, |
| 786 | "LIP occurred (%x).\n", mb[1]); |
| 787 | |
| 788 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 789 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 790 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 791 | qla2x00_mark_all_devices_lost(vha, 1); |
| 792 | } |
| 793 | |
| 794 | if (vha->vp_idx) { |
| 795 | atomic_set(&vha->vp_state, VP_FAILED); |
| 796 | fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED); |
| 797 | } |
| 798 | |
| 799 | set_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags); |
| 800 | set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags); |
| 801 | |
| 802 | vha->flags.management_server_logged_in = 0; |
| 803 | qla2x00_post_aen_work(vha, FCH_EVT_LIP, mb[1]); |
| 804 | break; |
| 805 | |
| 806 | case MBA_LOOP_UP: /* Loop Up Event */ |
| 807 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) |
| 808 | ha->link_data_rate = PORT_SPEED_1GB; |
| 809 | else |
| 810 | ha->link_data_rate = mb[1]; |
| 811 | |
| 812 | ql_log(ql_log_info, vha, 0x500a, |
| 813 | "LOOP UP detected (%s Gbps).\n", |
| 814 | qla2x00_get_link_speed_str(ha, ha->link_data_rate)); |
| 815 | |
| 816 | vha->flags.management_server_logged_in = 0; |
| 817 | qla2x00_post_aen_work(vha, FCH_EVT_LINKUP, ha->link_data_rate); |
| 818 | |
| 819 | if (AUTO_DETECT_SFP_SUPPORT(vha)) { |
| 820 | set_bit(DETECT_SFP_CHANGE, &vha->dpc_flags); |
| 821 | qla2xxx_wake_dpc(vha); |
| 822 | } |
| 823 | break; |
| 824 | |
| 825 | case MBA_LOOP_DOWN: /* Loop Down Event */ |
| 826 | SAVE_TOPO(ha); |
| 827 | ha->flags.lip_ae = 0; |
| 828 | ha->current_topology = 0; |
| 829 | |
| 830 | mbx = (IS_QLA81XX(ha) || IS_QLA8031(ha)) |
| 831 | ? RD_REG_WORD(®24->mailbox4) : 0; |
| 832 | mbx = (IS_P3P_TYPE(ha)) ? RD_REG_WORD(®82->mailbox_out[4]) |
| 833 | : mbx; |
| 834 | ql_log(ql_log_info, vha, 0x500b, |
| 835 | "LOOP DOWN detected (%x %x %x %x).\n", |
| 836 | mb[1], mb[2], mb[3], mbx); |
| 837 | |
| 838 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 839 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 840 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 841 | /* |
| 842 | * In case of loop down, restore WWPN from |
| 843 | * NVRAM in case of FA-WWPN capable ISP |
| 844 | * Restore for Physical Port only |
| 845 | */ |
| 846 | if (!vha->vp_idx) { |
| 847 | if (ha->flags.fawwpn_enabled && |
| 848 | (ha->current_topology == ISP_CFG_F)) { |
| 849 | void *wwpn = ha->init_cb->port_name; |
| 850 | |
| 851 | memcpy(vha->port_name, wwpn, WWN_SIZE); |
| 852 | fc_host_port_name(vha->host) = |
| 853 | wwn_to_u64(vha->port_name); |
| 854 | ql_dbg(ql_dbg_init + ql_dbg_verbose, |
| 855 | vha, 0x00d8, "LOOP DOWN detected," |
| 856 | "restore WWPN %016llx\n", |
| 857 | wwn_to_u64(vha->port_name)); |
| 858 | } |
| 859 | |
| 860 | clear_bit(VP_CONFIG_OK, &vha->vp_flags); |
| 861 | } |
| 862 | |
| 863 | vha->device_flags |= DFLG_NO_CABLE; |
| 864 | qla2x00_mark_all_devices_lost(vha, 1); |
| 865 | } |
| 866 | |
| 867 | if (vha->vp_idx) { |
| 868 | atomic_set(&vha->vp_state, VP_FAILED); |
| 869 | fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED); |
| 870 | } |
| 871 | |
| 872 | vha->flags.management_server_logged_in = 0; |
| 873 | ha->link_data_rate = PORT_SPEED_UNKNOWN; |
| 874 | qla2x00_post_aen_work(vha, FCH_EVT_LINKDOWN, 0); |
| 875 | break; |
| 876 | |
| 877 | case MBA_LIP_RESET: /* LIP reset occurred */ |
| 878 | ql_dbg(ql_dbg_async, vha, 0x500c, |
| 879 | "LIP reset occurred (%x).\n", mb[1]); |
| 880 | |
| 881 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 882 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 883 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 884 | qla2x00_mark_all_devices_lost(vha, 1); |
| 885 | } |
| 886 | |
| 887 | if (vha->vp_idx) { |
| 888 | atomic_set(&vha->vp_state, VP_FAILED); |
| 889 | fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED); |
| 890 | } |
| 891 | |
| 892 | set_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
| 893 | |
| 894 | ha->operating_mode = LOOP; |
| 895 | vha->flags.management_server_logged_in = 0; |
| 896 | qla2x00_post_aen_work(vha, FCH_EVT_LIPRESET, mb[1]); |
| 897 | break; |
| 898 | |
| 899 | /* case MBA_DCBX_COMPLETE: */ |
| 900 | case MBA_POINT_TO_POINT: /* Point-to-Point */ |
| 901 | ha->flags.lip_ae = 0; |
| 902 | |
| 903 | if (IS_QLA2100(ha)) |
| 904 | break; |
| 905 | |
| 906 | if (IS_CNA_CAPABLE(ha)) { |
| 907 | ql_dbg(ql_dbg_async, vha, 0x500d, |
| 908 | "DCBX Completed -- %04x %04x %04x.\n", |
| 909 | mb[1], mb[2], mb[3]); |
| 910 | if (ha->notify_dcbx_comp && !vha->vp_idx) |
| 911 | complete(&ha->dcbx_comp); |
| 912 | |
| 913 | } else |
| 914 | ql_dbg(ql_dbg_async, vha, 0x500e, |
| 915 | "Asynchronous P2P MODE received.\n"); |
| 916 | |
| 917 | /* |
| 918 | * Until there's a transition from loop down to loop up, treat |
| 919 | * this as loop down only. |
| 920 | */ |
| 921 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 922 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 923 | if (!atomic_read(&vha->loop_down_timer)) |
| 924 | atomic_set(&vha->loop_down_timer, |
| 925 | LOOP_DOWN_TIME); |
| 926 | if (!N2N_TOPO(ha)) |
| 927 | qla2x00_mark_all_devices_lost(vha, 1); |
| 928 | } |
| 929 | |
| 930 | if (vha->vp_idx) { |
| 931 | atomic_set(&vha->vp_state, VP_FAILED); |
| 932 | fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED); |
| 933 | } |
| 934 | |
| 935 | if (!(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))) |
| 936 | set_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
| 937 | |
| 938 | set_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags); |
| 939 | set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags); |
| 940 | |
| 941 | vha->flags.management_server_logged_in = 0; |
| 942 | break; |
| 943 | |
| 944 | case MBA_CHG_IN_CONNECTION: /* Change in connection mode */ |
| 945 | if (IS_QLA2100(ha)) |
| 946 | break; |
| 947 | |
| 948 | ql_dbg(ql_dbg_async, vha, 0x500f, |
| 949 | "Configuration change detected: value=%x.\n", mb[1]); |
| 950 | |
| 951 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 952 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 953 | if (!atomic_read(&vha->loop_down_timer)) |
| 954 | atomic_set(&vha->loop_down_timer, |
| 955 | LOOP_DOWN_TIME); |
| 956 | qla2x00_mark_all_devices_lost(vha, 1); |
| 957 | } |
| 958 | |
| 959 | if (vha->vp_idx) { |
| 960 | atomic_set(&vha->vp_state, VP_FAILED); |
| 961 | fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED); |
| 962 | } |
| 963 | |
| 964 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 965 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
| 966 | break; |
| 967 | |
| 968 | case MBA_PORT_UPDATE: /* Port database update */ |
| 969 | /* |
| 970 | * Handle only global and vn-port update events |
| 971 | * |
| 972 | * Relevant inputs: |
| 973 | * mb[1] = N_Port handle of changed port |
| 974 | * OR 0xffff for global event |
| 975 | * mb[2] = New login state |
| 976 | * 7 = Port logged out |
| 977 | * mb[3] = LSB is vp_idx, 0xff = all vps |
| 978 | * |
| 979 | * Skip processing if: |
| 980 | * Event is global, vp_idx is NOT all vps, |
| 981 | * vp_idx does not match |
| 982 | * Event is not global, vp_idx does not match |
| 983 | */ |
| 984 | if (IS_QLA2XXX_MIDTYPE(ha) && |
| 985 | ((mb[1] == 0xffff && (mb[3] & 0xff) != 0xff) || |
| 986 | (mb[1] != 0xffff)) && vha->vp_idx != (mb[3] & 0xff)) |
| 987 | break; |
| 988 | |
| 989 | if (mb[2] == 0x7) { |
| 990 | ql_dbg(ql_dbg_async, vha, 0x5010, |
| 991 | "Port %s %04x %04x %04x.\n", |
| 992 | mb[1] == 0xffff ? "unavailable" : "logout", |
| 993 | mb[1], mb[2], mb[3]); |
| 994 | |
| 995 | if (mb[1] == 0xffff) |
| 996 | goto global_port_update; |
| 997 | |
| 998 | if (mb[1] == NPH_SNS_LID(ha)) { |
| 999 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 1000 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
| 1001 | break; |
| 1002 | } |
| 1003 | |
| 1004 | /* use handle_cnt for loop id/nport handle */ |
| 1005 | if (IS_FWI2_CAPABLE(ha)) |
| 1006 | handle_cnt = NPH_SNS; |
| 1007 | else |
| 1008 | handle_cnt = SIMPLE_NAME_SERVER; |
| 1009 | if (mb[1] == handle_cnt) { |
| 1010 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 1011 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
| 1012 | break; |
| 1013 | } |
| 1014 | |
| 1015 | /* Port logout */ |
| 1016 | fcport = qla2x00_find_fcport_by_loopid(vha, mb[1]); |
| 1017 | if (!fcport) |
| 1018 | break; |
| 1019 | if (atomic_read(&fcport->state) != FCS_ONLINE) |
| 1020 | break; |
| 1021 | ql_dbg(ql_dbg_async, vha, 0x508a, |
| 1022 | "Marking port lost loopid=%04x portid=%06x.\n", |
| 1023 | fcport->loop_id, fcport->d_id.b24); |
| 1024 | if (qla_ini_mode_enabled(vha)) { |
| 1025 | qla2x00_mark_device_lost(fcport->vha, fcport, 1, 1); |
| 1026 | fcport->logout_on_delete = 0; |
| 1027 | qlt_schedule_sess_for_deletion(fcport); |
| 1028 | } |
| 1029 | break; |
| 1030 | |
| 1031 | global_port_update: |
| 1032 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 1033 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 1034 | atomic_set(&vha->loop_down_timer, |
| 1035 | LOOP_DOWN_TIME); |
| 1036 | vha->device_flags |= DFLG_NO_CABLE; |
| 1037 | qla2x00_mark_all_devices_lost(vha, 1); |
| 1038 | } |
| 1039 | |
| 1040 | if (vha->vp_idx) { |
| 1041 | atomic_set(&vha->vp_state, VP_FAILED); |
| 1042 | fc_vport_set_state(vha->fc_vport, |
| 1043 | FC_VPORT_FAILED); |
| 1044 | qla2x00_mark_all_devices_lost(vha, 1); |
| 1045 | } |
| 1046 | |
| 1047 | vha->flags.management_server_logged_in = 0; |
| 1048 | ha->link_data_rate = PORT_SPEED_UNKNOWN; |
| 1049 | break; |
| 1050 | } |
| 1051 | |
| 1052 | /* |
| 1053 | * If PORT UPDATE is global (received LIP_OCCURRED/LIP_RESET |
| 1054 | * event etc. earlier indicating loop is down) then process |
| 1055 | * it. Otherwise ignore it and Wait for RSCN to come in. |
| 1056 | */ |
| 1057 | atomic_set(&vha->loop_down_timer, 0); |
| 1058 | if (atomic_read(&vha->loop_state) != LOOP_DOWN && |
| 1059 | !ha->flags.n2n_ae && |
| 1060 | atomic_read(&vha->loop_state) != LOOP_DEAD) { |
| 1061 | ql_dbg(ql_dbg_async, vha, 0x5011, |
| 1062 | "Asynchronous PORT UPDATE ignored %04x/%04x/%04x.\n", |
| 1063 | mb[1], mb[2], mb[3]); |
| 1064 | |
| 1065 | qlt_async_event(mb[0], vha, mb); |
| 1066 | break; |
| 1067 | } |
| 1068 | |
| 1069 | ql_dbg(ql_dbg_async, vha, 0x5012, |
| 1070 | "Port database changed %04x %04x %04x.\n", |
| 1071 | mb[1], mb[2], mb[3]); |
| 1072 | |
| 1073 | /* |
| 1074 | * Mark all devices as missing so we will login again. |
| 1075 | */ |
| 1076 | atomic_set(&vha->loop_state, LOOP_UP); |
| 1077 | vha->scan.scan_retry = 0; |
| 1078 | |
| 1079 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 1080 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
| 1081 | set_bit(VP_CONFIG_OK, &vha->vp_flags); |
| 1082 | |
| 1083 | qlt_async_event(mb[0], vha, mb); |
| 1084 | break; |
| 1085 | |
| 1086 | case MBA_RSCN_UPDATE: /* State Change Registration */ |
| 1087 | /* Check if the Vport has issued a SCR */ |
| 1088 | if (vha->vp_idx && test_bit(VP_SCR_NEEDED, &vha->vp_flags)) |
| 1089 | break; |
| 1090 | /* Only handle SCNs for our Vport index. */ |
| 1091 | if (ha->flags.npiv_supported && vha->vp_idx != (mb[3] & 0xff)) |
| 1092 | break; |
| 1093 | |
| 1094 | ql_dbg(ql_dbg_async, vha, 0x5013, |
| 1095 | "RSCN database changed -- %04x %04x %04x.\n", |
| 1096 | mb[1], mb[2], mb[3]); |
| 1097 | |
| 1098 | rscn_entry = ((mb[1] & 0xff) << 16) | mb[2]; |
| 1099 | host_pid = (vha->d_id.b.domain << 16) | (vha->d_id.b.area << 8) |
| 1100 | | vha->d_id.b.al_pa; |
| 1101 | if (rscn_entry == host_pid) { |
| 1102 | ql_dbg(ql_dbg_async, vha, 0x5014, |
| 1103 | "Ignoring RSCN update to local host " |
| 1104 | "port ID (%06x).\n", host_pid); |
| 1105 | break; |
| 1106 | } |
| 1107 | |
| 1108 | /* Ignore reserved bits from RSCN-payload. */ |
| 1109 | rscn_entry = ((mb[1] & 0x3ff) << 16) | mb[2]; |
| 1110 | |
| 1111 | /* Skip RSCNs for virtual ports on the same physical port */ |
| 1112 | if (qla2x00_is_a_vp_did(vha, rscn_entry)) |
| 1113 | break; |
| 1114 | |
| 1115 | atomic_set(&vha->loop_down_timer, 0); |
| 1116 | vha->flags.management_server_logged_in = 0; |
| 1117 | { |
| 1118 | struct event_arg ea; |
| 1119 | |
| 1120 | memset(&ea, 0, sizeof(ea)); |
| 1121 | ea.event = FCME_RSCN; |
| 1122 | ea.id.b24 = rscn_entry; |
| 1123 | ea.id.b.rsvd_1 = rscn_entry >> 24; |
| 1124 | qla2x00_fcport_event_handler(vha, &ea); |
| 1125 | qla2x00_post_aen_work(vha, FCH_EVT_RSCN, rscn_entry); |
| 1126 | } |
| 1127 | break; |
| 1128 | /* case MBA_RIO_RESPONSE: */ |
| 1129 | case MBA_ZIO_RESPONSE: |
| 1130 | ql_dbg(ql_dbg_async, vha, 0x5015, |
| 1131 | "[R|Z]IO update completion.\n"); |
| 1132 | |
| 1133 | if (IS_FWI2_CAPABLE(ha)) |
| 1134 | qla24xx_process_response_queue(vha, rsp); |
| 1135 | else |
| 1136 | qla2x00_process_response_queue(rsp); |
| 1137 | break; |
| 1138 | |
| 1139 | case MBA_DISCARD_RND_FRAME: |
| 1140 | ql_dbg(ql_dbg_async, vha, 0x5016, |
| 1141 | "Discard RND Frame -- %04x %04x %04x.\n", |
| 1142 | mb[1], mb[2], mb[3]); |
| 1143 | break; |
| 1144 | |
| 1145 | case MBA_TRACE_NOTIFICATION: |
| 1146 | ql_dbg(ql_dbg_async, vha, 0x5017, |
| 1147 | "Trace Notification -- %04x %04x.\n", mb[1], mb[2]); |
| 1148 | break; |
| 1149 | |
| 1150 | case MBA_ISP84XX_ALERT: |
| 1151 | ql_dbg(ql_dbg_async, vha, 0x5018, |
| 1152 | "ISP84XX Alert Notification -- %04x %04x %04x.\n", |
| 1153 | mb[1], mb[2], mb[3]); |
| 1154 | |
| 1155 | spin_lock_irqsave(&ha->cs84xx->access_lock, flags); |
| 1156 | switch (mb[1]) { |
| 1157 | case A84_PANIC_RECOVERY: |
| 1158 | ql_log(ql_log_info, vha, 0x5019, |
| 1159 | "Alert 84XX: panic recovery %04x %04x.\n", |
| 1160 | mb[2], mb[3]); |
| 1161 | break; |
| 1162 | case A84_OP_LOGIN_COMPLETE: |
| 1163 | ha->cs84xx->op_fw_version = mb[3] << 16 | mb[2]; |
| 1164 | ql_log(ql_log_info, vha, 0x501a, |
| 1165 | "Alert 84XX: firmware version %x.\n", |
| 1166 | ha->cs84xx->op_fw_version); |
| 1167 | break; |
| 1168 | case A84_DIAG_LOGIN_COMPLETE: |
| 1169 | ha->cs84xx->diag_fw_version = mb[3] << 16 | mb[2]; |
| 1170 | ql_log(ql_log_info, vha, 0x501b, |
| 1171 | "Alert 84XX: diagnostic firmware version %x.\n", |
| 1172 | ha->cs84xx->diag_fw_version); |
| 1173 | break; |
| 1174 | case A84_GOLD_LOGIN_COMPLETE: |
| 1175 | ha->cs84xx->diag_fw_version = mb[3] << 16 | mb[2]; |
| 1176 | ha->cs84xx->fw_update = 1; |
| 1177 | ql_log(ql_log_info, vha, 0x501c, |
| 1178 | "Alert 84XX: gold firmware version %x.\n", |
| 1179 | ha->cs84xx->gold_fw_version); |
| 1180 | break; |
| 1181 | default: |
| 1182 | ql_log(ql_log_warn, vha, 0x501d, |
| 1183 | "Alert 84xx: Invalid Alert %04x %04x %04x.\n", |
| 1184 | mb[1], mb[2], mb[3]); |
| 1185 | } |
| 1186 | spin_unlock_irqrestore(&ha->cs84xx->access_lock, flags); |
| 1187 | break; |
| 1188 | case MBA_DCBX_START: |
| 1189 | ql_dbg(ql_dbg_async, vha, 0x501e, |
| 1190 | "DCBX Started -- %04x %04x %04x.\n", |
| 1191 | mb[1], mb[2], mb[3]); |
| 1192 | break; |
| 1193 | case MBA_DCBX_PARAM_UPDATE: |
| 1194 | ql_dbg(ql_dbg_async, vha, 0x501f, |
| 1195 | "DCBX Parameters Updated -- %04x %04x %04x.\n", |
| 1196 | mb[1], mb[2], mb[3]); |
| 1197 | break; |
| 1198 | case MBA_FCF_CONF_ERR: |
| 1199 | ql_dbg(ql_dbg_async, vha, 0x5020, |
| 1200 | "FCF Configuration Error -- %04x %04x %04x.\n", |
| 1201 | mb[1], mb[2], mb[3]); |
| 1202 | break; |
| 1203 | case MBA_IDC_NOTIFY: |
| 1204 | if (IS_QLA8031(vha->hw) || IS_QLA8044(ha)) { |
| 1205 | mb[4] = RD_REG_WORD(®24->mailbox4); |
| 1206 | if (((mb[2] & 0x7fff) == MBC_PORT_RESET || |
| 1207 | (mb[2] & 0x7fff) == MBC_SET_PORT_CONFIG) && |
| 1208 | (mb[4] & INTERNAL_LOOPBACK_MASK) != 0) { |
| 1209 | set_bit(ISP_QUIESCE_NEEDED, &vha->dpc_flags); |
| 1210 | /* |
| 1211 | * Extend loop down timer since port is active. |
| 1212 | */ |
| 1213 | if (atomic_read(&vha->loop_state) == LOOP_DOWN) |
| 1214 | atomic_set(&vha->loop_down_timer, |
| 1215 | LOOP_DOWN_TIME); |
| 1216 | qla2xxx_wake_dpc(vha); |
| 1217 | } |
| 1218 | } |
| 1219 | /* fall through */ |
| 1220 | case MBA_IDC_COMPLETE: |
| 1221 | if (ha->notify_lb_portup_comp && !vha->vp_idx) |
| 1222 | complete(&ha->lb_portup_comp); |
| 1223 | /* Fallthru */ |
| 1224 | case MBA_IDC_TIME_EXT: |
| 1225 | if (IS_QLA81XX(vha->hw) || IS_QLA8031(vha->hw) || |
| 1226 | IS_QLA8044(ha)) |
| 1227 | qla81xx_idc_event(vha, mb[0], mb[1]); |
| 1228 | break; |
| 1229 | |
| 1230 | case MBA_IDC_AEN: |
| 1231 | mb[4] = RD_REG_WORD(®24->mailbox4); |
| 1232 | mb[5] = RD_REG_WORD(®24->mailbox5); |
| 1233 | mb[6] = RD_REG_WORD(®24->mailbox6); |
| 1234 | mb[7] = RD_REG_WORD(®24->mailbox7); |
| 1235 | qla83xx_handle_8200_aen(vha, mb); |
| 1236 | break; |
| 1237 | |
| 1238 | case MBA_DPORT_DIAGNOSTICS: |
| 1239 | ql_dbg(ql_dbg_async, vha, 0x5052, |
| 1240 | "D-Port Diagnostics: %04x result=%s\n", |
| 1241 | mb[0], |
| 1242 | mb[1] == 0 ? "start" : |
| 1243 | mb[1] == 1 ? "done (pass)" : |
| 1244 | mb[1] == 2 ? "done (error)" : "other"); |
| 1245 | break; |
| 1246 | |
| 1247 | case MBA_TEMPERATURE_ALERT: |
| 1248 | ql_dbg(ql_dbg_async, vha, 0x505e, |
| 1249 | "TEMPERATURE ALERT: %04x %04x %04x\n", mb[1], mb[2], mb[3]); |
| 1250 | if (mb[1] == 0x12) |
| 1251 | schedule_work(&ha->board_disable); |
| 1252 | break; |
| 1253 | |
| 1254 | case MBA_TRANS_INSERT: |
| 1255 | ql_dbg(ql_dbg_async, vha, 0x5091, |
| 1256 | "Transceiver Insertion: %04x\n", mb[1]); |
| 1257 | break; |
| 1258 | |
| 1259 | default: |
| 1260 | ql_dbg(ql_dbg_async, vha, 0x5057, |
| 1261 | "Unknown AEN:%04x %04x %04x %04x\n", |
| 1262 | mb[0], mb[1], mb[2], mb[3]); |
| 1263 | } |
| 1264 | |
| 1265 | qlt_async_event(mb[0], vha, mb); |
| 1266 | |
| 1267 | if (!vha->vp_idx && ha->num_vhosts) |
| 1268 | qla2x00_alert_all_vps(rsp, mb); |
| 1269 | } |
| 1270 | |
| 1271 | /** |
| 1272 | * qla2x00_process_completed_request() - Process a Fast Post response. |
| 1273 | * @vha: SCSI driver HA context |
| 1274 | * @req: request queue |
| 1275 | * @index: SRB index |
| 1276 | */ |
| 1277 | void |
| 1278 | qla2x00_process_completed_request(struct scsi_qla_host *vha, |
| 1279 | struct req_que *req, uint32_t index) |
| 1280 | { |
| 1281 | srb_t *sp; |
| 1282 | struct qla_hw_data *ha = vha->hw; |
| 1283 | |
| 1284 | /* Validate handle. */ |
| 1285 | if (index >= req->num_outstanding_cmds) { |
| 1286 | ql_log(ql_log_warn, vha, 0x3014, |
| 1287 | "Invalid SCSI command index (%x).\n", index); |
| 1288 | |
| 1289 | if (IS_P3P_TYPE(ha)) |
| 1290 | set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags); |
| 1291 | else |
| 1292 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 1293 | return; |
| 1294 | } |
| 1295 | |
| 1296 | sp = req->outstanding_cmds[index]; |
| 1297 | if (sp) { |
| 1298 | /* Free outstanding command slot. */ |
| 1299 | req->outstanding_cmds[index] = NULL; |
| 1300 | |
| 1301 | /* Save ISP completion status */ |
| 1302 | sp->done(sp, DID_OK << 16); |
| 1303 | } else { |
| 1304 | ql_log(ql_log_warn, vha, 0x3016, "Invalid SCSI SRB.\n"); |
| 1305 | |
| 1306 | if (IS_P3P_TYPE(ha)) |
| 1307 | set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags); |
| 1308 | else |
| 1309 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 1310 | } |
| 1311 | } |
| 1312 | |
| 1313 | srb_t * |
| 1314 | qla2x00_get_sp_from_handle(scsi_qla_host_t *vha, const char *func, |
| 1315 | struct req_que *req, void *iocb) |
| 1316 | { |
| 1317 | struct qla_hw_data *ha = vha->hw; |
| 1318 | sts_entry_t *pkt = iocb; |
| 1319 | srb_t *sp = NULL; |
| 1320 | uint16_t index; |
| 1321 | |
| 1322 | index = LSW(pkt->handle); |
| 1323 | if (index >= req->num_outstanding_cmds) { |
| 1324 | ql_log(ql_log_warn, vha, 0x5031, |
| 1325 | "Invalid command index (%x) type %8ph.\n", |
| 1326 | index, iocb); |
| 1327 | if (IS_P3P_TYPE(ha)) |
| 1328 | set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags); |
| 1329 | else |
| 1330 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 1331 | goto done; |
| 1332 | } |
| 1333 | sp = req->outstanding_cmds[index]; |
| 1334 | if (!sp) { |
| 1335 | ql_log(ql_log_warn, vha, 0x5032, |
| 1336 | "Invalid completion handle (%x) -- timed-out.\n", index); |
| 1337 | return sp; |
| 1338 | } |
| 1339 | if (sp->handle != index) { |
| 1340 | ql_log(ql_log_warn, vha, 0x5033, |
| 1341 | "SRB handle (%x) mismatch %x.\n", sp->handle, index); |
| 1342 | return NULL; |
| 1343 | } |
| 1344 | |
| 1345 | req->outstanding_cmds[index] = NULL; |
| 1346 | |
| 1347 | done: |
| 1348 | return sp; |
| 1349 | } |
| 1350 | |
| 1351 | static void |
| 1352 | qla2x00_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, |
| 1353 | struct mbx_entry *mbx) |
| 1354 | { |
| 1355 | const char func[] = "MBX-IOCB"; |
| 1356 | const char *type; |
| 1357 | fc_port_t *fcport; |
| 1358 | srb_t *sp; |
| 1359 | struct srb_iocb *lio; |
| 1360 | uint16_t *data; |
| 1361 | uint16_t status; |
| 1362 | |
| 1363 | sp = qla2x00_get_sp_from_handle(vha, func, req, mbx); |
| 1364 | if (!sp) |
| 1365 | return; |
| 1366 | |
| 1367 | lio = &sp->u.iocb_cmd; |
| 1368 | type = sp->name; |
| 1369 | fcport = sp->fcport; |
| 1370 | data = lio->u.logio.data; |
| 1371 | |
| 1372 | data[0] = MBS_COMMAND_ERROR; |
| 1373 | data[1] = lio->u.logio.flags & SRB_LOGIN_RETRIED ? |
| 1374 | QLA_LOGIO_LOGIN_RETRIED : 0; |
| 1375 | if (mbx->entry_status) { |
| 1376 | ql_dbg(ql_dbg_async, vha, 0x5043, |
| 1377 | "Async-%s error entry - hdl=%x portid=%02x%02x%02x " |
| 1378 | "entry-status=%x status=%x state-flag=%x " |
| 1379 | "status-flags=%x.\n", type, sp->handle, |
| 1380 | fcport->d_id.b.domain, fcport->d_id.b.area, |
| 1381 | fcport->d_id.b.al_pa, mbx->entry_status, |
| 1382 | le16_to_cpu(mbx->status), le16_to_cpu(mbx->state_flags), |
| 1383 | le16_to_cpu(mbx->status_flags)); |
| 1384 | |
| 1385 | ql_dump_buffer(ql_dbg_async + ql_dbg_buffer, vha, 0x5029, |
| 1386 | mbx, sizeof(*mbx)); |
| 1387 | |
| 1388 | goto logio_done; |
| 1389 | } |
| 1390 | |
| 1391 | status = le16_to_cpu(mbx->status); |
| 1392 | if (status == 0x30 && sp->type == SRB_LOGIN_CMD && |
| 1393 | le16_to_cpu(mbx->mb0) == MBS_COMMAND_COMPLETE) |
| 1394 | status = 0; |
| 1395 | if (!status && le16_to_cpu(mbx->mb0) == MBS_COMMAND_COMPLETE) { |
| 1396 | ql_dbg(ql_dbg_async, vha, 0x5045, |
| 1397 | "Async-%s complete - hdl=%x portid=%02x%02x%02x mbx1=%x.\n", |
| 1398 | type, sp->handle, fcport->d_id.b.domain, |
| 1399 | fcport->d_id.b.area, fcport->d_id.b.al_pa, |
| 1400 | le16_to_cpu(mbx->mb1)); |
| 1401 | |
| 1402 | data[0] = MBS_COMMAND_COMPLETE; |
| 1403 | if (sp->type == SRB_LOGIN_CMD) { |
| 1404 | fcport->port_type = FCT_TARGET; |
| 1405 | if (le16_to_cpu(mbx->mb1) & BIT_0) |
| 1406 | fcport->port_type = FCT_INITIATOR; |
| 1407 | else if (le16_to_cpu(mbx->mb1) & BIT_1) |
| 1408 | fcport->flags |= FCF_FCP2_DEVICE; |
| 1409 | } |
| 1410 | goto logio_done; |
| 1411 | } |
| 1412 | |
| 1413 | data[0] = le16_to_cpu(mbx->mb0); |
| 1414 | switch (data[0]) { |
| 1415 | case MBS_PORT_ID_USED: |
| 1416 | data[1] = le16_to_cpu(mbx->mb1); |
| 1417 | break; |
| 1418 | case MBS_LOOP_ID_USED: |
| 1419 | break; |
| 1420 | default: |
| 1421 | data[0] = MBS_COMMAND_ERROR; |
| 1422 | break; |
| 1423 | } |
| 1424 | |
| 1425 | ql_log(ql_log_warn, vha, 0x5046, |
| 1426 | "Async-%s failed - hdl=%x portid=%02x%02x%02x status=%x " |
| 1427 | "mb0=%x mb1=%x mb2=%x mb6=%x mb7=%x.\n", type, sp->handle, |
| 1428 | fcport->d_id.b.domain, fcport->d_id.b.area, fcport->d_id.b.al_pa, |
| 1429 | status, le16_to_cpu(mbx->mb0), le16_to_cpu(mbx->mb1), |
| 1430 | le16_to_cpu(mbx->mb2), le16_to_cpu(mbx->mb6), |
| 1431 | le16_to_cpu(mbx->mb7)); |
| 1432 | |
| 1433 | logio_done: |
| 1434 | sp->done(sp, 0); |
| 1435 | } |
| 1436 | |
| 1437 | static void |
| 1438 | qla24xx_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, |
| 1439 | struct mbx_24xx_entry *pkt) |
| 1440 | { |
| 1441 | const char func[] = "MBX-IOCB2"; |
| 1442 | srb_t *sp; |
| 1443 | struct srb_iocb *si; |
| 1444 | u16 sz, i; |
| 1445 | int res; |
| 1446 | |
| 1447 | sp = qla2x00_get_sp_from_handle(vha, func, req, pkt); |
| 1448 | if (!sp) |
| 1449 | return; |
| 1450 | |
| 1451 | si = &sp->u.iocb_cmd; |
| 1452 | sz = min(ARRAY_SIZE(pkt->mb), ARRAY_SIZE(sp->u.iocb_cmd.u.mbx.in_mb)); |
| 1453 | |
| 1454 | for (i = 0; i < sz; i++) |
| 1455 | si->u.mbx.in_mb[i] = le16_to_cpu(pkt->mb[i]); |
| 1456 | |
| 1457 | res = (si->u.mbx.in_mb[0] & MBS_MASK); |
| 1458 | |
| 1459 | sp->done(sp, res); |
| 1460 | } |
| 1461 | |
| 1462 | static void |
| 1463 | qla24xxx_nack_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, |
| 1464 | struct nack_to_isp *pkt) |
| 1465 | { |
| 1466 | const char func[] = "nack"; |
| 1467 | srb_t *sp; |
| 1468 | int res = 0; |
| 1469 | |
| 1470 | sp = qla2x00_get_sp_from_handle(vha, func, req, pkt); |
| 1471 | if (!sp) |
| 1472 | return; |
| 1473 | |
| 1474 | if (pkt->u.isp2x.status != cpu_to_le16(NOTIFY_ACK_SUCCESS)) |
| 1475 | res = QLA_FUNCTION_FAILED; |
| 1476 | |
| 1477 | sp->done(sp, res); |
| 1478 | } |
| 1479 | |
| 1480 | static void |
| 1481 | qla2x00_ct_entry(scsi_qla_host_t *vha, struct req_que *req, |
| 1482 | sts_entry_t *pkt, int iocb_type) |
| 1483 | { |
| 1484 | const char func[] = "CT_IOCB"; |
| 1485 | const char *type; |
| 1486 | srb_t *sp; |
| 1487 | struct bsg_job *bsg_job; |
| 1488 | struct fc_bsg_reply *bsg_reply; |
| 1489 | uint16_t comp_status; |
| 1490 | int res = 0; |
| 1491 | |
| 1492 | sp = qla2x00_get_sp_from_handle(vha, func, req, pkt); |
| 1493 | if (!sp) |
| 1494 | return; |
| 1495 | |
| 1496 | switch (sp->type) { |
| 1497 | case SRB_CT_CMD: |
| 1498 | bsg_job = sp->u.bsg_job; |
| 1499 | bsg_reply = bsg_job->reply; |
| 1500 | |
| 1501 | type = "ct pass-through"; |
| 1502 | |
| 1503 | comp_status = le16_to_cpu(pkt->comp_status); |
| 1504 | |
| 1505 | /* |
| 1506 | * return FC_CTELS_STATUS_OK and leave the decoding of the ELS/CT |
| 1507 | * fc payload to the caller |
| 1508 | */ |
| 1509 | bsg_reply->reply_data.ctels_reply.status = FC_CTELS_STATUS_OK; |
| 1510 | bsg_job->reply_len = sizeof(struct fc_bsg_reply); |
| 1511 | |
| 1512 | if (comp_status != CS_COMPLETE) { |
| 1513 | if (comp_status == CS_DATA_UNDERRUN) { |
| 1514 | res = DID_OK << 16; |
| 1515 | bsg_reply->reply_payload_rcv_len = |
| 1516 | le16_to_cpu(pkt->rsp_info_len); |
| 1517 | |
| 1518 | ql_log(ql_log_warn, vha, 0x5048, |
| 1519 | "CT pass-through-%s error comp_status=0x%x total_byte=0x%x.\n", |
| 1520 | type, comp_status, |
| 1521 | bsg_reply->reply_payload_rcv_len); |
| 1522 | } else { |
| 1523 | ql_log(ql_log_warn, vha, 0x5049, |
| 1524 | "CT pass-through-%s error comp_status=0x%x.\n", |
| 1525 | type, comp_status); |
| 1526 | res = DID_ERROR << 16; |
| 1527 | bsg_reply->reply_payload_rcv_len = 0; |
| 1528 | } |
| 1529 | ql_dump_buffer(ql_dbg_async + ql_dbg_buffer, vha, 0x5035, |
| 1530 | pkt, sizeof(*pkt)); |
| 1531 | } else { |
| 1532 | res = DID_OK << 16; |
| 1533 | bsg_reply->reply_payload_rcv_len = |
| 1534 | bsg_job->reply_payload.payload_len; |
| 1535 | bsg_job->reply_len = 0; |
| 1536 | } |
| 1537 | break; |
| 1538 | case SRB_CT_PTHRU_CMD: |
| 1539 | /* |
| 1540 | * borrowing sts_entry_24xx.comp_status. |
| 1541 | * same location as ct_entry_24xx.comp_status |
| 1542 | */ |
| 1543 | res = qla2x00_chk_ms_status(vha, (ms_iocb_entry_t *)pkt, |
| 1544 | (struct ct_sns_rsp *)sp->u.iocb_cmd.u.ctarg.rsp, |
| 1545 | sp->name); |
| 1546 | break; |
| 1547 | } |
| 1548 | |
| 1549 | sp->done(sp, res); |
| 1550 | } |
| 1551 | |
| 1552 | static void |
| 1553 | qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req, |
| 1554 | struct sts_entry_24xx *pkt, int iocb_type) |
| 1555 | { |
| 1556 | const char func[] = "ELS_CT_IOCB"; |
| 1557 | const char *type; |
| 1558 | srb_t *sp; |
| 1559 | struct bsg_job *bsg_job; |
| 1560 | struct fc_bsg_reply *bsg_reply; |
| 1561 | uint16_t comp_status; |
| 1562 | uint32_t fw_status[3]; |
| 1563 | int res; |
| 1564 | struct srb_iocb *els; |
| 1565 | |
| 1566 | sp = qla2x00_get_sp_from_handle(vha, func, req, pkt); |
| 1567 | if (!sp) |
| 1568 | return; |
| 1569 | |
| 1570 | type = NULL; |
| 1571 | switch (sp->type) { |
| 1572 | case SRB_ELS_CMD_RPT: |
| 1573 | case SRB_ELS_CMD_HST: |
| 1574 | type = "els"; |
| 1575 | break; |
| 1576 | case SRB_CT_CMD: |
| 1577 | type = "ct pass-through"; |
| 1578 | break; |
| 1579 | case SRB_ELS_DCMD: |
| 1580 | type = "Driver ELS logo"; |
| 1581 | if (iocb_type != ELS_IOCB_TYPE) { |
| 1582 | ql_dbg(ql_dbg_user, vha, 0x5047, |
| 1583 | "Completing %s: (%p) type=%d.\n", |
| 1584 | type, sp, sp->type); |
| 1585 | sp->done(sp, 0); |
| 1586 | return; |
| 1587 | } |
| 1588 | break; |
| 1589 | case SRB_CT_PTHRU_CMD: |
| 1590 | /* borrowing sts_entry_24xx.comp_status. |
| 1591 | same location as ct_entry_24xx.comp_status |
| 1592 | */ |
| 1593 | res = qla2x00_chk_ms_status(sp->vha, (ms_iocb_entry_t *)pkt, |
| 1594 | (struct ct_sns_rsp *)sp->u.iocb_cmd.u.ctarg.rsp, |
| 1595 | sp->name); |
| 1596 | sp->done(sp, res); |
| 1597 | return; |
| 1598 | default: |
| 1599 | ql_dbg(ql_dbg_user, vha, 0x503e, |
| 1600 | "Unrecognized SRB: (%p) type=%d.\n", sp, sp->type); |
| 1601 | return; |
| 1602 | } |
| 1603 | |
| 1604 | comp_status = fw_status[0] = le16_to_cpu(pkt->comp_status); |
| 1605 | fw_status[1] = le16_to_cpu(((struct els_sts_entry_24xx *)pkt)->error_subcode_1); |
| 1606 | fw_status[2] = le16_to_cpu(((struct els_sts_entry_24xx *)pkt)->error_subcode_2); |
| 1607 | |
| 1608 | if (iocb_type == ELS_IOCB_TYPE) { |
| 1609 | els = &sp->u.iocb_cmd; |
| 1610 | els->u.els_plogi.fw_status[0] = fw_status[0]; |
| 1611 | els->u.els_plogi.fw_status[1] = fw_status[1]; |
| 1612 | els->u.els_plogi.fw_status[2] = fw_status[2]; |
| 1613 | els->u.els_plogi.comp_status = fw_status[0]; |
| 1614 | if (comp_status == CS_COMPLETE) { |
| 1615 | res = DID_OK << 16; |
| 1616 | } else { |
| 1617 | if (comp_status == CS_DATA_UNDERRUN) { |
| 1618 | res = DID_OK << 16; |
| 1619 | els->u.els_plogi.len = |
| 1620 | le16_to_cpu(((struct els_sts_entry_24xx *) |
| 1621 | pkt)->total_byte_count); |
| 1622 | } else { |
| 1623 | els->u.els_plogi.len = 0; |
| 1624 | res = DID_ERROR << 16; |
| 1625 | } |
| 1626 | } |
| 1627 | ql_dbg(ql_dbg_user, vha, 0x503f, |
| 1628 | "ELS IOCB Done -%s error hdl=%x comp_status=0x%x error subcode 1=0x%x error subcode 2=0x%x total_byte=0x%x\n", |
| 1629 | type, sp->handle, comp_status, fw_status[1], fw_status[2], |
| 1630 | le16_to_cpu(((struct els_sts_entry_24xx *) |
| 1631 | pkt)->total_byte_count)); |
| 1632 | goto els_ct_done; |
| 1633 | } |
| 1634 | |
| 1635 | /* return FC_CTELS_STATUS_OK and leave the decoding of the ELS/CT |
| 1636 | * fc payload to the caller |
| 1637 | */ |
| 1638 | bsg_job = sp->u.bsg_job; |
| 1639 | bsg_reply = bsg_job->reply; |
| 1640 | bsg_reply->reply_data.ctels_reply.status = FC_CTELS_STATUS_OK; |
| 1641 | bsg_job->reply_len = sizeof(struct fc_bsg_reply) + sizeof(fw_status); |
| 1642 | |
| 1643 | if (comp_status != CS_COMPLETE) { |
| 1644 | if (comp_status == CS_DATA_UNDERRUN) { |
| 1645 | res = DID_OK << 16; |
| 1646 | bsg_reply->reply_payload_rcv_len = |
| 1647 | le16_to_cpu(((struct els_sts_entry_24xx *)pkt)->total_byte_count); |
| 1648 | |
| 1649 | ql_dbg(ql_dbg_user, vha, 0x503f, |
| 1650 | "ELS-CT pass-through-%s error hdl=%x comp_status-status=0x%x " |
| 1651 | "error subcode 1=0x%x error subcode 2=0x%x total_byte = 0x%x.\n", |
| 1652 | type, sp->handle, comp_status, fw_status[1], fw_status[2], |
| 1653 | le16_to_cpu(((struct els_sts_entry_24xx *) |
| 1654 | pkt)->total_byte_count)); |
| 1655 | } else { |
| 1656 | ql_dbg(ql_dbg_user, vha, 0x5040, |
| 1657 | "ELS-CT pass-through-%s error hdl=%x comp_status-status=0x%x " |
| 1658 | "error subcode 1=0x%x error subcode 2=0x%x.\n", |
| 1659 | type, sp->handle, comp_status, |
| 1660 | le16_to_cpu(((struct els_sts_entry_24xx *) |
| 1661 | pkt)->error_subcode_1), |
| 1662 | le16_to_cpu(((struct els_sts_entry_24xx *) |
| 1663 | pkt)->error_subcode_2)); |
| 1664 | res = DID_ERROR << 16; |
| 1665 | bsg_reply->reply_payload_rcv_len = 0; |
| 1666 | } |
| 1667 | memcpy(bsg_job->reply + sizeof(struct fc_bsg_reply), |
| 1668 | fw_status, sizeof(fw_status)); |
| 1669 | ql_dump_buffer(ql_dbg_user + ql_dbg_buffer, vha, 0x5056, |
| 1670 | pkt, sizeof(*pkt)); |
| 1671 | } |
| 1672 | else { |
| 1673 | res = DID_OK << 16; |
| 1674 | bsg_reply->reply_payload_rcv_len = bsg_job->reply_payload.payload_len; |
| 1675 | bsg_job->reply_len = 0; |
| 1676 | } |
| 1677 | els_ct_done: |
| 1678 | |
| 1679 | sp->done(sp, res); |
| 1680 | } |
| 1681 | |
| 1682 | static void |
| 1683 | qla24xx_logio_entry(scsi_qla_host_t *vha, struct req_que *req, |
| 1684 | struct logio_entry_24xx *logio) |
| 1685 | { |
| 1686 | const char func[] = "LOGIO-IOCB"; |
| 1687 | const char *type; |
| 1688 | fc_port_t *fcport; |
| 1689 | srb_t *sp; |
| 1690 | struct srb_iocb *lio; |
| 1691 | uint16_t *data; |
| 1692 | uint32_t iop[2]; |
| 1693 | |
| 1694 | sp = qla2x00_get_sp_from_handle(vha, func, req, logio); |
| 1695 | if (!sp) |
| 1696 | return; |
| 1697 | |
| 1698 | lio = &sp->u.iocb_cmd; |
| 1699 | type = sp->name; |
| 1700 | fcport = sp->fcport; |
| 1701 | data = lio->u.logio.data; |
| 1702 | |
| 1703 | data[0] = MBS_COMMAND_ERROR; |
| 1704 | data[1] = lio->u.logio.flags & SRB_LOGIN_RETRIED ? |
| 1705 | QLA_LOGIO_LOGIN_RETRIED : 0; |
| 1706 | if (logio->entry_status) { |
| 1707 | ql_log(ql_log_warn, fcport->vha, 0x5034, |
| 1708 | "Async-%s error entry - %8phC hdl=%x" |
| 1709 | "portid=%02x%02x%02x entry-status=%x.\n", |
| 1710 | type, fcport->port_name, sp->handle, fcport->d_id.b.domain, |
| 1711 | fcport->d_id.b.area, fcport->d_id.b.al_pa, |
| 1712 | logio->entry_status); |
| 1713 | ql_dump_buffer(ql_dbg_async + ql_dbg_buffer, vha, 0x504d, |
| 1714 | logio, sizeof(*logio)); |
| 1715 | |
| 1716 | goto logio_done; |
| 1717 | } |
| 1718 | |
| 1719 | if (le16_to_cpu(logio->comp_status) == CS_COMPLETE) { |
| 1720 | ql_dbg(ql_dbg_async, fcport->vha, 0x5036, |
| 1721 | "Async-%s complete - %8phC hdl=%x portid=%02x%02x%02x " |
| 1722 | "iop0=%x.\n", type, fcport->port_name, sp->handle, |
| 1723 | fcport->d_id.b.domain, |
| 1724 | fcport->d_id.b.area, fcport->d_id.b.al_pa, |
| 1725 | le32_to_cpu(logio->io_parameter[0])); |
| 1726 | |
| 1727 | vha->hw->exch_starvation = 0; |
| 1728 | data[0] = MBS_COMMAND_COMPLETE; |
| 1729 | |
| 1730 | if (sp->type == SRB_PRLI_CMD) { |
| 1731 | lio->u.logio.iop[0] = |
| 1732 | le32_to_cpu(logio->io_parameter[0]); |
| 1733 | lio->u.logio.iop[1] = |
| 1734 | le32_to_cpu(logio->io_parameter[1]); |
| 1735 | goto logio_done; |
| 1736 | } |
| 1737 | |
| 1738 | if (sp->type != SRB_LOGIN_CMD) |
| 1739 | goto logio_done; |
| 1740 | |
| 1741 | iop[0] = le32_to_cpu(logio->io_parameter[0]); |
| 1742 | if (iop[0] & BIT_4) { |
| 1743 | fcport->port_type = FCT_TARGET; |
| 1744 | if (iop[0] & BIT_8) |
| 1745 | fcport->flags |= FCF_FCP2_DEVICE; |
| 1746 | } else if (iop[0] & BIT_5) |
| 1747 | fcport->port_type = FCT_INITIATOR; |
| 1748 | |
| 1749 | if (iop[0] & BIT_7) |
| 1750 | fcport->flags |= FCF_CONF_COMP_SUPPORTED; |
| 1751 | |
| 1752 | if (logio->io_parameter[7] || logio->io_parameter[8]) |
| 1753 | fcport->supported_classes |= FC_COS_CLASS2; |
| 1754 | if (logio->io_parameter[9] || logio->io_parameter[10]) |
| 1755 | fcport->supported_classes |= FC_COS_CLASS3; |
| 1756 | |
| 1757 | goto logio_done; |
| 1758 | } |
| 1759 | |
| 1760 | iop[0] = le32_to_cpu(logio->io_parameter[0]); |
| 1761 | iop[1] = le32_to_cpu(logio->io_parameter[1]); |
| 1762 | lio->u.logio.iop[0] = iop[0]; |
| 1763 | lio->u.logio.iop[1] = iop[1]; |
| 1764 | switch (iop[0]) { |
| 1765 | case LSC_SCODE_PORTID_USED: |
| 1766 | data[0] = MBS_PORT_ID_USED; |
| 1767 | data[1] = LSW(iop[1]); |
| 1768 | break; |
| 1769 | case LSC_SCODE_NPORT_USED: |
| 1770 | data[0] = MBS_LOOP_ID_USED; |
| 1771 | break; |
| 1772 | case LSC_SCODE_CMD_FAILED: |
| 1773 | if (iop[1] == 0x0606) { |
| 1774 | /* |
| 1775 | * PLOGI/PRLI Completed. We must have Recv PLOGI/PRLI, |
| 1776 | * Target side acked. |
| 1777 | */ |
| 1778 | data[0] = MBS_COMMAND_COMPLETE; |
| 1779 | goto logio_done; |
| 1780 | } |
| 1781 | data[0] = MBS_COMMAND_ERROR; |
| 1782 | break; |
| 1783 | case LSC_SCODE_NOXCB: |
| 1784 | vha->hw->exch_starvation++; |
| 1785 | if (vha->hw->exch_starvation > 5) { |
| 1786 | ql_log(ql_log_warn, vha, 0xd046, |
| 1787 | "Exchange starvation. Resetting RISC\n"); |
| 1788 | |
| 1789 | vha->hw->exch_starvation = 0; |
| 1790 | |
| 1791 | if (IS_P3P_TYPE(vha->hw)) |
| 1792 | set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags); |
| 1793 | else |
| 1794 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 1795 | qla2xxx_wake_dpc(vha); |
| 1796 | } |
| 1797 | /* fall through */ |
| 1798 | default: |
| 1799 | data[0] = MBS_COMMAND_ERROR; |
| 1800 | break; |
| 1801 | } |
| 1802 | |
| 1803 | ql_dbg(ql_dbg_async, fcport->vha, 0x5037, |
| 1804 | "Async-%s failed - %8phC hdl=%x portid=%02x%02x%02x comp=%x " |
| 1805 | "iop0=%x iop1=%x.\n", type, fcport->port_name, |
| 1806 | sp->handle, fcport->d_id.b.domain, |
| 1807 | fcport->d_id.b.area, fcport->d_id.b.al_pa, |
| 1808 | le16_to_cpu(logio->comp_status), |
| 1809 | le32_to_cpu(logio->io_parameter[0]), |
| 1810 | le32_to_cpu(logio->io_parameter[1])); |
| 1811 | |
| 1812 | logio_done: |
| 1813 | sp->done(sp, 0); |
| 1814 | } |
| 1815 | |
| 1816 | static void |
| 1817 | qla24xx_tm_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, void *tsk) |
| 1818 | { |
| 1819 | const char func[] = "TMF-IOCB"; |
| 1820 | const char *type; |
| 1821 | fc_port_t *fcport; |
| 1822 | srb_t *sp; |
| 1823 | struct srb_iocb *iocb; |
| 1824 | struct sts_entry_24xx *sts = (struct sts_entry_24xx *)tsk; |
| 1825 | |
| 1826 | sp = qla2x00_get_sp_from_handle(vha, func, req, tsk); |
| 1827 | if (!sp) |
| 1828 | return; |
| 1829 | |
| 1830 | iocb = &sp->u.iocb_cmd; |
| 1831 | type = sp->name; |
| 1832 | fcport = sp->fcport; |
| 1833 | iocb->u.tmf.data = QLA_SUCCESS; |
| 1834 | |
| 1835 | if (sts->entry_status) { |
| 1836 | ql_log(ql_log_warn, fcport->vha, 0x5038, |
| 1837 | "Async-%s error - hdl=%x entry-status(%x).\n", |
| 1838 | type, sp->handle, sts->entry_status); |
| 1839 | iocb->u.tmf.data = QLA_FUNCTION_FAILED; |
| 1840 | } else if (sts->comp_status != cpu_to_le16(CS_COMPLETE)) { |
| 1841 | ql_log(ql_log_warn, fcport->vha, 0x5039, |
| 1842 | "Async-%s error - hdl=%x completion status(%x).\n", |
| 1843 | type, sp->handle, sts->comp_status); |
| 1844 | iocb->u.tmf.data = QLA_FUNCTION_FAILED; |
| 1845 | } else if ((le16_to_cpu(sts->scsi_status) & |
| 1846 | SS_RESPONSE_INFO_LEN_VALID)) { |
| 1847 | if (le32_to_cpu(sts->rsp_data_len) < 4) { |
| 1848 | ql_log(ql_log_warn, fcport->vha, 0x503b, |
| 1849 | "Async-%s error - hdl=%x not enough response(%d).\n", |
| 1850 | type, sp->handle, sts->rsp_data_len); |
| 1851 | } else if (sts->data[3]) { |
| 1852 | ql_log(ql_log_warn, fcport->vha, 0x503c, |
| 1853 | "Async-%s error - hdl=%x response(%x).\n", |
| 1854 | type, sp->handle, sts->data[3]); |
| 1855 | iocb->u.tmf.data = QLA_FUNCTION_FAILED; |
| 1856 | } |
| 1857 | } |
| 1858 | |
| 1859 | if (iocb->u.tmf.data != QLA_SUCCESS) |
| 1860 | ql_dump_buffer(ql_dbg_async + ql_dbg_buffer, sp->vha, 0x5055, |
| 1861 | sts, sizeof(*sts)); |
| 1862 | |
| 1863 | sp->done(sp, 0); |
| 1864 | } |
| 1865 | |
| 1866 | static void qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, |
| 1867 | void *tsk, srb_t *sp) |
| 1868 | { |
| 1869 | fc_port_t *fcport; |
| 1870 | struct srb_iocb *iocb; |
| 1871 | struct sts_entry_24xx *sts = (struct sts_entry_24xx *)tsk; |
| 1872 | uint16_t state_flags; |
| 1873 | struct nvmefc_fcp_req *fd; |
| 1874 | uint16_t ret = QLA_SUCCESS; |
| 1875 | uint16_t comp_status = le16_to_cpu(sts->comp_status); |
| 1876 | |
| 1877 | iocb = &sp->u.iocb_cmd; |
| 1878 | fcport = sp->fcport; |
| 1879 | iocb->u.nvme.comp_status = comp_status; |
| 1880 | state_flags = le16_to_cpu(sts->state_flags); |
| 1881 | fd = iocb->u.nvme.desc; |
| 1882 | |
| 1883 | if (unlikely(iocb->u.nvme.aen_op)) |
| 1884 | atomic_dec(&sp->vha->hw->nvme_active_aen_cnt); |
| 1885 | |
| 1886 | /* |
| 1887 | * State flags: Bit 6 and 0. |
| 1888 | * If 0 is set, we don't care about 6. |
| 1889 | * both cases resp was dma'd to host buffer |
| 1890 | * if both are 0, that is good path case. |
| 1891 | * if six is set and 0 is clear, we need to |
| 1892 | * copy resp data from status iocb to resp buffer. |
| 1893 | */ |
| 1894 | if (!(state_flags & (SF_FCP_RSP_DMA | SF_NVME_ERSP))) { |
| 1895 | iocb->u.nvme.rsp_pyld_len = 0; |
| 1896 | } else if ((state_flags & SF_FCP_RSP_DMA)) { |
| 1897 | iocb->u.nvme.rsp_pyld_len = le16_to_cpu(sts->nvme_rsp_pyld_len); |
| 1898 | } else if (state_flags & SF_NVME_ERSP) { |
| 1899 | uint32_t *inbuf, *outbuf; |
| 1900 | uint16_t iter; |
| 1901 | |
| 1902 | inbuf = (uint32_t *)&sts->nvme_ersp_data; |
| 1903 | outbuf = (uint32_t *)fd->rspaddr; |
| 1904 | iocb->u.nvme.rsp_pyld_len = le16_to_cpu(sts->nvme_rsp_pyld_len); |
| 1905 | iter = iocb->u.nvme.rsp_pyld_len >> 2; |
| 1906 | for (; iter; iter--) |
| 1907 | *outbuf++ = swab32(*inbuf++); |
| 1908 | } else { /* unhandled case */ |
| 1909 | ql_log(ql_log_warn, fcport->vha, 0x503a, |
| 1910 | "NVME-%s error. Unhandled state_flags of %x\n", |
| 1911 | sp->name, state_flags); |
| 1912 | } |
| 1913 | |
| 1914 | fd->transferred_length = fd->payload_length - |
| 1915 | le32_to_cpu(sts->residual_len); |
| 1916 | |
| 1917 | if (unlikely(comp_status != CS_COMPLETE)) |
| 1918 | ql_log(ql_log_warn, fcport->vha, 0x5060, |
| 1919 | "NVME-%s ERR Handling - hdl=%x status(%x) tr_len:%x resid=%x ox_id=%x\n", |
| 1920 | sp->name, sp->handle, comp_status, |
| 1921 | fd->transferred_length, le32_to_cpu(sts->residual_len), |
| 1922 | sts->ox_id); |
| 1923 | |
| 1924 | /* |
| 1925 | * If transport error then Failure (HBA rejects request) |
| 1926 | * otherwise transport will handle. |
| 1927 | */ |
| 1928 | switch (comp_status) { |
| 1929 | case CS_COMPLETE: |
| 1930 | break; |
| 1931 | |
| 1932 | case CS_RESET: |
| 1933 | case CS_PORT_UNAVAILABLE: |
| 1934 | case CS_PORT_LOGGED_OUT: |
| 1935 | fcport->nvme_flag |= NVME_FLAG_RESETTING; |
| 1936 | /* fall through */ |
| 1937 | case CS_ABORTED: |
| 1938 | case CS_PORT_BUSY: |
| 1939 | fd->transferred_length = 0; |
| 1940 | iocb->u.nvme.rsp_pyld_len = 0; |
| 1941 | ret = QLA_ABORTED; |
| 1942 | break; |
| 1943 | case CS_DATA_UNDERRUN: |
| 1944 | break; |
| 1945 | default: |
| 1946 | ret = QLA_FUNCTION_FAILED; |
| 1947 | break; |
| 1948 | } |
| 1949 | sp->done(sp, ret); |
| 1950 | } |
| 1951 | |
| 1952 | static void qla_ctrlvp_completed(scsi_qla_host_t *vha, struct req_que *req, |
| 1953 | struct vp_ctrl_entry_24xx *vce) |
| 1954 | { |
| 1955 | const char func[] = "CTRLVP-IOCB"; |
| 1956 | srb_t *sp; |
| 1957 | int rval = QLA_SUCCESS; |
| 1958 | |
| 1959 | sp = qla2x00_get_sp_from_handle(vha, func, req, vce); |
| 1960 | if (!sp) |
| 1961 | return; |
| 1962 | |
| 1963 | if (vce->entry_status != 0) { |
| 1964 | ql_dbg(ql_dbg_vport, vha, 0x10c4, |
| 1965 | "%s: Failed to complete IOCB -- error status (%x)\n", |
| 1966 | sp->name, vce->entry_status); |
| 1967 | rval = QLA_FUNCTION_FAILED; |
| 1968 | } else if (vce->comp_status != cpu_to_le16(CS_COMPLETE)) { |
| 1969 | ql_dbg(ql_dbg_vport, vha, 0x10c5, |
| 1970 | "%s: Failed to complete IOCB -- completion status (%x) vpidx %x\n", |
| 1971 | sp->name, le16_to_cpu(vce->comp_status), |
| 1972 | le16_to_cpu(vce->vp_idx_failed)); |
| 1973 | rval = QLA_FUNCTION_FAILED; |
| 1974 | } else { |
| 1975 | ql_dbg(ql_dbg_vport, vha, 0x10c6, |
| 1976 | "Done %s.\n", __func__); |
| 1977 | } |
| 1978 | |
| 1979 | sp->rc = rval; |
| 1980 | sp->done(sp, rval); |
| 1981 | } |
| 1982 | |
| 1983 | /* Process a single response queue entry. */ |
| 1984 | static void qla2x00_process_response_entry(struct scsi_qla_host *vha, |
| 1985 | struct rsp_que *rsp, |
| 1986 | sts_entry_t *pkt) |
| 1987 | { |
| 1988 | sts21_entry_t *sts21_entry; |
| 1989 | sts22_entry_t *sts22_entry; |
| 1990 | uint16_t handle_cnt; |
| 1991 | uint16_t cnt; |
| 1992 | |
| 1993 | switch (pkt->entry_type) { |
| 1994 | case STATUS_TYPE: |
| 1995 | qla2x00_status_entry(vha, rsp, pkt); |
| 1996 | break; |
| 1997 | case STATUS_TYPE_21: |
| 1998 | sts21_entry = (sts21_entry_t *)pkt; |
| 1999 | handle_cnt = sts21_entry->handle_count; |
| 2000 | for (cnt = 0; cnt < handle_cnt; cnt++) |
| 2001 | qla2x00_process_completed_request(vha, rsp->req, |
| 2002 | sts21_entry->handle[cnt]); |
| 2003 | break; |
| 2004 | case STATUS_TYPE_22: |
| 2005 | sts22_entry = (sts22_entry_t *)pkt; |
| 2006 | handle_cnt = sts22_entry->handle_count; |
| 2007 | for (cnt = 0; cnt < handle_cnt; cnt++) |
| 2008 | qla2x00_process_completed_request(vha, rsp->req, |
| 2009 | sts22_entry->handle[cnt]); |
| 2010 | break; |
| 2011 | case STATUS_CONT_TYPE: |
| 2012 | qla2x00_status_cont_entry(rsp, (sts_cont_entry_t *)pkt); |
| 2013 | break; |
| 2014 | case MBX_IOCB_TYPE: |
| 2015 | qla2x00_mbx_iocb_entry(vha, rsp->req, (struct mbx_entry *)pkt); |
| 2016 | break; |
| 2017 | case CT_IOCB_TYPE: |
| 2018 | qla2x00_ct_entry(vha, rsp->req, pkt, CT_IOCB_TYPE); |
| 2019 | break; |
| 2020 | default: |
| 2021 | /* Type Not Supported. */ |
| 2022 | ql_log(ql_log_warn, vha, 0x504a, |
| 2023 | "Received unknown response pkt type %x entry status=%x.\n", |
| 2024 | pkt->entry_type, pkt->entry_status); |
| 2025 | break; |
| 2026 | } |
| 2027 | } |
| 2028 | |
| 2029 | /** |
| 2030 | * qla2x00_process_response_queue() - Process response queue entries. |
| 2031 | * @rsp: response queue |
| 2032 | */ |
| 2033 | void |
| 2034 | qla2x00_process_response_queue(struct rsp_que *rsp) |
| 2035 | { |
| 2036 | struct scsi_qla_host *vha; |
| 2037 | struct qla_hw_data *ha = rsp->hw; |
| 2038 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 2039 | sts_entry_t *pkt; |
| 2040 | |
| 2041 | vha = pci_get_drvdata(ha->pdev); |
| 2042 | |
| 2043 | if (!vha->flags.online) |
| 2044 | return; |
| 2045 | |
| 2046 | while (rsp->ring_ptr->signature != RESPONSE_PROCESSED) { |
| 2047 | pkt = (sts_entry_t *)rsp->ring_ptr; |
| 2048 | |
| 2049 | rsp->ring_index++; |
| 2050 | if (rsp->ring_index == rsp->length) { |
| 2051 | rsp->ring_index = 0; |
| 2052 | rsp->ring_ptr = rsp->ring; |
| 2053 | } else { |
| 2054 | rsp->ring_ptr++; |
| 2055 | } |
| 2056 | |
| 2057 | if (pkt->entry_status != 0) { |
| 2058 | qla2x00_error_entry(vha, rsp, pkt); |
| 2059 | ((response_t *)pkt)->signature = RESPONSE_PROCESSED; |
| 2060 | wmb(); |
| 2061 | continue; |
| 2062 | } |
| 2063 | |
| 2064 | qla2x00_process_response_entry(vha, rsp, pkt); |
| 2065 | ((response_t *)pkt)->signature = RESPONSE_PROCESSED; |
| 2066 | wmb(); |
| 2067 | } |
| 2068 | |
| 2069 | /* Adjust ring index */ |
| 2070 | WRT_REG_WORD(ISP_RSP_Q_OUT(ha, reg), rsp->ring_index); |
| 2071 | } |
| 2072 | |
| 2073 | static inline void |
| 2074 | qla2x00_handle_sense(srb_t *sp, uint8_t *sense_data, uint32_t par_sense_len, |
| 2075 | uint32_t sense_len, struct rsp_que *rsp, int res) |
| 2076 | { |
| 2077 | struct scsi_qla_host *vha = sp->vha; |
| 2078 | struct scsi_cmnd *cp = GET_CMD_SP(sp); |
| 2079 | uint32_t track_sense_len; |
| 2080 | |
| 2081 | if (sense_len >= SCSI_SENSE_BUFFERSIZE) |
| 2082 | sense_len = SCSI_SENSE_BUFFERSIZE; |
| 2083 | |
| 2084 | SET_CMD_SENSE_LEN(sp, sense_len); |
| 2085 | SET_CMD_SENSE_PTR(sp, cp->sense_buffer); |
| 2086 | track_sense_len = sense_len; |
| 2087 | |
| 2088 | if (sense_len > par_sense_len) |
| 2089 | sense_len = par_sense_len; |
| 2090 | |
| 2091 | memcpy(cp->sense_buffer, sense_data, sense_len); |
| 2092 | |
| 2093 | SET_CMD_SENSE_PTR(sp, cp->sense_buffer + sense_len); |
| 2094 | track_sense_len -= sense_len; |
| 2095 | SET_CMD_SENSE_LEN(sp, track_sense_len); |
| 2096 | |
| 2097 | if (track_sense_len != 0) { |
| 2098 | rsp->status_srb = sp; |
| 2099 | cp->result = res; |
| 2100 | } |
| 2101 | |
| 2102 | if (sense_len) { |
| 2103 | ql_dbg(ql_dbg_io + ql_dbg_buffer, vha, 0x301c, |
| 2104 | "Check condition Sense data, nexus%ld:%d:%llu cmd=%p.\n", |
| 2105 | sp->vha->host_no, cp->device->id, cp->device->lun, |
| 2106 | cp); |
| 2107 | ql_dump_buffer(ql_dbg_io + ql_dbg_buffer, vha, 0x302b, |
| 2108 | cp->sense_buffer, sense_len); |
| 2109 | } |
| 2110 | } |
| 2111 | |
| 2112 | struct scsi_dif_tuple { |
| 2113 | __be16 guard; /* Checksum */ |
| 2114 | __be16 app_tag; /* APPL identifier */ |
| 2115 | __be32 ref_tag; /* Target LBA or indirect LBA */ |
| 2116 | }; |
| 2117 | |
| 2118 | /* |
| 2119 | * Checks the guard or meta-data for the type of error |
| 2120 | * detected by the HBA. In case of errors, we set the |
| 2121 | * ASC/ASCQ fields in the sense buffer with ILLEGAL_REQUEST |
| 2122 | * to indicate to the kernel that the HBA detected error. |
| 2123 | */ |
| 2124 | static inline int |
| 2125 | qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24) |
| 2126 | { |
| 2127 | struct scsi_qla_host *vha = sp->vha; |
| 2128 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 2129 | uint8_t *ap = &sts24->data[12]; |
| 2130 | uint8_t *ep = &sts24->data[20]; |
| 2131 | uint32_t e_ref_tag, a_ref_tag; |
| 2132 | uint16_t e_app_tag, a_app_tag; |
| 2133 | uint16_t e_guard, a_guard; |
| 2134 | |
| 2135 | /* |
| 2136 | * swab32 of the "data" field in the beginning of qla2x00_status_entry() |
| 2137 | * would make guard field appear at offset 2 |
| 2138 | */ |
| 2139 | a_guard = le16_to_cpu(*(uint16_t *)(ap + 2)); |
| 2140 | a_app_tag = le16_to_cpu(*(uint16_t *)(ap + 0)); |
| 2141 | a_ref_tag = le32_to_cpu(*(uint32_t *)(ap + 4)); |
| 2142 | e_guard = le16_to_cpu(*(uint16_t *)(ep + 2)); |
| 2143 | e_app_tag = le16_to_cpu(*(uint16_t *)(ep + 0)); |
| 2144 | e_ref_tag = le32_to_cpu(*(uint32_t *)(ep + 4)); |
| 2145 | |
| 2146 | ql_dbg(ql_dbg_io, vha, 0x3023, |
| 2147 | "iocb(s) %p Returned STATUS.\n", sts24); |
| 2148 | |
| 2149 | ql_dbg(ql_dbg_io, vha, 0x3024, |
| 2150 | "DIF ERROR in cmd 0x%x lba 0x%llx act ref" |
| 2151 | " tag=0x%x, exp ref_tag=0x%x, act app tag=0x%x, exp app" |
| 2152 | " tag=0x%x, act guard=0x%x, exp guard=0x%x.\n", |
| 2153 | cmd->cmnd[0], (u64)scsi_get_lba(cmd), a_ref_tag, e_ref_tag, |
| 2154 | a_app_tag, e_app_tag, a_guard, e_guard); |
| 2155 | |
| 2156 | /* |
| 2157 | * Ignore sector if: |
| 2158 | * For type 3: ref & app tag is all 'f's |
| 2159 | * For type 0,1,2: app tag is all 'f's |
| 2160 | */ |
| 2161 | if ((a_app_tag == T10_PI_APP_ESCAPE) && |
| 2162 | ((scsi_get_prot_type(cmd) != SCSI_PROT_DIF_TYPE3) || |
| 2163 | (a_ref_tag == T10_PI_REF_ESCAPE))) { |
| 2164 | uint32_t blocks_done, resid; |
| 2165 | sector_t lba_s = scsi_get_lba(cmd); |
| 2166 | |
| 2167 | /* 2TB boundary case covered automatically with this */ |
| 2168 | blocks_done = e_ref_tag - (uint32_t)lba_s + 1; |
| 2169 | |
| 2170 | resid = scsi_bufflen(cmd) - (blocks_done * |
| 2171 | cmd->device->sector_size); |
| 2172 | |
| 2173 | scsi_set_resid(cmd, resid); |
| 2174 | cmd->result = DID_OK << 16; |
| 2175 | |
| 2176 | /* Update protection tag */ |
| 2177 | if (scsi_prot_sg_count(cmd)) { |
| 2178 | uint32_t i, j = 0, k = 0, num_ent; |
| 2179 | struct scatterlist *sg; |
| 2180 | struct t10_pi_tuple *spt; |
| 2181 | |
| 2182 | /* Patch the corresponding protection tags */ |
| 2183 | scsi_for_each_prot_sg(cmd, sg, |
| 2184 | scsi_prot_sg_count(cmd), i) { |
| 2185 | num_ent = sg_dma_len(sg) / 8; |
| 2186 | if (k + num_ent < blocks_done) { |
| 2187 | k += num_ent; |
| 2188 | continue; |
| 2189 | } |
| 2190 | j = blocks_done - k - 1; |
| 2191 | k = blocks_done; |
| 2192 | break; |
| 2193 | } |
| 2194 | |
| 2195 | if (k != blocks_done) { |
| 2196 | ql_log(ql_log_warn, vha, 0x302f, |
| 2197 | "unexpected tag values tag:lba=%x:%llx)\n", |
| 2198 | e_ref_tag, (unsigned long long)lba_s); |
| 2199 | return 1; |
| 2200 | } |
| 2201 | |
| 2202 | spt = page_address(sg_page(sg)) + sg->offset; |
| 2203 | spt += j; |
| 2204 | |
| 2205 | spt->app_tag = T10_PI_APP_ESCAPE; |
| 2206 | if (scsi_get_prot_type(cmd) == SCSI_PROT_DIF_TYPE3) |
| 2207 | spt->ref_tag = T10_PI_REF_ESCAPE; |
| 2208 | } |
| 2209 | |
| 2210 | return 0; |
| 2211 | } |
| 2212 | |
| 2213 | /* check guard */ |
| 2214 | if (e_guard != a_guard) { |
| 2215 | scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, |
| 2216 | 0x10, 0x1); |
| 2217 | set_driver_byte(cmd, DRIVER_SENSE); |
| 2218 | set_host_byte(cmd, DID_ABORT); |
| 2219 | cmd->result |= SAM_STAT_CHECK_CONDITION; |
| 2220 | return 1; |
| 2221 | } |
| 2222 | |
| 2223 | /* check ref tag */ |
| 2224 | if (e_ref_tag != a_ref_tag) { |
| 2225 | scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, |
| 2226 | 0x10, 0x3); |
| 2227 | set_driver_byte(cmd, DRIVER_SENSE); |
| 2228 | set_host_byte(cmd, DID_ABORT); |
| 2229 | cmd->result |= SAM_STAT_CHECK_CONDITION; |
| 2230 | return 1; |
| 2231 | } |
| 2232 | |
| 2233 | /* check appl tag */ |
| 2234 | if (e_app_tag != a_app_tag) { |
| 2235 | scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, |
| 2236 | 0x10, 0x2); |
| 2237 | set_driver_byte(cmd, DRIVER_SENSE); |
| 2238 | set_host_byte(cmd, DID_ABORT); |
| 2239 | cmd->result |= SAM_STAT_CHECK_CONDITION; |
| 2240 | return 1; |
| 2241 | } |
| 2242 | |
| 2243 | return 1; |
| 2244 | } |
| 2245 | |
| 2246 | static void |
| 2247 | qla25xx_process_bidir_status_iocb(scsi_qla_host_t *vha, void *pkt, |
| 2248 | struct req_que *req, uint32_t index) |
| 2249 | { |
| 2250 | struct qla_hw_data *ha = vha->hw; |
| 2251 | srb_t *sp; |
| 2252 | uint16_t comp_status; |
| 2253 | uint16_t scsi_status; |
| 2254 | uint16_t thread_id; |
| 2255 | uint32_t rval = EXT_STATUS_OK; |
| 2256 | struct bsg_job *bsg_job = NULL; |
| 2257 | struct fc_bsg_request *bsg_request; |
| 2258 | struct fc_bsg_reply *bsg_reply; |
| 2259 | sts_entry_t *sts = pkt; |
| 2260 | struct sts_entry_24xx *sts24 = pkt; |
| 2261 | |
| 2262 | /* Validate handle. */ |
| 2263 | if (index >= req->num_outstanding_cmds) { |
| 2264 | ql_log(ql_log_warn, vha, 0x70af, |
| 2265 | "Invalid SCSI completion handle 0x%x.\n", index); |
| 2266 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 2267 | return; |
| 2268 | } |
| 2269 | |
| 2270 | sp = req->outstanding_cmds[index]; |
| 2271 | if (!sp) { |
| 2272 | ql_log(ql_log_warn, vha, 0x70b0, |
| 2273 | "Req:%d: Invalid ISP SCSI completion handle(0x%x)\n", |
| 2274 | req->id, index); |
| 2275 | |
| 2276 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 2277 | return; |
| 2278 | } |
| 2279 | |
| 2280 | /* Free outstanding command slot. */ |
| 2281 | req->outstanding_cmds[index] = NULL; |
| 2282 | bsg_job = sp->u.bsg_job; |
| 2283 | bsg_request = bsg_job->request; |
| 2284 | bsg_reply = bsg_job->reply; |
| 2285 | |
| 2286 | if (IS_FWI2_CAPABLE(ha)) { |
| 2287 | comp_status = le16_to_cpu(sts24->comp_status); |
| 2288 | scsi_status = le16_to_cpu(sts24->scsi_status) & SS_MASK; |
| 2289 | } else { |
| 2290 | comp_status = le16_to_cpu(sts->comp_status); |
| 2291 | scsi_status = le16_to_cpu(sts->scsi_status) & SS_MASK; |
| 2292 | } |
| 2293 | |
| 2294 | thread_id = bsg_request->rqst_data.h_vendor.vendor_cmd[1]; |
| 2295 | switch (comp_status) { |
| 2296 | case CS_COMPLETE: |
| 2297 | if (scsi_status == 0) { |
| 2298 | bsg_reply->reply_payload_rcv_len = |
| 2299 | bsg_job->reply_payload.payload_len; |
| 2300 | vha->qla_stats.input_bytes += |
| 2301 | bsg_reply->reply_payload_rcv_len; |
| 2302 | vha->qla_stats.input_requests++; |
| 2303 | rval = EXT_STATUS_OK; |
| 2304 | } |
| 2305 | goto done; |
| 2306 | |
| 2307 | case CS_DATA_OVERRUN: |
| 2308 | ql_dbg(ql_dbg_user, vha, 0x70b1, |
| 2309 | "Command completed with data overrun thread_id=%d\n", |
| 2310 | thread_id); |
| 2311 | rval = EXT_STATUS_DATA_OVERRUN; |
| 2312 | break; |
| 2313 | |
| 2314 | case CS_DATA_UNDERRUN: |
| 2315 | ql_dbg(ql_dbg_user, vha, 0x70b2, |
| 2316 | "Command completed with data underrun thread_id=%d\n", |
| 2317 | thread_id); |
| 2318 | rval = EXT_STATUS_DATA_UNDERRUN; |
| 2319 | break; |
| 2320 | case CS_BIDIR_RD_OVERRUN: |
| 2321 | ql_dbg(ql_dbg_user, vha, 0x70b3, |
| 2322 | "Command completed with read data overrun thread_id=%d\n", |
| 2323 | thread_id); |
| 2324 | rval = EXT_STATUS_DATA_OVERRUN; |
| 2325 | break; |
| 2326 | |
| 2327 | case CS_BIDIR_RD_WR_OVERRUN: |
| 2328 | ql_dbg(ql_dbg_user, vha, 0x70b4, |
| 2329 | "Command completed with read and write data overrun " |
| 2330 | "thread_id=%d\n", thread_id); |
| 2331 | rval = EXT_STATUS_DATA_OVERRUN; |
| 2332 | break; |
| 2333 | |
| 2334 | case CS_BIDIR_RD_OVERRUN_WR_UNDERRUN: |
| 2335 | ql_dbg(ql_dbg_user, vha, 0x70b5, |
| 2336 | "Command completed with read data over and write data " |
| 2337 | "underrun thread_id=%d\n", thread_id); |
| 2338 | rval = EXT_STATUS_DATA_OVERRUN; |
| 2339 | break; |
| 2340 | |
| 2341 | case CS_BIDIR_RD_UNDERRUN: |
| 2342 | ql_dbg(ql_dbg_user, vha, 0x70b6, |
| 2343 | "Command completed with read data underrun " |
| 2344 | "thread_id=%d\n", thread_id); |
| 2345 | rval = EXT_STATUS_DATA_UNDERRUN; |
| 2346 | break; |
| 2347 | |
| 2348 | case CS_BIDIR_RD_UNDERRUN_WR_OVERRUN: |
| 2349 | ql_dbg(ql_dbg_user, vha, 0x70b7, |
| 2350 | "Command completed with read data under and write data " |
| 2351 | "overrun thread_id=%d\n", thread_id); |
| 2352 | rval = EXT_STATUS_DATA_UNDERRUN; |
| 2353 | break; |
| 2354 | |
| 2355 | case CS_BIDIR_RD_WR_UNDERRUN: |
| 2356 | ql_dbg(ql_dbg_user, vha, 0x70b8, |
| 2357 | "Command completed with read and write data underrun " |
| 2358 | "thread_id=%d\n", thread_id); |
| 2359 | rval = EXT_STATUS_DATA_UNDERRUN; |
| 2360 | break; |
| 2361 | |
| 2362 | case CS_BIDIR_DMA: |
| 2363 | ql_dbg(ql_dbg_user, vha, 0x70b9, |
| 2364 | "Command completed with data DMA error thread_id=%d\n", |
| 2365 | thread_id); |
| 2366 | rval = EXT_STATUS_DMA_ERR; |
| 2367 | break; |
| 2368 | |
| 2369 | case CS_TIMEOUT: |
| 2370 | ql_dbg(ql_dbg_user, vha, 0x70ba, |
| 2371 | "Command completed with timeout thread_id=%d\n", |
| 2372 | thread_id); |
| 2373 | rval = EXT_STATUS_TIMEOUT; |
| 2374 | break; |
| 2375 | default: |
| 2376 | ql_dbg(ql_dbg_user, vha, 0x70bb, |
| 2377 | "Command completed with completion status=0x%x " |
| 2378 | "thread_id=%d\n", comp_status, thread_id); |
| 2379 | rval = EXT_STATUS_ERR; |
| 2380 | break; |
| 2381 | } |
| 2382 | bsg_reply->reply_payload_rcv_len = 0; |
| 2383 | |
| 2384 | done: |
| 2385 | /* Return the vendor specific reply to API */ |
| 2386 | bsg_reply->reply_data.vendor_reply.vendor_rsp[0] = rval; |
| 2387 | bsg_job->reply_len = sizeof(struct fc_bsg_reply); |
| 2388 | /* Always return DID_OK, bsg will send the vendor specific response |
| 2389 | * in this case only */ |
| 2390 | sp->done(sp, DID_OK << 16); |
| 2391 | |
| 2392 | } |
| 2393 | |
| 2394 | /** |
| 2395 | * qla2x00_status_entry() - Process a Status IOCB entry. |
| 2396 | * @vha: SCSI driver HA context |
| 2397 | * @rsp: response queue |
| 2398 | * @pkt: Entry pointer |
| 2399 | */ |
| 2400 | static void |
| 2401 | qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt) |
| 2402 | { |
| 2403 | srb_t *sp; |
| 2404 | fc_port_t *fcport; |
| 2405 | struct scsi_cmnd *cp; |
| 2406 | sts_entry_t *sts = pkt; |
| 2407 | struct sts_entry_24xx *sts24 = pkt; |
| 2408 | uint16_t comp_status; |
| 2409 | uint16_t scsi_status; |
| 2410 | uint16_t ox_id; |
| 2411 | uint8_t lscsi_status; |
| 2412 | int32_t resid; |
| 2413 | uint32_t sense_len, par_sense_len, rsp_info_len, resid_len, |
| 2414 | fw_resid_len; |
| 2415 | uint8_t *rsp_info, *sense_data; |
| 2416 | struct qla_hw_data *ha = vha->hw; |
| 2417 | uint32_t handle; |
| 2418 | uint16_t que; |
| 2419 | struct req_que *req; |
| 2420 | int logit = 1; |
| 2421 | int res = 0; |
| 2422 | uint16_t state_flags = 0; |
| 2423 | uint16_t retry_delay = 0; |
| 2424 | |
| 2425 | if (IS_FWI2_CAPABLE(ha)) { |
| 2426 | comp_status = le16_to_cpu(sts24->comp_status); |
| 2427 | scsi_status = le16_to_cpu(sts24->scsi_status) & SS_MASK; |
| 2428 | state_flags = le16_to_cpu(sts24->state_flags); |
| 2429 | } else { |
| 2430 | comp_status = le16_to_cpu(sts->comp_status); |
| 2431 | scsi_status = le16_to_cpu(sts->scsi_status) & SS_MASK; |
| 2432 | } |
| 2433 | handle = (uint32_t) LSW(sts->handle); |
| 2434 | que = MSW(sts->handle); |
| 2435 | req = ha->req_q_map[que]; |
| 2436 | |
| 2437 | /* Check for invalid queue pointer */ |
| 2438 | if (req == NULL || |
| 2439 | que >= find_first_zero_bit(ha->req_qid_map, ha->max_req_queues)) { |
| 2440 | ql_dbg(ql_dbg_io, vha, 0x3059, |
| 2441 | "Invalid status handle (0x%x): Bad req pointer. req=%p, " |
| 2442 | "que=%u.\n", sts->handle, req, que); |
| 2443 | return; |
| 2444 | } |
| 2445 | |
| 2446 | /* Validate handle. */ |
| 2447 | if (handle < req->num_outstanding_cmds) { |
| 2448 | sp = req->outstanding_cmds[handle]; |
| 2449 | if (!sp) { |
| 2450 | ql_dbg(ql_dbg_io, vha, 0x3075, |
| 2451 | "%s(%ld): Already returned command for status handle (0x%x).\n", |
| 2452 | __func__, vha->host_no, sts->handle); |
| 2453 | return; |
| 2454 | } |
| 2455 | } else { |
| 2456 | ql_dbg(ql_dbg_io, vha, 0x3017, |
| 2457 | "Invalid status handle, out of range (0x%x).\n", |
| 2458 | sts->handle); |
| 2459 | |
| 2460 | if (!test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) { |
| 2461 | if (IS_P3P_TYPE(ha)) |
| 2462 | set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags); |
| 2463 | else |
| 2464 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 2465 | qla2xxx_wake_dpc(vha); |
| 2466 | } |
| 2467 | return; |
| 2468 | } |
| 2469 | |
| 2470 | if (sp->cmd_type != TYPE_SRB) { |
| 2471 | req->outstanding_cmds[handle] = NULL; |
| 2472 | ql_dbg(ql_dbg_io, vha, 0x3015, |
| 2473 | "Unknown sp->cmd_type %x %p).\n", |
| 2474 | sp->cmd_type, sp); |
| 2475 | return; |
| 2476 | } |
| 2477 | |
| 2478 | /* NVME completion. */ |
| 2479 | if (sp->type == SRB_NVME_CMD) { |
| 2480 | req->outstanding_cmds[handle] = NULL; |
| 2481 | qla24xx_nvme_iocb_entry(vha, req, pkt, sp); |
| 2482 | return; |
| 2483 | } |
| 2484 | |
| 2485 | if (unlikely((state_flags & BIT_1) && (sp->type == SRB_BIDI_CMD))) { |
| 2486 | qla25xx_process_bidir_status_iocb(vha, pkt, req, handle); |
| 2487 | return; |
| 2488 | } |
| 2489 | |
| 2490 | /* Task Management completion. */ |
| 2491 | if (sp->type == SRB_TM_CMD) { |
| 2492 | qla24xx_tm_iocb_entry(vha, req, pkt); |
| 2493 | return; |
| 2494 | } |
| 2495 | |
| 2496 | /* Fast path completion. */ |
| 2497 | if (comp_status == CS_COMPLETE && scsi_status == 0) { |
| 2498 | qla2x00_process_completed_request(vha, req, handle); |
| 2499 | |
| 2500 | return; |
| 2501 | } |
| 2502 | |
| 2503 | req->outstanding_cmds[handle] = NULL; |
| 2504 | cp = GET_CMD_SP(sp); |
| 2505 | if (cp == NULL) { |
| 2506 | ql_dbg(ql_dbg_io, vha, 0x3018, |
| 2507 | "Command already returned (0x%x/%p).\n", |
| 2508 | sts->handle, sp); |
| 2509 | |
| 2510 | return; |
| 2511 | } |
| 2512 | |
| 2513 | lscsi_status = scsi_status & STATUS_MASK; |
| 2514 | |
| 2515 | fcport = sp->fcport; |
| 2516 | |
| 2517 | ox_id = 0; |
| 2518 | sense_len = par_sense_len = rsp_info_len = resid_len = |
| 2519 | fw_resid_len = 0; |
| 2520 | if (IS_FWI2_CAPABLE(ha)) { |
| 2521 | if (scsi_status & SS_SENSE_LEN_VALID) |
| 2522 | sense_len = le32_to_cpu(sts24->sense_len); |
| 2523 | if (scsi_status & SS_RESPONSE_INFO_LEN_VALID) |
| 2524 | rsp_info_len = le32_to_cpu(sts24->rsp_data_len); |
| 2525 | if (scsi_status & (SS_RESIDUAL_UNDER | SS_RESIDUAL_OVER)) |
| 2526 | resid_len = le32_to_cpu(sts24->rsp_residual_count); |
| 2527 | if (comp_status == CS_DATA_UNDERRUN) |
| 2528 | fw_resid_len = le32_to_cpu(sts24->residual_len); |
| 2529 | rsp_info = sts24->data; |
| 2530 | sense_data = sts24->data; |
| 2531 | host_to_fcp_swap(sts24->data, sizeof(sts24->data)); |
| 2532 | ox_id = le16_to_cpu(sts24->ox_id); |
| 2533 | par_sense_len = sizeof(sts24->data); |
| 2534 | /* Valid values of the retry delay timer are 0x1-0xffef */ |
| 2535 | if (sts24->retry_delay > 0 && sts24->retry_delay < 0xfff1) { |
| 2536 | retry_delay = sts24->retry_delay & 0x3fff; |
| 2537 | ql_dbg(ql_dbg_io, sp->vha, 0x3033, |
| 2538 | "%s: scope=%#x retry_delay=%#x\n", __func__, |
| 2539 | sts24->retry_delay >> 14, retry_delay); |
| 2540 | } |
| 2541 | } else { |
| 2542 | if (scsi_status & SS_SENSE_LEN_VALID) |
| 2543 | sense_len = le16_to_cpu(sts->req_sense_length); |
| 2544 | if (scsi_status & SS_RESPONSE_INFO_LEN_VALID) |
| 2545 | rsp_info_len = le16_to_cpu(sts->rsp_info_len); |
| 2546 | resid_len = le32_to_cpu(sts->residual_length); |
| 2547 | rsp_info = sts->rsp_info; |
| 2548 | sense_data = sts->req_sense_data; |
| 2549 | par_sense_len = sizeof(sts->req_sense_data); |
| 2550 | } |
| 2551 | |
| 2552 | /* Check for any FCP transport errors. */ |
| 2553 | if (scsi_status & SS_RESPONSE_INFO_LEN_VALID) { |
| 2554 | /* Sense data lies beyond any FCP RESPONSE data. */ |
| 2555 | if (IS_FWI2_CAPABLE(ha)) { |
| 2556 | sense_data += rsp_info_len; |
| 2557 | par_sense_len -= rsp_info_len; |
| 2558 | } |
| 2559 | if (rsp_info_len > 3 && rsp_info[3]) { |
| 2560 | ql_dbg(ql_dbg_io, fcport->vha, 0x3019, |
| 2561 | "FCP I/O protocol failure (0x%x/0x%x).\n", |
| 2562 | rsp_info_len, rsp_info[3]); |
| 2563 | |
| 2564 | res = DID_BUS_BUSY << 16; |
| 2565 | goto out; |
| 2566 | } |
| 2567 | } |
| 2568 | |
| 2569 | /* Check for overrun. */ |
| 2570 | if (IS_FWI2_CAPABLE(ha) && comp_status == CS_COMPLETE && |
| 2571 | scsi_status & SS_RESIDUAL_OVER) |
| 2572 | comp_status = CS_DATA_OVERRUN; |
| 2573 | |
| 2574 | /* |
| 2575 | * Check retry_delay_timer value if we receive a busy or |
| 2576 | * queue full. |
| 2577 | */ |
| 2578 | if (lscsi_status == SAM_STAT_TASK_SET_FULL || |
| 2579 | lscsi_status == SAM_STAT_BUSY) |
| 2580 | qla2x00_set_retry_delay_timestamp(fcport, retry_delay); |
| 2581 | |
| 2582 | /* |
| 2583 | * Based on Host and scsi status generate status code for Linux |
| 2584 | */ |
| 2585 | switch (comp_status) { |
| 2586 | case CS_COMPLETE: |
| 2587 | case CS_QUEUE_FULL: |
| 2588 | if (scsi_status == 0) { |
| 2589 | res = DID_OK << 16; |
| 2590 | break; |
| 2591 | } |
| 2592 | if (scsi_status & (SS_RESIDUAL_UNDER | SS_RESIDUAL_OVER)) { |
| 2593 | resid = resid_len; |
| 2594 | scsi_set_resid(cp, resid); |
| 2595 | |
| 2596 | if (!lscsi_status && |
| 2597 | ((unsigned)(scsi_bufflen(cp) - resid) < |
| 2598 | cp->underflow)) { |
| 2599 | ql_dbg(ql_dbg_io, fcport->vha, 0x301a, |
| 2600 | "Mid-layer underflow detected (0x%x of 0x%x bytes).\n", |
| 2601 | resid, scsi_bufflen(cp)); |
| 2602 | |
| 2603 | res = DID_ERROR << 16; |
| 2604 | break; |
| 2605 | } |
| 2606 | } |
| 2607 | res = DID_OK << 16 | lscsi_status; |
| 2608 | |
| 2609 | if (lscsi_status == SAM_STAT_TASK_SET_FULL) { |
| 2610 | ql_dbg(ql_dbg_io, fcport->vha, 0x301b, |
| 2611 | "QUEUE FULL detected.\n"); |
| 2612 | break; |
| 2613 | } |
| 2614 | logit = 0; |
| 2615 | if (lscsi_status != SS_CHECK_CONDITION) |
| 2616 | break; |
| 2617 | |
| 2618 | memset(cp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); |
| 2619 | if (!(scsi_status & SS_SENSE_LEN_VALID)) |
| 2620 | break; |
| 2621 | |
| 2622 | qla2x00_handle_sense(sp, sense_data, par_sense_len, sense_len, |
| 2623 | rsp, res); |
| 2624 | break; |
| 2625 | |
| 2626 | case CS_DATA_UNDERRUN: |
| 2627 | /* Use F/W calculated residual length. */ |
| 2628 | resid = IS_FWI2_CAPABLE(ha) ? fw_resid_len : resid_len; |
| 2629 | scsi_set_resid(cp, resid); |
| 2630 | if (scsi_status & SS_RESIDUAL_UNDER) { |
| 2631 | if (IS_FWI2_CAPABLE(ha) && fw_resid_len != resid_len) { |
| 2632 | ql_dbg(ql_dbg_io, fcport->vha, 0x301d, |
| 2633 | "Dropped frame(s) detected (0x%x of 0x%x bytes).\n", |
| 2634 | resid, scsi_bufflen(cp)); |
| 2635 | |
| 2636 | res = DID_ERROR << 16 | lscsi_status; |
| 2637 | goto check_scsi_status; |
| 2638 | } |
| 2639 | |
| 2640 | if (!lscsi_status && |
| 2641 | ((unsigned)(scsi_bufflen(cp) - resid) < |
| 2642 | cp->underflow)) { |
| 2643 | ql_dbg(ql_dbg_io, fcport->vha, 0x301e, |
| 2644 | "Mid-layer underflow detected (0x%x of 0x%x bytes).\n", |
| 2645 | resid, scsi_bufflen(cp)); |
| 2646 | |
| 2647 | res = DID_ERROR << 16; |
| 2648 | break; |
| 2649 | } |
| 2650 | } else if (lscsi_status != SAM_STAT_TASK_SET_FULL && |
| 2651 | lscsi_status != SAM_STAT_BUSY) { |
| 2652 | /* |
| 2653 | * scsi status of task set and busy are considered to be |
| 2654 | * task not completed. |
| 2655 | */ |
| 2656 | |
| 2657 | ql_dbg(ql_dbg_io, fcport->vha, 0x301f, |
| 2658 | "Dropped frame(s) detected (0x%x of 0x%x bytes).\n", |
| 2659 | resid, scsi_bufflen(cp)); |
| 2660 | |
| 2661 | res = DID_ERROR << 16 | lscsi_status; |
| 2662 | goto check_scsi_status; |
| 2663 | } else { |
| 2664 | ql_dbg(ql_dbg_io, fcport->vha, 0x3030, |
| 2665 | "scsi_status: 0x%x, lscsi_status: 0x%x\n", |
| 2666 | scsi_status, lscsi_status); |
| 2667 | } |
| 2668 | |
| 2669 | res = DID_OK << 16 | lscsi_status; |
| 2670 | logit = 0; |
| 2671 | |
| 2672 | check_scsi_status: |
| 2673 | /* |
| 2674 | * Check to see if SCSI Status is non zero. If so report SCSI |
| 2675 | * Status. |
| 2676 | */ |
| 2677 | if (lscsi_status != 0) { |
| 2678 | if (lscsi_status == SAM_STAT_TASK_SET_FULL) { |
| 2679 | ql_dbg(ql_dbg_io, fcport->vha, 0x3020, |
| 2680 | "QUEUE FULL detected.\n"); |
| 2681 | logit = 1; |
| 2682 | break; |
| 2683 | } |
| 2684 | if (lscsi_status != SS_CHECK_CONDITION) |
| 2685 | break; |
| 2686 | |
| 2687 | memset(cp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); |
| 2688 | if (!(scsi_status & SS_SENSE_LEN_VALID)) |
| 2689 | break; |
| 2690 | |
| 2691 | qla2x00_handle_sense(sp, sense_data, par_sense_len, |
| 2692 | sense_len, rsp, res); |
| 2693 | } |
| 2694 | break; |
| 2695 | |
| 2696 | case CS_PORT_LOGGED_OUT: |
| 2697 | case CS_PORT_CONFIG_CHG: |
| 2698 | case CS_PORT_BUSY: |
| 2699 | case CS_INCOMPLETE: |
| 2700 | case CS_PORT_UNAVAILABLE: |
| 2701 | case CS_TIMEOUT: |
| 2702 | case CS_RESET: |
| 2703 | |
| 2704 | /* |
| 2705 | * We are going to have the fc class block the rport |
| 2706 | * while we try to recover so instruct the mid layer |
| 2707 | * to requeue until the class decides how to handle this. |
| 2708 | */ |
| 2709 | res = DID_TRANSPORT_DISRUPTED << 16; |
| 2710 | |
| 2711 | if (comp_status == CS_TIMEOUT) { |
| 2712 | if (IS_FWI2_CAPABLE(ha)) |
| 2713 | break; |
| 2714 | else if ((le16_to_cpu(sts->status_flags) & |
| 2715 | SF_LOGOUT_SENT) == 0) |
| 2716 | break; |
| 2717 | } |
| 2718 | |
| 2719 | if (atomic_read(&fcport->state) == FCS_ONLINE) { |
| 2720 | ql_dbg(ql_dbg_disc, fcport->vha, 0x3021, |
| 2721 | "Port to be marked lost on fcport=%02x%02x%02x, current " |
| 2722 | "port state= %s comp_status %x.\n", fcport->d_id.b.domain, |
| 2723 | fcport->d_id.b.area, fcport->d_id.b.al_pa, |
| 2724 | port_state_str[FCS_ONLINE], |
| 2725 | comp_status); |
| 2726 | |
| 2727 | qla2x00_mark_device_lost(fcport->vha, fcport, 1, 1); |
| 2728 | qlt_schedule_sess_for_deletion(fcport); |
| 2729 | } |
| 2730 | |
| 2731 | break; |
| 2732 | |
| 2733 | case CS_ABORTED: |
| 2734 | res = DID_RESET << 16; |
| 2735 | break; |
| 2736 | |
| 2737 | case CS_DIF_ERROR: |
| 2738 | logit = qla2x00_handle_dif_error(sp, sts24); |
| 2739 | res = cp->result; |
| 2740 | break; |
| 2741 | |
| 2742 | case CS_TRANSPORT: |
| 2743 | res = DID_ERROR << 16; |
| 2744 | |
| 2745 | if (!IS_PI_SPLIT_DET_CAPABLE(ha)) |
| 2746 | break; |
| 2747 | |
| 2748 | if (state_flags & BIT_4) |
| 2749 | scmd_printk(KERN_WARNING, cp, |
| 2750 | "Unsupported device '%s' found.\n", |
| 2751 | cp->device->vendor); |
| 2752 | break; |
| 2753 | |
| 2754 | case CS_DMA: |
| 2755 | ql_log(ql_log_info, fcport->vha, 0x3022, |
| 2756 | "CS_DMA error: 0x%x-0x%x (0x%x) nexus=%ld:%d:%llu portid=%06x oxid=0x%x cdb=%10phN len=0x%x rsp_info=0x%x resid=0x%x fw_resid=0x%x sp=%p cp=%p.\n", |
| 2757 | comp_status, scsi_status, res, vha->host_no, |
| 2758 | cp->device->id, cp->device->lun, fcport->d_id.b24, |
| 2759 | ox_id, cp->cmnd, scsi_bufflen(cp), rsp_info_len, |
| 2760 | resid_len, fw_resid_len, sp, cp); |
| 2761 | ql_dump_buffer(ql_dbg_tgt + ql_dbg_verbose, vha, 0xe0ee, |
| 2762 | pkt, sizeof(*sts24)); |
| 2763 | res = DID_ERROR << 16; |
| 2764 | break; |
| 2765 | default: |
| 2766 | res = DID_ERROR << 16; |
| 2767 | break; |
| 2768 | } |
| 2769 | |
| 2770 | out: |
| 2771 | if (logit) |
| 2772 | ql_dbg(ql_dbg_io, fcport->vha, 0x3022, |
| 2773 | "FCP command status: 0x%x-0x%x (0x%x) nexus=%ld:%d:%llu " |
| 2774 | "portid=%02x%02x%02x oxid=0x%x cdb=%10phN len=0x%x " |
| 2775 | "rsp_info=0x%x resid=0x%x fw_resid=0x%x sp=%p cp=%p.\n", |
| 2776 | comp_status, scsi_status, res, vha->host_no, |
| 2777 | cp->device->id, cp->device->lun, fcport->d_id.b.domain, |
| 2778 | fcport->d_id.b.area, fcport->d_id.b.al_pa, ox_id, |
| 2779 | cp->cmnd, scsi_bufflen(cp), rsp_info_len, |
| 2780 | resid_len, fw_resid_len, sp, cp); |
| 2781 | |
| 2782 | if (rsp->status_srb == NULL) |
| 2783 | sp->done(sp, res); |
| 2784 | else |
| 2785 | WARN_ON_ONCE(true); |
| 2786 | } |
| 2787 | |
| 2788 | /** |
| 2789 | * qla2x00_status_cont_entry() - Process a Status Continuations entry. |
| 2790 | * @rsp: response queue |
| 2791 | * @pkt: Entry pointer |
| 2792 | * |
| 2793 | * Extended sense data. |
| 2794 | */ |
| 2795 | static void |
| 2796 | qla2x00_status_cont_entry(struct rsp_que *rsp, sts_cont_entry_t *pkt) |
| 2797 | { |
| 2798 | uint8_t sense_sz = 0; |
| 2799 | struct qla_hw_data *ha = rsp->hw; |
| 2800 | struct scsi_qla_host *vha = pci_get_drvdata(ha->pdev); |
| 2801 | srb_t *sp = rsp->status_srb; |
| 2802 | struct scsi_cmnd *cp; |
| 2803 | uint32_t sense_len; |
| 2804 | uint8_t *sense_ptr; |
| 2805 | |
| 2806 | if (!sp || !GET_CMD_SENSE_LEN(sp)) |
| 2807 | return; |
| 2808 | |
| 2809 | sense_len = GET_CMD_SENSE_LEN(sp); |
| 2810 | sense_ptr = GET_CMD_SENSE_PTR(sp); |
| 2811 | |
| 2812 | cp = GET_CMD_SP(sp); |
| 2813 | if (cp == NULL) { |
| 2814 | ql_log(ql_log_warn, vha, 0x3025, |
| 2815 | "cmd is NULL: already returned to OS (sp=%p).\n", sp); |
| 2816 | |
| 2817 | rsp->status_srb = NULL; |
| 2818 | return; |
| 2819 | } |
| 2820 | |
| 2821 | if (sense_len > sizeof(pkt->data)) |
| 2822 | sense_sz = sizeof(pkt->data); |
| 2823 | else |
| 2824 | sense_sz = sense_len; |
| 2825 | |
| 2826 | /* Move sense data. */ |
| 2827 | if (IS_FWI2_CAPABLE(ha)) |
| 2828 | host_to_fcp_swap(pkt->data, sizeof(pkt->data)); |
| 2829 | memcpy(sense_ptr, pkt->data, sense_sz); |
| 2830 | ql_dump_buffer(ql_dbg_io + ql_dbg_buffer, vha, 0x302c, |
| 2831 | sense_ptr, sense_sz); |
| 2832 | |
| 2833 | sense_len -= sense_sz; |
| 2834 | sense_ptr += sense_sz; |
| 2835 | |
| 2836 | SET_CMD_SENSE_PTR(sp, sense_ptr); |
| 2837 | SET_CMD_SENSE_LEN(sp, sense_len); |
| 2838 | |
| 2839 | /* Place command on done queue. */ |
| 2840 | if (sense_len == 0) { |
| 2841 | rsp->status_srb = NULL; |
| 2842 | sp->done(sp, cp->result); |
| 2843 | } else { |
| 2844 | WARN_ON_ONCE(true); |
| 2845 | } |
| 2846 | } |
| 2847 | |
| 2848 | /** |
| 2849 | * qla2x00_error_entry() - Process an error entry. |
| 2850 | * @vha: SCSI driver HA context |
| 2851 | * @rsp: response queue |
| 2852 | * @pkt: Entry pointer |
| 2853 | * return : 1=allow further error analysis. 0=no additional error analysis. |
| 2854 | */ |
| 2855 | static int |
| 2856 | qla2x00_error_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, sts_entry_t *pkt) |
| 2857 | { |
| 2858 | srb_t *sp; |
| 2859 | struct qla_hw_data *ha = vha->hw; |
| 2860 | const char func[] = "ERROR-IOCB"; |
| 2861 | uint16_t que = MSW(pkt->handle); |
| 2862 | struct req_que *req = NULL; |
| 2863 | int res = DID_ERROR << 16; |
| 2864 | |
| 2865 | ql_dbg(ql_dbg_async, vha, 0x502a, |
| 2866 | "iocb type %xh with error status %xh, handle %xh, rspq id %d\n", |
| 2867 | pkt->entry_type, pkt->entry_status, pkt->handle, rsp->id); |
| 2868 | |
| 2869 | if (que >= ha->max_req_queues || !ha->req_q_map[que]) |
| 2870 | goto fatal; |
| 2871 | |
| 2872 | req = ha->req_q_map[que]; |
| 2873 | |
| 2874 | if (pkt->entry_status & RF_BUSY) |
| 2875 | res = DID_BUS_BUSY << 16; |
| 2876 | |
| 2877 | if ((pkt->handle & ~QLA_TGT_HANDLE_MASK) == QLA_TGT_SKIP_HANDLE) |
| 2878 | return 0; |
| 2879 | |
| 2880 | switch (pkt->entry_type) { |
| 2881 | case NOTIFY_ACK_TYPE: |
| 2882 | case STATUS_TYPE: |
| 2883 | case STATUS_CONT_TYPE: |
| 2884 | case LOGINOUT_PORT_IOCB_TYPE: |
| 2885 | case CT_IOCB_TYPE: |
| 2886 | case ELS_IOCB_TYPE: |
| 2887 | case ABORT_IOCB_TYPE: |
| 2888 | case MBX_IOCB_TYPE: |
| 2889 | default: |
| 2890 | sp = qla2x00_get_sp_from_handle(vha, func, req, pkt); |
| 2891 | if (sp) { |
| 2892 | sp->done(sp, res); |
| 2893 | return 0; |
| 2894 | } |
| 2895 | break; |
| 2896 | |
| 2897 | case ABTS_RESP_24XX: |
| 2898 | case CTIO_TYPE7: |
| 2899 | case CTIO_CRC2: |
| 2900 | return 1; |
| 2901 | } |
| 2902 | fatal: |
| 2903 | ql_log(ql_log_warn, vha, 0x5030, |
| 2904 | "Error entry - invalid handle/queue (%04x).\n", que); |
| 2905 | return 0; |
| 2906 | } |
| 2907 | |
| 2908 | /** |
| 2909 | * qla24xx_mbx_completion() - Process mailbox command completions. |
| 2910 | * @vha: SCSI driver HA context |
| 2911 | * @mb0: Mailbox0 register |
| 2912 | */ |
| 2913 | static void |
| 2914 | qla24xx_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0) |
| 2915 | { |
| 2916 | uint16_t cnt; |
| 2917 | uint32_t mboxes; |
| 2918 | uint16_t __iomem *wptr; |
| 2919 | struct qla_hw_data *ha = vha->hw; |
| 2920 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 2921 | |
| 2922 | /* Read all mbox registers? */ |
| 2923 | WARN_ON_ONCE(ha->mbx_count > 32); |
| 2924 | mboxes = (1ULL << ha->mbx_count) - 1; |
| 2925 | if (!ha->mcp) |
| 2926 | ql_dbg(ql_dbg_async, vha, 0x504e, "MBX pointer ERROR.\n"); |
| 2927 | else |
| 2928 | mboxes = ha->mcp->in_mb; |
| 2929 | |
| 2930 | /* Load return mailbox registers. */ |
| 2931 | ha->flags.mbox_int = 1; |
| 2932 | ha->mailbox_out[0] = mb0; |
| 2933 | mboxes >>= 1; |
| 2934 | wptr = (uint16_t __iomem *)®->mailbox1; |
| 2935 | |
| 2936 | for (cnt = 1; cnt < ha->mbx_count; cnt++) { |
| 2937 | if (mboxes & BIT_0) |
| 2938 | ha->mailbox_out[cnt] = RD_REG_WORD(wptr); |
| 2939 | |
| 2940 | mboxes >>= 1; |
| 2941 | wptr++; |
| 2942 | } |
| 2943 | } |
| 2944 | |
| 2945 | static void |
| 2946 | qla24xx_abort_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, |
| 2947 | struct abort_entry_24xx *pkt) |
| 2948 | { |
| 2949 | const char func[] = "ABT_IOCB"; |
| 2950 | srb_t *sp; |
| 2951 | struct srb_iocb *abt; |
| 2952 | |
| 2953 | sp = qla2x00_get_sp_from_handle(vha, func, req, pkt); |
| 2954 | if (!sp) |
| 2955 | return; |
| 2956 | |
| 2957 | abt = &sp->u.iocb_cmd; |
| 2958 | abt->u.abt.comp_status = le16_to_cpu(pkt->nport_handle); |
| 2959 | sp->done(sp, 0); |
| 2960 | } |
| 2961 | |
| 2962 | void qla24xx_nvme_ls4_iocb(struct scsi_qla_host *vha, |
| 2963 | struct pt_ls4_request *pkt, struct req_que *req) |
| 2964 | { |
| 2965 | srb_t *sp; |
| 2966 | const char func[] = "LS4_IOCB"; |
| 2967 | uint16_t comp_status; |
| 2968 | |
| 2969 | sp = qla2x00_get_sp_from_handle(vha, func, req, pkt); |
| 2970 | if (!sp) |
| 2971 | return; |
| 2972 | |
| 2973 | comp_status = le16_to_cpu(pkt->status); |
| 2974 | sp->done(sp, comp_status); |
| 2975 | } |
| 2976 | |
| 2977 | /** |
| 2978 | * qla24xx_process_response_queue() - Process response queue entries. |
| 2979 | * @vha: SCSI driver HA context |
| 2980 | * @rsp: response queue |
| 2981 | */ |
| 2982 | void qla24xx_process_response_queue(struct scsi_qla_host *vha, |
| 2983 | struct rsp_que *rsp) |
| 2984 | { |
| 2985 | struct sts_entry_24xx *pkt; |
| 2986 | struct qla_hw_data *ha = vha->hw; |
| 2987 | |
| 2988 | if (!ha->flags.fw_started) |
| 2989 | return; |
| 2990 | |
| 2991 | if (rsp->qpair->cpuid != smp_processor_id()) |
| 2992 | qla_cpu_update(rsp->qpair, smp_processor_id()); |
| 2993 | |
| 2994 | while (rsp->ring_ptr->signature != RESPONSE_PROCESSED) { |
| 2995 | pkt = (struct sts_entry_24xx *)rsp->ring_ptr; |
| 2996 | |
| 2997 | rsp->ring_index++; |
| 2998 | if (rsp->ring_index == rsp->length) { |
| 2999 | rsp->ring_index = 0; |
| 3000 | rsp->ring_ptr = rsp->ring; |
| 3001 | } else { |
| 3002 | rsp->ring_ptr++; |
| 3003 | } |
| 3004 | |
| 3005 | if (pkt->entry_status != 0) { |
| 3006 | if (qla2x00_error_entry(vha, rsp, (sts_entry_t *) pkt)) |
| 3007 | goto process_err; |
| 3008 | |
| 3009 | ((response_t *)pkt)->signature = RESPONSE_PROCESSED; |
| 3010 | wmb(); |
| 3011 | continue; |
| 3012 | } |
| 3013 | process_err: |
| 3014 | |
| 3015 | switch (pkt->entry_type) { |
| 3016 | case STATUS_TYPE: |
| 3017 | qla2x00_status_entry(vha, rsp, pkt); |
| 3018 | break; |
| 3019 | case STATUS_CONT_TYPE: |
| 3020 | qla2x00_status_cont_entry(rsp, (sts_cont_entry_t *)pkt); |
| 3021 | break; |
| 3022 | case VP_RPT_ID_IOCB_TYPE: |
| 3023 | qla24xx_report_id_acquisition(vha, |
| 3024 | (struct vp_rpt_id_entry_24xx *)pkt); |
| 3025 | break; |
| 3026 | case LOGINOUT_PORT_IOCB_TYPE: |
| 3027 | qla24xx_logio_entry(vha, rsp->req, |
| 3028 | (struct logio_entry_24xx *)pkt); |
| 3029 | break; |
| 3030 | case CT_IOCB_TYPE: |
| 3031 | qla24xx_els_ct_entry(vha, rsp->req, pkt, CT_IOCB_TYPE); |
| 3032 | break; |
| 3033 | case ELS_IOCB_TYPE: |
| 3034 | qla24xx_els_ct_entry(vha, rsp->req, pkt, ELS_IOCB_TYPE); |
| 3035 | break; |
| 3036 | case ABTS_RECV_24XX: |
| 3037 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || |
| 3038 | IS_QLA28XX(ha)) { |
| 3039 | /* ensure that the ATIO queue is empty */ |
| 3040 | qlt_handle_abts_recv(vha, rsp, |
| 3041 | (response_t *)pkt); |
| 3042 | break; |
| 3043 | } else { |
| 3044 | qlt_24xx_process_atio_queue(vha, 1); |
| 3045 | } |
| 3046 | /* fall through */ |
| 3047 | case ABTS_RESP_24XX: |
| 3048 | case CTIO_TYPE7: |
| 3049 | case CTIO_CRC2: |
| 3050 | qlt_response_pkt_all_vps(vha, rsp, (response_t *)pkt); |
| 3051 | break; |
| 3052 | case PT_LS4_REQUEST: |
| 3053 | qla24xx_nvme_ls4_iocb(vha, (struct pt_ls4_request *)pkt, |
| 3054 | rsp->req); |
| 3055 | break; |
| 3056 | case NOTIFY_ACK_TYPE: |
| 3057 | if (pkt->handle == QLA_TGT_SKIP_HANDLE) |
| 3058 | qlt_response_pkt_all_vps(vha, rsp, |
| 3059 | (response_t *)pkt); |
| 3060 | else |
| 3061 | qla24xxx_nack_iocb_entry(vha, rsp->req, |
| 3062 | (struct nack_to_isp *)pkt); |
| 3063 | break; |
| 3064 | case MARKER_TYPE: |
| 3065 | /* Do nothing in this case, this check is to prevent it |
| 3066 | * from falling into default case |
| 3067 | */ |
| 3068 | break; |
| 3069 | case ABORT_IOCB_TYPE: |
| 3070 | qla24xx_abort_iocb_entry(vha, rsp->req, |
| 3071 | (struct abort_entry_24xx *)pkt); |
| 3072 | break; |
| 3073 | case MBX_IOCB_TYPE: |
| 3074 | qla24xx_mbx_iocb_entry(vha, rsp->req, |
| 3075 | (struct mbx_24xx_entry *)pkt); |
| 3076 | break; |
| 3077 | case VP_CTRL_IOCB_TYPE: |
| 3078 | qla_ctrlvp_completed(vha, rsp->req, |
| 3079 | (struct vp_ctrl_entry_24xx *)pkt); |
| 3080 | break; |
| 3081 | default: |
| 3082 | /* Type Not Supported. */ |
| 3083 | ql_dbg(ql_dbg_async, vha, 0x5042, |
| 3084 | "Received unknown response pkt type %x " |
| 3085 | "entry status=%x.\n", |
| 3086 | pkt->entry_type, pkt->entry_status); |
| 3087 | break; |
| 3088 | } |
| 3089 | ((response_t *)pkt)->signature = RESPONSE_PROCESSED; |
| 3090 | wmb(); |
| 3091 | } |
| 3092 | |
| 3093 | /* Adjust ring index */ |
| 3094 | if (IS_P3P_TYPE(ha)) { |
| 3095 | struct device_reg_82xx __iomem *reg = &ha->iobase->isp82; |
| 3096 | |
| 3097 | WRT_REG_DWORD(®->rsp_q_out[0], rsp->ring_index); |
| 3098 | } else { |
| 3099 | WRT_REG_DWORD(rsp->rsp_q_out, rsp->ring_index); |
| 3100 | } |
| 3101 | } |
| 3102 | |
| 3103 | static void |
| 3104 | qla2xxx_check_risc_status(scsi_qla_host_t *vha) |
| 3105 | { |
| 3106 | int rval; |
| 3107 | uint32_t cnt; |
| 3108 | struct qla_hw_data *ha = vha->hw; |
| 3109 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 3110 | |
| 3111 | if (!IS_QLA25XX(ha) && !IS_QLA81XX(ha) && !IS_QLA83XX(ha) && |
| 3112 | !IS_QLA27XX(ha) && !IS_QLA28XX(ha)) |
| 3113 | return; |
| 3114 | |
| 3115 | rval = QLA_SUCCESS; |
| 3116 | WRT_REG_DWORD(®->iobase_addr, 0x7C00); |
| 3117 | RD_REG_DWORD(®->iobase_addr); |
| 3118 | WRT_REG_DWORD(®->iobase_window, 0x0001); |
| 3119 | for (cnt = 10000; (RD_REG_DWORD(®->iobase_window) & BIT_0) == 0 && |
| 3120 | rval == QLA_SUCCESS; cnt--) { |
| 3121 | if (cnt) { |
| 3122 | WRT_REG_DWORD(®->iobase_window, 0x0001); |
| 3123 | udelay(10); |
| 3124 | } else |
| 3125 | rval = QLA_FUNCTION_TIMEOUT; |
| 3126 | } |
| 3127 | if (rval == QLA_SUCCESS) |
| 3128 | goto next_test; |
| 3129 | |
| 3130 | rval = QLA_SUCCESS; |
| 3131 | WRT_REG_DWORD(®->iobase_window, 0x0003); |
| 3132 | for (cnt = 100; (RD_REG_DWORD(®->iobase_window) & BIT_0) == 0 && |
| 3133 | rval == QLA_SUCCESS; cnt--) { |
| 3134 | if (cnt) { |
| 3135 | WRT_REG_DWORD(®->iobase_window, 0x0003); |
| 3136 | udelay(10); |
| 3137 | } else |
| 3138 | rval = QLA_FUNCTION_TIMEOUT; |
| 3139 | } |
| 3140 | if (rval != QLA_SUCCESS) |
| 3141 | goto done; |
| 3142 | |
| 3143 | next_test: |
| 3144 | if (RD_REG_DWORD(®->iobase_c8) & BIT_3) |
| 3145 | ql_log(ql_log_info, vha, 0x504c, |
| 3146 | "Additional code -- 0x55AA.\n"); |
| 3147 | |
| 3148 | done: |
| 3149 | WRT_REG_DWORD(®->iobase_window, 0x0000); |
| 3150 | RD_REG_DWORD(®->iobase_window); |
| 3151 | } |
| 3152 | |
| 3153 | /** |
| 3154 | * qla24xx_intr_handler() - Process interrupts for the ISP23xx and ISP24xx. |
| 3155 | * @irq: interrupt number |
| 3156 | * @dev_id: SCSI driver HA context |
| 3157 | * |
| 3158 | * Called by system whenever the host adapter generates an interrupt. |
| 3159 | * |
| 3160 | * Returns handled flag. |
| 3161 | */ |
| 3162 | irqreturn_t |
| 3163 | qla24xx_intr_handler(int irq, void *dev_id) |
| 3164 | { |
| 3165 | scsi_qla_host_t *vha; |
| 3166 | struct qla_hw_data *ha; |
| 3167 | struct device_reg_24xx __iomem *reg; |
| 3168 | int status; |
| 3169 | unsigned long iter; |
| 3170 | uint32_t stat; |
| 3171 | uint32_t hccr; |
| 3172 | uint16_t mb[8]; |
| 3173 | struct rsp_que *rsp; |
| 3174 | unsigned long flags; |
| 3175 | bool process_atio = false; |
| 3176 | |
| 3177 | rsp = (struct rsp_que *) dev_id; |
| 3178 | if (!rsp) { |
| 3179 | ql_log(ql_log_info, NULL, 0x5059, |
| 3180 | "%s: NULL response queue pointer.\n", __func__); |
| 3181 | return IRQ_NONE; |
| 3182 | } |
| 3183 | |
| 3184 | ha = rsp->hw; |
| 3185 | reg = &ha->iobase->isp24; |
| 3186 | status = 0; |
| 3187 | |
| 3188 | if (unlikely(pci_channel_offline(ha->pdev))) |
| 3189 | return IRQ_HANDLED; |
| 3190 | |
| 3191 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 3192 | vha = pci_get_drvdata(ha->pdev); |
| 3193 | for (iter = 50; iter--; ) { |
| 3194 | stat = RD_REG_DWORD(®->host_status); |
| 3195 | if (qla2x00_check_reg32_for_disconnect(vha, stat)) |
| 3196 | break; |
| 3197 | if (stat & HSRX_RISC_PAUSED) { |
| 3198 | if (unlikely(pci_channel_offline(ha->pdev))) |
| 3199 | break; |
| 3200 | |
| 3201 | hccr = RD_REG_DWORD(®->hccr); |
| 3202 | |
| 3203 | ql_log(ql_log_warn, vha, 0x504b, |
| 3204 | "RISC paused -- HCCR=%x, Dumping firmware.\n", |
| 3205 | hccr); |
| 3206 | |
| 3207 | qla2xxx_check_risc_status(vha); |
| 3208 | |
| 3209 | ha->isp_ops->fw_dump(vha, 1); |
| 3210 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 3211 | break; |
| 3212 | } else if ((stat & HSRX_RISC_INT) == 0) |
| 3213 | break; |
| 3214 | |
| 3215 | switch (stat & 0xff) { |
| 3216 | case INTR_ROM_MB_SUCCESS: |
| 3217 | case INTR_ROM_MB_FAILED: |
| 3218 | case INTR_MB_SUCCESS: |
| 3219 | case INTR_MB_FAILED: |
| 3220 | qla24xx_mbx_completion(vha, MSW(stat)); |
| 3221 | status |= MBX_INTERRUPT; |
| 3222 | |
| 3223 | break; |
| 3224 | case INTR_ASYNC_EVENT: |
| 3225 | mb[0] = MSW(stat); |
| 3226 | mb[1] = RD_REG_WORD(®->mailbox1); |
| 3227 | mb[2] = RD_REG_WORD(®->mailbox2); |
| 3228 | mb[3] = RD_REG_WORD(®->mailbox3); |
| 3229 | qla2x00_async_event(vha, rsp, mb); |
| 3230 | break; |
| 3231 | case INTR_RSP_QUE_UPDATE: |
| 3232 | case INTR_RSP_QUE_UPDATE_83XX: |
| 3233 | qla24xx_process_response_queue(vha, rsp); |
| 3234 | break; |
| 3235 | case INTR_ATIO_QUE_UPDATE_27XX: |
| 3236 | case INTR_ATIO_QUE_UPDATE: |
| 3237 | process_atio = true; |
| 3238 | break; |
| 3239 | case INTR_ATIO_RSP_QUE_UPDATE: |
| 3240 | process_atio = true; |
| 3241 | qla24xx_process_response_queue(vha, rsp); |
| 3242 | break; |
| 3243 | default: |
| 3244 | ql_dbg(ql_dbg_async, vha, 0x504f, |
| 3245 | "Unrecognized interrupt type (%d).\n", stat * 0xff); |
| 3246 | break; |
| 3247 | } |
| 3248 | WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_INT); |
| 3249 | RD_REG_DWORD_RELAXED(®->hccr); |
| 3250 | if (unlikely(IS_QLA83XX(ha) && (ha->pdev->revision == 1))) |
| 3251 | ndelay(3500); |
| 3252 | } |
| 3253 | qla2x00_handle_mbx_completion(ha, status); |
| 3254 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 3255 | |
| 3256 | if (process_atio) { |
| 3257 | spin_lock_irqsave(&ha->tgt.atio_lock, flags); |
| 3258 | qlt_24xx_process_atio_queue(vha, 0); |
| 3259 | spin_unlock_irqrestore(&ha->tgt.atio_lock, flags); |
| 3260 | } |
| 3261 | |
| 3262 | return IRQ_HANDLED; |
| 3263 | } |
| 3264 | |
| 3265 | static irqreturn_t |
| 3266 | qla24xx_msix_rsp_q(int irq, void *dev_id) |
| 3267 | { |
| 3268 | struct qla_hw_data *ha; |
| 3269 | struct rsp_que *rsp; |
| 3270 | struct device_reg_24xx __iomem *reg; |
| 3271 | struct scsi_qla_host *vha; |
| 3272 | unsigned long flags; |
| 3273 | |
| 3274 | rsp = (struct rsp_que *) dev_id; |
| 3275 | if (!rsp) { |
| 3276 | ql_log(ql_log_info, NULL, 0x505a, |
| 3277 | "%s: NULL response queue pointer.\n", __func__); |
| 3278 | return IRQ_NONE; |
| 3279 | } |
| 3280 | ha = rsp->hw; |
| 3281 | reg = &ha->iobase->isp24; |
| 3282 | |
| 3283 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 3284 | |
| 3285 | vha = pci_get_drvdata(ha->pdev); |
| 3286 | qla24xx_process_response_queue(vha, rsp); |
| 3287 | if (!ha->flags.disable_msix_handshake) { |
| 3288 | WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_INT); |
| 3289 | RD_REG_DWORD_RELAXED(®->hccr); |
| 3290 | } |
| 3291 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 3292 | |
| 3293 | return IRQ_HANDLED; |
| 3294 | } |
| 3295 | |
| 3296 | static irqreturn_t |
| 3297 | qla24xx_msix_default(int irq, void *dev_id) |
| 3298 | { |
| 3299 | scsi_qla_host_t *vha; |
| 3300 | struct qla_hw_data *ha; |
| 3301 | struct rsp_que *rsp; |
| 3302 | struct device_reg_24xx __iomem *reg; |
| 3303 | int status; |
| 3304 | uint32_t stat; |
| 3305 | uint32_t hccr; |
| 3306 | uint16_t mb[8]; |
| 3307 | unsigned long flags; |
| 3308 | bool process_atio = false; |
| 3309 | |
| 3310 | rsp = (struct rsp_que *) dev_id; |
| 3311 | if (!rsp) { |
| 3312 | ql_log(ql_log_info, NULL, 0x505c, |
| 3313 | "%s: NULL response queue pointer.\n", __func__); |
| 3314 | return IRQ_NONE; |
| 3315 | } |
| 3316 | ha = rsp->hw; |
| 3317 | reg = &ha->iobase->isp24; |
| 3318 | status = 0; |
| 3319 | |
| 3320 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 3321 | vha = pci_get_drvdata(ha->pdev); |
| 3322 | do { |
| 3323 | stat = RD_REG_DWORD(®->host_status); |
| 3324 | if (qla2x00_check_reg32_for_disconnect(vha, stat)) |
| 3325 | break; |
| 3326 | if (stat & HSRX_RISC_PAUSED) { |
| 3327 | if (unlikely(pci_channel_offline(ha->pdev))) |
| 3328 | break; |
| 3329 | |
| 3330 | hccr = RD_REG_DWORD(®->hccr); |
| 3331 | |
| 3332 | ql_log(ql_log_info, vha, 0x5050, |
| 3333 | "RISC paused -- HCCR=%x, Dumping firmware.\n", |
| 3334 | hccr); |
| 3335 | |
| 3336 | qla2xxx_check_risc_status(vha); |
| 3337 | |
| 3338 | ha->isp_ops->fw_dump(vha, 1); |
| 3339 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 3340 | break; |
| 3341 | } else if ((stat & HSRX_RISC_INT) == 0) |
| 3342 | break; |
| 3343 | |
| 3344 | switch (stat & 0xff) { |
| 3345 | case INTR_ROM_MB_SUCCESS: |
| 3346 | case INTR_ROM_MB_FAILED: |
| 3347 | case INTR_MB_SUCCESS: |
| 3348 | case INTR_MB_FAILED: |
| 3349 | qla24xx_mbx_completion(vha, MSW(stat)); |
| 3350 | status |= MBX_INTERRUPT; |
| 3351 | |
| 3352 | break; |
| 3353 | case INTR_ASYNC_EVENT: |
| 3354 | mb[0] = MSW(stat); |
| 3355 | mb[1] = RD_REG_WORD(®->mailbox1); |
| 3356 | mb[2] = RD_REG_WORD(®->mailbox2); |
| 3357 | mb[3] = RD_REG_WORD(®->mailbox3); |
| 3358 | qla2x00_async_event(vha, rsp, mb); |
| 3359 | break; |
| 3360 | case INTR_RSP_QUE_UPDATE: |
| 3361 | case INTR_RSP_QUE_UPDATE_83XX: |
| 3362 | qla24xx_process_response_queue(vha, rsp); |
| 3363 | break; |
| 3364 | case INTR_ATIO_QUE_UPDATE_27XX: |
| 3365 | case INTR_ATIO_QUE_UPDATE: |
| 3366 | process_atio = true; |
| 3367 | break; |
| 3368 | case INTR_ATIO_RSP_QUE_UPDATE: |
| 3369 | process_atio = true; |
| 3370 | qla24xx_process_response_queue(vha, rsp); |
| 3371 | break; |
| 3372 | default: |
| 3373 | ql_dbg(ql_dbg_async, vha, 0x5051, |
| 3374 | "Unrecognized interrupt type (%d).\n", stat & 0xff); |
| 3375 | break; |
| 3376 | } |
| 3377 | WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_INT); |
| 3378 | } while (0); |
| 3379 | qla2x00_handle_mbx_completion(ha, status); |
| 3380 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 3381 | |
| 3382 | if (process_atio) { |
| 3383 | spin_lock_irqsave(&ha->tgt.atio_lock, flags); |
| 3384 | qlt_24xx_process_atio_queue(vha, 0); |
| 3385 | spin_unlock_irqrestore(&ha->tgt.atio_lock, flags); |
| 3386 | } |
| 3387 | |
| 3388 | return IRQ_HANDLED; |
| 3389 | } |
| 3390 | |
| 3391 | irqreturn_t |
| 3392 | qla2xxx_msix_rsp_q(int irq, void *dev_id) |
| 3393 | { |
| 3394 | struct qla_hw_data *ha; |
| 3395 | struct qla_qpair *qpair; |
| 3396 | struct device_reg_24xx __iomem *reg; |
| 3397 | unsigned long flags; |
| 3398 | |
| 3399 | qpair = dev_id; |
| 3400 | if (!qpair) { |
| 3401 | ql_log(ql_log_info, NULL, 0x505b, |
| 3402 | "%s: NULL response queue pointer.\n", __func__); |
| 3403 | return IRQ_NONE; |
| 3404 | } |
| 3405 | ha = qpair->hw; |
| 3406 | |
| 3407 | /* Clear the interrupt, if enabled, for this response queue */ |
| 3408 | if (unlikely(!ha->flags.disable_msix_handshake)) { |
| 3409 | reg = &ha->iobase->isp24; |
| 3410 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 3411 | WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_INT); |
| 3412 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 3413 | } |
| 3414 | |
| 3415 | queue_work(ha->wq, &qpair->q_work); |
| 3416 | |
| 3417 | return IRQ_HANDLED; |
| 3418 | } |
| 3419 | |
| 3420 | /* Interrupt handling helpers. */ |
| 3421 | |
| 3422 | struct qla_init_msix_entry { |
| 3423 | const char *name; |
| 3424 | irq_handler_t handler; |
| 3425 | }; |
| 3426 | |
| 3427 | static const struct qla_init_msix_entry msix_entries[] = { |
| 3428 | { "default", qla24xx_msix_default }, |
| 3429 | { "rsp_q", qla24xx_msix_rsp_q }, |
| 3430 | { "atio_q", qla83xx_msix_atio_q }, |
| 3431 | { "qpair_multiq", qla2xxx_msix_rsp_q }, |
| 3432 | }; |
| 3433 | |
| 3434 | static const struct qla_init_msix_entry qla82xx_msix_entries[] = { |
| 3435 | { "qla2xxx (default)", qla82xx_msix_default }, |
| 3436 | { "qla2xxx (rsp_q)", qla82xx_msix_rsp_q }, |
| 3437 | }; |
| 3438 | |
| 3439 | static int |
| 3440 | qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp) |
| 3441 | { |
| 3442 | int i, ret; |
| 3443 | struct qla_msix_entry *qentry; |
| 3444 | scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); |
| 3445 | int min_vecs = QLA_BASE_VECTORS; |
| 3446 | struct irq_affinity desc = { |
| 3447 | .pre_vectors = QLA_BASE_VECTORS, |
| 3448 | }; |
| 3449 | |
| 3450 | if (QLA_TGT_MODE_ENABLED() && (ql2xenablemsix != 0) && |
| 3451 | IS_ATIO_MSIX_CAPABLE(ha)) { |
| 3452 | desc.pre_vectors++; |
| 3453 | min_vecs++; |
| 3454 | } |
| 3455 | |
| 3456 | if (USER_CTRL_IRQ(ha) || !ha->mqiobase) { |
| 3457 | /* user wants to control IRQ setting for target mode */ |
| 3458 | ret = pci_alloc_irq_vectors(ha->pdev, min_vecs, |
| 3459 | ha->msix_count, PCI_IRQ_MSIX); |
| 3460 | } else |
| 3461 | ret = pci_alloc_irq_vectors_affinity(ha->pdev, min_vecs, |
| 3462 | ha->msix_count, PCI_IRQ_MSIX | PCI_IRQ_AFFINITY, |
| 3463 | &desc); |
| 3464 | |
| 3465 | if (ret < 0) { |
| 3466 | ql_log(ql_log_fatal, vha, 0x00c7, |
| 3467 | "MSI-X: Failed to enable support, " |
| 3468 | "giving up -- %d/%d.\n", |
| 3469 | ha->msix_count, ret); |
| 3470 | goto msix_out; |
| 3471 | } else if (ret < ha->msix_count) { |
| 3472 | ql_log(ql_log_warn, vha, 0x00c6, |
| 3473 | "MSI-X: Failed to enable support " |
| 3474 | "with %d vectors, using %d vectors.\n", |
| 3475 | ha->msix_count, ret); |
| 3476 | ha->msix_count = ret; |
| 3477 | /* Recalculate queue values */ |
| 3478 | if (ha->mqiobase && (ql2xmqsupport || ql2xnvmeenable)) { |
| 3479 | ha->max_req_queues = ha->msix_count - 1; |
| 3480 | |
| 3481 | /* ATIOQ needs 1 vector. That's 1 less QPair */ |
| 3482 | if (QLA_TGT_MODE_ENABLED()) |
| 3483 | ha->max_req_queues--; |
| 3484 | |
| 3485 | ha->max_rsp_queues = ha->max_req_queues; |
| 3486 | |
| 3487 | ha->max_qpairs = ha->max_req_queues - 1; |
| 3488 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0190, |
| 3489 | "Adjusted Max no of queues pairs: %d.\n", ha->max_qpairs); |
| 3490 | } |
| 3491 | } |
| 3492 | vha->irq_offset = desc.pre_vectors; |
| 3493 | ha->msix_entries = kcalloc(ha->msix_count, |
| 3494 | sizeof(struct qla_msix_entry), |
| 3495 | GFP_KERNEL); |
| 3496 | if (!ha->msix_entries) { |
| 3497 | ql_log(ql_log_fatal, vha, 0x00c8, |
| 3498 | "Failed to allocate memory for ha->msix_entries.\n"); |
| 3499 | ret = -ENOMEM; |
| 3500 | goto free_irqs; |
| 3501 | } |
| 3502 | ha->flags.msix_enabled = 1; |
| 3503 | |
| 3504 | for (i = 0; i < ha->msix_count; i++) { |
| 3505 | qentry = &ha->msix_entries[i]; |
| 3506 | qentry->vector = pci_irq_vector(ha->pdev, i); |
| 3507 | qentry->entry = i; |
| 3508 | qentry->have_irq = 0; |
| 3509 | qentry->in_use = 0; |
| 3510 | qentry->handle = NULL; |
| 3511 | } |
| 3512 | |
| 3513 | /* Enable MSI-X vectors for the base queue */ |
| 3514 | for (i = 0; i < QLA_BASE_VECTORS; i++) { |
| 3515 | qentry = &ha->msix_entries[i]; |
| 3516 | qentry->handle = rsp; |
| 3517 | rsp->msix = qentry; |
| 3518 | scnprintf(qentry->name, sizeof(qentry->name), |
| 3519 | "qla2xxx%lu_%s", vha->host_no, msix_entries[i].name); |
| 3520 | if (IS_P3P_TYPE(ha)) |
| 3521 | ret = request_irq(qentry->vector, |
| 3522 | qla82xx_msix_entries[i].handler, |
| 3523 | 0, qla82xx_msix_entries[i].name, rsp); |
| 3524 | else |
| 3525 | ret = request_irq(qentry->vector, |
| 3526 | msix_entries[i].handler, |
| 3527 | 0, qentry->name, rsp); |
| 3528 | if (ret) |
| 3529 | goto msix_register_fail; |
| 3530 | qentry->have_irq = 1; |
| 3531 | qentry->in_use = 1; |
| 3532 | } |
| 3533 | |
| 3534 | /* |
| 3535 | * If target mode is enable, also request the vector for the ATIO |
| 3536 | * queue. |
| 3537 | */ |
| 3538 | if (QLA_TGT_MODE_ENABLED() && (ql2xenablemsix != 0) && |
| 3539 | IS_ATIO_MSIX_CAPABLE(ha)) { |
| 3540 | qentry = &ha->msix_entries[QLA_ATIO_VECTOR]; |
| 3541 | rsp->msix = qentry; |
| 3542 | qentry->handle = rsp; |
| 3543 | scnprintf(qentry->name, sizeof(qentry->name), |
| 3544 | "qla2xxx%lu_%s", vha->host_no, |
| 3545 | msix_entries[QLA_ATIO_VECTOR].name); |
| 3546 | qentry->in_use = 1; |
| 3547 | ret = request_irq(qentry->vector, |
| 3548 | msix_entries[QLA_ATIO_VECTOR].handler, |
| 3549 | 0, qentry->name, rsp); |
| 3550 | qentry->have_irq = 1; |
| 3551 | } |
| 3552 | |
| 3553 | msix_register_fail: |
| 3554 | if (ret) { |
| 3555 | ql_log(ql_log_fatal, vha, 0x00cb, |
| 3556 | "MSI-X: unable to register handler -- %x/%d.\n", |
| 3557 | qentry->vector, ret); |
| 3558 | qla2x00_free_irqs(vha); |
| 3559 | ha->mqenable = 0; |
| 3560 | goto msix_out; |
| 3561 | } |
| 3562 | |
| 3563 | /* Enable MSI-X vector for response queue update for queue 0 */ |
| 3564 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) { |
| 3565 | if (ha->msixbase && ha->mqiobase && |
| 3566 | (ha->max_rsp_queues > 1 || ha->max_req_queues > 1 || |
| 3567 | ql2xmqsupport)) |
| 3568 | ha->mqenable = 1; |
| 3569 | } else |
| 3570 | if (ha->mqiobase && |
| 3571 | (ha->max_rsp_queues > 1 || ha->max_req_queues > 1 || |
| 3572 | ql2xmqsupport)) |
| 3573 | ha->mqenable = 1; |
| 3574 | ql_dbg(ql_dbg_multiq, vha, 0xc005, |
| 3575 | "mqiobase=%p, max_rsp_queues=%d, max_req_queues=%d.\n", |
| 3576 | ha->mqiobase, ha->max_rsp_queues, ha->max_req_queues); |
| 3577 | ql_dbg(ql_dbg_init, vha, 0x0055, |
| 3578 | "mqiobase=%p, max_rsp_queues=%d, max_req_queues=%d.\n", |
| 3579 | ha->mqiobase, ha->max_rsp_queues, ha->max_req_queues); |
| 3580 | |
| 3581 | msix_out: |
| 3582 | return ret; |
| 3583 | |
| 3584 | free_irqs: |
| 3585 | pci_free_irq_vectors(ha->pdev); |
| 3586 | goto msix_out; |
| 3587 | } |
| 3588 | |
| 3589 | int |
| 3590 | qla2x00_request_irqs(struct qla_hw_data *ha, struct rsp_que *rsp) |
| 3591 | { |
| 3592 | int ret = QLA_FUNCTION_FAILED; |
| 3593 | device_reg_t *reg = ha->iobase; |
| 3594 | scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); |
| 3595 | |
| 3596 | /* If possible, enable MSI-X. */ |
| 3597 | if (ql2xenablemsix == 0 || (!IS_QLA2432(ha) && !IS_QLA2532(ha) && |
| 3598 | !IS_QLA8432(ha) && !IS_CNA_CAPABLE(ha) && !IS_QLA2031(ha) && |
| 3599 | !IS_QLAFX00(ha) && !IS_QLA27XX(ha) && !IS_QLA28XX(ha))) |
| 3600 | goto skip_msi; |
| 3601 | |
| 3602 | if (ql2xenablemsix == 2) |
| 3603 | goto skip_msix; |
| 3604 | |
| 3605 | if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_HP && |
| 3606 | (ha->pdev->subsystem_device == 0x7040 || |
| 3607 | ha->pdev->subsystem_device == 0x7041 || |
| 3608 | ha->pdev->subsystem_device == 0x1705)) { |
| 3609 | ql_log(ql_log_warn, vha, 0x0034, |
| 3610 | "MSI-X: Unsupported ISP 2432 SSVID/SSDID (0x%X,0x%X).\n", |
| 3611 | ha->pdev->subsystem_vendor, |
| 3612 | ha->pdev->subsystem_device); |
| 3613 | goto skip_msi; |
| 3614 | } |
| 3615 | |
| 3616 | if (IS_QLA2432(ha) && (ha->pdev->revision < QLA_MSIX_CHIP_REV_24XX)) { |
| 3617 | ql_log(ql_log_warn, vha, 0x0035, |
| 3618 | "MSI-X; Unsupported ISP2432 (0x%X, 0x%X).\n", |
| 3619 | ha->pdev->revision, QLA_MSIX_CHIP_REV_24XX); |
| 3620 | goto skip_msix; |
| 3621 | } |
| 3622 | |
| 3623 | ret = qla24xx_enable_msix(ha, rsp); |
| 3624 | if (!ret) { |
| 3625 | ql_dbg(ql_dbg_init, vha, 0x0036, |
| 3626 | "MSI-X: Enabled (0x%X, 0x%X).\n", |
| 3627 | ha->chip_revision, ha->fw_attributes); |
| 3628 | goto clear_risc_ints; |
| 3629 | } |
| 3630 | |
| 3631 | skip_msix: |
| 3632 | |
| 3633 | ql_log(ql_log_info, vha, 0x0037, |
| 3634 | "Falling back-to MSI mode -%d.\n", ret); |
| 3635 | |
| 3636 | if (!IS_QLA24XX(ha) && !IS_QLA2532(ha) && !IS_QLA8432(ha) && |
| 3637 | !IS_QLA8001(ha) && !IS_P3P_TYPE(ha) && !IS_QLAFX00(ha) && |
| 3638 | !IS_QLA27XX(ha) && !IS_QLA28XX(ha)) |
| 3639 | goto skip_msi; |
| 3640 | |
| 3641 | ret = pci_alloc_irq_vectors(ha->pdev, 1, 1, PCI_IRQ_MSI); |
| 3642 | if (!ret) { |
| 3643 | ql_dbg(ql_dbg_init, vha, 0x0038, |
| 3644 | "MSI: Enabled.\n"); |
| 3645 | ha->flags.msi_enabled = 1; |
| 3646 | } else |
| 3647 | ql_log(ql_log_warn, vha, 0x0039, |
| 3648 | "Falling back-to INTa mode -- %d.\n", ret); |
| 3649 | skip_msi: |
| 3650 | |
| 3651 | /* Skip INTx on ISP82xx. */ |
| 3652 | if (!ha->flags.msi_enabled && IS_QLA82XX(ha)) |
| 3653 | return QLA_FUNCTION_FAILED; |
| 3654 | |
| 3655 | ret = request_irq(ha->pdev->irq, ha->isp_ops->intr_handler, |
| 3656 | ha->flags.msi_enabled ? 0 : IRQF_SHARED, |
| 3657 | QLA2XXX_DRIVER_NAME, rsp); |
| 3658 | if (ret) { |
| 3659 | ql_log(ql_log_warn, vha, 0x003a, |
| 3660 | "Failed to reserve interrupt %d already in use.\n", |
| 3661 | ha->pdev->irq); |
| 3662 | goto fail; |
| 3663 | } else if (!ha->flags.msi_enabled) { |
| 3664 | ql_dbg(ql_dbg_init, vha, 0x0125, |
| 3665 | "INTa mode: Enabled.\n"); |
| 3666 | ha->flags.mr_intr_valid = 1; |
| 3667 | } |
| 3668 | |
| 3669 | clear_risc_ints: |
| 3670 | if (IS_FWI2_CAPABLE(ha) || IS_QLAFX00(ha)) |
| 3671 | goto fail; |
| 3672 | |
| 3673 | spin_lock_irq(&ha->hardware_lock); |
| 3674 | WRT_REG_WORD(®->isp.semaphore, 0); |
| 3675 | spin_unlock_irq(&ha->hardware_lock); |
| 3676 | |
| 3677 | fail: |
| 3678 | return ret; |
| 3679 | } |
| 3680 | |
| 3681 | void |
| 3682 | qla2x00_free_irqs(scsi_qla_host_t *vha) |
| 3683 | { |
| 3684 | struct qla_hw_data *ha = vha->hw; |
| 3685 | struct rsp_que *rsp; |
| 3686 | struct qla_msix_entry *qentry; |
| 3687 | int i; |
| 3688 | |
| 3689 | /* |
| 3690 | * We need to check that ha->rsp_q_map is valid in case we are called |
| 3691 | * from a probe failure context. |
| 3692 | */ |
| 3693 | if (!ha->rsp_q_map || !ha->rsp_q_map[0]) |
| 3694 | goto free_irqs; |
| 3695 | rsp = ha->rsp_q_map[0]; |
| 3696 | |
| 3697 | if (ha->flags.msix_enabled) { |
| 3698 | for (i = 0; i < ha->msix_count; i++) { |
| 3699 | qentry = &ha->msix_entries[i]; |
| 3700 | if (qentry->have_irq) { |
| 3701 | irq_set_affinity_notifier(qentry->vector, NULL); |
| 3702 | free_irq(pci_irq_vector(ha->pdev, i), qentry->handle); |
| 3703 | } |
| 3704 | } |
| 3705 | kfree(ha->msix_entries); |
| 3706 | ha->msix_entries = NULL; |
| 3707 | ha->flags.msix_enabled = 0; |
| 3708 | ql_dbg(ql_dbg_init, vha, 0x0042, |
| 3709 | "Disabled MSI-X.\n"); |
| 3710 | } else { |
| 3711 | free_irq(pci_irq_vector(ha->pdev, 0), rsp); |
| 3712 | } |
| 3713 | |
| 3714 | free_irqs: |
| 3715 | pci_free_irq_vectors(ha->pdev); |
| 3716 | } |
| 3717 | |
| 3718 | int qla25xx_request_irq(struct qla_hw_data *ha, struct qla_qpair *qpair, |
| 3719 | struct qla_msix_entry *msix, int vector_type) |
| 3720 | { |
| 3721 | const struct qla_init_msix_entry *intr = &msix_entries[vector_type]; |
| 3722 | scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); |
| 3723 | int ret; |
| 3724 | |
| 3725 | scnprintf(msix->name, sizeof(msix->name), |
| 3726 | "qla2xxx%lu_qpair%d", vha->host_no, qpair->id); |
| 3727 | ret = request_irq(msix->vector, intr->handler, 0, msix->name, qpair); |
| 3728 | if (ret) { |
| 3729 | ql_log(ql_log_fatal, vha, 0x00e6, |
| 3730 | "MSI-X: Unable to register handler -- %x/%d.\n", |
| 3731 | msix->vector, ret); |
| 3732 | return ret; |
| 3733 | } |
| 3734 | msix->have_irq = 1; |
| 3735 | msix->handle = qpair; |
| 3736 | return ret; |
| 3737 | } |