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