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