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