Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * QLOGIC LINUX SOFTWARE |
| 3 | * |
| 4 | * QLogic ISP2x00 device driver for Linux 2.6.x |
Andrew Vasquez | ae91193 | 2005-07-06 10:32:27 -0700 | [diff] [blame] | 5 | * Copyright (C) 2003-2005 QLogic Corporation |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * (www.qlogic.com) |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public License as published by the |
| 10 | * Free Software Foundation; either version 2, or (at your option) any |
| 11 | * later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, but |
| 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | * General Public License for more details. |
| 17 | * |
| 18 | */ |
| 19 | #include "qla_def.h" |
| 20 | |
| 21 | static void qla2x00_mbx_completion(scsi_qla_host_t *, uint16_t); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 22 | static void qla2x00_async_event(scsi_qla_host_t *, uint16_t *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | static void qla2x00_process_completed_request(struct scsi_qla_host *, uint32_t); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 24 | static void qla2x00_status_entry(scsi_qla_host_t *, void *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | static void qla2x00_status_cont_entry(scsi_qla_host_t *, sts_cont_entry_t *); |
| 26 | static void qla2x00_error_entry(scsi_qla_host_t *, sts_entry_t *); |
| 27 | static void qla2x00_ms_entry(scsi_qla_host_t *, ms_iocb_entry_t *); |
| 28 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 29 | static void qla24xx_ms_entry(scsi_qla_host_t *, struct ct_entry_24xx *); |
| 30 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | /** |
| 32 | * qla2100_intr_handler() - Process interrupts for the ISP2100 and ISP2200. |
| 33 | * @irq: |
| 34 | * @dev_id: SCSI driver HA context |
| 35 | * @regs: |
| 36 | * |
| 37 | * Called by system whenever the host adapter generates an interrupt. |
| 38 | * |
| 39 | * Returns handled flag. |
| 40 | */ |
| 41 | irqreturn_t |
| 42 | qla2100_intr_handler(int irq, void *dev_id, struct pt_regs *regs) |
| 43 | { |
| 44 | scsi_qla_host_t *ha; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 45 | struct device_reg_2xxx __iomem *reg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | int status; |
| 47 | unsigned long flags; |
| 48 | unsigned long iter; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 49 | uint16_t mb[4]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
| 51 | ha = (scsi_qla_host_t *) dev_id; |
| 52 | if (!ha) { |
| 53 | printk(KERN_INFO |
| 54 | "%s(): NULL host pointer\n", __func__); |
| 55 | return (IRQ_NONE); |
| 56 | } |
| 57 | |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 58 | reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | status = 0; |
| 60 | |
| 61 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 62 | for (iter = 50; iter--; ) { |
| 63 | if ((RD_REG_WORD(®->istatus) & ISR_RISC_INT) == 0) |
| 64 | break; |
| 65 | |
| 66 | if (RD_REG_WORD(®->semaphore) & BIT_0) { |
| 67 | WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT); |
| 68 | RD_REG_WORD(®->hccr); |
| 69 | |
| 70 | /* Get mailbox data. */ |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 71 | mb[0] = RD_MAILBOX_REG(ha, reg, 0); |
| 72 | if (mb[0] > 0x3fff && mb[0] < 0x8000) { |
| 73 | qla2x00_mbx_completion(ha, mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | status |= MBX_INTERRUPT; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 75 | } else if (mb[0] > 0x7fff && mb[0] < 0xc000) { |
| 76 | mb[1] = RD_MAILBOX_REG(ha, reg, 1); |
| 77 | mb[2] = RD_MAILBOX_REG(ha, reg, 2); |
| 78 | mb[3] = RD_MAILBOX_REG(ha, reg, 3); |
| 79 | qla2x00_async_event(ha, mb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | } else { |
| 81 | /*EMPTY*/ |
| 82 | DEBUG2(printk("scsi(%ld): Unrecognized " |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 83 | "interrupt type (%d).\n", |
| 84 | ha->host_no, mb[0])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | } |
| 86 | /* Release mailbox registers. */ |
| 87 | WRT_REG_WORD(®->semaphore, 0); |
| 88 | RD_REG_WORD(®->semaphore); |
| 89 | } else { |
| 90 | qla2x00_process_response_queue(ha); |
| 91 | |
| 92 | WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT); |
| 93 | RD_REG_WORD(®->hccr); |
| 94 | } |
| 95 | } |
| 96 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 97 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) && |
| 99 | (status & MBX_INTERRUPT) && ha->flags.mbox_int) { |
| 100 | spin_lock_irqsave(&ha->mbx_reg_lock, flags); |
| 101 | |
| 102 | set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
| 103 | up(&ha->mbx_intr_sem); |
| 104 | |
| 105 | spin_unlock_irqrestore(&ha->mbx_reg_lock, flags); |
| 106 | } |
| 107 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | return (IRQ_HANDLED); |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * qla2300_intr_handler() - Process interrupts for the ISP23xx and ISP63xx. |
| 113 | * @irq: |
| 114 | * @dev_id: SCSI driver HA context |
| 115 | * @regs: |
| 116 | * |
| 117 | * Called by system whenever the host adapter generates an interrupt. |
| 118 | * |
| 119 | * Returns handled flag. |
| 120 | */ |
| 121 | irqreturn_t |
| 122 | qla2300_intr_handler(int irq, void *dev_id, struct pt_regs *regs) |
| 123 | { |
| 124 | scsi_qla_host_t *ha; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 125 | struct device_reg_2xxx __iomem *reg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | int status; |
| 127 | unsigned long flags; |
| 128 | unsigned long iter; |
| 129 | uint32_t stat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | uint16_t hccr; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 131 | uint16_t mb[4]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | |
| 133 | ha = (scsi_qla_host_t *) dev_id; |
| 134 | if (!ha) { |
| 135 | printk(KERN_INFO |
| 136 | "%s(): NULL host pointer\n", __func__); |
| 137 | return (IRQ_NONE); |
| 138 | } |
| 139 | |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 140 | reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | status = 0; |
| 142 | |
| 143 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 144 | for (iter = 50; iter--; ) { |
| 145 | stat = RD_REG_DWORD(®->u.isp2300.host_status); |
| 146 | if (stat & HSR_RISC_PAUSED) { |
| 147 | hccr = RD_REG_WORD(®->hccr); |
| 148 | if (hccr & (BIT_15 | BIT_13 | BIT_11 | BIT_8)) |
| 149 | qla_printk(KERN_INFO, ha, |
| 150 | "Parity error -- HCCR=%x.\n", hccr); |
| 151 | else |
| 152 | qla_printk(KERN_INFO, ha, |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 153 | "RISC paused -- HCCR=%x.\n", hccr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | |
| 155 | /* |
| 156 | * Issue a "HARD" reset in order for the RISC |
| 157 | * interrupt bit to be cleared. Schedule a big |
| 158 | * hammmer to get out of the RISC PAUSED state. |
| 159 | */ |
| 160 | WRT_REG_WORD(®->hccr, HCCR_RESET_RISC); |
| 161 | RD_REG_WORD(®->hccr); |
| 162 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); |
| 163 | break; |
| 164 | } else if ((stat & HSR_RISC_INT) == 0) |
| 165 | break; |
| 166 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | switch (stat & 0xff) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | case 0x1: |
| 169 | case 0x2: |
| 170 | case 0x10: |
| 171 | case 0x11: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 172 | qla2x00_mbx_completion(ha, MSW(stat)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | status |= MBX_INTERRUPT; |
| 174 | |
| 175 | /* Release mailbox registers. */ |
| 176 | WRT_REG_WORD(®->semaphore, 0); |
| 177 | break; |
| 178 | case 0x12: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 179 | mb[0] = MSW(stat); |
| 180 | mb[1] = RD_MAILBOX_REG(ha, reg, 1); |
| 181 | mb[2] = RD_MAILBOX_REG(ha, reg, 2); |
| 182 | mb[3] = RD_MAILBOX_REG(ha, reg, 3); |
| 183 | qla2x00_async_event(ha, mb); |
| 184 | break; |
| 185 | case 0x13: |
| 186 | qla2x00_process_response_queue(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | break; |
| 188 | case 0x15: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 189 | mb[0] = MBA_CMPLT_1_16BIT; |
| 190 | mb[1] = MSW(stat); |
| 191 | qla2x00_async_event(ha, mb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | break; |
| 193 | case 0x16: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 194 | mb[0] = MBA_SCSI_COMPLETION; |
| 195 | mb[1] = MSW(stat); |
| 196 | mb[2] = RD_MAILBOX_REG(ha, reg, 2); |
| 197 | qla2x00_async_event(ha, mb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | break; |
| 199 | default: |
| 200 | DEBUG2(printk("scsi(%ld): Unrecognized interrupt type " |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 201 | "(%d).\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | ha->host_no, stat & 0xff)); |
| 203 | break; |
| 204 | } |
| 205 | WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT); |
| 206 | RD_REG_WORD_RELAXED(®->hccr); |
| 207 | } |
| 208 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 209 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) && |
| 211 | (status & MBX_INTERRUPT) && ha->flags.mbox_int) { |
| 212 | spin_lock_irqsave(&ha->mbx_reg_lock, flags); |
| 213 | |
| 214 | set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
| 215 | up(&ha->mbx_intr_sem); |
| 216 | |
| 217 | spin_unlock_irqrestore(&ha->mbx_reg_lock, flags); |
| 218 | } |
| 219 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | return (IRQ_HANDLED); |
| 221 | } |
| 222 | |
| 223 | /** |
| 224 | * qla2x00_mbx_completion() - Process mailbox command completions. |
| 225 | * @ha: SCSI driver HA context |
| 226 | * @mb0: Mailbox0 register |
| 227 | */ |
| 228 | static void |
| 229 | qla2x00_mbx_completion(scsi_qla_host_t *ha, uint16_t mb0) |
| 230 | { |
| 231 | uint16_t cnt; |
| 232 | uint16_t __iomem *wptr; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 233 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | |
| 235 | /* Load return mailbox registers. */ |
| 236 | ha->flags.mbox_int = 1; |
| 237 | ha->mailbox_out[0] = mb0; |
| 238 | wptr = (uint16_t __iomem *)MAILBOX_REG(ha, reg, 1); |
| 239 | |
| 240 | for (cnt = 1; cnt < ha->mbx_count; cnt++) { |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 241 | if (IS_QLA2200(ha) && cnt == 8) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | wptr = (uint16_t __iomem *)MAILBOX_REG(ha, reg, 8); |
| 243 | if (cnt == 4 || cnt == 5) |
| 244 | ha->mailbox_out[cnt] = qla2x00_debounce_register(wptr); |
| 245 | else |
| 246 | ha->mailbox_out[cnt] = RD_REG_WORD(wptr); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 247 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | wptr++; |
| 249 | } |
| 250 | |
| 251 | if (ha->mcp) { |
| 252 | DEBUG3(printk("%s(%ld): Got mailbox completion. cmd=%x.\n", |
| 253 | __func__, ha->host_no, ha->mcp->mb[0])); |
| 254 | } else { |
| 255 | DEBUG2_3(printk("%s(%ld): MBX pointer ERROR!\n", |
| 256 | __func__, ha->host_no)); |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | /** |
| 261 | * qla2x00_async_event() - Process aynchronous events. |
| 262 | * @ha: SCSI driver HA context |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 263 | * @mb: Mailbox registers (0 - 3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | */ |
| 265 | static void |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 266 | qla2x00_async_event(scsi_qla_host_t *ha, uint16_t *mb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 268 | #define LS_UNKNOWN 2 |
| 269 | static char *link_speeds[5] = { "1", "2", "?", "4", "10" }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | char *link_speed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | uint16_t handle_cnt; |
| 272 | uint16_t cnt; |
| 273 | uint32_t handles[5]; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 274 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | uint32_t rscn_entry, host_pid; |
| 276 | uint8_t rscn_queue_index; |
| 277 | |
| 278 | /* Setup to process RIO completion. */ |
| 279 | handle_cnt = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | switch (mb[0]) { |
| 281 | case MBA_SCSI_COMPLETION: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 282 | handles[0] = le32_to_cpu((uint32_t)((mb[2] << 16) | mb[1])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | handle_cnt = 1; |
| 284 | break; |
| 285 | case MBA_CMPLT_1_16BIT: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 286 | handles[0] = mb[1]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | handle_cnt = 1; |
| 288 | mb[0] = MBA_SCSI_COMPLETION; |
| 289 | break; |
| 290 | case MBA_CMPLT_2_16BIT: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 291 | handles[0] = mb[1]; |
| 292 | handles[1] = mb[2]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | handle_cnt = 2; |
| 294 | mb[0] = MBA_SCSI_COMPLETION; |
| 295 | break; |
| 296 | case MBA_CMPLT_3_16BIT: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 297 | handles[0] = mb[1]; |
| 298 | handles[1] = mb[2]; |
| 299 | handles[2] = mb[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | handle_cnt = 3; |
| 301 | mb[0] = MBA_SCSI_COMPLETION; |
| 302 | break; |
| 303 | case MBA_CMPLT_4_16BIT: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 304 | handles[0] = mb[1]; |
| 305 | handles[1] = mb[2]; |
| 306 | handles[2] = mb[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | handles[3] = (uint32_t)RD_MAILBOX_REG(ha, reg, 6); |
| 308 | handle_cnt = 4; |
| 309 | mb[0] = MBA_SCSI_COMPLETION; |
| 310 | break; |
| 311 | case MBA_CMPLT_5_16BIT: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 312 | handles[0] = mb[1]; |
| 313 | handles[1] = mb[2]; |
| 314 | handles[2] = mb[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | handles[3] = (uint32_t)RD_MAILBOX_REG(ha, reg, 6); |
| 316 | handles[4] = (uint32_t)RD_MAILBOX_REG(ha, reg, 7); |
| 317 | handle_cnt = 5; |
| 318 | mb[0] = MBA_SCSI_COMPLETION; |
| 319 | break; |
| 320 | case MBA_CMPLT_2_32BIT: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 321 | handles[0] = le32_to_cpu((uint32_t)((mb[2] << 16) | mb[1])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | handles[1] = le32_to_cpu( |
| 323 | ((uint32_t)(RD_MAILBOX_REG(ha, reg, 7) << 16)) | |
| 324 | RD_MAILBOX_REG(ha, reg, 6)); |
| 325 | handle_cnt = 2; |
| 326 | mb[0] = MBA_SCSI_COMPLETION; |
| 327 | break; |
| 328 | default: |
| 329 | break; |
| 330 | } |
| 331 | |
| 332 | switch (mb[0]) { |
| 333 | case MBA_SCSI_COMPLETION: /* Fast Post */ |
| 334 | if (!ha->flags.online) |
| 335 | break; |
| 336 | |
| 337 | for (cnt = 0; cnt < handle_cnt; cnt++) |
| 338 | qla2x00_process_completed_request(ha, handles[cnt]); |
| 339 | break; |
| 340 | |
| 341 | case MBA_RESET: /* Reset */ |
| 342 | DEBUG2(printk("scsi(%ld): Asynchronous RESET.\n", ha->host_no)); |
| 343 | |
| 344 | set_bit(RESET_MARKER_NEEDED, &ha->dpc_flags); |
| 345 | break; |
| 346 | |
| 347 | case MBA_SYSTEM_ERR: /* System Error */ |
| 348 | mb[1] = RD_MAILBOX_REG(ha, reg, 1); |
| 349 | mb[2] = RD_MAILBOX_REG(ha, reg, 2); |
| 350 | mb[3] = RD_MAILBOX_REG(ha, reg, 3); |
| 351 | |
| 352 | qla_printk(KERN_INFO, ha, |
| 353 | "ISP System Error - mbx1=%xh mbx2=%xh mbx3=%xh.\n", |
| 354 | mb[1], mb[2], mb[3]); |
| 355 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 356 | ha->isp_ops.fw_dump(ha, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 358 | if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) { |
| 359 | if (mb[1] == 0 && mb[2] == 0) { |
| 360 | qla_printk(KERN_ERR, ha, |
| 361 | "Unrecoverable Hardware Error: adapter " |
| 362 | "marked OFFLINE!\n"); |
| 363 | ha->flags.online = 0; |
| 364 | } else |
| 365 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); |
| 366 | } else if (mb[1] == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | qla_printk(KERN_INFO, ha, |
| 368 | "Unrecoverable Hardware Error: adapter marked " |
| 369 | "OFFLINE!\n"); |
| 370 | ha->flags.online = 0; |
| 371 | } else |
| 372 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); |
| 373 | break; |
| 374 | |
| 375 | case MBA_REQ_TRANSFER_ERR: /* Request Transfer Error */ |
| 376 | DEBUG2(printk("scsi(%ld): ISP Request Transfer Error.\n", |
| 377 | ha->host_no)); |
| 378 | qla_printk(KERN_WARNING, ha, "ISP Request Transfer Error.\n"); |
| 379 | |
| 380 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); |
| 381 | break; |
| 382 | |
| 383 | case MBA_RSP_TRANSFER_ERR: /* Response Transfer Error */ |
| 384 | DEBUG2(printk("scsi(%ld): ISP Response Transfer Error.\n", |
| 385 | ha->host_no)); |
| 386 | qla_printk(KERN_WARNING, ha, "ISP Response Transfer Error.\n"); |
| 387 | |
| 388 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); |
| 389 | break; |
| 390 | |
| 391 | case MBA_WAKEUP_THRES: /* Request Queue Wake-up */ |
| 392 | DEBUG2(printk("scsi(%ld): Asynchronous WAKEUP_THRES.\n", |
| 393 | ha->host_no)); |
| 394 | break; |
| 395 | |
| 396 | case MBA_LIP_OCCURRED: /* Loop Initialization Procedure */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | DEBUG2(printk("scsi(%ld): LIP occured (%x).\n", ha->host_no, |
| 398 | mb[1])); |
| 399 | qla_printk(KERN_INFO, ha, "LIP occured (%x).\n", mb[1]); |
| 400 | |
| 401 | if (atomic_read(&ha->loop_state) != LOOP_DOWN) { |
| 402 | atomic_set(&ha->loop_state, LOOP_DOWN); |
| 403 | atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); |
| 404 | qla2x00_mark_all_devices_lost(ha); |
| 405 | } |
| 406 | |
| 407 | set_bit(REGISTER_FC4_NEEDED, &ha->dpc_flags); |
| 408 | |
| 409 | ha->flags.management_server_logged_in = 0; |
| 410 | |
| 411 | /* Update AEN queue. */ |
| 412 | qla2x00_enqueue_aen(ha, MBA_LIP_OCCURRED, NULL); |
| 413 | |
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 | ha->link_data_rate = 0; |
| 418 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
| 419 | link_speed = link_speeds[0]; |
| 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; |
| 433 | |
| 434 | /* Update AEN queue. */ |
| 435 | qla2x00_enqueue_aen(ha, MBA_LOOP_UP, NULL); |
| 436 | break; |
| 437 | |
| 438 | case MBA_LOOP_DOWN: /* Loop Down Event */ |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 439 | DEBUG2(printk("scsi(%ld): Asynchronous LOOP DOWN (%x).\n", |
| 440 | ha->host_no, mb[1])); |
| 441 | qla_printk(KERN_INFO, ha, "LOOP DOWN detected (%x).\n", mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | |
| 443 | if (atomic_read(&ha->loop_state) != LOOP_DOWN) { |
| 444 | atomic_set(&ha->loop_state, LOOP_DOWN); |
| 445 | atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); |
| 446 | ha->device_flags |= DFLG_NO_CABLE; |
| 447 | qla2x00_mark_all_devices_lost(ha); |
| 448 | } |
| 449 | |
| 450 | ha->flags.management_server_logged_in = 0; |
| 451 | ha->link_data_rate = 0; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 452 | if (ql2xfdmienable) |
| 453 | set_bit(REGISTER_FDMI_NEEDED, &ha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | |
| 455 | /* Update AEN queue. */ |
| 456 | qla2x00_enqueue_aen(ha, MBA_LOOP_DOWN, NULL); |
| 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, |
| 463 | "LIP reset occured (%x).\n", mb[1]); |
| 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); |
| 468 | qla2x00_mark_all_devices_lost(ha); |
| 469 | } |
| 470 | |
| 471 | set_bit(RESET_MARKER_NEEDED, &ha->dpc_flags); |
| 472 | |
| 473 | ha->operating_mode = LOOP; |
| 474 | ha->flags.management_server_logged_in = 0; |
| 475 | |
| 476 | /* Update AEN queue. */ |
| 477 | qla2x00_enqueue_aen(ha, MBA_LIP_RESET, NULL); |
| 478 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | break; |
| 480 | |
| 481 | case MBA_POINT_TO_POINT: /* Point-to-Point */ |
| 482 | if (IS_QLA2100(ha)) |
| 483 | break; |
| 484 | |
| 485 | DEBUG2(printk("scsi(%ld): Asynchronous P2P MODE received.\n", |
| 486 | ha->host_no)); |
| 487 | |
| 488 | /* |
| 489 | * Until there's a transition from loop down to loop up, treat |
| 490 | * this as loop down only. |
| 491 | */ |
| 492 | if (atomic_read(&ha->loop_state) != LOOP_DOWN) { |
| 493 | atomic_set(&ha->loop_state, LOOP_DOWN); |
| 494 | if (!atomic_read(&ha->loop_down_timer)) |
| 495 | atomic_set(&ha->loop_down_timer, |
| 496 | LOOP_DOWN_TIME); |
| 497 | qla2x00_mark_all_devices_lost(ha); |
| 498 | } |
| 499 | |
| 500 | if (!(test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags))) { |
| 501 | set_bit(RESET_MARKER_NEEDED, &ha->dpc_flags); |
| 502 | } |
| 503 | set_bit(REGISTER_FC4_NEEDED, &ha->dpc_flags); |
| 504 | break; |
| 505 | |
| 506 | case MBA_CHG_IN_CONNECTION: /* Change in connection mode */ |
| 507 | if (IS_QLA2100(ha)) |
| 508 | break; |
| 509 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | DEBUG2(printk("scsi(%ld): Asynchronous Change In Connection " |
| 511 | "received.\n", |
| 512 | ha->host_no)); |
| 513 | qla_printk(KERN_INFO, ha, |
| 514 | "Configuration change detected: value=%x.\n", mb[1]); |
| 515 | |
| 516 | if (atomic_read(&ha->loop_state) != LOOP_DOWN) { |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 517 | atomic_set(&ha->loop_state, LOOP_DOWN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 518 | if (!atomic_read(&ha->loop_down_timer)) |
| 519 | atomic_set(&ha->loop_down_timer, |
| 520 | LOOP_DOWN_TIME); |
| 521 | qla2x00_mark_all_devices_lost(ha); |
| 522 | } |
| 523 | |
| 524 | set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags); |
| 525 | set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags); |
| 526 | break; |
| 527 | |
| 528 | case MBA_PORT_UPDATE: /* Port database update */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | /* |
| 530 | * If a single remote port just logged into (or logged out of) |
| 531 | * us, create a new entry in our rscn fcports list and handle |
| 532 | * the event like an RSCN. |
| 533 | */ |
| 534 | if (!IS_QLA2100(ha) && !IS_QLA2200(ha) && !IS_QLA6312(ha) && |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 535 | !IS_QLA6322(ha) && !IS_QLA24XX(ha) && !IS_QLA25XX(ha) && |
| 536 | ha->flags.init_done && mb[1] != 0xffff && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 537 | ((ha->operating_mode == P2P && mb[1] != 0) || |
| 538 | (ha->operating_mode != P2P && mb[1] != |
| 539 | SNS_FIRST_LOOP_ID)) && (mb[2] == 6 || mb[2] == 7)) { |
| 540 | int rval; |
| 541 | fc_port_t *rscn_fcport; |
| 542 | |
| 543 | /* Create new fcport for login. */ |
| 544 | rscn_fcport = qla2x00_alloc_rscn_fcport(ha, GFP_ATOMIC); |
| 545 | if (rscn_fcport) { |
| 546 | DEBUG14(printk("scsi(%ld): Port Update -- " |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 547 | "creating RSCN fcport %p for %x/%x/%x.\n", |
| 548 | ha->host_no, rscn_fcport, mb[1], mb[2], |
| 549 | mb[3])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | |
| 551 | rscn_fcport->loop_id = mb[1]; |
| 552 | rscn_fcport->d_id.b24 = INVALID_PORT_ID; |
| 553 | atomic_set(&rscn_fcport->state, |
| 554 | FCS_DEVICE_LOST); |
| 555 | list_add_tail(&rscn_fcport->list, |
| 556 | &ha->rscn_fcports); |
| 557 | |
| 558 | rval = qla2x00_handle_port_rscn(ha, 0, |
| 559 | rscn_fcport, 1); |
| 560 | if (rval == QLA_SUCCESS) |
| 561 | break; |
| 562 | } else { |
| 563 | DEBUG14(printk("scsi(%ld): Port Update -- " |
| 564 | "-- unable to allocate RSCN fcport " |
| 565 | "login.\n", ha->host_no)); |
| 566 | } |
| 567 | } |
| 568 | |
| 569 | /* |
| 570 | * If PORT UPDATE is global (recieved LIP_OCCURED/LIP_RESET |
| 571 | * event etc. earlier indicating loop is down) then process |
| 572 | * it. Otherwise ignore it and Wait for RSCN to come in. |
| 573 | */ |
| 574 | atomic_set(&ha->loop_down_timer, 0); |
| 575 | if (atomic_read(&ha->loop_state) != LOOP_DOWN && |
| 576 | atomic_read(&ha->loop_state) != LOOP_DEAD) { |
| 577 | DEBUG2(printk("scsi(%ld): Asynchronous PORT UPDATE " |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 578 | "ignored %04x/%04x/%04x.\n", ha->host_no, mb[1], |
| 579 | mb[2], mb[3])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 | break; |
| 581 | } |
| 582 | |
| 583 | DEBUG2(printk("scsi(%ld): Asynchronous PORT UPDATE.\n", |
| 584 | ha->host_no)); |
| 585 | DEBUG(printk(KERN_INFO |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 586 | "scsi(%ld): Port database changed %04x %04x %04x.\n", |
| 587 | ha->host_no, mb[1], mb[2], mb[3])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 588 | |
| 589 | /* |
| 590 | * Mark all devices as missing so we will login again. |
| 591 | */ |
| 592 | atomic_set(&ha->loop_state, LOOP_UP); |
| 593 | |
| 594 | qla2x00_mark_all_devices_lost(ha); |
| 595 | |
| 596 | ha->flags.rscn_queue_overflow = 1; |
| 597 | |
| 598 | set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags); |
| 599 | set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags); |
| 600 | |
| 601 | /* Update AEN queue. */ |
| 602 | qla2x00_enqueue_aen(ha, MBA_PORT_UPDATE, NULL); |
| 603 | break; |
| 604 | |
| 605 | case MBA_RSCN_UPDATE: /* State Change Registration */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | DEBUG2(printk("scsi(%ld): Asynchronous RSCR UPDATE.\n", |
| 607 | ha->host_no)); |
| 608 | DEBUG(printk(KERN_INFO |
| 609 | "scsi(%ld): RSCN database changed -- %04x %04x.\n", |
| 610 | ha->host_no, mb[1], mb[2])); |
| 611 | |
| 612 | rscn_entry = (mb[1] << 16) | mb[2]; |
| 613 | host_pid = (ha->d_id.b.domain << 16) | (ha->d_id.b.area << 8) | |
| 614 | ha->d_id.b.al_pa; |
| 615 | if (rscn_entry == host_pid) { |
| 616 | DEBUG(printk(KERN_INFO |
| 617 | "scsi(%ld): Ignoring RSCN update to local host " |
| 618 | "port ID (%06x)\n", |
| 619 | ha->host_no, host_pid)); |
| 620 | break; |
| 621 | } |
| 622 | |
| 623 | rscn_queue_index = ha->rscn_in_ptr + 1; |
| 624 | if (rscn_queue_index == MAX_RSCN_COUNT) |
| 625 | rscn_queue_index = 0; |
| 626 | if (rscn_queue_index != ha->rscn_out_ptr) { |
| 627 | ha->rscn_queue[ha->rscn_in_ptr] = rscn_entry; |
| 628 | ha->rscn_in_ptr = rscn_queue_index; |
| 629 | } else { |
| 630 | ha->flags.rscn_queue_overflow = 1; |
| 631 | } |
| 632 | |
| 633 | atomic_set(&ha->loop_state, LOOP_UPDATE); |
| 634 | atomic_set(&ha->loop_down_timer, 0); |
| 635 | ha->flags.management_server_logged_in = 0; |
| 636 | |
| 637 | set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags); |
| 638 | set_bit(RSCN_UPDATE, &ha->dpc_flags); |
| 639 | |
| 640 | /* Update AEN queue. */ |
| 641 | qla2x00_enqueue_aen(ha, MBA_RSCN_UPDATE, &mb[0]); |
| 642 | break; |
| 643 | |
| 644 | /* case MBA_RIO_RESPONSE: */ |
| 645 | case MBA_ZIO_RESPONSE: |
| 646 | DEBUG2(printk("scsi(%ld): [R|Z]IO update completion.\n", |
| 647 | ha->host_no)); |
| 648 | DEBUG(printk(KERN_INFO |
| 649 | "scsi(%ld): [R|Z]IO update completion.\n", |
| 650 | ha->host_no)); |
| 651 | |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 652 | if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) |
| 653 | qla24xx_process_response_queue(ha); |
| 654 | else |
| 655 | qla2x00_process_response_queue(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 656 | break; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 657 | |
| 658 | case MBA_DISCARD_RND_FRAME: |
| 659 | DEBUG2(printk("scsi(%ld): Discard RND Frame -- %04x %04x " |
| 660 | "%04x.\n", ha->host_no, mb[1], mb[2], mb[3])); |
| 661 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | } |
| 663 | } |
| 664 | |
| 665 | /** |
| 666 | * qla2x00_process_completed_request() - Process a Fast Post response. |
| 667 | * @ha: SCSI driver HA context |
| 668 | * @index: SRB index |
| 669 | */ |
| 670 | static void |
| 671 | qla2x00_process_completed_request(struct scsi_qla_host *ha, uint32_t index) |
| 672 | { |
| 673 | srb_t *sp; |
| 674 | |
| 675 | /* Validate handle. */ |
| 676 | if (index >= MAX_OUTSTANDING_COMMANDS) { |
| 677 | DEBUG2(printk("scsi(%ld): Invalid SCSI completion handle %d.\n", |
| 678 | ha->host_no, index)); |
| 679 | qla_printk(KERN_WARNING, ha, |
| 680 | "Invalid SCSI completion handle %d.\n", index); |
| 681 | |
| 682 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); |
| 683 | return; |
| 684 | } |
| 685 | |
| 686 | sp = ha->outstanding_cmds[index]; |
| 687 | if (sp) { |
| 688 | /* Free outstanding command slot. */ |
| 689 | ha->outstanding_cmds[index] = NULL; |
| 690 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | CMD_COMPL_STATUS(sp->cmd) = 0L; |
| 692 | CMD_SCSI_STATUS(sp->cmd) = 0L; |
| 693 | |
| 694 | /* Save ISP completion status */ |
| 695 | sp->cmd->result = DID_OK << 16; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 696 | qla2x00_sp_compl(ha, sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 697 | } else { |
| 698 | DEBUG2(printk("scsi(%ld): Invalid ISP SCSI completion handle\n", |
| 699 | ha->host_no)); |
| 700 | qla_printk(KERN_WARNING, ha, |
| 701 | "Invalid ISP SCSI completion handle\n"); |
| 702 | |
| 703 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); |
| 704 | } |
| 705 | } |
| 706 | |
| 707 | /** |
| 708 | * qla2x00_process_response_queue() - Process response queue entries. |
| 709 | * @ha: SCSI driver HA context |
| 710 | */ |
| 711 | void |
| 712 | qla2x00_process_response_queue(struct scsi_qla_host *ha) |
| 713 | { |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 714 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 715 | sts_entry_t *pkt; |
| 716 | uint16_t handle_cnt; |
| 717 | uint16_t cnt; |
| 718 | |
| 719 | if (!ha->flags.online) |
| 720 | return; |
| 721 | |
| 722 | while (ha->response_ring_ptr->signature != RESPONSE_PROCESSED) { |
| 723 | pkt = (sts_entry_t *)ha->response_ring_ptr; |
| 724 | |
| 725 | ha->rsp_ring_index++; |
| 726 | if (ha->rsp_ring_index == ha->response_q_length) { |
| 727 | ha->rsp_ring_index = 0; |
| 728 | ha->response_ring_ptr = ha->response_ring; |
| 729 | } else { |
| 730 | ha->response_ring_ptr++; |
| 731 | } |
| 732 | |
| 733 | if (pkt->entry_status != 0) { |
| 734 | DEBUG3(printk(KERN_INFO |
| 735 | "scsi(%ld): Process error entry.\n", ha->host_no)); |
| 736 | |
| 737 | qla2x00_error_entry(ha, pkt); |
| 738 | ((response_t *)pkt)->signature = RESPONSE_PROCESSED; |
| 739 | wmb(); |
| 740 | continue; |
| 741 | } |
| 742 | |
| 743 | switch (pkt->entry_type) { |
| 744 | case STATUS_TYPE: |
| 745 | qla2x00_status_entry(ha, pkt); |
| 746 | break; |
| 747 | case STATUS_TYPE_21: |
| 748 | handle_cnt = ((sts21_entry_t *)pkt)->handle_count; |
| 749 | for (cnt = 0; cnt < handle_cnt; cnt++) { |
| 750 | qla2x00_process_completed_request(ha, |
| 751 | ((sts21_entry_t *)pkt)->handle[cnt]); |
| 752 | } |
| 753 | break; |
| 754 | case STATUS_TYPE_22: |
| 755 | handle_cnt = ((sts22_entry_t *)pkt)->handle_count; |
| 756 | for (cnt = 0; cnt < handle_cnt; cnt++) { |
| 757 | qla2x00_process_completed_request(ha, |
| 758 | ((sts22_entry_t *)pkt)->handle[cnt]); |
| 759 | } |
| 760 | break; |
| 761 | case STATUS_CONT_TYPE: |
| 762 | qla2x00_status_cont_entry(ha, (sts_cont_entry_t *)pkt); |
| 763 | break; |
| 764 | case MS_IOCB_TYPE: |
| 765 | qla2x00_ms_entry(ha, (ms_iocb_entry_t *)pkt); |
| 766 | break; |
| 767 | case MBX_IOCB_TYPE: |
| 768 | if (!IS_QLA2100(ha) && !IS_QLA2200(ha) && |
| 769 | !IS_QLA6312(ha) && !IS_QLA6322(ha)) { |
| 770 | if (pkt->sys_define == SOURCE_ASYNC_IOCB) { |
| 771 | qla2x00_process_iodesc(ha, |
| 772 | (struct mbx_entry *)pkt); |
| 773 | } else { |
| 774 | /* MBX IOCB Type Not Supported. */ |
| 775 | DEBUG4(printk(KERN_WARNING |
| 776 | "scsi(%ld): Received unknown MBX " |
| 777 | "IOCB response pkt type=%x " |
| 778 | "source=%x entry status=%x.\n", |
| 779 | ha->host_no, pkt->entry_type, |
| 780 | pkt->sys_define, |
| 781 | pkt->entry_status)); |
| 782 | } |
| 783 | break; |
| 784 | } |
| 785 | /* Fallthrough. */ |
| 786 | default: |
| 787 | /* Type Not Supported. */ |
| 788 | DEBUG4(printk(KERN_WARNING |
| 789 | "scsi(%ld): Received unknown response pkt type %x " |
| 790 | "entry status=%x.\n", |
| 791 | ha->host_no, pkt->entry_type, pkt->entry_status)); |
| 792 | break; |
| 793 | } |
| 794 | ((response_t *)pkt)->signature = RESPONSE_PROCESSED; |
| 795 | wmb(); |
| 796 | } |
| 797 | |
| 798 | /* Adjust ring index */ |
| 799 | WRT_REG_WORD(ISP_RSP_Q_OUT(ha, reg), ha->rsp_ring_index); |
| 800 | } |
| 801 | |
| 802 | /** |
| 803 | * qla2x00_status_entry() - Process a Status IOCB entry. |
| 804 | * @ha: SCSI driver HA context |
| 805 | * @pkt: Entry pointer |
| 806 | */ |
| 807 | static void |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 808 | qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 809 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 810 | srb_t *sp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 811 | fc_port_t *fcport; |
| 812 | struct scsi_cmnd *cp; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 813 | sts_entry_t *sts; |
| 814 | struct sts_entry_24xx *sts24; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 815 | uint16_t comp_status; |
| 816 | uint16_t scsi_status; |
| 817 | uint8_t lscsi_status; |
| 818 | int32_t resid; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 819 | uint32_t sense_len, rsp_info_len, resid_len; |
| 820 | uint8_t *rsp_info, *sense_data; |
| 821 | |
| 822 | sts = (sts_entry_t *) pkt; |
| 823 | sts24 = (struct sts_entry_24xx *) pkt; |
| 824 | if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) { |
| 825 | comp_status = le16_to_cpu(sts24->comp_status); |
| 826 | scsi_status = le16_to_cpu(sts24->scsi_status) & SS_MASK; |
| 827 | } else { |
| 828 | comp_status = le16_to_cpu(sts->comp_status); |
| 829 | scsi_status = le16_to_cpu(sts->scsi_status) & SS_MASK; |
| 830 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 831 | |
| 832 | /* Fast path completion. */ |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 833 | if (comp_status == CS_COMPLETE && scsi_status == 0) { |
| 834 | qla2x00_process_completed_request(ha, sts->handle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 835 | |
| 836 | return; |
| 837 | } |
| 838 | |
| 839 | /* Validate handle. */ |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 840 | if (sts->handle < MAX_OUTSTANDING_COMMANDS) { |
| 841 | sp = ha->outstanding_cmds[sts->handle]; |
| 842 | ha->outstanding_cmds[sts->handle] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 843 | } else |
| 844 | sp = NULL; |
| 845 | |
| 846 | if (sp == NULL) { |
| 847 | DEBUG2(printk("scsi(%ld): Status Entry invalid handle.\n", |
| 848 | ha->host_no)); |
| 849 | qla_printk(KERN_WARNING, ha, "Status Entry invalid handle.\n"); |
| 850 | |
| 851 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 852 | if (ha->dpc_wait && !ha->dpc_active) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 853 | up(ha->dpc_wait); |
| 854 | |
| 855 | return; |
| 856 | } |
| 857 | cp = sp->cmd; |
| 858 | if (cp == NULL) { |
| 859 | DEBUG2(printk("scsi(%ld): Command already returned back to OS " |
| 860 | "pkt->handle=%d sp=%p sp->state:%d\n", |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 861 | ha->host_no, sts->handle, sp, sp->state)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 862 | qla_printk(KERN_WARNING, ha, |
| 863 | "Command is NULL: already returned to OS (sp=%p)\n", sp); |
| 864 | |
| 865 | return; |
| 866 | } |
| 867 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 868 | lscsi_status = scsi_status & STATUS_MASK; |
| 869 | CMD_ENTRY_STATUS(cp) = sts->entry_status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 870 | CMD_COMPL_STATUS(cp) = comp_status; |
| 871 | CMD_SCSI_STATUS(cp) = scsi_status; |
| 872 | |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 873 | fcport = sp->fcport; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 874 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 875 | sense_len = rsp_info_len = resid_len = 0; |
| 876 | if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) { |
| 877 | sense_len = le32_to_cpu(sts24->sense_len); |
| 878 | rsp_info_len = le32_to_cpu(sts24->rsp_data_len); |
| 879 | resid_len = le32_to_cpu(sts24->rsp_residual_count); |
| 880 | rsp_info = sts24->data; |
| 881 | sense_data = sts24->data; |
| 882 | host_to_fcp_swap(sts24->data, sizeof(sts24->data)); |
| 883 | } else { |
| 884 | sense_len = le16_to_cpu(sts->req_sense_length); |
| 885 | rsp_info_len = le16_to_cpu(sts->rsp_info_len); |
| 886 | resid_len = le32_to_cpu(sts->residual_length); |
| 887 | rsp_info = sts->rsp_info; |
| 888 | sense_data = sts->req_sense_data; |
| 889 | } |
| 890 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 891 | /* Check for any FCP transport errors. */ |
| 892 | if (scsi_status & SS_RESPONSE_INFO_LEN_VALID) { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 893 | /* Sense data lies beyond any FCP RESPONSE data. */ |
| 894 | if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) |
| 895 | sense_data += rsp_info_len; |
| 896 | if (rsp_info_len > 3 && rsp_info[3]) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 897 | DEBUG2(printk("scsi(%ld:%d:%d:%d) FCP I/O protocol " |
| 898 | "failure (%x/%02x%02x%02x%02x%02x%02x%02x%02x)..." |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 899 | "retrying command\n", ha->host_no, |
| 900 | cp->device->channel, cp->device->id, |
| 901 | cp->device->lun, rsp_info_len, rsp_info[0], |
| 902 | rsp_info[1], rsp_info[2], rsp_info[3], rsp_info[4], |
| 903 | rsp_info[5], rsp_info[6], rsp_info[7])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 904 | |
| 905 | cp->result = DID_BUS_BUSY << 16; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 906 | qla2x00_sp_compl(ha, sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 907 | return; |
| 908 | } |
| 909 | } |
| 910 | |
| 911 | /* |
| 912 | * Based on Host and scsi status generate status code for Linux |
| 913 | */ |
| 914 | switch (comp_status) { |
| 915 | case CS_COMPLETE: |
| 916 | if (scsi_status == 0) { |
| 917 | cp->result = DID_OK << 16; |
| 918 | break; |
| 919 | } |
| 920 | if (scsi_status & (SS_RESIDUAL_UNDER | SS_RESIDUAL_OVER)) { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 921 | resid = resid_len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 922 | cp->resid = resid; |
| 923 | CMD_RESID_LEN(cp) = resid; |
| 924 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 925 | cp->result = DID_OK << 16 | lscsi_status; |
| 926 | |
| 927 | if (lscsi_status != SS_CHECK_CONDITION) |
| 928 | break; |
| 929 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 930 | /* Copy Sense Data into sense buffer. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 931 | memset(cp->sense_buffer, 0, sizeof(cp->sense_buffer)); |
| 932 | |
| 933 | if (!(scsi_status & SS_SENSE_LEN_VALID)) |
| 934 | break; |
| 935 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 936 | if (sense_len >= sizeof(cp->sense_buffer)) |
| 937 | sense_len = sizeof(cp->sense_buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 938 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 939 | CMD_ACTUAL_SNSLEN(cp) = sense_len; |
| 940 | sp->request_sense_length = sense_len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 941 | sp->request_sense_ptr = cp->sense_buffer; |
| 942 | |
| 943 | if (sp->request_sense_length > 32) |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 944 | sense_len = 32; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 945 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 946 | memcpy(cp->sense_buffer, sense_data, sense_len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 947 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 948 | sp->request_sense_ptr += sense_len; |
| 949 | sp->request_sense_length -= sense_len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 950 | if (sp->request_sense_length != 0) |
| 951 | ha->status_srb = sp; |
| 952 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 953 | DEBUG5(printk("%s(): Check condition Sense data, " |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 954 | "scsi(%ld:%d:%d:%d) cmd=%p pid=%ld\n", __func__, |
| 955 | ha->host_no, cp->device->channel, cp->device->id, |
| 956 | cp->device->lun, cp, cp->serial_number)); |
| 957 | if (sense_len) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 958 | DEBUG5(qla2x00_dump_buffer(cp->sense_buffer, |
| 959 | CMD_ACTUAL_SNSLEN(cp))); |
| 960 | break; |
| 961 | |
| 962 | case CS_DATA_UNDERRUN: |
| 963 | DEBUG2(printk(KERN_INFO |
| 964 | "scsi(%ld:%d:%d) UNDERRUN status detected 0x%x-0x%x.\n", |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 965 | ha->host_no, cp->device->id, cp->device->lun, comp_status, |
| 966 | scsi_status)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 967 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 968 | resid = resid_len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 969 | if (scsi_status & SS_RESIDUAL_UNDER) { |
| 970 | cp->resid = resid; |
| 971 | CMD_RESID_LEN(cp) = resid; |
| 972 | } |
| 973 | |
| 974 | /* |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 975 | * 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] | 976 | * Status. |
| 977 | */ |
| 978 | if (lscsi_status != 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 979 | cp->result = DID_OK << 16 | lscsi_status; |
| 980 | |
| 981 | if (lscsi_status != SS_CHECK_CONDITION) |
| 982 | break; |
| 983 | |
| 984 | /* Copy Sense Data into sense buffer */ |
| 985 | memset(cp->sense_buffer, 0, sizeof(cp->sense_buffer)); |
| 986 | |
| 987 | if (!(scsi_status & SS_SENSE_LEN_VALID)) |
| 988 | break; |
| 989 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 990 | if (sense_len >= sizeof(cp->sense_buffer)) |
| 991 | sense_len = sizeof(cp->sense_buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 992 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 993 | CMD_ACTUAL_SNSLEN(cp) = sense_len; |
| 994 | sp->request_sense_length = sense_len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 995 | sp->request_sense_ptr = cp->sense_buffer; |
| 996 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 997 | if (sp->request_sense_length > 32) |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 998 | sense_len = 32; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 999 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1000 | memcpy(cp->sense_buffer, sense_data, sense_len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1001 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1002 | sp->request_sense_ptr += sense_len; |
| 1003 | sp->request_sense_length -= sense_len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1004 | if (sp->request_sense_length != 0) |
| 1005 | ha->status_srb = sp; |
| 1006 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1007 | DEBUG5(printk("%s(): Check condition Sense data, " |
| 1008 | "scsi(%ld:%d:%d:%d) cmd=%p pid=%ld\n", |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1009 | __func__, ha->host_no, cp->device->channel, |
| 1010 | cp->device->id, cp->device->lun, cp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1011 | cp->serial_number)); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1012 | |
| 1013 | if (sense_len) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1014 | DEBUG5(qla2x00_dump_buffer(cp->sense_buffer, |
| 1015 | CMD_ACTUAL_SNSLEN(cp))); |
| 1016 | } else { |
| 1017 | /* |
| 1018 | * If RISC reports underrun and target does not report |
| 1019 | * it then we must have a lost frame, so tell upper |
| 1020 | * layer to retry it by reporting a bus busy. |
| 1021 | */ |
| 1022 | if (!(scsi_status & SS_RESIDUAL_UNDER)) { |
| 1023 | DEBUG2(printk("scsi(%ld:%d:%d:%d) Dropped " |
| 1024 | "frame(s) detected (%x of %x bytes)..." |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1025 | "retrying command.\n", ha->host_no, |
| 1026 | cp->device->channel, cp->device->id, |
| 1027 | cp->device->lun, resid, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1028 | cp->request_bufflen)); |
| 1029 | |
| 1030 | cp->result = DID_BUS_BUSY << 16; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1031 | break; |
| 1032 | } |
| 1033 | |
| 1034 | /* Handle mid-layer underflow */ |
| 1035 | if ((unsigned)(cp->request_bufflen - resid) < |
| 1036 | cp->underflow) { |
| 1037 | qla_printk(KERN_INFO, ha, |
| 1038 | "scsi(%ld:%d:%d:%d): Mid-layer underflow " |
| 1039 | "detected (%x of %x bytes)...returning " |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1040 | "error status.\n", ha->host_no, |
| 1041 | cp->device->channel, cp->device->id, |
| 1042 | cp->device->lun, resid, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1043 | cp->request_bufflen); |
| 1044 | |
| 1045 | cp->result = DID_ERROR << 16; |
| 1046 | break; |
| 1047 | } |
| 1048 | |
| 1049 | /* Everybody online, looking good... */ |
| 1050 | cp->result = DID_OK << 16; |
| 1051 | } |
| 1052 | break; |
| 1053 | |
| 1054 | case CS_DATA_OVERRUN: |
| 1055 | DEBUG2(printk(KERN_INFO |
| 1056 | "scsi(%ld:%d:%d): OVERRUN status detected 0x%x-0x%x\n", |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1057 | ha->host_no, cp->device->id, cp->device->lun, comp_status, |
| 1058 | scsi_status)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1059 | DEBUG2(printk(KERN_INFO |
| 1060 | "CDB: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n", |
| 1061 | cp->cmnd[0], cp->cmnd[1], cp->cmnd[2], cp->cmnd[3], |
| 1062 | cp->cmnd[4], cp->cmnd[5])); |
| 1063 | DEBUG2(printk(KERN_INFO |
| 1064 | "PID=0x%lx req=0x%x xtra=0x%x -- returning DID_ERROR " |
| 1065 | "status!\n", |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1066 | cp->serial_number, cp->request_bufflen, resid_len)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1067 | |
| 1068 | cp->result = DID_ERROR << 16; |
| 1069 | break; |
| 1070 | |
| 1071 | case CS_PORT_LOGGED_OUT: |
| 1072 | case CS_PORT_CONFIG_CHG: |
| 1073 | case CS_PORT_BUSY: |
| 1074 | case CS_INCOMPLETE: |
| 1075 | case CS_PORT_UNAVAILABLE: |
| 1076 | /* |
| 1077 | * If the port is in Target Down state, return all IOs for this |
| 1078 | * Target with DID_NO_CONNECT ELSE Queue the IOs in the |
| 1079 | * retry_queue. |
| 1080 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1081 | DEBUG2(printk("scsi(%ld:%d:%d): status_entry: Port Down " |
| 1082 | "pid=%ld, compl status=0x%x, port state=0x%x\n", |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1083 | ha->host_no, cp->device->id, cp->device->lun, |
| 1084 | cp->serial_number, comp_status, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1085 | atomic_read(&fcport->state))); |
| 1086 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1087 | cp->result = DID_BUS_BUSY << 16; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1088 | if (atomic_read(&fcport->state) == FCS_ONLINE) { |
| 1089 | qla2x00_mark_device_lost(ha, fcport, 1); |
| 1090 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1091 | break; |
| 1092 | |
| 1093 | case CS_RESET: |
| 1094 | DEBUG2(printk(KERN_INFO |
| 1095 | "scsi(%ld): RESET status detected 0x%x-0x%x.\n", |
| 1096 | ha->host_no, comp_status, scsi_status)); |
| 1097 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1098 | cp->result = DID_RESET << 16; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1099 | break; |
| 1100 | |
| 1101 | case CS_ABORTED: |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1102 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1103 | * hv2.19.12 - DID_ABORT does not retry the request if we |
| 1104 | * aborted this request then abort otherwise it must be a |
| 1105 | * reset. |
| 1106 | */ |
| 1107 | DEBUG2(printk(KERN_INFO |
| 1108 | "scsi(%ld): ABORT status detected 0x%x-0x%x.\n", |
| 1109 | ha->host_no, comp_status, scsi_status)); |
| 1110 | |
| 1111 | cp->result = DID_RESET << 16; |
| 1112 | break; |
| 1113 | |
| 1114 | case CS_TIMEOUT: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1115 | cp->result = DID_BUS_BUSY << 16; |
| 1116 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1117 | if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) { |
| 1118 | DEBUG2(printk(KERN_INFO |
| 1119 | "scsi(%ld:%d:%d:%d): TIMEOUT status detected " |
| 1120 | "0x%x-0x%x\n", ha->host_no, cp->device->channel, |
| 1121 | cp->device->id, cp->device->lun, comp_status, |
| 1122 | scsi_status)); |
| 1123 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1124 | } |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1125 | DEBUG2(printk(KERN_INFO |
| 1126 | "scsi(%ld:%d:%d:%d): TIMEOUT status detected 0x%x-0x%x " |
| 1127 | "sflags=%x.\n", ha->host_no, cp->device->channel, |
| 1128 | cp->device->id, cp->device->lun, comp_status, scsi_status, |
| 1129 | le16_to_cpu(sts->status_flags))); |
| 1130 | |
| 1131 | /* Check to see if logout occurred. */ |
| 1132 | if ((le16_to_cpu(sts->status_flags) & SF_LOGOUT_SENT)) |
| 1133 | qla2x00_mark_device_lost(ha, fcport, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1134 | break; |
| 1135 | |
| 1136 | case CS_QUEUE_FULL: |
| 1137 | DEBUG2(printk(KERN_INFO |
| 1138 | "scsi(%ld): QUEUE FULL status detected 0x%x-0x%x.\n", |
| 1139 | ha->host_no, comp_status, scsi_status)); |
| 1140 | |
| 1141 | /* SCSI Mid-Layer handles device queue full */ |
| 1142 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1143 | cp->result = DID_OK << 16 | lscsi_status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1144 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1145 | break; |
| 1146 | |
| 1147 | default: |
| 1148 | DEBUG3(printk("scsi(%ld): Error detected (unknown status) " |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1149 | "0x%x-0x%x.\n", ha->host_no, comp_status, scsi_status)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1150 | qla_printk(KERN_INFO, ha, |
| 1151 | "Unknown status detected 0x%x-0x%x.\n", |
| 1152 | comp_status, scsi_status); |
| 1153 | |
| 1154 | cp->result = DID_ERROR << 16; |
| 1155 | break; |
| 1156 | } |
| 1157 | |
| 1158 | /* Place command on done queue. */ |
| 1159 | if (ha->status_srb == NULL) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1160 | qla2x00_sp_compl(ha, sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1161 | } |
| 1162 | |
| 1163 | /** |
| 1164 | * qla2x00_status_cont_entry() - Process a Status Continuations entry. |
| 1165 | * @ha: SCSI driver HA context |
| 1166 | * @pkt: Entry pointer |
| 1167 | * |
| 1168 | * Extended sense data. |
| 1169 | */ |
| 1170 | static void |
| 1171 | qla2x00_status_cont_entry(scsi_qla_host_t *ha, sts_cont_entry_t *pkt) |
| 1172 | { |
| 1173 | uint8_t sense_sz = 0; |
| 1174 | srb_t *sp = ha->status_srb; |
| 1175 | struct scsi_cmnd *cp; |
| 1176 | |
| 1177 | if (sp != NULL && sp->request_sense_length != 0) { |
| 1178 | cp = sp->cmd; |
| 1179 | if (cp == NULL) { |
| 1180 | DEBUG2(printk("%s(): Cmd already returned back to OS " |
| 1181 | "sp=%p sp->state:%d\n", __func__, sp, sp->state)); |
| 1182 | qla_printk(KERN_INFO, ha, |
| 1183 | "cmd is NULL: already returned to OS (sp=%p)\n", |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1184 | sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1185 | |
| 1186 | ha->status_srb = NULL; |
| 1187 | return; |
| 1188 | } |
| 1189 | |
| 1190 | if (sp->request_sense_length > sizeof(pkt->data)) { |
| 1191 | sense_sz = sizeof(pkt->data); |
| 1192 | } else { |
| 1193 | sense_sz = sp->request_sense_length; |
| 1194 | } |
| 1195 | |
| 1196 | /* Move sense data. */ |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1197 | if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) |
| 1198 | host_to_fcp_swap(pkt->data, sizeof(pkt->data)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1199 | memcpy(sp->request_sense_ptr, pkt->data, sense_sz); |
| 1200 | DEBUG5(qla2x00_dump_buffer(sp->request_sense_ptr, sense_sz)); |
| 1201 | |
| 1202 | sp->request_sense_ptr += sense_sz; |
| 1203 | sp->request_sense_length -= sense_sz; |
| 1204 | |
| 1205 | /* Place command on done queue. */ |
| 1206 | if (sp->request_sense_length == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1207 | ha->status_srb = NULL; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1208 | qla2x00_sp_compl(ha, sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1209 | } |
| 1210 | } |
| 1211 | } |
| 1212 | |
| 1213 | /** |
| 1214 | * qla2x00_error_entry() - Process an error entry. |
| 1215 | * @ha: SCSI driver HA context |
| 1216 | * @pkt: Entry pointer |
| 1217 | */ |
| 1218 | static void |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1219 | qla2x00_error_entry(scsi_qla_host_t *ha, sts_entry_t *pkt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1220 | { |
| 1221 | srb_t *sp; |
| 1222 | |
| 1223 | #if defined(QL_DEBUG_LEVEL_2) |
| 1224 | if (pkt->entry_status & RF_INV_E_ORDER) |
| 1225 | qla_printk(KERN_ERR, ha, "%s: Invalid Entry Order\n", __func__); |
| 1226 | else if (pkt->entry_status & RF_INV_E_COUNT) |
| 1227 | qla_printk(KERN_ERR, ha, "%s: Invalid Entry Count\n", __func__); |
| 1228 | else if (pkt->entry_status & RF_INV_E_PARAM) |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1229 | qla_printk(KERN_ERR, ha, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1230 | "%s: Invalid Entry Parameter\n", __func__); |
| 1231 | else if (pkt->entry_status & RF_INV_E_TYPE) |
| 1232 | qla_printk(KERN_ERR, ha, "%s: Invalid Entry Type\n", __func__); |
| 1233 | else if (pkt->entry_status & RF_BUSY) |
| 1234 | qla_printk(KERN_ERR, ha, "%s: Busy\n", __func__); |
| 1235 | else |
| 1236 | qla_printk(KERN_ERR, ha, "%s: UNKNOWN flag error\n", __func__); |
| 1237 | #endif |
| 1238 | |
| 1239 | /* Validate handle. */ |
| 1240 | if (pkt->handle < MAX_OUTSTANDING_COMMANDS) |
| 1241 | sp = ha->outstanding_cmds[pkt->handle]; |
| 1242 | else |
| 1243 | sp = NULL; |
| 1244 | |
| 1245 | if (sp) { |
| 1246 | /* Free outstanding command slot. */ |
| 1247 | ha->outstanding_cmds[pkt->handle] = NULL; |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 1248 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1249 | /* Bad payload or header */ |
| 1250 | if (pkt->entry_status & |
| 1251 | (RF_INV_E_ORDER | RF_INV_E_COUNT | |
| 1252 | RF_INV_E_PARAM | RF_INV_E_TYPE)) { |
| 1253 | sp->cmd->result = DID_ERROR << 16; |
| 1254 | } else if (pkt->entry_status & RF_BUSY) { |
| 1255 | sp->cmd->result = DID_BUS_BUSY << 16; |
| 1256 | } else { |
| 1257 | sp->cmd->result = DID_ERROR << 16; |
| 1258 | } |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1259 | qla2x00_sp_compl(ha, sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1260 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1261 | } else if (pkt->entry_type == COMMAND_A64_TYPE || pkt->entry_type == |
| 1262 | COMMAND_TYPE || pkt->entry_type == COMMAND_TYPE_7) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1263 | DEBUG2(printk("scsi(%ld): Error entry - invalid handle\n", |
| 1264 | ha->host_no)); |
| 1265 | qla_printk(KERN_WARNING, ha, |
| 1266 | "Error entry - invalid handle\n"); |
| 1267 | |
| 1268 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1269 | if (ha->dpc_wait && !ha->dpc_active) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1270 | up(ha->dpc_wait); |
| 1271 | } |
| 1272 | } |
| 1273 | |
| 1274 | /** |
| 1275 | * qla2x00_ms_entry() - Process a Management Server entry. |
| 1276 | * @ha: SCSI driver HA context |
| 1277 | * @index: Response queue out pointer |
| 1278 | */ |
| 1279 | static void |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1280 | 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] | 1281 | { |
| 1282 | srb_t *sp; |
| 1283 | |
| 1284 | DEBUG3(printk("%s(%ld): pkt=%p pkthandle=%d.\n", |
| 1285 | __func__, ha->host_no, pkt, pkt->handle1)); |
| 1286 | |
| 1287 | /* Validate handle. */ |
| 1288 | if (pkt->handle1 < MAX_OUTSTANDING_COMMANDS) |
| 1289 | sp = ha->outstanding_cmds[pkt->handle1]; |
| 1290 | else |
| 1291 | sp = NULL; |
| 1292 | |
| 1293 | if (sp == NULL) { |
| 1294 | DEBUG2(printk("scsi(%ld): MS entry - invalid handle\n", |
| 1295 | ha->host_no)); |
| 1296 | qla_printk(KERN_WARNING, ha, "MS entry - invalid handle\n"); |
| 1297 | |
| 1298 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); |
| 1299 | return; |
| 1300 | } |
| 1301 | |
| 1302 | CMD_COMPL_STATUS(sp->cmd) = le16_to_cpu(pkt->status); |
| 1303 | CMD_ENTRY_STATUS(sp->cmd) = pkt->entry_status; |
| 1304 | |
| 1305 | /* Free outstanding command slot. */ |
| 1306 | ha->outstanding_cmds[pkt->handle1] = NULL; |
| 1307 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1308 | qla2x00_sp_compl(ha, sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1309 | } |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1310 | |
| 1311 | |
| 1312 | /** |
| 1313 | * qla24xx_mbx_completion() - Process mailbox command completions. |
| 1314 | * @ha: SCSI driver HA context |
| 1315 | * @mb0: Mailbox0 register |
| 1316 | */ |
| 1317 | static void |
| 1318 | qla24xx_mbx_completion(scsi_qla_host_t *ha, uint16_t mb0) |
| 1319 | { |
| 1320 | uint16_t cnt; |
| 1321 | uint16_t __iomem *wptr; |
| 1322 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1323 | |
| 1324 | /* Load return mailbox registers. */ |
| 1325 | ha->flags.mbox_int = 1; |
| 1326 | ha->mailbox_out[0] = mb0; |
| 1327 | wptr = (uint16_t __iomem *)®->mailbox1; |
| 1328 | |
| 1329 | for (cnt = 1; cnt < ha->mbx_count; cnt++) { |
| 1330 | ha->mailbox_out[cnt] = RD_REG_WORD(wptr); |
| 1331 | wptr++; |
| 1332 | } |
| 1333 | |
| 1334 | if (ha->mcp) { |
| 1335 | DEBUG3(printk("%s(%ld): Got mailbox completion. cmd=%x.\n", |
| 1336 | __func__, ha->host_no, ha->mcp->mb[0])); |
| 1337 | } else { |
| 1338 | DEBUG2_3(printk("%s(%ld): MBX pointer ERROR!\n", |
| 1339 | __func__, ha->host_no)); |
| 1340 | } |
| 1341 | } |
| 1342 | |
| 1343 | /** |
| 1344 | * qla24xx_process_response_queue() - Process response queue entries. |
| 1345 | * @ha: SCSI driver HA context |
| 1346 | */ |
| 1347 | void |
| 1348 | qla24xx_process_response_queue(struct scsi_qla_host *ha) |
| 1349 | { |
| 1350 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1351 | struct sts_entry_24xx *pkt; |
| 1352 | |
| 1353 | if (!ha->flags.online) |
| 1354 | return; |
| 1355 | |
| 1356 | while (ha->response_ring_ptr->signature != RESPONSE_PROCESSED) { |
| 1357 | pkt = (struct sts_entry_24xx *)ha->response_ring_ptr; |
| 1358 | |
| 1359 | ha->rsp_ring_index++; |
| 1360 | if (ha->rsp_ring_index == ha->response_q_length) { |
| 1361 | ha->rsp_ring_index = 0; |
| 1362 | ha->response_ring_ptr = ha->response_ring; |
| 1363 | } else { |
| 1364 | ha->response_ring_ptr++; |
| 1365 | } |
| 1366 | |
| 1367 | if (pkt->entry_status != 0) { |
| 1368 | DEBUG3(printk(KERN_INFO |
| 1369 | "scsi(%ld): Process error entry.\n", ha->host_no)); |
| 1370 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1371 | qla2x00_error_entry(ha, (sts_entry_t *) pkt); |
| 1372 | ((response_t *)pkt)->signature = RESPONSE_PROCESSED; |
| 1373 | wmb(); |
| 1374 | continue; |
| 1375 | } |
| 1376 | |
| 1377 | switch (pkt->entry_type) { |
| 1378 | case STATUS_TYPE: |
| 1379 | qla2x00_status_entry(ha, pkt); |
| 1380 | break; |
| 1381 | case STATUS_CONT_TYPE: |
| 1382 | qla2x00_status_cont_entry(ha, (sts_cont_entry_t *)pkt); |
| 1383 | break; |
| 1384 | case MS_IOCB_TYPE: |
| 1385 | qla24xx_ms_entry(ha, (struct ct_entry_24xx *)pkt); |
| 1386 | break; |
| 1387 | default: |
| 1388 | /* Type Not Supported. */ |
| 1389 | DEBUG4(printk(KERN_WARNING |
| 1390 | "scsi(%ld): Received unknown response pkt type %x " |
| 1391 | "entry status=%x.\n", |
| 1392 | ha->host_no, pkt->entry_type, pkt->entry_status)); |
| 1393 | break; |
| 1394 | } |
| 1395 | ((response_t *)pkt)->signature = RESPONSE_PROCESSED; |
| 1396 | wmb(); |
| 1397 | } |
| 1398 | |
| 1399 | /* Adjust ring index */ |
| 1400 | WRT_REG_DWORD(®->rsp_q_out, ha->rsp_ring_index); |
| 1401 | } |
| 1402 | |
| 1403 | /** |
| 1404 | * qla24xx_intr_handler() - Process interrupts for the ISP23xx and ISP63xx. |
| 1405 | * @irq: |
| 1406 | * @dev_id: SCSI driver HA context |
| 1407 | * @regs: |
| 1408 | * |
| 1409 | * Called by system whenever the host adapter generates an interrupt. |
| 1410 | * |
| 1411 | * Returns handled flag. |
| 1412 | */ |
| 1413 | irqreturn_t |
| 1414 | qla24xx_intr_handler(int irq, void *dev_id, struct pt_regs *regs) |
| 1415 | { |
| 1416 | scsi_qla_host_t *ha; |
| 1417 | struct device_reg_24xx __iomem *reg; |
| 1418 | int status; |
| 1419 | unsigned long flags; |
| 1420 | unsigned long iter; |
| 1421 | uint32_t stat; |
| 1422 | uint32_t hccr; |
| 1423 | uint16_t mb[4]; |
| 1424 | |
| 1425 | ha = (scsi_qla_host_t *) dev_id; |
| 1426 | if (!ha) { |
| 1427 | printk(KERN_INFO |
| 1428 | "%s(): NULL host pointer\n", __func__); |
| 1429 | return IRQ_NONE; |
| 1430 | } |
| 1431 | |
| 1432 | reg = &ha->iobase->isp24; |
| 1433 | status = 0; |
| 1434 | |
| 1435 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1436 | for (iter = 50; iter--; ) { |
| 1437 | stat = RD_REG_DWORD(®->host_status); |
| 1438 | if (stat & HSRX_RISC_PAUSED) { |
| 1439 | hccr = RD_REG_DWORD(®->hccr); |
| 1440 | |
| 1441 | qla_printk(KERN_INFO, ha, "RISC paused -- HCCR=%x, " |
| 1442 | "Dumping firmware!\n", hccr); |
| 1443 | qla24xx_fw_dump(ha, 1); |
| 1444 | |
| 1445 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); |
| 1446 | break; |
| 1447 | } else if ((stat & HSRX_RISC_INT) == 0) |
| 1448 | break; |
| 1449 | |
| 1450 | switch (stat & 0xff) { |
| 1451 | case 0x1: |
| 1452 | case 0x2: |
| 1453 | case 0x10: |
| 1454 | case 0x11: |
| 1455 | qla24xx_mbx_completion(ha, MSW(stat)); |
| 1456 | status |= MBX_INTERRUPT; |
| 1457 | |
| 1458 | break; |
| 1459 | case 0x12: |
| 1460 | mb[0] = MSW(stat); |
| 1461 | mb[1] = RD_REG_WORD(®->mailbox1); |
| 1462 | mb[2] = RD_REG_WORD(®->mailbox2); |
| 1463 | mb[3] = RD_REG_WORD(®->mailbox3); |
| 1464 | qla2x00_async_event(ha, mb); |
| 1465 | break; |
| 1466 | case 0x13: |
| 1467 | qla24xx_process_response_queue(ha); |
| 1468 | break; |
| 1469 | default: |
| 1470 | DEBUG2(printk("scsi(%ld): Unrecognized interrupt type " |
| 1471 | "(%d).\n", |
| 1472 | ha->host_no, stat & 0xff)); |
| 1473 | break; |
| 1474 | } |
| 1475 | WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_INT); |
| 1476 | RD_REG_DWORD_RELAXED(®->hccr); |
| 1477 | } |
| 1478 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1479 | |
| 1480 | if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) && |
| 1481 | (status & MBX_INTERRUPT) && ha->flags.mbox_int) { |
| 1482 | spin_lock_irqsave(&ha->mbx_reg_lock, flags); |
| 1483 | |
| 1484 | set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
| 1485 | up(&ha->mbx_intr_sem); |
| 1486 | |
| 1487 | spin_unlock_irqrestore(&ha->mbx_reg_lock, flags); |
| 1488 | } |
| 1489 | |
| 1490 | return IRQ_HANDLED; |
| 1491 | } |
| 1492 | |
| 1493 | /** |
| 1494 | * qla24xx_ms_entry() - Process a Management Server entry. |
| 1495 | * @ha: SCSI driver HA context |
| 1496 | * @index: Response queue out pointer |
| 1497 | */ |
| 1498 | static void |
| 1499 | qla24xx_ms_entry(scsi_qla_host_t *ha, struct ct_entry_24xx *pkt) |
| 1500 | { |
| 1501 | srb_t *sp; |
| 1502 | |
| 1503 | DEBUG3(printk("%s(%ld): pkt=%p pkthandle=%d.\n", |
| 1504 | __func__, ha->host_no, pkt, pkt->handle)); |
| 1505 | |
| 1506 | DEBUG9(printk("%s: ct pkt dump:\n", __func__);) |
| 1507 | DEBUG9(qla2x00_dump_buffer((void *)pkt, sizeof(struct ct_entry_24xx));) |
| 1508 | |
| 1509 | /* Validate handle. */ |
| 1510 | if (pkt->handle < MAX_OUTSTANDING_COMMANDS) |
| 1511 | sp = ha->outstanding_cmds[pkt->handle]; |
| 1512 | else |
| 1513 | sp = NULL; |
| 1514 | |
| 1515 | if (sp == NULL) { |
| 1516 | DEBUG2(printk("scsi(%ld): MS entry - invalid handle\n", |
| 1517 | ha->host_no)); |
| 1518 | DEBUG10(printk("scsi(%ld): MS entry - invalid handle\n", |
| 1519 | ha->host_no)); |
| 1520 | qla_printk(KERN_WARNING, ha, "MS entry - invalid handle %d\n", |
| 1521 | pkt->handle); |
| 1522 | |
| 1523 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); |
| 1524 | return; |
| 1525 | } |
| 1526 | |
| 1527 | CMD_COMPL_STATUS(sp->cmd) = le16_to_cpu(pkt->comp_status); |
| 1528 | CMD_ENTRY_STATUS(sp->cmd) = pkt->entry_status; |
| 1529 | |
| 1530 | /* Free outstanding command slot. */ |
| 1531 | ha->outstanding_cmds[pkt->handle] = NULL; |
| 1532 | |
| 1533 | qla2x00_sp_compl(ha, sp); |
| 1534 | } |
| 1535 | |