Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Andrew Vasquez | fa90c54 | 2005-10-27 11:10:08 -0700 | [diff] [blame] | 2 | * QLogic Fibre Channel HBA Driver |
Armen Baloyan | bd21eaf | 2014-04-11 16:54:24 -0400 | [diff] [blame] | 3 | * Copyright (c) 2003-2014 QLogic Corporation |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Andrew Vasquez | fa90c54 | 2005-10-27 11:10:08 -0700 | [diff] [blame] | 5 | * See LICENSE.qla2xxx for copyright and licensing details. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | */ |
| 7 | #include "qla_def.h" |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 8 | #include "qla_target.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | |
| 10 | #include <linux/delay.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 11 | #include <linux/gfp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 13 | static struct mb_cmd_name { |
| 14 | uint16_t cmd; |
| 15 | const char *str; |
| 16 | } mb_str[] = { |
| 17 | {MBC_GET_PORT_DATABASE, "GPDB"}, |
| 18 | {MBC_GET_ID_LIST, "GIDList"}, |
| 19 | {MBC_GET_LINK_PRIV_STATS, "Stats"}, |
Quinn Tran | 94d83e3 | 2017-12-28 12:33:23 -0800 | [diff] [blame] | 20 | {MBC_GET_RESOURCE_COUNTS, "ResCnt"}, |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 21 | }; |
| 22 | |
| 23 | static const char *mb_to_str(uint16_t cmd) |
| 24 | { |
| 25 | int i; |
| 26 | struct mb_cmd_name *e; |
| 27 | |
| 28 | for (i = 0; i < ARRAY_SIZE(mb_str); i++) { |
| 29 | e = mb_str + i; |
| 30 | if (cmd == e->cmd) |
| 31 | return e->str; |
| 32 | } |
| 33 | return "unknown"; |
| 34 | } |
| 35 | |
Bart Van Assche | ca82582 | 2017-01-17 09:34:14 -0800 | [diff] [blame] | 36 | static struct rom_cmd { |
himanshu.madhani@cavium.com | 77ddb94 | 2016-12-12 14:40:05 -0800 | [diff] [blame] | 37 | uint16_t cmd; |
| 38 | } rom_cmds[] = { |
| 39 | { MBC_LOAD_RAM }, |
| 40 | { MBC_EXECUTE_FIRMWARE }, |
| 41 | { MBC_READ_RAM_WORD }, |
| 42 | { MBC_MAILBOX_REGISTER_TEST }, |
| 43 | { MBC_VERIFY_CHECKSUM }, |
| 44 | { MBC_GET_FIRMWARE_VERSION }, |
| 45 | { MBC_LOAD_RISC_RAM }, |
| 46 | { MBC_DUMP_RISC_RAM }, |
| 47 | { MBC_LOAD_RISC_RAM_EXTENDED }, |
| 48 | { MBC_DUMP_RISC_RAM_EXTENDED }, |
| 49 | { MBC_WRITE_RAM_WORD_EXTENDED }, |
| 50 | { MBC_READ_RAM_EXTENDED }, |
| 51 | { MBC_GET_RESOURCE_COUNTS }, |
| 52 | { MBC_SET_FIRMWARE_OPTION }, |
| 53 | { MBC_MID_INITIALIZE_FIRMWARE }, |
| 54 | { MBC_GET_FIRMWARE_STATE }, |
| 55 | { MBC_GET_MEM_OFFLOAD_CNTRL_STAT }, |
| 56 | { MBC_GET_RETRY_COUNT }, |
| 57 | { MBC_TRACE_CONTROL }, |
Michael Hernandez | b7edfa2 | 2017-08-23 15:04:56 -0700 | [diff] [blame] | 58 | { MBC_INITIALIZE_MULTIQ }, |
Quinn Tran | 1608cc4 | 2017-08-23 15:05:03 -0700 | [diff] [blame] | 59 | { MBC_IOCB_COMMAND_A64 }, |
| 60 | { MBC_GET_ADAPTER_LOOP_ID }, |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 61 | { MBC_READ_SFP }, |
himanshu.madhani@cavium.com | 77ddb94 | 2016-12-12 14:40:05 -0800 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | static int is_rom_cmd(uint16_t cmd) |
| 65 | { |
| 66 | int i; |
| 67 | struct rom_cmd *wc; |
| 68 | |
| 69 | for (i = 0; i < ARRAY_SIZE(rom_cmds); i++) { |
| 70 | wc = rom_cmds + i; |
| 71 | if (wc->cmd == cmd) |
| 72 | return 1; |
| 73 | } |
| 74 | |
| 75 | return 0; |
| 76 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | |
| 78 | /* |
| 79 | * qla2x00_mailbox_command |
| 80 | * Issue mailbox command and waits for completion. |
| 81 | * |
| 82 | * Input: |
| 83 | * ha = adapter block pointer. |
| 84 | * mcp = driver internal mbx struct pointer. |
| 85 | * |
| 86 | * Output: |
| 87 | * mb[MAX_MAILBOX_REGISTER_COUNT] = returned mailbox data. |
| 88 | * |
| 89 | * Returns: |
| 90 | * 0 : QLA_SUCCESS = cmd performed success |
| 91 | * 1 : QLA_FUNCTION_FAILED (error encountered) |
| 92 | * 6 : QLA_FUNCTION_TIMEOUT (timeout condition encountered) |
| 93 | * |
| 94 | * Context: |
| 95 | * Kernel context. |
| 96 | */ |
| 97 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 98 | qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | { |
Himanshu Madhani | d14e72f | 2015-04-09 15:00:03 -0400 | [diff] [blame] | 100 | int rval, i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | unsigned long flags = 0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 102 | device_reg_t *reg; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 103 | uint8_t abort_active; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 104 | uint8_t io_lock_on; |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 105 | uint16_t command = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | uint16_t *iptr; |
| 107 | uint16_t __iomem *optr; |
| 108 | uint32_t cnt; |
| 109 | uint32_t mboxes; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | unsigned long wait_time; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 111 | struct qla_hw_data *ha = vha->hw; |
| 112 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 113 | |
Himanshu Madhani | d14e72f | 2015-04-09 15:00:03 -0400 | [diff] [blame] | 114 | |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 115 | ql_dbg(ql_dbg_mbx, vha, 0x1000, "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 116 | |
| 117 | if (ha->pdev->error_state > pci_channel_io_frozen) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 118 | ql_log(ql_log_warn, vha, 0x1001, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 119 | "error_state is greater than pci_channel_io_frozen, " |
| 120 | "exiting.\n"); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 121 | return QLA_FUNCTION_TIMEOUT; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 122 | } |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 123 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 124 | if (vha->device_flags & DFLG_DEV_FAILED) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 125 | ql_log(ql_log_warn, vha, 0x1002, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 126 | "Device in failed state, exiting.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 127 | return QLA_FUNCTION_TIMEOUT; |
| 128 | } |
| 129 | |
Bart Van Assche | c2a5d94 | 2017-01-11 15:58:58 -0800 | [diff] [blame] | 130 | /* if PCI error, then avoid mbx processing.*/ |
Sawan Chandak | ba17589 | 2017-06-02 09:11:58 -0700 | [diff] [blame] | 131 | if (test_bit(PFLG_DISCONNECTED, &base_vha->dpc_flags) && |
| 132 | test_bit(UNLOADING, &base_vha->dpc_flags)) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 133 | ql_log(ql_log_warn, vha, 0xd04e, |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 134 | "PCI error, exiting.\n"); |
| 135 | return QLA_FUNCTION_TIMEOUT; |
Bart Van Assche | c2a5d94 | 2017-01-11 15:58:58 -0800 | [diff] [blame] | 136 | } |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 137 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 138 | reg = ha->iobase; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 139 | io_lock_on = base_vha->flags.init_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | |
| 141 | rval = QLA_SUCCESS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 142 | abort_active = test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 144 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 145 | if (ha->flags.pci_channel_io_perm_failure) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 146 | ql_log(ql_log_warn, vha, 0x1003, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 147 | "Perm failure on EEH timeout MBX, exiting.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 148 | return QLA_FUNCTION_TIMEOUT; |
| 149 | } |
| 150 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 151 | if (IS_P3P_TYPE(ha) && ha->flags.isp82xx_fw_hung) { |
Giridhar Malavali | 862cd01 | 2011-02-23 15:27:11 -0800 | [diff] [blame] | 152 | /* Setting Link-Down error */ |
| 153 | mcp->mb[0] = MBS_LINK_DOWN_ERROR; |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 154 | ql_log(ql_log_warn, vha, 0x1004, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 155 | "FW hung = %d.\n", ha->flags.isp82xx_fw_hung); |
Andrew Vasquez | 1806fcd | 2011-11-18 09:02:15 -0800 | [diff] [blame] | 156 | return QLA_FUNCTION_TIMEOUT; |
Giridhar Malavali | 862cd01 | 2011-02-23 15:27:11 -0800 | [diff] [blame] | 157 | } |
| 158 | |
himanshu.madhani@cavium.com | 77ddb94 | 2016-12-12 14:40:05 -0800 | [diff] [blame] | 159 | /* check if ISP abort is active and return cmd with timeout */ |
| 160 | if ((test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 161 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 162 | test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) && |
| 163 | !is_rom_cmd(mcp->mb[0])) { |
| 164 | ql_log(ql_log_info, vha, 0x1005, |
| 165 | "Cmd 0x%x aborted with timeout since ISP Abort is pending\n", |
| 166 | mcp->mb[0]); |
| 167 | return QLA_FUNCTION_TIMEOUT; |
| 168 | } |
| 169 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | /* |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 171 | * Wait for active mailbox commands to finish by waiting at most tov |
| 172 | * seconds. This is to serialize actual issuing of mailbox cmds during |
| 173 | * non ISP abort time. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | */ |
Andrew Vasquez | 8eca3f3 | 2009-01-22 09:45:31 -0800 | [diff] [blame] | 175 | if (!wait_for_completion_timeout(&ha->mbx_cmd_comp, mcp->tov * HZ)) { |
| 176 | /* Timeout occurred. Return error. */ |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 177 | ql_log(ql_log_warn, vha, 0xd035, |
Chad Dupuis | d8c0d54 | 2012-02-09 11:15:46 -0800 | [diff] [blame] | 178 | "Cmd access timeout, cmd=0x%x, Exiting.\n", |
| 179 | mcp->mb[0]); |
Andrew Vasquez | 8eca3f3 | 2009-01-22 09:45:31 -0800 | [diff] [blame] | 180 | return QLA_FUNCTION_TIMEOUT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | ha->flags.mbox_busy = 1; |
| 184 | /* Save mailbox command for debug */ |
| 185 | ha->mcp = mcp; |
| 186 | |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 187 | ql_dbg(ql_dbg_mbx, vha, 0x1006, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 188 | "Prepare to issue mbox cmd=0x%x.\n", mcp->mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | |
| 190 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 191 | |
| 192 | /* Load mailbox registers. */ |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 193 | if (IS_P3P_TYPE(ha)) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 194 | optr = (uint16_t __iomem *)®->isp82.mailbox_in[0]; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 195 | else if (IS_FWI2_CAPABLE(ha) && !(IS_P3P_TYPE(ha))) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 196 | optr = (uint16_t __iomem *)®->isp24.mailbox0; |
| 197 | else |
| 198 | optr = (uint16_t __iomem *)MAILBOX_REG(ha, ®->isp, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | |
| 200 | iptr = mcp->mb; |
| 201 | command = mcp->mb[0]; |
| 202 | mboxes = mcp->out_mb; |
| 203 | |
Joe Carnuccio | 7b71162 | 2014-09-25 05:16:43 -0400 | [diff] [blame] | 204 | ql_dbg(ql_dbg_mbx, vha, 0x1111, |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 205 | "Mailbox registers (OUT):\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | for (cnt = 0; cnt < ha->mbx_count; cnt++) { |
| 207 | if (IS_QLA2200(ha) && cnt == 8) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 208 | optr = |
| 209 | (uint16_t __iomem *)MAILBOX_REG(ha, ®->isp, 8); |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 210 | if (mboxes & BIT_0) { |
| 211 | ql_dbg(ql_dbg_mbx, vha, 0x1112, |
| 212 | "mbox[%d]<-0x%04x\n", cnt, *iptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | WRT_REG_WORD(optr, *iptr); |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 214 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | |
| 216 | mboxes >>= 1; |
| 217 | optr++; |
| 218 | iptr++; |
| 219 | } |
| 220 | |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 221 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1117, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 222 | "I/O Address = %p.\n", optr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | |
| 224 | /* Issue set host interrupt command to send cmd out. */ |
| 225 | ha->flags.mbox_int = 0; |
| 226 | clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
| 227 | |
| 228 | /* Unlock mbx registers and wait for interrupt */ |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 229 | ql_dbg(ql_dbg_mbx, vha, 0x100f, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 230 | "Going to unlock irq & waiting for interrupts. " |
| 231 | "jiffies=%lx.\n", jiffies); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | |
| 233 | /* Wait for mbx cmd completion until timeout */ |
| 234 | |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 235 | if ((!abort_active && io_lock_on) || IS_NOPOLLING_TYPE(ha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | set_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); |
| 237 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 238 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 239 | if (RD_REG_DWORD(®->isp82.hint) & |
| 240 | HINT_MBX_INT_PENDING) { |
| 241 | spin_unlock_irqrestore(&ha->hardware_lock, |
| 242 | flags); |
Giridhar Malavali | 8937f2f | 2011-11-18 09:02:18 -0800 | [diff] [blame] | 243 | ha->flags.mbox_busy = 0; |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 244 | ql_dbg(ql_dbg_mbx, vha, 0x1010, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 245 | "Pending mailbox timeout, exiting.\n"); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 246 | rval = QLA_FUNCTION_TIMEOUT; |
| 247 | goto premature_exit; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 248 | } |
| 249 | WRT_REG_DWORD(®->isp82.hint, HINT_MBX_INT_PENDING); |
| 250 | } else if (IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 251 | WRT_REG_DWORD(®->isp24.hccr, HCCRX_SET_HOST_INT); |
| 252 | else |
| 253 | WRT_REG_WORD(®->isp.hccr, HCCR_SET_HOST_INT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 255 | |
himanshu.madhani@cavium.com | 77ddb94 | 2016-12-12 14:40:05 -0800 | [diff] [blame] | 256 | wait_time = jiffies; |
Giridhar Malavali | 754d124 | 2013-06-25 11:27:16 -0400 | [diff] [blame] | 257 | if (!wait_for_completion_timeout(&ha->mbx_intr_comp, |
| 258 | mcp->tov * HZ)) { |
| 259 | ql_dbg(ql_dbg_mbx, vha, 0x117a, |
| 260 | "cmd=%x Timeout.\n", command); |
| 261 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 262 | clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); |
| 263 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 264 | } |
himanshu.madhani@cavium.com | 77ddb94 | 2016-12-12 14:40:05 -0800 | [diff] [blame] | 265 | if (time_after(jiffies, wait_time + 5 * HZ)) |
| 266 | ql_log(ql_log_warn, vha, 0x1015, "cmd=0x%x, waited %d msecs\n", |
| 267 | command, jiffies_to_msecs(jiffies - wait_time)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | } else { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 269 | ql_dbg(ql_dbg_mbx, vha, 0x1011, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 270 | "Cmd=%x Polling Mode.\n", command); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 272 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 273 | if (RD_REG_DWORD(®->isp82.hint) & |
| 274 | HINT_MBX_INT_PENDING) { |
| 275 | spin_unlock_irqrestore(&ha->hardware_lock, |
| 276 | flags); |
Giridhar Malavali | 8937f2f | 2011-11-18 09:02:18 -0800 | [diff] [blame] | 277 | ha->flags.mbox_busy = 0; |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 278 | ql_dbg(ql_dbg_mbx, vha, 0x1012, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 279 | "Pending mailbox timeout, exiting.\n"); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 280 | rval = QLA_FUNCTION_TIMEOUT; |
| 281 | goto premature_exit; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 282 | } |
| 283 | WRT_REG_DWORD(®->isp82.hint, HINT_MBX_INT_PENDING); |
| 284 | } else if (IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 285 | WRT_REG_DWORD(®->isp24.hccr, HCCRX_SET_HOST_INT); |
| 286 | else |
| 287 | WRT_REG_WORD(®->isp.hccr, HCCR_SET_HOST_INT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | |
| 290 | wait_time = jiffies + mcp->tov * HZ; /* wait at most tov secs */ |
| 291 | while (!ha->flags.mbox_int) { |
| 292 | if (time_after(jiffies, wait_time)) |
| 293 | break; |
| 294 | |
| 295 | /* Check for pending interrupts. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 296 | qla2x00_poll(ha->rsp_q_map[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 298 | if (!ha->flags.mbox_int && |
| 299 | !(IS_QLA2200(ha) && |
| 300 | command == MBC_LOAD_RISC_RAM_EXTENDED)) |
andrew.vasquez@qlogic.com | 5998983 | 2006-01-13 17:05:10 -0800 | [diff] [blame] | 301 | msleep(10); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | } /* while */ |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 303 | ql_dbg(ql_dbg_mbx, vha, 0x1013, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 304 | "Waited %d sec.\n", |
| 305 | (uint)((jiffies - (wait_time - (mcp->tov * HZ)))/HZ)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | } |
| 307 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | /* Check whether we timed out */ |
| 309 | if (ha->flags.mbox_int) { |
| 310 | uint16_t *iptr2; |
| 311 | |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 312 | ql_dbg(ql_dbg_mbx, vha, 0x1014, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 313 | "Cmd=%x completed.\n", command); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | |
| 315 | /* Got interrupt. Clear the flag. */ |
| 316 | ha->flags.mbox_int = 0; |
| 317 | clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
| 318 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 319 | if (IS_P3P_TYPE(ha) && ha->flags.isp82xx_fw_hung) { |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 320 | ha->flags.mbox_busy = 0; |
| 321 | /* Setting Link-Down error */ |
| 322 | mcp->mb[0] = MBS_LINK_DOWN_ERROR; |
| 323 | ha->mcp = NULL; |
| 324 | rval = QLA_FUNCTION_FAILED; |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 325 | ql_log(ql_log_warn, vha, 0xd048, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 326 | "FW hung = %d.\n", ha->flags.isp82xx_fw_hung); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 327 | goto premature_exit; |
| 328 | } |
| 329 | |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 330 | if (ha->mailbox_out[0] != MBS_COMMAND_COMPLETE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | rval = QLA_FUNCTION_FAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | |
| 333 | /* Load return mailbox registers. */ |
| 334 | iptr2 = mcp->mb; |
| 335 | iptr = (uint16_t *)&ha->mailbox_out[0]; |
| 336 | mboxes = mcp->in_mb; |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 337 | |
| 338 | ql_dbg(ql_dbg_mbx, vha, 0x1113, |
| 339 | "Mailbox registers (IN):\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | for (cnt = 0; cnt < ha->mbx_count; cnt++) { |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 341 | if (mboxes & BIT_0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | *iptr2 = *iptr; |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 343 | ql_dbg(ql_dbg_mbx, vha, 0x1114, |
| 344 | "mbox[%d]->0x%04x\n", cnt, *iptr2); |
| 345 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | |
| 347 | mboxes >>= 1; |
| 348 | iptr2++; |
| 349 | iptr++; |
| 350 | } |
| 351 | } else { |
| 352 | |
Quinn Tran | 8d3c9c2 | 2016-12-23 18:06:09 -0800 | [diff] [blame] | 353 | uint16_t mb[8]; |
| 354 | uint32_t ictrl, host_status, hccr; |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 355 | uint16_t w; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 356 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 357 | if (IS_FWI2_CAPABLE(ha)) { |
Quinn Tran | 8d3c9c2 | 2016-12-23 18:06:09 -0800 | [diff] [blame] | 358 | mb[0] = RD_REG_WORD(®->isp24.mailbox0); |
| 359 | mb[1] = RD_REG_WORD(®->isp24.mailbox1); |
| 360 | mb[2] = RD_REG_WORD(®->isp24.mailbox2); |
| 361 | mb[3] = RD_REG_WORD(®->isp24.mailbox3); |
| 362 | mb[7] = RD_REG_WORD(®->isp24.mailbox7); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 363 | ictrl = RD_REG_DWORD(®->isp24.ictrl); |
Quinn Tran | 8d3c9c2 | 2016-12-23 18:06:09 -0800 | [diff] [blame] | 364 | host_status = RD_REG_DWORD(®->isp24.host_status); |
| 365 | hccr = RD_REG_DWORD(®->isp24.hccr); |
| 366 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 367 | ql_log(ql_log_warn, vha, 0xd04c, |
Quinn Tran | 8d3c9c2 | 2016-12-23 18:06:09 -0800 | [diff] [blame] | 368 | "MBX Command timeout for cmd %x, iocontrol=%x jiffies=%lx " |
| 369 | "mb[0-3]=[0x%x 0x%x 0x%x 0x%x] mb7 0x%x host_status 0x%x hccr 0x%x\n", |
| 370 | command, ictrl, jiffies, mb[0], mb[1], mb[2], mb[3], |
| 371 | mb[7], host_status, hccr); |
| 372 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 373 | } else { |
Quinn Tran | 8d3c9c2 | 2016-12-23 18:06:09 -0800 | [diff] [blame] | 374 | mb[0] = RD_MAILBOX_REG(ha, ®->isp, 0); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 375 | ictrl = RD_REG_WORD(®->isp.ictrl); |
Quinn Tran | 8d3c9c2 | 2016-12-23 18:06:09 -0800 | [diff] [blame] | 376 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1119, |
| 377 | "MBX Command timeout for cmd %x, iocontrol=%x jiffies=%lx " |
| 378 | "mb[0]=0x%x\n", command, ictrl, jiffies, mb[0]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 379 | } |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 380 | ql_dump_regs(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1019); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 382 | /* Capture FW dump only, if PCI device active */ |
| 383 | if (!pci_channel_offline(vha->hw->pdev)) { |
| 384 | pci_read_config_word(ha->pdev, PCI_VENDOR_ID, &w); |
| 385 | if (w == 0xffff || ictrl == 0xffffffff) { |
| 386 | /* This is special case if there is unload |
| 387 | * of driver happening and if PCI device go |
| 388 | * into bad state due to PCI error condition |
| 389 | * then only PCI ERR flag would be set. |
| 390 | * we will do premature exit for above case. |
| 391 | */ |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 392 | ha->flags.mbox_busy = 0; |
| 393 | rval = QLA_FUNCTION_TIMEOUT; |
| 394 | goto premature_exit; |
| 395 | } |
Chad Dupuis | f55bfc8 | 2012-02-09 11:15:53 -0800 | [diff] [blame] | 396 | |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 397 | /* Attempt to capture firmware dump for further |
| 398 | * anallysis of the current formware state. we do not |
| 399 | * need to do this if we are intentionally generating |
| 400 | * a dump |
| 401 | */ |
| 402 | if (mcp->mb[0] != MBC_GEN_SYSTEM_ERROR) |
| 403 | ha->isp_ops->fw_dump(vha, 0); |
| 404 | rval = QLA_FUNCTION_TIMEOUT; |
| 405 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | } |
| 407 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | ha->flags.mbox_busy = 0; |
| 409 | |
| 410 | /* Clean up */ |
| 411 | ha->mcp = NULL; |
| 412 | |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 413 | if ((abort_active || !io_lock_on) && !IS_NOPOLLING_TYPE(ha)) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 414 | ql_dbg(ql_dbg_mbx, vha, 0x101a, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 415 | "Checking for additional resp interrupt.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | |
| 417 | /* polling mode for non isp_abort commands. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 418 | qla2x00_poll(ha->rsp_q_map[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | } |
| 420 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 421 | if (rval == QLA_FUNCTION_TIMEOUT && |
| 422 | mcp->mb[0] != MBC_GEN_SYSTEM_ERROR) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 423 | if (!io_lock_on || (mcp->flags & IOCTL_CMD) || |
| 424 | ha->flags.eeh_busy) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | /* not in dpc. schedule it for dpc to take over. */ |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 426 | ql_dbg(ql_dbg_mbx, vha, 0x101b, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 427 | "Timeout, schedule isp_abort_needed.\n"); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 428 | |
| 429 | if (!test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) && |
| 430 | !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) && |
| 431 | !test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) { |
Giridhar Malavali | 6315491 | 2011-11-18 09:02:19 -0800 | [diff] [blame] | 432 | if (IS_QLA82XX(ha)) { |
| 433 | ql_dbg(ql_dbg_mbx, vha, 0x112a, |
| 434 | "disabling pause transmit on port " |
| 435 | "0 & 1.\n"); |
| 436 | qla82xx_wr_32(ha, |
| 437 | QLA82XX_CRB_NIU + 0x98, |
| 438 | CRB_NIU_XG_PAUSE_CTL_P0| |
| 439 | CRB_NIU_XG_PAUSE_CTL_P1); |
| 440 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 441 | ql_log(ql_log_info, base_vha, 0x101c, |
Masanari Iida | 24d9ee8 | 2012-05-15 14:34:10 -0400 | [diff] [blame] | 442 | "Mailbox cmd timeout occurred, cmd=0x%x, " |
Chad Dupuis | d8c0d54 | 2012-02-09 11:15:46 -0800 | [diff] [blame] | 443 | "mb[0]=0x%x, eeh_busy=0x%x. Scheduling ISP " |
| 444 | "abort.\n", command, mcp->mb[0], |
| 445 | ha->flags.eeh_busy); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 446 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 447 | qla2xxx_wake_dpc(vha); |
| 448 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | } else if (!abort_active) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | /* call abort directly since we are in the DPC thread */ |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 451 | ql_dbg(ql_dbg_mbx, vha, 0x101d, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 452 | "Timeout, calling abort_isp.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 454 | if (!test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) && |
| 455 | !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) && |
| 456 | !test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) { |
Giridhar Malavali | 6315491 | 2011-11-18 09:02:19 -0800 | [diff] [blame] | 457 | if (IS_QLA82XX(ha)) { |
| 458 | ql_dbg(ql_dbg_mbx, vha, 0x112b, |
| 459 | "disabling pause transmit on port " |
| 460 | "0 & 1.\n"); |
| 461 | qla82xx_wr_32(ha, |
| 462 | QLA82XX_CRB_NIU + 0x98, |
| 463 | CRB_NIU_XG_PAUSE_CTL_P0| |
| 464 | CRB_NIU_XG_PAUSE_CTL_P1); |
| 465 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 466 | ql_log(ql_log_info, base_vha, 0x101e, |
Masanari Iida | 24d9ee8 | 2012-05-15 14:34:10 -0400 | [diff] [blame] | 467 | "Mailbox cmd timeout occurred, cmd=0x%x, " |
Chad Dupuis | d8c0d54 | 2012-02-09 11:15:46 -0800 | [diff] [blame] | 468 | "mb[0]=0x%x. Scheduling ISP abort ", |
| 469 | command, mcp->mb[0]); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 470 | set_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags); |
| 471 | clear_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Giridhar Malavali | d336096 | 2012-02-09 11:14:10 -0800 | [diff] [blame] | 472 | /* Allow next mbx cmd to come in. */ |
| 473 | complete(&ha->mbx_cmd_comp); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 474 | if (ha->isp_ops->abort_isp(vha)) { |
| 475 | /* Failed. retry later. */ |
| 476 | set_bit(ISP_ABORT_NEEDED, |
| 477 | &vha->dpc_flags); |
| 478 | } |
| 479 | clear_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags); |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 480 | ql_dbg(ql_dbg_mbx, vha, 0x101f, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 481 | "Finished abort_isp.\n"); |
Giridhar Malavali | d336096 | 2012-02-09 11:14:10 -0800 | [diff] [blame] | 482 | goto mbx_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | } |
| 485 | } |
| 486 | |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 487 | premature_exit: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | /* Allow next mbx cmd to come in. */ |
Andrew Vasquez | 8eca3f3 | 2009-01-22 09:45:31 -0800 | [diff] [blame] | 489 | complete(&ha->mbx_cmd_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | |
Giridhar Malavali | d336096 | 2012-02-09 11:14:10 -0800 | [diff] [blame] | 491 | mbx_done: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | if (rval) { |
Joe Carnuccio | 050dc76 | 2017-08-23 15:05:14 -0700 | [diff] [blame] | 493 | if (ql2xextended_error_logging & (ql_dbg_disc|ql_dbg_mbx)) { |
| 494 | pr_warn("%s [%s]-%04x:%ld: **** Failed", QL_MSGHDR, |
| 495 | dev_name(&ha->pdev->dev), 0x1020+0x800, |
| 496 | vha->host_no); |
| 497 | mboxes = mcp->in_mb; |
| 498 | cnt = 4; |
| 499 | for (i = 0; i < ha->mbx_count && cnt; i++, mboxes >>= 1) |
| 500 | if (mboxes & BIT_0) { |
| 501 | printk(" mb[%u]=%x", i, mcp->mb[i]); |
| 502 | cnt--; |
| 503 | } |
| 504 | pr_warn(" cmd=%x ****\n", command); |
| 505 | } |
Sawan Chandak | 75d560e | 2016-07-06 11:14:33 -0400 | [diff] [blame] | 506 | ql_dbg(ql_dbg_mbx, vha, 0x1198, |
Joe Carnuccio | 050dc76 | 2017-08-23 15:05:14 -0700 | [diff] [blame] | 507 | "host_status=%#x intr_ctrl=%#x intr_status=%#x\n", |
Himanshu Madhani | d14e72f | 2015-04-09 15:00:03 -0400 | [diff] [blame] | 508 | RD_REG_DWORD(®->isp24.host_status), |
Himanshu Madhani | d14e72f | 2015-04-09 15:00:03 -0400 | [diff] [blame] | 509 | RD_REG_DWORD(®->isp24.ictrl), |
| 510 | RD_REG_DWORD(®->isp24.istatus)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 512 | ql_dbg(ql_dbg_mbx, base_vha, 0x1021, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | } |
| 514 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 | return rval; |
| 516 | } |
| 517 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 518 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 519 | qla2x00_load_ram(scsi_qla_host_t *vha, dma_addr_t req_dma, uint32_t risc_addr, |
andrew.vasquez@qlogic.com | 590f98e | 2006-01-13 17:05:37 -0800 | [diff] [blame] | 520 | uint32_t risc_code_size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | { |
| 522 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 523 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 524 | mbx_cmd_t mc; |
| 525 | mbx_cmd_t *mcp = &mc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 527 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1022, |
| 528 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 530 | if (MSW(risc_addr) || IS_FWI2_CAPABLE(ha)) { |
andrew.vasquez@qlogic.com | 590f98e | 2006-01-13 17:05:37 -0800 | [diff] [blame] | 531 | mcp->mb[0] = MBC_LOAD_RISC_RAM_EXTENDED; |
| 532 | mcp->mb[8] = MSW(risc_addr); |
| 533 | mcp->out_mb = MBX_8|MBX_0; |
| 534 | } else { |
| 535 | mcp->mb[0] = MBC_LOAD_RISC_RAM; |
| 536 | mcp->out_mb = MBX_0; |
| 537 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | mcp->mb[1] = LSW(risc_addr); |
| 539 | mcp->mb[2] = MSW(req_dma); |
| 540 | mcp->mb[3] = LSW(req_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | mcp->mb[6] = MSW(MSD(req_dma)); |
| 542 | mcp->mb[7] = LSW(MSD(req_dma)); |
andrew.vasquez@qlogic.com | 590f98e | 2006-01-13 17:05:37 -0800 | [diff] [blame] | 543 | mcp->out_mb |= MBX_7|MBX_6|MBX_3|MBX_2|MBX_1; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 544 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 545 | mcp->mb[4] = MSW(risc_code_size); |
| 546 | mcp->mb[5] = LSW(risc_code_size); |
| 547 | mcp->out_mb |= MBX_5|MBX_4; |
| 548 | } else { |
| 549 | mcp->mb[4] = LSW(risc_code_size); |
| 550 | mcp->out_mb |= MBX_4; |
| 551 | } |
| 552 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 554 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 556 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 559 | ql_dbg(ql_dbg_mbx, vha, 0x1023, |
| 560 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 561 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 562 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1024, |
| 563 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 564 | } |
| 565 | |
| 566 | return rval; |
| 567 | } |
| 568 | |
Santosh Vernekar | cad454b | 2010-03-19 16:59:16 -0700 | [diff] [blame] | 569 | #define EXTENDED_BB_CREDITS BIT_0 |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 570 | #define NVME_ENABLE_FLAG BIT_3 |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 571 | static inline uint16_t qla25xx_set_sfp_lr_dist(struct qla_hw_data *ha) |
| 572 | { |
| 573 | uint16_t mb4 = BIT_0; |
| 574 | |
| 575 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
| 576 | mb4 |= ha->long_range_distance << LR_DIST_FW_POS; |
| 577 | |
| 578 | return mb4; |
| 579 | } |
| 580 | |
| 581 | static inline uint16_t qla25xx_set_nvr_lr_dist(struct qla_hw_data *ha) |
| 582 | { |
| 583 | uint16_t mb4 = BIT_0; |
| 584 | |
| 585 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
| 586 | struct nvram_81xx *nv = ha->nvram; |
| 587 | |
| 588 | mb4 |= LR_DIST_FW_FIELD(nv->enhanced_features); |
| 589 | } |
| 590 | |
| 591 | return mb4; |
| 592 | } |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 593 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | /* |
| 595 | * qla2x00_execute_fw |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 596 | * Start adapter firmware. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | * |
| 598 | * Input: |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 599 | * ha = adapter block pointer. |
| 600 | * TARGET_QUEUE_LOCK must be released. |
| 601 | * ADAPTER_STATE_LOCK must be released. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | * |
| 603 | * Returns: |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 604 | * qla2x00 local function return status code. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | * |
| 606 | * Context: |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 607 | * Kernel context. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | */ |
| 609 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 610 | qla2x00_execute_fw(scsi_qla_host_t *vha, uint32_t risc_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 611 | { |
| 612 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 613 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | mbx_cmd_t mc; |
| 615 | mbx_cmd_t *mcp = &mc; |
| 616 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 617 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1025, |
| 618 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | |
| 620 | mcp->mb[0] = MBC_EXECUTE_FIRMWARE; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 621 | mcp->out_mb = MBX_0; |
| 622 | mcp->in_mb = MBX_0; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 623 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 624 | mcp->mb[1] = MSW(risc_addr); |
| 625 | mcp->mb[2] = LSW(risc_addr); |
| 626 | mcp->mb[3] = 0; |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 627 | mcp->mb[4] = 0; |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 628 | ha->flags.using_lr_setting = 0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 629 | if (IS_QLA25XX(ha) || IS_QLA81XX(ha) || IS_QLA83XX(ha) || |
| 630 | IS_QLA27XX(ha)) { |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 631 | if (ql2xautodetectsfp) { |
| 632 | if (ha->flags.detected_lr_sfp) { |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 633 | mcp->mb[4] |= |
| 634 | qla25xx_set_sfp_lr_dist(ha); |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 635 | ha->flags.using_lr_setting = 1; |
| 636 | } |
| 637 | } else { |
| 638 | struct nvram_81xx *nv = ha->nvram; |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 639 | /* set LR distance if specified in nvram */ |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 640 | if (nv->enhanced_features & |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 641 | NEF_LR_DIST_ENABLE) { |
| 642 | mcp->mb[4] |= |
| 643 | qla25xx_set_nvr_lr_dist(ha); |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 644 | ha->flags.using_lr_setting = 1; |
| 645 | } |
| 646 | } |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 647 | } |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 648 | |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 649 | if (ql2xnvmeenable && IS_QLA27XX(ha)) |
| 650 | mcp->mb[4] |= NVME_ENABLE_FLAG; |
| 651 | |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 652 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
| 653 | struct nvram_81xx *nv = ha->nvram; |
| 654 | /* set minimum speed if specified in nvram */ |
| 655 | if (nv->min_link_speed >= 2 && |
| 656 | nv->min_link_speed <= 5) { |
| 657 | mcp->mb[4] |= BIT_4; |
| 658 | mcp->mb[11] = nv->min_link_speed; |
| 659 | mcp->out_mb |= MBX_11; |
| 660 | mcp->in_mb |= BIT_5; |
| 661 | vha->min_link_speed_feat = nv->min_link_speed; |
| 662 | } |
| 663 | } |
| 664 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 665 | if (ha->flags.exlogins_enabled) |
| 666 | mcp->mb[4] |= ENABLE_EXTENDED_LOGIN; |
| 667 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 668 | if (ha->flags.exchoffld_enabled) |
| 669 | mcp->mb[4] |= ENABLE_EXCHANGE_OFFLD; |
| 670 | |
Andrew Vasquez | 8b3253d | 2007-09-20 14:07:48 -0700 | [diff] [blame] | 671 | mcp->out_mb |= MBX_4|MBX_3|MBX_2|MBX_1; |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 672 | mcp->in_mb |= MBX_3 | MBX_2 | MBX_1; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 673 | } else { |
| 674 | mcp->mb[1] = LSW(risc_addr); |
| 675 | mcp->out_mb |= MBX_1; |
| 676 | if (IS_QLA2322(ha) || IS_QLA6322(ha)) { |
| 677 | mcp->mb[2] = 0; |
| 678 | mcp->out_mb |= MBX_2; |
| 679 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 680 | } |
| 681 | |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 682 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 684 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 686 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 687 | ql_dbg(ql_dbg_mbx, vha, 0x1026, |
| 688 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 689 | } else { |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 690 | if (IS_FWI2_CAPABLE(ha)) { |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 691 | ha->fw_ability_mask = mcp->mb[3] << 16 | mcp->mb[2]; |
| 692 | ql_dbg(ql_dbg_mbx, vha, 0x119a, |
| 693 | "fw_ability_mask=%x.\n", ha->fw_ability_mask); |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 694 | ql_dbg(ql_dbg_mbx, vha, 0x1027, |
| 695 | "exchanges=%x.\n", mcp->mb[1]); |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 696 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
| 697 | ha->max_speed_sup = mcp->mb[2] & BIT_0; |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 698 | ql_dbg(ql_dbg_mbx, vha, 0x119b, |
| 699 | "Maximum speed supported=%s.\n", |
| 700 | ha->max_speed_sup ? "32Gps" : "16Gps"); |
| 701 | if (vha->min_link_speed_feat) { |
| 702 | ha->min_link_speed = mcp->mb[5]; |
| 703 | ql_dbg(ql_dbg_mbx, vha, 0x119c, |
| 704 | "Minimum speed set=%s.\n", |
| 705 | mcp->mb[5] == 5 ? "32Gps" : |
| 706 | mcp->mb[5] == 4 ? "16Gps" : |
| 707 | mcp->mb[5] == 3 ? "8Gps" : |
| 708 | mcp->mb[5] == 2 ? "4Gps" : |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 709 | "unknown"); |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 710 | } |
| 711 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 712 | } |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 713 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1028, |
| 714 | "Done.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 715 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 716 | |
| 717 | return rval; |
| 718 | } |
| 719 | |
| 720 | /* |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 721 | * qla_get_exlogin_status |
| 722 | * Get extended login status |
| 723 | * uses the memory offload control/status Mailbox |
| 724 | * |
| 725 | * Input: |
| 726 | * ha: adapter state pointer. |
| 727 | * fwopt: firmware options |
| 728 | * |
| 729 | * Returns: |
| 730 | * qla2x00 local function status |
| 731 | * |
| 732 | * Context: |
| 733 | * Kernel context. |
| 734 | */ |
| 735 | #define FETCH_XLOGINS_STAT 0x8 |
| 736 | int |
| 737 | qla_get_exlogin_status(scsi_qla_host_t *vha, uint16_t *buf_sz, |
| 738 | uint16_t *ex_logins_cnt) |
| 739 | { |
| 740 | int rval; |
| 741 | mbx_cmd_t mc; |
| 742 | mbx_cmd_t *mcp = &mc; |
| 743 | |
| 744 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x118f, |
| 745 | "Entered %s\n", __func__); |
| 746 | |
| 747 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 748 | mcp->mb[0] = MBC_GET_MEM_OFFLOAD_CNTRL_STAT; |
| 749 | mcp->mb[1] = FETCH_XLOGINS_STAT; |
| 750 | mcp->out_mb = MBX_1|MBX_0; |
| 751 | mcp->in_mb = MBX_10|MBX_4|MBX_0; |
| 752 | mcp->tov = MBX_TOV_SECONDS; |
| 753 | mcp->flags = 0; |
| 754 | |
| 755 | rval = qla2x00_mailbox_command(vha, mcp); |
| 756 | if (rval != QLA_SUCCESS) { |
| 757 | ql_dbg(ql_dbg_mbx, vha, 0x1115, "Failed=%x.\n", rval); |
| 758 | } else { |
| 759 | *buf_sz = mcp->mb[4]; |
| 760 | *ex_logins_cnt = mcp->mb[10]; |
| 761 | |
| 762 | ql_log(ql_log_info, vha, 0x1190, |
| 763 | "buffer size 0x%x, exchange login count=%d\n", |
| 764 | mcp->mb[4], mcp->mb[10]); |
| 765 | |
| 766 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1116, |
| 767 | "Done %s.\n", __func__); |
| 768 | } |
| 769 | |
| 770 | return rval; |
| 771 | } |
| 772 | |
| 773 | /* |
| 774 | * qla_set_exlogin_mem_cfg |
| 775 | * set extended login memory configuration |
| 776 | * Mbx needs to be issues before init_cb is set |
| 777 | * |
| 778 | * Input: |
| 779 | * ha: adapter state pointer. |
| 780 | * buffer: buffer pointer |
| 781 | * phys_addr: physical address of buffer |
| 782 | * size: size of buffer |
| 783 | * TARGET_QUEUE_LOCK must be released |
| 784 | * ADAPTER_STATE_LOCK must be release |
| 785 | * |
| 786 | * Returns: |
| 787 | * qla2x00 local funxtion status code. |
| 788 | * |
| 789 | * Context: |
| 790 | * Kernel context. |
| 791 | */ |
| 792 | #define CONFIG_XLOGINS_MEM 0x3 |
| 793 | int |
| 794 | qla_set_exlogin_mem_cfg(scsi_qla_host_t *vha, dma_addr_t phys_addr) |
| 795 | { |
| 796 | int rval; |
| 797 | mbx_cmd_t mc; |
| 798 | mbx_cmd_t *mcp = &mc; |
| 799 | struct qla_hw_data *ha = vha->hw; |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 800 | |
| 801 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x111a, |
| 802 | "Entered %s.\n", __func__); |
| 803 | |
| 804 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 805 | mcp->mb[0] = MBC_GET_MEM_OFFLOAD_CNTRL_STAT; |
| 806 | mcp->mb[1] = CONFIG_XLOGINS_MEM; |
| 807 | mcp->mb[2] = MSW(phys_addr); |
| 808 | mcp->mb[3] = LSW(phys_addr); |
| 809 | mcp->mb[6] = MSW(MSD(phys_addr)); |
| 810 | mcp->mb[7] = LSW(MSD(phys_addr)); |
| 811 | mcp->mb[8] = MSW(ha->exlogin_size); |
| 812 | mcp->mb[9] = LSW(ha->exlogin_size); |
| 813 | mcp->out_mb = MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 814 | mcp->in_mb = MBX_11|MBX_0; |
| 815 | mcp->tov = MBX_TOV_SECONDS; |
| 816 | mcp->flags = 0; |
| 817 | rval = qla2x00_mailbox_command(vha, mcp); |
| 818 | if (rval != QLA_SUCCESS) { |
| 819 | /*EMPTY*/ |
| 820 | ql_dbg(ql_dbg_mbx, vha, 0x111b, "Failed=%x.\n", rval); |
| 821 | } else { |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 822 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x118c, |
| 823 | "Done %s.\n", __func__); |
| 824 | } |
| 825 | |
| 826 | return rval; |
| 827 | } |
| 828 | |
| 829 | /* |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 830 | * qla_get_exchoffld_status |
| 831 | * Get exchange offload status |
| 832 | * uses the memory offload control/status Mailbox |
| 833 | * |
| 834 | * Input: |
| 835 | * ha: adapter state pointer. |
| 836 | * fwopt: firmware options |
| 837 | * |
| 838 | * Returns: |
| 839 | * qla2x00 local function status |
| 840 | * |
| 841 | * Context: |
| 842 | * Kernel context. |
| 843 | */ |
| 844 | #define FETCH_XCHOFFLD_STAT 0x2 |
| 845 | int |
| 846 | qla_get_exchoffld_status(scsi_qla_host_t *vha, uint16_t *buf_sz, |
| 847 | uint16_t *ex_logins_cnt) |
| 848 | { |
| 849 | int rval; |
| 850 | mbx_cmd_t mc; |
| 851 | mbx_cmd_t *mcp = &mc; |
| 852 | |
| 853 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1019, |
| 854 | "Entered %s\n", __func__); |
| 855 | |
| 856 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 857 | mcp->mb[0] = MBC_GET_MEM_OFFLOAD_CNTRL_STAT; |
| 858 | mcp->mb[1] = FETCH_XCHOFFLD_STAT; |
| 859 | mcp->out_mb = MBX_1|MBX_0; |
| 860 | mcp->in_mb = MBX_10|MBX_4|MBX_0; |
| 861 | mcp->tov = MBX_TOV_SECONDS; |
| 862 | mcp->flags = 0; |
| 863 | |
| 864 | rval = qla2x00_mailbox_command(vha, mcp); |
| 865 | if (rval != QLA_SUCCESS) { |
| 866 | ql_dbg(ql_dbg_mbx, vha, 0x1155, "Failed=%x.\n", rval); |
| 867 | } else { |
| 868 | *buf_sz = mcp->mb[4]; |
| 869 | *ex_logins_cnt = mcp->mb[10]; |
| 870 | |
| 871 | ql_log(ql_log_info, vha, 0x118e, |
| 872 | "buffer size 0x%x, exchange offload count=%d\n", |
| 873 | mcp->mb[4], mcp->mb[10]); |
| 874 | |
| 875 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1156, |
| 876 | "Done %s.\n", __func__); |
| 877 | } |
| 878 | |
| 879 | return rval; |
| 880 | } |
| 881 | |
| 882 | /* |
| 883 | * qla_set_exchoffld_mem_cfg |
| 884 | * Set exchange offload memory configuration |
| 885 | * Mbx needs to be issues before init_cb is set |
| 886 | * |
| 887 | * Input: |
| 888 | * ha: adapter state pointer. |
| 889 | * buffer: buffer pointer |
| 890 | * phys_addr: physical address of buffer |
| 891 | * size: size of buffer |
| 892 | * TARGET_QUEUE_LOCK must be released |
| 893 | * ADAPTER_STATE_LOCK must be release |
| 894 | * |
| 895 | * Returns: |
| 896 | * qla2x00 local funxtion status code. |
| 897 | * |
| 898 | * Context: |
| 899 | * Kernel context. |
| 900 | */ |
| 901 | #define CONFIG_XCHOFFLD_MEM 0x3 |
| 902 | int |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 903 | qla_set_exchoffld_mem_cfg(scsi_qla_host_t *vha) |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 904 | { |
| 905 | int rval; |
| 906 | mbx_cmd_t mc; |
| 907 | mbx_cmd_t *mcp = &mc; |
| 908 | struct qla_hw_data *ha = vha->hw; |
| 909 | |
| 910 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1157, |
| 911 | "Entered %s.\n", __func__); |
| 912 | |
| 913 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 914 | mcp->mb[0] = MBC_GET_MEM_OFFLOAD_CNTRL_STAT; |
| 915 | mcp->mb[1] = CONFIG_XCHOFFLD_MEM; |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 916 | mcp->mb[2] = MSW(ha->exchoffld_buf_dma); |
| 917 | mcp->mb[3] = LSW(ha->exchoffld_buf_dma); |
| 918 | mcp->mb[6] = MSW(MSD(ha->exchoffld_buf_dma)); |
| 919 | mcp->mb[7] = LSW(MSD(ha->exchoffld_buf_dma)); |
| 920 | mcp->mb[8] = MSW(ha->exchoffld_size); |
| 921 | mcp->mb[9] = LSW(ha->exchoffld_size); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 922 | mcp->out_mb = MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 923 | mcp->in_mb = MBX_11|MBX_0; |
| 924 | mcp->tov = MBX_TOV_SECONDS; |
| 925 | mcp->flags = 0; |
| 926 | rval = qla2x00_mailbox_command(vha, mcp); |
| 927 | if (rval != QLA_SUCCESS) { |
| 928 | /*EMPTY*/ |
| 929 | ql_dbg(ql_dbg_mbx, vha, 0x1158, "Failed=%x.\n", rval); |
| 930 | } else { |
| 931 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1192, |
| 932 | "Done %s.\n", __func__); |
| 933 | } |
| 934 | |
| 935 | return rval; |
| 936 | } |
| 937 | |
| 938 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 939 | * qla2x00_get_fw_version |
| 940 | * Get firmware version. |
| 941 | * |
| 942 | * Input: |
| 943 | * ha: adapter state pointer. |
| 944 | * major: pointer for major number. |
| 945 | * minor: pointer for minor number. |
| 946 | * subminor: pointer for subminor number. |
| 947 | * |
| 948 | * Returns: |
| 949 | * qla2x00 local function return status code. |
| 950 | * |
| 951 | * Context: |
| 952 | * Kernel context. |
| 953 | */ |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 954 | int |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 955 | qla2x00_get_fw_version(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 956 | { |
| 957 | int rval; |
| 958 | mbx_cmd_t mc; |
| 959 | mbx_cmd_t *mcp = &mc; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 960 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 961 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 962 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1029, |
| 963 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 964 | |
| 965 | mcp->mb[0] = MBC_GET_FIRMWARE_VERSION; |
| 966 | mcp->out_mb = MBX_0; |
| 967 | mcp->in_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 968 | if (IS_QLA81XX(vha->hw) || IS_QLA8031(ha) || IS_QLA8044(ha)) |
Andrew Vasquez | 55a9615 | 2009-03-24 09:08:03 -0700 | [diff] [blame] | 969 | mcp->in_mb |= MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8; |
Saurav Kashyap | fb0effe | 2012-08-22 14:21:28 -0400 | [diff] [blame] | 970 | if (IS_FWI2_CAPABLE(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 971 | mcp->in_mb |= MBX_17|MBX_16|MBX_15; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 972 | if (IS_QLA27XX(ha)) |
Joe Carnuccio | ad1ef17 | 2016-07-06 11:14:18 -0400 | [diff] [blame] | 973 | mcp->in_mb |= |
| 974 | MBX_25|MBX_24|MBX_23|MBX_22|MBX_21|MBX_20|MBX_19|MBX_18| |
| 975 | MBX_14|MBX_13|MBX_11|MBX_10|MBX_9|MBX_8; |
Sawan Chandak | 03aa868 | 2015-08-04 13:37:59 -0400 | [diff] [blame] | 976 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 977 | mcp->flags = 0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 978 | mcp->tov = MBX_TOV_SECONDS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 979 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 980 | if (rval != QLA_SUCCESS) |
| 981 | goto failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 982 | |
| 983 | /* Return mailbox data. */ |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 984 | ha->fw_major_version = mcp->mb[1]; |
| 985 | ha->fw_minor_version = mcp->mb[2]; |
| 986 | ha->fw_subminor_version = mcp->mb[3]; |
| 987 | ha->fw_attributes = mcp->mb[6]; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 988 | if (IS_QLA2100(vha->hw) || IS_QLA2200(vha->hw)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 989 | ha->fw_memory_size = 0x1FFFF; /* Defaults to 128KB. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 990 | else |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 991 | ha->fw_memory_size = (mcp->mb[5] << 16) | mcp->mb[4]; |
Sawan Chandak | 03aa868 | 2015-08-04 13:37:59 -0400 | [diff] [blame] | 992 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 993 | if (IS_QLA81XX(vha->hw) || IS_QLA8031(vha->hw) || IS_QLA8044(ha)) { |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 994 | ha->mpi_version[0] = mcp->mb[10] & 0xff; |
| 995 | ha->mpi_version[1] = mcp->mb[11] >> 8; |
| 996 | ha->mpi_version[2] = mcp->mb[11] & 0xff; |
| 997 | ha->mpi_capabilities = (mcp->mb[12] << 16) | mcp->mb[13]; |
| 998 | ha->phy_version[0] = mcp->mb[8] & 0xff; |
| 999 | ha->phy_version[1] = mcp->mb[9] >> 8; |
| 1000 | ha->phy_version[2] = mcp->mb[9] & 0xff; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1001 | } |
Sawan Chandak | 03aa868 | 2015-08-04 13:37:59 -0400 | [diff] [blame] | 1002 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 1003 | if (IS_FWI2_CAPABLE(ha)) { |
| 1004 | ha->fw_attributes_h = mcp->mb[15]; |
| 1005 | ha->fw_attributes_ext[0] = mcp->mb[16]; |
| 1006 | ha->fw_attributes_ext[1] = mcp->mb[17]; |
| 1007 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1139, |
| 1008 | "%s: FW_attributes Upper: 0x%x, Lower: 0x%x.\n", |
| 1009 | __func__, mcp->mb[15], mcp->mb[6]); |
| 1010 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x112f, |
| 1011 | "%s: Ext_FwAttributes Upper: 0x%x, Lower: 0x%x.\n", |
| 1012 | __func__, mcp->mb[17], mcp->mb[16]); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 1013 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 1014 | if (ha->fw_attributes_h & 0x4) |
| 1015 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x118d, |
| 1016 | "%s: Firmware supports Extended Login 0x%x\n", |
| 1017 | __func__, ha->fw_attributes_h); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 1018 | |
| 1019 | if (ha->fw_attributes_h & 0x8) |
| 1020 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1191, |
| 1021 | "%s: Firmware supports Exchange Offload 0x%x\n", |
| 1022 | __func__, ha->fw_attributes_h); |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 1023 | |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 1024 | /* |
| 1025 | * FW supports nvme and driver load parameter requested nvme. |
| 1026 | * BIT 26 of fw_attributes indicates NVMe support. |
| 1027 | */ |
| 1028 | if ((ha->fw_attributes_h & 0x400) && ql2xnvmeenable) |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 1029 | vha->flags.nvme_enabled = 1; |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 1030 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1031 | } |
Sawan Chandak | 03aa868 | 2015-08-04 13:37:59 -0400 | [diff] [blame] | 1032 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 1033 | if (IS_QLA27XX(ha)) { |
Sawan Chandak | 03aa868 | 2015-08-04 13:37:59 -0400 | [diff] [blame] | 1034 | ha->mpi_version[0] = mcp->mb[10] & 0xff; |
| 1035 | ha->mpi_version[1] = mcp->mb[11] >> 8; |
| 1036 | ha->mpi_version[2] = mcp->mb[11] & 0xff; |
| 1037 | ha->pep_version[0] = mcp->mb[13] & 0xff; |
| 1038 | ha->pep_version[1] = mcp->mb[14] >> 8; |
| 1039 | ha->pep_version[2] = mcp->mb[14] & 0xff; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 1040 | ha->fw_shared_ram_start = (mcp->mb[19] << 16) | mcp->mb[18]; |
| 1041 | ha->fw_shared_ram_end = (mcp->mb[21] << 16) | mcp->mb[20]; |
Joe Carnuccio | ad1ef17 | 2016-07-06 11:14:18 -0400 | [diff] [blame] | 1042 | ha->fw_ddr_ram_start = (mcp->mb[23] << 16) | mcp->mb[22]; |
| 1043 | ha->fw_ddr_ram_end = (mcp->mb[25] << 16) | mcp->mb[24]; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 1044 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1045 | |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 1046 | failed: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1047 | if (rval != QLA_SUCCESS) { |
| 1048 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1049 | ql_dbg(ql_dbg_mbx, vha, 0x102a, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1050 | } else { |
| 1051 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1052 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102b, |
| 1053 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1054 | } |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 1055 | return rval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1056 | } |
| 1057 | |
| 1058 | /* |
| 1059 | * qla2x00_get_fw_options |
| 1060 | * Set firmware options. |
| 1061 | * |
| 1062 | * Input: |
| 1063 | * ha = adapter block pointer. |
| 1064 | * fwopt = pointer for firmware options. |
| 1065 | * |
| 1066 | * Returns: |
| 1067 | * qla2x00 local function return status code. |
| 1068 | * |
| 1069 | * Context: |
| 1070 | * Kernel context. |
| 1071 | */ |
| 1072 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1073 | qla2x00_get_fw_options(scsi_qla_host_t *vha, uint16_t *fwopts) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1074 | { |
| 1075 | int rval; |
| 1076 | mbx_cmd_t mc; |
| 1077 | mbx_cmd_t *mcp = &mc; |
| 1078 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1079 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102c, |
| 1080 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1081 | |
| 1082 | mcp->mb[0] = MBC_GET_FIRMWARE_OPTION; |
| 1083 | mcp->out_mb = MBX_0; |
| 1084 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1085 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1086 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1087 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1088 | |
| 1089 | if (rval != QLA_SUCCESS) { |
| 1090 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1091 | ql_dbg(ql_dbg_mbx, vha, 0x102d, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1092 | } else { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1093 | fwopts[0] = mcp->mb[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1094 | fwopts[1] = mcp->mb[1]; |
| 1095 | fwopts[2] = mcp->mb[2]; |
| 1096 | fwopts[3] = mcp->mb[3]; |
| 1097 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1098 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102e, |
| 1099 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1100 | } |
| 1101 | |
| 1102 | return rval; |
| 1103 | } |
| 1104 | |
| 1105 | |
| 1106 | /* |
| 1107 | * qla2x00_set_fw_options |
| 1108 | * Set firmware options. |
| 1109 | * |
| 1110 | * Input: |
| 1111 | * ha = adapter block pointer. |
| 1112 | * fwopt = pointer for firmware options. |
| 1113 | * |
| 1114 | * Returns: |
| 1115 | * qla2x00 local function return status code. |
| 1116 | * |
| 1117 | * Context: |
| 1118 | * Kernel context. |
| 1119 | */ |
| 1120 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1121 | qla2x00_set_fw_options(scsi_qla_host_t *vha, uint16_t *fwopts) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1122 | { |
| 1123 | int rval; |
| 1124 | mbx_cmd_t mc; |
| 1125 | mbx_cmd_t *mcp = &mc; |
| 1126 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1127 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102f, |
| 1128 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1129 | |
| 1130 | mcp->mb[0] = MBC_SET_FIRMWARE_OPTION; |
| 1131 | mcp->mb[1] = fwopts[1]; |
| 1132 | mcp->mb[2] = fwopts[2]; |
| 1133 | mcp->mb[3] = fwopts[3]; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1134 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1135 | mcp->in_mb = MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1136 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1137 | mcp->in_mb |= MBX_1; |
Quinn Tran | 2da5273 | 2017-06-02 09:12:05 -0700 | [diff] [blame] | 1138 | mcp->mb[10] = fwopts[10]; |
| 1139 | mcp->out_mb |= MBX_10; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1140 | } else { |
| 1141 | mcp->mb[10] = fwopts[10]; |
| 1142 | mcp->mb[11] = fwopts[11]; |
| 1143 | mcp->mb[12] = 0; /* Undocumented, but used */ |
| 1144 | mcp->out_mb |= MBX_12|MBX_11|MBX_10; |
| 1145 | } |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1146 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1147 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1148 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1149 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1150 | fwopts[0] = mcp->mb[0]; |
| 1151 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1152 | if (rval != QLA_SUCCESS) { |
| 1153 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1154 | ql_dbg(ql_dbg_mbx, vha, 0x1030, |
| 1155 | "Failed=%x (%x/%x).\n", rval, mcp->mb[0], mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1156 | } else { |
| 1157 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1158 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1031, |
| 1159 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1160 | } |
| 1161 | |
| 1162 | return rval; |
| 1163 | } |
| 1164 | |
| 1165 | /* |
| 1166 | * qla2x00_mbx_reg_test |
| 1167 | * Mailbox register wrap test. |
| 1168 | * |
| 1169 | * Input: |
| 1170 | * ha = adapter block pointer. |
| 1171 | * TARGET_QUEUE_LOCK must be released. |
| 1172 | * ADAPTER_STATE_LOCK must be released. |
| 1173 | * |
| 1174 | * Returns: |
| 1175 | * qla2x00 local function return status code. |
| 1176 | * |
| 1177 | * Context: |
| 1178 | * Kernel context. |
| 1179 | */ |
| 1180 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1181 | qla2x00_mbx_reg_test(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1182 | { |
| 1183 | int rval; |
| 1184 | mbx_cmd_t mc; |
| 1185 | mbx_cmd_t *mcp = &mc; |
| 1186 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1187 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1032, |
| 1188 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1189 | |
| 1190 | mcp->mb[0] = MBC_MAILBOX_REGISTER_TEST; |
| 1191 | mcp->mb[1] = 0xAAAA; |
| 1192 | mcp->mb[2] = 0x5555; |
| 1193 | mcp->mb[3] = 0xAA55; |
| 1194 | mcp->mb[4] = 0x55AA; |
| 1195 | mcp->mb[5] = 0xA5A5; |
| 1196 | mcp->mb[6] = 0x5A5A; |
| 1197 | mcp->mb[7] = 0x2525; |
| 1198 | mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 1199 | mcp->in_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1200 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1201 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1202 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1203 | |
| 1204 | if (rval == QLA_SUCCESS) { |
| 1205 | if (mcp->mb[1] != 0xAAAA || mcp->mb[2] != 0x5555 || |
| 1206 | mcp->mb[3] != 0xAA55 || mcp->mb[4] != 0x55AA) |
| 1207 | rval = QLA_FUNCTION_FAILED; |
| 1208 | if (mcp->mb[5] != 0xA5A5 || mcp->mb[6] != 0x5A5A || |
| 1209 | mcp->mb[7] != 0x2525) |
| 1210 | rval = QLA_FUNCTION_FAILED; |
| 1211 | } |
| 1212 | |
| 1213 | if (rval != QLA_SUCCESS) { |
| 1214 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1215 | ql_dbg(ql_dbg_mbx, vha, 0x1033, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1216 | } else { |
| 1217 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1218 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1034, |
| 1219 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1220 | } |
| 1221 | |
| 1222 | return rval; |
| 1223 | } |
| 1224 | |
| 1225 | /* |
| 1226 | * qla2x00_verify_checksum |
| 1227 | * Verify firmware checksum. |
| 1228 | * |
| 1229 | * Input: |
| 1230 | * ha = adapter block pointer. |
| 1231 | * TARGET_QUEUE_LOCK must be released. |
| 1232 | * ADAPTER_STATE_LOCK must be released. |
| 1233 | * |
| 1234 | * Returns: |
| 1235 | * qla2x00 local function return status code. |
| 1236 | * |
| 1237 | * Context: |
| 1238 | * Kernel context. |
| 1239 | */ |
| 1240 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1241 | qla2x00_verify_checksum(scsi_qla_host_t *vha, uint32_t risc_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1242 | { |
| 1243 | int rval; |
| 1244 | mbx_cmd_t mc; |
| 1245 | mbx_cmd_t *mcp = &mc; |
| 1246 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1247 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1035, |
| 1248 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1249 | |
| 1250 | mcp->mb[0] = MBC_VERIFY_CHECKSUM; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1251 | mcp->out_mb = MBX_0; |
| 1252 | mcp->in_mb = MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1253 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1254 | mcp->mb[1] = MSW(risc_addr); |
| 1255 | mcp->mb[2] = LSW(risc_addr); |
| 1256 | mcp->out_mb |= MBX_2|MBX_1; |
| 1257 | mcp->in_mb |= MBX_2|MBX_1; |
| 1258 | } else { |
| 1259 | mcp->mb[1] = LSW(risc_addr); |
| 1260 | mcp->out_mb |= MBX_1; |
| 1261 | mcp->in_mb |= MBX_1; |
| 1262 | } |
| 1263 | |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1264 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1265 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1266 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1267 | |
| 1268 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1269 | ql_dbg(ql_dbg_mbx, vha, 0x1036, |
| 1270 | "Failed=%x chm sum=%x.\n", rval, IS_FWI2_CAPABLE(vha->hw) ? |
| 1271 | (mcp->mb[2] << 16) | mcp->mb[1] : mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1272 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1273 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1037, |
| 1274 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1275 | } |
| 1276 | |
| 1277 | return rval; |
| 1278 | } |
| 1279 | |
| 1280 | /* |
| 1281 | * qla2x00_issue_iocb |
| 1282 | * Issue IOCB using mailbox command |
| 1283 | * |
| 1284 | * Input: |
| 1285 | * ha = adapter state pointer. |
| 1286 | * buffer = buffer pointer. |
| 1287 | * phys_addr = physical address of buffer. |
| 1288 | * size = size of buffer. |
| 1289 | * TARGET_QUEUE_LOCK must be released. |
| 1290 | * ADAPTER_STATE_LOCK must be released. |
| 1291 | * |
| 1292 | * Returns: |
| 1293 | * qla2x00 local function return status code. |
| 1294 | * |
| 1295 | * Context: |
| 1296 | * Kernel context. |
| 1297 | */ |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 1298 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1299 | qla2x00_issue_iocb_timeout(scsi_qla_host_t *vha, void *buffer, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1300 | dma_addr_t phys_addr, size_t size, uint32_t tov) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1301 | { |
| 1302 | int rval; |
| 1303 | mbx_cmd_t mc; |
| 1304 | mbx_cmd_t *mcp = &mc; |
| 1305 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1306 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1038, |
| 1307 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1308 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1309 | mcp->mb[0] = MBC_IOCB_COMMAND_A64; |
| 1310 | mcp->mb[1] = 0; |
| 1311 | mcp->mb[2] = MSW(phys_addr); |
| 1312 | mcp->mb[3] = LSW(phys_addr); |
| 1313 | mcp->mb[6] = MSW(MSD(phys_addr)); |
| 1314 | mcp->mb[7] = LSW(MSD(phys_addr)); |
| 1315 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 1316 | mcp->in_mb = MBX_2|MBX_0; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1317 | mcp->tov = tov; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1318 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1319 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1320 | |
| 1321 | if (rval != QLA_SUCCESS) { |
| 1322 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1323 | ql_dbg(ql_dbg_mbx, vha, 0x1039, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1324 | } else { |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 1325 | sts_entry_t *sts_entry = (sts_entry_t *) buffer; |
| 1326 | |
| 1327 | /* Mask reserved bits. */ |
| 1328 | sts_entry->entry_status &= |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1329 | IS_FWI2_CAPABLE(vha->hw) ? RF_MASK_24XX : RF_MASK; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1330 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103a, |
| 1331 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1332 | } |
| 1333 | |
| 1334 | return rval; |
| 1335 | } |
| 1336 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1337 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1338 | qla2x00_issue_iocb(scsi_qla_host_t *vha, void *buffer, dma_addr_t phys_addr, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1339 | size_t size) |
| 1340 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1341 | return qla2x00_issue_iocb_timeout(vha, buffer, phys_addr, size, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1342 | MBX_TOV_SECONDS); |
| 1343 | } |
| 1344 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1345 | /* |
| 1346 | * qla2x00_abort_command |
| 1347 | * Abort command aborts a specified IOCB. |
| 1348 | * |
| 1349 | * Input: |
| 1350 | * ha = adapter block pointer. |
| 1351 | * sp = SB structure pointer. |
| 1352 | * |
| 1353 | * Returns: |
| 1354 | * qla2x00 local function return status code. |
| 1355 | * |
| 1356 | * Context: |
| 1357 | * Kernel context. |
| 1358 | */ |
| 1359 | int |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1360 | qla2x00_abort_command(srb_t *sp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1361 | { |
| 1362 | unsigned long flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1363 | int rval; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1364 | uint32_t handle = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1365 | mbx_cmd_t mc; |
| 1366 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1367 | fc_port_t *fcport = sp->fcport; |
| 1368 | scsi_qla_host_t *vha = fcport->vha; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1369 | struct qla_hw_data *ha = vha->hw; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1370 | struct req_que *req; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1371 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1372 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1373 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103b, |
| 1374 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1375 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1376 | if (vha->flags.qpairs_available && sp->qpair) |
| 1377 | req = sp->qpair->req; |
| 1378 | else |
| 1379 | req = vha->req; |
| 1380 | |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 1381 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1382 | for (handle = 1; handle < req->num_outstanding_cmds; handle++) { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1383 | if (req->outstanding_cmds[handle] == sp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1384 | break; |
| 1385 | } |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 1386 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1387 | |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1388 | if (handle == req->num_outstanding_cmds) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1389 | /* command not found */ |
| 1390 | return QLA_FUNCTION_FAILED; |
| 1391 | } |
| 1392 | |
| 1393 | mcp->mb[0] = MBC_ABORT_COMMAND; |
| 1394 | if (HAS_EXTENDED_IDS(ha)) |
| 1395 | mcp->mb[1] = fcport->loop_id; |
| 1396 | else |
| 1397 | mcp->mb[1] = fcport->loop_id << 8; |
| 1398 | mcp->mb[2] = (uint16_t)handle; |
| 1399 | mcp->mb[3] = (uint16_t)(handle >> 16); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1400 | mcp->mb[6] = (uint16_t)cmd->device->lun; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1401 | mcp->out_mb = MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 1402 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1403 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1404 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1405 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1406 | |
| 1407 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1408 | ql_dbg(ql_dbg_mbx, vha, 0x103c, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1409 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1410 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103d, |
| 1411 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1412 | } |
| 1413 | |
| 1414 | return rval; |
| 1415 | } |
| 1416 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1417 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1418 | qla2x00_abort_target(struct fc_port *fcport, uint64_t l, int tag) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1419 | { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1420 | int rval, rval2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1421 | mbx_cmd_t mc; |
| 1422 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1423 | scsi_qla_host_t *vha; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1424 | struct req_que *req; |
| 1425 | struct rsp_que *rsp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1426 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1427 | l = l; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1428 | vha = fcport->vha; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1429 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1430 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103e, |
| 1431 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1432 | |
Giridhar Malavali | 7e2b895 | 2010-05-28 15:08:17 -0700 | [diff] [blame] | 1433 | req = vha->hw->req_q_map[0]; |
| 1434 | rsp = req->rsp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1435 | mcp->mb[0] = MBC_ABORT_TARGET; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1436 | mcp->out_mb = MBX_9|MBX_2|MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1437 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1438 | mcp->mb[1] = fcport->loop_id; |
| 1439 | mcp->mb[10] = 0; |
| 1440 | mcp->out_mb |= MBX_10; |
| 1441 | } else { |
| 1442 | mcp->mb[1] = fcport->loop_id << 8; |
| 1443 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1444 | mcp->mb[2] = vha->hw->loop_reset_delay; |
| 1445 | mcp->mb[9] = vha->vp_idx; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1446 | |
| 1447 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1448 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1449 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1450 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1451 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1452 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103f, |
| 1453 | "Failed=%x.\n", rval); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1454 | } |
| 1455 | |
| 1456 | /* Issue marker IOCB. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1457 | rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, 0, |
| 1458 | MK_SYNC_ID); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1459 | if (rval2 != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1460 | ql_dbg(ql_dbg_mbx, vha, 0x1040, |
| 1461 | "Failed to issue marker IOCB (%x).\n", rval2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1462 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1463 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1041, |
| 1464 | "Done %s.\n", __func__); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1465 | } |
| 1466 | |
| 1467 | return rval; |
| 1468 | } |
| 1469 | |
| 1470 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1471 | qla2x00_lun_reset(struct fc_port *fcport, uint64_t l, int tag) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1472 | { |
| 1473 | int rval, rval2; |
| 1474 | mbx_cmd_t mc; |
| 1475 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1476 | scsi_qla_host_t *vha; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1477 | struct req_que *req; |
| 1478 | struct rsp_que *rsp; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1479 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1480 | vha = fcport->vha; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1481 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1482 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1042, |
| 1483 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1484 | |
Giridhar Malavali | 7e2b895 | 2010-05-28 15:08:17 -0700 | [diff] [blame] | 1485 | req = vha->hw->req_q_map[0]; |
| 1486 | rsp = req->rsp; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1487 | mcp->mb[0] = MBC_LUN_RESET; |
| 1488 | mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1489 | if (HAS_EXTENDED_IDS(vha->hw)) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1490 | mcp->mb[1] = fcport->loop_id; |
| 1491 | else |
| 1492 | mcp->mb[1] = fcport->loop_id << 8; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1493 | mcp->mb[2] = (u32)l; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1494 | mcp->mb[3] = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1495 | mcp->mb[9] = vha->vp_idx; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1496 | |
| 1497 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1498 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1499 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1500 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1501 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1502 | ql_dbg(ql_dbg_mbx, vha, 0x1043, "Failed=%x.\n", rval); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1503 | } |
| 1504 | |
| 1505 | /* Issue marker IOCB. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1506 | rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, l, |
| 1507 | MK_SYNC_ID_LUN); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1508 | if (rval2 != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1509 | ql_dbg(ql_dbg_mbx, vha, 0x1044, |
| 1510 | "Failed to issue marker IOCB (%x).\n", rval2); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1511 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1512 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1045, |
| 1513 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1514 | } |
| 1515 | |
| 1516 | return rval; |
| 1517 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1518 | |
| 1519 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1520 | * qla2x00_get_adapter_id |
| 1521 | * Get adapter ID and topology. |
| 1522 | * |
| 1523 | * Input: |
| 1524 | * ha = adapter block pointer. |
| 1525 | * id = pointer for loop ID. |
| 1526 | * al_pa = pointer for AL_PA. |
| 1527 | * area = pointer for area. |
| 1528 | * domain = pointer for domain. |
| 1529 | * top = pointer for topology. |
| 1530 | * TARGET_QUEUE_LOCK must be released. |
| 1531 | * ADAPTER_STATE_LOCK must be released. |
| 1532 | * |
| 1533 | * Returns: |
| 1534 | * qla2x00 local function return status code. |
| 1535 | * |
| 1536 | * Context: |
| 1537 | * Kernel context. |
| 1538 | */ |
| 1539 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1540 | qla2x00_get_adapter_id(scsi_qla_host_t *vha, uint16_t *id, uint8_t *al_pa, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1541 | uint8_t *area, uint8_t *domain, uint16_t *top, uint16_t *sw_cap) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1542 | { |
| 1543 | int rval; |
| 1544 | mbx_cmd_t mc; |
| 1545 | mbx_cmd_t *mcp = &mc; |
| 1546 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1547 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1046, |
| 1548 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1549 | |
| 1550 | mcp->mb[0] = MBC_GET_ADAPTER_LOOP_ID; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1551 | mcp->mb[9] = vha->vp_idx; |
Andrew Vasquez | eb66dc6 | 2007-11-12 10:30:58 -0800 | [diff] [blame] | 1552 | mcp->out_mb = MBX_9|MBX_0; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1553 | mcp->in_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1554 | if (IS_CNA_CAPABLE(vha->hw)) |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1555 | mcp->in_mb |= MBX_13|MBX_12|MBX_11|MBX_10; |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 1556 | if (IS_FWI2_CAPABLE(vha->hw)) |
| 1557 | mcp->in_mb |= MBX_19|MBX_18|MBX_17|MBX_16; |
Sawan Chandak | 969a619 | 2016-01-27 12:03:32 -0500 | [diff] [blame] | 1558 | if (IS_QLA27XX(vha->hw)) |
| 1559 | mcp->in_mb |= MBX_15; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1560 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1561 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1562 | rval = qla2x00_mailbox_command(vha, mcp); |
Ravi Anand | 33135aa | 2005-11-08 14:37:20 -0800 | [diff] [blame] | 1563 | if (mcp->mb[0] == MBS_COMMAND_ERROR) |
| 1564 | rval = QLA_COMMAND_ERROR; |
Andrew Vasquez | 42e421b | 2008-07-10 16:56:01 -0700 | [diff] [blame] | 1565 | else if (mcp->mb[0] == MBS_INVALID_COMMAND) |
| 1566 | rval = QLA_INVALID_COMMAND; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1567 | |
| 1568 | /* Return data. */ |
| 1569 | *id = mcp->mb[1]; |
| 1570 | *al_pa = LSB(mcp->mb[2]); |
| 1571 | *area = MSB(mcp->mb[2]); |
| 1572 | *domain = LSB(mcp->mb[3]); |
| 1573 | *top = mcp->mb[6]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1574 | *sw_cap = mcp->mb[7]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1575 | |
| 1576 | if (rval != QLA_SUCCESS) { |
| 1577 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1578 | ql_dbg(ql_dbg_mbx, vha, 0x1047, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1579 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1580 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1048, |
| 1581 | "Done %s.\n", __func__); |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1582 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1583 | if (IS_CNA_CAPABLE(vha->hw)) { |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1584 | vha->fcoe_vlan_id = mcp->mb[9] & 0xfff; |
| 1585 | vha->fcoe_fcf_idx = mcp->mb[10]; |
| 1586 | vha->fcoe_vn_port_mac[5] = mcp->mb[11] >> 8; |
| 1587 | vha->fcoe_vn_port_mac[4] = mcp->mb[11] & 0xff; |
| 1588 | vha->fcoe_vn_port_mac[3] = mcp->mb[12] >> 8; |
| 1589 | vha->fcoe_vn_port_mac[2] = mcp->mb[12] & 0xff; |
| 1590 | vha->fcoe_vn_port_mac[1] = mcp->mb[13] >> 8; |
| 1591 | vha->fcoe_vn_port_mac[0] = mcp->mb[13] & 0xff; |
| 1592 | } |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 1593 | /* If FA-WWN supported */ |
Saurav Kashyap | d6b9b42 | 2015-08-04 13:37:55 -0400 | [diff] [blame] | 1594 | if (IS_FAWWN_CAPABLE(vha->hw)) { |
| 1595 | if (mcp->mb[7] & BIT_14) { |
| 1596 | vha->port_name[0] = MSB(mcp->mb[16]); |
| 1597 | vha->port_name[1] = LSB(mcp->mb[16]); |
| 1598 | vha->port_name[2] = MSB(mcp->mb[17]); |
| 1599 | vha->port_name[3] = LSB(mcp->mb[17]); |
| 1600 | vha->port_name[4] = MSB(mcp->mb[18]); |
| 1601 | vha->port_name[5] = LSB(mcp->mb[18]); |
| 1602 | vha->port_name[6] = MSB(mcp->mb[19]); |
| 1603 | vha->port_name[7] = LSB(mcp->mb[19]); |
| 1604 | fc_host_port_name(vha->host) = |
| 1605 | wwn_to_u64(vha->port_name); |
| 1606 | ql_dbg(ql_dbg_mbx, vha, 0x10ca, |
| 1607 | "FA-WWN acquired %016llx\n", |
| 1608 | wwn_to_u64(vha->port_name)); |
| 1609 | } |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 1610 | } |
Sawan Chandak | 969a619 | 2016-01-27 12:03:32 -0500 | [diff] [blame] | 1611 | |
| 1612 | if (IS_QLA27XX(vha->hw)) |
| 1613 | vha->bbcr = mcp->mb[15]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1614 | } |
| 1615 | |
| 1616 | return rval; |
| 1617 | } |
| 1618 | |
| 1619 | /* |
| 1620 | * qla2x00_get_retry_cnt |
| 1621 | * Get current firmware login retry count and delay. |
| 1622 | * |
| 1623 | * Input: |
| 1624 | * ha = adapter block pointer. |
| 1625 | * retry_cnt = pointer to login retry count. |
| 1626 | * tov = pointer to login timeout value. |
| 1627 | * |
| 1628 | * Returns: |
| 1629 | * qla2x00 local function return status code. |
| 1630 | * |
| 1631 | * Context: |
| 1632 | * Kernel context. |
| 1633 | */ |
| 1634 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1635 | qla2x00_get_retry_cnt(scsi_qla_host_t *vha, uint8_t *retry_cnt, uint8_t *tov, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1636 | uint16_t *r_a_tov) |
| 1637 | { |
| 1638 | int rval; |
| 1639 | uint16_t ratov; |
| 1640 | mbx_cmd_t mc; |
| 1641 | mbx_cmd_t *mcp = &mc; |
| 1642 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1643 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1049, |
| 1644 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1645 | |
| 1646 | mcp->mb[0] = MBC_GET_RETRY_COUNT; |
| 1647 | mcp->out_mb = MBX_0; |
| 1648 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1649 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1650 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1651 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1652 | |
| 1653 | if (rval != QLA_SUCCESS) { |
| 1654 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1655 | ql_dbg(ql_dbg_mbx, vha, 0x104a, |
| 1656 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1657 | } else { |
| 1658 | /* Convert returned data and check our values. */ |
| 1659 | *r_a_tov = mcp->mb[3] / 2; |
| 1660 | ratov = (mcp->mb[3]/2) / 10; /* mb[3] value is in 100ms */ |
| 1661 | if (mcp->mb[1] * ratov > (*retry_cnt) * (*tov)) { |
| 1662 | /* Update to the larger values */ |
| 1663 | *retry_cnt = (uint8_t)mcp->mb[1]; |
| 1664 | *tov = ratov; |
| 1665 | } |
| 1666 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1667 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104b, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1668 | "Done %s mb3=%d ratov=%d.\n", __func__, mcp->mb[3], ratov); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1669 | } |
| 1670 | |
| 1671 | return rval; |
| 1672 | } |
| 1673 | |
| 1674 | /* |
| 1675 | * qla2x00_init_firmware |
| 1676 | * Initialize adapter firmware. |
| 1677 | * |
| 1678 | * Input: |
| 1679 | * ha = adapter block pointer. |
| 1680 | * dptr = Initialization control block pointer. |
| 1681 | * size = size of initialization control block. |
| 1682 | * TARGET_QUEUE_LOCK must be released. |
| 1683 | * ADAPTER_STATE_LOCK must be released. |
| 1684 | * |
| 1685 | * Returns: |
| 1686 | * qla2x00 local function return status code. |
| 1687 | * |
| 1688 | * Context: |
| 1689 | * Kernel context. |
| 1690 | */ |
| 1691 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1692 | qla2x00_init_firmware(scsi_qla_host_t *vha, uint16_t size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1693 | { |
| 1694 | int rval; |
| 1695 | mbx_cmd_t mc; |
| 1696 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1697 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1698 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1699 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104c, |
| 1700 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1701 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1702 | if (IS_P3P_TYPE(ha) && ql2xdbwr) |
Bart Van Assche | 8dfa4b5a | 2015-07-09 07:24:50 -0700 | [diff] [blame] | 1703 | qla82xx_wr_32(ha, (uintptr_t __force)ha->nxdb_wr_ptr, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1704 | (0x04 | (ha->portnum << 5) | (0 << 8) | (0 << 16))); |
| 1705 | |
Andrew Vasquez | e6e074f | 2008-01-31 12:33:53 -0800 | [diff] [blame] | 1706 | if (ha->flags.npiv_supported) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1707 | mcp->mb[0] = MBC_MID_INITIALIZE_FIRMWARE; |
| 1708 | else |
| 1709 | mcp->mb[0] = MBC_INITIALIZE_FIRMWARE; |
| 1710 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 1711 | mcp->mb[1] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1712 | mcp->mb[2] = MSW(ha->init_cb_dma); |
| 1713 | mcp->mb[3] = LSW(ha->init_cb_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1714 | mcp->mb[6] = MSW(MSD(ha->init_cb_dma)); |
| 1715 | mcp->mb[7] = LSW(MSD(ha->init_cb_dma)); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 1716 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
Joe Carnuccio | 4ef21bd | 2013-10-30 03:38:11 -0400 | [diff] [blame] | 1717 | if (ha->ex_init_cb && ha->ex_init_cb->ex_version) { |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 1718 | mcp->mb[1] = BIT_0; |
| 1719 | mcp->mb[10] = MSW(ha->ex_init_cb_dma); |
| 1720 | mcp->mb[11] = LSW(ha->ex_init_cb_dma); |
| 1721 | mcp->mb[12] = MSW(MSD(ha->ex_init_cb_dma)); |
| 1722 | mcp->mb[13] = LSW(MSD(ha->ex_init_cb_dma)); |
| 1723 | mcp->mb[14] = sizeof(*ha->ex_init_cb); |
| 1724 | mcp->out_mb |= MBX_14|MBX_13|MBX_12|MBX_11|MBX_10; |
| 1725 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1726 | /* 1 and 2 should normally be captured. */ |
| 1727 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 1728 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1729 | /* mb3 is additional info about the installed SFP. */ |
| 1730 | mcp->in_mb |= MBX_3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1731 | mcp->buf_size = size; |
| 1732 | mcp->flags = MBX_DMA_OUT; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1733 | mcp->tov = MBX_TOV_SECONDS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1734 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1735 | |
| 1736 | if (rval != QLA_SUCCESS) { |
| 1737 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1738 | ql_dbg(ql_dbg_mbx, vha, 0x104d, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1739 | "Failed=%x mb[0]=%x, mb[1]=%x, mb[2]=%x, mb[3]=%x,.\n", |
| 1740 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2], mcp->mb[3]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1741 | } else { |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 1742 | if (IS_QLA27XX(ha)) { |
| 1743 | if (mcp->mb[2] == 6 || mcp->mb[3] == 2) |
| 1744 | ql_dbg(ql_dbg_mbx, vha, 0x119d, |
| 1745 | "Invalid SFP/Validation Failed\n"); |
| 1746 | } |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1747 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104e, |
| 1748 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1749 | } |
| 1750 | |
| 1751 | return rval; |
| 1752 | } |
| 1753 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 1754 | |
| 1755 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1756 | * qla2x00_get_port_database |
| 1757 | * Issue normal/enhanced get port database mailbox command |
| 1758 | * and copy device name as necessary. |
| 1759 | * |
| 1760 | * Input: |
| 1761 | * ha = adapter state pointer. |
| 1762 | * dev = structure pointer. |
| 1763 | * opt = enhanced cmd option byte. |
| 1764 | * |
| 1765 | * Returns: |
| 1766 | * qla2x00 local function return status code. |
| 1767 | * |
| 1768 | * Context: |
| 1769 | * Kernel context. |
| 1770 | */ |
| 1771 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1772 | qla2x00_get_port_database(scsi_qla_host_t *vha, fc_port_t *fcport, uint8_t opt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1773 | { |
| 1774 | int rval; |
| 1775 | mbx_cmd_t mc; |
| 1776 | mbx_cmd_t *mcp = &mc; |
| 1777 | port_database_t *pd; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1778 | struct port_database_24xx *pd24; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1779 | dma_addr_t pd_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1780 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1781 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1782 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104f, |
| 1783 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1784 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1785 | pd24 = NULL; |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 1786 | pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1787 | if (pd == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1788 | ql_log(ql_log_warn, vha, 0x1050, |
| 1789 | "Failed to allocate port database structure.\n"); |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 1790 | fcport->query = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1791 | return QLA_MEMORY_ALLOC_FAILED; |
| 1792 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1793 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1794 | mcp->mb[0] = MBC_GET_PORT_DATABASE; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1795 | if (opt != 0 && !IS_FWI2_CAPABLE(ha)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1796 | mcp->mb[0] = MBC_ENHANCED_GET_PORT_DATABASE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1797 | mcp->mb[2] = MSW(pd_dma); |
| 1798 | mcp->mb[3] = LSW(pd_dma); |
| 1799 | mcp->mb[6] = MSW(MSD(pd_dma)); |
| 1800 | mcp->mb[7] = LSW(MSD(pd_dma)); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1801 | mcp->mb[9] = vha->vp_idx; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1802 | mcp->out_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1803 | mcp->in_mb = MBX_0; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1804 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1805 | mcp->mb[1] = fcport->loop_id; |
| 1806 | mcp->mb[10] = opt; |
| 1807 | mcp->out_mb |= MBX_10|MBX_1; |
| 1808 | mcp->in_mb |= MBX_1; |
| 1809 | } else if (HAS_EXTENDED_IDS(ha)) { |
| 1810 | mcp->mb[1] = fcport->loop_id; |
| 1811 | mcp->mb[10] = opt; |
| 1812 | mcp->out_mb |= MBX_10|MBX_1; |
| 1813 | } else { |
| 1814 | mcp->mb[1] = fcport->loop_id << 8 | opt; |
| 1815 | mcp->out_mb |= MBX_1; |
| 1816 | } |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1817 | mcp->buf_size = IS_FWI2_CAPABLE(ha) ? |
| 1818 | PORT_DATABASE_24XX_SIZE : PORT_DATABASE_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1819 | mcp->flags = MBX_DMA_IN; |
| 1820 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1821 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1822 | if (rval != QLA_SUCCESS) |
| 1823 | goto gpd_error_out; |
| 1824 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1825 | if (IS_FWI2_CAPABLE(ha)) { |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1826 | uint64_t zero = 0; |
Duane Grigsby | c0c462c | 2017-10-13 09:34:05 -0700 | [diff] [blame] | 1827 | u8 current_login_state, last_login_state; |
| 1828 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1829 | pd24 = (struct port_database_24xx *) pd; |
| 1830 | |
| 1831 | /* Check for logged in state. */ |
Duane Grigsby | c0c462c | 2017-10-13 09:34:05 -0700 | [diff] [blame] | 1832 | if (fcport->fc4f_nvme) { |
| 1833 | current_login_state = pd24->current_login_state >> 4; |
| 1834 | last_login_state = pd24->last_login_state >> 4; |
| 1835 | } else { |
| 1836 | current_login_state = pd24->current_login_state & 0xf; |
| 1837 | last_login_state = pd24->last_login_state & 0xf; |
| 1838 | } |
| 1839 | fcport->current_login_state = pd24->current_login_state; |
| 1840 | fcport->last_login_state = pd24->last_login_state; |
| 1841 | |
| 1842 | /* Check for logged in state. */ |
| 1843 | if (current_login_state != PDS_PRLI_COMPLETE && |
| 1844 | last_login_state != PDS_PRLI_COMPLETE) { |
| 1845 | ql_dbg(ql_dbg_mbx, vha, 0x119a, |
| 1846 | "Unable to verify login-state (%x/%x) for loop_id %x.\n", |
| 1847 | current_login_state, last_login_state, |
| 1848 | fcport->loop_id); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1849 | rval = QLA_FUNCTION_FAILED; |
Duane Grigsby | c0c462c | 2017-10-13 09:34:05 -0700 | [diff] [blame] | 1850 | |
| 1851 | if (!fcport->query) |
| 1852 | goto gpd_error_out; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1853 | } |
| 1854 | |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1855 | if (fcport->loop_id == FC_NO_LOOP_ID || |
| 1856 | (memcmp(fcport->port_name, (uint8_t *)&zero, 8) && |
| 1857 | memcmp(fcport->port_name, pd24->port_name, 8))) { |
| 1858 | /* We lost the device mid way. */ |
| 1859 | rval = QLA_NOT_LOGGED_IN; |
| 1860 | goto gpd_error_out; |
| 1861 | } |
| 1862 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1863 | /* Names are little-endian. */ |
| 1864 | memcpy(fcport->node_name, pd24->node_name, WWN_SIZE); |
| 1865 | memcpy(fcport->port_name, pd24->port_name, WWN_SIZE); |
| 1866 | |
| 1867 | /* Get port_id of device. */ |
| 1868 | fcport->d_id.b.domain = pd24->port_id[0]; |
| 1869 | fcport->d_id.b.area = pd24->port_id[1]; |
| 1870 | fcport->d_id.b.al_pa = pd24->port_id[2]; |
| 1871 | fcport->d_id.b.rsvd_1 = 0; |
| 1872 | |
| 1873 | /* If not target must be initiator or unknown type. */ |
| 1874 | if ((pd24->prli_svc_param_word_3[0] & BIT_4) == 0) |
| 1875 | fcport->port_type = FCT_INITIATOR; |
| 1876 | else |
| 1877 | fcport->port_type = FCT_TARGET; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 1878 | |
| 1879 | /* Passback COS information. */ |
| 1880 | fcport->supported_classes = (pd24->flags & PDF_CLASS_2) ? |
| 1881 | FC_COS_CLASS2 : FC_COS_CLASS3; |
| 1882 | |
| 1883 | if (pd24->prli_svc_param_word_3[0] & BIT_7) |
| 1884 | fcport->flags |= FCF_CONF_COMP_SUPPORTED; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1885 | } else { |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1886 | uint64_t zero = 0; |
| 1887 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1888 | /* Check for logged in state. */ |
| 1889 | if (pd->master_state != PD_STATE_PORT_LOGGED_IN && |
| 1890 | pd->slave_state != PD_STATE_PORT_LOGGED_IN) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1891 | ql_dbg(ql_dbg_mbx, vha, 0x100a, |
| 1892 | "Unable to verify login-state (%x/%x) - " |
| 1893 | "portid=%02x%02x%02x.\n", pd->master_state, |
| 1894 | pd->slave_state, fcport->d_id.b.domain, |
| 1895 | fcport->d_id.b.area, fcport->d_id.b.al_pa); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1896 | rval = QLA_FUNCTION_FAILED; |
| 1897 | goto gpd_error_out; |
| 1898 | } |
| 1899 | |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1900 | if (fcport->loop_id == FC_NO_LOOP_ID || |
| 1901 | (memcmp(fcport->port_name, (uint8_t *)&zero, 8) && |
| 1902 | memcmp(fcport->port_name, pd->port_name, 8))) { |
| 1903 | /* We lost the device mid way. */ |
| 1904 | rval = QLA_NOT_LOGGED_IN; |
| 1905 | goto gpd_error_out; |
| 1906 | } |
| 1907 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1908 | /* Names are little-endian. */ |
| 1909 | memcpy(fcport->node_name, pd->node_name, WWN_SIZE); |
| 1910 | memcpy(fcport->port_name, pd->port_name, WWN_SIZE); |
| 1911 | |
| 1912 | /* Get port_id of device. */ |
| 1913 | fcport->d_id.b.domain = pd->port_id[0]; |
| 1914 | fcport->d_id.b.area = pd->port_id[3]; |
| 1915 | fcport->d_id.b.al_pa = pd->port_id[2]; |
| 1916 | fcport->d_id.b.rsvd_1 = 0; |
| 1917 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1918 | /* If not target must be initiator or unknown type. */ |
| 1919 | if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0) |
| 1920 | fcport->port_type = FCT_INITIATOR; |
| 1921 | else |
| 1922 | fcport->port_type = FCT_TARGET; |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 1923 | |
| 1924 | /* Passback COS information. */ |
| 1925 | fcport->supported_classes = (pd->options & BIT_4) ? |
| 1926 | FC_COS_CLASS2: FC_COS_CLASS3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1927 | } |
| 1928 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1929 | gpd_error_out: |
| 1930 | dma_pool_free(ha->s_dma_pool, pd, pd_dma); |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 1931 | fcport->query = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1932 | |
| 1933 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1934 | ql_dbg(ql_dbg_mbx, vha, 0x1052, |
| 1935 | "Failed=%x mb[0]=%x mb[1]=%x.\n", rval, |
| 1936 | mcp->mb[0], mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1937 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1938 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1053, |
| 1939 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1940 | } |
| 1941 | |
| 1942 | return rval; |
| 1943 | } |
| 1944 | |
| 1945 | /* |
| 1946 | * qla2x00_get_firmware_state |
| 1947 | * Get adapter firmware state. |
| 1948 | * |
| 1949 | * Input: |
| 1950 | * ha = adapter block pointer. |
| 1951 | * dptr = pointer for firmware state. |
| 1952 | * TARGET_QUEUE_LOCK must be released. |
| 1953 | * ADAPTER_STATE_LOCK must be released. |
| 1954 | * |
| 1955 | * Returns: |
| 1956 | * qla2x00 local function return status code. |
| 1957 | * |
| 1958 | * Context: |
| 1959 | * Kernel context. |
| 1960 | */ |
| 1961 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1962 | qla2x00_get_firmware_state(scsi_qla_host_t *vha, uint16_t *states) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1963 | { |
| 1964 | int rval; |
| 1965 | mbx_cmd_t mc; |
| 1966 | mbx_cmd_t *mcp = &mc; |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 1967 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1968 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1969 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1054, |
| 1970 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1971 | |
| 1972 | mcp->mb[0] = MBC_GET_FIRMWARE_STATE; |
| 1973 | mcp->out_mb = MBX_0; |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 1974 | if (IS_FWI2_CAPABLE(vha->hw)) |
Joe Carnuccio | b5a340d | 2014-09-25 05:16:48 -0400 | [diff] [blame] | 1975 | mcp->in_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 1976 | else |
| 1977 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1978 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1979 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1980 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1981 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1982 | /* Return firmware states. */ |
| 1983 | states[0] = mcp->mb[1]; |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 1984 | if (IS_FWI2_CAPABLE(vha->hw)) { |
| 1985 | states[1] = mcp->mb[2]; |
Joe Carnuccio | ec89146 | 2016-07-06 11:14:26 -0400 | [diff] [blame] | 1986 | states[2] = mcp->mb[3]; /* SFP info */ |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 1987 | states[3] = mcp->mb[4]; |
| 1988 | states[4] = mcp->mb[5]; |
Joe Carnuccio | b5a340d | 2014-09-25 05:16:48 -0400 | [diff] [blame] | 1989 | states[5] = mcp->mb[6]; /* DPORT status */ |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 1990 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1991 | |
| 1992 | if (rval != QLA_SUCCESS) { |
| 1993 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1994 | ql_dbg(ql_dbg_mbx, vha, 0x1055, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1995 | } else { |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 1996 | if (IS_QLA27XX(ha)) { |
| 1997 | if (mcp->mb[2] == 6 || mcp->mb[3] == 2) |
| 1998 | ql_dbg(ql_dbg_mbx, vha, 0x119e, |
| 1999 | "Invalid SFP/Validation Failed\n"); |
| 2000 | } |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2001 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1056, |
| 2002 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2003 | } |
| 2004 | |
| 2005 | return rval; |
| 2006 | } |
| 2007 | |
| 2008 | /* |
| 2009 | * qla2x00_get_port_name |
| 2010 | * Issue get port name mailbox command. |
| 2011 | * Returned name is in big endian format. |
| 2012 | * |
| 2013 | * Input: |
| 2014 | * ha = adapter block pointer. |
| 2015 | * loop_id = loop ID of device. |
| 2016 | * name = pointer for name. |
| 2017 | * TARGET_QUEUE_LOCK must be released. |
| 2018 | * ADAPTER_STATE_LOCK must be released. |
| 2019 | * |
| 2020 | * Returns: |
| 2021 | * qla2x00 local function return status code. |
| 2022 | * |
| 2023 | * Context: |
| 2024 | * Kernel context. |
| 2025 | */ |
| 2026 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2027 | qla2x00_get_port_name(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t *name, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2028 | uint8_t opt) |
| 2029 | { |
| 2030 | int rval; |
| 2031 | mbx_cmd_t mc; |
| 2032 | mbx_cmd_t *mcp = &mc; |
| 2033 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2034 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1057, |
| 2035 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2036 | |
| 2037 | mcp->mb[0] = MBC_GET_PORT_NAME; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2038 | mcp->mb[9] = vha->vp_idx; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2039 | mcp->out_mb = MBX_9|MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2040 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2041 | mcp->mb[1] = loop_id; |
| 2042 | mcp->mb[10] = opt; |
| 2043 | mcp->out_mb |= MBX_10; |
| 2044 | } else { |
| 2045 | mcp->mb[1] = loop_id << 8 | opt; |
| 2046 | } |
| 2047 | |
| 2048 | mcp->in_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2049 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2050 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2051 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2052 | |
| 2053 | if (rval != QLA_SUCCESS) { |
| 2054 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2055 | ql_dbg(ql_dbg_mbx, vha, 0x1058, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2056 | } else { |
| 2057 | if (name != NULL) { |
| 2058 | /* This function returns name in big endian. */ |
Richard Lary | 1196ae0 | 2007-03-22 10:53:19 -0500 | [diff] [blame] | 2059 | name[0] = MSB(mcp->mb[2]); |
| 2060 | name[1] = LSB(mcp->mb[2]); |
| 2061 | name[2] = MSB(mcp->mb[3]); |
| 2062 | name[3] = LSB(mcp->mb[3]); |
| 2063 | name[4] = MSB(mcp->mb[6]); |
| 2064 | name[5] = LSB(mcp->mb[6]); |
| 2065 | name[6] = MSB(mcp->mb[7]); |
| 2066 | name[7] = LSB(mcp->mb[7]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2067 | } |
| 2068 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2069 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1059, |
| 2070 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2071 | } |
| 2072 | |
| 2073 | return rval; |
| 2074 | } |
| 2075 | |
| 2076 | /* |
Joe Carnuccio | 61e1b26 | 2013-02-08 01:57:48 -0500 | [diff] [blame] | 2077 | * qla24xx_link_initialization |
| 2078 | * Issue link initialization mailbox command. |
| 2079 | * |
| 2080 | * Input: |
| 2081 | * ha = adapter block pointer. |
| 2082 | * TARGET_QUEUE_LOCK must be released. |
| 2083 | * ADAPTER_STATE_LOCK must be released. |
| 2084 | * |
| 2085 | * Returns: |
| 2086 | * qla2x00 local function return status code. |
| 2087 | * |
| 2088 | * Context: |
| 2089 | * Kernel context. |
| 2090 | */ |
| 2091 | int |
| 2092 | qla24xx_link_initialize(scsi_qla_host_t *vha) |
| 2093 | { |
| 2094 | int rval; |
| 2095 | mbx_cmd_t mc; |
| 2096 | mbx_cmd_t *mcp = &mc; |
| 2097 | |
| 2098 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1152, |
| 2099 | "Entered %s.\n", __func__); |
| 2100 | |
| 2101 | if (!IS_FWI2_CAPABLE(vha->hw) || IS_CNA_CAPABLE(vha->hw)) |
| 2102 | return QLA_FUNCTION_FAILED; |
| 2103 | |
| 2104 | mcp->mb[0] = MBC_LINK_INITIALIZATION; |
Joe Carnuccio | 5a5c27b | 2013-08-27 01:37:49 -0400 | [diff] [blame] | 2105 | mcp->mb[1] = BIT_4; |
| 2106 | if (vha->hw->operating_mode == LOOP) |
| 2107 | mcp->mb[1] |= BIT_6; |
| 2108 | else |
| 2109 | mcp->mb[1] |= BIT_5; |
Joe Carnuccio | 61e1b26 | 2013-02-08 01:57:48 -0500 | [diff] [blame] | 2110 | mcp->mb[2] = 0; |
| 2111 | mcp->mb[3] = 0; |
| 2112 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 2113 | mcp->in_mb = MBX_0; |
| 2114 | mcp->tov = MBX_TOV_SECONDS; |
| 2115 | mcp->flags = 0; |
| 2116 | rval = qla2x00_mailbox_command(vha, mcp); |
| 2117 | |
| 2118 | if (rval != QLA_SUCCESS) { |
| 2119 | ql_dbg(ql_dbg_mbx, vha, 0x1153, "Failed=%x.\n", rval); |
| 2120 | } else { |
| 2121 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1154, |
| 2122 | "Done %s.\n", __func__); |
| 2123 | } |
| 2124 | |
| 2125 | return rval; |
| 2126 | } |
| 2127 | |
| 2128 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2129 | * qla2x00_lip_reset |
| 2130 | * Issue LIP reset mailbox command. |
| 2131 | * |
| 2132 | * Input: |
| 2133 | * ha = adapter block pointer. |
| 2134 | * TARGET_QUEUE_LOCK must be released. |
| 2135 | * ADAPTER_STATE_LOCK must be released. |
| 2136 | * |
| 2137 | * Returns: |
| 2138 | * qla2x00 local function return status code. |
| 2139 | * |
| 2140 | * Context: |
| 2141 | * Kernel context. |
| 2142 | */ |
| 2143 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2144 | qla2x00_lip_reset(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2145 | { |
| 2146 | int rval; |
| 2147 | mbx_cmd_t mc; |
| 2148 | mbx_cmd_t *mcp = &mc; |
| 2149 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2150 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105a, |
| 2151 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2152 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2153 | if (IS_CNA_CAPABLE(vha->hw)) { |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2154 | /* Logout across all FCFs. */ |
| 2155 | mcp->mb[0] = MBC_LIP_FULL_LOGIN; |
| 2156 | mcp->mb[1] = BIT_1; |
| 2157 | mcp->mb[2] = 0; |
| 2158 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 2159 | } else if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2160 | mcp->mb[0] = MBC_LIP_FULL_LOGIN; |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 2161 | mcp->mb[1] = BIT_6; |
| 2162 | mcp->mb[2] = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2163 | mcp->mb[3] = vha->hw->loop_reset_delay; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2164 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2165 | } else { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2166 | mcp->mb[0] = MBC_LIP_RESET; |
| 2167 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2168 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2169 | mcp->mb[1] = 0x00ff; |
| 2170 | mcp->mb[10] = 0; |
| 2171 | mcp->out_mb |= MBX_10; |
| 2172 | } else { |
| 2173 | mcp->mb[1] = 0xff00; |
| 2174 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2175 | mcp->mb[2] = vha->hw->loop_reset_delay; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2176 | mcp->mb[3] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2177 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2178 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2179 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2180 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2181 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2182 | |
| 2183 | if (rval != QLA_SUCCESS) { |
| 2184 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2185 | ql_dbg(ql_dbg_mbx, vha, 0x105b, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2186 | } else { |
| 2187 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2188 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105c, |
| 2189 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2190 | } |
| 2191 | |
| 2192 | return rval; |
| 2193 | } |
| 2194 | |
| 2195 | /* |
| 2196 | * qla2x00_send_sns |
| 2197 | * Send SNS command. |
| 2198 | * |
| 2199 | * Input: |
| 2200 | * ha = adapter block pointer. |
| 2201 | * sns = pointer for command. |
| 2202 | * cmd_size = command size. |
| 2203 | * buf_size = response/command size. |
| 2204 | * TARGET_QUEUE_LOCK must be released. |
| 2205 | * ADAPTER_STATE_LOCK must be released. |
| 2206 | * |
| 2207 | * Returns: |
| 2208 | * qla2x00 local function return status code. |
| 2209 | * |
| 2210 | * Context: |
| 2211 | * Kernel context. |
| 2212 | */ |
| 2213 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2214 | qla2x00_send_sns(scsi_qla_host_t *vha, dma_addr_t sns_phys_address, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2215 | uint16_t cmd_size, size_t buf_size) |
| 2216 | { |
| 2217 | int rval; |
| 2218 | mbx_cmd_t mc; |
| 2219 | mbx_cmd_t *mcp = &mc; |
| 2220 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2221 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105d, |
| 2222 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2223 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2224 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105e, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2225 | "Retry cnt=%d ratov=%d total tov=%d.\n", |
| 2226 | vha->hw->retry_count, vha->hw->login_timeout, mcp->tov); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2227 | |
| 2228 | mcp->mb[0] = MBC_SEND_SNS_COMMAND; |
| 2229 | mcp->mb[1] = cmd_size; |
| 2230 | mcp->mb[2] = MSW(sns_phys_address); |
| 2231 | mcp->mb[3] = LSW(sns_phys_address); |
| 2232 | mcp->mb[6] = MSW(MSD(sns_phys_address)); |
| 2233 | mcp->mb[7] = LSW(MSD(sns_phys_address)); |
| 2234 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 2235 | mcp->in_mb = MBX_0|MBX_1; |
| 2236 | mcp->buf_size = buf_size; |
| 2237 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2238 | mcp->tov = (vha->hw->login_timeout * 2) + (vha->hw->login_timeout / 2); |
| 2239 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2240 | |
| 2241 | if (rval != QLA_SUCCESS) { |
| 2242 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2243 | ql_dbg(ql_dbg_mbx, vha, 0x105f, |
| 2244 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 2245 | rval, mcp->mb[0], mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2246 | } else { |
| 2247 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2248 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1060, |
| 2249 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2250 | } |
| 2251 | |
| 2252 | return rval; |
| 2253 | } |
| 2254 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2255 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2256 | qla24xx_login_fabric(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain, |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2257 | uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt) |
| 2258 | { |
| 2259 | int rval; |
| 2260 | |
| 2261 | struct logio_entry_24xx *lg; |
| 2262 | dma_addr_t lg_dma; |
| 2263 | uint32_t iop[2]; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2264 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2265 | struct req_que *req; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2266 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2267 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1061, |
| 2268 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2269 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2270 | if (vha->vp_idx && vha->qpair) |
| 2271 | req = vha->qpair->req; |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2272 | else |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2273 | req = ha->req_q_map[0]; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2274 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 2275 | lg = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2276 | if (lg == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2277 | ql_log(ql_log_warn, vha, 0x1062, |
| 2278 | "Failed to allocate login IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2279 | return QLA_MEMORY_ALLOC_FAILED; |
| 2280 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2281 | |
| 2282 | lg->entry_type = LOGINOUT_PORT_IOCB_TYPE; |
| 2283 | lg->entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2284 | lg->handle = MAKE_HANDLE(req->id, lg->handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2285 | lg->nport_handle = cpu_to_le16(loop_id); |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2286 | lg->control_flags = cpu_to_le16(LCF_COMMAND_PLOGI); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2287 | if (opt & BIT_0) |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2288 | lg->control_flags |= cpu_to_le16(LCF_COND_PLOGI); |
Andrew Vasquez | 8baa51a | 2006-06-23 16:10:44 -0700 | [diff] [blame] | 2289 | if (opt & BIT_1) |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2290 | lg->control_flags |= cpu_to_le16(LCF_SKIP_PRLI); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2291 | lg->port_id[0] = al_pa; |
| 2292 | lg->port_id[1] = area; |
| 2293 | lg->port_id[2] = domain; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2294 | lg->vp_index = vha->vp_idx; |
Andrew Vasquez | 7f45dd0 | 2012-02-09 11:15:45 -0800 | [diff] [blame] | 2295 | rval = qla2x00_issue_iocb_timeout(vha, lg, lg_dma, 0, |
| 2296 | (ha->r_a_tov / 10 * 2) + 2); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2297 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2298 | ql_dbg(ql_dbg_mbx, vha, 0x1063, |
| 2299 | "Failed to issue login IOCB (%x).\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2300 | } else if (lg->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2301 | ql_dbg(ql_dbg_mbx, vha, 0x1064, |
| 2302 | "Failed to complete IOCB -- error status (%x).\n", |
| 2303 | lg->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2304 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2305 | } else if (lg->comp_status != cpu_to_le16(CS_COMPLETE)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2306 | iop[0] = le32_to_cpu(lg->io_parameter[0]); |
| 2307 | iop[1] = le32_to_cpu(lg->io_parameter[1]); |
| 2308 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2309 | ql_dbg(ql_dbg_mbx, vha, 0x1065, |
| 2310 | "Failed to complete IOCB -- completion status (%x) " |
| 2311 | "ioparam=%x/%x.\n", le16_to_cpu(lg->comp_status), |
| 2312 | iop[0], iop[1]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2313 | |
| 2314 | switch (iop[0]) { |
| 2315 | case LSC_SCODE_PORTID_USED: |
| 2316 | mb[0] = MBS_PORT_ID_USED; |
| 2317 | mb[1] = LSW(iop[1]); |
| 2318 | break; |
| 2319 | case LSC_SCODE_NPORT_USED: |
| 2320 | mb[0] = MBS_LOOP_ID_USED; |
| 2321 | break; |
| 2322 | case LSC_SCODE_NOLINK: |
| 2323 | case LSC_SCODE_NOIOCB: |
| 2324 | case LSC_SCODE_NOXCB: |
| 2325 | case LSC_SCODE_CMD_FAILED: |
| 2326 | case LSC_SCODE_NOFABRIC: |
| 2327 | case LSC_SCODE_FW_NOT_READY: |
| 2328 | case LSC_SCODE_NOT_LOGGED_IN: |
| 2329 | case LSC_SCODE_NOPCB: |
| 2330 | case LSC_SCODE_ELS_REJECT: |
| 2331 | case LSC_SCODE_CMD_PARAM_ERR: |
| 2332 | case LSC_SCODE_NONPORT: |
| 2333 | case LSC_SCODE_LOGGED_IN: |
| 2334 | case LSC_SCODE_NOFLOGI_ACC: |
| 2335 | default: |
| 2336 | mb[0] = MBS_COMMAND_ERROR; |
| 2337 | break; |
| 2338 | } |
| 2339 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2340 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1066, |
| 2341 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2342 | |
| 2343 | iop[0] = le32_to_cpu(lg->io_parameter[0]); |
| 2344 | |
| 2345 | mb[0] = MBS_COMMAND_COMPLETE; |
| 2346 | mb[1] = 0; |
| 2347 | if (iop[0] & BIT_4) { |
| 2348 | if (iop[0] & BIT_8) |
| 2349 | mb[1] |= BIT_1; |
| 2350 | } else |
| 2351 | mb[1] = BIT_0; |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 2352 | |
| 2353 | /* Passback COS information. */ |
| 2354 | mb[10] = 0; |
| 2355 | if (lg->io_parameter[7] || lg->io_parameter[8]) |
| 2356 | mb[10] |= BIT_0; /* Class 2. */ |
| 2357 | if (lg->io_parameter[9] || lg->io_parameter[10]) |
| 2358 | mb[10] |= BIT_1; /* Class 3. */ |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2359 | if (lg->io_parameter[0] & cpu_to_le32(BIT_7)) |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2360 | mb[10] |= BIT_7; /* Confirmed Completion |
| 2361 | * Allowed |
| 2362 | */ |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2363 | } |
| 2364 | |
| 2365 | dma_pool_free(ha->s_dma_pool, lg, lg_dma); |
| 2366 | |
| 2367 | return rval; |
| 2368 | } |
| 2369 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2370 | /* |
| 2371 | * qla2x00_login_fabric |
| 2372 | * Issue login fabric port mailbox command. |
| 2373 | * |
| 2374 | * Input: |
| 2375 | * ha = adapter block pointer. |
| 2376 | * loop_id = device loop ID. |
| 2377 | * domain = device domain. |
| 2378 | * area = device area. |
| 2379 | * al_pa = device AL_PA. |
| 2380 | * status = pointer for return status. |
| 2381 | * opt = command options. |
| 2382 | * TARGET_QUEUE_LOCK must be released. |
| 2383 | * ADAPTER_STATE_LOCK must be released. |
| 2384 | * |
| 2385 | * Returns: |
| 2386 | * qla2x00 local function return status code. |
| 2387 | * |
| 2388 | * Context: |
| 2389 | * Kernel context. |
| 2390 | */ |
| 2391 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2392 | qla2x00_login_fabric(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2393 | uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt) |
| 2394 | { |
| 2395 | int rval; |
| 2396 | mbx_cmd_t mc; |
| 2397 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2398 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2399 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2400 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1067, |
| 2401 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2402 | |
| 2403 | mcp->mb[0] = MBC_LOGIN_FABRIC_PORT; |
| 2404 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 2405 | if (HAS_EXTENDED_IDS(ha)) { |
| 2406 | mcp->mb[1] = loop_id; |
| 2407 | mcp->mb[10] = opt; |
| 2408 | mcp->out_mb |= MBX_10; |
| 2409 | } else { |
| 2410 | mcp->mb[1] = (loop_id << 8) | opt; |
| 2411 | } |
| 2412 | mcp->mb[2] = domain; |
| 2413 | mcp->mb[3] = area << 8 | al_pa; |
| 2414 | |
| 2415 | mcp->in_mb = MBX_7|MBX_6|MBX_2|MBX_1|MBX_0; |
| 2416 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
| 2417 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2418 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2419 | |
| 2420 | /* Return mailbox statuses. */ |
| 2421 | if (mb != NULL) { |
| 2422 | mb[0] = mcp->mb[0]; |
| 2423 | mb[1] = mcp->mb[1]; |
| 2424 | mb[2] = mcp->mb[2]; |
| 2425 | mb[6] = mcp->mb[6]; |
| 2426 | mb[7] = mcp->mb[7]; |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 2427 | /* COS retrieved from Get-Port-Database mailbox command. */ |
| 2428 | mb[10] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2429 | } |
| 2430 | |
| 2431 | if (rval != QLA_SUCCESS) { |
| 2432 | /* RLU tmp code: need to change main mailbox_command function to |
| 2433 | * return ok even when the mailbox completion value is not |
| 2434 | * SUCCESS. The caller needs to be responsible to interpret |
| 2435 | * the return values of this mailbox command if we're not |
| 2436 | * to change too much of the existing code. |
| 2437 | */ |
| 2438 | if (mcp->mb[0] == 0x4001 || mcp->mb[0] == 0x4002 || |
| 2439 | mcp->mb[0] == 0x4003 || mcp->mb[0] == 0x4005 || |
| 2440 | mcp->mb[0] == 0x4006) |
| 2441 | rval = QLA_SUCCESS; |
| 2442 | |
| 2443 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2444 | ql_dbg(ql_dbg_mbx, vha, 0x1068, |
| 2445 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 2446 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2447 | } else { |
| 2448 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2449 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1069, |
| 2450 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2451 | } |
| 2452 | |
| 2453 | return rval; |
| 2454 | } |
| 2455 | |
| 2456 | /* |
| 2457 | * qla2x00_login_local_device |
| 2458 | * Issue login loop port mailbox command. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2459 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2460 | * Input: |
| 2461 | * ha = adapter block pointer. |
| 2462 | * loop_id = device loop ID. |
| 2463 | * opt = command options. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2464 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2465 | * Returns: |
| 2466 | * Return status code. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2467 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2468 | * Context: |
| 2469 | * Kernel context. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2470 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2471 | */ |
| 2472 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2473 | qla2x00_login_local_device(scsi_qla_host_t *vha, fc_port_t *fcport, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2474 | uint16_t *mb_ret, uint8_t opt) |
| 2475 | { |
| 2476 | int rval; |
| 2477 | mbx_cmd_t mc; |
| 2478 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2479 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2480 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2481 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106a, |
| 2482 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2483 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2484 | if (IS_FWI2_CAPABLE(ha)) |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2485 | return qla24xx_login_fabric(vha, fcport->loop_id, |
andrew.vasquez@qlogic.com | 9a52a57c | 2006-03-09 14:27:44 -0800 | [diff] [blame] | 2486 | fcport->d_id.b.domain, fcport->d_id.b.area, |
| 2487 | fcport->d_id.b.al_pa, mb_ret, opt); |
| 2488 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2489 | mcp->mb[0] = MBC_LOGIN_LOOP_PORT; |
| 2490 | if (HAS_EXTENDED_IDS(ha)) |
andrew.vasquez@qlogic.com | 9a52a57c | 2006-03-09 14:27:44 -0800 | [diff] [blame] | 2491 | mcp->mb[1] = fcport->loop_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2492 | else |
andrew.vasquez@qlogic.com | 9a52a57c | 2006-03-09 14:27:44 -0800 | [diff] [blame] | 2493 | mcp->mb[1] = fcport->loop_id << 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2494 | mcp->mb[2] = opt; |
| 2495 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 2496 | mcp->in_mb = MBX_7|MBX_6|MBX_1|MBX_0; |
| 2497 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
| 2498 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2499 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2500 | |
| 2501 | /* Return mailbox statuses. */ |
| 2502 | if (mb_ret != NULL) { |
| 2503 | mb_ret[0] = mcp->mb[0]; |
| 2504 | mb_ret[1] = mcp->mb[1]; |
| 2505 | mb_ret[6] = mcp->mb[6]; |
| 2506 | mb_ret[7] = mcp->mb[7]; |
| 2507 | } |
| 2508 | |
| 2509 | if (rval != QLA_SUCCESS) { |
| 2510 | /* AV tmp code: need to change main mailbox_command function to |
| 2511 | * return ok even when the mailbox completion value is not |
| 2512 | * SUCCESS. The caller needs to be responsible to interpret |
| 2513 | * the return values of this mailbox command if we're not |
| 2514 | * to change too much of the existing code. |
| 2515 | */ |
| 2516 | if (mcp->mb[0] == 0x4005 || mcp->mb[0] == 0x4006) |
| 2517 | rval = QLA_SUCCESS; |
| 2518 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2519 | ql_dbg(ql_dbg_mbx, vha, 0x106b, |
| 2520 | "Failed=%x mb[0]=%x mb[1]=%x mb[6]=%x mb[7]=%x.\n", |
| 2521 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[6], mcp->mb[7]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2522 | } else { |
| 2523 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2524 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106c, |
| 2525 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2526 | } |
| 2527 | |
| 2528 | return (rval); |
| 2529 | } |
| 2530 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2531 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2532 | qla24xx_fabric_logout(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain, |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2533 | uint8_t area, uint8_t al_pa) |
| 2534 | { |
| 2535 | int rval; |
| 2536 | struct logio_entry_24xx *lg; |
| 2537 | dma_addr_t lg_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2538 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2539 | struct req_que *req; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2540 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2541 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106d, |
| 2542 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2543 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 2544 | lg = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2545 | if (lg == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2546 | ql_log(ql_log_warn, vha, 0x106e, |
| 2547 | "Failed to allocate logout IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2548 | return QLA_MEMORY_ALLOC_FAILED; |
| 2549 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2550 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2551 | req = vha->req; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2552 | lg->entry_type = LOGINOUT_PORT_IOCB_TYPE; |
| 2553 | lg->entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2554 | lg->handle = MAKE_HANDLE(req->id, lg->handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2555 | lg->nport_handle = cpu_to_le16(loop_id); |
| 2556 | lg->control_flags = |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2557 | cpu_to_le16(LCF_COMMAND_LOGO|LCF_IMPL_LOGO| |
Andrew Vasquez | c8d6691 | 2011-03-30 11:46:21 -0700 | [diff] [blame] | 2558 | LCF_FREE_NPORT); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2559 | lg->port_id[0] = al_pa; |
| 2560 | lg->port_id[1] = area; |
| 2561 | lg->port_id[2] = domain; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2562 | lg->vp_index = vha->vp_idx; |
Andrew Vasquez | 7f45dd0 | 2012-02-09 11:15:45 -0800 | [diff] [blame] | 2563 | rval = qla2x00_issue_iocb_timeout(vha, lg, lg_dma, 0, |
| 2564 | (ha->r_a_tov / 10 * 2) + 2); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2565 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2566 | ql_dbg(ql_dbg_mbx, vha, 0x106f, |
| 2567 | "Failed to issue logout IOCB (%x).\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2568 | } else if (lg->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2569 | ql_dbg(ql_dbg_mbx, vha, 0x1070, |
| 2570 | "Failed to complete IOCB -- error status (%x).\n", |
| 2571 | lg->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2572 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2573 | } else if (lg->comp_status != cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2574 | ql_dbg(ql_dbg_mbx, vha, 0x1071, |
| 2575 | "Failed to complete IOCB -- completion status (%x) " |
| 2576 | "ioparam=%x/%x.\n", le16_to_cpu(lg->comp_status), |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2577 | le32_to_cpu(lg->io_parameter[0]), |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2578 | le32_to_cpu(lg->io_parameter[1])); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2579 | } else { |
| 2580 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2581 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1072, |
| 2582 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2583 | } |
| 2584 | |
| 2585 | dma_pool_free(ha->s_dma_pool, lg, lg_dma); |
| 2586 | |
| 2587 | return rval; |
| 2588 | } |
| 2589 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2590 | /* |
| 2591 | * qla2x00_fabric_logout |
| 2592 | * Issue logout fabric port mailbox command. |
| 2593 | * |
| 2594 | * Input: |
| 2595 | * ha = adapter block pointer. |
| 2596 | * loop_id = device loop ID. |
| 2597 | * TARGET_QUEUE_LOCK must be released. |
| 2598 | * ADAPTER_STATE_LOCK must be released. |
| 2599 | * |
| 2600 | * Returns: |
| 2601 | * qla2x00 local function return status code. |
| 2602 | * |
| 2603 | * Context: |
| 2604 | * Kernel context. |
| 2605 | */ |
| 2606 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2607 | qla2x00_fabric_logout(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain, |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2608 | uint8_t area, uint8_t al_pa) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2609 | { |
| 2610 | int rval; |
| 2611 | mbx_cmd_t mc; |
| 2612 | mbx_cmd_t *mcp = &mc; |
| 2613 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2614 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1073, |
| 2615 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2616 | |
| 2617 | mcp->mb[0] = MBC_LOGOUT_FABRIC_PORT; |
| 2618 | mcp->out_mb = MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2619 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2620 | mcp->mb[1] = loop_id; |
| 2621 | mcp->mb[10] = 0; |
| 2622 | mcp->out_mb |= MBX_10; |
| 2623 | } else { |
| 2624 | mcp->mb[1] = loop_id << 8; |
| 2625 | } |
| 2626 | |
| 2627 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2628 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2629 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2630 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2631 | |
| 2632 | if (rval != QLA_SUCCESS) { |
| 2633 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2634 | ql_dbg(ql_dbg_mbx, vha, 0x1074, |
| 2635 | "Failed=%x mb[1]=%x.\n", rval, mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2636 | } else { |
| 2637 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2638 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1075, |
| 2639 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2640 | } |
| 2641 | |
| 2642 | return rval; |
| 2643 | } |
| 2644 | |
| 2645 | /* |
| 2646 | * qla2x00_full_login_lip |
| 2647 | * Issue full login LIP mailbox command. |
| 2648 | * |
| 2649 | * Input: |
| 2650 | * ha = adapter block pointer. |
| 2651 | * TARGET_QUEUE_LOCK must be released. |
| 2652 | * ADAPTER_STATE_LOCK must be released. |
| 2653 | * |
| 2654 | * Returns: |
| 2655 | * qla2x00 local function return status code. |
| 2656 | * |
| 2657 | * Context: |
| 2658 | * Kernel context. |
| 2659 | */ |
| 2660 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2661 | qla2x00_full_login_lip(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2662 | { |
| 2663 | int rval; |
| 2664 | mbx_cmd_t mc; |
| 2665 | mbx_cmd_t *mcp = &mc; |
| 2666 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2667 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1076, |
| 2668 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2669 | |
| 2670 | mcp->mb[0] = MBC_LIP_FULL_LOGIN; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2671 | mcp->mb[1] = IS_FWI2_CAPABLE(vha->hw) ? BIT_3 : 0; |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 2672 | mcp->mb[2] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2673 | mcp->mb[3] = 0; |
| 2674 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 2675 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2676 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2677 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2678 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2679 | |
| 2680 | if (rval != QLA_SUCCESS) { |
| 2681 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2682 | ql_dbg(ql_dbg_mbx, vha, 0x1077, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2683 | } else { |
| 2684 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2685 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1078, |
| 2686 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2687 | } |
| 2688 | |
| 2689 | return rval; |
| 2690 | } |
| 2691 | |
| 2692 | /* |
| 2693 | * qla2x00_get_id_list |
| 2694 | * |
| 2695 | * Input: |
| 2696 | * ha = adapter block pointer. |
| 2697 | * |
| 2698 | * Returns: |
| 2699 | * qla2x00 local function return status code. |
| 2700 | * |
| 2701 | * Context: |
| 2702 | * Kernel context. |
| 2703 | */ |
| 2704 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2705 | qla2x00_get_id_list(scsi_qla_host_t *vha, void *id_list, dma_addr_t id_list_dma, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2706 | uint16_t *entries) |
| 2707 | { |
| 2708 | int rval; |
| 2709 | mbx_cmd_t mc; |
| 2710 | mbx_cmd_t *mcp = &mc; |
| 2711 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2712 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1079, |
| 2713 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2714 | |
| 2715 | if (id_list == NULL) |
| 2716 | return QLA_FUNCTION_FAILED; |
| 2717 | |
| 2718 | mcp->mb[0] = MBC_GET_ID_LIST; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2719 | mcp->out_mb = MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2720 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2721 | mcp->mb[2] = MSW(id_list_dma); |
| 2722 | mcp->mb[3] = LSW(id_list_dma); |
| 2723 | mcp->mb[6] = MSW(MSD(id_list_dma)); |
| 2724 | mcp->mb[7] = LSW(MSD(id_list_dma)); |
andrew.vasquez@qlogic.com | 247ec45 | 2006-02-07 08:45:40 -0800 | [diff] [blame] | 2725 | mcp->mb[8] = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2726 | mcp->mb[9] = vha->vp_idx; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2727 | mcp->out_mb |= MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2728 | } else { |
| 2729 | mcp->mb[1] = MSW(id_list_dma); |
| 2730 | mcp->mb[2] = LSW(id_list_dma); |
| 2731 | mcp->mb[3] = MSW(MSD(id_list_dma)); |
| 2732 | mcp->mb[6] = LSW(MSD(id_list_dma)); |
| 2733 | mcp->out_mb |= MBX_6|MBX_3|MBX_2|MBX_1; |
| 2734 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2735 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2736 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2737 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2738 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2739 | |
| 2740 | if (rval != QLA_SUCCESS) { |
| 2741 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2742 | ql_dbg(ql_dbg_mbx, vha, 0x107a, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2743 | } else { |
| 2744 | *entries = mcp->mb[1]; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2745 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107b, |
| 2746 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2747 | } |
| 2748 | |
| 2749 | return rval; |
| 2750 | } |
| 2751 | |
| 2752 | /* |
| 2753 | * qla2x00_get_resource_cnts |
| 2754 | * Get current firmware resource counts. |
| 2755 | * |
| 2756 | * Input: |
| 2757 | * ha = adapter block pointer. |
| 2758 | * |
| 2759 | * Returns: |
| 2760 | * qla2x00 local function return status code. |
| 2761 | * |
| 2762 | * Context: |
| 2763 | * Kernel context. |
| 2764 | */ |
| 2765 | int |
Quinn Tran | 03e8c68 | 2015-12-17 14:56:59 -0500 | [diff] [blame] | 2766 | qla2x00_get_resource_cnts(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2767 | { |
Quinn Tran | 03e8c68 | 2015-12-17 14:56:59 -0500 | [diff] [blame] | 2768 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2769 | int rval; |
| 2770 | mbx_cmd_t mc; |
| 2771 | mbx_cmd_t *mcp = &mc; |
| 2772 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2773 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107c, |
| 2774 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2775 | |
| 2776 | mcp->mb[0] = MBC_GET_RESOURCE_COUNTS; |
| 2777 | mcp->out_mb = MBX_0; |
Seokmann Ju | 4d0ea24 | 2007-09-20 14:07:43 -0700 | [diff] [blame] | 2778 | mcp->in_mb = MBX_11|MBX_10|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2779 | if (IS_QLA81XX(vha->hw) || IS_QLA83XX(vha->hw) || IS_QLA27XX(vha->hw)) |
Andrew Vasquez | f3a0a77 | 2009-10-13 15:16:49 -0700 | [diff] [blame] | 2780 | mcp->in_mb |= MBX_12; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2781 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2782 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2783 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2784 | |
| 2785 | if (rval != QLA_SUCCESS) { |
| 2786 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2787 | ql_dbg(ql_dbg_mbx, vha, 0x107d, |
| 2788 | "Failed mb[0]=%x.\n", mcp->mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2789 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2790 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107e, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2791 | "Done %s mb1=%x mb2=%x mb3=%x mb6=%x mb7=%x mb10=%x " |
| 2792 | "mb11=%x mb12=%x.\n", __func__, mcp->mb[1], mcp->mb[2], |
| 2793 | mcp->mb[3], mcp->mb[6], mcp->mb[7], mcp->mb[10], |
| 2794 | mcp->mb[11], mcp->mb[12]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2795 | |
Quinn Tran | 03e8c68 | 2015-12-17 14:56:59 -0500 | [diff] [blame] | 2796 | ha->orig_fw_tgt_xcb_count = mcp->mb[1]; |
| 2797 | ha->cur_fw_tgt_xcb_count = mcp->mb[2]; |
| 2798 | ha->cur_fw_xcb_count = mcp->mb[3]; |
| 2799 | ha->orig_fw_xcb_count = mcp->mb[6]; |
| 2800 | ha->cur_fw_iocb_count = mcp->mb[7]; |
| 2801 | ha->orig_fw_iocb_count = mcp->mb[10]; |
| 2802 | if (ha->flags.npiv_supported) |
| 2803 | ha->max_npiv_vports = mcp->mb[11]; |
| 2804 | if (IS_QLA81XX(ha) || IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
| 2805 | ha->fw_max_fcf_count = mcp->mb[12]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2806 | } |
| 2807 | |
| 2808 | return (rval); |
| 2809 | } |
| 2810 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2811 | /* |
| 2812 | * qla2x00_get_fcal_position_map |
| 2813 | * Get FCAL (LILP) position map using mailbox command |
| 2814 | * |
| 2815 | * Input: |
| 2816 | * ha = adapter state pointer. |
| 2817 | * pos_map = buffer pointer (can be NULL). |
| 2818 | * |
| 2819 | * Returns: |
| 2820 | * qla2x00 local function return status code. |
| 2821 | * |
| 2822 | * Context: |
| 2823 | * Kernel context. |
| 2824 | */ |
| 2825 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2826 | qla2x00_get_fcal_position_map(scsi_qla_host_t *vha, char *pos_map) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2827 | { |
| 2828 | int rval; |
| 2829 | mbx_cmd_t mc; |
| 2830 | mbx_cmd_t *mcp = &mc; |
| 2831 | char *pmap; |
| 2832 | dma_addr_t pmap_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2833 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2834 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2835 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107f, |
| 2836 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2837 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 2838 | pmap = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pmap_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2839 | if (pmap == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2840 | ql_log(ql_log_warn, vha, 0x1080, |
| 2841 | "Memory alloc failed.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2842 | return QLA_MEMORY_ALLOC_FAILED; |
| 2843 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2844 | |
| 2845 | mcp->mb[0] = MBC_GET_FC_AL_POSITION_MAP; |
| 2846 | mcp->mb[2] = MSW(pmap_dma); |
| 2847 | mcp->mb[3] = LSW(pmap_dma); |
| 2848 | mcp->mb[6] = MSW(MSD(pmap_dma)); |
| 2849 | mcp->mb[7] = LSW(MSD(pmap_dma)); |
| 2850 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; |
| 2851 | mcp->in_mb = MBX_1|MBX_0; |
| 2852 | mcp->buf_size = FCAL_MAP_SIZE; |
| 2853 | mcp->flags = MBX_DMA_IN; |
| 2854 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2855 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2856 | |
| 2857 | if (rval == QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2858 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1081, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2859 | "mb0/mb1=%x/%X FC/AL position map size (%x).\n", |
| 2860 | mcp->mb[0], mcp->mb[1], (unsigned)pmap[0]); |
| 2861 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111d, |
| 2862 | pmap, pmap[0] + 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2863 | |
| 2864 | if (pos_map) |
| 2865 | memcpy(pos_map, pmap, FCAL_MAP_SIZE); |
| 2866 | } |
| 2867 | dma_pool_free(ha->s_dma_pool, pmap, pmap_dma); |
| 2868 | |
| 2869 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2870 | ql_dbg(ql_dbg_mbx, vha, 0x1082, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2871 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2872 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1083, |
| 2873 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2874 | } |
| 2875 | |
| 2876 | return rval; |
| 2877 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2878 | |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2879 | /* |
| 2880 | * qla2x00_get_link_status |
| 2881 | * |
| 2882 | * Input: |
| 2883 | * ha = adapter block pointer. |
| 2884 | * loop_id = device loop ID. |
| 2885 | * ret_buf = pointer to link status return buffer. |
| 2886 | * |
| 2887 | * Returns: |
| 2888 | * 0 = success. |
| 2889 | * BIT_0 = mem alloc error. |
| 2890 | * BIT_1 = mailbox error. |
| 2891 | */ |
| 2892 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2893 | qla2x00_get_link_status(scsi_qla_host_t *vha, uint16_t loop_id, |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2894 | struct link_statistics *stats, dma_addr_t stats_dma) |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2895 | { |
| 2896 | int rval; |
| 2897 | mbx_cmd_t mc; |
| 2898 | mbx_cmd_t *mcp = &mc; |
Joe Carnuccio | c6dc990 | 2016-07-06 11:14:24 -0400 | [diff] [blame] | 2899 | uint32_t *iter = (void *)stats; |
| 2900 | ushort dwords = offsetof(typeof(*stats), link_up_cnt)/sizeof(*iter); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2901 | struct qla_hw_data *ha = vha->hw; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2902 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2903 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1084, |
| 2904 | "Entered %s.\n", __func__); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2905 | |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2906 | mcp->mb[0] = MBC_GET_LINK_STATUS; |
Joe Carnuccio | c6dc990 | 2016-07-06 11:14:24 -0400 | [diff] [blame] | 2907 | mcp->mb[2] = MSW(LSD(stats_dma)); |
| 2908 | mcp->mb[3] = LSW(LSD(stats_dma)); |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2909 | mcp->mb[6] = MSW(MSD(stats_dma)); |
| 2910 | mcp->mb[7] = LSW(MSD(stats_dma)); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2911 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; |
| 2912 | mcp->in_mb = MBX_0; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2913 | if (IS_FWI2_CAPABLE(ha)) { |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2914 | mcp->mb[1] = loop_id; |
| 2915 | mcp->mb[4] = 0; |
| 2916 | mcp->mb[10] = 0; |
| 2917 | mcp->out_mb |= MBX_10|MBX_4|MBX_1; |
| 2918 | mcp->in_mb |= MBX_1; |
| 2919 | } else if (HAS_EXTENDED_IDS(ha)) { |
| 2920 | mcp->mb[1] = loop_id; |
| 2921 | mcp->mb[10] = 0; |
| 2922 | mcp->out_mb |= MBX_10|MBX_1; |
| 2923 | } else { |
| 2924 | mcp->mb[1] = loop_id << 8; |
| 2925 | mcp->out_mb |= MBX_1; |
| 2926 | } |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2927 | mcp->tov = MBX_TOV_SECONDS; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2928 | mcp->flags = IOCTL_CMD; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2929 | rval = qla2x00_mailbox_command(vha, mcp); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2930 | |
| 2931 | if (rval == QLA_SUCCESS) { |
| 2932 | if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2933 | ql_dbg(ql_dbg_mbx, vha, 0x1085, |
| 2934 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2935 | rval = QLA_FUNCTION_FAILED; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2936 | } else { |
Joe Carnuccio | c6dc990 | 2016-07-06 11:14:24 -0400 | [diff] [blame] | 2937 | /* Re-endianize - firmware data is le32. */ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2938 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1086, |
| 2939 | "Done %s.\n", __func__); |
Joe Carnuccio | da08ef5 | 2016-01-27 12:03:34 -0500 | [diff] [blame] | 2940 | for ( ; dwords--; iter++) |
| 2941 | le32_to_cpus(iter); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2942 | } |
| 2943 | } else { |
| 2944 | /* Failed. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2945 | ql_dbg(ql_dbg_mbx, vha, 0x1087, "Failed=%x.\n", rval); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2946 | } |
| 2947 | |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2948 | return rval; |
| 2949 | } |
| 2950 | |
| 2951 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2952 | qla24xx_get_isp_stats(scsi_qla_host_t *vha, struct link_statistics *stats, |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 2953 | dma_addr_t stats_dma, uint16_t options) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2954 | { |
| 2955 | int rval; |
| 2956 | mbx_cmd_t mc; |
| 2957 | mbx_cmd_t *mcp = &mc; |
Joe Carnuccio | da08ef5 | 2016-01-27 12:03:34 -0500 | [diff] [blame] | 2958 | uint32_t *iter, dwords; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2959 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2960 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1088, |
| 2961 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2962 | |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 2963 | memset(&mc, 0, sizeof(mc)); |
| 2964 | mc.mb[0] = MBC_GET_LINK_PRIV_STATS; |
| 2965 | mc.mb[2] = MSW(stats_dma); |
| 2966 | mc.mb[3] = LSW(stats_dma); |
| 2967 | mc.mb[6] = MSW(MSD(stats_dma)); |
| 2968 | mc.mb[7] = LSW(MSD(stats_dma)); |
| 2969 | mc.mb[8] = sizeof(struct link_statistics) / 4; |
| 2970 | mc.mb[9] = cpu_to_le16(vha->vp_idx); |
| 2971 | mc.mb[10] = cpu_to_le16(options); |
| 2972 | |
| 2973 | rval = qla24xx_send_mb_cmd(vha, &mc); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2974 | |
| 2975 | if (rval == QLA_SUCCESS) { |
| 2976 | if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2977 | ql_dbg(ql_dbg_mbx, vha, 0x1089, |
| 2978 | "Failed mb[0]=%x.\n", mcp->mb[0]); |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2979 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2980 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2981 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x108a, |
| 2982 | "Done %s.\n", __func__); |
Joe Carnuccio | c6dc990 | 2016-07-06 11:14:24 -0400 | [diff] [blame] | 2983 | /* Re-endianize - firmware data is le32. */ |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2984 | dwords = sizeof(struct link_statistics) / 4; |
Joe Carnuccio | da08ef5 | 2016-01-27 12:03:34 -0500 | [diff] [blame] | 2985 | iter = &stats->link_fail_cnt; |
| 2986 | for ( ; dwords--; iter++) |
| 2987 | le32_to_cpus(iter); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2988 | } |
| 2989 | } else { |
| 2990 | /* Failed. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2991 | ql_dbg(ql_dbg_mbx, vha, 0x108b, "Failed=%x.\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2992 | } |
| 2993 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2994 | return rval; |
| 2995 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2996 | |
| 2997 | int |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2998 | qla24xx_abort_command(srb_t *sp) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2999 | { |
| 3000 | int rval; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3001 | unsigned long flags = 0; |
| 3002 | |
| 3003 | struct abort_entry_24xx *abt; |
| 3004 | dma_addr_t abt_dma; |
| 3005 | uint32_t handle; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3006 | fc_port_t *fcport = sp->fcport; |
| 3007 | struct scsi_qla_host *vha = fcport->vha; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3008 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 3009 | struct req_que *req = vha->req; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3010 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3011 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x108c, |
| 3012 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3013 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3014 | if (vha->flags.qpairs_available && sp->qpair) |
| 3015 | req = sp->qpair->req; |
| 3016 | |
Armen Baloyan | 4440e46 | 2014-02-26 04:15:18 -0500 | [diff] [blame] | 3017 | if (ql2xasynctmfenable) |
| 3018 | return qla24xx_async_abort_command(sp); |
| 3019 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3020 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 3021 | for (handle = 1; handle < req->num_outstanding_cmds; handle++) { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3022 | if (req->outstanding_cmds[handle] == sp) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3023 | break; |
| 3024 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3025 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 3026 | if (handle == req->num_outstanding_cmds) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3027 | /* Command not found. */ |
| 3028 | return QLA_FUNCTION_FAILED; |
| 3029 | } |
| 3030 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 3031 | abt = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &abt_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3032 | if (abt == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3033 | ql_log(ql_log_warn, vha, 0x108d, |
| 3034 | "Failed to allocate abort IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3035 | return QLA_MEMORY_ALLOC_FAILED; |
| 3036 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3037 | |
| 3038 | abt->entry_type = ABORT_IOCB_TYPE; |
| 3039 | abt->entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3040 | abt->handle = MAKE_HANDLE(req->id, abt->handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3041 | abt->nport_handle = cpu_to_le16(fcport->loop_id); |
Mike Hernandez | a74ec14 | 2011-03-30 11:46:20 -0700 | [diff] [blame] | 3042 | abt->handle_to_abort = MAKE_HANDLE(req->id, handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3043 | abt->port_id[0] = fcport->d_id.b.al_pa; |
| 3044 | abt->port_id[1] = fcport->d_id.b.area; |
| 3045 | abt->port_id[2] = fcport->d_id.b.domain; |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3046 | abt->vp_index = fcport->vha->vp_idx; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3047 | |
| 3048 | abt->req_que_no = cpu_to_le16(req->id); |
| 3049 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3050 | rval = qla2x00_issue_iocb(vha, abt, abt_dma, 0); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3051 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3052 | ql_dbg(ql_dbg_mbx, vha, 0x108e, |
| 3053 | "Failed to issue IOCB (%x).\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3054 | } else if (abt->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3055 | ql_dbg(ql_dbg_mbx, vha, 0x108f, |
| 3056 | "Failed to complete IOCB -- error status (%x).\n", |
| 3057 | abt->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3058 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 3059 | } else if (abt->nport_handle != cpu_to_le16(0)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3060 | ql_dbg(ql_dbg_mbx, vha, 0x1090, |
| 3061 | "Failed to complete IOCB -- completion status (%x).\n", |
| 3062 | le16_to_cpu(abt->nport_handle)); |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 3063 | if (abt->nport_handle == CS_IOCB_ERROR) |
| 3064 | rval = QLA_FUNCTION_PARAMETER_ERROR; |
| 3065 | else |
| 3066 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3067 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3068 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1091, |
| 3069 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3070 | } |
| 3071 | |
| 3072 | dma_pool_free(ha->s_dma_pool, abt, abt_dma); |
| 3073 | |
| 3074 | return rval; |
| 3075 | } |
| 3076 | |
| 3077 | struct tsk_mgmt_cmd { |
| 3078 | union { |
| 3079 | struct tsk_mgmt_entry tsk; |
| 3080 | struct sts_entry_24xx sts; |
| 3081 | } p; |
| 3082 | }; |
| 3083 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3084 | static int |
| 3085 | __qla24xx_issue_tmf(char *name, uint32_t type, struct fc_port *fcport, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 3086 | uint64_t l, int tag) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3087 | { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3088 | int rval, rval2; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3089 | struct tsk_mgmt_cmd *tsk; |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 3090 | struct sts_entry_24xx *sts; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3091 | dma_addr_t tsk_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3092 | scsi_qla_host_t *vha; |
| 3093 | struct qla_hw_data *ha; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3094 | struct req_que *req; |
| 3095 | struct rsp_que *rsp; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3096 | struct qla_qpair *qpair; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3097 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3098 | vha = fcport->vha; |
| 3099 | ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3100 | req = vha->req; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3101 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3102 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1092, |
| 3103 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3104 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3105 | if (vha->vp_idx && vha->qpair) { |
| 3106 | /* NPIV port */ |
| 3107 | qpair = vha->qpair; |
| 3108 | rsp = qpair->rsp; |
| 3109 | req = qpair->req; |
| 3110 | } else { |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 3111 | rsp = req->rsp; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3112 | } |
| 3113 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 3114 | tsk = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &tsk_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3115 | if (tsk == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3116 | ql_log(ql_log_warn, vha, 0x1093, |
| 3117 | "Failed to allocate task management IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3118 | return QLA_MEMORY_ALLOC_FAILED; |
| 3119 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3120 | |
| 3121 | tsk->p.tsk.entry_type = TSK_MGMT_IOCB_TYPE; |
| 3122 | tsk->p.tsk.entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3123 | tsk->p.tsk.handle = MAKE_HANDLE(req->id, tsk->p.tsk.handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3124 | tsk->p.tsk.nport_handle = cpu_to_le16(fcport->loop_id); |
Andrew Vasquez | 00a537b | 2008-02-28 14:06:11 -0800 | [diff] [blame] | 3125 | tsk->p.tsk.timeout = cpu_to_le16(ha->r_a_tov / 10 * 2); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3126 | tsk->p.tsk.control_flags = cpu_to_le32(type); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3127 | tsk->p.tsk.port_id[0] = fcport->d_id.b.al_pa; |
| 3128 | tsk->p.tsk.port_id[1] = fcport->d_id.b.area; |
| 3129 | tsk->p.tsk.port_id[2] = fcport->d_id.b.domain; |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3130 | tsk->p.tsk.vp_index = fcport->vha->vp_idx; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3131 | if (type == TCF_LUN_RESET) { |
| 3132 | int_to_scsilun(l, &tsk->p.tsk.lun); |
| 3133 | host_to_fcp_swap((uint8_t *)&tsk->p.tsk.lun, |
| 3134 | sizeof(tsk->p.tsk.lun)); |
| 3135 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3136 | |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 3137 | sts = &tsk->p.sts; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3138 | rval = qla2x00_issue_iocb(vha, tsk, tsk_dma, 0); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3139 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3140 | ql_dbg(ql_dbg_mbx, vha, 0x1094, |
| 3141 | "Failed to issue %s reset IOCB (%x).\n", name, rval); |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 3142 | } else if (sts->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3143 | ql_dbg(ql_dbg_mbx, vha, 0x1095, |
| 3144 | "Failed to complete IOCB -- error status (%x).\n", |
| 3145 | sts->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3146 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 3147 | } else if (sts->comp_status != cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3148 | ql_dbg(ql_dbg_mbx, vha, 0x1096, |
| 3149 | "Failed to complete IOCB -- completion status (%x).\n", |
| 3150 | le16_to_cpu(sts->comp_status)); |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 3151 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 97dec56 | 2011-02-23 15:27:14 -0800 | [diff] [blame] | 3152 | } else if (le16_to_cpu(sts->scsi_status) & |
| 3153 | SS_RESPONSE_INFO_LEN_VALID) { |
| 3154 | if (le32_to_cpu(sts->rsp_data_len) < 4) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3155 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1097, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3156 | "Ignoring inconsistent data length -- not enough " |
| 3157 | "response info (%d).\n", |
| 3158 | le32_to_cpu(sts->rsp_data_len)); |
Andrew Vasquez | 97dec56 | 2011-02-23 15:27:14 -0800 | [diff] [blame] | 3159 | } else if (sts->data[3]) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3160 | ql_dbg(ql_dbg_mbx, vha, 0x1098, |
| 3161 | "Failed to complete IOCB -- response (%x).\n", |
| 3162 | sts->data[3]); |
Andrew Vasquez | 97dec56 | 2011-02-23 15:27:14 -0800 | [diff] [blame] | 3163 | rval = QLA_FUNCTION_FAILED; |
| 3164 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3165 | } |
| 3166 | |
| 3167 | /* Issue marker IOCB. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3168 | rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, l, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3169 | type == TCF_LUN_RESET ? MK_SYNC_ID_LUN: MK_SYNC_ID); |
| 3170 | if (rval2 != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3171 | ql_dbg(ql_dbg_mbx, vha, 0x1099, |
| 3172 | "Failed to issue marker IOCB (%x).\n", rval2); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3173 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3174 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109a, |
| 3175 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3176 | } |
| 3177 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3178 | dma_pool_free(ha->s_dma_pool, tsk, tsk_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3179 | |
| 3180 | return rval; |
| 3181 | } |
| 3182 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3183 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 3184 | qla24xx_abort_target(struct fc_port *fcport, uint64_t l, int tag) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3185 | { |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 3186 | struct qla_hw_data *ha = fcport->vha->hw; |
| 3187 | |
| 3188 | if ((ql2xasynctmfenable) && IS_FWI2_CAPABLE(ha)) |
| 3189 | return qla2x00_async_tm_cmd(fcport, TCF_TARGET_RESET, l, tag); |
| 3190 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3191 | return __qla24xx_issue_tmf("Target", TCF_TARGET_RESET, fcport, l, tag); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3192 | } |
| 3193 | |
| 3194 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 3195 | qla24xx_lun_reset(struct fc_port *fcport, uint64_t l, int tag) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3196 | { |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 3197 | struct qla_hw_data *ha = fcport->vha->hw; |
| 3198 | |
| 3199 | if ((ql2xasynctmfenable) && IS_FWI2_CAPABLE(ha)) |
| 3200 | return qla2x00_async_tm_cmd(fcport, TCF_LUN_RESET, l, tag); |
| 3201 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3202 | return __qla24xx_issue_tmf("Lun", TCF_LUN_RESET, fcport, l, tag); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3203 | } |
| 3204 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3205 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3206 | qla2x00_system_error(scsi_qla_host_t *vha) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3207 | { |
| 3208 | int rval; |
| 3209 | mbx_cmd_t mc; |
| 3210 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3211 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3212 | |
Andrew Vasquez | 68af081 | 2008-05-12 22:21:13 -0700 | [diff] [blame] | 3213 | if (!IS_QLA23XX(ha) && !IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3214 | return QLA_FUNCTION_FAILED; |
| 3215 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3216 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109b, |
| 3217 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3218 | |
| 3219 | mcp->mb[0] = MBC_GEN_SYSTEM_ERROR; |
| 3220 | mcp->out_mb = MBX_0; |
| 3221 | mcp->in_mb = MBX_0; |
| 3222 | mcp->tov = 5; |
| 3223 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3224 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3225 | |
| 3226 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3227 | ql_dbg(ql_dbg_mbx, vha, 0x109c, "Failed=%x.\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3228 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3229 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109d, |
| 3230 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3231 | } |
| 3232 | |
| 3233 | return rval; |
| 3234 | } |
| 3235 | |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 3236 | int |
| 3237 | qla2x00_write_serdes_word(scsi_qla_host_t *vha, uint16_t addr, uint16_t data) |
| 3238 | { |
| 3239 | int rval; |
| 3240 | mbx_cmd_t mc; |
| 3241 | mbx_cmd_t *mcp = &mc; |
| 3242 | |
Joe Carnuccio | f299c7c | 2015-08-04 13:37:51 -0400 | [diff] [blame] | 3243 | if (!IS_QLA25XX(vha->hw) && !IS_QLA2031(vha->hw) && |
| 3244 | !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 3245 | return QLA_FUNCTION_FAILED; |
| 3246 | |
| 3247 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1182, |
| 3248 | "Entered %s.\n", __func__); |
| 3249 | |
| 3250 | mcp->mb[0] = MBC_WRITE_SERDES; |
| 3251 | mcp->mb[1] = addr; |
Andrew Vasquez | 064135e | 2015-04-09 15:00:02 -0400 | [diff] [blame] | 3252 | if (IS_QLA2031(vha->hw)) |
| 3253 | mcp->mb[2] = data & 0xff; |
| 3254 | else |
| 3255 | mcp->mb[2] = data; |
| 3256 | |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 3257 | mcp->mb[3] = 0; |
| 3258 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 3259 | mcp->in_mb = MBX_0; |
| 3260 | mcp->tov = MBX_TOV_SECONDS; |
| 3261 | mcp->flags = 0; |
| 3262 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3263 | |
| 3264 | if (rval != QLA_SUCCESS) { |
| 3265 | ql_dbg(ql_dbg_mbx, vha, 0x1183, |
| 3266 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 3267 | } else { |
| 3268 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1184, |
| 3269 | "Done %s.\n", __func__); |
| 3270 | } |
| 3271 | |
| 3272 | return rval; |
| 3273 | } |
| 3274 | |
| 3275 | int |
| 3276 | qla2x00_read_serdes_word(scsi_qla_host_t *vha, uint16_t addr, uint16_t *data) |
| 3277 | { |
| 3278 | int rval; |
| 3279 | mbx_cmd_t mc; |
| 3280 | mbx_cmd_t *mcp = &mc; |
| 3281 | |
Joe Carnuccio | f299c7c | 2015-08-04 13:37:51 -0400 | [diff] [blame] | 3282 | if (!IS_QLA25XX(vha->hw) && !IS_QLA2031(vha->hw) && |
| 3283 | !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 3284 | return QLA_FUNCTION_FAILED; |
| 3285 | |
| 3286 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1185, |
| 3287 | "Entered %s.\n", __func__); |
| 3288 | |
| 3289 | mcp->mb[0] = MBC_READ_SERDES; |
| 3290 | mcp->mb[1] = addr; |
| 3291 | mcp->mb[3] = 0; |
| 3292 | mcp->out_mb = MBX_3|MBX_1|MBX_0; |
| 3293 | mcp->in_mb = MBX_1|MBX_0; |
| 3294 | mcp->tov = MBX_TOV_SECONDS; |
| 3295 | mcp->flags = 0; |
| 3296 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3297 | |
Andrew Vasquez | 064135e | 2015-04-09 15:00:02 -0400 | [diff] [blame] | 3298 | if (IS_QLA2031(vha->hw)) |
| 3299 | *data = mcp->mb[1] & 0xff; |
| 3300 | else |
| 3301 | *data = mcp->mb[1]; |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 3302 | |
| 3303 | if (rval != QLA_SUCCESS) { |
| 3304 | ql_dbg(ql_dbg_mbx, vha, 0x1186, |
| 3305 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 3306 | } else { |
| 3307 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1187, |
| 3308 | "Done %s.\n", __func__); |
| 3309 | } |
| 3310 | |
| 3311 | return rval; |
| 3312 | } |
| 3313 | |
Joe Carnuccio | e8887c5 | 2014-04-11 16:54:17 -0400 | [diff] [blame] | 3314 | int |
| 3315 | qla8044_write_serdes_word(scsi_qla_host_t *vha, uint32_t addr, uint32_t data) |
| 3316 | { |
| 3317 | int rval; |
| 3318 | mbx_cmd_t mc; |
| 3319 | mbx_cmd_t *mcp = &mc; |
| 3320 | |
| 3321 | if (!IS_QLA8044(vha->hw)) |
| 3322 | return QLA_FUNCTION_FAILED; |
| 3323 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3324 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x11a0, |
Joe Carnuccio | e8887c5 | 2014-04-11 16:54:17 -0400 | [diff] [blame] | 3325 | "Entered %s.\n", __func__); |
| 3326 | |
| 3327 | mcp->mb[0] = MBC_SET_GET_ETH_SERDES_REG; |
| 3328 | mcp->mb[1] = HCS_WRITE_SERDES; |
| 3329 | mcp->mb[3] = LSW(addr); |
| 3330 | mcp->mb[4] = MSW(addr); |
| 3331 | mcp->mb[5] = LSW(data); |
| 3332 | mcp->mb[6] = MSW(data); |
| 3333 | mcp->out_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_1|MBX_0; |
| 3334 | mcp->in_mb = MBX_0; |
| 3335 | mcp->tov = MBX_TOV_SECONDS; |
| 3336 | mcp->flags = 0; |
| 3337 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3338 | |
| 3339 | if (rval != QLA_SUCCESS) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3340 | ql_dbg(ql_dbg_mbx, vha, 0x11a1, |
Joe Carnuccio | e8887c5 | 2014-04-11 16:54:17 -0400 | [diff] [blame] | 3341 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 3342 | } else { |
| 3343 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1188, |
| 3344 | "Done %s.\n", __func__); |
| 3345 | } |
| 3346 | |
| 3347 | return rval; |
| 3348 | } |
| 3349 | |
| 3350 | int |
| 3351 | qla8044_read_serdes_word(scsi_qla_host_t *vha, uint32_t addr, uint32_t *data) |
| 3352 | { |
| 3353 | int rval; |
| 3354 | mbx_cmd_t mc; |
| 3355 | mbx_cmd_t *mcp = &mc; |
| 3356 | |
| 3357 | if (!IS_QLA8044(vha->hw)) |
| 3358 | return QLA_FUNCTION_FAILED; |
| 3359 | |
| 3360 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1189, |
| 3361 | "Entered %s.\n", __func__); |
| 3362 | |
| 3363 | mcp->mb[0] = MBC_SET_GET_ETH_SERDES_REG; |
| 3364 | mcp->mb[1] = HCS_READ_SERDES; |
| 3365 | mcp->mb[3] = LSW(addr); |
| 3366 | mcp->mb[4] = MSW(addr); |
| 3367 | mcp->out_mb = MBX_4|MBX_3|MBX_1|MBX_0; |
| 3368 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 3369 | mcp->tov = MBX_TOV_SECONDS; |
| 3370 | mcp->flags = 0; |
| 3371 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3372 | |
| 3373 | *data = mcp->mb[2] << 16 | mcp->mb[1]; |
| 3374 | |
| 3375 | if (rval != QLA_SUCCESS) { |
| 3376 | ql_dbg(ql_dbg_mbx, vha, 0x118a, |
| 3377 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 3378 | } else { |
| 3379 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x118b, |
| 3380 | "Done %s.\n", __func__); |
| 3381 | } |
| 3382 | |
| 3383 | return rval; |
| 3384 | } |
| 3385 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3386 | /** |
| 3387 | * qla2x00_set_serdes_params() - |
Bart Van Assche | 2db6228 | 2018-01-23 16:33:51 -0800 | [diff] [blame] | 3388 | * @vha: HA context |
| 3389 | * @sw_em_1g: |
| 3390 | * @sw_em_2g: |
| 3391 | * @sw_em_4g: |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3392 | * |
| 3393 | * Returns |
| 3394 | */ |
| 3395 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3396 | qla2x00_set_serdes_params(scsi_qla_host_t *vha, uint16_t sw_em_1g, |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3397 | uint16_t sw_em_2g, uint16_t sw_em_4g) |
| 3398 | { |
| 3399 | int rval; |
| 3400 | mbx_cmd_t mc; |
| 3401 | mbx_cmd_t *mcp = &mc; |
| 3402 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3403 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109e, |
| 3404 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3405 | |
| 3406 | mcp->mb[0] = MBC_SERDES_PARAMS; |
| 3407 | mcp->mb[1] = BIT_0; |
andrew.vasquez@qlogic.com | fdbc683 | 2006-03-09 14:27:29 -0800 | [diff] [blame] | 3408 | mcp->mb[2] = sw_em_1g | BIT_15; |
| 3409 | mcp->mb[3] = sw_em_2g | BIT_15; |
| 3410 | mcp->mb[4] = sw_em_4g | BIT_15; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3411 | mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3412 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3413 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3414 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3415 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3416 | |
| 3417 | if (rval != QLA_SUCCESS) { |
| 3418 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3419 | ql_dbg(ql_dbg_mbx, vha, 0x109f, |
| 3420 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3421 | } else { |
| 3422 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3423 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a0, |
| 3424 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3425 | } |
| 3426 | |
| 3427 | return rval; |
| 3428 | } |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3429 | |
| 3430 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3431 | qla2x00_stop_firmware(scsi_qla_host_t *vha) |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3432 | { |
| 3433 | int rval; |
| 3434 | mbx_cmd_t mc; |
| 3435 | mbx_cmd_t *mcp = &mc; |
| 3436 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3437 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3438 | return QLA_FUNCTION_FAILED; |
| 3439 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3440 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a1, |
| 3441 | "Entered %s.\n", __func__); |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3442 | |
| 3443 | mcp->mb[0] = MBC_STOP_FIRMWARE; |
Andrew Vasquez | 4ba988d | 2012-02-09 11:14:06 -0800 | [diff] [blame] | 3444 | mcp->mb[1] = 0; |
| 3445 | mcp->out_mb = MBX_1|MBX_0; |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3446 | mcp->in_mb = MBX_0; |
| 3447 | mcp->tov = 5; |
| 3448 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3449 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3450 | |
| 3451 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3452 | ql_dbg(ql_dbg_mbx, vha, 0x10a2, "Failed=%x.\n", rval); |
Andrew Vasquez | b469a7c | 2009-04-06 22:33:48 -0700 | [diff] [blame] | 3453 | if (mcp->mb[0] == MBS_INVALID_COMMAND) |
| 3454 | rval = QLA_INVALID_COMMAND; |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3455 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3456 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a3, |
| 3457 | "Done %s.\n", __func__); |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3458 | } |
| 3459 | |
| 3460 | return rval; |
| 3461 | } |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3462 | |
| 3463 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3464 | qla2x00_enable_eft_trace(scsi_qla_host_t *vha, dma_addr_t eft_dma, |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3465 | uint16_t buffers) |
| 3466 | { |
| 3467 | int rval; |
| 3468 | mbx_cmd_t mc; |
| 3469 | mbx_cmd_t *mcp = &mc; |
| 3470 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3471 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a4, |
| 3472 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3473 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3474 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3475 | return QLA_FUNCTION_FAILED; |
| 3476 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3477 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3478 | return QLA_FUNCTION_FAILED; |
| 3479 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3480 | mcp->mb[0] = MBC_TRACE_CONTROL; |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3481 | mcp->mb[1] = TC_EFT_ENABLE; |
| 3482 | mcp->mb[2] = LSW(eft_dma); |
| 3483 | mcp->mb[3] = MSW(eft_dma); |
| 3484 | mcp->mb[4] = LSW(MSD(eft_dma)); |
| 3485 | mcp->mb[5] = MSW(MSD(eft_dma)); |
| 3486 | mcp->mb[6] = buffers; |
| 3487 | mcp->mb[7] = TC_AEN_DISABLE; |
| 3488 | mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3489 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3490 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3491 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3492 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3493 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3494 | ql_dbg(ql_dbg_mbx, vha, 0x10a5, |
| 3495 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3496 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3497 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3498 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a6, |
| 3499 | "Done %s.\n", __func__); |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3500 | } |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3501 | |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3502 | return rval; |
| 3503 | } |
| 3504 | |
| 3505 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3506 | qla2x00_disable_eft_trace(scsi_qla_host_t *vha) |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3507 | { |
| 3508 | int rval; |
| 3509 | mbx_cmd_t mc; |
| 3510 | mbx_cmd_t *mcp = &mc; |
| 3511 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3512 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a7, |
| 3513 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3514 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3515 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3516 | return QLA_FUNCTION_FAILED; |
| 3517 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3518 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3519 | return QLA_FUNCTION_FAILED; |
| 3520 | |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3521 | mcp->mb[0] = MBC_TRACE_CONTROL; |
| 3522 | mcp->mb[1] = TC_EFT_DISABLE; |
| 3523 | mcp->out_mb = MBX_1|MBX_0; |
| 3524 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3525 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3526 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3527 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3528 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3529 | ql_dbg(ql_dbg_mbx, vha, 0x10a8, |
| 3530 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3531 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3532 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3533 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a9, |
| 3534 | "Done %s.\n", __func__); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3535 | } |
| 3536 | |
| 3537 | return rval; |
| 3538 | } |
| 3539 | |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 3540 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3541 | qla2x00_enable_fce_trace(scsi_qla_host_t *vha, dma_addr_t fce_dma, |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3542 | uint16_t buffers, uint16_t *mb, uint32_t *dwords) |
| 3543 | { |
| 3544 | int rval; |
| 3545 | mbx_cmd_t mc; |
| 3546 | mbx_cmd_t *mcp = &mc; |
| 3547 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3548 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10aa, |
| 3549 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3550 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3551 | if (!IS_QLA25XX(vha->hw) && !IS_QLA81XX(vha->hw) && |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3552 | !IS_QLA83XX(vha->hw) && !IS_QLA27XX(vha->hw)) |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3553 | return QLA_FUNCTION_FAILED; |
| 3554 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3555 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3556 | return QLA_FUNCTION_FAILED; |
| 3557 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3558 | mcp->mb[0] = MBC_TRACE_CONTROL; |
| 3559 | mcp->mb[1] = TC_FCE_ENABLE; |
| 3560 | mcp->mb[2] = LSW(fce_dma); |
| 3561 | mcp->mb[3] = MSW(fce_dma); |
| 3562 | mcp->mb[4] = LSW(MSD(fce_dma)); |
| 3563 | mcp->mb[5] = MSW(MSD(fce_dma)); |
| 3564 | mcp->mb[6] = buffers; |
| 3565 | mcp->mb[7] = TC_AEN_DISABLE; |
| 3566 | mcp->mb[8] = 0; |
| 3567 | mcp->mb[9] = TC_FCE_DEFAULT_RX_SIZE; |
| 3568 | mcp->mb[10] = TC_FCE_DEFAULT_TX_SIZE; |
| 3569 | mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2| |
| 3570 | MBX_1|MBX_0; |
| 3571 | mcp->in_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3572 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3573 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3574 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3575 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3576 | ql_dbg(ql_dbg_mbx, vha, 0x10ab, |
| 3577 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3578 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3579 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3580 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ac, |
| 3581 | "Done %s.\n", __func__); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3582 | |
| 3583 | if (mb) |
| 3584 | memcpy(mb, mcp->mb, 8 * sizeof(*mb)); |
| 3585 | if (dwords) |
Andrew Vasquez | fa0926d | 2008-05-12 22:21:12 -0700 | [diff] [blame] | 3586 | *dwords = buffers; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3587 | } |
| 3588 | |
| 3589 | return rval; |
| 3590 | } |
| 3591 | |
| 3592 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3593 | qla2x00_disable_fce_trace(scsi_qla_host_t *vha, uint64_t *wr, uint64_t *rd) |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3594 | { |
| 3595 | int rval; |
| 3596 | mbx_cmd_t mc; |
| 3597 | mbx_cmd_t *mcp = &mc; |
| 3598 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3599 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ad, |
| 3600 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3601 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3602 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3603 | return QLA_FUNCTION_FAILED; |
| 3604 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3605 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3606 | return QLA_FUNCTION_FAILED; |
| 3607 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3608 | mcp->mb[0] = MBC_TRACE_CONTROL; |
| 3609 | mcp->mb[1] = TC_FCE_DISABLE; |
| 3610 | mcp->mb[2] = TC_FCE_DISABLE_TRACE; |
| 3611 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 3612 | mcp->in_mb = MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2| |
| 3613 | MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3614 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3615 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3616 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3617 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3618 | ql_dbg(ql_dbg_mbx, vha, 0x10ae, |
| 3619 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3620 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3621 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3622 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10af, |
| 3623 | "Done %s.\n", __func__); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3624 | |
| 3625 | if (wr) |
| 3626 | *wr = (uint64_t) mcp->mb[5] << 48 | |
| 3627 | (uint64_t) mcp->mb[4] << 32 | |
| 3628 | (uint64_t) mcp->mb[3] << 16 | |
| 3629 | (uint64_t) mcp->mb[2]; |
| 3630 | if (rd) |
| 3631 | *rd = (uint64_t) mcp->mb[9] << 48 | |
| 3632 | (uint64_t) mcp->mb[8] << 32 | |
| 3633 | (uint64_t) mcp->mb[7] << 16 | |
| 3634 | (uint64_t) mcp->mb[6]; |
| 3635 | } |
| 3636 | |
| 3637 | return rval; |
| 3638 | } |
| 3639 | |
| 3640 | int |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3641 | qla2x00_get_idma_speed(scsi_qla_host_t *vha, uint16_t loop_id, |
| 3642 | uint16_t *port_speed, uint16_t *mb) |
| 3643 | { |
| 3644 | int rval; |
| 3645 | mbx_cmd_t mc; |
| 3646 | mbx_cmd_t *mcp = &mc; |
| 3647 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3648 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b0, |
| 3649 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3650 | |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3651 | if (!IS_IIDMA_CAPABLE(vha->hw)) |
| 3652 | return QLA_FUNCTION_FAILED; |
| 3653 | |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3654 | mcp->mb[0] = MBC_PORT_PARAMS; |
| 3655 | mcp->mb[1] = loop_id; |
| 3656 | mcp->mb[2] = mcp->mb[3] = 0; |
| 3657 | mcp->mb[9] = vha->vp_idx; |
| 3658 | mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3659 | mcp->in_mb = MBX_3|MBX_1|MBX_0; |
| 3660 | mcp->tov = MBX_TOV_SECONDS; |
| 3661 | mcp->flags = 0; |
| 3662 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3663 | |
| 3664 | /* Return mailbox statuses. */ |
| 3665 | if (mb != NULL) { |
| 3666 | mb[0] = mcp->mb[0]; |
| 3667 | mb[1] = mcp->mb[1]; |
| 3668 | mb[3] = mcp->mb[3]; |
| 3669 | } |
| 3670 | |
| 3671 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3672 | ql_dbg(ql_dbg_mbx, vha, 0x10b1, "Failed=%x.\n", rval); |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3673 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3674 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b2, |
| 3675 | "Done %s.\n", __func__); |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3676 | if (port_speed) |
| 3677 | *port_speed = mcp->mb[3]; |
| 3678 | } |
| 3679 | |
| 3680 | return rval; |
| 3681 | } |
| 3682 | |
| 3683 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3684 | qla2x00_set_idma_speed(scsi_qla_host_t *vha, uint16_t loop_id, |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3685 | uint16_t port_speed, uint16_t *mb) |
| 3686 | { |
| 3687 | int rval; |
| 3688 | mbx_cmd_t mc; |
| 3689 | mbx_cmd_t *mcp = &mc; |
| 3690 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3691 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b3, |
| 3692 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3693 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3694 | if (!IS_IIDMA_CAPABLE(vha->hw)) |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3695 | return QLA_FUNCTION_FAILED; |
| 3696 | |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3697 | mcp->mb[0] = MBC_PORT_PARAMS; |
| 3698 | mcp->mb[1] = loop_id; |
| 3699 | mcp->mb[2] = BIT_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3700 | if (IS_CNA_CAPABLE(vha->hw)) |
Harish Zunjarrao | 1bb3954 | 2009-06-17 10:30:29 -0700 | [diff] [blame] | 3701 | mcp->mb[3] = port_speed & (BIT_5|BIT_4|BIT_3|BIT_2|BIT_1|BIT_0); |
| 3702 | else |
| 3703 | mcp->mb[3] = port_speed & (BIT_2|BIT_1|BIT_0); |
| 3704 | mcp->mb[9] = vha->vp_idx; |
| 3705 | mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3706 | mcp->in_mb = MBX_3|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3707 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3708 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3709 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3710 | |
| 3711 | /* Return mailbox statuses. */ |
| 3712 | if (mb != NULL) { |
| 3713 | mb[0] = mcp->mb[0]; |
| 3714 | mb[1] = mcp->mb[1]; |
| 3715 | mb[3] = mcp->mb[3]; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3716 | } |
| 3717 | |
| 3718 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3719 | ql_dbg(ql_dbg_mbx, vha, 0x10b4, |
| 3720 | "Failed=%x.\n", rval); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3721 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3722 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b5, |
| 3723 | "Done %s.\n", __func__); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3724 | } |
| 3725 | |
| 3726 | return rval; |
| 3727 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3728 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3729 | void |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3730 | qla24xx_report_id_acquisition(scsi_qla_host_t *vha, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3731 | struct vp_rpt_id_entry_24xx *rptid_entry) |
| 3732 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3733 | struct qla_hw_data *ha = vha->hw; |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3734 | scsi_qla_host_t *vp = NULL; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3735 | unsigned long flags; |
Andrew Vasquez | 4ac8d4ca | 2013-02-08 01:57:58 -0500 | [diff] [blame] | 3736 | int found; |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3737 | port_id_t id; |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 3738 | struct fc_port *fcport; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3739 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3740 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b6, |
| 3741 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3742 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3743 | if (rptid_entry->entry_status != 0) |
| 3744 | return; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3745 | |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3746 | id.b.domain = rptid_entry->port_id[2]; |
| 3747 | id.b.area = rptid_entry->port_id[1]; |
| 3748 | id.b.al_pa = rptid_entry->port_id[0]; |
| 3749 | id.b.rsvd_1 = 0; |
Darren Trapp | 1763c1f | 2018-03-20 23:09:34 -0700 | [diff] [blame^] | 3750 | ha->flags.n2n_ae = 0; |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3751 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3752 | if (rptid_entry->format == 0) { |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3753 | /* loop */ |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 3754 | ql_dbg(ql_dbg_async, vha, 0x10b7, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3755 | "Format 0 : Number of VPs setup %d, number of " |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3756 | "VPs acquired %d.\n", rptid_entry->vp_setup, |
| 3757 | rptid_entry->vp_acquired); |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 3758 | ql_dbg(ql_dbg_async, vha, 0x10b8, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3759 | "Primary port id %02x%02x%02x.\n", |
| 3760 | rptid_entry->port_id[2], rptid_entry->port_id[1], |
| 3761 | rptid_entry->port_id[0]); |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 3762 | ha->current_topology = ISP_CFG_NL; |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3763 | qlt_update_host_map(vha, id); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3764 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3765 | } else if (rptid_entry->format == 1) { |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3766 | /* fabric */ |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 3767 | ql_dbg(ql_dbg_async, vha, 0x10b9, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3768 | "Format 1: VP[%d] enabled - status %d - with " |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3769 | "port id %02x%02x%02x.\n", rptid_entry->vp_idx, |
| 3770 | rptid_entry->vp_status, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3771 | rptid_entry->port_id[2], rptid_entry->port_id[1], |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3772 | rptid_entry->port_id[0]); |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 3773 | ql_dbg(ql_dbg_async, vha, 0x5075, |
| 3774 | "Format 1: Remote WWPN %8phC.\n", |
| 3775 | rptid_entry->u.f1.port_name); |
| 3776 | |
| 3777 | ql_dbg(ql_dbg_async, vha, 0x5075, |
| 3778 | "Format 1: WWPN %8phC.\n", |
| 3779 | vha->port_name); |
| 3780 | |
| 3781 | /* N2N. direct connect */ |
| 3782 | if (IS_QLA27XX(ha) && |
| 3783 | ((rptid_entry->u.f1.flags>>1) & 0x7) == 2) { |
| 3784 | /* if our portname is higher then initiate N2N login */ |
| 3785 | if (wwn_to_u64(vha->port_name) > |
| 3786 | wwn_to_u64(rptid_entry->u.f1.port_name)) { |
| 3787 | // ??? qlt_update_host_map(vha, id); |
| 3788 | vha->n2n_id = 0x1; |
| 3789 | ql_dbg(ql_dbg_async, vha, 0x5075, |
| 3790 | "Format 1: Setting n2n_update_needed for id %d\n", |
| 3791 | vha->n2n_id); |
| 3792 | } else { |
| 3793 | ql_dbg(ql_dbg_async, vha, 0x5075, |
| 3794 | "Format 1: Remote login - Waiting for WWPN %8phC.\n", |
| 3795 | rptid_entry->u.f1.port_name); |
| 3796 | } |
| 3797 | |
| 3798 | memcpy(vha->n2n_port_name, rptid_entry->u.f1.port_name, |
| 3799 | WWN_SIZE); |
| 3800 | set_bit(N2N_LOGIN_NEEDED, &vha->dpc_flags); |
| 3801 | set_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags); |
| 3802 | set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags); |
Darren Trapp | 1763c1f | 2018-03-20 23:09:34 -0700 | [diff] [blame^] | 3803 | ha->flags.n2n_ae = 1; |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 3804 | return; |
| 3805 | } |
Andrew Vasquez | 531a82d | 2009-10-13 15:16:51 -0700 | [diff] [blame] | 3806 | |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 3807 | ha->flags.gpsc_supported = 1; |
| 3808 | ha->current_topology = ISP_CFG_F; |
Sawan Chandak | 969a619 | 2016-01-27 12:03:32 -0500 | [diff] [blame] | 3809 | /* buffer to buffer credit flag */ |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3810 | vha->flags.bbcr_enable = (rptid_entry->u.f1.bbcr & 0xf) != 0; |
Sawan Chandak | 969a619 | 2016-01-27 12:03:32 -0500 | [diff] [blame] | 3811 | |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3812 | if (rptid_entry->vp_idx == 0) { |
| 3813 | if (rptid_entry->vp_status == VP_STAT_COMPL) { |
| 3814 | /* FA-WWN is only for physical port */ |
| 3815 | if (qla_ini_mode_enabled(vha) && |
| 3816 | ha->flags.fawwpn_enabled && |
| 3817 | (rptid_entry->u.f1.flags & |
Sawan Chandak | fcc5b5c | 2017-08-23 15:05:02 -0700 | [diff] [blame] | 3818 | BIT_6)) { |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3819 | memcpy(vha->port_name, |
| 3820 | rptid_entry->u.f1.port_name, |
| 3821 | WWN_SIZE); |
| 3822 | } |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 3823 | |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3824 | qlt_update_host_map(vha, id); |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 3825 | } |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3826 | |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3827 | set_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags); |
| 3828 | set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags); |
| 3829 | } else { |
| 3830 | if (rptid_entry->vp_status != VP_STAT_COMPL && |
| 3831 | rptid_entry->vp_status != VP_STAT_ID_CHG) { |
| 3832 | ql_dbg(ql_dbg_mbx, vha, 0x10ba, |
| 3833 | "Could not acquire ID for VP[%d].\n", |
| 3834 | rptid_entry->vp_idx); |
| 3835 | return; |
Andrew Vasquez | 4ac8d4ca | 2013-02-08 01:57:58 -0500 | [diff] [blame] | 3836 | } |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3837 | |
| 3838 | found = 0; |
| 3839 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 3840 | list_for_each_entry(vp, &ha->vp_list, list) { |
| 3841 | if (rptid_entry->vp_idx == vp->vp_idx) { |
| 3842 | found = 1; |
| 3843 | break; |
| 3844 | } |
| 3845 | } |
| 3846 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 3847 | |
| 3848 | if (!found) |
| 3849 | return; |
| 3850 | |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3851 | qlt_update_host_map(vp, id); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3852 | |
| 3853 | /* |
| 3854 | * Cannot configure here as we are still sitting on the |
| 3855 | * response queue. Handle it in dpc context. |
| 3856 | */ |
| 3857 | set_bit(VP_IDX_ACQUIRED, &vp->vp_flags); |
| 3858 | set_bit(REGISTER_FC4_NEEDED, &vp->dpc_flags); |
| 3859 | set_bit(REGISTER_FDMI_NEEDED, &vp->dpc_flags); |
Andrew Vasquez | 4ac8d4ca | 2013-02-08 01:57:58 -0500 | [diff] [blame] | 3860 | } |
Andrew Vasquez | 531a82d | 2009-10-13 15:16:51 -0700 | [diff] [blame] | 3861 | set_bit(VP_DPC_NEEDED, &vha->dpc_flags); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3862 | qla2xxx_wake_dpc(vha); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3863 | } else if (rptid_entry->format == 2) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3864 | ql_dbg(ql_dbg_async, vha, 0x505f, |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3865 | "RIDA: format 2/N2N Primary port id %02x%02x%02x.\n", |
| 3866 | rptid_entry->port_id[2], rptid_entry->port_id[1], |
| 3867 | rptid_entry->port_id[0]); |
| 3868 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3869 | ql_dbg(ql_dbg_async, vha, 0x5075, |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3870 | "N2N: Remote WWPN %8phC.\n", |
| 3871 | rptid_entry->u.f2.port_name); |
| 3872 | |
| 3873 | /* N2N. direct connect */ |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 3874 | ha->current_topology = ISP_CFG_N; |
| 3875 | ha->flags.rida_fmt2 = 1; |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3876 | vha->d_id.b.domain = rptid_entry->port_id[2]; |
| 3877 | vha->d_id.b.area = rptid_entry->port_id[1]; |
| 3878 | vha->d_id.b.al_pa = rptid_entry->port_id[0]; |
| 3879 | |
Darren Trapp | 1763c1f | 2018-03-20 23:09:34 -0700 | [diff] [blame^] | 3880 | ha->flags.n2n_ae = 1; |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3881 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 3882 | qlt_update_vp_map(vha, SET_AL_PA); |
| 3883 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 3884 | |
| 3885 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 3886 | fcport->scan_state = QLA_FCPORT_SCAN; |
| 3887 | } |
| 3888 | |
| 3889 | fcport = qla2x00_find_fcport_by_wwpn(vha, |
| 3890 | rptid_entry->u.f2.port_name, 1); |
| 3891 | |
| 3892 | if (fcport) { |
| 3893 | fcport->plogi_nack_done_deadline = jiffies + HZ; |
| 3894 | fcport->scan_state = QLA_FCPORT_FOUND; |
| 3895 | switch (fcport->disc_state) { |
| 3896 | case DSC_DELETED: |
| 3897 | ql_dbg(ql_dbg_disc, vha, 0x210d, |
| 3898 | "%s %d %8phC login\n", |
| 3899 | __func__, __LINE__, fcport->port_name); |
| 3900 | qla24xx_fcport_handle_login(vha, fcport); |
| 3901 | break; |
| 3902 | case DSC_DELETE_PEND: |
| 3903 | break; |
| 3904 | default: |
Quinn Tran | d8630bb | 2017-12-28 12:33:43 -0800 | [diff] [blame] | 3905 | qlt_schedule_sess_for_deletion(fcport); |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 3906 | break; |
| 3907 | } |
| 3908 | } else { |
| 3909 | id.b.al_pa = rptid_entry->u.f2.remote_nport_id[0]; |
| 3910 | id.b.area = rptid_entry->u.f2.remote_nport_id[1]; |
| 3911 | id.b.domain = rptid_entry->u.f2.remote_nport_id[2]; |
| 3912 | qla24xx_post_newsess_work(vha, &id, |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 3913 | rptid_entry->u.f2.port_name, |
| 3914 | rptid_entry->u.f2.node_name, |
| 3915 | NULL, |
| 3916 | FC4_TYPE_UNKNOWN); |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 3917 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3918 | } |
| 3919 | } |
| 3920 | |
| 3921 | /* |
| 3922 | * qla24xx_modify_vp_config |
| 3923 | * Change VP configuration for vha |
| 3924 | * |
| 3925 | * Input: |
| 3926 | * vha = adapter block pointer. |
| 3927 | * |
| 3928 | * Returns: |
| 3929 | * qla2xxx local function return status code. |
| 3930 | * |
| 3931 | * Context: |
| 3932 | * Kernel context. |
| 3933 | */ |
| 3934 | int |
| 3935 | qla24xx_modify_vp_config(scsi_qla_host_t *vha) |
| 3936 | { |
| 3937 | int rval; |
| 3938 | struct vp_config_entry_24xx *vpmod; |
| 3939 | dma_addr_t vpmod_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3940 | struct qla_hw_data *ha = vha->hw; |
| 3941 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3942 | |
| 3943 | /* This can be called by the parent */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3944 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3945 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10bb, |
| 3946 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3947 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 3948 | vpmod = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &vpmod_dma); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3949 | if (!vpmod) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3950 | ql_log(ql_log_warn, vha, 0x10bc, |
| 3951 | "Failed to allocate modify VP IOCB.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3952 | return QLA_MEMORY_ALLOC_FAILED; |
| 3953 | } |
| 3954 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3955 | vpmod->entry_type = VP_CONFIG_IOCB_TYPE; |
| 3956 | vpmod->entry_count = 1; |
| 3957 | vpmod->command = VCT_COMMAND_MOD_ENABLE_VPS; |
| 3958 | vpmod->vp_count = 1; |
| 3959 | vpmod->vp_index1 = vha->vp_idx; |
| 3960 | vpmod->options_idx1 = BIT_3|BIT_4|BIT_5; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3961 | |
| 3962 | qlt_modify_vp_config(vha, vpmod); |
| 3963 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3964 | memcpy(vpmod->node_name_idx1, vha->node_name, WWN_SIZE); |
| 3965 | memcpy(vpmod->port_name_idx1, vha->port_name, WWN_SIZE); |
| 3966 | vpmod->entry_count = 1; |
| 3967 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3968 | rval = qla2x00_issue_iocb(base_vha, vpmod, vpmod_dma, 0); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3969 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3970 | ql_dbg(ql_dbg_mbx, vha, 0x10bd, |
| 3971 | "Failed to issue VP config IOCB (%x).\n", rval); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3972 | } else if (vpmod->comp_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3973 | ql_dbg(ql_dbg_mbx, vha, 0x10be, |
| 3974 | "Failed to complete IOCB -- error status (%x).\n", |
| 3975 | vpmod->comp_status); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3976 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 3977 | } else if (vpmod->comp_status != cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3978 | ql_dbg(ql_dbg_mbx, vha, 0x10bf, |
| 3979 | "Failed to complete IOCB -- completion status (%x).\n", |
| 3980 | le16_to_cpu(vpmod->comp_status)); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3981 | rval = QLA_FUNCTION_FAILED; |
| 3982 | } else { |
| 3983 | /* EMPTY */ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3984 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c0, |
| 3985 | "Done %s.\n", __func__); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3986 | fc_vport_set_state(vha->fc_vport, FC_VPORT_INITIALIZING); |
| 3987 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3988 | dma_pool_free(ha->s_dma_pool, vpmod, vpmod_dma); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3989 | |
| 3990 | return rval; |
| 3991 | } |
| 3992 | |
| 3993 | /* |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3994 | * qla2x00_send_change_request |
| 3995 | * Receive or disable RSCN request from fabric controller |
| 3996 | * |
| 3997 | * Input: |
| 3998 | * ha = adapter block pointer |
| 3999 | * format = registration format: |
| 4000 | * 0 - Reserved |
| 4001 | * 1 - Fabric detected registration |
| 4002 | * 2 - N_port detected registration |
| 4003 | * 3 - Full registration |
| 4004 | * FF - clear registration |
| 4005 | * vp_idx = Virtual port index |
| 4006 | * |
| 4007 | * Returns: |
| 4008 | * qla2x00 local function return status code. |
| 4009 | * |
| 4010 | * Context: |
| 4011 | * Kernel Context |
| 4012 | */ |
| 4013 | |
| 4014 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4015 | qla2x00_send_change_request(scsi_qla_host_t *vha, uint16_t format, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4016 | uint16_t vp_idx) |
| 4017 | { |
| 4018 | int rval; |
| 4019 | mbx_cmd_t mc; |
| 4020 | mbx_cmd_t *mcp = &mc; |
| 4021 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4022 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c7, |
| 4023 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4024 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4025 | mcp->mb[0] = MBC_SEND_CHANGE_REQUEST; |
| 4026 | mcp->mb[1] = format; |
| 4027 | mcp->mb[9] = vp_idx; |
| 4028 | mcp->out_mb = MBX_9|MBX_1|MBX_0; |
| 4029 | mcp->in_mb = MBX_0|MBX_1; |
| 4030 | mcp->tov = MBX_TOV_SECONDS; |
| 4031 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4032 | rval = qla2x00_mailbox_command(vha, mcp); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4033 | |
| 4034 | if (rval == QLA_SUCCESS) { |
| 4035 | if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { |
| 4036 | rval = BIT_1; |
| 4037 | } |
| 4038 | } else |
| 4039 | rval = BIT_1; |
| 4040 | |
| 4041 | return rval; |
| 4042 | } |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4043 | |
| 4044 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4045 | qla2x00_dump_ram(scsi_qla_host_t *vha, dma_addr_t req_dma, uint32_t addr, |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4046 | uint32_t size) |
| 4047 | { |
| 4048 | int rval; |
| 4049 | mbx_cmd_t mc; |
| 4050 | mbx_cmd_t *mcp = &mc; |
| 4051 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4052 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1009, |
| 4053 | "Entered %s.\n", __func__); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4054 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4055 | if (MSW(addr) || IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4056 | mcp->mb[0] = MBC_DUMP_RISC_RAM_EXTENDED; |
| 4057 | mcp->mb[8] = MSW(addr); |
| 4058 | mcp->out_mb = MBX_8|MBX_0; |
| 4059 | } else { |
| 4060 | mcp->mb[0] = MBC_DUMP_RISC_RAM; |
| 4061 | mcp->out_mb = MBX_0; |
| 4062 | } |
| 4063 | mcp->mb[1] = LSW(addr); |
| 4064 | mcp->mb[2] = MSW(req_dma); |
| 4065 | mcp->mb[3] = LSW(req_dma); |
| 4066 | mcp->mb[6] = MSW(MSD(req_dma)); |
| 4067 | mcp->mb[7] = LSW(MSD(req_dma)); |
| 4068 | mcp->out_mb |= MBX_7|MBX_6|MBX_3|MBX_2|MBX_1; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4069 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4070 | mcp->mb[4] = MSW(size); |
| 4071 | mcp->mb[5] = LSW(size); |
| 4072 | mcp->out_mb |= MBX_5|MBX_4; |
| 4073 | } else { |
| 4074 | mcp->mb[4] = LSW(size); |
| 4075 | mcp->out_mb |= MBX_4; |
| 4076 | } |
| 4077 | |
| 4078 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 4079 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4080 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4081 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4082 | |
| 4083 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4084 | ql_dbg(ql_dbg_mbx, vha, 0x1008, |
| 4085 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4086 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4087 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1007, |
| 4088 | "Done %s.\n", __func__); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4089 | } |
| 4090 | |
| 4091 | return rval; |
| 4092 | } |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4093 | /* 84XX Support **************************************************************/ |
| 4094 | |
| 4095 | struct cs84xx_mgmt_cmd { |
| 4096 | union { |
| 4097 | struct verify_chip_entry_84xx req; |
| 4098 | struct verify_chip_rsp_84xx rsp; |
| 4099 | } p; |
| 4100 | }; |
| 4101 | |
| 4102 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4103 | qla84xx_verify_chip(struct scsi_qla_host *vha, uint16_t *status) |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4104 | { |
| 4105 | int rval, retry; |
| 4106 | struct cs84xx_mgmt_cmd *mn; |
| 4107 | dma_addr_t mn_dma; |
| 4108 | uint16_t options; |
| 4109 | unsigned long flags; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4110 | struct qla_hw_data *ha = vha->hw; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4111 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4112 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c8, |
| 4113 | "Entered %s.\n", __func__); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4114 | |
| 4115 | mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma); |
| 4116 | if (mn == NULL) { |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4117 | return QLA_MEMORY_ALLOC_FAILED; |
| 4118 | } |
| 4119 | |
| 4120 | /* Force Update? */ |
| 4121 | options = ha->cs84xx->fw_update ? VCO_FORCE_UPDATE : 0; |
| 4122 | /* Diagnostic firmware? */ |
| 4123 | /* options |= MENLO_DIAG_FW; */ |
| 4124 | /* We update the firmware with only one data sequence. */ |
| 4125 | options |= VCO_END_OF_DATA; |
| 4126 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4127 | do { |
Andrew Vasquez | c1ec1f1 | 2008-04-24 15:21:24 -0700 | [diff] [blame] | 4128 | retry = 0; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4129 | memset(mn, 0, sizeof(*mn)); |
| 4130 | mn->p.req.entry_type = VERIFY_CHIP_IOCB_TYPE; |
| 4131 | mn->p.req.entry_count = 1; |
| 4132 | mn->p.req.options = cpu_to_le16(options); |
| 4133 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4134 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111c, |
| 4135 | "Dump of Verify Request.\n"); |
| 4136 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111e, |
| 4137 | (uint8_t *)mn, sizeof(*mn)); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4138 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4139 | rval = qla2x00_issue_iocb_timeout(vha, mn, mn_dma, 0, 120); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4140 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4141 | ql_dbg(ql_dbg_mbx, vha, 0x10cb, |
| 4142 | "Failed to issue verify IOCB (%x).\n", rval); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4143 | goto verify_done; |
| 4144 | } |
| 4145 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4146 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1110, |
| 4147 | "Dump of Verify Response.\n"); |
| 4148 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1118, |
| 4149 | (uint8_t *)mn, sizeof(*mn)); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4150 | |
| 4151 | status[0] = le16_to_cpu(mn->p.rsp.comp_status); |
| 4152 | status[1] = status[0] == CS_VCS_CHIP_FAILURE ? |
| 4153 | le16_to_cpu(mn->p.rsp.failure_code) : 0; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4154 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ce, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4155 | "cs=%x fc=%x.\n", status[0], status[1]); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4156 | |
| 4157 | if (status[0] != CS_COMPLETE) { |
| 4158 | rval = QLA_FUNCTION_FAILED; |
| 4159 | if (!(options & VCO_DONT_UPDATE_FW)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4160 | ql_dbg(ql_dbg_mbx, vha, 0x10cf, |
| 4161 | "Firmware update failed. Retrying " |
| 4162 | "without update firmware.\n"); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4163 | options |= VCO_DONT_UPDATE_FW; |
| 4164 | options &= ~VCO_FORCE_UPDATE; |
| 4165 | retry = 1; |
| 4166 | } |
| 4167 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4168 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d0, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4169 | "Firmware updated to %x.\n", |
| 4170 | le32_to_cpu(mn->p.rsp.fw_ver)); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4171 | |
| 4172 | /* NOTE: we only update OP firmware. */ |
| 4173 | spin_lock_irqsave(&ha->cs84xx->access_lock, flags); |
| 4174 | ha->cs84xx->op_fw_version = |
| 4175 | le32_to_cpu(mn->p.rsp.fw_ver); |
| 4176 | spin_unlock_irqrestore(&ha->cs84xx->access_lock, |
| 4177 | flags); |
| 4178 | } |
| 4179 | } while (retry); |
| 4180 | |
| 4181 | verify_done: |
| 4182 | dma_pool_free(ha->s_dma_pool, mn, mn_dma); |
| 4183 | |
| 4184 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4185 | ql_dbg(ql_dbg_mbx, vha, 0x10d1, |
| 4186 | "Failed=%x.\n", rval); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4187 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4188 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d2, |
| 4189 | "Done %s.\n", __func__); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4190 | } |
| 4191 | |
| 4192 | return rval; |
| 4193 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4194 | |
| 4195 | int |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4196 | qla25xx_init_req_que(struct scsi_qla_host *vha, struct req_que *req) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4197 | { |
| 4198 | int rval; |
| 4199 | unsigned long flags; |
| 4200 | mbx_cmd_t mc; |
| 4201 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4202 | struct qla_hw_data *ha = vha->hw; |
| 4203 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4204 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d3, |
| 4205 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4206 | |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 4207 | if (IS_SHADOW_REG_CAPABLE(ha)) |
| 4208 | req->options |= BIT_13; |
| 4209 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4210 | mcp->mb[0] = MBC_INITIALIZE_MULTIQ; |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4211 | mcp->mb[1] = req->options; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4212 | mcp->mb[2] = MSW(LSD(req->dma)); |
| 4213 | mcp->mb[3] = LSW(LSD(req->dma)); |
| 4214 | mcp->mb[6] = MSW(MSD(req->dma)); |
| 4215 | mcp->mb[7] = LSW(MSD(req->dma)); |
| 4216 | mcp->mb[5] = req->length; |
| 4217 | if (req->rsp) |
| 4218 | mcp->mb[10] = req->rsp->id; |
| 4219 | mcp->mb[12] = req->qos; |
| 4220 | mcp->mb[11] = req->vp_idx; |
| 4221 | mcp->mb[13] = req->rid; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4222 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4223 | mcp->mb[15] = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4224 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4225 | mcp->mb[4] = req->id; |
| 4226 | /* que in ptr index */ |
| 4227 | mcp->mb[8] = 0; |
| 4228 | /* que out ptr index */ |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 4229 | mcp->mb[9] = *req->out_ptr = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4230 | mcp->out_mb = MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8|MBX_7| |
| 4231 | MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4232 | mcp->in_mb = MBX_0; |
| 4233 | mcp->flags = MBX_DMA_OUT; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4234 | mcp->tov = MBX_TOV_SECONDS * 2; |
| 4235 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4236 | if (IS_QLA81XX(ha) || IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4237 | mcp->in_mb |= MBX_1; |
Joe Carnuccio | ba4828b | 2014-04-11 16:54:10 -0400 | [diff] [blame] | 4238 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4239 | mcp->out_mb |= MBX_15; |
| 4240 | /* debug q create issue in SR-IOV */ |
| 4241 | mcp->in_mb |= MBX_9 | MBX_8 | MBX_7; |
| 4242 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4243 | |
| 4244 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4245 | if (!(req->options & BIT_0)) { |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 4246 | WRT_REG_DWORD(req->req_q_in, 0); |
Joe Carnuccio | 29db41c | 2014-04-11 16:54:09 -0400 | [diff] [blame] | 4247 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 4248 | WRT_REG_DWORD(req->req_q_out, 0); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4249 | } |
| 4250 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 4251 | |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 4252 | rval = qla2x00_mailbox_command(vha, mcp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4253 | if (rval != QLA_SUCCESS) { |
| 4254 | ql_dbg(ql_dbg_mbx, vha, 0x10d4, |
| 4255 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 4256 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4257 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d5, |
| 4258 | "Done %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4259 | } |
| 4260 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4261 | return rval; |
| 4262 | } |
| 4263 | |
| 4264 | int |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4265 | qla25xx_init_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4266 | { |
| 4267 | int rval; |
| 4268 | unsigned long flags; |
| 4269 | mbx_cmd_t mc; |
| 4270 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4271 | struct qla_hw_data *ha = vha->hw; |
| 4272 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4273 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d6, |
| 4274 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4275 | |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 4276 | if (IS_SHADOW_REG_CAPABLE(ha)) |
| 4277 | rsp->options |= BIT_13; |
| 4278 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4279 | mcp->mb[0] = MBC_INITIALIZE_MULTIQ; |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4280 | mcp->mb[1] = rsp->options; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4281 | mcp->mb[2] = MSW(LSD(rsp->dma)); |
| 4282 | mcp->mb[3] = LSW(LSD(rsp->dma)); |
| 4283 | mcp->mb[6] = MSW(MSD(rsp->dma)); |
| 4284 | mcp->mb[7] = LSW(MSD(rsp->dma)); |
| 4285 | mcp->mb[5] = rsp->length; |
Andrew Vasquez | 444786d | 2009-01-05 11:18:10 -0800 | [diff] [blame] | 4286 | mcp->mb[14] = rsp->msix->entry; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4287 | mcp->mb[13] = rsp->rid; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4288 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4289 | mcp->mb[15] = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4290 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4291 | mcp->mb[4] = rsp->id; |
| 4292 | /* que in ptr index */ |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 4293 | mcp->mb[8] = *rsp->in_ptr = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4294 | /* que out ptr index */ |
| 4295 | mcp->mb[9] = 0; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 4296 | mcp->out_mb = MBX_14|MBX_13|MBX_9|MBX_8|MBX_7 |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4297 | |MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4298 | mcp->in_mb = MBX_0; |
| 4299 | mcp->flags = MBX_DMA_OUT; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4300 | mcp->tov = MBX_TOV_SECONDS * 2; |
| 4301 | |
| 4302 | if (IS_QLA81XX(ha)) { |
| 4303 | mcp->out_mb |= MBX_12|MBX_11|MBX_10; |
| 4304 | mcp->in_mb |= MBX_1; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4305 | } else if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4306 | mcp->out_mb |= MBX_15|MBX_12|MBX_11|MBX_10; |
| 4307 | mcp->in_mb |= MBX_1; |
| 4308 | /* debug q create issue in SR-IOV */ |
| 4309 | mcp->in_mb |= MBX_9 | MBX_8 | MBX_7; |
| 4310 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4311 | |
| 4312 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4313 | if (!(rsp->options & BIT_0)) { |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 4314 | WRT_REG_DWORD(rsp->rsp_q_out, 0); |
Himanshu Madhani | b20f02e | 2015-06-10 11:05:18 -0400 | [diff] [blame] | 4315 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 4316 | WRT_REG_DWORD(rsp->rsp_q_in, 0); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4317 | } |
| 4318 | |
| 4319 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 4320 | |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 4321 | rval = qla2x00_mailbox_command(vha, mcp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4322 | if (rval != QLA_SUCCESS) { |
| 4323 | ql_dbg(ql_dbg_mbx, vha, 0x10d7, |
| 4324 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 4325 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4326 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d8, |
| 4327 | "Done %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4328 | } |
| 4329 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4330 | return rval; |
| 4331 | } |
| 4332 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4333 | int |
| 4334 | qla81xx_idc_ack(scsi_qla_host_t *vha, uint16_t *mb) |
| 4335 | { |
| 4336 | int rval; |
| 4337 | mbx_cmd_t mc; |
| 4338 | mbx_cmd_t *mcp = &mc; |
| 4339 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4340 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d9, |
| 4341 | "Entered %s.\n", __func__); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4342 | |
| 4343 | mcp->mb[0] = MBC_IDC_ACK; |
| 4344 | memcpy(&mcp->mb[1], mb, QLA_IDC_ACK_REGS * sizeof(uint16_t)); |
| 4345 | mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4346 | mcp->in_mb = MBX_0; |
| 4347 | mcp->tov = MBX_TOV_SECONDS; |
| 4348 | mcp->flags = 0; |
| 4349 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4350 | |
| 4351 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4352 | ql_dbg(ql_dbg_mbx, vha, 0x10da, |
| 4353 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4354 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4355 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10db, |
| 4356 | "Done %s.\n", __func__); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4357 | } |
| 4358 | |
| 4359 | return rval; |
| 4360 | } |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4361 | |
| 4362 | int |
| 4363 | qla81xx_fac_get_sector_size(scsi_qla_host_t *vha, uint32_t *sector_size) |
| 4364 | { |
| 4365 | int rval; |
| 4366 | mbx_cmd_t mc; |
| 4367 | mbx_cmd_t *mcp = &mc; |
| 4368 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4369 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10dc, |
| 4370 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4371 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4372 | if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) && |
| 4373 | !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4374 | return QLA_FUNCTION_FAILED; |
| 4375 | |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4376 | mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; |
| 4377 | mcp->mb[1] = FAC_OPT_CMD_GET_SECTOR_SIZE; |
| 4378 | mcp->out_mb = MBX_1|MBX_0; |
| 4379 | mcp->in_mb = MBX_1|MBX_0; |
| 4380 | mcp->tov = MBX_TOV_SECONDS; |
| 4381 | mcp->flags = 0; |
| 4382 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4383 | |
| 4384 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4385 | ql_dbg(ql_dbg_mbx, vha, 0x10dd, |
| 4386 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 4387 | rval, mcp->mb[0], mcp->mb[1]); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4388 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4389 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10de, |
| 4390 | "Done %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4391 | *sector_size = mcp->mb[1]; |
| 4392 | } |
| 4393 | |
| 4394 | return rval; |
| 4395 | } |
| 4396 | |
| 4397 | int |
| 4398 | qla81xx_fac_do_write_enable(scsi_qla_host_t *vha, int enable) |
| 4399 | { |
| 4400 | int rval; |
| 4401 | mbx_cmd_t mc; |
| 4402 | mbx_cmd_t *mcp = &mc; |
| 4403 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4404 | if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) && |
| 4405 | !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4406 | return QLA_FUNCTION_FAILED; |
| 4407 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4408 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10df, |
| 4409 | "Entered %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4410 | |
| 4411 | mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; |
| 4412 | mcp->mb[1] = enable ? FAC_OPT_CMD_WRITE_ENABLE : |
| 4413 | FAC_OPT_CMD_WRITE_PROTECT; |
| 4414 | mcp->out_mb = MBX_1|MBX_0; |
| 4415 | mcp->in_mb = MBX_1|MBX_0; |
| 4416 | mcp->tov = MBX_TOV_SECONDS; |
| 4417 | mcp->flags = 0; |
| 4418 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4419 | |
| 4420 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4421 | ql_dbg(ql_dbg_mbx, vha, 0x10e0, |
| 4422 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 4423 | rval, mcp->mb[0], mcp->mb[1]); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4424 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4425 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e1, |
| 4426 | "Done %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4427 | } |
| 4428 | |
| 4429 | return rval; |
| 4430 | } |
| 4431 | |
| 4432 | int |
| 4433 | qla81xx_fac_erase_sector(scsi_qla_host_t *vha, uint32_t start, uint32_t finish) |
| 4434 | { |
| 4435 | int rval; |
| 4436 | mbx_cmd_t mc; |
| 4437 | mbx_cmd_t *mcp = &mc; |
| 4438 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4439 | if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) && |
| 4440 | !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4441 | return QLA_FUNCTION_FAILED; |
| 4442 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4443 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e2, |
| 4444 | "Entered %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4445 | |
| 4446 | mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; |
| 4447 | mcp->mb[1] = FAC_OPT_CMD_ERASE_SECTOR; |
| 4448 | mcp->mb[2] = LSW(start); |
| 4449 | mcp->mb[3] = MSW(start); |
| 4450 | mcp->mb[4] = LSW(finish); |
| 4451 | mcp->mb[5] = MSW(finish); |
| 4452 | mcp->out_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4453 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 4454 | mcp->tov = MBX_TOV_SECONDS; |
| 4455 | mcp->flags = 0; |
| 4456 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4457 | |
| 4458 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4459 | ql_dbg(ql_dbg_mbx, vha, 0x10e3, |
| 4460 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 4461 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4462 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4463 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e4, |
| 4464 | "Done %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4465 | } |
| 4466 | |
| 4467 | return rval; |
| 4468 | } |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4469 | |
| 4470 | int |
| 4471 | qla81xx_restart_mpi_firmware(scsi_qla_host_t *vha) |
| 4472 | { |
| 4473 | int rval = 0; |
| 4474 | mbx_cmd_t mc; |
| 4475 | mbx_cmd_t *mcp = &mc; |
| 4476 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4477 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e5, |
| 4478 | "Entered %s.\n", __func__); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4479 | |
| 4480 | mcp->mb[0] = MBC_RESTART_MPI_FW; |
| 4481 | mcp->out_mb = MBX_0; |
| 4482 | mcp->in_mb = MBX_0|MBX_1; |
| 4483 | mcp->tov = MBX_TOV_SECONDS; |
| 4484 | mcp->flags = 0; |
| 4485 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4486 | |
| 4487 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4488 | ql_dbg(ql_dbg_mbx, vha, 0x10e6, |
| 4489 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 4490 | rval, mcp->mb[0], mcp->mb[1]); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4491 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4492 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e7, |
| 4493 | "Done %s.\n", __func__); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4494 | } |
| 4495 | |
| 4496 | return rval; |
| 4497 | } |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4498 | |
Joe Carnuccio | c46e65c | 2013-08-27 01:37:35 -0400 | [diff] [blame] | 4499 | int |
| 4500 | qla82xx_set_driver_version(scsi_qla_host_t *vha, char *version) |
| 4501 | { |
| 4502 | int rval; |
| 4503 | mbx_cmd_t mc; |
| 4504 | mbx_cmd_t *mcp = &mc; |
| 4505 | int i; |
| 4506 | int len; |
| 4507 | uint16_t *str; |
| 4508 | struct qla_hw_data *ha = vha->hw; |
| 4509 | |
| 4510 | if (!IS_P3P_TYPE(ha)) |
| 4511 | return QLA_FUNCTION_FAILED; |
| 4512 | |
| 4513 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x117b, |
| 4514 | "Entered %s.\n", __func__); |
| 4515 | |
| 4516 | str = (void *)version; |
| 4517 | len = strlen(version); |
| 4518 | |
| 4519 | mcp->mb[0] = MBC_SET_RNID_PARAMS; |
| 4520 | mcp->mb[1] = RNID_TYPE_SET_VERSION << 8; |
| 4521 | mcp->out_mb = MBX_1|MBX_0; |
| 4522 | for (i = 4; i < 16 && len; i++, str++, len -= 2) { |
| 4523 | mcp->mb[i] = cpu_to_le16p(str); |
| 4524 | mcp->out_mb |= 1<<i; |
| 4525 | } |
| 4526 | for (; i < 16; i++) { |
| 4527 | mcp->mb[i] = 0; |
| 4528 | mcp->out_mb |= 1<<i; |
| 4529 | } |
| 4530 | mcp->in_mb = MBX_1|MBX_0; |
| 4531 | mcp->tov = MBX_TOV_SECONDS; |
| 4532 | mcp->flags = 0; |
| 4533 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4534 | |
| 4535 | if (rval != QLA_SUCCESS) { |
| 4536 | ql_dbg(ql_dbg_mbx, vha, 0x117c, |
| 4537 | "Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]); |
| 4538 | } else { |
| 4539 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x117d, |
| 4540 | "Done %s.\n", __func__); |
| 4541 | } |
| 4542 | |
| 4543 | return rval; |
| 4544 | } |
| 4545 | |
| 4546 | int |
| 4547 | qla25xx_set_driver_version(scsi_qla_host_t *vha, char *version) |
| 4548 | { |
| 4549 | int rval; |
| 4550 | mbx_cmd_t mc; |
| 4551 | mbx_cmd_t *mcp = &mc; |
| 4552 | int len; |
| 4553 | uint16_t dwlen; |
| 4554 | uint8_t *str; |
| 4555 | dma_addr_t str_dma; |
| 4556 | struct qla_hw_data *ha = vha->hw; |
| 4557 | |
| 4558 | if (!IS_FWI2_CAPABLE(ha) || IS_QLA24XX_TYPE(ha) || IS_QLA81XX(ha) || |
| 4559 | IS_P3P_TYPE(ha)) |
| 4560 | return QLA_FUNCTION_FAILED; |
| 4561 | |
| 4562 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x117e, |
| 4563 | "Entered %s.\n", __func__); |
| 4564 | |
| 4565 | str = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &str_dma); |
| 4566 | if (!str) { |
| 4567 | ql_log(ql_log_warn, vha, 0x117f, |
| 4568 | "Failed to allocate driver version param.\n"); |
| 4569 | return QLA_MEMORY_ALLOC_FAILED; |
| 4570 | } |
| 4571 | |
| 4572 | memcpy(str, "\x7\x3\x11\x0", 4); |
| 4573 | dwlen = str[0]; |
| 4574 | len = dwlen * 4 - 4; |
| 4575 | memset(str + 4, 0, len); |
| 4576 | if (len > strlen(version)) |
| 4577 | len = strlen(version); |
| 4578 | memcpy(str + 4, version, len); |
| 4579 | |
| 4580 | mcp->mb[0] = MBC_SET_RNID_PARAMS; |
| 4581 | mcp->mb[1] = RNID_TYPE_SET_VERSION << 8 | dwlen; |
| 4582 | mcp->mb[2] = MSW(LSD(str_dma)); |
| 4583 | mcp->mb[3] = LSW(LSD(str_dma)); |
| 4584 | mcp->mb[6] = MSW(MSD(str_dma)); |
| 4585 | mcp->mb[7] = LSW(MSD(str_dma)); |
| 4586 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4587 | mcp->in_mb = MBX_1|MBX_0; |
| 4588 | mcp->tov = MBX_TOV_SECONDS; |
| 4589 | mcp->flags = 0; |
| 4590 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4591 | |
| 4592 | if (rval != QLA_SUCCESS) { |
| 4593 | ql_dbg(ql_dbg_mbx, vha, 0x1180, |
| 4594 | "Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]); |
| 4595 | } else { |
| 4596 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1181, |
| 4597 | "Done %s.\n", __func__); |
| 4598 | } |
| 4599 | |
| 4600 | dma_pool_free(ha->s_dma_pool, str, str_dma); |
| 4601 | |
| 4602 | return rval; |
| 4603 | } |
| 4604 | |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 4605 | int |
| 4606 | qla24xx_get_port_login_templ(scsi_qla_host_t *vha, dma_addr_t buf_dma, |
| 4607 | void *buf, uint16_t bufsiz) |
| 4608 | { |
| 4609 | int rval, i; |
| 4610 | mbx_cmd_t mc; |
| 4611 | mbx_cmd_t *mcp = &mc; |
| 4612 | uint32_t *bp; |
| 4613 | |
| 4614 | if (!IS_FWI2_CAPABLE(vha->hw)) |
| 4615 | return QLA_FUNCTION_FAILED; |
| 4616 | |
| 4617 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1159, |
| 4618 | "Entered %s.\n", __func__); |
| 4619 | |
| 4620 | mcp->mb[0] = MBC_GET_RNID_PARAMS; |
| 4621 | mcp->mb[1] = RNID_TYPE_PORT_LOGIN << 8; |
| 4622 | mcp->mb[2] = MSW(buf_dma); |
| 4623 | mcp->mb[3] = LSW(buf_dma); |
| 4624 | mcp->mb[6] = MSW(MSD(buf_dma)); |
| 4625 | mcp->mb[7] = LSW(MSD(buf_dma)); |
| 4626 | mcp->mb[8] = bufsiz/4; |
| 4627 | mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4628 | mcp->in_mb = MBX_1|MBX_0; |
| 4629 | mcp->tov = MBX_TOV_SECONDS; |
| 4630 | mcp->flags = 0; |
| 4631 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4632 | |
| 4633 | if (rval != QLA_SUCCESS) { |
| 4634 | ql_dbg(ql_dbg_mbx, vha, 0x115a, |
| 4635 | "Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]); |
| 4636 | } else { |
| 4637 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x115b, |
| 4638 | "Done %s.\n", __func__); |
| 4639 | bp = (uint32_t *) buf; |
| 4640 | for (i = 0; i < (bufsiz-4)/4; i++, bp++) |
| 4641 | *bp = cpu_to_be32(*bp); |
| 4642 | } |
| 4643 | |
| 4644 | return rval; |
| 4645 | } |
| 4646 | |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 4647 | static int |
| 4648 | qla2x00_read_asic_temperature(scsi_qla_host_t *vha, uint16_t *temp) |
| 4649 | { |
| 4650 | int rval; |
| 4651 | mbx_cmd_t mc; |
| 4652 | mbx_cmd_t *mcp = &mc; |
| 4653 | |
| 4654 | if (!IS_FWI2_CAPABLE(vha->hw)) |
| 4655 | return QLA_FUNCTION_FAILED; |
| 4656 | |
| 4657 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1159, |
| 4658 | "Entered %s.\n", __func__); |
| 4659 | |
| 4660 | mcp->mb[0] = MBC_GET_RNID_PARAMS; |
| 4661 | mcp->mb[1] = RNID_TYPE_ASIC_TEMP << 8; |
| 4662 | mcp->out_mb = MBX_1|MBX_0; |
| 4663 | mcp->in_mb = MBX_1|MBX_0; |
| 4664 | mcp->tov = MBX_TOV_SECONDS; |
| 4665 | mcp->flags = 0; |
| 4666 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4667 | *temp = mcp->mb[1]; |
| 4668 | |
| 4669 | if (rval != QLA_SUCCESS) { |
| 4670 | ql_dbg(ql_dbg_mbx, vha, 0x115a, |
| 4671 | "Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]); |
| 4672 | } else { |
| 4673 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x115b, |
| 4674 | "Done %s.\n", __func__); |
| 4675 | } |
| 4676 | |
| 4677 | return rval; |
| 4678 | } |
| 4679 | |
Joe Carnuccio | 3a11711 | 2013-02-08 01:58:00 -0500 | [diff] [blame] | 4680 | int |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4681 | qla2x00_read_sfp(scsi_qla_host_t *vha, dma_addr_t sfp_dma, uint8_t *sfp, |
| 4682 | uint16_t dev, uint16_t off, uint16_t len, uint16_t opt) |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4683 | { |
| 4684 | int rval; |
| 4685 | mbx_cmd_t mc; |
| 4686 | mbx_cmd_t *mcp = &mc; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4687 | struct qla_hw_data *ha = vha->hw; |
| 4688 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4689 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e8, |
| 4690 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4691 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4692 | if (!IS_FWI2_CAPABLE(ha)) |
| 4693 | return QLA_FUNCTION_FAILED; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4694 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4695 | if (len == 1) |
| 4696 | opt |= BIT_0; |
| 4697 | |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4698 | mcp->mb[0] = MBC_READ_SFP; |
| 4699 | mcp->mb[1] = dev; |
| 4700 | mcp->mb[2] = MSW(sfp_dma); |
| 4701 | mcp->mb[3] = LSW(sfp_dma); |
| 4702 | mcp->mb[6] = MSW(MSD(sfp_dma)); |
| 4703 | mcp->mb[7] = LSW(MSD(sfp_dma)); |
| 4704 | mcp->mb[8] = len; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4705 | mcp->mb[9] = off; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4706 | mcp->mb[10] = opt; |
| 4707 | mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
Joe Carnuccio | 1bff6cc | 2011-05-10 11:30:11 -0700 | [diff] [blame] | 4708 | mcp->in_mb = MBX_1|MBX_0; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4709 | mcp->tov = MBX_TOV_SECONDS; |
| 4710 | mcp->flags = 0; |
| 4711 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4712 | |
| 4713 | if (opt & BIT_0) |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4714 | *sfp = mcp->mb[1]; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4715 | |
| 4716 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4717 | ql_dbg(ql_dbg_mbx, vha, 0x10e9, |
| 4718 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 4719 | if (mcp->mb[0] == MBS_COMMAND_ERROR && |
| 4720 | mcp->mb[1] == 0x22) |
| 4721 | /* sfp is not there */ |
| 4722 | rval = QLA_INTERFACE_ERROR; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4723 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4724 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ea, |
| 4725 | "Done %s.\n", __func__); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4726 | } |
| 4727 | |
| 4728 | return rval; |
| 4729 | } |
| 4730 | |
| 4731 | int |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4732 | qla2x00_write_sfp(scsi_qla_host_t *vha, dma_addr_t sfp_dma, uint8_t *sfp, |
| 4733 | uint16_t dev, uint16_t off, uint16_t len, uint16_t opt) |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4734 | { |
| 4735 | int rval; |
| 4736 | mbx_cmd_t mc; |
| 4737 | mbx_cmd_t *mcp = &mc; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4738 | struct qla_hw_data *ha = vha->hw; |
| 4739 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4740 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10eb, |
| 4741 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4742 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4743 | if (!IS_FWI2_CAPABLE(ha)) |
| 4744 | return QLA_FUNCTION_FAILED; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4745 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4746 | if (len == 1) |
| 4747 | opt |= BIT_0; |
| 4748 | |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4749 | if (opt & BIT_0) |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4750 | len = *sfp; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4751 | |
| 4752 | mcp->mb[0] = MBC_WRITE_SFP; |
| 4753 | mcp->mb[1] = dev; |
| 4754 | mcp->mb[2] = MSW(sfp_dma); |
| 4755 | mcp->mb[3] = LSW(sfp_dma); |
| 4756 | mcp->mb[6] = MSW(MSD(sfp_dma)); |
| 4757 | mcp->mb[7] = LSW(MSD(sfp_dma)); |
| 4758 | mcp->mb[8] = len; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4759 | mcp->mb[9] = off; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4760 | mcp->mb[10] = opt; |
| 4761 | mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4762 | mcp->in_mb = MBX_1|MBX_0; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4763 | mcp->tov = MBX_TOV_SECONDS; |
| 4764 | mcp->flags = 0; |
| 4765 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4766 | |
| 4767 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4768 | ql_dbg(ql_dbg_mbx, vha, 0x10ec, |
| 4769 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4770 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4771 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ed, |
| 4772 | "Done %s.\n", __func__); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4773 | } |
| 4774 | |
| 4775 | return rval; |
| 4776 | } |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4777 | |
| 4778 | int |
| 4779 | qla2x00_get_xgmac_stats(scsi_qla_host_t *vha, dma_addr_t stats_dma, |
| 4780 | uint16_t size_in_bytes, uint16_t *actual_size) |
| 4781 | { |
| 4782 | int rval; |
| 4783 | mbx_cmd_t mc; |
| 4784 | mbx_cmd_t *mcp = &mc; |
| 4785 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4786 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ee, |
| 4787 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4788 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4789 | if (!IS_CNA_CAPABLE(vha->hw)) |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4790 | return QLA_FUNCTION_FAILED; |
| 4791 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4792 | mcp->mb[0] = MBC_GET_XGMAC_STATS; |
| 4793 | mcp->mb[2] = MSW(stats_dma); |
| 4794 | mcp->mb[3] = LSW(stats_dma); |
| 4795 | mcp->mb[6] = MSW(MSD(stats_dma)); |
| 4796 | mcp->mb[7] = LSW(MSD(stats_dma)); |
| 4797 | mcp->mb[8] = size_in_bytes >> 2; |
| 4798 | mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; |
| 4799 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 4800 | mcp->tov = MBX_TOV_SECONDS; |
| 4801 | mcp->flags = 0; |
| 4802 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4803 | |
| 4804 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4805 | ql_dbg(ql_dbg_mbx, vha, 0x10ef, |
| 4806 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 4807 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4808 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4809 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f0, |
| 4810 | "Done %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4811 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4812 | |
| 4813 | *actual_size = mcp->mb[2] << 2; |
| 4814 | } |
| 4815 | |
| 4816 | return rval; |
| 4817 | } |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4818 | |
| 4819 | int |
| 4820 | qla2x00_get_dcbx_params(scsi_qla_host_t *vha, dma_addr_t tlv_dma, |
| 4821 | uint16_t size) |
| 4822 | { |
| 4823 | int rval; |
| 4824 | mbx_cmd_t mc; |
| 4825 | mbx_cmd_t *mcp = &mc; |
| 4826 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4827 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f1, |
| 4828 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4829 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4830 | if (!IS_CNA_CAPABLE(vha->hw)) |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4831 | return QLA_FUNCTION_FAILED; |
| 4832 | |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4833 | mcp->mb[0] = MBC_GET_DCBX_PARAMS; |
| 4834 | mcp->mb[1] = 0; |
| 4835 | mcp->mb[2] = MSW(tlv_dma); |
| 4836 | mcp->mb[3] = LSW(tlv_dma); |
| 4837 | mcp->mb[6] = MSW(MSD(tlv_dma)); |
| 4838 | mcp->mb[7] = LSW(MSD(tlv_dma)); |
| 4839 | mcp->mb[8] = size; |
| 4840 | mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4841 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 4842 | mcp->tov = MBX_TOV_SECONDS; |
| 4843 | mcp->flags = 0; |
| 4844 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4845 | |
| 4846 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4847 | ql_dbg(ql_dbg_mbx, vha, 0x10f2, |
| 4848 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 4849 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4850 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4851 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f3, |
| 4852 | "Done %s.\n", __func__); |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4853 | } |
| 4854 | |
| 4855 | return rval; |
| 4856 | } |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4857 | |
| 4858 | int |
| 4859 | qla2x00_read_ram_word(scsi_qla_host_t *vha, uint32_t risc_addr, uint32_t *data) |
| 4860 | { |
| 4861 | int rval; |
| 4862 | mbx_cmd_t mc; |
| 4863 | mbx_cmd_t *mcp = &mc; |
| 4864 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4865 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f4, |
| 4866 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4867 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4868 | if (!IS_FWI2_CAPABLE(vha->hw)) |
| 4869 | return QLA_FUNCTION_FAILED; |
| 4870 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4871 | mcp->mb[0] = MBC_READ_RAM_EXTENDED; |
| 4872 | mcp->mb[1] = LSW(risc_addr); |
| 4873 | mcp->mb[8] = MSW(risc_addr); |
| 4874 | mcp->out_mb = MBX_8|MBX_1|MBX_0; |
| 4875 | mcp->in_mb = MBX_3|MBX_2|MBX_0; |
| 4876 | mcp->tov = 30; |
| 4877 | mcp->flags = 0; |
| 4878 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4879 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4880 | ql_dbg(ql_dbg_mbx, vha, 0x10f5, |
| 4881 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4882 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4883 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f6, |
| 4884 | "Done %s.\n", __func__); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4885 | *data = mcp->mb[3] << 16 | mcp->mb[2]; |
| 4886 | } |
| 4887 | |
| 4888 | return rval; |
| 4889 | } |
| 4890 | |
| 4891 | int |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4892 | qla2x00_loopback_test(scsi_qla_host_t *vha, struct msg_echo_lb *mreq, |
| 4893 | uint16_t *mresp) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4894 | { |
| 4895 | int rval; |
| 4896 | mbx_cmd_t mc; |
| 4897 | mbx_cmd_t *mcp = &mc; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4898 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4899 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f7, |
| 4900 | "Entered %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4901 | |
| 4902 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 4903 | mcp->mb[0] = MBC_DIAGNOSTIC_LOOP_BACK; |
| 4904 | mcp->mb[1] = mreq->options | BIT_6; // BIT_6 specifies 64 bit addressing |
| 4905 | |
| 4906 | /* transfer count */ |
| 4907 | mcp->mb[10] = LSW(mreq->transfer_size); |
| 4908 | mcp->mb[11] = MSW(mreq->transfer_size); |
| 4909 | |
| 4910 | /* send data address */ |
| 4911 | mcp->mb[14] = LSW(mreq->send_dma); |
| 4912 | mcp->mb[15] = MSW(mreq->send_dma); |
| 4913 | mcp->mb[20] = LSW(MSD(mreq->send_dma)); |
| 4914 | mcp->mb[21] = MSW(MSD(mreq->send_dma)); |
| 4915 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 4916 | /* receive data address */ |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4917 | mcp->mb[16] = LSW(mreq->rcv_dma); |
| 4918 | mcp->mb[17] = MSW(mreq->rcv_dma); |
| 4919 | mcp->mb[6] = LSW(MSD(mreq->rcv_dma)); |
| 4920 | mcp->mb[7] = MSW(MSD(mreq->rcv_dma)); |
| 4921 | |
| 4922 | /* Iteration count */ |
Joe Carnuccio | 1b98b42 | 2013-03-28 08:21:26 -0400 | [diff] [blame] | 4923 | mcp->mb[18] = LSW(mreq->iteration_count); |
| 4924 | mcp->mb[19] = MSW(mreq->iteration_count); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4925 | |
| 4926 | mcp->out_mb = MBX_21|MBX_20|MBX_19|MBX_18|MBX_17|MBX_16|MBX_15| |
| 4927 | MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_7|MBX_6|MBX_1|MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4928 | if (IS_CNA_CAPABLE(vha->hw)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4929 | mcp->out_mb |= MBX_2; |
| 4930 | mcp->in_mb = MBX_19|MBX_18|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4931 | |
| 4932 | mcp->buf_size = mreq->transfer_size; |
| 4933 | mcp->tov = MBX_TOV_SECONDS; |
| 4934 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 4935 | |
| 4936 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4937 | |
| 4938 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4939 | ql_dbg(ql_dbg_mbx, vha, 0x10f8, |
| 4940 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[3]=%x mb[18]=%x " |
| 4941 | "mb[19]=%x.\n", rval, mcp->mb[0], mcp->mb[1], mcp->mb[2], |
| 4942 | mcp->mb[3], mcp->mb[18], mcp->mb[19]); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4943 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4944 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f9, |
| 4945 | "Done %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4946 | } |
| 4947 | |
| 4948 | /* Copy mailbox information */ |
| 4949 | memcpy( mresp, mcp->mb, 64); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4950 | return rval; |
| 4951 | } |
| 4952 | |
| 4953 | int |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4954 | qla2x00_echo_test(scsi_qla_host_t *vha, struct msg_echo_lb *mreq, |
| 4955 | uint16_t *mresp) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4956 | { |
| 4957 | int rval; |
| 4958 | mbx_cmd_t mc; |
| 4959 | mbx_cmd_t *mcp = &mc; |
| 4960 | struct qla_hw_data *ha = vha->hw; |
| 4961 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4962 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10fa, |
| 4963 | "Entered %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4964 | |
| 4965 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 4966 | mcp->mb[0] = MBC_DIAGNOSTIC_ECHO; |
Joe Carnuccio | 1d63496 | 2017-05-24 18:06:22 -0700 | [diff] [blame] | 4967 | /* BIT_6 specifies 64bit address */ |
| 4968 | mcp->mb[1] = mreq->options | BIT_15 | BIT_6; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4969 | if (IS_CNA_CAPABLE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4970 | mcp->mb[2] = vha->fcoe_fcf_idx; |
| 4971 | } |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4972 | mcp->mb[16] = LSW(mreq->rcv_dma); |
| 4973 | mcp->mb[17] = MSW(mreq->rcv_dma); |
| 4974 | mcp->mb[6] = LSW(MSD(mreq->rcv_dma)); |
| 4975 | mcp->mb[7] = MSW(MSD(mreq->rcv_dma)); |
| 4976 | |
| 4977 | mcp->mb[10] = LSW(mreq->transfer_size); |
| 4978 | |
| 4979 | mcp->mb[14] = LSW(mreq->send_dma); |
| 4980 | mcp->mb[15] = MSW(mreq->send_dma); |
| 4981 | mcp->mb[20] = LSW(MSD(mreq->send_dma)); |
| 4982 | mcp->mb[21] = MSW(MSD(mreq->send_dma)); |
| 4983 | |
| 4984 | mcp->out_mb = MBX_21|MBX_20|MBX_17|MBX_16|MBX_15| |
| 4985 | MBX_14|MBX_10|MBX_7|MBX_6|MBX_1|MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4986 | if (IS_CNA_CAPABLE(ha)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4987 | mcp->out_mb |= MBX_2; |
| 4988 | |
| 4989 | mcp->in_mb = MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4990 | if (IS_QLA24XX_TYPE(ha) || IS_QLA25XX(ha) || |
| 4991 | IS_CNA_CAPABLE(ha) || IS_QLA2031(ha)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4992 | mcp->in_mb |= MBX_1; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4993 | if (IS_CNA_CAPABLE(ha) || IS_QLA2031(ha)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4994 | mcp->in_mb |= MBX_3; |
| 4995 | |
| 4996 | mcp->tov = MBX_TOV_SECONDS; |
| 4997 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 4998 | mcp->buf_size = mreq->transfer_size; |
| 4999 | |
| 5000 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5001 | |
| 5002 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5003 | ql_dbg(ql_dbg_mbx, vha, 0x10fb, |
| 5004 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 5005 | rval, mcp->mb[0], mcp->mb[1]); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5006 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5007 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10fc, |
| 5008 | "Done %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5009 | } |
| 5010 | |
| 5011 | /* Copy mailbox information */ |
Giridhar Malavali | 6dbdda4 | 2010-09-03 15:20:49 -0700 | [diff] [blame] | 5012 | memcpy(mresp, mcp->mb, 64); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5013 | return rval; |
| 5014 | } |
Giridhar Malavali | 6dbdda4 | 2010-09-03 15:20:49 -0700 | [diff] [blame] | 5015 | |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5016 | int |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5017 | qla84xx_reset_chip(scsi_qla_host_t *vha, uint16_t enable_diagnostic) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5018 | { |
| 5019 | int rval; |
| 5020 | mbx_cmd_t mc; |
| 5021 | mbx_cmd_t *mcp = &mc; |
| 5022 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5023 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10fd, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5024 | "Entered %s enable_diag=%d.\n", __func__, enable_diagnostic); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5025 | |
| 5026 | mcp->mb[0] = MBC_ISP84XX_RESET; |
| 5027 | mcp->mb[1] = enable_diagnostic; |
| 5028 | mcp->out_mb = MBX_1|MBX_0; |
| 5029 | mcp->in_mb = MBX_1|MBX_0; |
| 5030 | mcp->tov = MBX_TOV_SECONDS; |
| 5031 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5032 | rval = qla2x00_mailbox_command(vha, mcp); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5033 | |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5034 | if (rval != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5035 | ql_dbg(ql_dbg_mbx, vha, 0x10fe, "Failed=%x.\n", rval); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5036 | else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5037 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ff, |
| 5038 | "Done %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5039 | |
| 5040 | return rval; |
| 5041 | } |
| 5042 | |
| 5043 | int |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5044 | qla2x00_write_ram_word(scsi_qla_host_t *vha, uint32_t risc_addr, uint32_t data) |
| 5045 | { |
| 5046 | int rval; |
| 5047 | mbx_cmd_t mc; |
| 5048 | mbx_cmd_t *mcp = &mc; |
| 5049 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5050 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1100, |
| 5051 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5052 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5053 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | 6c452a4 | 2010-03-19 17:04:02 -0700 | [diff] [blame] | 5054 | return QLA_FUNCTION_FAILED; |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5055 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5056 | mcp->mb[0] = MBC_WRITE_RAM_WORD_EXTENDED; |
| 5057 | mcp->mb[1] = LSW(risc_addr); |
| 5058 | mcp->mb[2] = LSW(data); |
| 5059 | mcp->mb[3] = MSW(data); |
| 5060 | mcp->mb[8] = MSW(risc_addr); |
| 5061 | mcp->out_mb = MBX_8|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5062 | mcp->in_mb = MBX_0; |
| 5063 | mcp->tov = 30; |
| 5064 | mcp->flags = 0; |
| 5065 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5066 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5067 | ql_dbg(ql_dbg_mbx, vha, 0x1101, |
| 5068 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5069 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5070 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1102, |
| 5071 | "Done %s.\n", __func__); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5072 | } |
| 5073 | |
| 5074 | return rval; |
| 5075 | } |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5076 | |
| 5077 | int |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 5078 | qla81xx_write_mpi_register(scsi_qla_host_t *vha, uint16_t *mb) |
| 5079 | { |
| 5080 | int rval; |
| 5081 | uint32_t stat, timer; |
| 5082 | uint16_t mb0 = 0; |
| 5083 | struct qla_hw_data *ha = vha->hw; |
| 5084 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 5085 | |
| 5086 | rval = QLA_SUCCESS; |
| 5087 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5088 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1103, |
| 5089 | "Entered %s.\n", __func__); |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 5090 | |
| 5091 | clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
| 5092 | |
| 5093 | /* Write the MBC data to the registers */ |
| 5094 | WRT_REG_WORD(®->mailbox0, MBC_WRITE_MPI_REGISTER); |
| 5095 | WRT_REG_WORD(®->mailbox1, mb[0]); |
| 5096 | WRT_REG_WORD(®->mailbox2, mb[1]); |
| 5097 | WRT_REG_WORD(®->mailbox3, mb[2]); |
| 5098 | WRT_REG_WORD(®->mailbox4, mb[3]); |
| 5099 | |
| 5100 | WRT_REG_DWORD(®->hccr, HCCRX_SET_HOST_INT); |
| 5101 | |
| 5102 | /* Poll for MBC interrupt */ |
| 5103 | for (timer = 6000000; timer; timer--) { |
| 5104 | /* Check for pending interrupts. */ |
| 5105 | stat = RD_REG_DWORD(®->host_status); |
| 5106 | if (stat & HSRX_RISC_INT) { |
| 5107 | stat &= 0xff; |
| 5108 | |
| 5109 | if (stat == 0x1 || stat == 0x2 || |
| 5110 | stat == 0x10 || stat == 0x11) { |
| 5111 | set_bit(MBX_INTERRUPT, |
| 5112 | &ha->mbx_cmd_flags); |
| 5113 | mb0 = RD_REG_WORD(®->mailbox0); |
| 5114 | WRT_REG_DWORD(®->hccr, |
| 5115 | HCCRX_CLR_RISC_INT); |
| 5116 | RD_REG_DWORD(®->hccr); |
| 5117 | break; |
| 5118 | } |
| 5119 | } |
| 5120 | udelay(5); |
| 5121 | } |
| 5122 | |
| 5123 | if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) |
| 5124 | rval = mb0 & MBS_MASK; |
| 5125 | else |
| 5126 | rval = QLA_FUNCTION_FAILED; |
| 5127 | |
| 5128 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5129 | ql_dbg(ql_dbg_mbx, vha, 0x1104, |
| 5130 | "Failed=%x mb[0]=%x.\n", rval, mb[0]); |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 5131 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5132 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1105, |
| 5133 | "Done %s.\n", __func__); |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 5134 | } |
| 5135 | |
| 5136 | return rval; |
| 5137 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5138 | |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 5139 | int |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5140 | qla2x00_get_data_rate(scsi_qla_host_t *vha) |
| 5141 | { |
| 5142 | int rval; |
| 5143 | mbx_cmd_t mc; |
| 5144 | mbx_cmd_t *mcp = &mc; |
| 5145 | struct qla_hw_data *ha = vha->hw; |
| 5146 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5147 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1106, |
| 5148 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5149 | |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5150 | if (!IS_FWI2_CAPABLE(ha)) |
| 5151 | return QLA_FUNCTION_FAILED; |
| 5152 | |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5153 | mcp->mb[0] = MBC_DATA_RATE; |
| 5154 | mcp->mb[1] = 0; |
| 5155 | mcp->out_mb = MBX_1|MBX_0; |
| 5156 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5157 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5158 | mcp->in_mb |= MBX_3; |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5159 | mcp->tov = MBX_TOV_SECONDS; |
| 5160 | mcp->flags = 0; |
| 5161 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5162 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5163 | ql_dbg(ql_dbg_mbx, vha, 0x1107, |
| 5164 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5165 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5166 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1108, |
| 5167 | "Done %s.\n", __func__); |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5168 | if (mcp->mb[1] != 0x7) |
| 5169 | ha->link_data_rate = mcp->mb[1]; |
| 5170 | } |
| 5171 | |
| 5172 | return rval; |
| 5173 | } |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5174 | |
| 5175 | int |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5176 | qla81xx_get_port_config(scsi_qla_host_t *vha, uint16_t *mb) |
| 5177 | { |
| 5178 | int rval; |
| 5179 | mbx_cmd_t mc; |
| 5180 | mbx_cmd_t *mcp = &mc; |
| 5181 | struct qla_hw_data *ha = vha->hw; |
| 5182 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5183 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1109, |
| 5184 | "Entered %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5185 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5186 | if (!IS_QLA81XX(ha) && !IS_QLA83XX(ha) && !IS_QLA8044(ha) && |
| 5187 | !IS_QLA27XX(ha)) |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5188 | return QLA_FUNCTION_FAILED; |
| 5189 | mcp->mb[0] = MBC_GET_PORT_CONFIG; |
| 5190 | mcp->out_mb = MBX_0; |
| 5191 | mcp->in_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5192 | mcp->tov = MBX_TOV_SECONDS; |
| 5193 | mcp->flags = 0; |
| 5194 | |
| 5195 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5196 | |
| 5197 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5198 | ql_dbg(ql_dbg_mbx, vha, 0x110a, |
| 5199 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5200 | } else { |
| 5201 | /* Copy all bits to preserve original value */ |
| 5202 | memcpy(mb, &mcp->mb[1], sizeof(uint16_t) * 4); |
| 5203 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5204 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110b, |
| 5205 | "Done %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5206 | } |
| 5207 | return rval; |
| 5208 | } |
| 5209 | |
| 5210 | int |
| 5211 | qla81xx_set_port_config(scsi_qla_host_t *vha, uint16_t *mb) |
| 5212 | { |
| 5213 | int rval; |
| 5214 | mbx_cmd_t mc; |
| 5215 | mbx_cmd_t *mcp = &mc; |
| 5216 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5217 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110c, |
| 5218 | "Entered %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5219 | |
| 5220 | mcp->mb[0] = MBC_SET_PORT_CONFIG; |
| 5221 | /* Copy all bits to preserve original setting */ |
| 5222 | memcpy(&mcp->mb[1], mb, sizeof(uint16_t) * 4); |
| 5223 | mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5224 | mcp->in_mb = MBX_0; |
| 5225 | mcp->tov = MBX_TOV_SECONDS; |
| 5226 | mcp->flags = 0; |
| 5227 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5228 | |
| 5229 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5230 | ql_dbg(ql_dbg_mbx, vha, 0x110d, |
| 5231 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5232 | } else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5233 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110e, |
| 5234 | "Done %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5235 | |
| 5236 | return rval; |
| 5237 | } |
| 5238 | |
| 5239 | |
| 5240 | int |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5241 | qla24xx_set_fcp_prio(scsi_qla_host_t *vha, uint16_t loop_id, uint16_t priority, |
| 5242 | uint16_t *mb) |
| 5243 | { |
| 5244 | int rval; |
| 5245 | mbx_cmd_t mc; |
| 5246 | mbx_cmd_t *mcp = &mc; |
| 5247 | struct qla_hw_data *ha = vha->hw; |
| 5248 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5249 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110f, |
| 5250 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5251 | |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5252 | if (!IS_QLA24XX_TYPE(ha) && !IS_QLA25XX(ha)) |
| 5253 | return QLA_FUNCTION_FAILED; |
| 5254 | |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5255 | mcp->mb[0] = MBC_PORT_PARAMS; |
| 5256 | mcp->mb[1] = loop_id; |
| 5257 | if (ha->flags.fcp_prio_enabled) |
| 5258 | mcp->mb[2] = BIT_1; |
| 5259 | else |
| 5260 | mcp->mb[2] = BIT_2; |
| 5261 | mcp->mb[4] = priority & 0xf; |
| 5262 | mcp->mb[9] = vha->vp_idx; |
| 5263 | mcp->out_mb = MBX_9|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5264 | mcp->in_mb = MBX_4|MBX_3|MBX_1|MBX_0; |
| 5265 | mcp->tov = 30; |
| 5266 | mcp->flags = 0; |
| 5267 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5268 | if (mb != NULL) { |
| 5269 | mb[0] = mcp->mb[0]; |
| 5270 | mb[1] = mcp->mb[1]; |
| 5271 | mb[3] = mcp->mb[3]; |
| 5272 | mb[4] = mcp->mb[4]; |
| 5273 | } |
| 5274 | |
| 5275 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5276 | ql_dbg(ql_dbg_mbx, vha, 0x10cd, "Failed=%x.\n", rval); |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5277 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5278 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10cc, |
| 5279 | "Done %s.\n", __func__); |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5280 | } |
| 5281 | |
| 5282 | return rval; |
| 5283 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5284 | |
| 5285 | int |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 5286 | qla2x00_get_thermal_temp(scsi_qla_host_t *vha, uint16_t *temp) |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5287 | { |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 5288 | int rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5289 | struct qla_hw_data *ha = vha->hw; |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 5290 | uint8_t byte; |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5291 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 5292 | if (!IS_FWI2_CAPABLE(ha) || IS_QLA24XX_TYPE(ha) || IS_QLA81XX(ha)) { |
| 5293 | ql_dbg(ql_dbg_mbx, vha, 0x1150, |
| 5294 | "Thermal not supported by this card.\n"); |
| 5295 | return rval; |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5296 | } |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5297 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 5298 | if (IS_QLA25XX(ha)) { |
| 5299 | if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC && |
| 5300 | ha->pdev->subsystem_device == 0x0175) { |
| 5301 | rval = qla2x00_read_sfp(vha, 0, &byte, |
| 5302 | 0x98, 0x1, 1, BIT_13|BIT_0); |
| 5303 | *temp = byte; |
| 5304 | return rval; |
| 5305 | } |
| 5306 | if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_HP && |
| 5307 | ha->pdev->subsystem_device == 0x338e) { |
| 5308 | rval = qla2x00_read_sfp(vha, 0, &byte, |
| 5309 | 0x98, 0x1, 1, BIT_15|BIT_14|BIT_0); |
| 5310 | *temp = byte; |
| 5311 | return rval; |
| 5312 | } |
| 5313 | ql_dbg(ql_dbg_mbx, vha, 0x10c9, |
| 5314 | "Thermal not supported by this card.\n"); |
| 5315 | return rval; |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 5316 | } |
| 5317 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 5318 | if (IS_QLA82XX(ha)) { |
| 5319 | *temp = qla82xx_read_temperature(vha); |
| 5320 | rval = QLA_SUCCESS; |
| 5321 | return rval; |
| 5322 | } else if (IS_QLA8044(ha)) { |
| 5323 | *temp = qla8044_read_temperature(vha); |
| 5324 | rval = QLA_SUCCESS; |
| 5325 | return rval; |
| 5326 | } |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 5327 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 5328 | rval = qla2x00_read_asic_temperature(vha, temp); |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5329 | return rval; |
| 5330 | } |
| 5331 | |
| 5332 | int |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5333 | qla82xx_mbx_intr_enable(scsi_qla_host_t *vha) |
| 5334 | { |
| 5335 | int rval; |
| 5336 | struct qla_hw_data *ha = vha->hw; |
| 5337 | mbx_cmd_t mc; |
| 5338 | mbx_cmd_t *mcp = &mc; |
| 5339 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5340 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1017, |
| 5341 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5342 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5343 | if (!IS_FWI2_CAPABLE(ha)) |
| 5344 | return QLA_FUNCTION_FAILED; |
| 5345 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5346 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
Giridhar Malavali | 3711333 | 2010-07-23 15:28:34 +0500 | [diff] [blame] | 5347 | mcp->mb[0] = MBC_TOGGLE_INTERRUPT; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5348 | mcp->mb[1] = 1; |
| 5349 | |
| 5350 | mcp->out_mb = MBX_1|MBX_0; |
| 5351 | mcp->in_mb = MBX_0; |
| 5352 | mcp->tov = 30; |
| 5353 | mcp->flags = 0; |
| 5354 | |
| 5355 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5356 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5357 | ql_dbg(ql_dbg_mbx, vha, 0x1016, |
| 5358 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5359 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5360 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x100e, |
| 5361 | "Done %s.\n", __func__); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5362 | } |
| 5363 | |
| 5364 | return rval; |
| 5365 | } |
| 5366 | |
| 5367 | int |
| 5368 | qla82xx_mbx_intr_disable(scsi_qla_host_t *vha) |
| 5369 | { |
| 5370 | int rval; |
| 5371 | struct qla_hw_data *ha = vha->hw; |
| 5372 | mbx_cmd_t mc; |
| 5373 | mbx_cmd_t *mcp = &mc; |
| 5374 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5375 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x100d, |
| 5376 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5377 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5378 | if (!IS_P3P_TYPE(ha)) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5379 | return QLA_FUNCTION_FAILED; |
| 5380 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5381 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
Giridhar Malavali | 3711333 | 2010-07-23 15:28:34 +0500 | [diff] [blame] | 5382 | mcp->mb[0] = MBC_TOGGLE_INTERRUPT; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5383 | mcp->mb[1] = 0; |
| 5384 | |
| 5385 | mcp->out_mb = MBX_1|MBX_0; |
| 5386 | mcp->in_mb = MBX_0; |
| 5387 | mcp->tov = 30; |
| 5388 | mcp->flags = 0; |
| 5389 | |
| 5390 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5391 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5392 | ql_dbg(ql_dbg_mbx, vha, 0x100c, |
| 5393 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5394 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5395 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x100b, |
| 5396 | "Done %s.\n", __func__); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5397 | } |
| 5398 | |
| 5399 | return rval; |
| 5400 | } |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5401 | |
| 5402 | int |
| 5403 | qla82xx_md_get_template_size(scsi_qla_host_t *vha) |
| 5404 | { |
| 5405 | struct qla_hw_data *ha = vha->hw; |
| 5406 | mbx_cmd_t mc; |
| 5407 | mbx_cmd_t *mcp = &mc; |
| 5408 | int rval = QLA_FUNCTION_FAILED; |
| 5409 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5410 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x111f, |
| 5411 | "Entered %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5412 | |
| 5413 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 5414 | mcp->mb[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5415 | mcp->mb[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5416 | mcp->mb[2] = LSW(RQST_TMPLT_SIZE); |
| 5417 | mcp->mb[3] = MSW(RQST_TMPLT_SIZE); |
| 5418 | |
| 5419 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 5420 | mcp->in_mb = MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8| |
| 5421 | MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5422 | |
| 5423 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 5424 | mcp->tov = MBX_TOV_SECONDS; |
| 5425 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5426 | |
| 5427 | /* Always copy back return mailbox values. */ |
| 5428 | if (rval != QLA_SUCCESS) { |
| 5429 | ql_dbg(ql_dbg_mbx, vha, 0x1120, |
| 5430 | "mailbox command FAILED=0x%x, subcode=%x.\n", |
| 5431 | (mcp->mb[1] << 16) | mcp->mb[0], |
| 5432 | (mcp->mb[3] << 16) | mcp->mb[2]); |
| 5433 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5434 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1121, |
| 5435 | "Done %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5436 | ha->md_template_size = ((mcp->mb[3] << 16) | mcp->mb[2]); |
| 5437 | if (!ha->md_template_size) { |
| 5438 | ql_dbg(ql_dbg_mbx, vha, 0x1122, |
| 5439 | "Null template size obtained.\n"); |
| 5440 | rval = QLA_FUNCTION_FAILED; |
| 5441 | } |
| 5442 | } |
| 5443 | return rval; |
| 5444 | } |
| 5445 | |
| 5446 | int |
| 5447 | qla82xx_md_get_template(scsi_qla_host_t *vha) |
| 5448 | { |
| 5449 | struct qla_hw_data *ha = vha->hw; |
| 5450 | mbx_cmd_t mc; |
| 5451 | mbx_cmd_t *mcp = &mc; |
| 5452 | int rval = QLA_FUNCTION_FAILED; |
| 5453 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5454 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1123, |
| 5455 | "Entered %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5456 | |
| 5457 | ha->md_tmplt_hdr = dma_alloc_coherent(&ha->pdev->dev, |
| 5458 | ha->md_template_size, &ha->md_tmplt_hdr_dma, GFP_KERNEL); |
| 5459 | if (!ha->md_tmplt_hdr) { |
| 5460 | ql_log(ql_log_warn, vha, 0x1124, |
| 5461 | "Unable to allocate memory for Minidump template.\n"); |
| 5462 | return rval; |
| 5463 | } |
| 5464 | |
| 5465 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 5466 | mcp->mb[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5467 | mcp->mb[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5468 | mcp->mb[2] = LSW(RQST_TMPLT); |
| 5469 | mcp->mb[3] = MSW(RQST_TMPLT); |
| 5470 | mcp->mb[4] = LSW(LSD(ha->md_tmplt_hdr_dma)); |
| 5471 | mcp->mb[5] = MSW(LSD(ha->md_tmplt_hdr_dma)); |
| 5472 | mcp->mb[6] = LSW(MSD(ha->md_tmplt_hdr_dma)); |
| 5473 | mcp->mb[7] = MSW(MSD(ha->md_tmplt_hdr_dma)); |
| 5474 | mcp->mb[8] = LSW(ha->md_template_size); |
| 5475 | mcp->mb[9] = MSW(ha->md_template_size); |
| 5476 | |
| 5477 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 5478 | mcp->tov = MBX_TOV_SECONDS; |
| 5479 | mcp->out_mb = MBX_11|MBX_10|MBX_9|MBX_8| |
| 5480 | MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5481 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 5482 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5483 | |
| 5484 | if (rval != QLA_SUCCESS) { |
| 5485 | ql_dbg(ql_dbg_mbx, vha, 0x1125, |
| 5486 | "mailbox command FAILED=0x%x, subcode=%x.\n", |
| 5487 | ((mcp->mb[1] << 16) | mcp->mb[0]), |
| 5488 | ((mcp->mb[3] << 16) | mcp->mb[2])); |
| 5489 | } else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5490 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1126, |
| 5491 | "Done %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5492 | return rval; |
| 5493 | } |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5494 | |
| 5495 | int |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5496 | qla8044_md_get_template(scsi_qla_host_t *vha) |
| 5497 | { |
| 5498 | struct qla_hw_data *ha = vha->hw; |
| 5499 | mbx_cmd_t mc; |
| 5500 | mbx_cmd_t *mcp = &mc; |
| 5501 | int rval = QLA_FUNCTION_FAILED; |
| 5502 | int offset = 0, size = MINIDUMP_SIZE_36K; |
| 5503 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0xb11f, |
| 5504 | "Entered %s.\n", __func__); |
| 5505 | |
| 5506 | ha->md_tmplt_hdr = dma_alloc_coherent(&ha->pdev->dev, |
| 5507 | ha->md_template_size, &ha->md_tmplt_hdr_dma, GFP_KERNEL); |
| 5508 | if (!ha->md_tmplt_hdr) { |
| 5509 | ql_log(ql_log_warn, vha, 0xb11b, |
| 5510 | "Unable to allocate memory for Minidump template.\n"); |
| 5511 | return rval; |
| 5512 | } |
| 5513 | |
| 5514 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 5515 | while (offset < ha->md_template_size) { |
| 5516 | mcp->mb[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5517 | mcp->mb[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5518 | mcp->mb[2] = LSW(RQST_TMPLT); |
| 5519 | mcp->mb[3] = MSW(RQST_TMPLT); |
| 5520 | mcp->mb[4] = LSW(LSD(ha->md_tmplt_hdr_dma + offset)); |
| 5521 | mcp->mb[5] = MSW(LSD(ha->md_tmplt_hdr_dma + offset)); |
| 5522 | mcp->mb[6] = LSW(MSD(ha->md_tmplt_hdr_dma + offset)); |
| 5523 | mcp->mb[7] = MSW(MSD(ha->md_tmplt_hdr_dma + offset)); |
| 5524 | mcp->mb[8] = LSW(size); |
| 5525 | mcp->mb[9] = MSW(size); |
| 5526 | mcp->mb[10] = offset & 0x0000FFFF; |
| 5527 | mcp->mb[11] = offset & 0xFFFF0000; |
| 5528 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 5529 | mcp->tov = MBX_TOV_SECONDS; |
| 5530 | mcp->out_mb = MBX_11|MBX_10|MBX_9|MBX_8| |
| 5531 | MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5532 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 5533 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5534 | |
| 5535 | if (rval != QLA_SUCCESS) { |
| 5536 | ql_dbg(ql_dbg_mbx, vha, 0xb11c, |
| 5537 | "mailbox command FAILED=0x%x, subcode=%x.\n", |
| 5538 | ((mcp->mb[1] << 16) | mcp->mb[0]), |
| 5539 | ((mcp->mb[3] << 16) | mcp->mb[2])); |
| 5540 | return rval; |
| 5541 | } else |
| 5542 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0xb11d, |
| 5543 | "Done %s.\n", __func__); |
| 5544 | offset = offset + size; |
| 5545 | } |
| 5546 | return rval; |
| 5547 | } |
| 5548 | |
| 5549 | int |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5550 | qla81xx_set_led_config(scsi_qla_host_t *vha, uint16_t *led_cfg) |
| 5551 | { |
| 5552 | int rval; |
| 5553 | struct qla_hw_data *ha = vha->hw; |
| 5554 | mbx_cmd_t mc; |
| 5555 | mbx_cmd_t *mcp = &mc; |
| 5556 | |
| 5557 | if (!IS_QLA81XX(ha) && !IS_QLA8031(ha)) |
| 5558 | return QLA_FUNCTION_FAILED; |
| 5559 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5560 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1133, |
| 5561 | "Entered %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5562 | |
| 5563 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
| 5564 | mcp->mb[0] = MBC_SET_LED_CONFIG; |
| 5565 | mcp->mb[1] = led_cfg[0]; |
| 5566 | mcp->mb[2] = led_cfg[1]; |
| 5567 | if (IS_QLA8031(ha)) { |
| 5568 | mcp->mb[3] = led_cfg[2]; |
| 5569 | mcp->mb[4] = led_cfg[3]; |
| 5570 | mcp->mb[5] = led_cfg[4]; |
| 5571 | mcp->mb[6] = led_cfg[5]; |
| 5572 | } |
| 5573 | |
| 5574 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 5575 | if (IS_QLA8031(ha)) |
| 5576 | mcp->out_mb |= MBX_6|MBX_5|MBX_4|MBX_3; |
| 5577 | mcp->in_mb = MBX_0; |
| 5578 | mcp->tov = 30; |
| 5579 | mcp->flags = 0; |
| 5580 | |
| 5581 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5582 | if (rval != QLA_SUCCESS) { |
| 5583 | ql_dbg(ql_dbg_mbx, vha, 0x1134, |
| 5584 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5585 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5586 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1135, |
| 5587 | "Done %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5588 | } |
| 5589 | |
| 5590 | return rval; |
| 5591 | } |
| 5592 | |
| 5593 | int |
| 5594 | qla81xx_get_led_config(scsi_qla_host_t *vha, uint16_t *led_cfg) |
| 5595 | { |
| 5596 | int rval; |
| 5597 | struct qla_hw_data *ha = vha->hw; |
| 5598 | mbx_cmd_t mc; |
| 5599 | mbx_cmd_t *mcp = &mc; |
| 5600 | |
| 5601 | if (!IS_QLA81XX(ha) && !IS_QLA8031(ha)) |
| 5602 | return QLA_FUNCTION_FAILED; |
| 5603 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5604 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1136, |
| 5605 | "Entered %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5606 | |
| 5607 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
| 5608 | mcp->mb[0] = MBC_GET_LED_CONFIG; |
| 5609 | |
| 5610 | mcp->out_mb = MBX_0; |
| 5611 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 5612 | if (IS_QLA8031(ha)) |
| 5613 | mcp->in_mb |= MBX_6|MBX_5|MBX_4|MBX_3; |
| 5614 | mcp->tov = 30; |
| 5615 | mcp->flags = 0; |
| 5616 | |
| 5617 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5618 | if (rval != QLA_SUCCESS) { |
| 5619 | ql_dbg(ql_dbg_mbx, vha, 0x1137, |
| 5620 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5621 | } else { |
| 5622 | led_cfg[0] = mcp->mb[1]; |
| 5623 | led_cfg[1] = mcp->mb[2]; |
| 5624 | if (IS_QLA8031(ha)) { |
| 5625 | led_cfg[2] = mcp->mb[3]; |
| 5626 | led_cfg[3] = mcp->mb[4]; |
| 5627 | led_cfg[4] = mcp->mb[5]; |
| 5628 | led_cfg[5] = mcp->mb[6]; |
| 5629 | } |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5630 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1138, |
| 5631 | "Done %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5632 | } |
| 5633 | |
| 5634 | return rval; |
| 5635 | } |
| 5636 | |
| 5637 | int |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5638 | qla82xx_mbx_beacon_ctl(scsi_qla_host_t *vha, int enable) |
| 5639 | { |
| 5640 | int rval; |
| 5641 | struct qla_hw_data *ha = vha->hw; |
| 5642 | mbx_cmd_t mc; |
| 5643 | mbx_cmd_t *mcp = &mc; |
| 5644 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5645 | if (!IS_P3P_TYPE(ha)) |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5646 | return QLA_FUNCTION_FAILED; |
| 5647 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5648 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1127, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5649 | "Entered %s.\n", __func__); |
| 5650 | |
| 5651 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
| 5652 | mcp->mb[0] = MBC_SET_LED_CONFIG; |
| 5653 | if (enable) |
| 5654 | mcp->mb[7] = 0xE; |
| 5655 | else |
| 5656 | mcp->mb[7] = 0xD; |
| 5657 | |
| 5658 | mcp->out_mb = MBX_7|MBX_0; |
| 5659 | mcp->in_mb = MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5660 | mcp->tov = MBX_TOV_SECONDS; |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5661 | mcp->flags = 0; |
| 5662 | |
| 5663 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5664 | if (rval != QLA_SUCCESS) { |
| 5665 | ql_dbg(ql_dbg_mbx, vha, 0x1128, |
| 5666 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5667 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5668 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1129, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5669 | "Done %s.\n", __func__); |
| 5670 | } |
| 5671 | |
| 5672 | return rval; |
| 5673 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5674 | |
| 5675 | int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5676 | qla83xx_wr_reg(scsi_qla_host_t *vha, uint32_t reg, uint32_t data) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5677 | { |
| 5678 | int rval; |
| 5679 | struct qla_hw_data *ha = vha->hw; |
| 5680 | mbx_cmd_t mc; |
| 5681 | mbx_cmd_t *mcp = &mc; |
| 5682 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5683 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5684 | return QLA_FUNCTION_FAILED; |
| 5685 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5686 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1130, |
| 5687 | "Entered %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5688 | |
| 5689 | mcp->mb[0] = MBC_WRITE_REMOTE_REG; |
| 5690 | mcp->mb[1] = LSW(reg); |
| 5691 | mcp->mb[2] = MSW(reg); |
| 5692 | mcp->mb[3] = LSW(data); |
| 5693 | mcp->mb[4] = MSW(data); |
| 5694 | mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5695 | |
| 5696 | mcp->in_mb = MBX_1|MBX_0; |
| 5697 | mcp->tov = MBX_TOV_SECONDS; |
| 5698 | mcp->flags = 0; |
| 5699 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5700 | |
| 5701 | if (rval != QLA_SUCCESS) { |
| 5702 | ql_dbg(ql_dbg_mbx, vha, 0x1131, |
| 5703 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5704 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5705 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1132, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5706 | "Done %s.\n", __func__); |
| 5707 | } |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5708 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5709 | return rval; |
| 5710 | } |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5711 | |
| 5712 | int |
| 5713 | qla2x00_port_logout(scsi_qla_host_t *vha, struct fc_port *fcport) |
| 5714 | { |
| 5715 | int rval; |
| 5716 | struct qla_hw_data *ha = vha->hw; |
| 5717 | mbx_cmd_t mc; |
| 5718 | mbx_cmd_t *mcp = &mc; |
| 5719 | |
| 5720 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5721 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x113b, |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5722 | "Implicit LOGO Unsupported.\n"); |
| 5723 | return QLA_FUNCTION_FAILED; |
| 5724 | } |
| 5725 | |
| 5726 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5727 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x113c, |
| 5728 | "Entering %s.\n", __func__); |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5729 | |
| 5730 | /* Perform Implicit LOGO. */ |
| 5731 | mcp->mb[0] = MBC_PORT_LOGOUT; |
| 5732 | mcp->mb[1] = fcport->loop_id; |
| 5733 | mcp->mb[10] = BIT_15; |
| 5734 | mcp->out_mb = MBX_10|MBX_1|MBX_0; |
| 5735 | mcp->in_mb = MBX_0; |
| 5736 | mcp->tov = MBX_TOV_SECONDS; |
| 5737 | mcp->flags = 0; |
| 5738 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5739 | if (rval != QLA_SUCCESS) |
| 5740 | ql_dbg(ql_dbg_mbx, vha, 0x113d, |
| 5741 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5742 | else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5743 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x113e, |
| 5744 | "Done %s.\n", __func__); |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5745 | |
| 5746 | return rval; |
| 5747 | } |
| 5748 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5749 | int |
| 5750 | qla83xx_rd_reg(scsi_qla_host_t *vha, uint32_t reg, uint32_t *data) |
| 5751 | { |
| 5752 | int rval; |
| 5753 | mbx_cmd_t mc; |
| 5754 | mbx_cmd_t *mcp = &mc; |
| 5755 | struct qla_hw_data *ha = vha->hw; |
| 5756 | unsigned long retry_max_time = jiffies + (2 * HZ); |
| 5757 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5758 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5759 | return QLA_FUNCTION_FAILED; |
| 5760 | |
| 5761 | ql_dbg(ql_dbg_mbx, vha, 0x114b, "Entered %s.\n", __func__); |
| 5762 | |
| 5763 | retry_rd_reg: |
| 5764 | mcp->mb[0] = MBC_READ_REMOTE_REG; |
| 5765 | mcp->mb[1] = LSW(reg); |
| 5766 | mcp->mb[2] = MSW(reg); |
| 5767 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 5768 | mcp->in_mb = MBX_4|MBX_3|MBX_1|MBX_0; |
| 5769 | mcp->tov = MBX_TOV_SECONDS; |
| 5770 | mcp->flags = 0; |
| 5771 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5772 | |
| 5773 | if (rval != QLA_SUCCESS) { |
| 5774 | ql_dbg(ql_dbg_mbx, vha, 0x114c, |
| 5775 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 5776 | rval, mcp->mb[0], mcp->mb[1]); |
| 5777 | } else { |
| 5778 | *data = (mcp->mb[3] | (mcp->mb[4] << 16)); |
| 5779 | if (*data == QLA8XXX_BAD_VALUE) { |
| 5780 | /* |
| 5781 | * During soft-reset CAMRAM register reads might |
| 5782 | * return 0xbad0bad0. So retry for MAX of 2 sec |
| 5783 | * while reading camram registers. |
| 5784 | */ |
| 5785 | if (time_after(jiffies, retry_max_time)) { |
| 5786 | ql_dbg(ql_dbg_mbx, vha, 0x1141, |
| 5787 | "Failure to read CAMRAM register. " |
| 5788 | "data=0x%x.\n", *data); |
| 5789 | return QLA_FUNCTION_FAILED; |
| 5790 | } |
| 5791 | msleep(100); |
| 5792 | goto retry_rd_reg; |
| 5793 | } |
| 5794 | ql_dbg(ql_dbg_mbx, vha, 0x1142, "Done %s.\n", __func__); |
| 5795 | } |
| 5796 | |
| 5797 | return rval; |
| 5798 | } |
| 5799 | |
| 5800 | int |
| 5801 | qla83xx_restart_nic_firmware(scsi_qla_host_t *vha) |
| 5802 | { |
| 5803 | int rval; |
| 5804 | mbx_cmd_t mc; |
| 5805 | mbx_cmd_t *mcp = &mc; |
| 5806 | struct qla_hw_data *ha = vha->hw; |
| 5807 | |
Himanshu Madhani | b20f02e | 2015-06-10 11:05:18 -0400 | [diff] [blame] | 5808 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5809 | return QLA_FUNCTION_FAILED; |
| 5810 | |
| 5811 | ql_dbg(ql_dbg_mbx, vha, 0x1143, "Entered %s.\n", __func__); |
| 5812 | |
| 5813 | mcp->mb[0] = MBC_RESTART_NIC_FIRMWARE; |
| 5814 | mcp->out_mb = MBX_0; |
| 5815 | mcp->in_mb = MBX_1|MBX_0; |
| 5816 | mcp->tov = MBX_TOV_SECONDS; |
| 5817 | mcp->flags = 0; |
| 5818 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5819 | |
| 5820 | if (rval != QLA_SUCCESS) { |
| 5821 | ql_dbg(ql_dbg_mbx, vha, 0x1144, |
| 5822 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 5823 | rval, mcp->mb[0], mcp->mb[1]); |
| 5824 | ha->isp_ops->fw_dump(vha, 0); |
| 5825 | } else { |
| 5826 | ql_dbg(ql_dbg_mbx, vha, 0x1145, "Done %s.\n", __func__); |
| 5827 | } |
| 5828 | |
| 5829 | return rval; |
| 5830 | } |
| 5831 | |
| 5832 | int |
| 5833 | qla83xx_access_control(scsi_qla_host_t *vha, uint16_t options, |
| 5834 | uint32_t start_addr, uint32_t end_addr, uint16_t *sector_size) |
| 5835 | { |
| 5836 | int rval; |
| 5837 | mbx_cmd_t mc; |
| 5838 | mbx_cmd_t *mcp = &mc; |
| 5839 | uint8_t subcode = (uint8_t)options; |
| 5840 | struct qla_hw_data *ha = vha->hw; |
| 5841 | |
| 5842 | if (!IS_QLA8031(ha)) |
| 5843 | return QLA_FUNCTION_FAILED; |
| 5844 | |
| 5845 | ql_dbg(ql_dbg_mbx, vha, 0x1146, "Entered %s.\n", __func__); |
| 5846 | |
| 5847 | mcp->mb[0] = MBC_SET_ACCESS_CONTROL; |
| 5848 | mcp->mb[1] = options; |
| 5849 | mcp->out_mb = MBX_1|MBX_0; |
| 5850 | if (subcode & BIT_2) { |
| 5851 | mcp->mb[2] = LSW(start_addr); |
| 5852 | mcp->mb[3] = MSW(start_addr); |
| 5853 | mcp->mb[4] = LSW(end_addr); |
| 5854 | mcp->mb[5] = MSW(end_addr); |
| 5855 | mcp->out_mb |= MBX_5|MBX_4|MBX_3|MBX_2; |
| 5856 | } |
| 5857 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 5858 | if (!(subcode & (BIT_2 | BIT_5))) |
| 5859 | mcp->in_mb |= MBX_4|MBX_3; |
| 5860 | mcp->tov = MBX_TOV_SECONDS; |
| 5861 | mcp->flags = 0; |
| 5862 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5863 | |
| 5864 | if (rval != QLA_SUCCESS) { |
| 5865 | ql_dbg(ql_dbg_mbx, vha, 0x1147, |
| 5866 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[3]=%x mb[4]=%x.\n", |
| 5867 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2], mcp->mb[3], |
| 5868 | mcp->mb[4]); |
| 5869 | ha->isp_ops->fw_dump(vha, 0); |
| 5870 | } else { |
| 5871 | if (subcode & BIT_5) |
| 5872 | *sector_size = mcp->mb[1]; |
| 5873 | else if (subcode & (BIT_6 | BIT_7)) { |
| 5874 | ql_dbg(ql_dbg_mbx, vha, 0x1148, |
| 5875 | "Driver-lock id=%x%x", mcp->mb[4], mcp->mb[3]); |
| 5876 | } else if (subcode & (BIT_3 | BIT_4)) { |
| 5877 | ql_dbg(ql_dbg_mbx, vha, 0x1149, |
| 5878 | "Flash-lock id=%x%x", mcp->mb[4], mcp->mb[3]); |
| 5879 | } |
| 5880 | ql_dbg(ql_dbg_mbx, vha, 0x114a, "Done %s.\n", __func__); |
| 5881 | } |
| 5882 | |
| 5883 | return rval; |
| 5884 | } |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 5885 | |
| 5886 | int |
| 5887 | qla2x00_dump_mctp_data(scsi_qla_host_t *vha, dma_addr_t req_dma, uint32_t addr, |
| 5888 | uint32_t size) |
| 5889 | { |
| 5890 | int rval; |
| 5891 | mbx_cmd_t mc; |
| 5892 | mbx_cmd_t *mcp = &mc; |
| 5893 | |
| 5894 | if (!IS_MCTP_CAPABLE(vha->hw)) |
| 5895 | return QLA_FUNCTION_FAILED; |
| 5896 | |
| 5897 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x114f, |
| 5898 | "Entered %s.\n", __func__); |
| 5899 | |
| 5900 | mcp->mb[0] = MBC_DUMP_RISC_RAM_EXTENDED; |
| 5901 | mcp->mb[1] = LSW(addr); |
| 5902 | mcp->mb[2] = MSW(req_dma); |
| 5903 | mcp->mb[3] = LSW(req_dma); |
| 5904 | mcp->mb[4] = MSW(size); |
| 5905 | mcp->mb[5] = LSW(size); |
| 5906 | mcp->mb[6] = MSW(MSD(req_dma)); |
| 5907 | mcp->mb[7] = LSW(MSD(req_dma)); |
| 5908 | mcp->mb[8] = MSW(addr); |
| 5909 | /* Setting RAM ID to valid */ |
| 5910 | mcp->mb[10] |= BIT_7; |
| 5911 | /* For MCTP RAM ID is 0x40 */ |
| 5912 | mcp->mb[10] |= 0x40; |
| 5913 | |
| 5914 | mcp->out_mb |= MBX_10|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1| |
| 5915 | MBX_0; |
| 5916 | |
| 5917 | mcp->in_mb = MBX_0; |
| 5918 | mcp->tov = MBX_TOV_SECONDS; |
| 5919 | mcp->flags = 0; |
| 5920 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5921 | |
| 5922 | if (rval != QLA_SUCCESS) { |
| 5923 | ql_dbg(ql_dbg_mbx, vha, 0x114e, |
| 5924 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5925 | } else { |
| 5926 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x114d, |
| 5927 | "Done %s.\n", __func__); |
| 5928 | } |
| 5929 | |
| 5930 | return rval; |
| 5931 | } |
Joe Carnuccio | ec89146 | 2016-07-06 11:14:26 -0400 | [diff] [blame] | 5932 | |
| 5933 | int |
| 5934 | qla26xx_dport_diagnostics(scsi_qla_host_t *vha, |
| 5935 | void *dd_buf, uint size, uint options) |
| 5936 | { |
| 5937 | int rval; |
| 5938 | mbx_cmd_t mc; |
| 5939 | mbx_cmd_t *mcp = &mc; |
| 5940 | dma_addr_t dd_dma; |
| 5941 | |
| 5942 | if (!IS_QLA83XX(vha->hw) && !IS_QLA27XX(vha->hw)) |
| 5943 | return QLA_FUNCTION_FAILED; |
| 5944 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 5945 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x119f, |
Joe Carnuccio | ec89146 | 2016-07-06 11:14:26 -0400 | [diff] [blame] | 5946 | "Entered %s.\n", __func__); |
| 5947 | |
Joe Carnuccio | ec89146 | 2016-07-06 11:14:26 -0400 | [diff] [blame] | 5948 | dd_dma = dma_map_single(&vha->hw->pdev->dev, |
| 5949 | dd_buf, size, DMA_FROM_DEVICE); |
Pan Bian | 0b2ce19 | 2017-08-08 21:55:30 +0800 | [diff] [blame] | 5950 | if (dma_mapping_error(&vha->hw->pdev->dev, dd_dma)) { |
Joe Carnuccio | ec89146 | 2016-07-06 11:14:26 -0400 | [diff] [blame] | 5951 | ql_log(ql_log_warn, vha, 0x1194, "Failed to map dma buffer.\n"); |
| 5952 | return QLA_MEMORY_ALLOC_FAILED; |
| 5953 | } |
| 5954 | |
| 5955 | memset(dd_buf, 0, size); |
| 5956 | |
| 5957 | mcp->mb[0] = MBC_DPORT_DIAGNOSTICS; |
| 5958 | mcp->mb[1] = options; |
| 5959 | mcp->mb[2] = MSW(LSD(dd_dma)); |
| 5960 | mcp->mb[3] = LSW(LSD(dd_dma)); |
| 5961 | mcp->mb[6] = MSW(MSD(dd_dma)); |
| 5962 | mcp->mb[7] = LSW(MSD(dd_dma)); |
| 5963 | mcp->mb[8] = size; |
| 5964 | mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5965 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 5966 | mcp->buf_size = size; |
| 5967 | mcp->flags = MBX_DMA_IN; |
| 5968 | mcp->tov = MBX_TOV_SECONDS * 4; |
| 5969 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5970 | |
| 5971 | if (rval != QLA_SUCCESS) { |
| 5972 | ql_dbg(ql_dbg_mbx, vha, 0x1195, "Failed=%x.\n", rval); |
| 5973 | } else { |
| 5974 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1196, |
| 5975 | "Done %s.\n", __func__); |
| 5976 | } |
| 5977 | |
| 5978 | dma_unmap_single(&vha->hw->pdev->dev, dd_dma, |
| 5979 | size, DMA_FROM_DEVICE); |
| 5980 | |
| 5981 | return rval; |
| 5982 | } |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 5983 | |
| 5984 | static void qla2x00_async_mb_sp_done(void *s, int res) |
| 5985 | { |
| 5986 | struct srb *sp = s; |
| 5987 | |
| 5988 | sp->u.iocb_cmd.u.mbx.rc = res; |
| 5989 | |
| 5990 | complete(&sp->u.iocb_cmd.u.mbx.comp); |
| 5991 | /* don't free sp here. Let the caller do the free */ |
| 5992 | } |
| 5993 | |
| 5994 | /* |
| 5995 | * This mailbox uses the iocb interface to send MB command. |
| 5996 | * This allows non-critial (non chip setup) command to go |
| 5997 | * out in parrallel. |
| 5998 | */ |
| 5999 | int qla24xx_send_mb_cmd(struct scsi_qla_host *vha, mbx_cmd_t *mcp) |
| 6000 | { |
| 6001 | int rval = QLA_FUNCTION_FAILED; |
| 6002 | srb_t *sp; |
| 6003 | struct srb_iocb *c; |
| 6004 | |
| 6005 | if (!vha->hw->flags.fw_started) |
| 6006 | goto done; |
| 6007 | |
| 6008 | sp = qla2x00_get_sp(vha, NULL, GFP_KERNEL); |
| 6009 | if (!sp) |
| 6010 | goto done; |
| 6011 | |
| 6012 | sp->type = SRB_MB_IOCB; |
| 6013 | sp->name = mb_to_str(mcp->mb[0]); |
| 6014 | |
| 6015 | qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); |
| 6016 | |
| 6017 | memcpy(sp->u.iocb_cmd.u.mbx.out_mb, mcp->mb, SIZEOF_IOCB_MB_REG); |
| 6018 | |
| 6019 | c = &sp->u.iocb_cmd; |
| 6020 | c->timeout = qla2x00_async_iocb_timeout; |
| 6021 | init_completion(&c->u.mbx.comp); |
| 6022 | |
| 6023 | sp->done = qla2x00_async_mb_sp_done; |
| 6024 | |
| 6025 | rval = qla2x00_start_sp(sp); |
| 6026 | if (rval != QLA_SUCCESS) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6027 | ql_dbg(ql_dbg_mbx, vha, 0x1018, |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6028 | "%s: %s Failed submission. %x.\n", |
| 6029 | __func__, sp->name, rval); |
| 6030 | goto done_free_sp; |
| 6031 | } |
| 6032 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6033 | ql_dbg(ql_dbg_mbx, vha, 0x113f, "MB:%s hndl %x submitted\n", |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6034 | sp->name, sp->handle); |
| 6035 | |
| 6036 | wait_for_completion(&c->u.mbx.comp); |
| 6037 | memcpy(mcp->mb, sp->u.iocb_cmd.u.mbx.in_mb, SIZEOF_IOCB_MB_REG); |
| 6038 | |
| 6039 | rval = c->u.mbx.rc; |
| 6040 | switch (rval) { |
| 6041 | case QLA_FUNCTION_TIMEOUT: |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6042 | ql_dbg(ql_dbg_mbx, vha, 0x1140, "%s: %s Timeout. %x.\n", |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6043 | __func__, sp->name, rval); |
| 6044 | break; |
| 6045 | case QLA_SUCCESS: |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6046 | ql_dbg(ql_dbg_mbx, vha, 0x119d, "%s: %s done.\n", |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6047 | __func__, sp->name); |
| 6048 | sp->free(sp); |
| 6049 | break; |
| 6050 | default: |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6051 | ql_dbg(ql_dbg_mbx, vha, 0x119e, "%s: %s Failed. %x.\n", |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6052 | __func__, sp->name, rval); |
| 6053 | sp->free(sp); |
| 6054 | break; |
| 6055 | } |
| 6056 | |
| 6057 | return rval; |
| 6058 | |
| 6059 | done_free_sp: |
| 6060 | sp->free(sp); |
| 6061 | done: |
| 6062 | return rval; |
| 6063 | } |
| 6064 | |
| 6065 | /* |
| 6066 | * qla24xx_gpdb_wait |
| 6067 | * NOTE: Do not call this routine from DPC thread |
| 6068 | */ |
| 6069 | int qla24xx_gpdb_wait(struct scsi_qla_host *vha, fc_port_t *fcport, u8 opt) |
| 6070 | { |
| 6071 | int rval = QLA_FUNCTION_FAILED; |
| 6072 | dma_addr_t pd_dma; |
| 6073 | struct port_database_24xx *pd; |
| 6074 | struct qla_hw_data *ha = vha->hw; |
| 6075 | mbx_cmd_t mc; |
| 6076 | |
| 6077 | if (!vha->hw->flags.fw_started) |
| 6078 | goto done; |
| 6079 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 6080 | pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6081 | if (pd == NULL) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6082 | ql_log(ql_log_warn, vha, 0xd047, |
| 6083 | "Failed to allocate port database structure.\n"); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6084 | goto done_free_sp; |
| 6085 | } |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6086 | |
| 6087 | memset(&mc, 0, sizeof(mc)); |
| 6088 | mc.mb[0] = MBC_GET_PORT_DATABASE; |
| 6089 | mc.mb[1] = cpu_to_le16(fcport->loop_id); |
| 6090 | mc.mb[2] = MSW(pd_dma); |
| 6091 | mc.mb[3] = LSW(pd_dma); |
| 6092 | mc.mb[6] = MSW(MSD(pd_dma)); |
| 6093 | mc.mb[7] = LSW(MSD(pd_dma)); |
| 6094 | mc.mb[9] = cpu_to_le16(vha->vp_idx); |
| 6095 | mc.mb[10] = cpu_to_le16((uint16_t)opt); |
| 6096 | |
| 6097 | rval = qla24xx_send_mb_cmd(vha, &mc); |
| 6098 | if (rval != QLA_SUCCESS) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6099 | ql_dbg(ql_dbg_mbx, vha, 0x1193, |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6100 | "%s: %8phC fail\n", __func__, fcport->port_name); |
| 6101 | goto done_free_sp; |
| 6102 | } |
| 6103 | |
| 6104 | rval = __qla24xx_parse_gpdb(vha, fcport, pd); |
| 6105 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6106 | ql_dbg(ql_dbg_mbx, vha, 0x1197, "%s: %8phC done\n", |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6107 | __func__, fcport->port_name); |
| 6108 | |
| 6109 | done_free_sp: |
| 6110 | if (pd) |
| 6111 | dma_pool_free(ha->s_dma_pool, pd, pd_dma); |
| 6112 | done: |
| 6113 | return rval; |
| 6114 | } |
| 6115 | |
| 6116 | int __qla24xx_parse_gpdb(struct scsi_qla_host *vha, fc_port_t *fcport, |
| 6117 | struct port_database_24xx *pd) |
| 6118 | { |
| 6119 | int rval = QLA_SUCCESS; |
| 6120 | uint64_t zero = 0; |
Duane Grigsby | a5d42f4 | 2017-06-21 13:48:41 -0700 | [diff] [blame] | 6121 | u8 current_login_state, last_login_state; |
| 6122 | |
| 6123 | if (fcport->fc4f_nvme) { |
| 6124 | current_login_state = pd->current_login_state >> 4; |
| 6125 | last_login_state = pd->last_login_state >> 4; |
| 6126 | } else { |
| 6127 | current_login_state = pd->current_login_state & 0xf; |
| 6128 | last_login_state = pd->last_login_state & 0xf; |
| 6129 | } |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6130 | |
| 6131 | /* Check for logged in state. */ |
Quinn Tran | 23c6455 | 2017-12-04 14:45:08 -0800 | [diff] [blame] | 6132 | if (current_login_state != PDS_PRLI_COMPLETE) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6133 | ql_dbg(ql_dbg_mbx, vha, 0x119a, |
| 6134 | "Unable to verify login-state (%x/%x) for loop_id %x.\n", |
Duane Grigsby | a5d42f4 | 2017-06-21 13:48:41 -0700 | [diff] [blame] | 6135 | current_login_state, last_login_state, fcport->loop_id); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6136 | rval = QLA_FUNCTION_FAILED; |
| 6137 | goto gpd_error_out; |
| 6138 | } |
| 6139 | |
| 6140 | if (fcport->loop_id == FC_NO_LOOP_ID || |
| 6141 | (memcmp(fcport->port_name, (uint8_t *)&zero, 8) && |
| 6142 | memcmp(fcport->port_name, pd->port_name, 8))) { |
| 6143 | /* We lost the device mid way. */ |
| 6144 | rval = QLA_NOT_LOGGED_IN; |
| 6145 | goto gpd_error_out; |
| 6146 | } |
| 6147 | |
| 6148 | /* Names are little-endian. */ |
| 6149 | memcpy(fcport->node_name, pd->node_name, WWN_SIZE); |
| 6150 | memcpy(fcport->port_name, pd->port_name, WWN_SIZE); |
| 6151 | |
| 6152 | /* Get port_id of device. */ |
| 6153 | fcport->d_id.b.domain = pd->port_id[0]; |
| 6154 | fcport->d_id.b.area = pd->port_id[1]; |
| 6155 | fcport->d_id.b.al_pa = pd->port_id[2]; |
| 6156 | fcport->d_id.b.rsvd_1 = 0; |
| 6157 | |
Duane Grigsby | a5d42f4 | 2017-06-21 13:48:41 -0700 | [diff] [blame] | 6158 | if (fcport->fc4f_nvme) { |
| 6159 | fcport->nvme_prli_service_param = |
| 6160 | pd->prli_nvme_svc_param_word_3; |
| 6161 | fcport->port_type = FCT_NVME; |
| 6162 | } else { |
| 6163 | /* If not target must be initiator or unknown type. */ |
| 6164 | if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0) |
| 6165 | fcport->port_type = FCT_INITIATOR; |
| 6166 | else |
| 6167 | fcport->port_type = FCT_TARGET; |
| 6168 | } |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6169 | /* Passback COS information. */ |
| 6170 | fcport->supported_classes = (pd->flags & PDF_CLASS_2) ? |
| 6171 | FC_COS_CLASS2 : FC_COS_CLASS3; |
| 6172 | |
| 6173 | if (pd->prli_svc_param_word_3[0] & BIT_7) { |
| 6174 | fcport->flags |= FCF_CONF_COMP_SUPPORTED; |
| 6175 | fcport->conf_compl_supported = 1; |
| 6176 | } |
| 6177 | |
| 6178 | gpd_error_out: |
| 6179 | return rval; |
| 6180 | } |
| 6181 | |
| 6182 | /* |
| 6183 | * qla24xx_gidlist__wait |
| 6184 | * NOTE: don't call this routine from DPC thread. |
| 6185 | */ |
| 6186 | int qla24xx_gidlist_wait(struct scsi_qla_host *vha, |
| 6187 | void *id_list, dma_addr_t id_list_dma, uint16_t *entries) |
| 6188 | { |
| 6189 | int rval = QLA_FUNCTION_FAILED; |
| 6190 | mbx_cmd_t mc; |
| 6191 | |
| 6192 | if (!vha->hw->flags.fw_started) |
| 6193 | goto done; |
| 6194 | |
| 6195 | memset(&mc, 0, sizeof(mc)); |
| 6196 | mc.mb[0] = MBC_GET_ID_LIST; |
| 6197 | mc.mb[2] = MSW(id_list_dma); |
| 6198 | mc.mb[3] = LSW(id_list_dma); |
| 6199 | mc.mb[6] = MSW(MSD(id_list_dma)); |
| 6200 | mc.mb[7] = LSW(MSD(id_list_dma)); |
| 6201 | mc.mb[8] = 0; |
| 6202 | mc.mb[9] = cpu_to_le16(vha->vp_idx); |
| 6203 | |
| 6204 | rval = qla24xx_send_mb_cmd(vha, &mc); |
| 6205 | if (rval != QLA_SUCCESS) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6206 | ql_dbg(ql_dbg_mbx, vha, 0x119b, |
| 6207 | "%s: fail\n", __func__); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6208 | } else { |
| 6209 | *entries = mc.mb[1]; |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6210 | ql_dbg(ql_dbg_mbx, vha, 0x119c, |
| 6211 | "%s: done\n", __func__); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6212 | } |
| 6213 | done: |
| 6214 | return rval; |
| 6215 | } |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 6216 | |
| 6217 | int qla27xx_set_zio_threshold(scsi_qla_host_t *vha, uint16_t value) |
| 6218 | { |
| 6219 | int rval; |
| 6220 | mbx_cmd_t mc; |
| 6221 | mbx_cmd_t *mcp = &mc; |
| 6222 | |
| 6223 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1200, |
| 6224 | "Entered %s\n", __func__); |
| 6225 | |
| 6226 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 6227 | mcp->mb[0] = MBC_GET_SET_ZIO_THRESHOLD; |
| 6228 | mcp->mb[1] = cpu_to_le16(1); |
| 6229 | mcp->mb[2] = cpu_to_le16(value); |
| 6230 | mcp->out_mb = MBX_2 | MBX_1 | MBX_0; |
| 6231 | mcp->in_mb = MBX_2 | MBX_0; |
| 6232 | mcp->tov = MBX_TOV_SECONDS; |
| 6233 | mcp->flags = 0; |
| 6234 | |
| 6235 | rval = qla2x00_mailbox_command(vha, mcp); |
| 6236 | |
| 6237 | ql_dbg(ql_dbg_mbx, vha, 0x1201, "%s %x\n", |
| 6238 | (rval != QLA_SUCCESS) ? "Failed" : "Done", rval); |
| 6239 | |
| 6240 | return rval; |
| 6241 | } |
| 6242 | |
| 6243 | int qla27xx_get_zio_threshold(scsi_qla_host_t *vha, uint16_t *value) |
| 6244 | { |
| 6245 | int rval; |
| 6246 | mbx_cmd_t mc; |
| 6247 | mbx_cmd_t *mcp = &mc; |
| 6248 | |
| 6249 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1203, |
| 6250 | "Entered %s\n", __func__); |
| 6251 | |
| 6252 | memset(mcp->mb, 0, sizeof(mcp->mb)); |
| 6253 | mcp->mb[0] = MBC_GET_SET_ZIO_THRESHOLD; |
| 6254 | mcp->mb[1] = cpu_to_le16(0); |
| 6255 | mcp->out_mb = MBX_1 | MBX_0; |
| 6256 | mcp->in_mb = MBX_2 | MBX_0; |
| 6257 | mcp->tov = MBX_TOV_SECONDS; |
| 6258 | mcp->flags = 0; |
| 6259 | |
| 6260 | rval = qla2x00_mailbox_command(vha, mcp); |
| 6261 | if (rval == QLA_SUCCESS) |
| 6262 | *value = mc.mb[2]; |
| 6263 | |
| 6264 | ql_dbg(ql_dbg_mbx, vha, 0x1205, "%s %x\n", |
| 6265 | (rval != QLA_SUCCESS) ? "Failed" : "Done", rval); |
| 6266 | |
| 6267 | return rval; |
| 6268 | } |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 6269 | |
| 6270 | int |
| 6271 | qla2x00_read_sfp_dev(struct scsi_qla_host *vha, char *buf, int count) |
| 6272 | { |
| 6273 | struct qla_hw_data *ha = vha->hw; |
| 6274 | uint16_t iter, addr, offset; |
| 6275 | dma_addr_t phys_addr; |
| 6276 | int rval, c; |
| 6277 | u8 *sfp_data; |
| 6278 | |
| 6279 | memset(ha->sfp_data, 0, SFP_DEV_SIZE); |
| 6280 | addr = 0xa0; |
| 6281 | phys_addr = ha->sfp_data_dma; |
| 6282 | sfp_data = ha->sfp_data; |
| 6283 | offset = c = 0; |
| 6284 | |
| 6285 | for (iter = 0; iter < SFP_DEV_SIZE / SFP_BLOCK_SIZE; iter++) { |
| 6286 | if (iter == 4) { |
| 6287 | /* Skip to next device address. */ |
| 6288 | addr = 0xa2; |
| 6289 | offset = 0; |
| 6290 | } |
| 6291 | |
| 6292 | rval = qla2x00_read_sfp(vha, phys_addr, sfp_data, |
| 6293 | addr, offset, SFP_BLOCK_SIZE, BIT_1); |
| 6294 | if (rval != QLA_SUCCESS) { |
| 6295 | ql_log(ql_log_warn, vha, 0x706d, |
| 6296 | "Unable to read SFP data (%x/%x/%x).\n", rval, |
| 6297 | addr, offset); |
| 6298 | |
| 6299 | return rval; |
| 6300 | } |
| 6301 | |
| 6302 | if (buf && (c < count)) { |
| 6303 | u16 sz; |
| 6304 | |
| 6305 | if ((count - c) >= SFP_BLOCK_SIZE) |
| 6306 | sz = SFP_BLOCK_SIZE; |
| 6307 | else |
| 6308 | sz = count - c; |
| 6309 | |
| 6310 | memcpy(buf, sfp_data, sz); |
| 6311 | buf += SFP_BLOCK_SIZE; |
| 6312 | c += sz; |
| 6313 | } |
| 6314 | phys_addr += SFP_BLOCK_SIZE; |
| 6315 | sfp_data += SFP_BLOCK_SIZE; |
| 6316 | offset += SFP_BLOCK_SIZE; |
| 6317 | } |
| 6318 | |
| 6319 | return rval; |
| 6320 | } |
Quinn Tran | 94d83e3 | 2017-12-28 12:33:23 -0800 | [diff] [blame] | 6321 | |
| 6322 | int qla24xx_res_count_wait(struct scsi_qla_host *vha, |
| 6323 | uint16_t *out_mb, int out_mb_sz) |
| 6324 | { |
| 6325 | int rval = QLA_FUNCTION_FAILED; |
| 6326 | mbx_cmd_t mc; |
| 6327 | |
| 6328 | if (!vha->hw->flags.fw_started) |
| 6329 | goto done; |
| 6330 | |
| 6331 | memset(&mc, 0, sizeof(mc)); |
| 6332 | mc.mb[0] = MBC_GET_RESOURCE_COUNTS; |
| 6333 | |
| 6334 | rval = qla24xx_send_mb_cmd(vha, &mc); |
| 6335 | if (rval != QLA_SUCCESS) { |
| 6336 | ql_dbg(ql_dbg_mbx, vha, 0xffff, |
| 6337 | "%s: fail\n", __func__); |
| 6338 | } else { |
| 6339 | if (out_mb_sz <= SIZEOF_IOCB_MB_REG) |
| 6340 | memcpy(out_mb, mc.mb, out_mb_sz); |
| 6341 | else |
| 6342 | memcpy(out_mb, mc.mb, SIZEOF_IOCB_MB_REG); |
| 6343 | |
| 6344 | ql_dbg(ql_dbg_mbx, vha, 0xffff, |
| 6345 | "%s: done\n", __func__); |
| 6346 | } |
| 6347 | done: |
| 6348 | return rval; |
| 6349 | } |