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