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