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