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 }, |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 62 | { MBC_GET_RNID_PARAMS }, |
Quinn Tran | 8b4673b | 2018-09-04 14:19:14 -0700 | [diff] [blame] | 63 | { MBC_GET_SET_ZIO_THRESHOLD }, |
himanshu.madhani@cavium.com | 77ddb94 | 2016-12-12 14:40:05 -0800 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | static int is_rom_cmd(uint16_t cmd) |
| 67 | { |
| 68 | int i; |
| 69 | struct rom_cmd *wc; |
| 70 | |
| 71 | for (i = 0; i < ARRAY_SIZE(rom_cmds); i++) { |
| 72 | wc = rom_cmds + i; |
| 73 | if (wc->cmd == cmd) |
| 74 | return 1; |
| 75 | } |
| 76 | |
| 77 | return 0; |
| 78 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | |
| 80 | /* |
| 81 | * qla2x00_mailbox_command |
| 82 | * Issue mailbox command and waits for completion. |
| 83 | * |
| 84 | * Input: |
| 85 | * ha = adapter block pointer. |
| 86 | * mcp = driver internal mbx struct pointer. |
| 87 | * |
| 88 | * Output: |
| 89 | * mb[MAX_MAILBOX_REGISTER_COUNT] = returned mailbox data. |
| 90 | * |
| 91 | * Returns: |
| 92 | * 0 : QLA_SUCCESS = cmd performed success |
| 93 | * 1 : QLA_FUNCTION_FAILED (error encountered) |
| 94 | * 6 : QLA_FUNCTION_TIMEOUT (timeout condition encountered) |
| 95 | * |
| 96 | * Context: |
| 97 | * Kernel context. |
| 98 | */ |
| 99 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 100 | qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | { |
Himanshu Madhani | d14e72f | 2015-04-09 15:00:03 -0400 | [diff] [blame] | 102 | int rval, i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | unsigned long flags = 0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 104 | device_reg_t *reg; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 105 | uint8_t abort_active; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 106 | uint8_t io_lock_on; |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 107 | uint16_t command = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | uint16_t *iptr; |
| 109 | uint16_t __iomem *optr; |
| 110 | uint32_t cnt; |
| 111 | uint32_t mboxes; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | unsigned long wait_time; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 113 | struct qla_hw_data *ha = vha->hw; |
| 114 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 115 | u32 chip_reset; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 116 | |
Himanshu Madhani | d14e72f | 2015-04-09 15:00:03 -0400 | [diff] [blame] | 117 | |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 118 | ql_dbg(ql_dbg_mbx, vha, 0x1000, "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 119 | |
| 120 | if (ha->pdev->error_state > pci_channel_io_frozen) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 121 | ql_log(ql_log_warn, vha, 0x1001, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 122 | "error_state is greater than pci_channel_io_frozen, " |
| 123 | "exiting.\n"); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 124 | return QLA_FUNCTION_TIMEOUT; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 125 | } |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 126 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 127 | if (vha->device_flags & DFLG_DEV_FAILED) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 128 | ql_log(ql_log_warn, vha, 0x1002, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 129 | "Device in failed state, exiting.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 130 | return QLA_FUNCTION_TIMEOUT; |
| 131 | } |
| 132 | |
Bart Van Assche | c2a5d94 | 2017-01-11 15:58:58 -0800 | [diff] [blame] | 133 | /* if PCI error, then avoid mbx processing.*/ |
Sawan Chandak | ba17589 | 2017-06-02 09:11:58 -0700 | [diff] [blame] | 134 | if (test_bit(PFLG_DISCONNECTED, &base_vha->dpc_flags) && |
| 135 | test_bit(UNLOADING, &base_vha->dpc_flags)) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 136 | ql_log(ql_log_warn, vha, 0xd04e, |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 137 | "PCI error, exiting.\n"); |
| 138 | return QLA_FUNCTION_TIMEOUT; |
Bart Van Assche | c2a5d94 | 2017-01-11 15:58:58 -0800 | [diff] [blame] | 139 | } |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 140 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 141 | reg = ha->iobase; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 142 | io_lock_on = base_vha->flags.init_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | |
| 144 | rval = QLA_SUCCESS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 145 | abort_active = test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 146 | chip_reset = ha->chip_reset; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 147 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 148 | if (ha->flags.pci_channel_io_perm_failure) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 149 | ql_log(ql_log_warn, vha, 0x1003, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 150 | "Perm failure on EEH timeout MBX, exiting.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 151 | return QLA_FUNCTION_TIMEOUT; |
| 152 | } |
| 153 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 154 | if (IS_P3P_TYPE(ha) && ha->flags.isp82xx_fw_hung) { |
Giridhar Malavali | 862cd01 | 2011-02-23 15:27:11 -0800 | [diff] [blame] | 155 | /* Setting Link-Down error */ |
| 156 | mcp->mb[0] = MBS_LINK_DOWN_ERROR; |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 157 | ql_log(ql_log_warn, vha, 0x1004, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 158 | "FW hung = %d.\n", ha->flags.isp82xx_fw_hung); |
Andrew Vasquez | 1806fcd | 2011-11-18 09:02:15 -0800 | [diff] [blame] | 159 | return QLA_FUNCTION_TIMEOUT; |
Giridhar Malavali | 862cd01 | 2011-02-23 15:27:11 -0800 | [diff] [blame] | 160 | } |
| 161 | |
himanshu.madhani@cavium.com | 77ddb94 | 2016-12-12 14:40:05 -0800 | [diff] [blame] | 162 | /* check if ISP abort is active and return cmd with timeout */ |
| 163 | if ((test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 164 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 165 | test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) && |
| 166 | !is_rom_cmd(mcp->mb[0])) { |
| 167 | ql_log(ql_log_info, vha, 0x1005, |
| 168 | "Cmd 0x%x aborted with timeout since ISP Abort is pending\n", |
| 169 | mcp->mb[0]); |
| 170 | return QLA_FUNCTION_TIMEOUT; |
| 171 | } |
| 172 | |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 173 | atomic_inc(&ha->num_pend_mbx_stage1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | /* |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 175 | * Wait for active mailbox commands to finish by waiting at most tov |
| 176 | * seconds. This is to serialize actual issuing of mailbox cmds during |
| 177 | * non ISP abort time. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | */ |
Andrew Vasquez | 8eca3f3 | 2009-01-22 09:45:31 -0800 | [diff] [blame] | 179 | if (!wait_for_completion_timeout(&ha->mbx_cmd_comp, mcp->tov * HZ)) { |
| 180 | /* Timeout occurred. Return error. */ |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 181 | ql_log(ql_log_warn, vha, 0xd035, |
Chad Dupuis | d8c0d54 | 2012-02-09 11:15:46 -0800 | [diff] [blame] | 182 | "Cmd access timeout, cmd=0x%x, Exiting.\n", |
| 183 | mcp->mb[0]); |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 184 | atomic_dec(&ha->num_pend_mbx_stage1); |
Andrew Vasquez | 8eca3f3 | 2009-01-22 09:45:31 -0800 | [diff] [blame] | 185 | return QLA_FUNCTION_TIMEOUT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | } |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 187 | atomic_dec(&ha->num_pend_mbx_stage1); |
| 188 | if (ha->flags.purge_mbox || chip_reset != ha->chip_reset) { |
| 189 | rval = QLA_ABORTED; |
| 190 | goto premature_exit; |
| 191 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 193 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | /* Save mailbox command for debug */ |
| 195 | ha->mcp = mcp; |
| 196 | |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 197 | ql_dbg(ql_dbg_mbx, vha, 0x1006, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 198 | "Prepare to issue mbox cmd=0x%x.\n", mcp->mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | |
| 200 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 201 | |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 202 | if (ha->flags.purge_mbox || chip_reset != ha->chip_reset || |
| 203 | ha->flags.mbox_busy) { |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 204 | rval = QLA_ABORTED; |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 205 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 206 | goto premature_exit; |
| 207 | } |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 208 | ha->flags.mbox_busy = 1; |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 209 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | /* Load mailbox registers. */ |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 211 | if (IS_P3P_TYPE(ha)) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 212 | optr = (uint16_t __iomem *)®->isp82.mailbox_in[0]; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 213 | else if (IS_FWI2_CAPABLE(ha) && !(IS_P3P_TYPE(ha))) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 214 | optr = (uint16_t __iomem *)®->isp24.mailbox0; |
| 215 | else |
| 216 | optr = (uint16_t __iomem *)MAILBOX_REG(ha, ®->isp, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | |
| 218 | iptr = mcp->mb; |
| 219 | command = mcp->mb[0]; |
| 220 | mboxes = mcp->out_mb; |
| 221 | |
Joe Carnuccio | 7b71162 | 2014-09-25 05:16:43 -0400 | [diff] [blame] | 222 | ql_dbg(ql_dbg_mbx, vha, 0x1111, |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 223 | "Mailbox registers (OUT):\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | for (cnt = 0; cnt < ha->mbx_count; cnt++) { |
| 225 | if (IS_QLA2200(ha) && cnt == 8) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 226 | optr = |
| 227 | (uint16_t __iomem *)MAILBOX_REG(ha, ®->isp, 8); |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 228 | if (mboxes & BIT_0) { |
| 229 | ql_dbg(ql_dbg_mbx, vha, 0x1112, |
| 230 | "mbox[%d]<-0x%04x\n", cnt, *iptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | WRT_REG_WORD(optr, *iptr); |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 232 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | |
| 234 | mboxes >>= 1; |
| 235 | optr++; |
| 236 | iptr++; |
| 237 | } |
| 238 | |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 239 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1117, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 240 | "I/O Address = %p.\n", optr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | |
| 242 | /* Issue set host interrupt command to send cmd out. */ |
| 243 | ha->flags.mbox_int = 0; |
| 244 | clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
| 245 | |
| 246 | /* Unlock mbx registers and wait for interrupt */ |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 247 | ql_dbg(ql_dbg_mbx, vha, 0x100f, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 248 | "Going to unlock irq & waiting for interrupts. " |
| 249 | "jiffies=%lx.\n", jiffies); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | |
| 251 | /* Wait for mbx cmd completion until timeout */ |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 252 | atomic_inc(&ha->num_pend_mbx_stage2); |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 253 | if ((!abort_active && io_lock_on) || IS_NOPOLLING_TYPE(ha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | set_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); |
| 255 | |
Himanshu Madhani | 32a13df | 2019-08-30 15:23:59 -0700 | [diff] [blame] | 256 | if (IS_P3P_TYPE(ha)) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 257 | WRT_REG_DWORD(®->isp82.hint, HINT_MBX_INT_PENDING); |
Himanshu Madhani | 32a13df | 2019-08-30 15:23:59 -0700 | [diff] [blame] | 258 | else if (IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 259 | WRT_REG_DWORD(®->isp24.hccr, HCCRX_SET_HOST_INT); |
| 260 | else |
| 261 | WRT_REG_WORD(®->isp.hccr, HCCR_SET_HOST_INT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 263 | |
himanshu.madhani@cavium.com | 77ddb94 | 2016-12-12 14:40:05 -0800 | [diff] [blame] | 264 | wait_time = jiffies; |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 265 | atomic_inc(&ha->num_pend_mbx_stage3); |
Giridhar Malavali | 754d124 | 2013-06-25 11:27:16 -0400 | [diff] [blame] | 266 | if (!wait_for_completion_timeout(&ha->mbx_intr_comp, |
| 267 | mcp->tov * HZ)) { |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 268 | if (chip_reset != ha->chip_reset) { |
| 269 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 270 | ha->flags.mbox_busy = 0; |
| 271 | spin_unlock_irqrestore(&ha->hardware_lock, |
| 272 | flags); |
| 273 | atomic_dec(&ha->num_pend_mbx_stage2); |
| 274 | atomic_dec(&ha->num_pend_mbx_stage3); |
| 275 | rval = QLA_ABORTED; |
| 276 | goto premature_exit; |
| 277 | } |
Giridhar Malavali | 754d124 | 2013-06-25 11:27:16 -0400 | [diff] [blame] | 278 | ql_dbg(ql_dbg_mbx, vha, 0x117a, |
| 279 | "cmd=%x Timeout.\n", command); |
| 280 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 281 | clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); |
| 282 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 283 | |
| 284 | } else if (ha->flags.purge_mbox || |
| 285 | chip_reset != ha->chip_reset) { |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 286 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 287 | ha->flags.mbox_busy = 0; |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 288 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 289 | atomic_dec(&ha->num_pend_mbx_stage2); |
| 290 | atomic_dec(&ha->num_pend_mbx_stage3); |
| 291 | rval = QLA_ABORTED; |
| 292 | goto premature_exit; |
Giridhar Malavali | 754d124 | 2013-06-25 11:27:16 -0400 | [diff] [blame] | 293 | } |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 294 | atomic_dec(&ha->num_pend_mbx_stage3); |
| 295 | |
himanshu.madhani@cavium.com | 77ddb94 | 2016-12-12 14:40:05 -0800 | [diff] [blame] | 296 | if (time_after(jiffies, wait_time + 5 * HZ)) |
| 297 | ql_log(ql_log_warn, vha, 0x1015, "cmd=0x%x, waited %d msecs\n", |
| 298 | command, jiffies_to_msecs(jiffies - wait_time)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | } else { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 300 | ql_dbg(ql_dbg_mbx, vha, 0x1011, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 301 | "Cmd=%x Polling Mode.\n", command); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 303 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 304 | if (RD_REG_DWORD(®->isp82.hint) & |
| 305 | HINT_MBX_INT_PENDING) { |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 306 | ha->flags.mbox_busy = 0; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 307 | spin_unlock_irqrestore(&ha->hardware_lock, |
| 308 | flags); |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 309 | atomic_dec(&ha->num_pend_mbx_stage2); |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 310 | ql_dbg(ql_dbg_mbx, vha, 0x1012, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 311 | "Pending mailbox timeout, exiting.\n"); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 312 | rval = QLA_FUNCTION_TIMEOUT; |
| 313 | goto premature_exit; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 314 | } |
| 315 | WRT_REG_DWORD(®->isp82.hint, HINT_MBX_INT_PENDING); |
| 316 | } else if (IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 317 | WRT_REG_DWORD(®->isp24.hccr, HCCRX_SET_HOST_INT); |
| 318 | else |
| 319 | WRT_REG_WORD(®->isp.hccr, HCCR_SET_HOST_INT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | |
| 322 | wait_time = jiffies + mcp->tov * HZ; /* wait at most tov secs */ |
| 323 | while (!ha->flags.mbox_int) { |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 324 | if (ha->flags.purge_mbox || |
| 325 | chip_reset != ha->chip_reset) { |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 326 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 327 | ha->flags.mbox_busy = 0; |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 328 | spin_unlock_irqrestore(&ha->hardware_lock, |
| 329 | flags); |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 330 | atomic_dec(&ha->num_pend_mbx_stage2); |
| 331 | rval = QLA_ABORTED; |
| 332 | goto premature_exit; |
| 333 | } |
| 334 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | if (time_after(jiffies, wait_time)) |
| 336 | break; |
| 337 | |
Rodrigo R. Galvao | 3cb182b | 2018-05-28 14:58:44 -0300 | [diff] [blame] | 338 | /* |
| 339 | * Check if it's UNLOADING, cause we cannot poll in |
| 340 | * this case, or else a NULL pointer dereference |
| 341 | * is triggered. |
| 342 | */ |
| 343 | if (unlikely(test_bit(UNLOADING, &base_vha->dpc_flags))) |
| 344 | return QLA_FUNCTION_TIMEOUT; |
| 345 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | /* Check for pending interrupts. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 347 | qla2x00_poll(ha->rsp_q_map[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 349 | if (!ha->flags.mbox_int && |
| 350 | !(IS_QLA2200(ha) && |
| 351 | command == MBC_LOAD_RISC_RAM_EXTENDED)) |
andrew.vasquez@qlogic.com | 5998983 | 2006-01-13 17:05:10 -0800 | [diff] [blame] | 352 | msleep(10); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | } /* while */ |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 354 | ql_dbg(ql_dbg_mbx, vha, 0x1013, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 355 | "Waited %d sec.\n", |
| 356 | (uint)((jiffies - (wait_time - (mcp->tov * HZ)))/HZ)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | } |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 358 | atomic_dec(&ha->num_pend_mbx_stage2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | /* Check whether we timed out */ |
| 361 | if (ha->flags.mbox_int) { |
| 362 | uint16_t *iptr2; |
| 363 | |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 364 | ql_dbg(ql_dbg_mbx, vha, 0x1014, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 365 | "Cmd=%x completed.\n", command); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | |
| 367 | /* Got interrupt. Clear the flag. */ |
| 368 | ha->flags.mbox_int = 0; |
| 369 | clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
| 370 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 371 | if (IS_P3P_TYPE(ha) && ha->flags.isp82xx_fw_hung) { |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 372 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 373 | ha->flags.mbox_busy = 0; |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 374 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 375 | |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 376 | /* Setting Link-Down error */ |
| 377 | mcp->mb[0] = MBS_LINK_DOWN_ERROR; |
| 378 | ha->mcp = NULL; |
| 379 | rval = QLA_FUNCTION_FAILED; |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 380 | ql_log(ql_log_warn, vha, 0xd048, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 381 | "FW hung = %d.\n", ha->flags.isp82xx_fw_hung); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 382 | goto premature_exit; |
| 383 | } |
| 384 | |
Bart Van Assche | b3e9772 | 2019-08-08 20:01:41 -0700 | [diff] [blame] | 385 | if (ha->mailbox_out[0] != MBS_COMMAND_COMPLETE) { |
| 386 | ql_dbg(ql_dbg_mbx, vha, 0x11ff, |
| 387 | "mb_out[0] = %#x <> %#x\n", ha->mailbox_out[0], |
| 388 | MBS_COMMAND_COMPLETE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | b3e9772 | 2019-08-08 20:01:41 -0700 | [diff] [blame] | 390 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | |
| 392 | /* Load return mailbox registers. */ |
| 393 | iptr2 = mcp->mb; |
| 394 | iptr = (uint16_t *)&ha->mailbox_out[0]; |
| 395 | mboxes = mcp->in_mb; |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 396 | |
| 397 | ql_dbg(ql_dbg_mbx, vha, 0x1113, |
| 398 | "Mailbox registers (IN):\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | for (cnt = 0; cnt < ha->mbx_count; cnt++) { |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 400 | if (mboxes & BIT_0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | *iptr2 = *iptr; |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 402 | ql_dbg(ql_dbg_mbx, vha, 0x1114, |
| 403 | "mbox[%d]->0x%04x\n", cnt, *iptr2); |
| 404 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | |
| 406 | mboxes >>= 1; |
| 407 | iptr2++; |
| 408 | iptr++; |
| 409 | } |
| 410 | } else { |
| 411 | |
Quinn Tran | 8d3c9c2 | 2016-12-23 18:06:09 -0800 | [diff] [blame] | 412 | uint16_t mb[8]; |
| 413 | uint32_t ictrl, host_status, hccr; |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 414 | uint16_t w; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 415 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 416 | if (IS_FWI2_CAPABLE(ha)) { |
Quinn Tran | 8d3c9c2 | 2016-12-23 18:06:09 -0800 | [diff] [blame] | 417 | mb[0] = RD_REG_WORD(®->isp24.mailbox0); |
| 418 | mb[1] = RD_REG_WORD(®->isp24.mailbox1); |
| 419 | mb[2] = RD_REG_WORD(®->isp24.mailbox2); |
| 420 | mb[3] = RD_REG_WORD(®->isp24.mailbox3); |
| 421 | mb[7] = RD_REG_WORD(®->isp24.mailbox7); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 422 | ictrl = RD_REG_DWORD(®->isp24.ictrl); |
Quinn Tran | 8d3c9c2 | 2016-12-23 18:06:09 -0800 | [diff] [blame] | 423 | host_status = RD_REG_DWORD(®->isp24.host_status); |
| 424 | hccr = RD_REG_DWORD(®->isp24.hccr); |
| 425 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 426 | ql_log(ql_log_warn, vha, 0xd04c, |
Quinn Tran | 8d3c9c2 | 2016-12-23 18:06:09 -0800 | [diff] [blame] | 427 | "MBX Command timeout for cmd %x, iocontrol=%x jiffies=%lx " |
| 428 | "mb[0-3]=[0x%x 0x%x 0x%x 0x%x] mb7 0x%x host_status 0x%x hccr 0x%x\n", |
| 429 | command, ictrl, jiffies, mb[0], mb[1], mb[2], mb[3], |
| 430 | mb[7], host_status, hccr); |
| 431 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 432 | } else { |
Quinn Tran | 8d3c9c2 | 2016-12-23 18:06:09 -0800 | [diff] [blame] | 433 | mb[0] = RD_MAILBOX_REG(ha, ®->isp, 0); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 434 | ictrl = RD_REG_WORD(®->isp.ictrl); |
Quinn Tran | 8d3c9c2 | 2016-12-23 18:06:09 -0800 | [diff] [blame] | 435 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1119, |
| 436 | "MBX Command timeout for cmd %x, iocontrol=%x jiffies=%lx " |
| 437 | "mb[0]=0x%x\n", command, ictrl, jiffies, mb[0]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 438 | } |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 439 | ql_dump_regs(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1019); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 441 | /* Capture FW dump only, if PCI device active */ |
| 442 | if (!pci_channel_offline(vha->hw->pdev)) { |
| 443 | pci_read_config_word(ha->pdev, PCI_VENDOR_ID, &w); |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 444 | if (w == 0xffff || ictrl == 0xffffffff || |
| 445 | (chip_reset != ha->chip_reset)) { |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 446 | /* This is special case if there is unload |
| 447 | * of driver happening and if PCI device go |
| 448 | * into bad state due to PCI error condition |
| 449 | * then only PCI ERR flag would be set. |
| 450 | * we will do premature exit for above case. |
| 451 | */ |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 452 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 453 | ha->flags.mbox_busy = 0; |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 454 | spin_unlock_irqrestore(&ha->hardware_lock, |
| 455 | flags); |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 456 | rval = QLA_FUNCTION_TIMEOUT; |
| 457 | goto premature_exit; |
| 458 | } |
Chad Dupuis | f55bfc8 | 2012-02-09 11:15:53 -0800 | [diff] [blame] | 459 | |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 460 | /* Attempt to capture firmware dump for further |
| 461 | * anallysis of the current formware state. we do not |
| 462 | * need to do this if we are intentionally generating |
| 463 | * a dump |
| 464 | */ |
| 465 | if (mcp->mb[0] != MBC_GEN_SYSTEM_ERROR) |
| 466 | ha->isp_ops->fw_dump(vha, 0); |
| 467 | rval = QLA_FUNCTION_TIMEOUT; |
| 468 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | } |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 470 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | ha->flags.mbox_busy = 0; |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 472 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | |
| 474 | /* Clean up */ |
| 475 | ha->mcp = NULL; |
| 476 | |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 477 | if ((abort_active || !io_lock_on) && !IS_NOPOLLING_TYPE(ha)) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 478 | ql_dbg(ql_dbg_mbx, vha, 0x101a, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 479 | "Checking for additional resp interrupt.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | |
| 481 | /* polling mode for non isp_abort commands. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 482 | qla2x00_poll(ha->rsp_q_map[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | } |
| 484 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 485 | if (rval == QLA_FUNCTION_TIMEOUT && |
| 486 | mcp->mb[0] != MBC_GEN_SYSTEM_ERROR) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 487 | if (!io_lock_on || (mcp->flags & IOCTL_CMD) || |
| 488 | ha->flags.eeh_busy) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | /* not in dpc. schedule it for dpc to take over. */ |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 490 | ql_dbg(ql_dbg_mbx, vha, 0x101b, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 491 | "Timeout, schedule isp_abort_needed.\n"); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 492 | |
| 493 | if (!test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) && |
| 494 | !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) && |
| 495 | !test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) { |
Giridhar Malavali | 6315491 | 2011-11-18 09:02:19 -0800 | [diff] [blame] | 496 | if (IS_QLA82XX(ha)) { |
| 497 | ql_dbg(ql_dbg_mbx, vha, 0x112a, |
| 498 | "disabling pause transmit on port " |
| 499 | "0 & 1.\n"); |
| 500 | qla82xx_wr_32(ha, |
| 501 | QLA82XX_CRB_NIU + 0x98, |
| 502 | CRB_NIU_XG_PAUSE_CTL_P0| |
| 503 | CRB_NIU_XG_PAUSE_CTL_P1); |
| 504 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 505 | ql_log(ql_log_info, base_vha, 0x101c, |
Masanari Iida | 24d9ee8 | 2012-05-15 14:34:10 -0400 | [diff] [blame] | 506 | "Mailbox cmd timeout occurred, cmd=0x%x, " |
Chad Dupuis | d8c0d54 | 2012-02-09 11:15:46 -0800 | [diff] [blame] | 507 | "mb[0]=0x%x, eeh_busy=0x%x. Scheduling ISP " |
| 508 | "abort.\n", command, mcp->mb[0], |
| 509 | ha->flags.eeh_busy); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 510 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 511 | qla2xxx_wake_dpc(vha); |
| 512 | } |
Quinn Tran | 710bc78 | 2018-09-26 22:05:16 -0700 | [diff] [blame] | 513 | } else if (current == ha->dpc_thread) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 514 | /* call abort directly since we are in the DPC thread */ |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 515 | ql_dbg(ql_dbg_mbx, vha, 0x101d, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 516 | "Timeout, calling abort_isp.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 517 | |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 518 | if (!test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) && |
| 519 | !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) && |
| 520 | !test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) { |
Giridhar Malavali | 6315491 | 2011-11-18 09:02:19 -0800 | [diff] [blame] | 521 | if (IS_QLA82XX(ha)) { |
| 522 | ql_dbg(ql_dbg_mbx, vha, 0x112b, |
| 523 | "disabling pause transmit on port " |
| 524 | "0 & 1.\n"); |
| 525 | qla82xx_wr_32(ha, |
| 526 | QLA82XX_CRB_NIU + 0x98, |
| 527 | CRB_NIU_XG_PAUSE_CTL_P0| |
| 528 | CRB_NIU_XG_PAUSE_CTL_P1); |
| 529 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 530 | ql_log(ql_log_info, base_vha, 0x101e, |
Masanari Iida | 24d9ee8 | 2012-05-15 14:34:10 -0400 | [diff] [blame] | 531 | "Mailbox cmd timeout occurred, cmd=0x%x, " |
Chad Dupuis | d8c0d54 | 2012-02-09 11:15:46 -0800 | [diff] [blame] | 532 | "mb[0]=0x%x. Scheduling ISP abort ", |
| 533 | command, mcp->mb[0]); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 534 | set_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags); |
| 535 | clear_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Giridhar Malavali | d336096 | 2012-02-09 11:14:10 -0800 | [diff] [blame] | 536 | /* Allow next mbx cmd to come in. */ |
| 537 | complete(&ha->mbx_cmd_comp); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 538 | if (ha->isp_ops->abort_isp(vha)) { |
| 539 | /* Failed. retry later. */ |
| 540 | set_bit(ISP_ABORT_NEEDED, |
| 541 | &vha->dpc_flags); |
| 542 | } |
| 543 | clear_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags); |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 544 | ql_dbg(ql_dbg_mbx, vha, 0x101f, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 545 | "Finished abort_isp.\n"); |
Giridhar Malavali | d336096 | 2012-02-09 11:14:10 -0800 | [diff] [blame] | 546 | goto mbx_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | } |
| 549 | } |
| 550 | |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 551 | premature_exit: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | /* Allow next mbx cmd to come in. */ |
Andrew Vasquez | 8eca3f3 | 2009-01-22 09:45:31 -0800 | [diff] [blame] | 553 | complete(&ha->mbx_cmd_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | |
Giridhar Malavali | d336096 | 2012-02-09 11:14:10 -0800 | [diff] [blame] | 555 | mbx_done: |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 556 | if (rval == QLA_ABORTED) { |
| 557 | ql_log(ql_log_info, vha, 0xd035, |
| 558 | "Chip Reset in progress. Purging Mbox cmd=0x%x.\n", |
| 559 | mcp->mb[0]); |
| 560 | } else if (rval) { |
Joe Carnuccio | 050dc76 | 2017-08-23 15:05:14 -0700 | [diff] [blame] | 561 | if (ql2xextended_error_logging & (ql_dbg_disc|ql_dbg_mbx)) { |
Bart Van Assche | 3f918ff | 2019-04-17 14:44:20 -0700 | [diff] [blame] | 562 | pr_warn("%s [%s]-%04x:%ld: **** Failed=%x", QL_MSGHDR, |
Joe Carnuccio | 050dc76 | 2017-08-23 15:05:14 -0700 | [diff] [blame] | 563 | dev_name(&ha->pdev->dev), 0x1020+0x800, |
Bart Van Assche | 3f918ff | 2019-04-17 14:44:20 -0700 | [diff] [blame] | 564 | vha->host_no, rval); |
Joe Carnuccio | 050dc76 | 2017-08-23 15:05:14 -0700 | [diff] [blame] | 565 | mboxes = mcp->in_mb; |
| 566 | cnt = 4; |
| 567 | for (i = 0; i < ha->mbx_count && cnt; i++, mboxes >>= 1) |
| 568 | if (mboxes & BIT_0) { |
| 569 | printk(" mb[%u]=%x", i, mcp->mb[i]); |
| 570 | cnt--; |
| 571 | } |
| 572 | pr_warn(" cmd=%x ****\n", command); |
| 573 | } |
Meelis Roos | f7e59e9 | 2018-03-08 15:44:07 +0200 | [diff] [blame] | 574 | if (IS_FWI2_CAPABLE(ha) && !(IS_P3P_TYPE(ha))) { |
| 575 | ql_dbg(ql_dbg_mbx, vha, 0x1198, |
| 576 | "host_status=%#x intr_ctrl=%#x intr_status=%#x\n", |
| 577 | RD_REG_DWORD(®->isp24.host_status), |
| 578 | RD_REG_DWORD(®->isp24.ictrl), |
| 579 | RD_REG_DWORD(®->isp24.istatus)); |
| 580 | } else { |
| 581 | ql_dbg(ql_dbg_mbx, vha, 0x1206, |
| 582 | "ctrl_status=%#x ictrl=%#x istatus=%#x\n", |
| 583 | RD_REG_WORD(®->isp.ctrl_status), |
| 584 | RD_REG_WORD(®->isp.ictrl), |
| 585 | RD_REG_WORD(®->isp.istatus)); |
| 586 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 588 | ql_dbg(ql_dbg_mbx, base_vha, 0x1021, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | } |
| 590 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | return rval; |
| 592 | } |
| 593 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 595 | 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] | 596 | uint32_t risc_code_size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | { |
| 598 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 599 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | mbx_cmd_t mc; |
| 601 | mbx_cmd_t *mcp = &mc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 603 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1022, |
| 604 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 606 | if (MSW(risc_addr) || IS_FWI2_CAPABLE(ha)) { |
andrew.vasquez@qlogic.com | 590f98e | 2006-01-13 17:05:37 -0800 | [diff] [blame] | 607 | mcp->mb[0] = MBC_LOAD_RISC_RAM_EXTENDED; |
| 608 | mcp->mb[8] = MSW(risc_addr); |
| 609 | mcp->out_mb = MBX_8|MBX_0; |
| 610 | } else { |
| 611 | mcp->mb[0] = MBC_LOAD_RISC_RAM; |
| 612 | mcp->out_mb = MBX_0; |
| 613 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | mcp->mb[1] = LSW(risc_addr); |
| 615 | mcp->mb[2] = MSW(req_dma); |
| 616 | mcp->mb[3] = LSW(req_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | mcp->mb[6] = MSW(MSD(req_dma)); |
| 618 | mcp->mb[7] = LSW(MSD(req_dma)); |
andrew.vasquez@qlogic.com | 590f98e | 2006-01-13 17:05:37 -0800 | [diff] [blame] | 619 | 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] | 620 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 621 | mcp->mb[4] = MSW(risc_code_size); |
| 622 | mcp->mb[5] = LSW(risc_code_size); |
| 623 | mcp->out_mb |= MBX_5|MBX_4; |
| 624 | } else { |
| 625 | mcp->mb[4] = LSW(risc_code_size); |
| 626 | mcp->out_mb |= MBX_4; |
| 627 | } |
| 628 | |
Joe Carnuccio | 2a3192a | 2019-03-12 11:08:14 -0700 | [diff] [blame] | 629 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 630 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 632 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 635 | ql_dbg(ql_dbg_mbx, vha, 0x1023, |
Joe Carnuccio | 2a3192a | 2019-03-12 11:08:14 -0700 | [diff] [blame] | 636 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 637 | rval, mcp->mb[0], mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 638 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 639 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1024, |
| 640 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 641 | } |
| 642 | |
| 643 | return rval; |
| 644 | } |
| 645 | |
Santosh Vernekar | cad454b | 2010-03-19 16:59:16 -0700 | [diff] [blame] | 646 | #define EXTENDED_BB_CREDITS BIT_0 |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 647 | #define NVME_ENABLE_FLAG BIT_3 |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 648 | static inline uint16_t qla25xx_set_sfp_lr_dist(struct qla_hw_data *ha) |
| 649 | { |
| 650 | uint16_t mb4 = BIT_0; |
| 651 | |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 652 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 653 | mb4 |= ha->long_range_distance << LR_DIST_FW_POS; |
| 654 | |
| 655 | return mb4; |
| 656 | } |
| 657 | |
| 658 | static inline uint16_t qla25xx_set_nvr_lr_dist(struct qla_hw_data *ha) |
| 659 | { |
| 660 | uint16_t mb4 = BIT_0; |
| 661 | |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 662 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) { |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 663 | struct nvram_81xx *nv = ha->nvram; |
| 664 | |
| 665 | mb4 |= LR_DIST_FW_FIELD(nv->enhanced_features); |
| 666 | } |
| 667 | |
| 668 | return mb4; |
| 669 | } |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 670 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | /* |
| 672 | * qla2x00_execute_fw |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 673 | * Start adapter firmware. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 674 | * |
| 675 | * Input: |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 676 | * ha = adapter block pointer. |
| 677 | * TARGET_QUEUE_LOCK must be released. |
| 678 | * ADAPTER_STATE_LOCK must be released. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | * |
| 680 | * Returns: |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 681 | * qla2x00 local function return status code. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | * |
| 683 | * Context: |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 684 | * Kernel context. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | */ |
| 686 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 687 | qla2x00_execute_fw(scsi_qla_host_t *vha, uint32_t risc_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 688 | { |
| 689 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 690 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | mbx_cmd_t mc; |
| 692 | mbx_cmd_t *mcp = &mc; |
| 693 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 694 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1025, |
| 695 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | |
| 697 | mcp->mb[0] = MBC_EXECUTE_FIRMWARE; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 698 | mcp->out_mb = MBX_0; |
| 699 | mcp->in_mb = MBX_0; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 700 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 701 | mcp->mb[1] = MSW(risc_addr); |
| 702 | mcp->mb[2] = LSW(risc_addr); |
| 703 | mcp->mb[3] = 0; |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 704 | mcp->mb[4] = 0; |
Himanshu Madhani | c2ff2a3 | 2019-10-22 12:36:42 -0700 | [diff] [blame] | 705 | mcp->mb[11] = 0; |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 706 | ha->flags.using_lr_setting = 0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 707 | if (IS_QLA25XX(ha) || IS_QLA81XX(ha) || IS_QLA83XX(ha) || |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 708 | IS_QLA27XX(ha) || IS_QLA28XX(ha)) { |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 709 | if (ql2xautodetectsfp) { |
| 710 | if (ha->flags.detected_lr_sfp) { |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 711 | mcp->mb[4] |= |
| 712 | qla25xx_set_sfp_lr_dist(ha); |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 713 | ha->flags.using_lr_setting = 1; |
| 714 | } |
| 715 | } else { |
| 716 | struct nvram_81xx *nv = ha->nvram; |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 717 | /* set LR distance if specified in nvram */ |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 718 | if (nv->enhanced_features & |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 719 | NEF_LR_DIST_ENABLE) { |
| 720 | mcp->mb[4] |= |
| 721 | qla25xx_set_nvr_lr_dist(ha); |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 722 | ha->flags.using_lr_setting = 1; |
| 723 | } |
| 724 | } |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 725 | } |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 726 | |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 727 | if (ql2xnvmeenable && (IS_QLA27XX(ha) || IS_QLA28XX(ha))) |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 728 | mcp->mb[4] |= NVME_ENABLE_FLAG; |
| 729 | |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 730 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) { |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 731 | struct nvram_81xx *nv = ha->nvram; |
| 732 | /* set minimum speed if specified in nvram */ |
Joe Carnuccio | 72a92df | 2019-03-12 11:08:15 -0700 | [diff] [blame] | 733 | if (nv->min_supported_speed >= 2 && |
| 734 | nv->min_supported_speed <= 5) { |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 735 | mcp->mb[4] |= BIT_4; |
Joe Carnuccio | 72a92df | 2019-03-12 11:08:15 -0700 | [diff] [blame] | 736 | mcp->mb[11] |= nv->min_supported_speed & 0xF; |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 737 | mcp->out_mb |= MBX_11; |
| 738 | mcp->in_mb |= BIT_5; |
Joe Carnuccio | 72a92df | 2019-03-12 11:08:15 -0700 | [diff] [blame] | 739 | vha->min_supported_speed = |
| 740 | nv->min_supported_speed; |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 741 | } |
| 742 | } |
| 743 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 744 | if (ha->flags.exlogins_enabled) |
| 745 | mcp->mb[4] |= ENABLE_EXTENDED_LOGIN; |
| 746 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 747 | if (ha->flags.exchoffld_enabled) |
| 748 | mcp->mb[4] |= ENABLE_EXCHANGE_OFFLD; |
| 749 | |
Himanshu Madhani | c2ff2a3 | 2019-10-22 12:36:42 -0700 | [diff] [blame] | 750 | mcp->out_mb |= MBX_4 | MBX_3 | MBX_2 | MBX_1 | MBX_11; |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 751 | mcp->in_mb |= MBX_3 | MBX_2 | MBX_1; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 752 | } else { |
| 753 | mcp->mb[1] = LSW(risc_addr); |
| 754 | mcp->out_mb |= MBX_1; |
| 755 | if (IS_QLA2322(ha) || IS_QLA6322(ha)) { |
| 756 | mcp->mb[2] = 0; |
| 757 | mcp->out_mb |= MBX_2; |
| 758 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 759 | } |
| 760 | |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 761 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 762 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 763 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 764 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 765 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 766 | ql_dbg(ql_dbg_mbx, vha, 0x1026, |
| 767 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Joe Carnuccio | 72a92df | 2019-03-12 11:08:15 -0700 | [diff] [blame] | 768 | return rval; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 769 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 770 | |
Joe Carnuccio | 72a92df | 2019-03-12 11:08:15 -0700 | [diff] [blame] | 771 | if (!IS_FWI2_CAPABLE(ha)) |
| 772 | goto done; |
| 773 | |
| 774 | ha->fw_ability_mask = mcp->mb[3] << 16 | mcp->mb[2]; |
| 775 | ql_dbg(ql_dbg_mbx, vha, 0x119a, |
| 776 | "fw_ability_mask=%x.\n", ha->fw_ability_mask); |
| 777 | ql_dbg(ql_dbg_mbx, vha, 0x1027, "exchanges=%x.\n", mcp->mb[1]); |
| 778 | if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) { |
| 779 | ha->max_supported_speed = mcp->mb[2] & (BIT_0|BIT_1); |
| 780 | ql_dbg(ql_dbg_mbx, vha, 0x119b, "max_supported_speed=%s.\n", |
| 781 | ha->max_supported_speed == 0 ? "16Gps" : |
| 782 | ha->max_supported_speed == 1 ? "32Gps" : |
| 783 | ha->max_supported_speed == 2 ? "64Gps" : "unknown"); |
| 784 | if (vha->min_supported_speed) { |
| 785 | ha->min_supported_speed = mcp->mb[5] & |
| 786 | (BIT_0 | BIT_1 | BIT_2); |
| 787 | ql_dbg(ql_dbg_mbx, vha, 0x119c, |
| 788 | "min_supported_speed=%s.\n", |
| 789 | ha->min_supported_speed == 6 ? "64Gps" : |
| 790 | ha->min_supported_speed == 5 ? "32Gps" : |
| 791 | ha->min_supported_speed == 4 ? "16Gps" : |
| 792 | ha->min_supported_speed == 3 ? "8Gps" : |
| 793 | ha->min_supported_speed == 2 ? "4Gps" : "unknown"); |
| 794 | } |
| 795 | } |
| 796 | |
| 797 | done: |
| 798 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1028, |
| 799 | "Done %s.\n", __func__); |
| 800 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 801 | return rval; |
| 802 | } |
| 803 | |
| 804 | /* |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 805 | * qla_get_exlogin_status |
| 806 | * Get extended login status |
| 807 | * uses the memory offload control/status Mailbox |
| 808 | * |
| 809 | * Input: |
| 810 | * ha: adapter state pointer. |
| 811 | * fwopt: firmware options |
| 812 | * |
| 813 | * Returns: |
| 814 | * qla2x00 local function status |
| 815 | * |
| 816 | * Context: |
| 817 | * Kernel context. |
| 818 | */ |
| 819 | #define FETCH_XLOGINS_STAT 0x8 |
| 820 | int |
| 821 | qla_get_exlogin_status(scsi_qla_host_t *vha, uint16_t *buf_sz, |
| 822 | uint16_t *ex_logins_cnt) |
| 823 | { |
| 824 | int rval; |
| 825 | mbx_cmd_t mc; |
| 826 | mbx_cmd_t *mcp = &mc; |
| 827 | |
| 828 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x118f, |
| 829 | "Entered %s\n", __func__); |
| 830 | |
| 831 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 832 | mcp->mb[0] = MBC_GET_MEM_OFFLOAD_CNTRL_STAT; |
| 833 | mcp->mb[1] = FETCH_XLOGINS_STAT; |
| 834 | mcp->out_mb = MBX_1|MBX_0; |
| 835 | mcp->in_mb = MBX_10|MBX_4|MBX_0; |
| 836 | mcp->tov = MBX_TOV_SECONDS; |
| 837 | mcp->flags = 0; |
| 838 | |
| 839 | rval = qla2x00_mailbox_command(vha, mcp); |
| 840 | if (rval != QLA_SUCCESS) { |
| 841 | ql_dbg(ql_dbg_mbx, vha, 0x1115, "Failed=%x.\n", rval); |
| 842 | } else { |
| 843 | *buf_sz = mcp->mb[4]; |
| 844 | *ex_logins_cnt = mcp->mb[10]; |
| 845 | |
| 846 | ql_log(ql_log_info, vha, 0x1190, |
| 847 | "buffer size 0x%x, exchange login count=%d\n", |
| 848 | mcp->mb[4], mcp->mb[10]); |
| 849 | |
| 850 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1116, |
| 851 | "Done %s.\n", __func__); |
| 852 | } |
| 853 | |
| 854 | return rval; |
| 855 | } |
| 856 | |
| 857 | /* |
| 858 | * qla_set_exlogin_mem_cfg |
| 859 | * set extended login memory configuration |
| 860 | * Mbx needs to be issues before init_cb is set |
| 861 | * |
| 862 | * Input: |
| 863 | * ha: adapter state pointer. |
| 864 | * buffer: buffer pointer |
| 865 | * phys_addr: physical address of buffer |
| 866 | * size: size of buffer |
| 867 | * TARGET_QUEUE_LOCK must be released |
| 868 | * ADAPTER_STATE_LOCK must be release |
| 869 | * |
| 870 | * Returns: |
| 871 | * qla2x00 local funxtion status code. |
| 872 | * |
| 873 | * Context: |
| 874 | * Kernel context. |
| 875 | */ |
| 876 | #define CONFIG_XLOGINS_MEM 0x3 |
| 877 | int |
| 878 | qla_set_exlogin_mem_cfg(scsi_qla_host_t *vha, dma_addr_t phys_addr) |
| 879 | { |
| 880 | int rval; |
| 881 | mbx_cmd_t mc; |
| 882 | mbx_cmd_t *mcp = &mc; |
| 883 | struct qla_hw_data *ha = vha->hw; |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 884 | |
| 885 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x111a, |
| 886 | "Entered %s.\n", __func__); |
| 887 | |
| 888 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 889 | mcp->mb[0] = MBC_GET_MEM_OFFLOAD_CNTRL_STAT; |
| 890 | mcp->mb[1] = CONFIG_XLOGINS_MEM; |
| 891 | mcp->mb[2] = MSW(phys_addr); |
| 892 | mcp->mb[3] = LSW(phys_addr); |
| 893 | mcp->mb[6] = MSW(MSD(phys_addr)); |
| 894 | mcp->mb[7] = LSW(MSD(phys_addr)); |
| 895 | mcp->mb[8] = MSW(ha->exlogin_size); |
| 896 | mcp->mb[9] = LSW(ha->exlogin_size); |
| 897 | mcp->out_mb = MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 898 | mcp->in_mb = MBX_11|MBX_0; |
| 899 | mcp->tov = MBX_TOV_SECONDS; |
| 900 | mcp->flags = 0; |
| 901 | rval = qla2x00_mailbox_command(vha, mcp); |
| 902 | if (rval != QLA_SUCCESS) { |
| 903 | /*EMPTY*/ |
| 904 | ql_dbg(ql_dbg_mbx, vha, 0x111b, "Failed=%x.\n", rval); |
| 905 | } else { |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 906 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x118c, |
| 907 | "Done %s.\n", __func__); |
| 908 | } |
| 909 | |
| 910 | return rval; |
| 911 | } |
| 912 | |
| 913 | /* |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 914 | * qla_get_exchoffld_status |
| 915 | * Get exchange offload status |
| 916 | * uses the memory offload control/status Mailbox |
| 917 | * |
| 918 | * Input: |
| 919 | * ha: adapter state pointer. |
| 920 | * fwopt: firmware options |
| 921 | * |
| 922 | * Returns: |
| 923 | * qla2x00 local function status |
| 924 | * |
| 925 | * Context: |
| 926 | * Kernel context. |
| 927 | */ |
| 928 | #define FETCH_XCHOFFLD_STAT 0x2 |
| 929 | int |
| 930 | qla_get_exchoffld_status(scsi_qla_host_t *vha, uint16_t *buf_sz, |
| 931 | uint16_t *ex_logins_cnt) |
| 932 | { |
| 933 | int rval; |
| 934 | mbx_cmd_t mc; |
| 935 | mbx_cmd_t *mcp = &mc; |
| 936 | |
| 937 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1019, |
| 938 | "Entered %s\n", __func__); |
| 939 | |
| 940 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 941 | mcp->mb[0] = MBC_GET_MEM_OFFLOAD_CNTRL_STAT; |
| 942 | mcp->mb[1] = FETCH_XCHOFFLD_STAT; |
| 943 | mcp->out_mb = MBX_1|MBX_0; |
| 944 | mcp->in_mb = MBX_10|MBX_4|MBX_0; |
| 945 | mcp->tov = MBX_TOV_SECONDS; |
| 946 | mcp->flags = 0; |
| 947 | |
| 948 | rval = qla2x00_mailbox_command(vha, mcp); |
| 949 | if (rval != QLA_SUCCESS) { |
| 950 | ql_dbg(ql_dbg_mbx, vha, 0x1155, "Failed=%x.\n", rval); |
| 951 | } else { |
| 952 | *buf_sz = mcp->mb[4]; |
| 953 | *ex_logins_cnt = mcp->mb[10]; |
| 954 | |
| 955 | ql_log(ql_log_info, vha, 0x118e, |
| 956 | "buffer size 0x%x, exchange offload count=%d\n", |
| 957 | mcp->mb[4], mcp->mb[10]); |
| 958 | |
| 959 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1156, |
| 960 | "Done %s.\n", __func__); |
| 961 | } |
| 962 | |
| 963 | return rval; |
| 964 | } |
| 965 | |
| 966 | /* |
| 967 | * qla_set_exchoffld_mem_cfg |
| 968 | * Set exchange offload memory configuration |
| 969 | * Mbx needs to be issues before init_cb is set |
| 970 | * |
| 971 | * Input: |
| 972 | * ha: adapter state pointer. |
| 973 | * buffer: buffer pointer |
| 974 | * phys_addr: physical address of buffer |
| 975 | * size: size of buffer |
| 976 | * TARGET_QUEUE_LOCK must be released |
| 977 | * ADAPTER_STATE_LOCK must be release |
| 978 | * |
| 979 | * Returns: |
| 980 | * qla2x00 local funxtion status code. |
| 981 | * |
| 982 | * Context: |
| 983 | * Kernel context. |
| 984 | */ |
| 985 | #define CONFIG_XCHOFFLD_MEM 0x3 |
| 986 | int |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 987 | qla_set_exchoffld_mem_cfg(scsi_qla_host_t *vha) |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 988 | { |
| 989 | int rval; |
| 990 | mbx_cmd_t mc; |
| 991 | mbx_cmd_t *mcp = &mc; |
| 992 | struct qla_hw_data *ha = vha->hw; |
| 993 | |
| 994 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1157, |
| 995 | "Entered %s.\n", __func__); |
| 996 | |
| 997 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 998 | mcp->mb[0] = MBC_GET_MEM_OFFLOAD_CNTRL_STAT; |
| 999 | mcp->mb[1] = CONFIG_XCHOFFLD_MEM; |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 1000 | mcp->mb[2] = MSW(ha->exchoffld_buf_dma); |
| 1001 | mcp->mb[3] = LSW(ha->exchoffld_buf_dma); |
| 1002 | mcp->mb[6] = MSW(MSD(ha->exchoffld_buf_dma)); |
| 1003 | mcp->mb[7] = LSW(MSD(ha->exchoffld_buf_dma)); |
| 1004 | mcp->mb[8] = MSW(ha->exchoffld_size); |
| 1005 | mcp->mb[9] = LSW(ha->exchoffld_size); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 1006 | mcp->out_mb = MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 1007 | mcp->in_mb = MBX_11|MBX_0; |
| 1008 | mcp->tov = MBX_TOV_SECONDS; |
| 1009 | mcp->flags = 0; |
| 1010 | rval = qla2x00_mailbox_command(vha, mcp); |
| 1011 | if (rval != QLA_SUCCESS) { |
| 1012 | /*EMPTY*/ |
| 1013 | ql_dbg(ql_dbg_mbx, vha, 0x1158, "Failed=%x.\n", rval); |
| 1014 | } else { |
| 1015 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1192, |
| 1016 | "Done %s.\n", __func__); |
| 1017 | } |
| 1018 | |
| 1019 | return rval; |
| 1020 | } |
| 1021 | |
| 1022 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1023 | * qla2x00_get_fw_version |
| 1024 | * Get firmware version. |
| 1025 | * |
| 1026 | * Input: |
| 1027 | * ha: adapter state pointer. |
| 1028 | * major: pointer for major number. |
| 1029 | * minor: pointer for minor number. |
| 1030 | * subminor: pointer for subminor number. |
| 1031 | * |
| 1032 | * Returns: |
| 1033 | * qla2x00 local function return status code. |
| 1034 | * |
| 1035 | * Context: |
| 1036 | * Kernel context. |
| 1037 | */ |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 1038 | int |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1039 | qla2x00_get_fw_version(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1040 | { |
| 1041 | int rval; |
| 1042 | mbx_cmd_t mc; |
| 1043 | mbx_cmd_t *mcp = &mc; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1044 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1045 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1046 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1029, |
| 1047 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1048 | |
| 1049 | mcp->mb[0] = MBC_GET_FIRMWARE_VERSION; |
| 1050 | mcp->out_mb = MBX_0; |
| 1051 | 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] | 1052 | if (IS_QLA81XX(vha->hw) || IS_QLA8031(ha) || IS_QLA8044(ha)) |
Andrew Vasquez | 55a9615 | 2009-03-24 09:08:03 -0700 | [diff] [blame] | 1053 | 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] | 1054 | if (IS_FWI2_CAPABLE(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1055 | mcp->in_mb |= MBX_17|MBX_16|MBX_15; |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 1056 | if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) |
Joe Carnuccio | ad1ef17 | 2016-07-06 11:14:18 -0400 | [diff] [blame] | 1057 | mcp->in_mb |= |
| 1058 | MBX_25|MBX_24|MBX_23|MBX_22|MBX_21|MBX_20|MBX_19|MBX_18| |
Joe Carnuccio | 2a3192a | 2019-03-12 11:08:14 -0700 | [diff] [blame] | 1059 | MBX_14|MBX_13|MBX_11|MBX_10|MBX_9|MBX_8|MBX_7; |
Sawan Chandak | 03aa868 | 2015-08-04 13:37:59 -0400 | [diff] [blame] | 1060 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1061 | mcp->flags = 0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1062 | mcp->tov = MBX_TOV_SECONDS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1063 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 1064 | if (rval != QLA_SUCCESS) |
| 1065 | goto failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1066 | |
| 1067 | /* Return mailbox data. */ |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1068 | ha->fw_major_version = mcp->mb[1]; |
| 1069 | ha->fw_minor_version = mcp->mb[2]; |
| 1070 | ha->fw_subminor_version = mcp->mb[3]; |
| 1071 | ha->fw_attributes = mcp->mb[6]; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1072 | if (IS_QLA2100(vha->hw) || IS_QLA2200(vha->hw)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1073 | ha->fw_memory_size = 0x1FFFF; /* Defaults to 128KB. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1074 | else |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1075 | ha->fw_memory_size = (mcp->mb[5] << 16) | mcp->mb[4]; |
Sawan Chandak | 03aa868 | 2015-08-04 13:37:59 -0400 | [diff] [blame] | 1076 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1077 | if (IS_QLA81XX(vha->hw) || IS_QLA8031(vha->hw) || IS_QLA8044(ha)) { |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1078 | ha->mpi_version[0] = mcp->mb[10] & 0xff; |
| 1079 | ha->mpi_version[1] = mcp->mb[11] >> 8; |
| 1080 | ha->mpi_version[2] = mcp->mb[11] & 0xff; |
| 1081 | ha->mpi_capabilities = (mcp->mb[12] << 16) | mcp->mb[13]; |
| 1082 | ha->phy_version[0] = mcp->mb[8] & 0xff; |
| 1083 | ha->phy_version[1] = mcp->mb[9] >> 8; |
| 1084 | ha->phy_version[2] = mcp->mb[9] & 0xff; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1085 | } |
Sawan Chandak | 03aa868 | 2015-08-04 13:37:59 -0400 | [diff] [blame] | 1086 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 1087 | if (IS_FWI2_CAPABLE(ha)) { |
| 1088 | ha->fw_attributes_h = mcp->mb[15]; |
| 1089 | ha->fw_attributes_ext[0] = mcp->mb[16]; |
| 1090 | ha->fw_attributes_ext[1] = mcp->mb[17]; |
| 1091 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1139, |
| 1092 | "%s: FW_attributes Upper: 0x%x, Lower: 0x%x.\n", |
| 1093 | __func__, mcp->mb[15], mcp->mb[6]); |
| 1094 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x112f, |
| 1095 | "%s: Ext_FwAttributes Upper: 0x%x, Lower: 0x%x.\n", |
| 1096 | __func__, mcp->mb[17], mcp->mb[16]); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 1097 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 1098 | if (ha->fw_attributes_h & 0x4) |
| 1099 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x118d, |
| 1100 | "%s: Firmware supports Extended Login 0x%x\n", |
| 1101 | __func__, ha->fw_attributes_h); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 1102 | |
| 1103 | if (ha->fw_attributes_h & 0x8) |
| 1104 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1191, |
| 1105 | "%s: Firmware supports Exchange Offload 0x%x\n", |
| 1106 | __func__, ha->fw_attributes_h); |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 1107 | |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 1108 | /* |
| 1109 | * FW supports nvme and driver load parameter requested nvme. |
| 1110 | * BIT 26 of fw_attributes indicates NVMe support. |
| 1111 | */ |
Giridhar Malavali | 171e490 | 2019-01-30 09:50:44 -0800 | [diff] [blame] | 1112 | if ((ha->fw_attributes_h & |
| 1113 | (FW_ATTR_H_NVME | FW_ATTR_H_NVME_UPDATED)) && |
| 1114 | ql2xnvmeenable) { |
Darren Trapp | 03aaa89 | 2019-02-15 14:37:13 -0800 | [diff] [blame] | 1115 | if (ha->fw_attributes_h & FW_ATTR_H_NVME_FBURST) |
| 1116 | vha->flags.nvme_first_burst = 1; |
| 1117 | |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 1118 | vha->flags.nvme_enabled = 1; |
Darren Trapp | 1cbc0ef | 2018-03-20 23:09:37 -0700 | [diff] [blame] | 1119 | ql_log(ql_log_info, vha, 0xd302, |
| 1120 | "%s: FC-NVMe is Enabled (0x%x)\n", |
| 1121 | __func__, ha->fw_attributes_h); |
| 1122 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1123 | } |
Sawan Chandak | 03aa868 | 2015-08-04 13:37:59 -0400 | [diff] [blame] | 1124 | |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 1125 | if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) { |
Joe Carnuccio | 2a3192a | 2019-03-12 11:08:14 -0700 | [diff] [blame] | 1126 | ha->serdes_version[0] = mcp->mb[7] & 0xff; |
| 1127 | ha->serdes_version[1] = mcp->mb[8] >> 8; |
| 1128 | ha->serdes_version[2] = mcp->mb[8] & 0xff; |
Sawan Chandak | 03aa868 | 2015-08-04 13:37:59 -0400 | [diff] [blame] | 1129 | ha->mpi_version[0] = mcp->mb[10] & 0xff; |
| 1130 | ha->mpi_version[1] = mcp->mb[11] >> 8; |
| 1131 | ha->mpi_version[2] = mcp->mb[11] & 0xff; |
| 1132 | ha->pep_version[0] = mcp->mb[13] & 0xff; |
| 1133 | ha->pep_version[1] = mcp->mb[14] >> 8; |
| 1134 | ha->pep_version[2] = mcp->mb[14] & 0xff; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 1135 | ha->fw_shared_ram_start = (mcp->mb[19] << 16) | mcp->mb[18]; |
| 1136 | ha->fw_shared_ram_end = (mcp->mb[21] << 16) | mcp->mb[20]; |
Joe Carnuccio | ad1ef17 | 2016-07-06 11:14:18 -0400 | [diff] [blame] | 1137 | ha->fw_ddr_ram_start = (mcp->mb[23] << 16) | mcp->mb[22]; |
| 1138 | ha->fw_ddr_ram_end = (mcp->mb[25] << 16) | mcp->mb[24]; |
Michael Hernandez | 3f006ac | 2019-03-12 11:08:22 -0700 | [diff] [blame] | 1139 | if (IS_QLA28XX(ha)) { |
| 1140 | if (mcp->mb[16] & BIT_10) { |
| 1141 | ql_log(ql_log_info, vha, 0xffff, |
| 1142 | "FW support secure flash updates\n"); |
| 1143 | ha->flags.secure_fw = 1; |
| 1144 | } |
| 1145 | } |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 1146 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1147 | |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 1148 | failed: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1149 | if (rval != QLA_SUCCESS) { |
| 1150 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1151 | ql_dbg(ql_dbg_mbx, vha, 0x102a, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1152 | } else { |
| 1153 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1154 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102b, |
| 1155 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1156 | } |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 1157 | return rval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1158 | } |
| 1159 | |
| 1160 | /* |
| 1161 | * qla2x00_get_fw_options |
| 1162 | * Set firmware options. |
| 1163 | * |
| 1164 | * Input: |
| 1165 | * ha = adapter block pointer. |
| 1166 | * fwopt = pointer for firmware options. |
| 1167 | * |
| 1168 | * Returns: |
| 1169 | * qla2x00 local function return status code. |
| 1170 | * |
| 1171 | * Context: |
| 1172 | * Kernel context. |
| 1173 | */ |
| 1174 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1175 | qla2x00_get_fw_options(scsi_qla_host_t *vha, uint16_t *fwopts) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1176 | { |
| 1177 | int rval; |
| 1178 | mbx_cmd_t mc; |
| 1179 | mbx_cmd_t *mcp = &mc; |
| 1180 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1181 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102c, |
| 1182 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1183 | |
| 1184 | mcp->mb[0] = MBC_GET_FIRMWARE_OPTION; |
| 1185 | mcp->out_mb = MBX_0; |
| 1186 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1187 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1188 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1189 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1190 | |
| 1191 | if (rval != QLA_SUCCESS) { |
| 1192 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1193 | ql_dbg(ql_dbg_mbx, vha, 0x102d, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1194 | } else { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1195 | fwopts[0] = mcp->mb[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1196 | fwopts[1] = mcp->mb[1]; |
| 1197 | fwopts[2] = mcp->mb[2]; |
| 1198 | fwopts[3] = mcp->mb[3]; |
| 1199 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1200 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102e, |
| 1201 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1202 | } |
| 1203 | |
| 1204 | return rval; |
| 1205 | } |
| 1206 | |
| 1207 | |
| 1208 | /* |
| 1209 | * qla2x00_set_fw_options |
| 1210 | * Set firmware options. |
| 1211 | * |
| 1212 | * Input: |
| 1213 | * ha = adapter block pointer. |
| 1214 | * fwopt = pointer for firmware options. |
| 1215 | * |
| 1216 | * Returns: |
| 1217 | * qla2x00 local function return status code. |
| 1218 | * |
| 1219 | * Context: |
| 1220 | * Kernel context. |
| 1221 | */ |
| 1222 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1223 | qla2x00_set_fw_options(scsi_qla_host_t *vha, uint16_t *fwopts) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1224 | { |
| 1225 | int rval; |
| 1226 | mbx_cmd_t mc; |
| 1227 | mbx_cmd_t *mcp = &mc; |
| 1228 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1229 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102f, |
| 1230 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1231 | |
| 1232 | mcp->mb[0] = MBC_SET_FIRMWARE_OPTION; |
| 1233 | mcp->mb[1] = fwopts[1]; |
| 1234 | mcp->mb[2] = fwopts[2]; |
| 1235 | mcp->mb[3] = fwopts[3]; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1236 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1237 | mcp->in_mb = MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1238 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1239 | mcp->in_mb |= MBX_1; |
Quinn Tran | 2da5273 | 2017-06-02 09:12:05 -0700 | [diff] [blame] | 1240 | mcp->mb[10] = fwopts[10]; |
| 1241 | mcp->out_mb |= MBX_10; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1242 | } else { |
| 1243 | mcp->mb[10] = fwopts[10]; |
| 1244 | mcp->mb[11] = fwopts[11]; |
| 1245 | mcp->mb[12] = 0; /* Undocumented, but used */ |
| 1246 | mcp->out_mb |= MBX_12|MBX_11|MBX_10; |
| 1247 | } |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1248 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1249 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1250 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1251 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1252 | fwopts[0] = mcp->mb[0]; |
| 1253 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1254 | if (rval != QLA_SUCCESS) { |
| 1255 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1256 | ql_dbg(ql_dbg_mbx, vha, 0x1030, |
| 1257 | "Failed=%x (%x/%x).\n", rval, mcp->mb[0], mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1258 | } else { |
| 1259 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1260 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1031, |
| 1261 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1262 | } |
| 1263 | |
| 1264 | return rval; |
| 1265 | } |
| 1266 | |
| 1267 | /* |
| 1268 | * qla2x00_mbx_reg_test |
| 1269 | * Mailbox register wrap test. |
| 1270 | * |
| 1271 | * Input: |
| 1272 | * ha = adapter block pointer. |
| 1273 | * TARGET_QUEUE_LOCK must be released. |
| 1274 | * ADAPTER_STATE_LOCK must be released. |
| 1275 | * |
| 1276 | * Returns: |
| 1277 | * qla2x00 local function return status code. |
| 1278 | * |
| 1279 | * Context: |
| 1280 | * Kernel context. |
| 1281 | */ |
| 1282 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1283 | qla2x00_mbx_reg_test(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1284 | { |
| 1285 | int rval; |
| 1286 | mbx_cmd_t mc; |
| 1287 | mbx_cmd_t *mcp = &mc; |
| 1288 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1289 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1032, |
| 1290 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1291 | |
| 1292 | mcp->mb[0] = MBC_MAILBOX_REGISTER_TEST; |
| 1293 | mcp->mb[1] = 0xAAAA; |
| 1294 | mcp->mb[2] = 0x5555; |
| 1295 | mcp->mb[3] = 0xAA55; |
| 1296 | mcp->mb[4] = 0x55AA; |
| 1297 | mcp->mb[5] = 0xA5A5; |
| 1298 | mcp->mb[6] = 0x5A5A; |
| 1299 | mcp->mb[7] = 0x2525; |
| 1300 | mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 1301 | 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] | 1302 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1303 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1304 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1305 | |
| 1306 | if (rval == QLA_SUCCESS) { |
| 1307 | if (mcp->mb[1] != 0xAAAA || mcp->mb[2] != 0x5555 || |
| 1308 | mcp->mb[3] != 0xAA55 || mcp->mb[4] != 0x55AA) |
| 1309 | rval = QLA_FUNCTION_FAILED; |
| 1310 | if (mcp->mb[5] != 0xA5A5 || mcp->mb[6] != 0x5A5A || |
| 1311 | mcp->mb[7] != 0x2525) |
| 1312 | rval = QLA_FUNCTION_FAILED; |
| 1313 | } |
| 1314 | |
| 1315 | if (rval != QLA_SUCCESS) { |
| 1316 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1317 | ql_dbg(ql_dbg_mbx, vha, 0x1033, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1318 | } else { |
| 1319 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1320 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1034, |
| 1321 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1322 | } |
| 1323 | |
| 1324 | return rval; |
| 1325 | } |
| 1326 | |
| 1327 | /* |
| 1328 | * qla2x00_verify_checksum |
| 1329 | * Verify firmware checksum. |
| 1330 | * |
| 1331 | * Input: |
| 1332 | * ha = adapter block pointer. |
| 1333 | * TARGET_QUEUE_LOCK must be released. |
| 1334 | * ADAPTER_STATE_LOCK must be released. |
| 1335 | * |
| 1336 | * Returns: |
| 1337 | * qla2x00 local function return status code. |
| 1338 | * |
| 1339 | * Context: |
| 1340 | * Kernel context. |
| 1341 | */ |
| 1342 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1343 | qla2x00_verify_checksum(scsi_qla_host_t *vha, uint32_t risc_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1344 | { |
| 1345 | int rval; |
| 1346 | mbx_cmd_t mc; |
| 1347 | mbx_cmd_t *mcp = &mc; |
| 1348 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1349 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1035, |
| 1350 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1351 | |
| 1352 | mcp->mb[0] = MBC_VERIFY_CHECKSUM; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1353 | mcp->out_mb = MBX_0; |
| 1354 | mcp->in_mb = MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1355 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1356 | mcp->mb[1] = MSW(risc_addr); |
| 1357 | mcp->mb[2] = LSW(risc_addr); |
| 1358 | mcp->out_mb |= MBX_2|MBX_1; |
| 1359 | mcp->in_mb |= MBX_2|MBX_1; |
| 1360 | } else { |
| 1361 | mcp->mb[1] = LSW(risc_addr); |
| 1362 | mcp->out_mb |= MBX_1; |
| 1363 | mcp->in_mb |= MBX_1; |
| 1364 | } |
| 1365 | |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1366 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1367 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1368 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1369 | |
| 1370 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1371 | ql_dbg(ql_dbg_mbx, vha, 0x1036, |
| 1372 | "Failed=%x chm sum=%x.\n", rval, IS_FWI2_CAPABLE(vha->hw) ? |
| 1373 | (mcp->mb[2] << 16) | mcp->mb[1] : mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1374 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1375 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1037, |
| 1376 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1377 | } |
| 1378 | |
| 1379 | return rval; |
| 1380 | } |
| 1381 | |
| 1382 | /* |
| 1383 | * qla2x00_issue_iocb |
| 1384 | * Issue IOCB using mailbox command |
| 1385 | * |
| 1386 | * Input: |
| 1387 | * ha = adapter state pointer. |
| 1388 | * buffer = buffer pointer. |
| 1389 | * phys_addr = physical address of buffer. |
| 1390 | * size = size of buffer. |
| 1391 | * TARGET_QUEUE_LOCK must be released. |
| 1392 | * ADAPTER_STATE_LOCK must be released. |
| 1393 | * |
| 1394 | * Returns: |
| 1395 | * qla2x00 local function return status code. |
| 1396 | * |
| 1397 | * Context: |
| 1398 | * Kernel context. |
| 1399 | */ |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 1400 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1401 | qla2x00_issue_iocb_timeout(scsi_qla_host_t *vha, void *buffer, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1402 | dma_addr_t phys_addr, size_t size, uint32_t tov) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1403 | { |
| 1404 | int rval; |
| 1405 | mbx_cmd_t mc; |
| 1406 | mbx_cmd_t *mcp = &mc; |
| 1407 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1408 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1038, |
| 1409 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1410 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1411 | mcp->mb[0] = MBC_IOCB_COMMAND_A64; |
| 1412 | mcp->mb[1] = 0; |
| 1413 | mcp->mb[2] = MSW(phys_addr); |
| 1414 | mcp->mb[3] = LSW(phys_addr); |
| 1415 | mcp->mb[6] = MSW(MSD(phys_addr)); |
| 1416 | mcp->mb[7] = LSW(MSD(phys_addr)); |
| 1417 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 1418 | mcp->in_mb = MBX_2|MBX_0; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1419 | mcp->tov = tov; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1420 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1421 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1422 | |
| 1423 | if (rval != QLA_SUCCESS) { |
| 1424 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1425 | ql_dbg(ql_dbg_mbx, vha, 0x1039, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1426 | } else { |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 1427 | sts_entry_t *sts_entry = (sts_entry_t *) buffer; |
| 1428 | |
| 1429 | /* Mask reserved bits. */ |
| 1430 | sts_entry->entry_status &= |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1431 | IS_FWI2_CAPABLE(vha->hw) ? RF_MASK_24XX : RF_MASK; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1432 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103a, |
| 1433 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1434 | } |
| 1435 | |
| 1436 | return rval; |
| 1437 | } |
| 1438 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1439 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1440 | 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] | 1441 | size_t size) |
| 1442 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1443 | return qla2x00_issue_iocb_timeout(vha, buffer, phys_addr, size, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1444 | MBX_TOV_SECONDS); |
| 1445 | } |
| 1446 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1447 | /* |
| 1448 | * qla2x00_abort_command |
| 1449 | * Abort command aborts a specified IOCB. |
| 1450 | * |
| 1451 | * Input: |
| 1452 | * ha = adapter block pointer. |
| 1453 | * sp = SB structure pointer. |
| 1454 | * |
| 1455 | * Returns: |
| 1456 | * qla2x00 local function return status code. |
| 1457 | * |
| 1458 | * Context: |
| 1459 | * Kernel context. |
| 1460 | */ |
| 1461 | int |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1462 | qla2x00_abort_command(srb_t *sp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1463 | { |
| 1464 | unsigned long flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1465 | int rval; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1466 | uint32_t handle = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1467 | mbx_cmd_t mc; |
| 1468 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1469 | fc_port_t *fcport = sp->fcport; |
| 1470 | scsi_qla_host_t *vha = fcport->vha; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1471 | struct qla_hw_data *ha = vha->hw; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1472 | struct req_que *req; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1473 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1474 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1475 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103b, |
| 1476 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1477 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1478 | if (vha->flags.qpairs_available && sp->qpair) |
| 1479 | req = sp->qpair->req; |
| 1480 | else |
| 1481 | req = vha->req; |
| 1482 | |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 1483 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1484 | for (handle = 1; handle < req->num_outstanding_cmds; handle++) { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1485 | if (req->outstanding_cmds[handle] == sp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1486 | break; |
| 1487 | } |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 1488 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1489 | |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1490 | if (handle == req->num_outstanding_cmds) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1491 | /* command not found */ |
| 1492 | return QLA_FUNCTION_FAILED; |
| 1493 | } |
| 1494 | |
| 1495 | mcp->mb[0] = MBC_ABORT_COMMAND; |
| 1496 | if (HAS_EXTENDED_IDS(ha)) |
| 1497 | mcp->mb[1] = fcport->loop_id; |
| 1498 | else |
| 1499 | mcp->mb[1] = fcport->loop_id << 8; |
| 1500 | mcp->mb[2] = (uint16_t)handle; |
| 1501 | mcp->mb[3] = (uint16_t)(handle >> 16); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1502 | mcp->mb[6] = (uint16_t)cmd->device->lun; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1503 | mcp->out_mb = MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 1504 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1505 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1506 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1507 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1508 | |
| 1509 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1510 | ql_dbg(ql_dbg_mbx, vha, 0x103c, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1511 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1512 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103d, |
| 1513 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1514 | } |
| 1515 | |
| 1516 | return rval; |
| 1517 | } |
| 1518 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1519 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1520 | qla2x00_abort_target(struct fc_port *fcport, uint64_t l, int tag) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1521 | { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1522 | int rval, rval2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1523 | mbx_cmd_t mc; |
| 1524 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1525 | scsi_qla_host_t *vha; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1526 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1527 | vha = fcport->vha; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1528 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1529 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103e, |
| 1530 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1531 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1532 | mcp->mb[0] = MBC_ABORT_TARGET; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1533 | mcp->out_mb = MBX_9|MBX_2|MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1534 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1535 | mcp->mb[1] = fcport->loop_id; |
| 1536 | mcp->mb[10] = 0; |
| 1537 | mcp->out_mb |= MBX_10; |
| 1538 | } else { |
| 1539 | mcp->mb[1] = fcport->loop_id << 8; |
| 1540 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1541 | mcp->mb[2] = vha->hw->loop_reset_delay; |
| 1542 | mcp->mb[9] = vha->vp_idx; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1543 | |
| 1544 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1545 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1546 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1547 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1548 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1549 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103f, |
| 1550 | "Failed=%x.\n", rval); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1551 | } |
| 1552 | |
| 1553 | /* Issue marker IOCB. */ |
Quinn Tran | 9eb9c6d | 2019-02-15 14:37:19 -0800 | [diff] [blame] | 1554 | rval2 = qla2x00_marker(vha, vha->hw->base_qpair, fcport->loop_id, 0, |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1555 | MK_SYNC_ID); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1556 | if (rval2 != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1557 | ql_dbg(ql_dbg_mbx, vha, 0x1040, |
| 1558 | "Failed to issue marker IOCB (%x).\n", rval2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1559 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1560 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1041, |
| 1561 | "Done %s.\n", __func__); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1562 | } |
| 1563 | |
| 1564 | return rval; |
| 1565 | } |
| 1566 | |
| 1567 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1568 | qla2x00_lun_reset(struct fc_port *fcport, uint64_t l, int tag) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1569 | { |
| 1570 | int rval, rval2; |
| 1571 | mbx_cmd_t mc; |
| 1572 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1573 | scsi_qla_host_t *vha; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1574 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1575 | vha = fcport->vha; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1576 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1577 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1042, |
| 1578 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1579 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1580 | mcp->mb[0] = MBC_LUN_RESET; |
| 1581 | 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] | 1582 | if (HAS_EXTENDED_IDS(vha->hw)) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1583 | mcp->mb[1] = fcport->loop_id; |
| 1584 | else |
| 1585 | mcp->mb[1] = fcport->loop_id << 8; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1586 | mcp->mb[2] = (u32)l; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1587 | mcp->mb[3] = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1588 | mcp->mb[9] = vha->vp_idx; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1589 | |
| 1590 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1591 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1592 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1593 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1594 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1595 | ql_dbg(ql_dbg_mbx, vha, 0x1043, "Failed=%x.\n", rval); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1596 | } |
| 1597 | |
| 1598 | /* Issue marker IOCB. */ |
Quinn Tran | 9eb9c6d | 2019-02-15 14:37:19 -0800 | [diff] [blame] | 1599 | rval2 = qla2x00_marker(vha, vha->hw->base_qpair, fcport->loop_id, l, |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1600 | MK_SYNC_ID_LUN); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1601 | if (rval2 != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1602 | ql_dbg(ql_dbg_mbx, vha, 0x1044, |
| 1603 | "Failed to issue marker IOCB (%x).\n", rval2); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1604 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1605 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1045, |
| 1606 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1607 | } |
| 1608 | |
| 1609 | return rval; |
| 1610 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1611 | |
| 1612 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1613 | * qla2x00_get_adapter_id |
| 1614 | * Get adapter ID and topology. |
| 1615 | * |
| 1616 | * Input: |
| 1617 | * ha = adapter block pointer. |
| 1618 | * id = pointer for loop ID. |
| 1619 | * al_pa = pointer for AL_PA. |
| 1620 | * area = pointer for area. |
| 1621 | * domain = pointer for domain. |
| 1622 | * top = pointer for topology. |
| 1623 | * TARGET_QUEUE_LOCK must be released. |
| 1624 | * ADAPTER_STATE_LOCK must be released. |
| 1625 | * |
| 1626 | * Returns: |
| 1627 | * qla2x00 local function return status code. |
| 1628 | * |
| 1629 | * Context: |
| 1630 | * Kernel context. |
| 1631 | */ |
| 1632 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1633 | 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] | 1634 | 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] | 1635 | { |
| 1636 | int rval; |
| 1637 | mbx_cmd_t mc; |
| 1638 | mbx_cmd_t *mcp = &mc; |
| 1639 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1640 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1046, |
| 1641 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1642 | |
| 1643 | mcp->mb[0] = MBC_GET_ADAPTER_LOOP_ID; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1644 | mcp->mb[9] = vha->vp_idx; |
Andrew Vasquez | eb66dc6 | 2007-11-12 10:30:58 -0800 | [diff] [blame] | 1645 | mcp->out_mb = MBX_9|MBX_0; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1646 | 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] | 1647 | if (IS_CNA_CAPABLE(vha->hw)) |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1648 | mcp->in_mb |= MBX_13|MBX_12|MBX_11|MBX_10; |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 1649 | if (IS_FWI2_CAPABLE(vha->hw)) |
| 1650 | mcp->in_mb |= MBX_19|MBX_18|MBX_17|MBX_16; |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 1651 | if (IS_QLA27XX(vha->hw) || IS_QLA28XX(vha->hw)) |
Sawan Chandak | 969a619 | 2016-01-27 12:03:32 -0500 | [diff] [blame] | 1652 | mcp->in_mb |= MBX_15; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1653 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1654 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1655 | rval = qla2x00_mailbox_command(vha, mcp); |
Ravi Anand | 33135aa | 2005-11-08 14:37:20 -0800 | [diff] [blame] | 1656 | if (mcp->mb[0] == MBS_COMMAND_ERROR) |
| 1657 | rval = QLA_COMMAND_ERROR; |
Andrew Vasquez | 42e421b | 2008-07-10 16:56:01 -0700 | [diff] [blame] | 1658 | else if (mcp->mb[0] == MBS_INVALID_COMMAND) |
| 1659 | rval = QLA_INVALID_COMMAND; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1660 | |
| 1661 | /* Return data. */ |
| 1662 | *id = mcp->mb[1]; |
| 1663 | *al_pa = LSB(mcp->mb[2]); |
| 1664 | *area = MSB(mcp->mb[2]); |
| 1665 | *domain = LSB(mcp->mb[3]); |
| 1666 | *top = mcp->mb[6]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1667 | *sw_cap = mcp->mb[7]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1668 | |
| 1669 | if (rval != QLA_SUCCESS) { |
| 1670 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1671 | ql_dbg(ql_dbg_mbx, vha, 0x1047, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1672 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1673 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1048, |
| 1674 | "Done %s.\n", __func__); |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1675 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1676 | if (IS_CNA_CAPABLE(vha->hw)) { |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1677 | vha->fcoe_vlan_id = mcp->mb[9] & 0xfff; |
| 1678 | vha->fcoe_fcf_idx = mcp->mb[10]; |
| 1679 | vha->fcoe_vn_port_mac[5] = mcp->mb[11] >> 8; |
| 1680 | vha->fcoe_vn_port_mac[4] = mcp->mb[11] & 0xff; |
| 1681 | vha->fcoe_vn_port_mac[3] = mcp->mb[12] >> 8; |
| 1682 | vha->fcoe_vn_port_mac[2] = mcp->mb[12] & 0xff; |
| 1683 | vha->fcoe_vn_port_mac[1] = mcp->mb[13] >> 8; |
| 1684 | vha->fcoe_vn_port_mac[0] = mcp->mb[13] & 0xff; |
| 1685 | } |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 1686 | /* If FA-WWN supported */ |
Saurav Kashyap | d6b9b42 | 2015-08-04 13:37:55 -0400 | [diff] [blame] | 1687 | if (IS_FAWWN_CAPABLE(vha->hw)) { |
| 1688 | if (mcp->mb[7] & BIT_14) { |
| 1689 | vha->port_name[0] = MSB(mcp->mb[16]); |
| 1690 | vha->port_name[1] = LSB(mcp->mb[16]); |
| 1691 | vha->port_name[2] = MSB(mcp->mb[17]); |
| 1692 | vha->port_name[3] = LSB(mcp->mb[17]); |
| 1693 | vha->port_name[4] = MSB(mcp->mb[18]); |
| 1694 | vha->port_name[5] = LSB(mcp->mb[18]); |
| 1695 | vha->port_name[6] = MSB(mcp->mb[19]); |
| 1696 | vha->port_name[7] = LSB(mcp->mb[19]); |
| 1697 | fc_host_port_name(vha->host) = |
| 1698 | wwn_to_u64(vha->port_name); |
| 1699 | ql_dbg(ql_dbg_mbx, vha, 0x10ca, |
| 1700 | "FA-WWN acquired %016llx\n", |
| 1701 | wwn_to_u64(vha->port_name)); |
| 1702 | } |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 1703 | } |
Sawan Chandak | 969a619 | 2016-01-27 12:03:32 -0500 | [diff] [blame] | 1704 | |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 1705 | if (IS_QLA27XX(vha->hw) || IS_QLA28XX(vha->hw)) |
Sawan Chandak | 969a619 | 2016-01-27 12:03:32 -0500 | [diff] [blame] | 1706 | vha->bbcr = mcp->mb[15]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1707 | } |
| 1708 | |
| 1709 | return rval; |
| 1710 | } |
| 1711 | |
| 1712 | /* |
| 1713 | * qla2x00_get_retry_cnt |
| 1714 | * Get current firmware login retry count and delay. |
| 1715 | * |
| 1716 | * Input: |
| 1717 | * ha = adapter block pointer. |
| 1718 | * retry_cnt = pointer to login retry count. |
| 1719 | * tov = pointer to login timeout value. |
| 1720 | * |
| 1721 | * Returns: |
| 1722 | * qla2x00 local function return status code. |
| 1723 | * |
| 1724 | * Context: |
| 1725 | * Kernel context. |
| 1726 | */ |
| 1727 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1728 | 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] | 1729 | uint16_t *r_a_tov) |
| 1730 | { |
| 1731 | int rval; |
| 1732 | uint16_t ratov; |
| 1733 | mbx_cmd_t mc; |
| 1734 | mbx_cmd_t *mcp = &mc; |
| 1735 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1736 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1049, |
| 1737 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1738 | |
| 1739 | mcp->mb[0] = MBC_GET_RETRY_COUNT; |
| 1740 | mcp->out_mb = MBX_0; |
| 1741 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1742 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1743 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1744 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1745 | |
| 1746 | if (rval != QLA_SUCCESS) { |
| 1747 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1748 | ql_dbg(ql_dbg_mbx, vha, 0x104a, |
| 1749 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1750 | } else { |
| 1751 | /* Convert returned data and check our values. */ |
| 1752 | *r_a_tov = mcp->mb[3] / 2; |
| 1753 | ratov = (mcp->mb[3]/2) / 10; /* mb[3] value is in 100ms */ |
| 1754 | if (mcp->mb[1] * ratov > (*retry_cnt) * (*tov)) { |
| 1755 | /* Update to the larger values */ |
| 1756 | *retry_cnt = (uint8_t)mcp->mb[1]; |
| 1757 | *tov = ratov; |
| 1758 | } |
| 1759 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1760 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104b, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1761 | "Done %s mb3=%d ratov=%d.\n", __func__, mcp->mb[3], ratov); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1762 | } |
| 1763 | |
| 1764 | return rval; |
| 1765 | } |
| 1766 | |
| 1767 | /* |
| 1768 | * qla2x00_init_firmware |
| 1769 | * Initialize adapter firmware. |
| 1770 | * |
| 1771 | * Input: |
| 1772 | * ha = adapter block pointer. |
| 1773 | * dptr = Initialization control block pointer. |
| 1774 | * size = size of initialization control block. |
| 1775 | * TARGET_QUEUE_LOCK must be released. |
| 1776 | * ADAPTER_STATE_LOCK must be released. |
| 1777 | * |
| 1778 | * Returns: |
| 1779 | * qla2x00 local function return status code. |
| 1780 | * |
| 1781 | * Context: |
| 1782 | * Kernel context. |
| 1783 | */ |
| 1784 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1785 | qla2x00_init_firmware(scsi_qla_host_t *vha, uint16_t size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1786 | { |
| 1787 | int rval; |
| 1788 | mbx_cmd_t mc; |
| 1789 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1790 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1791 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1792 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104c, |
| 1793 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1794 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1795 | if (IS_P3P_TYPE(ha) && ql2xdbwr) |
Bart Van Assche | 8dfa4b5a | 2015-07-09 07:24:50 -0700 | [diff] [blame] | 1796 | qla82xx_wr_32(ha, (uintptr_t __force)ha->nxdb_wr_ptr, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1797 | (0x04 | (ha->portnum << 5) | (0 << 8) | (0 << 16))); |
| 1798 | |
Andrew Vasquez | e6e074f | 2008-01-31 12:33:53 -0800 | [diff] [blame] | 1799 | if (ha->flags.npiv_supported) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1800 | mcp->mb[0] = MBC_MID_INITIALIZE_FIRMWARE; |
| 1801 | else |
| 1802 | mcp->mb[0] = MBC_INITIALIZE_FIRMWARE; |
| 1803 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 1804 | mcp->mb[1] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1805 | mcp->mb[2] = MSW(ha->init_cb_dma); |
| 1806 | mcp->mb[3] = LSW(ha->init_cb_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1807 | mcp->mb[6] = MSW(MSD(ha->init_cb_dma)); |
| 1808 | mcp->mb[7] = LSW(MSD(ha->init_cb_dma)); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 1809 | 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] | 1810 | if (ha->ex_init_cb && ha->ex_init_cb->ex_version) { |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 1811 | mcp->mb[1] = BIT_0; |
| 1812 | mcp->mb[10] = MSW(ha->ex_init_cb_dma); |
| 1813 | mcp->mb[11] = LSW(ha->ex_init_cb_dma); |
| 1814 | mcp->mb[12] = MSW(MSD(ha->ex_init_cb_dma)); |
| 1815 | mcp->mb[13] = LSW(MSD(ha->ex_init_cb_dma)); |
| 1816 | mcp->mb[14] = sizeof(*ha->ex_init_cb); |
| 1817 | mcp->out_mb |= MBX_14|MBX_13|MBX_12|MBX_11|MBX_10; |
| 1818 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1819 | /* 1 and 2 should normally be captured. */ |
| 1820 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 1821 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1822 | /* mb3 is additional info about the installed SFP. */ |
| 1823 | mcp->in_mb |= MBX_3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1824 | mcp->buf_size = size; |
| 1825 | mcp->flags = MBX_DMA_OUT; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1826 | mcp->tov = MBX_TOV_SECONDS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1827 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1828 | |
| 1829 | if (rval != QLA_SUCCESS) { |
| 1830 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1831 | ql_dbg(ql_dbg_mbx, vha, 0x104d, |
Joe Carnuccio | f8f97b0 | 2019-03-12 11:08:16 -0700 | [diff] [blame] | 1832 | "Failed=%x mb[0]=%x, mb[1]=%x, mb[2]=%x, mb[3]=%x.\n", |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1833 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2], mcp->mb[3]); |
Joe Carnuccio | f8f97b0 | 2019-03-12 11:08:16 -0700 | [diff] [blame] | 1834 | if (ha->init_cb) { |
| 1835 | ql_dbg(ql_dbg_mbx, vha, 0x104d, "init_cb:\n"); |
| 1836 | ql_dump_buffer(ql_dbg_init + ql_dbg_verbose, vha, |
| 1837 | 0x0104d, ha->init_cb, sizeof(*ha->init_cb)); |
| 1838 | } |
| 1839 | if (ha->ex_init_cb && ha->ex_init_cb->ex_version) { |
| 1840 | ql_dbg(ql_dbg_mbx, vha, 0x104d, "ex_init_cb:\n"); |
| 1841 | ql_dump_buffer(ql_dbg_init + ql_dbg_verbose, vha, |
| 1842 | 0x0104d, ha->ex_init_cb, sizeof(*ha->ex_init_cb)); |
| 1843 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1844 | } else { |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 1845 | if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) { |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 1846 | if (mcp->mb[2] == 6 || mcp->mb[3] == 2) |
| 1847 | ql_dbg(ql_dbg_mbx, vha, 0x119d, |
| 1848 | "Invalid SFP/Validation Failed\n"); |
| 1849 | } |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1850 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104e, |
| 1851 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1852 | } |
| 1853 | |
| 1854 | return rval; |
| 1855 | } |
| 1856 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 1857 | |
| 1858 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1859 | * qla2x00_get_port_database |
| 1860 | * Issue normal/enhanced get port database mailbox command |
| 1861 | * and copy device name as necessary. |
| 1862 | * |
| 1863 | * Input: |
| 1864 | * ha = adapter state pointer. |
| 1865 | * dev = structure pointer. |
| 1866 | * opt = enhanced cmd option byte. |
| 1867 | * |
| 1868 | * Returns: |
| 1869 | * qla2x00 local function return status code. |
| 1870 | * |
| 1871 | * Context: |
| 1872 | * Kernel context. |
| 1873 | */ |
| 1874 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1875 | 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] | 1876 | { |
| 1877 | int rval; |
| 1878 | mbx_cmd_t mc; |
| 1879 | mbx_cmd_t *mcp = &mc; |
| 1880 | port_database_t *pd; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1881 | struct port_database_24xx *pd24; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1882 | dma_addr_t pd_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1883 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1884 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1885 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104f, |
| 1886 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1887 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1888 | pd24 = NULL; |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 1889 | pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1890 | if (pd == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1891 | ql_log(ql_log_warn, vha, 0x1050, |
| 1892 | "Failed to allocate port database structure.\n"); |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 1893 | fcport->query = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1894 | return QLA_MEMORY_ALLOC_FAILED; |
| 1895 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1896 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1897 | mcp->mb[0] = MBC_GET_PORT_DATABASE; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1898 | if (opt != 0 && !IS_FWI2_CAPABLE(ha)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1899 | mcp->mb[0] = MBC_ENHANCED_GET_PORT_DATABASE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1900 | mcp->mb[2] = MSW(pd_dma); |
| 1901 | mcp->mb[3] = LSW(pd_dma); |
| 1902 | mcp->mb[6] = MSW(MSD(pd_dma)); |
| 1903 | mcp->mb[7] = LSW(MSD(pd_dma)); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1904 | mcp->mb[9] = vha->vp_idx; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1905 | 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] | 1906 | mcp->in_mb = MBX_0; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1907 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1908 | mcp->mb[1] = fcport->loop_id; |
| 1909 | mcp->mb[10] = opt; |
| 1910 | mcp->out_mb |= MBX_10|MBX_1; |
| 1911 | mcp->in_mb |= MBX_1; |
| 1912 | } else if (HAS_EXTENDED_IDS(ha)) { |
| 1913 | mcp->mb[1] = fcport->loop_id; |
| 1914 | mcp->mb[10] = opt; |
| 1915 | mcp->out_mb |= MBX_10|MBX_1; |
| 1916 | } else { |
| 1917 | mcp->mb[1] = fcport->loop_id << 8 | opt; |
| 1918 | mcp->out_mb |= MBX_1; |
| 1919 | } |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1920 | mcp->buf_size = IS_FWI2_CAPABLE(ha) ? |
| 1921 | PORT_DATABASE_24XX_SIZE : PORT_DATABASE_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1922 | mcp->flags = MBX_DMA_IN; |
| 1923 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1924 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1925 | if (rval != QLA_SUCCESS) |
| 1926 | goto gpd_error_out; |
| 1927 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1928 | if (IS_FWI2_CAPABLE(ha)) { |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1929 | uint64_t zero = 0; |
Duane Grigsby | c0c462c | 2017-10-13 09:34:05 -0700 | [diff] [blame] | 1930 | u8 current_login_state, last_login_state; |
| 1931 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1932 | pd24 = (struct port_database_24xx *) pd; |
| 1933 | |
| 1934 | /* Check for logged in state. */ |
Michael Hernandez | 84ed362 | 2019-09-12 11:09:12 -0700 | [diff] [blame] | 1935 | if (NVME_TARGET(ha, fcport)) { |
Duane Grigsby | c0c462c | 2017-10-13 09:34:05 -0700 | [diff] [blame] | 1936 | current_login_state = pd24->current_login_state >> 4; |
| 1937 | last_login_state = pd24->last_login_state >> 4; |
| 1938 | } else { |
| 1939 | current_login_state = pd24->current_login_state & 0xf; |
| 1940 | last_login_state = pd24->last_login_state & 0xf; |
| 1941 | } |
| 1942 | fcport->current_login_state = pd24->current_login_state; |
| 1943 | fcport->last_login_state = pd24->last_login_state; |
| 1944 | |
| 1945 | /* Check for logged in state. */ |
| 1946 | if (current_login_state != PDS_PRLI_COMPLETE && |
| 1947 | last_login_state != PDS_PRLI_COMPLETE) { |
| 1948 | ql_dbg(ql_dbg_mbx, vha, 0x119a, |
| 1949 | "Unable to verify login-state (%x/%x) for loop_id %x.\n", |
| 1950 | current_login_state, last_login_state, |
| 1951 | fcport->loop_id); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1952 | rval = QLA_FUNCTION_FAILED; |
Duane Grigsby | c0c462c | 2017-10-13 09:34:05 -0700 | [diff] [blame] | 1953 | |
| 1954 | if (!fcport->query) |
| 1955 | goto gpd_error_out; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1956 | } |
| 1957 | |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1958 | if (fcport->loop_id == FC_NO_LOOP_ID || |
| 1959 | (memcmp(fcport->port_name, (uint8_t *)&zero, 8) && |
| 1960 | memcmp(fcport->port_name, pd24->port_name, 8))) { |
| 1961 | /* We lost the device mid way. */ |
| 1962 | rval = QLA_NOT_LOGGED_IN; |
| 1963 | goto gpd_error_out; |
| 1964 | } |
| 1965 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1966 | /* Names are little-endian. */ |
| 1967 | memcpy(fcport->node_name, pd24->node_name, WWN_SIZE); |
| 1968 | memcpy(fcport->port_name, pd24->port_name, WWN_SIZE); |
| 1969 | |
| 1970 | /* Get port_id of device. */ |
| 1971 | fcport->d_id.b.domain = pd24->port_id[0]; |
| 1972 | fcport->d_id.b.area = pd24->port_id[1]; |
| 1973 | fcport->d_id.b.al_pa = pd24->port_id[2]; |
| 1974 | fcport->d_id.b.rsvd_1 = 0; |
| 1975 | |
| 1976 | /* If not target must be initiator or unknown type. */ |
| 1977 | if ((pd24->prli_svc_param_word_3[0] & BIT_4) == 0) |
| 1978 | fcport->port_type = FCT_INITIATOR; |
| 1979 | else |
| 1980 | fcport->port_type = FCT_TARGET; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 1981 | |
| 1982 | /* Passback COS information. */ |
| 1983 | fcport->supported_classes = (pd24->flags & PDF_CLASS_2) ? |
| 1984 | FC_COS_CLASS2 : FC_COS_CLASS3; |
| 1985 | |
| 1986 | if (pd24->prli_svc_param_word_3[0] & BIT_7) |
| 1987 | fcport->flags |= FCF_CONF_COMP_SUPPORTED; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1988 | } else { |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1989 | uint64_t zero = 0; |
| 1990 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1991 | /* Check for logged in state. */ |
| 1992 | if (pd->master_state != PD_STATE_PORT_LOGGED_IN && |
| 1993 | pd->slave_state != PD_STATE_PORT_LOGGED_IN) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1994 | ql_dbg(ql_dbg_mbx, vha, 0x100a, |
| 1995 | "Unable to verify login-state (%x/%x) - " |
| 1996 | "portid=%02x%02x%02x.\n", pd->master_state, |
| 1997 | pd->slave_state, fcport->d_id.b.domain, |
| 1998 | fcport->d_id.b.area, fcport->d_id.b.al_pa); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1999 | rval = QLA_FUNCTION_FAILED; |
| 2000 | goto gpd_error_out; |
| 2001 | } |
| 2002 | |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 2003 | if (fcport->loop_id == FC_NO_LOOP_ID || |
| 2004 | (memcmp(fcport->port_name, (uint8_t *)&zero, 8) && |
| 2005 | memcmp(fcport->port_name, pd->port_name, 8))) { |
| 2006 | /* We lost the device mid way. */ |
| 2007 | rval = QLA_NOT_LOGGED_IN; |
| 2008 | goto gpd_error_out; |
| 2009 | } |
| 2010 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2011 | /* Names are little-endian. */ |
| 2012 | memcpy(fcport->node_name, pd->node_name, WWN_SIZE); |
| 2013 | memcpy(fcport->port_name, pd->port_name, WWN_SIZE); |
| 2014 | |
| 2015 | /* Get port_id of device. */ |
| 2016 | fcport->d_id.b.domain = pd->port_id[0]; |
| 2017 | fcport->d_id.b.area = pd->port_id[3]; |
| 2018 | fcport->d_id.b.al_pa = pd->port_id[2]; |
| 2019 | fcport->d_id.b.rsvd_1 = 0; |
| 2020 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2021 | /* If not target must be initiator or unknown type. */ |
| 2022 | if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0) |
| 2023 | fcport->port_type = FCT_INITIATOR; |
| 2024 | else |
| 2025 | fcport->port_type = FCT_TARGET; |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 2026 | |
| 2027 | /* Passback COS information. */ |
| 2028 | fcport->supported_classes = (pd->options & BIT_4) ? |
Bart Van Assche | 58e2753 | 2019-04-11 14:53:19 -0700 | [diff] [blame] | 2029 | FC_COS_CLASS2 : FC_COS_CLASS3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2030 | } |
| 2031 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2032 | gpd_error_out: |
| 2033 | dma_pool_free(ha->s_dma_pool, pd, pd_dma); |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 2034 | fcport->query = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2035 | |
| 2036 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2037 | ql_dbg(ql_dbg_mbx, vha, 0x1052, |
| 2038 | "Failed=%x mb[0]=%x mb[1]=%x.\n", rval, |
| 2039 | mcp->mb[0], mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2040 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2041 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1053, |
| 2042 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2043 | } |
| 2044 | |
| 2045 | return rval; |
| 2046 | } |
| 2047 | |
| 2048 | /* |
| 2049 | * qla2x00_get_firmware_state |
| 2050 | * Get adapter firmware state. |
| 2051 | * |
| 2052 | * Input: |
| 2053 | * ha = adapter block pointer. |
| 2054 | * dptr = pointer for firmware state. |
| 2055 | * TARGET_QUEUE_LOCK must be released. |
| 2056 | * ADAPTER_STATE_LOCK must be released. |
| 2057 | * |
| 2058 | * Returns: |
| 2059 | * qla2x00 local function return status code. |
| 2060 | * |
| 2061 | * Context: |
| 2062 | * Kernel context. |
| 2063 | */ |
| 2064 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2065 | qla2x00_get_firmware_state(scsi_qla_host_t *vha, uint16_t *states) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2066 | { |
| 2067 | int rval; |
| 2068 | mbx_cmd_t mc; |
| 2069 | mbx_cmd_t *mcp = &mc; |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 2070 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2071 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2072 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1054, |
| 2073 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2074 | |
| 2075 | mcp->mb[0] = MBC_GET_FIRMWARE_STATE; |
| 2076 | mcp->out_mb = MBX_0; |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 2077 | if (IS_FWI2_CAPABLE(vha->hw)) |
Joe Carnuccio | b5a340d | 2014-09-25 05:16:48 -0400 | [diff] [blame] | 2078 | 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] | 2079 | else |
| 2080 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2081 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2082 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2083 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2084 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2085 | /* Return firmware states. */ |
| 2086 | states[0] = mcp->mb[1]; |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 2087 | if (IS_FWI2_CAPABLE(vha->hw)) { |
| 2088 | states[1] = mcp->mb[2]; |
Joe Carnuccio | ec89146 | 2016-07-06 11:14:26 -0400 | [diff] [blame] | 2089 | states[2] = mcp->mb[3]; /* SFP info */ |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 2090 | states[3] = mcp->mb[4]; |
| 2091 | states[4] = mcp->mb[5]; |
Joe Carnuccio | b5a340d | 2014-09-25 05:16:48 -0400 | [diff] [blame] | 2092 | states[5] = mcp->mb[6]; /* DPORT status */ |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 2093 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2094 | |
| 2095 | if (rval != QLA_SUCCESS) { |
| 2096 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2097 | ql_dbg(ql_dbg_mbx, vha, 0x1055, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2098 | } else { |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 2099 | if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) { |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 2100 | if (mcp->mb[2] == 6 || mcp->mb[3] == 2) |
| 2101 | ql_dbg(ql_dbg_mbx, vha, 0x119e, |
| 2102 | "Invalid SFP/Validation Failed\n"); |
| 2103 | } |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2104 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1056, |
| 2105 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2106 | } |
| 2107 | |
| 2108 | return rval; |
| 2109 | } |
| 2110 | |
| 2111 | /* |
| 2112 | * qla2x00_get_port_name |
| 2113 | * Issue get port name mailbox command. |
| 2114 | * Returned name is in big endian format. |
| 2115 | * |
| 2116 | * Input: |
| 2117 | * ha = adapter block pointer. |
| 2118 | * loop_id = loop ID of device. |
| 2119 | * name = pointer for name. |
| 2120 | * TARGET_QUEUE_LOCK must be released. |
| 2121 | * ADAPTER_STATE_LOCK must be released. |
| 2122 | * |
| 2123 | * Returns: |
| 2124 | * qla2x00 local function return status code. |
| 2125 | * |
| 2126 | * Context: |
| 2127 | * Kernel context. |
| 2128 | */ |
| 2129 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2130 | 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] | 2131 | uint8_t opt) |
| 2132 | { |
| 2133 | int rval; |
| 2134 | mbx_cmd_t mc; |
| 2135 | mbx_cmd_t *mcp = &mc; |
| 2136 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2137 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1057, |
| 2138 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2139 | |
| 2140 | mcp->mb[0] = MBC_GET_PORT_NAME; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2141 | mcp->mb[9] = vha->vp_idx; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2142 | mcp->out_mb = MBX_9|MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2143 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2144 | mcp->mb[1] = loop_id; |
| 2145 | mcp->mb[10] = opt; |
| 2146 | mcp->out_mb |= MBX_10; |
| 2147 | } else { |
| 2148 | mcp->mb[1] = loop_id << 8 | opt; |
| 2149 | } |
| 2150 | |
| 2151 | 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] | 2152 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2153 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2154 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2155 | |
| 2156 | if (rval != QLA_SUCCESS) { |
| 2157 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2158 | ql_dbg(ql_dbg_mbx, vha, 0x1058, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2159 | } else { |
| 2160 | if (name != NULL) { |
| 2161 | /* This function returns name in big endian. */ |
Richard Lary | 1196ae0 | 2007-03-22 10:53:19 -0500 | [diff] [blame] | 2162 | name[0] = MSB(mcp->mb[2]); |
| 2163 | name[1] = LSB(mcp->mb[2]); |
| 2164 | name[2] = MSB(mcp->mb[3]); |
| 2165 | name[3] = LSB(mcp->mb[3]); |
| 2166 | name[4] = MSB(mcp->mb[6]); |
| 2167 | name[5] = LSB(mcp->mb[6]); |
| 2168 | name[6] = MSB(mcp->mb[7]); |
| 2169 | name[7] = LSB(mcp->mb[7]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2170 | } |
| 2171 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2172 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1059, |
| 2173 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2174 | } |
| 2175 | |
| 2176 | return rval; |
| 2177 | } |
| 2178 | |
| 2179 | /* |
Joe Carnuccio | 61e1b26 | 2013-02-08 01:57:48 -0500 | [diff] [blame] | 2180 | * qla24xx_link_initialization |
| 2181 | * Issue link initialization mailbox command. |
| 2182 | * |
| 2183 | * Input: |
| 2184 | * ha = adapter block pointer. |
| 2185 | * TARGET_QUEUE_LOCK must be released. |
| 2186 | * ADAPTER_STATE_LOCK must be released. |
| 2187 | * |
| 2188 | * Returns: |
| 2189 | * qla2x00 local function return status code. |
| 2190 | * |
| 2191 | * Context: |
| 2192 | * Kernel context. |
| 2193 | */ |
| 2194 | int |
| 2195 | qla24xx_link_initialize(scsi_qla_host_t *vha) |
| 2196 | { |
| 2197 | int rval; |
| 2198 | mbx_cmd_t mc; |
| 2199 | mbx_cmd_t *mcp = &mc; |
| 2200 | |
| 2201 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1152, |
| 2202 | "Entered %s.\n", __func__); |
| 2203 | |
| 2204 | if (!IS_FWI2_CAPABLE(vha->hw) || IS_CNA_CAPABLE(vha->hw)) |
| 2205 | return QLA_FUNCTION_FAILED; |
| 2206 | |
| 2207 | mcp->mb[0] = MBC_LINK_INITIALIZATION; |
Joe Carnuccio | 5a5c27b | 2013-08-27 01:37:49 -0400 | [diff] [blame] | 2208 | mcp->mb[1] = BIT_4; |
| 2209 | if (vha->hw->operating_mode == LOOP) |
| 2210 | mcp->mb[1] |= BIT_6; |
| 2211 | else |
| 2212 | mcp->mb[1] |= BIT_5; |
Joe Carnuccio | 61e1b26 | 2013-02-08 01:57:48 -0500 | [diff] [blame] | 2213 | mcp->mb[2] = 0; |
| 2214 | mcp->mb[3] = 0; |
| 2215 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 2216 | mcp->in_mb = MBX_0; |
| 2217 | mcp->tov = MBX_TOV_SECONDS; |
| 2218 | mcp->flags = 0; |
| 2219 | rval = qla2x00_mailbox_command(vha, mcp); |
| 2220 | |
| 2221 | if (rval != QLA_SUCCESS) { |
| 2222 | ql_dbg(ql_dbg_mbx, vha, 0x1153, "Failed=%x.\n", rval); |
| 2223 | } else { |
| 2224 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1154, |
| 2225 | "Done %s.\n", __func__); |
| 2226 | } |
| 2227 | |
| 2228 | return rval; |
| 2229 | } |
| 2230 | |
| 2231 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2232 | * qla2x00_lip_reset |
| 2233 | * Issue LIP reset mailbox command. |
| 2234 | * |
| 2235 | * Input: |
| 2236 | * ha = adapter block pointer. |
| 2237 | * TARGET_QUEUE_LOCK must be released. |
| 2238 | * ADAPTER_STATE_LOCK must be released. |
| 2239 | * |
| 2240 | * Returns: |
| 2241 | * qla2x00 local function return status code. |
| 2242 | * |
| 2243 | * Context: |
| 2244 | * Kernel context. |
| 2245 | */ |
| 2246 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2247 | qla2x00_lip_reset(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2248 | { |
| 2249 | int rval; |
| 2250 | mbx_cmd_t mc; |
| 2251 | mbx_cmd_t *mcp = &mc; |
| 2252 | |
Quinn Tran | 7f2a398 | 2019-09-12 11:09:09 -0700 | [diff] [blame] | 2253 | ql_dbg(ql_dbg_disc, vha, 0x105a, |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2254 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2255 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2256 | if (IS_CNA_CAPABLE(vha->hw)) { |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2257 | /* Logout across all FCFs. */ |
| 2258 | mcp->mb[0] = MBC_LIP_FULL_LOGIN; |
| 2259 | mcp->mb[1] = BIT_1; |
| 2260 | mcp->mb[2] = 0; |
| 2261 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 2262 | } else if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2263 | mcp->mb[0] = MBC_LIP_FULL_LOGIN; |
Quinn Tran | 87d6814a | 2019-01-24 23:23:49 -0800 | [diff] [blame] | 2264 | mcp->mb[1] = BIT_4; |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 2265 | mcp->mb[2] = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2266 | mcp->mb[3] = vha->hw->loop_reset_delay; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2267 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2268 | } else { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2269 | mcp->mb[0] = MBC_LIP_RESET; |
| 2270 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2271 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2272 | mcp->mb[1] = 0x00ff; |
| 2273 | mcp->mb[10] = 0; |
| 2274 | mcp->out_mb |= MBX_10; |
| 2275 | } else { |
| 2276 | mcp->mb[1] = 0xff00; |
| 2277 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2278 | mcp->mb[2] = vha->hw->loop_reset_delay; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2279 | mcp->mb[3] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2280 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2281 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2282 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2283 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2284 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2285 | |
| 2286 | if (rval != QLA_SUCCESS) { |
| 2287 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2288 | ql_dbg(ql_dbg_mbx, vha, 0x105b, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2289 | } else { |
| 2290 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2291 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105c, |
| 2292 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2293 | } |
| 2294 | |
| 2295 | return rval; |
| 2296 | } |
| 2297 | |
| 2298 | /* |
| 2299 | * qla2x00_send_sns |
| 2300 | * Send SNS command. |
| 2301 | * |
| 2302 | * Input: |
| 2303 | * ha = adapter block pointer. |
| 2304 | * sns = pointer for command. |
| 2305 | * cmd_size = command size. |
| 2306 | * buf_size = response/command size. |
| 2307 | * TARGET_QUEUE_LOCK must be released. |
| 2308 | * ADAPTER_STATE_LOCK must be released. |
| 2309 | * |
| 2310 | * Returns: |
| 2311 | * qla2x00 local function return status code. |
| 2312 | * |
| 2313 | * Context: |
| 2314 | * Kernel context. |
| 2315 | */ |
| 2316 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2317 | 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] | 2318 | uint16_t cmd_size, size_t buf_size) |
| 2319 | { |
| 2320 | int rval; |
| 2321 | mbx_cmd_t mc; |
| 2322 | mbx_cmd_t *mcp = &mc; |
| 2323 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2324 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105d, |
| 2325 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2326 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2327 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105e, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2328 | "Retry cnt=%d ratov=%d total tov=%d.\n", |
| 2329 | vha->hw->retry_count, vha->hw->login_timeout, mcp->tov); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2330 | |
| 2331 | mcp->mb[0] = MBC_SEND_SNS_COMMAND; |
| 2332 | mcp->mb[1] = cmd_size; |
| 2333 | mcp->mb[2] = MSW(sns_phys_address); |
| 2334 | mcp->mb[3] = LSW(sns_phys_address); |
| 2335 | mcp->mb[6] = MSW(MSD(sns_phys_address)); |
| 2336 | mcp->mb[7] = LSW(MSD(sns_phys_address)); |
| 2337 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 2338 | mcp->in_mb = MBX_0|MBX_1; |
| 2339 | mcp->buf_size = buf_size; |
| 2340 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2341 | mcp->tov = (vha->hw->login_timeout * 2) + (vha->hw->login_timeout / 2); |
| 2342 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2343 | |
| 2344 | if (rval != QLA_SUCCESS) { |
| 2345 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2346 | ql_dbg(ql_dbg_mbx, vha, 0x105f, |
| 2347 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 2348 | rval, mcp->mb[0], mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2349 | } else { |
| 2350 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2351 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1060, |
| 2352 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2353 | } |
| 2354 | |
| 2355 | return rval; |
| 2356 | } |
| 2357 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2358 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2359 | 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] | 2360 | uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt) |
| 2361 | { |
| 2362 | int rval; |
| 2363 | |
| 2364 | struct logio_entry_24xx *lg; |
| 2365 | dma_addr_t lg_dma; |
| 2366 | uint32_t iop[2]; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2367 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2368 | struct req_que *req; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2369 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2370 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1061, |
| 2371 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2372 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2373 | if (vha->vp_idx && vha->qpair) |
| 2374 | req = vha->qpair->req; |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2375 | else |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2376 | req = ha->req_q_map[0]; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2377 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 2378 | lg = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2379 | if (lg == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2380 | ql_log(ql_log_warn, vha, 0x1062, |
| 2381 | "Failed to allocate login IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2382 | return QLA_MEMORY_ALLOC_FAILED; |
| 2383 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2384 | |
| 2385 | lg->entry_type = LOGINOUT_PORT_IOCB_TYPE; |
| 2386 | lg->entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2387 | lg->handle = MAKE_HANDLE(req->id, lg->handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2388 | lg->nport_handle = cpu_to_le16(loop_id); |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2389 | lg->control_flags = cpu_to_le16(LCF_COMMAND_PLOGI); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2390 | if (opt & BIT_0) |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2391 | lg->control_flags |= cpu_to_le16(LCF_COND_PLOGI); |
Andrew Vasquez | 8baa51a | 2006-06-23 16:10:44 -0700 | [diff] [blame] | 2392 | if (opt & BIT_1) |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2393 | lg->control_flags |= cpu_to_le16(LCF_SKIP_PRLI); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2394 | lg->port_id[0] = al_pa; |
| 2395 | lg->port_id[1] = area; |
| 2396 | lg->port_id[2] = domain; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2397 | lg->vp_index = vha->vp_idx; |
Andrew Vasquez | 7f45dd0 | 2012-02-09 11:15:45 -0800 | [diff] [blame] | 2398 | rval = qla2x00_issue_iocb_timeout(vha, lg, lg_dma, 0, |
| 2399 | (ha->r_a_tov / 10 * 2) + 2); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2400 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2401 | ql_dbg(ql_dbg_mbx, vha, 0x1063, |
| 2402 | "Failed to issue login IOCB (%x).\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2403 | } else if (lg->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2404 | ql_dbg(ql_dbg_mbx, vha, 0x1064, |
| 2405 | "Failed to complete IOCB -- error status (%x).\n", |
| 2406 | lg->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2407 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2408 | } else if (lg->comp_status != cpu_to_le16(CS_COMPLETE)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2409 | iop[0] = le32_to_cpu(lg->io_parameter[0]); |
| 2410 | iop[1] = le32_to_cpu(lg->io_parameter[1]); |
| 2411 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2412 | ql_dbg(ql_dbg_mbx, vha, 0x1065, |
| 2413 | "Failed to complete IOCB -- completion status (%x) " |
| 2414 | "ioparam=%x/%x.\n", le16_to_cpu(lg->comp_status), |
| 2415 | iop[0], iop[1]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2416 | |
| 2417 | switch (iop[0]) { |
| 2418 | case LSC_SCODE_PORTID_USED: |
| 2419 | mb[0] = MBS_PORT_ID_USED; |
| 2420 | mb[1] = LSW(iop[1]); |
| 2421 | break; |
| 2422 | case LSC_SCODE_NPORT_USED: |
| 2423 | mb[0] = MBS_LOOP_ID_USED; |
| 2424 | break; |
| 2425 | case LSC_SCODE_NOLINK: |
| 2426 | case LSC_SCODE_NOIOCB: |
| 2427 | case LSC_SCODE_NOXCB: |
| 2428 | case LSC_SCODE_CMD_FAILED: |
| 2429 | case LSC_SCODE_NOFABRIC: |
| 2430 | case LSC_SCODE_FW_NOT_READY: |
| 2431 | case LSC_SCODE_NOT_LOGGED_IN: |
| 2432 | case LSC_SCODE_NOPCB: |
| 2433 | case LSC_SCODE_ELS_REJECT: |
| 2434 | case LSC_SCODE_CMD_PARAM_ERR: |
| 2435 | case LSC_SCODE_NONPORT: |
| 2436 | case LSC_SCODE_LOGGED_IN: |
| 2437 | case LSC_SCODE_NOFLOGI_ACC: |
| 2438 | default: |
| 2439 | mb[0] = MBS_COMMAND_ERROR; |
| 2440 | break; |
| 2441 | } |
| 2442 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2443 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1066, |
| 2444 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2445 | |
| 2446 | iop[0] = le32_to_cpu(lg->io_parameter[0]); |
| 2447 | |
| 2448 | mb[0] = MBS_COMMAND_COMPLETE; |
| 2449 | mb[1] = 0; |
| 2450 | if (iop[0] & BIT_4) { |
| 2451 | if (iop[0] & BIT_8) |
| 2452 | mb[1] |= BIT_1; |
| 2453 | } else |
| 2454 | mb[1] = BIT_0; |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 2455 | |
| 2456 | /* Passback COS information. */ |
| 2457 | mb[10] = 0; |
| 2458 | if (lg->io_parameter[7] || lg->io_parameter[8]) |
| 2459 | mb[10] |= BIT_0; /* Class 2. */ |
| 2460 | if (lg->io_parameter[9] || lg->io_parameter[10]) |
| 2461 | mb[10] |= BIT_1; /* Class 3. */ |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2462 | if (lg->io_parameter[0] & cpu_to_le32(BIT_7)) |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2463 | mb[10] |= BIT_7; /* Confirmed Completion |
| 2464 | * Allowed |
| 2465 | */ |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2466 | } |
| 2467 | |
| 2468 | dma_pool_free(ha->s_dma_pool, lg, lg_dma); |
| 2469 | |
| 2470 | return rval; |
| 2471 | } |
| 2472 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2473 | /* |
| 2474 | * qla2x00_login_fabric |
| 2475 | * Issue login fabric port mailbox command. |
| 2476 | * |
| 2477 | * Input: |
| 2478 | * ha = adapter block pointer. |
| 2479 | * loop_id = device loop ID. |
| 2480 | * domain = device domain. |
| 2481 | * area = device area. |
| 2482 | * al_pa = device AL_PA. |
| 2483 | * status = pointer for return status. |
| 2484 | * opt = command options. |
| 2485 | * TARGET_QUEUE_LOCK must be released. |
| 2486 | * ADAPTER_STATE_LOCK must be released. |
| 2487 | * |
| 2488 | * Returns: |
| 2489 | * qla2x00 local function return status code. |
| 2490 | * |
| 2491 | * Context: |
| 2492 | * Kernel context. |
| 2493 | */ |
| 2494 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2495 | 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] | 2496 | uint8_t area, uint8_t al_pa, uint16_t *mb, 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, 0x1067, |
| 2504 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2505 | |
| 2506 | mcp->mb[0] = MBC_LOGIN_FABRIC_PORT; |
| 2507 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 2508 | if (HAS_EXTENDED_IDS(ha)) { |
| 2509 | mcp->mb[1] = loop_id; |
| 2510 | mcp->mb[10] = opt; |
| 2511 | mcp->out_mb |= MBX_10; |
| 2512 | } else { |
| 2513 | mcp->mb[1] = (loop_id << 8) | opt; |
| 2514 | } |
| 2515 | mcp->mb[2] = domain; |
| 2516 | mcp->mb[3] = area << 8 | al_pa; |
| 2517 | |
| 2518 | mcp->in_mb = MBX_7|MBX_6|MBX_2|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 != NULL) { |
| 2525 | mb[0] = mcp->mb[0]; |
| 2526 | mb[1] = mcp->mb[1]; |
| 2527 | mb[2] = mcp->mb[2]; |
| 2528 | mb[6] = mcp->mb[6]; |
| 2529 | mb[7] = mcp->mb[7]; |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 2530 | /* COS retrieved from Get-Port-Database mailbox command. */ |
| 2531 | mb[10] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2532 | } |
| 2533 | |
| 2534 | if (rval != QLA_SUCCESS) { |
| 2535 | /* RLU tmp code: need to change main mailbox_command function to |
| 2536 | * return ok even when the mailbox completion value is not |
| 2537 | * SUCCESS. The caller needs to be responsible to interpret |
| 2538 | * the return values of this mailbox command if we're not |
| 2539 | * to change too much of the existing code. |
| 2540 | */ |
| 2541 | if (mcp->mb[0] == 0x4001 || mcp->mb[0] == 0x4002 || |
| 2542 | mcp->mb[0] == 0x4003 || mcp->mb[0] == 0x4005 || |
| 2543 | mcp->mb[0] == 0x4006) |
| 2544 | rval = QLA_SUCCESS; |
| 2545 | |
| 2546 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2547 | ql_dbg(ql_dbg_mbx, vha, 0x1068, |
| 2548 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 2549 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2550 | } else { |
| 2551 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2552 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1069, |
| 2553 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2554 | } |
| 2555 | |
| 2556 | return rval; |
| 2557 | } |
| 2558 | |
| 2559 | /* |
| 2560 | * qla2x00_login_local_device |
| 2561 | * Issue login loop port mailbox command. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2562 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2563 | * Input: |
| 2564 | * ha = adapter block pointer. |
| 2565 | * loop_id = device loop ID. |
| 2566 | * opt = command options. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2567 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2568 | * Returns: |
| 2569 | * Return status code. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2570 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2571 | * Context: |
| 2572 | * Kernel context. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2573 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2574 | */ |
| 2575 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2576 | 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] | 2577 | uint16_t *mb_ret, uint8_t opt) |
| 2578 | { |
| 2579 | int rval; |
| 2580 | mbx_cmd_t mc; |
| 2581 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2582 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2583 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2584 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106a, |
| 2585 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2586 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2587 | if (IS_FWI2_CAPABLE(ha)) |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2588 | return qla24xx_login_fabric(vha, fcport->loop_id, |
andrew.vasquez@qlogic.com | 9a52a57c | 2006-03-09 14:27:44 -0800 | [diff] [blame] | 2589 | fcport->d_id.b.domain, fcport->d_id.b.area, |
| 2590 | fcport->d_id.b.al_pa, mb_ret, opt); |
| 2591 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2592 | mcp->mb[0] = MBC_LOGIN_LOOP_PORT; |
| 2593 | if (HAS_EXTENDED_IDS(ha)) |
andrew.vasquez@qlogic.com | 9a52a57c | 2006-03-09 14:27:44 -0800 | [diff] [blame] | 2594 | mcp->mb[1] = fcport->loop_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2595 | else |
andrew.vasquez@qlogic.com | 9a52a57c | 2006-03-09 14:27:44 -0800 | [diff] [blame] | 2596 | mcp->mb[1] = fcport->loop_id << 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2597 | mcp->mb[2] = opt; |
| 2598 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 2599 | mcp->in_mb = MBX_7|MBX_6|MBX_1|MBX_0; |
| 2600 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
| 2601 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2602 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2603 | |
| 2604 | /* Return mailbox statuses. */ |
| 2605 | if (mb_ret != NULL) { |
| 2606 | mb_ret[0] = mcp->mb[0]; |
| 2607 | mb_ret[1] = mcp->mb[1]; |
| 2608 | mb_ret[6] = mcp->mb[6]; |
| 2609 | mb_ret[7] = mcp->mb[7]; |
| 2610 | } |
| 2611 | |
| 2612 | if (rval != QLA_SUCCESS) { |
| 2613 | /* AV tmp code: need to change main mailbox_command function to |
| 2614 | * return ok even when the mailbox completion value is not |
| 2615 | * SUCCESS. The caller needs to be responsible to interpret |
| 2616 | * the return values of this mailbox command if we're not |
| 2617 | * to change too much of the existing code. |
| 2618 | */ |
| 2619 | if (mcp->mb[0] == 0x4005 || mcp->mb[0] == 0x4006) |
| 2620 | rval = QLA_SUCCESS; |
| 2621 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2622 | ql_dbg(ql_dbg_mbx, vha, 0x106b, |
| 2623 | "Failed=%x mb[0]=%x mb[1]=%x mb[6]=%x mb[7]=%x.\n", |
| 2624 | 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] | 2625 | } else { |
| 2626 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2627 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106c, |
| 2628 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2629 | } |
| 2630 | |
| 2631 | return (rval); |
| 2632 | } |
| 2633 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2634 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2635 | 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] | 2636 | uint8_t area, uint8_t al_pa) |
| 2637 | { |
| 2638 | int rval; |
| 2639 | struct logio_entry_24xx *lg; |
| 2640 | dma_addr_t lg_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2641 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2642 | struct req_que *req; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2643 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2644 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106d, |
| 2645 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2646 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 2647 | lg = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2648 | if (lg == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2649 | ql_log(ql_log_warn, vha, 0x106e, |
| 2650 | "Failed to allocate logout IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2651 | return QLA_MEMORY_ALLOC_FAILED; |
| 2652 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2653 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2654 | req = vha->req; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2655 | lg->entry_type = LOGINOUT_PORT_IOCB_TYPE; |
| 2656 | lg->entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2657 | lg->handle = MAKE_HANDLE(req->id, lg->handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2658 | lg->nport_handle = cpu_to_le16(loop_id); |
| 2659 | lg->control_flags = |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2660 | cpu_to_le16(LCF_COMMAND_LOGO|LCF_IMPL_LOGO| |
Andrew Vasquez | c8d6691 | 2011-03-30 11:46:21 -0700 | [diff] [blame] | 2661 | LCF_FREE_NPORT); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2662 | lg->port_id[0] = al_pa; |
| 2663 | lg->port_id[1] = area; |
| 2664 | lg->port_id[2] = domain; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2665 | lg->vp_index = vha->vp_idx; |
Andrew Vasquez | 7f45dd0 | 2012-02-09 11:15:45 -0800 | [diff] [blame] | 2666 | rval = qla2x00_issue_iocb_timeout(vha, lg, lg_dma, 0, |
| 2667 | (ha->r_a_tov / 10 * 2) + 2); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2668 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2669 | ql_dbg(ql_dbg_mbx, vha, 0x106f, |
| 2670 | "Failed to issue logout IOCB (%x).\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2671 | } else if (lg->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2672 | ql_dbg(ql_dbg_mbx, vha, 0x1070, |
| 2673 | "Failed to complete IOCB -- error status (%x).\n", |
| 2674 | lg->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2675 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2676 | } else if (lg->comp_status != cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2677 | ql_dbg(ql_dbg_mbx, vha, 0x1071, |
| 2678 | "Failed to complete IOCB -- completion status (%x) " |
| 2679 | "ioparam=%x/%x.\n", le16_to_cpu(lg->comp_status), |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2680 | le32_to_cpu(lg->io_parameter[0]), |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2681 | le32_to_cpu(lg->io_parameter[1])); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2682 | } else { |
| 2683 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2684 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1072, |
| 2685 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2686 | } |
| 2687 | |
| 2688 | dma_pool_free(ha->s_dma_pool, lg, lg_dma); |
| 2689 | |
| 2690 | return rval; |
| 2691 | } |
| 2692 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2693 | /* |
| 2694 | * qla2x00_fabric_logout |
| 2695 | * Issue logout fabric port mailbox command. |
| 2696 | * |
| 2697 | * Input: |
| 2698 | * ha = adapter block pointer. |
| 2699 | * loop_id = device loop ID. |
| 2700 | * TARGET_QUEUE_LOCK must be released. |
| 2701 | * ADAPTER_STATE_LOCK must be released. |
| 2702 | * |
| 2703 | * Returns: |
| 2704 | * qla2x00 local function return status code. |
| 2705 | * |
| 2706 | * Context: |
| 2707 | * Kernel context. |
| 2708 | */ |
| 2709 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2710 | 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] | 2711 | uint8_t area, uint8_t al_pa) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2712 | { |
| 2713 | int rval; |
| 2714 | mbx_cmd_t mc; |
| 2715 | mbx_cmd_t *mcp = &mc; |
| 2716 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2717 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1073, |
| 2718 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2719 | |
| 2720 | mcp->mb[0] = MBC_LOGOUT_FABRIC_PORT; |
| 2721 | mcp->out_mb = MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2722 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2723 | mcp->mb[1] = loop_id; |
| 2724 | mcp->mb[10] = 0; |
| 2725 | mcp->out_mb |= MBX_10; |
| 2726 | } else { |
| 2727 | mcp->mb[1] = loop_id << 8; |
| 2728 | } |
| 2729 | |
| 2730 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2731 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2732 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2733 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2734 | |
| 2735 | if (rval != QLA_SUCCESS) { |
| 2736 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2737 | ql_dbg(ql_dbg_mbx, vha, 0x1074, |
| 2738 | "Failed=%x mb[1]=%x.\n", rval, mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2739 | } else { |
| 2740 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2741 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1075, |
| 2742 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2743 | } |
| 2744 | |
| 2745 | return rval; |
| 2746 | } |
| 2747 | |
| 2748 | /* |
| 2749 | * qla2x00_full_login_lip |
| 2750 | * Issue full login LIP mailbox command. |
| 2751 | * |
| 2752 | * Input: |
| 2753 | * ha = adapter block pointer. |
| 2754 | * TARGET_QUEUE_LOCK must be released. |
| 2755 | * ADAPTER_STATE_LOCK must be released. |
| 2756 | * |
| 2757 | * Returns: |
| 2758 | * qla2x00 local function return status code. |
| 2759 | * |
| 2760 | * Context: |
| 2761 | * Kernel context. |
| 2762 | */ |
| 2763 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2764 | qla2x00_full_login_lip(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2765 | { |
| 2766 | int rval; |
| 2767 | mbx_cmd_t mc; |
| 2768 | mbx_cmd_t *mcp = &mc; |
| 2769 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2770 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1076, |
| 2771 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2772 | |
| 2773 | mcp->mb[0] = MBC_LIP_FULL_LOGIN; |
Quinn Tran | 87d6814a | 2019-01-24 23:23:49 -0800 | [diff] [blame] | 2774 | mcp->mb[1] = IS_FWI2_CAPABLE(vha->hw) ? BIT_4 : 0; |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 2775 | mcp->mb[2] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2776 | mcp->mb[3] = 0; |
| 2777 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 2778 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2779 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2780 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2781 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2782 | |
| 2783 | if (rval != QLA_SUCCESS) { |
| 2784 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2785 | ql_dbg(ql_dbg_mbx, vha, 0x1077, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2786 | } else { |
| 2787 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2788 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1078, |
| 2789 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2790 | } |
| 2791 | |
| 2792 | return rval; |
| 2793 | } |
| 2794 | |
| 2795 | /* |
| 2796 | * qla2x00_get_id_list |
| 2797 | * |
| 2798 | * Input: |
| 2799 | * ha = adapter block pointer. |
| 2800 | * |
| 2801 | * Returns: |
| 2802 | * qla2x00 local function return status code. |
| 2803 | * |
| 2804 | * Context: |
| 2805 | * Kernel context. |
| 2806 | */ |
| 2807 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2808 | 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] | 2809 | uint16_t *entries) |
| 2810 | { |
| 2811 | int rval; |
| 2812 | mbx_cmd_t mc; |
| 2813 | mbx_cmd_t *mcp = &mc; |
| 2814 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2815 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1079, |
| 2816 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2817 | |
| 2818 | if (id_list == NULL) |
| 2819 | return QLA_FUNCTION_FAILED; |
| 2820 | |
| 2821 | mcp->mb[0] = MBC_GET_ID_LIST; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2822 | mcp->out_mb = MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2823 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2824 | mcp->mb[2] = MSW(id_list_dma); |
| 2825 | mcp->mb[3] = LSW(id_list_dma); |
| 2826 | mcp->mb[6] = MSW(MSD(id_list_dma)); |
| 2827 | mcp->mb[7] = LSW(MSD(id_list_dma)); |
andrew.vasquez@qlogic.com | 247ec45 | 2006-02-07 08:45:40 -0800 | [diff] [blame] | 2828 | mcp->mb[8] = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2829 | mcp->mb[9] = vha->vp_idx; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2830 | 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] | 2831 | } else { |
| 2832 | mcp->mb[1] = MSW(id_list_dma); |
| 2833 | mcp->mb[2] = LSW(id_list_dma); |
| 2834 | mcp->mb[3] = MSW(MSD(id_list_dma)); |
| 2835 | mcp->mb[6] = LSW(MSD(id_list_dma)); |
| 2836 | mcp->out_mb |= MBX_6|MBX_3|MBX_2|MBX_1; |
| 2837 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2838 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2839 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2840 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2841 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2842 | |
| 2843 | if (rval != QLA_SUCCESS) { |
| 2844 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2845 | ql_dbg(ql_dbg_mbx, vha, 0x107a, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2846 | } else { |
| 2847 | *entries = mcp->mb[1]; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2848 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107b, |
| 2849 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2850 | } |
| 2851 | |
| 2852 | return rval; |
| 2853 | } |
| 2854 | |
| 2855 | /* |
| 2856 | * qla2x00_get_resource_cnts |
| 2857 | * Get current firmware resource counts. |
| 2858 | * |
| 2859 | * Input: |
| 2860 | * ha = adapter block pointer. |
| 2861 | * |
| 2862 | * Returns: |
| 2863 | * qla2x00 local function return status code. |
| 2864 | * |
| 2865 | * Context: |
| 2866 | * Kernel context. |
| 2867 | */ |
| 2868 | int |
Quinn Tran | 03e8c68 | 2015-12-17 14:56:59 -0500 | [diff] [blame] | 2869 | qla2x00_get_resource_cnts(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2870 | { |
Quinn Tran | 03e8c68 | 2015-12-17 14:56:59 -0500 | [diff] [blame] | 2871 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2872 | int rval; |
| 2873 | mbx_cmd_t mc; |
| 2874 | mbx_cmd_t *mcp = &mc; |
| 2875 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2876 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107c, |
| 2877 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2878 | |
| 2879 | mcp->mb[0] = MBC_GET_RESOURCE_COUNTS; |
| 2880 | mcp->out_mb = MBX_0; |
Seokmann Ju | 4d0ea24 | 2007-09-20 14:07:43 -0700 | [diff] [blame] | 2881 | mcp->in_mb = MBX_11|MBX_10|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 2882 | if (IS_QLA81XX(ha) || IS_QLA83XX(ha) || |
| 2883 | IS_QLA27XX(ha) || IS_QLA28XX(ha)) |
Andrew Vasquez | f3a0a77 | 2009-10-13 15:16:49 -0700 | [diff] [blame] | 2884 | mcp->in_mb |= MBX_12; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2885 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2886 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2887 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2888 | |
| 2889 | if (rval != QLA_SUCCESS) { |
| 2890 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2891 | ql_dbg(ql_dbg_mbx, vha, 0x107d, |
| 2892 | "Failed mb[0]=%x.\n", mcp->mb[0]); |
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, 0x107e, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2895 | "Done %s mb1=%x mb2=%x mb3=%x mb6=%x mb7=%x mb10=%x " |
| 2896 | "mb11=%x mb12=%x.\n", __func__, mcp->mb[1], mcp->mb[2], |
| 2897 | mcp->mb[3], mcp->mb[6], mcp->mb[7], mcp->mb[10], |
| 2898 | mcp->mb[11], mcp->mb[12]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2899 | |
Quinn Tran | 03e8c68 | 2015-12-17 14:56:59 -0500 | [diff] [blame] | 2900 | ha->orig_fw_tgt_xcb_count = mcp->mb[1]; |
| 2901 | ha->cur_fw_tgt_xcb_count = mcp->mb[2]; |
| 2902 | ha->cur_fw_xcb_count = mcp->mb[3]; |
| 2903 | ha->orig_fw_xcb_count = mcp->mb[6]; |
| 2904 | ha->cur_fw_iocb_count = mcp->mb[7]; |
| 2905 | ha->orig_fw_iocb_count = mcp->mb[10]; |
| 2906 | if (ha->flags.npiv_supported) |
| 2907 | ha->max_npiv_vports = mcp->mb[11]; |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 2908 | if (IS_QLA81XX(ha) || IS_QLA83XX(ha) || IS_QLA27XX(ha) || |
| 2909 | IS_QLA28XX(ha)) |
Quinn Tran | 03e8c68 | 2015-12-17 14:56:59 -0500 | [diff] [blame] | 2910 | ha->fw_max_fcf_count = mcp->mb[12]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2911 | } |
| 2912 | |
| 2913 | return (rval); |
| 2914 | } |
| 2915 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2916 | /* |
| 2917 | * qla2x00_get_fcal_position_map |
| 2918 | * Get FCAL (LILP) position map using mailbox command |
| 2919 | * |
| 2920 | * Input: |
| 2921 | * ha = adapter state pointer. |
| 2922 | * pos_map = buffer pointer (can be NULL). |
| 2923 | * |
| 2924 | * Returns: |
| 2925 | * qla2x00 local function return status code. |
| 2926 | * |
| 2927 | * Context: |
| 2928 | * Kernel context. |
| 2929 | */ |
| 2930 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2931 | 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] | 2932 | { |
| 2933 | int rval; |
| 2934 | mbx_cmd_t mc; |
| 2935 | mbx_cmd_t *mcp = &mc; |
| 2936 | char *pmap; |
| 2937 | dma_addr_t pmap_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2938 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2939 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2940 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107f, |
| 2941 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2942 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 2943 | pmap = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pmap_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2944 | if (pmap == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2945 | ql_log(ql_log_warn, vha, 0x1080, |
| 2946 | "Memory alloc failed.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2947 | return QLA_MEMORY_ALLOC_FAILED; |
| 2948 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2949 | |
| 2950 | mcp->mb[0] = MBC_GET_FC_AL_POSITION_MAP; |
| 2951 | mcp->mb[2] = MSW(pmap_dma); |
| 2952 | mcp->mb[3] = LSW(pmap_dma); |
| 2953 | mcp->mb[6] = MSW(MSD(pmap_dma)); |
| 2954 | mcp->mb[7] = LSW(MSD(pmap_dma)); |
| 2955 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; |
| 2956 | mcp->in_mb = MBX_1|MBX_0; |
| 2957 | mcp->buf_size = FCAL_MAP_SIZE; |
| 2958 | mcp->flags = MBX_DMA_IN; |
| 2959 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2960 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2961 | |
| 2962 | if (rval == QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2963 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1081, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2964 | "mb0/mb1=%x/%X FC/AL position map size (%x).\n", |
| 2965 | mcp->mb[0], mcp->mb[1], (unsigned)pmap[0]); |
| 2966 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111d, |
| 2967 | pmap, pmap[0] + 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2968 | |
| 2969 | if (pos_map) |
| 2970 | memcpy(pos_map, pmap, FCAL_MAP_SIZE); |
| 2971 | } |
| 2972 | dma_pool_free(ha->s_dma_pool, pmap, pmap_dma); |
| 2973 | |
| 2974 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2975 | ql_dbg(ql_dbg_mbx, vha, 0x1082, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2976 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2977 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1083, |
| 2978 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2979 | } |
| 2980 | |
| 2981 | return rval; |
| 2982 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2983 | |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2984 | /* |
| 2985 | * qla2x00_get_link_status |
| 2986 | * |
| 2987 | * Input: |
| 2988 | * ha = adapter block pointer. |
| 2989 | * loop_id = device loop ID. |
| 2990 | * ret_buf = pointer to link status return buffer. |
| 2991 | * |
| 2992 | * Returns: |
| 2993 | * 0 = success. |
| 2994 | * BIT_0 = mem alloc error. |
| 2995 | * BIT_1 = mailbox error. |
| 2996 | */ |
| 2997 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2998 | 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] | 2999 | struct link_statistics *stats, dma_addr_t stats_dma) |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 3000 | { |
| 3001 | int rval; |
| 3002 | mbx_cmd_t mc; |
| 3003 | mbx_cmd_t *mcp = &mc; |
Joe Carnuccio | c6dc990 | 2016-07-06 11:14:24 -0400 | [diff] [blame] | 3004 | uint32_t *iter = (void *)stats; |
| 3005 | ushort dwords = offsetof(typeof(*stats), link_up_cnt)/sizeof(*iter); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3006 | struct qla_hw_data *ha = vha->hw; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 3007 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3008 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1084, |
| 3009 | "Entered %s.\n", __func__); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 3010 | |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 3011 | mcp->mb[0] = MBC_GET_LINK_STATUS; |
Joe Carnuccio | c6dc990 | 2016-07-06 11:14:24 -0400 | [diff] [blame] | 3012 | mcp->mb[2] = MSW(LSD(stats_dma)); |
| 3013 | mcp->mb[3] = LSW(LSD(stats_dma)); |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 3014 | mcp->mb[6] = MSW(MSD(stats_dma)); |
| 3015 | mcp->mb[7] = LSW(MSD(stats_dma)); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 3016 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; |
| 3017 | mcp->in_mb = MBX_0; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 3018 | if (IS_FWI2_CAPABLE(ha)) { |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 3019 | mcp->mb[1] = loop_id; |
| 3020 | mcp->mb[4] = 0; |
| 3021 | mcp->mb[10] = 0; |
| 3022 | mcp->out_mb |= MBX_10|MBX_4|MBX_1; |
| 3023 | mcp->in_mb |= MBX_1; |
| 3024 | } else if (HAS_EXTENDED_IDS(ha)) { |
| 3025 | mcp->mb[1] = loop_id; |
| 3026 | mcp->mb[10] = 0; |
| 3027 | mcp->out_mb |= MBX_10|MBX_1; |
| 3028 | } else { |
| 3029 | mcp->mb[1] = loop_id << 8; |
| 3030 | mcp->out_mb |= MBX_1; |
| 3031 | } |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3032 | mcp->tov = MBX_TOV_SECONDS; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 3033 | mcp->flags = IOCTL_CMD; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3034 | rval = qla2x00_mailbox_command(vha, mcp); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 3035 | |
| 3036 | if (rval == QLA_SUCCESS) { |
| 3037 | if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3038 | ql_dbg(ql_dbg_mbx, vha, 0x1085, |
| 3039 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 3040 | rval = QLA_FUNCTION_FAILED; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 3041 | } else { |
Joe Carnuccio | c6dc990 | 2016-07-06 11:14:24 -0400 | [diff] [blame] | 3042 | /* Re-endianize - firmware data is le32. */ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3043 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1086, |
| 3044 | "Done %s.\n", __func__); |
Joe Carnuccio | da08ef5 | 2016-01-27 12:03:34 -0500 | [diff] [blame] | 3045 | for ( ; dwords--; iter++) |
| 3046 | le32_to_cpus(iter); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 3047 | } |
| 3048 | } else { |
| 3049 | /* Failed. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3050 | 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] | 3051 | } |
| 3052 | |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 3053 | return rval; |
| 3054 | } |
| 3055 | |
| 3056 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3057 | 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] | 3058 | dma_addr_t stats_dma, uint16_t options) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3059 | { |
| 3060 | int rval; |
| 3061 | mbx_cmd_t mc; |
| 3062 | mbx_cmd_t *mcp = &mc; |
Joe Carnuccio | da08ef5 | 2016-01-27 12:03:34 -0500 | [diff] [blame] | 3063 | uint32_t *iter, dwords; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3064 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3065 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1088, |
| 3066 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3067 | |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 3068 | memset(&mc, 0, sizeof(mc)); |
| 3069 | mc.mb[0] = MBC_GET_LINK_PRIV_STATS; |
| 3070 | mc.mb[2] = MSW(stats_dma); |
| 3071 | mc.mb[3] = LSW(stats_dma); |
| 3072 | mc.mb[6] = MSW(MSD(stats_dma)); |
| 3073 | mc.mb[7] = LSW(MSD(stats_dma)); |
| 3074 | mc.mb[8] = sizeof(struct link_statistics) / 4; |
| 3075 | mc.mb[9] = cpu_to_le16(vha->vp_idx); |
| 3076 | mc.mb[10] = cpu_to_le16(options); |
| 3077 | |
| 3078 | rval = qla24xx_send_mb_cmd(vha, &mc); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3079 | |
| 3080 | if (rval == QLA_SUCCESS) { |
| 3081 | if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3082 | ql_dbg(ql_dbg_mbx, vha, 0x1089, |
| 3083 | "Failed mb[0]=%x.\n", mcp->mb[0]); |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 3084 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3085 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3086 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x108a, |
| 3087 | "Done %s.\n", __func__); |
Joe Carnuccio | c6dc990 | 2016-07-06 11:14:24 -0400 | [diff] [blame] | 3088 | /* Re-endianize - firmware data is le32. */ |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 3089 | dwords = sizeof(struct link_statistics) / 4; |
Joe Carnuccio | da08ef5 | 2016-01-27 12:03:34 -0500 | [diff] [blame] | 3090 | iter = &stats->link_fail_cnt; |
| 3091 | for ( ; dwords--; iter++) |
| 3092 | le32_to_cpus(iter); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3093 | } |
| 3094 | } else { |
| 3095 | /* Failed. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3096 | ql_dbg(ql_dbg_mbx, vha, 0x108b, "Failed=%x.\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3097 | } |
| 3098 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3099 | return rval; |
| 3100 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3101 | |
| 3102 | int |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3103 | qla24xx_abort_command(srb_t *sp) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3104 | { |
| 3105 | int rval; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3106 | unsigned long flags = 0; |
| 3107 | |
| 3108 | struct abort_entry_24xx *abt; |
| 3109 | dma_addr_t abt_dma; |
| 3110 | uint32_t handle; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3111 | fc_port_t *fcport = sp->fcport; |
| 3112 | struct scsi_qla_host *vha = fcport->vha; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3113 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 3114 | struct req_que *req = vha->req; |
Quinn Tran | 585def9 | 2018-09-04 14:19:20 -0700 | [diff] [blame] | 3115 | struct qla_qpair *qpair = sp->qpair; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3116 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3117 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x108c, |
| 3118 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3119 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3120 | if (vha->flags.qpairs_available && sp->qpair) |
| 3121 | req = sp->qpair->req; |
Quinn Tran | 585def9 | 2018-09-04 14:19:20 -0700 | [diff] [blame] | 3122 | else |
| 3123 | return QLA_FUNCTION_FAILED; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3124 | |
Armen Baloyan | 4440e46 | 2014-02-26 04:15:18 -0500 | [diff] [blame] | 3125 | if (ql2xasynctmfenable) |
| 3126 | return qla24xx_async_abort_command(sp); |
| 3127 | |
Quinn Tran | 585def9 | 2018-09-04 14:19:20 -0700 | [diff] [blame] | 3128 | spin_lock_irqsave(qpair->qp_lock_ptr, flags); |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 3129 | for (handle = 1; handle < req->num_outstanding_cmds; handle++) { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3130 | if (req->outstanding_cmds[handle] == sp) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3131 | break; |
| 3132 | } |
Quinn Tran | 585def9 | 2018-09-04 14:19:20 -0700 | [diff] [blame] | 3133 | spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 3134 | if (handle == req->num_outstanding_cmds) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3135 | /* Command not found. */ |
| 3136 | return QLA_FUNCTION_FAILED; |
| 3137 | } |
| 3138 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 3139 | abt = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &abt_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3140 | if (abt == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3141 | ql_log(ql_log_warn, vha, 0x108d, |
| 3142 | "Failed to allocate abort IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3143 | return QLA_MEMORY_ALLOC_FAILED; |
| 3144 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3145 | |
| 3146 | abt->entry_type = ABORT_IOCB_TYPE; |
| 3147 | abt->entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3148 | abt->handle = MAKE_HANDLE(req->id, abt->handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3149 | abt->nport_handle = cpu_to_le16(fcport->loop_id); |
Mike Hernandez | a74ec14 | 2011-03-30 11:46:20 -0700 | [diff] [blame] | 3150 | abt->handle_to_abort = MAKE_HANDLE(req->id, handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3151 | abt->port_id[0] = fcport->d_id.b.al_pa; |
| 3152 | abt->port_id[1] = fcport->d_id.b.area; |
| 3153 | abt->port_id[2] = fcport->d_id.b.domain; |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3154 | abt->vp_index = fcport->vha->vp_idx; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3155 | |
| 3156 | abt->req_que_no = cpu_to_le16(req->id); |
| 3157 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3158 | rval = qla2x00_issue_iocb(vha, abt, abt_dma, 0); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3159 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3160 | ql_dbg(ql_dbg_mbx, vha, 0x108e, |
| 3161 | "Failed to issue IOCB (%x).\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3162 | } else if (abt->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3163 | ql_dbg(ql_dbg_mbx, vha, 0x108f, |
| 3164 | "Failed to complete IOCB -- error status (%x).\n", |
| 3165 | abt->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3166 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 3167 | } else if (abt->nport_handle != cpu_to_le16(0)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3168 | ql_dbg(ql_dbg_mbx, vha, 0x1090, |
| 3169 | "Failed to complete IOCB -- completion status (%x).\n", |
| 3170 | le16_to_cpu(abt->nport_handle)); |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 3171 | if (abt->nport_handle == CS_IOCB_ERROR) |
| 3172 | rval = QLA_FUNCTION_PARAMETER_ERROR; |
| 3173 | else |
| 3174 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3175 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3176 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1091, |
| 3177 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3178 | } |
| 3179 | |
| 3180 | dma_pool_free(ha->s_dma_pool, abt, abt_dma); |
| 3181 | |
| 3182 | return rval; |
| 3183 | } |
| 3184 | |
| 3185 | struct tsk_mgmt_cmd { |
| 3186 | union { |
| 3187 | struct tsk_mgmt_entry tsk; |
| 3188 | struct sts_entry_24xx sts; |
| 3189 | } p; |
| 3190 | }; |
| 3191 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3192 | static int |
| 3193 | __qla24xx_issue_tmf(char *name, uint32_t type, struct fc_port *fcport, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 3194 | uint64_t l, int tag) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3195 | { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3196 | int rval, rval2; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3197 | struct tsk_mgmt_cmd *tsk; |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 3198 | struct sts_entry_24xx *sts; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3199 | dma_addr_t tsk_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3200 | scsi_qla_host_t *vha; |
| 3201 | struct qla_hw_data *ha; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3202 | struct req_que *req; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3203 | struct qla_qpair *qpair; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3204 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3205 | vha = fcport->vha; |
| 3206 | ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3207 | req = vha->req; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3208 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3209 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1092, |
| 3210 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3211 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3212 | if (vha->vp_idx && vha->qpair) { |
| 3213 | /* NPIV port */ |
| 3214 | qpair = vha->qpair; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3215 | req = qpair->req; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3216 | } |
| 3217 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 3218 | tsk = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &tsk_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3219 | if (tsk == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3220 | ql_log(ql_log_warn, vha, 0x1093, |
| 3221 | "Failed to allocate task management IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3222 | return QLA_MEMORY_ALLOC_FAILED; |
| 3223 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3224 | |
| 3225 | tsk->p.tsk.entry_type = TSK_MGMT_IOCB_TYPE; |
| 3226 | tsk->p.tsk.entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3227 | tsk->p.tsk.handle = MAKE_HANDLE(req->id, tsk->p.tsk.handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3228 | tsk->p.tsk.nport_handle = cpu_to_le16(fcport->loop_id); |
Andrew Vasquez | 00a537b | 2008-02-28 14:06:11 -0800 | [diff] [blame] | 3229 | 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] | 3230 | tsk->p.tsk.control_flags = cpu_to_le32(type); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3231 | tsk->p.tsk.port_id[0] = fcport->d_id.b.al_pa; |
| 3232 | tsk->p.tsk.port_id[1] = fcport->d_id.b.area; |
| 3233 | tsk->p.tsk.port_id[2] = fcport->d_id.b.domain; |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3234 | tsk->p.tsk.vp_index = fcport->vha->vp_idx; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3235 | if (type == TCF_LUN_RESET) { |
| 3236 | int_to_scsilun(l, &tsk->p.tsk.lun); |
| 3237 | host_to_fcp_swap((uint8_t *)&tsk->p.tsk.lun, |
| 3238 | sizeof(tsk->p.tsk.lun)); |
| 3239 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3240 | |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 3241 | sts = &tsk->p.sts; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3242 | rval = qla2x00_issue_iocb(vha, tsk, tsk_dma, 0); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3243 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3244 | ql_dbg(ql_dbg_mbx, vha, 0x1094, |
| 3245 | "Failed to issue %s reset IOCB (%x).\n", name, rval); |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 3246 | } else if (sts->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3247 | ql_dbg(ql_dbg_mbx, vha, 0x1095, |
| 3248 | "Failed to complete IOCB -- error status (%x).\n", |
| 3249 | sts->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3250 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 3251 | } else if (sts->comp_status != cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3252 | ql_dbg(ql_dbg_mbx, vha, 0x1096, |
| 3253 | "Failed to complete IOCB -- completion status (%x).\n", |
| 3254 | le16_to_cpu(sts->comp_status)); |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 3255 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 97dec56 | 2011-02-23 15:27:14 -0800 | [diff] [blame] | 3256 | } else if (le16_to_cpu(sts->scsi_status) & |
| 3257 | SS_RESPONSE_INFO_LEN_VALID) { |
| 3258 | if (le32_to_cpu(sts->rsp_data_len) < 4) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3259 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1097, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3260 | "Ignoring inconsistent data length -- not enough " |
| 3261 | "response info (%d).\n", |
| 3262 | le32_to_cpu(sts->rsp_data_len)); |
Andrew Vasquez | 97dec56 | 2011-02-23 15:27:14 -0800 | [diff] [blame] | 3263 | } else if (sts->data[3]) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3264 | ql_dbg(ql_dbg_mbx, vha, 0x1098, |
| 3265 | "Failed to complete IOCB -- response (%x).\n", |
| 3266 | sts->data[3]); |
Andrew Vasquez | 97dec56 | 2011-02-23 15:27:14 -0800 | [diff] [blame] | 3267 | rval = QLA_FUNCTION_FAILED; |
| 3268 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3269 | } |
| 3270 | |
| 3271 | /* Issue marker IOCB. */ |
Quinn Tran | 9eb9c6d | 2019-02-15 14:37:19 -0800 | [diff] [blame] | 3272 | rval2 = qla2x00_marker(vha, ha->base_qpair, fcport->loop_id, l, |
Bart Van Assche | 58e2753 | 2019-04-11 14:53:19 -0700 | [diff] [blame] | 3273 | type == TCF_LUN_RESET ? MK_SYNC_ID_LUN : MK_SYNC_ID); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3274 | if (rval2 != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3275 | ql_dbg(ql_dbg_mbx, vha, 0x1099, |
| 3276 | "Failed to issue marker IOCB (%x).\n", rval2); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3277 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3278 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109a, |
| 3279 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3280 | } |
| 3281 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3282 | dma_pool_free(ha->s_dma_pool, tsk, tsk_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3283 | |
| 3284 | return rval; |
| 3285 | } |
| 3286 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3287 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 3288 | qla24xx_abort_target(struct fc_port *fcport, uint64_t l, int tag) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3289 | { |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 3290 | struct qla_hw_data *ha = fcport->vha->hw; |
| 3291 | |
| 3292 | if ((ql2xasynctmfenable) && IS_FWI2_CAPABLE(ha)) |
| 3293 | return qla2x00_async_tm_cmd(fcport, TCF_TARGET_RESET, l, tag); |
| 3294 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3295 | return __qla24xx_issue_tmf("Target", TCF_TARGET_RESET, fcport, l, tag); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3296 | } |
| 3297 | |
| 3298 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 3299 | qla24xx_lun_reset(struct fc_port *fcport, uint64_t l, int tag) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3300 | { |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 3301 | struct qla_hw_data *ha = fcport->vha->hw; |
| 3302 | |
| 3303 | if ((ql2xasynctmfenable) && IS_FWI2_CAPABLE(ha)) |
| 3304 | return qla2x00_async_tm_cmd(fcport, TCF_LUN_RESET, l, tag); |
| 3305 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3306 | return __qla24xx_issue_tmf("Lun", TCF_LUN_RESET, fcport, l, tag); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3307 | } |
| 3308 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3309 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3310 | qla2x00_system_error(scsi_qla_host_t *vha) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3311 | { |
| 3312 | int rval; |
| 3313 | mbx_cmd_t mc; |
| 3314 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3315 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3316 | |
Andrew Vasquez | 68af081 | 2008-05-12 22:21:13 -0700 | [diff] [blame] | 3317 | if (!IS_QLA23XX(ha) && !IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3318 | return QLA_FUNCTION_FAILED; |
| 3319 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3320 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109b, |
| 3321 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3322 | |
| 3323 | mcp->mb[0] = MBC_GEN_SYSTEM_ERROR; |
| 3324 | mcp->out_mb = MBX_0; |
| 3325 | mcp->in_mb = MBX_0; |
| 3326 | mcp->tov = 5; |
| 3327 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3328 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3329 | |
| 3330 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3331 | ql_dbg(ql_dbg_mbx, vha, 0x109c, "Failed=%x.\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3332 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3333 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109d, |
| 3334 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3335 | } |
| 3336 | |
| 3337 | return rval; |
| 3338 | } |
| 3339 | |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 3340 | int |
| 3341 | qla2x00_write_serdes_word(scsi_qla_host_t *vha, uint16_t addr, uint16_t data) |
| 3342 | { |
| 3343 | int rval; |
| 3344 | mbx_cmd_t mc; |
| 3345 | mbx_cmd_t *mcp = &mc; |
| 3346 | |
Joe Carnuccio | f299c7c | 2015-08-04 13:37:51 -0400 | [diff] [blame] | 3347 | if (!IS_QLA25XX(vha->hw) && !IS_QLA2031(vha->hw) && |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 3348 | !IS_QLA27XX(vha->hw) && !IS_QLA28XX(vha->hw)) |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 3349 | return QLA_FUNCTION_FAILED; |
| 3350 | |
| 3351 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1182, |
| 3352 | "Entered %s.\n", __func__); |
| 3353 | |
| 3354 | mcp->mb[0] = MBC_WRITE_SERDES; |
| 3355 | mcp->mb[1] = addr; |
Andrew Vasquez | 064135e | 2015-04-09 15:00:02 -0400 | [diff] [blame] | 3356 | if (IS_QLA2031(vha->hw)) |
| 3357 | mcp->mb[2] = data & 0xff; |
| 3358 | else |
| 3359 | mcp->mb[2] = data; |
| 3360 | |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 3361 | mcp->mb[3] = 0; |
| 3362 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 3363 | mcp->in_mb = MBX_0; |
| 3364 | mcp->tov = MBX_TOV_SECONDS; |
| 3365 | mcp->flags = 0; |
| 3366 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3367 | |
| 3368 | if (rval != QLA_SUCCESS) { |
| 3369 | ql_dbg(ql_dbg_mbx, vha, 0x1183, |
| 3370 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 3371 | } else { |
| 3372 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1184, |
| 3373 | "Done %s.\n", __func__); |
| 3374 | } |
| 3375 | |
| 3376 | return rval; |
| 3377 | } |
| 3378 | |
| 3379 | int |
| 3380 | qla2x00_read_serdes_word(scsi_qla_host_t *vha, uint16_t addr, uint16_t *data) |
| 3381 | { |
| 3382 | int rval; |
| 3383 | mbx_cmd_t mc; |
| 3384 | mbx_cmd_t *mcp = &mc; |
| 3385 | |
Joe Carnuccio | f299c7c | 2015-08-04 13:37:51 -0400 | [diff] [blame] | 3386 | if (!IS_QLA25XX(vha->hw) && !IS_QLA2031(vha->hw) && |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 3387 | !IS_QLA27XX(vha->hw) && !IS_QLA28XX(vha->hw)) |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 3388 | return QLA_FUNCTION_FAILED; |
| 3389 | |
| 3390 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1185, |
| 3391 | "Entered %s.\n", __func__); |
| 3392 | |
| 3393 | mcp->mb[0] = MBC_READ_SERDES; |
| 3394 | mcp->mb[1] = addr; |
| 3395 | mcp->mb[3] = 0; |
| 3396 | mcp->out_mb = MBX_3|MBX_1|MBX_0; |
| 3397 | mcp->in_mb = MBX_1|MBX_0; |
| 3398 | mcp->tov = MBX_TOV_SECONDS; |
| 3399 | mcp->flags = 0; |
| 3400 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3401 | |
Andrew Vasquez | 064135e | 2015-04-09 15:00:02 -0400 | [diff] [blame] | 3402 | if (IS_QLA2031(vha->hw)) |
| 3403 | *data = mcp->mb[1] & 0xff; |
| 3404 | else |
| 3405 | *data = mcp->mb[1]; |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 3406 | |
| 3407 | if (rval != QLA_SUCCESS) { |
| 3408 | ql_dbg(ql_dbg_mbx, vha, 0x1186, |
| 3409 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 3410 | } else { |
| 3411 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1187, |
| 3412 | "Done %s.\n", __func__); |
| 3413 | } |
| 3414 | |
| 3415 | return rval; |
| 3416 | } |
| 3417 | |
Joe Carnuccio | e8887c5 | 2014-04-11 16:54:17 -0400 | [diff] [blame] | 3418 | int |
| 3419 | qla8044_write_serdes_word(scsi_qla_host_t *vha, uint32_t addr, uint32_t data) |
| 3420 | { |
| 3421 | int rval; |
| 3422 | mbx_cmd_t mc; |
| 3423 | mbx_cmd_t *mcp = &mc; |
| 3424 | |
| 3425 | if (!IS_QLA8044(vha->hw)) |
| 3426 | return QLA_FUNCTION_FAILED; |
| 3427 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3428 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x11a0, |
Joe Carnuccio | e8887c5 | 2014-04-11 16:54:17 -0400 | [diff] [blame] | 3429 | "Entered %s.\n", __func__); |
| 3430 | |
| 3431 | mcp->mb[0] = MBC_SET_GET_ETH_SERDES_REG; |
| 3432 | mcp->mb[1] = HCS_WRITE_SERDES; |
| 3433 | mcp->mb[3] = LSW(addr); |
| 3434 | mcp->mb[4] = MSW(addr); |
| 3435 | mcp->mb[5] = LSW(data); |
| 3436 | mcp->mb[6] = MSW(data); |
| 3437 | mcp->out_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_1|MBX_0; |
| 3438 | mcp->in_mb = MBX_0; |
| 3439 | mcp->tov = MBX_TOV_SECONDS; |
| 3440 | mcp->flags = 0; |
| 3441 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3442 | |
| 3443 | if (rval != QLA_SUCCESS) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3444 | ql_dbg(ql_dbg_mbx, vha, 0x11a1, |
Joe Carnuccio | e8887c5 | 2014-04-11 16:54:17 -0400 | [diff] [blame] | 3445 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 3446 | } else { |
| 3447 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1188, |
| 3448 | "Done %s.\n", __func__); |
| 3449 | } |
| 3450 | |
| 3451 | return rval; |
| 3452 | } |
| 3453 | |
| 3454 | int |
| 3455 | qla8044_read_serdes_word(scsi_qla_host_t *vha, uint32_t addr, uint32_t *data) |
| 3456 | { |
| 3457 | int rval; |
| 3458 | mbx_cmd_t mc; |
| 3459 | mbx_cmd_t *mcp = &mc; |
| 3460 | |
| 3461 | if (!IS_QLA8044(vha->hw)) |
| 3462 | return QLA_FUNCTION_FAILED; |
| 3463 | |
| 3464 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1189, |
| 3465 | "Entered %s.\n", __func__); |
| 3466 | |
| 3467 | mcp->mb[0] = MBC_SET_GET_ETH_SERDES_REG; |
| 3468 | mcp->mb[1] = HCS_READ_SERDES; |
| 3469 | mcp->mb[3] = LSW(addr); |
| 3470 | mcp->mb[4] = MSW(addr); |
| 3471 | mcp->out_mb = MBX_4|MBX_3|MBX_1|MBX_0; |
| 3472 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 3473 | mcp->tov = MBX_TOV_SECONDS; |
| 3474 | mcp->flags = 0; |
| 3475 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3476 | |
| 3477 | *data = mcp->mb[2] << 16 | mcp->mb[1]; |
| 3478 | |
| 3479 | if (rval != QLA_SUCCESS) { |
| 3480 | ql_dbg(ql_dbg_mbx, vha, 0x118a, |
| 3481 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 3482 | } else { |
| 3483 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x118b, |
| 3484 | "Done %s.\n", __func__); |
| 3485 | } |
| 3486 | |
| 3487 | return rval; |
| 3488 | } |
| 3489 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3490 | /** |
| 3491 | * qla2x00_set_serdes_params() - |
Bart Van Assche | 2db6228 | 2018-01-23 16:33:51 -0800 | [diff] [blame] | 3492 | * @vha: HA context |
Bart Van Assche | 807eb90 | 2018-10-18 15:45:41 -0700 | [diff] [blame] | 3493 | * @sw_em_1g: serial link options |
| 3494 | * @sw_em_2g: serial link options |
| 3495 | * @sw_em_4g: serial link options |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3496 | * |
| 3497 | * Returns |
| 3498 | */ |
| 3499 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3500 | 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] | 3501 | uint16_t sw_em_2g, uint16_t sw_em_4g) |
| 3502 | { |
| 3503 | int rval; |
| 3504 | mbx_cmd_t mc; |
| 3505 | mbx_cmd_t *mcp = &mc; |
| 3506 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3507 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109e, |
| 3508 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3509 | |
| 3510 | mcp->mb[0] = MBC_SERDES_PARAMS; |
| 3511 | mcp->mb[1] = BIT_0; |
andrew.vasquez@qlogic.com | fdbc683 | 2006-03-09 14:27:29 -0800 | [diff] [blame] | 3512 | mcp->mb[2] = sw_em_1g | BIT_15; |
| 3513 | mcp->mb[3] = sw_em_2g | BIT_15; |
| 3514 | mcp->mb[4] = sw_em_4g | BIT_15; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3515 | mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3516 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3517 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3518 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3519 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3520 | |
| 3521 | if (rval != QLA_SUCCESS) { |
| 3522 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3523 | ql_dbg(ql_dbg_mbx, vha, 0x109f, |
| 3524 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3525 | } else { |
| 3526 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3527 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a0, |
| 3528 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3529 | } |
| 3530 | |
| 3531 | return rval; |
| 3532 | } |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3533 | |
| 3534 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3535 | qla2x00_stop_firmware(scsi_qla_host_t *vha) |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3536 | { |
| 3537 | int rval; |
| 3538 | mbx_cmd_t mc; |
| 3539 | mbx_cmd_t *mcp = &mc; |
| 3540 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3541 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3542 | return QLA_FUNCTION_FAILED; |
| 3543 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3544 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a1, |
| 3545 | "Entered %s.\n", __func__); |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3546 | |
| 3547 | mcp->mb[0] = MBC_STOP_FIRMWARE; |
Andrew Vasquez | 4ba988d | 2012-02-09 11:14:06 -0800 | [diff] [blame] | 3548 | mcp->mb[1] = 0; |
| 3549 | mcp->out_mb = MBX_1|MBX_0; |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3550 | mcp->in_mb = MBX_0; |
| 3551 | mcp->tov = 5; |
| 3552 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3553 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3554 | |
| 3555 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3556 | ql_dbg(ql_dbg_mbx, vha, 0x10a2, "Failed=%x.\n", rval); |
Andrew Vasquez | b469a7c | 2009-04-06 22:33:48 -0700 | [diff] [blame] | 3557 | if (mcp->mb[0] == MBS_INVALID_COMMAND) |
| 3558 | rval = QLA_INVALID_COMMAND; |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3559 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3560 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a3, |
| 3561 | "Done %s.\n", __func__); |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3562 | } |
| 3563 | |
| 3564 | return rval; |
| 3565 | } |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3566 | |
| 3567 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3568 | 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] | 3569 | uint16_t buffers) |
| 3570 | { |
| 3571 | int rval; |
| 3572 | mbx_cmd_t mc; |
| 3573 | mbx_cmd_t *mcp = &mc; |
| 3574 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3575 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a4, |
| 3576 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3577 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3578 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3579 | return QLA_FUNCTION_FAILED; |
| 3580 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3581 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3582 | return QLA_FUNCTION_FAILED; |
| 3583 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3584 | mcp->mb[0] = MBC_TRACE_CONTROL; |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3585 | mcp->mb[1] = TC_EFT_ENABLE; |
| 3586 | mcp->mb[2] = LSW(eft_dma); |
| 3587 | mcp->mb[3] = MSW(eft_dma); |
| 3588 | mcp->mb[4] = LSW(MSD(eft_dma)); |
| 3589 | mcp->mb[5] = MSW(MSD(eft_dma)); |
| 3590 | mcp->mb[6] = buffers; |
| 3591 | mcp->mb[7] = TC_AEN_DISABLE; |
| 3592 | 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] | 3593 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3594 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [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 | 00b6bd2 | 2008-01-17 09:02:16 -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, 0x10a5, |
| 3599 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3600 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -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, 0x10a6, |
| 3603 | "Done %s.\n", __func__); |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3604 | } |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3605 | |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3606 | return rval; |
| 3607 | } |
| 3608 | |
| 3609 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3610 | qla2x00_disable_eft_trace(scsi_qla_host_t *vha) |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3611 | { |
| 3612 | int rval; |
| 3613 | mbx_cmd_t mc; |
| 3614 | mbx_cmd_t *mcp = &mc; |
| 3615 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3616 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a7, |
| 3617 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3618 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3619 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3620 | return QLA_FUNCTION_FAILED; |
| 3621 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3622 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3623 | return QLA_FUNCTION_FAILED; |
| 3624 | |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3625 | mcp->mb[0] = MBC_TRACE_CONTROL; |
| 3626 | mcp->mb[1] = TC_EFT_DISABLE; |
| 3627 | mcp->out_mb = MBX_1|MBX_0; |
| 3628 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3629 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3630 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3631 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3632 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3633 | ql_dbg(ql_dbg_mbx, vha, 0x10a8, |
| 3634 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3635 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3636 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3637 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a9, |
| 3638 | "Done %s.\n", __func__); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3639 | } |
| 3640 | |
| 3641 | return rval; |
| 3642 | } |
| 3643 | |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 3644 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3645 | 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] | 3646 | uint16_t buffers, uint16_t *mb, uint32_t *dwords) |
| 3647 | { |
| 3648 | int rval; |
| 3649 | mbx_cmd_t mc; |
| 3650 | mbx_cmd_t *mcp = &mc; |
| 3651 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3652 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10aa, |
| 3653 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3654 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3655 | if (!IS_QLA25XX(vha->hw) && !IS_QLA81XX(vha->hw) && |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 3656 | !IS_QLA83XX(vha->hw) && !IS_QLA27XX(vha->hw) && |
| 3657 | !IS_QLA28XX(vha->hw)) |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3658 | return QLA_FUNCTION_FAILED; |
| 3659 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3660 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3661 | return QLA_FUNCTION_FAILED; |
| 3662 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3663 | mcp->mb[0] = MBC_TRACE_CONTROL; |
| 3664 | mcp->mb[1] = TC_FCE_ENABLE; |
| 3665 | mcp->mb[2] = LSW(fce_dma); |
| 3666 | mcp->mb[3] = MSW(fce_dma); |
| 3667 | mcp->mb[4] = LSW(MSD(fce_dma)); |
| 3668 | mcp->mb[5] = MSW(MSD(fce_dma)); |
| 3669 | mcp->mb[6] = buffers; |
| 3670 | mcp->mb[7] = TC_AEN_DISABLE; |
| 3671 | mcp->mb[8] = 0; |
| 3672 | mcp->mb[9] = TC_FCE_DEFAULT_RX_SIZE; |
| 3673 | mcp->mb[10] = TC_FCE_DEFAULT_TX_SIZE; |
| 3674 | mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2| |
| 3675 | MBX_1|MBX_0; |
| 3676 | 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] | 3677 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3678 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3679 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3680 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3681 | ql_dbg(ql_dbg_mbx, vha, 0x10ab, |
| 3682 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3683 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3684 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3685 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ac, |
| 3686 | "Done %s.\n", __func__); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3687 | |
| 3688 | if (mb) |
| 3689 | memcpy(mb, mcp->mb, 8 * sizeof(*mb)); |
| 3690 | if (dwords) |
Andrew Vasquez | fa0926d | 2008-05-12 22:21:12 -0700 | [diff] [blame] | 3691 | *dwords = buffers; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3692 | } |
| 3693 | |
| 3694 | return rval; |
| 3695 | } |
| 3696 | |
| 3697 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3698 | 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] | 3699 | { |
| 3700 | int rval; |
| 3701 | mbx_cmd_t mc; |
| 3702 | mbx_cmd_t *mcp = &mc; |
| 3703 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3704 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ad, |
| 3705 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3706 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3707 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3708 | return QLA_FUNCTION_FAILED; |
| 3709 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3710 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3711 | return QLA_FUNCTION_FAILED; |
| 3712 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3713 | mcp->mb[0] = MBC_TRACE_CONTROL; |
| 3714 | mcp->mb[1] = TC_FCE_DISABLE; |
| 3715 | mcp->mb[2] = TC_FCE_DISABLE_TRACE; |
| 3716 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 3717 | mcp->in_mb = MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2| |
| 3718 | MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3719 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3720 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3721 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3722 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3723 | ql_dbg(ql_dbg_mbx, vha, 0x10ae, |
| 3724 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3725 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3726 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3727 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10af, |
| 3728 | "Done %s.\n", __func__); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3729 | |
| 3730 | if (wr) |
| 3731 | *wr = (uint64_t) mcp->mb[5] << 48 | |
| 3732 | (uint64_t) mcp->mb[4] << 32 | |
| 3733 | (uint64_t) mcp->mb[3] << 16 | |
| 3734 | (uint64_t) mcp->mb[2]; |
| 3735 | if (rd) |
| 3736 | *rd = (uint64_t) mcp->mb[9] << 48 | |
| 3737 | (uint64_t) mcp->mb[8] << 32 | |
| 3738 | (uint64_t) mcp->mb[7] << 16 | |
| 3739 | (uint64_t) mcp->mb[6]; |
| 3740 | } |
| 3741 | |
| 3742 | return rval; |
| 3743 | } |
| 3744 | |
| 3745 | int |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3746 | qla2x00_get_idma_speed(scsi_qla_host_t *vha, uint16_t loop_id, |
| 3747 | uint16_t *port_speed, uint16_t *mb) |
| 3748 | { |
| 3749 | int rval; |
| 3750 | mbx_cmd_t mc; |
| 3751 | mbx_cmd_t *mcp = &mc; |
| 3752 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3753 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b0, |
| 3754 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3755 | |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3756 | if (!IS_IIDMA_CAPABLE(vha->hw)) |
| 3757 | return QLA_FUNCTION_FAILED; |
| 3758 | |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3759 | mcp->mb[0] = MBC_PORT_PARAMS; |
| 3760 | mcp->mb[1] = loop_id; |
| 3761 | mcp->mb[2] = mcp->mb[3] = 0; |
| 3762 | mcp->mb[9] = vha->vp_idx; |
| 3763 | mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3764 | mcp->in_mb = MBX_3|MBX_1|MBX_0; |
| 3765 | mcp->tov = MBX_TOV_SECONDS; |
| 3766 | mcp->flags = 0; |
| 3767 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3768 | |
| 3769 | /* Return mailbox statuses. */ |
Joe Carnuccio | 2a3192a | 2019-03-12 11:08:14 -0700 | [diff] [blame] | 3770 | if (mb) { |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3771 | mb[0] = mcp->mb[0]; |
| 3772 | mb[1] = mcp->mb[1]; |
| 3773 | mb[3] = mcp->mb[3]; |
| 3774 | } |
| 3775 | |
| 3776 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3777 | ql_dbg(ql_dbg_mbx, vha, 0x10b1, "Failed=%x.\n", rval); |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3778 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3779 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b2, |
| 3780 | "Done %s.\n", __func__); |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3781 | if (port_speed) |
| 3782 | *port_speed = mcp->mb[3]; |
| 3783 | } |
| 3784 | |
| 3785 | return rval; |
| 3786 | } |
| 3787 | |
| 3788 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3789 | 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] | 3790 | uint16_t port_speed, uint16_t *mb) |
| 3791 | { |
| 3792 | int rval; |
| 3793 | mbx_cmd_t mc; |
| 3794 | mbx_cmd_t *mcp = &mc; |
| 3795 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3796 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b3, |
| 3797 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3798 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3799 | if (!IS_IIDMA_CAPABLE(vha->hw)) |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3800 | return QLA_FUNCTION_FAILED; |
| 3801 | |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3802 | mcp->mb[0] = MBC_PORT_PARAMS; |
| 3803 | mcp->mb[1] = loop_id; |
| 3804 | mcp->mb[2] = BIT_0; |
Joe Carnuccio | 2a3192a | 2019-03-12 11:08:14 -0700 | [diff] [blame] | 3805 | mcp->mb[3] = port_speed & 0x3F; |
Harish Zunjarrao | 1bb3954 | 2009-06-17 10:30:29 -0700 | [diff] [blame] | 3806 | mcp->mb[9] = vha->vp_idx; |
| 3807 | mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3808 | mcp->in_mb = MBX_3|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3809 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3810 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3811 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3812 | |
| 3813 | /* Return mailbox statuses. */ |
Joe Carnuccio | 2a3192a | 2019-03-12 11:08:14 -0700 | [diff] [blame] | 3814 | if (mb) { |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3815 | mb[0] = mcp->mb[0]; |
| 3816 | mb[1] = mcp->mb[1]; |
| 3817 | mb[3] = mcp->mb[3]; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3818 | } |
| 3819 | |
| 3820 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3821 | ql_dbg(ql_dbg_mbx, vha, 0x10b4, |
| 3822 | "Failed=%x.\n", rval); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3823 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3824 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b5, |
| 3825 | "Done %s.\n", __func__); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3826 | } |
| 3827 | |
| 3828 | return rval; |
| 3829 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3830 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3831 | void |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3832 | qla24xx_report_id_acquisition(scsi_qla_host_t *vha, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3833 | struct vp_rpt_id_entry_24xx *rptid_entry) |
| 3834 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3835 | struct qla_hw_data *ha = vha->hw; |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3836 | scsi_qla_host_t *vp = NULL; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3837 | unsigned long flags; |
Andrew Vasquez | 4ac8d4ca | 2013-02-08 01:57:58 -0500 | [diff] [blame] | 3838 | int found; |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3839 | port_id_t id; |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 3840 | struct fc_port *fcport; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3841 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3842 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b6, |
| 3843 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3844 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3845 | if (rptid_entry->entry_status != 0) |
| 3846 | return; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3847 | |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3848 | id.b.domain = rptid_entry->port_id[2]; |
| 3849 | id.b.area = rptid_entry->port_id[1]; |
| 3850 | id.b.al_pa = rptid_entry->port_id[0]; |
| 3851 | id.b.rsvd_1 = 0; |
Darren Trapp | 1763c1f | 2018-03-20 23:09:34 -0700 | [diff] [blame] | 3852 | ha->flags.n2n_ae = 0; |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3853 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3854 | if (rptid_entry->format == 0) { |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3855 | /* loop */ |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 3856 | ql_dbg(ql_dbg_async, vha, 0x10b7, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3857 | "Format 0 : Number of VPs setup %d, number of " |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3858 | "VPs acquired %d.\n", rptid_entry->vp_setup, |
| 3859 | rptid_entry->vp_acquired); |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 3860 | ql_dbg(ql_dbg_async, vha, 0x10b8, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3861 | "Primary port id %02x%02x%02x.\n", |
| 3862 | rptid_entry->port_id[2], rptid_entry->port_id[1], |
| 3863 | rptid_entry->port_id[0]); |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 3864 | ha->current_topology = ISP_CFG_NL; |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3865 | qlt_update_host_map(vha, id); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3866 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3867 | } else if (rptid_entry->format == 1) { |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3868 | /* fabric */ |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 3869 | ql_dbg(ql_dbg_async, vha, 0x10b9, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3870 | "Format 1: VP[%d] enabled - status %d - with " |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3871 | "port id %02x%02x%02x.\n", rptid_entry->vp_idx, |
| 3872 | rptid_entry->vp_status, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3873 | rptid_entry->port_id[2], rptid_entry->port_id[1], |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3874 | rptid_entry->port_id[0]); |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 3875 | ql_dbg(ql_dbg_async, vha, 0x5075, |
| 3876 | "Format 1: Remote WWPN %8phC.\n", |
| 3877 | rptid_entry->u.f1.port_name); |
| 3878 | |
| 3879 | ql_dbg(ql_dbg_async, vha, 0x5075, |
| 3880 | "Format 1: WWPN %8phC.\n", |
| 3881 | vha->port_name); |
| 3882 | |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 3883 | switch (rptid_entry->u.f1.flags & TOPO_MASK) { |
| 3884 | case TOPO_N2N: |
| 3885 | ha->current_topology = ISP_CFG_N; |
| 3886 | spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); |
Quinn Tran | 7f2a398 | 2019-09-12 11:09:09 -0700 | [diff] [blame] | 3887 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 3888 | fcport->scan_state = QLA_FCPORT_SCAN; |
| 3889 | fcport->n2n_flag = 0; |
| 3890 | } |
| 3891 | |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 3892 | fcport = qla2x00_find_fcport_by_wwpn(vha, |
| 3893 | rptid_entry->u.f1.port_name, 1); |
| 3894 | spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); |
| 3895 | |
| 3896 | if (fcport) { |
| 3897 | fcport->plogi_nack_done_deadline = jiffies + HZ; |
Quinn Tran | 7f2a398 | 2019-09-12 11:09:09 -0700 | [diff] [blame] | 3898 | fcport->dm_login_expire = jiffies + 2*HZ; |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 3899 | fcport->scan_state = QLA_FCPORT_FOUND; |
Quinn Tran | 7f2a398 | 2019-09-12 11:09:09 -0700 | [diff] [blame] | 3900 | fcport->n2n_flag = 1; |
Quinn Tran | f3f1938 | 2019-09-12 11:09:10 -0700 | [diff] [blame] | 3901 | fcport->keep_nport_handle = 1; |
Michael Hernandez | 84ed362 | 2019-09-12 11:09:12 -0700 | [diff] [blame] | 3902 | fcport->fc4_type = FS_FC4TYPE_FCP; |
Quinn Tran | 7f2a398 | 2019-09-12 11:09:09 -0700 | [diff] [blame] | 3903 | if (vha->flags.nvme_enabled) |
Michael Hernandez | 84ed362 | 2019-09-12 11:09:12 -0700 | [diff] [blame] | 3904 | fcport->fc4_type |= FS_FC4TYPE_NVME; |
Quinn Tran | 7f2a398 | 2019-09-12 11:09:09 -0700 | [diff] [blame] | 3905 | |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 3906 | switch (fcport->disc_state) { |
| 3907 | case DSC_DELETED: |
| 3908 | set_bit(RELOGIN_NEEDED, |
| 3909 | &vha->dpc_flags); |
| 3910 | break; |
| 3911 | case DSC_DELETE_PEND: |
| 3912 | break; |
| 3913 | default: |
| 3914 | qlt_schedule_sess_for_deletion(fcport); |
| 3915 | break; |
| 3916 | } |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 3917 | } else { |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 3918 | id.b24 = 0; |
| 3919 | if (wwn_to_u64(vha->port_name) > |
| 3920 | wwn_to_u64(rptid_entry->u.f1.port_name)) { |
| 3921 | vha->d_id.b24 = 0; |
| 3922 | vha->d_id.b.al_pa = 1; |
| 3923 | ha->flags.n2n_bigger = 1; |
Roman Bolshakov | af22f0c | 2019-11-25 19:57:01 +0300 | [diff] [blame] | 3924 | ha->flags.n2n_ae = 0; |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 3925 | |
| 3926 | id.b.al_pa = 2; |
| 3927 | ql_dbg(ql_dbg_async, vha, 0x5075, |
| 3928 | "Format 1: assign local id %x remote id %x\n", |
| 3929 | vha->d_id.b24, id.b24); |
| 3930 | } else { |
| 3931 | ql_dbg(ql_dbg_async, vha, 0x5075, |
| 3932 | "Format 1: Remote login - Waiting for WWPN %8phC.\n", |
| 3933 | rptid_entry->u.f1.port_name); |
| 3934 | ha->flags.n2n_bigger = 0; |
Roman Bolshakov | af22f0c | 2019-11-25 19:57:01 +0300 | [diff] [blame] | 3935 | ha->flags.n2n_ae = 1; |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 3936 | } |
| 3937 | qla24xx_post_newsess_work(vha, &id, |
| 3938 | rptid_entry->u.f1.port_name, |
| 3939 | rptid_entry->u.f1.node_name, |
| 3940 | NULL, |
Quinn Tran | 7f2a398 | 2019-09-12 11:09:09 -0700 | [diff] [blame] | 3941 | FS_FCP_IS_N2N); |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 3942 | } |
| 3943 | |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 3944 | /* if our portname is higher then initiate N2N login */ |
| 3945 | |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 3946 | set_bit(N2N_LOGIN_NEEDED, &vha->dpc_flags); |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 3947 | return; |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 3948 | break; |
| 3949 | case TOPO_FL: |
| 3950 | ha->current_topology = ISP_CFG_FL; |
| 3951 | break; |
| 3952 | case TOPO_F: |
| 3953 | ha->current_topology = ISP_CFG_F; |
| 3954 | break; |
| 3955 | default: |
| 3956 | break; |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 3957 | } |
Andrew Vasquez | 531a82d | 2009-10-13 15:16:51 -0700 | [diff] [blame] | 3958 | |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 3959 | ha->flags.gpsc_supported = 1; |
| 3960 | ha->current_topology = ISP_CFG_F; |
Sawan Chandak | 969a619 | 2016-01-27 12:03:32 -0500 | [diff] [blame] | 3961 | /* buffer to buffer credit flag */ |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3962 | vha->flags.bbcr_enable = (rptid_entry->u.f1.bbcr & 0xf) != 0; |
Sawan Chandak | 969a619 | 2016-01-27 12:03:32 -0500 | [diff] [blame] | 3963 | |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3964 | if (rptid_entry->vp_idx == 0) { |
| 3965 | if (rptid_entry->vp_status == VP_STAT_COMPL) { |
| 3966 | /* FA-WWN is only for physical port */ |
| 3967 | if (qla_ini_mode_enabled(vha) && |
| 3968 | ha->flags.fawwpn_enabled && |
| 3969 | (rptid_entry->u.f1.flags & |
Sawan Chandak | fcc5b5c | 2017-08-23 15:05:02 -0700 | [diff] [blame] | 3970 | BIT_6)) { |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3971 | memcpy(vha->port_name, |
| 3972 | rptid_entry->u.f1.port_name, |
| 3973 | WWN_SIZE); |
| 3974 | } |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 3975 | |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3976 | qlt_update_host_map(vha, id); |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 3977 | } |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3978 | |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3979 | set_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags); |
| 3980 | set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags); |
| 3981 | } else { |
| 3982 | if (rptid_entry->vp_status != VP_STAT_COMPL && |
| 3983 | rptid_entry->vp_status != VP_STAT_ID_CHG) { |
| 3984 | ql_dbg(ql_dbg_mbx, vha, 0x10ba, |
| 3985 | "Could not acquire ID for VP[%d].\n", |
| 3986 | rptid_entry->vp_idx); |
| 3987 | return; |
Andrew Vasquez | 4ac8d4ca | 2013-02-08 01:57:58 -0500 | [diff] [blame] | 3988 | } |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3989 | |
| 3990 | found = 0; |
| 3991 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 3992 | list_for_each_entry(vp, &ha->vp_list, list) { |
| 3993 | if (rptid_entry->vp_idx == vp->vp_idx) { |
| 3994 | found = 1; |
| 3995 | break; |
| 3996 | } |
| 3997 | } |
| 3998 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 3999 | |
| 4000 | if (!found) |
| 4001 | return; |
| 4002 | |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 4003 | qlt_update_host_map(vp, id); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4004 | |
| 4005 | /* |
| 4006 | * Cannot configure here as we are still sitting on the |
| 4007 | * response queue. Handle it in dpc context. |
| 4008 | */ |
| 4009 | set_bit(VP_IDX_ACQUIRED, &vp->vp_flags); |
| 4010 | set_bit(REGISTER_FC4_NEEDED, &vp->dpc_flags); |
| 4011 | set_bit(REGISTER_FDMI_NEEDED, &vp->dpc_flags); |
Andrew Vasquez | 4ac8d4ca | 2013-02-08 01:57:58 -0500 | [diff] [blame] | 4012 | } |
Andrew Vasquez | 531a82d | 2009-10-13 15:16:51 -0700 | [diff] [blame] | 4013 | set_bit(VP_DPC_NEEDED, &vha->dpc_flags); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4014 | qla2xxx_wake_dpc(vha); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4015 | } else if (rptid_entry->format == 2) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 4016 | ql_dbg(ql_dbg_async, vha, 0x505f, |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4017 | "RIDA: format 2/N2N Primary port id %02x%02x%02x.\n", |
| 4018 | rptid_entry->port_id[2], rptid_entry->port_id[1], |
| 4019 | rptid_entry->port_id[0]); |
| 4020 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 4021 | ql_dbg(ql_dbg_async, vha, 0x5075, |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4022 | "N2N: Remote WWPN %8phC.\n", |
| 4023 | rptid_entry->u.f2.port_name); |
| 4024 | |
| 4025 | /* N2N. direct connect */ |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 4026 | ha->current_topology = ISP_CFG_N; |
| 4027 | ha->flags.rida_fmt2 = 1; |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4028 | vha->d_id.b.domain = rptid_entry->port_id[2]; |
| 4029 | vha->d_id.b.area = rptid_entry->port_id[1]; |
| 4030 | vha->d_id.b.al_pa = rptid_entry->port_id[0]; |
| 4031 | |
Darren Trapp | 1763c1f | 2018-03-20 23:09:34 -0700 | [diff] [blame] | 4032 | ha->flags.n2n_ae = 1; |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4033 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 4034 | qlt_update_vp_map(vha, SET_AL_PA); |
| 4035 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 4036 | |
| 4037 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 4038 | fcport->scan_state = QLA_FCPORT_SCAN; |
Quinn Tran | 7f2a398 | 2019-09-12 11:09:09 -0700 | [diff] [blame] | 4039 | fcport->n2n_flag = 0; |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 4040 | } |
| 4041 | |
| 4042 | fcport = qla2x00_find_fcport_by_wwpn(vha, |
| 4043 | rptid_entry->u.f2.port_name, 1); |
| 4044 | |
| 4045 | if (fcport) { |
Quinn Tran | 23dd98a | 2018-08-02 13:16:45 -0700 | [diff] [blame] | 4046 | fcport->login_retry = vha->hw->login_retry_count; |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 4047 | fcport->plogi_nack_done_deadline = jiffies + HZ; |
| 4048 | fcport->scan_state = QLA_FCPORT_FOUND; |
Quinn Tran | f3f1938 | 2019-09-12 11:09:10 -0700 | [diff] [blame] | 4049 | fcport->keep_nport_handle = 1; |
Quinn Tran | 7f2a398 | 2019-09-12 11:09:09 -0700 | [diff] [blame] | 4050 | fcport->n2n_flag = 1; |
| 4051 | fcport->d_id.b.domain = |
| 4052 | rptid_entry->u.f2.remote_nport_id[2]; |
| 4053 | fcport->d_id.b.area = |
| 4054 | rptid_entry->u.f2.remote_nport_id[1]; |
| 4055 | fcport->d_id.b.al_pa = |
| 4056 | rptid_entry->u.f2.remote_nport_id[0]; |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 4057 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4058 | } |
| 4059 | } |
| 4060 | |
| 4061 | /* |
| 4062 | * qla24xx_modify_vp_config |
| 4063 | * Change VP configuration for vha |
| 4064 | * |
| 4065 | * Input: |
| 4066 | * vha = adapter block pointer. |
| 4067 | * |
| 4068 | * Returns: |
| 4069 | * qla2xxx local function return status code. |
| 4070 | * |
| 4071 | * Context: |
| 4072 | * Kernel context. |
| 4073 | */ |
| 4074 | int |
| 4075 | qla24xx_modify_vp_config(scsi_qla_host_t *vha) |
| 4076 | { |
| 4077 | int rval; |
| 4078 | struct vp_config_entry_24xx *vpmod; |
| 4079 | dma_addr_t vpmod_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4080 | struct qla_hw_data *ha = vha->hw; |
| 4081 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4082 | |
| 4083 | /* This can be called by the parent */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4084 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4085 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10bb, |
| 4086 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4087 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 4088 | vpmod = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &vpmod_dma); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4089 | if (!vpmod) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4090 | ql_log(ql_log_warn, vha, 0x10bc, |
| 4091 | "Failed to allocate modify VP IOCB.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4092 | return QLA_MEMORY_ALLOC_FAILED; |
| 4093 | } |
| 4094 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4095 | vpmod->entry_type = VP_CONFIG_IOCB_TYPE; |
| 4096 | vpmod->entry_count = 1; |
| 4097 | vpmod->command = VCT_COMMAND_MOD_ENABLE_VPS; |
| 4098 | vpmod->vp_count = 1; |
| 4099 | vpmod->vp_index1 = vha->vp_idx; |
| 4100 | vpmod->options_idx1 = BIT_3|BIT_4|BIT_5; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4101 | |
| 4102 | qlt_modify_vp_config(vha, vpmod); |
| 4103 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4104 | memcpy(vpmod->node_name_idx1, vha->node_name, WWN_SIZE); |
| 4105 | memcpy(vpmod->port_name_idx1, vha->port_name, WWN_SIZE); |
| 4106 | vpmod->entry_count = 1; |
| 4107 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4108 | rval = qla2x00_issue_iocb(base_vha, vpmod, vpmod_dma, 0); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4109 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4110 | ql_dbg(ql_dbg_mbx, vha, 0x10bd, |
| 4111 | "Failed to issue VP config IOCB (%x).\n", rval); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4112 | } else if (vpmod->comp_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4113 | ql_dbg(ql_dbg_mbx, vha, 0x10be, |
| 4114 | "Failed to complete IOCB -- error status (%x).\n", |
| 4115 | vpmod->comp_status); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4116 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 4117 | } else if (vpmod->comp_status != cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4118 | ql_dbg(ql_dbg_mbx, vha, 0x10bf, |
| 4119 | "Failed to complete IOCB -- completion status (%x).\n", |
| 4120 | le16_to_cpu(vpmod->comp_status)); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4121 | rval = QLA_FUNCTION_FAILED; |
| 4122 | } else { |
| 4123 | /* EMPTY */ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4124 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c0, |
| 4125 | "Done %s.\n", __func__); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4126 | fc_vport_set_state(vha->fc_vport, FC_VPORT_INITIALIZING); |
| 4127 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4128 | dma_pool_free(ha->s_dma_pool, vpmod, vpmod_dma); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4129 | |
| 4130 | return rval; |
| 4131 | } |
| 4132 | |
| 4133 | /* |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4134 | * qla2x00_send_change_request |
| 4135 | * Receive or disable RSCN request from fabric controller |
| 4136 | * |
| 4137 | * Input: |
| 4138 | * ha = adapter block pointer |
| 4139 | * format = registration format: |
| 4140 | * 0 - Reserved |
| 4141 | * 1 - Fabric detected registration |
| 4142 | * 2 - N_port detected registration |
| 4143 | * 3 - Full registration |
| 4144 | * FF - clear registration |
| 4145 | * vp_idx = Virtual port index |
| 4146 | * |
| 4147 | * Returns: |
| 4148 | * qla2x00 local function return status code. |
| 4149 | * |
| 4150 | * Context: |
| 4151 | * Kernel Context |
| 4152 | */ |
| 4153 | |
| 4154 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4155 | qla2x00_send_change_request(scsi_qla_host_t *vha, uint16_t format, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4156 | uint16_t vp_idx) |
| 4157 | { |
| 4158 | int rval; |
| 4159 | mbx_cmd_t mc; |
| 4160 | mbx_cmd_t *mcp = &mc; |
| 4161 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4162 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c7, |
| 4163 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4164 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4165 | mcp->mb[0] = MBC_SEND_CHANGE_REQUEST; |
| 4166 | mcp->mb[1] = format; |
| 4167 | mcp->mb[9] = vp_idx; |
| 4168 | mcp->out_mb = MBX_9|MBX_1|MBX_0; |
| 4169 | mcp->in_mb = MBX_0|MBX_1; |
| 4170 | mcp->tov = MBX_TOV_SECONDS; |
| 4171 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4172 | rval = qla2x00_mailbox_command(vha, mcp); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4173 | |
| 4174 | if (rval == QLA_SUCCESS) { |
| 4175 | if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { |
| 4176 | rval = BIT_1; |
| 4177 | } |
| 4178 | } else |
| 4179 | rval = BIT_1; |
| 4180 | |
| 4181 | return rval; |
| 4182 | } |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4183 | |
| 4184 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4185 | 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] | 4186 | uint32_t size) |
| 4187 | { |
| 4188 | int rval; |
| 4189 | mbx_cmd_t mc; |
| 4190 | mbx_cmd_t *mcp = &mc; |
| 4191 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4192 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1009, |
| 4193 | "Entered %s.\n", __func__); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4194 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4195 | if (MSW(addr) || IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4196 | mcp->mb[0] = MBC_DUMP_RISC_RAM_EXTENDED; |
| 4197 | mcp->mb[8] = MSW(addr); |
| 4198 | mcp->out_mb = MBX_8|MBX_0; |
| 4199 | } else { |
| 4200 | mcp->mb[0] = MBC_DUMP_RISC_RAM; |
| 4201 | mcp->out_mb = MBX_0; |
| 4202 | } |
| 4203 | mcp->mb[1] = LSW(addr); |
| 4204 | mcp->mb[2] = MSW(req_dma); |
| 4205 | mcp->mb[3] = LSW(req_dma); |
| 4206 | mcp->mb[6] = MSW(MSD(req_dma)); |
| 4207 | mcp->mb[7] = LSW(MSD(req_dma)); |
| 4208 | 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] | 4209 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4210 | mcp->mb[4] = MSW(size); |
| 4211 | mcp->mb[5] = LSW(size); |
| 4212 | mcp->out_mb |= MBX_5|MBX_4; |
| 4213 | } else { |
| 4214 | mcp->mb[4] = LSW(size); |
| 4215 | mcp->out_mb |= MBX_4; |
| 4216 | } |
| 4217 | |
| 4218 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 4219 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4220 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4221 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4222 | |
| 4223 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4224 | ql_dbg(ql_dbg_mbx, vha, 0x1008, |
| 4225 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4226 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4227 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1007, |
| 4228 | "Done %s.\n", __func__); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4229 | } |
| 4230 | |
| 4231 | return rval; |
| 4232 | } |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4233 | /* 84XX Support **************************************************************/ |
| 4234 | |
| 4235 | struct cs84xx_mgmt_cmd { |
| 4236 | union { |
| 4237 | struct verify_chip_entry_84xx req; |
| 4238 | struct verify_chip_rsp_84xx rsp; |
| 4239 | } p; |
| 4240 | }; |
| 4241 | |
| 4242 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4243 | qla84xx_verify_chip(struct scsi_qla_host *vha, uint16_t *status) |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4244 | { |
| 4245 | int rval, retry; |
| 4246 | struct cs84xx_mgmt_cmd *mn; |
| 4247 | dma_addr_t mn_dma; |
| 4248 | uint16_t options; |
| 4249 | unsigned long flags; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4250 | struct qla_hw_data *ha = vha->hw; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4251 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4252 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c8, |
| 4253 | "Entered %s.\n", __func__); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4254 | |
| 4255 | mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma); |
| 4256 | if (mn == NULL) { |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4257 | return QLA_MEMORY_ALLOC_FAILED; |
| 4258 | } |
| 4259 | |
| 4260 | /* Force Update? */ |
| 4261 | options = ha->cs84xx->fw_update ? VCO_FORCE_UPDATE : 0; |
| 4262 | /* Diagnostic firmware? */ |
| 4263 | /* options |= MENLO_DIAG_FW; */ |
| 4264 | /* We update the firmware with only one data sequence. */ |
| 4265 | options |= VCO_END_OF_DATA; |
| 4266 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4267 | do { |
Andrew Vasquez | c1ec1f1 | 2008-04-24 15:21:24 -0700 | [diff] [blame] | 4268 | retry = 0; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4269 | memset(mn, 0, sizeof(*mn)); |
| 4270 | mn->p.req.entry_type = VERIFY_CHIP_IOCB_TYPE; |
| 4271 | mn->p.req.entry_count = 1; |
| 4272 | mn->p.req.options = cpu_to_le16(options); |
| 4273 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4274 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111c, |
| 4275 | "Dump of Verify Request.\n"); |
| 4276 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111e, |
Joe Carnuccio | f8f97b0 | 2019-03-12 11:08:16 -0700 | [diff] [blame] | 4277 | mn, sizeof(*mn)); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4278 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4279 | rval = qla2x00_issue_iocb_timeout(vha, mn, mn_dma, 0, 120); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4280 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4281 | ql_dbg(ql_dbg_mbx, vha, 0x10cb, |
| 4282 | "Failed to issue verify IOCB (%x).\n", rval); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4283 | goto verify_done; |
| 4284 | } |
| 4285 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4286 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1110, |
| 4287 | "Dump of Verify Response.\n"); |
| 4288 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1118, |
Joe Carnuccio | f8f97b0 | 2019-03-12 11:08:16 -0700 | [diff] [blame] | 4289 | mn, sizeof(*mn)); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4290 | |
| 4291 | status[0] = le16_to_cpu(mn->p.rsp.comp_status); |
| 4292 | status[1] = status[0] == CS_VCS_CHIP_FAILURE ? |
| 4293 | le16_to_cpu(mn->p.rsp.failure_code) : 0; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4294 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ce, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4295 | "cs=%x fc=%x.\n", status[0], status[1]); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4296 | |
| 4297 | if (status[0] != CS_COMPLETE) { |
| 4298 | rval = QLA_FUNCTION_FAILED; |
| 4299 | if (!(options & VCO_DONT_UPDATE_FW)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4300 | ql_dbg(ql_dbg_mbx, vha, 0x10cf, |
| 4301 | "Firmware update failed. Retrying " |
| 4302 | "without update firmware.\n"); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4303 | options |= VCO_DONT_UPDATE_FW; |
| 4304 | options &= ~VCO_FORCE_UPDATE; |
| 4305 | retry = 1; |
| 4306 | } |
| 4307 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4308 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d0, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4309 | "Firmware updated to %x.\n", |
| 4310 | le32_to_cpu(mn->p.rsp.fw_ver)); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4311 | |
| 4312 | /* NOTE: we only update OP firmware. */ |
| 4313 | spin_lock_irqsave(&ha->cs84xx->access_lock, flags); |
| 4314 | ha->cs84xx->op_fw_version = |
| 4315 | le32_to_cpu(mn->p.rsp.fw_ver); |
| 4316 | spin_unlock_irqrestore(&ha->cs84xx->access_lock, |
| 4317 | flags); |
| 4318 | } |
| 4319 | } while (retry); |
| 4320 | |
| 4321 | verify_done: |
| 4322 | dma_pool_free(ha->s_dma_pool, mn, mn_dma); |
| 4323 | |
| 4324 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4325 | ql_dbg(ql_dbg_mbx, vha, 0x10d1, |
| 4326 | "Failed=%x.\n", rval); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4327 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4328 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d2, |
| 4329 | "Done %s.\n", __func__); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4330 | } |
| 4331 | |
| 4332 | return rval; |
| 4333 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4334 | |
| 4335 | int |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4336 | 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] | 4337 | { |
| 4338 | int rval; |
| 4339 | unsigned long flags; |
| 4340 | mbx_cmd_t mc; |
| 4341 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4342 | struct qla_hw_data *ha = vha->hw; |
| 4343 | |
Quinn Tran | 4523502 | 2018-07-18 14:29:53 -0700 | [diff] [blame] | 4344 | if (!ha->flags.fw_started) |
| 4345 | return QLA_SUCCESS; |
| 4346 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4347 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d3, |
| 4348 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4349 | |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 4350 | if (IS_SHADOW_REG_CAPABLE(ha)) |
| 4351 | req->options |= BIT_13; |
| 4352 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4353 | mcp->mb[0] = MBC_INITIALIZE_MULTIQ; |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4354 | mcp->mb[1] = req->options; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4355 | mcp->mb[2] = MSW(LSD(req->dma)); |
| 4356 | mcp->mb[3] = LSW(LSD(req->dma)); |
| 4357 | mcp->mb[6] = MSW(MSD(req->dma)); |
| 4358 | mcp->mb[7] = LSW(MSD(req->dma)); |
| 4359 | mcp->mb[5] = req->length; |
| 4360 | if (req->rsp) |
| 4361 | mcp->mb[10] = req->rsp->id; |
| 4362 | mcp->mb[12] = req->qos; |
| 4363 | mcp->mb[11] = req->vp_idx; |
| 4364 | mcp->mb[13] = req->rid; |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 4365 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4366 | mcp->mb[15] = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4367 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4368 | mcp->mb[4] = req->id; |
| 4369 | /* que in ptr index */ |
| 4370 | mcp->mb[8] = 0; |
| 4371 | /* que out ptr index */ |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 4372 | mcp->mb[9] = *req->out_ptr = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4373 | mcp->out_mb = MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8|MBX_7| |
| 4374 | MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4375 | mcp->in_mb = MBX_0; |
| 4376 | mcp->flags = MBX_DMA_OUT; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4377 | mcp->tov = MBX_TOV_SECONDS * 2; |
| 4378 | |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 4379 | if (IS_QLA81XX(ha) || IS_QLA83XX(ha) || IS_QLA27XX(ha) || |
| 4380 | IS_QLA28XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4381 | mcp->in_mb |= MBX_1; |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 4382 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) { |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4383 | mcp->out_mb |= MBX_15; |
| 4384 | /* debug q create issue in SR-IOV */ |
| 4385 | mcp->in_mb |= MBX_9 | MBX_8 | MBX_7; |
| 4386 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4387 | |
| 4388 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4389 | if (!(req->options & BIT_0)) { |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 4390 | WRT_REG_DWORD(req->req_q_in, 0); |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 4391 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha) && !IS_QLA28XX(ha)) |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 4392 | WRT_REG_DWORD(req->req_q_out, 0); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4393 | } |
| 4394 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 4395 | |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 4396 | rval = qla2x00_mailbox_command(vha, mcp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4397 | if (rval != QLA_SUCCESS) { |
| 4398 | ql_dbg(ql_dbg_mbx, vha, 0x10d4, |
| 4399 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 4400 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4401 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d5, |
| 4402 | "Done %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4403 | } |
| 4404 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4405 | return rval; |
| 4406 | } |
| 4407 | |
| 4408 | int |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4409 | 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] | 4410 | { |
| 4411 | int rval; |
| 4412 | unsigned long flags; |
| 4413 | mbx_cmd_t mc; |
| 4414 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4415 | struct qla_hw_data *ha = vha->hw; |
| 4416 | |
Quinn Tran | 4523502 | 2018-07-18 14:29:53 -0700 | [diff] [blame] | 4417 | if (!ha->flags.fw_started) |
| 4418 | return QLA_SUCCESS; |
| 4419 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4420 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d6, |
| 4421 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4422 | |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 4423 | if (IS_SHADOW_REG_CAPABLE(ha)) |
| 4424 | rsp->options |= BIT_13; |
| 4425 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4426 | mcp->mb[0] = MBC_INITIALIZE_MULTIQ; |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4427 | mcp->mb[1] = rsp->options; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4428 | mcp->mb[2] = MSW(LSD(rsp->dma)); |
| 4429 | mcp->mb[3] = LSW(LSD(rsp->dma)); |
| 4430 | mcp->mb[6] = MSW(MSD(rsp->dma)); |
| 4431 | mcp->mb[7] = LSW(MSD(rsp->dma)); |
| 4432 | mcp->mb[5] = rsp->length; |
Andrew Vasquez | 444786d | 2009-01-05 11:18:10 -0800 | [diff] [blame] | 4433 | mcp->mb[14] = rsp->msix->entry; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4434 | mcp->mb[13] = rsp->rid; |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 4435 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4436 | mcp->mb[15] = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4437 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4438 | mcp->mb[4] = rsp->id; |
| 4439 | /* que in ptr index */ |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 4440 | mcp->mb[8] = *rsp->in_ptr = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4441 | /* que out ptr index */ |
| 4442 | mcp->mb[9] = 0; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 4443 | 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] | 4444 | |MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4445 | mcp->in_mb = MBX_0; |
| 4446 | mcp->flags = MBX_DMA_OUT; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4447 | mcp->tov = MBX_TOV_SECONDS * 2; |
| 4448 | |
| 4449 | if (IS_QLA81XX(ha)) { |
| 4450 | mcp->out_mb |= MBX_12|MBX_11|MBX_10; |
| 4451 | mcp->in_mb |= MBX_1; |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 4452 | } else if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) { |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4453 | mcp->out_mb |= MBX_15|MBX_12|MBX_11|MBX_10; |
| 4454 | mcp->in_mb |= MBX_1; |
| 4455 | /* debug q create issue in SR-IOV */ |
| 4456 | mcp->in_mb |= MBX_9 | MBX_8 | MBX_7; |
| 4457 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4458 | |
| 4459 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4460 | if (!(rsp->options & BIT_0)) { |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 4461 | WRT_REG_DWORD(rsp->rsp_q_out, 0); |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 4462 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha) && !IS_QLA28XX(ha)) |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 4463 | WRT_REG_DWORD(rsp->rsp_q_in, 0); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4464 | } |
| 4465 | |
| 4466 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 4467 | |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 4468 | rval = qla2x00_mailbox_command(vha, mcp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4469 | if (rval != QLA_SUCCESS) { |
| 4470 | ql_dbg(ql_dbg_mbx, vha, 0x10d7, |
| 4471 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 4472 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4473 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d8, |
| 4474 | "Done %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4475 | } |
| 4476 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4477 | return rval; |
| 4478 | } |
| 4479 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4480 | int |
| 4481 | qla81xx_idc_ack(scsi_qla_host_t *vha, uint16_t *mb) |
| 4482 | { |
| 4483 | int rval; |
| 4484 | mbx_cmd_t mc; |
| 4485 | mbx_cmd_t *mcp = &mc; |
| 4486 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4487 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d9, |
| 4488 | "Entered %s.\n", __func__); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4489 | |
| 4490 | mcp->mb[0] = MBC_IDC_ACK; |
| 4491 | memcpy(&mcp->mb[1], mb, QLA_IDC_ACK_REGS * sizeof(uint16_t)); |
| 4492 | mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4493 | mcp->in_mb = MBX_0; |
| 4494 | mcp->tov = MBX_TOV_SECONDS; |
| 4495 | mcp->flags = 0; |
| 4496 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4497 | |
| 4498 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4499 | ql_dbg(ql_dbg_mbx, vha, 0x10da, |
| 4500 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4501 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4502 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10db, |
| 4503 | "Done %s.\n", __func__); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4504 | } |
| 4505 | |
| 4506 | return rval; |
| 4507 | } |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4508 | |
| 4509 | int |
| 4510 | qla81xx_fac_get_sector_size(scsi_qla_host_t *vha, uint32_t *sector_size) |
| 4511 | { |
| 4512 | int rval; |
| 4513 | mbx_cmd_t mc; |
| 4514 | mbx_cmd_t *mcp = &mc; |
| 4515 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4516 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10dc, |
| 4517 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4518 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4519 | if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) && |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 4520 | !IS_QLA27XX(vha->hw) && !IS_QLA28XX(vha->hw)) |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4521 | return QLA_FUNCTION_FAILED; |
| 4522 | |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4523 | mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; |
| 4524 | mcp->mb[1] = FAC_OPT_CMD_GET_SECTOR_SIZE; |
| 4525 | mcp->out_mb = MBX_1|MBX_0; |
| 4526 | mcp->in_mb = MBX_1|MBX_0; |
| 4527 | mcp->tov = MBX_TOV_SECONDS; |
| 4528 | mcp->flags = 0; |
| 4529 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4530 | |
| 4531 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4532 | ql_dbg(ql_dbg_mbx, vha, 0x10dd, |
| 4533 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 4534 | rval, mcp->mb[0], mcp->mb[1]); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4535 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4536 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10de, |
| 4537 | "Done %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4538 | *sector_size = mcp->mb[1]; |
| 4539 | } |
| 4540 | |
| 4541 | return rval; |
| 4542 | } |
| 4543 | |
| 4544 | int |
| 4545 | qla81xx_fac_do_write_enable(scsi_qla_host_t *vha, int enable) |
| 4546 | { |
| 4547 | int rval; |
| 4548 | mbx_cmd_t mc; |
| 4549 | mbx_cmd_t *mcp = &mc; |
| 4550 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4551 | if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) && |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 4552 | !IS_QLA27XX(vha->hw) && !IS_QLA28XX(vha->hw)) |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4553 | return QLA_FUNCTION_FAILED; |
| 4554 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4555 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10df, |
| 4556 | "Entered %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4557 | |
| 4558 | mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; |
| 4559 | mcp->mb[1] = enable ? FAC_OPT_CMD_WRITE_ENABLE : |
| 4560 | FAC_OPT_CMD_WRITE_PROTECT; |
| 4561 | mcp->out_mb = MBX_1|MBX_0; |
| 4562 | mcp->in_mb = MBX_1|MBX_0; |
| 4563 | mcp->tov = MBX_TOV_SECONDS; |
| 4564 | mcp->flags = 0; |
| 4565 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4566 | |
| 4567 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4568 | ql_dbg(ql_dbg_mbx, vha, 0x10e0, |
| 4569 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 4570 | rval, mcp->mb[0], mcp->mb[1]); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4571 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4572 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e1, |
| 4573 | "Done %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4574 | } |
| 4575 | |
| 4576 | return rval; |
| 4577 | } |
| 4578 | |
| 4579 | int |
| 4580 | qla81xx_fac_erase_sector(scsi_qla_host_t *vha, uint32_t start, uint32_t finish) |
| 4581 | { |
| 4582 | int rval; |
| 4583 | mbx_cmd_t mc; |
| 4584 | mbx_cmd_t *mcp = &mc; |
| 4585 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4586 | if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) && |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 4587 | !IS_QLA27XX(vha->hw) && !IS_QLA28XX(vha->hw)) |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4588 | return QLA_FUNCTION_FAILED; |
| 4589 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4590 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e2, |
| 4591 | "Entered %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4592 | |
| 4593 | mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; |
| 4594 | mcp->mb[1] = FAC_OPT_CMD_ERASE_SECTOR; |
| 4595 | mcp->mb[2] = LSW(start); |
| 4596 | mcp->mb[3] = MSW(start); |
| 4597 | mcp->mb[4] = LSW(finish); |
| 4598 | mcp->mb[5] = MSW(finish); |
| 4599 | mcp->out_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4600 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 4601 | mcp->tov = MBX_TOV_SECONDS; |
| 4602 | mcp->flags = 0; |
| 4603 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4604 | |
| 4605 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4606 | ql_dbg(ql_dbg_mbx, vha, 0x10e3, |
| 4607 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 4608 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4609 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4610 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e4, |
| 4611 | "Done %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4612 | } |
| 4613 | |
| 4614 | return rval; |
| 4615 | } |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4616 | |
| 4617 | int |
Michael Hernandez | 3f006ac | 2019-03-12 11:08:22 -0700 | [diff] [blame] | 4618 | qla81xx_fac_semaphore_access(scsi_qla_host_t *vha, int lock) |
| 4619 | { |
| 4620 | int rval = QLA_SUCCESS; |
| 4621 | mbx_cmd_t mc; |
| 4622 | mbx_cmd_t *mcp = &mc; |
| 4623 | struct qla_hw_data *ha = vha->hw; |
| 4624 | |
| 4625 | if (!IS_QLA81XX(ha) && !IS_QLA83XX(ha) && |
| 4626 | !IS_QLA27XX(ha) && !IS_QLA28XX(ha)) |
| 4627 | return rval; |
| 4628 | |
| 4629 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e2, |
| 4630 | "Entered %s.\n", __func__); |
| 4631 | |
| 4632 | mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; |
| 4633 | mcp->mb[1] = (lock ? FAC_OPT_CMD_LOCK_SEMAPHORE : |
| 4634 | FAC_OPT_CMD_UNLOCK_SEMAPHORE); |
| 4635 | mcp->out_mb = MBX_1|MBX_0; |
| 4636 | mcp->in_mb = MBX_1|MBX_0; |
| 4637 | mcp->tov = MBX_TOV_SECONDS; |
| 4638 | mcp->flags = 0; |
| 4639 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4640 | |
| 4641 | if (rval != QLA_SUCCESS) { |
| 4642 | ql_dbg(ql_dbg_mbx, vha, 0x10e3, |
| 4643 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 4644 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
| 4645 | } else { |
| 4646 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e4, |
| 4647 | "Done %s.\n", __func__); |
| 4648 | } |
| 4649 | |
| 4650 | return rval; |
| 4651 | } |
| 4652 | |
| 4653 | int |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4654 | qla81xx_restart_mpi_firmware(scsi_qla_host_t *vha) |
| 4655 | { |
| 4656 | int rval = 0; |
| 4657 | mbx_cmd_t mc; |
| 4658 | mbx_cmd_t *mcp = &mc; |
| 4659 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4660 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e5, |
| 4661 | "Entered %s.\n", __func__); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4662 | |
| 4663 | mcp->mb[0] = MBC_RESTART_MPI_FW; |
| 4664 | mcp->out_mb = MBX_0; |
| 4665 | mcp->in_mb = MBX_0|MBX_1; |
| 4666 | mcp->tov = MBX_TOV_SECONDS; |
| 4667 | mcp->flags = 0; |
| 4668 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4669 | |
| 4670 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4671 | ql_dbg(ql_dbg_mbx, vha, 0x10e6, |
| 4672 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 4673 | rval, mcp->mb[0], mcp->mb[1]); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4674 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4675 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e7, |
| 4676 | "Done %s.\n", __func__); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4677 | } |
| 4678 | |
| 4679 | return rval; |
| 4680 | } |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4681 | |
Joe Carnuccio | c46e65c | 2013-08-27 01:37:35 -0400 | [diff] [blame] | 4682 | int |
| 4683 | qla82xx_set_driver_version(scsi_qla_host_t *vha, char *version) |
| 4684 | { |
| 4685 | int rval; |
| 4686 | mbx_cmd_t mc; |
| 4687 | mbx_cmd_t *mcp = &mc; |
| 4688 | int i; |
| 4689 | int len; |
| 4690 | uint16_t *str; |
| 4691 | struct qla_hw_data *ha = vha->hw; |
| 4692 | |
| 4693 | if (!IS_P3P_TYPE(ha)) |
| 4694 | return QLA_FUNCTION_FAILED; |
| 4695 | |
| 4696 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x117b, |
| 4697 | "Entered %s.\n", __func__); |
| 4698 | |
| 4699 | str = (void *)version; |
| 4700 | len = strlen(version); |
| 4701 | |
| 4702 | mcp->mb[0] = MBC_SET_RNID_PARAMS; |
| 4703 | mcp->mb[1] = RNID_TYPE_SET_VERSION << 8; |
| 4704 | mcp->out_mb = MBX_1|MBX_0; |
| 4705 | for (i = 4; i < 16 && len; i++, str++, len -= 2) { |
| 4706 | mcp->mb[i] = cpu_to_le16p(str); |
| 4707 | mcp->out_mb |= 1<<i; |
| 4708 | } |
| 4709 | for (; i < 16; i++) { |
| 4710 | mcp->mb[i] = 0; |
| 4711 | mcp->out_mb |= 1<<i; |
| 4712 | } |
| 4713 | mcp->in_mb = MBX_1|MBX_0; |
| 4714 | mcp->tov = MBX_TOV_SECONDS; |
| 4715 | mcp->flags = 0; |
| 4716 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4717 | |
| 4718 | if (rval != QLA_SUCCESS) { |
| 4719 | ql_dbg(ql_dbg_mbx, vha, 0x117c, |
| 4720 | "Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]); |
| 4721 | } else { |
| 4722 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x117d, |
| 4723 | "Done %s.\n", __func__); |
| 4724 | } |
| 4725 | |
| 4726 | return rval; |
| 4727 | } |
| 4728 | |
| 4729 | int |
| 4730 | qla25xx_set_driver_version(scsi_qla_host_t *vha, char *version) |
| 4731 | { |
| 4732 | int rval; |
| 4733 | mbx_cmd_t mc; |
| 4734 | mbx_cmd_t *mcp = &mc; |
| 4735 | int len; |
| 4736 | uint16_t dwlen; |
| 4737 | uint8_t *str; |
| 4738 | dma_addr_t str_dma; |
| 4739 | struct qla_hw_data *ha = vha->hw; |
| 4740 | |
| 4741 | if (!IS_FWI2_CAPABLE(ha) || IS_QLA24XX_TYPE(ha) || IS_QLA81XX(ha) || |
| 4742 | IS_P3P_TYPE(ha)) |
| 4743 | return QLA_FUNCTION_FAILED; |
| 4744 | |
| 4745 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x117e, |
| 4746 | "Entered %s.\n", __func__); |
| 4747 | |
| 4748 | str = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &str_dma); |
| 4749 | if (!str) { |
| 4750 | ql_log(ql_log_warn, vha, 0x117f, |
| 4751 | "Failed to allocate driver version param.\n"); |
| 4752 | return QLA_MEMORY_ALLOC_FAILED; |
| 4753 | } |
| 4754 | |
| 4755 | memcpy(str, "\x7\x3\x11\x0", 4); |
| 4756 | dwlen = str[0]; |
| 4757 | len = dwlen * 4 - 4; |
| 4758 | memset(str + 4, 0, len); |
| 4759 | if (len > strlen(version)) |
| 4760 | len = strlen(version); |
| 4761 | memcpy(str + 4, version, len); |
| 4762 | |
| 4763 | mcp->mb[0] = MBC_SET_RNID_PARAMS; |
| 4764 | mcp->mb[1] = RNID_TYPE_SET_VERSION << 8 | dwlen; |
| 4765 | mcp->mb[2] = MSW(LSD(str_dma)); |
| 4766 | mcp->mb[3] = LSW(LSD(str_dma)); |
| 4767 | mcp->mb[6] = MSW(MSD(str_dma)); |
| 4768 | mcp->mb[7] = LSW(MSD(str_dma)); |
| 4769 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4770 | mcp->in_mb = MBX_1|MBX_0; |
| 4771 | mcp->tov = MBX_TOV_SECONDS; |
| 4772 | mcp->flags = 0; |
| 4773 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4774 | |
| 4775 | if (rval != QLA_SUCCESS) { |
| 4776 | ql_dbg(ql_dbg_mbx, vha, 0x1180, |
| 4777 | "Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]); |
| 4778 | } else { |
| 4779 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1181, |
| 4780 | "Done %s.\n", __func__); |
| 4781 | } |
| 4782 | |
| 4783 | dma_pool_free(ha->s_dma_pool, str, str_dma); |
| 4784 | |
| 4785 | return rval; |
| 4786 | } |
| 4787 | |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 4788 | int |
| 4789 | qla24xx_get_port_login_templ(scsi_qla_host_t *vha, dma_addr_t buf_dma, |
| 4790 | void *buf, uint16_t bufsiz) |
| 4791 | { |
| 4792 | int rval, i; |
| 4793 | mbx_cmd_t mc; |
| 4794 | mbx_cmd_t *mcp = &mc; |
| 4795 | uint32_t *bp; |
| 4796 | |
| 4797 | if (!IS_FWI2_CAPABLE(vha->hw)) |
| 4798 | return QLA_FUNCTION_FAILED; |
| 4799 | |
| 4800 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1159, |
| 4801 | "Entered %s.\n", __func__); |
| 4802 | |
| 4803 | mcp->mb[0] = MBC_GET_RNID_PARAMS; |
| 4804 | mcp->mb[1] = RNID_TYPE_PORT_LOGIN << 8; |
| 4805 | mcp->mb[2] = MSW(buf_dma); |
| 4806 | mcp->mb[3] = LSW(buf_dma); |
| 4807 | mcp->mb[6] = MSW(MSD(buf_dma)); |
| 4808 | mcp->mb[7] = LSW(MSD(buf_dma)); |
| 4809 | mcp->mb[8] = bufsiz/4; |
| 4810 | mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4811 | mcp->in_mb = MBX_1|MBX_0; |
| 4812 | mcp->tov = MBX_TOV_SECONDS; |
| 4813 | mcp->flags = 0; |
| 4814 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4815 | |
| 4816 | if (rval != QLA_SUCCESS) { |
| 4817 | ql_dbg(ql_dbg_mbx, vha, 0x115a, |
| 4818 | "Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]); |
| 4819 | } else { |
| 4820 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x115b, |
| 4821 | "Done %s.\n", __func__); |
| 4822 | bp = (uint32_t *) buf; |
| 4823 | for (i = 0; i < (bufsiz-4)/4; i++, bp++) |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 4824 | *bp = le32_to_cpu(*bp); |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 4825 | } |
| 4826 | |
| 4827 | return rval; |
| 4828 | } |
| 4829 | |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 4830 | static int |
| 4831 | qla2x00_read_asic_temperature(scsi_qla_host_t *vha, uint16_t *temp) |
| 4832 | { |
| 4833 | int rval; |
| 4834 | mbx_cmd_t mc; |
| 4835 | mbx_cmd_t *mcp = &mc; |
| 4836 | |
| 4837 | if (!IS_FWI2_CAPABLE(vha->hw)) |
| 4838 | return QLA_FUNCTION_FAILED; |
| 4839 | |
| 4840 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1159, |
| 4841 | "Entered %s.\n", __func__); |
| 4842 | |
| 4843 | mcp->mb[0] = MBC_GET_RNID_PARAMS; |
| 4844 | mcp->mb[1] = RNID_TYPE_ASIC_TEMP << 8; |
| 4845 | mcp->out_mb = MBX_1|MBX_0; |
| 4846 | mcp->in_mb = MBX_1|MBX_0; |
| 4847 | mcp->tov = MBX_TOV_SECONDS; |
| 4848 | mcp->flags = 0; |
| 4849 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4850 | *temp = mcp->mb[1]; |
| 4851 | |
| 4852 | if (rval != QLA_SUCCESS) { |
| 4853 | ql_dbg(ql_dbg_mbx, vha, 0x115a, |
| 4854 | "Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]); |
| 4855 | } else { |
| 4856 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x115b, |
| 4857 | "Done %s.\n", __func__); |
| 4858 | } |
| 4859 | |
| 4860 | return rval; |
| 4861 | } |
| 4862 | |
Joe Carnuccio | 3a11711 | 2013-02-08 01:58:00 -0500 | [diff] [blame] | 4863 | int |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4864 | qla2x00_read_sfp(scsi_qla_host_t *vha, dma_addr_t sfp_dma, uint8_t *sfp, |
| 4865 | uint16_t dev, uint16_t off, uint16_t len, uint16_t opt) |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4866 | { |
| 4867 | int rval; |
| 4868 | mbx_cmd_t mc; |
| 4869 | mbx_cmd_t *mcp = &mc; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4870 | struct qla_hw_data *ha = vha->hw; |
| 4871 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4872 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e8, |
| 4873 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4874 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4875 | if (!IS_FWI2_CAPABLE(ha)) |
| 4876 | return QLA_FUNCTION_FAILED; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4877 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4878 | if (len == 1) |
| 4879 | opt |= BIT_0; |
| 4880 | |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4881 | mcp->mb[0] = MBC_READ_SFP; |
| 4882 | mcp->mb[1] = dev; |
| 4883 | mcp->mb[2] = MSW(sfp_dma); |
| 4884 | mcp->mb[3] = LSW(sfp_dma); |
| 4885 | mcp->mb[6] = MSW(MSD(sfp_dma)); |
| 4886 | mcp->mb[7] = LSW(MSD(sfp_dma)); |
| 4887 | mcp->mb[8] = len; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4888 | mcp->mb[9] = off; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4889 | mcp->mb[10] = opt; |
| 4890 | 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] | 4891 | mcp->in_mb = MBX_1|MBX_0; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4892 | mcp->tov = MBX_TOV_SECONDS; |
| 4893 | mcp->flags = 0; |
| 4894 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4895 | |
| 4896 | if (opt & BIT_0) |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4897 | *sfp = mcp->mb[1]; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4898 | |
| 4899 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4900 | ql_dbg(ql_dbg_mbx, vha, 0x10e9, |
| 4901 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Joe Carnuccio | 2a3192a | 2019-03-12 11:08:14 -0700 | [diff] [blame] | 4902 | if (mcp->mb[0] == MBS_COMMAND_ERROR && mcp->mb[1] == 0x22) { |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 4903 | /* sfp is not there */ |
| 4904 | rval = QLA_INTERFACE_ERROR; |
Joe Carnuccio | 2a3192a | 2019-03-12 11:08:14 -0700 | [diff] [blame] | 4905 | } |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4906 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4907 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ea, |
| 4908 | "Done %s.\n", __func__); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4909 | } |
| 4910 | |
| 4911 | return rval; |
| 4912 | } |
| 4913 | |
| 4914 | int |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4915 | qla2x00_write_sfp(scsi_qla_host_t *vha, dma_addr_t sfp_dma, uint8_t *sfp, |
| 4916 | uint16_t dev, uint16_t off, uint16_t len, uint16_t opt) |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4917 | { |
| 4918 | int rval; |
| 4919 | mbx_cmd_t mc; |
| 4920 | mbx_cmd_t *mcp = &mc; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4921 | struct qla_hw_data *ha = vha->hw; |
| 4922 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4923 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10eb, |
| 4924 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4925 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4926 | if (!IS_FWI2_CAPABLE(ha)) |
| 4927 | return QLA_FUNCTION_FAILED; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4928 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4929 | if (len == 1) |
| 4930 | opt |= BIT_0; |
| 4931 | |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4932 | if (opt & BIT_0) |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4933 | len = *sfp; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4934 | |
| 4935 | mcp->mb[0] = MBC_WRITE_SFP; |
| 4936 | mcp->mb[1] = dev; |
| 4937 | mcp->mb[2] = MSW(sfp_dma); |
| 4938 | mcp->mb[3] = LSW(sfp_dma); |
| 4939 | mcp->mb[6] = MSW(MSD(sfp_dma)); |
| 4940 | mcp->mb[7] = LSW(MSD(sfp_dma)); |
| 4941 | mcp->mb[8] = len; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4942 | mcp->mb[9] = off; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4943 | mcp->mb[10] = opt; |
| 4944 | 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] | 4945 | mcp->in_mb = MBX_1|MBX_0; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4946 | mcp->tov = MBX_TOV_SECONDS; |
| 4947 | mcp->flags = 0; |
| 4948 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4949 | |
| 4950 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4951 | ql_dbg(ql_dbg_mbx, vha, 0x10ec, |
| 4952 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4953 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4954 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ed, |
| 4955 | "Done %s.\n", __func__); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4956 | } |
| 4957 | |
| 4958 | return rval; |
| 4959 | } |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4960 | |
| 4961 | int |
| 4962 | qla2x00_get_xgmac_stats(scsi_qla_host_t *vha, dma_addr_t stats_dma, |
| 4963 | uint16_t size_in_bytes, uint16_t *actual_size) |
| 4964 | { |
| 4965 | int rval; |
| 4966 | mbx_cmd_t mc; |
| 4967 | mbx_cmd_t *mcp = &mc; |
| 4968 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4969 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ee, |
| 4970 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4971 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4972 | if (!IS_CNA_CAPABLE(vha->hw)) |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4973 | return QLA_FUNCTION_FAILED; |
| 4974 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4975 | mcp->mb[0] = MBC_GET_XGMAC_STATS; |
| 4976 | mcp->mb[2] = MSW(stats_dma); |
| 4977 | mcp->mb[3] = LSW(stats_dma); |
| 4978 | mcp->mb[6] = MSW(MSD(stats_dma)); |
| 4979 | mcp->mb[7] = LSW(MSD(stats_dma)); |
| 4980 | mcp->mb[8] = size_in_bytes >> 2; |
| 4981 | mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; |
| 4982 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 4983 | mcp->tov = MBX_TOV_SECONDS; |
| 4984 | mcp->flags = 0; |
| 4985 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4986 | |
| 4987 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4988 | ql_dbg(ql_dbg_mbx, vha, 0x10ef, |
| 4989 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 4990 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4991 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4992 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f0, |
| 4993 | "Done %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4994 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4995 | |
| 4996 | *actual_size = mcp->mb[2] << 2; |
| 4997 | } |
| 4998 | |
| 4999 | return rval; |
| 5000 | } |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 5001 | |
| 5002 | int |
| 5003 | qla2x00_get_dcbx_params(scsi_qla_host_t *vha, dma_addr_t tlv_dma, |
| 5004 | uint16_t size) |
| 5005 | { |
| 5006 | int rval; |
| 5007 | mbx_cmd_t mc; |
| 5008 | mbx_cmd_t *mcp = &mc; |
| 5009 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5010 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f1, |
| 5011 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5012 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5013 | if (!IS_CNA_CAPABLE(vha->hw)) |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 5014 | return QLA_FUNCTION_FAILED; |
| 5015 | |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 5016 | mcp->mb[0] = MBC_GET_DCBX_PARAMS; |
| 5017 | mcp->mb[1] = 0; |
| 5018 | mcp->mb[2] = MSW(tlv_dma); |
| 5019 | mcp->mb[3] = LSW(tlv_dma); |
| 5020 | mcp->mb[6] = MSW(MSD(tlv_dma)); |
| 5021 | mcp->mb[7] = LSW(MSD(tlv_dma)); |
| 5022 | mcp->mb[8] = size; |
| 5023 | mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5024 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 5025 | mcp->tov = MBX_TOV_SECONDS; |
| 5026 | mcp->flags = 0; |
| 5027 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5028 | |
| 5029 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5030 | ql_dbg(ql_dbg_mbx, vha, 0x10f2, |
| 5031 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 5032 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 5033 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5034 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f3, |
| 5035 | "Done %s.\n", __func__); |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 5036 | } |
| 5037 | |
| 5038 | return rval; |
| 5039 | } |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5040 | |
| 5041 | int |
| 5042 | qla2x00_read_ram_word(scsi_qla_host_t *vha, uint32_t risc_addr, uint32_t *data) |
| 5043 | { |
| 5044 | int rval; |
| 5045 | mbx_cmd_t mc; |
| 5046 | mbx_cmd_t *mcp = &mc; |
| 5047 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5048 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f4, |
| 5049 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5050 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5051 | if (!IS_FWI2_CAPABLE(vha->hw)) |
| 5052 | return QLA_FUNCTION_FAILED; |
| 5053 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5054 | mcp->mb[0] = MBC_READ_RAM_EXTENDED; |
| 5055 | mcp->mb[1] = LSW(risc_addr); |
| 5056 | mcp->mb[8] = MSW(risc_addr); |
| 5057 | mcp->out_mb = MBX_8|MBX_1|MBX_0; |
| 5058 | mcp->in_mb = MBX_3|MBX_2|MBX_0; |
| 5059 | mcp->tov = 30; |
| 5060 | mcp->flags = 0; |
| 5061 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5062 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5063 | ql_dbg(ql_dbg_mbx, vha, 0x10f5, |
| 5064 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5065 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5066 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f6, |
| 5067 | "Done %s.\n", __func__); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5068 | *data = mcp->mb[3] << 16 | mcp->mb[2]; |
| 5069 | } |
| 5070 | |
| 5071 | return rval; |
| 5072 | } |
| 5073 | |
| 5074 | int |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5075 | qla2x00_loopback_test(scsi_qla_host_t *vha, struct msg_echo_lb *mreq, |
| 5076 | uint16_t *mresp) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5077 | { |
| 5078 | int rval; |
| 5079 | mbx_cmd_t mc; |
| 5080 | mbx_cmd_t *mcp = &mc; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5081 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5082 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f7, |
| 5083 | "Entered %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5084 | |
| 5085 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 5086 | mcp->mb[0] = MBC_DIAGNOSTIC_LOOP_BACK; |
| 5087 | mcp->mb[1] = mreq->options | BIT_6; // BIT_6 specifies 64 bit addressing |
| 5088 | |
| 5089 | /* transfer count */ |
| 5090 | mcp->mb[10] = LSW(mreq->transfer_size); |
| 5091 | mcp->mb[11] = MSW(mreq->transfer_size); |
| 5092 | |
| 5093 | /* send data address */ |
| 5094 | mcp->mb[14] = LSW(mreq->send_dma); |
| 5095 | mcp->mb[15] = MSW(mreq->send_dma); |
| 5096 | mcp->mb[20] = LSW(MSD(mreq->send_dma)); |
| 5097 | mcp->mb[21] = MSW(MSD(mreq->send_dma)); |
| 5098 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 5099 | /* receive data address */ |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5100 | mcp->mb[16] = LSW(mreq->rcv_dma); |
| 5101 | mcp->mb[17] = MSW(mreq->rcv_dma); |
| 5102 | mcp->mb[6] = LSW(MSD(mreq->rcv_dma)); |
| 5103 | mcp->mb[7] = MSW(MSD(mreq->rcv_dma)); |
| 5104 | |
| 5105 | /* Iteration count */ |
Joe Carnuccio | 1b98b42 | 2013-03-28 08:21:26 -0400 | [diff] [blame] | 5106 | mcp->mb[18] = LSW(mreq->iteration_count); |
| 5107 | mcp->mb[19] = MSW(mreq->iteration_count); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5108 | |
| 5109 | mcp->out_mb = MBX_21|MBX_20|MBX_19|MBX_18|MBX_17|MBX_16|MBX_15| |
| 5110 | 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] | 5111 | if (IS_CNA_CAPABLE(vha->hw)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5112 | mcp->out_mb |= MBX_2; |
| 5113 | mcp->in_mb = MBX_19|MBX_18|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5114 | |
| 5115 | mcp->buf_size = mreq->transfer_size; |
| 5116 | mcp->tov = MBX_TOV_SECONDS; |
| 5117 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 5118 | |
| 5119 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5120 | |
| 5121 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5122 | ql_dbg(ql_dbg_mbx, vha, 0x10f8, |
| 5123 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[3]=%x mb[18]=%x " |
| 5124 | "mb[19]=%x.\n", rval, mcp->mb[0], mcp->mb[1], mcp->mb[2], |
| 5125 | mcp->mb[3], mcp->mb[18], mcp->mb[19]); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5126 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5127 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f9, |
| 5128 | "Done %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5129 | } |
| 5130 | |
| 5131 | /* Copy mailbox information */ |
| 5132 | memcpy( mresp, mcp->mb, 64); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5133 | return rval; |
| 5134 | } |
| 5135 | |
| 5136 | int |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5137 | qla2x00_echo_test(scsi_qla_host_t *vha, struct msg_echo_lb *mreq, |
| 5138 | uint16_t *mresp) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5139 | { |
| 5140 | int rval; |
| 5141 | mbx_cmd_t mc; |
| 5142 | mbx_cmd_t *mcp = &mc; |
| 5143 | struct qla_hw_data *ha = vha->hw; |
| 5144 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5145 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10fa, |
| 5146 | "Entered %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5147 | |
| 5148 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 5149 | mcp->mb[0] = MBC_DIAGNOSTIC_ECHO; |
Joe Carnuccio | 1d63496 | 2017-05-24 18:06:22 -0700 | [diff] [blame] | 5150 | /* BIT_6 specifies 64bit address */ |
| 5151 | mcp->mb[1] = mreq->options | BIT_15 | BIT_6; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5152 | if (IS_CNA_CAPABLE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5153 | mcp->mb[2] = vha->fcoe_fcf_idx; |
| 5154 | } |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5155 | mcp->mb[16] = LSW(mreq->rcv_dma); |
| 5156 | mcp->mb[17] = MSW(mreq->rcv_dma); |
| 5157 | mcp->mb[6] = LSW(MSD(mreq->rcv_dma)); |
| 5158 | mcp->mb[7] = MSW(MSD(mreq->rcv_dma)); |
| 5159 | |
| 5160 | mcp->mb[10] = LSW(mreq->transfer_size); |
| 5161 | |
| 5162 | mcp->mb[14] = LSW(mreq->send_dma); |
| 5163 | mcp->mb[15] = MSW(mreq->send_dma); |
| 5164 | mcp->mb[20] = LSW(MSD(mreq->send_dma)); |
| 5165 | mcp->mb[21] = MSW(MSD(mreq->send_dma)); |
| 5166 | |
| 5167 | mcp->out_mb = MBX_21|MBX_20|MBX_17|MBX_16|MBX_15| |
| 5168 | MBX_14|MBX_10|MBX_7|MBX_6|MBX_1|MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5169 | if (IS_CNA_CAPABLE(ha)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5170 | mcp->out_mb |= MBX_2; |
| 5171 | |
| 5172 | mcp->in_mb = MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5173 | if (IS_QLA24XX_TYPE(ha) || IS_QLA25XX(ha) || |
| 5174 | IS_CNA_CAPABLE(ha) || IS_QLA2031(ha)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5175 | mcp->in_mb |= MBX_1; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5176 | if (IS_CNA_CAPABLE(ha) || IS_QLA2031(ha)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5177 | mcp->in_mb |= MBX_3; |
| 5178 | |
| 5179 | mcp->tov = MBX_TOV_SECONDS; |
| 5180 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 5181 | mcp->buf_size = mreq->transfer_size; |
| 5182 | |
| 5183 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5184 | |
| 5185 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5186 | ql_dbg(ql_dbg_mbx, vha, 0x10fb, |
| 5187 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 5188 | rval, mcp->mb[0], mcp->mb[1]); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5189 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5190 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10fc, |
| 5191 | "Done %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5192 | } |
| 5193 | |
| 5194 | /* Copy mailbox information */ |
Giridhar Malavali | 6dbdda4 | 2010-09-03 15:20:49 -0700 | [diff] [blame] | 5195 | memcpy(mresp, mcp->mb, 64); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5196 | return rval; |
| 5197 | } |
Giridhar Malavali | 6dbdda4 | 2010-09-03 15:20:49 -0700 | [diff] [blame] | 5198 | |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5199 | int |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5200 | qla84xx_reset_chip(scsi_qla_host_t *vha, uint16_t enable_diagnostic) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5201 | { |
| 5202 | int rval; |
| 5203 | mbx_cmd_t mc; |
| 5204 | mbx_cmd_t *mcp = &mc; |
| 5205 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5206 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10fd, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5207 | "Entered %s enable_diag=%d.\n", __func__, enable_diagnostic); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5208 | |
| 5209 | mcp->mb[0] = MBC_ISP84XX_RESET; |
| 5210 | mcp->mb[1] = enable_diagnostic; |
| 5211 | mcp->out_mb = MBX_1|MBX_0; |
| 5212 | mcp->in_mb = MBX_1|MBX_0; |
| 5213 | mcp->tov = MBX_TOV_SECONDS; |
| 5214 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5215 | rval = qla2x00_mailbox_command(vha, mcp); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5216 | |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5217 | if (rval != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5218 | ql_dbg(ql_dbg_mbx, vha, 0x10fe, "Failed=%x.\n", rval); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5219 | else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5220 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ff, |
| 5221 | "Done %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5222 | |
| 5223 | return rval; |
| 5224 | } |
| 5225 | |
| 5226 | int |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5227 | qla2x00_write_ram_word(scsi_qla_host_t *vha, uint32_t risc_addr, uint32_t data) |
| 5228 | { |
| 5229 | int rval; |
| 5230 | mbx_cmd_t mc; |
| 5231 | mbx_cmd_t *mcp = &mc; |
| 5232 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5233 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1100, |
| 5234 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5235 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5236 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | 6c452a4 | 2010-03-19 17:04:02 -0700 | [diff] [blame] | 5237 | return QLA_FUNCTION_FAILED; |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5238 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5239 | mcp->mb[0] = MBC_WRITE_RAM_WORD_EXTENDED; |
| 5240 | mcp->mb[1] = LSW(risc_addr); |
| 5241 | mcp->mb[2] = LSW(data); |
| 5242 | mcp->mb[3] = MSW(data); |
| 5243 | mcp->mb[8] = MSW(risc_addr); |
| 5244 | mcp->out_mb = MBX_8|MBX_3|MBX_2|MBX_1|MBX_0; |
Joe Carnuccio | 2a3192a | 2019-03-12 11:08:14 -0700 | [diff] [blame] | 5245 | mcp->in_mb = MBX_1|MBX_0; |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5246 | mcp->tov = 30; |
| 5247 | mcp->flags = 0; |
| 5248 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5249 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5250 | ql_dbg(ql_dbg_mbx, vha, 0x1101, |
Joe Carnuccio | 2a3192a | 2019-03-12 11:08:14 -0700 | [diff] [blame] | 5251 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 5252 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5253 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5254 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1102, |
| 5255 | "Done %s.\n", __func__); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5256 | } |
| 5257 | |
| 5258 | return rval; |
| 5259 | } |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5260 | |
| 5261 | int |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 5262 | qla81xx_write_mpi_register(scsi_qla_host_t *vha, uint16_t *mb) |
| 5263 | { |
| 5264 | int rval; |
| 5265 | uint32_t stat, timer; |
| 5266 | uint16_t mb0 = 0; |
| 5267 | struct qla_hw_data *ha = vha->hw; |
| 5268 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 5269 | |
| 5270 | rval = QLA_SUCCESS; |
| 5271 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5272 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1103, |
| 5273 | "Entered %s.\n", __func__); |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 5274 | |
| 5275 | clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
| 5276 | |
| 5277 | /* Write the MBC data to the registers */ |
| 5278 | WRT_REG_WORD(®->mailbox0, MBC_WRITE_MPI_REGISTER); |
| 5279 | WRT_REG_WORD(®->mailbox1, mb[0]); |
| 5280 | WRT_REG_WORD(®->mailbox2, mb[1]); |
| 5281 | WRT_REG_WORD(®->mailbox3, mb[2]); |
| 5282 | WRT_REG_WORD(®->mailbox4, mb[3]); |
| 5283 | |
| 5284 | WRT_REG_DWORD(®->hccr, HCCRX_SET_HOST_INT); |
| 5285 | |
| 5286 | /* Poll for MBC interrupt */ |
| 5287 | for (timer = 6000000; timer; timer--) { |
| 5288 | /* Check for pending interrupts. */ |
| 5289 | stat = RD_REG_DWORD(®->host_status); |
| 5290 | if (stat & HSRX_RISC_INT) { |
| 5291 | stat &= 0xff; |
| 5292 | |
| 5293 | if (stat == 0x1 || stat == 0x2 || |
| 5294 | stat == 0x10 || stat == 0x11) { |
| 5295 | set_bit(MBX_INTERRUPT, |
| 5296 | &ha->mbx_cmd_flags); |
| 5297 | mb0 = RD_REG_WORD(®->mailbox0); |
| 5298 | WRT_REG_DWORD(®->hccr, |
| 5299 | HCCRX_CLR_RISC_INT); |
| 5300 | RD_REG_DWORD(®->hccr); |
| 5301 | break; |
| 5302 | } |
| 5303 | } |
| 5304 | udelay(5); |
| 5305 | } |
| 5306 | |
| 5307 | if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) |
| 5308 | rval = mb0 & MBS_MASK; |
| 5309 | else |
| 5310 | rval = QLA_FUNCTION_FAILED; |
| 5311 | |
| 5312 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5313 | ql_dbg(ql_dbg_mbx, vha, 0x1104, |
| 5314 | "Failed=%x mb[0]=%x.\n", rval, mb[0]); |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 5315 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5316 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1105, |
| 5317 | "Done %s.\n", __func__); |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 5318 | } |
| 5319 | |
| 5320 | return rval; |
| 5321 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5322 | |
Anil Gurumurthy | 4910b52 | 2019-02-15 14:37:17 -0800 | [diff] [blame] | 5323 | /* Set the specified data rate */ |
| 5324 | int |
| 5325 | qla2x00_set_data_rate(scsi_qla_host_t *vha, uint16_t mode) |
| 5326 | { |
| 5327 | int rval; |
| 5328 | mbx_cmd_t mc; |
| 5329 | mbx_cmd_t *mcp = &mc; |
| 5330 | struct qla_hw_data *ha = vha->hw; |
| 5331 | uint16_t val; |
| 5332 | |
| 5333 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1106, |
| 5334 | "Entered %s speed:0x%x mode:0x%x.\n", __func__, ha->set_data_rate, |
| 5335 | mode); |
| 5336 | |
| 5337 | if (!IS_FWI2_CAPABLE(ha)) |
| 5338 | return QLA_FUNCTION_FAILED; |
| 5339 | |
| 5340 | memset(mcp, 0, sizeof(*mcp)); |
| 5341 | switch (ha->set_data_rate) { |
| 5342 | case PORT_SPEED_AUTO: |
| 5343 | case PORT_SPEED_4GB: |
| 5344 | case PORT_SPEED_8GB: |
| 5345 | case PORT_SPEED_16GB: |
| 5346 | case PORT_SPEED_32GB: |
| 5347 | val = ha->set_data_rate; |
| 5348 | break; |
| 5349 | default: |
| 5350 | ql_log(ql_log_warn, vha, 0x1199, |
| 5351 | "Unrecognized speed setting:%d. Setting Autoneg\n", |
| 5352 | ha->set_data_rate); |
| 5353 | val = ha->set_data_rate = PORT_SPEED_AUTO; |
| 5354 | break; |
| 5355 | } |
| 5356 | |
| 5357 | mcp->mb[0] = MBC_DATA_RATE; |
| 5358 | mcp->mb[1] = mode; |
| 5359 | mcp->mb[2] = val; |
| 5360 | |
| 5361 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 5362 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 5363 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) |
Anil Gurumurthy | 4910b52 | 2019-02-15 14:37:17 -0800 | [diff] [blame] | 5364 | mcp->in_mb |= MBX_4|MBX_3; |
| 5365 | mcp->tov = MBX_TOV_SECONDS; |
| 5366 | mcp->flags = 0; |
| 5367 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5368 | if (rval != QLA_SUCCESS) { |
| 5369 | ql_dbg(ql_dbg_mbx, vha, 0x1107, |
| 5370 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5371 | } else { |
| 5372 | if (mcp->mb[1] != 0x7) |
| 5373 | ql_dbg(ql_dbg_mbx, vha, 0x1179, |
| 5374 | "Speed set:0x%x\n", mcp->mb[1]); |
| 5375 | |
| 5376 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1108, |
| 5377 | "Done %s.\n", __func__); |
| 5378 | } |
| 5379 | |
| 5380 | return rval; |
| 5381 | } |
| 5382 | |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 5383 | int |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5384 | qla2x00_get_data_rate(scsi_qla_host_t *vha) |
| 5385 | { |
| 5386 | int rval; |
| 5387 | mbx_cmd_t mc; |
| 5388 | mbx_cmd_t *mcp = &mc; |
| 5389 | struct qla_hw_data *ha = vha->hw; |
| 5390 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5391 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1106, |
| 5392 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5393 | |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5394 | if (!IS_FWI2_CAPABLE(ha)) |
| 5395 | return QLA_FUNCTION_FAILED; |
| 5396 | |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5397 | mcp->mb[0] = MBC_DATA_RATE; |
Anil Gurumurthy | 4910b52 | 2019-02-15 14:37:17 -0800 | [diff] [blame] | 5398 | mcp->mb[1] = QLA_GET_DATA_RATE; |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5399 | mcp->out_mb = MBX_1|MBX_0; |
| 5400 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 5401 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5402 | mcp->in_mb |= MBX_3; |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5403 | mcp->tov = MBX_TOV_SECONDS; |
| 5404 | mcp->flags = 0; |
| 5405 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5406 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5407 | ql_dbg(ql_dbg_mbx, vha, 0x1107, |
| 5408 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5409 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5410 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1108, |
| 5411 | "Done %s.\n", __func__); |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5412 | if (mcp->mb[1] != 0x7) |
| 5413 | ha->link_data_rate = mcp->mb[1]; |
| 5414 | } |
| 5415 | |
| 5416 | return rval; |
| 5417 | } |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5418 | |
| 5419 | int |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5420 | qla81xx_get_port_config(scsi_qla_host_t *vha, uint16_t *mb) |
| 5421 | { |
| 5422 | int rval; |
| 5423 | mbx_cmd_t mc; |
| 5424 | mbx_cmd_t *mcp = &mc; |
| 5425 | struct qla_hw_data *ha = vha->hw; |
| 5426 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5427 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1109, |
| 5428 | "Entered %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5429 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5430 | if (!IS_QLA81XX(ha) && !IS_QLA83XX(ha) && !IS_QLA8044(ha) && |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 5431 | !IS_QLA27XX(ha) && !IS_QLA28XX(ha)) |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5432 | return QLA_FUNCTION_FAILED; |
| 5433 | mcp->mb[0] = MBC_GET_PORT_CONFIG; |
| 5434 | mcp->out_mb = MBX_0; |
| 5435 | mcp->in_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5436 | mcp->tov = MBX_TOV_SECONDS; |
| 5437 | mcp->flags = 0; |
| 5438 | |
| 5439 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5440 | |
| 5441 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5442 | ql_dbg(ql_dbg_mbx, vha, 0x110a, |
| 5443 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5444 | } else { |
| 5445 | /* Copy all bits to preserve original value */ |
| 5446 | memcpy(mb, &mcp->mb[1], sizeof(uint16_t) * 4); |
| 5447 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5448 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110b, |
| 5449 | "Done %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5450 | } |
| 5451 | return rval; |
| 5452 | } |
| 5453 | |
| 5454 | int |
| 5455 | qla81xx_set_port_config(scsi_qla_host_t *vha, uint16_t *mb) |
| 5456 | { |
| 5457 | int rval; |
| 5458 | mbx_cmd_t mc; |
| 5459 | mbx_cmd_t *mcp = &mc; |
| 5460 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5461 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110c, |
| 5462 | "Entered %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5463 | |
| 5464 | mcp->mb[0] = MBC_SET_PORT_CONFIG; |
| 5465 | /* Copy all bits to preserve original setting */ |
| 5466 | memcpy(&mcp->mb[1], mb, sizeof(uint16_t) * 4); |
| 5467 | mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5468 | mcp->in_mb = MBX_0; |
| 5469 | mcp->tov = MBX_TOV_SECONDS; |
| 5470 | mcp->flags = 0; |
| 5471 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5472 | |
| 5473 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5474 | ql_dbg(ql_dbg_mbx, vha, 0x110d, |
| 5475 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5476 | } else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5477 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110e, |
| 5478 | "Done %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5479 | |
| 5480 | return rval; |
| 5481 | } |
| 5482 | |
| 5483 | |
| 5484 | int |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5485 | qla24xx_set_fcp_prio(scsi_qla_host_t *vha, uint16_t loop_id, uint16_t priority, |
| 5486 | uint16_t *mb) |
| 5487 | { |
| 5488 | int rval; |
| 5489 | mbx_cmd_t mc; |
| 5490 | mbx_cmd_t *mcp = &mc; |
| 5491 | struct qla_hw_data *ha = vha->hw; |
| 5492 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5493 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110f, |
| 5494 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5495 | |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5496 | if (!IS_QLA24XX_TYPE(ha) && !IS_QLA25XX(ha)) |
| 5497 | return QLA_FUNCTION_FAILED; |
| 5498 | |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5499 | mcp->mb[0] = MBC_PORT_PARAMS; |
| 5500 | mcp->mb[1] = loop_id; |
| 5501 | if (ha->flags.fcp_prio_enabled) |
| 5502 | mcp->mb[2] = BIT_1; |
| 5503 | else |
| 5504 | mcp->mb[2] = BIT_2; |
| 5505 | mcp->mb[4] = priority & 0xf; |
| 5506 | mcp->mb[9] = vha->vp_idx; |
| 5507 | mcp->out_mb = MBX_9|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5508 | mcp->in_mb = MBX_4|MBX_3|MBX_1|MBX_0; |
| 5509 | mcp->tov = 30; |
| 5510 | mcp->flags = 0; |
| 5511 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5512 | if (mb != NULL) { |
| 5513 | mb[0] = mcp->mb[0]; |
| 5514 | mb[1] = mcp->mb[1]; |
| 5515 | mb[3] = mcp->mb[3]; |
| 5516 | mb[4] = mcp->mb[4]; |
| 5517 | } |
| 5518 | |
| 5519 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5520 | ql_dbg(ql_dbg_mbx, vha, 0x10cd, "Failed=%x.\n", rval); |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5521 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5522 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10cc, |
| 5523 | "Done %s.\n", __func__); |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5524 | } |
| 5525 | |
| 5526 | return rval; |
| 5527 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5528 | |
| 5529 | int |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 5530 | qla2x00_get_thermal_temp(scsi_qla_host_t *vha, uint16_t *temp) |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5531 | { |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 5532 | int rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5533 | struct qla_hw_data *ha = vha->hw; |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 5534 | uint8_t byte; |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5535 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 5536 | if (!IS_FWI2_CAPABLE(ha) || IS_QLA24XX_TYPE(ha) || IS_QLA81XX(ha)) { |
| 5537 | ql_dbg(ql_dbg_mbx, vha, 0x1150, |
| 5538 | "Thermal not supported by this card.\n"); |
| 5539 | return rval; |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5540 | } |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5541 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 5542 | if (IS_QLA25XX(ha)) { |
| 5543 | if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC && |
| 5544 | ha->pdev->subsystem_device == 0x0175) { |
| 5545 | rval = qla2x00_read_sfp(vha, 0, &byte, |
| 5546 | 0x98, 0x1, 1, BIT_13|BIT_0); |
| 5547 | *temp = byte; |
| 5548 | return rval; |
| 5549 | } |
| 5550 | if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_HP && |
| 5551 | ha->pdev->subsystem_device == 0x338e) { |
| 5552 | rval = qla2x00_read_sfp(vha, 0, &byte, |
| 5553 | 0x98, 0x1, 1, BIT_15|BIT_14|BIT_0); |
| 5554 | *temp = byte; |
| 5555 | return rval; |
| 5556 | } |
| 5557 | ql_dbg(ql_dbg_mbx, vha, 0x10c9, |
| 5558 | "Thermal not supported by this card.\n"); |
| 5559 | return rval; |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 5560 | } |
| 5561 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 5562 | if (IS_QLA82XX(ha)) { |
| 5563 | *temp = qla82xx_read_temperature(vha); |
| 5564 | rval = QLA_SUCCESS; |
| 5565 | return rval; |
| 5566 | } else if (IS_QLA8044(ha)) { |
| 5567 | *temp = qla8044_read_temperature(vha); |
| 5568 | rval = QLA_SUCCESS; |
| 5569 | return rval; |
| 5570 | } |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 5571 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 5572 | rval = qla2x00_read_asic_temperature(vha, temp); |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5573 | return rval; |
| 5574 | } |
| 5575 | |
| 5576 | int |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5577 | qla82xx_mbx_intr_enable(scsi_qla_host_t *vha) |
| 5578 | { |
| 5579 | int rval; |
| 5580 | struct qla_hw_data *ha = vha->hw; |
| 5581 | mbx_cmd_t mc; |
| 5582 | mbx_cmd_t *mcp = &mc; |
| 5583 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5584 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1017, |
| 5585 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5586 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5587 | if (!IS_FWI2_CAPABLE(ha)) |
| 5588 | return QLA_FUNCTION_FAILED; |
| 5589 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5590 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
Giridhar Malavali | 3711333 | 2010-07-23 15:28:34 +0500 | [diff] [blame] | 5591 | mcp->mb[0] = MBC_TOGGLE_INTERRUPT; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5592 | mcp->mb[1] = 1; |
| 5593 | |
| 5594 | mcp->out_mb = MBX_1|MBX_0; |
| 5595 | mcp->in_mb = MBX_0; |
| 5596 | mcp->tov = 30; |
| 5597 | mcp->flags = 0; |
| 5598 | |
| 5599 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5600 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5601 | ql_dbg(ql_dbg_mbx, vha, 0x1016, |
| 5602 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5603 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5604 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x100e, |
| 5605 | "Done %s.\n", __func__); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5606 | } |
| 5607 | |
| 5608 | return rval; |
| 5609 | } |
| 5610 | |
| 5611 | int |
| 5612 | qla82xx_mbx_intr_disable(scsi_qla_host_t *vha) |
| 5613 | { |
| 5614 | int rval; |
| 5615 | struct qla_hw_data *ha = vha->hw; |
| 5616 | mbx_cmd_t mc; |
| 5617 | mbx_cmd_t *mcp = &mc; |
| 5618 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5619 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x100d, |
| 5620 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5621 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5622 | if (!IS_P3P_TYPE(ha)) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5623 | return QLA_FUNCTION_FAILED; |
| 5624 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5625 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
Giridhar Malavali | 3711333 | 2010-07-23 15:28:34 +0500 | [diff] [blame] | 5626 | mcp->mb[0] = MBC_TOGGLE_INTERRUPT; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5627 | mcp->mb[1] = 0; |
| 5628 | |
| 5629 | mcp->out_mb = MBX_1|MBX_0; |
| 5630 | mcp->in_mb = MBX_0; |
| 5631 | mcp->tov = 30; |
| 5632 | mcp->flags = 0; |
| 5633 | |
| 5634 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5635 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5636 | ql_dbg(ql_dbg_mbx, vha, 0x100c, |
| 5637 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5638 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5639 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x100b, |
| 5640 | "Done %s.\n", __func__); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5641 | } |
| 5642 | |
| 5643 | return rval; |
| 5644 | } |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5645 | |
| 5646 | int |
| 5647 | qla82xx_md_get_template_size(scsi_qla_host_t *vha) |
| 5648 | { |
| 5649 | struct qla_hw_data *ha = vha->hw; |
| 5650 | mbx_cmd_t mc; |
| 5651 | mbx_cmd_t *mcp = &mc; |
| 5652 | int rval = QLA_FUNCTION_FAILED; |
| 5653 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5654 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x111f, |
| 5655 | "Entered %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5656 | |
| 5657 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 5658 | mcp->mb[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5659 | mcp->mb[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5660 | mcp->mb[2] = LSW(RQST_TMPLT_SIZE); |
| 5661 | mcp->mb[3] = MSW(RQST_TMPLT_SIZE); |
| 5662 | |
| 5663 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 5664 | mcp->in_mb = MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8| |
| 5665 | MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5666 | |
| 5667 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 5668 | mcp->tov = MBX_TOV_SECONDS; |
| 5669 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5670 | |
| 5671 | /* Always copy back return mailbox values. */ |
| 5672 | if (rval != QLA_SUCCESS) { |
| 5673 | ql_dbg(ql_dbg_mbx, vha, 0x1120, |
| 5674 | "mailbox command FAILED=0x%x, subcode=%x.\n", |
| 5675 | (mcp->mb[1] << 16) | mcp->mb[0], |
| 5676 | (mcp->mb[3] << 16) | mcp->mb[2]); |
| 5677 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5678 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1121, |
| 5679 | "Done %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5680 | ha->md_template_size = ((mcp->mb[3] << 16) | mcp->mb[2]); |
| 5681 | if (!ha->md_template_size) { |
| 5682 | ql_dbg(ql_dbg_mbx, vha, 0x1122, |
| 5683 | "Null template size obtained.\n"); |
| 5684 | rval = QLA_FUNCTION_FAILED; |
| 5685 | } |
| 5686 | } |
| 5687 | return rval; |
| 5688 | } |
| 5689 | |
| 5690 | int |
| 5691 | qla82xx_md_get_template(scsi_qla_host_t *vha) |
| 5692 | { |
| 5693 | struct qla_hw_data *ha = vha->hw; |
| 5694 | mbx_cmd_t mc; |
| 5695 | mbx_cmd_t *mcp = &mc; |
| 5696 | int rval = QLA_FUNCTION_FAILED; |
| 5697 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5698 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1123, |
| 5699 | "Entered %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5700 | |
| 5701 | ha->md_tmplt_hdr = dma_alloc_coherent(&ha->pdev->dev, |
| 5702 | ha->md_template_size, &ha->md_tmplt_hdr_dma, GFP_KERNEL); |
| 5703 | if (!ha->md_tmplt_hdr) { |
| 5704 | ql_log(ql_log_warn, vha, 0x1124, |
| 5705 | "Unable to allocate memory for Minidump template.\n"); |
| 5706 | return rval; |
| 5707 | } |
| 5708 | |
| 5709 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 5710 | mcp->mb[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5711 | mcp->mb[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5712 | mcp->mb[2] = LSW(RQST_TMPLT); |
| 5713 | mcp->mb[3] = MSW(RQST_TMPLT); |
| 5714 | mcp->mb[4] = LSW(LSD(ha->md_tmplt_hdr_dma)); |
| 5715 | mcp->mb[5] = MSW(LSD(ha->md_tmplt_hdr_dma)); |
| 5716 | mcp->mb[6] = LSW(MSD(ha->md_tmplt_hdr_dma)); |
| 5717 | mcp->mb[7] = MSW(MSD(ha->md_tmplt_hdr_dma)); |
| 5718 | mcp->mb[8] = LSW(ha->md_template_size); |
| 5719 | mcp->mb[9] = MSW(ha->md_template_size); |
| 5720 | |
| 5721 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 5722 | mcp->tov = MBX_TOV_SECONDS; |
| 5723 | mcp->out_mb = MBX_11|MBX_10|MBX_9|MBX_8| |
| 5724 | MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5725 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 5726 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5727 | |
| 5728 | if (rval != QLA_SUCCESS) { |
| 5729 | ql_dbg(ql_dbg_mbx, vha, 0x1125, |
| 5730 | "mailbox command FAILED=0x%x, subcode=%x.\n", |
| 5731 | ((mcp->mb[1] << 16) | mcp->mb[0]), |
| 5732 | ((mcp->mb[3] << 16) | mcp->mb[2])); |
| 5733 | } else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5734 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1126, |
| 5735 | "Done %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5736 | return rval; |
| 5737 | } |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5738 | |
| 5739 | int |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5740 | qla8044_md_get_template(scsi_qla_host_t *vha) |
| 5741 | { |
| 5742 | struct qla_hw_data *ha = vha->hw; |
| 5743 | mbx_cmd_t mc; |
| 5744 | mbx_cmd_t *mcp = &mc; |
| 5745 | int rval = QLA_FUNCTION_FAILED; |
| 5746 | int offset = 0, size = MINIDUMP_SIZE_36K; |
Bart Van Assche | bd432bb | 2019-04-11 14:53:17 -0700 | [diff] [blame] | 5747 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5748 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0xb11f, |
| 5749 | "Entered %s.\n", __func__); |
| 5750 | |
| 5751 | ha->md_tmplt_hdr = dma_alloc_coherent(&ha->pdev->dev, |
| 5752 | ha->md_template_size, &ha->md_tmplt_hdr_dma, GFP_KERNEL); |
| 5753 | if (!ha->md_tmplt_hdr) { |
| 5754 | ql_log(ql_log_warn, vha, 0xb11b, |
| 5755 | "Unable to allocate memory for Minidump template.\n"); |
| 5756 | return rval; |
| 5757 | } |
| 5758 | |
| 5759 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 5760 | while (offset < ha->md_template_size) { |
| 5761 | mcp->mb[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5762 | mcp->mb[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5763 | mcp->mb[2] = LSW(RQST_TMPLT); |
| 5764 | mcp->mb[3] = MSW(RQST_TMPLT); |
| 5765 | mcp->mb[4] = LSW(LSD(ha->md_tmplt_hdr_dma + offset)); |
| 5766 | mcp->mb[5] = MSW(LSD(ha->md_tmplt_hdr_dma + offset)); |
| 5767 | mcp->mb[6] = LSW(MSD(ha->md_tmplt_hdr_dma + offset)); |
| 5768 | mcp->mb[7] = MSW(MSD(ha->md_tmplt_hdr_dma + offset)); |
| 5769 | mcp->mb[8] = LSW(size); |
| 5770 | mcp->mb[9] = MSW(size); |
| 5771 | mcp->mb[10] = offset & 0x0000FFFF; |
| 5772 | mcp->mb[11] = offset & 0xFFFF0000; |
| 5773 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 5774 | mcp->tov = MBX_TOV_SECONDS; |
| 5775 | mcp->out_mb = MBX_11|MBX_10|MBX_9|MBX_8| |
| 5776 | MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5777 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 5778 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5779 | |
| 5780 | if (rval != QLA_SUCCESS) { |
| 5781 | ql_dbg(ql_dbg_mbx, vha, 0xb11c, |
| 5782 | "mailbox command FAILED=0x%x, subcode=%x.\n", |
| 5783 | ((mcp->mb[1] << 16) | mcp->mb[0]), |
| 5784 | ((mcp->mb[3] << 16) | mcp->mb[2])); |
| 5785 | return rval; |
| 5786 | } else |
| 5787 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0xb11d, |
| 5788 | "Done %s.\n", __func__); |
| 5789 | offset = offset + size; |
| 5790 | } |
| 5791 | return rval; |
| 5792 | } |
| 5793 | |
| 5794 | int |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5795 | qla81xx_set_led_config(scsi_qla_host_t *vha, uint16_t *led_cfg) |
| 5796 | { |
| 5797 | int rval; |
| 5798 | struct qla_hw_data *ha = vha->hw; |
| 5799 | mbx_cmd_t mc; |
| 5800 | mbx_cmd_t *mcp = &mc; |
| 5801 | |
| 5802 | if (!IS_QLA81XX(ha) && !IS_QLA8031(ha)) |
| 5803 | return QLA_FUNCTION_FAILED; |
| 5804 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5805 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1133, |
| 5806 | "Entered %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5807 | |
| 5808 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
| 5809 | mcp->mb[0] = MBC_SET_LED_CONFIG; |
| 5810 | mcp->mb[1] = led_cfg[0]; |
| 5811 | mcp->mb[2] = led_cfg[1]; |
| 5812 | if (IS_QLA8031(ha)) { |
| 5813 | mcp->mb[3] = led_cfg[2]; |
| 5814 | mcp->mb[4] = led_cfg[3]; |
| 5815 | mcp->mb[5] = led_cfg[4]; |
| 5816 | mcp->mb[6] = led_cfg[5]; |
| 5817 | } |
| 5818 | |
| 5819 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 5820 | if (IS_QLA8031(ha)) |
| 5821 | mcp->out_mb |= MBX_6|MBX_5|MBX_4|MBX_3; |
| 5822 | mcp->in_mb = MBX_0; |
| 5823 | mcp->tov = 30; |
| 5824 | mcp->flags = 0; |
| 5825 | |
| 5826 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5827 | if (rval != QLA_SUCCESS) { |
| 5828 | ql_dbg(ql_dbg_mbx, vha, 0x1134, |
| 5829 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5830 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5831 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1135, |
| 5832 | "Done %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5833 | } |
| 5834 | |
| 5835 | return rval; |
| 5836 | } |
| 5837 | |
| 5838 | int |
| 5839 | qla81xx_get_led_config(scsi_qla_host_t *vha, uint16_t *led_cfg) |
| 5840 | { |
| 5841 | int rval; |
| 5842 | struct qla_hw_data *ha = vha->hw; |
| 5843 | mbx_cmd_t mc; |
| 5844 | mbx_cmd_t *mcp = &mc; |
| 5845 | |
| 5846 | if (!IS_QLA81XX(ha) && !IS_QLA8031(ha)) |
| 5847 | return QLA_FUNCTION_FAILED; |
| 5848 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5849 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1136, |
| 5850 | "Entered %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5851 | |
| 5852 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
| 5853 | mcp->mb[0] = MBC_GET_LED_CONFIG; |
| 5854 | |
| 5855 | mcp->out_mb = MBX_0; |
| 5856 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 5857 | if (IS_QLA8031(ha)) |
| 5858 | mcp->in_mb |= MBX_6|MBX_5|MBX_4|MBX_3; |
| 5859 | mcp->tov = 30; |
| 5860 | mcp->flags = 0; |
| 5861 | |
| 5862 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5863 | if (rval != QLA_SUCCESS) { |
| 5864 | ql_dbg(ql_dbg_mbx, vha, 0x1137, |
| 5865 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5866 | } else { |
| 5867 | led_cfg[0] = mcp->mb[1]; |
| 5868 | led_cfg[1] = mcp->mb[2]; |
| 5869 | if (IS_QLA8031(ha)) { |
| 5870 | led_cfg[2] = mcp->mb[3]; |
| 5871 | led_cfg[3] = mcp->mb[4]; |
| 5872 | led_cfg[4] = mcp->mb[5]; |
| 5873 | led_cfg[5] = mcp->mb[6]; |
| 5874 | } |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5875 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1138, |
| 5876 | "Done %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5877 | } |
| 5878 | |
| 5879 | return rval; |
| 5880 | } |
| 5881 | |
| 5882 | int |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5883 | qla82xx_mbx_beacon_ctl(scsi_qla_host_t *vha, int enable) |
| 5884 | { |
| 5885 | int rval; |
| 5886 | struct qla_hw_data *ha = vha->hw; |
| 5887 | mbx_cmd_t mc; |
| 5888 | mbx_cmd_t *mcp = &mc; |
| 5889 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5890 | if (!IS_P3P_TYPE(ha)) |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5891 | return QLA_FUNCTION_FAILED; |
| 5892 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5893 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1127, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5894 | "Entered %s.\n", __func__); |
| 5895 | |
| 5896 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
| 5897 | mcp->mb[0] = MBC_SET_LED_CONFIG; |
| 5898 | if (enable) |
| 5899 | mcp->mb[7] = 0xE; |
| 5900 | else |
| 5901 | mcp->mb[7] = 0xD; |
| 5902 | |
| 5903 | mcp->out_mb = MBX_7|MBX_0; |
| 5904 | mcp->in_mb = MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5905 | mcp->tov = MBX_TOV_SECONDS; |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5906 | mcp->flags = 0; |
| 5907 | |
| 5908 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5909 | if (rval != QLA_SUCCESS) { |
| 5910 | ql_dbg(ql_dbg_mbx, vha, 0x1128, |
| 5911 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5912 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5913 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1129, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5914 | "Done %s.\n", __func__); |
| 5915 | } |
| 5916 | |
| 5917 | return rval; |
| 5918 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5919 | |
| 5920 | int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5921 | 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] | 5922 | { |
| 5923 | int rval; |
| 5924 | struct qla_hw_data *ha = vha->hw; |
| 5925 | mbx_cmd_t mc; |
| 5926 | mbx_cmd_t *mcp = &mc; |
| 5927 | |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 5928 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha) && !IS_QLA28XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5929 | return QLA_FUNCTION_FAILED; |
| 5930 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5931 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1130, |
| 5932 | "Entered %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5933 | |
| 5934 | mcp->mb[0] = MBC_WRITE_REMOTE_REG; |
| 5935 | mcp->mb[1] = LSW(reg); |
| 5936 | mcp->mb[2] = MSW(reg); |
| 5937 | mcp->mb[3] = LSW(data); |
| 5938 | mcp->mb[4] = MSW(data); |
| 5939 | mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5940 | |
| 5941 | mcp->in_mb = MBX_1|MBX_0; |
| 5942 | mcp->tov = MBX_TOV_SECONDS; |
| 5943 | mcp->flags = 0; |
| 5944 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5945 | |
| 5946 | if (rval != QLA_SUCCESS) { |
| 5947 | ql_dbg(ql_dbg_mbx, vha, 0x1131, |
| 5948 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5949 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5950 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1132, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5951 | "Done %s.\n", __func__); |
| 5952 | } |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5953 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5954 | return rval; |
| 5955 | } |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5956 | |
| 5957 | int |
| 5958 | qla2x00_port_logout(scsi_qla_host_t *vha, struct fc_port *fcport) |
| 5959 | { |
| 5960 | int rval; |
| 5961 | struct qla_hw_data *ha = vha->hw; |
| 5962 | mbx_cmd_t mc; |
| 5963 | mbx_cmd_t *mcp = &mc; |
| 5964 | |
| 5965 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5966 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x113b, |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5967 | "Implicit LOGO Unsupported.\n"); |
| 5968 | return QLA_FUNCTION_FAILED; |
| 5969 | } |
| 5970 | |
| 5971 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5972 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x113c, |
| 5973 | "Entering %s.\n", __func__); |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5974 | |
| 5975 | /* Perform Implicit LOGO. */ |
| 5976 | mcp->mb[0] = MBC_PORT_LOGOUT; |
| 5977 | mcp->mb[1] = fcport->loop_id; |
| 5978 | mcp->mb[10] = BIT_15; |
| 5979 | mcp->out_mb = MBX_10|MBX_1|MBX_0; |
| 5980 | mcp->in_mb = MBX_0; |
| 5981 | mcp->tov = MBX_TOV_SECONDS; |
| 5982 | mcp->flags = 0; |
| 5983 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5984 | if (rval != QLA_SUCCESS) |
| 5985 | ql_dbg(ql_dbg_mbx, vha, 0x113d, |
| 5986 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5987 | else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5988 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x113e, |
| 5989 | "Done %s.\n", __func__); |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5990 | |
| 5991 | return rval; |
| 5992 | } |
| 5993 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5994 | int |
| 5995 | qla83xx_rd_reg(scsi_qla_host_t *vha, uint32_t reg, uint32_t *data) |
| 5996 | { |
| 5997 | int rval; |
| 5998 | mbx_cmd_t mc; |
| 5999 | mbx_cmd_t *mcp = &mc; |
| 6000 | struct qla_hw_data *ha = vha->hw; |
| 6001 | unsigned long retry_max_time = jiffies + (2 * HZ); |
| 6002 | |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 6003 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha) && !IS_QLA28XX(ha)) |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 6004 | return QLA_FUNCTION_FAILED; |
| 6005 | |
| 6006 | ql_dbg(ql_dbg_mbx, vha, 0x114b, "Entered %s.\n", __func__); |
| 6007 | |
| 6008 | retry_rd_reg: |
| 6009 | mcp->mb[0] = MBC_READ_REMOTE_REG; |
| 6010 | mcp->mb[1] = LSW(reg); |
| 6011 | mcp->mb[2] = MSW(reg); |
| 6012 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 6013 | mcp->in_mb = MBX_4|MBX_3|MBX_1|MBX_0; |
| 6014 | mcp->tov = MBX_TOV_SECONDS; |
| 6015 | mcp->flags = 0; |
| 6016 | rval = qla2x00_mailbox_command(vha, mcp); |
| 6017 | |
| 6018 | if (rval != QLA_SUCCESS) { |
| 6019 | ql_dbg(ql_dbg_mbx, vha, 0x114c, |
| 6020 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 6021 | rval, mcp->mb[0], mcp->mb[1]); |
| 6022 | } else { |
| 6023 | *data = (mcp->mb[3] | (mcp->mb[4] << 16)); |
| 6024 | if (*data == QLA8XXX_BAD_VALUE) { |
| 6025 | /* |
| 6026 | * During soft-reset CAMRAM register reads might |
| 6027 | * return 0xbad0bad0. So retry for MAX of 2 sec |
| 6028 | * while reading camram registers. |
| 6029 | */ |
| 6030 | if (time_after(jiffies, retry_max_time)) { |
| 6031 | ql_dbg(ql_dbg_mbx, vha, 0x1141, |
| 6032 | "Failure to read CAMRAM register. " |
| 6033 | "data=0x%x.\n", *data); |
| 6034 | return QLA_FUNCTION_FAILED; |
| 6035 | } |
| 6036 | msleep(100); |
| 6037 | goto retry_rd_reg; |
| 6038 | } |
| 6039 | ql_dbg(ql_dbg_mbx, vha, 0x1142, "Done %s.\n", __func__); |
| 6040 | } |
| 6041 | |
| 6042 | return rval; |
| 6043 | } |
| 6044 | |
| 6045 | int |
| 6046 | qla83xx_restart_nic_firmware(scsi_qla_host_t *vha) |
| 6047 | { |
| 6048 | int rval; |
| 6049 | mbx_cmd_t mc; |
| 6050 | mbx_cmd_t *mcp = &mc; |
| 6051 | struct qla_hw_data *ha = vha->hw; |
| 6052 | |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 6053 | if (!IS_QLA83XX(ha)) |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 6054 | return QLA_FUNCTION_FAILED; |
| 6055 | |
| 6056 | ql_dbg(ql_dbg_mbx, vha, 0x1143, "Entered %s.\n", __func__); |
| 6057 | |
| 6058 | mcp->mb[0] = MBC_RESTART_NIC_FIRMWARE; |
| 6059 | mcp->out_mb = MBX_0; |
| 6060 | mcp->in_mb = MBX_1|MBX_0; |
| 6061 | mcp->tov = MBX_TOV_SECONDS; |
| 6062 | mcp->flags = 0; |
| 6063 | rval = qla2x00_mailbox_command(vha, mcp); |
| 6064 | |
| 6065 | if (rval != QLA_SUCCESS) { |
| 6066 | ql_dbg(ql_dbg_mbx, vha, 0x1144, |
| 6067 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 6068 | rval, mcp->mb[0], mcp->mb[1]); |
| 6069 | ha->isp_ops->fw_dump(vha, 0); |
| 6070 | } else { |
| 6071 | ql_dbg(ql_dbg_mbx, vha, 0x1145, "Done %s.\n", __func__); |
| 6072 | } |
| 6073 | |
| 6074 | return rval; |
| 6075 | } |
| 6076 | |
| 6077 | int |
| 6078 | qla83xx_access_control(scsi_qla_host_t *vha, uint16_t options, |
| 6079 | uint32_t start_addr, uint32_t end_addr, uint16_t *sector_size) |
| 6080 | { |
| 6081 | int rval; |
| 6082 | mbx_cmd_t mc; |
| 6083 | mbx_cmd_t *mcp = &mc; |
| 6084 | uint8_t subcode = (uint8_t)options; |
| 6085 | struct qla_hw_data *ha = vha->hw; |
| 6086 | |
| 6087 | if (!IS_QLA8031(ha)) |
| 6088 | return QLA_FUNCTION_FAILED; |
| 6089 | |
| 6090 | ql_dbg(ql_dbg_mbx, vha, 0x1146, "Entered %s.\n", __func__); |
| 6091 | |
| 6092 | mcp->mb[0] = MBC_SET_ACCESS_CONTROL; |
| 6093 | mcp->mb[1] = options; |
| 6094 | mcp->out_mb = MBX_1|MBX_0; |
| 6095 | if (subcode & BIT_2) { |
| 6096 | mcp->mb[2] = LSW(start_addr); |
| 6097 | mcp->mb[3] = MSW(start_addr); |
| 6098 | mcp->mb[4] = LSW(end_addr); |
| 6099 | mcp->mb[5] = MSW(end_addr); |
| 6100 | mcp->out_mb |= MBX_5|MBX_4|MBX_3|MBX_2; |
| 6101 | } |
| 6102 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 6103 | if (!(subcode & (BIT_2 | BIT_5))) |
| 6104 | mcp->in_mb |= MBX_4|MBX_3; |
| 6105 | mcp->tov = MBX_TOV_SECONDS; |
| 6106 | mcp->flags = 0; |
| 6107 | rval = qla2x00_mailbox_command(vha, mcp); |
| 6108 | |
| 6109 | if (rval != QLA_SUCCESS) { |
| 6110 | ql_dbg(ql_dbg_mbx, vha, 0x1147, |
| 6111 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[3]=%x mb[4]=%x.\n", |
| 6112 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2], mcp->mb[3], |
| 6113 | mcp->mb[4]); |
| 6114 | ha->isp_ops->fw_dump(vha, 0); |
| 6115 | } else { |
| 6116 | if (subcode & BIT_5) |
| 6117 | *sector_size = mcp->mb[1]; |
| 6118 | else if (subcode & (BIT_6 | BIT_7)) { |
| 6119 | ql_dbg(ql_dbg_mbx, vha, 0x1148, |
| 6120 | "Driver-lock id=%x%x", mcp->mb[4], mcp->mb[3]); |
| 6121 | } else if (subcode & (BIT_3 | BIT_4)) { |
| 6122 | ql_dbg(ql_dbg_mbx, vha, 0x1149, |
| 6123 | "Flash-lock id=%x%x", mcp->mb[4], mcp->mb[3]); |
| 6124 | } |
| 6125 | ql_dbg(ql_dbg_mbx, vha, 0x114a, "Done %s.\n", __func__); |
| 6126 | } |
| 6127 | |
| 6128 | return rval; |
| 6129 | } |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 6130 | |
| 6131 | int |
| 6132 | qla2x00_dump_mctp_data(scsi_qla_host_t *vha, dma_addr_t req_dma, uint32_t addr, |
| 6133 | uint32_t size) |
| 6134 | { |
| 6135 | int rval; |
| 6136 | mbx_cmd_t mc; |
| 6137 | mbx_cmd_t *mcp = &mc; |
| 6138 | |
| 6139 | if (!IS_MCTP_CAPABLE(vha->hw)) |
| 6140 | return QLA_FUNCTION_FAILED; |
| 6141 | |
| 6142 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x114f, |
| 6143 | "Entered %s.\n", __func__); |
| 6144 | |
| 6145 | mcp->mb[0] = MBC_DUMP_RISC_RAM_EXTENDED; |
| 6146 | mcp->mb[1] = LSW(addr); |
| 6147 | mcp->mb[2] = MSW(req_dma); |
| 6148 | mcp->mb[3] = LSW(req_dma); |
| 6149 | mcp->mb[4] = MSW(size); |
| 6150 | mcp->mb[5] = LSW(size); |
| 6151 | mcp->mb[6] = MSW(MSD(req_dma)); |
| 6152 | mcp->mb[7] = LSW(MSD(req_dma)); |
| 6153 | mcp->mb[8] = MSW(addr); |
| 6154 | /* Setting RAM ID to valid */ |
| 6155 | mcp->mb[10] |= BIT_7; |
| 6156 | /* For MCTP RAM ID is 0x40 */ |
| 6157 | mcp->mb[10] |= 0x40; |
| 6158 | |
| 6159 | mcp->out_mb |= MBX_10|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1| |
| 6160 | MBX_0; |
| 6161 | |
| 6162 | mcp->in_mb = MBX_0; |
| 6163 | mcp->tov = MBX_TOV_SECONDS; |
| 6164 | mcp->flags = 0; |
| 6165 | rval = qla2x00_mailbox_command(vha, mcp); |
| 6166 | |
| 6167 | if (rval != QLA_SUCCESS) { |
| 6168 | ql_dbg(ql_dbg_mbx, vha, 0x114e, |
| 6169 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 6170 | } else { |
| 6171 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x114d, |
| 6172 | "Done %s.\n", __func__); |
| 6173 | } |
| 6174 | |
| 6175 | return rval; |
| 6176 | } |
Joe Carnuccio | ec89146 | 2016-07-06 11:14:26 -0400 | [diff] [blame] | 6177 | |
| 6178 | int |
| 6179 | qla26xx_dport_diagnostics(scsi_qla_host_t *vha, |
| 6180 | void *dd_buf, uint size, uint options) |
| 6181 | { |
| 6182 | int rval; |
| 6183 | mbx_cmd_t mc; |
| 6184 | mbx_cmd_t *mcp = &mc; |
| 6185 | dma_addr_t dd_dma; |
| 6186 | |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 6187 | if (!IS_QLA83XX(vha->hw) && !IS_QLA27XX(vha->hw) && |
| 6188 | !IS_QLA28XX(vha->hw)) |
Joe Carnuccio | ec89146 | 2016-07-06 11:14:26 -0400 | [diff] [blame] | 6189 | return QLA_FUNCTION_FAILED; |
| 6190 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6191 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x119f, |
Joe Carnuccio | ec89146 | 2016-07-06 11:14:26 -0400 | [diff] [blame] | 6192 | "Entered %s.\n", __func__); |
| 6193 | |
Joe Carnuccio | ec89146 | 2016-07-06 11:14:26 -0400 | [diff] [blame] | 6194 | dd_dma = dma_map_single(&vha->hw->pdev->dev, |
| 6195 | dd_buf, size, DMA_FROM_DEVICE); |
Pan Bian | 0b2ce19 | 2017-08-08 21:55:30 +0800 | [diff] [blame] | 6196 | if (dma_mapping_error(&vha->hw->pdev->dev, dd_dma)) { |
Joe Carnuccio | ec89146 | 2016-07-06 11:14:26 -0400 | [diff] [blame] | 6197 | ql_log(ql_log_warn, vha, 0x1194, "Failed to map dma buffer.\n"); |
| 6198 | return QLA_MEMORY_ALLOC_FAILED; |
| 6199 | } |
| 6200 | |
| 6201 | memset(dd_buf, 0, size); |
| 6202 | |
| 6203 | mcp->mb[0] = MBC_DPORT_DIAGNOSTICS; |
| 6204 | mcp->mb[1] = options; |
| 6205 | mcp->mb[2] = MSW(LSD(dd_dma)); |
| 6206 | mcp->mb[3] = LSW(LSD(dd_dma)); |
| 6207 | mcp->mb[6] = MSW(MSD(dd_dma)); |
| 6208 | mcp->mb[7] = LSW(MSD(dd_dma)); |
| 6209 | mcp->mb[8] = size; |
| 6210 | mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 6211 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 6212 | mcp->buf_size = size; |
| 6213 | mcp->flags = MBX_DMA_IN; |
| 6214 | mcp->tov = MBX_TOV_SECONDS * 4; |
| 6215 | rval = qla2x00_mailbox_command(vha, mcp); |
| 6216 | |
| 6217 | if (rval != QLA_SUCCESS) { |
| 6218 | ql_dbg(ql_dbg_mbx, vha, 0x1195, "Failed=%x.\n", rval); |
| 6219 | } else { |
| 6220 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1196, |
| 6221 | "Done %s.\n", __func__); |
| 6222 | } |
| 6223 | |
| 6224 | dma_unmap_single(&vha->hw->pdev->dev, dd_dma, |
| 6225 | size, DMA_FROM_DEVICE); |
| 6226 | |
| 6227 | return rval; |
| 6228 | } |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6229 | |
Bart Van Assche | 6c18a43 | 2019-08-08 20:02:04 -0700 | [diff] [blame] | 6230 | static void qla2x00_async_mb_sp_done(srb_t *sp, int res) |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6231 | { |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6232 | sp->u.iocb_cmd.u.mbx.rc = res; |
| 6233 | |
| 6234 | complete(&sp->u.iocb_cmd.u.mbx.comp); |
| 6235 | /* don't free sp here. Let the caller do the free */ |
| 6236 | } |
| 6237 | |
| 6238 | /* |
| 6239 | * This mailbox uses the iocb interface to send MB command. |
| 6240 | * This allows non-critial (non chip setup) command to go |
| 6241 | * out in parrallel. |
| 6242 | */ |
| 6243 | int qla24xx_send_mb_cmd(struct scsi_qla_host *vha, mbx_cmd_t *mcp) |
| 6244 | { |
| 6245 | int rval = QLA_FUNCTION_FAILED; |
| 6246 | srb_t *sp; |
| 6247 | struct srb_iocb *c; |
| 6248 | |
| 6249 | if (!vha->hw->flags.fw_started) |
| 6250 | goto done; |
| 6251 | |
| 6252 | sp = qla2x00_get_sp(vha, NULL, GFP_KERNEL); |
| 6253 | if (!sp) |
| 6254 | goto done; |
| 6255 | |
| 6256 | sp->type = SRB_MB_IOCB; |
| 6257 | sp->name = mb_to_str(mcp->mb[0]); |
| 6258 | |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6259 | c = &sp->u.iocb_cmd; |
| 6260 | c->timeout = qla2x00_async_iocb_timeout; |
| 6261 | init_completion(&c->u.mbx.comp); |
| 6262 | |
Ben Hutchings | e74e7d9 | 2018-03-20 21:36:14 +0000 | [diff] [blame] | 6263 | qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); |
| 6264 | |
| 6265 | memcpy(sp->u.iocb_cmd.u.mbx.out_mb, mcp->mb, SIZEOF_IOCB_MB_REG); |
| 6266 | |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6267 | sp->done = qla2x00_async_mb_sp_done; |
| 6268 | |
| 6269 | rval = qla2x00_start_sp(sp); |
| 6270 | if (rval != QLA_SUCCESS) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6271 | ql_dbg(ql_dbg_mbx, vha, 0x1018, |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6272 | "%s: %s Failed submission. %x.\n", |
| 6273 | __func__, sp->name, rval); |
| 6274 | goto done_free_sp; |
| 6275 | } |
| 6276 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6277 | 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] | 6278 | sp->name, sp->handle); |
| 6279 | |
| 6280 | wait_for_completion(&c->u.mbx.comp); |
| 6281 | memcpy(mcp->mb, sp->u.iocb_cmd.u.mbx.in_mb, SIZEOF_IOCB_MB_REG); |
| 6282 | |
| 6283 | rval = c->u.mbx.rc; |
| 6284 | switch (rval) { |
| 6285 | case QLA_FUNCTION_TIMEOUT: |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6286 | ql_dbg(ql_dbg_mbx, vha, 0x1140, "%s: %s Timeout. %x.\n", |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6287 | __func__, sp->name, rval); |
| 6288 | break; |
| 6289 | case QLA_SUCCESS: |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6290 | ql_dbg(ql_dbg_mbx, vha, 0x119d, "%s: %s done.\n", |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6291 | __func__, sp->name); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6292 | break; |
| 6293 | default: |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6294 | ql_dbg(ql_dbg_mbx, vha, 0x119e, "%s: %s Failed. %x.\n", |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6295 | __func__, sp->name, rval); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6296 | break; |
| 6297 | } |
| 6298 | |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6299 | done_free_sp: |
| 6300 | sp->free(sp); |
| 6301 | done: |
| 6302 | return rval; |
| 6303 | } |
| 6304 | |
| 6305 | /* |
| 6306 | * qla24xx_gpdb_wait |
| 6307 | * NOTE: Do not call this routine from DPC thread |
| 6308 | */ |
| 6309 | int qla24xx_gpdb_wait(struct scsi_qla_host *vha, fc_port_t *fcport, u8 opt) |
| 6310 | { |
| 6311 | int rval = QLA_FUNCTION_FAILED; |
| 6312 | dma_addr_t pd_dma; |
| 6313 | struct port_database_24xx *pd; |
| 6314 | struct qla_hw_data *ha = vha->hw; |
| 6315 | mbx_cmd_t mc; |
| 6316 | |
| 6317 | if (!vha->hw->flags.fw_started) |
| 6318 | goto done; |
| 6319 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 6320 | pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6321 | if (pd == NULL) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6322 | ql_log(ql_log_warn, vha, 0xd047, |
| 6323 | "Failed to allocate port database structure.\n"); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6324 | goto done_free_sp; |
| 6325 | } |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6326 | |
| 6327 | memset(&mc, 0, sizeof(mc)); |
| 6328 | mc.mb[0] = MBC_GET_PORT_DATABASE; |
| 6329 | mc.mb[1] = cpu_to_le16(fcport->loop_id); |
| 6330 | mc.mb[2] = MSW(pd_dma); |
| 6331 | mc.mb[3] = LSW(pd_dma); |
| 6332 | mc.mb[6] = MSW(MSD(pd_dma)); |
| 6333 | mc.mb[7] = LSW(MSD(pd_dma)); |
| 6334 | mc.mb[9] = cpu_to_le16(vha->vp_idx); |
| 6335 | mc.mb[10] = cpu_to_le16((uint16_t)opt); |
| 6336 | |
| 6337 | rval = qla24xx_send_mb_cmd(vha, &mc); |
| 6338 | if (rval != QLA_SUCCESS) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6339 | ql_dbg(ql_dbg_mbx, vha, 0x1193, |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6340 | "%s: %8phC fail\n", __func__, fcport->port_name); |
| 6341 | goto done_free_sp; |
| 6342 | } |
| 6343 | |
| 6344 | rval = __qla24xx_parse_gpdb(vha, fcport, pd); |
| 6345 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6346 | ql_dbg(ql_dbg_mbx, vha, 0x1197, "%s: %8phC done\n", |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6347 | __func__, fcport->port_name); |
| 6348 | |
| 6349 | done_free_sp: |
| 6350 | if (pd) |
| 6351 | dma_pool_free(ha->s_dma_pool, pd, pd_dma); |
| 6352 | done: |
| 6353 | return rval; |
| 6354 | } |
| 6355 | |
| 6356 | int __qla24xx_parse_gpdb(struct scsi_qla_host *vha, fc_port_t *fcport, |
| 6357 | struct port_database_24xx *pd) |
| 6358 | { |
| 6359 | int rval = QLA_SUCCESS; |
| 6360 | uint64_t zero = 0; |
Duane Grigsby | a5d42f4 | 2017-06-21 13:48:41 -0700 | [diff] [blame] | 6361 | u8 current_login_state, last_login_state; |
| 6362 | |
Michael Hernandez | 84ed362 | 2019-09-12 11:09:12 -0700 | [diff] [blame] | 6363 | if (NVME_TARGET(vha->hw, fcport)) { |
Duane Grigsby | a5d42f4 | 2017-06-21 13:48:41 -0700 | [diff] [blame] | 6364 | current_login_state = pd->current_login_state >> 4; |
| 6365 | last_login_state = pd->last_login_state >> 4; |
| 6366 | } else { |
| 6367 | current_login_state = pd->current_login_state & 0xf; |
| 6368 | last_login_state = pd->last_login_state & 0xf; |
| 6369 | } |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6370 | |
| 6371 | /* Check for logged in state. */ |
Quinn Tran | 23c6455 | 2017-12-04 14:45:08 -0800 | [diff] [blame] | 6372 | if (current_login_state != PDS_PRLI_COMPLETE) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6373 | ql_dbg(ql_dbg_mbx, vha, 0x119a, |
| 6374 | "Unable to verify login-state (%x/%x) for loop_id %x.\n", |
Duane Grigsby | a5d42f4 | 2017-06-21 13:48:41 -0700 | [diff] [blame] | 6375 | current_login_state, last_login_state, fcport->loop_id); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6376 | rval = QLA_FUNCTION_FAILED; |
| 6377 | goto gpd_error_out; |
| 6378 | } |
| 6379 | |
| 6380 | if (fcport->loop_id == FC_NO_LOOP_ID || |
| 6381 | (memcmp(fcport->port_name, (uint8_t *)&zero, 8) && |
| 6382 | memcmp(fcport->port_name, pd->port_name, 8))) { |
| 6383 | /* We lost the device mid way. */ |
| 6384 | rval = QLA_NOT_LOGGED_IN; |
| 6385 | goto gpd_error_out; |
| 6386 | } |
| 6387 | |
| 6388 | /* Names are little-endian. */ |
| 6389 | memcpy(fcport->node_name, pd->node_name, WWN_SIZE); |
| 6390 | memcpy(fcport->port_name, pd->port_name, WWN_SIZE); |
| 6391 | |
| 6392 | /* Get port_id of device. */ |
| 6393 | fcport->d_id.b.domain = pd->port_id[0]; |
| 6394 | fcport->d_id.b.area = pd->port_id[1]; |
| 6395 | fcport->d_id.b.al_pa = pd->port_id[2]; |
| 6396 | fcport->d_id.b.rsvd_1 = 0; |
| 6397 | |
Michael Hernandez | 84ed362 | 2019-09-12 11:09:12 -0700 | [diff] [blame] | 6398 | if (NVME_TARGET(vha->hw, fcport)) { |
| 6399 | fcport->port_type = FCT_NVME; |
Hannes Reinecke | a6a6d05 | 2019-04-10 16:16:19 +0200 | [diff] [blame] | 6400 | if ((pd->prli_svc_param_word_3[0] & BIT_5) == 0) |
| 6401 | fcport->port_type |= FCT_NVME_INITIATOR; |
| 6402 | if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0) |
| 6403 | fcport->port_type |= FCT_NVME_TARGET; |
| 6404 | if ((pd->prli_svc_param_word_3[0] & BIT_3) == 0) |
| 6405 | fcport->port_type |= FCT_NVME_DISCOVERY; |
Duane Grigsby | a5d42f4 | 2017-06-21 13:48:41 -0700 | [diff] [blame] | 6406 | } else { |
| 6407 | /* If not target must be initiator or unknown type. */ |
| 6408 | if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0) |
| 6409 | fcport->port_type = FCT_INITIATOR; |
| 6410 | else |
| 6411 | fcport->port_type = FCT_TARGET; |
| 6412 | } |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6413 | /* Passback COS information. */ |
| 6414 | fcport->supported_classes = (pd->flags & PDF_CLASS_2) ? |
| 6415 | FC_COS_CLASS2 : FC_COS_CLASS3; |
| 6416 | |
| 6417 | if (pd->prli_svc_param_word_3[0] & BIT_7) { |
| 6418 | fcport->flags |= FCF_CONF_COMP_SUPPORTED; |
| 6419 | fcport->conf_compl_supported = 1; |
| 6420 | } |
| 6421 | |
| 6422 | gpd_error_out: |
| 6423 | return rval; |
| 6424 | } |
| 6425 | |
| 6426 | /* |
| 6427 | * qla24xx_gidlist__wait |
| 6428 | * NOTE: don't call this routine from DPC thread. |
| 6429 | */ |
| 6430 | int qla24xx_gidlist_wait(struct scsi_qla_host *vha, |
| 6431 | void *id_list, dma_addr_t id_list_dma, uint16_t *entries) |
| 6432 | { |
| 6433 | int rval = QLA_FUNCTION_FAILED; |
| 6434 | mbx_cmd_t mc; |
| 6435 | |
| 6436 | if (!vha->hw->flags.fw_started) |
| 6437 | goto done; |
| 6438 | |
| 6439 | memset(&mc, 0, sizeof(mc)); |
| 6440 | mc.mb[0] = MBC_GET_ID_LIST; |
| 6441 | mc.mb[2] = MSW(id_list_dma); |
| 6442 | mc.mb[3] = LSW(id_list_dma); |
| 6443 | mc.mb[6] = MSW(MSD(id_list_dma)); |
| 6444 | mc.mb[7] = LSW(MSD(id_list_dma)); |
| 6445 | mc.mb[8] = 0; |
| 6446 | mc.mb[9] = cpu_to_le16(vha->vp_idx); |
| 6447 | |
| 6448 | rval = qla24xx_send_mb_cmd(vha, &mc); |
| 6449 | if (rval != QLA_SUCCESS) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6450 | ql_dbg(ql_dbg_mbx, vha, 0x119b, |
| 6451 | "%s: fail\n", __func__); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6452 | } else { |
| 6453 | *entries = mc.mb[1]; |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6454 | ql_dbg(ql_dbg_mbx, vha, 0x119c, |
| 6455 | "%s: done\n", __func__); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6456 | } |
| 6457 | done: |
| 6458 | return rval; |
| 6459 | } |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 6460 | |
| 6461 | int qla27xx_set_zio_threshold(scsi_qla_host_t *vha, uint16_t value) |
| 6462 | { |
| 6463 | int rval; |
| 6464 | mbx_cmd_t mc; |
| 6465 | mbx_cmd_t *mcp = &mc; |
| 6466 | |
| 6467 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1200, |
| 6468 | "Entered %s\n", __func__); |
| 6469 | |
| 6470 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 6471 | mcp->mb[0] = MBC_GET_SET_ZIO_THRESHOLD; |
| 6472 | mcp->mb[1] = cpu_to_le16(1); |
| 6473 | mcp->mb[2] = cpu_to_le16(value); |
| 6474 | mcp->out_mb = MBX_2 | MBX_1 | MBX_0; |
| 6475 | mcp->in_mb = MBX_2 | MBX_0; |
| 6476 | mcp->tov = MBX_TOV_SECONDS; |
| 6477 | mcp->flags = 0; |
| 6478 | |
| 6479 | rval = qla2x00_mailbox_command(vha, mcp); |
| 6480 | |
| 6481 | ql_dbg(ql_dbg_mbx, vha, 0x1201, "%s %x\n", |
| 6482 | (rval != QLA_SUCCESS) ? "Failed" : "Done", rval); |
| 6483 | |
| 6484 | return rval; |
| 6485 | } |
| 6486 | |
| 6487 | int qla27xx_get_zio_threshold(scsi_qla_host_t *vha, uint16_t *value) |
| 6488 | { |
| 6489 | int rval; |
| 6490 | mbx_cmd_t mc; |
| 6491 | mbx_cmd_t *mcp = &mc; |
| 6492 | |
| 6493 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1203, |
| 6494 | "Entered %s\n", __func__); |
| 6495 | |
| 6496 | memset(mcp->mb, 0, sizeof(mcp->mb)); |
| 6497 | mcp->mb[0] = MBC_GET_SET_ZIO_THRESHOLD; |
| 6498 | mcp->mb[1] = cpu_to_le16(0); |
| 6499 | mcp->out_mb = MBX_1 | MBX_0; |
| 6500 | mcp->in_mb = MBX_2 | MBX_0; |
| 6501 | mcp->tov = MBX_TOV_SECONDS; |
| 6502 | mcp->flags = 0; |
| 6503 | |
| 6504 | rval = qla2x00_mailbox_command(vha, mcp); |
| 6505 | if (rval == QLA_SUCCESS) |
| 6506 | *value = mc.mb[2]; |
| 6507 | |
| 6508 | ql_dbg(ql_dbg_mbx, vha, 0x1205, "%s %x\n", |
| 6509 | (rval != QLA_SUCCESS) ? "Failed" : "Done", rval); |
| 6510 | |
| 6511 | return rval; |
| 6512 | } |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 6513 | |
| 6514 | int |
| 6515 | qla2x00_read_sfp_dev(struct scsi_qla_host *vha, char *buf, int count) |
| 6516 | { |
| 6517 | struct qla_hw_data *ha = vha->hw; |
| 6518 | uint16_t iter, addr, offset; |
| 6519 | dma_addr_t phys_addr; |
| 6520 | int rval, c; |
| 6521 | u8 *sfp_data; |
| 6522 | |
| 6523 | memset(ha->sfp_data, 0, SFP_DEV_SIZE); |
| 6524 | addr = 0xa0; |
| 6525 | phys_addr = ha->sfp_data_dma; |
| 6526 | sfp_data = ha->sfp_data; |
| 6527 | offset = c = 0; |
| 6528 | |
| 6529 | for (iter = 0; iter < SFP_DEV_SIZE / SFP_BLOCK_SIZE; iter++) { |
| 6530 | if (iter == 4) { |
| 6531 | /* Skip to next device address. */ |
| 6532 | addr = 0xa2; |
| 6533 | offset = 0; |
| 6534 | } |
| 6535 | |
| 6536 | rval = qla2x00_read_sfp(vha, phys_addr, sfp_data, |
| 6537 | addr, offset, SFP_BLOCK_SIZE, BIT_1); |
| 6538 | if (rval != QLA_SUCCESS) { |
| 6539 | ql_log(ql_log_warn, vha, 0x706d, |
| 6540 | "Unable to read SFP data (%x/%x/%x).\n", rval, |
| 6541 | addr, offset); |
| 6542 | |
| 6543 | return rval; |
| 6544 | } |
| 6545 | |
| 6546 | if (buf && (c < count)) { |
| 6547 | u16 sz; |
| 6548 | |
| 6549 | if ((count - c) >= SFP_BLOCK_SIZE) |
| 6550 | sz = SFP_BLOCK_SIZE; |
| 6551 | else |
| 6552 | sz = count - c; |
| 6553 | |
| 6554 | memcpy(buf, sfp_data, sz); |
| 6555 | buf += SFP_BLOCK_SIZE; |
| 6556 | c += sz; |
| 6557 | } |
| 6558 | phys_addr += SFP_BLOCK_SIZE; |
| 6559 | sfp_data += SFP_BLOCK_SIZE; |
| 6560 | offset += SFP_BLOCK_SIZE; |
| 6561 | } |
| 6562 | |
| 6563 | return rval; |
| 6564 | } |
Quinn Tran | 94d83e3 | 2017-12-28 12:33:23 -0800 | [diff] [blame] | 6565 | |
| 6566 | int qla24xx_res_count_wait(struct scsi_qla_host *vha, |
| 6567 | uint16_t *out_mb, int out_mb_sz) |
| 6568 | { |
| 6569 | int rval = QLA_FUNCTION_FAILED; |
| 6570 | mbx_cmd_t mc; |
| 6571 | |
| 6572 | if (!vha->hw->flags.fw_started) |
| 6573 | goto done; |
| 6574 | |
| 6575 | memset(&mc, 0, sizeof(mc)); |
| 6576 | mc.mb[0] = MBC_GET_RESOURCE_COUNTS; |
| 6577 | |
| 6578 | rval = qla24xx_send_mb_cmd(vha, &mc); |
| 6579 | if (rval != QLA_SUCCESS) { |
| 6580 | ql_dbg(ql_dbg_mbx, vha, 0xffff, |
| 6581 | "%s: fail\n", __func__); |
| 6582 | } else { |
| 6583 | if (out_mb_sz <= SIZEOF_IOCB_MB_REG) |
| 6584 | memcpy(out_mb, mc.mb, out_mb_sz); |
| 6585 | else |
| 6586 | memcpy(out_mb, mc.mb, SIZEOF_IOCB_MB_REG); |
| 6587 | |
| 6588 | ql_dbg(ql_dbg_mbx, vha, 0xffff, |
| 6589 | "%s: done\n", __func__); |
| 6590 | } |
| 6591 | done: |
| 6592 | return rval; |
| 6593 | } |
Michael Hernandez | 3f006ac | 2019-03-12 11:08:22 -0700 | [diff] [blame] | 6594 | |
| 6595 | int qla28xx_secure_flash_update(scsi_qla_host_t *vha, uint16_t opts, |
| 6596 | uint16_t region, uint32_t len, dma_addr_t sfub_dma_addr, |
| 6597 | uint32_t sfub_len) |
| 6598 | { |
| 6599 | int rval; |
| 6600 | mbx_cmd_t mc; |
| 6601 | mbx_cmd_t *mcp = &mc; |
| 6602 | |
| 6603 | mcp->mb[0] = MBC_SECURE_FLASH_UPDATE; |
| 6604 | mcp->mb[1] = opts; |
| 6605 | mcp->mb[2] = region; |
| 6606 | mcp->mb[3] = MSW(len); |
| 6607 | mcp->mb[4] = LSW(len); |
| 6608 | mcp->mb[5] = MSW(sfub_dma_addr); |
| 6609 | mcp->mb[6] = LSW(sfub_dma_addr); |
| 6610 | mcp->mb[7] = MSW(MSD(sfub_dma_addr)); |
| 6611 | mcp->mb[8] = LSW(MSD(sfub_dma_addr)); |
| 6612 | mcp->mb[9] = sfub_len; |
| 6613 | mcp->out_mb = |
| 6614 | MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 6615 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 6616 | mcp->tov = MBX_TOV_SECONDS; |
| 6617 | mcp->flags = 0; |
| 6618 | rval = qla2x00_mailbox_command(vha, mcp); |
| 6619 | |
| 6620 | if (rval != QLA_SUCCESS) { |
| 6621 | ql_dbg(ql_dbg_mbx, vha, 0xffff, "%s(%ld): failed rval 0x%x, %x %x %x", |
| 6622 | __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1], |
| 6623 | mcp->mb[2]); |
| 6624 | } |
| 6625 | |
| 6626 | return rval; |
| 6627 | } |
| 6628 | |
| 6629 | int qla2xxx_write_remote_register(scsi_qla_host_t *vha, uint32_t addr, |
| 6630 | uint32_t data) |
| 6631 | { |
| 6632 | int rval; |
| 6633 | mbx_cmd_t mc; |
| 6634 | mbx_cmd_t *mcp = &mc; |
| 6635 | |
| 6636 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e8, |
| 6637 | "Entered %s.\n", __func__); |
| 6638 | |
| 6639 | mcp->mb[0] = MBC_WRITE_REMOTE_REG; |
| 6640 | mcp->mb[1] = LSW(addr); |
| 6641 | mcp->mb[2] = MSW(addr); |
| 6642 | mcp->mb[3] = LSW(data); |
| 6643 | mcp->mb[4] = MSW(data); |
| 6644 | mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 6645 | mcp->in_mb = MBX_1|MBX_0; |
| 6646 | mcp->tov = MBX_TOV_SECONDS; |
| 6647 | mcp->flags = 0; |
| 6648 | rval = qla2x00_mailbox_command(vha, mcp); |
| 6649 | |
| 6650 | if (rval != QLA_SUCCESS) { |
| 6651 | ql_dbg(ql_dbg_mbx, vha, 0x10e9, |
| 6652 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 6653 | } else { |
| 6654 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ea, |
| 6655 | "Done %s.\n", __func__); |
| 6656 | } |
| 6657 | |
| 6658 | return rval; |
| 6659 | } |
| 6660 | |
| 6661 | int qla2xxx_read_remote_register(scsi_qla_host_t *vha, uint32_t addr, |
| 6662 | uint32_t *data) |
| 6663 | { |
| 6664 | int rval; |
| 6665 | mbx_cmd_t mc; |
| 6666 | mbx_cmd_t *mcp = &mc; |
| 6667 | |
| 6668 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e8, |
| 6669 | "Entered %s.\n", __func__); |
| 6670 | |
| 6671 | mcp->mb[0] = MBC_READ_REMOTE_REG; |
| 6672 | mcp->mb[1] = LSW(addr); |
| 6673 | mcp->mb[2] = MSW(addr); |
| 6674 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 6675 | mcp->in_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 6676 | mcp->tov = MBX_TOV_SECONDS; |
| 6677 | mcp->flags = 0; |
| 6678 | rval = qla2x00_mailbox_command(vha, mcp); |
| 6679 | |
| 6680 | *data = (uint32_t)((((uint32_t)mcp->mb[4]) << 16) | mcp->mb[3]); |
| 6681 | |
| 6682 | if (rval != QLA_SUCCESS) { |
| 6683 | ql_dbg(ql_dbg_mbx, vha, 0x10e9, |
| 6684 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 6685 | } else { |
| 6686 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ea, |
| 6687 | "Done %s.\n", __func__); |
| 6688 | } |
| 6689 | |
| 6690 | return rval; |
| 6691 | } |