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