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