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