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 | |
Rodrigo R. Galvao | 3cb182b | 2018-05-28 14:58:44 -0300 | [diff] [blame] | 295 | /* |
| 296 | * Check if it's UNLOADING, cause we cannot poll in |
| 297 | * this case, or else a NULL pointer dereference |
| 298 | * is triggered. |
| 299 | */ |
| 300 | if (unlikely(test_bit(UNLOADING, &base_vha->dpc_flags))) |
| 301 | return QLA_FUNCTION_TIMEOUT; |
| 302 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | /* Check for pending interrupts. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 304 | qla2x00_poll(ha->rsp_q_map[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 306 | if (!ha->flags.mbox_int && |
| 307 | !(IS_QLA2200(ha) && |
| 308 | command == MBC_LOAD_RISC_RAM_EXTENDED)) |
andrew.vasquez@qlogic.com | 5998983 | 2006-01-13 17:05:10 -0800 | [diff] [blame] | 309 | msleep(10); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | } /* while */ |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 311 | ql_dbg(ql_dbg_mbx, vha, 0x1013, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 312 | "Waited %d sec.\n", |
| 313 | (uint)((jiffies - (wait_time - (mcp->tov * HZ)))/HZ)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | } |
| 315 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | /* Check whether we timed out */ |
| 317 | if (ha->flags.mbox_int) { |
| 318 | uint16_t *iptr2; |
| 319 | |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 320 | ql_dbg(ql_dbg_mbx, vha, 0x1014, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 321 | "Cmd=%x completed.\n", command); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | |
| 323 | /* Got interrupt. Clear the flag. */ |
| 324 | ha->flags.mbox_int = 0; |
| 325 | clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
| 326 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 327 | if (IS_P3P_TYPE(ha) && ha->flags.isp82xx_fw_hung) { |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 328 | ha->flags.mbox_busy = 0; |
| 329 | /* Setting Link-Down error */ |
| 330 | mcp->mb[0] = MBS_LINK_DOWN_ERROR; |
| 331 | ha->mcp = NULL; |
| 332 | rval = QLA_FUNCTION_FAILED; |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 333 | ql_log(ql_log_warn, vha, 0xd048, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 334 | "FW hung = %d.\n", ha->flags.isp82xx_fw_hung); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 335 | goto premature_exit; |
| 336 | } |
| 337 | |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 338 | if (ha->mailbox_out[0] != MBS_COMMAND_COMPLETE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | rval = QLA_FUNCTION_FAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | |
| 341 | /* Load return mailbox registers. */ |
| 342 | iptr2 = mcp->mb; |
| 343 | iptr = (uint16_t *)&ha->mailbox_out[0]; |
| 344 | mboxes = mcp->in_mb; |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 345 | |
| 346 | ql_dbg(ql_dbg_mbx, vha, 0x1113, |
| 347 | "Mailbox registers (IN):\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | for (cnt = 0; cnt < ha->mbx_count; cnt++) { |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 349 | if (mboxes & BIT_0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | *iptr2 = *iptr; |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 351 | ql_dbg(ql_dbg_mbx, vha, 0x1114, |
| 352 | "mbox[%d]->0x%04x\n", cnt, *iptr2); |
| 353 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | |
| 355 | mboxes >>= 1; |
| 356 | iptr2++; |
| 357 | iptr++; |
| 358 | } |
| 359 | } else { |
| 360 | |
Quinn Tran | 8d3c9c2 | 2016-12-23 18:06:09 -0800 | [diff] [blame] | 361 | uint16_t mb[8]; |
| 362 | uint32_t ictrl, host_status, hccr; |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 363 | uint16_t w; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 364 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 365 | if (IS_FWI2_CAPABLE(ha)) { |
Quinn Tran | 8d3c9c2 | 2016-12-23 18:06:09 -0800 | [diff] [blame] | 366 | mb[0] = RD_REG_WORD(®->isp24.mailbox0); |
| 367 | mb[1] = RD_REG_WORD(®->isp24.mailbox1); |
| 368 | mb[2] = RD_REG_WORD(®->isp24.mailbox2); |
| 369 | mb[3] = RD_REG_WORD(®->isp24.mailbox3); |
| 370 | mb[7] = RD_REG_WORD(®->isp24.mailbox7); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 371 | ictrl = RD_REG_DWORD(®->isp24.ictrl); |
Quinn Tran | 8d3c9c2 | 2016-12-23 18:06:09 -0800 | [diff] [blame] | 372 | host_status = RD_REG_DWORD(®->isp24.host_status); |
| 373 | hccr = RD_REG_DWORD(®->isp24.hccr); |
| 374 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 375 | ql_log(ql_log_warn, vha, 0xd04c, |
Quinn Tran | 8d3c9c2 | 2016-12-23 18:06:09 -0800 | [diff] [blame] | 376 | "MBX Command timeout for cmd %x, iocontrol=%x jiffies=%lx " |
| 377 | "mb[0-3]=[0x%x 0x%x 0x%x 0x%x] mb7 0x%x host_status 0x%x hccr 0x%x\n", |
| 378 | command, ictrl, jiffies, mb[0], mb[1], mb[2], mb[3], |
| 379 | mb[7], host_status, hccr); |
| 380 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 381 | } else { |
Quinn Tran | 8d3c9c2 | 2016-12-23 18:06:09 -0800 | [diff] [blame] | 382 | mb[0] = RD_MAILBOX_REG(ha, ®->isp, 0); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 383 | ictrl = RD_REG_WORD(®->isp.ictrl); |
Quinn Tran | 8d3c9c2 | 2016-12-23 18:06:09 -0800 | [diff] [blame] | 384 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1119, |
| 385 | "MBX Command timeout for cmd %x, iocontrol=%x jiffies=%lx " |
| 386 | "mb[0]=0x%x\n", command, ictrl, jiffies, mb[0]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 387 | } |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 388 | ql_dump_regs(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1019); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 390 | /* Capture FW dump only, if PCI device active */ |
| 391 | if (!pci_channel_offline(vha->hw->pdev)) { |
| 392 | pci_read_config_word(ha->pdev, PCI_VENDOR_ID, &w); |
| 393 | if (w == 0xffff || ictrl == 0xffffffff) { |
| 394 | /* This is special case if there is unload |
| 395 | * of driver happening and if PCI device go |
| 396 | * into bad state due to PCI error condition |
| 397 | * then only PCI ERR flag would be set. |
| 398 | * we will do premature exit for above case. |
| 399 | */ |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 400 | ha->flags.mbox_busy = 0; |
| 401 | rval = QLA_FUNCTION_TIMEOUT; |
| 402 | goto premature_exit; |
| 403 | } |
Chad Dupuis | f55bfc8 | 2012-02-09 11:15:53 -0800 | [diff] [blame] | 404 | |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 405 | /* Attempt to capture firmware dump for further |
| 406 | * anallysis of the current formware state. we do not |
| 407 | * need to do this if we are intentionally generating |
| 408 | * a dump |
| 409 | */ |
| 410 | if (mcp->mb[0] != MBC_GEN_SYSTEM_ERROR) |
| 411 | ha->isp_ops->fw_dump(vha, 0); |
| 412 | rval = QLA_FUNCTION_TIMEOUT; |
| 413 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | } |
| 415 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | ha->flags.mbox_busy = 0; |
| 417 | |
| 418 | /* Clean up */ |
| 419 | ha->mcp = NULL; |
| 420 | |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 421 | if ((abort_active || !io_lock_on) && !IS_NOPOLLING_TYPE(ha)) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 422 | ql_dbg(ql_dbg_mbx, vha, 0x101a, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 423 | "Checking for additional resp interrupt.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | |
| 425 | /* polling mode for non isp_abort commands. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 426 | qla2x00_poll(ha->rsp_q_map[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | } |
| 428 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 429 | if (rval == QLA_FUNCTION_TIMEOUT && |
| 430 | mcp->mb[0] != MBC_GEN_SYSTEM_ERROR) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 431 | if (!io_lock_on || (mcp->flags & IOCTL_CMD) || |
| 432 | ha->flags.eeh_busy) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | /* not in dpc. schedule it for dpc to take over. */ |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 434 | ql_dbg(ql_dbg_mbx, vha, 0x101b, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 435 | "Timeout, schedule isp_abort_needed.\n"); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 436 | |
| 437 | if (!test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) && |
| 438 | !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) && |
| 439 | !test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) { |
Giridhar Malavali | 6315491 | 2011-11-18 09:02:19 -0800 | [diff] [blame] | 440 | if (IS_QLA82XX(ha)) { |
| 441 | ql_dbg(ql_dbg_mbx, vha, 0x112a, |
| 442 | "disabling pause transmit on port " |
| 443 | "0 & 1.\n"); |
| 444 | qla82xx_wr_32(ha, |
| 445 | QLA82XX_CRB_NIU + 0x98, |
| 446 | CRB_NIU_XG_PAUSE_CTL_P0| |
| 447 | CRB_NIU_XG_PAUSE_CTL_P1); |
| 448 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 449 | ql_log(ql_log_info, base_vha, 0x101c, |
Masanari Iida | 24d9ee8 | 2012-05-15 14:34:10 -0400 | [diff] [blame] | 450 | "Mailbox cmd timeout occurred, cmd=0x%x, " |
Chad Dupuis | d8c0d54 | 2012-02-09 11:15:46 -0800 | [diff] [blame] | 451 | "mb[0]=0x%x, eeh_busy=0x%x. Scheduling ISP " |
| 452 | "abort.\n", command, mcp->mb[0], |
| 453 | ha->flags.eeh_busy); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 454 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 455 | qla2xxx_wake_dpc(vha); |
| 456 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | } else if (!abort_active) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | /* call abort directly since we are in the DPC thread */ |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 459 | ql_dbg(ql_dbg_mbx, vha, 0x101d, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 460 | "Timeout, calling abort_isp.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 462 | if (!test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) && |
| 463 | !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) && |
| 464 | !test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) { |
Giridhar Malavali | 6315491 | 2011-11-18 09:02:19 -0800 | [diff] [blame] | 465 | if (IS_QLA82XX(ha)) { |
| 466 | ql_dbg(ql_dbg_mbx, vha, 0x112b, |
| 467 | "disabling pause transmit on port " |
| 468 | "0 & 1.\n"); |
| 469 | qla82xx_wr_32(ha, |
| 470 | QLA82XX_CRB_NIU + 0x98, |
| 471 | CRB_NIU_XG_PAUSE_CTL_P0| |
| 472 | CRB_NIU_XG_PAUSE_CTL_P1); |
| 473 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 474 | ql_log(ql_log_info, base_vha, 0x101e, |
Masanari Iida | 24d9ee8 | 2012-05-15 14:34:10 -0400 | [diff] [blame] | 475 | "Mailbox cmd timeout occurred, cmd=0x%x, " |
Chad Dupuis | d8c0d54 | 2012-02-09 11:15:46 -0800 | [diff] [blame] | 476 | "mb[0]=0x%x. Scheduling ISP abort ", |
| 477 | command, mcp->mb[0]); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 478 | set_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags); |
| 479 | clear_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Giridhar Malavali | d336096 | 2012-02-09 11:14:10 -0800 | [diff] [blame] | 480 | /* Allow next mbx cmd to come in. */ |
| 481 | complete(&ha->mbx_cmd_comp); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 482 | if (ha->isp_ops->abort_isp(vha)) { |
| 483 | /* Failed. retry later. */ |
| 484 | set_bit(ISP_ABORT_NEEDED, |
| 485 | &vha->dpc_flags); |
| 486 | } |
| 487 | clear_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags); |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 488 | ql_dbg(ql_dbg_mbx, vha, 0x101f, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 489 | "Finished abort_isp.\n"); |
Giridhar Malavali | d336096 | 2012-02-09 11:14:10 -0800 | [diff] [blame] | 490 | goto mbx_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | } |
| 493 | } |
| 494 | |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 495 | premature_exit: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | /* Allow next mbx cmd to come in. */ |
Andrew Vasquez | 8eca3f3 | 2009-01-22 09:45:31 -0800 | [diff] [blame] | 497 | complete(&ha->mbx_cmd_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | |
Giridhar Malavali | d336096 | 2012-02-09 11:14:10 -0800 | [diff] [blame] | 499 | mbx_done: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | if (rval) { |
Joe Carnuccio | 050dc76 | 2017-08-23 15:05:14 -0700 | [diff] [blame] | 501 | if (ql2xextended_error_logging & (ql_dbg_disc|ql_dbg_mbx)) { |
| 502 | pr_warn("%s [%s]-%04x:%ld: **** Failed", QL_MSGHDR, |
| 503 | dev_name(&ha->pdev->dev), 0x1020+0x800, |
| 504 | vha->host_no); |
| 505 | mboxes = mcp->in_mb; |
| 506 | cnt = 4; |
| 507 | for (i = 0; i < ha->mbx_count && cnt; i++, mboxes >>= 1) |
| 508 | if (mboxes & BIT_0) { |
| 509 | printk(" mb[%u]=%x", i, mcp->mb[i]); |
| 510 | cnt--; |
| 511 | } |
| 512 | pr_warn(" cmd=%x ****\n", command); |
| 513 | } |
Meelis Roos | f7e59e9 | 2018-03-08 15:44:07 +0200 | [diff] [blame] | 514 | if (IS_FWI2_CAPABLE(ha) && !(IS_P3P_TYPE(ha))) { |
| 515 | ql_dbg(ql_dbg_mbx, vha, 0x1198, |
| 516 | "host_status=%#x intr_ctrl=%#x intr_status=%#x\n", |
| 517 | RD_REG_DWORD(®->isp24.host_status), |
| 518 | RD_REG_DWORD(®->isp24.ictrl), |
| 519 | RD_REG_DWORD(®->isp24.istatus)); |
| 520 | } else { |
| 521 | ql_dbg(ql_dbg_mbx, vha, 0x1206, |
| 522 | "ctrl_status=%#x ictrl=%#x istatus=%#x\n", |
| 523 | RD_REG_WORD(®->isp.ctrl_status), |
| 524 | RD_REG_WORD(®->isp.ictrl), |
| 525 | RD_REG_WORD(®->isp.istatus)); |
| 526 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 528 | ql_dbg(ql_dbg_mbx, base_vha, 0x1021, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | } |
| 530 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | return rval; |
| 532 | } |
| 533 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 535 | 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] | 536 | uint32_t risc_code_size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 537 | { |
| 538 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 539 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | mbx_cmd_t mc; |
| 541 | mbx_cmd_t *mcp = &mc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 543 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1022, |
| 544 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 546 | if (MSW(risc_addr) || IS_FWI2_CAPABLE(ha)) { |
andrew.vasquez@qlogic.com | 590f98e | 2006-01-13 17:05:37 -0800 | [diff] [blame] | 547 | mcp->mb[0] = MBC_LOAD_RISC_RAM_EXTENDED; |
| 548 | mcp->mb[8] = MSW(risc_addr); |
| 549 | mcp->out_mb = MBX_8|MBX_0; |
| 550 | } else { |
| 551 | mcp->mb[0] = MBC_LOAD_RISC_RAM; |
| 552 | mcp->out_mb = MBX_0; |
| 553 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | mcp->mb[1] = LSW(risc_addr); |
| 555 | mcp->mb[2] = MSW(req_dma); |
| 556 | mcp->mb[3] = LSW(req_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | mcp->mb[6] = MSW(MSD(req_dma)); |
| 558 | mcp->mb[7] = LSW(MSD(req_dma)); |
andrew.vasquez@qlogic.com | 590f98e | 2006-01-13 17:05:37 -0800 | [diff] [blame] | 559 | 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] | 560 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 561 | mcp->mb[4] = MSW(risc_code_size); |
| 562 | mcp->mb[5] = LSW(risc_code_size); |
| 563 | mcp->out_mb |= MBX_5|MBX_4; |
| 564 | } else { |
| 565 | mcp->mb[4] = LSW(risc_code_size); |
| 566 | mcp->out_mb |= MBX_4; |
| 567 | } |
| 568 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 570 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 572 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 575 | ql_dbg(ql_dbg_mbx, vha, 0x1023, |
| 576 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 578 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1024, |
| 579 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 | } |
| 581 | |
| 582 | return rval; |
| 583 | } |
| 584 | |
Santosh Vernekar | cad454b | 2010-03-19 16:59:16 -0700 | [diff] [blame] | 585 | #define EXTENDED_BB_CREDITS BIT_0 |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 586 | #define NVME_ENABLE_FLAG BIT_3 |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 587 | static inline uint16_t qla25xx_set_sfp_lr_dist(struct qla_hw_data *ha) |
| 588 | { |
| 589 | uint16_t mb4 = BIT_0; |
| 590 | |
| 591 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
| 592 | mb4 |= ha->long_range_distance << LR_DIST_FW_POS; |
| 593 | |
| 594 | return mb4; |
| 595 | } |
| 596 | |
| 597 | static inline uint16_t qla25xx_set_nvr_lr_dist(struct qla_hw_data *ha) |
| 598 | { |
| 599 | uint16_t mb4 = BIT_0; |
| 600 | |
| 601 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
| 602 | struct nvram_81xx *nv = ha->nvram; |
| 603 | |
| 604 | mb4 |= LR_DIST_FW_FIELD(nv->enhanced_features); |
| 605 | } |
| 606 | |
| 607 | return mb4; |
| 608 | } |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 609 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | /* |
| 611 | * qla2x00_execute_fw |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 612 | * Start adapter firmware. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | * |
| 614 | * Input: |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 615 | * ha = adapter block pointer. |
| 616 | * TARGET_QUEUE_LOCK must be released. |
| 617 | * ADAPTER_STATE_LOCK must be released. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | * |
| 619 | * Returns: |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 620 | * qla2x00 local function return status code. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | * |
| 622 | * Context: |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 623 | * Kernel context. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | */ |
| 625 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 626 | qla2x00_execute_fw(scsi_qla_host_t *vha, uint32_t risc_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | { |
| 628 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 629 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | mbx_cmd_t mc; |
| 631 | mbx_cmd_t *mcp = &mc; |
| 632 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 633 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1025, |
| 634 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 635 | |
| 636 | mcp->mb[0] = MBC_EXECUTE_FIRMWARE; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 637 | mcp->out_mb = MBX_0; |
| 638 | mcp->in_mb = MBX_0; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 639 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 640 | mcp->mb[1] = MSW(risc_addr); |
| 641 | mcp->mb[2] = LSW(risc_addr); |
| 642 | mcp->mb[3] = 0; |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 643 | mcp->mb[4] = 0; |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 644 | ha->flags.using_lr_setting = 0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 645 | if (IS_QLA25XX(ha) || IS_QLA81XX(ha) || IS_QLA83XX(ha) || |
| 646 | IS_QLA27XX(ha)) { |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 647 | if (ql2xautodetectsfp) { |
| 648 | if (ha->flags.detected_lr_sfp) { |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 649 | mcp->mb[4] |= |
| 650 | qla25xx_set_sfp_lr_dist(ha); |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 651 | ha->flags.using_lr_setting = 1; |
| 652 | } |
| 653 | } else { |
| 654 | struct nvram_81xx *nv = ha->nvram; |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 655 | /* set LR distance if specified in nvram */ |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 656 | if (nv->enhanced_features & |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 657 | NEF_LR_DIST_ENABLE) { |
| 658 | mcp->mb[4] |= |
| 659 | qla25xx_set_nvr_lr_dist(ha); |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 660 | ha->flags.using_lr_setting = 1; |
| 661 | } |
| 662 | } |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 663 | } |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 664 | |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 665 | if (ql2xnvmeenable && IS_QLA27XX(ha)) |
| 666 | mcp->mb[4] |= NVME_ENABLE_FLAG; |
| 667 | |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 668 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
| 669 | struct nvram_81xx *nv = ha->nvram; |
| 670 | /* set minimum speed if specified in nvram */ |
| 671 | if (nv->min_link_speed >= 2 && |
| 672 | nv->min_link_speed <= 5) { |
| 673 | mcp->mb[4] |= BIT_4; |
| 674 | mcp->mb[11] = nv->min_link_speed; |
| 675 | mcp->out_mb |= MBX_11; |
| 676 | mcp->in_mb |= BIT_5; |
| 677 | vha->min_link_speed_feat = nv->min_link_speed; |
| 678 | } |
| 679 | } |
| 680 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 681 | if (ha->flags.exlogins_enabled) |
| 682 | mcp->mb[4] |= ENABLE_EXTENDED_LOGIN; |
| 683 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 684 | if (ha->flags.exchoffld_enabled) |
| 685 | mcp->mb[4] |= ENABLE_EXCHANGE_OFFLD; |
| 686 | |
Andrew Vasquez | 8b3253d | 2007-09-20 14:07:48 -0700 | [diff] [blame] | 687 | mcp->out_mb |= MBX_4|MBX_3|MBX_2|MBX_1; |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 688 | mcp->in_mb |= MBX_3 | MBX_2 | MBX_1; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 689 | } else { |
| 690 | mcp->mb[1] = LSW(risc_addr); |
| 691 | mcp->out_mb |= MBX_1; |
| 692 | if (IS_QLA2322(ha) || IS_QLA6322(ha)) { |
| 693 | mcp->mb[2] = 0; |
| 694 | mcp->out_mb |= MBX_2; |
| 695 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | } |
| 697 | |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 698 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 700 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 701 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 702 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 703 | ql_dbg(ql_dbg_mbx, vha, 0x1026, |
| 704 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 705 | } else { |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 706 | if (IS_FWI2_CAPABLE(ha)) { |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 707 | ha->fw_ability_mask = mcp->mb[3] << 16 | mcp->mb[2]; |
| 708 | ql_dbg(ql_dbg_mbx, vha, 0x119a, |
| 709 | "fw_ability_mask=%x.\n", ha->fw_ability_mask); |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 710 | ql_dbg(ql_dbg_mbx, vha, 0x1027, |
| 711 | "exchanges=%x.\n", mcp->mb[1]); |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 712 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
| 713 | ha->max_speed_sup = mcp->mb[2] & BIT_0; |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 714 | ql_dbg(ql_dbg_mbx, vha, 0x119b, |
| 715 | "Maximum speed supported=%s.\n", |
| 716 | ha->max_speed_sup ? "32Gps" : "16Gps"); |
| 717 | if (vha->min_link_speed_feat) { |
| 718 | ha->min_link_speed = mcp->mb[5]; |
| 719 | ql_dbg(ql_dbg_mbx, vha, 0x119c, |
| 720 | "Minimum speed set=%s.\n", |
| 721 | mcp->mb[5] == 5 ? "32Gps" : |
| 722 | mcp->mb[5] == 4 ? "16Gps" : |
| 723 | mcp->mb[5] == 3 ? "8Gps" : |
| 724 | mcp->mb[5] == 2 ? "4Gps" : |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 725 | "unknown"); |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 726 | } |
| 727 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 728 | } |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 729 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1028, |
| 730 | "Done.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 731 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 732 | |
| 733 | return rval; |
| 734 | } |
| 735 | |
| 736 | /* |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 737 | * qla_get_exlogin_status |
| 738 | * Get extended login status |
| 739 | * uses the memory offload control/status Mailbox |
| 740 | * |
| 741 | * Input: |
| 742 | * ha: adapter state pointer. |
| 743 | * fwopt: firmware options |
| 744 | * |
| 745 | * Returns: |
| 746 | * qla2x00 local function status |
| 747 | * |
| 748 | * Context: |
| 749 | * Kernel context. |
| 750 | */ |
| 751 | #define FETCH_XLOGINS_STAT 0x8 |
| 752 | int |
| 753 | qla_get_exlogin_status(scsi_qla_host_t *vha, uint16_t *buf_sz, |
| 754 | uint16_t *ex_logins_cnt) |
| 755 | { |
| 756 | int rval; |
| 757 | mbx_cmd_t mc; |
| 758 | mbx_cmd_t *mcp = &mc; |
| 759 | |
| 760 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x118f, |
| 761 | "Entered %s\n", __func__); |
| 762 | |
| 763 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 764 | mcp->mb[0] = MBC_GET_MEM_OFFLOAD_CNTRL_STAT; |
| 765 | mcp->mb[1] = FETCH_XLOGINS_STAT; |
| 766 | mcp->out_mb = MBX_1|MBX_0; |
| 767 | mcp->in_mb = MBX_10|MBX_4|MBX_0; |
| 768 | mcp->tov = MBX_TOV_SECONDS; |
| 769 | mcp->flags = 0; |
| 770 | |
| 771 | rval = qla2x00_mailbox_command(vha, mcp); |
| 772 | if (rval != QLA_SUCCESS) { |
| 773 | ql_dbg(ql_dbg_mbx, vha, 0x1115, "Failed=%x.\n", rval); |
| 774 | } else { |
| 775 | *buf_sz = mcp->mb[4]; |
| 776 | *ex_logins_cnt = mcp->mb[10]; |
| 777 | |
| 778 | ql_log(ql_log_info, vha, 0x1190, |
| 779 | "buffer size 0x%x, exchange login count=%d\n", |
| 780 | mcp->mb[4], mcp->mb[10]); |
| 781 | |
| 782 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1116, |
| 783 | "Done %s.\n", __func__); |
| 784 | } |
| 785 | |
| 786 | return rval; |
| 787 | } |
| 788 | |
| 789 | /* |
| 790 | * qla_set_exlogin_mem_cfg |
| 791 | * set extended login memory configuration |
| 792 | * Mbx needs to be issues before init_cb is set |
| 793 | * |
| 794 | * Input: |
| 795 | * ha: adapter state pointer. |
| 796 | * buffer: buffer pointer |
| 797 | * phys_addr: physical address of buffer |
| 798 | * size: size of buffer |
| 799 | * TARGET_QUEUE_LOCK must be released |
| 800 | * ADAPTER_STATE_LOCK must be release |
| 801 | * |
| 802 | * Returns: |
| 803 | * qla2x00 local funxtion status code. |
| 804 | * |
| 805 | * Context: |
| 806 | * Kernel context. |
| 807 | */ |
| 808 | #define CONFIG_XLOGINS_MEM 0x3 |
| 809 | int |
| 810 | qla_set_exlogin_mem_cfg(scsi_qla_host_t *vha, dma_addr_t phys_addr) |
| 811 | { |
| 812 | int rval; |
| 813 | mbx_cmd_t mc; |
| 814 | mbx_cmd_t *mcp = &mc; |
| 815 | struct qla_hw_data *ha = vha->hw; |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 816 | |
| 817 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x111a, |
| 818 | "Entered %s.\n", __func__); |
| 819 | |
| 820 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 821 | mcp->mb[0] = MBC_GET_MEM_OFFLOAD_CNTRL_STAT; |
| 822 | mcp->mb[1] = CONFIG_XLOGINS_MEM; |
| 823 | mcp->mb[2] = MSW(phys_addr); |
| 824 | mcp->mb[3] = LSW(phys_addr); |
| 825 | mcp->mb[6] = MSW(MSD(phys_addr)); |
| 826 | mcp->mb[7] = LSW(MSD(phys_addr)); |
| 827 | mcp->mb[8] = MSW(ha->exlogin_size); |
| 828 | mcp->mb[9] = LSW(ha->exlogin_size); |
| 829 | mcp->out_mb = MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 830 | mcp->in_mb = MBX_11|MBX_0; |
| 831 | mcp->tov = MBX_TOV_SECONDS; |
| 832 | mcp->flags = 0; |
| 833 | rval = qla2x00_mailbox_command(vha, mcp); |
| 834 | if (rval != QLA_SUCCESS) { |
| 835 | /*EMPTY*/ |
| 836 | ql_dbg(ql_dbg_mbx, vha, 0x111b, "Failed=%x.\n", rval); |
| 837 | } else { |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 838 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x118c, |
| 839 | "Done %s.\n", __func__); |
| 840 | } |
| 841 | |
| 842 | return rval; |
| 843 | } |
| 844 | |
| 845 | /* |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 846 | * qla_get_exchoffld_status |
| 847 | * Get exchange offload status |
| 848 | * uses the memory offload control/status Mailbox |
| 849 | * |
| 850 | * Input: |
| 851 | * ha: adapter state pointer. |
| 852 | * fwopt: firmware options |
| 853 | * |
| 854 | * Returns: |
| 855 | * qla2x00 local function status |
| 856 | * |
| 857 | * Context: |
| 858 | * Kernel context. |
| 859 | */ |
| 860 | #define FETCH_XCHOFFLD_STAT 0x2 |
| 861 | int |
| 862 | qla_get_exchoffld_status(scsi_qla_host_t *vha, uint16_t *buf_sz, |
| 863 | uint16_t *ex_logins_cnt) |
| 864 | { |
| 865 | int rval; |
| 866 | mbx_cmd_t mc; |
| 867 | mbx_cmd_t *mcp = &mc; |
| 868 | |
| 869 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1019, |
| 870 | "Entered %s\n", __func__); |
| 871 | |
| 872 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 873 | mcp->mb[0] = MBC_GET_MEM_OFFLOAD_CNTRL_STAT; |
| 874 | mcp->mb[1] = FETCH_XCHOFFLD_STAT; |
| 875 | mcp->out_mb = MBX_1|MBX_0; |
| 876 | mcp->in_mb = MBX_10|MBX_4|MBX_0; |
| 877 | mcp->tov = MBX_TOV_SECONDS; |
| 878 | mcp->flags = 0; |
| 879 | |
| 880 | rval = qla2x00_mailbox_command(vha, mcp); |
| 881 | if (rval != QLA_SUCCESS) { |
| 882 | ql_dbg(ql_dbg_mbx, vha, 0x1155, "Failed=%x.\n", rval); |
| 883 | } else { |
| 884 | *buf_sz = mcp->mb[4]; |
| 885 | *ex_logins_cnt = mcp->mb[10]; |
| 886 | |
| 887 | ql_log(ql_log_info, vha, 0x118e, |
| 888 | "buffer size 0x%x, exchange offload count=%d\n", |
| 889 | mcp->mb[4], mcp->mb[10]); |
| 890 | |
| 891 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1156, |
| 892 | "Done %s.\n", __func__); |
| 893 | } |
| 894 | |
| 895 | return rval; |
| 896 | } |
| 897 | |
| 898 | /* |
| 899 | * qla_set_exchoffld_mem_cfg |
| 900 | * Set exchange offload memory configuration |
| 901 | * Mbx needs to be issues before init_cb is set |
| 902 | * |
| 903 | * Input: |
| 904 | * ha: adapter state pointer. |
| 905 | * buffer: buffer pointer |
| 906 | * phys_addr: physical address of buffer |
| 907 | * size: size of buffer |
| 908 | * TARGET_QUEUE_LOCK must be released |
| 909 | * ADAPTER_STATE_LOCK must be release |
| 910 | * |
| 911 | * Returns: |
| 912 | * qla2x00 local funxtion status code. |
| 913 | * |
| 914 | * Context: |
| 915 | * Kernel context. |
| 916 | */ |
| 917 | #define CONFIG_XCHOFFLD_MEM 0x3 |
| 918 | int |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 919 | qla_set_exchoffld_mem_cfg(scsi_qla_host_t *vha) |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 920 | { |
| 921 | int rval; |
| 922 | mbx_cmd_t mc; |
| 923 | mbx_cmd_t *mcp = &mc; |
| 924 | struct qla_hw_data *ha = vha->hw; |
| 925 | |
| 926 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1157, |
| 927 | "Entered %s.\n", __func__); |
| 928 | |
| 929 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 930 | mcp->mb[0] = MBC_GET_MEM_OFFLOAD_CNTRL_STAT; |
| 931 | mcp->mb[1] = CONFIG_XCHOFFLD_MEM; |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 932 | mcp->mb[2] = MSW(ha->exchoffld_buf_dma); |
| 933 | mcp->mb[3] = LSW(ha->exchoffld_buf_dma); |
| 934 | mcp->mb[6] = MSW(MSD(ha->exchoffld_buf_dma)); |
| 935 | mcp->mb[7] = LSW(MSD(ha->exchoffld_buf_dma)); |
| 936 | mcp->mb[8] = MSW(ha->exchoffld_size); |
| 937 | mcp->mb[9] = LSW(ha->exchoffld_size); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 938 | mcp->out_mb = MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 939 | mcp->in_mb = MBX_11|MBX_0; |
| 940 | mcp->tov = MBX_TOV_SECONDS; |
| 941 | mcp->flags = 0; |
| 942 | rval = qla2x00_mailbox_command(vha, mcp); |
| 943 | if (rval != QLA_SUCCESS) { |
| 944 | /*EMPTY*/ |
| 945 | ql_dbg(ql_dbg_mbx, vha, 0x1158, "Failed=%x.\n", rval); |
| 946 | } else { |
| 947 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1192, |
| 948 | "Done %s.\n", __func__); |
| 949 | } |
| 950 | |
| 951 | return rval; |
| 952 | } |
| 953 | |
| 954 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 955 | * qla2x00_get_fw_version |
| 956 | * Get firmware version. |
| 957 | * |
| 958 | * Input: |
| 959 | * ha: adapter state pointer. |
| 960 | * major: pointer for major number. |
| 961 | * minor: pointer for minor number. |
| 962 | * subminor: pointer for subminor number. |
| 963 | * |
| 964 | * Returns: |
| 965 | * qla2x00 local function return status code. |
| 966 | * |
| 967 | * Context: |
| 968 | * Kernel context. |
| 969 | */ |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 970 | int |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 971 | qla2x00_get_fw_version(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 972 | { |
| 973 | int rval; |
| 974 | mbx_cmd_t mc; |
| 975 | mbx_cmd_t *mcp = &mc; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 976 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 977 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 978 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1029, |
| 979 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 980 | |
| 981 | mcp->mb[0] = MBC_GET_FIRMWARE_VERSION; |
| 982 | mcp->out_mb = MBX_0; |
| 983 | 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] | 984 | if (IS_QLA81XX(vha->hw) || IS_QLA8031(ha) || IS_QLA8044(ha)) |
Andrew Vasquez | 55a9615 | 2009-03-24 09:08:03 -0700 | [diff] [blame] | 985 | 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] | 986 | if (IS_FWI2_CAPABLE(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 987 | mcp->in_mb |= MBX_17|MBX_16|MBX_15; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 988 | if (IS_QLA27XX(ha)) |
Joe Carnuccio | ad1ef17 | 2016-07-06 11:14:18 -0400 | [diff] [blame] | 989 | mcp->in_mb |= |
| 990 | MBX_25|MBX_24|MBX_23|MBX_22|MBX_21|MBX_20|MBX_19|MBX_18| |
| 991 | MBX_14|MBX_13|MBX_11|MBX_10|MBX_9|MBX_8; |
Sawan Chandak | 03aa868 | 2015-08-04 13:37:59 -0400 | [diff] [blame] | 992 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 993 | mcp->flags = 0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 994 | mcp->tov = MBX_TOV_SECONDS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 995 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 996 | if (rval != QLA_SUCCESS) |
| 997 | goto failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 998 | |
| 999 | /* Return mailbox data. */ |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1000 | ha->fw_major_version = mcp->mb[1]; |
| 1001 | ha->fw_minor_version = mcp->mb[2]; |
| 1002 | ha->fw_subminor_version = mcp->mb[3]; |
| 1003 | ha->fw_attributes = mcp->mb[6]; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1004 | if (IS_QLA2100(vha->hw) || IS_QLA2200(vha->hw)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1005 | ha->fw_memory_size = 0x1FFFF; /* Defaults to 128KB. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1006 | else |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1007 | ha->fw_memory_size = (mcp->mb[5] << 16) | mcp->mb[4]; |
Sawan Chandak | 03aa868 | 2015-08-04 13:37:59 -0400 | [diff] [blame] | 1008 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1009 | if (IS_QLA81XX(vha->hw) || IS_QLA8031(vha->hw) || IS_QLA8044(ha)) { |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1010 | ha->mpi_version[0] = mcp->mb[10] & 0xff; |
| 1011 | ha->mpi_version[1] = mcp->mb[11] >> 8; |
| 1012 | ha->mpi_version[2] = mcp->mb[11] & 0xff; |
| 1013 | ha->mpi_capabilities = (mcp->mb[12] << 16) | mcp->mb[13]; |
| 1014 | ha->phy_version[0] = mcp->mb[8] & 0xff; |
| 1015 | ha->phy_version[1] = mcp->mb[9] >> 8; |
| 1016 | ha->phy_version[2] = mcp->mb[9] & 0xff; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1017 | } |
Sawan Chandak | 03aa868 | 2015-08-04 13:37:59 -0400 | [diff] [blame] | 1018 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 1019 | if (IS_FWI2_CAPABLE(ha)) { |
| 1020 | ha->fw_attributes_h = mcp->mb[15]; |
| 1021 | ha->fw_attributes_ext[0] = mcp->mb[16]; |
| 1022 | ha->fw_attributes_ext[1] = mcp->mb[17]; |
| 1023 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1139, |
| 1024 | "%s: FW_attributes Upper: 0x%x, Lower: 0x%x.\n", |
| 1025 | __func__, mcp->mb[15], mcp->mb[6]); |
| 1026 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x112f, |
| 1027 | "%s: Ext_FwAttributes Upper: 0x%x, Lower: 0x%x.\n", |
| 1028 | __func__, mcp->mb[17], mcp->mb[16]); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 1029 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 1030 | if (ha->fw_attributes_h & 0x4) |
| 1031 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x118d, |
| 1032 | "%s: Firmware supports Extended Login 0x%x\n", |
| 1033 | __func__, ha->fw_attributes_h); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 1034 | |
| 1035 | if (ha->fw_attributes_h & 0x8) |
| 1036 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1191, |
| 1037 | "%s: Firmware supports Exchange Offload 0x%x\n", |
| 1038 | __func__, ha->fw_attributes_h); |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 1039 | |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 1040 | /* |
| 1041 | * FW supports nvme and driver load parameter requested nvme. |
| 1042 | * BIT 26 of fw_attributes indicates NVMe support. |
| 1043 | */ |
Darren Trapp | 1cbc0ef | 2018-03-20 23:09:37 -0700 | [diff] [blame] | 1044 | if ((ha->fw_attributes_h & 0x400) && ql2xnvmeenable) { |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 1045 | vha->flags.nvme_enabled = 1; |
Darren Trapp | 1cbc0ef | 2018-03-20 23:09:37 -0700 | [diff] [blame] | 1046 | ql_log(ql_log_info, vha, 0xd302, |
| 1047 | "%s: FC-NVMe is Enabled (0x%x)\n", |
| 1048 | __func__, ha->fw_attributes_h); |
| 1049 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1050 | } |
Sawan Chandak | 03aa868 | 2015-08-04 13:37:59 -0400 | [diff] [blame] | 1051 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 1052 | if (IS_QLA27XX(ha)) { |
Sawan Chandak | 03aa868 | 2015-08-04 13:37:59 -0400 | [diff] [blame] | 1053 | ha->mpi_version[0] = mcp->mb[10] & 0xff; |
| 1054 | ha->mpi_version[1] = mcp->mb[11] >> 8; |
| 1055 | ha->mpi_version[2] = mcp->mb[11] & 0xff; |
| 1056 | ha->pep_version[0] = mcp->mb[13] & 0xff; |
| 1057 | ha->pep_version[1] = mcp->mb[14] >> 8; |
| 1058 | ha->pep_version[2] = mcp->mb[14] & 0xff; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 1059 | ha->fw_shared_ram_start = (mcp->mb[19] << 16) | mcp->mb[18]; |
| 1060 | ha->fw_shared_ram_end = (mcp->mb[21] << 16) | mcp->mb[20]; |
Joe Carnuccio | ad1ef17 | 2016-07-06 11:14:18 -0400 | [diff] [blame] | 1061 | ha->fw_ddr_ram_start = (mcp->mb[23] << 16) | mcp->mb[22]; |
| 1062 | ha->fw_ddr_ram_end = (mcp->mb[25] << 16) | mcp->mb[24]; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 1063 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1064 | |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 1065 | failed: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1066 | if (rval != QLA_SUCCESS) { |
| 1067 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1068 | ql_dbg(ql_dbg_mbx, vha, 0x102a, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1069 | } else { |
| 1070 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1071 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102b, |
| 1072 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1073 | } |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 1074 | return rval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1075 | } |
| 1076 | |
| 1077 | /* |
| 1078 | * qla2x00_get_fw_options |
| 1079 | * Set firmware options. |
| 1080 | * |
| 1081 | * Input: |
| 1082 | * ha = adapter block pointer. |
| 1083 | * fwopt = pointer for firmware options. |
| 1084 | * |
| 1085 | * Returns: |
| 1086 | * qla2x00 local function return status code. |
| 1087 | * |
| 1088 | * Context: |
| 1089 | * Kernel context. |
| 1090 | */ |
| 1091 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1092 | qla2x00_get_fw_options(scsi_qla_host_t *vha, uint16_t *fwopts) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1093 | { |
| 1094 | int rval; |
| 1095 | mbx_cmd_t mc; |
| 1096 | mbx_cmd_t *mcp = &mc; |
| 1097 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1098 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102c, |
| 1099 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1100 | |
| 1101 | mcp->mb[0] = MBC_GET_FIRMWARE_OPTION; |
| 1102 | mcp->out_mb = MBX_0; |
| 1103 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1104 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1105 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1106 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1107 | |
| 1108 | if (rval != QLA_SUCCESS) { |
| 1109 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1110 | ql_dbg(ql_dbg_mbx, vha, 0x102d, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1111 | } else { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1112 | fwopts[0] = mcp->mb[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1113 | fwopts[1] = mcp->mb[1]; |
| 1114 | fwopts[2] = mcp->mb[2]; |
| 1115 | fwopts[3] = mcp->mb[3]; |
| 1116 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1117 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102e, |
| 1118 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1119 | } |
| 1120 | |
| 1121 | return rval; |
| 1122 | } |
| 1123 | |
| 1124 | |
| 1125 | /* |
| 1126 | * qla2x00_set_fw_options |
| 1127 | * Set firmware options. |
| 1128 | * |
| 1129 | * Input: |
| 1130 | * ha = adapter block pointer. |
| 1131 | * fwopt = pointer for firmware options. |
| 1132 | * |
| 1133 | * Returns: |
| 1134 | * qla2x00 local function return status code. |
| 1135 | * |
| 1136 | * Context: |
| 1137 | * Kernel context. |
| 1138 | */ |
| 1139 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1140 | qla2x00_set_fw_options(scsi_qla_host_t *vha, uint16_t *fwopts) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1141 | { |
| 1142 | int rval; |
| 1143 | mbx_cmd_t mc; |
| 1144 | mbx_cmd_t *mcp = &mc; |
| 1145 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1146 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102f, |
| 1147 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1148 | |
| 1149 | mcp->mb[0] = MBC_SET_FIRMWARE_OPTION; |
| 1150 | mcp->mb[1] = fwopts[1]; |
| 1151 | mcp->mb[2] = fwopts[2]; |
| 1152 | mcp->mb[3] = fwopts[3]; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1153 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1154 | mcp->in_mb = MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1155 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1156 | mcp->in_mb |= MBX_1; |
Quinn Tran | 2da5273 | 2017-06-02 09:12:05 -0700 | [diff] [blame] | 1157 | mcp->mb[10] = fwopts[10]; |
| 1158 | mcp->out_mb |= MBX_10; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1159 | } else { |
| 1160 | mcp->mb[10] = fwopts[10]; |
| 1161 | mcp->mb[11] = fwopts[11]; |
| 1162 | mcp->mb[12] = 0; /* Undocumented, but used */ |
| 1163 | mcp->out_mb |= MBX_12|MBX_11|MBX_10; |
| 1164 | } |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1165 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1166 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1167 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1168 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1169 | fwopts[0] = mcp->mb[0]; |
| 1170 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1171 | if (rval != QLA_SUCCESS) { |
| 1172 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1173 | ql_dbg(ql_dbg_mbx, vha, 0x1030, |
| 1174 | "Failed=%x (%x/%x).\n", rval, mcp->mb[0], mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1175 | } else { |
| 1176 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1177 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1031, |
| 1178 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1179 | } |
| 1180 | |
| 1181 | return rval; |
| 1182 | } |
| 1183 | |
| 1184 | /* |
| 1185 | * qla2x00_mbx_reg_test |
| 1186 | * Mailbox register wrap test. |
| 1187 | * |
| 1188 | * Input: |
| 1189 | * ha = adapter block pointer. |
| 1190 | * TARGET_QUEUE_LOCK must be released. |
| 1191 | * ADAPTER_STATE_LOCK must be released. |
| 1192 | * |
| 1193 | * Returns: |
| 1194 | * qla2x00 local function return status code. |
| 1195 | * |
| 1196 | * Context: |
| 1197 | * Kernel context. |
| 1198 | */ |
| 1199 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1200 | qla2x00_mbx_reg_test(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1201 | { |
| 1202 | int rval; |
| 1203 | mbx_cmd_t mc; |
| 1204 | mbx_cmd_t *mcp = &mc; |
| 1205 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1206 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1032, |
| 1207 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1208 | |
| 1209 | mcp->mb[0] = MBC_MAILBOX_REGISTER_TEST; |
| 1210 | mcp->mb[1] = 0xAAAA; |
| 1211 | mcp->mb[2] = 0x5555; |
| 1212 | mcp->mb[3] = 0xAA55; |
| 1213 | mcp->mb[4] = 0x55AA; |
| 1214 | mcp->mb[5] = 0xA5A5; |
| 1215 | mcp->mb[6] = 0x5A5A; |
| 1216 | mcp->mb[7] = 0x2525; |
| 1217 | mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 1218 | 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] | 1219 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1220 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1221 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1222 | |
| 1223 | if (rval == QLA_SUCCESS) { |
| 1224 | if (mcp->mb[1] != 0xAAAA || mcp->mb[2] != 0x5555 || |
| 1225 | mcp->mb[3] != 0xAA55 || mcp->mb[4] != 0x55AA) |
| 1226 | rval = QLA_FUNCTION_FAILED; |
| 1227 | if (mcp->mb[5] != 0xA5A5 || mcp->mb[6] != 0x5A5A || |
| 1228 | mcp->mb[7] != 0x2525) |
| 1229 | rval = QLA_FUNCTION_FAILED; |
| 1230 | } |
| 1231 | |
| 1232 | if (rval != QLA_SUCCESS) { |
| 1233 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1234 | ql_dbg(ql_dbg_mbx, vha, 0x1033, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1235 | } else { |
| 1236 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1237 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1034, |
| 1238 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1239 | } |
| 1240 | |
| 1241 | return rval; |
| 1242 | } |
| 1243 | |
| 1244 | /* |
| 1245 | * qla2x00_verify_checksum |
| 1246 | * Verify firmware checksum. |
| 1247 | * |
| 1248 | * Input: |
| 1249 | * ha = adapter block pointer. |
| 1250 | * TARGET_QUEUE_LOCK must be released. |
| 1251 | * ADAPTER_STATE_LOCK must be released. |
| 1252 | * |
| 1253 | * Returns: |
| 1254 | * qla2x00 local function return status code. |
| 1255 | * |
| 1256 | * Context: |
| 1257 | * Kernel context. |
| 1258 | */ |
| 1259 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1260 | qla2x00_verify_checksum(scsi_qla_host_t *vha, uint32_t risc_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1261 | { |
| 1262 | int rval; |
| 1263 | mbx_cmd_t mc; |
| 1264 | mbx_cmd_t *mcp = &mc; |
| 1265 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1266 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1035, |
| 1267 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1268 | |
| 1269 | mcp->mb[0] = MBC_VERIFY_CHECKSUM; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1270 | mcp->out_mb = MBX_0; |
| 1271 | mcp->in_mb = MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1272 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1273 | mcp->mb[1] = MSW(risc_addr); |
| 1274 | mcp->mb[2] = LSW(risc_addr); |
| 1275 | mcp->out_mb |= MBX_2|MBX_1; |
| 1276 | mcp->in_mb |= MBX_2|MBX_1; |
| 1277 | } else { |
| 1278 | mcp->mb[1] = LSW(risc_addr); |
| 1279 | mcp->out_mb |= MBX_1; |
| 1280 | mcp->in_mb |= MBX_1; |
| 1281 | } |
| 1282 | |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1283 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1284 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1285 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1286 | |
| 1287 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1288 | ql_dbg(ql_dbg_mbx, vha, 0x1036, |
| 1289 | "Failed=%x chm sum=%x.\n", rval, IS_FWI2_CAPABLE(vha->hw) ? |
| 1290 | (mcp->mb[2] << 16) | mcp->mb[1] : mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1291 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1292 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1037, |
| 1293 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1294 | } |
| 1295 | |
| 1296 | return rval; |
| 1297 | } |
| 1298 | |
| 1299 | /* |
| 1300 | * qla2x00_issue_iocb |
| 1301 | * Issue IOCB using mailbox command |
| 1302 | * |
| 1303 | * Input: |
| 1304 | * ha = adapter state pointer. |
| 1305 | * buffer = buffer pointer. |
| 1306 | * phys_addr = physical address of buffer. |
| 1307 | * size = size of buffer. |
| 1308 | * TARGET_QUEUE_LOCK must be released. |
| 1309 | * ADAPTER_STATE_LOCK must be released. |
| 1310 | * |
| 1311 | * Returns: |
| 1312 | * qla2x00 local function return status code. |
| 1313 | * |
| 1314 | * Context: |
| 1315 | * Kernel context. |
| 1316 | */ |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 1317 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1318 | qla2x00_issue_iocb_timeout(scsi_qla_host_t *vha, void *buffer, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1319 | dma_addr_t phys_addr, size_t size, uint32_t tov) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1320 | { |
| 1321 | int rval; |
| 1322 | mbx_cmd_t mc; |
| 1323 | mbx_cmd_t *mcp = &mc; |
| 1324 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1325 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1038, |
| 1326 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1327 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1328 | mcp->mb[0] = MBC_IOCB_COMMAND_A64; |
| 1329 | mcp->mb[1] = 0; |
| 1330 | mcp->mb[2] = MSW(phys_addr); |
| 1331 | mcp->mb[3] = LSW(phys_addr); |
| 1332 | mcp->mb[6] = MSW(MSD(phys_addr)); |
| 1333 | mcp->mb[7] = LSW(MSD(phys_addr)); |
| 1334 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 1335 | mcp->in_mb = MBX_2|MBX_0; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1336 | mcp->tov = tov; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1337 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1338 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1339 | |
| 1340 | if (rval != QLA_SUCCESS) { |
| 1341 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1342 | ql_dbg(ql_dbg_mbx, vha, 0x1039, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1343 | } else { |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 1344 | sts_entry_t *sts_entry = (sts_entry_t *) buffer; |
| 1345 | |
| 1346 | /* Mask reserved bits. */ |
| 1347 | sts_entry->entry_status &= |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1348 | IS_FWI2_CAPABLE(vha->hw) ? RF_MASK_24XX : RF_MASK; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1349 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103a, |
| 1350 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1351 | } |
| 1352 | |
| 1353 | return rval; |
| 1354 | } |
| 1355 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1356 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1357 | 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] | 1358 | size_t size) |
| 1359 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1360 | return qla2x00_issue_iocb_timeout(vha, buffer, phys_addr, size, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1361 | MBX_TOV_SECONDS); |
| 1362 | } |
| 1363 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1364 | /* |
| 1365 | * qla2x00_abort_command |
| 1366 | * Abort command aborts a specified IOCB. |
| 1367 | * |
| 1368 | * Input: |
| 1369 | * ha = adapter block pointer. |
| 1370 | * sp = SB structure pointer. |
| 1371 | * |
| 1372 | * Returns: |
| 1373 | * qla2x00 local function return status code. |
| 1374 | * |
| 1375 | * Context: |
| 1376 | * Kernel context. |
| 1377 | */ |
| 1378 | int |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1379 | qla2x00_abort_command(srb_t *sp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1380 | { |
| 1381 | unsigned long flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1382 | int rval; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1383 | uint32_t handle = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1384 | mbx_cmd_t mc; |
| 1385 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1386 | fc_port_t *fcport = sp->fcport; |
| 1387 | scsi_qla_host_t *vha = fcport->vha; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1388 | struct qla_hw_data *ha = vha->hw; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1389 | struct req_que *req; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1390 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1391 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1392 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103b, |
| 1393 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1394 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1395 | if (vha->flags.qpairs_available && sp->qpair) |
| 1396 | req = sp->qpair->req; |
| 1397 | else |
| 1398 | req = vha->req; |
| 1399 | |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 1400 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1401 | for (handle = 1; handle < req->num_outstanding_cmds; handle++) { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1402 | if (req->outstanding_cmds[handle] == sp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1403 | break; |
| 1404 | } |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 1405 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1406 | |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1407 | if (handle == req->num_outstanding_cmds) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1408 | /* command not found */ |
| 1409 | return QLA_FUNCTION_FAILED; |
| 1410 | } |
| 1411 | |
| 1412 | mcp->mb[0] = MBC_ABORT_COMMAND; |
| 1413 | if (HAS_EXTENDED_IDS(ha)) |
| 1414 | mcp->mb[1] = fcport->loop_id; |
| 1415 | else |
| 1416 | mcp->mb[1] = fcport->loop_id << 8; |
| 1417 | mcp->mb[2] = (uint16_t)handle; |
| 1418 | mcp->mb[3] = (uint16_t)(handle >> 16); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1419 | mcp->mb[6] = (uint16_t)cmd->device->lun; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1420 | mcp->out_mb = MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 1421 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1422 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1423 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1424 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1425 | |
| 1426 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1427 | ql_dbg(ql_dbg_mbx, vha, 0x103c, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1428 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1429 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103d, |
| 1430 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1431 | } |
| 1432 | |
| 1433 | return rval; |
| 1434 | } |
| 1435 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1436 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1437 | qla2x00_abort_target(struct fc_port *fcport, uint64_t l, int tag) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1438 | { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1439 | int rval, rval2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1440 | mbx_cmd_t mc; |
| 1441 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1442 | scsi_qla_host_t *vha; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1443 | struct req_que *req; |
| 1444 | struct rsp_que *rsp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1445 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1446 | l = l; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1447 | vha = fcport->vha; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1448 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1449 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103e, |
| 1450 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1451 | |
Giridhar Malavali | 7e2b895 | 2010-05-28 15:08:17 -0700 | [diff] [blame] | 1452 | req = vha->hw->req_q_map[0]; |
| 1453 | rsp = req->rsp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1454 | mcp->mb[0] = MBC_ABORT_TARGET; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1455 | mcp->out_mb = MBX_9|MBX_2|MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1456 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1457 | mcp->mb[1] = fcport->loop_id; |
| 1458 | mcp->mb[10] = 0; |
| 1459 | mcp->out_mb |= MBX_10; |
| 1460 | } else { |
| 1461 | mcp->mb[1] = fcport->loop_id << 8; |
| 1462 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1463 | mcp->mb[2] = vha->hw->loop_reset_delay; |
| 1464 | mcp->mb[9] = vha->vp_idx; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1465 | |
| 1466 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1467 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1468 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1469 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1470 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1471 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103f, |
| 1472 | "Failed=%x.\n", rval); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1473 | } |
| 1474 | |
| 1475 | /* Issue marker IOCB. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1476 | rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, 0, |
| 1477 | MK_SYNC_ID); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1478 | if (rval2 != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1479 | ql_dbg(ql_dbg_mbx, vha, 0x1040, |
| 1480 | "Failed to issue marker IOCB (%x).\n", rval2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1481 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1482 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1041, |
| 1483 | "Done %s.\n", __func__); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1484 | } |
| 1485 | |
| 1486 | return rval; |
| 1487 | } |
| 1488 | |
| 1489 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1490 | qla2x00_lun_reset(struct fc_port *fcport, uint64_t l, int tag) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1491 | { |
| 1492 | int rval, rval2; |
| 1493 | mbx_cmd_t mc; |
| 1494 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1495 | scsi_qla_host_t *vha; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1496 | struct req_que *req; |
| 1497 | struct rsp_que *rsp; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1498 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1499 | vha = fcport->vha; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1500 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1501 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1042, |
| 1502 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1503 | |
Giridhar Malavali | 7e2b895 | 2010-05-28 15:08:17 -0700 | [diff] [blame] | 1504 | req = vha->hw->req_q_map[0]; |
| 1505 | rsp = req->rsp; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1506 | mcp->mb[0] = MBC_LUN_RESET; |
| 1507 | 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] | 1508 | if (HAS_EXTENDED_IDS(vha->hw)) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1509 | mcp->mb[1] = fcport->loop_id; |
| 1510 | else |
| 1511 | mcp->mb[1] = fcport->loop_id << 8; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1512 | mcp->mb[2] = (u32)l; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1513 | mcp->mb[3] = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1514 | mcp->mb[9] = vha->vp_idx; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1515 | |
| 1516 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1517 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1518 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1519 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1520 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1521 | ql_dbg(ql_dbg_mbx, vha, 0x1043, "Failed=%x.\n", rval); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1522 | } |
| 1523 | |
| 1524 | /* Issue marker IOCB. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1525 | rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, l, |
| 1526 | MK_SYNC_ID_LUN); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1527 | if (rval2 != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1528 | ql_dbg(ql_dbg_mbx, vha, 0x1044, |
| 1529 | "Failed to issue marker IOCB (%x).\n", rval2); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1530 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1531 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1045, |
| 1532 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1533 | } |
| 1534 | |
| 1535 | return rval; |
| 1536 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1537 | |
| 1538 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1539 | * qla2x00_get_adapter_id |
| 1540 | * Get adapter ID and topology. |
| 1541 | * |
| 1542 | * Input: |
| 1543 | * ha = adapter block pointer. |
| 1544 | * id = pointer for loop ID. |
| 1545 | * al_pa = pointer for AL_PA. |
| 1546 | * area = pointer for area. |
| 1547 | * domain = pointer for domain. |
| 1548 | * top = pointer for topology. |
| 1549 | * TARGET_QUEUE_LOCK must be released. |
| 1550 | * ADAPTER_STATE_LOCK must be released. |
| 1551 | * |
| 1552 | * Returns: |
| 1553 | * qla2x00 local function return status code. |
| 1554 | * |
| 1555 | * Context: |
| 1556 | * Kernel context. |
| 1557 | */ |
| 1558 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1559 | 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] | 1560 | 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] | 1561 | { |
| 1562 | int rval; |
| 1563 | mbx_cmd_t mc; |
| 1564 | mbx_cmd_t *mcp = &mc; |
| 1565 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1566 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1046, |
| 1567 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1568 | |
| 1569 | mcp->mb[0] = MBC_GET_ADAPTER_LOOP_ID; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1570 | mcp->mb[9] = vha->vp_idx; |
Andrew Vasquez | eb66dc6 | 2007-11-12 10:30:58 -0800 | [diff] [blame] | 1571 | mcp->out_mb = MBX_9|MBX_0; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1572 | 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] | 1573 | if (IS_CNA_CAPABLE(vha->hw)) |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1574 | mcp->in_mb |= MBX_13|MBX_12|MBX_11|MBX_10; |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 1575 | if (IS_FWI2_CAPABLE(vha->hw)) |
| 1576 | mcp->in_mb |= MBX_19|MBX_18|MBX_17|MBX_16; |
Sawan Chandak | 969a619 | 2016-01-27 12:03:32 -0500 | [diff] [blame] | 1577 | if (IS_QLA27XX(vha->hw)) |
| 1578 | mcp->in_mb |= MBX_15; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1579 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1580 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1581 | rval = qla2x00_mailbox_command(vha, mcp); |
Ravi Anand | 33135aa | 2005-11-08 14:37:20 -0800 | [diff] [blame] | 1582 | if (mcp->mb[0] == MBS_COMMAND_ERROR) |
| 1583 | rval = QLA_COMMAND_ERROR; |
Andrew Vasquez | 42e421b | 2008-07-10 16:56:01 -0700 | [diff] [blame] | 1584 | else if (mcp->mb[0] == MBS_INVALID_COMMAND) |
| 1585 | rval = QLA_INVALID_COMMAND; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1586 | |
| 1587 | /* Return data. */ |
| 1588 | *id = mcp->mb[1]; |
| 1589 | *al_pa = LSB(mcp->mb[2]); |
| 1590 | *area = MSB(mcp->mb[2]); |
| 1591 | *domain = LSB(mcp->mb[3]); |
| 1592 | *top = mcp->mb[6]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1593 | *sw_cap = mcp->mb[7]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1594 | |
| 1595 | if (rval != QLA_SUCCESS) { |
| 1596 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1597 | ql_dbg(ql_dbg_mbx, vha, 0x1047, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1598 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1599 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1048, |
| 1600 | "Done %s.\n", __func__); |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1601 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1602 | if (IS_CNA_CAPABLE(vha->hw)) { |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1603 | vha->fcoe_vlan_id = mcp->mb[9] & 0xfff; |
| 1604 | vha->fcoe_fcf_idx = mcp->mb[10]; |
| 1605 | vha->fcoe_vn_port_mac[5] = mcp->mb[11] >> 8; |
| 1606 | vha->fcoe_vn_port_mac[4] = mcp->mb[11] & 0xff; |
| 1607 | vha->fcoe_vn_port_mac[3] = mcp->mb[12] >> 8; |
| 1608 | vha->fcoe_vn_port_mac[2] = mcp->mb[12] & 0xff; |
| 1609 | vha->fcoe_vn_port_mac[1] = mcp->mb[13] >> 8; |
| 1610 | vha->fcoe_vn_port_mac[0] = mcp->mb[13] & 0xff; |
| 1611 | } |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 1612 | /* If FA-WWN supported */ |
Saurav Kashyap | d6b9b42 | 2015-08-04 13:37:55 -0400 | [diff] [blame] | 1613 | if (IS_FAWWN_CAPABLE(vha->hw)) { |
| 1614 | if (mcp->mb[7] & BIT_14) { |
| 1615 | vha->port_name[0] = MSB(mcp->mb[16]); |
| 1616 | vha->port_name[1] = LSB(mcp->mb[16]); |
| 1617 | vha->port_name[2] = MSB(mcp->mb[17]); |
| 1618 | vha->port_name[3] = LSB(mcp->mb[17]); |
| 1619 | vha->port_name[4] = MSB(mcp->mb[18]); |
| 1620 | vha->port_name[5] = LSB(mcp->mb[18]); |
| 1621 | vha->port_name[6] = MSB(mcp->mb[19]); |
| 1622 | vha->port_name[7] = LSB(mcp->mb[19]); |
| 1623 | fc_host_port_name(vha->host) = |
| 1624 | wwn_to_u64(vha->port_name); |
| 1625 | ql_dbg(ql_dbg_mbx, vha, 0x10ca, |
| 1626 | "FA-WWN acquired %016llx\n", |
| 1627 | wwn_to_u64(vha->port_name)); |
| 1628 | } |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 1629 | } |
Sawan Chandak | 969a619 | 2016-01-27 12:03:32 -0500 | [diff] [blame] | 1630 | |
| 1631 | if (IS_QLA27XX(vha->hw)) |
| 1632 | vha->bbcr = mcp->mb[15]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1633 | } |
| 1634 | |
| 1635 | return rval; |
| 1636 | } |
| 1637 | |
| 1638 | /* |
| 1639 | * qla2x00_get_retry_cnt |
| 1640 | * Get current firmware login retry count and delay. |
| 1641 | * |
| 1642 | * Input: |
| 1643 | * ha = adapter block pointer. |
| 1644 | * retry_cnt = pointer to login retry count. |
| 1645 | * tov = pointer to login timeout value. |
| 1646 | * |
| 1647 | * Returns: |
| 1648 | * qla2x00 local function return status code. |
| 1649 | * |
| 1650 | * Context: |
| 1651 | * Kernel context. |
| 1652 | */ |
| 1653 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1654 | 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] | 1655 | uint16_t *r_a_tov) |
| 1656 | { |
| 1657 | int rval; |
| 1658 | uint16_t ratov; |
| 1659 | mbx_cmd_t mc; |
| 1660 | mbx_cmd_t *mcp = &mc; |
| 1661 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1662 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1049, |
| 1663 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1664 | |
| 1665 | mcp->mb[0] = MBC_GET_RETRY_COUNT; |
| 1666 | mcp->out_mb = MBX_0; |
| 1667 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1668 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1669 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1670 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1671 | |
| 1672 | if (rval != QLA_SUCCESS) { |
| 1673 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1674 | ql_dbg(ql_dbg_mbx, vha, 0x104a, |
| 1675 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1676 | } else { |
| 1677 | /* Convert returned data and check our values. */ |
| 1678 | *r_a_tov = mcp->mb[3] / 2; |
| 1679 | ratov = (mcp->mb[3]/2) / 10; /* mb[3] value is in 100ms */ |
| 1680 | if (mcp->mb[1] * ratov > (*retry_cnt) * (*tov)) { |
| 1681 | /* Update to the larger values */ |
| 1682 | *retry_cnt = (uint8_t)mcp->mb[1]; |
| 1683 | *tov = ratov; |
| 1684 | } |
| 1685 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1686 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104b, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1687 | "Done %s mb3=%d ratov=%d.\n", __func__, mcp->mb[3], ratov); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1688 | } |
| 1689 | |
| 1690 | return rval; |
| 1691 | } |
| 1692 | |
| 1693 | /* |
| 1694 | * qla2x00_init_firmware |
| 1695 | * Initialize adapter firmware. |
| 1696 | * |
| 1697 | * Input: |
| 1698 | * ha = adapter block pointer. |
| 1699 | * dptr = Initialization control block pointer. |
| 1700 | * size = size of initialization control block. |
| 1701 | * TARGET_QUEUE_LOCK must be released. |
| 1702 | * ADAPTER_STATE_LOCK must be released. |
| 1703 | * |
| 1704 | * Returns: |
| 1705 | * qla2x00 local function return status code. |
| 1706 | * |
| 1707 | * Context: |
| 1708 | * Kernel context. |
| 1709 | */ |
| 1710 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1711 | qla2x00_init_firmware(scsi_qla_host_t *vha, uint16_t size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1712 | { |
| 1713 | int rval; |
| 1714 | mbx_cmd_t mc; |
| 1715 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1716 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1717 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1718 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104c, |
| 1719 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1720 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1721 | if (IS_P3P_TYPE(ha) && ql2xdbwr) |
Bart Van Assche | 8dfa4b5a | 2015-07-09 07:24:50 -0700 | [diff] [blame] | 1722 | qla82xx_wr_32(ha, (uintptr_t __force)ha->nxdb_wr_ptr, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1723 | (0x04 | (ha->portnum << 5) | (0 << 8) | (0 << 16))); |
| 1724 | |
Andrew Vasquez | e6e074f | 2008-01-31 12:33:53 -0800 | [diff] [blame] | 1725 | if (ha->flags.npiv_supported) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1726 | mcp->mb[0] = MBC_MID_INITIALIZE_FIRMWARE; |
| 1727 | else |
| 1728 | mcp->mb[0] = MBC_INITIALIZE_FIRMWARE; |
| 1729 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 1730 | mcp->mb[1] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1731 | mcp->mb[2] = MSW(ha->init_cb_dma); |
| 1732 | mcp->mb[3] = LSW(ha->init_cb_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1733 | mcp->mb[6] = MSW(MSD(ha->init_cb_dma)); |
| 1734 | mcp->mb[7] = LSW(MSD(ha->init_cb_dma)); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 1735 | 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] | 1736 | if (ha->ex_init_cb && ha->ex_init_cb->ex_version) { |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 1737 | mcp->mb[1] = BIT_0; |
| 1738 | mcp->mb[10] = MSW(ha->ex_init_cb_dma); |
| 1739 | mcp->mb[11] = LSW(ha->ex_init_cb_dma); |
| 1740 | mcp->mb[12] = MSW(MSD(ha->ex_init_cb_dma)); |
| 1741 | mcp->mb[13] = LSW(MSD(ha->ex_init_cb_dma)); |
| 1742 | mcp->mb[14] = sizeof(*ha->ex_init_cb); |
| 1743 | mcp->out_mb |= MBX_14|MBX_13|MBX_12|MBX_11|MBX_10; |
| 1744 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1745 | /* 1 and 2 should normally be captured. */ |
| 1746 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 1747 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1748 | /* mb3 is additional info about the installed SFP. */ |
| 1749 | mcp->in_mb |= MBX_3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1750 | mcp->buf_size = size; |
| 1751 | mcp->flags = MBX_DMA_OUT; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1752 | mcp->tov = MBX_TOV_SECONDS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1753 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1754 | |
| 1755 | if (rval != QLA_SUCCESS) { |
| 1756 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1757 | ql_dbg(ql_dbg_mbx, vha, 0x104d, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1758 | "Failed=%x mb[0]=%x, mb[1]=%x, mb[2]=%x, mb[3]=%x,.\n", |
| 1759 | 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] | 1760 | } else { |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 1761 | if (IS_QLA27XX(ha)) { |
| 1762 | if (mcp->mb[2] == 6 || mcp->mb[3] == 2) |
| 1763 | ql_dbg(ql_dbg_mbx, vha, 0x119d, |
| 1764 | "Invalid SFP/Validation Failed\n"); |
| 1765 | } |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1766 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104e, |
| 1767 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1768 | } |
| 1769 | |
| 1770 | return rval; |
| 1771 | } |
| 1772 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 1773 | |
| 1774 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1775 | * qla2x00_get_port_database |
| 1776 | * Issue normal/enhanced get port database mailbox command |
| 1777 | * and copy device name as necessary. |
| 1778 | * |
| 1779 | * Input: |
| 1780 | * ha = adapter state pointer. |
| 1781 | * dev = structure pointer. |
| 1782 | * opt = enhanced cmd option byte. |
| 1783 | * |
| 1784 | * Returns: |
| 1785 | * qla2x00 local function return status code. |
| 1786 | * |
| 1787 | * Context: |
| 1788 | * Kernel context. |
| 1789 | */ |
| 1790 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1791 | 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] | 1792 | { |
| 1793 | int rval; |
| 1794 | mbx_cmd_t mc; |
| 1795 | mbx_cmd_t *mcp = &mc; |
| 1796 | port_database_t *pd; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1797 | struct port_database_24xx *pd24; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1798 | dma_addr_t pd_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1799 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1800 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1801 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104f, |
| 1802 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1803 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1804 | pd24 = NULL; |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 1805 | pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1806 | if (pd == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1807 | ql_log(ql_log_warn, vha, 0x1050, |
| 1808 | "Failed to allocate port database structure.\n"); |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 1809 | fcport->query = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1810 | return QLA_MEMORY_ALLOC_FAILED; |
| 1811 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1812 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1813 | mcp->mb[0] = MBC_GET_PORT_DATABASE; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1814 | if (opt != 0 && !IS_FWI2_CAPABLE(ha)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1815 | mcp->mb[0] = MBC_ENHANCED_GET_PORT_DATABASE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1816 | mcp->mb[2] = MSW(pd_dma); |
| 1817 | mcp->mb[3] = LSW(pd_dma); |
| 1818 | mcp->mb[6] = MSW(MSD(pd_dma)); |
| 1819 | mcp->mb[7] = LSW(MSD(pd_dma)); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1820 | mcp->mb[9] = vha->vp_idx; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1821 | 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] | 1822 | mcp->in_mb = MBX_0; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1823 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1824 | mcp->mb[1] = fcport->loop_id; |
| 1825 | mcp->mb[10] = opt; |
| 1826 | mcp->out_mb |= MBX_10|MBX_1; |
| 1827 | mcp->in_mb |= MBX_1; |
| 1828 | } else if (HAS_EXTENDED_IDS(ha)) { |
| 1829 | mcp->mb[1] = fcport->loop_id; |
| 1830 | mcp->mb[10] = opt; |
| 1831 | mcp->out_mb |= MBX_10|MBX_1; |
| 1832 | } else { |
| 1833 | mcp->mb[1] = fcport->loop_id << 8 | opt; |
| 1834 | mcp->out_mb |= MBX_1; |
| 1835 | } |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1836 | mcp->buf_size = IS_FWI2_CAPABLE(ha) ? |
| 1837 | PORT_DATABASE_24XX_SIZE : PORT_DATABASE_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1838 | mcp->flags = MBX_DMA_IN; |
| 1839 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1840 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1841 | if (rval != QLA_SUCCESS) |
| 1842 | goto gpd_error_out; |
| 1843 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1844 | if (IS_FWI2_CAPABLE(ha)) { |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1845 | uint64_t zero = 0; |
Duane Grigsby | c0c462c | 2017-10-13 09:34:05 -0700 | [diff] [blame] | 1846 | u8 current_login_state, last_login_state; |
| 1847 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1848 | pd24 = (struct port_database_24xx *) pd; |
| 1849 | |
| 1850 | /* Check for logged in state. */ |
Duane Grigsby | c0c462c | 2017-10-13 09:34:05 -0700 | [diff] [blame] | 1851 | if (fcport->fc4f_nvme) { |
| 1852 | current_login_state = pd24->current_login_state >> 4; |
| 1853 | last_login_state = pd24->last_login_state >> 4; |
| 1854 | } else { |
| 1855 | current_login_state = pd24->current_login_state & 0xf; |
| 1856 | last_login_state = pd24->last_login_state & 0xf; |
| 1857 | } |
| 1858 | fcport->current_login_state = pd24->current_login_state; |
| 1859 | fcport->last_login_state = pd24->last_login_state; |
| 1860 | |
| 1861 | /* Check for logged in state. */ |
| 1862 | if (current_login_state != PDS_PRLI_COMPLETE && |
| 1863 | last_login_state != PDS_PRLI_COMPLETE) { |
| 1864 | ql_dbg(ql_dbg_mbx, vha, 0x119a, |
| 1865 | "Unable to verify login-state (%x/%x) for loop_id %x.\n", |
| 1866 | current_login_state, last_login_state, |
| 1867 | fcport->loop_id); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1868 | rval = QLA_FUNCTION_FAILED; |
Duane Grigsby | c0c462c | 2017-10-13 09:34:05 -0700 | [diff] [blame] | 1869 | |
| 1870 | if (!fcport->query) |
| 1871 | goto gpd_error_out; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1872 | } |
| 1873 | |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1874 | if (fcport->loop_id == FC_NO_LOOP_ID || |
| 1875 | (memcmp(fcport->port_name, (uint8_t *)&zero, 8) && |
| 1876 | memcmp(fcport->port_name, pd24->port_name, 8))) { |
| 1877 | /* We lost the device mid way. */ |
| 1878 | rval = QLA_NOT_LOGGED_IN; |
| 1879 | goto gpd_error_out; |
| 1880 | } |
| 1881 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1882 | /* Names are little-endian. */ |
| 1883 | memcpy(fcport->node_name, pd24->node_name, WWN_SIZE); |
| 1884 | memcpy(fcport->port_name, pd24->port_name, WWN_SIZE); |
| 1885 | |
| 1886 | /* Get port_id of device. */ |
| 1887 | fcport->d_id.b.domain = pd24->port_id[0]; |
| 1888 | fcport->d_id.b.area = pd24->port_id[1]; |
| 1889 | fcport->d_id.b.al_pa = pd24->port_id[2]; |
| 1890 | fcport->d_id.b.rsvd_1 = 0; |
| 1891 | |
| 1892 | /* If not target must be initiator or unknown type. */ |
| 1893 | if ((pd24->prli_svc_param_word_3[0] & BIT_4) == 0) |
| 1894 | fcport->port_type = FCT_INITIATOR; |
| 1895 | else |
| 1896 | fcport->port_type = FCT_TARGET; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 1897 | |
| 1898 | /* Passback COS information. */ |
| 1899 | fcport->supported_classes = (pd24->flags & PDF_CLASS_2) ? |
| 1900 | FC_COS_CLASS2 : FC_COS_CLASS3; |
| 1901 | |
| 1902 | if (pd24->prli_svc_param_word_3[0] & BIT_7) |
| 1903 | fcport->flags |= FCF_CONF_COMP_SUPPORTED; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1904 | } else { |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1905 | uint64_t zero = 0; |
| 1906 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1907 | /* Check for logged in state. */ |
| 1908 | if (pd->master_state != PD_STATE_PORT_LOGGED_IN && |
| 1909 | pd->slave_state != PD_STATE_PORT_LOGGED_IN) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1910 | ql_dbg(ql_dbg_mbx, vha, 0x100a, |
| 1911 | "Unable to verify login-state (%x/%x) - " |
| 1912 | "portid=%02x%02x%02x.\n", pd->master_state, |
| 1913 | pd->slave_state, fcport->d_id.b.domain, |
| 1914 | fcport->d_id.b.area, fcport->d_id.b.al_pa); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1915 | rval = QLA_FUNCTION_FAILED; |
| 1916 | goto gpd_error_out; |
| 1917 | } |
| 1918 | |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1919 | if (fcport->loop_id == FC_NO_LOOP_ID || |
| 1920 | (memcmp(fcport->port_name, (uint8_t *)&zero, 8) && |
| 1921 | memcmp(fcport->port_name, pd->port_name, 8))) { |
| 1922 | /* We lost the device mid way. */ |
| 1923 | rval = QLA_NOT_LOGGED_IN; |
| 1924 | goto gpd_error_out; |
| 1925 | } |
| 1926 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1927 | /* Names are little-endian. */ |
| 1928 | memcpy(fcport->node_name, pd->node_name, WWN_SIZE); |
| 1929 | memcpy(fcport->port_name, pd->port_name, WWN_SIZE); |
| 1930 | |
| 1931 | /* Get port_id of device. */ |
| 1932 | fcport->d_id.b.domain = pd->port_id[0]; |
| 1933 | fcport->d_id.b.area = pd->port_id[3]; |
| 1934 | fcport->d_id.b.al_pa = pd->port_id[2]; |
| 1935 | fcport->d_id.b.rsvd_1 = 0; |
| 1936 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1937 | /* If not target must be initiator or unknown type. */ |
| 1938 | if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0) |
| 1939 | fcport->port_type = FCT_INITIATOR; |
| 1940 | else |
| 1941 | fcport->port_type = FCT_TARGET; |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 1942 | |
| 1943 | /* Passback COS information. */ |
| 1944 | fcport->supported_classes = (pd->options & BIT_4) ? |
| 1945 | FC_COS_CLASS2: FC_COS_CLASS3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1946 | } |
| 1947 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1948 | gpd_error_out: |
| 1949 | dma_pool_free(ha->s_dma_pool, pd, pd_dma); |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 1950 | fcport->query = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1951 | |
| 1952 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1953 | ql_dbg(ql_dbg_mbx, vha, 0x1052, |
| 1954 | "Failed=%x mb[0]=%x mb[1]=%x.\n", rval, |
| 1955 | mcp->mb[0], mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1956 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1957 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1053, |
| 1958 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1959 | } |
| 1960 | |
| 1961 | return rval; |
| 1962 | } |
| 1963 | |
| 1964 | /* |
| 1965 | * qla2x00_get_firmware_state |
| 1966 | * Get adapter firmware state. |
| 1967 | * |
| 1968 | * Input: |
| 1969 | * ha = adapter block pointer. |
| 1970 | * dptr = pointer for firmware state. |
| 1971 | * TARGET_QUEUE_LOCK must be released. |
| 1972 | * ADAPTER_STATE_LOCK must be released. |
| 1973 | * |
| 1974 | * Returns: |
| 1975 | * qla2x00 local function return status code. |
| 1976 | * |
| 1977 | * Context: |
| 1978 | * Kernel context. |
| 1979 | */ |
| 1980 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1981 | qla2x00_get_firmware_state(scsi_qla_host_t *vha, uint16_t *states) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1982 | { |
| 1983 | int rval; |
| 1984 | mbx_cmd_t mc; |
| 1985 | mbx_cmd_t *mcp = &mc; |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 1986 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1987 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1988 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1054, |
| 1989 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1990 | |
| 1991 | mcp->mb[0] = MBC_GET_FIRMWARE_STATE; |
| 1992 | mcp->out_mb = MBX_0; |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 1993 | if (IS_FWI2_CAPABLE(vha->hw)) |
Joe Carnuccio | b5a340d | 2014-09-25 05:16:48 -0400 | [diff] [blame] | 1994 | 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] | 1995 | else |
| 1996 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1997 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1998 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1999 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2000 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2001 | /* Return firmware states. */ |
| 2002 | states[0] = mcp->mb[1]; |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 2003 | if (IS_FWI2_CAPABLE(vha->hw)) { |
| 2004 | states[1] = mcp->mb[2]; |
Joe Carnuccio | ec89146 | 2016-07-06 11:14:26 -0400 | [diff] [blame] | 2005 | states[2] = mcp->mb[3]; /* SFP info */ |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 2006 | states[3] = mcp->mb[4]; |
| 2007 | states[4] = mcp->mb[5]; |
Joe Carnuccio | b5a340d | 2014-09-25 05:16:48 -0400 | [diff] [blame] | 2008 | states[5] = mcp->mb[6]; /* DPORT status */ |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 2009 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2010 | |
| 2011 | if (rval != QLA_SUCCESS) { |
| 2012 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2013 | ql_dbg(ql_dbg_mbx, vha, 0x1055, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2014 | } else { |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 2015 | if (IS_QLA27XX(ha)) { |
| 2016 | if (mcp->mb[2] == 6 || mcp->mb[3] == 2) |
| 2017 | ql_dbg(ql_dbg_mbx, vha, 0x119e, |
| 2018 | "Invalid SFP/Validation Failed\n"); |
| 2019 | } |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2020 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1056, |
| 2021 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2022 | } |
| 2023 | |
| 2024 | return rval; |
| 2025 | } |
| 2026 | |
| 2027 | /* |
| 2028 | * qla2x00_get_port_name |
| 2029 | * Issue get port name mailbox command. |
| 2030 | * Returned name is in big endian format. |
| 2031 | * |
| 2032 | * Input: |
| 2033 | * ha = adapter block pointer. |
| 2034 | * loop_id = loop ID of device. |
| 2035 | * name = pointer for name. |
| 2036 | * TARGET_QUEUE_LOCK must be released. |
| 2037 | * ADAPTER_STATE_LOCK must be released. |
| 2038 | * |
| 2039 | * Returns: |
| 2040 | * qla2x00 local function return status code. |
| 2041 | * |
| 2042 | * Context: |
| 2043 | * Kernel context. |
| 2044 | */ |
| 2045 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2046 | 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] | 2047 | uint8_t opt) |
| 2048 | { |
| 2049 | int rval; |
| 2050 | mbx_cmd_t mc; |
| 2051 | mbx_cmd_t *mcp = &mc; |
| 2052 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2053 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1057, |
| 2054 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2055 | |
| 2056 | mcp->mb[0] = MBC_GET_PORT_NAME; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2057 | mcp->mb[9] = vha->vp_idx; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2058 | mcp->out_mb = MBX_9|MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2059 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2060 | mcp->mb[1] = loop_id; |
| 2061 | mcp->mb[10] = opt; |
| 2062 | mcp->out_mb |= MBX_10; |
| 2063 | } else { |
| 2064 | mcp->mb[1] = loop_id << 8 | opt; |
| 2065 | } |
| 2066 | |
| 2067 | 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] | 2068 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2069 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2070 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2071 | |
| 2072 | if (rval != QLA_SUCCESS) { |
| 2073 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2074 | ql_dbg(ql_dbg_mbx, vha, 0x1058, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2075 | } else { |
| 2076 | if (name != NULL) { |
| 2077 | /* This function returns name in big endian. */ |
Richard Lary | 1196ae0 | 2007-03-22 10:53:19 -0500 | [diff] [blame] | 2078 | name[0] = MSB(mcp->mb[2]); |
| 2079 | name[1] = LSB(mcp->mb[2]); |
| 2080 | name[2] = MSB(mcp->mb[3]); |
| 2081 | name[3] = LSB(mcp->mb[3]); |
| 2082 | name[4] = MSB(mcp->mb[6]); |
| 2083 | name[5] = LSB(mcp->mb[6]); |
| 2084 | name[6] = MSB(mcp->mb[7]); |
| 2085 | name[7] = LSB(mcp->mb[7]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2086 | } |
| 2087 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2088 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1059, |
| 2089 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2090 | } |
| 2091 | |
| 2092 | return rval; |
| 2093 | } |
| 2094 | |
| 2095 | /* |
Joe Carnuccio | 61e1b26 | 2013-02-08 01:57:48 -0500 | [diff] [blame] | 2096 | * qla24xx_link_initialization |
| 2097 | * Issue link initialization mailbox command. |
| 2098 | * |
| 2099 | * Input: |
| 2100 | * ha = adapter block pointer. |
| 2101 | * TARGET_QUEUE_LOCK must be released. |
| 2102 | * ADAPTER_STATE_LOCK must be released. |
| 2103 | * |
| 2104 | * Returns: |
| 2105 | * qla2x00 local function return status code. |
| 2106 | * |
| 2107 | * Context: |
| 2108 | * Kernel context. |
| 2109 | */ |
| 2110 | int |
| 2111 | qla24xx_link_initialize(scsi_qla_host_t *vha) |
| 2112 | { |
| 2113 | int rval; |
| 2114 | mbx_cmd_t mc; |
| 2115 | mbx_cmd_t *mcp = &mc; |
| 2116 | |
| 2117 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1152, |
| 2118 | "Entered %s.\n", __func__); |
| 2119 | |
| 2120 | if (!IS_FWI2_CAPABLE(vha->hw) || IS_CNA_CAPABLE(vha->hw)) |
| 2121 | return QLA_FUNCTION_FAILED; |
| 2122 | |
| 2123 | mcp->mb[0] = MBC_LINK_INITIALIZATION; |
Joe Carnuccio | 5a5c27b | 2013-08-27 01:37:49 -0400 | [diff] [blame] | 2124 | mcp->mb[1] = BIT_4; |
| 2125 | if (vha->hw->operating_mode == LOOP) |
| 2126 | mcp->mb[1] |= BIT_6; |
| 2127 | else |
| 2128 | mcp->mb[1] |= BIT_5; |
Joe Carnuccio | 61e1b26 | 2013-02-08 01:57:48 -0500 | [diff] [blame] | 2129 | mcp->mb[2] = 0; |
| 2130 | mcp->mb[3] = 0; |
| 2131 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 2132 | mcp->in_mb = MBX_0; |
| 2133 | mcp->tov = MBX_TOV_SECONDS; |
| 2134 | mcp->flags = 0; |
| 2135 | rval = qla2x00_mailbox_command(vha, mcp); |
| 2136 | |
| 2137 | if (rval != QLA_SUCCESS) { |
| 2138 | ql_dbg(ql_dbg_mbx, vha, 0x1153, "Failed=%x.\n", rval); |
| 2139 | } else { |
| 2140 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1154, |
| 2141 | "Done %s.\n", __func__); |
| 2142 | } |
| 2143 | |
| 2144 | return rval; |
| 2145 | } |
| 2146 | |
| 2147 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2148 | * qla2x00_lip_reset |
| 2149 | * Issue LIP reset mailbox command. |
| 2150 | * |
| 2151 | * Input: |
| 2152 | * ha = adapter block pointer. |
| 2153 | * TARGET_QUEUE_LOCK must be released. |
| 2154 | * ADAPTER_STATE_LOCK must be released. |
| 2155 | * |
| 2156 | * Returns: |
| 2157 | * qla2x00 local function return status code. |
| 2158 | * |
| 2159 | * Context: |
| 2160 | * Kernel context. |
| 2161 | */ |
| 2162 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2163 | qla2x00_lip_reset(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2164 | { |
| 2165 | int rval; |
| 2166 | mbx_cmd_t mc; |
| 2167 | mbx_cmd_t *mcp = &mc; |
| 2168 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2169 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105a, |
| 2170 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2171 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2172 | if (IS_CNA_CAPABLE(vha->hw)) { |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2173 | /* Logout across all FCFs. */ |
| 2174 | mcp->mb[0] = MBC_LIP_FULL_LOGIN; |
| 2175 | mcp->mb[1] = BIT_1; |
| 2176 | mcp->mb[2] = 0; |
| 2177 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 2178 | } else if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2179 | mcp->mb[0] = MBC_LIP_FULL_LOGIN; |
Quinn Tran | 48acad0 | 2018-08-02 13:16:44 -0700 | [diff] [blame] | 2180 | if (N2N_TOPO(vha->hw)) |
| 2181 | mcp->mb[1] = BIT_4; /* re-init */ |
| 2182 | else |
| 2183 | mcp->mb[1] = BIT_6; /* LIP */ |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 2184 | mcp->mb[2] = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2185 | mcp->mb[3] = vha->hw->loop_reset_delay; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2186 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2187 | } else { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2188 | mcp->mb[0] = MBC_LIP_RESET; |
| 2189 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2190 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2191 | mcp->mb[1] = 0x00ff; |
| 2192 | mcp->mb[10] = 0; |
| 2193 | mcp->out_mb |= MBX_10; |
| 2194 | } else { |
| 2195 | mcp->mb[1] = 0xff00; |
| 2196 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2197 | mcp->mb[2] = vha->hw->loop_reset_delay; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2198 | mcp->mb[3] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2199 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2200 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2201 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2202 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2203 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2204 | |
| 2205 | if (rval != QLA_SUCCESS) { |
| 2206 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2207 | ql_dbg(ql_dbg_mbx, vha, 0x105b, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2208 | } else { |
| 2209 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2210 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105c, |
| 2211 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2212 | } |
| 2213 | |
| 2214 | return rval; |
| 2215 | } |
| 2216 | |
| 2217 | /* |
| 2218 | * qla2x00_send_sns |
| 2219 | * Send SNS command. |
| 2220 | * |
| 2221 | * Input: |
| 2222 | * ha = adapter block pointer. |
| 2223 | * sns = pointer for command. |
| 2224 | * cmd_size = command size. |
| 2225 | * buf_size = response/command size. |
| 2226 | * TARGET_QUEUE_LOCK must be released. |
| 2227 | * ADAPTER_STATE_LOCK must be released. |
| 2228 | * |
| 2229 | * Returns: |
| 2230 | * qla2x00 local function return status code. |
| 2231 | * |
| 2232 | * Context: |
| 2233 | * Kernel context. |
| 2234 | */ |
| 2235 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2236 | 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] | 2237 | uint16_t cmd_size, size_t buf_size) |
| 2238 | { |
| 2239 | int rval; |
| 2240 | mbx_cmd_t mc; |
| 2241 | mbx_cmd_t *mcp = &mc; |
| 2242 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2243 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105d, |
| 2244 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2245 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2246 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105e, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2247 | "Retry cnt=%d ratov=%d total tov=%d.\n", |
| 2248 | vha->hw->retry_count, vha->hw->login_timeout, mcp->tov); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2249 | |
| 2250 | mcp->mb[0] = MBC_SEND_SNS_COMMAND; |
| 2251 | mcp->mb[1] = cmd_size; |
| 2252 | mcp->mb[2] = MSW(sns_phys_address); |
| 2253 | mcp->mb[3] = LSW(sns_phys_address); |
| 2254 | mcp->mb[6] = MSW(MSD(sns_phys_address)); |
| 2255 | mcp->mb[7] = LSW(MSD(sns_phys_address)); |
| 2256 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 2257 | mcp->in_mb = MBX_0|MBX_1; |
| 2258 | mcp->buf_size = buf_size; |
| 2259 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2260 | mcp->tov = (vha->hw->login_timeout * 2) + (vha->hw->login_timeout / 2); |
| 2261 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2262 | |
| 2263 | if (rval != QLA_SUCCESS) { |
| 2264 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2265 | ql_dbg(ql_dbg_mbx, vha, 0x105f, |
| 2266 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 2267 | rval, mcp->mb[0], mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2268 | } else { |
| 2269 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2270 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1060, |
| 2271 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2272 | } |
| 2273 | |
| 2274 | return rval; |
| 2275 | } |
| 2276 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2277 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2278 | 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] | 2279 | uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt) |
| 2280 | { |
| 2281 | int rval; |
| 2282 | |
| 2283 | struct logio_entry_24xx *lg; |
| 2284 | dma_addr_t lg_dma; |
| 2285 | uint32_t iop[2]; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2286 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2287 | struct req_que *req; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2288 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2289 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1061, |
| 2290 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2291 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2292 | if (vha->vp_idx && vha->qpair) |
| 2293 | req = vha->qpair->req; |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2294 | else |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2295 | req = ha->req_q_map[0]; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2296 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 2297 | lg = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2298 | if (lg == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2299 | ql_log(ql_log_warn, vha, 0x1062, |
| 2300 | "Failed to allocate login IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2301 | return QLA_MEMORY_ALLOC_FAILED; |
| 2302 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2303 | |
| 2304 | lg->entry_type = LOGINOUT_PORT_IOCB_TYPE; |
| 2305 | lg->entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2306 | lg->handle = MAKE_HANDLE(req->id, lg->handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2307 | lg->nport_handle = cpu_to_le16(loop_id); |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2308 | lg->control_flags = cpu_to_le16(LCF_COMMAND_PLOGI); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2309 | if (opt & BIT_0) |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2310 | lg->control_flags |= cpu_to_le16(LCF_COND_PLOGI); |
Andrew Vasquez | 8baa51a | 2006-06-23 16:10:44 -0700 | [diff] [blame] | 2311 | if (opt & BIT_1) |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2312 | lg->control_flags |= cpu_to_le16(LCF_SKIP_PRLI); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2313 | lg->port_id[0] = al_pa; |
| 2314 | lg->port_id[1] = area; |
| 2315 | lg->port_id[2] = domain; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2316 | lg->vp_index = vha->vp_idx; |
Andrew Vasquez | 7f45dd0 | 2012-02-09 11:15:45 -0800 | [diff] [blame] | 2317 | rval = qla2x00_issue_iocb_timeout(vha, lg, lg_dma, 0, |
| 2318 | (ha->r_a_tov / 10 * 2) + 2); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2319 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2320 | ql_dbg(ql_dbg_mbx, vha, 0x1063, |
| 2321 | "Failed to issue login IOCB (%x).\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2322 | } else if (lg->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2323 | ql_dbg(ql_dbg_mbx, vha, 0x1064, |
| 2324 | "Failed to complete IOCB -- error status (%x).\n", |
| 2325 | lg->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2326 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2327 | } else if (lg->comp_status != cpu_to_le16(CS_COMPLETE)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2328 | iop[0] = le32_to_cpu(lg->io_parameter[0]); |
| 2329 | iop[1] = le32_to_cpu(lg->io_parameter[1]); |
| 2330 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2331 | ql_dbg(ql_dbg_mbx, vha, 0x1065, |
| 2332 | "Failed to complete IOCB -- completion status (%x) " |
| 2333 | "ioparam=%x/%x.\n", le16_to_cpu(lg->comp_status), |
| 2334 | iop[0], iop[1]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2335 | |
| 2336 | switch (iop[0]) { |
| 2337 | case LSC_SCODE_PORTID_USED: |
| 2338 | mb[0] = MBS_PORT_ID_USED; |
| 2339 | mb[1] = LSW(iop[1]); |
| 2340 | break; |
| 2341 | case LSC_SCODE_NPORT_USED: |
| 2342 | mb[0] = MBS_LOOP_ID_USED; |
| 2343 | break; |
| 2344 | case LSC_SCODE_NOLINK: |
| 2345 | case LSC_SCODE_NOIOCB: |
| 2346 | case LSC_SCODE_NOXCB: |
| 2347 | case LSC_SCODE_CMD_FAILED: |
| 2348 | case LSC_SCODE_NOFABRIC: |
| 2349 | case LSC_SCODE_FW_NOT_READY: |
| 2350 | case LSC_SCODE_NOT_LOGGED_IN: |
| 2351 | case LSC_SCODE_NOPCB: |
| 2352 | case LSC_SCODE_ELS_REJECT: |
| 2353 | case LSC_SCODE_CMD_PARAM_ERR: |
| 2354 | case LSC_SCODE_NONPORT: |
| 2355 | case LSC_SCODE_LOGGED_IN: |
| 2356 | case LSC_SCODE_NOFLOGI_ACC: |
| 2357 | default: |
| 2358 | mb[0] = MBS_COMMAND_ERROR; |
| 2359 | break; |
| 2360 | } |
| 2361 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2362 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1066, |
| 2363 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2364 | |
| 2365 | iop[0] = le32_to_cpu(lg->io_parameter[0]); |
| 2366 | |
| 2367 | mb[0] = MBS_COMMAND_COMPLETE; |
| 2368 | mb[1] = 0; |
| 2369 | if (iop[0] & BIT_4) { |
| 2370 | if (iop[0] & BIT_8) |
| 2371 | mb[1] |= BIT_1; |
| 2372 | } else |
| 2373 | mb[1] = BIT_0; |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 2374 | |
| 2375 | /* Passback COS information. */ |
| 2376 | mb[10] = 0; |
| 2377 | if (lg->io_parameter[7] || lg->io_parameter[8]) |
| 2378 | mb[10] |= BIT_0; /* Class 2. */ |
| 2379 | if (lg->io_parameter[9] || lg->io_parameter[10]) |
| 2380 | mb[10] |= BIT_1; /* Class 3. */ |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2381 | if (lg->io_parameter[0] & cpu_to_le32(BIT_7)) |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2382 | mb[10] |= BIT_7; /* Confirmed Completion |
| 2383 | * Allowed |
| 2384 | */ |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2385 | } |
| 2386 | |
| 2387 | dma_pool_free(ha->s_dma_pool, lg, lg_dma); |
| 2388 | |
| 2389 | return rval; |
| 2390 | } |
| 2391 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2392 | /* |
| 2393 | * qla2x00_login_fabric |
| 2394 | * Issue login fabric port mailbox command. |
| 2395 | * |
| 2396 | * Input: |
| 2397 | * ha = adapter block pointer. |
| 2398 | * loop_id = device loop ID. |
| 2399 | * domain = device domain. |
| 2400 | * area = device area. |
| 2401 | * al_pa = device AL_PA. |
| 2402 | * status = pointer for return status. |
| 2403 | * opt = command options. |
| 2404 | * TARGET_QUEUE_LOCK must be released. |
| 2405 | * ADAPTER_STATE_LOCK must be released. |
| 2406 | * |
| 2407 | * Returns: |
| 2408 | * qla2x00 local function return status code. |
| 2409 | * |
| 2410 | * Context: |
| 2411 | * Kernel context. |
| 2412 | */ |
| 2413 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2414 | 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] | 2415 | uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt) |
| 2416 | { |
| 2417 | int rval; |
| 2418 | mbx_cmd_t mc; |
| 2419 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2420 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2421 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2422 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1067, |
| 2423 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2424 | |
| 2425 | mcp->mb[0] = MBC_LOGIN_FABRIC_PORT; |
| 2426 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 2427 | if (HAS_EXTENDED_IDS(ha)) { |
| 2428 | mcp->mb[1] = loop_id; |
| 2429 | mcp->mb[10] = opt; |
| 2430 | mcp->out_mb |= MBX_10; |
| 2431 | } else { |
| 2432 | mcp->mb[1] = (loop_id << 8) | opt; |
| 2433 | } |
| 2434 | mcp->mb[2] = domain; |
| 2435 | mcp->mb[3] = area << 8 | al_pa; |
| 2436 | |
| 2437 | mcp->in_mb = MBX_7|MBX_6|MBX_2|MBX_1|MBX_0; |
| 2438 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
| 2439 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2440 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2441 | |
| 2442 | /* Return mailbox statuses. */ |
| 2443 | if (mb != NULL) { |
| 2444 | mb[0] = mcp->mb[0]; |
| 2445 | mb[1] = mcp->mb[1]; |
| 2446 | mb[2] = mcp->mb[2]; |
| 2447 | mb[6] = mcp->mb[6]; |
| 2448 | mb[7] = mcp->mb[7]; |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 2449 | /* COS retrieved from Get-Port-Database mailbox command. */ |
| 2450 | mb[10] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2451 | } |
| 2452 | |
| 2453 | if (rval != QLA_SUCCESS) { |
| 2454 | /* RLU tmp code: need to change main mailbox_command function to |
| 2455 | * return ok even when the mailbox completion value is not |
| 2456 | * SUCCESS. The caller needs to be responsible to interpret |
| 2457 | * the return values of this mailbox command if we're not |
| 2458 | * to change too much of the existing code. |
| 2459 | */ |
| 2460 | if (mcp->mb[0] == 0x4001 || mcp->mb[0] == 0x4002 || |
| 2461 | mcp->mb[0] == 0x4003 || mcp->mb[0] == 0x4005 || |
| 2462 | mcp->mb[0] == 0x4006) |
| 2463 | rval = QLA_SUCCESS; |
| 2464 | |
| 2465 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2466 | ql_dbg(ql_dbg_mbx, vha, 0x1068, |
| 2467 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 2468 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2469 | } else { |
| 2470 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2471 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1069, |
| 2472 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2473 | } |
| 2474 | |
| 2475 | return rval; |
| 2476 | } |
| 2477 | |
| 2478 | /* |
| 2479 | * qla2x00_login_local_device |
| 2480 | * Issue login loop port mailbox command. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2481 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2482 | * Input: |
| 2483 | * ha = adapter block pointer. |
| 2484 | * loop_id = device loop ID. |
| 2485 | * opt = command options. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2486 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2487 | * Returns: |
| 2488 | * Return status code. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2489 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2490 | * Context: |
| 2491 | * Kernel context. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2492 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2493 | */ |
| 2494 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2495 | 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] | 2496 | uint16_t *mb_ret, uint8_t opt) |
| 2497 | { |
| 2498 | int rval; |
| 2499 | mbx_cmd_t mc; |
| 2500 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2501 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2502 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2503 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106a, |
| 2504 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2505 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2506 | if (IS_FWI2_CAPABLE(ha)) |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2507 | return qla24xx_login_fabric(vha, fcport->loop_id, |
andrew.vasquez@qlogic.com | 9a52a57c | 2006-03-09 14:27:44 -0800 | [diff] [blame] | 2508 | fcport->d_id.b.domain, fcport->d_id.b.area, |
| 2509 | fcport->d_id.b.al_pa, mb_ret, opt); |
| 2510 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2511 | mcp->mb[0] = MBC_LOGIN_LOOP_PORT; |
| 2512 | if (HAS_EXTENDED_IDS(ha)) |
andrew.vasquez@qlogic.com | 9a52a57c | 2006-03-09 14:27:44 -0800 | [diff] [blame] | 2513 | mcp->mb[1] = fcport->loop_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2514 | else |
andrew.vasquez@qlogic.com | 9a52a57c | 2006-03-09 14:27:44 -0800 | [diff] [blame] | 2515 | mcp->mb[1] = fcport->loop_id << 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2516 | mcp->mb[2] = opt; |
| 2517 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 2518 | mcp->in_mb = MBX_7|MBX_6|MBX_1|MBX_0; |
| 2519 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
| 2520 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2521 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2522 | |
| 2523 | /* Return mailbox statuses. */ |
| 2524 | if (mb_ret != NULL) { |
| 2525 | mb_ret[0] = mcp->mb[0]; |
| 2526 | mb_ret[1] = mcp->mb[1]; |
| 2527 | mb_ret[6] = mcp->mb[6]; |
| 2528 | mb_ret[7] = mcp->mb[7]; |
| 2529 | } |
| 2530 | |
| 2531 | if (rval != QLA_SUCCESS) { |
| 2532 | /* AV tmp code: need to change main mailbox_command function to |
| 2533 | * return ok even when the mailbox completion value is not |
| 2534 | * SUCCESS. The caller needs to be responsible to interpret |
| 2535 | * the return values of this mailbox command if we're not |
| 2536 | * to change too much of the existing code. |
| 2537 | */ |
| 2538 | if (mcp->mb[0] == 0x4005 || mcp->mb[0] == 0x4006) |
| 2539 | rval = QLA_SUCCESS; |
| 2540 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2541 | ql_dbg(ql_dbg_mbx, vha, 0x106b, |
| 2542 | "Failed=%x mb[0]=%x mb[1]=%x mb[6]=%x mb[7]=%x.\n", |
| 2543 | 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] | 2544 | } else { |
| 2545 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2546 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106c, |
| 2547 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2548 | } |
| 2549 | |
| 2550 | return (rval); |
| 2551 | } |
| 2552 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2553 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2554 | 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] | 2555 | uint8_t area, uint8_t al_pa) |
| 2556 | { |
| 2557 | int rval; |
| 2558 | struct logio_entry_24xx *lg; |
| 2559 | dma_addr_t lg_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2560 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2561 | struct req_que *req; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2562 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2563 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106d, |
| 2564 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2565 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 2566 | lg = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2567 | if (lg == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2568 | ql_log(ql_log_warn, vha, 0x106e, |
| 2569 | "Failed to allocate logout IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2570 | return QLA_MEMORY_ALLOC_FAILED; |
| 2571 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2572 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2573 | req = vha->req; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2574 | lg->entry_type = LOGINOUT_PORT_IOCB_TYPE; |
| 2575 | lg->entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2576 | lg->handle = MAKE_HANDLE(req->id, lg->handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2577 | lg->nport_handle = cpu_to_le16(loop_id); |
| 2578 | lg->control_flags = |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2579 | cpu_to_le16(LCF_COMMAND_LOGO|LCF_IMPL_LOGO| |
Andrew Vasquez | c8d6691 | 2011-03-30 11:46:21 -0700 | [diff] [blame] | 2580 | LCF_FREE_NPORT); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2581 | lg->port_id[0] = al_pa; |
| 2582 | lg->port_id[1] = area; |
| 2583 | lg->port_id[2] = domain; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2584 | lg->vp_index = vha->vp_idx; |
Andrew Vasquez | 7f45dd0 | 2012-02-09 11:15:45 -0800 | [diff] [blame] | 2585 | rval = qla2x00_issue_iocb_timeout(vha, lg, lg_dma, 0, |
| 2586 | (ha->r_a_tov / 10 * 2) + 2); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2587 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2588 | ql_dbg(ql_dbg_mbx, vha, 0x106f, |
| 2589 | "Failed to issue logout IOCB (%x).\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2590 | } else if (lg->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2591 | ql_dbg(ql_dbg_mbx, vha, 0x1070, |
| 2592 | "Failed to complete IOCB -- error status (%x).\n", |
| 2593 | lg->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2594 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2595 | } else if (lg->comp_status != cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2596 | ql_dbg(ql_dbg_mbx, vha, 0x1071, |
| 2597 | "Failed to complete IOCB -- completion status (%x) " |
| 2598 | "ioparam=%x/%x.\n", le16_to_cpu(lg->comp_status), |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2599 | le32_to_cpu(lg->io_parameter[0]), |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2600 | le32_to_cpu(lg->io_parameter[1])); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2601 | } else { |
| 2602 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2603 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1072, |
| 2604 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2605 | } |
| 2606 | |
| 2607 | dma_pool_free(ha->s_dma_pool, lg, lg_dma); |
| 2608 | |
| 2609 | return rval; |
| 2610 | } |
| 2611 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2612 | /* |
| 2613 | * qla2x00_fabric_logout |
| 2614 | * Issue logout fabric port mailbox command. |
| 2615 | * |
| 2616 | * Input: |
| 2617 | * ha = adapter block pointer. |
| 2618 | * loop_id = device loop ID. |
| 2619 | * TARGET_QUEUE_LOCK must be released. |
| 2620 | * ADAPTER_STATE_LOCK must be released. |
| 2621 | * |
| 2622 | * Returns: |
| 2623 | * qla2x00 local function return status code. |
| 2624 | * |
| 2625 | * Context: |
| 2626 | * Kernel context. |
| 2627 | */ |
| 2628 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2629 | 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] | 2630 | uint8_t area, uint8_t al_pa) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2631 | { |
| 2632 | int rval; |
| 2633 | mbx_cmd_t mc; |
| 2634 | mbx_cmd_t *mcp = &mc; |
| 2635 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2636 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1073, |
| 2637 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2638 | |
| 2639 | mcp->mb[0] = MBC_LOGOUT_FABRIC_PORT; |
| 2640 | mcp->out_mb = MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2641 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2642 | mcp->mb[1] = loop_id; |
| 2643 | mcp->mb[10] = 0; |
| 2644 | mcp->out_mb |= MBX_10; |
| 2645 | } else { |
| 2646 | mcp->mb[1] = loop_id << 8; |
| 2647 | } |
| 2648 | |
| 2649 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2650 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2651 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2652 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2653 | |
| 2654 | if (rval != QLA_SUCCESS) { |
| 2655 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2656 | ql_dbg(ql_dbg_mbx, vha, 0x1074, |
| 2657 | "Failed=%x mb[1]=%x.\n", rval, mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2658 | } else { |
| 2659 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2660 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1075, |
| 2661 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2662 | } |
| 2663 | |
| 2664 | return rval; |
| 2665 | } |
| 2666 | |
| 2667 | /* |
| 2668 | * qla2x00_full_login_lip |
| 2669 | * Issue full login LIP mailbox command. |
| 2670 | * |
| 2671 | * Input: |
| 2672 | * ha = adapter block pointer. |
| 2673 | * TARGET_QUEUE_LOCK must be released. |
| 2674 | * ADAPTER_STATE_LOCK must be released. |
| 2675 | * |
| 2676 | * Returns: |
| 2677 | * qla2x00 local function return status code. |
| 2678 | * |
| 2679 | * Context: |
| 2680 | * Kernel context. |
| 2681 | */ |
| 2682 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2683 | qla2x00_full_login_lip(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2684 | { |
| 2685 | int rval; |
| 2686 | mbx_cmd_t mc; |
| 2687 | mbx_cmd_t *mcp = &mc; |
| 2688 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2689 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1076, |
| 2690 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2691 | |
| 2692 | mcp->mb[0] = MBC_LIP_FULL_LOGIN; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2693 | mcp->mb[1] = IS_FWI2_CAPABLE(vha->hw) ? BIT_3 : 0; |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 2694 | mcp->mb[2] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2695 | mcp->mb[3] = 0; |
| 2696 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 2697 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2698 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2699 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2700 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2701 | |
| 2702 | if (rval != QLA_SUCCESS) { |
| 2703 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2704 | ql_dbg(ql_dbg_mbx, vha, 0x1077, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2705 | } else { |
| 2706 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2707 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1078, |
| 2708 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2709 | } |
| 2710 | |
| 2711 | return rval; |
| 2712 | } |
| 2713 | |
| 2714 | /* |
| 2715 | * qla2x00_get_id_list |
| 2716 | * |
| 2717 | * Input: |
| 2718 | * ha = adapter block pointer. |
| 2719 | * |
| 2720 | * Returns: |
| 2721 | * qla2x00 local function return status code. |
| 2722 | * |
| 2723 | * Context: |
| 2724 | * Kernel context. |
| 2725 | */ |
| 2726 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2727 | 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] | 2728 | uint16_t *entries) |
| 2729 | { |
| 2730 | int rval; |
| 2731 | mbx_cmd_t mc; |
| 2732 | mbx_cmd_t *mcp = &mc; |
| 2733 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2734 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1079, |
| 2735 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2736 | |
| 2737 | if (id_list == NULL) |
| 2738 | return QLA_FUNCTION_FAILED; |
| 2739 | |
| 2740 | mcp->mb[0] = MBC_GET_ID_LIST; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2741 | mcp->out_mb = MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2742 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2743 | mcp->mb[2] = MSW(id_list_dma); |
| 2744 | mcp->mb[3] = LSW(id_list_dma); |
| 2745 | mcp->mb[6] = MSW(MSD(id_list_dma)); |
| 2746 | mcp->mb[7] = LSW(MSD(id_list_dma)); |
andrew.vasquez@qlogic.com | 247ec45 | 2006-02-07 08:45:40 -0800 | [diff] [blame] | 2747 | mcp->mb[8] = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2748 | mcp->mb[9] = vha->vp_idx; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2749 | 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] | 2750 | } else { |
| 2751 | mcp->mb[1] = MSW(id_list_dma); |
| 2752 | mcp->mb[2] = LSW(id_list_dma); |
| 2753 | mcp->mb[3] = MSW(MSD(id_list_dma)); |
| 2754 | mcp->mb[6] = LSW(MSD(id_list_dma)); |
| 2755 | mcp->out_mb |= MBX_6|MBX_3|MBX_2|MBX_1; |
| 2756 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2757 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2758 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2759 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2760 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2761 | |
| 2762 | if (rval != QLA_SUCCESS) { |
| 2763 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2764 | ql_dbg(ql_dbg_mbx, vha, 0x107a, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2765 | } else { |
| 2766 | *entries = mcp->mb[1]; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2767 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107b, |
| 2768 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2769 | } |
| 2770 | |
| 2771 | return rval; |
| 2772 | } |
| 2773 | |
| 2774 | /* |
| 2775 | * qla2x00_get_resource_cnts |
| 2776 | * Get current firmware resource counts. |
| 2777 | * |
| 2778 | * Input: |
| 2779 | * ha = adapter block pointer. |
| 2780 | * |
| 2781 | * Returns: |
| 2782 | * qla2x00 local function return status code. |
| 2783 | * |
| 2784 | * Context: |
| 2785 | * Kernel context. |
| 2786 | */ |
| 2787 | int |
Quinn Tran | 03e8c68 | 2015-12-17 14:56:59 -0500 | [diff] [blame] | 2788 | qla2x00_get_resource_cnts(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2789 | { |
Quinn Tran | 03e8c68 | 2015-12-17 14:56:59 -0500 | [diff] [blame] | 2790 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2791 | int rval; |
| 2792 | mbx_cmd_t mc; |
| 2793 | mbx_cmd_t *mcp = &mc; |
| 2794 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2795 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107c, |
| 2796 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2797 | |
| 2798 | mcp->mb[0] = MBC_GET_RESOURCE_COUNTS; |
| 2799 | mcp->out_mb = MBX_0; |
Seokmann Ju | 4d0ea24 | 2007-09-20 14:07:43 -0700 | [diff] [blame] | 2800 | 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] | 2801 | 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] | 2802 | mcp->in_mb |= MBX_12; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2803 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2804 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2805 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2806 | |
| 2807 | if (rval != QLA_SUCCESS) { |
| 2808 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2809 | ql_dbg(ql_dbg_mbx, vha, 0x107d, |
| 2810 | "Failed mb[0]=%x.\n", mcp->mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2811 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2812 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107e, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2813 | "Done %s mb1=%x mb2=%x mb3=%x mb6=%x mb7=%x mb10=%x " |
| 2814 | "mb11=%x mb12=%x.\n", __func__, mcp->mb[1], mcp->mb[2], |
| 2815 | mcp->mb[3], mcp->mb[6], mcp->mb[7], mcp->mb[10], |
| 2816 | mcp->mb[11], mcp->mb[12]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2817 | |
Quinn Tran | 03e8c68 | 2015-12-17 14:56:59 -0500 | [diff] [blame] | 2818 | ha->orig_fw_tgt_xcb_count = mcp->mb[1]; |
| 2819 | ha->cur_fw_tgt_xcb_count = mcp->mb[2]; |
| 2820 | ha->cur_fw_xcb_count = mcp->mb[3]; |
| 2821 | ha->orig_fw_xcb_count = mcp->mb[6]; |
| 2822 | ha->cur_fw_iocb_count = mcp->mb[7]; |
| 2823 | ha->orig_fw_iocb_count = mcp->mb[10]; |
| 2824 | if (ha->flags.npiv_supported) |
| 2825 | ha->max_npiv_vports = mcp->mb[11]; |
| 2826 | if (IS_QLA81XX(ha) || IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
| 2827 | ha->fw_max_fcf_count = mcp->mb[12]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2828 | } |
| 2829 | |
| 2830 | return (rval); |
| 2831 | } |
| 2832 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2833 | /* |
| 2834 | * qla2x00_get_fcal_position_map |
| 2835 | * Get FCAL (LILP) position map using mailbox command |
| 2836 | * |
| 2837 | * Input: |
| 2838 | * ha = adapter state pointer. |
| 2839 | * pos_map = buffer pointer (can be NULL). |
| 2840 | * |
| 2841 | * Returns: |
| 2842 | * qla2x00 local function return status code. |
| 2843 | * |
| 2844 | * Context: |
| 2845 | * Kernel context. |
| 2846 | */ |
| 2847 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2848 | 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] | 2849 | { |
| 2850 | int rval; |
| 2851 | mbx_cmd_t mc; |
| 2852 | mbx_cmd_t *mcp = &mc; |
| 2853 | char *pmap; |
| 2854 | dma_addr_t pmap_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2855 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2856 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2857 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107f, |
| 2858 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2859 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 2860 | pmap = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pmap_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2861 | if (pmap == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2862 | ql_log(ql_log_warn, vha, 0x1080, |
| 2863 | "Memory alloc failed.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2864 | return QLA_MEMORY_ALLOC_FAILED; |
| 2865 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2866 | |
| 2867 | mcp->mb[0] = MBC_GET_FC_AL_POSITION_MAP; |
| 2868 | mcp->mb[2] = MSW(pmap_dma); |
| 2869 | mcp->mb[3] = LSW(pmap_dma); |
| 2870 | mcp->mb[6] = MSW(MSD(pmap_dma)); |
| 2871 | mcp->mb[7] = LSW(MSD(pmap_dma)); |
| 2872 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; |
| 2873 | mcp->in_mb = MBX_1|MBX_0; |
| 2874 | mcp->buf_size = FCAL_MAP_SIZE; |
| 2875 | mcp->flags = MBX_DMA_IN; |
| 2876 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2877 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2878 | |
| 2879 | if (rval == QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2880 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1081, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2881 | "mb0/mb1=%x/%X FC/AL position map size (%x).\n", |
| 2882 | mcp->mb[0], mcp->mb[1], (unsigned)pmap[0]); |
| 2883 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111d, |
| 2884 | pmap, pmap[0] + 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2885 | |
| 2886 | if (pos_map) |
| 2887 | memcpy(pos_map, pmap, FCAL_MAP_SIZE); |
| 2888 | } |
| 2889 | dma_pool_free(ha->s_dma_pool, pmap, pmap_dma); |
| 2890 | |
| 2891 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2892 | ql_dbg(ql_dbg_mbx, vha, 0x1082, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2893 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2894 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1083, |
| 2895 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2896 | } |
| 2897 | |
| 2898 | return rval; |
| 2899 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2900 | |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2901 | /* |
| 2902 | * qla2x00_get_link_status |
| 2903 | * |
| 2904 | * Input: |
| 2905 | * ha = adapter block pointer. |
| 2906 | * loop_id = device loop ID. |
| 2907 | * ret_buf = pointer to link status return buffer. |
| 2908 | * |
| 2909 | * Returns: |
| 2910 | * 0 = success. |
| 2911 | * BIT_0 = mem alloc error. |
| 2912 | * BIT_1 = mailbox error. |
| 2913 | */ |
| 2914 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2915 | 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] | 2916 | struct link_statistics *stats, dma_addr_t stats_dma) |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2917 | { |
| 2918 | int rval; |
| 2919 | mbx_cmd_t mc; |
| 2920 | mbx_cmd_t *mcp = &mc; |
Joe Carnuccio | c6dc990 | 2016-07-06 11:14:24 -0400 | [diff] [blame] | 2921 | uint32_t *iter = (void *)stats; |
| 2922 | ushort dwords = offsetof(typeof(*stats), link_up_cnt)/sizeof(*iter); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2923 | struct qla_hw_data *ha = vha->hw; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2924 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2925 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1084, |
| 2926 | "Entered %s.\n", __func__); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2927 | |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2928 | mcp->mb[0] = MBC_GET_LINK_STATUS; |
Joe Carnuccio | c6dc990 | 2016-07-06 11:14:24 -0400 | [diff] [blame] | 2929 | mcp->mb[2] = MSW(LSD(stats_dma)); |
| 2930 | mcp->mb[3] = LSW(LSD(stats_dma)); |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2931 | mcp->mb[6] = MSW(MSD(stats_dma)); |
| 2932 | mcp->mb[7] = LSW(MSD(stats_dma)); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2933 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; |
| 2934 | mcp->in_mb = MBX_0; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2935 | if (IS_FWI2_CAPABLE(ha)) { |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2936 | mcp->mb[1] = loop_id; |
| 2937 | mcp->mb[4] = 0; |
| 2938 | mcp->mb[10] = 0; |
| 2939 | mcp->out_mb |= MBX_10|MBX_4|MBX_1; |
| 2940 | mcp->in_mb |= MBX_1; |
| 2941 | } else if (HAS_EXTENDED_IDS(ha)) { |
| 2942 | mcp->mb[1] = loop_id; |
| 2943 | mcp->mb[10] = 0; |
| 2944 | mcp->out_mb |= MBX_10|MBX_1; |
| 2945 | } else { |
| 2946 | mcp->mb[1] = loop_id << 8; |
| 2947 | mcp->out_mb |= MBX_1; |
| 2948 | } |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2949 | mcp->tov = MBX_TOV_SECONDS; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2950 | mcp->flags = IOCTL_CMD; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2951 | rval = qla2x00_mailbox_command(vha, mcp); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2952 | |
| 2953 | if (rval == QLA_SUCCESS) { |
| 2954 | if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2955 | ql_dbg(ql_dbg_mbx, vha, 0x1085, |
| 2956 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2957 | rval = QLA_FUNCTION_FAILED; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2958 | } else { |
Joe Carnuccio | c6dc990 | 2016-07-06 11:14:24 -0400 | [diff] [blame] | 2959 | /* Re-endianize - firmware data is le32. */ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2960 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1086, |
| 2961 | "Done %s.\n", __func__); |
Joe Carnuccio | da08ef5 | 2016-01-27 12:03:34 -0500 | [diff] [blame] | 2962 | for ( ; dwords--; iter++) |
| 2963 | le32_to_cpus(iter); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2964 | } |
| 2965 | } else { |
| 2966 | /* Failed. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2967 | 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] | 2968 | } |
| 2969 | |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2970 | return rval; |
| 2971 | } |
| 2972 | |
| 2973 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2974 | 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] | 2975 | dma_addr_t stats_dma, uint16_t options) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2976 | { |
| 2977 | int rval; |
| 2978 | mbx_cmd_t mc; |
| 2979 | mbx_cmd_t *mcp = &mc; |
Joe Carnuccio | da08ef5 | 2016-01-27 12:03:34 -0500 | [diff] [blame] | 2980 | uint32_t *iter, dwords; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2981 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2982 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1088, |
| 2983 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2984 | |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 2985 | memset(&mc, 0, sizeof(mc)); |
| 2986 | mc.mb[0] = MBC_GET_LINK_PRIV_STATS; |
| 2987 | mc.mb[2] = MSW(stats_dma); |
| 2988 | mc.mb[3] = LSW(stats_dma); |
| 2989 | mc.mb[6] = MSW(MSD(stats_dma)); |
| 2990 | mc.mb[7] = LSW(MSD(stats_dma)); |
| 2991 | mc.mb[8] = sizeof(struct link_statistics) / 4; |
| 2992 | mc.mb[9] = cpu_to_le16(vha->vp_idx); |
| 2993 | mc.mb[10] = cpu_to_le16(options); |
| 2994 | |
| 2995 | rval = qla24xx_send_mb_cmd(vha, &mc); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2996 | |
| 2997 | if (rval == QLA_SUCCESS) { |
| 2998 | if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2999 | ql_dbg(ql_dbg_mbx, vha, 0x1089, |
| 3000 | "Failed mb[0]=%x.\n", mcp->mb[0]); |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 3001 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3002 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3003 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x108a, |
| 3004 | "Done %s.\n", __func__); |
Joe Carnuccio | c6dc990 | 2016-07-06 11:14:24 -0400 | [diff] [blame] | 3005 | /* Re-endianize - firmware data is le32. */ |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 3006 | dwords = sizeof(struct link_statistics) / 4; |
Joe Carnuccio | da08ef5 | 2016-01-27 12:03:34 -0500 | [diff] [blame] | 3007 | iter = &stats->link_fail_cnt; |
| 3008 | for ( ; dwords--; iter++) |
| 3009 | le32_to_cpus(iter); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3010 | } |
| 3011 | } else { |
| 3012 | /* Failed. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3013 | ql_dbg(ql_dbg_mbx, vha, 0x108b, "Failed=%x.\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3014 | } |
| 3015 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3016 | return rval; |
| 3017 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3018 | |
| 3019 | int |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3020 | qla24xx_abort_command(srb_t *sp) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3021 | { |
| 3022 | int rval; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3023 | unsigned long flags = 0; |
| 3024 | |
| 3025 | struct abort_entry_24xx *abt; |
| 3026 | dma_addr_t abt_dma; |
| 3027 | uint32_t handle; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3028 | fc_port_t *fcport = sp->fcport; |
| 3029 | struct scsi_qla_host *vha = fcport->vha; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3030 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 3031 | struct req_que *req = vha->req; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3032 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3033 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x108c, |
| 3034 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3035 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3036 | if (vha->flags.qpairs_available && sp->qpair) |
| 3037 | req = sp->qpair->req; |
| 3038 | |
Armen Baloyan | 4440e46 | 2014-02-26 04:15:18 -0500 | [diff] [blame] | 3039 | if (ql2xasynctmfenable) |
| 3040 | return qla24xx_async_abort_command(sp); |
| 3041 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3042 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 3043 | for (handle = 1; handle < req->num_outstanding_cmds; handle++) { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3044 | if (req->outstanding_cmds[handle] == sp) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3045 | break; |
| 3046 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3047 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 3048 | if (handle == req->num_outstanding_cmds) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3049 | /* Command not found. */ |
| 3050 | return QLA_FUNCTION_FAILED; |
| 3051 | } |
| 3052 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 3053 | abt = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &abt_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3054 | if (abt == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3055 | ql_log(ql_log_warn, vha, 0x108d, |
| 3056 | "Failed to allocate abort IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3057 | return QLA_MEMORY_ALLOC_FAILED; |
| 3058 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3059 | |
| 3060 | abt->entry_type = ABORT_IOCB_TYPE; |
| 3061 | abt->entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3062 | abt->handle = MAKE_HANDLE(req->id, abt->handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3063 | abt->nport_handle = cpu_to_le16(fcport->loop_id); |
Mike Hernandez | a74ec14 | 2011-03-30 11:46:20 -0700 | [diff] [blame] | 3064 | abt->handle_to_abort = MAKE_HANDLE(req->id, handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3065 | abt->port_id[0] = fcport->d_id.b.al_pa; |
| 3066 | abt->port_id[1] = fcport->d_id.b.area; |
| 3067 | abt->port_id[2] = fcport->d_id.b.domain; |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3068 | abt->vp_index = fcport->vha->vp_idx; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3069 | |
| 3070 | abt->req_que_no = cpu_to_le16(req->id); |
| 3071 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3072 | rval = qla2x00_issue_iocb(vha, abt, abt_dma, 0); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3073 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3074 | ql_dbg(ql_dbg_mbx, vha, 0x108e, |
| 3075 | "Failed to issue IOCB (%x).\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3076 | } else if (abt->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3077 | ql_dbg(ql_dbg_mbx, vha, 0x108f, |
| 3078 | "Failed to complete IOCB -- error status (%x).\n", |
| 3079 | abt->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3080 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 3081 | } else if (abt->nport_handle != cpu_to_le16(0)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3082 | ql_dbg(ql_dbg_mbx, vha, 0x1090, |
| 3083 | "Failed to complete IOCB -- completion status (%x).\n", |
| 3084 | le16_to_cpu(abt->nport_handle)); |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 3085 | if (abt->nport_handle == CS_IOCB_ERROR) |
| 3086 | rval = QLA_FUNCTION_PARAMETER_ERROR; |
| 3087 | else |
| 3088 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3089 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3090 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1091, |
| 3091 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3092 | } |
| 3093 | |
| 3094 | dma_pool_free(ha->s_dma_pool, abt, abt_dma); |
| 3095 | |
| 3096 | return rval; |
| 3097 | } |
| 3098 | |
| 3099 | struct tsk_mgmt_cmd { |
| 3100 | union { |
| 3101 | struct tsk_mgmt_entry tsk; |
| 3102 | struct sts_entry_24xx sts; |
| 3103 | } p; |
| 3104 | }; |
| 3105 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3106 | static int |
| 3107 | __qla24xx_issue_tmf(char *name, uint32_t type, struct fc_port *fcport, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 3108 | uint64_t l, int tag) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3109 | { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3110 | int rval, rval2; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3111 | struct tsk_mgmt_cmd *tsk; |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 3112 | struct sts_entry_24xx *sts; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3113 | dma_addr_t tsk_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3114 | scsi_qla_host_t *vha; |
| 3115 | struct qla_hw_data *ha; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3116 | struct req_que *req; |
| 3117 | struct rsp_que *rsp; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3118 | struct qla_qpair *qpair; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3119 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3120 | vha = fcport->vha; |
| 3121 | ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3122 | req = vha->req; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3123 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3124 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1092, |
| 3125 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3126 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3127 | if (vha->vp_idx && vha->qpair) { |
| 3128 | /* NPIV port */ |
| 3129 | qpair = vha->qpair; |
| 3130 | rsp = qpair->rsp; |
| 3131 | req = qpair->req; |
| 3132 | } else { |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 3133 | rsp = req->rsp; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3134 | } |
| 3135 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 3136 | tsk = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &tsk_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3137 | if (tsk == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3138 | ql_log(ql_log_warn, vha, 0x1093, |
| 3139 | "Failed to allocate task management IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3140 | return QLA_MEMORY_ALLOC_FAILED; |
| 3141 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3142 | |
| 3143 | tsk->p.tsk.entry_type = TSK_MGMT_IOCB_TYPE; |
| 3144 | tsk->p.tsk.entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3145 | tsk->p.tsk.handle = MAKE_HANDLE(req->id, tsk->p.tsk.handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3146 | tsk->p.tsk.nport_handle = cpu_to_le16(fcport->loop_id); |
Andrew Vasquez | 00a537b | 2008-02-28 14:06:11 -0800 | [diff] [blame] | 3147 | 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] | 3148 | tsk->p.tsk.control_flags = cpu_to_le32(type); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3149 | tsk->p.tsk.port_id[0] = fcport->d_id.b.al_pa; |
| 3150 | tsk->p.tsk.port_id[1] = fcport->d_id.b.area; |
| 3151 | tsk->p.tsk.port_id[2] = fcport->d_id.b.domain; |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3152 | tsk->p.tsk.vp_index = fcport->vha->vp_idx; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3153 | if (type == TCF_LUN_RESET) { |
| 3154 | int_to_scsilun(l, &tsk->p.tsk.lun); |
| 3155 | host_to_fcp_swap((uint8_t *)&tsk->p.tsk.lun, |
| 3156 | sizeof(tsk->p.tsk.lun)); |
| 3157 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3158 | |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 3159 | sts = &tsk->p.sts; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3160 | rval = qla2x00_issue_iocb(vha, tsk, tsk_dma, 0); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3161 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3162 | ql_dbg(ql_dbg_mbx, vha, 0x1094, |
| 3163 | "Failed to issue %s reset IOCB (%x).\n", name, rval); |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 3164 | } else if (sts->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3165 | ql_dbg(ql_dbg_mbx, vha, 0x1095, |
| 3166 | "Failed to complete IOCB -- error status (%x).\n", |
| 3167 | sts->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3168 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 3169 | } else if (sts->comp_status != cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3170 | ql_dbg(ql_dbg_mbx, vha, 0x1096, |
| 3171 | "Failed to complete IOCB -- completion status (%x).\n", |
| 3172 | le16_to_cpu(sts->comp_status)); |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 3173 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 97dec56 | 2011-02-23 15:27:14 -0800 | [diff] [blame] | 3174 | } else if (le16_to_cpu(sts->scsi_status) & |
| 3175 | SS_RESPONSE_INFO_LEN_VALID) { |
| 3176 | if (le32_to_cpu(sts->rsp_data_len) < 4) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3177 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1097, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3178 | "Ignoring inconsistent data length -- not enough " |
| 3179 | "response info (%d).\n", |
| 3180 | le32_to_cpu(sts->rsp_data_len)); |
Andrew Vasquez | 97dec56 | 2011-02-23 15:27:14 -0800 | [diff] [blame] | 3181 | } else if (sts->data[3]) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3182 | ql_dbg(ql_dbg_mbx, vha, 0x1098, |
| 3183 | "Failed to complete IOCB -- response (%x).\n", |
| 3184 | sts->data[3]); |
Andrew Vasquez | 97dec56 | 2011-02-23 15:27:14 -0800 | [diff] [blame] | 3185 | rval = QLA_FUNCTION_FAILED; |
| 3186 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3187 | } |
| 3188 | |
| 3189 | /* Issue marker IOCB. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3190 | rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, l, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3191 | type == TCF_LUN_RESET ? MK_SYNC_ID_LUN: MK_SYNC_ID); |
| 3192 | if (rval2 != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3193 | ql_dbg(ql_dbg_mbx, vha, 0x1099, |
| 3194 | "Failed to issue marker IOCB (%x).\n", rval2); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3195 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3196 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109a, |
| 3197 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3198 | } |
| 3199 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3200 | dma_pool_free(ha->s_dma_pool, tsk, tsk_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3201 | |
| 3202 | return rval; |
| 3203 | } |
| 3204 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3205 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 3206 | qla24xx_abort_target(struct fc_port *fcport, uint64_t l, int tag) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3207 | { |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 3208 | struct qla_hw_data *ha = fcport->vha->hw; |
| 3209 | |
| 3210 | if ((ql2xasynctmfenable) && IS_FWI2_CAPABLE(ha)) |
| 3211 | return qla2x00_async_tm_cmd(fcport, TCF_TARGET_RESET, l, tag); |
| 3212 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3213 | return __qla24xx_issue_tmf("Target", TCF_TARGET_RESET, fcport, l, tag); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3214 | } |
| 3215 | |
| 3216 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 3217 | qla24xx_lun_reset(struct fc_port *fcport, uint64_t l, int tag) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3218 | { |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 3219 | struct qla_hw_data *ha = fcport->vha->hw; |
| 3220 | |
| 3221 | if ((ql2xasynctmfenable) && IS_FWI2_CAPABLE(ha)) |
| 3222 | return qla2x00_async_tm_cmd(fcport, TCF_LUN_RESET, l, tag); |
| 3223 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3224 | return __qla24xx_issue_tmf("Lun", TCF_LUN_RESET, fcport, l, tag); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3225 | } |
| 3226 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3227 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3228 | qla2x00_system_error(scsi_qla_host_t *vha) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3229 | { |
| 3230 | int rval; |
| 3231 | mbx_cmd_t mc; |
| 3232 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3233 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3234 | |
Andrew Vasquez | 68af081 | 2008-05-12 22:21:13 -0700 | [diff] [blame] | 3235 | if (!IS_QLA23XX(ha) && !IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3236 | return QLA_FUNCTION_FAILED; |
| 3237 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3238 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109b, |
| 3239 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3240 | |
| 3241 | mcp->mb[0] = MBC_GEN_SYSTEM_ERROR; |
| 3242 | mcp->out_mb = MBX_0; |
| 3243 | mcp->in_mb = MBX_0; |
| 3244 | mcp->tov = 5; |
| 3245 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3246 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3247 | |
| 3248 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3249 | ql_dbg(ql_dbg_mbx, vha, 0x109c, "Failed=%x.\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3250 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3251 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109d, |
| 3252 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3253 | } |
| 3254 | |
| 3255 | return rval; |
| 3256 | } |
| 3257 | |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 3258 | int |
| 3259 | qla2x00_write_serdes_word(scsi_qla_host_t *vha, uint16_t addr, uint16_t data) |
| 3260 | { |
| 3261 | int rval; |
| 3262 | mbx_cmd_t mc; |
| 3263 | mbx_cmd_t *mcp = &mc; |
| 3264 | |
Joe Carnuccio | f299c7c | 2015-08-04 13:37:51 -0400 | [diff] [blame] | 3265 | if (!IS_QLA25XX(vha->hw) && !IS_QLA2031(vha->hw) && |
| 3266 | !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 3267 | return QLA_FUNCTION_FAILED; |
| 3268 | |
| 3269 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1182, |
| 3270 | "Entered %s.\n", __func__); |
| 3271 | |
| 3272 | mcp->mb[0] = MBC_WRITE_SERDES; |
| 3273 | mcp->mb[1] = addr; |
Andrew Vasquez | 064135e | 2015-04-09 15:00:02 -0400 | [diff] [blame] | 3274 | if (IS_QLA2031(vha->hw)) |
| 3275 | mcp->mb[2] = data & 0xff; |
| 3276 | else |
| 3277 | mcp->mb[2] = data; |
| 3278 | |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 3279 | mcp->mb[3] = 0; |
| 3280 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 3281 | mcp->in_mb = MBX_0; |
| 3282 | mcp->tov = MBX_TOV_SECONDS; |
| 3283 | mcp->flags = 0; |
| 3284 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3285 | |
| 3286 | if (rval != QLA_SUCCESS) { |
| 3287 | ql_dbg(ql_dbg_mbx, vha, 0x1183, |
| 3288 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 3289 | } else { |
| 3290 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1184, |
| 3291 | "Done %s.\n", __func__); |
| 3292 | } |
| 3293 | |
| 3294 | return rval; |
| 3295 | } |
| 3296 | |
| 3297 | int |
| 3298 | qla2x00_read_serdes_word(scsi_qla_host_t *vha, uint16_t addr, uint16_t *data) |
| 3299 | { |
| 3300 | int rval; |
| 3301 | mbx_cmd_t mc; |
| 3302 | mbx_cmd_t *mcp = &mc; |
| 3303 | |
Joe Carnuccio | f299c7c | 2015-08-04 13:37:51 -0400 | [diff] [blame] | 3304 | if (!IS_QLA25XX(vha->hw) && !IS_QLA2031(vha->hw) && |
| 3305 | !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 3306 | return QLA_FUNCTION_FAILED; |
| 3307 | |
| 3308 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1185, |
| 3309 | "Entered %s.\n", __func__); |
| 3310 | |
| 3311 | mcp->mb[0] = MBC_READ_SERDES; |
| 3312 | mcp->mb[1] = addr; |
| 3313 | mcp->mb[3] = 0; |
| 3314 | mcp->out_mb = MBX_3|MBX_1|MBX_0; |
| 3315 | mcp->in_mb = MBX_1|MBX_0; |
| 3316 | mcp->tov = MBX_TOV_SECONDS; |
| 3317 | mcp->flags = 0; |
| 3318 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3319 | |
Andrew Vasquez | 064135e | 2015-04-09 15:00:02 -0400 | [diff] [blame] | 3320 | if (IS_QLA2031(vha->hw)) |
| 3321 | *data = mcp->mb[1] & 0xff; |
| 3322 | else |
| 3323 | *data = mcp->mb[1]; |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 3324 | |
| 3325 | if (rval != QLA_SUCCESS) { |
| 3326 | ql_dbg(ql_dbg_mbx, vha, 0x1186, |
| 3327 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 3328 | } else { |
| 3329 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1187, |
| 3330 | "Done %s.\n", __func__); |
| 3331 | } |
| 3332 | |
| 3333 | return rval; |
| 3334 | } |
| 3335 | |
Joe Carnuccio | e8887c5 | 2014-04-11 16:54:17 -0400 | [diff] [blame] | 3336 | int |
| 3337 | qla8044_write_serdes_word(scsi_qla_host_t *vha, uint32_t addr, uint32_t data) |
| 3338 | { |
| 3339 | int rval; |
| 3340 | mbx_cmd_t mc; |
| 3341 | mbx_cmd_t *mcp = &mc; |
| 3342 | |
| 3343 | if (!IS_QLA8044(vha->hw)) |
| 3344 | return QLA_FUNCTION_FAILED; |
| 3345 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3346 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x11a0, |
Joe Carnuccio | e8887c5 | 2014-04-11 16:54:17 -0400 | [diff] [blame] | 3347 | "Entered %s.\n", __func__); |
| 3348 | |
| 3349 | mcp->mb[0] = MBC_SET_GET_ETH_SERDES_REG; |
| 3350 | mcp->mb[1] = HCS_WRITE_SERDES; |
| 3351 | mcp->mb[3] = LSW(addr); |
| 3352 | mcp->mb[4] = MSW(addr); |
| 3353 | mcp->mb[5] = LSW(data); |
| 3354 | mcp->mb[6] = MSW(data); |
| 3355 | mcp->out_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_1|MBX_0; |
| 3356 | mcp->in_mb = MBX_0; |
| 3357 | mcp->tov = MBX_TOV_SECONDS; |
| 3358 | mcp->flags = 0; |
| 3359 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3360 | |
| 3361 | if (rval != QLA_SUCCESS) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3362 | ql_dbg(ql_dbg_mbx, vha, 0x11a1, |
Joe Carnuccio | e8887c5 | 2014-04-11 16:54:17 -0400 | [diff] [blame] | 3363 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 3364 | } else { |
| 3365 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1188, |
| 3366 | "Done %s.\n", __func__); |
| 3367 | } |
| 3368 | |
| 3369 | return rval; |
| 3370 | } |
| 3371 | |
| 3372 | int |
| 3373 | qla8044_read_serdes_word(scsi_qla_host_t *vha, uint32_t addr, uint32_t *data) |
| 3374 | { |
| 3375 | int rval; |
| 3376 | mbx_cmd_t mc; |
| 3377 | mbx_cmd_t *mcp = &mc; |
| 3378 | |
| 3379 | if (!IS_QLA8044(vha->hw)) |
| 3380 | return QLA_FUNCTION_FAILED; |
| 3381 | |
| 3382 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1189, |
| 3383 | "Entered %s.\n", __func__); |
| 3384 | |
| 3385 | mcp->mb[0] = MBC_SET_GET_ETH_SERDES_REG; |
| 3386 | mcp->mb[1] = HCS_READ_SERDES; |
| 3387 | mcp->mb[3] = LSW(addr); |
| 3388 | mcp->mb[4] = MSW(addr); |
| 3389 | mcp->out_mb = MBX_4|MBX_3|MBX_1|MBX_0; |
| 3390 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 3391 | mcp->tov = MBX_TOV_SECONDS; |
| 3392 | mcp->flags = 0; |
| 3393 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3394 | |
| 3395 | *data = mcp->mb[2] << 16 | mcp->mb[1]; |
| 3396 | |
| 3397 | if (rval != QLA_SUCCESS) { |
| 3398 | ql_dbg(ql_dbg_mbx, vha, 0x118a, |
| 3399 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 3400 | } else { |
| 3401 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x118b, |
| 3402 | "Done %s.\n", __func__); |
| 3403 | } |
| 3404 | |
| 3405 | return rval; |
| 3406 | } |
| 3407 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3408 | /** |
| 3409 | * qla2x00_set_serdes_params() - |
Bart Van Assche | 2db6228 | 2018-01-23 16:33:51 -0800 | [diff] [blame] | 3410 | * @vha: HA context |
| 3411 | * @sw_em_1g: |
| 3412 | * @sw_em_2g: |
| 3413 | * @sw_em_4g: |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3414 | * |
| 3415 | * Returns |
| 3416 | */ |
| 3417 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3418 | 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] | 3419 | uint16_t sw_em_2g, uint16_t sw_em_4g) |
| 3420 | { |
| 3421 | int rval; |
| 3422 | mbx_cmd_t mc; |
| 3423 | mbx_cmd_t *mcp = &mc; |
| 3424 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3425 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109e, |
| 3426 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3427 | |
| 3428 | mcp->mb[0] = MBC_SERDES_PARAMS; |
| 3429 | mcp->mb[1] = BIT_0; |
andrew.vasquez@qlogic.com | fdbc683 | 2006-03-09 14:27:29 -0800 | [diff] [blame] | 3430 | mcp->mb[2] = sw_em_1g | BIT_15; |
| 3431 | mcp->mb[3] = sw_em_2g | BIT_15; |
| 3432 | mcp->mb[4] = sw_em_4g | BIT_15; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3433 | mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3434 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3435 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3436 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3437 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3438 | |
| 3439 | if (rval != QLA_SUCCESS) { |
| 3440 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3441 | ql_dbg(ql_dbg_mbx, vha, 0x109f, |
| 3442 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3443 | } else { |
| 3444 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3445 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a0, |
| 3446 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3447 | } |
| 3448 | |
| 3449 | return rval; |
| 3450 | } |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3451 | |
| 3452 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3453 | qla2x00_stop_firmware(scsi_qla_host_t *vha) |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3454 | { |
| 3455 | int rval; |
| 3456 | mbx_cmd_t mc; |
| 3457 | mbx_cmd_t *mcp = &mc; |
| 3458 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3459 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3460 | return QLA_FUNCTION_FAILED; |
| 3461 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3462 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a1, |
| 3463 | "Entered %s.\n", __func__); |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3464 | |
| 3465 | mcp->mb[0] = MBC_STOP_FIRMWARE; |
Andrew Vasquez | 4ba988d | 2012-02-09 11:14:06 -0800 | [diff] [blame] | 3466 | mcp->mb[1] = 0; |
| 3467 | mcp->out_mb = MBX_1|MBX_0; |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3468 | mcp->in_mb = MBX_0; |
| 3469 | mcp->tov = 5; |
| 3470 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3471 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3472 | |
| 3473 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3474 | ql_dbg(ql_dbg_mbx, vha, 0x10a2, "Failed=%x.\n", rval); |
Andrew Vasquez | b469a7c | 2009-04-06 22:33:48 -0700 | [diff] [blame] | 3475 | if (mcp->mb[0] == MBS_INVALID_COMMAND) |
| 3476 | rval = QLA_INVALID_COMMAND; |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3477 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3478 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a3, |
| 3479 | "Done %s.\n", __func__); |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3480 | } |
| 3481 | |
| 3482 | return rval; |
| 3483 | } |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3484 | |
| 3485 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3486 | 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] | 3487 | uint16_t buffers) |
| 3488 | { |
| 3489 | int rval; |
| 3490 | mbx_cmd_t mc; |
| 3491 | mbx_cmd_t *mcp = &mc; |
| 3492 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3493 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a4, |
| 3494 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3495 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3496 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3497 | return QLA_FUNCTION_FAILED; |
| 3498 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3499 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3500 | return QLA_FUNCTION_FAILED; |
| 3501 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3502 | mcp->mb[0] = MBC_TRACE_CONTROL; |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3503 | mcp->mb[1] = TC_EFT_ENABLE; |
| 3504 | mcp->mb[2] = LSW(eft_dma); |
| 3505 | mcp->mb[3] = MSW(eft_dma); |
| 3506 | mcp->mb[4] = LSW(MSD(eft_dma)); |
| 3507 | mcp->mb[5] = MSW(MSD(eft_dma)); |
| 3508 | mcp->mb[6] = buffers; |
| 3509 | mcp->mb[7] = TC_AEN_DISABLE; |
| 3510 | 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] | 3511 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3512 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3513 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3514 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3515 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3516 | ql_dbg(ql_dbg_mbx, vha, 0x10a5, |
| 3517 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3518 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3519 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3520 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a6, |
| 3521 | "Done %s.\n", __func__); |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3522 | } |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3523 | |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3524 | return rval; |
| 3525 | } |
| 3526 | |
| 3527 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3528 | qla2x00_disable_eft_trace(scsi_qla_host_t *vha) |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3529 | { |
| 3530 | int rval; |
| 3531 | mbx_cmd_t mc; |
| 3532 | mbx_cmd_t *mcp = &mc; |
| 3533 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3534 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a7, |
| 3535 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3536 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3537 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3538 | return QLA_FUNCTION_FAILED; |
| 3539 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3540 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3541 | return QLA_FUNCTION_FAILED; |
| 3542 | |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3543 | mcp->mb[0] = MBC_TRACE_CONTROL; |
| 3544 | mcp->mb[1] = TC_EFT_DISABLE; |
| 3545 | mcp->out_mb = MBX_1|MBX_0; |
| 3546 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3547 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3548 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3549 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3550 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3551 | ql_dbg(ql_dbg_mbx, vha, 0x10a8, |
| 3552 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3553 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3554 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3555 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a9, |
| 3556 | "Done %s.\n", __func__); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3557 | } |
| 3558 | |
| 3559 | return rval; |
| 3560 | } |
| 3561 | |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 3562 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3563 | 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] | 3564 | uint16_t buffers, uint16_t *mb, uint32_t *dwords) |
| 3565 | { |
| 3566 | int rval; |
| 3567 | mbx_cmd_t mc; |
| 3568 | mbx_cmd_t *mcp = &mc; |
| 3569 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3570 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10aa, |
| 3571 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3572 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3573 | if (!IS_QLA25XX(vha->hw) && !IS_QLA81XX(vha->hw) && |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3574 | !IS_QLA83XX(vha->hw) && !IS_QLA27XX(vha->hw)) |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3575 | return QLA_FUNCTION_FAILED; |
| 3576 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3577 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3578 | return QLA_FUNCTION_FAILED; |
| 3579 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3580 | mcp->mb[0] = MBC_TRACE_CONTROL; |
| 3581 | mcp->mb[1] = TC_FCE_ENABLE; |
| 3582 | mcp->mb[2] = LSW(fce_dma); |
| 3583 | mcp->mb[3] = MSW(fce_dma); |
| 3584 | mcp->mb[4] = LSW(MSD(fce_dma)); |
| 3585 | mcp->mb[5] = MSW(MSD(fce_dma)); |
| 3586 | mcp->mb[6] = buffers; |
| 3587 | mcp->mb[7] = TC_AEN_DISABLE; |
| 3588 | mcp->mb[8] = 0; |
| 3589 | mcp->mb[9] = TC_FCE_DEFAULT_RX_SIZE; |
| 3590 | mcp->mb[10] = TC_FCE_DEFAULT_TX_SIZE; |
| 3591 | mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2| |
| 3592 | MBX_1|MBX_0; |
| 3593 | 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] | 3594 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3595 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3596 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3597 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3598 | ql_dbg(ql_dbg_mbx, vha, 0x10ab, |
| 3599 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3600 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3601 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3602 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ac, |
| 3603 | "Done %s.\n", __func__); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3604 | |
| 3605 | if (mb) |
| 3606 | memcpy(mb, mcp->mb, 8 * sizeof(*mb)); |
| 3607 | if (dwords) |
Andrew Vasquez | fa0926d | 2008-05-12 22:21:12 -0700 | [diff] [blame] | 3608 | *dwords = buffers; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3609 | } |
| 3610 | |
| 3611 | return rval; |
| 3612 | } |
| 3613 | |
| 3614 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3615 | 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] | 3616 | { |
| 3617 | int rval; |
| 3618 | mbx_cmd_t mc; |
| 3619 | mbx_cmd_t *mcp = &mc; |
| 3620 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3621 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ad, |
| 3622 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3623 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3624 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3625 | return QLA_FUNCTION_FAILED; |
| 3626 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3627 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3628 | return QLA_FUNCTION_FAILED; |
| 3629 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3630 | mcp->mb[0] = MBC_TRACE_CONTROL; |
| 3631 | mcp->mb[1] = TC_FCE_DISABLE; |
| 3632 | mcp->mb[2] = TC_FCE_DISABLE_TRACE; |
| 3633 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 3634 | mcp->in_mb = MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2| |
| 3635 | MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3636 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3637 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3638 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3639 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3640 | ql_dbg(ql_dbg_mbx, vha, 0x10ae, |
| 3641 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3642 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3643 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3644 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10af, |
| 3645 | "Done %s.\n", __func__); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3646 | |
| 3647 | if (wr) |
| 3648 | *wr = (uint64_t) mcp->mb[5] << 48 | |
| 3649 | (uint64_t) mcp->mb[4] << 32 | |
| 3650 | (uint64_t) mcp->mb[3] << 16 | |
| 3651 | (uint64_t) mcp->mb[2]; |
| 3652 | if (rd) |
| 3653 | *rd = (uint64_t) mcp->mb[9] << 48 | |
| 3654 | (uint64_t) mcp->mb[8] << 32 | |
| 3655 | (uint64_t) mcp->mb[7] << 16 | |
| 3656 | (uint64_t) mcp->mb[6]; |
| 3657 | } |
| 3658 | |
| 3659 | return rval; |
| 3660 | } |
| 3661 | |
| 3662 | int |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3663 | qla2x00_get_idma_speed(scsi_qla_host_t *vha, uint16_t loop_id, |
| 3664 | uint16_t *port_speed, uint16_t *mb) |
| 3665 | { |
| 3666 | int rval; |
| 3667 | mbx_cmd_t mc; |
| 3668 | mbx_cmd_t *mcp = &mc; |
| 3669 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3670 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b0, |
| 3671 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3672 | |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3673 | if (!IS_IIDMA_CAPABLE(vha->hw)) |
| 3674 | return QLA_FUNCTION_FAILED; |
| 3675 | |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3676 | mcp->mb[0] = MBC_PORT_PARAMS; |
| 3677 | mcp->mb[1] = loop_id; |
| 3678 | mcp->mb[2] = mcp->mb[3] = 0; |
| 3679 | mcp->mb[9] = vha->vp_idx; |
| 3680 | mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3681 | mcp->in_mb = MBX_3|MBX_1|MBX_0; |
| 3682 | mcp->tov = MBX_TOV_SECONDS; |
| 3683 | mcp->flags = 0; |
| 3684 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3685 | |
| 3686 | /* Return mailbox statuses. */ |
| 3687 | if (mb != NULL) { |
| 3688 | mb[0] = mcp->mb[0]; |
| 3689 | mb[1] = mcp->mb[1]; |
| 3690 | mb[3] = mcp->mb[3]; |
| 3691 | } |
| 3692 | |
| 3693 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3694 | ql_dbg(ql_dbg_mbx, vha, 0x10b1, "Failed=%x.\n", rval); |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3695 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3696 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b2, |
| 3697 | "Done %s.\n", __func__); |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3698 | if (port_speed) |
| 3699 | *port_speed = mcp->mb[3]; |
| 3700 | } |
| 3701 | |
| 3702 | return rval; |
| 3703 | } |
| 3704 | |
| 3705 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3706 | 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] | 3707 | uint16_t port_speed, uint16_t *mb) |
| 3708 | { |
| 3709 | int rval; |
| 3710 | mbx_cmd_t mc; |
| 3711 | mbx_cmd_t *mcp = &mc; |
| 3712 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3713 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b3, |
| 3714 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3715 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3716 | if (!IS_IIDMA_CAPABLE(vha->hw)) |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3717 | return QLA_FUNCTION_FAILED; |
| 3718 | |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3719 | mcp->mb[0] = MBC_PORT_PARAMS; |
| 3720 | mcp->mb[1] = loop_id; |
| 3721 | mcp->mb[2] = BIT_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3722 | if (IS_CNA_CAPABLE(vha->hw)) |
Harish Zunjarrao | 1bb3954 | 2009-06-17 10:30:29 -0700 | [diff] [blame] | 3723 | mcp->mb[3] = port_speed & (BIT_5|BIT_4|BIT_3|BIT_2|BIT_1|BIT_0); |
| 3724 | else |
| 3725 | mcp->mb[3] = port_speed & (BIT_2|BIT_1|BIT_0); |
| 3726 | mcp->mb[9] = vha->vp_idx; |
| 3727 | mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3728 | mcp->in_mb = MBX_3|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3729 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3730 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3731 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3732 | |
| 3733 | /* Return mailbox statuses. */ |
| 3734 | if (mb != NULL) { |
| 3735 | mb[0] = mcp->mb[0]; |
| 3736 | mb[1] = mcp->mb[1]; |
| 3737 | mb[3] = mcp->mb[3]; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3738 | } |
| 3739 | |
| 3740 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3741 | ql_dbg(ql_dbg_mbx, vha, 0x10b4, |
| 3742 | "Failed=%x.\n", rval); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3743 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3744 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b5, |
| 3745 | "Done %s.\n", __func__); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3746 | } |
| 3747 | |
| 3748 | return rval; |
| 3749 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3750 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3751 | void |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3752 | qla24xx_report_id_acquisition(scsi_qla_host_t *vha, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3753 | struct vp_rpt_id_entry_24xx *rptid_entry) |
| 3754 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3755 | struct qla_hw_data *ha = vha->hw; |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3756 | scsi_qla_host_t *vp = NULL; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3757 | unsigned long flags; |
Andrew Vasquez | 4ac8d4ca | 2013-02-08 01:57:58 -0500 | [diff] [blame] | 3758 | int found; |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3759 | port_id_t id; |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 3760 | struct fc_port *fcport; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3761 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3762 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b6, |
| 3763 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3764 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3765 | if (rptid_entry->entry_status != 0) |
| 3766 | return; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3767 | |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3768 | id.b.domain = rptid_entry->port_id[2]; |
| 3769 | id.b.area = rptid_entry->port_id[1]; |
| 3770 | id.b.al_pa = rptid_entry->port_id[0]; |
| 3771 | id.b.rsvd_1 = 0; |
Darren Trapp | 1763c1f | 2018-03-20 23:09:34 -0700 | [diff] [blame] | 3772 | ha->flags.n2n_ae = 0; |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3773 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3774 | if (rptid_entry->format == 0) { |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3775 | /* loop */ |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 3776 | ql_dbg(ql_dbg_async, vha, 0x10b7, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3777 | "Format 0 : Number of VPs setup %d, number of " |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3778 | "VPs acquired %d.\n", rptid_entry->vp_setup, |
| 3779 | rptid_entry->vp_acquired); |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 3780 | ql_dbg(ql_dbg_async, vha, 0x10b8, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3781 | "Primary port id %02x%02x%02x.\n", |
| 3782 | rptid_entry->port_id[2], rptid_entry->port_id[1], |
| 3783 | rptid_entry->port_id[0]); |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 3784 | ha->current_topology = ISP_CFG_NL; |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3785 | qlt_update_host_map(vha, id); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3786 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3787 | } else if (rptid_entry->format == 1) { |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3788 | /* fabric */ |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 3789 | ql_dbg(ql_dbg_async, vha, 0x10b9, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3790 | "Format 1: VP[%d] enabled - status %d - with " |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3791 | "port id %02x%02x%02x.\n", rptid_entry->vp_idx, |
| 3792 | rptid_entry->vp_status, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3793 | rptid_entry->port_id[2], rptid_entry->port_id[1], |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3794 | rptid_entry->port_id[0]); |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 3795 | ql_dbg(ql_dbg_async, vha, 0x5075, |
| 3796 | "Format 1: Remote WWPN %8phC.\n", |
| 3797 | rptid_entry->u.f1.port_name); |
| 3798 | |
| 3799 | ql_dbg(ql_dbg_async, vha, 0x5075, |
| 3800 | "Format 1: WWPN %8phC.\n", |
| 3801 | vha->port_name); |
| 3802 | |
| 3803 | /* N2N. direct connect */ |
| 3804 | if (IS_QLA27XX(ha) && |
| 3805 | ((rptid_entry->u.f1.flags>>1) & 0x7) == 2) { |
| 3806 | /* if our portname is higher then initiate N2N login */ |
| 3807 | if (wwn_to_u64(vha->port_name) > |
| 3808 | wwn_to_u64(rptid_entry->u.f1.port_name)) { |
| 3809 | // ??? qlt_update_host_map(vha, id); |
| 3810 | vha->n2n_id = 0x1; |
| 3811 | ql_dbg(ql_dbg_async, vha, 0x5075, |
| 3812 | "Format 1: Setting n2n_update_needed for id %d\n", |
| 3813 | vha->n2n_id); |
| 3814 | } else { |
| 3815 | ql_dbg(ql_dbg_async, vha, 0x5075, |
| 3816 | "Format 1: Remote login - Waiting for WWPN %8phC.\n", |
| 3817 | rptid_entry->u.f1.port_name); |
| 3818 | } |
| 3819 | |
| 3820 | memcpy(vha->n2n_port_name, rptid_entry->u.f1.port_name, |
| 3821 | WWN_SIZE); |
| 3822 | set_bit(N2N_LOGIN_NEEDED, &vha->dpc_flags); |
| 3823 | set_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags); |
| 3824 | set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags); |
Darren Trapp | 1763c1f | 2018-03-20 23:09:34 -0700 | [diff] [blame] | 3825 | ha->flags.n2n_ae = 1; |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 3826 | return; |
| 3827 | } |
Andrew Vasquez | 531a82d | 2009-10-13 15:16:51 -0700 | [diff] [blame] | 3828 | |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 3829 | ha->flags.gpsc_supported = 1; |
| 3830 | ha->current_topology = ISP_CFG_F; |
Sawan Chandak | 969a619 | 2016-01-27 12:03:32 -0500 | [diff] [blame] | 3831 | /* buffer to buffer credit flag */ |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3832 | vha->flags.bbcr_enable = (rptid_entry->u.f1.bbcr & 0xf) != 0; |
Sawan Chandak | 969a619 | 2016-01-27 12:03:32 -0500 | [diff] [blame] | 3833 | |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3834 | if (rptid_entry->vp_idx == 0) { |
| 3835 | if (rptid_entry->vp_status == VP_STAT_COMPL) { |
| 3836 | /* FA-WWN is only for physical port */ |
| 3837 | if (qla_ini_mode_enabled(vha) && |
| 3838 | ha->flags.fawwpn_enabled && |
| 3839 | (rptid_entry->u.f1.flags & |
Sawan Chandak | fcc5b5c | 2017-08-23 15:05:02 -0700 | [diff] [blame] | 3840 | BIT_6)) { |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3841 | memcpy(vha->port_name, |
| 3842 | rptid_entry->u.f1.port_name, |
| 3843 | WWN_SIZE); |
| 3844 | } |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 3845 | |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3846 | qlt_update_host_map(vha, id); |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 3847 | } |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3848 | |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3849 | set_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags); |
| 3850 | set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags); |
| 3851 | } else { |
| 3852 | if (rptid_entry->vp_status != VP_STAT_COMPL && |
| 3853 | rptid_entry->vp_status != VP_STAT_ID_CHG) { |
| 3854 | ql_dbg(ql_dbg_mbx, vha, 0x10ba, |
| 3855 | "Could not acquire ID for VP[%d].\n", |
| 3856 | rptid_entry->vp_idx); |
| 3857 | return; |
Andrew Vasquez | 4ac8d4ca | 2013-02-08 01:57:58 -0500 | [diff] [blame] | 3858 | } |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3859 | |
| 3860 | found = 0; |
| 3861 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 3862 | list_for_each_entry(vp, &ha->vp_list, list) { |
| 3863 | if (rptid_entry->vp_idx == vp->vp_idx) { |
| 3864 | found = 1; |
| 3865 | break; |
| 3866 | } |
| 3867 | } |
| 3868 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 3869 | |
| 3870 | if (!found) |
| 3871 | return; |
| 3872 | |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3873 | qlt_update_host_map(vp, id); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3874 | |
| 3875 | /* |
| 3876 | * Cannot configure here as we are still sitting on the |
| 3877 | * response queue. Handle it in dpc context. |
| 3878 | */ |
| 3879 | set_bit(VP_IDX_ACQUIRED, &vp->vp_flags); |
| 3880 | set_bit(REGISTER_FC4_NEEDED, &vp->dpc_flags); |
| 3881 | set_bit(REGISTER_FDMI_NEEDED, &vp->dpc_flags); |
Andrew Vasquez | 4ac8d4ca | 2013-02-08 01:57:58 -0500 | [diff] [blame] | 3882 | } |
Andrew Vasquez | 531a82d | 2009-10-13 15:16:51 -0700 | [diff] [blame] | 3883 | set_bit(VP_DPC_NEEDED, &vha->dpc_flags); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3884 | qla2xxx_wake_dpc(vha); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3885 | } else if (rptid_entry->format == 2) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3886 | ql_dbg(ql_dbg_async, vha, 0x505f, |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3887 | "RIDA: format 2/N2N Primary port id %02x%02x%02x.\n", |
| 3888 | rptid_entry->port_id[2], rptid_entry->port_id[1], |
| 3889 | rptid_entry->port_id[0]); |
| 3890 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3891 | ql_dbg(ql_dbg_async, vha, 0x5075, |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3892 | "N2N: Remote WWPN %8phC.\n", |
| 3893 | rptid_entry->u.f2.port_name); |
| 3894 | |
| 3895 | /* N2N. direct connect */ |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 3896 | ha->current_topology = ISP_CFG_N; |
| 3897 | ha->flags.rida_fmt2 = 1; |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3898 | vha->d_id.b.domain = rptid_entry->port_id[2]; |
| 3899 | vha->d_id.b.area = rptid_entry->port_id[1]; |
| 3900 | vha->d_id.b.al_pa = rptid_entry->port_id[0]; |
| 3901 | |
Darren Trapp | 1763c1f | 2018-03-20 23:09:34 -0700 | [diff] [blame] | 3902 | ha->flags.n2n_ae = 1; |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3903 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 3904 | qlt_update_vp_map(vha, SET_AL_PA); |
| 3905 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 3906 | |
| 3907 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 3908 | fcport->scan_state = QLA_FCPORT_SCAN; |
| 3909 | } |
| 3910 | |
| 3911 | fcport = qla2x00_find_fcport_by_wwpn(vha, |
| 3912 | rptid_entry->u.f2.port_name, 1); |
| 3913 | |
| 3914 | if (fcport) { |
Quinn Tran | 23dd98a | 2018-08-02 13:16:45 -0700 | [diff] [blame^] | 3915 | fcport->login_retry = vha->hw->login_retry_count; |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 3916 | fcport->plogi_nack_done_deadline = jiffies + HZ; |
| 3917 | fcport->scan_state = QLA_FCPORT_FOUND; |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 3918 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3919 | } |
| 3920 | } |
| 3921 | |
| 3922 | /* |
| 3923 | * qla24xx_modify_vp_config |
| 3924 | * Change VP configuration for vha |
| 3925 | * |
| 3926 | * Input: |
| 3927 | * vha = adapter block pointer. |
| 3928 | * |
| 3929 | * Returns: |
| 3930 | * qla2xxx local function return status code. |
| 3931 | * |
| 3932 | * Context: |
| 3933 | * Kernel context. |
| 3934 | */ |
| 3935 | int |
| 3936 | qla24xx_modify_vp_config(scsi_qla_host_t *vha) |
| 3937 | { |
| 3938 | int rval; |
| 3939 | struct vp_config_entry_24xx *vpmod; |
| 3940 | dma_addr_t vpmod_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3941 | struct qla_hw_data *ha = vha->hw; |
| 3942 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3943 | |
| 3944 | /* This can be called by the parent */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3945 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3946 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10bb, |
| 3947 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3948 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 3949 | vpmod = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &vpmod_dma); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3950 | if (!vpmod) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3951 | ql_log(ql_log_warn, vha, 0x10bc, |
| 3952 | "Failed to allocate modify VP IOCB.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3953 | return QLA_MEMORY_ALLOC_FAILED; |
| 3954 | } |
| 3955 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3956 | vpmod->entry_type = VP_CONFIG_IOCB_TYPE; |
| 3957 | vpmod->entry_count = 1; |
| 3958 | vpmod->command = VCT_COMMAND_MOD_ENABLE_VPS; |
| 3959 | vpmod->vp_count = 1; |
| 3960 | vpmod->vp_index1 = vha->vp_idx; |
| 3961 | vpmod->options_idx1 = BIT_3|BIT_4|BIT_5; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3962 | |
| 3963 | qlt_modify_vp_config(vha, vpmod); |
| 3964 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3965 | memcpy(vpmod->node_name_idx1, vha->node_name, WWN_SIZE); |
| 3966 | memcpy(vpmod->port_name_idx1, vha->port_name, WWN_SIZE); |
| 3967 | vpmod->entry_count = 1; |
| 3968 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3969 | rval = qla2x00_issue_iocb(base_vha, vpmod, vpmod_dma, 0); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3970 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3971 | ql_dbg(ql_dbg_mbx, vha, 0x10bd, |
| 3972 | "Failed to issue VP config IOCB (%x).\n", rval); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3973 | } else if (vpmod->comp_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3974 | ql_dbg(ql_dbg_mbx, vha, 0x10be, |
| 3975 | "Failed to complete IOCB -- error status (%x).\n", |
| 3976 | vpmod->comp_status); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3977 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 3978 | } else if (vpmod->comp_status != cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3979 | ql_dbg(ql_dbg_mbx, vha, 0x10bf, |
| 3980 | "Failed to complete IOCB -- completion status (%x).\n", |
| 3981 | le16_to_cpu(vpmod->comp_status)); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3982 | rval = QLA_FUNCTION_FAILED; |
| 3983 | } else { |
| 3984 | /* EMPTY */ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3985 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c0, |
| 3986 | "Done %s.\n", __func__); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3987 | fc_vport_set_state(vha->fc_vport, FC_VPORT_INITIALIZING); |
| 3988 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3989 | dma_pool_free(ha->s_dma_pool, vpmod, vpmod_dma); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3990 | |
| 3991 | return rval; |
| 3992 | } |
| 3993 | |
| 3994 | /* |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3995 | * qla2x00_send_change_request |
| 3996 | * Receive or disable RSCN request from fabric controller |
| 3997 | * |
| 3998 | * Input: |
| 3999 | * ha = adapter block pointer |
| 4000 | * format = registration format: |
| 4001 | * 0 - Reserved |
| 4002 | * 1 - Fabric detected registration |
| 4003 | * 2 - N_port detected registration |
| 4004 | * 3 - Full registration |
| 4005 | * FF - clear registration |
| 4006 | * vp_idx = Virtual port index |
| 4007 | * |
| 4008 | * Returns: |
| 4009 | * qla2x00 local function return status code. |
| 4010 | * |
| 4011 | * Context: |
| 4012 | * Kernel Context |
| 4013 | */ |
| 4014 | |
| 4015 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4016 | qla2x00_send_change_request(scsi_qla_host_t *vha, uint16_t format, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4017 | uint16_t vp_idx) |
| 4018 | { |
| 4019 | int rval; |
| 4020 | mbx_cmd_t mc; |
| 4021 | mbx_cmd_t *mcp = &mc; |
| 4022 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4023 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c7, |
| 4024 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4025 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4026 | mcp->mb[0] = MBC_SEND_CHANGE_REQUEST; |
| 4027 | mcp->mb[1] = format; |
| 4028 | mcp->mb[9] = vp_idx; |
| 4029 | mcp->out_mb = MBX_9|MBX_1|MBX_0; |
| 4030 | mcp->in_mb = MBX_0|MBX_1; |
| 4031 | mcp->tov = MBX_TOV_SECONDS; |
| 4032 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4033 | rval = qla2x00_mailbox_command(vha, mcp); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4034 | |
| 4035 | if (rval == QLA_SUCCESS) { |
| 4036 | if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { |
| 4037 | rval = BIT_1; |
| 4038 | } |
| 4039 | } else |
| 4040 | rval = BIT_1; |
| 4041 | |
| 4042 | return rval; |
| 4043 | } |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4044 | |
| 4045 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4046 | 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] | 4047 | uint32_t size) |
| 4048 | { |
| 4049 | int rval; |
| 4050 | mbx_cmd_t mc; |
| 4051 | mbx_cmd_t *mcp = &mc; |
| 4052 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4053 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1009, |
| 4054 | "Entered %s.\n", __func__); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4055 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4056 | if (MSW(addr) || IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4057 | mcp->mb[0] = MBC_DUMP_RISC_RAM_EXTENDED; |
| 4058 | mcp->mb[8] = MSW(addr); |
| 4059 | mcp->out_mb = MBX_8|MBX_0; |
| 4060 | } else { |
| 4061 | mcp->mb[0] = MBC_DUMP_RISC_RAM; |
| 4062 | mcp->out_mb = MBX_0; |
| 4063 | } |
| 4064 | mcp->mb[1] = LSW(addr); |
| 4065 | mcp->mb[2] = MSW(req_dma); |
| 4066 | mcp->mb[3] = LSW(req_dma); |
| 4067 | mcp->mb[6] = MSW(MSD(req_dma)); |
| 4068 | mcp->mb[7] = LSW(MSD(req_dma)); |
| 4069 | 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] | 4070 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4071 | mcp->mb[4] = MSW(size); |
| 4072 | mcp->mb[5] = LSW(size); |
| 4073 | mcp->out_mb |= MBX_5|MBX_4; |
| 4074 | } else { |
| 4075 | mcp->mb[4] = LSW(size); |
| 4076 | mcp->out_mb |= MBX_4; |
| 4077 | } |
| 4078 | |
| 4079 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 4080 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4081 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4082 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4083 | |
| 4084 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4085 | ql_dbg(ql_dbg_mbx, vha, 0x1008, |
| 4086 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4087 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4088 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1007, |
| 4089 | "Done %s.\n", __func__); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4090 | } |
| 4091 | |
| 4092 | return rval; |
| 4093 | } |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4094 | /* 84XX Support **************************************************************/ |
| 4095 | |
| 4096 | struct cs84xx_mgmt_cmd { |
| 4097 | union { |
| 4098 | struct verify_chip_entry_84xx req; |
| 4099 | struct verify_chip_rsp_84xx rsp; |
| 4100 | } p; |
| 4101 | }; |
| 4102 | |
| 4103 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4104 | qla84xx_verify_chip(struct scsi_qla_host *vha, uint16_t *status) |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4105 | { |
| 4106 | int rval, retry; |
| 4107 | struct cs84xx_mgmt_cmd *mn; |
| 4108 | dma_addr_t mn_dma; |
| 4109 | uint16_t options; |
| 4110 | unsigned long flags; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4111 | struct qla_hw_data *ha = vha->hw; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4112 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4113 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c8, |
| 4114 | "Entered %s.\n", __func__); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4115 | |
| 4116 | mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma); |
| 4117 | if (mn == NULL) { |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4118 | return QLA_MEMORY_ALLOC_FAILED; |
| 4119 | } |
| 4120 | |
| 4121 | /* Force Update? */ |
| 4122 | options = ha->cs84xx->fw_update ? VCO_FORCE_UPDATE : 0; |
| 4123 | /* Diagnostic firmware? */ |
| 4124 | /* options |= MENLO_DIAG_FW; */ |
| 4125 | /* We update the firmware with only one data sequence. */ |
| 4126 | options |= VCO_END_OF_DATA; |
| 4127 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4128 | do { |
Andrew Vasquez | c1ec1f1 | 2008-04-24 15:21:24 -0700 | [diff] [blame] | 4129 | retry = 0; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4130 | memset(mn, 0, sizeof(*mn)); |
| 4131 | mn->p.req.entry_type = VERIFY_CHIP_IOCB_TYPE; |
| 4132 | mn->p.req.entry_count = 1; |
| 4133 | mn->p.req.options = cpu_to_le16(options); |
| 4134 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4135 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111c, |
| 4136 | "Dump of Verify Request.\n"); |
| 4137 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111e, |
| 4138 | (uint8_t *)mn, sizeof(*mn)); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4139 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4140 | rval = qla2x00_issue_iocb_timeout(vha, mn, mn_dma, 0, 120); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4141 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4142 | ql_dbg(ql_dbg_mbx, vha, 0x10cb, |
| 4143 | "Failed to issue verify IOCB (%x).\n", rval); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4144 | goto verify_done; |
| 4145 | } |
| 4146 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4147 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1110, |
| 4148 | "Dump of Verify Response.\n"); |
| 4149 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1118, |
| 4150 | (uint8_t *)mn, sizeof(*mn)); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4151 | |
| 4152 | status[0] = le16_to_cpu(mn->p.rsp.comp_status); |
| 4153 | status[1] = status[0] == CS_VCS_CHIP_FAILURE ? |
| 4154 | le16_to_cpu(mn->p.rsp.failure_code) : 0; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4155 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ce, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4156 | "cs=%x fc=%x.\n", status[0], status[1]); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4157 | |
| 4158 | if (status[0] != CS_COMPLETE) { |
| 4159 | rval = QLA_FUNCTION_FAILED; |
| 4160 | if (!(options & VCO_DONT_UPDATE_FW)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4161 | ql_dbg(ql_dbg_mbx, vha, 0x10cf, |
| 4162 | "Firmware update failed. Retrying " |
| 4163 | "without update firmware.\n"); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4164 | options |= VCO_DONT_UPDATE_FW; |
| 4165 | options &= ~VCO_FORCE_UPDATE; |
| 4166 | retry = 1; |
| 4167 | } |
| 4168 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4169 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d0, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4170 | "Firmware updated to %x.\n", |
| 4171 | le32_to_cpu(mn->p.rsp.fw_ver)); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4172 | |
| 4173 | /* NOTE: we only update OP firmware. */ |
| 4174 | spin_lock_irqsave(&ha->cs84xx->access_lock, flags); |
| 4175 | ha->cs84xx->op_fw_version = |
| 4176 | le32_to_cpu(mn->p.rsp.fw_ver); |
| 4177 | spin_unlock_irqrestore(&ha->cs84xx->access_lock, |
| 4178 | flags); |
| 4179 | } |
| 4180 | } while (retry); |
| 4181 | |
| 4182 | verify_done: |
| 4183 | dma_pool_free(ha->s_dma_pool, mn, mn_dma); |
| 4184 | |
| 4185 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4186 | ql_dbg(ql_dbg_mbx, vha, 0x10d1, |
| 4187 | "Failed=%x.\n", rval); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4188 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4189 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d2, |
| 4190 | "Done %s.\n", __func__); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4191 | } |
| 4192 | |
| 4193 | return rval; |
| 4194 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4195 | |
| 4196 | int |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4197 | 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] | 4198 | { |
| 4199 | int rval; |
| 4200 | unsigned long flags; |
| 4201 | mbx_cmd_t mc; |
| 4202 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4203 | struct qla_hw_data *ha = vha->hw; |
| 4204 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4205 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d3, |
| 4206 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4207 | |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 4208 | if (IS_SHADOW_REG_CAPABLE(ha)) |
| 4209 | req->options |= BIT_13; |
| 4210 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4211 | mcp->mb[0] = MBC_INITIALIZE_MULTIQ; |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4212 | mcp->mb[1] = req->options; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4213 | mcp->mb[2] = MSW(LSD(req->dma)); |
| 4214 | mcp->mb[3] = LSW(LSD(req->dma)); |
| 4215 | mcp->mb[6] = MSW(MSD(req->dma)); |
| 4216 | mcp->mb[7] = LSW(MSD(req->dma)); |
| 4217 | mcp->mb[5] = req->length; |
| 4218 | if (req->rsp) |
| 4219 | mcp->mb[10] = req->rsp->id; |
| 4220 | mcp->mb[12] = req->qos; |
| 4221 | mcp->mb[11] = req->vp_idx; |
| 4222 | mcp->mb[13] = req->rid; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4223 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4224 | mcp->mb[15] = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4225 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4226 | mcp->mb[4] = req->id; |
| 4227 | /* que in ptr index */ |
| 4228 | mcp->mb[8] = 0; |
| 4229 | /* que out ptr index */ |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 4230 | mcp->mb[9] = *req->out_ptr = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4231 | mcp->out_mb = MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8|MBX_7| |
| 4232 | MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4233 | mcp->in_mb = MBX_0; |
| 4234 | mcp->flags = MBX_DMA_OUT; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4235 | mcp->tov = MBX_TOV_SECONDS * 2; |
| 4236 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4237 | if (IS_QLA81XX(ha) || IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4238 | mcp->in_mb |= MBX_1; |
Joe Carnuccio | ba4828b | 2014-04-11 16:54:10 -0400 | [diff] [blame] | 4239 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4240 | mcp->out_mb |= MBX_15; |
| 4241 | /* debug q create issue in SR-IOV */ |
| 4242 | mcp->in_mb |= MBX_9 | MBX_8 | MBX_7; |
| 4243 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4244 | |
| 4245 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4246 | if (!(req->options & BIT_0)) { |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 4247 | WRT_REG_DWORD(req->req_q_in, 0); |
Joe Carnuccio | 29db41c | 2014-04-11 16:54:09 -0400 | [diff] [blame] | 4248 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 4249 | WRT_REG_DWORD(req->req_q_out, 0); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4250 | } |
| 4251 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 4252 | |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 4253 | rval = qla2x00_mailbox_command(vha, mcp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4254 | if (rval != QLA_SUCCESS) { |
| 4255 | ql_dbg(ql_dbg_mbx, vha, 0x10d4, |
| 4256 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 4257 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4258 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d5, |
| 4259 | "Done %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4260 | } |
| 4261 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4262 | return rval; |
| 4263 | } |
| 4264 | |
| 4265 | int |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4266 | 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] | 4267 | { |
| 4268 | int rval; |
| 4269 | unsigned long flags; |
| 4270 | mbx_cmd_t mc; |
| 4271 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4272 | struct qla_hw_data *ha = vha->hw; |
| 4273 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4274 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d6, |
| 4275 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4276 | |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 4277 | if (IS_SHADOW_REG_CAPABLE(ha)) |
| 4278 | rsp->options |= BIT_13; |
| 4279 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4280 | mcp->mb[0] = MBC_INITIALIZE_MULTIQ; |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4281 | mcp->mb[1] = rsp->options; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4282 | mcp->mb[2] = MSW(LSD(rsp->dma)); |
| 4283 | mcp->mb[3] = LSW(LSD(rsp->dma)); |
| 4284 | mcp->mb[6] = MSW(MSD(rsp->dma)); |
| 4285 | mcp->mb[7] = LSW(MSD(rsp->dma)); |
| 4286 | mcp->mb[5] = rsp->length; |
Andrew Vasquez | 444786d | 2009-01-05 11:18:10 -0800 | [diff] [blame] | 4287 | mcp->mb[14] = rsp->msix->entry; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4288 | mcp->mb[13] = rsp->rid; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4289 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4290 | mcp->mb[15] = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4291 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4292 | mcp->mb[4] = rsp->id; |
| 4293 | /* que in ptr index */ |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 4294 | mcp->mb[8] = *rsp->in_ptr = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4295 | /* que out ptr index */ |
| 4296 | mcp->mb[9] = 0; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 4297 | 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] | 4298 | |MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4299 | mcp->in_mb = MBX_0; |
| 4300 | mcp->flags = MBX_DMA_OUT; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4301 | mcp->tov = MBX_TOV_SECONDS * 2; |
| 4302 | |
| 4303 | if (IS_QLA81XX(ha)) { |
| 4304 | mcp->out_mb |= MBX_12|MBX_11|MBX_10; |
| 4305 | mcp->in_mb |= MBX_1; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4306 | } else if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4307 | mcp->out_mb |= MBX_15|MBX_12|MBX_11|MBX_10; |
| 4308 | mcp->in_mb |= MBX_1; |
| 4309 | /* debug q create issue in SR-IOV */ |
| 4310 | mcp->in_mb |= MBX_9 | MBX_8 | MBX_7; |
| 4311 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4312 | |
| 4313 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4314 | if (!(rsp->options & BIT_0)) { |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 4315 | WRT_REG_DWORD(rsp->rsp_q_out, 0); |
Himanshu Madhani | b20f02e | 2015-06-10 11:05:18 -0400 | [diff] [blame] | 4316 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 4317 | WRT_REG_DWORD(rsp->rsp_q_in, 0); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4318 | } |
| 4319 | |
| 4320 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 4321 | |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 4322 | rval = qla2x00_mailbox_command(vha, mcp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4323 | if (rval != QLA_SUCCESS) { |
| 4324 | ql_dbg(ql_dbg_mbx, vha, 0x10d7, |
| 4325 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 4326 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4327 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d8, |
| 4328 | "Done %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4329 | } |
| 4330 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4331 | return rval; |
| 4332 | } |
| 4333 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4334 | int |
| 4335 | qla81xx_idc_ack(scsi_qla_host_t *vha, uint16_t *mb) |
| 4336 | { |
| 4337 | int rval; |
| 4338 | mbx_cmd_t mc; |
| 4339 | mbx_cmd_t *mcp = &mc; |
| 4340 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4341 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d9, |
| 4342 | "Entered %s.\n", __func__); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4343 | |
| 4344 | mcp->mb[0] = MBC_IDC_ACK; |
| 4345 | memcpy(&mcp->mb[1], mb, QLA_IDC_ACK_REGS * sizeof(uint16_t)); |
| 4346 | mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4347 | mcp->in_mb = MBX_0; |
| 4348 | mcp->tov = MBX_TOV_SECONDS; |
| 4349 | mcp->flags = 0; |
| 4350 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4351 | |
| 4352 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4353 | ql_dbg(ql_dbg_mbx, vha, 0x10da, |
| 4354 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4355 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4356 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10db, |
| 4357 | "Done %s.\n", __func__); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4358 | } |
| 4359 | |
| 4360 | return rval; |
| 4361 | } |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4362 | |
| 4363 | int |
| 4364 | qla81xx_fac_get_sector_size(scsi_qla_host_t *vha, uint32_t *sector_size) |
| 4365 | { |
| 4366 | int rval; |
| 4367 | mbx_cmd_t mc; |
| 4368 | mbx_cmd_t *mcp = &mc; |
| 4369 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4370 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10dc, |
| 4371 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4372 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4373 | if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) && |
| 4374 | !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4375 | return QLA_FUNCTION_FAILED; |
| 4376 | |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4377 | mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; |
| 4378 | mcp->mb[1] = FAC_OPT_CMD_GET_SECTOR_SIZE; |
| 4379 | mcp->out_mb = MBX_1|MBX_0; |
| 4380 | mcp->in_mb = MBX_1|MBX_0; |
| 4381 | mcp->tov = MBX_TOV_SECONDS; |
| 4382 | mcp->flags = 0; |
| 4383 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4384 | |
| 4385 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4386 | ql_dbg(ql_dbg_mbx, vha, 0x10dd, |
| 4387 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 4388 | rval, mcp->mb[0], mcp->mb[1]); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4389 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4390 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10de, |
| 4391 | "Done %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4392 | *sector_size = mcp->mb[1]; |
| 4393 | } |
| 4394 | |
| 4395 | return rval; |
| 4396 | } |
| 4397 | |
| 4398 | int |
| 4399 | qla81xx_fac_do_write_enable(scsi_qla_host_t *vha, int enable) |
| 4400 | { |
| 4401 | int rval; |
| 4402 | mbx_cmd_t mc; |
| 4403 | mbx_cmd_t *mcp = &mc; |
| 4404 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4405 | if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) && |
| 4406 | !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4407 | return QLA_FUNCTION_FAILED; |
| 4408 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4409 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10df, |
| 4410 | "Entered %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4411 | |
| 4412 | mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; |
| 4413 | mcp->mb[1] = enable ? FAC_OPT_CMD_WRITE_ENABLE : |
| 4414 | FAC_OPT_CMD_WRITE_PROTECT; |
| 4415 | mcp->out_mb = MBX_1|MBX_0; |
| 4416 | mcp->in_mb = MBX_1|MBX_0; |
| 4417 | mcp->tov = MBX_TOV_SECONDS; |
| 4418 | mcp->flags = 0; |
| 4419 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4420 | |
| 4421 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4422 | ql_dbg(ql_dbg_mbx, vha, 0x10e0, |
| 4423 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 4424 | rval, mcp->mb[0], mcp->mb[1]); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4425 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4426 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e1, |
| 4427 | "Done %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4428 | } |
| 4429 | |
| 4430 | return rval; |
| 4431 | } |
| 4432 | |
| 4433 | int |
| 4434 | qla81xx_fac_erase_sector(scsi_qla_host_t *vha, uint32_t start, uint32_t finish) |
| 4435 | { |
| 4436 | int rval; |
| 4437 | mbx_cmd_t mc; |
| 4438 | mbx_cmd_t *mcp = &mc; |
| 4439 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4440 | if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) && |
| 4441 | !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4442 | return QLA_FUNCTION_FAILED; |
| 4443 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4444 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e2, |
| 4445 | "Entered %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4446 | |
| 4447 | mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; |
| 4448 | mcp->mb[1] = FAC_OPT_CMD_ERASE_SECTOR; |
| 4449 | mcp->mb[2] = LSW(start); |
| 4450 | mcp->mb[3] = MSW(start); |
| 4451 | mcp->mb[4] = LSW(finish); |
| 4452 | mcp->mb[5] = MSW(finish); |
| 4453 | mcp->out_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4454 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 4455 | mcp->tov = MBX_TOV_SECONDS; |
| 4456 | mcp->flags = 0; |
| 4457 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4458 | |
| 4459 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4460 | ql_dbg(ql_dbg_mbx, vha, 0x10e3, |
| 4461 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 4462 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4463 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4464 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e4, |
| 4465 | "Done %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4466 | } |
| 4467 | |
| 4468 | return rval; |
| 4469 | } |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4470 | |
| 4471 | int |
| 4472 | qla81xx_restart_mpi_firmware(scsi_qla_host_t *vha) |
| 4473 | { |
| 4474 | int rval = 0; |
| 4475 | mbx_cmd_t mc; |
| 4476 | mbx_cmd_t *mcp = &mc; |
| 4477 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4478 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e5, |
| 4479 | "Entered %s.\n", __func__); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4480 | |
| 4481 | mcp->mb[0] = MBC_RESTART_MPI_FW; |
| 4482 | mcp->out_mb = MBX_0; |
| 4483 | mcp->in_mb = MBX_0|MBX_1; |
| 4484 | mcp->tov = MBX_TOV_SECONDS; |
| 4485 | mcp->flags = 0; |
| 4486 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4487 | |
| 4488 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4489 | ql_dbg(ql_dbg_mbx, vha, 0x10e6, |
| 4490 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 4491 | rval, mcp->mb[0], mcp->mb[1]); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4492 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4493 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e7, |
| 4494 | "Done %s.\n", __func__); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4495 | } |
| 4496 | |
| 4497 | return rval; |
| 4498 | } |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4499 | |
Joe Carnuccio | c46e65c | 2013-08-27 01:37:35 -0400 | [diff] [blame] | 4500 | int |
| 4501 | qla82xx_set_driver_version(scsi_qla_host_t *vha, char *version) |
| 4502 | { |
| 4503 | int rval; |
| 4504 | mbx_cmd_t mc; |
| 4505 | mbx_cmd_t *mcp = &mc; |
| 4506 | int i; |
| 4507 | int len; |
| 4508 | uint16_t *str; |
| 4509 | struct qla_hw_data *ha = vha->hw; |
| 4510 | |
| 4511 | if (!IS_P3P_TYPE(ha)) |
| 4512 | return QLA_FUNCTION_FAILED; |
| 4513 | |
| 4514 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x117b, |
| 4515 | "Entered %s.\n", __func__); |
| 4516 | |
| 4517 | str = (void *)version; |
| 4518 | len = strlen(version); |
| 4519 | |
| 4520 | mcp->mb[0] = MBC_SET_RNID_PARAMS; |
| 4521 | mcp->mb[1] = RNID_TYPE_SET_VERSION << 8; |
| 4522 | mcp->out_mb = MBX_1|MBX_0; |
| 4523 | for (i = 4; i < 16 && len; i++, str++, len -= 2) { |
| 4524 | mcp->mb[i] = cpu_to_le16p(str); |
| 4525 | mcp->out_mb |= 1<<i; |
| 4526 | } |
| 4527 | for (; i < 16; i++) { |
| 4528 | mcp->mb[i] = 0; |
| 4529 | mcp->out_mb |= 1<<i; |
| 4530 | } |
| 4531 | mcp->in_mb = MBX_1|MBX_0; |
| 4532 | mcp->tov = MBX_TOV_SECONDS; |
| 4533 | mcp->flags = 0; |
| 4534 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4535 | |
| 4536 | if (rval != QLA_SUCCESS) { |
| 4537 | ql_dbg(ql_dbg_mbx, vha, 0x117c, |
| 4538 | "Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]); |
| 4539 | } else { |
| 4540 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x117d, |
| 4541 | "Done %s.\n", __func__); |
| 4542 | } |
| 4543 | |
| 4544 | return rval; |
| 4545 | } |
| 4546 | |
| 4547 | int |
| 4548 | qla25xx_set_driver_version(scsi_qla_host_t *vha, char *version) |
| 4549 | { |
| 4550 | int rval; |
| 4551 | mbx_cmd_t mc; |
| 4552 | mbx_cmd_t *mcp = &mc; |
| 4553 | int len; |
| 4554 | uint16_t dwlen; |
| 4555 | uint8_t *str; |
| 4556 | dma_addr_t str_dma; |
| 4557 | struct qla_hw_data *ha = vha->hw; |
| 4558 | |
| 4559 | if (!IS_FWI2_CAPABLE(ha) || IS_QLA24XX_TYPE(ha) || IS_QLA81XX(ha) || |
| 4560 | IS_P3P_TYPE(ha)) |
| 4561 | return QLA_FUNCTION_FAILED; |
| 4562 | |
| 4563 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x117e, |
| 4564 | "Entered %s.\n", __func__); |
| 4565 | |
| 4566 | str = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &str_dma); |
| 4567 | if (!str) { |
| 4568 | ql_log(ql_log_warn, vha, 0x117f, |
| 4569 | "Failed to allocate driver version param.\n"); |
| 4570 | return QLA_MEMORY_ALLOC_FAILED; |
| 4571 | } |
| 4572 | |
| 4573 | memcpy(str, "\x7\x3\x11\x0", 4); |
| 4574 | dwlen = str[0]; |
| 4575 | len = dwlen * 4 - 4; |
| 4576 | memset(str + 4, 0, len); |
| 4577 | if (len > strlen(version)) |
| 4578 | len = strlen(version); |
| 4579 | memcpy(str + 4, version, len); |
| 4580 | |
| 4581 | mcp->mb[0] = MBC_SET_RNID_PARAMS; |
| 4582 | mcp->mb[1] = RNID_TYPE_SET_VERSION << 8 | dwlen; |
| 4583 | mcp->mb[2] = MSW(LSD(str_dma)); |
| 4584 | mcp->mb[3] = LSW(LSD(str_dma)); |
| 4585 | mcp->mb[6] = MSW(MSD(str_dma)); |
| 4586 | mcp->mb[7] = LSW(MSD(str_dma)); |
| 4587 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4588 | mcp->in_mb = MBX_1|MBX_0; |
| 4589 | mcp->tov = MBX_TOV_SECONDS; |
| 4590 | mcp->flags = 0; |
| 4591 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4592 | |
| 4593 | if (rval != QLA_SUCCESS) { |
| 4594 | ql_dbg(ql_dbg_mbx, vha, 0x1180, |
| 4595 | "Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]); |
| 4596 | } else { |
| 4597 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1181, |
| 4598 | "Done %s.\n", __func__); |
| 4599 | } |
| 4600 | |
| 4601 | dma_pool_free(ha->s_dma_pool, str, str_dma); |
| 4602 | |
| 4603 | return rval; |
| 4604 | } |
| 4605 | |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 4606 | int |
| 4607 | qla24xx_get_port_login_templ(scsi_qla_host_t *vha, dma_addr_t buf_dma, |
| 4608 | void *buf, uint16_t bufsiz) |
| 4609 | { |
| 4610 | int rval, i; |
| 4611 | mbx_cmd_t mc; |
| 4612 | mbx_cmd_t *mcp = &mc; |
| 4613 | uint32_t *bp; |
| 4614 | |
| 4615 | if (!IS_FWI2_CAPABLE(vha->hw)) |
| 4616 | return QLA_FUNCTION_FAILED; |
| 4617 | |
| 4618 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1159, |
| 4619 | "Entered %s.\n", __func__); |
| 4620 | |
| 4621 | mcp->mb[0] = MBC_GET_RNID_PARAMS; |
| 4622 | mcp->mb[1] = RNID_TYPE_PORT_LOGIN << 8; |
| 4623 | mcp->mb[2] = MSW(buf_dma); |
| 4624 | mcp->mb[3] = LSW(buf_dma); |
| 4625 | mcp->mb[6] = MSW(MSD(buf_dma)); |
| 4626 | mcp->mb[7] = LSW(MSD(buf_dma)); |
| 4627 | mcp->mb[8] = bufsiz/4; |
| 4628 | mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4629 | mcp->in_mb = MBX_1|MBX_0; |
| 4630 | mcp->tov = MBX_TOV_SECONDS; |
| 4631 | mcp->flags = 0; |
| 4632 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4633 | |
| 4634 | if (rval != QLA_SUCCESS) { |
| 4635 | ql_dbg(ql_dbg_mbx, vha, 0x115a, |
| 4636 | "Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]); |
| 4637 | } else { |
| 4638 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x115b, |
| 4639 | "Done %s.\n", __func__); |
| 4640 | bp = (uint32_t *) buf; |
| 4641 | for (i = 0; i < (bufsiz-4)/4; i++, bp++) |
| 4642 | *bp = cpu_to_be32(*bp); |
| 4643 | } |
| 4644 | |
| 4645 | return rval; |
| 4646 | } |
| 4647 | |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 4648 | static int |
| 4649 | qla2x00_read_asic_temperature(scsi_qla_host_t *vha, uint16_t *temp) |
| 4650 | { |
| 4651 | int rval; |
| 4652 | mbx_cmd_t mc; |
| 4653 | mbx_cmd_t *mcp = &mc; |
| 4654 | |
| 4655 | if (!IS_FWI2_CAPABLE(vha->hw)) |
| 4656 | return QLA_FUNCTION_FAILED; |
| 4657 | |
| 4658 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1159, |
| 4659 | "Entered %s.\n", __func__); |
| 4660 | |
| 4661 | mcp->mb[0] = MBC_GET_RNID_PARAMS; |
| 4662 | mcp->mb[1] = RNID_TYPE_ASIC_TEMP << 8; |
| 4663 | mcp->out_mb = MBX_1|MBX_0; |
| 4664 | mcp->in_mb = MBX_1|MBX_0; |
| 4665 | mcp->tov = MBX_TOV_SECONDS; |
| 4666 | mcp->flags = 0; |
| 4667 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4668 | *temp = mcp->mb[1]; |
| 4669 | |
| 4670 | if (rval != QLA_SUCCESS) { |
| 4671 | ql_dbg(ql_dbg_mbx, vha, 0x115a, |
| 4672 | "Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]); |
| 4673 | } else { |
| 4674 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x115b, |
| 4675 | "Done %s.\n", __func__); |
| 4676 | } |
| 4677 | |
| 4678 | return rval; |
| 4679 | } |
| 4680 | |
Joe Carnuccio | 3a11711 | 2013-02-08 01:58:00 -0500 | [diff] [blame] | 4681 | int |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4682 | qla2x00_read_sfp(scsi_qla_host_t *vha, dma_addr_t sfp_dma, uint8_t *sfp, |
| 4683 | uint16_t dev, uint16_t off, uint16_t len, uint16_t opt) |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4684 | { |
| 4685 | int rval; |
| 4686 | mbx_cmd_t mc; |
| 4687 | mbx_cmd_t *mcp = &mc; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4688 | struct qla_hw_data *ha = vha->hw; |
| 4689 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4690 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e8, |
| 4691 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4692 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4693 | if (!IS_FWI2_CAPABLE(ha)) |
| 4694 | return QLA_FUNCTION_FAILED; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4695 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4696 | if (len == 1) |
| 4697 | opt |= BIT_0; |
| 4698 | |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4699 | mcp->mb[0] = MBC_READ_SFP; |
| 4700 | mcp->mb[1] = dev; |
| 4701 | mcp->mb[2] = MSW(sfp_dma); |
| 4702 | mcp->mb[3] = LSW(sfp_dma); |
| 4703 | mcp->mb[6] = MSW(MSD(sfp_dma)); |
| 4704 | mcp->mb[7] = LSW(MSD(sfp_dma)); |
| 4705 | mcp->mb[8] = len; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4706 | mcp->mb[9] = off; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4707 | mcp->mb[10] = opt; |
| 4708 | 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] | 4709 | mcp->in_mb = MBX_1|MBX_0; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4710 | mcp->tov = MBX_TOV_SECONDS; |
| 4711 | mcp->flags = 0; |
| 4712 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4713 | |
| 4714 | if (opt & BIT_0) |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4715 | *sfp = mcp->mb[1]; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4716 | |
| 4717 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4718 | ql_dbg(ql_dbg_mbx, vha, 0x10e9, |
| 4719 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 4720 | if (mcp->mb[0] == MBS_COMMAND_ERROR && |
| 4721 | mcp->mb[1] == 0x22) |
| 4722 | /* sfp is not there */ |
| 4723 | rval = QLA_INTERFACE_ERROR; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4724 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4725 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ea, |
| 4726 | "Done %s.\n", __func__); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4727 | } |
| 4728 | |
| 4729 | return rval; |
| 4730 | } |
| 4731 | |
| 4732 | int |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4733 | qla2x00_write_sfp(scsi_qla_host_t *vha, dma_addr_t sfp_dma, uint8_t *sfp, |
| 4734 | uint16_t dev, uint16_t off, uint16_t len, uint16_t opt) |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4735 | { |
| 4736 | int rval; |
| 4737 | mbx_cmd_t mc; |
| 4738 | mbx_cmd_t *mcp = &mc; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4739 | struct qla_hw_data *ha = vha->hw; |
| 4740 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4741 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10eb, |
| 4742 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4743 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4744 | if (!IS_FWI2_CAPABLE(ha)) |
| 4745 | return QLA_FUNCTION_FAILED; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4746 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4747 | if (len == 1) |
| 4748 | opt |= BIT_0; |
| 4749 | |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4750 | if (opt & BIT_0) |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4751 | len = *sfp; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4752 | |
| 4753 | mcp->mb[0] = MBC_WRITE_SFP; |
| 4754 | mcp->mb[1] = dev; |
| 4755 | mcp->mb[2] = MSW(sfp_dma); |
| 4756 | mcp->mb[3] = LSW(sfp_dma); |
| 4757 | mcp->mb[6] = MSW(MSD(sfp_dma)); |
| 4758 | mcp->mb[7] = LSW(MSD(sfp_dma)); |
| 4759 | mcp->mb[8] = len; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4760 | mcp->mb[9] = off; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4761 | mcp->mb[10] = opt; |
| 4762 | 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] | 4763 | mcp->in_mb = MBX_1|MBX_0; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4764 | mcp->tov = MBX_TOV_SECONDS; |
| 4765 | mcp->flags = 0; |
| 4766 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4767 | |
| 4768 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4769 | ql_dbg(ql_dbg_mbx, vha, 0x10ec, |
| 4770 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4771 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4772 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ed, |
| 4773 | "Done %s.\n", __func__); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4774 | } |
| 4775 | |
| 4776 | return rval; |
| 4777 | } |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4778 | |
| 4779 | int |
| 4780 | qla2x00_get_xgmac_stats(scsi_qla_host_t *vha, dma_addr_t stats_dma, |
| 4781 | uint16_t size_in_bytes, uint16_t *actual_size) |
| 4782 | { |
| 4783 | int rval; |
| 4784 | mbx_cmd_t mc; |
| 4785 | mbx_cmd_t *mcp = &mc; |
| 4786 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4787 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ee, |
| 4788 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4789 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4790 | if (!IS_CNA_CAPABLE(vha->hw)) |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4791 | return QLA_FUNCTION_FAILED; |
| 4792 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4793 | mcp->mb[0] = MBC_GET_XGMAC_STATS; |
| 4794 | mcp->mb[2] = MSW(stats_dma); |
| 4795 | mcp->mb[3] = LSW(stats_dma); |
| 4796 | mcp->mb[6] = MSW(MSD(stats_dma)); |
| 4797 | mcp->mb[7] = LSW(MSD(stats_dma)); |
| 4798 | mcp->mb[8] = size_in_bytes >> 2; |
| 4799 | mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; |
| 4800 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 4801 | mcp->tov = MBX_TOV_SECONDS; |
| 4802 | mcp->flags = 0; |
| 4803 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4804 | |
| 4805 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4806 | ql_dbg(ql_dbg_mbx, vha, 0x10ef, |
| 4807 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 4808 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4809 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4810 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f0, |
| 4811 | "Done %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4812 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4813 | |
| 4814 | *actual_size = mcp->mb[2] << 2; |
| 4815 | } |
| 4816 | |
| 4817 | return rval; |
| 4818 | } |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4819 | |
| 4820 | int |
| 4821 | qla2x00_get_dcbx_params(scsi_qla_host_t *vha, dma_addr_t tlv_dma, |
| 4822 | uint16_t size) |
| 4823 | { |
| 4824 | int rval; |
| 4825 | mbx_cmd_t mc; |
| 4826 | mbx_cmd_t *mcp = &mc; |
| 4827 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4828 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f1, |
| 4829 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4830 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4831 | if (!IS_CNA_CAPABLE(vha->hw)) |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4832 | return QLA_FUNCTION_FAILED; |
| 4833 | |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4834 | mcp->mb[0] = MBC_GET_DCBX_PARAMS; |
| 4835 | mcp->mb[1] = 0; |
| 4836 | mcp->mb[2] = MSW(tlv_dma); |
| 4837 | mcp->mb[3] = LSW(tlv_dma); |
| 4838 | mcp->mb[6] = MSW(MSD(tlv_dma)); |
| 4839 | mcp->mb[7] = LSW(MSD(tlv_dma)); |
| 4840 | mcp->mb[8] = size; |
| 4841 | mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4842 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 4843 | mcp->tov = MBX_TOV_SECONDS; |
| 4844 | mcp->flags = 0; |
| 4845 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4846 | |
| 4847 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4848 | ql_dbg(ql_dbg_mbx, vha, 0x10f2, |
| 4849 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 4850 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4851 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4852 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f3, |
| 4853 | "Done %s.\n", __func__); |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4854 | } |
| 4855 | |
| 4856 | return rval; |
| 4857 | } |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4858 | |
| 4859 | int |
| 4860 | qla2x00_read_ram_word(scsi_qla_host_t *vha, uint32_t risc_addr, uint32_t *data) |
| 4861 | { |
| 4862 | int rval; |
| 4863 | mbx_cmd_t mc; |
| 4864 | mbx_cmd_t *mcp = &mc; |
| 4865 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4866 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f4, |
| 4867 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4868 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4869 | if (!IS_FWI2_CAPABLE(vha->hw)) |
| 4870 | return QLA_FUNCTION_FAILED; |
| 4871 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4872 | mcp->mb[0] = MBC_READ_RAM_EXTENDED; |
| 4873 | mcp->mb[1] = LSW(risc_addr); |
| 4874 | mcp->mb[8] = MSW(risc_addr); |
| 4875 | mcp->out_mb = MBX_8|MBX_1|MBX_0; |
| 4876 | mcp->in_mb = MBX_3|MBX_2|MBX_0; |
| 4877 | mcp->tov = 30; |
| 4878 | mcp->flags = 0; |
| 4879 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4880 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4881 | ql_dbg(ql_dbg_mbx, vha, 0x10f5, |
| 4882 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4883 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4884 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f6, |
| 4885 | "Done %s.\n", __func__); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4886 | *data = mcp->mb[3] << 16 | mcp->mb[2]; |
| 4887 | } |
| 4888 | |
| 4889 | return rval; |
| 4890 | } |
| 4891 | |
| 4892 | int |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4893 | qla2x00_loopback_test(scsi_qla_host_t *vha, struct msg_echo_lb *mreq, |
| 4894 | uint16_t *mresp) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4895 | { |
| 4896 | int rval; |
| 4897 | mbx_cmd_t mc; |
| 4898 | mbx_cmd_t *mcp = &mc; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4899 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4900 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f7, |
| 4901 | "Entered %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4902 | |
| 4903 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 4904 | mcp->mb[0] = MBC_DIAGNOSTIC_LOOP_BACK; |
| 4905 | mcp->mb[1] = mreq->options | BIT_6; // BIT_6 specifies 64 bit addressing |
| 4906 | |
| 4907 | /* transfer count */ |
| 4908 | mcp->mb[10] = LSW(mreq->transfer_size); |
| 4909 | mcp->mb[11] = MSW(mreq->transfer_size); |
| 4910 | |
| 4911 | /* send data address */ |
| 4912 | mcp->mb[14] = LSW(mreq->send_dma); |
| 4913 | mcp->mb[15] = MSW(mreq->send_dma); |
| 4914 | mcp->mb[20] = LSW(MSD(mreq->send_dma)); |
| 4915 | mcp->mb[21] = MSW(MSD(mreq->send_dma)); |
| 4916 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 4917 | /* receive data address */ |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4918 | mcp->mb[16] = LSW(mreq->rcv_dma); |
| 4919 | mcp->mb[17] = MSW(mreq->rcv_dma); |
| 4920 | mcp->mb[6] = LSW(MSD(mreq->rcv_dma)); |
| 4921 | mcp->mb[7] = MSW(MSD(mreq->rcv_dma)); |
| 4922 | |
| 4923 | /* Iteration count */ |
Joe Carnuccio | 1b98b42 | 2013-03-28 08:21:26 -0400 | [diff] [blame] | 4924 | mcp->mb[18] = LSW(mreq->iteration_count); |
| 4925 | mcp->mb[19] = MSW(mreq->iteration_count); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4926 | |
| 4927 | mcp->out_mb = MBX_21|MBX_20|MBX_19|MBX_18|MBX_17|MBX_16|MBX_15| |
| 4928 | 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] | 4929 | if (IS_CNA_CAPABLE(vha->hw)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4930 | mcp->out_mb |= MBX_2; |
| 4931 | mcp->in_mb = MBX_19|MBX_18|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4932 | |
| 4933 | mcp->buf_size = mreq->transfer_size; |
| 4934 | mcp->tov = MBX_TOV_SECONDS; |
| 4935 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 4936 | |
| 4937 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4938 | |
| 4939 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4940 | ql_dbg(ql_dbg_mbx, vha, 0x10f8, |
| 4941 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[3]=%x mb[18]=%x " |
| 4942 | "mb[19]=%x.\n", rval, mcp->mb[0], mcp->mb[1], mcp->mb[2], |
| 4943 | mcp->mb[3], mcp->mb[18], mcp->mb[19]); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4944 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4945 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f9, |
| 4946 | "Done %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4947 | } |
| 4948 | |
| 4949 | /* Copy mailbox information */ |
| 4950 | memcpy( mresp, mcp->mb, 64); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4951 | return rval; |
| 4952 | } |
| 4953 | |
| 4954 | int |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4955 | qla2x00_echo_test(scsi_qla_host_t *vha, struct msg_echo_lb *mreq, |
| 4956 | uint16_t *mresp) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4957 | { |
| 4958 | int rval; |
| 4959 | mbx_cmd_t mc; |
| 4960 | mbx_cmd_t *mcp = &mc; |
| 4961 | struct qla_hw_data *ha = vha->hw; |
| 4962 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4963 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10fa, |
| 4964 | "Entered %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4965 | |
| 4966 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 4967 | mcp->mb[0] = MBC_DIAGNOSTIC_ECHO; |
Joe Carnuccio | 1d63496 | 2017-05-24 18:06:22 -0700 | [diff] [blame] | 4968 | /* BIT_6 specifies 64bit address */ |
| 4969 | mcp->mb[1] = mreq->options | BIT_15 | BIT_6; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4970 | if (IS_CNA_CAPABLE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4971 | mcp->mb[2] = vha->fcoe_fcf_idx; |
| 4972 | } |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4973 | mcp->mb[16] = LSW(mreq->rcv_dma); |
| 4974 | mcp->mb[17] = MSW(mreq->rcv_dma); |
| 4975 | mcp->mb[6] = LSW(MSD(mreq->rcv_dma)); |
| 4976 | mcp->mb[7] = MSW(MSD(mreq->rcv_dma)); |
| 4977 | |
| 4978 | mcp->mb[10] = LSW(mreq->transfer_size); |
| 4979 | |
| 4980 | mcp->mb[14] = LSW(mreq->send_dma); |
| 4981 | mcp->mb[15] = MSW(mreq->send_dma); |
| 4982 | mcp->mb[20] = LSW(MSD(mreq->send_dma)); |
| 4983 | mcp->mb[21] = MSW(MSD(mreq->send_dma)); |
| 4984 | |
| 4985 | mcp->out_mb = MBX_21|MBX_20|MBX_17|MBX_16|MBX_15| |
| 4986 | MBX_14|MBX_10|MBX_7|MBX_6|MBX_1|MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4987 | if (IS_CNA_CAPABLE(ha)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4988 | mcp->out_mb |= MBX_2; |
| 4989 | |
| 4990 | mcp->in_mb = MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4991 | if (IS_QLA24XX_TYPE(ha) || IS_QLA25XX(ha) || |
| 4992 | IS_CNA_CAPABLE(ha) || IS_QLA2031(ha)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4993 | mcp->in_mb |= MBX_1; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4994 | if (IS_CNA_CAPABLE(ha) || IS_QLA2031(ha)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4995 | mcp->in_mb |= MBX_3; |
| 4996 | |
| 4997 | mcp->tov = MBX_TOV_SECONDS; |
| 4998 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 4999 | mcp->buf_size = mreq->transfer_size; |
| 5000 | |
| 5001 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5002 | |
| 5003 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5004 | ql_dbg(ql_dbg_mbx, vha, 0x10fb, |
| 5005 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 5006 | rval, mcp->mb[0], mcp->mb[1]); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5007 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5008 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10fc, |
| 5009 | "Done %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5010 | } |
| 5011 | |
| 5012 | /* Copy mailbox information */ |
Giridhar Malavali | 6dbdda4 | 2010-09-03 15:20:49 -0700 | [diff] [blame] | 5013 | memcpy(mresp, mcp->mb, 64); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5014 | return rval; |
| 5015 | } |
Giridhar Malavali | 6dbdda4 | 2010-09-03 15:20:49 -0700 | [diff] [blame] | 5016 | |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5017 | int |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5018 | qla84xx_reset_chip(scsi_qla_host_t *vha, uint16_t enable_diagnostic) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5019 | { |
| 5020 | int rval; |
| 5021 | mbx_cmd_t mc; |
| 5022 | mbx_cmd_t *mcp = &mc; |
| 5023 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5024 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10fd, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5025 | "Entered %s enable_diag=%d.\n", __func__, enable_diagnostic); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5026 | |
| 5027 | mcp->mb[0] = MBC_ISP84XX_RESET; |
| 5028 | mcp->mb[1] = enable_diagnostic; |
| 5029 | mcp->out_mb = MBX_1|MBX_0; |
| 5030 | mcp->in_mb = MBX_1|MBX_0; |
| 5031 | mcp->tov = MBX_TOV_SECONDS; |
| 5032 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5033 | rval = qla2x00_mailbox_command(vha, mcp); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5034 | |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5035 | if (rval != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5036 | ql_dbg(ql_dbg_mbx, vha, 0x10fe, "Failed=%x.\n", rval); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5037 | else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5038 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ff, |
| 5039 | "Done %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5040 | |
| 5041 | return rval; |
| 5042 | } |
| 5043 | |
| 5044 | int |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5045 | qla2x00_write_ram_word(scsi_qla_host_t *vha, uint32_t risc_addr, uint32_t data) |
| 5046 | { |
| 5047 | int rval; |
| 5048 | mbx_cmd_t mc; |
| 5049 | mbx_cmd_t *mcp = &mc; |
| 5050 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5051 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1100, |
| 5052 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5053 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5054 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | 6c452a4 | 2010-03-19 17:04:02 -0700 | [diff] [blame] | 5055 | return QLA_FUNCTION_FAILED; |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5056 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5057 | mcp->mb[0] = MBC_WRITE_RAM_WORD_EXTENDED; |
| 5058 | mcp->mb[1] = LSW(risc_addr); |
| 5059 | mcp->mb[2] = LSW(data); |
| 5060 | mcp->mb[3] = MSW(data); |
| 5061 | mcp->mb[8] = MSW(risc_addr); |
| 5062 | mcp->out_mb = MBX_8|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5063 | mcp->in_mb = MBX_0; |
| 5064 | mcp->tov = 30; |
| 5065 | mcp->flags = 0; |
| 5066 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5067 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5068 | ql_dbg(ql_dbg_mbx, vha, 0x1101, |
| 5069 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5070 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5071 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1102, |
| 5072 | "Done %s.\n", __func__); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5073 | } |
| 5074 | |
| 5075 | return rval; |
| 5076 | } |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5077 | |
| 5078 | int |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 5079 | qla81xx_write_mpi_register(scsi_qla_host_t *vha, uint16_t *mb) |
| 5080 | { |
| 5081 | int rval; |
| 5082 | uint32_t stat, timer; |
| 5083 | uint16_t mb0 = 0; |
| 5084 | struct qla_hw_data *ha = vha->hw; |
| 5085 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 5086 | |
| 5087 | rval = QLA_SUCCESS; |
| 5088 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5089 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1103, |
| 5090 | "Entered %s.\n", __func__); |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 5091 | |
| 5092 | clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
| 5093 | |
| 5094 | /* Write the MBC data to the registers */ |
| 5095 | WRT_REG_WORD(®->mailbox0, MBC_WRITE_MPI_REGISTER); |
| 5096 | WRT_REG_WORD(®->mailbox1, mb[0]); |
| 5097 | WRT_REG_WORD(®->mailbox2, mb[1]); |
| 5098 | WRT_REG_WORD(®->mailbox3, mb[2]); |
| 5099 | WRT_REG_WORD(®->mailbox4, mb[3]); |
| 5100 | |
| 5101 | WRT_REG_DWORD(®->hccr, HCCRX_SET_HOST_INT); |
| 5102 | |
| 5103 | /* Poll for MBC interrupt */ |
| 5104 | for (timer = 6000000; timer; timer--) { |
| 5105 | /* Check for pending interrupts. */ |
| 5106 | stat = RD_REG_DWORD(®->host_status); |
| 5107 | if (stat & HSRX_RISC_INT) { |
| 5108 | stat &= 0xff; |
| 5109 | |
| 5110 | if (stat == 0x1 || stat == 0x2 || |
| 5111 | stat == 0x10 || stat == 0x11) { |
| 5112 | set_bit(MBX_INTERRUPT, |
| 5113 | &ha->mbx_cmd_flags); |
| 5114 | mb0 = RD_REG_WORD(®->mailbox0); |
| 5115 | WRT_REG_DWORD(®->hccr, |
| 5116 | HCCRX_CLR_RISC_INT); |
| 5117 | RD_REG_DWORD(®->hccr); |
| 5118 | break; |
| 5119 | } |
| 5120 | } |
| 5121 | udelay(5); |
| 5122 | } |
| 5123 | |
| 5124 | if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) |
| 5125 | rval = mb0 & MBS_MASK; |
| 5126 | else |
| 5127 | rval = QLA_FUNCTION_FAILED; |
| 5128 | |
| 5129 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5130 | ql_dbg(ql_dbg_mbx, vha, 0x1104, |
| 5131 | "Failed=%x mb[0]=%x.\n", rval, mb[0]); |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 5132 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5133 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1105, |
| 5134 | "Done %s.\n", __func__); |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 5135 | } |
| 5136 | |
| 5137 | return rval; |
| 5138 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5139 | |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 5140 | int |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5141 | qla2x00_get_data_rate(scsi_qla_host_t *vha) |
| 5142 | { |
| 5143 | int rval; |
| 5144 | mbx_cmd_t mc; |
| 5145 | mbx_cmd_t *mcp = &mc; |
| 5146 | struct qla_hw_data *ha = vha->hw; |
| 5147 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5148 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1106, |
| 5149 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5150 | |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5151 | if (!IS_FWI2_CAPABLE(ha)) |
| 5152 | return QLA_FUNCTION_FAILED; |
| 5153 | |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5154 | mcp->mb[0] = MBC_DATA_RATE; |
| 5155 | mcp->mb[1] = 0; |
| 5156 | mcp->out_mb = MBX_1|MBX_0; |
| 5157 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5158 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5159 | mcp->in_mb |= MBX_3; |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5160 | mcp->tov = MBX_TOV_SECONDS; |
| 5161 | mcp->flags = 0; |
| 5162 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5163 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5164 | ql_dbg(ql_dbg_mbx, vha, 0x1107, |
| 5165 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5166 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5167 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1108, |
| 5168 | "Done %s.\n", __func__); |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5169 | if (mcp->mb[1] != 0x7) |
| 5170 | ha->link_data_rate = mcp->mb[1]; |
| 5171 | } |
| 5172 | |
| 5173 | return rval; |
| 5174 | } |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5175 | |
| 5176 | int |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5177 | qla81xx_get_port_config(scsi_qla_host_t *vha, uint16_t *mb) |
| 5178 | { |
| 5179 | int rval; |
| 5180 | mbx_cmd_t mc; |
| 5181 | mbx_cmd_t *mcp = &mc; |
| 5182 | struct qla_hw_data *ha = vha->hw; |
| 5183 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5184 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1109, |
| 5185 | "Entered %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5186 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5187 | if (!IS_QLA81XX(ha) && !IS_QLA83XX(ha) && !IS_QLA8044(ha) && |
| 5188 | !IS_QLA27XX(ha)) |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5189 | return QLA_FUNCTION_FAILED; |
| 5190 | mcp->mb[0] = MBC_GET_PORT_CONFIG; |
| 5191 | mcp->out_mb = MBX_0; |
| 5192 | mcp->in_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5193 | mcp->tov = MBX_TOV_SECONDS; |
| 5194 | mcp->flags = 0; |
| 5195 | |
| 5196 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5197 | |
| 5198 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5199 | ql_dbg(ql_dbg_mbx, vha, 0x110a, |
| 5200 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5201 | } else { |
| 5202 | /* Copy all bits to preserve original value */ |
| 5203 | memcpy(mb, &mcp->mb[1], sizeof(uint16_t) * 4); |
| 5204 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5205 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110b, |
| 5206 | "Done %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5207 | } |
| 5208 | return rval; |
| 5209 | } |
| 5210 | |
| 5211 | int |
| 5212 | qla81xx_set_port_config(scsi_qla_host_t *vha, uint16_t *mb) |
| 5213 | { |
| 5214 | int rval; |
| 5215 | mbx_cmd_t mc; |
| 5216 | mbx_cmd_t *mcp = &mc; |
| 5217 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5218 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110c, |
| 5219 | "Entered %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5220 | |
| 5221 | mcp->mb[0] = MBC_SET_PORT_CONFIG; |
| 5222 | /* Copy all bits to preserve original setting */ |
| 5223 | memcpy(&mcp->mb[1], mb, sizeof(uint16_t) * 4); |
| 5224 | mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5225 | mcp->in_mb = MBX_0; |
| 5226 | mcp->tov = MBX_TOV_SECONDS; |
| 5227 | mcp->flags = 0; |
| 5228 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5229 | |
| 5230 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5231 | ql_dbg(ql_dbg_mbx, vha, 0x110d, |
| 5232 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5233 | } else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5234 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110e, |
| 5235 | "Done %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5236 | |
| 5237 | return rval; |
| 5238 | } |
| 5239 | |
| 5240 | |
| 5241 | int |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5242 | qla24xx_set_fcp_prio(scsi_qla_host_t *vha, uint16_t loop_id, uint16_t priority, |
| 5243 | uint16_t *mb) |
| 5244 | { |
| 5245 | int rval; |
| 5246 | mbx_cmd_t mc; |
| 5247 | mbx_cmd_t *mcp = &mc; |
| 5248 | struct qla_hw_data *ha = vha->hw; |
| 5249 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5250 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110f, |
| 5251 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5252 | |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5253 | if (!IS_QLA24XX_TYPE(ha) && !IS_QLA25XX(ha)) |
| 5254 | return QLA_FUNCTION_FAILED; |
| 5255 | |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5256 | mcp->mb[0] = MBC_PORT_PARAMS; |
| 5257 | mcp->mb[1] = loop_id; |
| 5258 | if (ha->flags.fcp_prio_enabled) |
| 5259 | mcp->mb[2] = BIT_1; |
| 5260 | else |
| 5261 | mcp->mb[2] = BIT_2; |
| 5262 | mcp->mb[4] = priority & 0xf; |
| 5263 | mcp->mb[9] = vha->vp_idx; |
| 5264 | mcp->out_mb = MBX_9|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5265 | mcp->in_mb = MBX_4|MBX_3|MBX_1|MBX_0; |
| 5266 | mcp->tov = 30; |
| 5267 | mcp->flags = 0; |
| 5268 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5269 | if (mb != NULL) { |
| 5270 | mb[0] = mcp->mb[0]; |
| 5271 | mb[1] = mcp->mb[1]; |
| 5272 | mb[3] = mcp->mb[3]; |
| 5273 | mb[4] = mcp->mb[4]; |
| 5274 | } |
| 5275 | |
| 5276 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5277 | ql_dbg(ql_dbg_mbx, vha, 0x10cd, "Failed=%x.\n", rval); |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5278 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5279 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10cc, |
| 5280 | "Done %s.\n", __func__); |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5281 | } |
| 5282 | |
| 5283 | return rval; |
| 5284 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5285 | |
| 5286 | int |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 5287 | qla2x00_get_thermal_temp(scsi_qla_host_t *vha, uint16_t *temp) |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5288 | { |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 5289 | int rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5290 | struct qla_hw_data *ha = vha->hw; |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 5291 | uint8_t byte; |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5292 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 5293 | if (!IS_FWI2_CAPABLE(ha) || IS_QLA24XX_TYPE(ha) || IS_QLA81XX(ha)) { |
| 5294 | ql_dbg(ql_dbg_mbx, vha, 0x1150, |
| 5295 | "Thermal not supported by this card.\n"); |
| 5296 | return rval; |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5297 | } |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5298 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 5299 | if (IS_QLA25XX(ha)) { |
| 5300 | if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC && |
| 5301 | ha->pdev->subsystem_device == 0x0175) { |
| 5302 | rval = qla2x00_read_sfp(vha, 0, &byte, |
| 5303 | 0x98, 0x1, 1, BIT_13|BIT_0); |
| 5304 | *temp = byte; |
| 5305 | return rval; |
| 5306 | } |
| 5307 | if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_HP && |
| 5308 | ha->pdev->subsystem_device == 0x338e) { |
| 5309 | rval = qla2x00_read_sfp(vha, 0, &byte, |
| 5310 | 0x98, 0x1, 1, BIT_15|BIT_14|BIT_0); |
| 5311 | *temp = byte; |
| 5312 | return rval; |
| 5313 | } |
| 5314 | ql_dbg(ql_dbg_mbx, vha, 0x10c9, |
| 5315 | "Thermal not supported by this card.\n"); |
| 5316 | return rval; |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 5317 | } |
| 5318 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 5319 | if (IS_QLA82XX(ha)) { |
| 5320 | *temp = qla82xx_read_temperature(vha); |
| 5321 | rval = QLA_SUCCESS; |
| 5322 | return rval; |
| 5323 | } else if (IS_QLA8044(ha)) { |
| 5324 | *temp = qla8044_read_temperature(vha); |
| 5325 | rval = QLA_SUCCESS; |
| 5326 | return rval; |
| 5327 | } |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 5328 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 5329 | rval = qla2x00_read_asic_temperature(vha, temp); |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5330 | return rval; |
| 5331 | } |
| 5332 | |
| 5333 | int |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5334 | qla82xx_mbx_intr_enable(scsi_qla_host_t *vha) |
| 5335 | { |
| 5336 | int rval; |
| 5337 | struct qla_hw_data *ha = vha->hw; |
| 5338 | mbx_cmd_t mc; |
| 5339 | mbx_cmd_t *mcp = &mc; |
| 5340 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5341 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1017, |
| 5342 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5343 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5344 | if (!IS_FWI2_CAPABLE(ha)) |
| 5345 | return QLA_FUNCTION_FAILED; |
| 5346 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5347 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
Giridhar Malavali | 3711333 | 2010-07-23 15:28:34 +0500 | [diff] [blame] | 5348 | mcp->mb[0] = MBC_TOGGLE_INTERRUPT; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5349 | mcp->mb[1] = 1; |
| 5350 | |
| 5351 | mcp->out_mb = MBX_1|MBX_0; |
| 5352 | mcp->in_mb = MBX_0; |
| 5353 | mcp->tov = 30; |
| 5354 | mcp->flags = 0; |
| 5355 | |
| 5356 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5357 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5358 | ql_dbg(ql_dbg_mbx, vha, 0x1016, |
| 5359 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5360 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5361 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x100e, |
| 5362 | "Done %s.\n", __func__); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5363 | } |
| 5364 | |
| 5365 | return rval; |
| 5366 | } |
| 5367 | |
| 5368 | int |
| 5369 | qla82xx_mbx_intr_disable(scsi_qla_host_t *vha) |
| 5370 | { |
| 5371 | int rval; |
| 5372 | struct qla_hw_data *ha = vha->hw; |
| 5373 | mbx_cmd_t mc; |
| 5374 | mbx_cmd_t *mcp = &mc; |
| 5375 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5376 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x100d, |
| 5377 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5378 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5379 | if (!IS_P3P_TYPE(ha)) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5380 | return QLA_FUNCTION_FAILED; |
| 5381 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5382 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
Giridhar Malavali | 3711333 | 2010-07-23 15:28:34 +0500 | [diff] [blame] | 5383 | mcp->mb[0] = MBC_TOGGLE_INTERRUPT; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5384 | mcp->mb[1] = 0; |
| 5385 | |
| 5386 | mcp->out_mb = MBX_1|MBX_0; |
| 5387 | mcp->in_mb = MBX_0; |
| 5388 | mcp->tov = 30; |
| 5389 | mcp->flags = 0; |
| 5390 | |
| 5391 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5392 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5393 | ql_dbg(ql_dbg_mbx, vha, 0x100c, |
| 5394 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5395 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5396 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x100b, |
| 5397 | "Done %s.\n", __func__); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5398 | } |
| 5399 | |
| 5400 | return rval; |
| 5401 | } |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5402 | |
| 5403 | int |
| 5404 | qla82xx_md_get_template_size(scsi_qla_host_t *vha) |
| 5405 | { |
| 5406 | struct qla_hw_data *ha = vha->hw; |
| 5407 | mbx_cmd_t mc; |
| 5408 | mbx_cmd_t *mcp = &mc; |
| 5409 | int rval = QLA_FUNCTION_FAILED; |
| 5410 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5411 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x111f, |
| 5412 | "Entered %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5413 | |
| 5414 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 5415 | mcp->mb[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5416 | mcp->mb[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5417 | mcp->mb[2] = LSW(RQST_TMPLT_SIZE); |
| 5418 | mcp->mb[3] = MSW(RQST_TMPLT_SIZE); |
| 5419 | |
| 5420 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 5421 | mcp->in_mb = MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8| |
| 5422 | MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5423 | |
| 5424 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 5425 | mcp->tov = MBX_TOV_SECONDS; |
| 5426 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5427 | |
| 5428 | /* Always copy back return mailbox values. */ |
| 5429 | if (rval != QLA_SUCCESS) { |
| 5430 | ql_dbg(ql_dbg_mbx, vha, 0x1120, |
| 5431 | "mailbox command FAILED=0x%x, subcode=%x.\n", |
| 5432 | (mcp->mb[1] << 16) | mcp->mb[0], |
| 5433 | (mcp->mb[3] << 16) | mcp->mb[2]); |
| 5434 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5435 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1121, |
| 5436 | "Done %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5437 | ha->md_template_size = ((mcp->mb[3] << 16) | mcp->mb[2]); |
| 5438 | if (!ha->md_template_size) { |
| 5439 | ql_dbg(ql_dbg_mbx, vha, 0x1122, |
| 5440 | "Null template size obtained.\n"); |
| 5441 | rval = QLA_FUNCTION_FAILED; |
| 5442 | } |
| 5443 | } |
| 5444 | return rval; |
| 5445 | } |
| 5446 | |
| 5447 | int |
| 5448 | qla82xx_md_get_template(scsi_qla_host_t *vha) |
| 5449 | { |
| 5450 | struct qla_hw_data *ha = vha->hw; |
| 5451 | mbx_cmd_t mc; |
| 5452 | mbx_cmd_t *mcp = &mc; |
| 5453 | int rval = QLA_FUNCTION_FAILED; |
| 5454 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5455 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1123, |
| 5456 | "Entered %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5457 | |
| 5458 | ha->md_tmplt_hdr = dma_alloc_coherent(&ha->pdev->dev, |
| 5459 | ha->md_template_size, &ha->md_tmplt_hdr_dma, GFP_KERNEL); |
| 5460 | if (!ha->md_tmplt_hdr) { |
| 5461 | ql_log(ql_log_warn, vha, 0x1124, |
| 5462 | "Unable to allocate memory for Minidump template.\n"); |
| 5463 | return rval; |
| 5464 | } |
| 5465 | |
| 5466 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 5467 | mcp->mb[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5468 | mcp->mb[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5469 | mcp->mb[2] = LSW(RQST_TMPLT); |
| 5470 | mcp->mb[3] = MSW(RQST_TMPLT); |
| 5471 | mcp->mb[4] = LSW(LSD(ha->md_tmplt_hdr_dma)); |
| 5472 | mcp->mb[5] = MSW(LSD(ha->md_tmplt_hdr_dma)); |
| 5473 | mcp->mb[6] = LSW(MSD(ha->md_tmplt_hdr_dma)); |
| 5474 | mcp->mb[7] = MSW(MSD(ha->md_tmplt_hdr_dma)); |
| 5475 | mcp->mb[8] = LSW(ha->md_template_size); |
| 5476 | mcp->mb[9] = MSW(ha->md_template_size); |
| 5477 | |
| 5478 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 5479 | mcp->tov = MBX_TOV_SECONDS; |
| 5480 | mcp->out_mb = MBX_11|MBX_10|MBX_9|MBX_8| |
| 5481 | MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5482 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 5483 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5484 | |
| 5485 | if (rval != QLA_SUCCESS) { |
| 5486 | ql_dbg(ql_dbg_mbx, vha, 0x1125, |
| 5487 | "mailbox command FAILED=0x%x, subcode=%x.\n", |
| 5488 | ((mcp->mb[1] << 16) | mcp->mb[0]), |
| 5489 | ((mcp->mb[3] << 16) | mcp->mb[2])); |
| 5490 | } else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5491 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1126, |
| 5492 | "Done %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5493 | return rval; |
| 5494 | } |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5495 | |
| 5496 | int |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5497 | qla8044_md_get_template(scsi_qla_host_t *vha) |
| 5498 | { |
| 5499 | struct qla_hw_data *ha = vha->hw; |
| 5500 | mbx_cmd_t mc; |
| 5501 | mbx_cmd_t *mcp = &mc; |
| 5502 | int rval = QLA_FUNCTION_FAILED; |
| 5503 | int offset = 0, size = MINIDUMP_SIZE_36K; |
| 5504 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0xb11f, |
| 5505 | "Entered %s.\n", __func__); |
| 5506 | |
| 5507 | ha->md_tmplt_hdr = dma_alloc_coherent(&ha->pdev->dev, |
| 5508 | ha->md_template_size, &ha->md_tmplt_hdr_dma, GFP_KERNEL); |
| 5509 | if (!ha->md_tmplt_hdr) { |
| 5510 | ql_log(ql_log_warn, vha, 0xb11b, |
| 5511 | "Unable to allocate memory for Minidump template.\n"); |
| 5512 | return rval; |
| 5513 | } |
| 5514 | |
| 5515 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 5516 | while (offset < ha->md_template_size) { |
| 5517 | mcp->mb[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5518 | mcp->mb[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5519 | mcp->mb[2] = LSW(RQST_TMPLT); |
| 5520 | mcp->mb[3] = MSW(RQST_TMPLT); |
| 5521 | mcp->mb[4] = LSW(LSD(ha->md_tmplt_hdr_dma + offset)); |
| 5522 | mcp->mb[5] = MSW(LSD(ha->md_tmplt_hdr_dma + offset)); |
| 5523 | mcp->mb[6] = LSW(MSD(ha->md_tmplt_hdr_dma + offset)); |
| 5524 | mcp->mb[7] = MSW(MSD(ha->md_tmplt_hdr_dma + offset)); |
| 5525 | mcp->mb[8] = LSW(size); |
| 5526 | mcp->mb[9] = MSW(size); |
| 5527 | mcp->mb[10] = offset & 0x0000FFFF; |
| 5528 | mcp->mb[11] = offset & 0xFFFF0000; |
| 5529 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 5530 | mcp->tov = MBX_TOV_SECONDS; |
| 5531 | mcp->out_mb = MBX_11|MBX_10|MBX_9|MBX_8| |
| 5532 | MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5533 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 5534 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5535 | |
| 5536 | if (rval != QLA_SUCCESS) { |
| 5537 | ql_dbg(ql_dbg_mbx, vha, 0xb11c, |
| 5538 | "mailbox command FAILED=0x%x, subcode=%x.\n", |
| 5539 | ((mcp->mb[1] << 16) | mcp->mb[0]), |
| 5540 | ((mcp->mb[3] << 16) | mcp->mb[2])); |
| 5541 | return rval; |
| 5542 | } else |
| 5543 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0xb11d, |
| 5544 | "Done %s.\n", __func__); |
| 5545 | offset = offset + size; |
| 5546 | } |
| 5547 | return rval; |
| 5548 | } |
| 5549 | |
| 5550 | int |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5551 | qla81xx_set_led_config(scsi_qla_host_t *vha, uint16_t *led_cfg) |
| 5552 | { |
| 5553 | int rval; |
| 5554 | struct qla_hw_data *ha = vha->hw; |
| 5555 | mbx_cmd_t mc; |
| 5556 | mbx_cmd_t *mcp = &mc; |
| 5557 | |
| 5558 | if (!IS_QLA81XX(ha) && !IS_QLA8031(ha)) |
| 5559 | return QLA_FUNCTION_FAILED; |
| 5560 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5561 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1133, |
| 5562 | "Entered %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5563 | |
| 5564 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
| 5565 | mcp->mb[0] = MBC_SET_LED_CONFIG; |
| 5566 | mcp->mb[1] = led_cfg[0]; |
| 5567 | mcp->mb[2] = led_cfg[1]; |
| 5568 | if (IS_QLA8031(ha)) { |
| 5569 | mcp->mb[3] = led_cfg[2]; |
| 5570 | mcp->mb[4] = led_cfg[3]; |
| 5571 | mcp->mb[5] = led_cfg[4]; |
| 5572 | mcp->mb[6] = led_cfg[5]; |
| 5573 | } |
| 5574 | |
| 5575 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 5576 | if (IS_QLA8031(ha)) |
| 5577 | mcp->out_mb |= MBX_6|MBX_5|MBX_4|MBX_3; |
| 5578 | mcp->in_mb = MBX_0; |
| 5579 | mcp->tov = 30; |
| 5580 | mcp->flags = 0; |
| 5581 | |
| 5582 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5583 | if (rval != QLA_SUCCESS) { |
| 5584 | ql_dbg(ql_dbg_mbx, vha, 0x1134, |
| 5585 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5586 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5587 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1135, |
| 5588 | "Done %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5589 | } |
| 5590 | |
| 5591 | return rval; |
| 5592 | } |
| 5593 | |
| 5594 | int |
| 5595 | qla81xx_get_led_config(scsi_qla_host_t *vha, uint16_t *led_cfg) |
| 5596 | { |
| 5597 | int rval; |
| 5598 | struct qla_hw_data *ha = vha->hw; |
| 5599 | mbx_cmd_t mc; |
| 5600 | mbx_cmd_t *mcp = &mc; |
| 5601 | |
| 5602 | if (!IS_QLA81XX(ha) && !IS_QLA8031(ha)) |
| 5603 | return QLA_FUNCTION_FAILED; |
| 5604 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5605 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1136, |
| 5606 | "Entered %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5607 | |
| 5608 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
| 5609 | mcp->mb[0] = MBC_GET_LED_CONFIG; |
| 5610 | |
| 5611 | mcp->out_mb = MBX_0; |
| 5612 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 5613 | if (IS_QLA8031(ha)) |
| 5614 | mcp->in_mb |= MBX_6|MBX_5|MBX_4|MBX_3; |
| 5615 | mcp->tov = 30; |
| 5616 | mcp->flags = 0; |
| 5617 | |
| 5618 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5619 | if (rval != QLA_SUCCESS) { |
| 5620 | ql_dbg(ql_dbg_mbx, vha, 0x1137, |
| 5621 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5622 | } else { |
| 5623 | led_cfg[0] = mcp->mb[1]; |
| 5624 | led_cfg[1] = mcp->mb[2]; |
| 5625 | if (IS_QLA8031(ha)) { |
| 5626 | led_cfg[2] = mcp->mb[3]; |
| 5627 | led_cfg[3] = mcp->mb[4]; |
| 5628 | led_cfg[4] = mcp->mb[5]; |
| 5629 | led_cfg[5] = mcp->mb[6]; |
| 5630 | } |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5631 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1138, |
| 5632 | "Done %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5633 | } |
| 5634 | |
| 5635 | return rval; |
| 5636 | } |
| 5637 | |
| 5638 | int |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5639 | qla82xx_mbx_beacon_ctl(scsi_qla_host_t *vha, int enable) |
| 5640 | { |
| 5641 | int rval; |
| 5642 | struct qla_hw_data *ha = vha->hw; |
| 5643 | mbx_cmd_t mc; |
| 5644 | mbx_cmd_t *mcp = &mc; |
| 5645 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5646 | if (!IS_P3P_TYPE(ha)) |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5647 | return QLA_FUNCTION_FAILED; |
| 5648 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5649 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1127, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5650 | "Entered %s.\n", __func__); |
| 5651 | |
| 5652 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
| 5653 | mcp->mb[0] = MBC_SET_LED_CONFIG; |
| 5654 | if (enable) |
| 5655 | mcp->mb[7] = 0xE; |
| 5656 | else |
| 5657 | mcp->mb[7] = 0xD; |
| 5658 | |
| 5659 | mcp->out_mb = MBX_7|MBX_0; |
| 5660 | mcp->in_mb = MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5661 | mcp->tov = MBX_TOV_SECONDS; |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5662 | mcp->flags = 0; |
| 5663 | |
| 5664 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5665 | if (rval != QLA_SUCCESS) { |
| 5666 | ql_dbg(ql_dbg_mbx, vha, 0x1128, |
| 5667 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5668 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5669 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1129, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5670 | "Done %s.\n", __func__); |
| 5671 | } |
| 5672 | |
| 5673 | return rval; |
| 5674 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5675 | |
| 5676 | int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5677 | 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] | 5678 | { |
| 5679 | int rval; |
| 5680 | struct qla_hw_data *ha = vha->hw; |
| 5681 | mbx_cmd_t mc; |
| 5682 | mbx_cmd_t *mcp = &mc; |
| 5683 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5684 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5685 | return QLA_FUNCTION_FAILED; |
| 5686 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5687 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1130, |
| 5688 | "Entered %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5689 | |
| 5690 | mcp->mb[0] = MBC_WRITE_REMOTE_REG; |
| 5691 | mcp->mb[1] = LSW(reg); |
| 5692 | mcp->mb[2] = MSW(reg); |
| 5693 | mcp->mb[3] = LSW(data); |
| 5694 | mcp->mb[4] = MSW(data); |
| 5695 | mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5696 | |
| 5697 | mcp->in_mb = MBX_1|MBX_0; |
| 5698 | mcp->tov = MBX_TOV_SECONDS; |
| 5699 | mcp->flags = 0; |
| 5700 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5701 | |
| 5702 | if (rval != QLA_SUCCESS) { |
| 5703 | ql_dbg(ql_dbg_mbx, vha, 0x1131, |
| 5704 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5705 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5706 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1132, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5707 | "Done %s.\n", __func__); |
| 5708 | } |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5709 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5710 | return rval; |
| 5711 | } |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5712 | |
| 5713 | int |
| 5714 | qla2x00_port_logout(scsi_qla_host_t *vha, struct fc_port *fcport) |
| 5715 | { |
| 5716 | int rval; |
| 5717 | struct qla_hw_data *ha = vha->hw; |
| 5718 | mbx_cmd_t mc; |
| 5719 | mbx_cmd_t *mcp = &mc; |
| 5720 | |
| 5721 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5722 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x113b, |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5723 | "Implicit LOGO Unsupported.\n"); |
| 5724 | return QLA_FUNCTION_FAILED; |
| 5725 | } |
| 5726 | |
| 5727 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5728 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x113c, |
| 5729 | "Entering %s.\n", __func__); |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5730 | |
| 5731 | /* Perform Implicit LOGO. */ |
| 5732 | mcp->mb[0] = MBC_PORT_LOGOUT; |
| 5733 | mcp->mb[1] = fcport->loop_id; |
| 5734 | mcp->mb[10] = BIT_15; |
| 5735 | mcp->out_mb = MBX_10|MBX_1|MBX_0; |
| 5736 | mcp->in_mb = MBX_0; |
| 5737 | mcp->tov = MBX_TOV_SECONDS; |
| 5738 | mcp->flags = 0; |
| 5739 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5740 | if (rval != QLA_SUCCESS) |
| 5741 | ql_dbg(ql_dbg_mbx, vha, 0x113d, |
| 5742 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5743 | else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5744 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x113e, |
| 5745 | "Done %s.\n", __func__); |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5746 | |
| 5747 | return rval; |
| 5748 | } |
| 5749 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5750 | int |
| 5751 | qla83xx_rd_reg(scsi_qla_host_t *vha, uint32_t reg, uint32_t *data) |
| 5752 | { |
| 5753 | int rval; |
| 5754 | mbx_cmd_t mc; |
| 5755 | mbx_cmd_t *mcp = &mc; |
| 5756 | struct qla_hw_data *ha = vha->hw; |
| 5757 | unsigned long retry_max_time = jiffies + (2 * HZ); |
| 5758 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5759 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5760 | return QLA_FUNCTION_FAILED; |
| 5761 | |
| 5762 | ql_dbg(ql_dbg_mbx, vha, 0x114b, "Entered %s.\n", __func__); |
| 5763 | |
| 5764 | retry_rd_reg: |
| 5765 | mcp->mb[0] = MBC_READ_REMOTE_REG; |
| 5766 | mcp->mb[1] = LSW(reg); |
| 5767 | mcp->mb[2] = MSW(reg); |
| 5768 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 5769 | mcp->in_mb = MBX_4|MBX_3|MBX_1|MBX_0; |
| 5770 | mcp->tov = MBX_TOV_SECONDS; |
| 5771 | mcp->flags = 0; |
| 5772 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5773 | |
| 5774 | if (rval != QLA_SUCCESS) { |
| 5775 | ql_dbg(ql_dbg_mbx, vha, 0x114c, |
| 5776 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 5777 | rval, mcp->mb[0], mcp->mb[1]); |
| 5778 | } else { |
| 5779 | *data = (mcp->mb[3] | (mcp->mb[4] << 16)); |
| 5780 | if (*data == QLA8XXX_BAD_VALUE) { |
| 5781 | /* |
| 5782 | * During soft-reset CAMRAM register reads might |
| 5783 | * return 0xbad0bad0. So retry for MAX of 2 sec |
| 5784 | * while reading camram registers. |
| 5785 | */ |
| 5786 | if (time_after(jiffies, retry_max_time)) { |
| 5787 | ql_dbg(ql_dbg_mbx, vha, 0x1141, |
| 5788 | "Failure to read CAMRAM register. " |
| 5789 | "data=0x%x.\n", *data); |
| 5790 | return QLA_FUNCTION_FAILED; |
| 5791 | } |
| 5792 | msleep(100); |
| 5793 | goto retry_rd_reg; |
| 5794 | } |
| 5795 | ql_dbg(ql_dbg_mbx, vha, 0x1142, "Done %s.\n", __func__); |
| 5796 | } |
| 5797 | |
| 5798 | return rval; |
| 5799 | } |
| 5800 | |
| 5801 | int |
| 5802 | qla83xx_restart_nic_firmware(scsi_qla_host_t *vha) |
| 5803 | { |
| 5804 | int rval; |
| 5805 | mbx_cmd_t mc; |
| 5806 | mbx_cmd_t *mcp = &mc; |
| 5807 | struct qla_hw_data *ha = vha->hw; |
| 5808 | |
Himanshu Madhani | b20f02e | 2015-06-10 11:05:18 -0400 | [diff] [blame] | 5809 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5810 | return QLA_FUNCTION_FAILED; |
| 5811 | |
| 5812 | ql_dbg(ql_dbg_mbx, vha, 0x1143, "Entered %s.\n", __func__); |
| 5813 | |
| 5814 | mcp->mb[0] = MBC_RESTART_NIC_FIRMWARE; |
| 5815 | mcp->out_mb = MBX_0; |
| 5816 | mcp->in_mb = MBX_1|MBX_0; |
| 5817 | mcp->tov = MBX_TOV_SECONDS; |
| 5818 | mcp->flags = 0; |
| 5819 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5820 | |
| 5821 | if (rval != QLA_SUCCESS) { |
| 5822 | ql_dbg(ql_dbg_mbx, vha, 0x1144, |
| 5823 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 5824 | rval, mcp->mb[0], mcp->mb[1]); |
| 5825 | ha->isp_ops->fw_dump(vha, 0); |
| 5826 | } else { |
| 5827 | ql_dbg(ql_dbg_mbx, vha, 0x1145, "Done %s.\n", __func__); |
| 5828 | } |
| 5829 | |
| 5830 | return rval; |
| 5831 | } |
| 5832 | |
| 5833 | int |
| 5834 | qla83xx_access_control(scsi_qla_host_t *vha, uint16_t options, |
| 5835 | uint32_t start_addr, uint32_t end_addr, uint16_t *sector_size) |
| 5836 | { |
| 5837 | int rval; |
| 5838 | mbx_cmd_t mc; |
| 5839 | mbx_cmd_t *mcp = &mc; |
| 5840 | uint8_t subcode = (uint8_t)options; |
| 5841 | struct qla_hw_data *ha = vha->hw; |
| 5842 | |
| 5843 | if (!IS_QLA8031(ha)) |
| 5844 | return QLA_FUNCTION_FAILED; |
| 5845 | |
| 5846 | ql_dbg(ql_dbg_mbx, vha, 0x1146, "Entered %s.\n", __func__); |
| 5847 | |
| 5848 | mcp->mb[0] = MBC_SET_ACCESS_CONTROL; |
| 5849 | mcp->mb[1] = options; |
| 5850 | mcp->out_mb = MBX_1|MBX_0; |
| 5851 | if (subcode & BIT_2) { |
| 5852 | mcp->mb[2] = LSW(start_addr); |
| 5853 | mcp->mb[3] = MSW(start_addr); |
| 5854 | mcp->mb[4] = LSW(end_addr); |
| 5855 | mcp->mb[5] = MSW(end_addr); |
| 5856 | mcp->out_mb |= MBX_5|MBX_4|MBX_3|MBX_2; |
| 5857 | } |
| 5858 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 5859 | if (!(subcode & (BIT_2 | BIT_5))) |
| 5860 | mcp->in_mb |= MBX_4|MBX_3; |
| 5861 | mcp->tov = MBX_TOV_SECONDS; |
| 5862 | mcp->flags = 0; |
| 5863 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5864 | |
| 5865 | if (rval != QLA_SUCCESS) { |
| 5866 | ql_dbg(ql_dbg_mbx, vha, 0x1147, |
| 5867 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[3]=%x mb[4]=%x.\n", |
| 5868 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2], mcp->mb[3], |
| 5869 | mcp->mb[4]); |
| 5870 | ha->isp_ops->fw_dump(vha, 0); |
| 5871 | } else { |
| 5872 | if (subcode & BIT_5) |
| 5873 | *sector_size = mcp->mb[1]; |
| 5874 | else if (subcode & (BIT_6 | BIT_7)) { |
| 5875 | ql_dbg(ql_dbg_mbx, vha, 0x1148, |
| 5876 | "Driver-lock id=%x%x", mcp->mb[4], mcp->mb[3]); |
| 5877 | } else if (subcode & (BIT_3 | BIT_4)) { |
| 5878 | ql_dbg(ql_dbg_mbx, vha, 0x1149, |
| 5879 | "Flash-lock id=%x%x", mcp->mb[4], mcp->mb[3]); |
| 5880 | } |
| 5881 | ql_dbg(ql_dbg_mbx, vha, 0x114a, "Done %s.\n", __func__); |
| 5882 | } |
| 5883 | |
| 5884 | return rval; |
| 5885 | } |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 5886 | |
| 5887 | int |
| 5888 | qla2x00_dump_mctp_data(scsi_qla_host_t *vha, dma_addr_t req_dma, uint32_t addr, |
| 5889 | uint32_t size) |
| 5890 | { |
| 5891 | int rval; |
| 5892 | mbx_cmd_t mc; |
| 5893 | mbx_cmd_t *mcp = &mc; |
| 5894 | |
| 5895 | if (!IS_MCTP_CAPABLE(vha->hw)) |
| 5896 | return QLA_FUNCTION_FAILED; |
| 5897 | |
| 5898 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x114f, |
| 5899 | "Entered %s.\n", __func__); |
| 5900 | |
| 5901 | mcp->mb[0] = MBC_DUMP_RISC_RAM_EXTENDED; |
| 5902 | mcp->mb[1] = LSW(addr); |
| 5903 | mcp->mb[2] = MSW(req_dma); |
| 5904 | mcp->mb[3] = LSW(req_dma); |
| 5905 | mcp->mb[4] = MSW(size); |
| 5906 | mcp->mb[5] = LSW(size); |
| 5907 | mcp->mb[6] = MSW(MSD(req_dma)); |
| 5908 | mcp->mb[7] = LSW(MSD(req_dma)); |
| 5909 | mcp->mb[8] = MSW(addr); |
| 5910 | /* Setting RAM ID to valid */ |
| 5911 | mcp->mb[10] |= BIT_7; |
| 5912 | /* For MCTP RAM ID is 0x40 */ |
| 5913 | mcp->mb[10] |= 0x40; |
| 5914 | |
| 5915 | mcp->out_mb |= MBX_10|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1| |
| 5916 | MBX_0; |
| 5917 | |
| 5918 | mcp->in_mb = MBX_0; |
| 5919 | mcp->tov = MBX_TOV_SECONDS; |
| 5920 | mcp->flags = 0; |
| 5921 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5922 | |
| 5923 | if (rval != QLA_SUCCESS) { |
| 5924 | ql_dbg(ql_dbg_mbx, vha, 0x114e, |
| 5925 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5926 | } else { |
| 5927 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x114d, |
| 5928 | "Done %s.\n", __func__); |
| 5929 | } |
| 5930 | |
| 5931 | return rval; |
| 5932 | } |
Joe Carnuccio | ec89146 | 2016-07-06 11:14:26 -0400 | [diff] [blame] | 5933 | |
| 5934 | int |
| 5935 | qla26xx_dport_diagnostics(scsi_qla_host_t *vha, |
| 5936 | void *dd_buf, uint size, uint options) |
| 5937 | { |
| 5938 | int rval; |
| 5939 | mbx_cmd_t mc; |
| 5940 | mbx_cmd_t *mcp = &mc; |
| 5941 | dma_addr_t dd_dma; |
| 5942 | |
| 5943 | if (!IS_QLA83XX(vha->hw) && !IS_QLA27XX(vha->hw)) |
| 5944 | return QLA_FUNCTION_FAILED; |
| 5945 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 5946 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x119f, |
Joe Carnuccio | ec89146 | 2016-07-06 11:14:26 -0400 | [diff] [blame] | 5947 | "Entered %s.\n", __func__); |
| 5948 | |
Joe Carnuccio | ec89146 | 2016-07-06 11:14:26 -0400 | [diff] [blame] | 5949 | dd_dma = dma_map_single(&vha->hw->pdev->dev, |
| 5950 | dd_buf, size, DMA_FROM_DEVICE); |
Pan Bian | 0b2ce19 | 2017-08-08 21:55:30 +0800 | [diff] [blame] | 5951 | if (dma_mapping_error(&vha->hw->pdev->dev, dd_dma)) { |
Joe Carnuccio | ec89146 | 2016-07-06 11:14:26 -0400 | [diff] [blame] | 5952 | ql_log(ql_log_warn, vha, 0x1194, "Failed to map dma buffer.\n"); |
| 5953 | return QLA_MEMORY_ALLOC_FAILED; |
| 5954 | } |
| 5955 | |
| 5956 | memset(dd_buf, 0, size); |
| 5957 | |
| 5958 | mcp->mb[0] = MBC_DPORT_DIAGNOSTICS; |
| 5959 | mcp->mb[1] = options; |
| 5960 | mcp->mb[2] = MSW(LSD(dd_dma)); |
| 5961 | mcp->mb[3] = LSW(LSD(dd_dma)); |
| 5962 | mcp->mb[6] = MSW(MSD(dd_dma)); |
| 5963 | mcp->mb[7] = LSW(MSD(dd_dma)); |
| 5964 | mcp->mb[8] = size; |
| 5965 | mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5966 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 5967 | mcp->buf_size = size; |
| 5968 | mcp->flags = MBX_DMA_IN; |
| 5969 | mcp->tov = MBX_TOV_SECONDS * 4; |
| 5970 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5971 | |
| 5972 | if (rval != QLA_SUCCESS) { |
| 5973 | ql_dbg(ql_dbg_mbx, vha, 0x1195, "Failed=%x.\n", rval); |
| 5974 | } else { |
| 5975 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1196, |
| 5976 | "Done %s.\n", __func__); |
| 5977 | } |
| 5978 | |
| 5979 | dma_unmap_single(&vha->hw->pdev->dev, dd_dma, |
| 5980 | size, DMA_FROM_DEVICE); |
| 5981 | |
| 5982 | return rval; |
| 5983 | } |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 5984 | |
| 5985 | static void qla2x00_async_mb_sp_done(void *s, int res) |
| 5986 | { |
| 5987 | struct srb *sp = s; |
| 5988 | |
| 5989 | sp->u.iocb_cmd.u.mbx.rc = res; |
| 5990 | |
| 5991 | complete(&sp->u.iocb_cmd.u.mbx.comp); |
| 5992 | /* don't free sp here. Let the caller do the free */ |
| 5993 | } |
| 5994 | |
| 5995 | /* |
| 5996 | * This mailbox uses the iocb interface to send MB command. |
| 5997 | * This allows non-critial (non chip setup) command to go |
| 5998 | * out in parrallel. |
| 5999 | */ |
| 6000 | int qla24xx_send_mb_cmd(struct scsi_qla_host *vha, mbx_cmd_t *mcp) |
| 6001 | { |
| 6002 | int rval = QLA_FUNCTION_FAILED; |
| 6003 | srb_t *sp; |
| 6004 | struct srb_iocb *c; |
| 6005 | |
| 6006 | if (!vha->hw->flags.fw_started) |
| 6007 | goto done; |
| 6008 | |
| 6009 | sp = qla2x00_get_sp(vha, NULL, GFP_KERNEL); |
| 6010 | if (!sp) |
| 6011 | goto done; |
| 6012 | |
| 6013 | sp->type = SRB_MB_IOCB; |
| 6014 | sp->name = mb_to_str(mcp->mb[0]); |
| 6015 | |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6016 | c = &sp->u.iocb_cmd; |
| 6017 | c->timeout = qla2x00_async_iocb_timeout; |
| 6018 | init_completion(&c->u.mbx.comp); |
| 6019 | |
Ben Hutchings | e74e7d9 | 2018-03-20 21:36:14 +0000 | [diff] [blame] | 6020 | qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); |
| 6021 | |
| 6022 | memcpy(sp->u.iocb_cmd.u.mbx.out_mb, mcp->mb, SIZEOF_IOCB_MB_REG); |
| 6023 | |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6024 | sp->done = qla2x00_async_mb_sp_done; |
| 6025 | |
| 6026 | rval = qla2x00_start_sp(sp); |
| 6027 | if (rval != QLA_SUCCESS) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6028 | ql_dbg(ql_dbg_mbx, vha, 0x1018, |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6029 | "%s: %s Failed submission. %x.\n", |
| 6030 | __func__, sp->name, rval); |
| 6031 | goto done_free_sp; |
| 6032 | } |
| 6033 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6034 | 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] | 6035 | sp->name, sp->handle); |
| 6036 | |
| 6037 | wait_for_completion(&c->u.mbx.comp); |
| 6038 | memcpy(mcp->mb, sp->u.iocb_cmd.u.mbx.in_mb, SIZEOF_IOCB_MB_REG); |
| 6039 | |
| 6040 | rval = c->u.mbx.rc; |
| 6041 | switch (rval) { |
| 6042 | case QLA_FUNCTION_TIMEOUT: |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6043 | ql_dbg(ql_dbg_mbx, vha, 0x1140, "%s: %s Timeout. %x.\n", |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6044 | __func__, sp->name, rval); |
| 6045 | break; |
| 6046 | case QLA_SUCCESS: |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6047 | ql_dbg(ql_dbg_mbx, vha, 0x119d, "%s: %s done.\n", |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6048 | __func__, sp->name); |
| 6049 | sp->free(sp); |
| 6050 | break; |
| 6051 | default: |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6052 | ql_dbg(ql_dbg_mbx, vha, 0x119e, "%s: %s Failed. %x.\n", |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6053 | __func__, sp->name, rval); |
| 6054 | sp->free(sp); |
| 6055 | break; |
| 6056 | } |
| 6057 | |
| 6058 | return rval; |
| 6059 | |
| 6060 | done_free_sp: |
| 6061 | sp->free(sp); |
| 6062 | done: |
| 6063 | return rval; |
| 6064 | } |
| 6065 | |
| 6066 | /* |
| 6067 | * qla24xx_gpdb_wait |
| 6068 | * NOTE: Do not call this routine from DPC thread |
| 6069 | */ |
| 6070 | int qla24xx_gpdb_wait(struct scsi_qla_host *vha, fc_port_t *fcport, u8 opt) |
| 6071 | { |
| 6072 | int rval = QLA_FUNCTION_FAILED; |
| 6073 | dma_addr_t pd_dma; |
| 6074 | struct port_database_24xx *pd; |
| 6075 | struct qla_hw_data *ha = vha->hw; |
| 6076 | mbx_cmd_t mc; |
| 6077 | |
| 6078 | if (!vha->hw->flags.fw_started) |
| 6079 | goto done; |
| 6080 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 6081 | pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6082 | if (pd == NULL) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6083 | ql_log(ql_log_warn, vha, 0xd047, |
| 6084 | "Failed to allocate port database structure.\n"); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6085 | goto done_free_sp; |
| 6086 | } |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6087 | |
| 6088 | memset(&mc, 0, sizeof(mc)); |
| 6089 | mc.mb[0] = MBC_GET_PORT_DATABASE; |
| 6090 | mc.mb[1] = cpu_to_le16(fcport->loop_id); |
| 6091 | mc.mb[2] = MSW(pd_dma); |
| 6092 | mc.mb[3] = LSW(pd_dma); |
| 6093 | mc.mb[6] = MSW(MSD(pd_dma)); |
| 6094 | mc.mb[7] = LSW(MSD(pd_dma)); |
| 6095 | mc.mb[9] = cpu_to_le16(vha->vp_idx); |
| 6096 | mc.mb[10] = cpu_to_le16((uint16_t)opt); |
| 6097 | |
| 6098 | rval = qla24xx_send_mb_cmd(vha, &mc); |
| 6099 | if (rval != QLA_SUCCESS) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6100 | ql_dbg(ql_dbg_mbx, vha, 0x1193, |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6101 | "%s: %8phC fail\n", __func__, fcport->port_name); |
| 6102 | goto done_free_sp; |
| 6103 | } |
| 6104 | |
| 6105 | rval = __qla24xx_parse_gpdb(vha, fcport, pd); |
| 6106 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6107 | ql_dbg(ql_dbg_mbx, vha, 0x1197, "%s: %8phC done\n", |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6108 | __func__, fcport->port_name); |
| 6109 | |
| 6110 | done_free_sp: |
| 6111 | if (pd) |
| 6112 | dma_pool_free(ha->s_dma_pool, pd, pd_dma); |
| 6113 | done: |
| 6114 | return rval; |
| 6115 | } |
| 6116 | |
| 6117 | int __qla24xx_parse_gpdb(struct scsi_qla_host *vha, fc_port_t *fcport, |
| 6118 | struct port_database_24xx *pd) |
| 6119 | { |
| 6120 | int rval = QLA_SUCCESS; |
| 6121 | uint64_t zero = 0; |
Duane Grigsby | a5d42f4 | 2017-06-21 13:48:41 -0700 | [diff] [blame] | 6122 | u8 current_login_state, last_login_state; |
| 6123 | |
| 6124 | if (fcport->fc4f_nvme) { |
| 6125 | current_login_state = pd->current_login_state >> 4; |
| 6126 | last_login_state = pd->last_login_state >> 4; |
| 6127 | } else { |
| 6128 | current_login_state = pd->current_login_state & 0xf; |
| 6129 | last_login_state = pd->last_login_state & 0xf; |
| 6130 | } |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6131 | |
| 6132 | /* Check for logged in state. */ |
Quinn Tran | 23c6455 | 2017-12-04 14:45:08 -0800 | [diff] [blame] | 6133 | if (current_login_state != PDS_PRLI_COMPLETE) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6134 | ql_dbg(ql_dbg_mbx, vha, 0x119a, |
| 6135 | "Unable to verify login-state (%x/%x) for loop_id %x.\n", |
Duane Grigsby | a5d42f4 | 2017-06-21 13:48:41 -0700 | [diff] [blame] | 6136 | current_login_state, last_login_state, fcport->loop_id); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6137 | rval = QLA_FUNCTION_FAILED; |
| 6138 | goto gpd_error_out; |
| 6139 | } |
| 6140 | |
| 6141 | if (fcport->loop_id == FC_NO_LOOP_ID || |
| 6142 | (memcmp(fcport->port_name, (uint8_t *)&zero, 8) && |
| 6143 | memcmp(fcport->port_name, pd->port_name, 8))) { |
| 6144 | /* We lost the device mid way. */ |
| 6145 | rval = QLA_NOT_LOGGED_IN; |
| 6146 | goto gpd_error_out; |
| 6147 | } |
| 6148 | |
| 6149 | /* Names are little-endian. */ |
| 6150 | memcpy(fcport->node_name, pd->node_name, WWN_SIZE); |
| 6151 | memcpy(fcport->port_name, pd->port_name, WWN_SIZE); |
| 6152 | |
| 6153 | /* Get port_id of device. */ |
| 6154 | fcport->d_id.b.domain = pd->port_id[0]; |
| 6155 | fcport->d_id.b.area = pd->port_id[1]; |
| 6156 | fcport->d_id.b.al_pa = pd->port_id[2]; |
| 6157 | fcport->d_id.b.rsvd_1 = 0; |
| 6158 | |
Duane Grigsby | a5d42f4 | 2017-06-21 13:48:41 -0700 | [diff] [blame] | 6159 | if (fcport->fc4f_nvme) { |
| 6160 | fcport->nvme_prli_service_param = |
| 6161 | pd->prli_nvme_svc_param_word_3; |
| 6162 | fcport->port_type = FCT_NVME; |
| 6163 | } else { |
| 6164 | /* If not target must be initiator or unknown type. */ |
| 6165 | if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0) |
| 6166 | fcport->port_type = FCT_INITIATOR; |
| 6167 | else |
| 6168 | fcport->port_type = FCT_TARGET; |
| 6169 | } |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6170 | /* Passback COS information. */ |
| 6171 | fcport->supported_classes = (pd->flags & PDF_CLASS_2) ? |
| 6172 | FC_COS_CLASS2 : FC_COS_CLASS3; |
| 6173 | |
| 6174 | if (pd->prli_svc_param_word_3[0] & BIT_7) { |
| 6175 | fcport->flags |= FCF_CONF_COMP_SUPPORTED; |
| 6176 | fcport->conf_compl_supported = 1; |
| 6177 | } |
| 6178 | |
| 6179 | gpd_error_out: |
| 6180 | return rval; |
| 6181 | } |
| 6182 | |
| 6183 | /* |
| 6184 | * qla24xx_gidlist__wait |
| 6185 | * NOTE: don't call this routine from DPC thread. |
| 6186 | */ |
| 6187 | int qla24xx_gidlist_wait(struct scsi_qla_host *vha, |
| 6188 | void *id_list, dma_addr_t id_list_dma, uint16_t *entries) |
| 6189 | { |
| 6190 | int rval = QLA_FUNCTION_FAILED; |
| 6191 | mbx_cmd_t mc; |
| 6192 | |
| 6193 | if (!vha->hw->flags.fw_started) |
| 6194 | goto done; |
| 6195 | |
| 6196 | memset(&mc, 0, sizeof(mc)); |
| 6197 | mc.mb[0] = MBC_GET_ID_LIST; |
| 6198 | mc.mb[2] = MSW(id_list_dma); |
| 6199 | mc.mb[3] = LSW(id_list_dma); |
| 6200 | mc.mb[6] = MSW(MSD(id_list_dma)); |
| 6201 | mc.mb[7] = LSW(MSD(id_list_dma)); |
| 6202 | mc.mb[8] = 0; |
| 6203 | mc.mb[9] = cpu_to_le16(vha->vp_idx); |
| 6204 | |
| 6205 | rval = qla24xx_send_mb_cmd(vha, &mc); |
| 6206 | if (rval != QLA_SUCCESS) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6207 | ql_dbg(ql_dbg_mbx, vha, 0x119b, |
| 6208 | "%s: fail\n", __func__); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6209 | } else { |
| 6210 | *entries = mc.mb[1]; |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6211 | ql_dbg(ql_dbg_mbx, vha, 0x119c, |
| 6212 | "%s: done\n", __func__); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6213 | } |
| 6214 | done: |
| 6215 | return rval; |
| 6216 | } |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 6217 | |
| 6218 | int qla27xx_set_zio_threshold(scsi_qla_host_t *vha, uint16_t value) |
| 6219 | { |
| 6220 | int rval; |
| 6221 | mbx_cmd_t mc; |
| 6222 | mbx_cmd_t *mcp = &mc; |
| 6223 | |
| 6224 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1200, |
| 6225 | "Entered %s\n", __func__); |
| 6226 | |
| 6227 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 6228 | mcp->mb[0] = MBC_GET_SET_ZIO_THRESHOLD; |
| 6229 | mcp->mb[1] = cpu_to_le16(1); |
| 6230 | mcp->mb[2] = cpu_to_le16(value); |
| 6231 | mcp->out_mb = MBX_2 | MBX_1 | MBX_0; |
| 6232 | mcp->in_mb = MBX_2 | MBX_0; |
| 6233 | mcp->tov = MBX_TOV_SECONDS; |
| 6234 | mcp->flags = 0; |
| 6235 | |
| 6236 | rval = qla2x00_mailbox_command(vha, mcp); |
| 6237 | |
| 6238 | ql_dbg(ql_dbg_mbx, vha, 0x1201, "%s %x\n", |
| 6239 | (rval != QLA_SUCCESS) ? "Failed" : "Done", rval); |
| 6240 | |
| 6241 | return rval; |
| 6242 | } |
| 6243 | |
| 6244 | int qla27xx_get_zio_threshold(scsi_qla_host_t *vha, uint16_t *value) |
| 6245 | { |
| 6246 | int rval; |
| 6247 | mbx_cmd_t mc; |
| 6248 | mbx_cmd_t *mcp = &mc; |
| 6249 | |
| 6250 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1203, |
| 6251 | "Entered %s\n", __func__); |
| 6252 | |
| 6253 | memset(mcp->mb, 0, sizeof(mcp->mb)); |
| 6254 | mcp->mb[0] = MBC_GET_SET_ZIO_THRESHOLD; |
| 6255 | mcp->mb[1] = cpu_to_le16(0); |
| 6256 | mcp->out_mb = MBX_1 | MBX_0; |
| 6257 | mcp->in_mb = MBX_2 | MBX_0; |
| 6258 | mcp->tov = MBX_TOV_SECONDS; |
| 6259 | mcp->flags = 0; |
| 6260 | |
| 6261 | rval = qla2x00_mailbox_command(vha, mcp); |
| 6262 | if (rval == QLA_SUCCESS) |
| 6263 | *value = mc.mb[2]; |
| 6264 | |
| 6265 | ql_dbg(ql_dbg_mbx, vha, 0x1205, "%s %x\n", |
| 6266 | (rval != QLA_SUCCESS) ? "Failed" : "Done", rval); |
| 6267 | |
| 6268 | return rval; |
| 6269 | } |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 6270 | |
| 6271 | int |
| 6272 | qla2x00_read_sfp_dev(struct scsi_qla_host *vha, char *buf, int count) |
| 6273 | { |
| 6274 | struct qla_hw_data *ha = vha->hw; |
| 6275 | uint16_t iter, addr, offset; |
| 6276 | dma_addr_t phys_addr; |
| 6277 | int rval, c; |
| 6278 | u8 *sfp_data; |
| 6279 | |
| 6280 | memset(ha->sfp_data, 0, SFP_DEV_SIZE); |
| 6281 | addr = 0xa0; |
| 6282 | phys_addr = ha->sfp_data_dma; |
| 6283 | sfp_data = ha->sfp_data; |
| 6284 | offset = c = 0; |
| 6285 | |
| 6286 | for (iter = 0; iter < SFP_DEV_SIZE / SFP_BLOCK_SIZE; iter++) { |
| 6287 | if (iter == 4) { |
| 6288 | /* Skip to next device address. */ |
| 6289 | addr = 0xa2; |
| 6290 | offset = 0; |
| 6291 | } |
| 6292 | |
| 6293 | rval = qla2x00_read_sfp(vha, phys_addr, sfp_data, |
| 6294 | addr, offset, SFP_BLOCK_SIZE, BIT_1); |
| 6295 | if (rval != QLA_SUCCESS) { |
| 6296 | ql_log(ql_log_warn, vha, 0x706d, |
| 6297 | "Unable to read SFP data (%x/%x/%x).\n", rval, |
| 6298 | addr, offset); |
| 6299 | |
| 6300 | return rval; |
| 6301 | } |
| 6302 | |
| 6303 | if (buf && (c < count)) { |
| 6304 | u16 sz; |
| 6305 | |
| 6306 | if ((count - c) >= SFP_BLOCK_SIZE) |
| 6307 | sz = SFP_BLOCK_SIZE; |
| 6308 | else |
| 6309 | sz = count - c; |
| 6310 | |
| 6311 | memcpy(buf, sfp_data, sz); |
| 6312 | buf += SFP_BLOCK_SIZE; |
| 6313 | c += sz; |
| 6314 | } |
| 6315 | phys_addr += SFP_BLOCK_SIZE; |
| 6316 | sfp_data += SFP_BLOCK_SIZE; |
| 6317 | offset += SFP_BLOCK_SIZE; |
| 6318 | } |
| 6319 | |
| 6320 | return rval; |
| 6321 | } |
Quinn Tran | 94d83e3 | 2017-12-28 12:33:23 -0800 | [diff] [blame] | 6322 | |
| 6323 | int qla24xx_res_count_wait(struct scsi_qla_host *vha, |
| 6324 | uint16_t *out_mb, int out_mb_sz) |
| 6325 | { |
| 6326 | int rval = QLA_FUNCTION_FAILED; |
| 6327 | mbx_cmd_t mc; |
| 6328 | |
| 6329 | if (!vha->hw->flags.fw_started) |
| 6330 | goto done; |
| 6331 | |
| 6332 | memset(&mc, 0, sizeof(mc)); |
| 6333 | mc.mb[0] = MBC_GET_RESOURCE_COUNTS; |
| 6334 | |
| 6335 | rval = qla24xx_send_mb_cmd(vha, &mc); |
| 6336 | if (rval != QLA_SUCCESS) { |
| 6337 | ql_dbg(ql_dbg_mbx, vha, 0xffff, |
| 6338 | "%s: fail\n", __func__); |
| 6339 | } else { |
| 6340 | if (out_mb_sz <= SIZEOF_IOCB_MB_REG) |
| 6341 | memcpy(out_mb, mc.mb, out_mb_sz); |
| 6342 | else |
| 6343 | memcpy(out_mb, mc.mb, SIZEOF_IOCB_MB_REG); |
| 6344 | |
| 6345 | ql_dbg(ql_dbg_mbx, vha, 0xffff, |
| 6346 | "%s: done\n", __func__); |
| 6347 | } |
| 6348 | done: |
| 6349 | return rval; |
| 6350 | } |