Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Andrew Vasquez | fa90c54 | 2005-10-27 11:10:08 -0700 | [diff] [blame] | 2 | * QLogic Fibre Channel HBA Driver |
Andrew Vasquez | 01e58d8 | 2008-04-03 13:13:13 -0700 | [diff] [blame] | 3 | * Copyright (c) 2003-2008 QLogic Corporation |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Andrew Vasquez | fa90c54 | 2005-10-27 11:10:08 -0700 | [diff] [blame] | 5 | * See LICENSE.qla2xxx for copyright and licensing details. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | */ |
| 7 | #include "qla_def.h" |
| 8 | |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 9 | #include <linux/delay.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 10 | #include <linux/slab.h> |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 11 | #include <scsi/scsi_tcq.h> |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 12 | #include <scsi/scsi_bsg_fc.h> |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 13 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | static void qla2x00_mbx_completion(scsi_qla_host_t *, uint16_t); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 15 | static void qla2x00_process_completed_request(struct scsi_qla_host *, |
| 16 | struct req_que *, uint32_t); |
| 17 | static void qla2x00_status_entry(scsi_qla_host_t *, struct rsp_que *, void *); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 18 | static void qla2x00_status_cont_entry(struct rsp_que *, sts_cont_entry_t *); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 19 | static void qla2x00_error_entry(scsi_qla_host_t *, struct rsp_que *, |
| 20 | sts_entry_t *); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 21 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | /** |
| 23 | * qla2100_intr_handler() - Process interrupts for the ISP2100 and ISP2200. |
| 24 | * @irq: |
| 25 | * @dev_id: SCSI driver HA context |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | * |
| 27 | * Called by system whenever the host adapter generates an interrupt. |
| 28 | * |
| 29 | * Returns handled flag. |
| 30 | */ |
| 31 | irqreturn_t |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 32 | qla2100_intr_handler(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 34 | scsi_qla_host_t *vha; |
| 35 | struct qla_hw_data *ha; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 36 | struct device_reg_2xxx __iomem *reg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | unsigned long iter; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 39 | uint16_t hccr; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 40 | uint16_t mb[4]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 41 | struct rsp_que *rsp; |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 42 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 44 | rsp = (struct rsp_que *) dev_id; |
| 45 | if (!rsp) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | printk(KERN_INFO |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 47 | "%s(): NULL response queue pointer\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | return (IRQ_NONE); |
| 49 | } |
| 50 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 51 | ha = rsp->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 52 | reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | status = 0; |
| 54 | |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 55 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 56 | vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | for (iter = 50; iter--; ) { |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 58 | hccr = RD_REG_WORD(®->hccr); |
| 59 | if (hccr & HCCR_RISC_PAUSE) { |
| 60 | if (pci_channel_offline(ha->pdev)) |
| 61 | break; |
| 62 | |
| 63 | /* |
| 64 | * Issue a "HARD" reset in order for the RISC interrupt |
| 65 | * bit to be cleared. Schedule a big hammmer to get |
| 66 | * out of the RISC PAUSED state. |
| 67 | */ |
| 68 | WRT_REG_WORD(®->hccr, HCCR_RESET_RISC); |
| 69 | RD_REG_WORD(®->hccr); |
| 70 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 71 | ha->isp_ops->fw_dump(vha, 1); |
| 72 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 73 | break; |
| 74 | } else if ((RD_REG_WORD(®->istatus) & ISR_RISC_INT) == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | break; |
| 76 | |
| 77 | if (RD_REG_WORD(®->semaphore) & BIT_0) { |
| 78 | WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT); |
| 79 | RD_REG_WORD(®->hccr); |
| 80 | |
| 81 | /* Get mailbox data. */ |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 82 | mb[0] = RD_MAILBOX_REG(ha, reg, 0); |
| 83 | if (mb[0] > 0x3fff && mb[0] < 0x8000) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 84 | qla2x00_mbx_completion(vha, mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | status |= MBX_INTERRUPT; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 86 | } else if (mb[0] > 0x7fff && mb[0] < 0xc000) { |
| 87 | mb[1] = RD_MAILBOX_REG(ha, reg, 1); |
| 88 | mb[2] = RD_MAILBOX_REG(ha, reg, 2); |
| 89 | mb[3] = RD_MAILBOX_REG(ha, reg, 3); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 90 | qla2x00_async_event(vha, rsp, mb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | } else { |
| 92 | /*EMPTY*/ |
| 93 | DEBUG2(printk("scsi(%ld): Unrecognized " |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 94 | "interrupt type (%d).\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 95 | vha->host_no, mb[0])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | } |
| 97 | /* Release mailbox registers. */ |
| 98 | WRT_REG_WORD(®->semaphore, 0); |
| 99 | RD_REG_WORD(®->semaphore); |
| 100 | } else { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 101 | qla2x00_process_response_queue(rsp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | |
| 103 | WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT); |
| 104 | RD_REG_WORD(®->hccr); |
| 105 | } |
| 106 | } |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 107 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) && |
| 110 | (status & MBX_INTERRUPT) && ha->flags.mbox_int) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 112 | complete(&ha->mbx_intr_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | } |
| 114 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | return (IRQ_HANDLED); |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * qla2300_intr_handler() - Process interrupts for the ISP23xx and ISP63xx. |
| 120 | * @irq: |
| 121 | * @dev_id: SCSI driver HA context |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | * |
| 123 | * Called by system whenever the host adapter generates an interrupt. |
| 124 | * |
| 125 | * Returns handled flag. |
| 126 | */ |
| 127 | irqreturn_t |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 128 | qla2300_intr_handler(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 130 | scsi_qla_host_t *vha; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 131 | struct device_reg_2xxx __iomem *reg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | unsigned long iter; |
| 134 | uint32_t stat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | uint16_t hccr; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 136 | uint16_t mb[4]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 137 | struct rsp_que *rsp; |
| 138 | struct qla_hw_data *ha; |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 139 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 141 | rsp = (struct rsp_que *) dev_id; |
| 142 | if (!rsp) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | printk(KERN_INFO |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 144 | "%s(): NULL response queue pointer\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | return (IRQ_NONE); |
| 146 | } |
| 147 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 148 | ha = rsp->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 149 | reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | status = 0; |
| 151 | |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 152 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 153 | vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | for (iter = 50; iter--; ) { |
| 155 | stat = RD_REG_DWORD(®->u.isp2300.host_status); |
| 156 | if (stat & HSR_RISC_PAUSED) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 157 | if (unlikely(pci_channel_offline(ha->pdev))) |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 158 | break; |
| 159 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | hccr = RD_REG_WORD(®->hccr); |
| 161 | if (hccr & (BIT_15 | BIT_13 | BIT_11 | BIT_8)) |
Andrew Vasquez | 07f3180 | 2006-12-13 19:20:31 -0800 | [diff] [blame] | 162 | qla_printk(KERN_INFO, ha, "Parity error -- " |
| 163 | "HCCR=%x, Dumping firmware!\n", hccr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | else |
Andrew Vasquez | 07f3180 | 2006-12-13 19:20:31 -0800 | [diff] [blame] | 165 | qla_printk(KERN_INFO, ha, "RISC paused -- " |
| 166 | "HCCR=%x, Dumping firmware!\n", hccr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | |
| 168 | /* |
| 169 | * Issue a "HARD" reset in order for the RISC |
| 170 | * interrupt bit to be cleared. Schedule a big |
| 171 | * hammmer to get out of the RISC PAUSED state. |
| 172 | */ |
| 173 | WRT_REG_WORD(®->hccr, HCCR_RESET_RISC); |
| 174 | RD_REG_WORD(®->hccr); |
Andrew Vasquez | 07f3180 | 2006-12-13 19:20:31 -0800 | [diff] [blame] | 175 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 176 | ha->isp_ops->fw_dump(vha, 1); |
| 177 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | break; |
| 179 | } else if ((stat & HSR_RISC_INT) == 0) |
| 180 | break; |
| 181 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | switch (stat & 0xff) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | case 0x1: |
| 184 | case 0x2: |
| 185 | case 0x10: |
| 186 | case 0x11: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 187 | qla2x00_mbx_completion(vha, MSW(stat)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | status |= MBX_INTERRUPT; |
| 189 | |
| 190 | /* Release mailbox registers. */ |
| 191 | WRT_REG_WORD(®->semaphore, 0); |
| 192 | break; |
| 193 | case 0x12: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 194 | mb[0] = MSW(stat); |
| 195 | mb[1] = RD_MAILBOX_REG(ha, reg, 1); |
| 196 | mb[2] = RD_MAILBOX_REG(ha, reg, 2); |
| 197 | mb[3] = RD_MAILBOX_REG(ha, reg, 3); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 198 | qla2x00_async_event(vha, rsp, mb); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 199 | break; |
| 200 | case 0x13: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 201 | qla2x00_process_response_queue(rsp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | break; |
| 203 | case 0x15: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 204 | mb[0] = MBA_CMPLT_1_16BIT; |
| 205 | mb[1] = MSW(stat); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 206 | qla2x00_async_event(vha, rsp, mb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | break; |
| 208 | case 0x16: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 209 | mb[0] = MBA_SCSI_COMPLETION; |
| 210 | mb[1] = MSW(stat); |
| 211 | mb[2] = RD_MAILBOX_REG(ha, reg, 2); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 212 | qla2x00_async_event(vha, rsp, mb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | break; |
| 214 | default: |
| 215 | DEBUG2(printk("scsi(%ld): Unrecognized interrupt type " |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 216 | "(%d).\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 217 | vha->host_no, stat & 0xff)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | break; |
| 219 | } |
| 220 | WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT); |
| 221 | RD_REG_WORD_RELAXED(®->hccr); |
| 222 | } |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 223 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) && |
| 226 | (status & MBX_INTERRUPT) && ha->flags.mbox_int) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 228 | complete(&ha->mbx_intr_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | } |
| 230 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | return (IRQ_HANDLED); |
| 232 | } |
| 233 | |
| 234 | /** |
| 235 | * qla2x00_mbx_completion() - Process mailbox command completions. |
| 236 | * @ha: SCSI driver HA context |
| 237 | * @mb0: Mailbox0 register |
| 238 | */ |
| 239 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 240 | qla2x00_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | { |
| 242 | uint16_t cnt; |
| 243 | uint16_t __iomem *wptr; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 244 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 245 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | |
| 247 | /* Load return mailbox registers. */ |
| 248 | ha->flags.mbox_int = 1; |
| 249 | ha->mailbox_out[0] = mb0; |
| 250 | wptr = (uint16_t __iomem *)MAILBOX_REG(ha, reg, 1); |
| 251 | |
| 252 | for (cnt = 1; cnt < ha->mbx_count; cnt++) { |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 253 | if (IS_QLA2200(ha) && cnt == 8) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | wptr = (uint16_t __iomem *)MAILBOX_REG(ha, reg, 8); |
| 255 | if (cnt == 4 || cnt == 5) |
| 256 | ha->mailbox_out[cnt] = qla2x00_debounce_register(wptr); |
| 257 | else |
| 258 | ha->mailbox_out[cnt] = RD_REG_WORD(wptr); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 259 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | wptr++; |
| 261 | } |
| 262 | |
| 263 | if (ha->mcp) { |
| 264 | DEBUG3(printk("%s(%ld): Got mailbox completion. cmd=%x.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 265 | __func__, vha->host_no, ha->mcp->mb[0])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | } else { |
| 267 | DEBUG2_3(printk("%s(%ld): MBX pointer ERROR!\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 268 | __func__, vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | } |
| 270 | } |
| 271 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 272 | static void |
| 273 | qla81xx_idc_event(scsi_qla_host_t *vha, uint16_t aen, uint16_t descr) |
| 274 | { |
| 275 | static char *event[] = |
| 276 | { "Complete", "Request Notification", "Time Extension" }; |
| 277 | int rval; |
| 278 | struct device_reg_24xx __iomem *reg24 = &vha->hw->iobase->isp24; |
| 279 | uint16_t __iomem *wptr; |
| 280 | uint16_t cnt, timeout, mb[QLA_IDC_ACK_REGS]; |
| 281 | |
| 282 | /* Seed data -- mailbox1 -> mailbox7. */ |
| 283 | wptr = (uint16_t __iomem *)®24->mailbox1; |
| 284 | for (cnt = 0; cnt < QLA_IDC_ACK_REGS; cnt++, wptr++) |
| 285 | mb[cnt] = RD_REG_WORD(wptr); |
| 286 | |
| 287 | DEBUG2(printk("scsi(%ld): Inter-Driver Commucation %s -- " |
| 288 | "%04x %04x %04x %04x %04x %04x %04x.\n", vha->host_no, |
| 289 | event[aen & 0xff], |
| 290 | mb[0], mb[1], mb[2], mb[3], mb[4], mb[5], mb[6])); |
| 291 | |
| 292 | /* Acknowledgement needed? [Notify && non-zero timeout]. */ |
| 293 | timeout = (descr >> 8) & 0xf; |
| 294 | if (aen != MBA_IDC_NOTIFY || !timeout) |
| 295 | return; |
| 296 | |
| 297 | DEBUG2(printk("scsi(%ld): Inter-Driver Commucation %s -- " |
| 298 | "ACK timeout=%d.\n", vha->host_no, event[aen & 0xff], timeout)); |
| 299 | |
| 300 | rval = qla2x00_post_idc_ack_work(vha, mb); |
| 301 | if (rval != QLA_SUCCESS) |
| 302 | qla_printk(KERN_WARNING, vha->hw, |
| 303 | "IDC failed to post ACK.\n"); |
| 304 | } |
| 305 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | /** |
| 307 | * qla2x00_async_event() - Process aynchronous events. |
| 308 | * @ha: SCSI driver HA context |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 309 | * @mb: Mailbox registers (0 - 3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 311 | void |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 312 | qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que *rsp, uint16_t *mb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 314 | #define LS_UNKNOWN 2 |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 315 | static char *link_speeds[] = { "1", "2", "?", "4", "8", "10" }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | char *link_speed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | uint16_t handle_cnt; |
Andrew Vasquez | bdab23d | 2009-10-13 15:16:46 -0700 | [diff] [blame] | 318 | uint16_t cnt, mbx; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | uint32_t handles[5]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 320 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 321 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Andrew Vasquez | bdab23d | 2009-10-13 15:16:46 -0700 | [diff] [blame] | 322 | struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | uint32_t rscn_entry, host_pid; |
| 324 | uint8_t rscn_queue_index; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 325 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | |
| 327 | /* Setup to process RIO completion. */ |
| 328 | handle_cnt = 0; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 329 | if (IS_QLA8XXX_TYPE(ha)) |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 330 | goto skip_rio; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | switch (mb[0]) { |
| 332 | case MBA_SCSI_COMPLETION: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 333 | handles[0] = le32_to_cpu((uint32_t)((mb[2] << 16) | mb[1])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | handle_cnt = 1; |
| 335 | break; |
| 336 | case MBA_CMPLT_1_16BIT: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 337 | handles[0] = mb[1]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | handle_cnt = 1; |
| 339 | mb[0] = MBA_SCSI_COMPLETION; |
| 340 | break; |
| 341 | case MBA_CMPLT_2_16BIT: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 342 | handles[0] = mb[1]; |
| 343 | handles[1] = mb[2]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | handle_cnt = 2; |
| 345 | mb[0] = MBA_SCSI_COMPLETION; |
| 346 | break; |
| 347 | case MBA_CMPLT_3_16BIT: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 348 | handles[0] = mb[1]; |
| 349 | handles[1] = mb[2]; |
| 350 | handles[2] = mb[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | handle_cnt = 3; |
| 352 | mb[0] = MBA_SCSI_COMPLETION; |
| 353 | break; |
| 354 | case MBA_CMPLT_4_16BIT: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 355 | handles[0] = mb[1]; |
| 356 | handles[1] = mb[2]; |
| 357 | handles[2] = mb[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | handles[3] = (uint32_t)RD_MAILBOX_REG(ha, reg, 6); |
| 359 | handle_cnt = 4; |
| 360 | mb[0] = MBA_SCSI_COMPLETION; |
| 361 | break; |
| 362 | case MBA_CMPLT_5_16BIT: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 363 | handles[0] = mb[1]; |
| 364 | handles[1] = mb[2]; |
| 365 | handles[2] = mb[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | handles[3] = (uint32_t)RD_MAILBOX_REG(ha, reg, 6); |
| 367 | handles[4] = (uint32_t)RD_MAILBOX_REG(ha, reg, 7); |
| 368 | handle_cnt = 5; |
| 369 | mb[0] = MBA_SCSI_COMPLETION; |
| 370 | break; |
| 371 | case MBA_CMPLT_2_32BIT: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 372 | handles[0] = le32_to_cpu((uint32_t)((mb[2] << 16) | mb[1])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | handles[1] = le32_to_cpu( |
| 374 | ((uint32_t)(RD_MAILBOX_REG(ha, reg, 7) << 16)) | |
| 375 | RD_MAILBOX_REG(ha, reg, 6)); |
| 376 | handle_cnt = 2; |
| 377 | mb[0] = MBA_SCSI_COMPLETION; |
| 378 | break; |
| 379 | default: |
| 380 | break; |
| 381 | } |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 382 | skip_rio: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | switch (mb[0]) { |
| 384 | case MBA_SCSI_COMPLETION: /* Fast Post */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 385 | if (!vha->flags.online) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | break; |
| 387 | |
| 388 | for (cnt = 0; cnt < handle_cnt; cnt++) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 389 | qla2x00_process_completed_request(vha, rsp->req, |
| 390 | handles[cnt]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | break; |
| 392 | |
| 393 | case MBA_RESET: /* Reset */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 394 | DEBUG2(printk("scsi(%ld): Asynchronous RESET.\n", |
| 395 | vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 397 | set_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | break; |
| 399 | |
| 400 | case MBA_SYSTEM_ERR: /* System Error */ |
Andrew Vasquez | bdab23d | 2009-10-13 15:16:46 -0700 | [diff] [blame] | 401 | mbx = IS_QLA81XX(ha) ? RD_REG_WORD(®24->mailbox7) : 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | qla_printk(KERN_INFO, ha, |
Andrew Vasquez | bdab23d | 2009-10-13 15:16:46 -0700 | [diff] [blame] | 403 | "ISP System Error - mbx1=%xh mbx2=%xh mbx3=%xh " |
| 404 | "mbx7=%xh.\n", mb[1], mb[2], mb[3], mbx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 406 | ha->isp_ops->fw_dump(vha, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 408 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 409 | if (mb[1] == 0 && mb[2] == 0) { |
| 410 | qla_printk(KERN_ERR, ha, |
| 411 | "Unrecoverable Hardware Error: adapter " |
| 412 | "marked OFFLINE!\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 413 | vha->flags.online = 0; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 414 | } else |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 415 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 416 | } else if (mb[1] == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | qla_printk(KERN_INFO, ha, |
| 418 | "Unrecoverable Hardware Error: adapter marked " |
| 419 | "OFFLINE!\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 420 | vha->flags.online = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | } else |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 422 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | break; |
| 424 | |
| 425 | case MBA_REQ_TRANSFER_ERR: /* Request Transfer Error */ |
Andrew Vasquez | bdab23d | 2009-10-13 15:16:46 -0700 | [diff] [blame] | 426 | DEBUG2(printk("scsi(%ld): ISP Request Transfer Error (%x).\n", |
| 427 | vha->host_no, mb[1])); |
| 428 | qla_printk(KERN_WARNING, ha, |
| 429 | "ISP Request Transfer Error (%x).\n", mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 431 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | break; |
| 433 | |
| 434 | case MBA_RSP_TRANSFER_ERR: /* Response Transfer Error */ |
| 435 | DEBUG2(printk("scsi(%ld): ISP Response Transfer Error.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 436 | vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | qla_printk(KERN_WARNING, ha, "ISP Response Transfer Error.\n"); |
| 438 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 439 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | break; |
| 441 | |
| 442 | case MBA_WAKEUP_THRES: /* Request Queue Wake-up */ |
| 443 | DEBUG2(printk("scsi(%ld): Asynchronous WAKEUP_THRES.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 444 | vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | break; |
| 446 | |
| 447 | case MBA_LIP_OCCURRED: /* Loop Initialization Procedure */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 448 | DEBUG2(printk("scsi(%ld): LIP occurred (%x).\n", vha->host_no, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | mb[1])); |
Bjorn Helgaas | cc3ef7b | 2008-09-11 21:22:51 -0700 | [diff] [blame] | 450 | qla_printk(KERN_INFO, ha, "LIP occurred (%x).\n", mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 452 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 453 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 454 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 455 | qla2x00_mark_all_devices_lost(vha, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | } |
| 457 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 458 | if (vha->vp_idx) { |
| 459 | atomic_set(&vha->vp_state, VP_FAILED); |
| 460 | fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 461 | } |
| 462 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 463 | set_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags); |
| 464 | set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 466 | vha->flags.management_server_logged_in = 0; |
| 467 | qla2x00_post_aen_work(vha, FCH_EVT_LIP, mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | break; |
| 469 | |
| 470 | case MBA_LOOP_UP: /* Loop Up Event */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
| 472 | link_speed = link_speeds[0]; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 473 | ha->link_data_rate = PORT_SPEED_1GB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | } else { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 475 | link_speed = link_speeds[LS_UNKNOWN]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | if (mb[1] < 5) |
| 477 | link_speed = link_speeds[mb[1]]; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 478 | else if (mb[1] == 0x13) |
| 479 | link_speed = link_speeds[5]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | ha->link_data_rate = mb[1]; |
| 481 | } |
| 482 | |
| 483 | DEBUG2(printk("scsi(%ld): Asynchronous LOOP UP (%s Gbps).\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 484 | vha->host_no, link_speed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | qla_printk(KERN_INFO, ha, "LOOP UP detected (%s Gbps).\n", |
| 486 | link_speed); |
| 487 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 488 | vha->flags.management_server_logged_in = 0; |
| 489 | qla2x00_post_aen_work(vha, FCH_EVT_LINKUP, ha->link_data_rate); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | break; |
| 491 | |
| 492 | case MBA_LOOP_DOWN: /* Loop Down Event */ |
Andrew Vasquez | bdab23d | 2009-10-13 15:16:46 -0700 | [diff] [blame] | 493 | mbx = IS_QLA81XX(ha) ? RD_REG_WORD(®24->mailbox4) : 0; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 494 | DEBUG2(printk("scsi(%ld): Asynchronous LOOP DOWN " |
Andrew Vasquez | bdab23d | 2009-10-13 15:16:46 -0700 | [diff] [blame] | 495 | "(%x %x %x %x).\n", vha->host_no, mb[1], mb[2], mb[3], |
| 496 | mbx)); |
| 497 | qla_printk(KERN_INFO, ha, |
| 498 | "LOOP DOWN detected (%x %x %x %x).\n", mb[1], mb[2], mb[3], |
| 499 | mbx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 501 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 502 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 503 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 504 | vha->device_flags |= DFLG_NO_CABLE; |
| 505 | qla2x00_mark_all_devices_lost(vha, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | } |
| 507 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 508 | if (vha->vp_idx) { |
| 509 | atomic_set(&vha->vp_state, VP_FAILED); |
| 510 | fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 511 | } |
| 512 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 513 | vha->flags.management_server_logged_in = 0; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 514 | ha->link_data_rate = PORT_SPEED_UNKNOWN; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 515 | qla2x00_post_aen_work(vha, FCH_EVT_LINKDOWN, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 516 | break; |
| 517 | |
| 518 | case MBA_LIP_RESET: /* LIP reset occurred */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | DEBUG2(printk("scsi(%ld): Asynchronous LIP RESET (%x).\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 520 | vha->host_no, mb[1])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | qla_printk(KERN_INFO, ha, |
Bjorn Helgaas | cc3ef7b | 2008-09-11 21:22:51 -0700 | [diff] [blame] | 522 | "LIP reset occurred (%x).\n", mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 524 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 525 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 526 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 527 | qla2x00_mark_all_devices_lost(vha, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | } |
| 529 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 530 | if (vha->vp_idx) { |
| 531 | atomic_set(&vha->vp_state, VP_FAILED); |
| 532 | fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 533 | } |
| 534 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 535 | set_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | |
| 537 | ha->operating_mode = LOOP; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 538 | vha->flags.management_server_logged_in = 0; |
| 539 | qla2x00_post_aen_work(vha, FCH_EVT_LIPRESET, mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | break; |
| 541 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 542 | /* case MBA_DCBX_COMPLETE: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | case MBA_POINT_TO_POINT: /* Point-to-Point */ |
| 544 | if (IS_QLA2100(ha)) |
| 545 | break; |
| 546 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 547 | if (IS_QLA8XXX_TYPE(ha)) |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 548 | DEBUG2(printk("scsi(%ld): DCBX Completed -- %04x %04x " |
| 549 | "%04x\n", vha->host_no, mb[1], mb[2], mb[3])); |
| 550 | else |
| 551 | DEBUG2(printk("scsi(%ld): Asynchronous P2P MODE " |
| 552 | "received.\n", vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | |
| 554 | /* |
| 555 | * Until there's a transition from loop down to loop up, treat |
| 556 | * this as loop down only. |
| 557 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 558 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 559 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 560 | if (!atomic_read(&vha->loop_down_timer)) |
| 561 | atomic_set(&vha->loop_down_timer, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | LOOP_DOWN_TIME); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 563 | qla2x00_mark_all_devices_lost(vha, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 564 | } |
| 565 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 566 | if (vha->vp_idx) { |
| 567 | atomic_set(&vha->vp_state, VP_FAILED); |
| 568 | fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 569 | } |
| 570 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 571 | if (!(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))) |
| 572 | set_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
| 573 | |
| 574 | set_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags); |
| 575 | set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | 4346b14 | 2006-12-13 19:20:28 -0800 | [diff] [blame] | 576 | |
| 577 | ha->flags.gpsc_supported = 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 578 | vha->flags.management_server_logged_in = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | break; |
| 580 | |
| 581 | case MBA_CHG_IN_CONNECTION: /* Change in connection mode */ |
| 582 | if (IS_QLA2100(ha)) |
| 583 | break; |
| 584 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | DEBUG2(printk("scsi(%ld): Asynchronous Change In Connection " |
| 586 | "received.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 587 | vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 588 | qla_printk(KERN_INFO, ha, |
| 589 | "Configuration change detected: value=%x.\n", mb[1]); |
| 590 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 591 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 592 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 593 | if (!atomic_read(&vha->loop_down_timer)) |
| 594 | atomic_set(&vha->loop_down_timer, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | LOOP_DOWN_TIME); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 596 | qla2x00_mark_all_devices_lost(vha, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | } |
| 598 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 599 | if (vha->vp_idx) { |
| 600 | atomic_set(&vha->vp_state, VP_FAILED); |
| 601 | fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 602 | } |
| 603 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 604 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 605 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | break; |
| 607 | |
| 608 | case MBA_PORT_UPDATE: /* Port database update */ |
Santosh Vernekar | 55903b9 | 2009-07-31 15:09:25 -0700 | [diff] [blame] | 609 | /* |
| 610 | * Handle only global and vn-port update events |
| 611 | * |
| 612 | * Relevant inputs: |
| 613 | * mb[1] = N_Port handle of changed port |
| 614 | * OR 0xffff for global event |
| 615 | * mb[2] = New login state |
| 616 | * 7 = Port logged out |
| 617 | * mb[3] = LSB is vp_idx, 0xff = all vps |
| 618 | * |
| 619 | * Skip processing if: |
| 620 | * Event is global, vp_idx is NOT all vps, |
| 621 | * vp_idx does not match |
| 622 | * Event is not global, vp_idx does not match |
| 623 | */ |
Andrew Vasquez | 12cec63e4 | 2010-03-19 16:59:17 -0700 | [diff] [blame] | 624 | if (IS_QLA2XXX_MIDTYPE(ha) && |
| 625 | ((mb[1] == 0xffff && (mb[3] & 0xff) != 0xff) || |
| 626 | (mb[1] != 0xffff)) && vha->vp_idx != (mb[3] & 0xff)) |
| 627 | break; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 628 | |
Andrew Vasquez | 9764ff8 | 2009-07-31 15:09:24 -0700 | [diff] [blame] | 629 | /* Global event -- port logout or port unavailable. */ |
| 630 | if (mb[1] == 0xffff && mb[2] == 0x7) { |
| 631 | DEBUG2(printk("scsi(%ld): Asynchronous PORT UPDATE.\n", |
| 632 | vha->host_no)); |
| 633 | DEBUG(printk(KERN_INFO |
| 634 | "scsi(%ld): Port unavailable %04x %04x %04x.\n", |
| 635 | vha->host_no, mb[1], mb[2], mb[3])); |
| 636 | |
| 637 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 638 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 639 | atomic_set(&vha->loop_down_timer, |
| 640 | LOOP_DOWN_TIME); |
| 641 | vha->device_flags |= DFLG_NO_CABLE; |
| 642 | qla2x00_mark_all_devices_lost(vha, 1); |
| 643 | } |
| 644 | |
| 645 | if (vha->vp_idx) { |
| 646 | atomic_set(&vha->vp_state, VP_FAILED); |
| 647 | fc_vport_set_state(vha->fc_vport, |
| 648 | FC_VPORT_FAILED); |
Santosh Vernekar | faadc5e | 2009-07-31 15:09:26 -0700 | [diff] [blame] | 649 | qla2x00_mark_all_devices_lost(vha, 1); |
Andrew Vasquez | 9764ff8 | 2009-07-31 15:09:24 -0700 | [diff] [blame] | 650 | } |
| 651 | |
| 652 | vha->flags.management_server_logged_in = 0; |
| 653 | ha->link_data_rate = PORT_SPEED_UNKNOWN; |
| 654 | break; |
| 655 | } |
| 656 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 657 | /* |
Bjorn Helgaas | cc3ef7b | 2008-09-11 21:22:51 -0700 | [diff] [blame] | 658 | * If PORT UPDATE is global (received LIP_OCCURRED/LIP_RESET |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | * event etc. earlier indicating loop is down) then process |
| 660 | * it. Otherwise ignore it and Wait for RSCN to come in. |
| 661 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 662 | atomic_set(&vha->loop_down_timer, 0); |
| 663 | if (atomic_read(&vha->loop_state) != LOOP_DOWN && |
| 664 | atomic_read(&vha->loop_state) != LOOP_DEAD) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | DEBUG2(printk("scsi(%ld): Asynchronous PORT UPDATE " |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 666 | "ignored %04x/%04x/%04x.\n", vha->host_no, mb[1], |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 667 | mb[2], mb[3])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | break; |
| 669 | } |
| 670 | |
| 671 | DEBUG2(printk("scsi(%ld): Asynchronous PORT UPDATE.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 672 | vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | DEBUG(printk(KERN_INFO |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 674 | "scsi(%ld): Port database changed %04x %04x %04x.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 675 | vha->host_no, mb[1], mb[2], mb[3])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 676 | |
| 677 | /* |
| 678 | * Mark all devices as missing so we will login again. |
| 679 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 680 | atomic_set(&vha->loop_state, LOOP_UP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 682 | qla2x00_mark_all_devices_lost(vha, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 684 | vha->flags.rscn_queue_overflow = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 686 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 687 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 688 | break; |
| 689 | |
| 690 | case MBA_RSCN_UPDATE: /* State Change Registration */ |
Seokmann Ju | 3c39740 | 2008-05-19 14:25:39 -0700 | [diff] [blame] | 691 | /* Check if the Vport has issued a SCR */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 692 | if (vha->vp_idx && test_bit(VP_SCR_NEEDED, &vha->vp_flags)) |
Seokmann Ju | 3c39740 | 2008-05-19 14:25:39 -0700 | [diff] [blame] | 693 | break; |
| 694 | /* Only handle SCNs for our Vport index. */ |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 695 | if (ha->flags.npiv_supported && vha->vp_idx != (mb[3] & 0xff)) |
Seokmann Ju | 3c39740 | 2008-05-19 14:25:39 -0700 | [diff] [blame] | 696 | break; |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 697 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 698 | DEBUG2(printk("scsi(%ld): Asynchronous RSCR UPDATE.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 699 | vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | DEBUG(printk(KERN_INFO |
Shyam Sundar | f4a8dbc | 2007-11-12 10:30:59 -0800 | [diff] [blame] | 701 | "scsi(%ld): RSCN database changed -- %04x %04x %04x.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 702 | vha->host_no, mb[1], mb[2], mb[3])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 703 | |
Ravi Anand | 59d72d8 | 2008-09-11 21:22:53 -0700 | [diff] [blame] | 704 | rscn_entry = ((mb[1] & 0xff) << 16) | mb[2]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 705 | host_pid = (vha->d_id.b.domain << 16) | (vha->d_id.b.area << 8) |
| 706 | | vha->d_id.b.al_pa; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | if (rscn_entry == host_pid) { |
| 708 | DEBUG(printk(KERN_INFO |
| 709 | "scsi(%ld): Ignoring RSCN update to local host " |
| 710 | "port ID (%06x)\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 711 | vha->host_no, host_pid)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 712 | break; |
| 713 | } |
| 714 | |
Ravi Anand | 59d72d8 | 2008-09-11 21:22:53 -0700 | [diff] [blame] | 715 | /* Ignore reserved bits from RSCN-payload. */ |
| 716 | rscn_entry = ((mb[1] & 0x3ff) << 16) | mb[2]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 717 | rscn_queue_index = vha->rscn_in_ptr + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 718 | if (rscn_queue_index == MAX_RSCN_COUNT) |
| 719 | rscn_queue_index = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 720 | if (rscn_queue_index != vha->rscn_out_ptr) { |
| 721 | vha->rscn_queue[vha->rscn_in_ptr] = rscn_entry; |
| 722 | vha->rscn_in_ptr = rscn_queue_index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 723 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 724 | vha->flags.rscn_queue_overflow = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 725 | } |
| 726 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 727 | atomic_set(&vha->loop_state, LOOP_UPDATE); |
| 728 | atomic_set(&vha->loop_down_timer, 0); |
| 729 | vha->flags.management_server_logged_in = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 730 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 731 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 732 | set_bit(RSCN_UPDATE, &vha->dpc_flags); |
| 733 | qla2x00_post_aen_work(vha, FCH_EVT_RSCN, rscn_entry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 734 | break; |
| 735 | |
| 736 | /* case MBA_RIO_RESPONSE: */ |
| 737 | case MBA_ZIO_RESPONSE: |
Andrew Vasquez | 3fd67cd | 2009-01-05 11:18:07 -0800 | [diff] [blame] | 738 | DEBUG3(printk("scsi(%ld): [R|Z]IO update completion.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 739 | vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 740 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 741 | if (IS_FWI2_CAPABLE(ha)) |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 742 | qla24xx_process_response_queue(vha, rsp); |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 743 | else |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 744 | qla2x00_process_response_queue(rsp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 745 | break; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 746 | |
| 747 | case MBA_DISCARD_RND_FRAME: |
| 748 | DEBUG2(printk("scsi(%ld): Discard RND Frame -- %04x %04x " |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 749 | "%04x.\n", vha->host_no, mb[1], mb[2], mb[3])); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 750 | break; |
Andrew Vasquez | 45ebeb5 | 2006-08-01 13:48:14 -0700 | [diff] [blame] | 751 | |
| 752 | case MBA_TRACE_NOTIFICATION: |
| 753 | DEBUG2(printk("scsi(%ld): Trace Notification -- %04x %04x.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 754 | vha->host_no, mb[1], mb[2])); |
Andrew Vasquez | 45ebeb5 | 2006-08-01 13:48:14 -0700 | [diff] [blame] | 755 | break; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 756 | |
| 757 | case MBA_ISP84XX_ALERT: |
| 758 | DEBUG2(printk("scsi(%ld): ISP84XX Alert Notification -- " |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 759 | "%04x %04x %04x\n", vha->host_no, mb[1], mb[2], mb[3])); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 760 | |
| 761 | spin_lock_irqsave(&ha->cs84xx->access_lock, flags); |
| 762 | switch (mb[1]) { |
| 763 | case A84_PANIC_RECOVERY: |
| 764 | qla_printk(KERN_INFO, ha, "Alert 84XX: panic recovery " |
| 765 | "%04x %04x\n", mb[2], mb[3]); |
| 766 | break; |
| 767 | case A84_OP_LOGIN_COMPLETE: |
| 768 | ha->cs84xx->op_fw_version = mb[3] << 16 | mb[2]; |
| 769 | DEBUG2(qla_printk(KERN_INFO, ha, "Alert 84XX:" |
| 770 | "firmware version %x\n", ha->cs84xx->op_fw_version)); |
| 771 | break; |
| 772 | case A84_DIAG_LOGIN_COMPLETE: |
| 773 | ha->cs84xx->diag_fw_version = mb[3] << 16 | mb[2]; |
| 774 | DEBUG2(qla_printk(KERN_INFO, ha, "Alert 84XX:" |
| 775 | "diagnostic firmware version %x\n", |
| 776 | ha->cs84xx->diag_fw_version)); |
| 777 | break; |
| 778 | case A84_GOLD_LOGIN_COMPLETE: |
| 779 | ha->cs84xx->diag_fw_version = mb[3] << 16 | mb[2]; |
| 780 | ha->cs84xx->fw_update = 1; |
| 781 | DEBUG2(qla_printk(KERN_INFO, ha, "Alert 84XX: gold " |
| 782 | "firmware version %x\n", |
| 783 | ha->cs84xx->gold_fw_version)); |
| 784 | break; |
| 785 | default: |
| 786 | qla_printk(KERN_ERR, ha, |
| 787 | "Alert 84xx: Invalid Alert %04x %04x %04x\n", |
| 788 | mb[1], mb[2], mb[3]); |
| 789 | } |
| 790 | spin_unlock_irqrestore(&ha->cs84xx->access_lock, flags); |
| 791 | break; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 792 | case MBA_DCBX_START: |
| 793 | DEBUG2(printk("scsi(%ld): DCBX Started -- %04x %04x %04x\n", |
| 794 | vha->host_no, mb[1], mb[2], mb[3])); |
| 795 | break; |
| 796 | case MBA_DCBX_PARAM_UPDATE: |
| 797 | DEBUG2(printk("scsi(%ld): DCBX Parameters Updated -- " |
| 798 | "%04x %04x %04x\n", vha->host_no, mb[1], mb[2], mb[3])); |
| 799 | break; |
| 800 | case MBA_FCF_CONF_ERR: |
| 801 | DEBUG2(printk("scsi(%ld): FCF Configuration Error -- " |
| 802 | "%04x %04x %04x\n", vha->host_no, mb[1], mb[2], mb[3])); |
| 803 | break; |
| 804 | case MBA_IDC_COMPLETE: |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 805 | case MBA_IDC_NOTIFY: |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 806 | case MBA_IDC_TIME_EXT: |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 807 | qla81xx_idc_event(vha, mb[0], mb[1]); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 808 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 809 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 810 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 811 | if (!vha->vp_idx && ha->num_vhosts) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 812 | qla2x00_alert_all_vps(rsp, mb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 813 | } |
| 814 | |
| 815 | /** |
| 816 | * qla2x00_process_completed_request() - Process a Fast Post response. |
| 817 | * @ha: SCSI driver HA context |
| 818 | * @index: SRB index |
| 819 | */ |
| 820 | static void |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 821 | qla2x00_process_completed_request(struct scsi_qla_host *vha, |
| 822 | struct req_que *req, uint32_t index) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 823 | { |
| 824 | srb_t *sp; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 825 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 826 | |
| 827 | /* Validate handle. */ |
| 828 | if (index >= MAX_OUTSTANDING_COMMANDS) { |
| 829 | DEBUG2(printk("scsi(%ld): Invalid SCSI completion handle %d.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 830 | vha->host_no, index)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 831 | qla_printk(KERN_WARNING, ha, |
| 832 | "Invalid SCSI completion handle %d.\n", index); |
| 833 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 834 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 835 | return; |
| 836 | } |
| 837 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 838 | sp = req->outstanding_cmds[index]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 839 | if (sp) { |
| 840 | /* Free outstanding command slot. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 841 | req->outstanding_cmds[index] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 842 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 843 | /* Save ISP completion status */ |
| 844 | sp->cmd->result = DID_OK << 16; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 845 | qla2x00_sp_compl(ha, sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 846 | } else { |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 847 | DEBUG2(printk("scsi(%ld) Req:%d: Invalid ISP SCSI completion" |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 848 | " handle(0x%x)\n", vha->host_no, req->id, index)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 849 | qla_printk(KERN_WARNING, ha, |
| 850 | "Invalid ISP SCSI completion handle\n"); |
| 851 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 852 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 853 | } |
| 854 | } |
| 855 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 856 | static srb_t * |
| 857 | qla2x00_get_sp_from_handle(scsi_qla_host_t *vha, const char *func, |
| 858 | struct req_que *req, void *iocb) |
| 859 | { |
| 860 | struct qla_hw_data *ha = vha->hw; |
| 861 | sts_entry_t *pkt = iocb; |
| 862 | srb_t *sp = NULL; |
| 863 | uint16_t index; |
| 864 | |
| 865 | index = LSW(pkt->handle); |
| 866 | if (index >= MAX_OUTSTANDING_COMMANDS) { |
| 867 | qla_printk(KERN_WARNING, ha, |
| 868 | "%s: Invalid completion handle (%x).\n", func, index); |
| 869 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 870 | goto done; |
| 871 | } |
| 872 | sp = req->outstanding_cmds[index]; |
| 873 | if (!sp) { |
| 874 | qla_printk(KERN_WARNING, ha, |
| 875 | "%s: Invalid completion handle (%x) -- timed-out.\n", func, |
| 876 | index); |
| 877 | return sp; |
| 878 | } |
| 879 | if (sp->handle != index) { |
| 880 | qla_printk(KERN_WARNING, ha, |
| 881 | "%s: SRB handle (%x) mismatch %x.\n", func, sp->handle, |
| 882 | index); |
| 883 | return NULL; |
| 884 | } |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 885 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 886 | req->outstanding_cmds[index] = NULL; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 887 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 888 | done: |
| 889 | return sp; |
| 890 | } |
| 891 | |
| 892 | static void |
| 893 | qla2x00_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, |
| 894 | struct mbx_entry *mbx) |
| 895 | { |
| 896 | const char func[] = "MBX-IOCB"; |
| 897 | const char *type; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 898 | fc_port_t *fcport; |
| 899 | srb_t *sp; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 900 | struct srb_iocb *lio; |
| 901 | struct srb_ctx *ctx; |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 902 | uint16_t *data; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 903 | uint16_t status; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 904 | |
| 905 | sp = qla2x00_get_sp_from_handle(vha, func, req, mbx); |
| 906 | if (!sp) |
| 907 | return; |
| 908 | |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 909 | ctx = sp->ctx; |
| 910 | lio = ctx->u.iocb_cmd; |
| 911 | type = ctx->name; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 912 | fcport = sp->fcport; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 913 | data = lio->u.logio.data; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 914 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 915 | data[0] = MBS_COMMAND_ERROR; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 916 | data[1] = lio->u.logio.flags & SRB_LOGIN_RETRIED ? |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 917 | QLA_LOGIO_LOGIN_RETRIED : 0; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 918 | if (mbx->entry_status) { |
| 919 | DEBUG2(printk(KERN_WARNING |
| 920 | "scsi(%ld:%x): Async-%s error entry - entry-status=%x " |
| 921 | "status=%x state-flag=%x status-flags=%x.\n", |
| 922 | fcport->vha->host_no, sp->handle, type, |
| 923 | mbx->entry_status, le16_to_cpu(mbx->status), |
| 924 | le16_to_cpu(mbx->state_flags), |
| 925 | le16_to_cpu(mbx->status_flags))); |
| 926 | DEBUG2(qla2x00_dump_buffer((uint8_t *)mbx, sizeof(*mbx))); |
| 927 | |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 928 | goto logio_done; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 929 | } |
| 930 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 931 | status = le16_to_cpu(mbx->status); |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 932 | if (status == 0x30 && ctx->type == SRB_LOGIN_CMD && |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 933 | le16_to_cpu(mbx->mb0) == MBS_COMMAND_COMPLETE) |
| 934 | status = 0; |
| 935 | if (!status && le16_to_cpu(mbx->mb0) == MBS_COMMAND_COMPLETE) { |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 936 | DEBUG2(printk(KERN_DEBUG |
| 937 | "scsi(%ld:%x): Async-%s complete - mbx1=%x.\n", |
| 938 | fcport->vha->host_no, sp->handle, type, |
| 939 | le16_to_cpu(mbx->mb1))); |
| 940 | |
| 941 | data[0] = MBS_COMMAND_COMPLETE; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 942 | if (ctx->type == SRB_LOGIN_CMD) { |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 943 | fcport->port_type = FCT_TARGET; |
| 944 | if (le16_to_cpu(mbx->mb1) & BIT_0) |
| 945 | fcport->port_type = FCT_INITIATOR; |
| 946 | if (le16_to_cpu(mbx->mb1) & BIT_1) |
| 947 | fcport->flags |= FCF_FCP2_DEVICE; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 948 | } |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 949 | goto logio_done; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 950 | } |
| 951 | |
| 952 | data[0] = le16_to_cpu(mbx->mb0); |
| 953 | switch (data[0]) { |
| 954 | case MBS_PORT_ID_USED: |
| 955 | data[1] = le16_to_cpu(mbx->mb1); |
| 956 | break; |
| 957 | case MBS_LOOP_ID_USED: |
| 958 | break; |
| 959 | default: |
| 960 | data[0] = MBS_COMMAND_ERROR; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 961 | break; |
| 962 | } |
| 963 | |
| 964 | DEBUG2(printk(KERN_WARNING |
| 965 | "scsi(%ld:%x): Async-%s failed - status=%x mb0=%x mb1=%x mb2=%x " |
| 966 | "mb6=%x mb7=%x.\n", |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 967 | fcport->vha->host_no, sp->handle, type, status, |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 968 | le16_to_cpu(mbx->mb0), le16_to_cpu(mbx->mb1), |
| 969 | le16_to_cpu(mbx->mb2), le16_to_cpu(mbx->mb6), |
| 970 | le16_to_cpu(mbx->mb7))); |
| 971 | |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 972 | logio_done: |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 973 | lio->done(sp); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 974 | } |
| 975 | |
| 976 | static void |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 977 | qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req, |
| 978 | struct sts_entry_24xx *pkt, int iocb_type) |
| 979 | { |
| 980 | const char func[] = "ELS_CT_IOCB"; |
| 981 | const char *type; |
| 982 | struct qla_hw_data *ha = vha->hw; |
| 983 | srb_t *sp; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 984 | struct srb_ctx *sp_bsg; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 985 | struct fc_bsg_job *bsg_job; |
| 986 | uint16_t comp_status; |
| 987 | uint32_t fw_status[3]; |
| 988 | uint8_t* fw_sts_ptr; |
| 989 | |
| 990 | sp = qla2x00_get_sp_from_handle(vha, func, req, pkt); |
| 991 | if (!sp) |
| 992 | return; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 993 | sp_bsg = sp->ctx; |
| 994 | bsg_job = sp_bsg->u.bsg_job; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 995 | |
| 996 | type = NULL; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 997 | switch (sp_bsg->type) { |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 998 | case SRB_ELS_CMD_RPT: |
| 999 | case SRB_ELS_CMD_HST: |
| 1000 | type = "els"; |
| 1001 | break; |
| 1002 | case SRB_CT_CMD: |
| 1003 | type = "ct pass-through"; |
| 1004 | break; |
| 1005 | default: |
| 1006 | qla_printk(KERN_WARNING, ha, |
| 1007 | "%s: Unrecognized SRB: (%p) type=%d.\n", func, sp, |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 1008 | sp_bsg->type); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1009 | return; |
| 1010 | } |
| 1011 | |
| 1012 | comp_status = fw_status[0] = le16_to_cpu(pkt->comp_status); |
| 1013 | fw_status[1] = le16_to_cpu(((struct els_sts_entry_24xx*)pkt)->error_subcode_1); |
| 1014 | fw_status[2] = le16_to_cpu(((struct els_sts_entry_24xx*)pkt)->error_subcode_2); |
| 1015 | |
| 1016 | /* return FC_CTELS_STATUS_OK and leave the decoding of the ELS/CT |
| 1017 | * fc payload to the caller |
| 1018 | */ |
| 1019 | bsg_job->reply->reply_data.ctels_reply.status = FC_CTELS_STATUS_OK; |
| 1020 | bsg_job->reply_len = sizeof(struct fc_bsg_reply) + sizeof(fw_status); |
| 1021 | |
| 1022 | if (comp_status != CS_COMPLETE) { |
| 1023 | if (comp_status == CS_DATA_UNDERRUN) { |
| 1024 | bsg_job->reply->result = DID_OK << 16; |
| 1025 | bsg_job->reply->reply_payload_rcv_len = |
| 1026 | le16_to_cpu(((struct els_sts_entry_24xx*)pkt)->total_byte_count); |
| 1027 | |
| 1028 | DEBUG2(qla_printk(KERN_WARNING, ha, |
| 1029 | "scsi(%ld:0x%x): ELS-CT pass-through-%s error comp_status-status=0x%x " |
| 1030 | "error subcode 1=0x%x error subcode 2=0x%x total_byte = 0x%x.\n", |
| 1031 | vha->host_no, sp->handle, type, comp_status, fw_status[1], fw_status[2], |
| 1032 | le16_to_cpu(((struct els_sts_entry_24xx*)pkt)->total_byte_count))); |
| 1033 | fw_sts_ptr = ((uint8_t*)bsg_job->req->sense) + sizeof(struct fc_bsg_reply); |
| 1034 | memcpy( fw_sts_ptr, fw_status, sizeof(fw_status)); |
| 1035 | } |
| 1036 | else { |
| 1037 | DEBUG2(qla_printk(KERN_WARNING, ha, |
| 1038 | "scsi(%ld:0x%x): ELS-CT pass-through-%s error comp_status-status=0x%x " |
| 1039 | "error subcode 1=0x%x error subcode 2=0x%x.\n", |
| 1040 | vha->host_no, sp->handle, type, comp_status, |
| 1041 | le16_to_cpu(((struct els_sts_entry_24xx*)pkt)->error_subcode_1), |
| 1042 | le16_to_cpu(((struct els_sts_entry_24xx*)pkt)->error_subcode_2))); |
| 1043 | bsg_job->reply->result = DID_ERROR << 16; |
| 1044 | bsg_job->reply->reply_payload_rcv_len = 0; |
| 1045 | fw_sts_ptr = ((uint8_t*)bsg_job->req->sense) + sizeof(struct fc_bsg_reply); |
| 1046 | memcpy( fw_sts_ptr, fw_status, sizeof(fw_status)); |
| 1047 | } |
| 1048 | DEBUG2(qla2x00_dump_buffer((uint8_t *)pkt, sizeof(*pkt))); |
| 1049 | } |
| 1050 | else { |
| 1051 | bsg_job->reply->result = DID_OK << 16;; |
| 1052 | bsg_job->reply->reply_payload_rcv_len = bsg_job->reply_payload.payload_len; |
| 1053 | bsg_job->reply_len = 0; |
| 1054 | } |
| 1055 | |
| 1056 | dma_unmap_sg(&ha->pdev->dev, |
| 1057 | bsg_job->request_payload.sg_list, |
| 1058 | bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE); |
| 1059 | dma_unmap_sg(&ha->pdev->dev, |
| 1060 | bsg_job->reply_payload.sg_list, |
| 1061 | bsg_job->reply_payload.sg_cnt, DMA_FROM_DEVICE); |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 1062 | if ((sp_bsg->type == SRB_ELS_CMD_HST) || |
| 1063 | (sp_bsg->type == SRB_CT_CMD)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1064 | kfree(sp->fcport); |
| 1065 | kfree(sp->ctx); |
| 1066 | mempool_free(sp, ha->srb_mempool); |
| 1067 | bsg_job->job_done(bsg_job); |
| 1068 | } |
| 1069 | |
| 1070 | static void |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1071 | qla24xx_logio_entry(scsi_qla_host_t *vha, struct req_que *req, |
| 1072 | struct logio_entry_24xx *logio) |
| 1073 | { |
| 1074 | const char func[] = "LOGIO-IOCB"; |
| 1075 | const char *type; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1076 | fc_port_t *fcport; |
| 1077 | srb_t *sp; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 1078 | struct srb_iocb *lio; |
| 1079 | struct srb_ctx *ctx; |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 1080 | uint16_t *data; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1081 | uint32_t iop[2]; |
| 1082 | |
| 1083 | sp = qla2x00_get_sp_from_handle(vha, func, req, logio); |
| 1084 | if (!sp) |
| 1085 | return; |
| 1086 | |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 1087 | ctx = sp->ctx; |
| 1088 | lio = ctx->u.iocb_cmd; |
| 1089 | type = ctx->name; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1090 | fcport = sp->fcport; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 1091 | data = lio->u.logio.data; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1092 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 1093 | data[0] = MBS_COMMAND_ERROR; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 1094 | data[1] = lio->u.logio.flags & SRB_LOGIN_RETRIED ? |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 1095 | QLA_LOGIO_LOGIN_RETRIED : 0; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1096 | if (logio->entry_status) { |
| 1097 | DEBUG2(printk(KERN_WARNING |
| 1098 | "scsi(%ld:%x): Async-%s error entry - entry-status=%x.\n", |
| 1099 | fcport->vha->host_no, sp->handle, type, |
| 1100 | logio->entry_status)); |
| 1101 | DEBUG2(qla2x00_dump_buffer((uint8_t *)logio, sizeof(*logio))); |
| 1102 | |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 1103 | goto logio_done; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1104 | } |
| 1105 | |
| 1106 | if (le16_to_cpu(logio->comp_status) == CS_COMPLETE) { |
| 1107 | DEBUG2(printk(KERN_DEBUG |
| 1108 | "scsi(%ld:%x): Async-%s complete - iop0=%x.\n", |
| 1109 | fcport->vha->host_no, sp->handle, type, |
| 1110 | le32_to_cpu(logio->io_parameter[0]))); |
| 1111 | |
| 1112 | data[0] = MBS_COMMAND_COMPLETE; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 1113 | if (ctx->type != SRB_LOGIN_CMD) |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 1114 | goto logio_done; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1115 | |
| 1116 | iop[0] = le32_to_cpu(logio->io_parameter[0]); |
| 1117 | if (iop[0] & BIT_4) { |
| 1118 | fcport->port_type = FCT_TARGET; |
| 1119 | if (iop[0] & BIT_8) |
Santosh Vernekar | 8474f3a | 2009-08-25 11:36:16 -0700 | [diff] [blame] | 1120 | fcport->flags |= FCF_FCP2_DEVICE; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1121 | } |
| 1122 | if (iop[0] & BIT_5) |
| 1123 | fcport->port_type = FCT_INITIATOR; |
| 1124 | if (logio->io_parameter[7] || logio->io_parameter[8]) |
| 1125 | fcport->supported_classes |= FC_COS_CLASS2; |
| 1126 | if (logio->io_parameter[9] || logio->io_parameter[10]) |
| 1127 | fcport->supported_classes |= FC_COS_CLASS3; |
| 1128 | |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 1129 | goto logio_done; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1130 | } |
| 1131 | |
| 1132 | iop[0] = le32_to_cpu(logio->io_parameter[0]); |
| 1133 | iop[1] = le32_to_cpu(logio->io_parameter[1]); |
| 1134 | switch (iop[0]) { |
| 1135 | case LSC_SCODE_PORTID_USED: |
| 1136 | data[0] = MBS_PORT_ID_USED; |
| 1137 | data[1] = LSW(iop[1]); |
| 1138 | break; |
| 1139 | case LSC_SCODE_NPORT_USED: |
| 1140 | data[0] = MBS_LOOP_ID_USED; |
| 1141 | break; |
| 1142 | case LSC_SCODE_CMD_FAILED: |
| 1143 | if ((iop[1] & 0xff) == 0x05) { |
| 1144 | data[0] = MBS_NOT_LOGGED_IN; |
| 1145 | break; |
| 1146 | } |
| 1147 | /* Fall through. */ |
| 1148 | default: |
| 1149 | data[0] = MBS_COMMAND_ERROR; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1150 | break; |
| 1151 | } |
| 1152 | |
| 1153 | DEBUG2(printk(KERN_WARNING |
| 1154 | "scsi(%ld:%x): Async-%s failed - comp=%x iop0=%x iop1=%x.\n", |
| 1155 | fcport->vha->host_no, sp->handle, type, |
| 1156 | le16_to_cpu(logio->comp_status), |
| 1157 | le32_to_cpu(logio->io_parameter[0]), |
| 1158 | le32_to_cpu(logio->io_parameter[1]))); |
| 1159 | |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 1160 | logio_done: |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 1161 | lio->done(sp); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1162 | } |
| 1163 | |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame^] | 1164 | static void |
| 1165 | qla24xx_tm_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, |
| 1166 | struct tsk_mgmt_entry *tsk) |
| 1167 | { |
| 1168 | const char func[] = "TMF-IOCB"; |
| 1169 | const char *type; |
| 1170 | fc_port_t *fcport; |
| 1171 | srb_t *sp; |
| 1172 | struct srb_iocb *iocb; |
| 1173 | struct srb_ctx *ctx; |
| 1174 | struct sts_entry_24xx *sts = (struct sts_entry_24xx *)tsk; |
| 1175 | int error = 1; |
| 1176 | |
| 1177 | sp = qla2x00_get_sp_from_handle(vha, func, req, tsk); |
| 1178 | if (!sp) |
| 1179 | return; |
| 1180 | |
| 1181 | ctx = sp->ctx; |
| 1182 | iocb = ctx->u.iocb_cmd; |
| 1183 | type = ctx->name; |
| 1184 | fcport = sp->fcport; |
| 1185 | |
| 1186 | if (sts->entry_status) { |
| 1187 | DEBUG2(printk(KERN_WARNING |
| 1188 | "scsi(%ld:%x): Async-%s error - entry-status(%x).\n", |
| 1189 | fcport->vha->host_no, sp->handle, type, |
| 1190 | sts->entry_status)); |
| 1191 | } else if (sts->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) { |
| 1192 | DEBUG2(printk(KERN_WARNING |
| 1193 | "scsi(%ld:%x): Async-%s error - completion status(%x).\n", |
| 1194 | fcport->vha->host_no, sp->handle, type, |
| 1195 | sts->comp_status)); |
| 1196 | } else if (!(le16_to_cpu(sts->scsi_status) & |
| 1197 | SS_RESPONSE_INFO_LEN_VALID)) { |
| 1198 | DEBUG2(printk(KERN_WARNING |
| 1199 | "scsi(%ld:%x): Async-%s error - no response info(%x).\n", |
| 1200 | fcport->vha->host_no, sp->handle, type, |
| 1201 | sts->scsi_status)); |
| 1202 | } else if (le32_to_cpu(sts->rsp_data_len) < 4) { |
| 1203 | DEBUG2(printk(KERN_WARNING |
| 1204 | "scsi(%ld:%x): Async-%s error - not enough response(%d).\n", |
| 1205 | fcport->vha->host_no, sp->handle, type, |
| 1206 | sts->rsp_data_len)); |
| 1207 | } else if (sts->data[3]) { |
| 1208 | DEBUG2(printk(KERN_WARNING |
| 1209 | "scsi(%ld:%x): Async-%s error - response(%x).\n", |
| 1210 | fcport->vha->host_no, sp->handle, type, |
| 1211 | sts->data[3])); |
| 1212 | } else { |
| 1213 | error = 0; |
| 1214 | } |
| 1215 | |
| 1216 | if (error) { |
| 1217 | iocb->u.tmf.data = error; |
| 1218 | DEBUG2(qla2x00_dump_buffer((uint8_t *)sts, sizeof(*sts))); |
| 1219 | } |
| 1220 | |
| 1221 | iocb->done(sp); |
| 1222 | } |
| 1223 | |
| 1224 | static void |
| 1225 | qla24xx_marker_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, |
| 1226 | struct mrk_entry_24xx *mrk) |
| 1227 | { |
| 1228 | const char func[] = "MRK-IOCB"; |
| 1229 | const char *type; |
| 1230 | fc_port_t *fcport; |
| 1231 | srb_t *sp; |
| 1232 | struct srb_iocb *iocb; |
| 1233 | struct srb_ctx *ctx; |
| 1234 | struct sts_entry_24xx *sts = (struct sts_entry_24xx *)mrk; |
| 1235 | |
| 1236 | sp = qla2x00_get_sp_from_handle(vha, func, req, mrk); |
| 1237 | if (!sp) |
| 1238 | return; |
| 1239 | |
| 1240 | ctx = sp->ctx; |
| 1241 | iocb = ctx->u.iocb_cmd; |
| 1242 | type = ctx->name; |
| 1243 | fcport = sp->fcport; |
| 1244 | |
| 1245 | if (sts->entry_status) { |
| 1246 | iocb->u.marker.data = 1; |
| 1247 | DEBUG2(printk(KERN_WARNING |
| 1248 | "scsi(%ld:%x): Async-%s error entry - entry-status=%x.\n", |
| 1249 | fcport->vha->host_no, sp->handle, type, |
| 1250 | sts->entry_status)); |
| 1251 | DEBUG2(qla2x00_dump_buffer((uint8_t *)mrk, sizeof(*sts))); |
| 1252 | } |
| 1253 | |
| 1254 | iocb->done(sp); |
| 1255 | } |
| 1256 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1257 | /** |
| 1258 | * qla2x00_process_response_queue() - Process response queue entries. |
| 1259 | * @ha: SCSI driver HA context |
| 1260 | */ |
| 1261 | void |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1262 | qla2x00_process_response_queue(struct rsp_que *rsp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1263 | { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1264 | struct scsi_qla_host *vha; |
| 1265 | struct qla_hw_data *ha = rsp->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 1266 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1267 | sts_entry_t *pkt; |
| 1268 | uint16_t handle_cnt; |
| 1269 | uint16_t cnt; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1270 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1271 | vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1272 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1273 | if (!vha->flags.online) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1274 | return; |
| 1275 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1276 | while (rsp->ring_ptr->signature != RESPONSE_PROCESSED) { |
| 1277 | pkt = (sts_entry_t *)rsp->ring_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1278 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1279 | rsp->ring_index++; |
| 1280 | if (rsp->ring_index == rsp->length) { |
| 1281 | rsp->ring_index = 0; |
| 1282 | rsp->ring_ptr = rsp->ring; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1283 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1284 | rsp->ring_ptr++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1285 | } |
| 1286 | |
| 1287 | if (pkt->entry_status != 0) { |
| 1288 | DEBUG3(printk(KERN_INFO |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1289 | "scsi(%ld): Process error entry.\n", vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1290 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1291 | qla2x00_error_entry(vha, rsp, pkt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1292 | ((response_t *)pkt)->signature = RESPONSE_PROCESSED; |
| 1293 | wmb(); |
| 1294 | continue; |
| 1295 | } |
| 1296 | |
| 1297 | switch (pkt->entry_type) { |
| 1298 | case STATUS_TYPE: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1299 | qla2x00_status_entry(vha, rsp, pkt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1300 | break; |
| 1301 | case STATUS_TYPE_21: |
| 1302 | handle_cnt = ((sts21_entry_t *)pkt)->handle_count; |
| 1303 | for (cnt = 0; cnt < handle_cnt; cnt++) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1304 | qla2x00_process_completed_request(vha, rsp->req, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1305 | ((sts21_entry_t *)pkt)->handle[cnt]); |
| 1306 | } |
| 1307 | break; |
| 1308 | case STATUS_TYPE_22: |
| 1309 | handle_cnt = ((sts22_entry_t *)pkt)->handle_count; |
| 1310 | for (cnt = 0; cnt < handle_cnt; cnt++) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1311 | qla2x00_process_completed_request(vha, rsp->req, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1312 | ((sts22_entry_t *)pkt)->handle[cnt]); |
| 1313 | } |
| 1314 | break; |
| 1315 | case STATUS_CONT_TYPE: |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1316 | qla2x00_status_cont_entry(rsp, (sts_cont_entry_t *)pkt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1317 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1318 | case MBX_IOCB_TYPE: |
| 1319 | qla2x00_mbx_iocb_entry(vha, rsp->req, |
| 1320 | (struct mbx_entry *)pkt); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame^] | 1321 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1322 | default: |
| 1323 | /* Type Not Supported. */ |
| 1324 | DEBUG4(printk(KERN_WARNING |
| 1325 | "scsi(%ld): Received unknown response pkt type %x " |
| 1326 | "entry status=%x.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1327 | vha->host_no, pkt->entry_type, pkt->entry_status)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1328 | break; |
| 1329 | } |
| 1330 | ((response_t *)pkt)->signature = RESPONSE_PROCESSED; |
| 1331 | wmb(); |
| 1332 | } |
| 1333 | |
| 1334 | /* Adjust ring index */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1335 | WRT_REG_WORD(ISP_RSP_Q_OUT(ha, reg), rsp->ring_index); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1336 | } |
| 1337 | |
Andrew Vasquez | 4733fcb | 2008-01-17 09:02:07 -0800 | [diff] [blame] | 1338 | static inline void |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1339 | qla2x00_handle_sense(srb_t *sp, uint8_t *sense_data, uint32_t sense_len, |
| 1340 | struct rsp_que *rsp) |
Andrew Vasquez | 4733fcb | 2008-01-17 09:02:07 -0800 | [diff] [blame] | 1341 | { |
| 1342 | struct scsi_cmnd *cp = sp->cmd; |
| 1343 | |
| 1344 | if (sense_len >= SCSI_SENSE_BUFFERSIZE) |
| 1345 | sense_len = SCSI_SENSE_BUFFERSIZE; |
| 1346 | |
Andrew Vasquez | 4733fcb | 2008-01-17 09:02:07 -0800 | [diff] [blame] | 1347 | sp->request_sense_length = sense_len; |
| 1348 | sp->request_sense_ptr = cp->sense_buffer; |
| 1349 | if (sp->request_sense_length > 32) |
| 1350 | sense_len = 32; |
| 1351 | |
| 1352 | memcpy(cp->sense_buffer, sense_data, sense_len); |
| 1353 | |
| 1354 | sp->request_sense_ptr += sense_len; |
| 1355 | sp->request_sense_length -= sense_len; |
| 1356 | if (sp->request_sense_length != 0) |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1357 | rsp->status_srb = sp; |
Andrew Vasquez | 4733fcb | 2008-01-17 09:02:07 -0800 | [diff] [blame] | 1358 | |
| 1359 | DEBUG5(printk("%s(): Check condition Sense data, scsi(%ld:%d:%d:%d) " |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1360 | "cmd=%p pid=%ld\n", __func__, sp->fcport->vha->host_no, |
Andrew Vasquez | 19851f1 | 2008-08-13 21:37:00 -0700 | [diff] [blame] | 1361 | cp->device->channel, cp->device->id, cp->device->lun, cp, |
| 1362 | cp->serial_number)); |
Andrew Vasquez | 4733fcb | 2008-01-17 09:02:07 -0800 | [diff] [blame] | 1363 | if (sense_len) |
Shyam Sundar | ddb9b12 | 2009-03-24 09:08:10 -0700 | [diff] [blame] | 1364 | DEBUG5(qla2x00_dump_buffer(cp->sense_buffer, sense_len)); |
Andrew Vasquez | 4733fcb | 2008-01-17 09:02:07 -0800 | [diff] [blame] | 1365 | } |
| 1366 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1367 | /** |
| 1368 | * qla2x00_status_entry() - Process a Status IOCB entry. |
| 1369 | * @ha: SCSI driver HA context |
| 1370 | * @pkt: Entry pointer |
| 1371 | */ |
| 1372 | static void |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1373 | qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1374 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1375 | srb_t *sp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1376 | fc_port_t *fcport; |
| 1377 | struct scsi_cmnd *cp; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1378 | sts_entry_t *sts; |
| 1379 | struct sts_entry_24xx *sts24; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1380 | uint16_t comp_status; |
| 1381 | uint16_t scsi_status; |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1382 | uint16_t ox_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1383 | uint8_t lscsi_status; |
| 1384 | int32_t resid; |
Ravi Anand | ed17c71b5 | 2006-05-17 15:08:55 -0700 | [diff] [blame] | 1385 | uint32_t sense_len, rsp_info_len, resid_len, fw_resid_len; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1386 | uint8_t *rsp_info, *sense_data; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1387 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1388 | uint32_t handle; |
| 1389 | uint16_t que; |
| 1390 | struct req_que *req; |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1391 | int logit = 1; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1392 | |
| 1393 | sts = (sts_entry_t *) pkt; |
| 1394 | sts24 = (struct sts_entry_24xx *) pkt; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1395 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1396 | comp_status = le16_to_cpu(sts24->comp_status); |
| 1397 | scsi_status = le16_to_cpu(sts24->scsi_status) & SS_MASK; |
| 1398 | } else { |
| 1399 | comp_status = le16_to_cpu(sts->comp_status); |
| 1400 | scsi_status = le16_to_cpu(sts->scsi_status) & SS_MASK; |
| 1401 | } |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1402 | handle = (uint32_t) LSW(sts->handle); |
| 1403 | que = MSW(sts->handle); |
| 1404 | req = ha->req_q_map[que]; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1405 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1406 | /* Fast path completion. */ |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1407 | if (comp_status == CS_COMPLETE && scsi_status == 0) { |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1408 | qla2x00_process_completed_request(vha, req, handle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1409 | |
| 1410 | return; |
| 1411 | } |
| 1412 | |
| 1413 | /* Validate handle. */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1414 | if (handle < MAX_OUTSTANDING_COMMANDS) { |
| 1415 | sp = req->outstanding_cmds[handle]; |
| 1416 | req->outstanding_cmds[handle] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1417 | } else |
| 1418 | sp = NULL; |
| 1419 | |
| 1420 | if (sp == NULL) { |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1421 | qla_printk(KERN_WARNING, ha, |
| 1422 | "scsi(%ld): Invalid status handle (0x%x).\n", vha->host_no, |
| 1423 | sts->handle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1424 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1425 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 1426 | qla2xxx_wake_dpc(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1427 | return; |
| 1428 | } |
| 1429 | cp = sp->cmd; |
| 1430 | if (cp == NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1431 | qla_printk(KERN_WARNING, ha, |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1432 | "scsi(%ld): Command already returned (0x%x/%p).\n", |
| 1433 | vha->host_no, sts->handle, sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1434 | |
| 1435 | return; |
| 1436 | } |
| 1437 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1438 | lscsi_status = scsi_status & STATUS_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1439 | |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1440 | fcport = sp->fcport; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1441 | |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1442 | ox_id = 0; |
Ravi Anand | ed17c71b5 | 2006-05-17 15:08:55 -0700 | [diff] [blame] | 1443 | sense_len = rsp_info_len = resid_len = fw_resid_len = 0; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1444 | if (IS_FWI2_CAPABLE(ha)) { |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 1445 | if (scsi_status & SS_SENSE_LEN_VALID) |
| 1446 | sense_len = le32_to_cpu(sts24->sense_len); |
| 1447 | if (scsi_status & SS_RESPONSE_INFO_LEN_VALID) |
| 1448 | rsp_info_len = le32_to_cpu(sts24->rsp_data_len); |
| 1449 | if (scsi_status & (SS_RESIDUAL_UNDER | SS_RESIDUAL_OVER)) |
| 1450 | resid_len = le32_to_cpu(sts24->rsp_residual_count); |
| 1451 | if (comp_status == CS_DATA_UNDERRUN) |
| 1452 | fw_resid_len = le32_to_cpu(sts24->residual_len); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1453 | rsp_info = sts24->data; |
| 1454 | sense_data = sts24->data; |
| 1455 | host_to_fcp_swap(sts24->data, sizeof(sts24->data)); |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1456 | ox_id = le16_to_cpu(sts24->ox_id); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1457 | } else { |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 1458 | if (scsi_status & SS_SENSE_LEN_VALID) |
| 1459 | sense_len = le16_to_cpu(sts->req_sense_length); |
| 1460 | if (scsi_status & SS_RESPONSE_INFO_LEN_VALID) |
| 1461 | rsp_info_len = le16_to_cpu(sts->rsp_info_len); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1462 | resid_len = le32_to_cpu(sts->residual_length); |
| 1463 | rsp_info = sts->rsp_info; |
| 1464 | sense_data = sts->req_sense_data; |
| 1465 | } |
| 1466 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1467 | /* Check for any FCP transport errors. */ |
| 1468 | if (scsi_status & SS_RESPONSE_INFO_LEN_VALID) { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1469 | /* Sense data lies beyond any FCP RESPONSE data. */ |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1470 | if (IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1471 | sense_data += rsp_info_len; |
| 1472 | if (rsp_info_len > 3 && rsp_info[3]) { |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1473 | DEBUG2(qla_printk(KERN_INFO, ha, |
| 1474 | "scsi(%ld:%d:%d): FCP I/O protocol failure " |
| 1475 | "(0x%x/0x%x).\n", vha->host_no, cp->device->id, |
| 1476 | cp->device->lun, rsp_info_len, rsp_info[3])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1477 | |
| 1478 | cp->result = DID_BUS_BUSY << 16; |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1479 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1480 | } |
| 1481 | } |
| 1482 | |
Andrew Vasquez | 3e8ce32 | 2008-02-28 14:06:10 -0800 | [diff] [blame] | 1483 | /* Check for overrun. */ |
| 1484 | if (IS_FWI2_CAPABLE(ha) && comp_status == CS_COMPLETE && |
| 1485 | scsi_status & SS_RESIDUAL_OVER) |
| 1486 | comp_status = CS_DATA_OVERRUN; |
| 1487 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1488 | /* |
| 1489 | * Based on Host and scsi status generate status code for Linux |
| 1490 | */ |
| 1491 | switch (comp_status) { |
| 1492 | case CS_COMPLETE: |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 1493 | case CS_QUEUE_FULL: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1494 | if (scsi_status == 0) { |
| 1495 | cp->result = DID_OK << 16; |
| 1496 | break; |
| 1497 | } |
| 1498 | if (scsi_status & (SS_RESIDUAL_UNDER | SS_RESIDUAL_OVER)) { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1499 | resid = resid_len; |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 1500 | scsi_set_resid(cp, resid); |
Andrew Vasquez | 0da69df | 2005-12-06 10:58:06 -0800 | [diff] [blame] | 1501 | |
| 1502 | if (!lscsi_status && |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 1503 | ((unsigned)(scsi_bufflen(cp) - resid) < |
Andrew Vasquez | 0da69df | 2005-12-06 10:58:06 -0800 | [diff] [blame] | 1504 | cp->underflow)) { |
| 1505 | qla_printk(KERN_INFO, ha, |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1506 | "scsi(%ld:%d:%d): Mid-layer underflow " |
| 1507 | "detected (0x%x of 0x%x bytes).\n", |
| 1508 | vha->host_no, cp->device->id, |
| 1509 | cp->device->lun, resid, scsi_bufflen(cp)); |
Andrew Vasquez | 0da69df | 2005-12-06 10:58:06 -0800 | [diff] [blame] | 1510 | |
| 1511 | cp->result = DID_ERROR << 16; |
| 1512 | break; |
| 1513 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1514 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1515 | cp->result = DID_OK << 16 | lscsi_status; |
| 1516 | |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 1517 | if (lscsi_status == SAM_STAT_TASK_SET_FULL) { |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1518 | DEBUG2(qla_printk(KERN_INFO, ha, |
| 1519 | "scsi(%ld:%d:%d) QUEUE FULL detected.\n", |
| 1520 | vha->host_no, cp->device->id, cp->device->lun)); |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 1521 | break; |
| 1522 | } |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1523 | logit = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1524 | if (lscsi_status != SS_CHECK_CONDITION) |
| 1525 | break; |
| 1526 | |
FUJITA Tomonori | b80ca4f | 2008-01-13 15:46:13 +0900 | [diff] [blame] | 1527 | memset(cp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1528 | if (!(scsi_status & SS_SENSE_LEN_VALID)) |
| 1529 | break; |
| 1530 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1531 | qla2x00_handle_sense(sp, sense_data, sense_len, rsp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1532 | break; |
| 1533 | |
| 1534 | case CS_DATA_UNDERRUN: |
Ravi Anand | ed17c71b5 | 2006-05-17 15:08:55 -0700 | [diff] [blame] | 1535 | /* Use F/W calculated residual length. */ |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 1536 | resid = IS_FWI2_CAPABLE(ha) ? fw_resid_len : resid_len; |
| 1537 | scsi_set_resid(cp, resid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1538 | if (scsi_status & SS_RESIDUAL_UNDER) { |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 1539 | if (IS_FWI2_CAPABLE(ha) && fw_resid_len != resid_len) { |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1540 | DEBUG2(qla_printk(KERN_INFO, ha, |
| 1541 | "scsi(%ld:%d:%d) Dropped frame(s) detected " |
| 1542 | "(0x%x of 0x%x bytes).\n", vha->host_no, |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 1543 | cp->device->id, cp->device->lun, resid, |
| 1544 | scsi_bufflen(cp))); |
andrew.vasquez@qlogic.com | e038a1b | 2006-01-13 17:04:59 -0800 | [diff] [blame] | 1545 | |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 1546 | cp->result = DID_ERROR << 16 | lscsi_status; |
| 1547 | break; |
| 1548 | } |
| 1549 | |
| 1550 | if (!lscsi_status && |
| 1551 | ((unsigned)(scsi_bufflen(cp) - resid) < |
| 1552 | cp->underflow)) { |
| 1553 | qla_printk(KERN_INFO, ha, |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1554 | "scsi(%ld:%d:%d): Mid-layer underflow " |
| 1555 | "detected (0x%x of 0x%x bytes).\n", |
| 1556 | vha->host_no, cp->device->id, |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 1557 | cp->device->lun, resid, scsi_bufflen(cp)); |
| 1558 | |
| 1559 | cp->result = DID_ERROR << 16; |
| 1560 | break; |
| 1561 | } |
| 1562 | } else if (!lscsi_status) { |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1563 | DEBUG2(qla_printk(KERN_INFO, ha, |
| 1564 | "scsi(%ld:%d:%d) Dropped frame(s) detected (0x%x " |
| 1565 | "of 0x%x bytes).\n", vha->host_no, cp->device->id, |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 1566 | cp->device->lun, resid, scsi_bufflen(cp))); |
| 1567 | |
| 1568 | cp->result = DID_ERROR << 16; |
| 1569 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1570 | } |
| 1571 | |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 1572 | cp->result = DID_OK << 16 | lscsi_status; |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1573 | logit = 0; |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 1574 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1575 | /* |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1576 | * Check to see if SCSI Status is non zero. If so report SCSI |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1577 | * Status. |
| 1578 | */ |
| 1579 | if (lscsi_status != 0) { |
Andrew Vasquez | ffec28a | 2007-01-29 10:22:27 -0800 | [diff] [blame] | 1580 | if (lscsi_status == SAM_STAT_TASK_SET_FULL) { |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1581 | DEBUG2(qla_printk(KERN_INFO, ha, |
| 1582 | "scsi(%ld:%d:%d) QUEUE FULL detected.\n", |
| 1583 | vha->host_no, cp->device->id, |
| 1584 | cp->device->lun)); |
| 1585 | logit = 1; |
Andrew Vasquez | ffec28a | 2007-01-29 10:22:27 -0800 | [diff] [blame] | 1586 | break; |
| 1587 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1588 | if (lscsi_status != SS_CHECK_CONDITION) |
| 1589 | break; |
| 1590 | |
FUJITA Tomonori | b80ca4f | 2008-01-13 15:46:13 +0900 | [diff] [blame] | 1591 | memset(cp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1592 | if (!(scsi_status & SS_SENSE_LEN_VALID)) |
| 1593 | break; |
| 1594 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1595 | qla2x00_handle_sense(sp, sense_data, sense_len, rsp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1596 | } |
| 1597 | break; |
| 1598 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1599 | case CS_PORT_LOGGED_OUT: |
| 1600 | case CS_PORT_CONFIG_CHG: |
| 1601 | case CS_PORT_BUSY: |
| 1602 | case CS_INCOMPLETE: |
| 1603 | case CS_PORT_UNAVAILABLE: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1604 | case CS_TIMEOUT: |
Mike Christie | 056a448 | 2008-08-19 18:45:29 -0500 | [diff] [blame] | 1605 | /* |
| 1606 | * We are going to have the fc class block the rport |
| 1607 | * while we try to recover so instruct the mid layer |
| 1608 | * to requeue until the class decides how to handle this. |
| 1609 | */ |
| 1610 | cp->result = DID_TRANSPORT_DISRUPTED << 16; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1611 | |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1612 | if (comp_status == CS_TIMEOUT) { |
| 1613 | if (IS_FWI2_CAPABLE(ha)) |
| 1614 | break; |
| 1615 | else if ((le16_to_cpu(sts->status_flags) & |
| 1616 | SF_LOGOUT_SENT) == 0) |
| 1617 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1618 | } |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1619 | |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1620 | DEBUG2(qla_printk(KERN_INFO, ha, |
| 1621 | "scsi(%ld:%d:%d) Port down status: port-state=0x%x\n", |
| 1622 | vha->host_no, cp->device->id, cp->device->lun, |
| 1623 | atomic_read(&fcport->state))); |
| 1624 | |
| 1625 | if (atomic_read(&fcport->state) == FCS_ONLINE) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1626 | qla2x00_mark_device_lost(fcport->vha, fcport, 1, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1627 | break; |
| 1628 | |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1629 | case CS_RESET: |
| 1630 | case CS_ABORTED: |
| 1631 | cp->result = DID_RESET << 16; |
| 1632 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1633 | default: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1634 | cp->result = DID_ERROR << 16; |
| 1635 | break; |
| 1636 | } |
| 1637 | |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1638 | out: |
| 1639 | if (logit) |
| 1640 | DEBUG2(qla_printk(KERN_INFO, ha, |
| 1641 | "scsi(%ld:%d:%d) FCP command status: 0x%x-0x%x (0x%x) " |
| 1642 | "oxid=0x%x ser=0x%lx cdb=%02x%02x%02x len=0x%x " |
| 1643 | "rsp_info=0x%x resid=0x%x fw_resid=0x%x\n", vha->host_no, |
| 1644 | cp->device->id, cp->device->lun, comp_status, scsi_status, |
| 1645 | cp->result, ox_id, cp->serial_number, cp->cmnd[0], |
| 1646 | cp->cmnd[1], cp->cmnd[2], scsi_bufflen(cp), rsp_info_len, |
| 1647 | resid_len, fw_resid_len)); |
| 1648 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1649 | if (rsp->status_srb == NULL) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1650 | qla2x00_sp_compl(ha, sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1651 | } |
| 1652 | |
| 1653 | /** |
| 1654 | * qla2x00_status_cont_entry() - Process a Status Continuations entry. |
| 1655 | * @ha: SCSI driver HA context |
| 1656 | * @pkt: Entry pointer |
| 1657 | * |
| 1658 | * Extended sense data. |
| 1659 | */ |
| 1660 | static void |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1661 | qla2x00_status_cont_entry(struct rsp_que *rsp, sts_cont_entry_t *pkt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1662 | { |
| 1663 | uint8_t sense_sz = 0; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1664 | struct qla_hw_data *ha = rsp->hw; |
| 1665 | srb_t *sp = rsp->status_srb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1666 | struct scsi_cmnd *cp; |
| 1667 | |
| 1668 | if (sp != NULL && sp->request_sense_length != 0) { |
| 1669 | cp = sp->cmd; |
| 1670 | if (cp == NULL) { |
| 1671 | DEBUG2(printk("%s(): Cmd already returned back to OS " |
Andrew Vasquez | 75bc419 | 2006-05-17 15:09:22 -0700 | [diff] [blame] | 1672 | "sp=%p.\n", __func__, sp)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1673 | qla_printk(KERN_INFO, ha, |
| 1674 | "cmd is NULL: already returned to OS (sp=%p)\n", |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1675 | sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1676 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1677 | rsp->status_srb = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1678 | return; |
| 1679 | } |
| 1680 | |
| 1681 | if (sp->request_sense_length > sizeof(pkt->data)) { |
| 1682 | sense_sz = sizeof(pkt->data); |
| 1683 | } else { |
| 1684 | sense_sz = sp->request_sense_length; |
| 1685 | } |
| 1686 | |
| 1687 | /* Move sense data. */ |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1688 | if (IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1689 | host_to_fcp_swap(pkt->data, sizeof(pkt->data)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1690 | memcpy(sp->request_sense_ptr, pkt->data, sense_sz); |
| 1691 | DEBUG5(qla2x00_dump_buffer(sp->request_sense_ptr, sense_sz)); |
| 1692 | |
| 1693 | sp->request_sense_ptr += sense_sz; |
| 1694 | sp->request_sense_length -= sense_sz; |
| 1695 | |
| 1696 | /* Place command on done queue. */ |
| 1697 | if (sp->request_sense_length == 0) { |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1698 | rsp->status_srb = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1699 | qla2x00_sp_compl(ha, sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1700 | } |
| 1701 | } |
| 1702 | } |
| 1703 | |
| 1704 | /** |
| 1705 | * qla2x00_error_entry() - Process an error entry. |
| 1706 | * @ha: SCSI driver HA context |
| 1707 | * @pkt: Entry pointer |
| 1708 | */ |
| 1709 | static void |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1710 | qla2x00_error_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, sts_entry_t *pkt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1711 | { |
| 1712 | srb_t *sp; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1713 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1714 | uint32_t handle = LSW(pkt->handle); |
| 1715 | uint16_t que = MSW(pkt->handle); |
| 1716 | struct req_que *req = ha->req_q_map[que]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1717 | #if defined(QL_DEBUG_LEVEL_2) |
| 1718 | if (pkt->entry_status & RF_INV_E_ORDER) |
| 1719 | qla_printk(KERN_ERR, ha, "%s: Invalid Entry Order\n", __func__); |
| 1720 | else if (pkt->entry_status & RF_INV_E_COUNT) |
| 1721 | qla_printk(KERN_ERR, ha, "%s: Invalid Entry Count\n", __func__); |
| 1722 | else if (pkt->entry_status & RF_INV_E_PARAM) |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1723 | qla_printk(KERN_ERR, ha, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1724 | "%s: Invalid Entry Parameter\n", __func__); |
| 1725 | else if (pkt->entry_status & RF_INV_E_TYPE) |
| 1726 | qla_printk(KERN_ERR, ha, "%s: Invalid Entry Type\n", __func__); |
| 1727 | else if (pkt->entry_status & RF_BUSY) |
| 1728 | qla_printk(KERN_ERR, ha, "%s: Busy\n", __func__); |
| 1729 | else |
| 1730 | qla_printk(KERN_ERR, ha, "%s: UNKNOWN flag error\n", __func__); |
| 1731 | #endif |
| 1732 | |
| 1733 | /* Validate handle. */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1734 | if (handle < MAX_OUTSTANDING_COMMANDS) |
| 1735 | sp = req->outstanding_cmds[handle]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1736 | else |
| 1737 | sp = NULL; |
| 1738 | |
| 1739 | if (sp) { |
| 1740 | /* Free outstanding command slot. */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1741 | req->outstanding_cmds[handle] = NULL; |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 1742 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1743 | /* Bad payload or header */ |
| 1744 | if (pkt->entry_status & |
| 1745 | (RF_INV_E_ORDER | RF_INV_E_COUNT | |
| 1746 | RF_INV_E_PARAM | RF_INV_E_TYPE)) { |
| 1747 | sp->cmd->result = DID_ERROR << 16; |
| 1748 | } else if (pkt->entry_status & RF_BUSY) { |
| 1749 | sp->cmd->result = DID_BUS_BUSY << 16; |
| 1750 | } else { |
| 1751 | sp->cmd->result = DID_ERROR << 16; |
| 1752 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1753 | qla2x00_sp_compl(ha, sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1754 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1755 | } else if (pkt->entry_type == COMMAND_A64_TYPE || pkt->entry_type == |
| 1756 | COMMAND_TYPE || pkt->entry_type == COMMAND_TYPE_7) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1757 | DEBUG2(printk("scsi(%ld): Error entry - invalid handle\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1758 | vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1759 | qla_printk(KERN_WARNING, ha, |
| 1760 | "Error entry - invalid handle\n"); |
| 1761 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1762 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 1763 | qla2xxx_wake_dpc(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1764 | } |
| 1765 | } |
| 1766 | |
| 1767 | /** |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1768 | * qla24xx_mbx_completion() - Process mailbox command completions. |
| 1769 | * @ha: SCSI driver HA context |
| 1770 | * @mb0: Mailbox0 register |
| 1771 | */ |
| 1772 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1773 | qla24xx_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0) |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1774 | { |
| 1775 | uint16_t cnt; |
| 1776 | uint16_t __iomem *wptr; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1777 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1778 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1779 | |
| 1780 | /* Load return mailbox registers. */ |
| 1781 | ha->flags.mbox_int = 1; |
| 1782 | ha->mailbox_out[0] = mb0; |
| 1783 | wptr = (uint16_t __iomem *)®->mailbox1; |
| 1784 | |
| 1785 | for (cnt = 1; cnt < ha->mbx_count; cnt++) { |
| 1786 | ha->mailbox_out[cnt] = RD_REG_WORD(wptr); |
| 1787 | wptr++; |
| 1788 | } |
| 1789 | |
| 1790 | if (ha->mcp) { |
| 1791 | DEBUG3(printk("%s(%ld): Got mailbox completion. cmd=%x.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1792 | __func__, vha->host_no, ha->mcp->mb[0])); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1793 | } else { |
| 1794 | DEBUG2_3(printk("%s(%ld): MBX pointer ERROR!\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1795 | __func__, vha->host_no)); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1796 | } |
| 1797 | } |
| 1798 | |
| 1799 | /** |
| 1800 | * qla24xx_process_response_queue() - Process response queue entries. |
| 1801 | * @ha: SCSI driver HA context |
| 1802 | */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1803 | void qla24xx_process_response_queue(struct scsi_qla_host *vha, |
| 1804 | struct rsp_que *rsp) |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1805 | { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1806 | struct sts_entry_24xx *pkt; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1807 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1808 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1809 | if (!vha->flags.online) |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1810 | return; |
| 1811 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1812 | while (rsp->ring_ptr->signature != RESPONSE_PROCESSED) { |
| 1813 | pkt = (struct sts_entry_24xx *)rsp->ring_ptr; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1814 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1815 | rsp->ring_index++; |
| 1816 | if (rsp->ring_index == rsp->length) { |
| 1817 | rsp->ring_index = 0; |
| 1818 | rsp->ring_ptr = rsp->ring; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1819 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1820 | rsp->ring_ptr++; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1821 | } |
| 1822 | |
| 1823 | if (pkt->entry_status != 0) { |
| 1824 | DEBUG3(printk(KERN_INFO |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1825 | "scsi(%ld): Process error entry.\n", vha->host_no)); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1826 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1827 | qla2x00_error_entry(vha, rsp, (sts_entry_t *) pkt); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1828 | ((response_t *)pkt)->signature = RESPONSE_PROCESSED; |
| 1829 | wmb(); |
| 1830 | continue; |
| 1831 | } |
| 1832 | |
| 1833 | switch (pkt->entry_type) { |
| 1834 | case STATUS_TYPE: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1835 | qla2x00_status_entry(vha, rsp, pkt); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1836 | break; |
| 1837 | case STATUS_CONT_TYPE: |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1838 | qla2x00_status_cont_entry(rsp, (sts_cont_entry_t *)pkt); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1839 | break; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1840 | case VP_RPT_ID_IOCB_TYPE: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1841 | qla24xx_report_id_acquisition(vha, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1842 | (struct vp_rpt_id_entry_24xx *)pkt); |
| 1843 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1844 | case LOGINOUT_PORT_IOCB_TYPE: |
| 1845 | qla24xx_logio_entry(vha, rsp->req, |
| 1846 | (struct logio_entry_24xx *)pkt); |
| 1847 | break; |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame^] | 1848 | case TSK_MGMT_IOCB_TYPE: |
| 1849 | qla24xx_tm_iocb_entry(vha, rsp->req, |
| 1850 | (struct tsk_mgmt_entry *)pkt); |
| 1851 | break; |
| 1852 | case MARKER_TYPE: |
| 1853 | qla24xx_marker_iocb_entry(vha, rsp->req, |
| 1854 | (struct mrk_entry_24xx *)pkt); |
| 1855 | break; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1856 | case CT_IOCB_TYPE: |
| 1857 | qla24xx_els_ct_entry(vha, rsp->req, pkt, CT_IOCB_TYPE); |
| 1858 | clear_bit(MBX_INTERRUPT, &vha->hw->mbx_cmd_flags); |
| 1859 | break; |
| 1860 | case ELS_IOCB_TYPE: |
| 1861 | qla24xx_els_ct_entry(vha, rsp->req, pkt, ELS_IOCB_TYPE); |
| 1862 | break; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1863 | default: |
| 1864 | /* Type Not Supported. */ |
| 1865 | DEBUG4(printk(KERN_WARNING |
| 1866 | "scsi(%ld): Received unknown response pkt type %x " |
| 1867 | "entry status=%x.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1868 | vha->host_no, pkt->entry_type, pkt->entry_status)); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1869 | break; |
| 1870 | } |
| 1871 | ((response_t *)pkt)->signature = RESPONSE_PROCESSED; |
| 1872 | wmb(); |
| 1873 | } |
| 1874 | |
| 1875 | /* Adjust ring index */ |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1876 | if (IS_QLA82XX(ha)) { |
| 1877 | struct device_reg_82xx __iomem *reg = &ha->iobase->isp82; |
| 1878 | WRT_REG_DWORD(®->rsp_q_out[0], rsp->ring_index); |
| 1879 | } else |
| 1880 | WRT_REG_DWORD(rsp->rsp_q_out, rsp->ring_index); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1881 | } |
| 1882 | |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 1883 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1884 | qla2xxx_check_risc_status(scsi_qla_host_t *vha) |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 1885 | { |
| 1886 | int rval; |
| 1887 | uint32_t cnt; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1888 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 1889 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1890 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1891 | if (!IS_QLA25XX(ha) && !IS_QLA81XX(ha)) |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 1892 | return; |
| 1893 | |
| 1894 | rval = QLA_SUCCESS; |
| 1895 | WRT_REG_DWORD(®->iobase_addr, 0x7C00); |
| 1896 | RD_REG_DWORD(®->iobase_addr); |
| 1897 | WRT_REG_DWORD(®->iobase_window, 0x0001); |
| 1898 | for (cnt = 10000; (RD_REG_DWORD(®->iobase_window) & BIT_0) == 0 && |
| 1899 | rval == QLA_SUCCESS; cnt--) { |
| 1900 | if (cnt) { |
| 1901 | WRT_REG_DWORD(®->iobase_window, 0x0001); |
| 1902 | udelay(10); |
| 1903 | } else |
| 1904 | rval = QLA_FUNCTION_TIMEOUT; |
| 1905 | } |
| 1906 | if (rval == QLA_SUCCESS) |
| 1907 | goto next_test; |
| 1908 | |
| 1909 | WRT_REG_DWORD(®->iobase_window, 0x0003); |
| 1910 | for (cnt = 100; (RD_REG_DWORD(®->iobase_window) & BIT_0) == 0 && |
| 1911 | rval == QLA_SUCCESS; cnt--) { |
| 1912 | if (cnt) { |
| 1913 | WRT_REG_DWORD(®->iobase_window, 0x0003); |
| 1914 | udelay(10); |
| 1915 | } else |
| 1916 | rval = QLA_FUNCTION_TIMEOUT; |
| 1917 | } |
| 1918 | if (rval != QLA_SUCCESS) |
| 1919 | goto done; |
| 1920 | |
| 1921 | next_test: |
| 1922 | if (RD_REG_DWORD(®->iobase_c8) & BIT_3) |
| 1923 | qla_printk(KERN_INFO, ha, "Additional code -- 0x55AA.\n"); |
| 1924 | |
| 1925 | done: |
| 1926 | WRT_REG_DWORD(®->iobase_window, 0x0000); |
| 1927 | RD_REG_DWORD(®->iobase_window); |
| 1928 | } |
| 1929 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1930 | /** |
| 1931 | * qla24xx_intr_handler() - Process interrupts for the ISP23xx and ISP63xx. |
| 1932 | * @irq: |
| 1933 | * @dev_id: SCSI driver HA context |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1934 | * |
| 1935 | * Called by system whenever the host adapter generates an interrupt. |
| 1936 | * |
| 1937 | * Returns handled flag. |
| 1938 | */ |
| 1939 | irqreturn_t |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 1940 | qla24xx_intr_handler(int irq, void *dev_id) |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1941 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1942 | scsi_qla_host_t *vha; |
| 1943 | struct qla_hw_data *ha; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1944 | struct device_reg_24xx __iomem *reg; |
| 1945 | int status; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1946 | unsigned long iter; |
| 1947 | uint32_t stat; |
| 1948 | uint32_t hccr; |
| 1949 | uint16_t mb[4]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1950 | struct rsp_que *rsp; |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 1951 | unsigned long flags; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1952 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1953 | rsp = (struct rsp_que *) dev_id; |
| 1954 | if (!rsp) { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1955 | printk(KERN_INFO |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1956 | "%s(): NULL response queue pointer\n", __func__); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1957 | return IRQ_NONE; |
| 1958 | } |
| 1959 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1960 | ha = rsp->hw; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1961 | reg = &ha->iobase->isp24; |
| 1962 | status = 0; |
| 1963 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 1964 | if (unlikely(pci_channel_offline(ha->pdev))) |
| 1965 | return IRQ_HANDLED; |
| 1966 | |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 1967 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1968 | vha = pci_get_drvdata(ha->pdev); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1969 | for (iter = 50; iter--; ) { |
| 1970 | stat = RD_REG_DWORD(®->host_status); |
| 1971 | if (stat & HSRX_RISC_PAUSED) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 1972 | if (unlikely(pci_channel_offline(ha->pdev))) |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 1973 | break; |
| 1974 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1975 | hccr = RD_REG_DWORD(®->hccr); |
| 1976 | |
| 1977 | qla_printk(KERN_INFO, ha, "RISC paused -- HCCR=%x, " |
| 1978 | "Dumping firmware!\n", hccr); |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 1979 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1980 | qla2xxx_check_risc_status(vha); |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 1981 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1982 | ha->isp_ops->fw_dump(vha, 1); |
| 1983 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1984 | break; |
| 1985 | } else if ((stat & HSRX_RISC_INT) == 0) |
| 1986 | break; |
| 1987 | |
| 1988 | switch (stat & 0xff) { |
| 1989 | case 0x1: |
| 1990 | case 0x2: |
| 1991 | case 0x10: |
| 1992 | case 0x11: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1993 | qla24xx_mbx_completion(vha, MSW(stat)); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1994 | status |= MBX_INTERRUPT; |
| 1995 | |
| 1996 | break; |
| 1997 | case 0x12: |
| 1998 | mb[0] = MSW(stat); |
| 1999 | mb[1] = RD_REG_WORD(®->mailbox1); |
| 2000 | mb[2] = RD_REG_WORD(®->mailbox2); |
| 2001 | mb[3] = RD_REG_WORD(®->mailbox3); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2002 | qla2x00_async_event(vha, rsp, mb); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2003 | break; |
| 2004 | case 0x13: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2005 | case 0x14: |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2006 | qla24xx_process_response_queue(vha, rsp); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2007 | break; |
| 2008 | default: |
| 2009 | DEBUG2(printk("scsi(%ld): Unrecognized interrupt type " |
| 2010 | "(%d).\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2011 | vha->host_no, stat & 0xff)); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2012 | break; |
| 2013 | } |
| 2014 | WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_INT); |
| 2015 | RD_REG_DWORD_RELAXED(®->hccr); |
| 2016 | } |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 2017 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2018 | |
| 2019 | if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) && |
| 2020 | (status & MBX_INTERRUPT) && ha->flags.mbox_int) { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2021 | set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 2022 | complete(&ha->mbx_intr_comp); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2023 | } |
| 2024 | |
| 2025 | return IRQ_HANDLED; |
| 2026 | } |
| 2027 | |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2028 | static irqreturn_t |
| 2029 | qla24xx_msix_rsp_q(int irq, void *dev_id) |
| 2030 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2031 | struct qla_hw_data *ha; |
| 2032 | struct rsp_que *rsp; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2033 | struct device_reg_24xx __iomem *reg; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2034 | struct scsi_qla_host *vha; |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2035 | unsigned long flags; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2036 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2037 | rsp = (struct rsp_que *) dev_id; |
| 2038 | if (!rsp) { |
| 2039 | printk(KERN_INFO |
| 2040 | "%s(): NULL response queue pointer\n", __func__); |
| 2041 | return IRQ_NONE; |
| 2042 | } |
| 2043 | ha = rsp->hw; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2044 | reg = &ha->iobase->isp24; |
| 2045 | |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2046 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2047 | |
Anirban Chakraborty | a67093d | 2010-02-04 14:17:59 -0800 | [diff] [blame] | 2048 | vha = pci_get_drvdata(ha->pdev); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2049 | qla24xx_process_response_queue(vha, rsp); |
Anirban Chakraborty | 3155754 | 2009-12-02 10:36:55 -0800 | [diff] [blame] | 2050 | if (!ha->flags.disable_msix_handshake) { |
Anirban Chakraborty | eb94114 | 2009-08-04 16:12:13 -0700 | [diff] [blame] | 2051 | WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_INT); |
| 2052 | RD_REG_DWORD_RELAXED(®->hccr); |
| 2053 | } |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2054 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2055 | |
| 2056 | return IRQ_HANDLED; |
| 2057 | } |
| 2058 | |
| 2059 | static irqreturn_t |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2060 | qla25xx_msix_rsp_q(int irq, void *dev_id) |
| 2061 | { |
| 2062 | struct qla_hw_data *ha; |
| 2063 | struct rsp_que *rsp; |
Anirban Chakraborty | 3155754 | 2009-12-02 10:36:55 -0800 | [diff] [blame] | 2064 | struct device_reg_24xx __iomem *reg; |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2065 | unsigned long flags; |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2066 | |
| 2067 | rsp = (struct rsp_que *) dev_id; |
| 2068 | if (!rsp) { |
| 2069 | printk(KERN_INFO |
| 2070 | "%s(): NULL response queue pointer\n", __func__); |
| 2071 | return IRQ_NONE; |
| 2072 | } |
| 2073 | ha = rsp->hw; |
| 2074 | |
Anirban Chakraborty | 3155754 | 2009-12-02 10:36:55 -0800 | [diff] [blame] | 2075 | /* Clear the interrupt, if enabled, for this response queue */ |
| 2076 | if (rsp->options & ~BIT_6) { |
| 2077 | reg = &ha->iobase->isp24; |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2078 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 3155754 | 2009-12-02 10:36:55 -0800 | [diff] [blame] | 2079 | WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_INT); |
| 2080 | RD_REG_DWORD_RELAXED(®->hccr); |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2081 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Anirban Chakraborty | 3155754 | 2009-12-02 10:36:55 -0800 | [diff] [blame] | 2082 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2083 | queue_work_on((int) (rsp->id - 1), ha->wq, &rsp->q_work); |
| 2084 | |
| 2085 | return IRQ_HANDLED; |
| 2086 | } |
| 2087 | |
| 2088 | static irqreturn_t |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2089 | qla24xx_msix_default(int irq, void *dev_id) |
| 2090 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2091 | scsi_qla_host_t *vha; |
| 2092 | struct qla_hw_data *ha; |
| 2093 | struct rsp_que *rsp; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2094 | struct device_reg_24xx __iomem *reg; |
| 2095 | int status; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2096 | uint32_t stat; |
| 2097 | uint32_t hccr; |
| 2098 | uint16_t mb[4]; |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2099 | unsigned long flags; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2100 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2101 | rsp = (struct rsp_que *) dev_id; |
| 2102 | if (!rsp) { |
| 2103 | DEBUG(printk( |
| 2104 | "%s(): NULL response queue pointer\n", __func__)); |
| 2105 | return IRQ_NONE; |
| 2106 | } |
| 2107 | ha = rsp->hw; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2108 | reg = &ha->iobase->isp24; |
| 2109 | status = 0; |
| 2110 | |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2111 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2112 | vha = pci_get_drvdata(ha->pdev); |
Andrew Vasquez | 87f2701 | 2007-09-20 14:07:49 -0700 | [diff] [blame] | 2113 | do { |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2114 | stat = RD_REG_DWORD(®->host_status); |
| 2115 | if (stat & HSRX_RISC_PAUSED) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 2116 | if (unlikely(pci_channel_offline(ha->pdev))) |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 2117 | break; |
| 2118 | |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2119 | hccr = RD_REG_DWORD(®->hccr); |
| 2120 | |
| 2121 | qla_printk(KERN_INFO, ha, "RISC paused -- HCCR=%x, " |
| 2122 | "Dumping firmware!\n", hccr); |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 2123 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2124 | qla2xxx_check_risc_status(vha); |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 2125 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2126 | ha->isp_ops->fw_dump(vha, 1); |
| 2127 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2128 | break; |
| 2129 | } else if ((stat & HSRX_RISC_INT) == 0) |
| 2130 | break; |
| 2131 | |
| 2132 | switch (stat & 0xff) { |
| 2133 | case 0x1: |
| 2134 | case 0x2: |
| 2135 | case 0x10: |
| 2136 | case 0x11: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2137 | qla24xx_mbx_completion(vha, MSW(stat)); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2138 | status |= MBX_INTERRUPT; |
| 2139 | |
| 2140 | break; |
| 2141 | case 0x12: |
| 2142 | mb[0] = MSW(stat); |
| 2143 | mb[1] = RD_REG_WORD(®->mailbox1); |
| 2144 | mb[2] = RD_REG_WORD(®->mailbox2); |
| 2145 | mb[3] = RD_REG_WORD(®->mailbox3); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2146 | qla2x00_async_event(vha, rsp, mb); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2147 | break; |
| 2148 | case 0x13: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2149 | case 0x14: |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2150 | qla24xx_process_response_queue(vha, rsp); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2151 | break; |
| 2152 | default: |
| 2153 | DEBUG2(printk("scsi(%ld): Unrecognized interrupt type " |
| 2154 | "(%d).\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2155 | vha->host_no, stat & 0xff)); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2156 | break; |
| 2157 | } |
| 2158 | WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_INT); |
Andrew Vasquez | 87f2701 | 2007-09-20 14:07:49 -0700 | [diff] [blame] | 2159 | } while (0); |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2160 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2161 | |
| 2162 | if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) && |
| 2163 | (status & MBX_INTERRUPT) && ha->flags.mbox_int) { |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2164 | set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 2165 | complete(&ha->mbx_intr_comp); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2166 | } |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2167 | return IRQ_HANDLED; |
| 2168 | } |
| 2169 | |
| 2170 | /* Interrupt handling helpers. */ |
| 2171 | |
| 2172 | struct qla_init_msix_entry { |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2173 | const char *name; |
Jeff Garzik | 476834c | 2007-05-23 14:41:44 -0700 | [diff] [blame] | 2174 | irq_handler_t handler; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2175 | }; |
| 2176 | |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2177 | static struct qla_init_msix_entry msix_entries[3] = { |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2178 | { "qla2xxx (default)", qla24xx_msix_default }, |
| 2179 | { "qla2xxx (rsp_q)", qla24xx_msix_rsp_q }, |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2180 | { "qla2xxx (multiq)", qla25xx_msix_rsp_q }, |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2181 | }; |
| 2182 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2183 | static struct qla_init_msix_entry qla82xx_msix_entries[2] = { |
| 2184 | { "qla2xxx (default)", qla82xx_msix_default }, |
| 2185 | { "qla2xxx (rsp_q)", qla82xx_msix_rsp_q }, |
| 2186 | }; |
| 2187 | |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2188 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2189 | qla24xx_disable_msix(struct qla_hw_data *ha) |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2190 | { |
| 2191 | int i; |
| 2192 | struct qla_msix_entry *qentry; |
| 2193 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2194 | for (i = 0; i < ha->msix_count; i++) { |
| 2195 | qentry = &ha->msix_entries[i]; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2196 | if (qentry->have_irq) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2197 | free_irq(qentry->vector, qentry->rsp); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2198 | } |
| 2199 | pci_disable_msix(ha->pdev); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2200 | kfree(ha->msix_entries); |
| 2201 | ha->msix_entries = NULL; |
| 2202 | ha->flags.msix_enabled = 0; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2203 | } |
| 2204 | |
| 2205 | static int |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2206 | qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp) |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2207 | { |
Lalit Chandivade | ad038fa | 2009-01-22 09:45:33 -0800 | [diff] [blame] | 2208 | #define MIN_MSIX_COUNT 2 |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2209 | int i, ret; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2210 | struct msix_entry *entries; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2211 | struct qla_msix_entry *qentry; |
| 2212 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2213 | entries = kzalloc(sizeof(struct msix_entry) * ha->msix_count, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2214 | GFP_KERNEL); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2215 | if (!entries) |
| 2216 | return -ENOMEM; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2217 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2218 | for (i = 0; i < ha->msix_count; i++) |
| 2219 | entries[i].entry = i; |
| 2220 | |
| 2221 | ret = pci_enable_msix(ha->pdev, entries, ha->msix_count); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2222 | if (ret) { |
Lalit Chandivade | ad038fa | 2009-01-22 09:45:33 -0800 | [diff] [blame] | 2223 | if (ret < MIN_MSIX_COUNT) |
| 2224 | goto msix_failed; |
| 2225 | |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2226 | qla_printk(KERN_WARNING, ha, |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2227 | "MSI-X: Failed to enable support -- %d/%d\n" |
| 2228 | " Retry with %d vectors\n", ha->msix_count, ret, ret); |
| 2229 | ha->msix_count = ret; |
| 2230 | ret = pci_enable_msix(ha->pdev, entries, ha->msix_count); |
| 2231 | if (ret) { |
Lalit Chandivade | ad038fa | 2009-01-22 09:45:33 -0800 | [diff] [blame] | 2232 | msix_failed: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2233 | qla_printk(KERN_WARNING, ha, "MSI-X: Failed to enable" |
| 2234 | " support, giving up -- %d/%d\n", |
| 2235 | ha->msix_count, ret); |
| 2236 | goto msix_out; |
| 2237 | } |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2238 | ha->max_rsp_queues = ha->msix_count - 1; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2239 | } |
| 2240 | ha->msix_entries = kzalloc(sizeof(struct qla_msix_entry) * |
| 2241 | ha->msix_count, GFP_KERNEL); |
| 2242 | if (!ha->msix_entries) { |
| 2243 | ret = -ENOMEM; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2244 | goto msix_out; |
| 2245 | } |
| 2246 | ha->flags.msix_enabled = 1; |
| 2247 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2248 | for (i = 0; i < ha->msix_count; i++) { |
| 2249 | qentry = &ha->msix_entries[i]; |
| 2250 | qentry->vector = entries[i].vector; |
| 2251 | qentry->entry = entries[i].entry; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2252 | qentry->have_irq = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2253 | qentry->rsp = NULL; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2254 | } |
| 2255 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2256 | /* Enable MSI-X vectors for the base queue */ |
| 2257 | for (i = 0; i < 2; i++) { |
| 2258 | qentry = &ha->msix_entries[i]; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2259 | if (IS_QLA82XX(ha)) { |
| 2260 | ret = request_irq(qentry->vector, |
| 2261 | qla82xx_msix_entries[i].handler, |
| 2262 | 0, qla82xx_msix_entries[i].name, rsp); |
| 2263 | } else { |
| 2264 | ret = request_irq(qentry->vector, |
| 2265 | msix_entries[i].handler, |
| 2266 | 0, msix_entries[i].name, rsp); |
| 2267 | } |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2268 | if (ret) { |
| 2269 | qla_printk(KERN_WARNING, ha, |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2270 | "MSI-X: Unable to register handler -- %x/%d.\n", |
| 2271 | qentry->vector, ret); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2272 | qla24xx_disable_msix(ha); |
| 2273 | ha->mqenable = 0; |
| 2274 | goto msix_out; |
| 2275 | } |
| 2276 | qentry->have_irq = 1; |
| 2277 | qentry->rsp = rsp; |
| 2278 | rsp->msix = qentry; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2279 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2280 | |
| 2281 | /* Enable MSI-X vector for response queue update for queue 0 */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2282 | if (ha->mqiobase && (ha->max_rsp_queues > 1 || ha->max_req_queues > 1)) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2283 | ha->mqenable = 1; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2284 | |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2285 | msix_out: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2286 | kfree(entries); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2287 | return ret; |
| 2288 | } |
| 2289 | |
| 2290 | int |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2291 | qla2x00_request_irqs(struct qla_hw_data *ha, struct rsp_que *rsp) |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2292 | { |
| 2293 | int ret; |
Andrew Vasquez | 963b0fd | 2008-01-31 12:33:50 -0800 | [diff] [blame] | 2294 | device_reg_t __iomem *reg = ha->iobase; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2295 | |
| 2296 | /* If possible, enable MSI-X. */ |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2297 | if (!IS_QLA2432(ha) && !IS_QLA2532(ha) && |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2298 | !IS_QLA8432(ha) && !IS_QLA8XXX_TYPE(ha)) |
Ben Hutchings | 6377a7a | 2010-03-19 16:59:19 -0700 | [diff] [blame] | 2299 | goto skip_msi; |
| 2300 | |
| 2301 | if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_HP && |
| 2302 | (ha->pdev->subsystem_device == 0x7040 || |
| 2303 | ha->pdev->subsystem_device == 0x7041 || |
| 2304 | ha->pdev->subsystem_device == 0x1705)) { |
| 2305 | DEBUG2(qla_printk(KERN_WARNING, ha, |
| 2306 | "MSI-X: Unsupported ISP2432 SSVID/SSDID (0x%X,0x%X).\n", |
| 2307 | ha->pdev->subsystem_vendor, |
| 2308 | ha->pdev->subsystem_device)); |
| 2309 | goto skip_msi; |
| 2310 | } |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2311 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2312 | if (IS_QLA2432(ha) && (ha->pdev->revision < QLA_MSIX_CHIP_REV_24XX || |
| 2313 | !QLA_MSIX_FW_MODE_1(ha->fw_attributes))) { |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2314 | DEBUG2(qla_printk(KERN_WARNING, ha, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2315 | "MSI-X: Unsupported ISP2432 (0x%X, 0x%X).\n", |
| 2316 | ha->pdev->revision, ha->fw_attributes)); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2317 | goto skip_msix; |
| 2318 | } |
| 2319 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2320 | ret = qla24xx_enable_msix(ha, rsp); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2321 | if (!ret) { |
| 2322 | DEBUG2(qla_printk(KERN_INFO, ha, |
| 2323 | "MSI-X: Enabled (0x%X, 0x%X).\n", ha->chip_revision, |
| 2324 | ha->fw_attributes)); |
Andrew Vasquez | 963b0fd | 2008-01-31 12:33:50 -0800 | [diff] [blame] | 2325 | goto clear_risc_ints; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2326 | } |
| 2327 | qla_printk(KERN_WARNING, ha, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2328 | "MSI-X: Falling back-to MSI mode -- %d.\n", ret); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2329 | skip_msix: |
Andrew Vasquez | cbedb60 | 2007-05-07 07:43:02 -0700 | [diff] [blame] | 2330 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2331 | if (!IS_QLA24XX(ha) && !IS_QLA2532(ha) && !IS_QLA8432(ha) && |
| 2332 | !IS_QLA8001(ha)) |
Andrew Vasquez | cbedb60 | 2007-05-07 07:43:02 -0700 | [diff] [blame] | 2333 | goto skip_msi; |
| 2334 | |
| 2335 | ret = pci_enable_msi(ha->pdev); |
| 2336 | if (!ret) { |
| 2337 | DEBUG2(qla_printk(KERN_INFO, ha, "MSI: Enabled.\n")); |
| 2338 | ha->flags.msi_enabled = 1; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2339 | } else |
| 2340 | qla_printk(KERN_WARNING, ha, |
| 2341 | "MSI-X: Falling back-to INTa mode -- %d.\n", ret); |
Andrew Vasquez | cbedb60 | 2007-05-07 07:43:02 -0700 | [diff] [blame] | 2342 | skip_msi: |
| 2343 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2344 | ret = request_irq(ha->pdev->irq, ha->isp_ops->intr_handler, |
Giridhar Malavali | d1b1bef | 2009-03-24 09:08:13 -0700 | [diff] [blame] | 2345 | IRQF_SHARED, QLA2XXX_DRIVER_NAME, rsp); |
Andrew Vasquez | 963b0fd | 2008-01-31 12:33:50 -0800 | [diff] [blame] | 2346 | if (ret) { |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2347 | qla_printk(KERN_WARNING, ha, |
| 2348 | "Failed to reserve interrupt %d already in use.\n", |
| 2349 | ha->pdev->irq); |
Andrew Vasquez | 963b0fd | 2008-01-31 12:33:50 -0800 | [diff] [blame] | 2350 | goto fail; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2351 | } |
Andrew Vasquez | 963b0fd | 2008-01-31 12:33:50 -0800 | [diff] [blame] | 2352 | ha->flags.inta_enabled = 1; |
Andrew Vasquez | 963b0fd | 2008-01-31 12:33:50 -0800 | [diff] [blame] | 2353 | clear_risc_ints: |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2354 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2355 | /* |
| 2356 | * FIXME: Noted that 8014s were being dropped during NK testing. |
| 2357 | * Timing deltas during MSI-X/INTa transitions? |
| 2358 | */ |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2359 | if (IS_QLA81XX(ha) || IS_QLA82XX(ha)) |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2360 | goto fail; |
Andrew Vasquez | c695248 | 2008-04-03 13:13:17 -0700 | [diff] [blame] | 2361 | spin_lock_irq(&ha->hardware_lock); |
Andrew Vasquez | 963b0fd | 2008-01-31 12:33:50 -0800 | [diff] [blame] | 2362 | if (IS_FWI2_CAPABLE(ha)) { |
| 2363 | WRT_REG_DWORD(®->isp24.hccr, HCCRX_CLR_HOST_INT); |
| 2364 | WRT_REG_DWORD(®->isp24.hccr, HCCRX_CLR_RISC_INT); |
| 2365 | } else { |
| 2366 | WRT_REG_WORD(®->isp.semaphore, 0); |
| 2367 | WRT_REG_WORD(®->isp.hccr, HCCR_CLR_RISC_INT); |
| 2368 | WRT_REG_WORD(®->isp.hccr, HCCR_CLR_HOST_INT); |
| 2369 | } |
Andrew Vasquez | c695248 | 2008-04-03 13:13:17 -0700 | [diff] [blame] | 2370 | spin_unlock_irq(&ha->hardware_lock); |
Andrew Vasquez | 963b0fd | 2008-01-31 12:33:50 -0800 | [diff] [blame] | 2371 | |
| 2372 | fail: |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2373 | return ret; |
| 2374 | } |
| 2375 | |
| 2376 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2377 | qla2x00_free_irqs(scsi_qla_host_t *vha) |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2378 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2379 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2380 | struct rsp_que *rsp = ha->rsp_q_map[0]; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2381 | |
| 2382 | if (ha->flags.msix_enabled) |
| 2383 | qla24xx_disable_msix(ha); |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 2384 | else if (ha->flags.msi_enabled) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2385 | free_irq(ha->pdev->irq, rsp); |
Andrew Vasquez | cbedb60 | 2007-05-07 07:43:02 -0700 | [diff] [blame] | 2386 | pci_disable_msi(ha->pdev); |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 2387 | } else |
| 2388 | free_irq(ha->pdev->irq, rsp); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2389 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2390 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2391 | |
| 2392 | int qla25xx_request_irq(struct rsp_que *rsp) |
| 2393 | { |
| 2394 | struct qla_hw_data *ha = rsp->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2395 | struct qla_init_msix_entry *intr = &msix_entries[2]; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2396 | struct qla_msix_entry *msix = rsp->msix; |
| 2397 | int ret; |
| 2398 | |
| 2399 | ret = request_irq(msix->vector, intr->handler, 0, intr->name, rsp); |
| 2400 | if (ret) { |
| 2401 | qla_printk(KERN_WARNING, ha, |
| 2402 | "MSI-X: Unable to register handler -- %x/%d.\n", |
| 2403 | msix->vector, ret); |
| 2404 | return ret; |
| 2405 | } |
| 2406 | msix->have_irq = 1; |
| 2407 | msix->rsp = rsp; |
| 2408 | return ret; |
| 2409 | } |