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