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