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