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> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 10 | #include <linux/slab.h> |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 11 | #include <scsi/scsi_tcq.h> |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 12 | #include <scsi/scsi_bsg_fc.h> |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 13 | #include <scsi/scsi_eh.h> |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 14 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | static void qla2x00_mbx_completion(scsi_qla_host_t *, uint16_t); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 16 | static void qla2x00_process_completed_request(struct scsi_qla_host *, |
| 17 | struct req_que *, uint32_t); |
| 18 | static void qla2x00_status_entry(scsi_qla_host_t *, struct rsp_que *, void *); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 19 | static void qla2x00_status_cont_entry(struct rsp_que *, sts_cont_entry_t *); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 20 | static void qla2x00_error_entry(scsi_qla_host_t *, struct rsp_que *, |
| 21 | sts_entry_t *); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 22 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | /** |
| 24 | * qla2100_intr_handler() - Process interrupts for the ISP2100 and ISP2200. |
| 25 | * @irq: |
| 26 | * @dev_id: SCSI driver HA context |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | * |
| 28 | * Called by system whenever the host adapter generates an interrupt. |
| 29 | * |
| 30 | * Returns handled flag. |
| 31 | */ |
| 32 | irqreturn_t |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 33 | qla2100_intr_handler(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 35 | scsi_qla_host_t *vha; |
| 36 | struct qla_hw_data *ha; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 37 | struct device_reg_2xxx __iomem *reg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | unsigned long iter; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 40 | uint16_t hccr; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 41 | uint16_t mb[4]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 42 | struct rsp_que *rsp; |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 43 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 45 | rsp = (struct rsp_que *) dev_id; |
| 46 | if (!rsp) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | printk(KERN_INFO |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 48 | "%s(): NULL response queue pointer\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | return (IRQ_NONE); |
| 50 | } |
| 51 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 52 | ha = rsp->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 53 | reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | status = 0; |
| 55 | |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 56 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 57 | vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | for (iter = 50; iter--; ) { |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 59 | hccr = RD_REG_WORD(®->hccr); |
| 60 | if (hccr & HCCR_RISC_PAUSE) { |
| 61 | if (pci_channel_offline(ha->pdev)) |
| 62 | break; |
| 63 | |
| 64 | /* |
| 65 | * Issue a "HARD" reset in order for the RISC interrupt |
| 66 | * bit to be cleared. Schedule a big hammmer to get |
| 67 | * out of the RISC PAUSED state. |
| 68 | */ |
| 69 | WRT_REG_WORD(®->hccr, HCCR_RESET_RISC); |
| 70 | RD_REG_WORD(®->hccr); |
| 71 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 72 | ha->isp_ops->fw_dump(vha, 1); |
| 73 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 74 | break; |
| 75 | } else if ((RD_REG_WORD(®->istatus) & ISR_RISC_INT) == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | break; |
| 77 | |
| 78 | if (RD_REG_WORD(®->semaphore) & BIT_0) { |
| 79 | WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT); |
| 80 | RD_REG_WORD(®->hccr); |
| 81 | |
| 82 | /* Get mailbox data. */ |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 83 | mb[0] = RD_MAILBOX_REG(ha, reg, 0); |
| 84 | if (mb[0] > 0x3fff && mb[0] < 0x8000) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 85 | qla2x00_mbx_completion(vha, mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | status |= MBX_INTERRUPT; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 87 | } else if (mb[0] > 0x7fff && mb[0] < 0xc000) { |
| 88 | mb[1] = RD_MAILBOX_REG(ha, reg, 1); |
| 89 | mb[2] = RD_MAILBOX_REG(ha, reg, 2); |
| 90 | mb[3] = RD_MAILBOX_REG(ha, reg, 3); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 91 | qla2x00_async_event(vha, rsp, mb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | } else { |
| 93 | /*EMPTY*/ |
| 94 | DEBUG2(printk("scsi(%ld): Unrecognized " |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 95 | "interrupt type (%d).\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 96 | vha->host_no, mb[0])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | } |
| 98 | /* Release mailbox registers. */ |
| 99 | WRT_REG_WORD(®->semaphore, 0); |
| 100 | RD_REG_WORD(®->semaphore); |
| 101 | } else { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 102 | qla2x00_process_response_queue(rsp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | |
| 104 | WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT); |
| 105 | RD_REG_WORD(®->hccr); |
| 106 | } |
| 107 | } |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 108 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) && |
| 111 | (status & MBX_INTERRUPT) && ha->flags.mbox_int) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 113 | complete(&ha->mbx_intr_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | } |
| 115 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | return (IRQ_HANDLED); |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * qla2300_intr_handler() - Process interrupts for the ISP23xx and ISP63xx. |
| 121 | * @irq: |
| 122 | * @dev_id: SCSI driver HA context |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | * |
| 124 | * Called by system whenever the host adapter generates an interrupt. |
| 125 | * |
| 126 | * Returns handled flag. |
| 127 | */ |
| 128 | irqreturn_t |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 129 | qla2300_intr_handler(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 131 | scsi_qla_host_t *vha; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 132 | struct device_reg_2xxx __iomem *reg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | unsigned long iter; |
| 135 | uint32_t stat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | uint16_t hccr; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 137 | uint16_t mb[4]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 138 | struct rsp_que *rsp; |
| 139 | struct qla_hw_data *ha; |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 140 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 142 | rsp = (struct rsp_que *) dev_id; |
| 143 | if (!rsp) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | printk(KERN_INFO |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 145 | "%s(): NULL response queue pointer\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | return (IRQ_NONE); |
| 147 | } |
| 148 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 149 | ha = rsp->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 150 | reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | status = 0; |
| 152 | |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 153 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 154 | vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | for (iter = 50; iter--; ) { |
| 156 | stat = RD_REG_DWORD(®->u.isp2300.host_status); |
| 157 | if (stat & HSR_RISC_PAUSED) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 158 | if (unlikely(pci_channel_offline(ha->pdev))) |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 159 | break; |
| 160 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | hccr = RD_REG_WORD(®->hccr); |
| 162 | if (hccr & (BIT_15 | BIT_13 | BIT_11 | BIT_8)) |
Andrew Vasquez | 07f3180 | 2006-12-13 19:20:31 -0800 | [diff] [blame] | 163 | qla_printk(KERN_INFO, ha, "Parity error -- " |
| 164 | "HCCR=%x, Dumping firmware!\n", hccr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | else |
Andrew Vasquez | 07f3180 | 2006-12-13 19:20:31 -0800 | [diff] [blame] | 166 | qla_printk(KERN_INFO, ha, "RISC paused -- " |
| 167 | "HCCR=%x, Dumping firmware!\n", hccr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | |
| 169 | /* |
| 170 | * Issue a "HARD" reset in order for the RISC |
| 171 | * interrupt bit to be cleared. Schedule a big |
| 172 | * hammmer to get out of the RISC PAUSED state. |
| 173 | */ |
| 174 | WRT_REG_WORD(®->hccr, HCCR_RESET_RISC); |
| 175 | RD_REG_WORD(®->hccr); |
Andrew Vasquez | 07f3180 | 2006-12-13 19:20:31 -0800 | [diff] [blame] | 176 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 177 | ha->isp_ops->fw_dump(vha, 1); |
| 178 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | break; |
| 180 | } else if ((stat & HSR_RISC_INT) == 0) |
| 181 | break; |
| 182 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | switch (stat & 0xff) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | case 0x1: |
| 185 | case 0x2: |
| 186 | case 0x10: |
| 187 | case 0x11: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 188 | qla2x00_mbx_completion(vha, MSW(stat)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | status |= MBX_INTERRUPT; |
| 190 | |
| 191 | /* Release mailbox registers. */ |
| 192 | WRT_REG_WORD(®->semaphore, 0); |
| 193 | break; |
| 194 | case 0x12: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 195 | mb[0] = MSW(stat); |
| 196 | mb[1] = RD_MAILBOX_REG(ha, reg, 1); |
| 197 | mb[2] = RD_MAILBOX_REG(ha, reg, 2); |
| 198 | mb[3] = RD_MAILBOX_REG(ha, reg, 3); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 199 | qla2x00_async_event(vha, rsp, mb); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 200 | break; |
| 201 | case 0x13: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 202 | qla2x00_process_response_queue(rsp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | break; |
| 204 | case 0x15: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 205 | mb[0] = MBA_CMPLT_1_16BIT; |
| 206 | mb[1] = MSW(stat); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 207 | qla2x00_async_event(vha, rsp, mb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | break; |
| 209 | case 0x16: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 210 | mb[0] = MBA_SCSI_COMPLETION; |
| 211 | mb[1] = MSW(stat); |
| 212 | mb[2] = RD_MAILBOX_REG(ha, reg, 2); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 213 | qla2x00_async_event(vha, rsp, mb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | break; |
| 215 | default: |
| 216 | DEBUG2(printk("scsi(%ld): Unrecognized interrupt type " |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 217 | "(%d).\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 218 | vha->host_no, stat & 0xff)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | break; |
| 220 | } |
| 221 | WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT); |
| 222 | RD_REG_WORD_RELAXED(®->hccr); |
| 223 | } |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 224 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) && |
| 227 | (status & MBX_INTERRUPT) && ha->flags.mbox_int) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 229 | complete(&ha->mbx_intr_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | } |
| 231 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | return (IRQ_HANDLED); |
| 233 | } |
| 234 | |
| 235 | /** |
| 236 | * qla2x00_mbx_completion() - Process mailbox command completions. |
| 237 | * @ha: SCSI driver HA context |
| 238 | * @mb0: Mailbox0 register |
| 239 | */ |
| 240 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 241 | qla2x00_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | { |
| 243 | uint16_t cnt; |
| 244 | uint16_t __iomem *wptr; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 245 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 246 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | |
| 248 | /* Load return mailbox registers. */ |
| 249 | ha->flags.mbox_int = 1; |
| 250 | ha->mailbox_out[0] = mb0; |
| 251 | wptr = (uint16_t __iomem *)MAILBOX_REG(ha, reg, 1); |
| 252 | |
| 253 | for (cnt = 1; cnt < ha->mbx_count; cnt++) { |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 254 | if (IS_QLA2200(ha) && cnt == 8) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | wptr = (uint16_t __iomem *)MAILBOX_REG(ha, reg, 8); |
| 256 | if (cnt == 4 || cnt == 5) |
| 257 | ha->mailbox_out[cnt] = qla2x00_debounce_register(wptr); |
| 258 | else |
| 259 | ha->mailbox_out[cnt] = RD_REG_WORD(wptr); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 260 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | wptr++; |
| 262 | } |
| 263 | |
| 264 | if (ha->mcp) { |
| 265 | DEBUG3(printk("%s(%ld): Got mailbox completion. cmd=%x.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 266 | __func__, vha->host_no, ha->mcp->mb[0])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | } else { |
| 268 | DEBUG2_3(printk("%s(%ld): MBX pointer ERROR!\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 269 | __func__, vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | } |
| 271 | } |
| 272 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 273 | static void |
| 274 | qla81xx_idc_event(scsi_qla_host_t *vha, uint16_t aen, uint16_t descr) |
| 275 | { |
| 276 | static char *event[] = |
| 277 | { "Complete", "Request Notification", "Time Extension" }; |
| 278 | int rval; |
| 279 | struct device_reg_24xx __iomem *reg24 = &vha->hw->iobase->isp24; |
| 280 | uint16_t __iomem *wptr; |
| 281 | uint16_t cnt, timeout, mb[QLA_IDC_ACK_REGS]; |
| 282 | |
| 283 | /* Seed data -- mailbox1 -> mailbox7. */ |
| 284 | wptr = (uint16_t __iomem *)®24->mailbox1; |
| 285 | for (cnt = 0; cnt < QLA_IDC_ACK_REGS; cnt++, wptr++) |
| 286 | mb[cnt] = RD_REG_WORD(wptr); |
| 287 | |
| 288 | DEBUG2(printk("scsi(%ld): Inter-Driver Commucation %s -- " |
| 289 | "%04x %04x %04x %04x %04x %04x %04x.\n", vha->host_no, |
| 290 | event[aen & 0xff], |
| 291 | mb[0], mb[1], mb[2], mb[3], mb[4], mb[5], mb[6])); |
| 292 | |
| 293 | /* Acknowledgement needed? [Notify && non-zero timeout]. */ |
| 294 | timeout = (descr >> 8) & 0xf; |
| 295 | if (aen != MBA_IDC_NOTIFY || !timeout) |
| 296 | return; |
| 297 | |
| 298 | DEBUG2(printk("scsi(%ld): Inter-Driver Commucation %s -- " |
| 299 | "ACK timeout=%d.\n", vha->host_no, event[aen & 0xff], timeout)); |
| 300 | |
| 301 | rval = qla2x00_post_idc_ack_work(vha, mb); |
| 302 | if (rval != QLA_SUCCESS) |
| 303 | qla_printk(KERN_WARNING, vha->hw, |
| 304 | "IDC failed to post ACK.\n"); |
| 305 | } |
| 306 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | /** |
| 308 | * qla2x00_async_event() - Process aynchronous events. |
| 309 | * @ha: SCSI driver HA context |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 310 | * @mb: Mailbox registers (0 - 3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 312 | void |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 313 | 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] | 314 | { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 315 | #define LS_UNKNOWN 2 |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 316 | static char *link_speeds[] = { "1", "2", "?", "4", "8", "10" }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | char *link_speed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | uint16_t handle_cnt; |
Andrew Vasquez | bdab23d | 2009-10-13 15:16:46 -0700 | [diff] [blame] | 319 | uint16_t cnt, mbx; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | uint32_t handles[5]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 321 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 322 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Andrew Vasquez | bdab23d | 2009-10-13 15:16:46 -0700 | [diff] [blame] | 323 | struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | uint32_t rscn_entry, host_pid; |
| 325 | uint8_t rscn_queue_index; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 326 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | |
| 328 | /* Setup to process RIO completion. */ |
| 329 | handle_cnt = 0; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 330 | if (IS_QLA8XXX_TYPE(ha)) |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 331 | goto skip_rio; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | switch (mb[0]) { |
| 333 | case MBA_SCSI_COMPLETION: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 334 | handles[0] = le32_to_cpu((uint32_t)((mb[2] << 16) | mb[1])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | handle_cnt = 1; |
| 336 | break; |
| 337 | case MBA_CMPLT_1_16BIT: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 338 | handles[0] = mb[1]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | handle_cnt = 1; |
| 340 | mb[0] = MBA_SCSI_COMPLETION; |
| 341 | break; |
| 342 | case MBA_CMPLT_2_16BIT: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 343 | handles[0] = mb[1]; |
| 344 | handles[1] = mb[2]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | handle_cnt = 2; |
| 346 | mb[0] = MBA_SCSI_COMPLETION; |
| 347 | break; |
| 348 | case MBA_CMPLT_3_16BIT: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 349 | handles[0] = mb[1]; |
| 350 | handles[1] = mb[2]; |
| 351 | handles[2] = mb[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | handle_cnt = 3; |
| 353 | mb[0] = MBA_SCSI_COMPLETION; |
| 354 | break; |
| 355 | case MBA_CMPLT_4_16BIT: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 356 | handles[0] = mb[1]; |
| 357 | handles[1] = mb[2]; |
| 358 | handles[2] = mb[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | handles[3] = (uint32_t)RD_MAILBOX_REG(ha, reg, 6); |
| 360 | handle_cnt = 4; |
| 361 | mb[0] = MBA_SCSI_COMPLETION; |
| 362 | break; |
| 363 | case MBA_CMPLT_5_16BIT: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 364 | handles[0] = mb[1]; |
| 365 | handles[1] = mb[2]; |
| 366 | handles[2] = mb[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | handles[3] = (uint32_t)RD_MAILBOX_REG(ha, reg, 6); |
| 368 | handles[4] = (uint32_t)RD_MAILBOX_REG(ha, reg, 7); |
| 369 | handle_cnt = 5; |
| 370 | mb[0] = MBA_SCSI_COMPLETION; |
| 371 | break; |
| 372 | case MBA_CMPLT_2_32BIT: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 373 | handles[0] = le32_to_cpu((uint32_t)((mb[2] << 16) | mb[1])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | handles[1] = le32_to_cpu( |
| 375 | ((uint32_t)(RD_MAILBOX_REG(ha, reg, 7) << 16)) | |
| 376 | RD_MAILBOX_REG(ha, reg, 6)); |
| 377 | handle_cnt = 2; |
| 378 | mb[0] = MBA_SCSI_COMPLETION; |
| 379 | break; |
| 380 | default: |
| 381 | break; |
| 382 | } |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 383 | skip_rio: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | switch (mb[0]) { |
| 385 | case MBA_SCSI_COMPLETION: /* Fast Post */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 386 | if (!vha->flags.online) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | break; |
| 388 | |
| 389 | for (cnt = 0; cnt < handle_cnt; cnt++) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 390 | qla2x00_process_completed_request(vha, rsp->req, |
| 391 | handles[cnt]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | break; |
| 393 | |
| 394 | case MBA_RESET: /* Reset */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 395 | DEBUG2(printk("scsi(%ld): Asynchronous RESET.\n", |
| 396 | vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 398 | set_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | break; |
| 400 | |
| 401 | case MBA_SYSTEM_ERR: /* System Error */ |
Andrew Vasquez | bdab23d | 2009-10-13 15:16:46 -0700 | [diff] [blame] | 402 | mbx = IS_QLA81XX(ha) ? RD_REG_WORD(®24->mailbox7) : 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | qla_printk(KERN_INFO, ha, |
Andrew Vasquez | bdab23d | 2009-10-13 15:16:46 -0700 | [diff] [blame] | 404 | "ISP System Error - mbx1=%xh mbx2=%xh mbx3=%xh " |
| 405 | "mbx7=%xh.\n", mb[1], mb[2], mb[3], mbx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 407 | ha->isp_ops->fw_dump(vha, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 409 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 410 | if (mb[1] == 0 && mb[2] == 0) { |
| 411 | qla_printk(KERN_ERR, ha, |
| 412 | "Unrecoverable Hardware Error: adapter " |
| 413 | "marked OFFLINE!\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 414 | vha->flags.online = 0; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 415 | } else |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 416 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 417 | } else if (mb[1] == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | qla_printk(KERN_INFO, ha, |
| 419 | "Unrecoverable Hardware Error: adapter marked " |
| 420 | "OFFLINE!\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 421 | vha->flags.online = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | } else |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 423 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | break; |
| 425 | |
| 426 | case MBA_REQ_TRANSFER_ERR: /* Request Transfer Error */ |
Andrew Vasquez | bdab23d | 2009-10-13 15:16:46 -0700 | [diff] [blame] | 427 | DEBUG2(printk("scsi(%ld): ISP Request Transfer Error (%x).\n", |
| 428 | vha->host_no, mb[1])); |
| 429 | qla_printk(KERN_WARNING, ha, |
| 430 | "ISP Request Transfer Error (%x).\n", mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 432 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | break; |
| 434 | |
| 435 | case MBA_RSP_TRANSFER_ERR: /* Response Transfer Error */ |
| 436 | DEBUG2(printk("scsi(%ld): ISP Response Transfer Error.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 437 | vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | qla_printk(KERN_WARNING, ha, "ISP Response Transfer Error.\n"); |
| 439 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 440 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | break; |
| 442 | |
| 443 | case MBA_WAKEUP_THRES: /* Request Queue Wake-up */ |
| 444 | DEBUG2(printk("scsi(%ld): Asynchronous WAKEUP_THRES.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 445 | vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | break; |
| 447 | |
| 448 | case MBA_LIP_OCCURRED: /* Loop Initialization Procedure */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 449 | DEBUG2(printk("scsi(%ld): LIP occurred (%x).\n", vha->host_no, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | mb[1])); |
Bjorn Helgaas | cc3ef7b | 2008-09-11 21:22:51 -0700 | [diff] [blame] | 451 | qla_printk(KERN_INFO, ha, "LIP occurred (%x).\n", mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 453 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 454 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 455 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 456 | qla2x00_mark_all_devices_lost(vha, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | } |
| 458 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 459 | if (vha->vp_idx) { |
| 460 | atomic_set(&vha->vp_state, VP_FAILED); |
| 461 | fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 462 | } |
| 463 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 464 | set_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags); |
| 465 | set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 467 | vha->flags.management_server_logged_in = 0; |
| 468 | qla2x00_post_aen_work(vha, FCH_EVT_LIP, mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | break; |
| 470 | |
| 471 | case MBA_LOOP_UP: /* Loop Up Event */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
| 473 | link_speed = link_speeds[0]; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 474 | ha->link_data_rate = PORT_SPEED_1GB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | } else { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 476 | link_speed = link_speeds[LS_UNKNOWN]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | if (mb[1] < 5) |
| 478 | link_speed = link_speeds[mb[1]]; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 479 | else if (mb[1] == 0x13) |
| 480 | link_speed = link_speeds[5]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | ha->link_data_rate = mb[1]; |
| 482 | } |
| 483 | |
| 484 | DEBUG2(printk("scsi(%ld): Asynchronous LOOP UP (%s Gbps).\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 485 | vha->host_no, link_speed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 486 | qla_printk(KERN_INFO, ha, "LOOP UP detected (%s Gbps).\n", |
| 487 | link_speed); |
| 488 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 489 | vha->flags.management_server_logged_in = 0; |
| 490 | qla2x00_post_aen_work(vha, FCH_EVT_LINKUP, ha->link_data_rate); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | break; |
| 492 | |
| 493 | case MBA_LOOP_DOWN: /* Loop Down Event */ |
Andrew Vasquez | bdab23d | 2009-10-13 15:16:46 -0700 | [diff] [blame] | 494 | mbx = IS_QLA81XX(ha) ? RD_REG_WORD(®24->mailbox4) : 0; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 495 | DEBUG2(printk("scsi(%ld): Asynchronous LOOP DOWN " |
Andrew Vasquez | bdab23d | 2009-10-13 15:16:46 -0700 | [diff] [blame] | 496 | "(%x %x %x %x).\n", vha->host_no, mb[1], mb[2], mb[3], |
| 497 | mbx)); |
| 498 | qla_printk(KERN_INFO, ha, |
| 499 | "LOOP DOWN detected (%x %x %x %x).\n", mb[1], mb[2], mb[3], |
| 500 | mbx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 502 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 503 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 504 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 505 | vha->device_flags |= DFLG_NO_CABLE; |
| 506 | qla2x00_mark_all_devices_lost(vha, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 507 | } |
| 508 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 509 | if (vha->vp_idx) { |
| 510 | atomic_set(&vha->vp_state, VP_FAILED); |
| 511 | fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 512 | } |
| 513 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 514 | vha->flags.management_server_logged_in = 0; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 515 | ha->link_data_rate = PORT_SPEED_UNKNOWN; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 516 | qla2x00_post_aen_work(vha, FCH_EVT_LINKDOWN, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 517 | break; |
| 518 | |
| 519 | case MBA_LIP_RESET: /* LIP reset occurred */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | DEBUG2(printk("scsi(%ld): Asynchronous LIP RESET (%x).\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 521 | vha->host_no, mb[1])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | qla_printk(KERN_INFO, ha, |
Bjorn Helgaas | cc3ef7b | 2008-09-11 21:22:51 -0700 | [diff] [blame] | 523 | "LIP reset occurred (%x).\n", mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 524 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 525 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 526 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 527 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 528 | qla2x00_mark_all_devices_lost(vha, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | } |
| 530 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 531 | if (vha->vp_idx) { |
| 532 | atomic_set(&vha->vp_state, VP_FAILED); |
| 533 | fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 534 | } |
| 535 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 536 | set_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 537 | |
| 538 | ha->operating_mode = LOOP; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 539 | vha->flags.management_server_logged_in = 0; |
| 540 | qla2x00_post_aen_work(vha, FCH_EVT_LIPRESET, mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | break; |
| 542 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 543 | /* case MBA_DCBX_COMPLETE: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 544 | case MBA_POINT_TO_POINT: /* Point-to-Point */ |
| 545 | if (IS_QLA2100(ha)) |
| 546 | break; |
| 547 | |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 548 | if (IS_QLA8XXX_TYPE(ha)) { |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 549 | DEBUG2(printk("scsi(%ld): DCBX Completed -- %04x %04x " |
| 550 | "%04x\n", vha->host_no, mb[1], mb[2], mb[3])); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 551 | if (ha->notify_dcbx_comp) |
| 552 | complete(&ha->dcbx_comp); |
| 553 | |
| 554 | } else |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 555 | DEBUG2(printk("scsi(%ld): Asynchronous P2P MODE " |
| 556 | "received.\n", vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | |
| 558 | /* |
| 559 | * Until there's a transition from loop down to loop up, treat |
| 560 | * this as loop down only. |
| 561 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 562 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 563 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 564 | if (!atomic_read(&vha->loop_down_timer)) |
| 565 | atomic_set(&vha->loop_down_timer, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 566 | LOOP_DOWN_TIME); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 567 | qla2x00_mark_all_devices_lost(vha, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | } |
| 569 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 570 | if (vha->vp_idx) { |
| 571 | atomic_set(&vha->vp_state, VP_FAILED); |
| 572 | fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 573 | } |
| 574 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 575 | if (!(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))) |
| 576 | set_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
| 577 | |
| 578 | set_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags); |
| 579 | set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | 4346b14 | 2006-12-13 19:20:28 -0800 | [diff] [blame] | 580 | |
| 581 | ha->flags.gpsc_supported = 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 582 | vha->flags.management_server_logged_in = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | break; |
| 584 | |
| 585 | case MBA_CHG_IN_CONNECTION: /* Change in connection mode */ |
| 586 | if (IS_QLA2100(ha)) |
| 587 | break; |
| 588 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | DEBUG2(printk("scsi(%ld): Asynchronous Change In Connection " |
| 590 | "received.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 591 | vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | qla_printk(KERN_INFO, ha, |
| 593 | "Configuration change detected: value=%x.\n", mb[1]); |
| 594 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 595 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 596 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 597 | if (!atomic_read(&vha->loop_down_timer)) |
| 598 | atomic_set(&vha->loop_down_timer, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | LOOP_DOWN_TIME); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 600 | qla2x00_mark_all_devices_lost(vha, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 601 | } |
| 602 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 603 | if (vha->vp_idx) { |
| 604 | atomic_set(&vha->vp_state, VP_FAILED); |
| 605 | fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 606 | } |
| 607 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 608 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 609 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | break; |
| 611 | |
| 612 | case MBA_PORT_UPDATE: /* Port database update */ |
Santosh Vernekar | 55903b9 | 2009-07-31 15:09:25 -0700 | [diff] [blame] | 613 | /* |
| 614 | * Handle only global and vn-port update events |
| 615 | * |
| 616 | * Relevant inputs: |
| 617 | * mb[1] = N_Port handle of changed port |
| 618 | * OR 0xffff for global event |
| 619 | * mb[2] = New login state |
| 620 | * 7 = Port logged out |
| 621 | * mb[3] = LSB is vp_idx, 0xff = all vps |
| 622 | * |
| 623 | * Skip processing if: |
| 624 | * Event is global, vp_idx is NOT all vps, |
| 625 | * vp_idx does not match |
| 626 | * Event is not global, vp_idx does not match |
| 627 | */ |
Andrew Vasquez | 12cec63e4 | 2010-03-19 16:59:17 -0700 | [diff] [blame] | 628 | if (IS_QLA2XXX_MIDTYPE(ha) && |
| 629 | ((mb[1] == 0xffff && (mb[3] & 0xff) != 0xff) || |
| 630 | (mb[1] != 0xffff)) && vha->vp_idx != (mb[3] & 0xff)) |
| 631 | break; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 632 | |
Andrew Vasquez | 9764ff8 | 2009-07-31 15:09:24 -0700 | [diff] [blame] | 633 | /* Global event -- port logout or port unavailable. */ |
| 634 | if (mb[1] == 0xffff && mb[2] == 0x7) { |
| 635 | DEBUG2(printk("scsi(%ld): Asynchronous PORT UPDATE.\n", |
| 636 | vha->host_no)); |
| 637 | DEBUG(printk(KERN_INFO |
| 638 | "scsi(%ld): Port unavailable %04x %04x %04x.\n", |
| 639 | vha->host_no, mb[1], mb[2], mb[3])); |
| 640 | |
| 641 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 642 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 643 | atomic_set(&vha->loop_down_timer, |
| 644 | LOOP_DOWN_TIME); |
| 645 | vha->device_flags |= DFLG_NO_CABLE; |
| 646 | qla2x00_mark_all_devices_lost(vha, 1); |
| 647 | } |
| 648 | |
| 649 | if (vha->vp_idx) { |
| 650 | atomic_set(&vha->vp_state, VP_FAILED); |
| 651 | fc_vport_set_state(vha->fc_vport, |
| 652 | FC_VPORT_FAILED); |
Santosh Vernekar | faadc5e | 2009-07-31 15:09:26 -0700 | [diff] [blame] | 653 | qla2x00_mark_all_devices_lost(vha, 1); |
Andrew Vasquez | 9764ff8 | 2009-07-31 15:09:24 -0700 | [diff] [blame] | 654 | } |
| 655 | |
| 656 | vha->flags.management_server_logged_in = 0; |
| 657 | ha->link_data_rate = PORT_SPEED_UNKNOWN; |
| 658 | break; |
| 659 | } |
| 660 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 661 | /* |
Bjorn Helgaas | cc3ef7b | 2008-09-11 21:22:51 -0700 | [diff] [blame] | 662 | * If PORT UPDATE is global (received LIP_OCCURRED/LIP_RESET |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | * event etc. earlier indicating loop is down) then process |
| 664 | * it. Otherwise ignore it and Wait for RSCN to come in. |
| 665 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 666 | atomic_set(&vha->loop_down_timer, 0); |
| 667 | if (atomic_read(&vha->loop_state) != LOOP_DOWN && |
| 668 | atomic_read(&vha->loop_state) != LOOP_DEAD) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 669 | DEBUG2(printk("scsi(%ld): Asynchronous PORT UPDATE " |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 670 | "ignored %04x/%04x/%04x.\n", vha->host_no, mb[1], |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 671 | mb[2], mb[3])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | break; |
| 673 | } |
| 674 | |
| 675 | DEBUG2(printk("scsi(%ld): Asynchronous PORT UPDATE.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 676 | vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 677 | DEBUG(printk(KERN_INFO |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 678 | "scsi(%ld): Port database changed %04x %04x %04x.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 679 | vha->host_no, mb[1], mb[2], mb[3])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 680 | |
| 681 | /* |
| 682 | * Mark all devices as missing so we will login again. |
| 683 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 684 | atomic_set(&vha->loop_state, LOOP_UP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 686 | qla2x00_mark_all_devices_lost(vha, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 687 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 688 | vha->flags.rscn_queue_overflow = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 690 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 691 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 692 | break; |
| 693 | |
| 694 | case MBA_RSCN_UPDATE: /* State Change Registration */ |
Seokmann Ju | 3c39740 | 2008-05-19 14:25:39 -0700 | [diff] [blame] | 695 | /* Check if the Vport has issued a SCR */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 696 | if (vha->vp_idx && test_bit(VP_SCR_NEEDED, &vha->vp_flags)) |
Seokmann Ju | 3c39740 | 2008-05-19 14:25:39 -0700 | [diff] [blame] | 697 | break; |
| 698 | /* Only handle SCNs for our Vport index. */ |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 699 | if (ha->flags.npiv_supported && vha->vp_idx != (mb[3] & 0xff)) |
Seokmann Ju | 3c39740 | 2008-05-19 14:25:39 -0700 | [diff] [blame] | 700 | break; |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 701 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | DEBUG2(printk("scsi(%ld): Asynchronous RSCR UPDATE.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 703 | vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 704 | DEBUG(printk(KERN_INFO |
Shyam Sundar | f4a8dbc | 2007-11-12 10:30:59 -0800 | [diff] [blame] | 705 | "scsi(%ld): RSCN database changed -- %04x %04x %04x.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 706 | vha->host_no, mb[1], mb[2], mb[3])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | |
Ravi Anand | 59d72d8 | 2008-09-11 21:22:53 -0700 | [diff] [blame] | 708 | rscn_entry = ((mb[1] & 0xff) << 16) | mb[2]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 709 | host_pid = (vha->d_id.b.domain << 16) | (vha->d_id.b.area << 8) |
| 710 | | vha->d_id.b.al_pa; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 711 | if (rscn_entry == host_pid) { |
| 712 | DEBUG(printk(KERN_INFO |
| 713 | "scsi(%ld): Ignoring RSCN update to local host " |
| 714 | "port ID (%06x)\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 715 | vha->host_no, host_pid)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 716 | break; |
| 717 | } |
| 718 | |
Ravi Anand | 59d72d8 | 2008-09-11 21:22:53 -0700 | [diff] [blame] | 719 | /* Ignore reserved bits from RSCN-payload. */ |
| 720 | rscn_entry = ((mb[1] & 0x3ff) << 16) | mb[2]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 721 | rscn_queue_index = vha->rscn_in_ptr + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 722 | if (rscn_queue_index == MAX_RSCN_COUNT) |
| 723 | rscn_queue_index = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 724 | if (rscn_queue_index != vha->rscn_out_ptr) { |
| 725 | vha->rscn_queue[vha->rscn_in_ptr] = rscn_entry; |
| 726 | vha->rscn_in_ptr = rscn_queue_index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 727 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 728 | vha->flags.rscn_queue_overflow = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 729 | } |
| 730 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 731 | atomic_set(&vha->loop_state, LOOP_UPDATE); |
| 732 | atomic_set(&vha->loop_down_timer, 0); |
| 733 | vha->flags.management_server_logged_in = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 734 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 735 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 736 | set_bit(RSCN_UPDATE, &vha->dpc_flags); |
| 737 | qla2x00_post_aen_work(vha, FCH_EVT_RSCN, rscn_entry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 738 | break; |
| 739 | |
| 740 | /* case MBA_RIO_RESPONSE: */ |
| 741 | case MBA_ZIO_RESPONSE: |
Andrew Vasquez | 3fd67cd | 2009-01-05 11:18:07 -0800 | [diff] [blame] | 742 | DEBUG3(printk("scsi(%ld): [R|Z]IO update completion.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 743 | vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 744 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 745 | if (IS_FWI2_CAPABLE(ha)) |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 746 | qla24xx_process_response_queue(vha, rsp); |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 747 | else |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 748 | qla2x00_process_response_queue(rsp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 749 | break; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 750 | |
| 751 | case MBA_DISCARD_RND_FRAME: |
| 752 | DEBUG2(printk("scsi(%ld): Discard RND Frame -- %04x %04x " |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 753 | "%04x.\n", vha->host_no, mb[1], mb[2], mb[3])); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 754 | break; |
Andrew Vasquez | 45ebeb5 | 2006-08-01 13:48:14 -0700 | [diff] [blame] | 755 | |
| 756 | case MBA_TRACE_NOTIFICATION: |
| 757 | DEBUG2(printk("scsi(%ld): Trace Notification -- %04x %04x.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 758 | vha->host_no, mb[1], mb[2])); |
Andrew Vasquez | 45ebeb5 | 2006-08-01 13:48:14 -0700 | [diff] [blame] | 759 | break; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 760 | |
| 761 | case MBA_ISP84XX_ALERT: |
| 762 | DEBUG2(printk("scsi(%ld): ISP84XX Alert Notification -- " |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 763 | "%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] | 764 | |
| 765 | spin_lock_irqsave(&ha->cs84xx->access_lock, flags); |
| 766 | switch (mb[1]) { |
| 767 | case A84_PANIC_RECOVERY: |
| 768 | qla_printk(KERN_INFO, ha, "Alert 84XX: panic recovery " |
| 769 | "%04x %04x\n", mb[2], mb[3]); |
| 770 | break; |
| 771 | case A84_OP_LOGIN_COMPLETE: |
| 772 | ha->cs84xx->op_fw_version = mb[3] << 16 | mb[2]; |
| 773 | DEBUG2(qla_printk(KERN_INFO, ha, "Alert 84XX:" |
| 774 | "firmware version %x\n", ha->cs84xx->op_fw_version)); |
| 775 | break; |
| 776 | case A84_DIAG_LOGIN_COMPLETE: |
| 777 | ha->cs84xx->diag_fw_version = mb[3] << 16 | mb[2]; |
| 778 | DEBUG2(qla_printk(KERN_INFO, ha, "Alert 84XX:" |
| 779 | "diagnostic firmware version %x\n", |
| 780 | ha->cs84xx->diag_fw_version)); |
| 781 | break; |
| 782 | case A84_GOLD_LOGIN_COMPLETE: |
| 783 | ha->cs84xx->diag_fw_version = mb[3] << 16 | mb[2]; |
| 784 | ha->cs84xx->fw_update = 1; |
| 785 | DEBUG2(qla_printk(KERN_INFO, ha, "Alert 84XX: gold " |
| 786 | "firmware version %x\n", |
| 787 | ha->cs84xx->gold_fw_version)); |
| 788 | break; |
| 789 | default: |
| 790 | qla_printk(KERN_ERR, ha, |
| 791 | "Alert 84xx: Invalid Alert %04x %04x %04x\n", |
| 792 | mb[1], mb[2], mb[3]); |
| 793 | } |
| 794 | spin_unlock_irqrestore(&ha->cs84xx->access_lock, flags); |
| 795 | break; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 796 | case MBA_DCBX_START: |
| 797 | DEBUG2(printk("scsi(%ld): DCBX Started -- %04x %04x %04x\n", |
| 798 | vha->host_no, mb[1], mb[2], mb[3])); |
| 799 | break; |
| 800 | case MBA_DCBX_PARAM_UPDATE: |
| 801 | DEBUG2(printk("scsi(%ld): DCBX Parameters Updated -- " |
| 802 | "%04x %04x %04x\n", vha->host_no, mb[1], mb[2], mb[3])); |
| 803 | break; |
| 804 | case MBA_FCF_CONF_ERR: |
| 805 | DEBUG2(printk("scsi(%ld): FCF Configuration Error -- " |
| 806 | "%04x %04x %04x\n", vha->host_no, mb[1], mb[2], mb[3])); |
| 807 | break; |
| 808 | case MBA_IDC_COMPLETE: |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 809 | case MBA_IDC_NOTIFY: |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 810 | case MBA_IDC_TIME_EXT: |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 811 | qla81xx_idc_event(vha, mb[0], mb[1]); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 812 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 813 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 814 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 815 | if (!vha->vp_idx && ha->num_vhosts) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 816 | qla2x00_alert_all_vps(rsp, mb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 817 | } |
| 818 | |
| 819 | /** |
| 820 | * qla2x00_process_completed_request() - Process a Fast Post response. |
| 821 | * @ha: SCSI driver HA context |
| 822 | * @index: SRB index |
| 823 | */ |
| 824 | static void |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 825 | qla2x00_process_completed_request(struct scsi_qla_host *vha, |
| 826 | struct req_que *req, uint32_t index) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 827 | { |
| 828 | srb_t *sp; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 829 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 830 | |
| 831 | /* Validate handle. */ |
| 832 | if (index >= MAX_OUTSTANDING_COMMANDS) { |
| 833 | DEBUG2(printk("scsi(%ld): Invalid SCSI completion handle %d.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 834 | vha->host_no, index)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 835 | qla_printk(KERN_WARNING, ha, |
| 836 | "Invalid SCSI completion handle %d.\n", index); |
| 837 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 838 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 839 | return; |
| 840 | } |
| 841 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 842 | sp = req->outstanding_cmds[index]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 843 | if (sp) { |
| 844 | /* Free outstanding command slot. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 845 | req->outstanding_cmds[index] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 846 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 847 | /* Save ISP completion status */ |
| 848 | sp->cmd->result = DID_OK << 16; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 849 | qla2x00_sp_compl(ha, sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 850 | } else { |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 851 | DEBUG2(printk("scsi(%ld) Req:%d: Invalid ISP SCSI completion" |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 852 | " handle(0x%x)\n", vha->host_no, req->id, index)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 853 | qla_printk(KERN_WARNING, ha, |
| 854 | "Invalid ISP SCSI completion handle\n"); |
| 855 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 856 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 857 | } |
| 858 | } |
| 859 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 860 | static srb_t * |
| 861 | qla2x00_get_sp_from_handle(scsi_qla_host_t *vha, const char *func, |
| 862 | struct req_que *req, void *iocb) |
| 863 | { |
| 864 | struct qla_hw_data *ha = vha->hw; |
| 865 | sts_entry_t *pkt = iocb; |
| 866 | srb_t *sp = NULL; |
| 867 | uint16_t index; |
| 868 | |
| 869 | index = LSW(pkt->handle); |
| 870 | if (index >= MAX_OUTSTANDING_COMMANDS) { |
| 871 | qla_printk(KERN_WARNING, ha, |
| 872 | "%s: Invalid completion handle (%x).\n", func, index); |
| 873 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 874 | goto done; |
| 875 | } |
| 876 | sp = req->outstanding_cmds[index]; |
| 877 | if (!sp) { |
| 878 | qla_printk(KERN_WARNING, ha, |
| 879 | "%s: Invalid completion handle (%x) -- timed-out.\n", func, |
| 880 | index); |
| 881 | return sp; |
| 882 | } |
| 883 | if (sp->handle != index) { |
| 884 | qla_printk(KERN_WARNING, ha, |
| 885 | "%s: SRB handle (%x) mismatch %x.\n", func, sp->handle, |
| 886 | index); |
| 887 | return NULL; |
| 888 | } |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 889 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 890 | req->outstanding_cmds[index] = NULL; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 891 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 892 | done: |
| 893 | return sp; |
| 894 | } |
| 895 | |
| 896 | static void |
| 897 | qla2x00_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, |
| 898 | struct mbx_entry *mbx) |
| 899 | { |
| 900 | const char func[] = "MBX-IOCB"; |
| 901 | const char *type; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 902 | fc_port_t *fcport; |
| 903 | srb_t *sp; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 904 | struct srb_iocb *lio; |
| 905 | struct srb_ctx *ctx; |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 906 | uint16_t *data; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 907 | uint16_t status; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 908 | |
| 909 | sp = qla2x00_get_sp_from_handle(vha, func, req, mbx); |
| 910 | if (!sp) |
| 911 | return; |
| 912 | |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 913 | ctx = sp->ctx; |
| 914 | lio = ctx->u.iocb_cmd; |
| 915 | type = ctx->name; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 916 | fcport = sp->fcport; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 917 | data = lio->u.logio.data; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 918 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 919 | data[0] = MBS_COMMAND_ERROR; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 920 | data[1] = lio->u.logio.flags & SRB_LOGIN_RETRIED ? |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 921 | QLA_LOGIO_LOGIN_RETRIED : 0; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 922 | if (mbx->entry_status) { |
| 923 | DEBUG2(printk(KERN_WARNING |
Andrew Vasquez | d3fa9e7 | 2010-05-28 15:08:16 -0700 | [diff] [blame] | 924 | "scsi(%ld:%x): Async-%s error entry - portid=%02x%02x%02x " |
| 925 | "entry-status=%x status=%x state-flag=%x " |
| 926 | "status-flags=%x.\n", |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 927 | fcport->vha->host_no, sp->handle, type, |
Andrew Vasquez | d3fa9e7 | 2010-05-28 15:08:16 -0700 | [diff] [blame] | 928 | fcport->d_id.b.domain, fcport->d_id.b.area, |
| 929 | fcport->d_id.b.al_pa, mbx->entry_status, |
| 930 | le16_to_cpu(mbx->status), le16_to_cpu(mbx->state_flags), |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 931 | le16_to_cpu(mbx->status_flags))); |
Andrew Vasquez | d3fa9e7 | 2010-05-28 15:08:16 -0700 | [diff] [blame] | 932 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 933 | DEBUG2(qla2x00_dump_buffer((uint8_t *)mbx, sizeof(*mbx))); |
| 934 | |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 935 | goto logio_done; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 936 | } |
| 937 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 938 | status = le16_to_cpu(mbx->status); |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 939 | if (status == 0x30 && ctx->type == SRB_LOGIN_CMD && |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 940 | le16_to_cpu(mbx->mb0) == MBS_COMMAND_COMPLETE) |
| 941 | status = 0; |
| 942 | if (!status && le16_to_cpu(mbx->mb0) == MBS_COMMAND_COMPLETE) { |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 943 | DEBUG2(printk(KERN_DEBUG |
Andrew Vasquez | d3fa9e7 | 2010-05-28 15:08:16 -0700 | [diff] [blame] | 944 | "scsi(%ld:%x): Async-%s complete - portid=%02x%02x%02x " |
| 945 | "mbx1=%x.\n", |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 946 | fcport->vha->host_no, sp->handle, type, |
Andrew Vasquez | d3fa9e7 | 2010-05-28 15:08:16 -0700 | [diff] [blame] | 947 | fcport->d_id.b.domain, fcport->d_id.b.area, |
| 948 | fcport->d_id.b.al_pa, le16_to_cpu(mbx->mb1))); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 949 | |
| 950 | data[0] = MBS_COMMAND_COMPLETE; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 951 | if (ctx->type == SRB_LOGIN_CMD) { |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 952 | fcport->port_type = FCT_TARGET; |
| 953 | if (le16_to_cpu(mbx->mb1) & BIT_0) |
| 954 | fcport->port_type = FCT_INITIATOR; |
Andrew Vasquez | 6ac5260 | 2010-05-28 15:08:19 -0700 | [diff] [blame] | 955 | else if (le16_to_cpu(mbx->mb1) & BIT_1) |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 956 | fcport->flags |= FCF_FCP2_DEVICE; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 957 | } |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 958 | goto logio_done; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 959 | } |
| 960 | |
| 961 | data[0] = le16_to_cpu(mbx->mb0); |
| 962 | switch (data[0]) { |
| 963 | case MBS_PORT_ID_USED: |
| 964 | data[1] = le16_to_cpu(mbx->mb1); |
| 965 | break; |
| 966 | case MBS_LOOP_ID_USED: |
| 967 | break; |
| 968 | default: |
| 969 | data[0] = MBS_COMMAND_ERROR; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 970 | break; |
| 971 | } |
| 972 | |
| 973 | DEBUG2(printk(KERN_WARNING |
Andrew Vasquez | d3fa9e7 | 2010-05-28 15:08:16 -0700 | [diff] [blame] | 974 | "scsi(%ld:%x): Async-%s failed - portid=%02x%02x%02x status=%x " |
| 975 | "mb0=%x mb1=%x mb2=%x mb6=%x mb7=%x.\n", |
| 976 | fcport->vha->host_no, sp->handle, type, fcport->d_id.b.domain, |
| 977 | fcport->d_id.b.area, fcport->d_id.b.al_pa, status, |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 978 | le16_to_cpu(mbx->mb0), le16_to_cpu(mbx->mb1), |
| 979 | le16_to_cpu(mbx->mb2), le16_to_cpu(mbx->mb6), |
| 980 | le16_to_cpu(mbx->mb7))); |
| 981 | |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 982 | logio_done: |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 983 | lio->done(sp); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 984 | } |
| 985 | |
| 986 | static void |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 987 | qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req, |
| 988 | struct sts_entry_24xx *pkt, int iocb_type) |
| 989 | { |
| 990 | const char func[] = "ELS_CT_IOCB"; |
| 991 | const char *type; |
| 992 | struct qla_hw_data *ha = vha->hw; |
| 993 | srb_t *sp; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 994 | struct srb_ctx *sp_bsg; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 995 | struct fc_bsg_job *bsg_job; |
| 996 | uint16_t comp_status; |
| 997 | uint32_t fw_status[3]; |
| 998 | uint8_t* fw_sts_ptr; |
| 999 | |
| 1000 | sp = qla2x00_get_sp_from_handle(vha, func, req, pkt); |
| 1001 | if (!sp) |
| 1002 | return; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 1003 | sp_bsg = sp->ctx; |
| 1004 | bsg_job = sp_bsg->u.bsg_job; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1005 | |
| 1006 | type = NULL; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 1007 | switch (sp_bsg->type) { |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1008 | case SRB_ELS_CMD_RPT: |
| 1009 | case SRB_ELS_CMD_HST: |
| 1010 | type = "els"; |
| 1011 | break; |
| 1012 | case SRB_CT_CMD: |
| 1013 | type = "ct pass-through"; |
| 1014 | break; |
| 1015 | default: |
| 1016 | qla_printk(KERN_WARNING, ha, |
| 1017 | "%s: Unrecognized SRB: (%p) type=%d.\n", func, sp, |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 1018 | sp_bsg->type); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1019 | return; |
| 1020 | } |
| 1021 | |
| 1022 | comp_status = fw_status[0] = le16_to_cpu(pkt->comp_status); |
| 1023 | fw_status[1] = le16_to_cpu(((struct els_sts_entry_24xx*)pkt)->error_subcode_1); |
| 1024 | fw_status[2] = le16_to_cpu(((struct els_sts_entry_24xx*)pkt)->error_subcode_2); |
| 1025 | |
| 1026 | /* return FC_CTELS_STATUS_OK and leave the decoding of the ELS/CT |
| 1027 | * fc payload to the caller |
| 1028 | */ |
| 1029 | bsg_job->reply->reply_data.ctels_reply.status = FC_CTELS_STATUS_OK; |
| 1030 | bsg_job->reply_len = sizeof(struct fc_bsg_reply) + sizeof(fw_status); |
| 1031 | |
| 1032 | if (comp_status != CS_COMPLETE) { |
| 1033 | if (comp_status == CS_DATA_UNDERRUN) { |
| 1034 | bsg_job->reply->result = DID_OK << 16; |
| 1035 | bsg_job->reply->reply_payload_rcv_len = |
| 1036 | le16_to_cpu(((struct els_sts_entry_24xx*)pkt)->total_byte_count); |
| 1037 | |
| 1038 | DEBUG2(qla_printk(KERN_WARNING, ha, |
| 1039 | "scsi(%ld:0x%x): ELS-CT pass-through-%s error comp_status-status=0x%x " |
| 1040 | "error subcode 1=0x%x error subcode 2=0x%x total_byte = 0x%x.\n", |
| 1041 | vha->host_no, sp->handle, type, comp_status, fw_status[1], fw_status[2], |
| 1042 | le16_to_cpu(((struct els_sts_entry_24xx*)pkt)->total_byte_count))); |
| 1043 | fw_sts_ptr = ((uint8_t*)bsg_job->req->sense) + sizeof(struct fc_bsg_reply); |
| 1044 | memcpy( fw_sts_ptr, fw_status, sizeof(fw_status)); |
| 1045 | } |
| 1046 | else { |
| 1047 | DEBUG2(qla_printk(KERN_WARNING, ha, |
| 1048 | "scsi(%ld:0x%x): ELS-CT pass-through-%s error comp_status-status=0x%x " |
| 1049 | "error subcode 1=0x%x error subcode 2=0x%x.\n", |
| 1050 | vha->host_no, sp->handle, type, comp_status, |
| 1051 | le16_to_cpu(((struct els_sts_entry_24xx*)pkt)->error_subcode_1), |
| 1052 | le16_to_cpu(((struct els_sts_entry_24xx*)pkt)->error_subcode_2))); |
| 1053 | bsg_job->reply->result = DID_ERROR << 16; |
| 1054 | bsg_job->reply->reply_payload_rcv_len = 0; |
| 1055 | fw_sts_ptr = ((uint8_t*)bsg_job->req->sense) + sizeof(struct fc_bsg_reply); |
| 1056 | memcpy( fw_sts_ptr, fw_status, sizeof(fw_status)); |
| 1057 | } |
| 1058 | DEBUG2(qla2x00_dump_buffer((uint8_t *)pkt, sizeof(*pkt))); |
| 1059 | } |
| 1060 | else { |
| 1061 | bsg_job->reply->result = DID_OK << 16;; |
| 1062 | bsg_job->reply->reply_payload_rcv_len = bsg_job->reply_payload.payload_len; |
| 1063 | bsg_job->reply_len = 0; |
| 1064 | } |
| 1065 | |
| 1066 | dma_unmap_sg(&ha->pdev->dev, |
| 1067 | bsg_job->request_payload.sg_list, |
| 1068 | bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE); |
| 1069 | dma_unmap_sg(&ha->pdev->dev, |
| 1070 | bsg_job->reply_payload.sg_list, |
| 1071 | bsg_job->reply_payload.sg_cnt, DMA_FROM_DEVICE); |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 1072 | if ((sp_bsg->type == SRB_ELS_CMD_HST) || |
| 1073 | (sp_bsg->type == SRB_CT_CMD)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1074 | kfree(sp->fcport); |
| 1075 | kfree(sp->ctx); |
| 1076 | mempool_free(sp, ha->srb_mempool); |
| 1077 | bsg_job->job_done(bsg_job); |
| 1078 | } |
| 1079 | |
| 1080 | static void |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1081 | qla24xx_logio_entry(scsi_qla_host_t *vha, struct req_que *req, |
| 1082 | struct logio_entry_24xx *logio) |
| 1083 | { |
| 1084 | const char func[] = "LOGIO-IOCB"; |
| 1085 | const char *type; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1086 | fc_port_t *fcport; |
| 1087 | srb_t *sp; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 1088 | struct srb_iocb *lio; |
| 1089 | struct srb_ctx *ctx; |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 1090 | uint16_t *data; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1091 | uint32_t iop[2]; |
| 1092 | |
| 1093 | sp = qla2x00_get_sp_from_handle(vha, func, req, logio); |
| 1094 | if (!sp) |
| 1095 | return; |
| 1096 | |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 1097 | ctx = sp->ctx; |
| 1098 | lio = ctx->u.iocb_cmd; |
| 1099 | type = ctx->name; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1100 | fcport = sp->fcport; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 1101 | data = lio->u.logio.data; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1102 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 1103 | data[0] = MBS_COMMAND_ERROR; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 1104 | data[1] = lio->u.logio.flags & SRB_LOGIN_RETRIED ? |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 1105 | QLA_LOGIO_LOGIN_RETRIED : 0; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1106 | if (logio->entry_status) { |
| 1107 | DEBUG2(printk(KERN_WARNING |
Andrew Vasquez | d3fa9e7 | 2010-05-28 15:08:16 -0700 | [diff] [blame] | 1108 | "scsi(%ld:%x): Async-%s error entry - " |
| 1109 | "portid=%02x%02x%02x entry-status=%x.\n", |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1110 | fcport->vha->host_no, sp->handle, type, |
Andrew Vasquez | d3fa9e7 | 2010-05-28 15:08:16 -0700 | [diff] [blame] | 1111 | fcport->d_id.b.domain, fcport->d_id.b.area, |
| 1112 | fcport->d_id.b.al_pa, logio->entry_status)); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1113 | DEBUG2(qla2x00_dump_buffer((uint8_t *)logio, sizeof(*logio))); |
| 1114 | |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 1115 | goto logio_done; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1116 | } |
| 1117 | |
| 1118 | if (le16_to_cpu(logio->comp_status) == CS_COMPLETE) { |
| 1119 | DEBUG2(printk(KERN_DEBUG |
Andrew Vasquez | d3fa9e7 | 2010-05-28 15:08:16 -0700 | [diff] [blame] | 1120 | "scsi(%ld:%x): Async-%s complete - portid=%02x%02x%02x " |
| 1121 | "iop0=%x.\n", |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1122 | fcport->vha->host_no, sp->handle, type, |
Andrew Vasquez | d3fa9e7 | 2010-05-28 15:08:16 -0700 | [diff] [blame] | 1123 | fcport->d_id.b.domain, fcport->d_id.b.area, |
| 1124 | fcport->d_id.b.al_pa, |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1125 | le32_to_cpu(logio->io_parameter[0]))); |
| 1126 | |
| 1127 | data[0] = MBS_COMMAND_COMPLETE; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 1128 | if (ctx->type != SRB_LOGIN_CMD) |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 1129 | goto logio_done; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1130 | |
| 1131 | iop[0] = le32_to_cpu(logio->io_parameter[0]); |
| 1132 | if (iop[0] & BIT_4) { |
| 1133 | fcport->port_type = FCT_TARGET; |
| 1134 | if (iop[0] & BIT_8) |
Santosh Vernekar | 8474f3a | 2009-08-25 11:36:16 -0700 | [diff] [blame] | 1135 | fcport->flags |= FCF_FCP2_DEVICE; |
Andrew Vasquez | b0cd579 | 2010-05-28 15:08:22 -0700 | [diff] [blame^] | 1136 | } else if (iop[0] & BIT_5) |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1137 | fcport->port_type = FCT_INITIATOR; |
Andrew Vasquez | b0cd579 | 2010-05-28 15:08:22 -0700 | [diff] [blame^] | 1138 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1139 | if (logio->io_parameter[7] || logio->io_parameter[8]) |
| 1140 | fcport->supported_classes |= FC_COS_CLASS2; |
| 1141 | if (logio->io_parameter[9] || logio->io_parameter[10]) |
| 1142 | fcport->supported_classes |= FC_COS_CLASS3; |
| 1143 | |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 1144 | goto logio_done; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1145 | } |
| 1146 | |
| 1147 | iop[0] = le32_to_cpu(logio->io_parameter[0]); |
| 1148 | iop[1] = le32_to_cpu(logio->io_parameter[1]); |
| 1149 | switch (iop[0]) { |
| 1150 | case LSC_SCODE_PORTID_USED: |
| 1151 | data[0] = MBS_PORT_ID_USED; |
| 1152 | data[1] = LSW(iop[1]); |
| 1153 | break; |
| 1154 | case LSC_SCODE_NPORT_USED: |
| 1155 | data[0] = MBS_LOOP_ID_USED; |
| 1156 | break; |
| 1157 | case LSC_SCODE_CMD_FAILED: |
| 1158 | if ((iop[1] & 0xff) == 0x05) { |
| 1159 | data[0] = MBS_NOT_LOGGED_IN; |
| 1160 | break; |
| 1161 | } |
| 1162 | /* Fall through. */ |
| 1163 | default: |
| 1164 | data[0] = MBS_COMMAND_ERROR; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1165 | break; |
| 1166 | } |
| 1167 | |
| 1168 | DEBUG2(printk(KERN_WARNING |
Andrew Vasquez | d3fa9e7 | 2010-05-28 15:08:16 -0700 | [diff] [blame] | 1169 | "scsi(%ld:%x): Async-%s failed - portid=%02x%02x%02x comp=%x " |
| 1170 | "iop0=%x iop1=%x.\n", |
| 1171 | fcport->vha->host_no, sp->handle, type, fcport->d_id.b.domain, |
| 1172 | fcport->d_id.b.area, fcport->d_id.b.al_pa, |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1173 | le16_to_cpu(logio->comp_status), |
| 1174 | le32_to_cpu(logio->io_parameter[0]), |
| 1175 | le32_to_cpu(logio->io_parameter[1]))); |
| 1176 | |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 1177 | logio_done: |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 1178 | lio->done(sp); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1179 | } |
| 1180 | |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 1181 | static void |
| 1182 | qla24xx_tm_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, |
| 1183 | struct tsk_mgmt_entry *tsk) |
| 1184 | { |
| 1185 | const char func[] = "TMF-IOCB"; |
| 1186 | const char *type; |
| 1187 | fc_port_t *fcport; |
| 1188 | srb_t *sp; |
| 1189 | struct srb_iocb *iocb; |
| 1190 | struct srb_ctx *ctx; |
| 1191 | struct sts_entry_24xx *sts = (struct sts_entry_24xx *)tsk; |
| 1192 | int error = 1; |
| 1193 | |
| 1194 | sp = qla2x00_get_sp_from_handle(vha, func, req, tsk); |
| 1195 | if (!sp) |
| 1196 | return; |
| 1197 | |
| 1198 | ctx = sp->ctx; |
| 1199 | iocb = ctx->u.iocb_cmd; |
| 1200 | type = ctx->name; |
| 1201 | fcport = sp->fcport; |
| 1202 | |
| 1203 | if (sts->entry_status) { |
| 1204 | DEBUG2(printk(KERN_WARNING |
| 1205 | "scsi(%ld:%x): Async-%s error - entry-status(%x).\n", |
| 1206 | fcport->vha->host_no, sp->handle, type, |
| 1207 | sts->entry_status)); |
| 1208 | } else if (sts->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) { |
| 1209 | DEBUG2(printk(KERN_WARNING |
| 1210 | "scsi(%ld:%x): Async-%s error - completion status(%x).\n", |
| 1211 | fcport->vha->host_no, sp->handle, type, |
| 1212 | sts->comp_status)); |
| 1213 | } else if (!(le16_to_cpu(sts->scsi_status) & |
| 1214 | SS_RESPONSE_INFO_LEN_VALID)) { |
| 1215 | DEBUG2(printk(KERN_WARNING |
| 1216 | "scsi(%ld:%x): Async-%s error - no response info(%x).\n", |
| 1217 | fcport->vha->host_no, sp->handle, type, |
| 1218 | sts->scsi_status)); |
| 1219 | } else if (le32_to_cpu(sts->rsp_data_len) < 4) { |
| 1220 | DEBUG2(printk(KERN_WARNING |
| 1221 | "scsi(%ld:%x): Async-%s error - not enough response(%d).\n", |
| 1222 | fcport->vha->host_no, sp->handle, type, |
| 1223 | sts->rsp_data_len)); |
| 1224 | } else if (sts->data[3]) { |
| 1225 | DEBUG2(printk(KERN_WARNING |
| 1226 | "scsi(%ld:%x): Async-%s error - response(%x).\n", |
| 1227 | fcport->vha->host_no, sp->handle, type, |
| 1228 | sts->data[3])); |
| 1229 | } else { |
| 1230 | error = 0; |
| 1231 | } |
| 1232 | |
| 1233 | if (error) { |
| 1234 | iocb->u.tmf.data = error; |
| 1235 | DEBUG2(qla2x00_dump_buffer((uint8_t *)sts, sizeof(*sts))); |
| 1236 | } |
| 1237 | |
| 1238 | iocb->done(sp); |
| 1239 | } |
| 1240 | |
| 1241 | static void |
| 1242 | qla24xx_marker_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, |
| 1243 | struct mrk_entry_24xx *mrk) |
| 1244 | { |
| 1245 | const char func[] = "MRK-IOCB"; |
| 1246 | const char *type; |
| 1247 | fc_port_t *fcport; |
| 1248 | srb_t *sp; |
| 1249 | struct srb_iocb *iocb; |
| 1250 | struct srb_ctx *ctx; |
| 1251 | struct sts_entry_24xx *sts = (struct sts_entry_24xx *)mrk; |
| 1252 | |
| 1253 | sp = qla2x00_get_sp_from_handle(vha, func, req, mrk); |
| 1254 | if (!sp) |
| 1255 | return; |
| 1256 | |
| 1257 | ctx = sp->ctx; |
| 1258 | iocb = ctx->u.iocb_cmd; |
| 1259 | type = ctx->name; |
| 1260 | fcport = sp->fcport; |
| 1261 | |
| 1262 | if (sts->entry_status) { |
| 1263 | iocb->u.marker.data = 1; |
| 1264 | DEBUG2(printk(KERN_WARNING |
| 1265 | "scsi(%ld:%x): Async-%s error entry - entry-status=%x.\n", |
| 1266 | fcport->vha->host_no, sp->handle, type, |
| 1267 | sts->entry_status)); |
| 1268 | DEBUG2(qla2x00_dump_buffer((uint8_t *)mrk, sizeof(*sts))); |
| 1269 | } |
| 1270 | |
| 1271 | iocb->done(sp); |
| 1272 | } |
| 1273 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1274 | /** |
| 1275 | * qla2x00_process_response_queue() - Process response queue entries. |
| 1276 | * @ha: SCSI driver HA context |
| 1277 | */ |
| 1278 | void |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1279 | qla2x00_process_response_queue(struct rsp_que *rsp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1280 | { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1281 | struct scsi_qla_host *vha; |
| 1282 | struct qla_hw_data *ha = rsp->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 1283 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1284 | sts_entry_t *pkt; |
| 1285 | uint16_t handle_cnt; |
| 1286 | uint16_t cnt; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1287 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1288 | vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1289 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1290 | if (!vha->flags.online) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1291 | return; |
| 1292 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1293 | while (rsp->ring_ptr->signature != RESPONSE_PROCESSED) { |
| 1294 | pkt = (sts_entry_t *)rsp->ring_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1295 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1296 | rsp->ring_index++; |
| 1297 | if (rsp->ring_index == rsp->length) { |
| 1298 | rsp->ring_index = 0; |
| 1299 | rsp->ring_ptr = rsp->ring; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1300 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1301 | rsp->ring_ptr++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1302 | } |
| 1303 | |
| 1304 | if (pkt->entry_status != 0) { |
| 1305 | DEBUG3(printk(KERN_INFO |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1306 | "scsi(%ld): Process error entry.\n", vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1307 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1308 | qla2x00_error_entry(vha, rsp, pkt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1309 | ((response_t *)pkt)->signature = RESPONSE_PROCESSED; |
| 1310 | wmb(); |
| 1311 | continue; |
| 1312 | } |
| 1313 | |
| 1314 | switch (pkt->entry_type) { |
| 1315 | case STATUS_TYPE: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1316 | qla2x00_status_entry(vha, rsp, pkt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1317 | break; |
| 1318 | case STATUS_TYPE_21: |
| 1319 | handle_cnt = ((sts21_entry_t *)pkt)->handle_count; |
| 1320 | for (cnt = 0; cnt < handle_cnt; cnt++) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1321 | qla2x00_process_completed_request(vha, rsp->req, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1322 | ((sts21_entry_t *)pkt)->handle[cnt]); |
| 1323 | } |
| 1324 | break; |
| 1325 | case STATUS_TYPE_22: |
| 1326 | handle_cnt = ((sts22_entry_t *)pkt)->handle_count; |
| 1327 | for (cnt = 0; cnt < handle_cnt; cnt++) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1328 | qla2x00_process_completed_request(vha, rsp->req, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1329 | ((sts22_entry_t *)pkt)->handle[cnt]); |
| 1330 | } |
| 1331 | break; |
| 1332 | case STATUS_CONT_TYPE: |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1333 | qla2x00_status_cont_entry(rsp, (sts_cont_entry_t *)pkt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1334 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1335 | case MBX_IOCB_TYPE: |
| 1336 | qla2x00_mbx_iocb_entry(vha, rsp->req, |
| 1337 | (struct mbx_entry *)pkt); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 1338 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1339 | default: |
| 1340 | /* Type Not Supported. */ |
| 1341 | DEBUG4(printk(KERN_WARNING |
| 1342 | "scsi(%ld): Received unknown response pkt type %x " |
| 1343 | "entry status=%x.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1344 | vha->host_no, pkt->entry_type, pkt->entry_status)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1345 | break; |
| 1346 | } |
| 1347 | ((response_t *)pkt)->signature = RESPONSE_PROCESSED; |
| 1348 | wmb(); |
| 1349 | } |
| 1350 | |
| 1351 | /* Adjust ring index */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1352 | WRT_REG_WORD(ISP_RSP_Q_OUT(ha, reg), rsp->ring_index); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1353 | } |
| 1354 | |
Andrew Vasquez | 4733fcb | 2008-01-17 09:02:07 -0800 | [diff] [blame] | 1355 | static inline void |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1356 | qla2x00_handle_sense(srb_t *sp, uint8_t *sense_data, uint32_t sense_len, |
| 1357 | struct rsp_que *rsp) |
Andrew Vasquez | 4733fcb | 2008-01-17 09:02:07 -0800 | [diff] [blame] | 1358 | { |
| 1359 | struct scsi_cmnd *cp = sp->cmd; |
| 1360 | |
| 1361 | if (sense_len >= SCSI_SENSE_BUFFERSIZE) |
| 1362 | sense_len = SCSI_SENSE_BUFFERSIZE; |
| 1363 | |
Andrew Vasquez | 4733fcb | 2008-01-17 09:02:07 -0800 | [diff] [blame] | 1364 | sp->request_sense_length = sense_len; |
| 1365 | sp->request_sense_ptr = cp->sense_buffer; |
| 1366 | if (sp->request_sense_length > 32) |
| 1367 | sense_len = 32; |
| 1368 | |
| 1369 | memcpy(cp->sense_buffer, sense_data, sense_len); |
| 1370 | |
| 1371 | sp->request_sense_ptr += sense_len; |
| 1372 | sp->request_sense_length -= sense_len; |
| 1373 | if (sp->request_sense_length != 0) |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1374 | rsp->status_srb = sp; |
Andrew Vasquez | 4733fcb | 2008-01-17 09:02:07 -0800 | [diff] [blame] | 1375 | |
| 1376 | DEBUG5(printk("%s(): Check condition Sense data, scsi(%ld:%d:%d:%d) " |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1377 | "cmd=%p pid=%ld\n", __func__, sp->fcport->vha->host_no, |
Andrew Vasquez | 19851f1 | 2008-08-13 21:37:00 -0700 | [diff] [blame] | 1378 | cp->device->channel, cp->device->id, cp->device->lun, cp, |
| 1379 | cp->serial_number)); |
Andrew Vasquez | 4733fcb | 2008-01-17 09:02:07 -0800 | [diff] [blame] | 1380 | if (sense_len) |
Shyam Sundar | ddb9b12 | 2009-03-24 09:08:10 -0700 | [diff] [blame] | 1381 | DEBUG5(qla2x00_dump_buffer(cp->sense_buffer, sense_len)); |
Andrew Vasquez | 4733fcb | 2008-01-17 09:02:07 -0800 | [diff] [blame] | 1382 | } |
| 1383 | |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1384 | struct scsi_dif_tuple { |
| 1385 | __be16 guard; /* Checksum */ |
| 1386 | __be16 app_tag; /* APPL identifer */ |
| 1387 | __be32 ref_tag; /* Target LBA or indirect LBA */ |
| 1388 | }; |
| 1389 | |
| 1390 | /* |
| 1391 | * Checks the guard or meta-data for the type of error |
| 1392 | * detected by the HBA. In case of errors, we set the |
| 1393 | * ASC/ASCQ fields in the sense buffer with ILLEGAL_REQUEST |
| 1394 | * to indicate to the kernel that the HBA detected error. |
| 1395 | */ |
| 1396 | static inline void |
| 1397 | qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24) |
| 1398 | { |
| 1399 | struct scsi_cmnd *cmd = sp->cmd; |
| 1400 | struct scsi_dif_tuple *ep = |
| 1401 | (struct scsi_dif_tuple *)&sts24->data[20]; |
| 1402 | struct scsi_dif_tuple *ap = |
| 1403 | (struct scsi_dif_tuple *)&sts24->data[12]; |
| 1404 | uint32_t e_ref_tag, a_ref_tag; |
| 1405 | uint16_t e_app_tag, a_app_tag; |
| 1406 | uint16_t e_guard, a_guard; |
| 1407 | |
| 1408 | e_ref_tag = be32_to_cpu(ep->ref_tag); |
| 1409 | a_ref_tag = be32_to_cpu(ap->ref_tag); |
| 1410 | e_app_tag = be16_to_cpu(ep->app_tag); |
| 1411 | a_app_tag = be16_to_cpu(ap->app_tag); |
| 1412 | e_guard = be16_to_cpu(ep->guard); |
| 1413 | a_guard = be16_to_cpu(ap->guard); |
| 1414 | |
| 1415 | DEBUG18(printk(KERN_DEBUG |
| 1416 | "%s(): iocb(s) %p Returned STATUS\n", __func__, sts24)); |
| 1417 | |
| 1418 | DEBUG18(printk(KERN_ERR "DIF ERROR in cmd 0x%x lba 0x%llx act ref" |
| 1419 | " tag=0x%x, exp ref_tag=0x%x, act app tag=0x%x, exp app" |
| 1420 | " tag=0x%x, act guard=0x%x, exp guard=0x%x\n", |
| 1421 | cmd->cmnd[0], (u64)scsi_get_lba(cmd), a_ref_tag, e_ref_tag, |
| 1422 | a_app_tag, e_app_tag, a_guard, e_guard)); |
| 1423 | |
| 1424 | |
| 1425 | /* check guard */ |
| 1426 | if (e_guard != a_guard) { |
| 1427 | scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, |
| 1428 | 0x10, 0x1); |
| 1429 | set_driver_byte(cmd, DRIVER_SENSE); |
| 1430 | set_host_byte(cmd, DID_ABORT); |
| 1431 | cmd->result |= SAM_STAT_CHECK_CONDITION << 1; |
| 1432 | return; |
| 1433 | } |
| 1434 | |
| 1435 | /* check appl tag */ |
| 1436 | if (e_app_tag != a_app_tag) { |
| 1437 | scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, |
| 1438 | 0x10, 0x2); |
| 1439 | set_driver_byte(cmd, DRIVER_SENSE); |
| 1440 | set_host_byte(cmd, DID_ABORT); |
| 1441 | cmd->result |= SAM_STAT_CHECK_CONDITION << 1; |
| 1442 | return; |
| 1443 | } |
| 1444 | |
| 1445 | /* check ref tag */ |
| 1446 | if (e_ref_tag != a_ref_tag) { |
| 1447 | scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, |
| 1448 | 0x10, 0x3); |
| 1449 | set_driver_byte(cmd, DRIVER_SENSE); |
| 1450 | set_host_byte(cmd, DID_ABORT); |
| 1451 | cmd->result |= SAM_STAT_CHECK_CONDITION << 1; |
| 1452 | return; |
| 1453 | } |
| 1454 | } |
| 1455 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1456 | /** |
| 1457 | * qla2x00_status_entry() - Process a Status IOCB entry. |
| 1458 | * @ha: SCSI driver HA context |
| 1459 | * @pkt: Entry pointer |
| 1460 | */ |
| 1461 | static void |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1462 | 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] | 1463 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1464 | srb_t *sp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1465 | fc_port_t *fcport; |
| 1466 | struct scsi_cmnd *cp; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1467 | sts_entry_t *sts; |
| 1468 | struct sts_entry_24xx *sts24; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1469 | uint16_t comp_status; |
| 1470 | uint16_t scsi_status; |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1471 | uint16_t ox_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1472 | uint8_t lscsi_status; |
| 1473 | int32_t resid; |
Ravi Anand | ed17c71b5 | 2006-05-17 15:08:55 -0700 | [diff] [blame] | 1474 | uint32_t sense_len, rsp_info_len, resid_len, fw_resid_len; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1475 | uint8_t *rsp_info, *sense_data; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1476 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1477 | uint32_t handle; |
| 1478 | uint16_t que; |
| 1479 | struct req_que *req; |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1480 | int logit = 1; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1481 | |
| 1482 | sts = (sts_entry_t *) pkt; |
| 1483 | sts24 = (struct sts_entry_24xx *) pkt; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1484 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1485 | comp_status = le16_to_cpu(sts24->comp_status); |
| 1486 | scsi_status = le16_to_cpu(sts24->scsi_status) & SS_MASK; |
| 1487 | } else { |
| 1488 | comp_status = le16_to_cpu(sts->comp_status); |
| 1489 | scsi_status = le16_to_cpu(sts->scsi_status) & SS_MASK; |
| 1490 | } |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1491 | handle = (uint32_t) LSW(sts->handle); |
| 1492 | que = MSW(sts->handle); |
| 1493 | req = ha->req_q_map[que]; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1494 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1495 | /* Fast path completion. */ |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1496 | if (comp_status == CS_COMPLETE && scsi_status == 0) { |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1497 | qla2x00_process_completed_request(vha, req, handle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1498 | |
| 1499 | return; |
| 1500 | } |
| 1501 | |
| 1502 | /* Validate handle. */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1503 | if (handle < MAX_OUTSTANDING_COMMANDS) { |
| 1504 | sp = req->outstanding_cmds[handle]; |
| 1505 | req->outstanding_cmds[handle] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1506 | } else |
| 1507 | sp = NULL; |
| 1508 | |
| 1509 | if (sp == NULL) { |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1510 | qla_printk(KERN_WARNING, ha, |
| 1511 | "scsi(%ld): Invalid status handle (0x%x).\n", vha->host_no, |
| 1512 | sts->handle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1513 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1514 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 1515 | qla2xxx_wake_dpc(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1516 | return; |
| 1517 | } |
| 1518 | cp = sp->cmd; |
| 1519 | if (cp == NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1520 | qla_printk(KERN_WARNING, ha, |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1521 | "scsi(%ld): Command already returned (0x%x/%p).\n", |
| 1522 | vha->host_no, sts->handle, sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1523 | |
| 1524 | return; |
| 1525 | } |
| 1526 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1527 | lscsi_status = scsi_status & STATUS_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1528 | |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1529 | fcport = sp->fcport; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1530 | |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1531 | ox_id = 0; |
Ravi Anand | ed17c71b5 | 2006-05-17 15:08:55 -0700 | [diff] [blame] | 1532 | sense_len = rsp_info_len = resid_len = fw_resid_len = 0; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1533 | if (IS_FWI2_CAPABLE(ha)) { |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 1534 | if (scsi_status & SS_SENSE_LEN_VALID) |
| 1535 | sense_len = le32_to_cpu(sts24->sense_len); |
| 1536 | if (scsi_status & SS_RESPONSE_INFO_LEN_VALID) |
| 1537 | rsp_info_len = le32_to_cpu(sts24->rsp_data_len); |
| 1538 | if (scsi_status & (SS_RESIDUAL_UNDER | SS_RESIDUAL_OVER)) |
| 1539 | resid_len = le32_to_cpu(sts24->rsp_residual_count); |
| 1540 | if (comp_status == CS_DATA_UNDERRUN) |
| 1541 | fw_resid_len = le32_to_cpu(sts24->residual_len); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1542 | rsp_info = sts24->data; |
| 1543 | sense_data = sts24->data; |
| 1544 | host_to_fcp_swap(sts24->data, sizeof(sts24->data)); |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1545 | ox_id = le16_to_cpu(sts24->ox_id); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1546 | } else { |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 1547 | if (scsi_status & SS_SENSE_LEN_VALID) |
| 1548 | sense_len = le16_to_cpu(sts->req_sense_length); |
| 1549 | if (scsi_status & SS_RESPONSE_INFO_LEN_VALID) |
| 1550 | rsp_info_len = le16_to_cpu(sts->rsp_info_len); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1551 | resid_len = le32_to_cpu(sts->residual_length); |
| 1552 | rsp_info = sts->rsp_info; |
| 1553 | sense_data = sts->req_sense_data; |
| 1554 | } |
| 1555 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1556 | /* Check for any FCP transport errors. */ |
| 1557 | if (scsi_status & SS_RESPONSE_INFO_LEN_VALID) { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1558 | /* Sense data lies beyond any FCP RESPONSE data. */ |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1559 | if (IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1560 | sense_data += rsp_info_len; |
| 1561 | if (rsp_info_len > 3 && rsp_info[3]) { |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1562 | DEBUG2(qla_printk(KERN_INFO, ha, |
| 1563 | "scsi(%ld:%d:%d): FCP I/O protocol failure " |
| 1564 | "(0x%x/0x%x).\n", vha->host_no, cp->device->id, |
| 1565 | cp->device->lun, rsp_info_len, rsp_info[3])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1566 | |
| 1567 | cp->result = DID_BUS_BUSY << 16; |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1568 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1569 | } |
| 1570 | } |
| 1571 | |
Andrew Vasquez | 3e8ce32 | 2008-02-28 14:06:10 -0800 | [diff] [blame] | 1572 | /* Check for overrun. */ |
| 1573 | if (IS_FWI2_CAPABLE(ha) && comp_status == CS_COMPLETE && |
| 1574 | scsi_status & SS_RESIDUAL_OVER) |
| 1575 | comp_status = CS_DATA_OVERRUN; |
| 1576 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1577 | /* |
| 1578 | * Based on Host and scsi status generate status code for Linux |
| 1579 | */ |
| 1580 | switch (comp_status) { |
| 1581 | case CS_COMPLETE: |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 1582 | case CS_QUEUE_FULL: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1583 | if (scsi_status == 0) { |
| 1584 | cp->result = DID_OK << 16; |
| 1585 | break; |
| 1586 | } |
| 1587 | if (scsi_status & (SS_RESIDUAL_UNDER | SS_RESIDUAL_OVER)) { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1588 | resid = resid_len; |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 1589 | scsi_set_resid(cp, resid); |
Andrew Vasquez | 0da69df | 2005-12-06 10:58:06 -0800 | [diff] [blame] | 1590 | |
| 1591 | if (!lscsi_status && |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 1592 | ((unsigned)(scsi_bufflen(cp) - resid) < |
Andrew Vasquez | 0da69df | 2005-12-06 10:58:06 -0800 | [diff] [blame] | 1593 | cp->underflow)) { |
| 1594 | qla_printk(KERN_INFO, ha, |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1595 | "scsi(%ld:%d:%d): Mid-layer underflow " |
| 1596 | "detected (0x%x of 0x%x bytes).\n", |
| 1597 | vha->host_no, cp->device->id, |
| 1598 | cp->device->lun, resid, scsi_bufflen(cp)); |
Andrew Vasquez | 0da69df | 2005-12-06 10:58:06 -0800 | [diff] [blame] | 1599 | |
| 1600 | cp->result = DID_ERROR << 16; |
| 1601 | break; |
| 1602 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1603 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1604 | cp->result = DID_OK << 16 | lscsi_status; |
| 1605 | |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 1606 | if (lscsi_status == SAM_STAT_TASK_SET_FULL) { |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1607 | DEBUG2(qla_printk(KERN_INFO, ha, |
| 1608 | "scsi(%ld:%d:%d) QUEUE FULL detected.\n", |
| 1609 | vha->host_no, cp->device->id, cp->device->lun)); |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 1610 | break; |
| 1611 | } |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1612 | logit = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1613 | if (lscsi_status != SS_CHECK_CONDITION) |
| 1614 | break; |
| 1615 | |
FUJITA Tomonori | b80ca4f | 2008-01-13 15:46:13 +0900 | [diff] [blame] | 1616 | memset(cp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1617 | if (!(scsi_status & SS_SENSE_LEN_VALID)) |
| 1618 | break; |
| 1619 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1620 | qla2x00_handle_sense(sp, sense_data, sense_len, rsp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1621 | break; |
| 1622 | |
| 1623 | case CS_DATA_UNDERRUN: |
Ravi Anand | ed17c71b5 | 2006-05-17 15:08:55 -0700 | [diff] [blame] | 1624 | /* Use F/W calculated residual length. */ |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 1625 | resid = IS_FWI2_CAPABLE(ha) ? fw_resid_len : resid_len; |
| 1626 | scsi_set_resid(cp, resid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1627 | if (scsi_status & SS_RESIDUAL_UNDER) { |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 1628 | if (IS_FWI2_CAPABLE(ha) && fw_resid_len != resid_len) { |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1629 | DEBUG2(qla_printk(KERN_INFO, ha, |
| 1630 | "scsi(%ld:%d:%d) Dropped frame(s) detected " |
| 1631 | "(0x%x of 0x%x bytes).\n", vha->host_no, |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 1632 | cp->device->id, cp->device->lun, resid, |
| 1633 | scsi_bufflen(cp))); |
andrew.vasquez@qlogic.com | e038a1b | 2006-01-13 17:04:59 -0800 | [diff] [blame] | 1634 | |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 1635 | cp->result = DID_ERROR << 16 | lscsi_status; |
| 1636 | break; |
| 1637 | } |
| 1638 | |
| 1639 | if (!lscsi_status && |
| 1640 | ((unsigned)(scsi_bufflen(cp) - resid) < |
| 1641 | cp->underflow)) { |
| 1642 | qla_printk(KERN_INFO, ha, |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1643 | "scsi(%ld:%d:%d): Mid-layer underflow " |
| 1644 | "detected (0x%x of 0x%x bytes).\n", |
| 1645 | vha->host_no, cp->device->id, |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 1646 | cp->device->lun, resid, scsi_bufflen(cp)); |
| 1647 | |
| 1648 | cp->result = DID_ERROR << 16; |
| 1649 | break; |
| 1650 | } |
| 1651 | } else if (!lscsi_status) { |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1652 | DEBUG2(qla_printk(KERN_INFO, ha, |
| 1653 | "scsi(%ld:%d:%d) Dropped frame(s) detected (0x%x " |
| 1654 | "of 0x%x bytes).\n", vha->host_no, cp->device->id, |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 1655 | cp->device->lun, resid, scsi_bufflen(cp))); |
| 1656 | |
| 1657 | cp->result = DID_ERROR << 16; |
| 1658 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1659 | } |
| 1660 | |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 1661 | cp->result = DID_OK << 16 | lscsi_status; |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1662 | logit = 0; |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 1663 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1664 | /* |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1665 | * 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] | 1666 | * Status. |
| 1667 | */ |
| 1668 | if (lscsi_status != 0) { |
Andrew Vasquez | ffec28a | 2007-01-29 10:22:27 -0800 | [diff] [blame] | 1669 | if (lscsi_status == SAM_STAT_TASK_SET_FULL) { |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1670 | DEBUG2(qla_printk(KERN_INFO, ha, |
| 1671 | "scsi(%ld:%d:%d) QUEUE FULL detected.\n", |
| 1672 | vha->host_no, cp->device->id, |
| 1673 | cp->device->lun)); |
| 1674 | logit = 1; |
Andrew Vasquez | ffec28a | 2007-01-29 10:22:27 -0800 | [diff] [blame] | 1675 | break; |
| 1676 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1677 | if (lscsi_status != SS_CHECK_CONDITION) |
| 1678 | break; |
| 1679 | |
FUJITA Tomonori | b80ca4f | 2008-01-13 15:46:13 +0900 | [diff] [blame] | 1680 | memset(cp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1681 | if (!(scsi_status & SS_SENSE_LEN_VALID)) |
| 1682 | break; |
| 1683 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1684 | qla2x00_handle_sense(sp, sense_data, sense_len, rsp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1685 | } |
| 1686 | break; |
| 1687 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1688 | case CS_PORT_LOGGED_OUT: |
| 1689 | case CS_PORT_CONFIG_CHG: |
| 1690 | case CS_PORT_BUSY: |
| 1691 | case CS_INCOMPLETE: |
| 1692 | case CS_PORT_UNAVAILABLE: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1693 | case CS_TIMEOUT: |
Mike Christie | 056a448 | 2008-08-19 18:45:29 -0500 | [diff] [blame] | 1694 | /* |
| 1695 | * We are going to have the fc class block the rport |
| 1696 | * while we try to recover so instruct the mid layer |
| 1697 | * to requeue until the class decides how to handle this. |
| 1698 | */ |
| 1699 | cp->result = DID_TRANSPORT_DISRUPTED << 16; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1700 | |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1701 | if (comp_status == CS_TIMEOUT) { |
| 1702 | if (IS_FWI2_CAPABLE(ha)) |
| 1703 | break; |
| 1704 | else if ((le16_to_cpu(sts->status_flags) & |
| 1705 | SF_LOGOUT_SENT) == 0) |
| 1706 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1707 | } |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1708 | |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1709 | DEBUG2(qla_printk(KERN_INFO, ha, |
| 1710 | "scsi(%ld:%d:%d) Port down status: port-state=0x%x\n", |
| 1711 | vha->host_no, cp->device->id, cp->device->lun, |
| 1712 | atomic_read(&fcport->state))); |
| 1713 | |
| 1714 | if (atomic_read(&fcport->state) == FCS_ONLINE) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1715 | qla2x00_mark_device_lost(fcport->vha, fcport, 1, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1716 | break; |
| 1717 | |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1718 | case CS_RESET: |
| 1719 | case CS_ABORTED: |
| 1720 | cp->result = DID_RESET << 16; |
| 1721 | break; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1722 | |
| 1723 | case CS_DIF_ERROR: |
| 1724 | qla2x00_handle_dif_error(sp, sts24); |
| 1725 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1726 | default: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1727 | cp->result = DID_ERROR << 16; |
| 1728 | break; |
| 1729 | } |
| 1730 | |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1731 | out: |
| 1732 | if (logit) |
| 1733 | DEBUG2(qla_printk(KERN_INFO, ha, |
| 1734 | "scsi(%ld:%d:%d) FCP command status: 0x%x-0x%x (0x%x) " |
| 1735 | "oxid=0x%x ser=0x%lx cdb=%02x%02x%02x len=0x%x " |
| 1736 | "rsp_info=0x%x resid=0x%x fw_resid=0x%x\n", vha->host_no, |
| 1737 | cp->device->id, cp->device->lun, comp_status, scsi_status, |
| 1738 | cp->result, ox_id, cp->serial_number, cp->cmnd[0], |
| 1739 | cp->cmnd[1], cp->cmnd[2], scsi_bufflen(cp), rsp_info_len, |
| 1740 | resid_len, fw_resid_len)); |
| 1741 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1742 | if (rsp->status_srb == NULL) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1743 | qla2x00_sp_compl(ha, sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1744 | } |
| 1745 | |
| 1746 | /** |
| 1747 | * qla2x00_status_cont_entry() - Process a Status Continuations entry. |
| 1748 | * @ha: SCSI driver HA context |
| 1749 | * @pkt: Entry pointer |
| 1750 | * |
| 1751 | * Extended sense data. |
| 1752 | */ |
| 1753 | static void |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1754 | qla2x00_status_cont_entry(struct rsp_que *rsp, sts_cont_entry_t *pkt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1755 | { |
| 1756 | uint8_t sense_sz = 0; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1757 | struct qla_hw_data *ha = rsp->hw; |
| 1758 | srb_t *sp = rsp->status_srb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1759 | struct scsi_cmnd *cp; |
| 1760 | |
| 1761 | if (sp != NULL && sp->request_sense_length != 0) { |
| 1762 | cp = sp->cmd; |
| 1763 | if (cp == NULL) { |
| 1764 | DEBUG2(printk("%s(): Cmd already returned back to OS " |
Andrew Vasquez | 75bc419 | 2006-05-17 15:09:22 -0700 | [diff] [blame] | 1765 | "sp=%p.\n", __func__, sp)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1766 | qla_printk(KERN_INFO, ha, |
| 1767 | "cmd is NULL: already returned to OS (sp=%p)\n", |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1768 | sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1769 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1770 | rsp->status_srb = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1771 | return; |
| 1772 | } |
| 1773 | |
| 1774 | if (sp->request_sense_length > sizeof(pkt->data)) { |
| 1775 | sense_sz = sizeof(pkt->data); |
| 1776 | } else { |
| 1777 | sense_sz = sp->request_sense_length; |
| 1778 | } |
| 1779 | |
| 1780 | /* Move sense data. */ |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1781 | if (IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1782 | host_to_fcp_swap(pkt->data, sizeof(pkt->data)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1783 | memcpy(sp->request_sense_ptr, pkt->data, sense_sz); |
| 1784 | DEBUG5(qla2x00_dump_buffer(sp->request_sense_ptr, sense_sz)); |
| 1785 | |
| 1786 | sp->request_sense_ptr += sense_sz; |
| 1787 | sp->request_sense_length -= sense_sz; |
| 1788 | |
| 1789 | /* Place command on done queue. */ |
| 1790 | if (sp->request_sense_length == 0) { |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1791 | rsp->status_srb = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1792 | qla2x00_sp_compl(ha, sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1793 | } |
| 1794 | } |
| 1795 | } |
| 1796 | |
| 1797 | /** |
| 1798 | * qla2x00_error_entry() - Process an error entry. |
| 1799 | * @ha: SCSI driver HA context |
| 1800 | * @pkt: Entry pointer |
| 1801 | */ |
| 1802 | static void |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1803 | 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] | 1804 | { |
| 1805 | srb_t *sp; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1806 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1807 | uint32_t handle = LSW(pkt->handle); |
| 1808 | uint16_t que = MSW(pkt->handle); |
| 1809 | struct req_que *req = ha->req_q_map[que]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1810 | #if defined(QL_DEBUG_LEVEL_2) |
| 1811 | if (pkt->entry_status & RF_INV_E_ORDER) |
| 1812 | qla_printk(KERN_ERR, ha, "%s: Invalid Entry Order\n", __func__); |
| 1813 | else if (pkt->entry_status & RF_INV_E_COUNT) |
| 1814 | qla_printk(KERN_ERR, ha, "%s: Invalid Entry Count\n", __func__); |
| 1815 | else if (pkt->entry_status & RF_INV_E_PARAM) |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1816 | qla_printk(KERN_ERR, ha, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1817 | "%s: Invalid Entry Parameter\n", __func__); |
| 1818 | else if (pkt->entry_status & RF_INV_E_TYPE) |
| 1819 | qla_printk(KERN_ERR, ha, "%s: Invalid Entry Type\n", __func__); |
| 1820 | else if (pkt->entry_status & RF_BUSY) |
| 1821 | qla_printk(KERN_ERR, ha, "%s: Busy\n", __func__); |
| 1822 | else |
| 1823 | qla_printk(KERN_ERR, ha, "%s: UNKNOWN flag error\n", __func__); |
| 1824 | #endif |
| 1825 | |
| 1826 | /* Validate handle. */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1827 | if (handle < MAX_OUTSTANDING_COMMANDS) |
| 1828 | sp = req->outstanding_cmds[handle]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1829 | else |
| 1830 | sp = NULL; |
| 1831 | |
| 1832 | if (sp) { |
| 1833 | /* Free outstanding command slot. */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1834 | req->outstanding_cmds[handle] = NULL; |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 1835 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1836 | /* Bad payload or header */ |
| 1837 | if (pkt->entry_status & |
| 1838 | (RF_INV_E_ORDER | RF_INV_E_COUNT | |
| 1839 | RF_INV_E_PARAM | RF_INV_E_TYPE)) { |
| 1840 | sp->cmd->result = DID_ERROR << 16; |
| 1841 | } else if (pkt->entry_status & RF_BUSY) { |
| 1842 | sp->cmd->result = DID_BUS_BUSY << 16; |
| 1843 | } else { |
| 1844 | sp->cmd->result = DID_ERROR << 16; |
| 1845 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1846 | qla2x00_sp_compl(ha, sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1847 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1848 | } else if (pkt->entry_type == COMMAND_A64_TYPE || pkt->entry_type == |
| 1849 | COMMAND_TYPE || pkt->entry_type == COMMAND_TYPE_7) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1850 | DEBUG2(printk("scsi(%ld): Error entry - invalid handle\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1851 | vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1852 | qla_printk(KERN_WARNING, ha, |
| 1853 | "Error entry - invalid handle\n"); |
| 1854 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1855 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 1856 | qla2xxx_wake_dpc(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1857 | } |
| 1858 | } |
| 1859 | |
| 1860 | /** |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1861 | * qla24xx_mbx_completion() - Process mailbox command completions. |
| 1862 | * @ha: SCSI driver HA context |
| 1863 | * @mb0: Mailbox0 register |
| 1864 | */ |
| 1865 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1866 | qla24xx_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0) |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1867 | { |
| 1868 | uint16_t cnt; |
| 1869 | uint16_t __iomem *wptr; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1870 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1871 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1872 | |
| 1873 | /* Load return mailbox registers. */ |
| 1874 | ha->flags.mbox_int = 1; |
| 1875 | ha->mailbox_out[0] = mb0; |
| 1876 | wptr = (uint16_t __iomem *)®->mailbox1; |
| 1877 | |
| 1878 | for (cnt = 1; cnt < ha->mbx_count; cnt++) { |
| 1879 | ha->mailbox_out[cnt] = RD_REG_WORD(wptr); |
| 1880 | wptr++; |
| 1881 | } |
| 1882 | |
| 1883 | if (ha->mcp) { |
| 1884 | DEBUG3(printk("%s(%ld): Got mailbox completion. cmd=%x.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1885 | __func__, vha->host_no, ha->mcp->mb[0])); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1886 | } else { |
| 1887 | DEBUG2_3(printk("%s(%ld): MBX pointer ERROR!\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1888 | __func__, vha->host_no)); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1889 | } |
| 1890 | } |
| 1891 | |
| 1892 | /** |
| 1893 | * qla24xx_process_response_queue() - Process response queue entries. |
| 1894 | * @ha: SCSI driver HA context |
| 1895 | */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1896 | void qla24xx_process_response_queue(struct scsi_qla_host *vha, |
| 1897 | struct rsp_que *rsp) |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1898 | { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1899 | struct sts_entry_24xx *pkt; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1900 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1901 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1902 | if (!vha->flags.online) |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1903 | return; |
| 1904 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1905 | while (rsp->ring_ptr->signature != RESPONSE_PROCESSED) { |
| 1906 | pkt = (struct sts_entry_24xx *)rsp->ring_ptr; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1907 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1908 | rsp->ring_index++; |
| 1909 | if (rsp->ring_index == rsp->length) { |
| 1910 | rsp->ring_index = 0; |
| 1911 | rsp->ring_ptr = rsp->ring; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1912 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1913 | rsp->ring_ptr++; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1914 | } |
| 1915 | |
| 1916 | if (pkt->entry_status != 0) { |
| 1917 | DEBUG3(printk(KERN_INFO |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1918 | "scsi(%ld): Process error entry.\n", vha->host_no)); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1919 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1920 | qla2x00_error_entry(vha, rsp, (sts_entry_t *) pkt); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1921 | ((response_t *)pkt)->signature = RESPONSE_PROCESSED; |
| 1922 | wmb(); |
| 1923 | continue; |
| 1924 | } |
| 1925 | |
| 1926 | switch (pkt->entry_type) { |
| 1927 | case STATUS_TYPE: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1928 | qla2x00_status_entry(vha, rsp, pkt); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1929 | break; |
| 1930 | case STATUS_CONT_TYPE: |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1931 | qla2x00_status_cont_entry(rsp, (sts_cont_entry_t *)pkt); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1932 | break; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1933 | case VP_RPT_ID_IOCB_TYPE: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1934 | qla24xx_report_id_acquisition(vha, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1935 | (struct vp_rpt_id_entry_24xx *)pkt); |
| 1936 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1937 | case LOGINOUT_PORT_IOCB_TYPE: |
| 1938 | qla24xx_logio_entry(vha, rsp->req, |
| 1939 | (struct logio_entry_24xx *)pkt); |
| 1940 | break; |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 1941 | case TSK_MGMT_IOCB_TYPE: |
| 1942 | qla24xx_tm_iocb_entry(vha, rsp->req, |
| 1943 | (struct tsk_mgmt_entry *)pkt); |
| 1944 | break; |
| 1945 | case MARKER_TYPE: |
| 1946 | qla24xx_marker_iocb_entry(vha, rsp->req, |
| 1947 | (struct mrk_entry_24xx *)pkt); |
| 1948 | break; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1949 | case CT_IOCB_TYPE: |
| 1950 | qla24xx_els_ct_entry(vha, rsp->req, pkt, CT_IOCB_TYPE); |
| 1951 | clear_bit(MBX_INTERRUPT, &vha->hw->mbx_cmd_flags); |
| 1952 | break; |
| 1953 | case ELS_IOCB_TYPE: |
| 1954 | qla24xx_els_ct_entry(vha, rsp->req, pkt, ELS_IOCB_TYPE); |
| 1955 | break; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1956 | default: |
| 1957 | /* Type Not Supported. */ |
| 1958 | DEBUG4(printk(KERN_WARNING |
| 1959 | "scsi(%ld): Received unknown response pkt type %x " |
| 1960 | "entry status=%x.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1961 | vha->host_no, pkt->entry_type, pkt->entry_status)); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1962 | break; |
| 1963 | } |
| 1964 | ((response_t *)pkt)->signature = RESPONSE_PROCESSED; |
| 1965 | wmb(); |
| 1966 | } |
| 1967 | |
| 1968 | /* Adjust ring index */ |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1969 | if (IS_QLA82XX(ha)) { |
| 1970 | struct device_reg_82xx __iomem *reg = &ha->iobase->isp82; |
| 1971 | WRT_REG_DWORD(®->rsp_q_out[0], rsp->ring_index); |
| 1972 | } else |
| 1973 | WRT_REG_DWORD(rsp->rsp_q_out, rsp->ring_index); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1974 | } |
| 1975 | |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 1976 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1977 | qla2xxx_check_risc_status(scsi_qla_host_t *vha) |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 1978 | { |
| 1979 | int rval; |
| 1980 | uint32_t cnt; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1981 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 1982 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1983 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1984 | if (!IS_QLA25XX(ha) && !IS_QLA81XX(ha)) |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 1985 | return; |
| 1986 | |
| 1987 | rval = QLA_SUCCESS; |
| 1988 | WRT_REG_DWORD(®->iobase_addr, 0x7C00); |
| 1989 | RD_REG_DWORD(®->iobase_addr); |
| 1990 | WRT_REG_DWORD(®->iobase_window, 0x0001); |
| 1991 | for (cnt = 10000; (RD_REG_DWORD(®->iobase_window) & BIT_0) == 0 && |
| 1992 | rval == QLA_SUCCESS; cnt--) { |
| 1993 | if (cnt) { |
| 1994 | WRT_REG_DWORD(®->iobase_window, 0x0001); |
| 1995 | udelay(10); |
| 1996 | } else |
| 1997 | rval = QLA_FUNCTION_TIMEOUT; |
| 1998 | } |
| 1999 | if (rval == QLA_SUCCESS) |
| 2000 | goto next_test; |
| 2001 | |
| 2002 | WRT_REG_DWORD(®->iobase_window, 0x0003); |
| 2003 | for (cnt = 100; (RD_REG_DWORD(®->iobase_window) & BIT_0) == 0 && |
| 2004 | rval == QLA_SUCCESS; cnt--) { |
| 2005 | if (cnt) { |
| 2006 | WRT_REG_DWORD(®->iobase_window, 0x0003); |
| 2007 | udelay(10); |
| 2008 | } else |
| 2009 | rval = QLA_FUNCTION_TIMEOUT; |
| 2010 | } |
| 2011 | if (rval != QLA_SUCCESS) |
| 2012 | goto done; |
| 2013 | |
| 2014 | next_test: |
| 2015 | if (RD_REG_DWORD(®->iobase_c8) & BIT_3) |
| 2016 | qla_printk(KERN_INFO, ha, "Additional code -- 0x55AA.\n"); |
| 2017 | |
| 2018 | done: |
| 2019 | WRT_REG_DWORD(®->iobase_window, 0x0000); |
| 2020 | RD_REG_DWORD(®->iobase_window); |
| 2021 | } |
| 2022 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2023 | /** |
| 2024 | * qla24xx_intr_handler() - Process interrupts for the ISP23xx and ISP63xx. |
| 2025 | * @irq: |
| 2026 | * @dev_id: SCSI driver HA context |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2027 | * |
| 2028 | * Called by system whenever the host adapter generates an interrupt. |
| 2029 | * |
| 2030 | * Returns handled flag. |
| 2031 | */ |
| 2032 | irqreturn_t |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 2033 | qla24xx_intr_handler(int irq, void *dev_id) |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2034 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2035 | scsi_qla_host_t *vha; |
| 2036 | struct qla_hw_data *ha; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2037 | struct device_reg_24xx __iomem *reg; |
| 2038 | int status; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2039 | unsigned long iter; |
| 2040 | uint32_t stat; |
| 2041 | uint32_t hccr; |
| 2042 | uint16_t mb[4]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2043 | struct rsp_que *rsp; |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 2044 | unsigned long flags; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2045 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2046 | rsp = (struct rsp_que *) dev_id; |
| 2047 | if (!rsp) { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2048 | printk(KERN_INFO |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2049 | "%s(): NULL response queue pointer\n", __func__); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2050 | return IRQ_NONE; |
| 2051 | } |
| 2052 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2053 | ha = rsp->hw; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2054 | reg = &ha->iobase->isp24; |
| 2055 | status = 0; |
| 2056 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 2057 | if (unlikely(pci_channel_offline(ha->pdev))) |
| 2058 | return IRQ_HANDLED; |
| 2059 | |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 2060 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2061 | vha = pci_get_drvdata(ha->pdev); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2062 | for (iter = 50; iter--; ) { |
| 2063 | stat = RD_REG_DWORD(®->host_status); |
| 2064 | if (stat & HSRX_RISC_PAUSED) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 2065 | if (unlikely(pci_channel_offline(ha->pdev))) |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 2066 | break; |
| 2067 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2068 | hccr = RD_REG_DWORD(®->hccr); |
| 2069 | |
| 2070 | qla_printk(KERN_INFO, ha, "RISC paused -- HCCR=%x, " |
| 2071 | "Dumping firmware!\n", hccr); |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 2072 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2073 | qla2xxx_check_risc_status(vha); |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 2074 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2075 | ha->isp_ops->fw_dump(vha, 1); |
| 2076 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2077 | break; |
| 2078 | } else if ((stat & HSRX_RISC_INT) == 0) |
| 2079 | break; |
| 2080 | |
| 2081 | switch (stat & 0xff) { |
| 2082 | case 0x1: |
| 2083 | case 0x2: |
| 2084 | case 0x10: |
| 2085 | case 0x11: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2086 | qla24xx_mbx_completion(vha, MSW(stat)); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2087 | status |= MBX_INTERRUPT; |
| 2088 | |
| 2089 | break; |
| 2090 | case 0x12: |
| 2091 | mb[0] = MSW(stat); |
| 2092 | mb[1] = RD_REG_WORD(®->mailbox1); |
| 2093 | mb[2] = RD_REG_WORD(®->mailbox2); |
| 2094 | mb[3] = RD_REG_WORD(®->mailbox3); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2095 | qla2x00_async_event(vha, rsp, mb); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2096 | break; |
| 2097 | case 0x13: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2098 | case 0x14: |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2099 | qla24xx_process_response_queue(vha, rsp); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2100 | break; |
| 2101 | default: |
| 2102 | DEBUG2(printk("scsi(%ld): Unrecognized interrupt type " |
| 2103 | "(%d).\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2104 | vha->host_no, stat & 0xff)); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2105 | break; |
| 2106 | } |
| 2107 | WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_INT); |
| 2108 | RD_REG_DWORD_RELAXED(®->hccr); |
| 2109 | } |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 2110 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2111 | |
| 2112 | if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) && |
| 2113 | (status & MBX_INTERRUPT) && ha->flags.mbox_int) { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2114 | set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 2115 | complete(&ha->mbx_intr_comp); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2116 | } |
| 2117 | |
| 2118 | return IRQ_HANDLED; |
| 2119 | } |
| 2120 | |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2121 | static irqreturn_t |
| 2122 | qla24xx_msix_rsp_q(int irq, void *dev_id) |
| 2123 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2124 | struct qla_hw_data *ha; |
| 2125 | struct rsp_que *rsp; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2126 | struct device_reg_24xx __iomem *reg; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2127 | struct scsi_qla_host *vha; |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2128 | unsigned long flags; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2129 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2130 | rsp = (struct rsp_que *) dev_id; |
| 2131 | if (!rsp) { |
| 2132 | printk(KERN_INFO |
| 2133 | "%s(): NULL response queue pointer\n", __func__); |
| 2134 | return IRQ_NONE; |
| 2135 | } |
| 2136 | ha = rsp->hw; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2137 | reg = &ha->iobase->isp24; |
| 2138 | |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2139 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2140 | |
Anirban Chakraborty | a67093d | 2010-02-04 14:17:59 -0800 | [diff] [blame] | 2141 | vha = pci_get_drvdata(ha->pdev); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2142 | qla24xx_process_response_queue(vha, rsp); |
Anirban Chakraborty | 3155754 | 2009-12-02 10:36:55 -0800 | [diff] [blame] | 2143 | if (!ha->flags.disable_msix_handshake) { |
Anirban Chakraborty | eb94114 | 2009-08-04 16:12:13 -0700 | [diff] [blame] | 2144 | WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_INT); |
| 2145 | RD_REG_DWORD_RELAXED(®->hccr); |
| 2146 | } |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2147 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2148 | |
| 2149 | return IRQ_HANDLED; |
| 2150 | } |
| 2151 | |
| 2152 | static irqreturn_t |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2153 | qla25xx_msix_rsp_q(int irq, void *dev_id) |
| 2154 | { |
| 2155 | struct qla_hw_data *ha; |
| 2156 | struct rsp_que *rsp; |
Anirban Chakraborty | 3155754 | 2009-12-02 10:36:55 -0800 | [diff] [blame] | 2157 | struct device_reg_24xx __iomem *reg; |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2158 | unsigned long flags; |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2159 | |
| 2160 | rsp = (struct rsp_que *) dev_id; |
| 2161 | if (!rsp) { |
| 2162 | printk(KERN_INFO |
| 2163 | "%s(): NULL response queue pointer\n", __func__); |
| 2164 | return IRQ_NONE; |
| 2165 | } |
| 2166 | ha = rsp->hw; |
| 2167 | |
Anirban Chakraborty | 3155754 | 2009-12-02 10:36:55 -0800 | [diff] [blame] | 2168 | /* Clear the interrupt, if enabled, for this response queue */ |
| 2169 | if (rsp->options & ~BIT_6) { |
| 2170 | reg = &ha->iobase->isp24; |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2171 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 3155754 | 2009-12-02 10:36:55 -0800 | [diff] [blame] | 2172 | WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_INT); |
| 2173 | RD_REG_DWORD_RELAXED(®->hccr); |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2174 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Anirban Chakraborty | 3155754 | 2009-12-02 10:36:55 -0800 | [diff] [blame] | 2175 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2176 | queue_work_on((int) (rsp->id - 1), ha->wq, &rsp->q_work); |
| 2177 | |
| 2178 | return IRQ_HANDLED; |
| 2179 | } |
| 2180 | |
| 2181 | static irqreturn_t |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2182 | qla24xx_msix_default(int irq, void *dev_id) |
| 2183 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2184 | scsi_qla_host_t *vha; |
| 2185 | struct qla_hw_data *ha; |
| 2186 | struct rsp_que *rsp; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2187 | struct device_reg_24xx __iomem *reg; |
| 2188 | int status; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2189 | uint32_t stat; |
| 2190 | uint32_t hccr; |
| 2191 | uint16_t mb[4]; |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2192 | unsigned long flags; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2193 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2194 | rsp = (struct rsp_que *) dev_id; |
| 2195 | if (!rsp) { |
| 2196 | DEBUG(printk( |
| 2197 | "%s(): NULL response queue pointer\n", __func__)); |
| 2198 | return IRQ_NONE; |
| 2199 | } |
| 2200 | ha = rsp->hw; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2201 | reg = &ha->iobase->isp24; |
| 2202 | status = 0; |
| 2203 | |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2204 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2205 | vha = pci_get_drvdata(ha->pdev); |
Andrew Vasquez | 87f2701 | 2007-09-20 14:07:49 -0700 | [diff] [blame] | 2206 | do { |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2207 | stat = RD_REG_DWORD(®->host_status); |
| 2208 | if (stat & HSRX_RISC_PAUSED) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 2209 | if (unlikely(pci_channel_offline(ha->pdev))) |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 2210 | break; |
| 2211 | |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2212 | hccr = RD_REG_DWORD(®->hccr); |
| 2213 | |
| 2214 | qla_printk(KERN_INFO, ha, "RISC paused -- HCCR=%x, " |
| 2215 | "Dumping firmware!\n", hccr); |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 2216 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2217 | qla2xxx_check_risc_status(vha); |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 2218 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2219 | ha->isp_ops->fw_dump(vha, 1); |
| 2220 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2221 | break; |
| 2222 | } else if ((stat & HSRX_RISC_INT) == 0) |
| 2223 | break; |
| 2224 | |
| 2225 | switch (stat & 0xff) { |
| 2226 | case 0x1: |
| 2227 | case 0x2: |
| 2228 | case 0x10: |
| 2229 | case 0x11: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2230 | qla24xx_mbx_completion(vha, MSW(stat)); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2231 | status |= MBX_INTERRUPT; |
| 2232 | |
| 2233 | break; |
| 2234 | case 0x12: |
| 2235 | mb[0] = MSW(stat); |
| 2236 | mb[1] = RD_REG_WORD(®->mailbox1); |
| 2237 | mb[2] = RD_REG_WORD(®->mailbox2); |
| 2238 | mb[3] = RD_REG_WORD(®->mailbox3); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2239 | qla2x00_async_event(vha, rsp, mb); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2240 | break; |
| 2241 | case 0x13: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2242 | case 0x14: |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2243 | qla24xx_process_response_queue(vha, rsp); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2244 | break; |
| 2245 | default: |
| 2246 | DEBUG2(printk("scsi(%ld): Unrecognized interrupt type " |
| 2247 | "(%d).\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2248 | vha->host_no, stat & 0xff)); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2249 | break; |
| 2250 | } |
| 2251 | WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_INT); |
Andrew Vasquez | 87f2701 | 2007-09-20 14:07:49 -0700 | [diff] [blame] | 2252 | } while (0); |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2253 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2254 | |
| 2255 | if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) && |
| 2256 | (status & MBX_INTERRUPT) && ha->flags.mbox_int) { |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2257 | set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 2258 | complete(&ha->mbx_intr_comp); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2259 | } |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2260 | return IRQ_HANDLED; |
| 2261 | } |
| 2262 | |
| 2263 | /* Interrupt handling helpers. */ |
| 2264 | |
| 2265 | struct qla_init_msix_entry { |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2266 | const char *name; |
Jeff Garzik | 476834c2 | 2007-05-23 14:41:44 -0700 | [diff] [blame] | 2267 | irq_handler_t handler; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2268 | }; |
| 2269 | |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2270 | static struct qla_init_msix_entry msix_entries[3] = { |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2271 | { "qla2xxx (default)", qla24xx_msix_default }, |
| 2272 | { "qla2xxx (rsp_q)", qla24xx_msix_rsp_q }, |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2273 | { "qla2xxx (multiq)", qla25xx_msix_rsp_q }, |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2274 | }; |
| 2275 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2276 | static struct qla_init_msix_entry qla82xx_msix_entries[2] = { |
| 2277 | { "qla2xxx (default)", qla82xx_msix_default }, |
| 2278 | { "qla2xxx (rsp_q)", qla82xx_msix_rsp_q }, |
| 2279 | }; |
| 2280 | |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2281 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2282 | qla24xx_disable_msix(struct qla_hw_data *ha) |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2283 | { |
| 2284 | int i; |
| 2285 | struct qla_msix_entry *qentry; |
| 2286 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2287 | for (i = 0; i < ha->msix_count; i++) { |
| 2288 | qentry = &ha->msix_entries[i]; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2289 | if (qentry->have_irq) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2290 | free_irq(qentry->vector, qentry->rsp); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2291 | } |
| 2292 | pci_disable_msix(ha->pdev); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2293 | kfree(ha->msix_entries); |
| 2294 | ha->msix_entries = NULL; |
| 2295 | ha->flags.msix_enabled = 0; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2296 | } |
| 2297 | |
| 2298 | static int |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2299 | qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp) |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2300 | { |
Lalit Chandivade | ad038fa | 2009-01-22 09:45:33 -0800 | [diff] [blame] | 2301 | #define MIN_MSIX_COUNT 2 |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2302 | int i, ret; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2303 | struct msix_entry *entries; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2304 | struct qla_msix_entry *qentry; |
| 2305 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2306 | entries = kzalloc(sizeof(struct msix_entry) * ha->msix_count, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2307 | GFP_KERNEL); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2308 | if (!entries) |
| 2309 | return -ENOMEM; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2310 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2311 | for (i = 0; i < ha->msix_count; i++) |
| 2312 | entries[i].entry = i; |
| 2313 | |
| 2314 | ret = pci_enable_msix(ha->pdev, entries, ha->msix_count); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2315 | if (ret) { |
Lalit Chandivade | ad038fa | 2009-01-22 09:45:33 -0800 | [diff] [blame] | 2316 | if (ret < MIN_MSIX_COUNT) |
| 2317 | goto msix_failed; |
| 2318 | |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2319 | qla_printk(KERN_WARNING, ha, |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2320 | "MSI-X: Failed to enable support -- %d/%d\n" |
| 2321 | " Retry with %d vectors\n", ha->msix_count, ret, ret); |
| 2322 | ha->msix_count = ret; |
| 2323 | ret = pci_enable_msix(ha->pdev, entries, ha->msix_count); |
| 2324 | if (ret) { |
Lalit Chandivade | ad038fa | 2009-01-22 09:45:33 -0800 | [diff] [blame] | 2325 | msix_failed: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2326 | qla_printk(KERN_WARNING, ha, "MSI-X: Failed to enable" |
| 2327 | " support, giving up -- %d/%d\n", |
| 2328 | ha->msix_count, ret); |
| 2329 | goto msix_out; |
| 2330 | } |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2331 | ha->max_rsp_queues = ha->msix_count - 1; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2332 | } |
| 2333 | ha->msix_entries = kzalloc(sizeof(struct qla_msix_entry) * |
| 2334 | ha->msix_count, GFP_KERNEL); |
| 2335 | if (!ha->msix_entries) { |
| 2336 | ret = -ENOMEM; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2337 | goto msix_out; |
| 2338 | } |
| 2339 | ha->flags.msix_enabled = 1; |
| 2340 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2341 | for (i = 0; i < ha->msix_count; i++) { |
| 2342 | qentry = &ha->msix_entries[i]; |
| 2343 | qentry->vector = entries[i].vector; |
| 2344 | qentry->entry = entries[i].entry; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2345 | qentry->have_irq = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2346 | qentry->rsp = NULL; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2347 | } |
| 2348 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2349 | /* Enable MSI-X vectors for the base queue */ |
| 2350 | for (i = 0; i < 2; i++) { |
| 2351 | qentry = &ha->msix_entries[i]; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2352 | if (IS_QLA82XX(ha)) { |
| 2353 | ret = request_irq(qentry->vector, |
| 2354 | qla82xx_msix_entries[i].handler, |
| 2355 | 0, qla82xx_msix_entries[i].name, rsp); |
| 2356 | } else { |
| 2357 | ret = request_irq(qentry->vector, |
| 2358 | msix_entries[i].handler, |
| 2359 | 0, msix_entries[i].name, rsp); |
| 2360 | } |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2361 | if (ret) { |
| 2362 | qla_printk(KERN_WARNING, ha, |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2363 | "MSI-X: Unable to register handler -- %x/%d.\n", |
| 2364 | qentry->vector, ret); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2365 | qla24xx_disable_msix(ha); |
| 2366 | ha->mqenable = 0; |
| 2367 | goto msix_out; |
| 2368 | } |
| 2369 | qentry->have_irq = 1; |
| 2370 | qentry->rsp = rsp; |
| 2371 | rsp->msix = qentry; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2372 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2373 | |
| 2374 | /* Enable MSI-X vector for response queue update for queue 0 */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2375 | if (ha->mqiobase && (ha->max_rsp_queues > 1 || ha->max_req_queues > 1)) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2376 | ha->mqenable = 1; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2377 | |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2378 | msix_out: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2379 | kfree(entries); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2380 | return ret; |
| 2381 | } |
| 2382 | |
| 2383 | int |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2384 | qla2x00_request_irqs(struct qla_hw_data *ha, struct rsp_que *rsp) |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2385 | { |
| 2386 | int ret; |
Andrew Vasquez | 963b0fd | 2008-01-31 12:33:50 -0800 | [diff] [blame] | 2387 | device_reg_t __iomem *reg = ha->iobase; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2388 | |
| 2389 | /* If possible, enable MSI-X. */ |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2390 | if (!IS_QLA2432(ha) && !IS_QLA2532(ha) && |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2391 | !IS_QLA8432(ha) && !IS_QLA8XXX_TYPE(ha)) |
Ben Hutchings | 6377a7a | 2010-03-19 16:59:19 -0700 | [diff] [blame] | 2392 | goto skip_msi; |
| 2393 | |
| 2394 | if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_HP && |
| 2395 | (ha->pdev->subsystem_device == 0x7040 || |
| 2396 | ha->pdev->subsystem_device == 0x7041 || |
| 2397 | ha->pdev->subsystem_device == 0x1705)) { |
| 2398 | DEBUG2(qla_printk(KERN_WARNING, ha, |
| 2399 | "MSI-X: Unsupported ISP2432 SSVID/SSDID (0x%X,0x%X).\n", |
| 2400 | ha->pdev->subsystem_vendor, |
| 2401 | ha->pdev->subsystem_device)); |
| 2402 | goto skip_msi; |
| 2403 | } |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2404 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2405 | if (IS_QLA2432(ha) && (ha->pdev->revision < QLA_MSIX_CHIP_REV_24XX || |
| 2406 | !QLA_MSIX_FW_MODE_1(ha->fw_attributes))) { |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2407 | DEBUG2(qla_printk(KERN_WARNING, ha, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2408 | "MSI-X: Unsupported ISP2432 (0x%X, 0x%X).\n", |
| 2409 | ha->pdev->revision, ha->fw_attributes)); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2410 | goto skip_msix; |
| 2411 | } |
| 2412 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2413 | ret = qla24xx_enable_msix(ha, rsp); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2414 | if (!ret) { |
| 2415 | DEBUG2(qla_printk(KERN_INFO, ha, |
| 2416 | "MSI-X: Enabled (0x%X, 0x%X).\n", ha->chip_revision, |
| 2417 | ha->fw_attributes)); |
Andrew Vasquez | 963b0fd | 2008-01-31 12:33:50 -0800 | [diff] [blame] | 2418 | goto clear_risc_ints; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2419 | } |
| 2420 | qla_printk(KERN_WARNING, ha, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2421 | "MSI-X: Falling back-to MSI mode -- %d.\n", ret); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2422 | skip_msix: |
Andrew Vasquez | cbedb60 | 2007-05-07 07:43:02 -0700 | [diff] [blame] | 2423 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2424 | if (!IS_QLA24XX(ha) && !IS_QLA2532(ha) && !IS_QLA8432(ha) && |
| 2425 | !IS_QLA8001(ha)) |
Andrew Vasquez | cbedb60 | 2007-05-07 07:43:02 -0700 | [diff] [blame] | 2426 | goto skip_msi; |
| 2427 | |
| 2428 | ret = pci_enable_msi(ha->pdev); |
| 2429 | if (!ret) { |
| 2430 | DEBUG2(qla_printk(KERN_INFO, ha, "MSI: Enabled.\n")); |
| 2431 | ha->flags.msi_enabled = 1; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2432 | } else |
| 2433 | qla_printk(KERN_WARNING, ha, |
| 2434 | "MSI-X: Falling back-to INTa mode -- %d.\n", ret); |
Andrew Vasquez | cbedb60 | 2007-05-07 07:43:02 -0700 | [diff] [blame] | 2435 | skip_msi: |
| 2436 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2437 | ret = request_irq(ha->pdev->irq, ha->isp_ops->intr_handler, |
Giridhar Malavali | d1b1bef | 2009-03-24 09:08:13 -0700 | [diff] [blame] | 2438 | IRQF_SHARED, QLA2XXX_DRIVER_NAME, rsp); |
Andrew Vasquez | 963b0fd | 2008-01-31 12:33:50 -0800 | [diff] [blame] | 2439 | if (ret) { |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2440 | qla_printk(KERN_WARNING, ha, |
| 2441 | "Failed to reserve interrupt %d already in use.\n", |
| 2442 | ha->pdev->irq); |
Andrew Vasquez | 963b0fd | 2008-01-31 12:33:50 -0800 | [diff] [blame] | 2443 | goto fail; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2444 | } |
Andrew Vasquez | 963b0fd | 2008-01-31 12:33:50 -0800 | [diff] [blame] | 2445 | ha->flags.inta_enabled = 1; |
Andrew Vasquez | 963b0fd | 2008-01-31 12:33:50 -0800 | [diff] [blame] | 2446 | clear_risc_ints: |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2447 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2448 | /* |
| 2449 | * FIXME: Noted that 8014s were being dropped during NK testing. |
| 2450 | * Timing deltas during MSI-X/INTa transitions? |
| 2451 | */ |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2452 | if (IS_QLA81XX(ha) || IS_QLA82XX(ha)) |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2453 | goto fail; |
Andrew Vasquez | c695248 | 2008-04-03 13:13:17 -0700 | [diff] [blame] | 2454 | spin_lock_irq(&ha->hardware_lock); |
Andrew Vasquez | 963b0fd | 2008-01-31 12:33:50 -0800 | [diff] [blame] | 2455 | if (IS_FWI2_CAPABLE(ha)) { |
| 2456 | WRT_REG_DWORD(®->isp24.hccr, HCCRX_CLR_HOST_INT); |
| 2457 | WRT_REG_DWORD(®->isp24.hccr, HCCRX_CLR_RISC_INT); |
| 2458 | } else { |
| 2459 | WRT_REG_WORD(®->isp.semaphore, 0); |
| 2460 | WRT_REG_WORD(®->isp.hccr, HCCR_CLR_RISC_INT); |
| 2461 | WRT_REG_WORD(®->isp.hccr, HCCR_CLR_HOST_INT); |
| 2462 | } |
Andrew Vasquez | c695248 | 2008-04-03 13:13:17 -0700 | [diff] [blame] | 2463 | spin_unlock_irq(&ha->hardware_lock); |
Andrew Vasquez | 963b0fd | 2008-01-31 12:33:50 -0800 | [diff] [blame] | 2464 | |
| 2465 | fail: |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2466 | return ret; |
| 2467 | } |
| 2468 | |
| 2469 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2470 | qla2x00_free_irqs(scsi_qla_host_t *vha) |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2471 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2472 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2473 | struct rsp_que *rsp = ha->rsp_q_map[0]; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2474 | |
| 2475 | if (ha->flags.msix_enabled) |
| 2476 | qla24xx_disable_msix(ha); |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 2477 | else if (ha->flags.msi_enabled) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2478 | free_irq(ha->pdev->irq, rsp); |
Andrew Vasquez | cbedb60 | 2007-05-07 07:43:02 -0700 | [diff] [blame] | 2479 | pci_disable_msi(ha->pdev); |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 2480 | } else |
| 2481 | free_irq(ha->pdev->irq, rsp); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2482 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2483 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2484 | |
| 2485 | int qla25xx_request_irq(struct rsp_que *rsp) |
| 2486 | { |
| 2487 | struct qla_hw_data *ha = rsp->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2488 | struct qla_init_msix_entry *intr = &msix_entries[2]; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2489 | struct qla_msix_entry *msix = rsp->msix; |
| 2490 | int ret; |
| 2491 | |
| 2492 | ret = request_irq(msix->vector, intr->handler, 0, intr->name, rsp); |
| 2493 | if (ret) { |
| 2494 | qla_printk(KERN_WARNING, ha, |
| 2495 | "MSI-X: Unable to register handler -- %x/%d.\n", |
| 2496 | msix->vector, ret); |
| 2497 | return ret; |
| 2498 | } |
| 2499 | msix->have_irq = 1; |
| 2500 | msix->rsp = rsp; |
| 2501 | return ret; |
| 2502 | } |