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