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 |
Chad Dupuis | 46152ce | 2012-08-22 14:21:08 -0400 | [diff] [blame] | 3 | * Copyright (c) 2003-2012 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" |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 8 | #include "qla_target.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 10 | #include <linux/delay.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 11 | #include <linux/slab.h> |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 12 | #include <scsi/scsi_tcq.h> |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 13 | #include <scsi/scsi_bsg_fc.h> |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 14 | #include <scsi/scsi_eh.h> |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 15 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | static void qla2x00_mbx_completion(scsi_qla_host_t *, uint16_t); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 17 | static void qla2x00_process_completed_request(struct scsi_qla_host *, |
| 18 | struct req_que *, uint32_t); |
| 19 | 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] | 20 | 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] | 21 | static void qla2x00_error_entry(scsi_qla_host_t *, struct rsp_que *, |
| 22 | sts_entry_t *); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 23 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | /** |
| 25 | * qla2100_intr_handler() - Process interrupts for the ISP2100 and ISP2200. |
| 26 | * @irq: |
| 27 | * @dev_id: SCSI driver HA context |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | * |
| 29 | * Called by system whenever the host adapter generates an interrupt. |
| 30 | * |
| 31 | * Returns handled flag. |
| 32 | */ |
| 33 | irqreturn_t |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 34 | qla2100_intr_handler(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 36 | scsi_qla_host_t *vha; |
| 37 | struct qla_hw_data *ha; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 38 | struct device_reg_2xxx __iomem *reg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | unsigned long iter; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 41 | uint16_t hccr; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 42 | uint16_t mb[4]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 43 | struct rsp_que *rsp; |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 44 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 46 | rsp = (struct rsp_que *) dev_id; |
| 47 | if (!rsp) { |
Chad Dupuis | 3256b43 | 2012-02-09 11:15:47 -0800 | [diff] [blame] | 48 | ql_log(ql_log_info, NULL, 0x505d, |
| 49 | "%s: NULL response queue pointer.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | return (IRQ_NONE); |
| 51 | } |
| 52 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 53 | ha = rsp->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 54 | reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | status = 0; |
| 56 | |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 57 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 58 | vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | for (iter = 50; iter--; ) { |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 60 | hccr = RD_REG_WORD(®->hccr); |
| 61 | if (hccr & HCCR_RISC_PAUSE) { |
| 62 | if (pci_channel_offline(ha->pdev)) |
| 63 | break; |
| 64 | |
| 65 | /* |
| 66 | * Issue a "HARD" reset in order for the RISC interrupt |
Justin P. Mattock | a06a0f8 | 2011-06-23 23:22:27 -0700 | [diff] [blame] | 67 | * bit to be cleared. Schedule a big hammer to get |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 68 | * out of the RISC PAUSED state. |
| 69 | */ |
| 70 | WRT_REG_WORD(®->hccr, HCCR_RESET_RISC); |
| 71 | RD_REG_WORD(®->hccr); |
| 72 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 73 | ha->isp_ops->fw_dump(vha, 1); |
| 74 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 75 | break; |
| 76 | } else if ((RD_REG_WORD(®->istatus) & ISR_RISC_INT) == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | break; |
| 78 | |
| 79 | if (RD_REG_WORD(®->semaphore) & BIT_0) { |
| 80 | WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT); |
| 81 | RD_REG_WORD(®->hccr); |
| 82 | |
| 83 | /* Get mailbox data. */ |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 84 | mb[0] = RD_MAILBOX_REG(ha, reg, 0); |
| 85 | if (mb[0] > 0x3fff && mb[0] < 0x8000) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 86 | qla2x00_mbx_completion(vha, mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | status |= MBX_INTERRUPT; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 88 | } else if (mb[0] > 0x7fff && mb[0] < 0xc000) { |
| 89 | mb[1] = RD_MAILBOX_REG(ha, reg, 1); |
| 90 | mb[2] = RD_MAILBOX_REG(ha, reg, 2); |
| 91 | mb[3] = RD_MAILBOX_REG(ha, reg, 3); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 92 | qla2x00_async_event(vha, rsp, mb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | } else { |
| 94 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 95 | ql_dbg(ql_dbg_async, vha, 0x5025, |
| 96 | "Unrecognized interrupt type (%d).\n", |
| 97 | mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | } |
| 99 | /* Release mailbox registers. */ |
| 100 | WRT_REG_WORD(®->semaphore, 0); |
| 101 | RD_REG_WORD(®->semaphore); |
| 102 | } else { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 103 | qla2x00_process_response_queue(rsp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | |
| 105 | WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT); |
| 106 | RD_REG_WORD(®->hccr); |
| 107 | } |
| 108 | } |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 109 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) && |
| 112 | (status & MBX_INTERRUPT) && ha->flags.mbox_int) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 114 | complete(&ha->mbx_intr_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | } |
| 116 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | return (IRQ_HANDLED); |
| 118 | } |
| 119 | |
| 120 | /** |
| 121 | * qla2300_intr_handler() - Process interrupts for the ISP23xx and ISP63xx. |
| 122 | * @irq: |
| 123 | * @dev_id: SCSI driver HA context |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | * |
| 125 | * Called by system whenever the host adapter generates an interrupt. |
| 126 | * |
| 127 | * Returns handled flag. |
| 128 | */ |
| 129 | irqreturn_t |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 130 | qla2300_intr_handler(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 132 | scsi_qla_host_t *vha; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 133 | struct device_reg_2xxx __iomem *reg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | unsigned long iter; |
| 136 | uint32_t stat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | uint16_t hccr; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 138 | uint16_t mb[4]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 139 | struct rsp_que *rsp; |
| 140 | struct qla_hw_data *ha; |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 141 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 143 | rsp = (struct rsp_que *) dev_id; |
| 144 | if (!rsp) { |
Chad Dupuis | 3256b43 | 2012-02-09 11:15:47 -0800 | [diff] [blame] | 145 | ql_log(ql_log_info, NULL, 0x5058, |
| 146 | "%s: NULL response queue pointer.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | return (IRQ_NONE); |
| 148 | } |
| 149 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 150 | ha = rsp->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 151 | reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | status = 0; |
| 153 | |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 154 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 155 | vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | for (iter = 50; iter--; ) { |
| 157 | stat = RD_REG_DWORD(®->u.isp2300.host_status); |
| 158 | if (stat & HSR_RISC_PAUSED) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 159 | if (unlikely(pci_channel_offline(ha->pdev))) |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 160 | break; |
| 161 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | hccr = RD_REG_WORD(®->hccr); |
| 163 | if (hccr & (BIT_15 | BIT_13 | BIT_11 | BIT_8)) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 164 | ql_log(ql_log_warn, vha, 0x5026, |
| 165 | "Parity error -- HCCR=%x, Dumping " |
| 166 | "firmware.\n", hccr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | else |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 168 | ql_log(ql_log_warn, vha, 0x5027, |
| 169 | "RISC paused -- HCCR=%x, Dumping " |
| 170 | "firmware.\n", hccr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | |
| 172 | /* |
| 173 | * Issue a "HARD" reset in order for the RISC |
| 174 | * interrupt bit to be cleared. Schedule a big |
Justin P. Mattock | a06a0f8 | 2011-06-23 23:22:27 -0700 | [diff] [blame] | 175 | * hammer to get out of the RISC PAUSED state. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | */ |
| 177 | WRT_REG_WORD(®->hccr, HCCR_RESET_RISC); |
| 178 | RD_REG_WORD(®->hccr); |
Andrew Vasquez | 07f3180 | 2006-12-13 19:20:31 -0800 | [diff] [blame] | 179 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 180 | ha->isp_ops->fw_dump(vha, 1); |
| 181 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | break; |
| 183 | } else if ((stat & HSR_RISC_INT) == 0) |
| 184 | break; |
| 185 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | switch (stat & 0xff) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | case 0x1: |
| 188 | case 0x2: |
| 189 | case 0x10: |
| 190 | case 0x11: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 191 | qla2x00_mbx_completion(vha, MSW(stat)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | status |= MBX_INTERRUPT; |
| 193 | |
| 194 | /* Release mailbox registers. */ |
| 195 | WRT_REG_WORD(®->semaphore, 0); |
| 196 | break; |
| 197 | case 0x12: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 198 | mb[0] = MSW(stat); |
| 199 | mb[1] = RD_MAILBOX_REG(ha, reg, 1); |
| 200 | mb[2] = RD_MAILBOX_REG(ha, reg, 2); |
| 201 | mb[3] = RD_MAILBOX_REG(ha, reg, 3); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 202 | qla2x00_async_event(vha, rsp, mb); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 203 | break; |
| 204 | case 0x13: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 205 | qla2x00_process_response_queue(rsp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | break; |
| 207 | case 0x15: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 208 | mb[0] = MBA_CMPLT_1_16BIT; |
| 209 | mb[1] = MSW(stat); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 210 | qla2x00_async_event(vha, rsp, mb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | break; |
| 212 | case 0x16: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 213 | mb[0] = MBA_SCSI_COMPLETION; |
| 214 | mb[1] = MSW(stat); |
| 215 | mb[2] = RD_MAILBOX_REG(ha, reg, 2); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 216 | qla2x00_async_event(vha, rsp, mb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | break; |
| 218 | default: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 219 | ql_dbg(ql_dbg_async, vha, 0x5028, |
| 220 | "Unrecognized interrupt type (%d).\n", stat & 0xff); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | break; |
| 222 | } |
| 223 | WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT); |
| 224 | RD_REG_WORD_RELAXED(®->hccr); |
| 225 | } |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 226 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) && |
| 229 | (status & MBX_INTERRUPT) && ha->flags.mbox_int) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 231 | complete(&ha->mbx_intr_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | } |
| 233 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | return (IRQ_HANDLED); |
| 235 | } |
| 236 | |
| 237 | /** |
| 238 | * qla2x00_mbx_completion() - Process mailbox command completions. |
| 239 | * @ha: SCSI driver HA context |
| 240 | * @mb0: Mailbox0 register |
| 241 | */ |
| 242 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 243 | qla2x00_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | { |
| 245 | uint16_t cnt; |
Andrew Vasquez | 4fa94f8 | 2011-11-18 09:03:09 -0800 | [diff] [blame] | 246 | uint32_t mboxes; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | uint16_t __iomem *wptr; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 248 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 249 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | |
Andrew Vasquez | 4fa94f8 | 2011-11-18 09:03:09 -0800 | [diff] [blame] | 251 | /* Read all mbox registers? */ |
| 252 | mboxes = (1 << ha->mbx_count) - 1; |
| 253 | if (!ha->mcp) |
Masanari Iida | a720101 | 2012-11-21 02:40:42 -0500 | [diff] [blame] | 254 | ql_dbg(ql_dbg_async, vha, 0x5001, "MBX pointer ERROR.\n"); |
Andrew Vasquez | 4fa94f8 | 2011-11-18 09:03:09 -0800 | [diff] [blame] | 255 | else |
| 256 | mboxes = ha->mcp->in_mb; |
| 257 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | /* Load return mailbox registers. */ |
| 259 | ha->flags.mbox_int = 1; |
| 260 | ha->mailbox_out[0] = mb0; |
Andrew Vasquez | 4fa94f8 | 2011-11-18 09:03:09 -0800 | [diff] [blame] | 261 | mboxes >>= 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | wptr = (uint16_t __iomem *)MAILBOX_REG(ha, reg, 1); |
| 263 | |
| 264 | for (cnt = 1; cnt < ha->mbx_count; cnt++) { |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 265 | if (IS_QLA2200(ha) && cnt == 8) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | wptr = (uint16_t __iomem *)MAILBOX_REG(ha, reg, 8); |
Andrew Vasquez | 4fa94f8 | 2011-11-18 09:03:09 -0800 | [diff] [blame] | 267 | if ((cnt == 4 || cnt == 5) && (mboxes & BIT_0)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | ha->mailbox_out[cnt] = qla2x00_debounce_register(wptr); |
Andrew Vasquez | 4fa94f8 | 2011-11-18 09:03:09 -0800 | [diff] [blame] | 269 | else if (mboxes & BIT_0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | ha->mailbox_out[cnt] = RD_REG_WORD(wptr); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 271 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | wptr++; |
Andrew Vasquez | 4fa94f8 | 2011-11-18 09:03:09 -0800 | [diff] [blame] | 273 | mboxes >>= 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | } |
| 276 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 277 | static void |
| 278 | qla81xx_idc_event(scsi_qla_host_t *vha, uint16_t aen, uint16_t descr) |
| 279 | { |
| 280 | static char *event[] = |
| 281 | { "Complete", "Request Notification", "Time Extension" }; |
| 282 | int rval; |
| 283 | struct device_reg_24xx __iomem *reg24 = &vha->hw->iobase->isp24; |
| 284 | uint16_t __iomem *wptr; |
| 285 | uint16_t cnt, timeout, mb[QLA_IDC_ACK_REGS]; |
| 286 | |
| 287 | /* Seed data -- mailbox1 -> mailbox7. */ |
| 288 | wptr = (uint16_t __iomem *)®24->mailbox1; |
| 289 | for (cnt = 0; cnt < QLA_IDC_ACK_REGS; cnt++, wptr++) |
| 290 | mb[cnt] = RD_REG_WORD(wptr); |
| 291 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 292 | ql_dbg(ql_dbg_async, vha, 0x5021, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 293 | "Inter-Driver Communication %s -- " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 294 | "%04x %04x %04x %04x %04x %04x %04x.\n", |
| 295 | event[aen & 0xff], mb[0], mb[1], mb[2], mb[3], |
| 296 | mb[4], mb[5], mb[6]); |
Chad Dupuis | bf5b8ad | 2012-08-22 14:21:24 -0400 | [diff] [blame] | 297 | if ((aen == MBA_IDC_COMPLETE && mb[1] >> 15)) { |
| 298 | vha->hw->flags.idc_compl_status = 1; |
| 299 | if (vha->hw->notify_dcbx_comp) |
| 300 | complete(&vha->hw->dcbx_comp); |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 301 | } |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 302 | |
Chad Dupuis | bf5b8ad | 2012-08-22 14:21:24 -0400 | [diff] [blame] | 303 | /* Acknowledgement needed? [Notify && non-zero timeout]. */ |
| 304 | timeout = (descr >> 8) & 0xf; |
| 305 | if (aen != MBA_IDC_NOTIFY || !timeout) |
| 306 | return; |
| 307 | |
| 308 | ql_dbg(ql_dbg_async, vha, 0x5022, |
| 309 | "%lu Inter-Driver Communication %s -- ACK timeout=%d.\n", |
| 310 | vha->host_no, event[aen & 0xff], timeout); |
| 311 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 312 | rval = qla2x00_post_idc_ack_work(vha, mb); |
| 313 | if (rval != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 314 | ql_log(ql_log_warn, vha, 0x5023, |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 315 | "IDC failed to post ACK.\n"); |
| 316 | } |
| 317 | |
Chad Dupuis | daae62a | 2012-05-15 14:34:23 -0400 | [diff] [blame] | 318 | #define LS_UNKNOWN 2 |
Joe Carnuccio | d0297c9 | 2012-11-21 02:40:40 -0500 | [diff] [blame] | 319 | const char * |
| 320 | qla2x00_get_link_speed_str(struct qla_hw_data *ha, uint16_t speed) |
Chad Dupuis | daae62a | 2012-05-15 14:34:23 -0400 | [diff] [blame] | 321 | { |
Joe Carnuccio | d0297c9 | 2012-11-21 02:40:40 -0500 | [diff] [blame] | 322 | static const char * const link_speeds[] = { |
| 323 | "1", "2", "?", "4", "8", "16", "10" |
| 324 | }; |
Chad Dupuis | daae62a | 2012-05-15 14:34:23 -0400 | [diff] [blame] | 325 | |
| 326 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) |
Joe Carnuccio | d0297c9 | 2012-11-21 02:40:40 -0500 | [diff] [blame] | 327 | return link_speeds[0]; |
| 328 | else if (speed == 0x13) |
| 329 | return link_speeds[6]; |
| 330 | else if (speed < 6) |
| 331 | return link_speeds[speed]; |
| 332 | else |
| 333 | return link_speeds[LS_UNKNOWN]; |
Chad Dupuis | daae62a | 2012-05-15 14:34:23 -0400 | [diff] [blame] | 334 | } |
| 335 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 336 | static void |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 337 | qla83xx_handle_8200_aen(scsi_qla_host_t *vha, uint16_t *mb) |
| 338 | { |
| 339 | struct qla_hw_data *ha = vha->hw; |
| 340 | |
| 341 | /* |
| 342 | * 8200 AEN Interpretation: |
| 343 | * mb[0] = AEN code |
| 344 | * mb[1] = AEN Reason code |
| 345 | * mb[2] = LSW of Peg-Halt Status-1 Register |
| 346 | * mb[6] = MSW of Peg-Halt Status-1 Register |
| 347 | * mb[3] = LSW of Peg-Halt Status-2 register |
| 348 | * mb[7] = MSW of Peg-Halt Status-2 register |
| 349 | * mb[4] = IDC Device-State Register value |
| 350 | * mb[5] = IDC Driver-Presence Register value |
| 351 | */ |
| 352 | ql_dbg(ql_dbg_async, vha, 0x506b, "AEN Code: mb[0] = 0x%x AEN reason: " |
| 353 | "mb[1] = 0x%x PH-status1: mb[2] = 0x%x PH-status1: mb[6] = 0x%x.\n", |
| 354 | mb[0], mb[1], mb[2], mb[6]); |
| 355 | ql_dbg(ql_dbg_async, vha, 0x506c, "PH-status2: mb[3] = 0x%x " |
| 356 | "PH-status2: mb[7] = 0x%x Device-State: mb[4] = 0x%x " |
| 357 | "Drv-Presence: mb[5] = 0x%x.\n", mb[3], mb[7], mb[4], mb[5]); |
| 358 | |
| 359 | if (mb[1] & (IDC_PEG_HALT_STATUS_CHANGE | IDC_NIC_FW_REPORTED_FAILURE | |
| 360 | IDC_HEARTBEAT_FAILURE)) { |
| 361 | ha->flags.nic_core_hung = 1; |
| 362 | ql_log(ql_log_warn, vha, 0x5060, |
| 363 | "83XX: F/W Error Reported: Check if reset required.\n"); |
| 364 | |
| 365 | if (mb[1] & IDC_PEG_HALT_STATUS_CHANGE) { |
| 366 | uint32_t protocol_engine_id, fw_err_code, err_level; |
| 367 | |
| 368 | /* |
| 369 | * IDC_PEG_HALT_STATUS_CHANGE interpretation: |
| 370 | * - PEG-Halt Status-1 Register: |
| 371 | * (LSW = mb[2], MSW = mb[6]) |
| 372 | * Bits 0-7 = protocol-engine ID |
| 373 | * Bits 8-28 = f/w error code |
| 374 | * Bits 29-31 = Error-level |
| 375 | * Error-level 0x1 = Non-Fatal error |
| 376 | * Error-level 0x2 = Recoverable Fatal error |
| 377 | * Error-level 0x4 = UnRecoverable Fatal error |
| 378 | * - PEG-Halt Status-2 Register: |
| 379 | * (LSW = mb[3], MSW = mb[7]) |
| 380 | */ |
| 381 | protocol_engine_id = (mb[2] & 0xff); |
| 382 | fw_err_code = (((mb[2] & 0xff00) >> 8) | |
| 383 | ((mb[6] & 0x1fff) << 8)); |
| 384 | err_level = ((mb[6] & 0xe000) >> 13); |
| 385 | ql_log(ql_log_warn, vha, 0x5061, "PegHalt Status-1 " |
| 386 | "Register: protocol_engine_id=0x%x " |
| 387 | "fw_err_code=0x%x err_level=0x%x.\n", |
| 388 | protocol_engine_id, fw_err_code, err_level); |
| 389 | ql_log(ql_log_warn, vha, 0x5062, "PegHalt Status-2 " |
| 390 | "Register: 0x%x%x.\n", mb[7], mb[3]); |
| 391 | if (err_level == ERR_LEVEL_NON_FATAL) { |
| 392 | ql_log(ql_log_warn, vha, 0x5063, |
| 393 | "Not a fatal error, f/w has recovered " |
| 394 | "iteself.\n"); |
| 395 | } else if (err_level == ERR_LEVEL_RECOVERABLE_FATAL) { |
| 396 | ql_log(ql_log_fatal, vha, 0x5064, |
| 397 | "Recoverable Fatal error: Chip reset " |
| 398 | "required.\n"); |
| 399 | qla83xx_schedule_work(vha, |
| 400 | QLA83XX_NIC_CORE_RESET); |
| 401 | } else if (err_level == ERR_LEVEL_UNRECOVERABLE_FATAL) { |
| 402 | ql_log(ql_log_fatal, vha, 0x5065, |
| 403 | "Unrecoverable Fatal error: Set FAILED " |
| 404 | "state, reboot required.\n"); |
| 405 | qla83xx_schedule_work(vha, |
| 406 | QLA83XX_NIC_CORE_UNRECOVERABLE); |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | if (mb[1] & IDC_NIC_FW_REPORTED_FAILURE) { |
| 411 | uint16_t peg_fw_state, nw_interface_link_up; |
| 412 | uint16_t nw_interface_signal_detect, sfp_status; |
| 413 | uint16_t htbt_counter, htbt_monitor_enable; |
| 414 | uint16_t sfp_additonal_info, sfp_multirate; |
| 415 | uint16_t sfp_tx_fault, link_speed, dcbx_status; |
| 416 | |
| 417 | /* |
| 418 | * IDC_NIC_FW_REPORTED_FAILURE interpretation: |
| 419 | * - PEG-to-FC Status Register: |
| 420 | * (LSW = mb[2], MSW = mb[6]) |
| 421 | * Bits 0-7 = Peg-Firmware state |
| 422 | * Bit 8 = N/W Interface Link-up |
| 423 | * Bit 9 = N/W Interface signal detected |
| 424 | * Bits 10-11 = SFP Status |
| 425 | * SFP Status 0x0 = SFP+ transceiver not expected |
| 426 | * SFP Status 0x1 = SFP+ transceiver not present |
| 427 | * SFP Status 0x2 = SFP+ transceiver invalid |
| 428 | * SFP Status 0x3 = SFP+ transceiver present and |
| 429 | * valid |
| 430 | * Bits 12-14 = Heartbeat Counter |
| 431 | * Bit 15 = Heartbeat Monitor Enable |
| 432 | * Bits 16-17 = SFP Additional Info |
| 433 | * SFP info 0x0 = Unregocnized transceiver for |
| 434 | * Ethernet |
| 435 | * SFP info 0x1 = SFP+ brand validation failed |
| 436 | * SFP info 0x2 = SFP+ speed validation failed |
| 437 | * SFP info 0x3 = SFP+ access error |
| 438 | * Bit 18 = SFP Multirate |
| 439 | * Bit 19 = SFP Tx Fault |
| 440 | * Bits 20-22 = Link Speed |
| 441 | * Bits 23-27 = Reserved |
| 442 | * Bits 28-30 = DCBX Status |
| 443 | * DCBX Status 0x0 = DCBX Disabled |
| 444 | * DCBX Status 0x1 = DCBX Enabled |
| 445 | * DCBX Status 0x2 = DCBX Exchange error |
| 446 | * Bit 31 = Reserved |
| 447 | */ |
| 448 | peg_fw_state = (mb[2] & 0x00ff); |
| 449 | nw_interface_link_up = ((mb[2] & 0x0100) >> 8); |
| 450 | nw_interface_signal_detect = ((mb[2] & 0x0200) >> 9); |
| 451 | sfp_status = ((mb[2] & 0x0c00) >> 10); |
| 452 | htbt_counter = ((mb[2] & 0x7000) >> 12); |
| 453 | htbt_monitor_enable = ((mb[2] & 0x8000) >> 15); |
| 454 | sfp_additonal_info = (mb[6] & 0x0003); |
| 455 | sfp_multirate = ((mb[6] & 0x0004) >> 2); |
| 456 | sfp_tx_fault = ((mb[6] & 0x0008) >> 3); |
| 457 | link_speed = ((mb[6] & 0x0070) >> 4); |
| 458 | dcbx_status = ((mb[6] & 0x7000) >> 12); |
| 459 | |
| 460 | ql_log(ql_log_warn, vha, 0x5066, |
| 461 | "Peg-to-Fc Status Register:\n" |
| 462 | "peg_fw_state=0x%x, nw_interface_link_up=0x%x, " |
| 463 | "nw_interface_signal_detect=0x%x" |
| 464 | "\nsfp_statis=0x%x.\n ", peg_fw_state, |
| 465 | nw_interface_link_up, nw_interface_signal_detect, |
| 466 | sfp_status); |
| 467 | ql_log(ql_log_warn, vha, 0x5067, |
| 468 | "htbt_counter=0x%x, htbt_monitor_enable=0x%x, " |
| 469 | "sfp_additonal_info=0x%x, sfp_multirate=0x%x.\n ", |
| 470 | htbt_counter, htbt_monitor_enable, |
| 471 | sfp_additonal_info, sfp_multirate); |
| 472 | ql_log(ql_log_warn, vha, 0x5068, |
| 473 | "sfp_tx_fault=0x%x, link_state=0x%x, " |
| 474 | "dcbx_status=0x%x.\n", sfp_tx_fault, link_speed, |
| 475 | dcbx_status); |
| 476 | |
| 477 | qla83xx_schedule_work(vha, QLA83XX_NIC_CORE_RESET); |
| 478 | } |
| 479 | |
| 480 | if (mb[1] & IDC_HEARTBEAT_FAILURE) { |
| 481 | ql_log(ql_log_warn, vha, 0x5069, |
| 482 | "Heartbeat Failure encountered, chip reset " |
| 483 | "required.\n"); |
| 484 | |
| 485 | qla83xx_schedule_work(vha, QLA83XX_NIC_CORE_RESET); |
| 486 | } |
| 487 | } |
| 488 | |
| 489 | if (mb[1] & IDC_DEVICE_STATE_CHANGE) { |
| 490 | ql_log(ql_log_info, vha, 0x506a, |
| 491 | "IDC Device-State changed = 0x%x.\n", mb[4]); |
| 492 | qla83xx_schedule_work(vha, MBA_IDC_AEN); |
| 493 | } |
| 494 | } |
| 495 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | /** |
| 497 | * qla2x00_async_event() - Process aynchronous events. |
| 498 | * @ha: SCSI driver HA context |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 499 | * @mb: Mailbox registers (0 - 3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 501 | void |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 502 | 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] | 503 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 504 | uint16_t handle_cnt; |
Andrew Vasquez | bdab23d | 2009-10-13 15:16:46 -0700 | [diff] [blame] | 505 | uint16_t cnt, mbx; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | uint32_t handles[5]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 507 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 508 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Andrew Vasquez | bdab23d | 2009-10-13 15:16:46 -0700 | [diff] [blame] | 509 | struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24; |
Andrew Vasquez | bc5c2aa | 2010-12-21 16:00:24 -0800 | [diff] [blame] | 510 | struct device_reg_82xx __iomem *reg82 = &ha->iobase->isp82; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | uint32_t rscn_entry, host_pid; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 512 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | |
| 514 | /* Setup to process RIO completion. */ |
| 515 | handle_cnt = 0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 516 | if (IS_CNA_CAPABLE(ha)) |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 517 | goto skip_rio; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 518 | switch (mb[0]) { |
| 519 | case MBA_SCSI_COMPLETION: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 520 | handles[0] = le32_to_cpu((uint32_t)((mb[2] << 16) | mb[1])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | handle_cnt = 1; |
| 522 | break; |
| 523 | case MBA_CMPLT_1_16BIT: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 524 | handles[0] = mb[1]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | handle_cnt = 1; |
| 526 | mb[0] = MBA_SCSI_COMPLETION; |
| 527 | break; |
| 528 | case MBA_CMPLT_2_16BIT: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 529 | handles[0] = mb[1]; |
| 530 | handles[1] = mb[2]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | handle_cnt = 2; |
| 532 | mb[0] = MBA_SCSI_COMPLETION; |
| 533 | break; |
| 534 | case MBA_CMPLT_3_16BIT: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 535 | handles[0] = mb[1]; |
| 536 | handles[1] = mb[2]; |
| 537 | handles[2] = mb[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | handle_cnt = 3; |
| 539 | mb[0] = MBA_SCSI_COMPLETION; |
| 540 | break; |
| 541 | case MBA_CMPLT_4_16BIT: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 542 | handles[0] = mb[1]; |
| 543 | handles[1] = mb[2]; |
| 544 | handles[2] = mb[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | handles[3] = (uint32_t)RD_MAILBOX_REG(ha, reg, 6); |
| 546 | handle_cnt = 4; |
| 547 | mb[0] = MBA_SCSI_COMPLETION; |
| 548 | break; |
| 549 | case MBA_CMPLT_5_16BIT: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 550 | handles[0] = mb[1]; |
| 551 | handles[1] = mb[2]; |
| 552 | handles[2] = mb[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | handles[3] = (uint32_t)RD_MAILBOX_REG(ha, reg, 6); |
| 554 | handles[4] = (uint32_t)RD_MAILBOX_REG(ha, reg, 7); |
| 555 | handle_cnt = 5; |
| 556 | mb[0] = MBA_SCSI_COMPLETION; |
| 557 | break; |
| 558 | case MBA_CMPLT_2_32BIT: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 559 | handles[0] = le32_to_cpu((uint32_t)((mb[2] << 16) | mb[1])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | handles[1] = le32_to_cpu( |
| 561 | ((uint32_t)(RD_MAILBOX_REG(ha, reg, 7) << 16)) | |
| 562 | RD_MAILBOX_REG(ha, reg, 6)); |
| 563 | handle_cnt = 2; |
| 564 | mb[0] = MBA_SCSI_COMPLETION; |
| 565 | break; |
| 566 | default: |
| 567 | break; |
| 568 | } |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 569 | skip_rio: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | switch (mb[0]) { |
| 571 | case MBA_SCSI_COMPLETION: /* Fast Post */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 572 | if (!vha->flags.online) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | break; |
| 574 | |
| 575 | for (cnt = 0; cnt < handle_cnt; cnt++) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 576 | qla2x00_process_completed_request(vha, rsp->req, |
| 577 | handles[cnt]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 578 | break; |
| 579 | |
| 580 | case MBA_RESET: /* Reset */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 581 | ql_dbg(ql_dbg_async, vha, 0x5002, |
| 582 | "Asynchronous RESET.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 584 | set_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | break; |
| 586 | |
| 587 | case MBA_SYSTEM_ERR: /* System Error */ |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 588 | mbx = (IS_QLA81XX(ha) || IS_QLA83XX(ha)) ? |
| 589 | RD_REG_WORD(®24->mailbox7) : 0; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 590 | ql_log(ql_log_warn, vha, 0x5003, |
Andrew Vasquez | bdab23d | 2009-10-13 15:16:46 -0700 | [diff] [blame] | 591 | "ISP System Error - mbx1=%xh mbx2=%xh mbx3=%xh " |
| 592 | "mbx7=%xh.\n", mb[1], mb[2], mb[3], mbx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 594 | ha->isp_ops->fw_dump(vha, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 596 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 597 | if (mb[1] == 0 && mb[2] == 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 598 | ql_log(ql_log_fatal, vha, 0x5004, |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 599 | "Unrecoverable Hardware Error: adapter " |
| 600 | "marked OFFLINE!\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 601 | vha->flags.online = 0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 602 | vha->device_flags |= DFLG_DEV_FAILED; |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 603 | } else { |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 604 | /* Check to see if MPI timeout occurred */ |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 605 | if ((mbx & MBX_3) && (ha->flags.port0)) |
| 606 | set_bit(MPI_RESET_NEEDED, |
| 607 | &vha->dpc_flags); |
| 608 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 609 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 610 | } |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 611 | } else if (mb[1] == 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 612 | ql_log(ql_log_fatal, vha, 0x5005, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | "Unrecoverable Hardware Error: adapter marked " |
| 614 | "OFFLINE!\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 615 | vha->flags.online = 0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 616 | vha->device_flags |= DFLG_DEV_FAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | } else |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 618 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | break; |
| 620 | |
| 621 | case MBA_REQ_TRANSFER_ERR: /* Request Transfer Error */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 622 | ql_log(ql_log_warn, vha, 0x5006, |
| 623 | "ISP Request Transfer Error (%x).\n", mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 625 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | break; |
| 627 | |
| 628 | case MBA_RSP_TRANSFER_ERR: /* Response Transfer Error */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 629 | ql_log(ql_log_warn, vha, 0x5007, |
| 630 | "ISP Response Transfer Error.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 632 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | break; |
| 634 | |
| 635 | case MBA_WAKEUP_THRES: /* Request Queue Wake-up */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 636 | ql_dbg(ql_dbg_async, vha, 0x5008, |
| 637 | "Asynchronous WAKEUP_THRES.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 638 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 639 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 640 | case MBA_LIP_OCCURRED: /* Loop Initialization Procedure */ |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 641 | ql_dbg(ql_dbg_async, vha, 0x5009, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 642 | "LIP occurred (%x).\n", mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 644 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 645 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 646 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 647 | qla2x00_mark_all_devices_lost(vha, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 648 | } |
| 649 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 650 | if (vha->vp_idx) { |
| 651 | atomic_set(&vha->vp_state, VP_FAILED); |
| 652 | fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 653 | } |
| 654 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 655 | set_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags); |
| 656 | set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 657 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 658 | vha->flags.management_server_logged_in = 0; |
| 659 | qla2x00_post_aen_work(vha, FCH_EVT_LIP, mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | break; |
| 661 | |
| 662 | case MBA_LOOP_UP: /* Loop Up Event */ |
Chad Dupuis | daae62a | 2012-05-15 14:34:23 -0400 | [diff] [blame] | 663 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 664 | ha->link_data_rate = PORT_SPEED_1GB; |
Chad Dupuis | daae62a | 2012-05-15 14:34:23 -0400 | [diff] [blame] | 665 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | ha->link_data_rate = mb[1]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 667 | |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 668 | ql_dbg(ql_dbg_async, vha, 0x500a, |
Chad Dupuis | daae62a | 2012-05-15 14:34:23 -0400 | [diff] [blame] | 669 | "LOOP UP detected (%s Gbps).\n", |
Joe Carnuccio | d0297c9 | 2012-11-21 02:40:40 -0500 | [diff] [blame] | 670 | qla2x00_get_link_speed_str(ha, ha->link_data_rate)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 672 | vha->flags.management_server_logged_in = 0; |
| 673 | qla2x00_post_aen_work(vha, FCH_EVT_LINKUP, ha->link_data_rate); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 674 | break; |
| 675 | |
| 676 | case MBA_LOOP_DOWN: /* Loop Down Event */ |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 677 | mbx = (IS_QLA81XX(ha) || IS_QLA8031(ha)) |
| 678 | ? RD_REG_WORD(®24->mailbox4) : 0; |
Andrew Vasquez | bc5c2aa | 2010-12-21 16:00:24 -0800 | [diff] [blame] | 679 | mbx = IS_QLA82XX(ha) ? RD_REG_WORD(®82->mailbox_out[4]) : mbx; |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 680 | ql_dbg(ql_dbg_async, vha, 0x500b, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 681 | "LOOP DOWN detected (%x %x %x %x).\n", |
| 682 | mb[1], mb[2], mb[3], mbx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 684 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 685 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 686 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 687 | vha->device_flags |= DFLG_NO_CABLE; |
| 688 | qla2x00_mark_all_devices_lost(vha, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | } |
| 690 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 691 | if (vha->vp_idx) { |
| 692 | atomic_set(&vha->vp_state, VP_FAILED); |
| 693 | fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 694 | } |
| 695 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 696 | vha->flags.management_server_logged_in = 0; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 697 | ha->link_data_rate = PORT_SPEED_UNKNOWN; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 698 | qla2x00_post_aen_work(vha, FCH_EVT_LINKDOWN, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | break; |
| 700 | |
| 701 | case MBA_LIP_RESET: /* LIP reset occurred */ |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 702 | ql_dbg(ql_dbg_async, vha, 0x500c, |
Bjorn Helgaas | cc3ef7b | 2008-09-11 21:22:51 -0700 | [diff] [blame] | 703 | "LIP reset occurred (%x).\n", mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 704 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 705 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 706 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 707 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 708 | qla2x00_mark_all_devices_lost(vha, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | } |
| 710 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 711 | if (vha->vp_idx) { |
| 712 | atomic_set(&vha->vp_state, VP_FAILED); |
| 713 | fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 714 | } |
| 715 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 716 | set_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | |
| 718 | ha->operating_mode = LOOP; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 719 | vha->flags.management_server_logged_in = 0; |
| 720 | qla2x00_post_aen_work(vha, FCH_EVT_LIPRESET, mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 721 | break; |
| 722 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 723 | /* case MBA_DCBX_COMPLETE: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 724 | case MBA_POINT_TO_POINT: /* Point-to-Point */ |
| 725 | if (IS_QLA2100(ha)) |
| 726 | break; |
| 727 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 728 | if (IS_QLA81XX(ha) || IS_QLA82XX(ha) || IS_QLA8031(ha)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 729 | ql_dbg(ql_dbg_async, vha, 0x500d, |
| 730 | "DCBX Completed -- %04x %04x %04x.\n", |
| 731 | mb[1], mb[2], mb[3]); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 732 | if (ha->notify_dcbx_comp) |
| 733 | complete(&ha->dcbx_comp); |
| 734 | |
| 735 | } else |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 736 | ql_dbg(ql_dbg_async, vha, 0x500e, |
| 737 | "Asynchronous P2P MODE received.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 738 | |
| 739 | /* |
| 740 | * Until there's a transition from loop down to loop up, treat |
| 741 | * this as loop down only. |
| 742 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 743 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 744 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 745 | if (!atomic_read(&vha->loop_down_timer)) |
| 746 | atomic_set(&vha->loop_down_timer, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 747 | LOOP_DOWN_TIME); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 748 | qla2x00_mark_all_devices_lost(vha, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 749 | } |
| 750 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 751 | if (vha->vp_idx) { |
| 752 | atomic_set(&vha->vp_state, VP_FAILED); |
| 753 | fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 754 | } |
| 755 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 756 | if (!(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))) |
| 757 | set_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
| 758 | |
| 759 | set_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags); |
| 760 | set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | 4346b14 | 2006-12-13 19:20:28 -0800 | [diff] [blame] | 761 | |
| 762 | ha->flags.gpsc_supported = 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 763 | vha->flags.management_server_logged_in = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 764 | break; |
| 765 | |
| 766 | case MBA_CHG_IN_CONNECTION: /* Change in connection mode */ |
| 767 | if (IS_QLA2100(ha)) |
| 768 | break; |
| 769 | |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 770 | ql_dbg(ql_dbg_async, vha, 0x500f, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 771 | "Configuration change detected: value=%x.\n", mb[1]); |
| 772 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 773 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 774 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 775 | if (!atomic_read(&vha->loop_down_timer)) |
| 776 | atomic_set(&vha->loop_down_timer, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 777 | LOOP_DOWN_TIME); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 778 | qla2x00_mark_all_devices_lost(vha, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 779 | } |
| 780 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 781 | if (vha->vp_idx) { |
| 782 | atomic_set(&vha->vp_state, VP_FAILED); |
| 783 | fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 784 | } |
| 785 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 786 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 787 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 788 | break; |
| 789 | |
| 790 | case MBA_PORT_UPDATE: /* Port database update */ |
Santosh Vernekar | 55903b9 | 2009-07-31 15:09:25 -0700 | [diff] [blame] | 791 | /* |
| 792 | * Handle only global and vn-port update events |
| 793 | * |
| 794 | * Relevant inputs: |
| 795 | * mb[1] = N_Port handle of changed port |
| 796 | * OR 0xffff for global event |
| 797 | * mb[2] = New login state |
| 798 | * 7 = Port logged out |
| 799 | * mb[3] = LSB is vp_idx, 0xff = all vps |
| 800 | * |
| 801 | * Skip processing if: |
| 802 | * Event is global, vp_idx is NOT all vps, |
| 803 | * vp_idx does not match |
| 804 | * Event is not global, vp_idx does not match |
| 805 | */ |
Andrew Vasquez | 12cec63e4 | 2010-03-19 16:59:17 -0700 | [diff] [blame] | 806 | if (IS_QLA2XXX_MIDTYPE(ha) && |
| 807 | ((mb[1] == 0xffff && (mb[3] & 0xff) != 0xff) || |
| 808 | (mb[1] != 0xffff)) && vha->vp_idx != (mb[3] & 0xff)) |
| 809 | break; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 810 | |
Andrew Vasquez | 9764ff8 | 2009-07-31 15:09:24 -0700 | [diff] [blame] | 811 | /* Global event -- port logout or port unavailable. */ |
| 812 | if (mb[1] == 0xffff && mb[2] == 0x7) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 813 | ql_dbg(ql_dbg_async, vha, 0x5010, |
| 814 | "Port unavailable %04x %04x %04x.\n", |
| 815 | mb[1], mb[2], mb[3]); |
Chad Dupuis | daae62a | 2012-05-15 14:34:23 -0400 | [diff] [blame] | 816 | ql_log(ql_log_warn, vha, 0x505e, |
| 817 | "Link is offline.\n"); |
Andrew Vasquez | 9764ff8 | 2009-07-31 15:09:24 -0700 | [diff] [blame] | 818 | |
| 819 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 820 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 821 | atomic_set(&vha->loop_down_timer, |
| 822 | LOOP_DOWN_TIME); |
| 823 | vha->device_flags |= DFLG_NO_CABLE; |
| 824 | qla2x00_mark_all_devices_lost(vha, 1); |
| 825 | } |
| 826 | |
| 827 | if (vha->vp_idx) { |
| 828 | atomic_set(&vha->vp_state, VP_FAILED); |
| 829 | fc_vport_set_state(vha->fc_vport, |
| 830 | FC_VPORT_FAILED); |
Santosh Vernekar | faadc5e | 2009-07-31 15:09:26 -0700 | [diff] [blame] | 831 | qla2x00_mark_all_devices_lost(vha, 1); |
Andrew Vasquez | 9764ff8 | 2009-07-31 15:09:24 -0700 | [diff] [blame] | 832 | } |
| 833 | |
| 834 | vha->flags.management_server_logged_in = 0; |
| 835 | ha->link_data_rate = PORT_SPEED_UNKNOWN; |
| 836 | break; |
| 837 | } |
| 838 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 839 | /* |
Bjorn Helgaas | cc3ef7b | 2008-09-11 21:22:51 -0700 | [diff] [blame] | 840 | * If PORT UPDATE is global (received LIP_OCCURRED/LIP_RESET |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 841 | * event etc. earlier indicating loop is down) then process |
| 842 | * it. Otherwise ignore it and Wait for RSCN to come in. |
| 843 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 844 | atomic_set(&vha->loop_down_timer, 0); |
Chad Dupuis | 79cc785 | 2012-08-22 14:21:09 -0400 | [diff] [blame] | 845 | if (mb[1] != 0xffff || (mb[2] != 0x6 && mb[2] != 0x4)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 846 | ql_dbg(ql_dbg_async, vha, 0x5011, |
| 847 | "Asynchronous PORT UPDATE ignored %04x/%04x/%04x.\n", |
| 848 | mb[1], mb[2], mb[3]); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 849 | |
| 850 | qlt_async_event(mb[0], vha, mb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 851 | break; |
| 852 | } |
| 853 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 854 | ql_dbg(ql_dbg_async, vha, 0x5012, |
| 855 | "Port database changed %04x %04x %04x.\n", |
| 856 | mb[1], mb[2], mb[3]); |
Chad Dupuis | daae62a | 2012-05-15 14:34:23 -0400 | [diff] [blame] | 857 | ql_log(ql_log_warn, vha, 0x505f, |
| 858 | "Link is operational (%s Gbps).\n", |
Joe Carnuccio | d0297c9 | 2012-11-21 02:40:40 -0500 | [diff] [blame] | 859 | qla2x00_get_link_speed_str(ha, ha->link_data_rate)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 860 | |
| 861 | /* |
| 862 | * Mark all devices as missing so we will login again. |
| 863 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 864 | atomic_set(&vha->loop_state, LOOP_UP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 865 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 866 | qla2x00_mark_all_devices_lost(vha, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 867 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 868 | if (vha->vp_idx == 0 && !qla_ini_mode_enabled(vha)) |
| 869 | set_bit(SCR_PENDING, &vha->dpc_flags); |
| 870 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 871 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 872 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 873 | |
| 874 | qlt_async_event(mb[0], vha, mb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 875 | break; |
| 876 | |
| 877 | case MBA_RSCN_UPDATE: /* State Change Registration */ |
Seokmann Ju | 3c39740 | 2008-05-19 14:25:39 -0700 | [diff] [blame] | 878 | /* Check if the Vport has issued a SCR */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 879 | if (vha->vp_idx && test_bit(VP_SCR_NEEDED, &vha->vp_flags)) |
Seokmann Ju | 3c39740 | 2008-05-19 14:25:39 -0700 | [diff] [blame] | 880 | break; |
| 881 | /* Only handle SCNs for our Vport index. */ |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 882 | if (ha->flags.npiv_supported && vha->vp_idx != (mb[3] & 0xff)) |
Seokmann Ju | 3c39740 | 2008-05-19 14:25:39 -0700 | [diff] [blame] | 883 | break; |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 884 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 885 | ql_dbg(ql_dbg_async, vha, 0x5013, |
| 886 | "RSCN database changed -- %04x %04x %04x.\n", |
| 887 | mb[1], mb[2], mb[3]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 888 | |
Ravi Anand | 59d72d8 | 2008-09-11 21:22:53 -0700 | [diff] [blame] | 889 | rscn_entry = ((mb[1] & 0xff) << 16) | mb[2]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 890 | host_pid = (vha->d_id.b.domain << 16) | (vha->d_id.b.area << 8) |
| 891 | | vha->d_id.b.al_pa; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 892 | if (rscn_entry == host_pid) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 893 | ql_dbg(ql_dbg_async, vha, 0x5014, |
| 894 | "Ignoring RSCN update to local host " |
| 895 | "port ID (%06x).\n", host_pid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 896 | break; |
| 897 | } |
| 898 | |
Ravi Anand | 59d72d8 | 2008-09-11 21:22:53 -0700 | [diff] [blame] | 899 | /* Ignore reserved bits from RSCN-payload. */ |
| 900 | rscn_entry = ((mb[1] & 0x3ff) << 16) | mb[2]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 901 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 902 | atomic_set(&vha->loop_down_timer, 0); |
| 903 | vha->flags.management_server_logged_in = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 904 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 905 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 906 | set_bit(RSCN_UPDATE, &vha->dpc_flags); |
| 907 | qla2x00_post_aen_work(vha, FCH_EVT_RSCN, rscn_entry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 908 | break; |
| 909 | |
| 910 | /* case MBA_RIO_RESPONSE: */ |
| 911 | case MBA_ZIO_RESPONSE: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 912 | ql_dbg(ql_dbg_async, vha, 0x5015, |
| 913 | "[R|Z]IO update completion.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 914 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 915 | if (IS_FWI2_CAPABLE(ha)) |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 916 | qla24xx_process_response_queue(vha, rsp); |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 917 | else |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 918 | qla2x00_process_response_queue(rsp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 919 | break; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 920 | |
| 921 | case MBA_DISCARD_RND_FRAME: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 922 | ql_dbg(ql_dbg_async, vha, 0x5016, |
| 923 | "Discard RND Frame -- %04x %04x %04x.\n", |
| 924 | mb[1], mb[2], mb[3]); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 925 | break; |
Andrew Vasquez | 45ebeb5 | 2006-08-01 13:48:14 -0700 | [diff] [blame] | 926 | |
| 927 | case MBA_TRACE_NOTIFICATION: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 928 | ql_dbg(ql_dbg_async, vha, 0x5017, |
| 929 | "Trace Notification -- %04x %04x.\n", mb[1], mb[2]); |
Andrew Vasquez | 45ebeb5 | 2006-08-01 13:48:14 -0700 | [diff] [blame] | 930 | break; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 931 | |
| 932 | case MBA_ISP84XX_ALERT: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 933 | ql_dbg(ql_dbg_async, vha, 0x5018, |
| 934 | "ISP84XX Alert Notification -- %04x %04x %04x.\n", |
| 935 | mb[1], mb[2], mb[3]); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 936 | |
| 937 | spin_lock_irqsave(&ha->cs84xx->access_lock, flags); |
| 938 | switch (mb[1]) { |
| 939 | case A84_PANIC_RECOVERY: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 940 | ql_log(ql_log_info, vha, 0x5019, |
| 941 | "Alert 84XX: panic recovery %04x %04x.\n", |
| 942 | mb[2], mb[3]); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 943 | break; |
| 944 | case A84_OP_LOGIN_COMPLETE: |
| 945 | ha->cs84xx->op_fw_version = mb[3] << 16 | mb[2]; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 946 | ql_log(ql_log_info, vha, 0x501a, |
| 947 | "Alert 84XX: firmware version %x.\n", |
| 948 | ha->cs84xx->op_fw_version); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 949 | break; |
| 950 | case A84_DIAG_LOGIN_COMPLETE: |
| 951 | ha->cs84xx->diag_fw_version = mb[3] << 16 | mb[2]; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 952 | ql_log(ql_log_info, vha, 0x501b, |
| 953 | "Alert 84XX: diagnostic firmware version %x.\n", |
| 954 | ha->cs84xx->diag_fw_version); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 955 | break; |
| 956 | case A84_GOLD_LOGIN_COMPLETE: |
| 957 | ha->cs84xx->diag_fw_version = mb[3] << 16 | mb[2]; |
| 958 | ha->cs84xx->fw_update = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 959 | ql_log(ql_log_info, vha, 0x501c, |
| 960 | "Alert 84XX: gold firmware version %x.\n", |
| 961 | ha->cs84xx->gold_fw_version); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 962 | break; |
| 963 | default: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 964 | ql_log(ql_log_warn, vha, 0x501d, |
| 965 | "Alert 84xx: Invalid Alert %04x %04x %04x.\n", |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 966 | mb[1], mb[2], mb[3]); |
| 967 | } |
| 968 | spin_unlock_irqrestore(&ha->cs84xx->access_lock, flags); |
| 969 | break; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 970 | case MBA_DCBX_START: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 971 | ql_dbg(ql_dbg_async, vha, 0x501e, |
| 972 | "DCBX Started -- %04x %04x %04x.\n", |
| 973 | mb[1], mb[2], mb[3]); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 974 | break; |
| 975 | case MBA_DCBX_PARAM_UPDATE: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 976 | ql_dbg(ql_dbg_async, vha, 0x501f, |
| 977 | "DCBX Parameters Updated -- %04x %04x %04x.\n", |
| 978 | mb[1], mb[2], mb[3]); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 979 | break; |
| 980 | case MBA_FCF_CONF_ERR: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 981 | ql_dbg(ql_dbg_async, vha, 0x5020, |
| 982 | "FCF Configuration Error -- %04x %04x %04x.\n", |
| 983 | mb[1], mb[2], mb[3]); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 984 | break; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 985 | case MBA_IDC_NOTIFY: |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 986 | /* See if we need to quiesce any I/O */ |
| 987 | if (IS_QLA8031(vha->hw)) |
| 988 | if ((mb[2] & 0x7fff) == MBC_PORT_RESET || |
| 989 | (mb[2] & 0x7fff) == MBC_SET_PORT_CONFIG) { |
| 990 | set_bit(ISP_QUIESCE_NEEDED, &vha->dpc_flags); |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 991 | qla2xxx_wake_dpc(vha); |
| 992 | } |
| 993 | case MBA_IDC_COMPLETE: |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 994 | case MBA_IDC_TIME_EXT: |
Chad Dupuis | bf5b8ad | 2012-08-22 14:21:24 -0400 | [diff] [blame] | 995 | if (IS_QLA81XX(vha->hw) || IS_QLA8031(vha->hw)) |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 996 | qla81xx_idc_event(vha, mb[0], mb[1]); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 997 | break; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 998 | |
| 999 | case MBA_IDC_AEN: |
| 1000 | mb[4] = RD_REG_WORD(®24->mailbox4); |
| 1001 | mb[5] = RD_REG_WORD(®24->mailbox5); |
| 1002 | mb[6] = RD_REG_WORD(®24->mailbox6); |
| 1003 | mb[7] = RD_REG_WORD(®24->mailbox7); |
| 1004 | qla83xx_handle_8200_aen(vha, mb); |
| 1005 | break; |
| 1006 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1007 | default: |
| 1008 | ql_dbg(ql_dbg_async, vha, 0x5057, |
| 1009 | "Unknown AEN:%04x %04x %04x %04x\n", |
| 1010 | mb[0], mb[1], mb[2], mb[3]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1011 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1012 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 1013 | qlt_async_event(mb[0], vha, mb); |
| 1014 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1015 | if (!vha->vp_idx && ha->num_vhosts) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1016 | qla2x00_alert_all_vps(rsp, mb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1017 | } |
| 1018 | |
| 1019 | /** |
| 1020 | * qla2x00_process_completed_request() - Process a Fast Post response. |
| 1021 | * @ha: SCSI driver HA context |
| 1022 | * @index: SRB index |
| 1023 | */ |
| 1024 | static void |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1025 | qla2x00_process_completed_request(struct scsi_qla_host *vha, |
| 1026 | struct req_que *req, uint32_t index) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1027 | { |
| 1028 | srb_t *sp; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1029 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1030 | |
| 1031 | /* Validate handle. */ |
| 1032 | if (index >= MAX_OUTSTANDING_COMMANDS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1033 | ql_log(ql_log_warn, vha, 0x3014, |
| 1034 | "Invalid SCSI command index (%x).\n", index); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1035 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 1036 | if (IS_QLA82XX(ha)) |
| 1037 | set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags); |
| 1038 | else |
| 1039 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1040 | return; |
| 1041 | } |
| 1042 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1043 | sp = req->outstanding_cmds[index]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1044 | if (sp) { |
| 1045 | /* Free outstanding command slot. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1046 | req->outstanding_cmds[index] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1047 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1048 | /* Save ISP completion status */ |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1049 | sp->done(ha, sp, DID_OK << 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1050 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1051 | ql_log(ql_log_warn, vha, 0x3016, "Invalid SCSI SRB.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1052 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 1053 | if (IS_QLA82XX(ha)) |
| 1054 | set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags); |
| 1055 | else |
| 1056 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1057 | } |
| 1058 | } |
| 1059 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1060 | static srb_t * |
| 1061 | qla2x00_get_sp_from_handle(scsi_qla_host_t *vha, const char *func, |
| 1062 | struct req_que *req, void *iocb) |
| 1063 | { |
| 1064 | struct qla_hw_data *ha = vha->hw; |
| 1065 | sts_entry_t *pkt = iocb; |
| 1066 | srb_t *sp = NULL; |
| 1067 | uint16_t index; |
| 1068 | |
| 1069 | index = LSW(pkt->handle); |
| 1070 | if (index >= MAX_OUTSTANDING_COMMANDS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1071 | ql_log(ql_log_warn, vha, 0x5031, |
| 1072 | "Invalid command index (%x).\n", index); |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 1073 | if (IS_QLA82XX(ha)) |
| 1074 | set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags); |
| 1075 | else |
| 1076 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1077 | goto done; |
| 1078 | } |
| 1079 | sp = req->outstanding_cmds[index]; |
| 1080 | if (!sp) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1081 | ql_log(ql_log_warn, vha, 0x5032, |
| 1082 | "Invalid completion handle (%x) -- timed-out.\n", index); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1083 | return sp; |
| 1084 | } |
| 1085 | if (sp->handle != index) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1086 | ql_log(ql_log_warn, vha, 0x5033, |
| 1087 | "SRB handle (%x) mismatch %x.\n", sp->handle, index); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1088 | return NULL; |
| 1089 | } |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1090 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1091 | req->outstanding_cmds[index] = NULL; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1092 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1093 | done: |
| 1094 | return sp; |
| 1095 | } |
| 1096 | |
| 1097 | static void |
| 1098 | qla2x00_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, |
| 1099 | struct mbx_entry *mbx) |
| 1100 | { |
| 1101 | const char func[] = "MBX-IOCB"; |
| 1102 | const char *type; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1103 | fc_port_t *fcport; |
| 1104 | srb_t *sp; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 1105 | struct srb_iocb *lio; |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 1106 | uint16_t *data; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 1107 | uint16_t status; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1108 | |
| 1109 | sp = qla2x00_get_sp_from_handle(vha, func, req, mbx); |
| 1110 | if (!sp) |
| 1111 | return; |
| 1112 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1113 | lio = &sp->u.iocb_cmd; |
| 1114 | type = sp->name; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1115 | fcport = sp->fcport; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 1116 | data = lio->u.logio.data; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1117 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 1118 | data[0] = MBS_COMMAND_ERROR; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 1119 | data[1] = lio->u.logio.flags & SRB_LOGIN_RETRIED ? |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 1120 | QLA_LOGIO_LOGIN_RETRIED : 0; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1121 | if (mbx->entry_status) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1122 | ql_dbg(ql_dbg_async, vha, 0x5043, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1123 | "Async-%s error entry - hdl=%x portid=%02x%02x%02x " |
Andrew Vasquez | d3fa9e7 | 2010-05-28 15:08:16 -0700 | [diff] [blame] | 1124 | "entry-status=%x status=%x state-flag=%x " |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1125 | "status-flags=%x.\n", type, sp->handle, |
| 1126 | fcport->d_id.b.domain, fcport->d_id.b.area, |
Andrew Vasquez | d3fa9e7 | 2010-05-28 15:08:16 -0700 | [diff] [blame] | 1127 | fcport->d_id.b.al_pa, mbx->entry_status, |
| 1128 | le16_to_cpu(mbx->status), le16_to_cpu(mbx->state_flags), |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1129 | le16_to_cpu(mbx->status_flags)); |
Andrew Vasquez | d3fa9e7 | 2010-05-28 15:08:16 -0700 | [diff] [blame] | 1130 | |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1131 | ql_dump_buffer(ql_dbg_async + ql_dbg_buffer, vha, 0x5029, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1132 | (uint8_t *)mbx, sizeof(*mbx)); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1133 | |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 1134 | goto logio_done; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1135 | } |
| 1136 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 1137 | status = le16_to_cpu(mbx->status); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1138 | if (status == 0x30 && sp->type == SRB_LOGIN_CMD && |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 1139 | le16_to_cpu(mbx->mb0) == MBS_COMMAND_COMPLETE) |
| 1140 | status = 0; |
| 1141 | if (!status && le16_to_cpu(mbx->mb0) == MBS_COMMAND_COMPLETE) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1142 | ql_dbg(ql_dbg_async, vha, 0x5045, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1143 | "Async-%s complete - hdl=%x portid=%02x%02x%02x mbx1=%x.\n", |
| 1144 | type, sp->handle, fcport->d_id.b.domain, |
| 1145 | fcport->d_id.b.area, fcport->d_id.b.al_pa, |
| 1146 | le16_to_cpu(mbx->mb1)); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1147 | |
| 1148 | data[0] = MBS_COMMAND_COMPLETE; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1149 | if (sp->type == SRB_LOGIN_CMD) { |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 1150 | fcport->port_type = FCT_TARGET; |
| 1151 | if (le16_to_cpu(mbx->mb1) & BIT_0) |
| 1152 | fcport->port_type = FCT_INITIATOR; |
Andrew Vasquez | 6ac5260 | 2010-05-28 15:08:19 -0700 | [diff] [blame] | 1153 | else if (le16_to_cpu(mbx->mb1) & BIT_1) |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 1154 | fcport->flags |= FCF_FCP2_DEVICE; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 1155 | } |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 1156 | goto logio_done; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1157 | } |
| 1158 | |
| 1159 | data[0] = le16_to_cpu(mbx->mb0); |
| 1160 | switch (data[0]) { |
| 1161 | case MBS_PORT_ID_USED: |
| 1162 | data[1] = le16_to_cpu(mbx->mb1); |
| 1163 | break; |
| 1164 | case MBS_LOOP_ID_USED: |
| 1165 | break; |
| 1166 | default: |
| 1167 | data[0] = MBS_COMMAND_ERROR; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1168 | break; |
| 1169 | } |
| 1170 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1171 | ql_log(ql_log_warn, vha, 0x5046, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1172 | "Async-%s failed - hdl=%x portid=%02x%02x%02x status=%x " |
| 1173 | "mb0=%x mb1=%x mb2=%x mb6=%x mb7=%x.\n", type, sp->handle, |
| 1174 | fcport->d_id.b.domain, fcport->d_id.b.area, fcport->d_id.b.al_pa, |
| 1175 | status, le16_to_cpu(mbx->mb0), le16_to_cpu(mbx->mb1), |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1176 | le16_to_cpu(mbx->mb2), le16_to_cpu(mbx->mb6), |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1177 | le16_to_cpu(mbx->mb7)); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1178 | |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 1179 | logio_done: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1180 | sp->done(vha, sp, 0); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1181 | } |
| 1182 | |
| 1183 | static void |
Harish Zunjarrao | 9bc4f4f | 2010-07-23 15:28:32 +0500 | [diff] [blame] | 1184 | qla2x00_ct_entry(scsi_qla_host_t *vha, struct req_que *req, |
| 1185 | sts_entry_t *pkt, int iocb_type) |
| 1186 | { |
| 1187 | const char func[] = "CT_IOCB"; |
| 1188 | const char *type; |
Harish Zunjarrao | 9bc4f4f | 2010-07-23 15:28:32 +0500 | [diff] [blame] | 1189 | srb_t *sp; |
Harish Zunjarrao | 9bc4f4f | 2010-07-23 15:28:32 +0500 | [diff] [blame] | 1190 | struct fc_bsg_job *bsg_job; |
| 1191 | uint16_t comp_status; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1192 | int res; |
Harish Zunjarrao | 9bc4f4f | 2010-07-23 15:28:32 +0500 | [diff] [blame] | 1193 | |
| 1194 | sp = qla2x00_get_sp_from_handle(vha, func, req, pkt); |
| 1195 | if (!sp) |
| 1196 | return; |
| 1197 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1198 | bsg_job = sp->u.bsg_job; |
Harish Zunjarrao | 9bc4f4f | 2010-07-23 15:28:32 +0500 | [diff] [blame] | 1199 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1200 | type = "ct pass-through"; |
Harish Zunjarrao | 9bc4f4f | 2010-07-23 15:28:32 +0500 | [diff] [blame] | 1201 | |
| 1202 | comp_status = le16_to_cpu(pkt->comp_status); |
| 1203 | |
| 1204 | /* return FC_CTELS_STATUS_OK and leave the decoding of the ELS/CT |
| 1205 | * fc payload to the caller |
| 1206 | */ |
| 1207 | bsg_job->reply->reply_data.ctels_reply.status = FC_CTELS_STATUS_OK; |
| 1208 | bsg_job->reply_len = sizeof(struct fc_bsg_reply); |
| 1209 | |
| 1210 | if (comp_status != CS_COMPLETE) { |
| 1211 | if (comp_status == CS_DATA_UNDERRUN) { |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1212 | res = DID_OK << 16; |
Harish Zunjarrao | 9bc4f4f | 2010-07-23 15:28:32 +0500 | [diff] [blame] | 1213 | bsg_job->reply->reply_payload_rcv_len = |
| 1214 | le16_to_cpu(((sts_entry_t *)pkt)->rsp_info_len); |
| 1215 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1216 | ql_log(ql_log_warn, vha, 0x5048, |
| 1217 | "CT pass-through-%s error " |
Harish Zunjarrao | 9bc4f4f | 2010-07-23 15:28:32 +0500 | [diff] [blame] | 1218 | "comp_status-status=0x%x total_byte = 0x%x.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1219 | type, comp_status, |
| 1220 | bsg_job->reply->reply_payload_rcv_len); |
Harish Zunjarrao | 9bc4f4f | 2010-07-23 15:28:32 +0500 | [diff] [blame] | 1221 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1222 | ql_log(ql_log_warn, vha, 0x5049, |
| 1223 | "CT pass-through-%s error " |
| 1224 | "comp_status-status=0x%x.\n", type, comp_status); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1225 | res = DID_ERROR << 16; |
Harish Zunjarrao | 9bc4f4f | 2010-07-23 15:28:32 +0500 | [diff] [blame] | 1226 | bsg_job->reply->reply_payload_rcv_len = 0; |
| 1227 | } |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1228 | ql_dump_buffer(ql_dbg_async + ql_dbg_buffer, vha, 0x5035, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1229 | (uint8_t *)pkt, sizeof(*pkt)); |
Harish Zunjarrao | 9bc4f4f | 2010-07-23 15:28:32 +0500 | [diff] [blame] | 1230 | } else { |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1231 | res = DID_OK << 16; |
Harish Zunjarrao | 9bc4f4f | 2010-07-23 15:28:32 +0500 | [diff] [blame] | 1232 | bsg_job->reply->reply_payload_rcv_len = |
| 1233 | bsg_job->reply_payload.payload_len; |
| 1234 | bsg_job->reply_len = 0; |
| 1235 | } |
| 1236 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1237 | sp->done(vha, sp, res); |
Harish Zunjarrao | 9bc4f4f | 2010-07-23 15:28:32 +0500 | [diff] [blame] | 1238 | } |
| 1239 | |
| 1240 | static void |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1241 | qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req, |
| 1242 | struct sts_entry_24xx *pkt, int iocb_type) |
| 1243 | { |
| 1244 | const char func[] = "ELS_CT_IOCB"; |
| 1245 | const char *type; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1246 | srb_t *sp; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1247 | struct fc_bsg_job *bsg_job; |
| 1248 | uint16_t comp_status; |
| 1249 | uint32_t fw_status[3]; |
| 1250 | uint8_t* fw_sts_ptr; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1251 | int res; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1252 | |
| 1253 | sp = qla2x00_get_sp_from_handle(vha, func, req, pkt); |
| 1254 | if (!sp) |
| 1255 | return; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1256 | bsg_job = sp->u.bsg_job; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1257 | |
| 1258 | type = NULL; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1259 | switch (sp->type) { |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1260 | case SRB_ELS_CMD_RPT: |
| 1261 | case SRB_ELS_CMD_HST: |
| 1262 | type = "els"; |
| 1263 | break; |
| 1264 | case SRB_CT_CMD: |
| 1265 | type = "ct pass-through"; |
| 1266 | break; |
| 1267 | default: |
Andrew Vasquez | 37fed3e | 2012-02-09 11:15:37 -0800 | [diff] [blame] | 1268 | ql_dbg(ql_dbg_user, vha, 0x503e, |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1269 | "Unrecognized SRB: (%p) type=%d.\n", sp, sp->type); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1270 | return; |
| 1271 | } |
| 1272 | |
| 1273 | comp_status = fw_status[0] = le16_to_cpu(pkt->comp_status); |
| 1274 | fw_status[1] = le16_to_cpu(((struct els_sts_entry_24xx*)pkt)->error_subcode_1); |
| 1275 | fw_status[2] = le16_to_cpu(((struct els_sts_entry_24xx*)pkt)->error_subcode_2); |
| 1276 | |
| 1277 | /* return FC_CTELS_STATUS_OK and leave the decoding of the ELS/CT |
| 1278 | * fc payload to the caller |
| 1279 | */ |
| 1280 | bsg_job->reply->reply_data.ctels_reply.status = FC_CTELS_STATUS_OK; |
| 1281 | bsg_job->reply_len = sizeof(struct fc_bsg_reply) + sizeof(fw_status); |
| 1282 | |
| 1283 | if (comp_status != CS_COMPLETE) { |
| 1284 | if (comp_status == CS_DATA_UNDERRUN) { |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1285 | res = DID_OK << 16; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1286 | bsg_job->reply->reply_payload_rcv_len = |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1287 | le16_to_cpu(((struct els_sts_entry_24xx *)pkt)->total_byte_count); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1288 | |
Andrew Vasquez | 37fed3e | 2012-02-09 11:15:37 -0800 | [diff] [blame] | 1289 | ql_dbg(ql_dbg_user, vha, 0x503f, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1290 | "ELS-CT pass-through-%s error hdl=%x comp_status-status=0x%x " |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1291 | "error subcode 1=0x%x error subcode 2=0x%x total_byte = 0x%x.\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1292 | type, sp->handle, comp_status, fw_status[1], fw_status[2], |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1293 | le16_to_cpu(((struct els_sts_entry_24xx *) |
| 1294 | pkt)->total_byte_count)); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1295 | fw_sts_ptr = ((uint8_t*)bsg_job->req->sense) + sizeof(struct fc_bsg_reply); |
| 1296 | memcpy( fw_sts_ptr, fw_status, sizeof(fw_status)); |
| 1297 | } |
| 1298 | else { |
Andrew Vasquez | 37fed3e | 2012-02-09 11:15:37 -0800 | [diff] [blame] | 1299 | ql_dbg(ql_dbg_user, vha, 0x5040, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1300 | "ELS-CT pass-through-%s error hdl=%x comp_status-status=0x%x " |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1301 | "error subcode 1=0x%x error subcode 2=0x%x.\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1302 | type, sp->handle, comp_status, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1303 | le16_to_cpu(((struct els_sts_entry_24xx *) |
| 1304 | pkt)->error_subcode_1), |
| 1305 | le16_to_cpu(((struct els_sts_entry_24xx *) |
| 1306 | pkt)->error_subcode_2)); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1307 | res = DID_ERROR << 16; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1308 | bsg_job->reply->reply_payload_rcv_len = 0; |
| 1309 | fw_sts_ptr = ((uint8_t*)bsg_job->req->sense) + sizeof(struct fc_bsg_reply); |
| 1310 | memcpy( fw_sts_ptr, fw_status, sizeof(fw_status)); |
| 1311 | } |
Andrew Vasquez | 37fed3e | 2012-02-09 11:15:37 -0800 | [diff] [blame] | 1312 | ql_dump_buffer(ql_dbg_user + ql_dbg_buffer, vha, 0x5056, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1313 | (uint8_t *)pkt, sizeof(*pkt)); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1314 | } |
| 1315 | else { |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1316 | res = DID_OK << 16; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1317 | bsg_job->reply->reply_payload_rcv_len = bsg_job->reply_payload.payload_len; |
| 1318 | bsg_job->reply_len = 0; |
| 1319 | } |
| 1320 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1321 | sp->done(vha, sp, res); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1322 | } |
| 1323 | |
| 1324 | static void |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1325 | qla24xx_logio_entry(scsi_qla_host_t *vha, struct req_que *req, |
| 1326 | struct logio_entry_24xx *logio) |
| 1327 | { |
| 1328 | const char func[] = "LOGIO-IOCB"; |
| 1329 | const char *type; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1330 | fc_port_t *fcport; |
| 1331 | srb_t *sp; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 1332 | struct srb_iocb *lio; |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 1333 | uint16_t *data; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1334 | uint32_t iop[2]; |
| 1335 | |
| 1336 | sp = qla2x00_get_sp_from_handle(vha, func, req, logio); |
| 1337 | if (!sp) |
| 1338 | return; |
| 1339 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1340 | lio = &sp->u.iocb_cmd; |
| 1341 | type = sp->name; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1342 | fcport = sp->fcport; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 1343 | data = lio->u.logio.data; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1344 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 1345 | data[0] = MBS_COMMAND_ERROR; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 1346 | data[1] = lio->u.logio.flags & SRB_LOGIN_RETRIED ? |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 1347 | QLA_LOGIO_LOGIN_RETRIED : 0; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1348 | if (logio->entry_status) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 1349 | ql_log(ql_log_warn, fcport->vha, 0x5034, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1350 | "Async-%s error entry - hdl=%x" |
Andrew Vasquez | d3fa9e7 | 2010-05-28 15:08:16 -0700 | [diff] [blame] | 1351 | "portid=%02x%02x%02x entry-status=%x.\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1352 | type, sp->handle, fcport->d_id.b.domain, |
| 1353 | fcport->d_id.b.area, fcport->d_id.b.al_pa, |
| 1354 | logio->entry_status); |
| 1355 | ql_dump_buffer(ql_dbg_async + ql_dbg_buffer, vha, 0x504d, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1356 | (uint8_t *)logio, sizeof(*logio)); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1357 | |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 1358 | goto logio_done; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1359 | } |
| 1360 | |
| 1361 | if (le16_to_cpu(logio->comp_status) == CS_COMPLETE) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 1362 | ql_dbg(ql_dbg_async, fcport->vha, 0x5036, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1363 | "Async-%s complete - hdl=%x portid=%02x%02x%02x " |
| 1364 | "iop0=%x.\n", type, sp->handle, fcport->d_id.b.domain, |
| 1365 | fcport->d_id.b.area, fcport->d_id.b.al_pa, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1366 | le32_to_cpu(logio->io_parameter[0])); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1367 | |
| 1368 | data[0] = MBS_COMMAND_COMPLETE; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1369 | if (sp->type != SRB_LOGIN_CMD) |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 1370 | goto logio_done; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1371 | |
| 1372 | iop[0] = le32_to_cpu(logio->io_parameter[0]); |
| 1373 | if (iop[0] & BIT_4) { |
| 1374 | fcport->port_type = FCT_TARGET; |
| 1375 | if (iop[0] & BIT_8) |
Santosh Vernekar | 8474f3a | 2009-08-25 11:36:16 -0700 | [diff] [blame] | 1376 | fcport->flags |= FCF_FCP2_DEVICE; |
Andrew Vasquez | b0cd579 | 2010-05-28 15:08:22 -0700 | [diff] [blame] | 1377 | } else if (iop[0] & BIT_5) |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1378 | fcport->port_type = FCT_INITIATOR; |
Andrew Vasquez | b0cd579 | 2010-05-28 15:08:22 -0700 | [diff] [blame] | 1379 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 1380 | if (iop[0] & BIT_7) |
| 1381 | fcport->flags |= FCF_CONF_COMP_SUPPORTED; |
| 1382 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1383 | if (logio->io_parameter[7] || logio->io_parameter[8]) |
| 1384 | fcport->supported_classes |= FC_COS_CLASS2; |
| 1385 | if (logio->io_parameter[9] || logio->io_parameter[10]) |
| 1386 | fcport->supported_classes |= FC_COS_CLASS3; |
| 1387 | |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 1388 | goto logio_done; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1389 | } |
| 1390 | |
| 1391 | iop[0] = le32_to_cpu(logio->io_parameter[0]); |
| 1392 | iop[1] = le32_to_cpu(logio->io_parameter[1]); |
| 1393 | switch (iop[0]) { |
| 1394 | case LSC_SCODE_PORTID_USED: |
| 1395 | data[0] = MBS_PORT_ID_USED; |
| 1396 | data[1] = LSW(iop[1]); |
| 1397 | break; |
| 1398 | case LSC_SCODE_NPORT_USED: |
| 1399 | data[0] = MBS_LOOP_ID_USED; |
| 1400 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1401 | default: |
| 1402 | data[0] = MBS_COMMAND_ERROR; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1403 | break; |
| 1404 | } |
| 1405 | |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 1406 | ql_dbg(ql_dbg_async, fcport->vha, 0x5037, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1407 | "Async-%s failed - hdl=%x portid=%02x%02x%02x comp=%x " |
| 1408 | "iop0=%x iop1=%x.\n", type, sp->handle, fcport->d_id.b.domain, |
Andrew Vasquez | d3fa9e7 | 2010-05-28 15:08:16 -0700 | [diff] [blame] | 1409 | fcport->d_id.b.area, fcport->d_id.b.al_pa, |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1410 | le16_to_cpu(logio->comp_status), |
| 1411 | le32_to_cpu(logio->io_parameter[0]), |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1412 | le32_to_cpu(logio->io_parameter[1])); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1413 | |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 1414 | logio_done: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1415 | sp->done(vha, sp, 0); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1416 | } |
| 1417 | |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 1418 | static void |
| 1419 | qla24xx_tm_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, |
| 1420 | struct tsk_mgmt_entry *tsk) |
| 1421 | { |
| 1422 | const char func[] = "TMF-IOCB"; |
| 1423 | const char *type; |
| 1424 | fc_port_t *fcport; |
| 1425 | srb_t *sp; |
| 1426 | struct srb_iocb *iocb; |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 1427 | struct sts_entry_24xx *sts = (struct sts_entry_24xx *)tsk; |
| 1428 | int error = 1; |
| 1429 | |
| 1430 | sp = qla2x00_get_sp_from_handle(vha, func, req, tsk); |
| 1431 | if (!sp) |
| 1432 | return; |
| 1433 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1434 | iocb = &sp->u.iocb_cmd; |
| 1435 | type = sp->name; |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 1436 | fcport = sp->fcport; |
| 1437 | |
| 1438 | if (sts->entry_status) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 1439 | ql_log(ql_log_warn, fcport->vha, 0x5038, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1440 | "Async-%s error - hdl=%x entry-status(%x).\n", |
| 1441 | type, sp->handle, sts->entry_status); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 1442 | } else if (sts->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 1443 | ql_log(ql_log_warn, fcport->vha, 0x5039, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1444 | "Async-%s error - hdl=%x completion status(%x).\n", |
| 1445 | type, sp->handle, sts->comp_status); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 1446 | } else if (!(le16_to_cpu(sts->scsi_status) & |
| 1447 | SS_RESPONSE_INFO_LEN_VALID)) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 1448 | ql_log(ql_log_warn, fcport->vha, 0x503a, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1449 | "Async-%s error - hdl=%x no response info(%x).\n", |
| 1450 | type, sp->handle, sts->scsi_status); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 1451 | } else if (le32_to_cpu(sts->rsp_data_len) < 4) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 1452 | ql_log(ql_log_warn, fcport->vha, 0x503b, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1453 | "Async-%s error - hdl=%x not enough response(%d).\n", |
| 1454 | type, sp->handle, sts->rsp_data_len); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 1455 | } else if (sts->data[3]) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 1456 | ql_log(ql_log_warn, fcport->vha, 0x503c, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1457 | "Async-%s error - hdl=%x response(%x).\n", |
| 1458 | type, sp->handle, sts->data[3]); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 1459 | } else { |
| 1460 | error = 0; |
| 1461 | } |
| 1462 | |
| 1463 | if (error) { |
| 1464 | iocb->u.tmf.data = error; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1465 | ql_dump_buffer(ql_dbg_async + ql_dbg_buffer, vha, 0x5055, |
| 1466 | (uint8_t *)sts, sizeof(*sts)); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 1467 | } |
| 1468 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1469 | sp->done(vha, sp, 0); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 1470 | } |
| 1471 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1472 | /** |
| 1473 | * qla2x00_process_response_queue() - Process response queue entries. |
| 1474 | * @ha: SCSI driver HA context |
| 1475 | */ |
| 1476 | void |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1477 | qla2x00_process_response_queue(struct rsp_que *rsp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1478 | { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1479 | struct scsi_qla_host *vha; |
| 1480 | struct qla_hw_data *ha = rsp->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 1481 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1482 | sts_entry_t *pkt; |
| 1483 | uint16_t handle_cnt; |
| 1484 | uint16_t cnt; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1485 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1486 | vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1487 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1488 | if (!vha->flags.online) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1489 | return; |
| 1490 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1491 | while (rsp->ring_ptr->signature != RESPONSE_PROCESSED) { |
| 1492 | pkt = (sts_entry_t *)rsp->ring_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1493 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1494 | rsp->ring_index++; |
| 1495 | if (rsp->ring_index == rsp->length) { |
| 1496 | rsp->ring_index = 0; |
| 1497 | rsp->ring_ptr = rsp->ring; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1498 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1499 | rsp->ring_ptr++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1500 | } |
| 1501 | |
| 1502 | if (pkt->entry_status != 0) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1503 | qla2x00_error_entry(vha, rsp, pkt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1504 | ((response_t *)pkt)->signature = RESPONSE_PROCESSED; |
| 1505 | wmb(); |
| 1506 | continue; |
| 1507 | } |
| 1508 | |
| 1509 | switch (pkt->entry_type) { |
| 1510 | case STATUS_TYPE: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1511 | qla2x00_status_entry(vha, rsp, pkt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1512 | break; |
| 1513 | case STATUS_TYPE_21: |
| 1514 | handle_cnt = ((sts21_entry_t *)pkt)->handle_count; |
| 1515 | for (cnt = 0; cnt < handle_cnt; cnt++) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1516 | qla2x00_process_completed_request(vha, rsp->req, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1517 | ((sts21_entry_t *)pkt)->handle[cnt]); |
| 1518 | } |
| 1519 | break; |
| 1520 | case STATUS_TYPE_22: |
| 1521 | handle_cnt = ((sts22_entry_t *)pkt)->handle_count; |
| 1522 | for (cnt = 0; cnt < handle_cnt; cnt++) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1523 | qla2x00_process_completed_request(vha, rsp->req, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1524 | ((sts22_entry_t *)pkt)->handle[cnt]); |
| 1525 | } |
| 1526 | break; |
| 1527 | case STATUS_CONT_TYPE: |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1528 | qla2x00_status_cont_entry(rsp, (sts_cont_entry_t *)pkt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1529 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1530 | case MBX_IOCB_TYPE: |
| 1531 | qla2x00_mbx_iocb_entry(vha, rsp->req, |
| 1532 | (struct mbx_entry *)pkt); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 1533 | break; |
Harish Zunjarrao | 9bc4f4f | 2010-07-23 15:28:32 +0500 | [diff] [blame] | 1534 | case CT_IOCB_TYPE: |
| 1535 | qla2x00_ct_entry(vha, rsp->req, pkt, CT_IOCB_TYPE); |
| 1536 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1537 | default: |
| 1538 | /* Type Not Supported. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1539 | ql_log(ql_log_warn, vha, 0x504a, |
| 1540 | "Received unknown response pkt type %x " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1541 | "entry status=%x.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1542 | pkt->entry_type, pkt->entry_status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1543 | break; |
| 1544 | } |
| 1545 | ((response_t *)pkt)->signature = RESPONSE_PROCESSED; |
| 1546 | wmb(); |
| 1547 | } |
| 1548 | |
| 1549 | /* Adjust ring index */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1550 | WRT_REG_WORD(ISP_RSP_Q_OUT(ha, reg), rsp->ring_index); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1551 | } |
| 1552 | |
Andrew Vasquez | 4733fcb | 2008-01-17 09:02:07 -0800 | [diff] [blame] | 1553 | static inline void |
Andrew Vasquez | 5544213 | 2010-07-23 15:28:27 +0500 | [diff] [blame] | 1554 | qla2x00_handle_sense(srb_t *sp, uint8_t *sense_data, uint32_t par_sense_len, |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1555 | uint32_t sense_len, struct rsp_que *rsp, int res) |
Andrew Vasquez | 4733fcb | 2008-01-17 09:02:07 -0800 | [diff] [blame] | 1556 | { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1557 | struct scsi_qla_host *vha = sp->fcport->vha; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1558 | struct scsi_cmnd *cp = GET_CMD_SP(sp); |
| 1559 | uint32_t track_sense_len; |
Andrew Vasquez | 4733fcb | 2008-01-17 09:02:07 -0800 | [diff] [blame] | 1560 | |
| 1561 | if (sense_len >= SCSI_SENSE_BUFFERSIZE) |
| 1562 | sense_len = SCSI_SENSE_BUFFERSIZE; |
| 1563 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1564 | SET_CMD_SENSE_LEN(sp, sense_len); |
| 1565 | SET_CMD_SENSE_PTR(sp, cp->sense_buffer); |
| 1566 | track_sense_len = sense_len; |
| 1567 | |
| 1568 | if (sense_len > par_sense_len) |
Andrew Vasquez | 5544213 | 2010-07-23 15:28:27 +0500 | [diff] [blame] | 1569 | sense_len = par_sense_len; |
Andrew Vasquez | 4733fcb | 2008-01-17 09:02:07 -0800 | [diff] [blame] | 1570 | |
| 1571 | memcpy(cp->sense_buffer, sense_data, sense_len); |
| 1572 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1573 | SET_CMD_SENSE_PTR(sp, cp->sense_buffer + sense_len); |
| 1574 | track_sense_len -= sense_len; |
| 1575 | SET_CMD_SENSE_LEN(sp, track_sense_len); |
| 1576 | |
| 1577 | if (track_sense_len != 0) { |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1578 | rsp->status_srb = sp; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1579 | cp->result = res; |
| 1580 | } |
Andrew Vasquez | 4733fcb | 2008-01-17 09:02:07 -0800 | [diff] [blame] | 1581 | |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1582 | if (sense_len) { |
| 1583 | ql_dbg(ql_dbg_io + ql_dbg_buffer, vha, 0x301c, |
| 1584 | "Check condition Sense data, nexus%ld:%d:%d cmd=%p.\n", |
| 1585 | sp->fcport->vha->host_no, cp->device->id, cp->device->lun, |
| 1586 | cp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1587 | ql_dump_buffer(ql_dbg_io + ql_dbg_buffer, vha, 0x302b, |
| 1588 | cp->sense_buffer, sense_len); |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1589 | } |
Andrew Vasquez | 4733fcb | 2008-01-17 09:02:07 -0800 | [diff] [blame] | 1590 | } |
| 1591 | |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1592 | struct scsi_dif_tuple { |
| 1593 | __be16 guard; /* Checksum */ |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1594 | __be16 app_tag; /* APPL identifier */ |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1595 | __be32 ref_tag; /* Target LBA or indirect LBA */ |
| 1596 | }; |
| 1597 | |
| 1598 | /* |
| 1599 | * Checks the guard or meta-data for the type of error |
| 1600 | * detected by the HBA. In case of errors, we set the |
| 1601 | * ASC/ASCQ fields in the sense buffer with ILLEGAL_REQUEST |
| 1602 | * to indicate to the kernel that the HBA detected error. |
| 1603 | */ |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 1604 | static inline int |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1605 | qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24) |
| 1606 | { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1607 | struct scsi_qla_host *vha = sp->fcport->vha; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1608 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 1609 | uint8_t *ap = &sts24->data[12]; |
| 1610 | uint8_t *ep = &sts24->data[20]; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1611 | uint32_t e_ref_tag, a_ref_tag; |
| 1612 | uint16_t e_app_tag, a_app_tag; |
| 1613 | uint16_t e_guard, a_guard; |
| 1614 | |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 1615 | /* |
| 1616 | * swab32 of the "data" field in the beginning of qla2x00_status_entry() |
| 1617 | * would make guard field appear at offset 2 |
| 1618 | */ |
| 1619 | a_guard = le16_to_cpu(*(uint16_t *)(ap + 2)); |
| 1620 | a_app_tag = le16_to_cpu(*(uint16_t *)(ap + 0)); |
| 1621 | a_ref_tag = le32_to_cpu(*(uint32_t *)(ap + 4)); |
| 1622 | e_guard = le16_to_cpu(*(uint16_t *)(ep + 2)); |
| 1623 | e_app_tag = le16_to_cpu(*(uint16_t *)(ep + 0)); |
| 1624 | e_ref_tag = le32_to_cpu(*(uint32_t *)(ep + 4)); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1625 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1626 | ql_dbg(ql_dbg_io, vha, 0x3023, |
| 1627 | "iocb(s) %p Returned STATUS.\n", sts24); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1628 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1629 | ql_dbg(ql_dbg_io, vha, 0x3024, |
| 1630 | "DIF ERROR in cmd 0x%x lba 0x%llx act ref" |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1631 | " tag=0x%x, exp ref_tag=0x%x, act app tag=0x%x, exp app" |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1632 | " tag=0x%x, act guard=0x%x, exp guard=0x%x.\n", |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1633 | cmd->cmnd[0], (u64)scsi_get_lba(cmd), a_ref_tag, e_ref_tag, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1634 | a_app_tag, e_app_tag, a_guard, e_guard); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1635 | |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 1636 | /* |
| 1637 | * Ignore sector if: |
| 1638 | * For type 3: ref & app tag is all 'f's |
| 1639 | * For type 0,1,2: app tag is all 'f's |
| 1640 | */ |
| 1641 | if ((a_app_tag == 0xffff) && |
| 1642 | ((scsi_get_prot_type(cmd) != SCSI_PROT_DIF_TYPE3) || |
| 1643 | (a_ref_tag == 0xffffffff))) { |
| 1644 | uint32_t blocks_done, resid; |
| 1645 | sector_t lba_s = scsi_get_lba(cmd); |
| 1646 | |
| 1647 | /* 2TB boundary case covered automatically with this */ |
| 1648 | blocks_done = e_ref_tag - (uint32_t)lba_s + 1; |
| 1649 | |
| 1650 | resid = scsi_bufflen(cmd) - (blocks_done * |
| 1651 | cmd->device->sector_size); |
| 1652 | |
| 1653 | scsi_set_resid(cmd, resid); |
| 1654 | cmd->result = DID_OK << 16; |
| 1655 | |
| 1656 | /* Update protection tag */ |
| 1657 | if (scsi_prot_sg_count(cmd)) { |
| 1658 | uint32_t i, j = 0, k = 0, num_ent; |
| 1659 | struct scatterlist *sg; |
| 1660 | struct sd_dif_tuple *spt; |
| 1661 | |
| 1662 | /* Patch the corresponding protection tags */ |
| 1663 | scsi_for_each_prot_sg(cmd, sg, |
| 1664 | scsi_prot_sg_count(cmd), i) { |
| 1665 | num_ent = sg_dma_len(sg) / 8; |
| 1666 | if (k + num_ent < blocks_done) { |
| 1667 | k += num_ent; |
| 1668 | continue; |
| 1669 | } |
| 1670 | j = blocks_done - k - 1; |
| 1671 | k = blocks_done; |
| 1672 | break; |
| 1673 | } |
| 1674 | |
| 1675 | if (k != blocks_done) { |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1676 | ql_log(ql_log_warn, vha, 0x302f, |
Randy Dunlap | 8ec9c7f | 2011-09-23 15:40:50 -0700 | [diff] [blame] | 1677 | "unexpected tag values tag:lba=%x:%llx)\n", |
| 1678 | e_ref_tag, (unsigned long long)lba_s); |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 1679 | return 1; |
| 1680 | } |
| 1681 | |
| 1682 | spt = page_address(sg_page(sg)) + sg->offset; |
| 1683 | spt += j; |
| 1684 | |
| 1685 | spt->app_tag = 0xffff; |
| 1686 | if (scsi_get_prot_type(cmd) == SCSI_PROT_DIF_TYPE3) |
| 1687 | spt->ref_tag = 0xffffffff; |
| 1688 | } |
| 1689 | |
| 1690 | return 0; |
| 1691 | } |
| 1692 | |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1693 | /* check guard */ |
| 1694 | if (e_guard != a_guard) { |
| 1695 | scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, |
| 1696 | 0x10, 0x1); |
| 1697 | set_driver_byte(cmd, DRIVER_SENSE); |
| 1698 | set_host_byte(cmd, DID_ABORT); |
| 1699 | cmd->result |= SAM_STAT_CHECK_CONDITION << 1; |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 1700 | return 1; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1701 | } |
| 1702 | |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 1703 | /* check ref tag */ |
| 1704 | if (e_ref_tag != a_ref_tag) { |
| 1705 | scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, |
| 1706 | 0x10, 0x3); |
| 1707 | set_driver_byte(cmd, DRIVER_SENSE); |
| 1708 | set_host_byte(cmd, DID_ABORT); |
| 1709 | cmd->result |= SAM_STAT_CHECK_CONDITION << 1; |
| 1710 | return 1; |
| 1711 | } |
| 1712 | |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1713 | /* check appl tag */ |
| 1714 | if (e_app_tag != a_app_tag) { |
| 1715 | scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST, |
| 1716 | 0x10, 0x2); |
| 1717 | set_driver_byte(cmd, DRIVER_SENSE); |
| 1718 | set_host_byte(cmd, DID_ABORT); |
| 1719 | cmd->result |= SAM_STAT_CHECK_CONDITION << 1; |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 1720 | return 1; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1721 | } |
| 1722 | |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 1723 | return 1; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1724 | } |
| 1725 | |
Saurav Kashyap | a9b6f72 | 2012-08-22 14:21:01 -0400 | [diff] [blame] | 1726 | static void |
| 1727 | qla25xx_process_bidir_status_iocb(scsi_qla_host_t *vha, void *pkt, |
| 1728 | struct req_que *req, uint32_t index) |
| 1729 | { |
| 1730 | struct qla_hw_data *ha = vha->hw; |
| 1731 | srb_t *sp; |
| 1732 | uint16_t comp_status; |
| 1733 | uint16_t scsi_status; |
| 1734 | uint16_t thread_id; |
| 1735 | uint32_t rval = EXT_STATUS_OK; |
| 1736 | struct fc_bsg_job *bsg_job = NULL; |
| 1737 | sts_entry_t *sts; |
| 1738 | struct sts_entry_24xx *sts24; |
| 1739 | sts = (sts_entry_t *) pkt; |
| 1740 | sts24 = (struct sts_entry_24xx *) pkt; |
| 1741 | |
| 1742 | /* Validate handle. */ |
| 1743 | if (index >= MAX_OUTSTANDING_COMMANDS) { |
| 1744 | ql_log(ql_log_warn, vha, 0x70af, |
| 1745 | "Invalid SCSI completion handle 0x%x.\n", index); |
| 1746 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 1747 | return; |
| 1748 | } |
| 1749 | |
| 1750 | sp = req->outstanding_cmds[index]; |
| 1751 | if (sp) { |
| 1752 | /* Free outstanding command slot. */ |
| 1753 | req->outstanding_cmds[index] = NULL; |
| 1754 | bsg_job = sp->u.bsg_job; |
| 1755 | } else { |
| 1756 | ql_log(ql_log_warn, vha, 0x70b0, |
| 1757 | "Req:%d: Invalid ISP SCSI completion handle(0x%x)\n", |
| 1758 | req->id, index); |
| 1759 | |
| 1760 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 1761 | return; |
| 1762 | } |
| 1763 | |
| 1764 | if (IS_FWI2_CAPABLE(ha)) { |
| 1765 | comp_status = le16_to_cpu(sts24->comp_status); |
| 1766 | scsi_status = le16_to_cpu(sts24->scsi_status) & SS_MASK; |
| 1767 | } else { |
| 1768 | comp_status = le16_to_cpu(sts->comp_status); |
| 1769 | scsi_status = le16_to_cpu(sts->scsi_status) & SS_MASK; |
| 1770 | } |
| 1771 | |
| 1772 | thread_id = bsg_job->request->rqst_data.h_vendor.vendor_cmd[1]; |
| 1773 | switch (comp_status) { |
| 1774 | case CS_COMPLETE: |
| 1775 | if (scsi_status == 0) { |
| 1776 | bsg_job->reply->reply_payload_rcv_len = |
| 1777 | bsg_job->reply_payload.payload_len; |
| 1778 | rval = EXT_STATUS_OK; |
| 1779 | } |
| 1780 | goto done; |
| 1781 | |
| 1782 | case CS_DATA_OVERRUN: |
| 1783 | ql_dbg(ql_dbg_user, vha, 0x70b1, |
| 1784 | "Command completed with date overrun thread_id=%d\n", |
| 1785 | thread_id); |
| 1786 | rval = EXT_STATUS_DATA_OVERRUN; |
| 1787 | break; |
| 1788 | |
| 1789 | case CS_DATA_UNDERRUN: |
| 1790 | ql_dbg(ql_dbg_user, vha, 0x70b2, |
| 1791 | "Command completed with date underrun thread_id=%d\n", |
| 1792 | thread_id); |
| 1793 | rval = EXT_STATUS_DATA_UNDERRUN; |
| 1794 | break; |
| 1795 | case CS_BIDIR_RD_OVERRUN: |
| 1796 | ql_dbg(ql_dbg_user, vha, 0x70b3, |
| 1797 | "Command completed with read data overrun thread_id=%d\n", |
| 1798 | thread_id); |
| 1799 | rval = EXT_STATUS_DATA_OVERRUN; |
| 1800 | break; |
| 1801 | |
| 1802 | case CS_BIDIR_RD_WR_OVERRUN: |
| 1803 | ql_dbg(ql_dbg_user, vha, 0x70b4, |
| 1804 | "Command completed with read and write data overrun " |
| 1805 | "thread_id=%d\n", thread_id); |
| 1806 | rval = EXT_STATUS_DATA_OVERRUN; |
| 1807 | break; |
| 1808 | |
| 1809 | case CS_BIDIR_RD_OVERRUN_WR_UNDERRUN: |
| 1810 | ql_dbg(ql_dbg_user, vha, 0x70b5, |
| 1811 | "Command completed with read data over and write data " |
| 1812 | "underrun thread_id=%d\n", thread_id); |
| 1813 | rval = EXT_STATUS_DATA_OVERRUN; |
| 1814 | break; |
| 1815 | |
| 1816 | case CS_BIDIR_RD_UNDERRUN: |
| 1817 | ql_dbg(ql_dbg_user, vha, 0x70b6, |
| 1818 | "Command completed with read data data underrun " |
| 1819 | "thread_id=%d\n", thread_id); |
| 1820 | rval = EXT_STATUS_DATA_UNDERRUN; |
| 1821 | break; |
| 1822 | |
| 1823 | case CS_BIDIR_RD_UNDERRUN_WR_OVERRUN: |
| 1824 | ql_dbg(ql_dbg_user, vha, 0x70b7, |
| 1825 | "Command completed with read data under and write data " |
| 1826 | "overrun thread_id=%d\n", thread_id); |
| 1827 | rval = EXT_STATUS_DATA_UNDERRUN; |
| 1828 | break; |
| 1829 | |
| 1830 | case CS_BIDIR_RD_WR_UNDERRUN: |
| 1831 | ql_dbg(ql_dbg_user, vha, 0x70b8, |
| 1832 | "Command completed with read and write data underrun " |
| 1833 | "thread_id=%d\n", thread_id); |
| 1834 | rval = EXT_STATUS_DATA_UNDERRUN; |
| 1835 | break; |
| 1836 | |
| 1837 | case CS_BIDIR_DMA: |
| 1838 | ql_dbg(ql_dbg_user, vha, 0x70b9, |
| 1839 | "Command completed with data DMA error thread_id=%d\n", |
| 1840 | thread_id); |
| 1841 | rval = EXT_STATUS_DMA_ERR; |
| 1842 | break; |
| 1843 | |
| 1844 | case CS_TIMEOUT: |
| 1845 | ql_dbg(ql_dbg_user, vha, 0x70ba, |
| 1846 | "Command completed with timeout thread_id=%d\n", |
| 1847 | thread_id); |
| 1848 | rval = EXT_STATUS_TIMEOUT; |
| 1849 | break; |
| 1850 | default: |
| 1851 | ql_dbg(ql_dbg_user, vha, 0x70bb, |
| 1852 | "Command completed with completion status=0x%x " |
| 1853 | "thread_id=%d\n", comp_status, thread_id); |
| 1854 | rval = EXT_STATUS_ERR; |
| 1855 | break; |
| 1856 | } |
| 1857 | bsg_job->reply->reply_payload_rcv_len = 0; |
| 1858 | |
| 1859 | done: |
| 1860 | /* Return the vendor specific reply to API */ |
| 1861 | bsg_job->reply->reply_data.vendor_reply.vendor_rsp[0] = rval; |
| 1862 | bsg_job->reply_len = sizeof(struct fc_bsg_reply); |
| 1863 | /* Always return DID_OK, bsg will send the vendor specific response |
| 1864 | * in this case only */ |
| 1865 | sp->done(vha, sp, (DID_OK << 6)); |
| 1866 | |
| 1867 | } |
| 1868 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1869 | /** |
| 1870 | * qla2x00_status_entry() - Process a Status IOCB entry. |
| 1871 | * @ha: SCSI driver HA context |
| 1872 | * @pkt: Entry pointer |
| 1873 | */ |
| 1874 | static void |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1875 | 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] | 1876 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1877 | srb_t *sp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1878 | fc_port_t *fcport; |
| 1879 | struct scsi_cmnd *cp; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1880 | sts_entry_t *sts; |
| 1881 | struct sts_entry_24xx *sts24; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1882 | uint16_t comp_status; |
| 1883 | uint16_t scsi_status; |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1884 | uint16_t ox_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1885 | uint8_t lscsi_status; |
| 1886 | int32_t resid; |
Andrew Vasquez | 5544213 | 2010-07-23 15:28:27 +0500 | [diff] [blame] | 1887 | uint32_t sense_len, par_sense_len, rsp_info_len, resid_len, |
| 1888 | fw_resid_len; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1889 | uint8_t *rsp_info, *sense_data; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1890 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1891 | uint32_t handle; |
| 1892 | uint16_t que; |
| 1893 | struct req_que *req; |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1894 | int logit = 1; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1895 | int res = 0; |
Saurav Kashyap | a9b6f72 | 2012-08-22 14:21:01 -0400 | [diff] [blame] | 1896 | uint16_t state_flags = 0; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1897 | |
| 1898 | sts = (sts_entry_t *) pkt; |
| 1899 | sts24 = (struct sts_entry_24xx *) pkt; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1900 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1901 | comp_status = le16_to_cpu(sts24->comp_status); |
| 1902 | scsi_status = le16_to_cpu(sts24->scsi_status) & SS_MASK; |
Saurav Kashyap | a9b6f72 | 2012-08-22 14:21:01 -0400 | [diff] [blame] | 1903 | state_flags = le16_to_cpu(sts24->state_flags); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1904 | } else { |
| 1905 | comp_status = le16_to_cpu(sts->comp_status); |
| 1906 | scsi_status = le16_to_cpu(sts->scsi_status) & SS_MASK; |
| 1907 | } |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1908 | handle = (uint32_t) LSW(sts->handle); |
| 1909 | que = MSW(sts->handle); |
| 1910 | req = ha->req_q_map[que]; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1911 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1912 | /* Validate handle. */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1913 | if (handle < MAX_OUTSTANDING_COMMANDS) { |
| 1914 | sp = req->outstanding_cmds[handle]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1915 | } else |
| 1916 | sp = NULL; |
| 1917 | |
| 1918 | if (sp == NULL) { |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1919 | ql_dbg(ql_dbg_io, vha, 0x3017, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1920 | "Invalid status handle (0x%x).\n", sts->handle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1921 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 1922 | if (IS_QLA82XX(ha)) |
| 1923 | set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags); |
| 1924 | else |
| 1925 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1926 | qla2xxx_wake_dpc(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1927 | return; |
| 1928 | } |
Saurav Kashyap | a9b6f72 | 2012-08-22 14:21:01 -0400 | [diff] [blame] | 1929 | |
| 1930 | if (unlikely((state_flags & BIT_1) && (sp->type == SRB_BIDI_CMD))) { |
| 1931 | qla25xx_process_bidir_status_iocb(vha, pkt, req, handle); |
| 1932 | return; |
| 1933 | } |
| 1934 | |
| 1935 | /* Fast path completion. */ |
| 1936 | if (comp_status == CS_COMPLETE && scsi_status == 0) { |
| 1937 | qla2x00_process_completed_request(vha, req, handle); |
| 1938 | |
| 1939 | return; |
| 1940 | } |
| 1941 | |
| 1942 | req->outstanding_cmds[handle] = NULL; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1943 | cp = GET_CMD_SP(sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1944 | if (cp == NULL) { |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1945 | ql_dbg(ql_dbg_io, vha, 0x3018, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1946 | "Command already returned (0x%x/%p).\n", |
| 1947 | sts->handle, sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1948 | |
| 1949 | return; |
| 1950 | } |
| 1951 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1952 | lscsi_status = scsi_status & STATUS_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1953 | |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1954 | fcport = sp->fcport; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1955 | |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1956 | ox_id = 0; |
Andrew Vasquez | 5544213 | 2010-07-23 15:28:27 +0500 | [diff] [blame] | 1957 | sense_len = par_sense_len = rsp_info_len = resid_len = |
| 1958 | fw_resid_len = 0; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1959 | if (IS_FWI2_CAPABLE(ha)) { |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 1960 | if (scsi_status & SS_SENSE_LEN_VALID) |
| 1961 | sense_len = le32_to_cpu(sts24->sense_len); |
| 1962 | if (scsi_status & SS_RESPONSE_INFO_LEN_VALID) |
| 1963 | rsp_info_len = le32_to_cpu(sts24->rsp_data_len); |
| 1964 | if (scsi_status & (SS_RESIDUAL_UNDER | SS_RESIDUAL_OVER)) |
| 1965 | resid_len = le32_to_cpu(sts24->rsp_residual_count); |
| 1966 | if (comp_status == CS_DATA_UNDERRUN) |
| 1967 | fw_resid_len = le32_to_cpu(sts24->residual_len); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1968 | rsp_info = sts24->data; |
| 1969 | sense_data = sts24->data; |
| 1970 | host_to_fcp_swap(sts24->data, sizeof(sts24->data)); |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1971 | ox_id = le16_to_cpu(sts24->ox_id); |
Andrew Vasquez | 5544213 | 2010-07-23 15:28:27 +0500 | [diff] [blame] | 1972 | par_sense_len = sizeof(sts24->data); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1973 | } else { |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 1974 | if (scsi_status & SS_SENSE_LEN_VALID) |
| 1975 | sense_len = le16_to_cpu(sts->req_sense_length); |
| 1976 | if (scsi_status & SS_RESPONSE_INFO_LEN_VALID) |
| 1977 | rsp_info_len = le16_to_cpu(sts->rsp_info_len); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1978 | resid_len = le32_to_cpu(sts->residual_length); |
| 1979 | rsp_info = sts->rsp_info; |
| 1980 | sense_data = sts->req_sense_data; |
Andrew Vasquez | 5544213 | 2010-07-23 15:28:27 +0500 | [diff] [blame] | 1981 | par_sense_len = sizeof(sts->req_sense_data); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1982 | } |
| 1983 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1984 | /* Check for any FCP transport errors. */ |
| 1985 | if (scsi_status & SS_RESPONSE_INFO_LEN_VALID) { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1986 | /* Sense data lies beyond any FCP RESPONSE data. */ |
Andrew Vasquez | 5544213 | 2010-07-23 15:28:27 +0500 | [diff] [blame] | 1987 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1988 | sense_data += rsp_info_len; |
Andrew Vasquez | 5544213 | 2010-07-23 15:28:27 +0500 | [diff] [blame] | 1989 | par_sense_len -= rsp_info_len; |
| 1990 | } |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 1991 | if (rsp_info_len > 3 && rsp_info[3]) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 1992 | ql_dbg(ql_dbg_io, fcport->vha, 0x3019, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1993 | "FCP I/O protocol failure (0x%x/0x%x).\n", |
| 1994 | rsp_info_len, rsp_info[3]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1995 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1996 | res = DID_BUS_BUSY << 16; |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 1997 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1998 | } |
| 1999 | } |
| 2000 | |
Andrew Vasquez | 3e8ce32 | 2008-02-28 14:06:10 -0800 | [diff] [blame] | 2001 | /* Check for overrun. */ |
| 2002 | if (IS_FWI2_CAPABLE(ha) && comp_status == CS_COMPLETE && |
| 2003 | scsi_status & SS_RESIDUAL_OVER) |
| 2004 | comp_status = CS_DATA_OVERRUN; |
| 2005 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2006 | /* |
| 2007 | * Based on Host and scsi status generate status code for Linux |
| 2008 | */ |
| 2009 | switch (comp_status) { |
| 2010 | case CS_COMPLETE: |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 2011 | case CS_QUEUE_FULL: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2012 | if (scsi_status == 0) { |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2013 | res = DID_OK << 16; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2014 | break; |
| 2015 | } |
| 2016 | if (scsi_status & (SS_RESIDUAL_UNDER | SS_RESIDUAL_OVER)) { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2017 | resid = resid_len; |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 2018 | scsi_set_resid(cp, resid); |
Andrew Vasquez | 0da69df | 2005-12-06 10:58:06 -0800 | [diff] [blame] | 2019 | |
| 2020 | if (!lscsi_status && |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 2021 | ((unsigned)(scsi_bufflen(cp) - resid) < |
Andrew Vasquez | 0da69df | 2005-12-06 10:58:06 -0800 | [diff] [blame] | 2022 | cp->underflow)) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 2023 | ql_dbg(ql_dbg_io, fcport->vha, 0x301a, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2024 | "Mid-layer underflow " |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 2025 | "detected (0x%x of 0x%x bytes).\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2026 | resid, scsi_bufflen(cp)); |
Andrew Vasquez | 0da69df | 2005-12-06 10:58:06 -0800 | [diff] [blame] | 2027 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2028 | res = DID_ERROR << 16; |
Andrew Vasquez | 0da69df | 2005-12-06 10:58:06 -0800 | [diff] [blame] | 2029 | break; |
| 2030 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2031 | } |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2032 | res = DID_OK << 16 | lscsi_status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2033 | |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 2034 | if (lscsi_status == SAM_STAT_TASK_SET_FULL) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 2035 | ql_dbg(ql_dbg_io, fcport->vha, 0x301b, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2036 | "QUEUE FULL detected.\n"); |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 2037 | break; |
| 2038 | } |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 2039 | logit = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2040 | if (lscsi_status != SS_CHECK_CONDITION) |
| 2041 | break; |
| 2042 | |
FUJITA Tomonori | b80ca4f | 2008-01-13 15:46:13 +0900 | [diff] [blame] | 2043 | memset(cp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2044 | if (!(scsi_status & SS_SENSE_LEN_VALID)) |
| 2045 | break; |
| 2046 | |
Andrew Vasquez | 5544213 | 2010-07-23 15:28:27 +0500 | [diff] [blame] | 2047 | qla2x00_handle_sense(sp, sense_data, par_sense_len, sense_len, |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2048 | rsp, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2049 | break; |
| 2050 | |
| 2051 | case CS_DATA_UNDERRUN: |
Ravi Anand | ed17c71b5 | 2006-05-17 15:08:55 -0700 | [diff] [blame] | 2052 | /* Use F/W calculated residual length. */ |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 2053 | resid = IS_FWI2_CAPABLE(ha) ? fw_resid_len : resid_len; |
| 2054 | scsi_set_resid(cp, resid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2055 | if (scsi_status & SS_RESIDUAL_UNDER) { |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 2056 | if (IS_FWI2_CAPABLE(ha) && fw_resid_len != resid_len) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 2057 | ql_dbg(ql_dbg_io, fcport->vha, 0x301d, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2058 | "Dropped frame(s) detected " |
| 2059 | "(0x%x of 0x%x bytes).\n", |
| 2060 | resid, scsi_bufflen(cp)); |
andrew.vasquez@qlogic.com | e038a1b | 2006-01-13 17:04:59 -0800 | [diff] [blame] | 2061 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2062 | res = DID_ERROR << 16 | lscsi_status; |
Arun Easi | 4e85e3d | 2011-11-18 09:02:10 -0800 | [diff] [blame] | 2063 | goto check_scsi_status; |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 2064 | } |
| 2065 | |
| 2066 | if (!lscsi_status && |
| 2067 | ((unsigned)(scsi_bufflen(cp) - resid) < |
| 2068 | cp->underflow)) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 2069 | ql_dbg(ql_dbg_io, fcport->vha, 0x301e, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2070 | "Mid-layer underflow " |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 2071 | "detected (0x%x of 0x%x bytes).\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2072 | resid, scsi_bufflen(cp)); |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 2073 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2074 | res = DID_ERROR << 16; |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 2075 | break; |
| 2076 | } |
Giridhar Malavali | 4aee576 | 2012-04-25 07:26:15 -0700 | [diff] [blame] | 2077 | } else if (lscsi_status != SAM_STAT_TASK_SET_FULL && |
| 2078 | lscsi_status != SAM_STAT_BUSY) { |
| 2079 | /* |
| 2080 | * scsi status of task set and busy are considered to be |
| 2081 | * task not completed. |
| 2082 | */ |
| 2083 | |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 2084 | ql_dbg(ql_dbg_io, fcport->vha, 0x301f, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2085 | "Dropped frame(s) detected (0x%x " |
Giridhar Malavali | 4aee576 | 2012-04-25 07:26:15 -0700 | [diff] [blame] | 2086 | "of 0x%x bytes).\n", resid, |
| 2087 | scsi_bufflen(cp)); |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 2088 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2089 | res = DID_ERROR << 16 | lscsi_status; |
Lalit Chandivade | 0374f55 | 2010-09-03 14:57:04 -0700 | [diff] [blame] | 2090 | goto check_scsi_status; |
Giridhar Malavali | 4aee576 | 2012-04-25 07:26:15 -0700 | [diff] [blame] | 2091 | } else { |
| 2092 | ql_dbg(ql_dbg_io, fcport->vha, 0x3030, |
| 2093 | "scsi_status: 0x%x, lscsi_status: 0x%x\n", |
| 2094 | scsi_status, lscsi_status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2095 | } |
| 2096 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2097 | res = DID_OK << 16 | lscsi_status; |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 2098 | logit = 0; |
Lalit Chandivade | 0f00a20 | 2009-10-13 15:16:52 -0700 | [diff] [blame] | 2099 | |
Lalit Chandivade | 0374f55 | 2010-09-03 14:57:04 -0700 | [diff] [blame] | 2100 | check_scsi_status: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2101 | /* |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2102 | * 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] | 2103 | * Status. |
| 2104 | */ |
| 2105 | if (lscsi_status != 0) { |
Andrew Vasquez | ffec28a | 2007-01-29 10:22:27 -0800 | [diff] [blame] | 2106 | if (lscsi_status == SAM_STAT_TASK_SET_FULL) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 2107 | ql_dbg(ql_dbg_io, fcport->vha, 0x3020, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2108 | "QUEUE FULL detected.\n"); |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 2109 | logit = 1; |
Andrew Vasquez | ffec28a | 2007-01-29 10:22:27 -0800 | [diff] [blame] | 2110 | break; |
| 2111 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2112 | if (lscsi_status != SS_CHECK_CONDITION) |
| 2113 | break; |
| 2114 | |
FUJITA Tomonori | b80ca4f | 2008-01-13 15:46:13 +0900 | [diff] [blame] | 2115 | memset(cp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2116 | if (!(scsi_status & SS_SENSE_LEN_VALID)) |
| 2117 | break; |
| 2118 | |
Andrew Vasquez | 5544213 | 2010-07-23 15:28:27 +0500 | [diff] [blame] | 2119 | qla2x00_handle_sense(sp, sense_data, par_sense_len, |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2120 | sense_len, rsp, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2121 | } |
| 2122 | break; |
| 2123 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2124 | case CS_PORT_LOGGED_OUT: |
| 2125 | case CS_PORT_CONFIG_CHG: |
| 2126 | case CS_PORT_BUSY: |
| 2127 | case CS_INCOMPLETE: |
| 2128 | case CS_PORT_UNAVAILABLE: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2129 | case CS_TIMEOUT: |
Chad Dupuis | ff454b0 | 2010-10-15 11:27:42 -0700 | [diff] [blame] | 2130 | case CS_RESET: |
| 2131 | |
Mike Christie | 056a448 | 2008-08-19 18:45:29 -0500 | [diff] [blame] | 2132 | /* |
| 2133 | * We are going to have the fc class block the rport |
| 2134 | * while we try to recover so instruct the mid layer |
| 2135 | * to requeue until the class decides how to handle this. |
| 2136 | */ |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2137 | res = DID_TRANSPORT_DISRUPTED << 16; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2138 | |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 2139 | if (comp_status == CS_TIMEOUT) { |
| 2140 | if (IS_FWI2_CAPABLE(ha)) |
| 2141 | break; |
| 2142 | else if ((le16_to_cpu(sts->status_flags) & |
| 2143 | SF_LOGOUT_SENT) == 0) |
| 2144 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2145 | } |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2146 | |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 2147 | ql_dbg(ql_dbg_io, fcport->vha, 0x3021, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2148 | "Port down status: port-state=0x%x.\n", |
| 2149 | atomic_read(&fcport->state)); |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 2150 | |
| 2151 | if (atomic_read(&fcport->state) == FCS_ONLINE) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2152 | qla2x00_mark_device_lost(fcport->vha, fcport, 1, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2153 | break; |
| 2154 | |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 2155 | case CS_ABORTED: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2156 | res = DID_RESET << 16; |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 2157 | break; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2158 | |
| 2159 | case CS_DIF_ERROR: |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 2160 | logit = qla2x00_handle_dif_error(sp, sts24); |
Arun Easi | fb6e466 | 2012-08-22 14:21:32 -0400 | [diff] [blame] | 2161 | res = cp->result; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2162 | break; |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 2163 | |
| 2164 | case CS_TRANSPORT: |
| 2165 | res = DID_ERROR << 16; |
| 2166 | |
| 2167 | if (!IS_PI_SPLIT_DET_CAPABLE(ha)) |
| 2168 | break; |
| 2169 | |
| 2170 | if (state_flags & BIT_4) |
| 2171 | scmd_printk(KERN_WARNING, cp, |
| 2172 | "Unsupported device '%s' found.\n", |
| 2173 | cp->device->vendor); |
| 2174 | break; |
| 2175 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2176 | default: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2177 | res = DID_ERROR << 16; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2178 | break; |
| 2179 | } |
| 2180 | |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 2181 | out: |
| 2182 | if (logit) |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 2183 | ql_dbg(ql_dbg_io, fcport->vha, 0x3022, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2184 | "FCP command status: 0x%x-0x%x (0x%x) " |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 2185 | "nexus=%ld:%d:%d portid=%02x%02x%02x oxid=0x%x " |
| 2186 | "cdb=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x len=0x%x " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2187 | "rsp_info=0x%x resid=0x%x fw_resid=0x%x.\n", |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2188 | comp_status, scsi_status, res, vha->host_no, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 2189 | cp->device->id, cp->device->lun, fcport->d_id.b.domain, |
| 2190 | fcport->d_id.b.area, fcport->d_id.b.al_pa, ox_id, |
| 2191 | cp->cmnd[0], cp->cmnd[1], cp->cmnd[2], cp->cmnd[3], |
| 2192 | cp->cmnd[4], cp->cmnd[5], cp->cmnd[6], cp->cmnd[7], |
| 2193 | cp->cmnd[8], cp->cmnd[9], scsi_bufflen(cp), rsp_info_len, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2194 | resid_len, fw_resid_len); |
Andrew Vasquez | b7d2280 | 2010-05-04 15:01:27 -0700 | [diff] [blame] | 2195 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2196 | if (rsp->status_srb == NULL) |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2197 | sp->done(ha, sp, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2198 | } |
| 2199 | |
| 2200 | /** |
| 2201 | * qla2x00_status_cont_entry() - Process a Status Continuations entry. |
| 2202 | * @ha: SCSI driver HA context |
| 2203 | * @pkt: Entry pointer |
| 2204 | * |
| 2205 | * Extended sense data. |
| 2206 | */ |
| 2207 | static void |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2208 | 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] | 2209 | { |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2210 | uint8_t sense_sz = 0; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2211 | struct qla_hw_data *ha = rsp->hw; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2212 | struct scsi_qla_host *vha = pci_get_drvdata(ha->pdev); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2213 | srb_t *sp = rsp->status_srb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2214 | struct scsi_cmnd *cp; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2215 | uint32_t sense_len; |
| 2216 | uint8_t *sense_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2217 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2218 | if (!sp || !GET_CMD_SENSE_LEN(sp)) |
| 2219 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2220 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2221 | sense_len = GET_CMD_SENSE_LEN(sp); |
| 2222 | sense_ptr = GET_CMD_SENSE_PTR(sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2223 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2224 | cp = GET_CMD_SP(sp); |
| 2225 | if (cp == NULL) { |
| 2226 | ql_log(ql_log_warn, vha, 0x3025, |
| 2227 | "cmd is NULL: already returned to OS (sp=%p).\n", sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2228 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2229 | rsp->status_srb = NULL; |
| 2230 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2231 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2232 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2233 | if (sense_len > sizeof(pkt->data)) |
| 2234 | sense_sz = sizeof(pkt->data); |
| 2235 | else |
| 2236 | sense_sz = sense_len; |
Giridhar Malavali | c463119 | 2011-11-18 09:03:08 -0800 | [diff] [blame] | 2237 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2238 | /* Move sense data. */ |
| 2239 | if (IS_FWI2_CAPABLE(ha)) |
| 2240 | host_to_fcp_swap(pkt->data, sizeof(pkt->data)); |
| 2241 | memcpy(sense_ptr, pkt->data, sense_sz); |
| 2242 | ql_dump_buffer(ql_dbg_io + ql_dbg_buffer, vha, 0x302c, |
| 2243 | sense_ptr, sense_sz); |
Giridhar Malavali | c463119 | 2011-11-18 09:03:08 -0800 | [diff] [blame] | 2244 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2245 | sense_len -= sense_sz; |
| 2246 | sense_ptr += sense_sz; |
Giridhar Malavali | c463119 | 2011-11-18 09:03:08 -0800 | [diff] [blame] | 2247 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2248 | SET_CMD_SENSE_PTR(sp, sense_ptr); |
| 2249 | SET_CMD_SENSE_LEN(sp, sense_len); |
Giridhar Malavali | c463119 | 2011-11-18 09:03:08 -0800 | [diff] [blame] | 2250 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2251 | /* Place command on done queue. */ |
| 2252 | if (sense_len == 0) { |
| 2253 | rsp->status_srb = NULL; |
| 2254 | sp->done(ha, sp, cp->result); |
Giridhar Malavali | c463119 | 2011-11-18 09:03:08 -0800 | [diff] [blame] | 2255 | } |
Giridhar Malavali | c463119 | 2011-11-18 09:03:08 -0800 | [diff] [blame] | 2256 | } |
| 2257 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2258 | /** |
| 2259 | * qla2x00_error_entry() - Process an error entry. |
| 2260 | * @ha: SCSI driver HA context |
| 2261 | * @pkt: Entry pointer |
| 2262 | */ |
| 2263 | static void |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2264 | 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] | 2265 | { |
| 2266 | srb_t *sp; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2267 | struct qla_hw_data *ha = vha->hw; |
Giridhar Malavali | c463119 | 2011-11-18 09:03:08 -0800 | [diff] [blame] | 2268 | const char func[] = "ERROR-IOCB"; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2269 | uint16_t que = MSW(pkt->handle); |
Arun Easi | a6fe35c | 2012-02-09 11:16:01 -0800 | [diff] [blame] | 2270 | struct req_que *req = NULL; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2271 | int res = DID_ERROR << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2272 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2273 | ql_dbg(ql_dbg_async, vha, 0x502a, |
| 2274 | "type of error status in response: 0x%x\n", pkt->entry_status); |
| 2275 | |
Arun Easi | a6fe35c | 2012-02-09 11:16:01 -0800 | [diff] [blame] | 2276 | if (que >= ha->max_req_queues || !ha->req_q_map[que]) |
| 2277 | goto fatal; |
| 2278 | |
| 2279 | req = ha->req_q_map[que]; |
| 2280 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2281 | if (pkt->entry_status & RF_BUSY) |
| 2282 | res = DID_BUS_BUSY << 16; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2283 | |
Giridhar Malavali | c463119 | 2011-11-18 09:03:08 -0800 | [diff] [blame] | 2284 | sp = qla2x00_get_sp_from_handle(vha, func, req, pkt); |
Arun Easi | a6fe35c | 2012-02-09 11:16:01 -0800 | [diff] [blame] | 2285 | if (sp) { |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 2286 | sp->done(ha, sp, res); |
Arun Easi | a6fe35c | 2012-02-09 11:16:01 -0800 | [diff] [blame] | 2287 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2288 | } |
Arun Easi | a6fe35c | 2012-02-09 11:16:01 -0800 | [diff] [blame] | 2289 | fatal: |
| 2290 | ql_log(ql_log_warn, vha, 0x5030, |
| 2291 | "Error entry - invalid handle/queue.\n"); |
| 2292 | |
| 2293 | if (IS_QLA82XX(ha)) |
| 2294 | set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags); |
| 2295 | else |
| 2296 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 2297 | qla2xxx_wake_dpc(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2298 | } |
| 2299 | |
| 2300 | /** |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2301 | * qla24xx_mbx_completion() - Process mailbox command completions. |
| 2302 | * @ha: SCSI driver HA context |
| 2303 | * @mb0: Mailbox0 register |
| 2304 | */ |
| 2305 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2306 | qla24xx_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0) |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2307 | { |
| 2308 | uint16_t cnt; |
Andrew Vasquez | 4fa94f8 | 2011-11-18 09:03:09 -0800 | [diff] [blame] | 2309 | uint32_t mboxes; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2310 | uint16_t __iomem *wptr; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2311 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2312 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 2313 | |
Andrew Vasquez | 4fa94f8 | 2011-11-18 09:03:09 -0800 | [diff] [blame] | 2314 | /* Read all mbox registers? */ |
| 2315 | mboxes = (1 << ha->mbx_count) - 1; |
| 2316 | if (!ha->mcp) |
Masanari Iida | a720101 | 2012-11-21 02:40:42 -0500 | [diff] [blame] | 2317 | ql_dbg(ql_dbg_async, vha, 0x504e, "MBX pointer ERROR.\n"); |
Andrew Vasquez | 4fa94f8 | 2011-11-18 09:03:09 -0800 | [diff] [blame] | 2318 | else |
| 2319 | mboxes = ha->mcp->in_mb; |
| 2320 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2321 | /* Load return mailbox registers. */ |
| 2322 | ha->flags.mbox_int = 1; |
| 2323 | ha->mailbox_out[0] = mb0; |
Andrew Vasquez | 4fa94f8 | 2011-11-18 09:03:09 -0800 | [diff] [blame] | 2324 | mboxes >>= 1; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2325 | wptr = (uint16_t __iomem *)®->mailbox1; |
| 2326 | |
| 2327 | for (cnt = 1; cnt < ha->mbx_count; cnt++) { |
Andrew Vasquez | 4fa94f8 | 2011-11-18 09:03:09 -0800 | [diff] [blame] | 2328 | if (mboxes & BIT_0) |
| 2329 | ha->mailbox_out[cnt] = RD_REG_WORD(wptr); |
| 2330 | |
| 2331 | mboxes >>= 1; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2332 | wptr++; |
| 2333 | } |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2334 | } |
| 2335 | |
| 2336 | /** |
| 2337 | * qla24xx_process_response_queue() - Process response queue entries. |
| 2338 | * @ha: SCSI driver HA context |
| 2339 | */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2340 | void qla24xx_process_response_queue(struct scsi_qla_host *vha, |
| 2341 | struct rsp_que *rsp) |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2342 | { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2343 | struct sts_entry_24xx *pkt; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2344 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2345 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2346 | if (!vha->flags.online) |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2347 | return; |
| 2348 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2349 | while (rsp->ring_ptr->signature != RESPONSE_PROCESSED) { |
| 2350 | pkt = (struct sts_entry_24xx *)rsp->ring_ptr; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2351 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2352 | rsp->ring_index++; |
| 2353 | if (rsp->ring_index == rsp->length) { |
| 2354 | rsp->ring_index = 0; |
| 2355 | rsp->ring_ptr = rsp->ring; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2356 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2357 | rsp->ring_ptr++; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2358 | } |
| 2359 | |
| 2360 | if (pkt->entry_status != 0) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2361 | qla2x00_error_entry(vha, rsp, (sts_entry_t *) pkt); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2362 | |
| 2363 | (void)qlt_24xx_process_response_error(vha, pkt); |
| 2364 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2365 | ((response_t *)pkt)->signature = RESPONSE_PROCESSED; |
| 2366 | wmb(); |
| 2367 | continue; |
| 2368 | } |
| 2369 | |
| 2370 | switch (pkt->entry_type) { |
| 2371 | case STATUS_TYPE: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2372 | qla2x00_status_entry(vha, rsp, pkt); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2373 | break; |
| 2374 | case STATUS_CONT_TYPE: |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2375 | qla2x00_status_cont_entry(rsp, (sts_cont_entry_t *)pkt); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2376 | break; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2377 | case VP_RPT_ID_IOCB_TYPE: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2378 | qla24xx_report_id_acquisition(vha, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2379 | (struct vp_rpt_id_entry_24xx *)pkt); |
| 2380 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 2381 | case LOGINOUT_PORT_IOCB_TYPE: |
| 2382 | qla24xx_logio_entry(vha, rsp->req, |
| 2383 | (struct logio_entry_24xx *)pkt); |
| 2384 | break; |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 2385 | case TSK_MGMT_IOCB_TYPE: |
| 2386 | qla24xx_tm_iocb_entry(vha, rsp->req, |
| 2387 | (struct tsk_mgmt_entry *)pkt); |
| 2388 | break; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 2389 | case CT_IOCB_TYPE: |
| 2390 | qla24xx_els_ct_entry(vha, rsp->req, pkt, CT_IOCB_TYPE); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 2391 | break; |
| 2392 | case ELS_IOCB_TYPE: |
| 2393 | qla24xx_els_ct_entry(vha, rsp->req, pkt, ELS_IOCB_TYPE); |
| 2394 | break; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2395 | case ABTS_RECV_24XX: |
| 2396 | /* ensure that the ATIO queue is empty */ |
| 2397 | qlt_24xx_process_atio_queue(vha); |
| 2398 | case ABTS_RESP_24XX: |
| 2399 | case CTIO_TYPE7: |
| 2400 | case NOTIFY_ACK_TYPE: |
| 2401 | qlt_response_pkt_all_vps(vha, (response_t *)pkt); |
| 2402 | break; |
Saurav Kashyap | 5488329 | 2011-08-16 11:31:48 -0700 | [diff] [blame] | 2403 | case MARKER_TYPE: |
| 2404 | /* Do nothing in this case, this check is to prevent it |
| 2405 | * from falling into default case |
| 2406 | */ |
| 2407 | break; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2408 | default: |
| 2409 | /* Type Not Supported. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2410 | ql_dbg(ql_dbg_async, vha, 0x5042, |
| 2411 | "Received unknown response pkt type %x " |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2412 | "entry status=%x.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2413 | pkt->entry_type, pkt->entry_status); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2414 | break; |
| 2415 | } |
| 2416 | ((response_t *)pkt)->signature = RESPONSE_PROCESSED; |
| 2417 | wmb(); |
| 2418 | } |
| 2419 | |
| 2420 | /* Adjust ring index */ |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2421 | if (IS_QLA82XX(ha)) { |
| 2422 | struct device_reg_82xx __iomem *reg = &ha->iobase->isp82; |
| 2423 | WRT_REG_DWORD(®->rsp_q_out[0], rsp->ring_index); |
| 2424 | } else |
| 2425 | WRT_REG_DWORD(rsp->rsp_q_out, rsp->ring_index); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2426 | } |
| 2427 | |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 2428 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2429 | qla2xxx_check_risc_status(scsi_qla_host_t *vha) |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 2430 | { |
| 2431 | int rval; |
| 2432 | uint32_t cnt; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2433 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 2434 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 2435 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2436 | if (!IS_QLA25XX(ha) && !IS_QLA81XX(ha) && !IS_QLA83XX(ha)) |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 2437 | return; |
| 2438 | |
| 2439 | rval = QLA_SUCCESS; |
| 2440 | WRT_REG_DWORD(®->iobase_addr, 0x7C00); |
| 2441 | RD_REG_DWORD(®->iobase_addr); |
| 2442 | WRT_REG_DWORD(®->iobase_window, 0x0001); |
| 2443 | for (cnt = 10000; (RD_REG_DWORD(®->iobase_window) & BIT_0) == 0 && |
| 2444 | rval == QLA_SUCCESS; cnt--) { |
| 2445 | if (cnt) { |
| 2446 | WRT_REG_DWORD(®->iobase_window, 0x0001); |
| 2447 | udelay(10); |
| 2448 | } else |
| 2449 | rval = QLA_FUNCTION_TIMEOUT; |
| 2450 | } |
| 2451 | if (rval == QLA_SUCCESS) |
| 2452 | goto next_test; |
| 2453 | |
| 2454 | WRT_REG_DWORD(®->iobase_window, 0x0003); |
| 2455 | for (cnt = 100; (RD_REG_DWORD(®->iobase_window) & BIT_0) == 0 && |
| 2456 | rval == QLA_SUCCESS; cnt--) { |
| 2457 | if (cnt) { |
| 2458 | WRT_REG_DWORD(®->iobase_window, 0x0003); |
| 2459 | udelay(10); |
| 2460 | } else |
| 2461 | rval = QLA_FUNCTION_TIMEOUT; |
| 2462 | } |
| 2463 | if (rval != QLA_SUCCESS) |
| 2464 | goto done; |
| 2465 | |
| 2466 | next_test: |
| 2467 | if (RD_REG_DWORD(®->iobase_c8) & BIT_3) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2468 | ql_log(ql_log_info, vha, 0x504c, |
| 2469 | "Additional code -- 0x55AA.\n"); |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 2470 | |
| 2471 | done: |
| 2472 | WRT_REG_DWORD(®->iobase_window, 0x0000); |
| 2473 | RD_REG_DWORD(®->iobase_window); |
| 2474 | } |
| 2475 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2476 | /** |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2477 | * qla24xx_intr_handler() - Process interrupts for the ISP23xx and ISP24xx. |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2478 | * @irq: |
| 2479 | * @dev_id: SCSI driver HA context |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2480 | * |
| 2481 | * Called by system whenever the host adapter generates an interrupt. |
| 2482 | * |
| 2483 | * Returns handled flag. |
| 2484 | */ |
| 2485 | irqreturn_t |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 2486 | qla24xx_intr_handler(int irq, void *dev_id) |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2487 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2488 | scsi_qla_host_t *vha; |
| 2489 | struct qla_hw_data *ha; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2490 | struct device_reg_24xx __iomem *reg; |
| 2491 | int status; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2492 | unsigned long iter; |
| 2493 | uint32_t stat; |
| 2494 | uint32_t hccr; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2495 | uint16_t mb[8]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2496 | struct rsp_que *rsp; |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 2497 | unsigned long flags; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2498 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2499 | rsp = (struct rsp_que *) dev_id; |
| 2500 | if (!rsp) { |
Chad Dupuis | 3256b43 | 2012-02-09 11:15:47 -0800 | [diff] [blame] | 2501 | ql_log(ql_log_info, NULL, 0x5059, |
| 2502 | "%s: NULL response queue pointer.\n", __func__); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2503 | return IRQ_NONE; |
| 2504 | } |
| 2505 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2506 | ha = rsp->hw; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2507 | reg = &ha->iobase->isp24; |
| 2508 | status = 0; |
| 2509 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 2510 | if (unlikely(pci_channel_offline(ha->pdev))) |
| 2511 | return IRQ_HANDLED; |
| 2512 | |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 2513 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2514 | vha = pci_get_drvdata(ha->pdev); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2515 | for (iter = 50; iter--; ) { |
| 2516 | stat = RD_REG_DWORD(®->host_status); |
| 2517 | if (stat & HSRX_RISC_PAUSED) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 2518 | if (unlikely(pci_channel_offline(ha->pdev))) |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 2519 | break; |
| 2520 | |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2521 | hccr = RD_REG_DWORD(®->hccr); |
| 2522 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2523 | ql_log(ql_log_warn, vha, 0x504b, |
| 2524 | "RISC paused -- HCCR=%x, Dumping firmware.\n", |
| 2525 | hccr); |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 2526 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2527 | qla2xxx_check_risc_status(vha); |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 2528 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2529 | ha->isp_ops->fw_dump(vha, 1); |
| 2530 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2531 | break; |
| 2532 | } else if ((stat & HSRX_RISC_INT) == 0) |
| 2533 | break; |
| 2534 | |
| 2535 | switch (stat & 0xff) { |
Arun Easi | fafbda9 | 2012-08-22 14:21:16 -0400 | [diff] [blame] | 2536 | case INTR_ROM_MB_SUCCESS: |
| 2537 | case INTR_ROM_MB_FAILED: |
| 2538 | case INTR_MB_SUCCESS: |
| 2539 | case INTR_MB_FAILED: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2540 | qla24xx_mbx_completion(vha, MSW(stat)); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2541 | status |= MBX_INTERRUPT; |
| 2542 | |
| 2543 | break; |
Arun Easi | fafbda9 | 2012-08-22 14:21:16 -0400 | [diff] [blame] | 2544 | case INTR_ASYNC_EVENT: |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2545 | mb[0] = MSW(stat); |
| 2546 | mb[1] = RD_REG_WORD(®->mailbox1); |
| 2547 | mb[2] = RD_REG_WORD(®->mailbox2); |
| 2548 | mb[3] = RD_REG_WORD(®->mailbox3); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2549 | qla2x00_async_event(vha, rsp, mb); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2550 | break; |
Arun Easi | fafbda9 | 2012-08-22 14:21:16 -0400 | [diff] [blame] | 2551 | case INTR_RSP_QUE_UPDATE: |
| 2552 | case INTR_RSP_QUE_UPDATE_83XX: |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2553 | qla24xx_process_response_queue(vha, rsp); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2554 | break; |
Arun Easi | fafbda9 | 2012-08-22 14:21:16 -0400 | [diff] [blame] | 2555 | case INTR_ATIO_QUE_UPDATE: |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2556 | qlt_24xx_process_atio_queue(vha); |
| 2557 | break; |
Arun Easi | fafbda9 | 2012-08-22 14:21:16 -0400 | [diff] [blame] | 2558 | case INTR_ATIO_RSP_QUE_UPDATE: |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2559 | qlt_24xx_process_atio_queue(vha); |
| 2560 | qla24xx_process_response_queue(vha, rsp); |
| 2561 | break; |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2562 | default: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2563 | ql_dbg(ql_dbg_async, vha, 0x504f, |
| 2564 | "Unrecognized interrupt type (%d).\n", stat * 0xff); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2565 | break; |
| 2566 | } |
| 2567 | WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_INT); |
| 2568 | RD_REG_DWORD_RELAXED(®->hccr); |
Giridhar Malavali | cb860bb | 2012-08-22 14:21:30 -0400 | [diff] [blame] | 2569 | if (unlikely(IS_QLA83XX(ha) && (ha->pdev->revision == 1))) |
| 2570 | ndelay(3500); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2571 | } |
Anirban Chakraborty | 43fac4d | 2009-06-10 13:55:11 -0700 | [diff] [blame] | 2572 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2573 | |
| 2574 | if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) && |
| 2575 | (status & MBX_INTERRUPT) && ha->flags.mbox_int) { |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2576 | set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 2577 | complete(&ha->mbx_intr_comp); |
Andrew Vasquez | 9a853f7 | 2005-07-06 10:31:27 -0700 | [diff] [blame] | 2578 | } |
| 2579 | |
| 2580 | return IRQ_HANDLED; |
| 2581 | } |
| 2582 | |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2583 | static irqreturn_t |
| 2584 | qla24xx_msix_rsp_q(int irq, void *dev_id) |
| 2585 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2586 | struct qla_hw_data *ha; |
| 2587 | struct rsp_que *rsp; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2588 | struct device_reg_24xx __iomem *reg; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2589 | struct scsi_qla_host *vha; |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2590 | unsigned long flags; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2591 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2592 | rsp = (struct rsp_que *) dev_id; |
| 2593 | if (!rsp) { |
Chad Dupuis | 3256b43 | 2012-02-09 11:15:47 -0800 | [diff] [blame] | 2594 | ql_log(ql_log_info, NULL, 0x505a, |
| 2595 | "%s: NULL response queue pointer.\n", __func__); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2596 | return IRQ_NONE; |
| 2597 | } |
| 2598 | ha = rsp->hw; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2599 | reg = &ha->iobase->isp24; |
| 2600 | |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2601 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2602 | |
Anirban Chakraborty | a67093d | 2010-02-04 14:17:59 -0800 | [diff] [blame] | 2603 | vha = pci_get_drvdata(ha->pdev); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2604 | qla24xx_process_response_queue(vha, rsp); |
Anirban Chakraborty | 3155754 | 2009-12-02 10:36:55 -0800 | [diff] [blame] | 2605 | if (!ha->flags.disable_msix_handshake) { |
Anirban Chakraborty | eb94114 | 2009-08-04 16:12:13 -0700 | [diff] [blame] | 2606 | WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_INT); |
| 2607 | RD_REG_DWORD_RELAXED(®->hccr); |
| 2608 | } |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2609 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2610 | |
| 2611 | return IRQ_HANDLED; |
| 2612 | } |
| 2613 | |
| 2614 | static irqreturn_t |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2615 | qla25xx_msix_rsp_q(int irq, void *dev_id) |
| 2616 | { |
| 2617 | struct qla_hw_data *ha; |
| 2618 | struct rsp_que *rsp; |
Anirban Chakraborty | 3155754 | 2009-12-02 10:36:55 -0800 | [diff] [blame] | 2619 | struct device_reg_24xx __iomem *reg; |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2620 | unsigned long flags; |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2621 | |
| 2622 | rsp = (struct rsp_que *) dev_id; |
| 2623 | if (!rsp) { |
Chad Dupuis | 3256b43 | 2012-02-09 11:15:47 -0800 | [diff] [blame] | 2624 | ql_log(ql_log_info, NULL, 0x505b, |
| 2625 | "%s: NULL response queue pointer.\n", __func__); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2626 | return IRQ_NONE; |
| 2627 | } |
| 2628 | ha = rsp->hw; |
| 2629 | |
Anirban Chakraborty | 3155754 | 2009-12-02 10:36:55 -0800 | [diff] [blame] | 2630 | /* Clear the interrupt, if enabled, for this response queue */ |
Andrew Vasquez | d424754 | 2011-10-26 14:20:13 -0700 | [diff] [blame] | 2631 | if (!ha->flags.disable_msix_handshake) { |
Anirban Chakraborty | 3155754 | 2009-12-02 10:36:55 -0800 | [diff] [blame] | 2632 | reg = &ha->iobase->isp24; |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2633 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 3155754 | 2009-12-02 10:36:55 -0800 | [diff] [blame] | 2634 | WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_INT); |
| 2635 | RD_REG_DWORD_RELAXED(®->hccr); |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2636 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Anirban Chakraborty | 3155754 | 2009-12-02 10:36:55 -0800 | [diff] [blame] | 2637 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2638 | queue_work_on((int) (rsp->id - 1), ha->wq, &rsp->q_work); |
| 2639 | |
| 2640 | return IRQ_HANDLED; |
| 2641 | } |
| 2642 | |
| 2643 | static irqreturn_t |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2644 | qla24xx_msix_default(int irq, void *dev_id) |
| 2645 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2646 | scsi_qla_host_t *vha; |
| 2647 | struct qla_hw_data *ha; |
| 2648 | struct rsp_que *rsp; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2649 | struct device_reg_24xx __iomem *reg; |
| 2650 | int status; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2651 | uint32_t stat; |
| 2652 | uint32_t hccr; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2653 | uint16_t mb[8]; |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2654 | unsigned long flags; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2655 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2656 | rsp = (struct rsp_que *) dev_id; |
| 2657 | if (!rsp) { |
Chad Dupuis | 3256b43 | 2012-02-09 11:15:47 -0800 | [diff] [blame] | 2658 | ql_log(ql_log_info, NULL, 0x505c, |
| 2659 | "%s: NULL response queue pointer.\n", __func__); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2660 | return IRQ_NONE; |
| 2661 | } |
| 2662 | ha = rsp->hw; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2663 | reg = &ha->iobase->isp24; |
| 2664 | status = 0; |
| 2665 | |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2666 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2667 | vha = pci_get_drvdata(ha->pdev); |
Andrew Vasquez | 87f2701 | 2007-09-20 14:07:49 -0700 | [diff] [blame] | 2668 | do { |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2669 | stat = RD_REG_DWORD(®->host_status); |
| 2670 | if (stat & HSRX_RISC_PAUSED) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 2671 | if (unlikely(pci_channel_offline(ha->pdev))) |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 2672 | break; |
| 2673 | |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2674 | hccr = RD_REG_DWORD(®->hccr); |
| 2675 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2676 | ql_log(ql_log_info, vha, 0x5050, |
| 2677 | "RISC paused -- HCCR=%x, Dumping firmware.\n", |
| 2678 | hccr); |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 2679 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2680 | qla2xxx_check_risc_status(vha); |
Andrew Vasquez | 05236a0 | 2007-09-20 14:07:37 -0700 | [diff] [blame] | 2681 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2682 | ha->isp_ops->fw_dump(vha, 1); |
| 2683 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2684 | break; |
| 2685 | } else if ((stat & HSRX_RISC_INT) == 0) |
| 2686 | break; |
| 2687 | |
| 2688 | switch (stat & 0xff) { |
Arun Easi | fafbda9 | 2012-08-22 14:21:16 -0400 | [diff] [blame] | 2689 | case INTR_ROM_MB_SUCCESS: |
| 2690 | case INTR_ROM_MB_FAILED: |
| 2691 | case INTR_MB_SUCCESS: |
| 2692 | case INTR_MB_FAILED: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2693 | qla24xx_mbx_completion(vha, MSW(stat)); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2694 | status |= MBX_INTERRUPT; |
| 2695 | |
| 2696 | break; |
Arun Easi | fafbda9 | 2012-08-22 14:21:16 -0400 | [diff] [blame] | 2697 | case INTR_ASYNC_EVENT: |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2698 | mb[0] = MSW(stat); |
| 2699 | mb[1] = RD_REG_WORD(®->mailbox1); |
| 2700 | mb[2] = RD_REG_WORD(®->mailbox2); |
| 2701 | mb[3] = RD_REG_WORD(®->mailbox3); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2702 | qla2x00_async_event(vha, rsp, mb); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2703 | break; |
Arun Easi | fafbda9 | 2012-08-22 14:21:16 -0400 | [diff] [blame] | 2704 | case INTR_RSP_QUE_UPDATE: |
| 2705 | case INTR_RSP_QUE_UPDATE_83XX: |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2706 | qla24xx_process_response_queue(vha, rsp); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2707 | break; |
Arun Easi | fafbda9 | 2012-08-22 14:21:16 -0400 | [diff] [blame] | 2708 | case INTR_ATIO_QUE_UPDATE: |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2709 | qlt_24xx_process_atio_queue(vha); |
| 2710 | break; |
Arun Easi | fafbda9 | 2012-08-22 14:21:16 -0400 | [diff] [blame] | 2711 | case INTR_ATIO_RSP_QUE_UPDATE: |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2712 | qlt_24xx_process_atio_queue(vha); |
| 2713 | qla24xx_process_response_queue(vha, rsp); |
| 2714 | break; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2715 | default: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2716 | ql_dbg(ql_dbg_async, vha, 0x5051, |
| 2717 | "Unrecognized interrupt type (%d).\n", stat & 0xff); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2718 | break; |
| 2719 | } |
| 2720 | WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_INT); |
Andrew Vasquez | 87f2701 | 2007-09-20 14:07:49 -0700 | [diff] [blame] | 2721 | } while (0); |
Xiaotian Feng | 0f19bc6 | 2010-01-29 18:09:30 +0800 | [diff] [blame] | 2722 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2723 | |
| 2724 | if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) && |
| 2725 | (status & MBX_INTERRUPT) && ha->flags.mbox_int) { |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2726 | set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 2727 | complete(&ha->mbx_intr_comp); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2728 | } |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2729 | return IRQ_HANDLED; |
| 2730 | } |
| 2731 | |
| 2732 | /* Interrupt handling helpers. */ |
| 2733 | |
| 2734 | struct qla_init_msix_entry { |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2735 | const char *name; |
Jeff Garzik | 476834c | 2007-05-23 14:41:44 -0700 | [diff] [blame] | 2736 | irq_handler_t handler; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2737 | }; |
| 2738 | |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2739 | static struct qla_init_msix_entry msix_entries[3] = { |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2740 | { "qla2xxx (default)", qla24xx_msix_default }, |
| 2741 | { "qla2xxx (rsp_q)", qla24xx_msix_rsp_q }, |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2742 | { "qla2xxx (multiq)", qla25xx_msix_rsp_q }, |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2743 | }; |
| 2744 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2745 | static struct qla_init_msix_entry qla82xx_msix_entries[2] = { |
| 2746 | { "qla2xxx (default)", qla82xx_msix_default }, |
| 2747 | { "qla2xxx (rsp_q)", qla82xx_msix_rsp_q }, |
| 2748 | }; |
| 2749 | |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2750 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2751 | qla24xx_disable_msix(struct qla_hw_data *ha) |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2752 | { |
| 2753 | int i; |
| 2754 | struct qla_msix_entry *qentry; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2755 | scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2756 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2757 | for (i = 0; i < ha->msix_count; i++) { |
| 2758 | qentry = &ha->msix_entries[i]; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2759 | if (qentry->have_irq) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2760 | free_irq(qentry->vector, qentry->rsp); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2761 | } |
| 2762 | pci_disable_msix(ha->pdev); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2763 | kfree(ha->msix_entries); |
| 2764 | ha->msix_entries = NULL; |
| 2765 | ha->flags.msix_enabled = 0; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2766 | ql_dbg(ql_dbg_init, vha, 0x0042, |
| 2767 | "Disabled the MSI.\n"); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2768 | } |
| 2769 | |
| 2770 | static int |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2771 | qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp) |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2772 | { |
Lalit Chandivade | ad038fa | 2009-01-22 09:45:33 -0800 | [diff] [blame] | 2773 | #define MIN_MSIX_COUNT 2 |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2774 | int i, ret; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2775 | struct msix_entry *entries; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2776 | struct qla_msix_entry *qentry; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2777 | scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2778 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2779 | entries = kzalloc(sizeof(struct msix_entry) * ha->msix_count, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2780 | GFP_KERNEL); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2781 | if (!entries) { |
| 2782 | ql_log(ql_log_warn, vha, 0x00bc, |
| 2783 | "Failed to allocate memory for msix_entry.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2784 | return -ENOMEM; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2785 | } |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2786 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2787 | for (i = 0; i < ha->msix_count; i++) |
| 2788 | entries[i].entry = i; |
| 2789 | |
| 2790 | ret = pci_enable_msix(ha->pdev, entries, ha->msix_count); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2791 | if (ret) { |
Lalit Chandivade | ad038fa | 2009-01-22 09:45:33 -0800 | [diff] [blame] | 2792 | if (ret < MIN_MSIX_COUNT) |
| 2793 | goto msix_failed; |
| 2794 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2795 | ql_log(ql_log_warn, vha, 0x00c6, |
| 2796 | "MSI-X: Failed to enable support " |
| 2797 | "-- %d/%d\n Retry with %d vectors.\n", |
| 2798 | ha->msix_count, ret, ret); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2799 | ha->msix_count = ret; |
| 2800 | ret = pci_enable_msix(ha->pdev, entries, ha->msix_count); |
| 2801 | if (ret) { |
Lalit Chandivade | ad038fa | 2009-01-22 09:45:33 -0800 | [diff] [blame] | 2802 | msix_failed: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2803 | ql_log(ql_log_fatal, vha, 0x00c7, |
| 2804 | "MSI-X: Failed to enable support, " |
| 2805 | "giving up -- %d/%d.\n", |
| 2806 | ha->msix_count, ret); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2807 | goto msix_out; |
| 2808 | } |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2809 | ha->max_rsp_queues = ha->msix_count - 1; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2810 | } |
| 2811 | ha->msix_entries = kzalloc(sizeof(struct qla_msix_entry) * |
| 2812 | ha->msix_count, GFP_KERNEL); |
| 2813 | if (!ha->msix_entries) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2814 | ql_log(ql_log_fatal, vha, 0x00c8, |
| 2815 | "Failed to allocate memory for ha->msix_entries.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2816 | ret = -ENOMEM; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2817 | goto msix_out; |
| 2818 | } |
| 2819 | ha->flags.msix_enabled = 1; |
| 2820 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2821 | for (i = 0; i < ha->msix_count; i++) { |
| 2822 | qentry = &ha->msix_entries[i]; |
| 2823 | qentry->vector = entries[i].vector; |
| 2824 | qentry->entry = entries[i].entry; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2825 | qentry->have_irq = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2826 | qentry->rsp = NULL; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2827 | } |
| 2828 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2829 | /* Enable MSI-X vectors for the base queue */ |
| 2830 | for (i = 0; i < 2; i++) { |
| 2831 | qentry = &ha->msix_entries[i]; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2832 | if (IS_QLA82XX(ha)) { |
| 2833 | ret = request_irq(qentry->vector, |
| 2834 | qla82xx_msix_entries[i].handler, |
| 2835 | 0, qla82xx_msix_entries[i].name, rsp); |
| 2836 | } else { |
| 2837 | ret = request_irq(qentry->vector, |
| 2838 | msix_entries[i].handler, |
| 2839 | 0, msix_entries[i].name, rsp); |
| 2840 | } |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2841 | if (ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2842 | ql_log(ql_log_fatal, vha, 0x00cb, |
| 2843 | "MSI-X: unable to register handler -- %x/%d.\n", |
| 2844 | qentry->vector, ret); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2845 | qla24xx_disable_msix(ha); |
| 2846 | ha->mqenable = 0; |
| 2847 | goto msix_out; |
| 2848 | } |
| 2849 | qentry->have_irq = 1; |
| 2850 | qentry->rsp = rsp; |
| 2851 | rsp->msix = qentry; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2852 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2853 | |
| 2854 | /* Enable MSI-X vector for response queue update for queue 0 */ |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2855 | if (IS_QLA83XX(ha)) { |
| 2856 | if (ha->msixbase && ha->mqiobase && |
| 2857 | (ha->max_rsp_queues > 1 || ha->max_req_queues > 1)) |
| 2858 | ha->mqenable = 1; |
| 2859 | } else |
| 2860 | if (ha->mqiobase |
| 2861 | && (ha->max_rsp_queues > 1 || ha->max_req_queues > 1)) |
| 2862 | ha->mqenable = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2863 | ql_dbg(ql_dbg_multiq, vha, 0xc005, |
| 2864 | "mqiobase=%p, max_rsp_queues=%d, max_req_queues=%d.\n", |
| 2865 | ha->mqiobase, ha->max_rsp_queues, ha->max_req_queues); |
| 2866 | ql_dbg(ql_dbg_init, vha, 0x0055, |
| 2867 | "mqiobase=%p, max_rsp_queues=%d, max_req_queues=%d.\n", |
| 2868 | ha->mqiobase, ha->max_rsp_queues, ha->max_req_queues); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2869 | |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2870 | msix_out: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2871 | kfree(entries); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2872 | return ret; |
| 2873 | } |
| 2874 | |
| 2875 | int |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2876 | qla2x00_request_irqs(struct qla_hw_data *ha, struct rsp_que *rsp) |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2877 | { |
| 2878 | int ret; |
Andrew Vasquez | 963b0fd | 2008-01-31 12:33:50 -0800 | [diff] [blame] | 2879 | device_reg_t __iomem *reg = ha->iobase; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2880 | scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2881 | |
| 2882 | /* If possible, enable MSI-X. */ |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2883 | if (!IS_QLA2432(ha) && !IS_QLA2532(ha) && !IS_QLA8432(ha) && |
| 2884 | !IS_CNA_CAPABLE(ha) && !IS_QLA2031(ha)) |
Ben Hutchings | 6377a7a | 2010-03-19 16:59:19 -0700 | [diff] [blame] | 2885 | goto skip_msi; |
| 2886 | |
| 2887 | if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_HP && |
| 2888 | (ha->pdev->subsystem_device == 0x7040 || |
| 2889 | ha->pdev->subsystem_device == 0x7041 || |
| 2890 | ha->pdev->subsystem_device == 0x1705)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2891 | ql_log(ql_log_warn, vha, 0x0034, |
| 2892 | "MSI-X: Unsupported ISP 2432 SSVID/SSDID (0x%X,0x%X).\n", |
Ben Hutchings | 6377a7a | 2010-03-19 16:59:19 -0700 | [diff] [blame] | 2893 | ha->pdev->subsystem_vendor, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2894 | ha->pdev->subsystem_device); |
Ben Hutchings | 6377a7a | 2010-03-19 16:59:19 -0700 | [diff] [blame] | 2895 | goto skip_msi; |
| 2896 | } |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2897 | |
Chad Dupuis | 42cd4f5 | 2011-08-16 11:29:24 -0700 | [diff] [blame] | 2898 | if (IS_QLA2432(ha) && (ha->pdev->revision < QLA_MSIX_CHIP_REV_24XX)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2899 | ql_log(ql_log_warn, vha, 0x0035, |
| 2900 | "MSI-X; Unsupported ISP2432 (0x%X, 0x%X).\n", |
Chad Dupuis | 42cd4f5 | 2011-08-16 11:29:24 -0700 | [diff] [blame] | 2901 | ha->pdev->revision, QLA_MSIX_CHIP_REV_24XX); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2902 | goto skip_msix; |
| 2903 | } |
| 2904 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2905 | ret = qla24xx_enable_msix(ha, rsp); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2906 | if (!ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2907 | ql_dbg(ql_dbg_init, vha, 0x0036, |
| 2908 | "MSI-X: Enabled (0x%X, 0x%X).\n", |
| 2909 | ha->chip_revision, ha->fw_attributes); |
Andrew Vasquez | 963b0fd | 2008-01-31 12:33:50 -0800 | [diff] [blame] | 2910 | goto clear_risc_ints; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2911 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2912 | ql_log(ql_log_info, vha, 0x0037, |
| 2913 | "MSI-X Falling back-to MSI mode -%d.\n", ret); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2914 | skip_msix: |
Andrew Vasquez | cbedb60 | 2007-05-07 07:43:02 -0700 | [diff] [blame] | 2915 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2916 | if (!IS_QLA24XX(ha) && !IS_QLA2532(ha) && !IS_QLA8432(ha) && |
Giridhar Malavali | 487370a | 2012-08-22 14:21:34 -0400 | [diff] [blame] | 2917 | !IS_QLA8001(ha) && !IS_QLA82XX(ha)) |
Andrew Vasquez | cbedb60 | 2007-05-07 07:43:02 -0700 | [diff] [blame] | 2918 | goto skip_msi; |
| 2919 | |
| 2920 | ret = pci_enable_msi(ha->pdev); |
| 2921 | if (!ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2922 | ql_dbg(ql_dbg_init, vha, 0x0038, |
| 2923 | "MSI: Enabled.\n"); |
Andrew Vasquez | cbedb60 | 2007-05-07 07:43:02 -0700 | [diff] [blame] | 2924 | ha->flags.msi_enabled = 1; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2925 | } else |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2926 | ql_log(ql_log_warn, vha, 0x0039, |
| 2927 | "MSI-X; Falling back-to INTa mode -- %d.\n", ret); |
Giridhar Malavali | a033b65 | 2012-08-22 14:21:07 -0400 | [diff] [blame] | 2928 | |
| 2929 | /* Skip INTx on ISP82xx. */ |
| 2930 | if (!ha->flags.msi_enabled && IS_QLA82XX(ha)) |
| 2931 | return QLA_FUNCTION_FAILED; |
| 2932 | |
Andrew Vasquez | cbedb60 | 2007-05-07 07:43:02 -0700 | [diff] [blame] | 2933 | skip_msi: |
| 2934 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2935 | ret = request_irq(ha->pdev->irq, ha->isp_ops->intr_handler, |
Mike Hernandez | 7992abf | 2010-11-23 16:52:47 -0800 | [diff] [blame] | 2936 | ha->flags.msi_enabled ? 0 : IRQF_SHARED, |
| 2937 | QLA2XXX_DRIVER_NAME, rsp); |
Andrew Vasquez | 963b0fd | 2008-01-31 12:33:50 -0800 | [diff] [blame] | 2938 | if (ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2939 | ql_log(ql_log_warn, vha, 0x003a, |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2940 | "Failed to reserve interrupt %d already in use.\n", |
| 2941 | ha->pdev->irq); |
Andrew Vasquez | 963b0fd | 2008-01-31 12:33:50 -0800 | [diff] [blame] | 2942 | goto fail; |
Saurav Kashyap | 68d91cb | 2012-11-21 02:40:44 -0500 | [diff] [blame^] | 2943 | } else if (!ha->flags.msi_enabled) |
| 2944 | ql_dbg(ql_dbg_init, vha, 0x0125, |
| 2945 | "INTa mode: Enabled.\n"); |
Mike Hernandez | 7992abf | 2010-11-23 16:52:47 -0800 | [diff] [blame] | 2946 | |
Andrew Vasquez | 963b0fd | 2008-01-31 12:33:50 -0800 | [diff] [blame] | 2947 | clear_risc_ints: |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2948 | |
Andrew Vasquez | c695248 | 2008-04-03 13:13:17 -0700 | [diff] [blame] | 2949 | spin_lock_irq(&ha->hardware_lock); |
Giridhar Malavali | c111495 | 2012-08-22 14:21:33 -0400 | [diff] [blame] | 2950 | if (!IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 963b0fd | 2008-01-31 12:33:50 -0800 | [diff] [blame] | 2951 | WRT_REG_WORD(®->isp.semaphore, 0); |
Andrew Vasquez | c695248 | 2008-04-03 13:13:17 -0700 | [diff] [blame] | 2952 | spin_unlock_irq(&ha->hardware_lock); |
Andrew Vasquez | 963b0fd | 2008-01-31 12:33:50 -0800 | [diff] [blame] | 2953 | |
| 2954 | fail: |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2955 | return ret; |
| 2956 | } |
| 2957 | |
| 2958 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2959 | qla2x00_free_irqs(scsi_qla_host_t *vha) |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2960 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2961 | struct qla_hw_data *ha = vha->hw; |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2962 | struct rsp_que *rsp; |
| 2963 | |
| 2964 | /* |
| 2965 | * We need to check that ha->rsp_q_map is valid in case we are called |
| 2966 | * from a probe failure context. |
| 2967 | */ |
| 2968 | if (!ha->rsp_q_map || !ha->rsp_q_map[0]) |
| 2969 | return; |
| 2970 | rsp = ha->rsp_q_map[0]; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2971 | |
| 2972 | if (ha->flags.msix_enabled) |
| 2973 | qla24xx_disable_msix(ha); |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 2974 | else if (ha->flags.msi_enabled) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2975 | free_irq(ha->pdev->irq, rsp); |
Andrew Vasquez | cbedb60 | 2007-05-07 07:43:02 -0700 | [diff] [blame] | 2976 | pci_disable_msi(ha->pdev); |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 2977 | } else |
| 2978 | free_irq(ha->pdev->irq, rsp); |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 2979 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2980 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2981 | |
| 2982 | int qla25xx_request_irq(struct rsp_que *rsp) |
| 2983 | { |
| 2984 | struct qla_hw_data *ha = rsp->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2985 | struct qla_init_msix_entry *intr = &msix_entries[2]; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2986 | struct qla_msix_entry *msix = rsp->msix; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2987 | scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2988 | int ret; |
| 2989 | |
| 2990 | ret = request_irq(msix->vector, intr->handler, 0, intr->name, rsp); |
| 2991 | if (ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2992 | ql_log(ql_log_fatal, vha, 0x00e6, |
| 2993 | "MSI-X: Unable to register handler -- %x/%d.\n", |
| 2994 | msix->vector, ret); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2995 | return ret; |
| 2996 | } |
| 2997 | msix->have_irq = 1; |
| 2998 | msix->rsp = rsp; |
| 2999 | return ret; |
| 3000 | } |