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