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