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