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