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 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 256 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 257 | if (RD_REG_DWORD(®->isp82.hint) & |
| 258 | HINT_MBX_INT_PENDING) { |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 259 | ha->flags.mbox_busy = 0; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 260 | spin_unlock_irqrestore(&ha->hardware_lock, |
| 261 | flags); |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 262 | |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 263 | atomic_dec(&ha->num_pend_mbx_stage2); |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 264 | ql_dbg(ql_dbg_mbx, vha, 0x1010, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 265 | "Pending mailbox timeout, exiting.\n"); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 266 | rval = QLA_FUNCTION_TIMEOUT; |
| 267 | goto premature_exit; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 268 | } |
| 269 | WRT_REG_DWORD(®->isp82.hint, HINT_MBX_INT_PENDING); |
| 270 | } else if (IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 271 | WRT_REG_DWORD(®->isp24.hccr, HCCRX_SET_HOST_INT); |
| 272 | else |
| 273 | WRT_REG_WORD(®->isp.hccr, HCCR_SET_HOST_INT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 275 | |
himanshu.madhani@cavium.com | 77ddb94 | 2016-12-12 14:40:05 -0800 | [diff] [blame] | 276 | wait_time = jiffies; |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 277 | atomic_inc(&ha->num_pend_mbx_stage3); |
Giridhar Malavali | 754d124 | 2013-06-25 11:27:16 -0400 | [diff] [blame] | 278 | if (!wait_for_completion_timeout(&ha->mbx_intr_comp, |
| 279 | mcp->tov * HZ)) { |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 280 | if (chip_reset != ha->chip_reset) { |
| 281 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 282 | ha->flags.mbox_busy = 0; |
| 283 | spin_unlock_irqrestore(&ha->hardware_lock, |
| 284 | flags); |
| 285 | atomic_dec(&ha->num_pend_mbx_stage2); |
| 286 | atomic_dec(&ha->num_pend_mbx_stage3); |
| 287 | rval = QLA_ABORTED; |
| 288 | goto premature_exit; |
| 289 | } |
Giridhar Malavali | 754d124 | 2013-06-25 11:27:16 -0400 | [diff] [blame] | 290 | ql_dbg(ql_dbg_mbx, vha, 0x117a, |
| 291 | "cmd=%x Timeout.\n", command); |
| 292 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 293 | clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); |
| 294 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 295 | |
| 296 | } else if (ha->flags.purge_mbox || |
| 297 | chip_reset != ha->chip_reset) { |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 298 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 299 | ha->flags.mbox_busy = 0; |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 300 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 301 | atomic_dec(&ha->num_pend_mbx_stage2); |
| 302 | atomic_dec(&ha->num_pend_mbx_stage3); |
| 303 | rval = QLA_ABORTED; |
| 304 | goto premature_exit; |
Giridhar Malavali | 754d124 | 2013-06-25 11:27:16 -0400 | [diff] [blame] | 305 | } |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 306 | atomic_dec(&ha->num_pend_mbx_stage3); |
| 307 | |
himanshu.madhani@cavium.com | 77ddb94 | 2016-12-12 14:40:05 -0800 | [diff] [blame] | 308 | if (time_after(jiffies, wait_time + 5 * HZ)) |
| 309 | ql_log(ql_log_warn, vha, 0x1015, "cmd=0x%x, waited %d msecs\n", |
| 310 | command, jiffies_to_msecs(jiffies - wait_time)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | } else { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 312 | ql_dbg(ql_dbg_mbx, vha, 0x1011, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 313 | "Cmd=%x Polling Mode.\n", command); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 315 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 316 | if (RD_REG_DWORD(®->isp82.hint) & |
| 317 | HINT_MBX_INT_PENDING) { |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 318 | ha->flags.mbox_busy = 0; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 319 | spin_unlock_irqrestore(&ha->hardware_lock, |
| 320 | flags); |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 321 | atomic_dec(&ha->num_pend_mbx_stage2); |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 322 | ql_dbg(ql_dbg_mbx, vha, 0x1012, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 323 | "Pending mailbox timeout, exiting.\n"); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 324 | rval = QLA_FUNCTION_TIMEOUT; |
| 325 | goto premature_exit; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 326 | } |
| 327 | WRT_REG_DWORD(®->isp82.hint, HINT_MBX_INT_PENDING); |
| 328 | } else if (IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 329 | WRT_REG_DWORD(®->isp24.hccr, HCCRX_SET_HOST_INT); |
| 330 | else |
| 331 | WRT_REG_WORD(®->isp.hccr, HCCR_SET_HOST_INT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | |
| 334 | wait_time = jiffies + mcp->tov * HZ; /* wait at most tov secs */ |
| 335 | while (!ha->flags.mbox_int) { |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 336 | if (ha->flags.purge_mbox || |
| 337 | chip_reset != ha->chip_reset) { |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 338 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 339 | ha->flags.mbox_busy = 0; |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 340 | spin_unlock_irqrestore(&ha->hardware_lock, |
| 341 | flags); |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 342 | atomic_dec(&ha->num_pend_mbx_stage2); |
| 343 | rval = QLA_ABORTED; |
| 344 | goto premature_exit; |
| 345 | } |
| 346 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | if (time_after(jiffies, wait_time)) |
| 348 | break; |
| 349 | |
Rodrigo R. Galvao | 3cb182b | 2018-05-28 14:58:44 -0300 | [diff] [blame] | 350 | /* |
| 351 | * Check if it's UNLOADING, cause we cannot poll in |
| 352 | * this case, or else a NULL pointer dereference |
| 353 | * is triggered. |
| 354 | */ |
| 355 | if (unlikely(test_bit(UNLOADING, &base_vha->dpc_flags))) |
| 356 | return QLA_FUNCTION_TIMEOUT; |
| 357 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | /* Check for pending interrupts. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 359 | qla2x00_poll(ha->rsp_q_map[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 361 | if (!ha->flags.mbox_int && |
| 362 | !(IS_QLA2200(ha) && |
| 363 | command == MBC_LOAD_RISC_RAM_EXTENDED)) |
andrew.vasquez@qlogic.com | 5998983 | 2006-01-13 17:05:10 -0800 | [diff] [blame] | 364 | msleep(10); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | } /* while */ |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 366 | ql_dbg(ql_dbg_mbx, vha, 0x1013, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 367 | "Waited %d sec.\n", |
| 368 | (uint)((jiffies - (wait_time - (mcp->tov * HZ)))/HZ)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | } |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 370 | atomic_dec(&ha->num_pend_mbx_stage2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | /* Check whether we timed out */ |
| 373 | if (ha->flags.mbox_int) { |
| 374 | uint16_t *iptr2; |
| 375 | |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 376 | ql_dbg(ql_dbg_mbx, vha, 0x1014, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 377 | "Cmd=%x completed.\n", command); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | |
| 379 | /* Got interrupt. Clear the flag. */ |
| 380 | ha->flags.mbox_int = 0; |
| 381 | clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
| 382 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 383 | if (IS_P3P_TYPE(ha) && ha->flags.isp82xx_fw_hung) { |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 384 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 385 | ha->flags.mbox_busy = 0; |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 386 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 387 | |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 388 | /* Setting Link-Down error */ |
| 389 | mcp->mb[0] = MBS_LINK_DOWN_ERROR; |
| 390 | ha->mcp = NULL; |
| 391 | rval = QLA_FUNCTION_FAILED; |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 392 | ql_log(ql_log_warn, vha, 0xd048, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 393 | "FW hung = %d.\n", ha->flags.isp82xx_fw_hung); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 394 | goto premature_exit; |
| 395 | } |
| 396 | |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 397 | if (ha->mailbox_out[0] != MBS_COMMAND_COMPLETE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | rval = QLA_FUNCTION_FAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | |
| 400 | /* Load return mailbox registers. */ |
| 401 | iptr2 = mcp->mb; |
| 402 | iptr = (uint16_t *)&ha->mailbox_out[0]; |
| 403 | mboxes = mcp->in_mb; |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 404 | |
| 405 | ql_dbg(ql_dbg_mbx, vha, 0x1113, |
| 406 | "Mailbox registers (IN):\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | for (cnt = 0; cnt < ha->mbx_count; cnt++) { |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 408 | if (mboxes & BIT_0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | *iptr2 = *iptr; |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 410 | ql_dbg(ql_dbg_mbx, vha, 0x1114, |
| 411 | "mbox[%d]->0x%04x\n", cnt, *iptr2); |
| 412 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | |
| 414 | mboxes >>= 1; |
| 415 | iptr2++; |
| 416 | iptr++; |
| 417 | } |
| 418 | } else { |
| 419 | |
Quinn Tran | 8d3c9c2 | 2016-12-23 18:06:09 -0800 | [diff] [blame] | 420 | uint16_t mb[8]; |
| 421 | uint32_t ictrl, host_status, hccr; |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 422 | uint16_t w; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 423 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 424 | if (IS_FWI2_CAPABLE(ha)) { |
Quinn Tran | 8d3c9c2 | 2016-12-23 18:06:09 -0800 | [diff] [blame] | 425 | mb[0] = RD_REG_WORD(®->isp24.mailbox0); |
| 426 | mb[1] = RD_REG_WORD(®->isp24.mailbox1); |
| 427 | mb[2] = RD_REG_WORD(®->isp24.mailbox2); |
| 428 | mb[3] = RD_REG_WORD(®->isp24.mailbox3); |
| 429 | mb[7] = RD_REG_WORD(®->isp24.mailbox7); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 430 | ictrl = RD_REG_DWORD(®->isp24.ictrl); |
Quinn Tran | 8d3c9c2 | 2016-12-23 18:06:09 -0800 | [diff] [blame] | 431 | host_status = RD_REG_DWORD(®->isp24.host_status); |
| 432 | hccr = RD_REG_DWORD(®->isp24.hccr); |
| 433 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 434 | ql_log(ql_log_warn, vha, 0xd04c, |
Quinn Tran | 8d3c9c2 | 2016-12-23 18:06:09 -0800 | [diff] [blame] | 435 | "MBX Command timeout for cmd %x, iocontrol=%x jiffies=%lx " |
| 436 | "mb[0-3]=[0x%x 0x%x 0x%x 0x%x] mb7 0x%x host_status 0x%x hccr 0x%x\n", |
| 437 | command, ictrl, jiffies, mb[0], mb[1], mb[2], mb[3], |
| 438 | mb[7], host_status, hccr); |
| 439 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 440 | } else { |
Quinn Tran | 8d3c9c2 | 2016-12-23 18:06:09 -0800 | [diff] [blame] | 441 | mb[0] = RD_MAILBOX_REG(ha, ®->isp, 0); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 442 | ictrl = RD_REG_WORD(®->isp.ictrl); |
Quinn Tran | 8d3c9c2 | 2016-12-23 18:06:09 -0800 | [diff] [blame] | 443 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1119, |
| 444 | "MBX Command timeout for cmd %x, iocontrol=%x jiffies=%lx " |
| 445 | "mb[0]=0x%x\n", command, ictrl, jiffies, mb[0]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 446 | } |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 447 | ql_dump_regs(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1019); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 449 | /* Capture FW dump only, if PCI device active */ |
| 450 | if (!pci_channel_offline(vha->hw->pdev)) { |
| 451 | pci_read_config_word(ha->pdev, PCI_VENDOR_ID, &w); |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 452 | if (w == 0xffff || ictrl == 0xffffffff || |
| 453 | (chip_reset != ha->chip_reset)) { |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 454 | /* This is special case if there is unload |
| 455 | * of driver happening and if PCI device go |
| 456 | * into bad state due to PCI error condition |
| 457 | * then only PCI ERR flag would be set. |
| 458 | * we will do premature exit for above case. |
| 459 | */ |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 460 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 461 | ha->flags.mbox_busy = 0; |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 462 | spin_unlock_irqrestore(&ha->hardware_lock, |
| 463 | flags); |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 464 | rval = QLA_FUNCTION_TIMEOUT; |
| 465 | goto premature_exit; |
| 466 | } |
Chad Dupuis | f55bfc8 | 2012-02-09 11:15:53 -0800 | [diff] [blame] | 467 | |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 468 | /* Attempt to capture firmware dump for further |
| 469 | * anallysis of the current formware state. we do not |
| 470 | * need to do this if we are intentionally generating |
| 471 | * a dump |
| 472 | */ |
| 473 | if (mcp->mb[0] != MBC_GEN_SYSTEM_ERROR) |
| 474 | ha->isp_ops->fw_dump(vha, 0); |
| 475 | rval = QLA_FUNCTION_TIMEOUT; |
| 476 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | } |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 478 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | ha->flags.mbox_busy = 0; |
Quinn Tran | b6faaaf | 2018-09-04 14:19:09 -0700 | [diff] [blame] | 480 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | |
| 482 | /* Clean up */ |
| 483 | ha->mcp = NULL; |
| 484 | |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 485 | if ((abort_active || !io_lock_on) && !IS_NOPOLLING_TYPE(ha)) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 486 | ql_dbg(ql_dbg_mbx, vha, 0x101a, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 487 | "Checking for additional resp interrupt.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | |
| 489 | /* polling mode for non isp_abort commands. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 490 | qla2x00_poll(ha->rsp_q_map[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | } |
| 492 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 493 | if (rval == QLA_FUNCTION_TIMEOUT && |
| 494 | mcp->mb[0] != MBC_GEN_SYSTEM_ERROR) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 495 | if (!io_lock_on || (mcp->flags & IOCTL_CMD) || |
| 496 | ha->flags.eeh_busy) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 497 | /* not in dpc. schedule it for dpc to take over. */ |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 498 | ql_dbg(ql_dbg_mbx, vha, 0x101b, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 499 | "Timeout, schedule isp_abort_needed.\n"); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 500 | |
| 501 | if (!test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) && |
| 502 | !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) && |
| 503 | !test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) { |
Giridhar Malavali | 6315491 | 2011-11-18 09:02:19 -0800 | [diff] [blame] | 504 | if (IS_QLA82XX(ha)) { |
| 505 | ql_dbg(ql_dbg_mbx, vha, 0x112a, |
| 506 | "disabling pause transmit on port " |
| 507 | "0 & 1.\n"); |
| 508 | qla82xx_wr_32(ha, |
| 509 | QLA82XX_CRB_NIU + 0x98, |
| 510 | CRB_NIU_XG_PAUSE_CTL_P0| |
| 511 | CRB_NIU_XG_PAUSE_CTL_P1); |
| 512 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 513 | ql_log(ql_log_info, base_vha, 0x101c, |
Masanari Iida | 24d9ee8 | 2012-05-15 14:34:10 -0400 | [diff] [blame] | 514 | "Mailbox cmd timeout occurred, cmd=0x%x, " |
Chad Dupuis | d8c0d54 | 2012-02-09 11:15:46 -0800 | [diff] [blame] | 515 | "mb[0]=0x%x, eeh_busy=0x%x. Scheduling ISP " |
| 516 | "abort.\n", command, mcp->mb[0], |
| 517 | ha->flags.eeh_busy); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 518 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 519 | qla2xxx_wake_dpc(vha); |
| 520 | } |
Quinn Tran | 710bc78 | 2018-09-26 22:05:16 -0700 | [diff] [blame] | 521 | } else if (current == ha->dpc_thread) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | /* call abort directly since we are in the DPC thread */ |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 523 | ql_dbg(ql_dbg_mbx, vha, 0x101d, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 524 | "Timeout, calling abort_isp.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 526 | if (!test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) && |
| 527 | !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) && |
| 528 | !test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) { |
Giridhar Malavali | 6315491 | 2011-11-18 09:02:19 -0800 | [diff] [blame] | 529 | if (IS_QLA82XX(ha)) { |
| 530 | ql_dbg(ql_dbg_mbx, vha, 0x112b, |
| 531 | "disabling pause transmit on port " |
| 532 | "0 & 1.\n"); |
| 533 | qla82xx_wr_32(ha, |
| 534 | QLA82XX_CRB_NIU + 0x98, |
| 535 | CRB_NIU_XG_PAUSE_CTL_P0| |
| 536 | CRB_NIU_XG_PAUSE_CTL_P1); |
| 537 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 538 | ql_log(ql_log_info, base_vha, 0x101e, |
Masanari Iida | 24d9ee8 | 2012-05-15 14:34:10 -0400 | [diff] [blame] | 539 | "Mailbox cmd timeout occurred, cmd=0x%x, " |
Chad Dupuis | d8c0d54 | 2012-02-09 11:15:46 -0800 | [diff] [blame] | 540 | "mb[0]=0x%x. Scheduling ISP abort ", |
| 541 | command, mcp->mb[0]); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 542 | set_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags); |
| 543 | clear_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Giridhar Malavali | d336096 | 2012-02-09 11:14:10 -0800 | [diff] [blame] | 544 | /* Allow next mbx cmd to come in. */ |
| 545 | complete(&ha->mbx_cmd_comp); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 546 | if (ha->isp_ops->abort_isp(vha)) { |
| 547 | /* Failed. retry later. */ |
| 548 | set_bit(ISP_ABORT_NEEDED, |
| 549 | &vha->dpc_flags); |
| 550 | } |
| 551 | clear_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags); |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 552 | ql_dbg(ql_dbg_mbx, vha, 0x101f, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 553 | "Finished abort_isp.\n"); |
Giridhar Malavali | d336096 | 2012-02-09 11:14:10 -0800 | [diff] [blame] | 554 | goto mbx_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | } |
| 557 | } |
| 558 | |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 559 | premature_exit: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | /* Allow next mbx cmd to come in. */ |
Andrew Vasquez | 8eca3f3 | 2009-01-22 09:45:31 -0800 | [diff] [blame] | 561 | complete(&ha->mbx_cmd_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | |
Giridhar Malavali | d336096 | 2012-02-09 11:14:10 -0800 | [diff] [blame] | 563 | mbx_done: |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 564 | if (rval == QLA_ABORTED) { |
| 565 | ql_log(ql_log_info, vha, 0xd035, |
| 566 | "Chip Reset in progress. Purging Mbox cmd=0x%x.\n", |
| 567 | mcp->mb[0]); |
| 568 | } else if (rval) { |
Joe Carnuccio | 050dc76 | 2017-08-23 15:05:14 -0700 | [diff] [blame] | 569 | if (ql2xextended_error_logging & (ql_dbg_disc|ql_dbg_mbx)) { |
| 570 | pr_warn("%s [%s]-%04x:%ld: **** Failed", QL_MSGHDR, |
| 571 | dev_name(&ha->pdev->dev), 0x1020+0x800, |
| 572 | vha->host_no); |
| 573 | mboxes = mcp->in_mb; |
| 574 | cnt = 4; |
| 575 | for (i = 0; i < ha->mbx_count && cnt; i++, mboxes >>= 1) |
| 576 | if (mboxes & BIT_0) { |
| 577 | printk(" mb[%u]=%x", i, mcp->mb[i]); |
| 578 | cnt--; |
| 579 | } |
| 580 | pr_warn(" cmd=%x ****\n", command); |
| 581 | } |
Meelis Roos | f7e59e9 | 2018-03-08 15:44:07 +0200 | [diff] [blame] | 582 | if (IS_FWI2_CAPABLE(ha) && !(IS_P3P_TYPE(ha))) { |
| 583 | ql_dbg(ql_dbg_mbx, vha, 0x1198, |
| 584 | "host_status=%#x intr_ctrl=%#x intr_status=%#x\n", |
| 585 | RD_REG_DWORD(®->isp24.host_status), |
| 586 | RD_REG_DWORD(®->isp24.ictrl), |
| 587 | RD_REG_DWORD(®->isp24.istatus)); |
| 588 | } else { |
| 589 | ql_dbg(ql_dbg_mbx, vha, 0x1206, |
| 590 | "ctrl_status=%#x ictrl=%#x istatus=%#x\n", |
| 591 | RD_REG_WORD(®->isp.ctrl_status), |
| 592 | RD_REG_WORD(®->isp.ictrl), |
| 593 | RD_REG_WORD(®->isp.istatus)); |
| 594 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 596 | ql_dbg(ql_dbg_mbx, base_vha, 0x1021, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | } |
| 598 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | return rval; |
| 600 | } |
| 601 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 603 | 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] | 604 | uint32_t risc_code_size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | { |
| 606 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 607 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | mbx_cmd_t mc; |
| 609 | mbx_cmd_t *mcp = &mc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 611 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1022, |
| 612 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 614 | if (MSW(risc_addr) || IS_FWI2_CAPABLE(ha)) { |
andrew.vasquez@qlogic.com | 590f98e | 2006-01-13 17:05:37 -0800 | [diff] [blame] | 615 | mcp->mb[0] = MBC_LOAD_RISC_RAM_EXTENDED; |
| 616 | mcp->mb[8] = MSW(risc_addr); |
| 617 | mcp->out_mb = MBX_8|MBX_0; |
| 618 | } else { |
| 619 | mcp->mb[0] = MBC_LOAD_RISC_RAM; |
| 620 | mcp->out_mb = MBX_0; |
| 621 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | mcp->mb[1] = LSW(risc_addr); |
| 623 | mcp->mb[2] = MSW(req_dma); |
| 624 | mcp->mb[3] = LSW(req_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 625 | mcp->mb[6] = MSW(MSD(req_dma)); |
| 626 | mcp->mb[7] = LSW(MSD(req_dma)); |
andrew.vasquez@qlogic.com | 590f98e | 2006-01-13 17:05:37 -0800 | [diff] [blame] | 627 | 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] | 628 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 629 | mcp->mb[4] = MSW(risc_code_size); |
| 630 | mcp->mb[5] = LSW(risc_code_size); |
| 631 | mcp->out_mb |= MBX_5|MBX_4; |
| 632 | } else { |
| 633 | mcp->mb[4] = LSW(risc_code_size); |
| 634 | mcp->out_mb |= MBX_4; |
| 635 | } |
| 636 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 638 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 640 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 641 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 642 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 643 | ql_dbg(ql_dbg_mbx, vha, 0x1023, |
| 644 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 646 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1024, |
| 647 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 648 | } |
| 649 | |
| 650 | return rval; |
| 651 | } |
| 652 | |
Santosh Vernekar | cad454b | 2010-03-19 16:59:16 -0700 | [diff] [blame] | 653 | #define EXTENDED_BB_CREDITS BIT_0 |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 654 | #define NVME_ENABLE_FLAG BIT_3 |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 655 | static inline uint16_t qla25xx_set_sfp_lr_dist(struct qla_hw_data *ha) |
| 656 | { |
| 657 | uint16_t mb4 = BIT_0; |
| 658 | |
| 659 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
| 660 | mb4 |= ha->long_range_distance << LR_DIST_FW_POS; |
| 661 | |
| 662 | return mb4; |
| 663 | } |
| 664 | |
| 665 | static inline uint16_t qla25xx_set_nvr_lr_dist(struct qla_hw_data *ha) |
| 666 | { |
| 667 | uint16_t mb4 = BIT_0; |
| 668 | |
| 669 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
| 670 | struct nvram_81xx *nv = ha->nvram; |
| 671 | |
| 672 | mb4 |= LR_DIST_FW_FIELD(nv->enhanced_features); |
| 673 | } |
| 674 | |
| 675 | return mb4; |
| 676 | } |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 677 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | /* |
| 679 | * qla2x00_execute_fw |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 680 | * Start adapter firmware. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | * |
| 682 | * Input: |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 683 | * ha = adapter block pointer. |
| 684 | * TARGET_QUEUE_LOCK must be released. |
| 685 | * ADAPTER_STATE_LOCK must be released. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | * |
| 687 | * Returns: |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 688 | * qla2x00 local function return status code. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | * |
| 690 | * Context: |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 691 | * Kernel context. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 692 | */ |
| 693 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 694 | qla2x00_execute_fw(scsi_qla_host_t *vha, uint32_t risc_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | { |
| 696 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 697 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 698 | mbx_cmd_t mc; |
| 699 | mbx_cmd_t *mcp = &mc; |
| 700 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 701 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1025, |
| 702 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 703 | |
| 704 | mcp->mb[0] = MBC_EXECUTE_FIRMWARE; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 705 | mcp->out_mb = MBX_0; |
| 706 | mcp->in_mb = MBX_0; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 707 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 708 | mcp->mb[1] = MSW(risc_addr); |
| 709 | mcp->mb[2] = LSW(risc_addr); |
| 710 | mcp->mb[3] = 0; |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 711 | mcp->mb[4] = 0; |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 712 | ha->flags.using_lr_setting = 0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 713 | if (IS_QLA25XX(ha) || IS_QLA81XX(ha) || IS_QLA83XX(ha) || |
| 714 | IS_QLA27XX(ha)) { |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 715 | if (ql2xautodetectsfp) { |
| 716 | if (ha->flags.detected_lr_sfp) { |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 717 | mcp->mb[4] |= |
| 718 | qla25xx_set_sfp_lr_dist(ha); |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 719 | ha->flags.using_lr_setting = 1; |
| 720 | } |
| 721 | } else { |
| 722 | struct nvram_81xx *nv = ha->nvram; |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 723 | /* set LR distance if specified in nvram */ |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 724 | if (nv->enhanced_features & |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 725 | NEF_LR_DIST_ENABLE) { |
| 726 | mcp->mb[4] |= |
| 727 | qla25xx_set_nvr_lr_dist(ha); |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 728 | ha->flags.using_lr_setting = 1; |
| 729 | } |
| 730 | } |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 731 | } |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 732 | |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 733 | if (ql2xnvmeenable && IS_QLA27XX(ha)) |
| 734 | mcp->mb[4] |= NVME_ENABLE_FLAG; |
| 735 | |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 736 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
| 737 | struct nvram_81xx *nv = ha->nvram; |
| 738 | /* set minimum speed if specified in nvram */ |
| 739 | if (nv->min_link_speed >= 2 && |
| 740 | nv->min_link_speed <= 5) { |
| 741 | mcp->mb[4] |= BIT_4; |
| 742 | mcp->mb[11] = nv->min_link_speed; |
| 743 | mcp->out_mb |= MBX_11; |
| 744 | mcp->in_mb |= BIT_5; |
| 745 | vha->min_link_speed_feat = nv->min_link_speed; |
| 746 | } |
| 747 | } |
| 748 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 749 | if (ha->flags.exlogins_enabled) |
| 750 | mcp->mb[4] |= ENABLE_EXTENDED_LOGIN; |
| 751 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 752 | if (ha->flags.exchoffld_enabled) |
| 753 | mcp->mb[4] |= ENABLE_EXCHANGE_OFFLD; |
| 754 | |
Andrew Vasquez | 8b3253d | 2007-09-20 14:07:48 -0700 | [diff] [blame] | 755 | mcp->out_mb |= MBX_4|MBX_3|MBX_2|MBX_1; |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 756 | mcp->in_mb |= MBX_3 | MBX_2 | MBX_1; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 757 | } else { |
| 758 | mcp->mb[1] = LSW(risc_addr); |
| 759 | mcp->out_mb |= MBX_1; |
| 760 | if (IS_QLA2322(ha) || IS_QLA6322(ha)) { |
| 761 | mcp->mb[2] = 0; |
| 762 | mcp->out_mb |= MBX_2; |
| 763 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 764 | } |
| 765 | |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 766 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 767 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 768 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 769 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 770 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 771 | ql_dbg(ql_dbg_mbx, vha, 0x1026, |
| 772 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 773 | } else { |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 774 | if (IS_FWI2_CAPABLE(ha)) { |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 775 | ha->fw_ability_mask = mcp->mb[3] << 16 | mcp->mb[2]; |
| 776 | ql_dbg(ql_dbg_mbx, vha, 0x119a, |
| 777 | "fw_ability_mask=%x.\n", ha->fw_ability_mask); |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 778 | ql_dbg(ql_dbg_mbx, vha, 0x1027, |
| 779 | "exchanges=%x.\n", mcp->mb[1]); |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 780 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
| 781 | ha->max_speed_sup = mcp->mb[2] & BIT_0; |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 782 | ql_dbg(ql_dbg_mbx, vha, 0x119b, |
| 783 | "Maximum speed supported=%s.\n", |
| 784 | ha->max_speed_sup ? "32Gps" : "16Gps"); |
| 785 | if (vha->min_link_speed_feat) { |
| 786 | ha->min_link_speed = mcp->mb[5]; |
| 787 | ql_dbg(ql_dbg_mbx, vha, 0x119c, |
| 788 | "Minimum speed set=%s.\n", |
| 789 | mcp->mb[5] == 5 ? "32Gps" : |
| 790 | mcp->mb[5] == 4 ? "16Gps" : |
| 791 | mcp->mb[5] == 3 ? "8Gps" : |
| 792 | mcp->mb[5] == 2 ? "4Gps" : |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 793 | "unknown"); |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 794 | } |
| 795 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 796 | } |
Joe Carnuccio | 1f4c7c3 | 2017-08-23 15:05:17 -0700 | [diff] [blame] | 797 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1028, |
| 798 | "Done.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 799 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 800 | |
| 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; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 1056 | if (IS_QLA27XX(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| |
| 1059 | MBX_14|MBX_13|MBX_11|MBX_10|MBX_9|MBX_8; |
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 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 1125 | if (IS_QLA27XX(ha)) { |
Sawan Chandak | 03aa868 | 2015-08-04 13:37:59 -0400 | [diff] [blame] | 1126 | ha->mpi_version[0] = mcp->mb[10] & 0xff; |
| 1127 | ha->mpi_version[1] = mcp->mb[11] >> 8; |
| 1128 | ha->mpi_version[2] = mcp->mb[11] & 0xff; |
| 1129 | ha->pep_version[0] = mcp->mb[13] & 0xff; |
| 1130 | ha->pep_version[1] = mcp->mb[14] >> 8; |
| 1131 | ha->pep_version[2] = mcp->mb[14] & 0xff; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 1132 | ha->fw_shared_ram_start = (mcp->mb[19] << 16) | mcp->mb[18]; |
| 1133 | ha->fw_shared_ram_end = (mcp->mb[21] << 16) | mcp->mb[20]; |
Joe Carnuccio | ad1ef17 | 2016-07-06 11:14:18 -0400 | [diff] [blame] | 1134 | ha->fw_ddr_ram_start = (mcp->mb[23] << 16) | mcp->mb[22]; |
| 1135 | ha->fw_ddr_ram_end = (mcp->mb[25] << 16) | mcp->mb[24]; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 1136 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1137 | |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 1138 | failed: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1139 | if (rval != QLA_SUCCESS) { |
| 1140 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1141 | ql_dbg(ql_dbg_mbx, vha, 0x102a, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1142 | } else { |
| 1143 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1144 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102b, |
| 1145 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1146 | } |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 1147 | return rval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1148 | } |
| 1149 | |
| 1150 | /* |
| 1151 | * qla2x00_get_fw_options |
| 1152 | * Set firmware options. |
| 1153 | * |
| 1154 | * Input: |
| 1155 | * ha = adapter block pointer. |
| 1156 | * fwopt = pointer for firmware options. |
| 1157 | * |
| 1158 | * Returns: |
| 1159 | * qla2x00 local function return status code. |
| 1160 | * |
| 1161 | * Context: |
| 1162 | * Kernel context. |
| 1163 | */ |
| 1164 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1165 | qla2x00_get_fw_options(scsi_qla_host_t *vha, uint16_t *fwopts) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1166 | { |
| 1167 | int rval; |
| 1168 | mbx_cmd_t mc; |
| 1169 | mbx_cmd_t *mcp = &mc; |
| 1170 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1171 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102c, |
| 1172 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1173 | |
| 1174 | mcp->mb[0] = MBC_GET_FIRMWARE_OPTION; |
| 1175 | mcp->out_mb = MBX_0; |
| 1176 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1177 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1178 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1179 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1180 | |
| 1181 | if (rval != QLA_SUCCESS) { |
| 1182 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1183 | ql_dbg(ql_dbg_mbx, vha, 0x102d, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1184 | } else { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1185 | fwopts[0] = mcp->mb[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1186 | fwopts[1] = mcp->mb[1]; |
| 1187 | fwopts[2] = mcp->mb[2]; |
| 1188 | fwopts[3] = mcp->mb[3]; |
| 1189 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1190 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102e, |
| 1191 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1192 | } |
| 1193 | |
| 1194 | return rval; |
| 1195 | } |
| 1196 | |
| 1197 | |
| 1198 | /* |
| 1199 | * qla2x00_set_fw_options |
| 1200 | * Set firmware options. |
| 1201 | * |
| 1202 | * Input: |
| 1203 | * ha = adapter block pointer. |
| 1204 | * fwopt = pointer for firmware options. |
| 1205 | * |
| 1206 | * Returns: |
| 1207 | * qla2x00 local function return status code. |
| 1208 | * |
| 1209 | * Context: |
| 1210 | * Kernel context. |
| 1211 | */ |
| 1212 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1213 | qla2x00_set_fw_options(scsi_qla_host_t *vha, uint16_t *fwopts) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1214 | { |
| 1215 | int rval; |
| 1216 | mbx_cmd_t mc; |
| 1217 | mbx_cmd_t *mcp = &mc; |
| 1218 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1219 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102f, |
| 1220 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1221 | |
| 1222 | mcp->mb[0] = MBC_SET_FIRMWARE_OPTION; |
| 1223 | mcp->mb[1] = fwopts[1]; |
| 1224 | mcp->mb[2] = fwopts[2]; |
| 1225 | mcp->mb[3] = fwopts[3]; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1226 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1227 | mcp->in_mb = MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1228 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1229 | mcp->in_mb |= MBX_1; |
Quinn Tran | 2da5273 | 2017-06-02 09:12:05 -0700 | [diff] [blame] | 1230 | mcp->mb[10] = fwopts[10]; |
| 1231 | mcp->out_mb |= MBX_10; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1232 | } else { |
| 1233 | mcp->mb[10] = fwopts[10]; |
| 1234 | mcp->mb[11] = fwopts[11]; |
| 1235 | mcp->mb[12] = 0; /* Undocumented, but used */ |
| 1236 | mcp->out_mb |= MBX_12|MBX_11|MBX_10; |
| 1237 | } |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1238 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1239 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1240 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1241 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1242 | fwopts[0] = mcp->mb[0]; |
| 1243 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1244 | if (rval != QLA_SUCCESS) { |
| 1245 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1246 | ql_dbg(ql_dbg_mbx, vha, 0x1030, |
| 1247 | "Failed=%x (%x/%x).\n", rval, mcp->mb[0], mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1248 | } else { |
| 1249 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1250 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1031, |
| 1251 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1252 | } |
| 1253 | |
| 1254 | return rval; |
| 1255 | } |
| 1256 | |
| 1257 | /* |
| 1258 | * qla2x00_mbx_reg_test |
| 1259 | * Mailbox register wrap test. |
| 1260 | * |
| 1261 | * Input: |
| 1262 | * ha = adapter block pointer. |
| 1263 | * TARGET_QUEUE_LOCK must be released. |
| 1264 | * ADAPTER_STATE_LOCK must be released. |
| 1265 | * |
| 1266 | * Returns: |
| 1267 | * qla2x00 local function return status code. |
| 1268 | * |
| 1269 | * Context: |
| 1270 | * Kernel context. |
| 1271 | */ |
| 1272 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1273 | qla2x00_mbx_reg_test(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1274 | { |
| 1275 | int rval; |
| 1276 | mbx_cmd_t mc; |
| 1277 | mbx_cmd_t *mcp = &mc; |
| 1278 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1279 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1032, |
| 1280 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1281 | |
| 1282 | mcp->mb[0] = MBC_MAILBOX_REGISTER_TEST; |
| 1283 | mcp->mb[1] = 0xAAAA; |
| 1284 | mcp->mb[2] = 0x5555; |
| 1285 | mcp->mb[3] = 0xAA55; |
| 1286 | mcp->mb[4] = 0x55AA; |
| 1287 | mcp->mb[5] = 0xA5A5; |
| 1288 | mcp->mb[6] = 0x5A5A; |
| 1289 | mcp->mb[7] = 0x2525; |
| 1290 | mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 1291 | 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] | 1292 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1293 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1294 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1295 | |
| 1296 | if (rval == QLA_SUCCESS) { |
| 1297 | if (mcp->mb[1] != 0xAAAA || mcp->mb[2] != 0x5555 || |
| 1298 | mcp->mb[3] != 0xAA55 || mcp->mb[4] != 0x55AA) |
| 1299 | rval = QLA_FUNCTION_FAILED; |
| 1300 | if (mcp->mb[5] != 0xA5A5 || mcp->mb[6] != 0x5A5A || |
| 1301 | mcp->mb[7] != 0x2525) |
| 1302 | rval = QLA_FUNCTION_FAILED; |
| 1303 | } |
| 1304 | |
| 1305 | if (rval != QLA_SUCCESS) { |
| 1306 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1307 | ql_dbg(ql_dbg_mbx, vha, 0x1033, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1308 | } else { |
| 1309 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1310 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1034, |
| 1311 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1312 | } |
| 1313 | |
| 1314 | return rval; |
| 1315 | } |
| 1316 | |
| 1317 | /* |
| 1318 | * qla2x00_verify_checksum |
| 1319 | * Verify firmware checksum. |
| 1320 | * |
| 1321 | * Input: |
| 1322 | * ha = adapter block pointer. |
| 1323 | * TARGET_QUEUE_LOCK must be released. |
| 1324 | * ADAPTER_STATE_LOCK must be released. |
| 1325 | * |
| 1326 | * Returns: |
| 1327 | * qla2x00 local function return status code. |
| 1328 | * |
| 1329 | * Context: |
| 1330 | * Kernel context. |
| 1331 | */ |
| 1332 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1333 | qla2x00_verify_checksum(scsi_qla_host_t *vha, uint32_t risc_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1334 | { |
| 1335 | int rval; |
| 1336 | mbx_cmd_t mc; |
| 1337 | mbx_cmd_t *mcp = &mc; |
| 1338 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1339 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1035, |
| 1340 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1341 | |
| 1342 | mcp->mb[0] = MBC_VERIFY_CHECKSUM; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1343 | mcp->out_mb = MBX_0; |
| 1344 | mcp->in_mb = MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1345 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1346 | mcp->mb[1] = MSW(risc_addr); |
| 1347 | mcp->mb[2] = LSW(risc_addr); |
| 1348 | mcp->out_mb |= MBX_2|MBX_1; |
| 1349 | mcp->in_mb |= MBX_2|MBX_1; |
| 1350 | } else { |
| 1351 | mcp->mb[1] = LSW(risc_addr); |
| 1352 | mcp->out_mb |= MBX_1; |
| 1353 | mcp->in_mb |= MBX_1; |
| 1354 | } |
| 1355 | |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1356 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1357 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1358 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1359 | |
| 1360 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1361 | ql_dbg(ql_dbg_mbx, vha, 0x1036, |
| 1362 | "Failed=%x chm sum=%x.\n", rval, IS_FWI2_CAPABLE(vha->hw) ? |
| 1363 | (mcp->mb[2] << 16) | mcp->mb[1] : mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1364 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1365 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1037, |
| 1366 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1367 | } |
| 1368 | |
| 1369 | return rval; |
| 1370 | } |
| 1371 | |
| 1372 | /* |
| 1373 | * qla2x00_issue_iocb |
| 1374 | * Issue IOCB using mailbox command |
| 1375 | * |
| 1376 | * Input: |
| 1377 | * ha = adapter state pointer. |
| 1378 | * buffer = buffer pointer. |
| 1379 | * phys_addr = physical address of buffer. |
| 1380 | * size = size of buffer. |
| 1381 | * TARGET_QUEUE_LOCK must be released. |
| 1382 | * ADAPTER_STATE_LOCK must be released. |
| 1383 | * |
| 1384 | * Returns: |
| 1385 | * qla2x00 local function return status code. |
| 1386 | * |
| 1387 | * Context: |
| 1388 | * Kernel context. |
| 1389 | */ |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 1390 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1391 | qla2x00_issue_iocb_timeout(scsi_qla_host_t *vha, void *buffer, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1392 | dma_addr_t phys_addr, size_t size, uint32_t tov) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1393 | { |
| 1394 | int rval; |
| 1395 | mbx_cmd_t mc; |
| 1396 | mbx_cmd_t *mcp = &mc; |
| 1397 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1398 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1038, |
| 1399 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1400 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1401 | mcp->mb[0] = MBC_IOCB_COMMAND_A64; |
| 1402 | mcp->mb[1] = 0; |
| 1403 | mcp->mb[2] = MSW(phys_addr); |
| 1404 | mcp->mb[3] = LSW(phys_addr); |
| 1405 | mcp->mb[6] = MSW(MSD(phys_addr)); |
| 1406 | mcp->mb[7] = LSW(MSD(phys_addr)); |
| 1407 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 1408 | mcp->in_mb = MBX_2|MBX_0; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1409 | mcp->tov = tov; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1410 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1411 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1412 | |
| 1413 | if (rval != QLA_SUCCESS) { |
| 1414 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1415 | ql_dbg(ql_dbg_mbx, vha, 0x1039, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1416 | } else { |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 1417 | sts_entry_t *sts_entry = (sts_entry_t *) buffer; |
| 1418 | |
| 1419 | /* Mask reserved bits. */ |
| 1420 | sts_entry->entry_status &= |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1421 | IS_FWI2_CAPABLE(vha->hw) ? RF_MASK_24XX : RF_MASK; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1422 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103a, |
| 1423 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1424 | } |
| 1425 | |
| 1426 | return rval; |
| 1427 | } |
| 1428 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1429 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1430 | 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] | 1431 | size_t size) |
| 1432 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1433 | return qla2x00_issue_iocb_timeout(vha, buffer, phys_addr, size, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1434 | MBX_TOV_SECONDS); |
| 1435 | } |
| 1436 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1437 | /* |
| 1438 | * qla2x00_abort_command |
| 1439 | * Abort command aborts a specified IOCB. |
| 1440 | * |
| 1441 | * Input: |
| 1442 | * ha = adapter block pointer. |
| 1443 | * sp = SB structure pointer. |
| 1444 | * |
| 1445 | * Returns: |
| 1446 | * qla2x00 local function return status code. |
| 1447 | * |
| 1448 | * Context: |
| 1449 | * Kernel context. |
| 1450 | */ |
| 1451 | int |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1452 | qla2x00_abort_command(srb_t *sp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1453 | { |
| 1454 | unsigned long flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1455 | int rval; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1456 | uint32_t handle = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1457 | mbx_cmd_t mc; |
| 1458 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1459 | fc_port_t *fcport = sp->fcport; |
| 1460 | scsi_qla_host_t *vha = fcport->vha; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1461 | struct qla_hw_data *ha = vha->hw; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1462 | struct req_que *req; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1463 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1464 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1465 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103b, |
| 1466 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1467 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1468 | if (vha->flags.qpairs_available && sp->qpair) |
| 1469 | req = sp->qpair->req; |
| 1470 | else |
| 1471 | req = vha->req; |
| 1472 | |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 1473 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1474 | for (handle = 1; handle < req->num_outstanding_cmds; handle++) { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1475 | if (req->outstanding_cmds[handle] == sp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1476 | break; |
| 1477 | } |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 1478 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1479 | |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1480 | if (handle == req->num_outstanding_cmds) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1481 | /* command not found */ |
| 1482 | return QLA_FUNCTION_FAILED; |
| 1483 | } |
| 1484 | |
| 1485 | mcp->mb[0] = MBC_ABORT_COMMAND; |
| 1486 | if (HAS_EXTENDED_IDS(ha)) |
| 1487 | mcp->mb[1] = fcport->loop_id; |
| 1488 | else |
| 1489 | mcp->mb[1] = fcport->loop_id << 8; |
| 1490 | mcp->mb[2] = (uint16_t)handle; |
| 1491 | mcp->mb[3] = (uint16_t)(handle >> 16); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1492 | mcp->mb[6] = (uint16_t)cmd->device->lun; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1493 | mcp->out_mb = MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 1494 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1495 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1496 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1497 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1498 | |
| 1499 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1500 | ql_dbg(ql_dbg_mbx, vha, 0x103c, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1501 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1502 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103d, |
| 1503 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1504 | } |
| 1505 | |
| 1506 | return rval; |
| 1507 | } |
| 1508 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1509 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1510 | qla2x00_abort_target(struct fc_port *fcport, uint64_t l, int tag) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1511 | { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1512 | int rval, rval2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1513 | mbx_cmd_t mc; |
| 1514 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1515 | scsi_qla_host_t *vha; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1516 | struct req_que *req; |
| 1517 | struct rsp_que *rsp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1518 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1519 | vha = fcport->vha; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1520 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1521 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103e, |
| 1522 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1523 | |
Giridhar Malavali | 7e2b895 | 2010-05-28 15:08:17 -0700 | [diff] [blame] | 1524 | req = vha->hw->req_q_map[0]; |
| 1525 | rsp = req->rsp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1526 | mcp->mb[0] = MBC_ABORT_TARGET; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1527 | mcp->out_mb = MBX_9|MBX_2|MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1528 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1529 | mcp->mb[1] = fcport->loop_id; |
| 1530 | mcp->mb[10] = 0; |
| 1531 | mcp->out_mb |= MBX_10; |
| 1532 | } else { |
| 1533 | mcp->mb[1] = fcport->loop_id << 8; |
| 1534 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1535 | mcp->mb[2] = vha->hw->loop_reset_delay; |
| 1536 | mcp->mb[9] = vha->vp_idx; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1537 | |
| 1538 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1539 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1540 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1541 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1542 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1543 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103f, |
| 1544 | "Failed=%x.\n", rval); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1545 | } |
| 1546 | |
| 1547 | /* Issue marker IOCB. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1548 | rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, 0, |
| 1549 | MK_SYNC_ID); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1550 | if (rval2 != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1551 | ql_dbg(ql_dbg_mbx, vha, 0x1040, |
| 1552 | "Failed to issue marker IOCB (%x).\n", rval2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1553 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1554 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1041, |
| 1555 | "Done %s.\n", __func__); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1556 | } |
| 1557 | |
| 1558 | return rval; |
| 1559 | } |
| 1560 | |
| 1561 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1562 | qla2x00_lun_reset(struct fc_port *fcport, uint64_t l, int tag) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1563 | { |
| 1564 | int rval, rval2; |
| 1565 | mbx_cmd_t mc; |
| 1566 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1567 | scsi_qla_host_t *vha; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1568 | struct req_que *req; |
| 1569 | struct rsp_que *rsp; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1570 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1571 | vha = fcport->vha; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1572 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1573 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1042, |
| 1574 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1575 | |
Giridhar Malavali | 7e2b895 | 2010-05-28 15:08:17 -0700 | [diff] [blame] | 1576 | req = vha->hw->req_q_map[0]; |
| 1577 | rsp = req->rsp; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1578 | mcp->mb[0] = MBC_LUN_RESET; |
| 1579 | 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] | 1580 | if (HAS_EXTENDED_IDS(vha->hw)) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1581 | mcp->mb[1] = fcport->loop_id; |
| 1582 | else |
| 1583 | mcp->mb[1] = fcport->loop_id << 8; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1584 | mcp->mb[2] = (u32)l; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1585 | mcp->mb[3] = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1586 | mcp->mb[9] = vha->vp_idx; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1587 | |
| 1588 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1589 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1590 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1591 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1592 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1593 | ql_dbg(ql_dbg_mbx, vha, 0x1043, "Failed=%x.\n", rval); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1594 | } |
| 1595 | |
| 1596 | /* Issue marker IOCB. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1597 | rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, l, |
| 1598 | MK_SYNC_ID_LUN); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1599 | if (rval2 != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1600 | ql_dbg(ql_dbg_mbx, vha, 0x1044, |
| 1601 | "Failed to issue marker IOCB (%x).\n", rval2); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1602 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1603 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1045, |
| 1604 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1605 | } |
| 1606 | |
| 1607 | return rval; |
| 1608 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1609 | |
| 1610 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1611 | * qla2x00_get_adapter_id |
| 1612 | * Get adapter ID and topology. |
| 1613 | * |
| 1614 | * Input: |
| 1615 | * ha = adapter block pointer. |
| 1616 | * id = pointer for loop ID. |
| 1617 | * al_pa = pointer for AL_PA. |
| 1618 | * area = pointer for area. |
| 1619 | * domain = pointer for domain. |
| 1620 | * top = pointer for topology. |
| 1621 | * TARGET_QUEUE_LOCK must be released. |
| 1622 | * ADAPTER_STATE_LOCK must be released. |
| 1623 | * |
| 1624 | * Returns: |
| 1625 | * qla2x00 local function return status code. |
| 1626 | * |
| 1627 | * Context: |
| 1628 | * Kernel context. |
| 1629 | */ |
| 1630 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1631 | 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] | 1632 | 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] | 1633 | { |
| 1634 | int rval; |
| 1635 | mbx_cmd_t mc; |
| 1636 | mbx_cmd_t *mcp = &mc; |
| 1637 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1638 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1046, |
| 1639 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1640 | |
| 1641 | mcp->mb[0] = MBC_GET_ADAPTER_LOOP_ID; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1642 | mcp->mb[9] = vha->vp_idx; |
Andrew Vasquez | eb66dc6 | 2007-11-12 10:30:58 -0800 | [diff] [blame] | 1643 | mcp->out_mb = MBX_9|MBX_0; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1644 | 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] | 1645 | if (IS_CNA_CAPABLE(vha->hw)) |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1646 | mcp->in_mb |= MBX_13|MBX_12|MBX_11|MBX_10; |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 1647 | if (IS_FWI2_CAPABLE(vha->hw)) |
| 1648 | mcp->in_mb |= MBX_19|MBX_18|MBX_17|MBX_16; |
Sawan Chandak | 969a619 | 2016-01-27 12:03:32 -0500 | [diff] [blame] | 1649 | if (IS_QLA27XX(vha->hw)) |
| 1650 | mcp->in_mb |= MBX_15; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1651 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1652 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1653 | rval = qla2x00_mailbox_command(vha, mcp); |
Ravi Anand | 33135aa | 2005-11-08 14:37:20 -0800 | [diff] [blame] | 1654 | if (mcp->mb[0] == MBS_COMMAND_ERROR) |
| 1655 | rval = QLA_COMMAND_ERROR; |
Andrew Vasquez | 42e421b | 2008-07-10 16:56:01 -0700 | [diff] [blame] | 1656 | else if (mcp->mb[0] == MBS_INVALID_COMMAND) |
| 1657 | rval = QLA_INVALID_COMMAND; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1658 | |
| 1659 | /* Return data. */ |
| 1660 | *id = mcp->mb[1]; |
| 1661 | *al_pa = LSB(mcp->mb[2]); |
| 1662 | *area = MSB(mcp->mb[2]); |
| 1663 | *domain = LSB(mcp->mb[3]); |
| 1664 | *top = mcp->mb[6]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1665 | *sw_cap = mcp->mb[7]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1666 | |
| 1667 | if (rval != QLA_SUCCESS) { |
| 1668 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1669 | ql_dbg(ql_dbg_mbx, vha, 0x1047, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1670 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1671 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1048, |
| 1672 | "Done %s.\n", __func__); |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1673 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1674 | if (IS_CNA_CAPABLE(vha->hw)) { |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1675 | vha->fcoe_vlan_id = mcp->mb[9] & 0xfff; |
| 1676 | vha->fcoe_fcf_idx = mcp->mb[10]; |
| 1677 | vha->fcoe_vn_port_mac[5] = mcp->mb[11] >> 8; |
| 1678 | vha->fcoe_vn_port_mac[4] = mcp->mb[11] & 0xff; |
| 1679 | vha->fcoe_vn_port_mac[3] = mcp->mb[12] >> 8; |
| 1680 | vha->fcoe_vn_port_mac[2] = mcp->mb[12] & 0xff; |
| 1681 | vha->fcoe_vn_port_mac[1] = mcp->mb[13] >> 8; |
| 1682 | vha->fcoe_vn_port_mac[0] = mcp->mb[13] & 0xff; |
| 1683 | } |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 1684 | /* If FA-WWN supported */ |
Saurav Kashyap | d6b9b42 | 2015-08-04 13:37:55 -0400 | [diff] [blame] | 1685 | if (IS_FAWWN_CAPABLE(vha->hw)) { |
| 1686 | if (mcp->mb[7] & BIT_14) { |
| 1687 | vha->port_name[0] = MSB(mcp->mb[16]); |
| 1688 | vha->port_name[1] = LSB(mcp->mb[16]); |
| 1689 | vha->port_name[2] = MSB(mcp->mb[17]); |
| 1690 | vha->port_name[3] = LSB(mcp->mb[17]); |
| 1691 | vha->port_name[4] = MSB(mcp->mb[18]); |
| 1692 | vha->port_name[5] = LSB(mcp->mb[18]); |
| 1693 | vha->port_name[6] = MSB(mcp->mb[19]); |
| 1694 | vha->port_name[7] = LSB(mcp->mb[19]); |
| 1695 | fc_host_port_name(vha->host) = |
| 1696 | wwn_to_u64(vha->port_name); |
| 1697 | ql_dbg(ql_dbg_mbx, vha, 0x10ca, |
| 1698 | "FA-WWN acquired %016llx\n", |
| 1699 | wwn_to_u64(vha->port_name)); |
| 1700 | } |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 1701 | } |
Sawan Chandak | 969a619 | 2016-01-27 12:03:32 -0500 | [diff] [blame] | 1702 | |
| 1703 | if (IS_QLA27XX(vha->hw)) |
| 1704 | vha->bbcr = mcp->mb[15]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1705 | } |
| 1706 | |
| 1707 | return rval; |
| 1708 | } |
| 1709 | |
| 1710 | /* |
| 1711 | * qla2x00_get_retry_cnt |
| 1712 | * Get current firmware login retry count and delay. |
| 1713 | * |
| 1714 | * Input: |
| 1715 | * ha = adapter block pointer. |
| 1716 | * retry_cnt = pointer to login retry count. |
| 1717 | * tov = pointer to login timeout value. |
| 1718 | * |
| 1719 | * Returns: |
| 1720 | * qla2x00 local function return status code. |
| 1721 | * |
| 1722 | * Context: |
| 1723 | * Kernel context. |
| 1724 | */ |
| 1725 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1726 | 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] | 1727 | uint16_t *r_a_tov) |
| 1728 | { |
| 1729 | int rval; |
| 1730 | uint16_t ratov; |
| 1731 | mbx_cmd_t mc; |
| 1732 | mbx_cmd_t *mcp = &mc; |
| 1733 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1734 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1049, |
| 1735 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1736 | |
| 1737 | mcp->mb[0] = MBC_GET_RETRY_COUNT; |
| 1738 | mcp->out_mb = MBX_0; |
| 1739 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1740 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1741 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1742 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1743 | |
| 1744 | if (rval != QLA_SUCCESS) { |
| 1745 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1746 | ql_dbg(ql_dbg_mbx, vha, 0x104a, |
| 1747 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1748 | } else { |
| 1749 | /* Convert returned data and check our values. */ |
| 1750 | *r_a_tov = mcp->mb[3] / 2; |
| 1751 | ratov = (mcp->mb[3]/2) / 10; /* mb[3] value is in 100ms */ |
| 1752 | if (mcp->mb[1] * ratov > (*retry_cnt) * (*tov)) { |
| 1753 | /* Update to the larger values */ |
| 1754 | *retry_cnt = (uint8_t)mcp->mb[1]; |
| 1755 | *tov = ratov; |
| 1756 | } |
| 1757 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1758 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104b, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1759 | "Done %s mb3=%d ratov=%d.\n", __func__, mcp->mb[3], ratov); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1760 | } |
| 1761 | |
| 1762 | return rval; |
| 1763 | } |
| 1764 | |
| 1765 | /* |
| 1766 | * qla2x00_init_firmware |
| 1767 | * Initialize adapter firmware. |
| 1768 | * |
| 1769 | * Input: |
| 1770 | * ha = adapter block pointer. |
| 1771 | * dptr = Initialization control block pointer. |
| 1772 | * size = size of initialization control block. |
| 1773 | * TARGET_QUEUE_LOCK must be released. |
| 1774 | * ADAPTER_STATE_LOCK must be released. |
| 1775 | * |
| 1776 | * Returns: |
| 1777 | * qla2x00 local function return status code. |
| 1778 | * |
| 1779 | * Context: |
| 1780 | * Kernel context. |
| 1781 | */ |
| 1782 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1783 | qla2x00_init_firmware(scsi_qla_host_t *vha, uint16_t size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1784 | { |
| 1785 | int rval; |
| 1786 | mbx_cmd_t mc; |
| 1787 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1788 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1789 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1790 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104c, |
| 1791 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1792 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1793 | if (IS_P3P_TYPE(ha) && ql2xdbwr) |
Bart Van Assche | 8dfa4b5a | 2015-07-09 07:24:50 -0700 | [diff] [blame] | 1794 | qla82xx_wr_32(ha, (uintptr_t __force)ha->nxdb_wr_ptr, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1795 | (0x04 | (ha->portnum << 5) | (0 << 8) | (0 << 16))); |
| 1796 | |
Andrew Vasquez | e6e074f | 2008-01-31 12:33:53 -0800 | [diff] [blame] | 1797 | if (ha->flags.npiv_supported) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1798 | mcp->mb[0] = MBC_MID_INITIALIZE_FIRMWARE; |
| 1799 | else |
| 1800 | mcp->mb[0] = MBC_INITIALIZE_FIRMWARE; |
| 1801 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 1802 | mcp->mb[1] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1803 | mcp->mb[2] = MSW(ha->init_cb_dma); |
| 1804 | mcp->mb[3] = LSW(ha->init_cb_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1805 | mcp->mb[6] = MSW(MSD(ha->init_cb_dma)); |
| 1806 | mcp->mb[7] = LSW(MSD(ha->init_cb_dma)); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 1807 | 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] | 1808 | if (ha->ex_init_cb && ha->ex_init_cb->ex_version) { |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 1809 | mcp->mb[1] = BIT_0; |
| 1810 | mcp->mb[10] = MSW(ha->ex_init_cb_dma); |
| 1811 | mcp->mb[11] = LSW(ha->ex_init_cb_dma); |
| 1812 | mcp->mb[12] = MSW(MSD(ha->ex_init_cb_dma)); |
| 1813 | mcp->mb[13] = LSW(MSD(ha->ex_init_cb_dma)); |
| 1814 | mcp->mb[14] = sizeof(*ha->ex_init_cb); |
| 1815 | mcp->out_mb |= MBX_14|MBX_13|MBX_12|MBX_11|MBX_10; |
| 1816 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1817 | /* 1 and 2 should normally be captured. */ |
| 1818 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 1819 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1820 | /* mb3 is additional info about the installed SFP. */ |
| 1821 | mcp->in_mb |= MBX_3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1822 | mcp->buf_size = size; |
| 1823 | mcp->flags = MBX_DMA_OUT; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1824 | mcp->tov = MBX_TOV_SECONDS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1825 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1826 | |
| 1827 | if (rval != QLA_SUCCESS) { |
| 1828 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1829 | ql_dbg(ql_dbg_mbx, vha, 0x104d, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1830 | "Failed=%x mb[0]=%x, mb[1]=%x, mb[2]=%x, mb[3]=%x,.\n", |
| 1831 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2], mcp->mb[3]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1832 | } else { |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 1833 | if (IS_QLA27XX(ha)) { |
| 1834 | if (mcp->mb[2] == 6 || mcp->mb[3] == 2) |
| 1835 | ql_dbg(ql_dbg_mbx, vha, 0x119d, |
| 1836 | "Invalid SFP/Validation Failed\n"); |
| 1837 | } |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1838 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104e, |
| 1839 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1840 | } |
| 1841 | |
| 1842 | return rval; |
| 1843 | } |
| 1844 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 1845 | |
| 1846 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1847 | * qla2x00_get_port_database |
| 1848 | * Issue normal/enhanced get port database mailbox command |
| 1849 | * and copy device name as necessary. |
| 1850 | * |
| 1851 | * Input: |
| 1852 | * ha = adapter state pointer. |
| 1853 | * dev = structure pointer. |
| 1854 | * opt = enhanced cmd option byte. |
| 1855 | * |
| 1856 | * Returns: |
| 1857 | * qla2x00 local function return status code. |
| 1858 | * |
| 1859 | * Context: |
| 1860 | * Kernel context. |
| 1861 | */ |
| 1862 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1863 | 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] | 1864 | { |
| 1865 | int rval; |
| 1866 | mbx_cmd_t mc; |
| 1867 | mbx_cmd_t *mcp = &mc; |
| 1868 | port_database_t *pd; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1869 | struct port_database_24xx *pd24; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1870 | dma_addr_t pd_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1871 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1872 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1873 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104f, |
| 1874 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1875 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1876 | pd24 = NULL; |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 1877 | pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1878 | if (pd == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1879 | ql_log(ql_log_warn, vha, 0x1050, |
| 1880 | "Failed to allocate port database structure.\n"); |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 1881 | fcport->query = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1882 | return QLA_MEMORY_ALLOC_FAILED; |
| 1883 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1884 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1885 | mcp->mb[0] = MBC_GET_PORT_DATABASE; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1886 | if (opt != 0 && !IS_FWI2_CAPABLE(ha)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1887 | mcp->mb[0] = MBC_ENHANCED_GET_PORT_DATABASE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1888 | mcp->mb[2] = MSW(pd_dma); |
| 1889 | mcp->mb[3] = LSW(pd_dma); |
| 1890 | mcp->mb[6] = MSW(MSD(pd_dma)); |
| 1891 | mcp->mb[7] = LSW(MSD(pd_dma)); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1892 | mcp->mb[9] = vha->vp_idx; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1893 | 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] | 1894 | mcp->in_mb = MBX_0; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1895 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1896 | mcp->mb[1] = fcport->loop_id; |
| 1897 | mcp->mb[10] = opt; |
| 1898 | mcp->out_mb |= MBX_10|MBX_1; |
| 1899 | mcp->in_mb |= MBX_1; |
| 1900 | } else if (HAS_EXTENDED_IDS(ha)) { |
| 1901 | mcp->mb[1] = fcport->loop_id; |
| 1902 | mcp->mb[10] = opt; |
| 1903 | mcp->out_mb |= MBX_10|MBX_1; |
| 1904 | } else { |
| 1905 | mcp->mb[1] = fcport->loop_id << 8 | opt; |
| 1906 | mcp->out_mb |= MBX_1; |
| 1907 | } |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1908 | mcp->buf_size = IS_FWI2_CAPABLE(ha) ? |
| 1909 | PORT_DATABASE_24XX_SIZE : PORT_DATABASE_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1910 | mcp->flags = MBX_DMA_IN; |
| 1911 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1912 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1913 | if (rval != QLA_SUCCESS) |
| 1914 | goto gpd_error_out; |
| 1915 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1916 | if (IS_FWI2_CAPABLE(ha)) { |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1917 | uint64_t zero = 0; |
Duane Grigsby | c0c462c | 2017-10-13 09:34:05 -0700 | [diff] [blame] | 1918 | u8 current_login_state, last_login_state; |
| 1919 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1920 | pd24 = (struct port_database_24xx *) pd; |
| 1921 | |
| 1922 | /* Check for logged in state. */ |
Duane Grigsby | c0c462c | 2017-10-13 09:34:05 -0700 | [diff] [blame] | 1923 | if (fcport->fc4f_nvme) { |
| 1924 | current_login_state = pd24->current_login_state >> 4; |
| 1925 | last_login_state = pd24->last_login_state >> 4; |
| 1926 | } else { |
| 1927 | current_login_state = pd24->current_login_state & 0xf; |
| 1928 | last_login_state = pd24->last_login_state & 0xf; |
| 1929 | } |
| 1930 | fcport->current_login_state = pd24->current_login_state; |
| 1931 | fcport->last_login_state = pd24->last_login_state; |
| 1932 | |
| 1933 | /* Check for logged in state. */ |
| 1934 | if (current_login_state != PDS_PRLI_COMPLETE && |
| 1935 | last_login_state != PDS_PRLI_COMPLETE) { |
| 1936 | ql_dbg(ql_dbg_mbx, vha, 0x119a, |
| 1937 | "Unable to verify login-state (%x/%x) for loop_id %x.\n", |
| 1938 | current_login_state, last_login_state, |
| 1939 | fcport->loop_id); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1940 | rval = QLA_FUNCTION_FAILED; |
Duane Grigsby | c0c462c | 2017-10-13 09:34:05 -0700 | [diff] [blame] | 1941 | |
| 1942 | if (!fcport->query) |
| 1943 | goto gpd_error_out; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1944 | } |
| 1945 | |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1946 | if (fcport->loop_id == FC_NO_LOOP_ID || |
| 1947 | (memcmp(fcport->port_name, (uint8_t *)&zero, 8) && |
| 1948 | memcmp(fcport->port_name, pd24->port_name, 8))) { |
| 1949 | /* We lost the device mid way. */ |
| 1950 | rval = QLA_NOT_LOGGED_IN; |
| 1951 | goto gpd_error_out; |
| 1952 | } |
| 1953 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1954 | /* Names are little-endian. */ |
| 1955 | memcpy(fcport->node_name, pd24->node_name, WWN_SIZE); |
| 1956 | memcpy(fcport->port_name, pd24->port_name, WWN_SIZE); |
| 1957 | |
| 1958 | /* Get port_id of device. */ |
| 1959 | fcport->d_id.b.domain = pd24->port_id[0]; |
| 1960 | fcport->d_id.b.area = pd24->port_id[1]; |
| 1961 | fcport->d_id.b.al_pa = pd24->port_id[2]; |
| 1962 | fcport->d_id.b.rsvd_1 = 0; |
| 1963 | |
| 1964 | /* If not target must be initiator or unknown type. */ |
| 1965 | if ((pd24->prli_svc_param_word_3[0] & BIT_4) == 0) |
| 1966 | fcport->port_type = FCT_INITIATOR; |
| 1967 | else |
| 1968 | fcport->port_type = FCT_TARGET; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 1969 | |
| 1970 | /* Passback COS information. */ |
| 1971 | fcport->supported_classes = (pd24->flags & PDF_CLASS_2) ? |
| 1972 | FC_COS_CLASS2 : FC_COS_CLASS3; |
| 1973 | |
| 1974 | if (pd24->prli_svc_param_word_3[0] & BIT_7) |
| 1975 | fcport->flags |= FCF_CONF_COMP_SUPPORTED; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1976 | } else { |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1977 | uint64_t zero = 0; |
| 1978 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1979 | /* Check for logged in state. */ |
| 1980 | if (pd->master_state != PD_STATE_PORT_LOGGED_IN && |
| 1981 | pd->slave_state != PD_STATE_PORT_LOGGED_IN) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1982 | ql_dbg(ql_dbg_mbx, vha, 0x100a, |
| 1983 | "Unable to verify login-state (%x/%x) - " |
| 1984 | "portid=%02x%02x%02x.\n", pd->master_state, |
| 1985 | pd->slave_state, fcport->d_id.b.domain, |
| 1986 | fcport->d_id.b.area, fcport->d_id.b.al_pa); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1987 | rval = QLA_FUNCTION_FAILED; |
| 1988 | goto gpd_error_out; |
| 1989 | } |
| 1990 | |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1991 | if (fcport->loop_id == FC_NO_LOOP_ID || |
| 1992 | (memcmp(fcport->port_name, (uint8_t *)&zero, 8) && |
| 1993 | memcmp(fcport->port_name, pd->port_name, 8))) { |
| 1994 | /* We lost the device mid way. */ |
| 1995 | rval = QLA_NOT_LOGGED_IN; |
| 1996 | goto gpd_error_out; |
| 1997 | } |
| 1998 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1999 | /* Names are little-endian. */ |
| 2000 | memcpy(fcport->node_name, pd->node_name, WWN_SIZE); |
| 2001 | memcpy(fcport->port_name, pd->port_name, WWN_SIZE); |
| 2002 | |
| 2003 | /* Get port_id of device. */ |
| 2004 | fcport->d_id.b.domain = pd->port_id[0]; |
| 2005 | fcport->d_id.b.area = pd->port_id[3]; |
| 2006 | fcport->d_id.b.al_pa = pd->port_id[2]; |
| 2007 | fcport->d_id.b.rsvd_1 = 0; |
| 2008 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2009 | /* If not target must be initiator or unknown type. */ |
| 2010 | if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0) |
| 2011 | fcport->port_type = FCT_INITIATOR; |
| 2012 | else |
| 2013 | fcport->port_type = FCT_TARGET; |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 2014 | |
| 2015 | /* Passback COS information. */ |
| 2016 | fcport->supported_classes = (pd->options & BIT_4) ? |
| 2017 | FC_COS_CLASS2: FC_COS_CLASS3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2018 | } |
| 2019 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2020 | gpd_error_out: |
| 2021 | dma_pool_free(ha->s_dma_pool, pd, pd_dma); |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 2022 | fcport->query = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2023 | |
| 2024 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2025 | ql_dbg(ql_dbg_mbx, vha, 0x1052, |
| 2026 | "Failed=%x mb[0]=%x mb[1]=%x.\n", rval, |
| 2027 | mcp->mb[0], mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2028 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2029 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1053, |
| 2030 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2031 | } |
| 2032 | |
| 2033 | return rval; |
| 2034 | } |
| 2035 | |
| 2036 | /* |
| 2037 | * qla2x00_get_firmware_state |
| 2038 | * Get adapter firmware state. |
| 2039 | * |
| 2040 | * Input: |
| 2041 | * ha = adapter block pointer. |
| 2042 | * dptr = pointer for firmware state. |
| 2043 | * TARGET_QUEUE_LOCK must be released. |
| 2044 | * ADAPTER_STATE_LOCK must be released. |
| 2045 | * |
| 2046 | * Returns: |
| 2047 | * qla2x00 local function return status code. |
| 2048 | * |
| 2049 | * Context: |
| 2050 | * Kernel context. |
| 2051 | */ |
| 2052 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2053 | qla2x00_get_firmware_state(scsi_qla_host_t *vha, uint16_t *states) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2054 | { |
| 2055 | int rval; |
| 2056 | mbx_cmd_t mc; |
| 2057 | mbx_cmd_t *mcp = &mc; |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 2058 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2059 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2060 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1054, |
| 2061 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2062 | |
| 2063 | mcp->mb[0] = MBC_GET_FIRMWARE_STATE; |
| 2064 | mcp->out_mb = MBX_0; |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 2065 | if (IS_FWI2_CAPABLE(vha->hw)) |
Joe Carnuccio | b5a340d | 2014-09-25 05:16:48 -0400 | [diff] [blame] | 2066 | 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] | 2067 | else |
| 2068 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2069 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2070 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2071 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2072 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2073 | /* Return firmware states. */ |
| 2074 | states[0] = mcp->mb[1]; |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 2075 | if (IS_FWI2_CAPABLE(vha->hw)) { |
| 2076 | states[1] = mcp->mb[2]; |
Joe Carnuccio | ec89146 | 2016-07-06 11:14:26 -0400 | [diff] [blame] | 2077 | states[2] = mcp->mb[3]; /* SFP info */ |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 2078 | states[3] = mcp->mb[4]; |
| 2079 | states[4] = mcp->mb[5]; |
Joe Carnuccio | b5a340d | 2014-09-25 05:16:48 -0400 | [diff] [blame] | 2080 | states[5] = mcp->mb[6]; /* DPORT status */ |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 2081 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2082 | |
| 2083 | if (rval != QLA_SUCCESS) { |
| 2084 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2085 | ql_dbg(ql_dbg_mbx, vha, 0x1055, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2086 | } else { |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 2087 | if (IS_QLA27XX(ha)) { |
| 2088 | if (mcp->mb[2] == 6 || mcp->mb[3] == 2) |
| 2089 | ql_dbg(ql_dbg_mbx, vha, 0x119e, |
| 2090 | "Invalid SFP/Validation Failed\n"); |
| 2091 | } |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2092 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1056, |
| 2093 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2094 | } |
| 2095 | |
| 2096 | return rval; |
| 2097 | } |
| 2098 | |
| 2099 | /* |
| 2100 | * qla2x00_get_port_name |
| 2101 | * Issue get port name mailbox command. |
| 2102 | * Returned name is in big endian format. |
| 2103 | * |
| 2104 | * Input: |
| 2105 | * ha = adapter block pointer. |
| 2106 | * loop_id = loop ID of device. |
| 2107 | * name = pointer for name. |
| 2108 | * TARGET_QUEUE_LOCK must be released. |
| 2109 | * ADAPTER_STATE_LOCK must be released. |
| 2110 | * |
| 2111 | * Returns: |
| 2112 | * qla2x00 local function return status code. |
| 2113 | * |
| 2114 | * Context: |
| 2115 | * Kernel context. |
| 2116 | */ |
| 2117 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2118 | 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] | 2119 | uint8_t opt) |
| 2120 | { |
| 2121 | int rval; |
| 2122 | mbx_cmd_t mc; |
| 2123 | mbx_cmd_t *mcp = &mc; |
| 2124 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2125 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1057, |
| 2126 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2127 | |
| 2128 | mcp->mb[0] = MBC_GET_PORT_NAME; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2129 | mcp->mb[9] = vha->vp_idx; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2130 | mcp->out_mb = MBX_9|MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2131 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2132 | mcp->mb[1] = loop_id; |
| 2133 | mcp->mb[10] = opt; |
| 2134 | mcp->out_mb |= MBX_10; |
| 2135 | } else { |
| 2136 | mcp->mb[1] = loop_id << 8 | opt; |
| 2137 | } |
| 2138 | |
| 2139 | 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] | 2140 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2141 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2142 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2143 | |
| 2144 | if (rval != QLA_SUCCESS) { |
| 2145 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2146 | ql_dbg(ql_dbg_mbx, vha, 0x1058, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2147 | } else { |
| 2148 | if (name != NULL) { |
| 2149 | /* This function returns name in big endian. */ |
Richard Lary | 1196ae0 | 2007-03-22 10:53:19 -0500 | [diff] [blame] | 2150 | name[0] = MSB(mcp->mb[2]); |
| 2151 | name[1] = LSB(mcp->mb[2]); |
| 2152 | name[2] = MSB(mcp->mb[3]); |
| 2153 | name[3] = LSB(mcp->mb[3]); |
| 2154 | name[4] = MSB(mcp->mb[6]); |
| 2155 | name[5] = LSB(mcp->mb[6]); |
| 2156 | name[6] = MSB(mcp->mb[7]); |
| 2157 | name[7] = LSB(mcp->mb[7]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2158 | } |
| 2159 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2160 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1059, |
| 2161 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2162 | } |
| 2163 | |
| 2164 | return rval; |
| 2165 | } |
| 2166 | |
| 2167 | /* |
Joe Carnuccio | 61e1b26 | 2013-02-08 01:57:48 -0500 | [diff] [blame] | 2168 | * qla24xx_link_initialization |
| 2169 | * Issue link initialization mailbox command. |
| 2170 | * |
| 2171 | * Input: |
| 2172 | * ha = adapter block pointer. |
| 2173 | * TARGET_QUEUE_LOCK must be released. |
| 2174 | * ADAPTER_STATE_LOCK must be released. |
| 2175 | * |
| 2176 | * Returns: |
| 2177 | * qla2x00 local function return status code. |
| 2178 | * |
| 2179 | * Context: |
| 2180 | * Kernel context. |
| 2181 | */ |
| 2182 | int |
| 2183 | qla24xx_link_initialize(scsi_qla_host_t *vha) |
| 2184 | { |
| 2185 | int rval; |
| 2186 | mbx_cmd_t mc; |
| 2187 | mbx_cmd_t *mcp = &mc; |
| 2188 | |
| 2189 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1152, |
| 2190 | "Entered %s.\n", __func__); |
| 2191 | |
| 2192 | if (!IS_FWI2_CAPABLE(vha->hw) || IS_CNA_CAPABLE(vha->hw)) |
| 2193 | return QLA_FUNCTION_FAILED; |
| 2194 | |
| 2195 | mcp->mb[0] = MBC_LINK_INITIALIZATION; |
Joe Carnuccio | 5a5c27b | 2013-08-27 01:37:49 -0400 | [diff] [blame] | 2196 | mcp->mb[1] = BIT_4; |
| 2197 | if (vha->hw->operating_mode == LOOP) |
| 2198 | mcp->mb[1] |= BIT_6; |
| 2199 | else |
| 2200 | mcp->mb[1] |= BIT_5; |
Joe Carnuccio | 61e1b26 | 2013-02-08 01:57:48 -0500 | [diff] [blame] | 2201 | mcp->mb[2] = 0; |
| 2202 | mcp->mb[3] = 0; |
| 2203 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 2204 | mcp->in_mb = MBX_0; |
| 2205 | mcp->tov = MBX_TOV_SECONDS; |
| 2206 | mcp->flags = 0; |
| 2207 | rval = qla2x00_mailbox_command(vha, mcp); |
| 2208 | |
| 2209 | if (rval != QLA_SUCCESS) { |
| 2210 | ql_dbg(ql_dbg_mbx, vha, 0x1153, "Failed=%x.\n", rval); |
| 2211 | } else { |
| 2212 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1154, |
| 2213 | "Done %s.\n", __func__); |
| 2214 | } |
| 2215 | |
| 2216 | return rval; |
| 2217 | } |
| 2218 | |
| 2219 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2220 | * qla2x00_lip_reset |
| 2221 | * Issue LIP reset mailbox command. |
| 2222 | * |
| 2223 | * Input: |
| 2224 | * ha = adapter block pointer. |
| 2225 | * TARGET_QUEUE_LOCK must be released. |
| 2226 | * ADAPTER_STATE_LOCK must be released. |
| 2227 | * |
| 2228 | * Returns: |
| 2229 | * qla2x00 local function return status code. |
| 2230 | * |
| 2231 | * Context: |
| 2232 | * Kernel context. |
| 2233 | */ |
| 2234 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2235 | qla2x00_lip_reset(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2236 | { |
| 2237 | int rval; |
| 2238 | mbx_cmd_t mc; |
| 2239 | mbx_cmd_t *mcp = &mc; |
| 2240 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2241 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105a, |
| 2242 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2243 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2244 | if (IS_CNA_CAPABLE(vha->hw)) { |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2245 | /* Logout across all FCFs. */ |
| 2246 | mcp->mb[0] = MBC_LIP_FULL_LOGIN; |
| 2247 | mcp->mb[1] = BIT_1; |
| 2248 | mcp->mb[2] = 0; |
| 2249 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 2250 | } else if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2251 | mcp->mb[0] = MBC_LIP_FULL_LOGIN; |
Quinn Tran | 87d6814a | 2019-01-24 23:23:49 -0800 | [diff] [blame] | 2252 | mcp->mb[1] = BIT_4; |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 2253 | mcp->mb[2] = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2254 | mcp->mb[3] = vha->hw->loop_reset_delay; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2255 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2256 | } else { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2257 | mcp->mb[0] = MBC_LIP_RESET; |
| 2258 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2259 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2260 | mcp->mb[1] = 0x00ff; |
| 2261 | mcp->mb[10] = 0; |
| 2262 | mcp->out_mb |= MBX_10; |
| 2263 | } else { |
| 2264 | mcp->mb[1] = 0xff00; |
| 2265 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2266 | mcp->mb[2] = vha->hw->loop_reset_delay; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2267 | mcp->mb[3] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2268 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2269 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2270 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2271 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2272 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2273 | |
| 2274 | if (rval != QLA_SUCCESS) { |
| 2275 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2276 | ql_dbg(ql_dbg_mbx, vha, 0x105b, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2277 | } else { |
| 2278 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2279 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105c, |
| 2280 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2281 | } |
| 2282 | |
| 2283 | return rval; |
| 2284 | } |
| 2285 | |
| 2286 | /* |
| 2287 | * qla2x00_send_sns |
| 2288 | * Send SNS command. |
| 2289 | * |
| 2290 | * Input: |
| 2291 | * ha = adapter block pointer. |
| 2292 | * sns = pointer for command. |
| 2293 | * cmd_size = command size. |
| 2294 | * buf_size = response/command size. |
| 2295 | * TARGET_QUEUE_LOCK must be released. |
| 2296 | * ADAPTER_STATE_LOCK must be released. |
| 2297 | * |
| 2298 | * Returns: |
| 2299 | * qla2x00 local function return status code. |
| 2300 | * |
| 2301 | * Context: |
| 2302 | * Kernel context. |
| 2303 | */ |
| 2304 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2305 | 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] | 2306 | uint16_t cmd_size, size_t buf_size) |
| 2307 | { |
| 2308 | int rval; |
| 2309 | mbx_cmd_t mc; |
| 2310 | mbx_cmd_t *mcp = &mc; |
| 2311 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2312 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105d, |
| 2313 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2314 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2315 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105e, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2316 | "Retry cnt=%d ratov=%d total tov=%d.\n", |
| 2317 | vha->hw->retry_count, vha->hw->login_timeout, mcp->tov); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2318 | |
| 2319 | mcp->mb[0] = MBC_SEND_SNS_COMMAND; |
| 2320 | mcp->mb[1] = cmd_size; |
| 2321 | mcp->mb[2] = MSW(sns_phys_address); |
| 2322 | mcp->mb[3] = LSW(sns_phys_address); |
| 2323 | mcp->mb[6] = MSW(MSD(sns_phys_address)); |
| 2324 | mcp->mb[7] = LSW(MSD(sns_phys_address)); |
| 2325 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 2326 | mcp->in_mb = MBX_0|MBX_1; |
| 2327 | mcp->buf_size = buf_size; |
| 2328 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2329 | mcp->tov = (vha->hw->login_timeout * 2) + (vha->hw->login_timeout / 2); |
| 2330 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2331 | |
| 2332 | if (rval != QLA_SUCCESS) { |
| 2333 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2334 | ql_dbg(ql_dbg_mbx, vha, 0x105f, |
| 2335 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 2336 | rval, mcp->mb[0], mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2337 | } else { |
| 2338 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2339 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1060, |
| 2340 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2341 | } |
| 2342 | |
| 2343 | return rval; |
| 2344 | } |
| 2345 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2346 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2347 | 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] | 2348 | uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt) |
| 2349 | { |
| 2350 | int rval; |
| 2351 | |
| 2352 | struct logio_entry_24xx *lg; |
| 2353 | dma_addr_t lg_dma; |
| 2354 | uint32_t iop[2]; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2355 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2356 | struct req_que *req; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2357 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2358 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1061, |
| 2359 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2360 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2361 | if (vha->vp_idx && vha->qpair) |
| 2362 | req = vha->qpair->req; |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2363 | else |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2364 | req = ha->req_q_map[0]; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2365 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 2366 | lg = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2367 | if (lg == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2368 | ql_log(ql_log_warn, vha, 0x1062, |
| 2369 | "Failed to allocate login IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2370 | return QLA_MEMORY_ALLOC_FAILED; |
| 2371 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2372 | |
| 2373 | lg->entry_type = LOGINOUT_PORT_IOCB_TYPE; |
| 2374 | lg->entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2375 | lg->handle = MAKE_HANDLE(req->id, lg->handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2376 | lg->nport_handle = cpu_to_le16(loop_id); |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2377 | lg->control_flags = cpu_to_le16(LCF_COMMAND_PLOGI); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2378 | if (opt & BIT_0) |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2379 | lg->control_flags |= cpu_to_le16(LCF_COND_PLOGI); |
Andrew Vasquez | 8baa51a | 2006-06-23 16:10:44 -0700 | [diff] [blame] | 2380 | if (opt & BIT_1) |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2381 | lg->control_flags |= cpu_to_le16(LCF_SKIP_PRLI); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2382 | lg->port_id[0] = al_pa; |
| 2383 | lg->port_id[1] = area; |
| 2384 | lg->port_id[2] = domain; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2385 | lg->vp_index = vha->vp_idx; |
Andrew Vasquez | 7f45dd0 | 2012-02-09 11:15:45 -0800 | [diff] [blame] | 2386 | rval = qla2x00_issue_iocb_timeout(vha, lg, lg_dma, 0, |
| 2387 | (ha->r_a_tov / 10 * 2) + 2); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2388 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2389 | ql_dbg(ql_dbg_mbx, vha, 0x1063, |
| 2390 | "Failed to issue login IOCB (%x).\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2391 | } else if (lg->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2392 | ql_dbg(ql_dbg_mbx, vha, 0x1064, |
| 2393 | "Failed to complete IOCB -- error status (%x).\n", |
| 2394 | lg->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2395 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2396 | } else if (lg->comp_status != cpu_to_le16(CS_COMPLETE)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2397 | iop[0] = le32_to_cpu(lg->io_parameter[0]); |
| 2398 | iop[1] = le32_to_cpu(lg->io_parameter[1]); |
| 2399 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2400 | ql_dbg(ql_dbg_mbx, vha, 0x1065, |
| 2401 | "Failed to complete IOCB -- completion status (%x) " |
| 2402 | "ioparam=%x/%x.\n", le16_to_cpu(lg->comp_status), |
| 2403 | iop[0], iop[1]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2404 | |
| 2405 | switch (iop[0]) { |
| 2406 | case LSC_SCODE_PORTID_USED: |
| 2407 | mb[0] = MBS_PORT_ID_USED; |
| 2408 | mb[1] = LSW(iop[1]); |
| 2409 | break; |
| 2410 | case LSC_SCODE_NPORT_USED: |
| 2411 | mb[0] = MBS_LOOP_ID_USED; |
| 2412 | break; |
| 2413 | case LSC_SCODE_NOLINK: |
| 2414 | case LSC_SCODE_NOIOCB: |
| 2415 | case LSC_SCODE_NOXCB: |
| 2416 | case LSC_SCODE_CMD_FAILED: |
| 2417 | case LSC_SCODE_NOFABRIC: |
| 2418 | case LSC_SCODE_FW_NOT_READY: |
| 2419 | case LSC_SCODE_NOT_LOGGED_IN: |
| 2420 | case LSC_SCODE_NOPCB: |
| 2421 | case LSC_SCODE_ELS_REJECT: |
| 2422 | case LSC_SCODE_CMD_PARAM_ERR: |
| 2423 | case LSC_SCODE_NONPORT: |
| 2424 | case LSC_SCODE_LOGGED_IN: |
| 2425 | case LSC_SCODE_NOFLOGI_ACC: |
| 2426 | default: |
| 2427 | mb[0] = MBS_COMMAND_ERROR; |
| 2428 | break; |
| 2429 | } |
| 2430 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2431 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1066, |
| 2432 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2433 | |
| 2434 | iop[0] = le32_to_cpu(lg->io_parameter[0]); |
| 2435 | |
| 2436 | mb[0] = MBS_COMMAND_COMPLETE; |
| 2437 | mb[1] = 0; |
| 2438 | if (iop[0] & BIT_4) { |
| 2439 | if (iop[0] & BIT_8) |
| 2440 | mb[1] |= BIT_1; |
| 2441 | } else |
| 2442 | mb[1] = BIT_0; |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 2443 | |
| 2444 | /* Passback COS information. */ |
| 2445 | mb[10] = 0; |
| 2446 | if (lg->io_parameter[7] || lg->io_parameter[8]) |
| 2447 | mb[10] |= BIT_0; /* Class 2. */ |
| 2448 | if (lg->io_parameter[9] || lg->io_parameter[10]) |
| 2449 | mb[10] |= BIT_1; /* Class 3. */ |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2450 | if (lg->io_parameter[0] & cpu_to_le32(BIT_7)) |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2451 | mb[10] |= BIT_7; /* Confirmed Completion |
| 2452 | * Allowed |
| 2453 | */ |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2454 | } |
| 2455 | |
| 2456 | dma_pool_free(ha->s_dma_pool, lg, lg_dma); |
| 2457 | |
| 2458 | return rval; |
| 2459 | } |
| 2460 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2461 | /* |
| 2462 | * qla2x00_login_fabric |
| 2463 | * Issue login fabric port mailbox command. |
| 2464 | * |
| 2465 | * Input: |
| 2466 | * ha = adapter block pointer. |
| 2467 | * loop_id = device loop ID. |
| 2468 | * domain = device domain. |
| 2469 | * area = device area. |
| 2470 | * al_pa = device AL_PA. |
| 2471 | * status = pointer for return status. |
| 2472 | * opt = command options. |
| 2473 | * TARGET_QUEUE_LOCK must be released. |
| 2474 | * ADAPTER_STATE_LOCK must be released. |
| 2475 | * |
| 2476 | * Returns: |
| 2477 | * qla2x00 local function return status code. |
| 2478 | * |
| 2479 | * Context: |
| 2480 | * Kernel context. |
| 2481 | */ |
| 2482 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2483 | 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] | 2484 | uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt) |
| 2485 | { |
| 2486 | int rval; |
| 2487 | mbx_cmd_t mc; |
| 2488 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2489 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2490 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2491 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1067, |
| 2492 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2493 | |
| 2494 | mcp->mb[0] = MBC_LOGIN_FABRIC_PORT; |
| 2495 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 2496 | if (HAS_EXTENDED_IDS(ha)) { |
| 2497 | mcp->mb[1] = loop_id; |
| 2498 | mcp->mb[10] = opt; |
| 2499 | mcp->out_mb |= MBX_10; |
| 2500 | } else { |
| 2501 | mcp->mb[1] = (loop_id << 8) | opt; |
| 2502 | } |
| 2503 | mcp->mb[2] = domain; |
| 2504 | mcp->mb[3] = area << 8 | al_pa; |
| 2505 | |
| 2506 | mcp->in_mb = MBX_7|MBX_6|MBX_2|MBX_1|MBX_0; |
| 2507 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
| 2508 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2509 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2510 | |
| 2511 | /* Return mailbox statuses. */ |
| 2512 | if (mb != NULL) { |
| 2513 | mb[0] = mcp->mb[0]; |
| 2514 | mb[1] = mcp->mb[1]; |
| 2515 | mb[2] = mcp->mb[2]; |
| 2516 | mb[6] = mcp->mb[6]; |
| 2517 | mb[7] = mcp->mb[7]; |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 2518 | /* COS retrieved from Get-Port-Database mailbox command. */ |
| 2519 | mb[10] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2520 | } |
| 2521 | |
| 2522 | if (rval != QLA_SUCCESS) { |
| 2523 | /* RLU tmp code: need to change main mailbox_command function to |
| 2524 | * return ok even when the mailbox completion value is not |
| 2525 | * SUCCESS. The caller needs to be responsible to interpret |
| 2526 | * the return values of this mailbox command if we're not |
| 2527 | * to change too much of the existing code. |
| 2528 | */ |
| 2529 | if (mcp->mb[0] == 0x4001 || mcp->mb[0] == 0x4002 || |
| 2530 | mcp->mb[0] == 0x4003 || mcp->mb[0] == 0x4005 || |
| 2531 | mcp->mb[0] == 0x4006) |
| 2532 | rval = QLA_SUCCESS; |
| 2533 | |
| 2534 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2535 | ql_dbg(ql_dbg_mbx, vha, 0x1068, |
| 2536 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 2537 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2538 | } else { |
| 2539 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2540 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1069, |
| 2541 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2542 | } |
| 2543 | |
| 2544 | return rval; |
| 2545 | } |
| 2546 | |
| 2547 | /* |
| 2548 | * qla2x00_login_local_device |
| 2549 | * Issue login loop port mailbox command. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2550 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2551 | * Input: |
| 2552 | * ha = adapter block pointer. |
| 2553 | * loop_id = device loop ID. |
| 2554 | * opt = command options. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2555 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2556 | * Returns: |
| 2557 | * Return status code. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2558 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2559 | * Context: |
| 2560 | * Kernel context. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2561 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2562 | */ |
| 2563 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2564 | 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] | 2565 | uint16_t *mb_ret, uint8_t opt) |
| 2566 | { |
| 2567 | int rval; |
| 2568 | mbx_cmd_t mc; |
| 2569 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2570 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2571 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2572 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106a, |
| 2573 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2574 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2575 | if (IS_FWI2_CAPABLE(ha)) |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2576 | return qla24xx_login_fabric(vha, fcport->loop_id, |
andrew.vasquez@qlogic.com | 9a52a57c | 2006-03-09 14:27:44 -0800 | [diff] [blame] | 2577 | fcport->d_id.b.domain, fcport->d_id.b.area, |
| 2578 | fcport->d_id.b.al_pa, mb_ret, opt); |
| 2579 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2580 | mcp->mb[0] = MBC_LOGIN_LOOP_PORT; |
| 2581 | if (HAS_EXTENDED_IDS(ha)) |
andrew.vasquez@qlogic.com | 9a52a57c | 2006-03-09 14:27:44 -0800 | [diff] [blame] | 2582 | mcp->mb[1] = fcport->loop_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2583 | else |
andrew.vasquez@qlogic.com | 9a52a57c | 2006-03-09 14:27:44 -0800 | [diff] [blame] | 2584 | mcp->mb[1] = fcport->loop_id << 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2585 | mcp->mb[2] = opt; |
| 2586 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 2587 | mcp->in_mb = MBX_7|MBX_6|MBX_1|MBX_0; |
| 2588 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
| 2589 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2590 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2591 | |
| 2592 | /* Return mailbox statuses. */ |
| 2593 | if (mb_ret != NULL) { |
| 2594 | mb_ret[0] = mcp->mb[0]; |
| 2595 | mb_ret[1] = mcp->mb[1]; |
| 2596 | mb_ret[6] = mcp->mb[6]; |
| 2597 | mb_ret[7] = mcp->mb[7]; |
| 2598 | } |
| 2599 | |
| 2600 | if (rval != QLA_SUCCESS) { |
| 2601 | /* AV tmp code: need to change main mailbox_command function to |
| 2602 | * return ok even when the mailbox completion value is not |
| 2603 | * SUCCESS. The caller needs to be responsible to interpret |
| 2604 | * the return values of this mailbox command if we're not |
| 2605 | * to change too much of the existing code. |
| 2606 | */ |
| 2607 | if (mcp->mb[0] == 0x4005 || mcp->mb[0] == 0x4006) |
| 2608 | rval = QLA_SUCCESS; |
| 2609 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2610 | ql_dbg(ql_dbg_mbx, vha, 0x106b, |
| 2611 | "Failed=%x mb[0]=%x mb[1]=%x mb[6]=%x mb[7]=%x.\n", |
| 2612 | 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] | 2613 | } else { |
| 2614 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2615 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106c, |
| 2616 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2617 | } |
| 2618 | |
| 2619 | return (rval); |
| 2620 | } |
| 2621 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2622 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2623 | 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] | 2624 | uint8_t area, uint8_t al_pa) |
| 2625 | { |
| 2626 | int rval; |
| 2627 | struct logio_entry_24xx *lg; |
| 2628 | dma_addr_t lg_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2629 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2630 | struct req_que *req; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2631 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2632 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106d, |
| 2633 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2634 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 2635 | lg = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2636 | if (lg == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2637 | ql_log(ql_log_warn, vha, 0x106e, |
| 2638 | "Failed to allocate logout IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2639 | return QLA_MEMORY_ALLOC_FAILED; |
| 2640 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2641 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2642 | req = vha->req; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2643 | lg->entry_type = LOGINOUT_PORT_IOCB_TYPE; |
| 2644 | lg->entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2645 | lg->handle = MAKE_HANDLE(req->id, lg->handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2646 | lg->nport_handle = cpu_to_le16(loop_id); |
| 2647 | lg->control_flags = |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2648 | cpu_to_le16(LCF_COMMAND_LOGO|LCF_IMPL_LOGO| |
Andrew Vasquez | c8d6691 | 2011-03-30 11:46:21 -0700 | [diff] [blame] | 2649 | LCF_FREE_NPORT); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2650 | lg->port_id[0] = al_pa; |
| 2651 | lg->port_id[1] = area; |
| 2652 | lg->port_id[2] = domain; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2653 | lg->vp_index = vha->vp_idx; |
Andrew Vasquez | 7f45dd0 | 2012-02-09 11:15:45 -0800 | [diff] [blame] | 2654 | rval = qla2x00_issue_iocb_timeout(vha, lg, lg_dma, 0, |
| 2655 | (ha->r_a_tov / 10 * 2) + 2); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2656 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2657 | ql_dbg(ql_dbg_mbx, vha, 0x106f, |
| 2658 | "Failed to issue logout IOCB (%x).\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2659 | } else if (lg->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2660 | ql_dbg(ql_dbg_mbx, vha, 0x1070, |
| 2661 | "Failed to complete IOCB -- error status (%x).\n", |
| 2662 | lg->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2663 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2664 | } else if (lg->comp_status != cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2665 | ql_dbg(ql_dbg_mbx, vha, 0x1071, |
| 2666 | "Failed to complete IOCB -- completion status (%x) " |
| 2667 | "ioparam=%x/%x.\n", le16_to_cpu(lg->comp_status), |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2668 | le32_to_cpu(lg->io_parameter[0]), |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2669 | le32_to_cpu(lg->io_parameter[1])); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2670 | } else { |
| 2671 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2672 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1072, |
| 2673 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2674 | } |
| 2675 | |
| 2676 | dma_pool_free(ha->s_dma_pool, lg, lg_dma); |
| 2677 | |
| 2678 | return rval; |
| 2679 | } |
| 2680 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2681 | /* |
| 2682 | * qla2x00_fabric_logout |
| 2683 | * Issue logout fabric port mailbox command. |
| 2684 | * |
| 2685 | * Input: |
| 2686 | * ha = adapter block pointer. |
| 2687 | * loop_id = device loop ID. |
| 2688 | * TARGET_QUEUE_LOCK must be released. |
| 2689 | * ADAPTER_STATE_LOCK must be released. |
| 2690 | * |
| 2691 | * Returns: |
| 2692 | * qla2x00 local function return status code. |
| 2693 | * |
| 2694 | * Context: |
| 2695 | * Kernel context. |
| 2696 | */ |
| 2697 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2698 | 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] | 2699 | uint8_t area, uint8_t al_pa) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2700 | { |
| 2701 | int rval; |
| 2702 | mbx_cmd_t mc; |
| 2703 | mbx_cmd_t *mcp = &mc; |
| 2704 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2705 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1073, |
| 2706 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2707 | |
| 2708 | mcp->mb[0] = MBC_LOGOUT_FABRIC_PORT; |
| 2709 | mcp->out_mb = MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2710 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2711 | mcp->mb[1] = loop_id; |
| 2712 | mcp->mb[10] = 0; |
| 2713 | mcp->out_mb |= MBX_10; |
| 2714 | } else { |
| 2715 | mcp->mb[1] = loop_id << 8; |
| 2716 | } |
| 2717 | |
| 2718 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2719 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2720 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2721 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2722 | |
| 2723 | if (rval != QLA_SUCCESS) { |
| 2724 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2725 | ql_dbg(ql_dbg_mbx, vha, 0x1074, |
| 2726 | "Failed=%x mb[1]=%x.\n", rval, mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2727 | } else { |
| 2728 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2729 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1075, |
| 2730 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2731 | } |
| 2732 | |
| 2733 | return rval; |
| 2734 | } |
| 2735 | |
| 2736 | /* |
| 2737 | * qla2x00_full_login_lip |
| 2738 | * Issue full login LIP mailbox command. |
| 2739 | * |
| 2740 | * Input: |
| 2741 | * ha = adapter block pointer. |
| 2742 | * TARGET_QUEUE_LOCK must be released. |
| 2743 | * ADAPTER_STATE_LOCK must be released. |
| 2744 | * |
| 2745 | * Returns: |
| 2746 | * qla2x00 local function return status code. |
| 2747 | * |
| 2748 | * Context: |
| 2749 | * Kernel context. |
| 2750 | */ |
| 2751 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2752 | qla2x00_full_login_lip(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2753 | { |
| 2754 | int rval; |
| 2755 | mbx_cmd_t mc; |
| 2756 | mbx_cmd_t *mcp = &mc; |
| 2757 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2758 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1076, |
| 2759 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2760 | |
| 2761 | mcp->mb[0] = MBC_LIP_FULL_LOGIN; |
Quinn Tran | 87d6814a | 2019-01-24 23:23:49 -0800 | [diff] [blame] | 2762 | mcp->mb[1] = IS_FWI2_CAPABLE(vha->hw) ? BIT_4 : 0; |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 2763 | mcp->mb[2] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2764 | mcp->mb[3] = 0; |
| 2765 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 2766 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2767 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2768 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2769 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2770 | |
| 2771 | if (rval != QLA_SUCCESS) { |
| 2772 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2773 | ql_dbg(ql_dbg_mbx, vha, 0x1077, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2774 | } else { |
| 2775 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2776 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1078, |
| 2777 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2778 | } |
| 2779 | |
| 2780 | return rval; |
| 2781 | } |
| 2782 | |
| 2783 | /* |
| 2784 | * qla2x00_get_id_list |
| 2785 | * |
| 2786 | * Input: |
| 2787 | * ha = adapter block pointer. |
| 2788 | * |
| 2789 | * Returns: |
| 2790 | * qla2x00 local function return status code. |
| 2791 | * |
| 2792 | * Context: |
| 2793 | * Kernel context. |
| 2794 | */ |
| 2795 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2796 | 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] | 2797 | uint16_t *entries) |
| 2798 | { |
| 2799 | int rval; |
| 2800 | mbx_cmd_t mc; |
| 2801 | mbx_cmd_t *mcp = &mc; |
| 2802 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2803 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1079, |
| 2804 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2805 | |
| 2806 | if (id_list == NULL) |
| 2807 | return QLA_FUNCTION_FAILED; |
| 2808 | |
| 2809 | mcp->mb[0] = MBC_GET_ID_LIST; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2810 | mcp->out_mb = MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2811 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2812 | mcp->mb[2] = MSW(id_list_dma); |
| 2813 | mcp->mb[3] = LSW(id_list_dma); |
| 2814 | mcp->mb[6] = MSW(MSD(id_list_dma)); |
| 2815 | mcp->mb[7] = LSW(MSD(id_list_dma)); |
andrew.vasquez@qlogic.com | 247ec45 | 2006-02-07 08:45:40 -0800 | [diff] [blame] | 2816 | mcp->mb[8] = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2817 | mcp->mb[9] = vha->vp_idx; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2818 | 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] | 2819 | } else { |
| 2820 | mcp->mb[1] = MSW(id_list_dma); |
| 2821 | mcp->mb[2] = LSW(id_list_dma); |
| 2822 | mcp->mb[3] = MSW(MSD(id_list_dma)); |
| 2823 | mcp->mb[6] = LSW(MSD(id_list_dma)); |
| 2824 | mcp->out_mb |= MBX_6|MBX_3|MBX_2|MBX_1; |
| 2825 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2826 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2827 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2828 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2829 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2830 | |
| 2831 | if (rval != QLA_SUCCESS) { |
| 2832 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2833 | ql_dbg(ql_dbg_mbx, vha, 0x107a, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2834 | } else { |
| 2835 | *entries = mcp->mb[1]; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2836 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107b, |
| 2837 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2838 | } |
| 2839 | |
| 2840 | return rval; |
| 2841 | } |
| 2842 | |
| 2843 | /* |
| 2844 | * qla2x00_get_resource_cnts |
| 2845 | * Get current firmware resource counts. |
| 2846 | * |
| 2847 | * Input: |
| 2848 | * ha = adapter block pointer. |
| 2849 | * |
| 2850 | * Returns: |
| 2851 | * qla2x00 local function return status code. |
| 2852 | * |
| 2853 | * Context: |
| 2854 | * Kernel context. |
| 2855 | */ |
| 2856 | int |
Quinn Tran | 03e8c68 | 2015-12-17 14:56:59 -0500 | [diff] [blame] | 2857 | qla2x00_get_resource_cnts(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2858 | { |
Quinn Tran | 03e8c68 | 2015-12-17 14:56:59 -0500 | [diff] [blame] | 2859 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2860 | int rval; |
| 2861 | mbx_cmd_t mc; |
| 2862 | mbx_cmd_t *mcp = &mc; |
| 2863 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2864 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107c, |
| 2865 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2866 | |
| 2867 | mcp->mb[0] = MBC_GET_RESOURCE_COUNTS; |
| 2868 | mcp->out_mb = MBX_0; |
Seokmann Ju | 4d0ea24 | 2007-09-20 14:07:43 -0700 | [diff] [blame] | 2869 | mcp->in_mb = MBX_11|MBX_10|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2870 | if (IS_QLA81XX(vha->hw) || IS_QLA83XX(vha->hw) || IS_QLA27XX(vha->hw)) |
Andrew Vasquez | f3a0a77 | 2009-10-13 15:16:49 -0700 | [diff] [blame] | 2871 | mcp->in_mb |= MBX_12; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2872 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2873 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2874 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2875 | |
| 2876 | if (rval != QLA_SUCCESS) { |
| 2877 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2878 | ql_dbg(ql_dbg_mbx, vha, 0x107d, |
| 2879 | "Failed mb[0]=%x.\n", mcp->mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2880 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2881 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107e, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2882 | "Done %s mb1=%x mb2=%x mb3=%x mb6=%x mb7=%x mb10=%x " |
| 2883 | "mb11=%x mb12=%x.\n", __func__, mcp->mb[1], mcp->mb[2], |
| 2884 | mcp->mb[3], mcp->mb[6], mcp->mb[7], mcp->mb[10], |
| 2885 | mcp->mb[11], mcp->mb[12]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2886 | |
Quinn Tran | 03e8c68 | 2015-12-17 14:56:59 -0500 | [diff] [blame] | 2887 | ha->orig_fw_tgt_xcb_count = mcp->mb[1]; |
| 2888 | ha->cur_fw_tgt_xcb_count = mcp->mb[2]; |
| 2889 | ha->cur_fw_xcb_count = mcp->mb[3]; |
| 2890 | ha->orig_fw_xcb_count = mcp->mb[6]; |
| 2891 | ha->cur_fw_iocb_count = mcp->mb[7]; |
| 2892 | ha->orig_fw_iocb_count = mcp->mb[10]; |
| 2893 | if (ha->flags.npiv_supported) |
| 2894 | ha->max_npiv_vports = mcp->mb[11]; |
| 2895 | if (IS_QLA81XX(ha) || IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
| 2896 | ha->fw_max_fcf_count = mcp->mb[12]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2897 | } |
| 2898 | |
| 2899 | return (rval); |
| 2900 | } |
| 2901 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2902 | /* |
| 2903 | * qla2x00_get_fcal_position_map |
| 2904 | * Get FCAL (LILP) position map using mailbox command |
| 2905 | * |
| 2906 | * Input: |
| 2907 | * ha = adapter state pointer. |
| 2908 | * pos_map = buffer pointer (can be NULL). |
| 2909 | * |
| 2910 | * Returns: |
| 2911 | * qla2x00 local function return status code. |
| 2912 | * |
| 2913 | * Context: |
| 2914 | * Kernel context. |
| 2915 | */ |
| 2916 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2917 | 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] | 2918 | { |
| 2919 | int rval; |
| 2920 | mbx_cmd_t mc; |
| 2921 | mbx_cmd_t *mcp = &mc; |
| 2922 | char *pmap; |
| 2923 | dma_addr_t pmap_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2924 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2925 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2926 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107f, |
| 2927 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2928 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 2929 | pmap = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pmap_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2930 | if (pmap == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2931 | ql_log(ql_log_warn, vha, 0x1080, |
| 2932 | "Memory alloc failed.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2933 | return QLA_MEMORY_ALLOC_FAILED; |
| 2934 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2935 | |
| 2936 | mcp->mb[0] = MBC_GET_FC_AL_POSITION_MAP; |
| 2937 | mcp->mb[2] = MSW(pmap_dma); |
| 2938 | mcp->mb[3] = LSW(pmap_dma); |
| 2939 | mcp->mb[6] = MSW(MSD(pmap_dma)); |
| 2940 | mcp->mb[7] = LSW(MSD(pmap_dma)); |
| 2941 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; |
| 2942 | mcp->in_mb = MBX_1|MBX_0; |
| 2943 | mcp->buf_size = FCAL_MAP_SIZE; |
| 2944 | mcp->flags = MBX_DMA_IN; |
| 2945 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2946 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2947 | |
| 2948 | if (rval == QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2949 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1081, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2950 | "mb0/mb1=%x/%X FC/AL position map size (%x).\n", |
| 2951 | mcp->mb[0], mcp->mb[1], (unsigned)pmap[0]); |
| 2952 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111d, |
| 2953 | pmap, pmap[0] + 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2954 | |
| 2955 | if (pos_map) |
| 2956 | memcpy(pos_map, pmap, FCAL_MAP_SIZE); |
| 2957 | } |
| 2958 | dma_pool_free(ha->s_dma_pool, pmap, pmap_dma); |
| 2959 | |
| 2960 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2961 | ql_dbg(ql_dbg_mbx, vha, 0x1082, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2962 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2963 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1083, |
| 2964 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2965 | } |
| 2966 | |
| 2967 | return rval; |
| 2968 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2969 | |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2970 | /* |
| 2971 | * qla2x00_get_link_status |
| 2972 | * |
| 2973 | * Input: |
| 2974 | * ha = adapter block pointer. |
| 2975 | * loop_id = device loop ID. |
| 2976 | * ret_buf = pointer to link status return buffer. |
| 2977 | * |
| 2978 | * Returns: |
| 2979 | * 0 = success. |
| 2980 | * BIT_0 = mem alloc error. |
| 2981 | * BIT_1 = mailbox error. |
| 2982 | */ |
| 2983 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2984 | 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] | 2985 | struct link_statistics *stats, dma_addr_t stats_dma) |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2986 | { |
| 2987 | int rval; |
| 2988 | mbx_cmd_t mc; |
| 2989 | mbx_cmd_t *mcp = &mc; |
Joe Carnuccio | c6dc990 | 2016-07-06 11:14:24 -0400 | [diff] [blame] | 2990 | uint32_t *iter = (void *)stats; |
| 2991 | ushort dwords = offsetof(typeof(*stats), link_up_cnt)/sizeof(*iter); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2992 | struct qla_hw_data *ha = vha->hw; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2993 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2994 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1084, |
| 2995 | "Entered %s.\n", __func__); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2996 | |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2997 | mcp->mb[0] = MBC_GET_LINK_STATUS; |
Joe Carnuccio | c6dc990 | 2016-07-06 11:14:24 -0400 | [diff] [blame] | 2998 | mcp->mb[2] = MSW(LSD(stats_dma)); |
| 2999 | mcp->mb[3] = LSW(LSD(stats_dma)); |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 3000 | mcp->mb[6] = MSW(MSD(stats_dma)); |
| 3001 | mcp->mb[7] = LSW(MSD(stats_dma)); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 3002 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; |
| 3003 | mcp->in_mb = MBX_0; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 3004 | if (IS_FWI2_CAPABLE(ha)) { |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 3005 | mcp->mb[1] = loop_id; |
| 3006 | mcp->mb[4] = 0; |
| 3007 | mcp->mb[10] = 0; |
| 3008 | mcp->out_mb |= MBX_10|MBX_4|MBX_1; |
| 3009 | mcp->in_mb |= MBX_1; |
| 3010 | } else if (HAS_EXTENDED_IDS(ha)) { |
| 3011 | mcp->mb[1] = loop_id; |
| 3012 | mcp->mb[10] = 0; |
| 3013 | mcp->out_mb |= MBX_10|MBX_1; |
| 3014 | } else { |
| 3015 | mcp->mb[1] = loop_id << 8; |
| 3016 | mcp->out_mb |= MBX_1; |
| 3017 | } |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3018 | mcp->tov = MBX_TOV_SECONDS; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 3019 | mcp->flags = IOCTL_CMD; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3020 | rval = qla2x00_mailbox_command(vha, mcp); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 3021 | |
| 3022 | if (rval == QLA_SUCCESS) { |
| 3023 | if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3024 | ql_dbg(ql_dbg_mbx, vha, 0x1085, |
| 3025 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 3026 | rval = QLA_FUNCTION_FAILED; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 3027 | } else { |
Joe Carnuccio | c6dc990 | 2016-07-06 11:14:24 -0400 | [diff] [blame] | 3028 | /* Re-endianize - firmware data is le32. */ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3029 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1086, |
| 3030 | "Done %s.\n", __func__); |
Joe Carnuccio | da08ef5 | 2016-01-27 12:03:34 -0500 | [diff] [blame] | 3031 | for ( ; dwords--; iter++) |
| 3032 | le32_to_cpus(iter); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 3033 | } |
| 3034 | } else { |
| 3035 | /* Failed. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3036 | 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] | 3037 | } |
| 3038 | |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 3039 | return rval; |
| 3040 | } |
| 3041 | |
| 3042 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3043 | 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] | 3044 | dma_addr_t stats_dma, uint16_t options) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3045 | { |
| 3046 | int rval; |
| 3047 | mbx_cmd_t mc; |
| 3048 | mbx_cmd_t *mcp = &mc; |
Joe Carnuccio | da08ef5 | 2016-01-27 12:03:34 -0500 | [diff] [blame] | 3049 | uint32_t *iter, dwords; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3050 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3051 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1088, |
| 3052 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3053 | |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 3054 | memset(&mc, 0, sizeof(mc)); |
| 3055 | mc.mb[0] = MBC_GET_LINK_PRIV_STATS; |
| 3056 | mc.mb[2] = MSW(stats_dma); |
| 3057 | mc.mb[3] = LSW(stats_dma); |
| 3058 | mc.mb[6] = MSW(MSD(stats_dma)); |
| 3059 | mc.mb[7] = LSW(MSD(stats_dma)); |
| 3060 | mc.mb[8] = sizeof(struct link_statistics) / 4; |
| 3061 | mc.mb[9] = cpu_to_le16(vha->vp_idx); |
| 3062 | mc.mb[10] = cpu_to_le16(options); |
| 3063 | |
| 3064 | rval = qla24xx_send_mb_cmd(vha, &mc); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3065 | |
| 3066 | if (rval == QLA_SUCCESS) { |
| 3067 | if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3068 | ql_dbg(ql_dbg_mbx, vha, 0x1089, |
| 3069 | "Failed mb[0]=%x.\n", mcp->mb[0]); |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 3070 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3071 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3072 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x108a, |
| 3073 | "Done %s.\n", __func__); |
Joe Carnuccio | c6dc990 | 2016-07-06 11:14:24 -0400 | [diff] [blame] | 3074 | /* Re-endianize - firmware data is le32. */ |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 3075 | dwords = sizeof(struct link_statistics) / 4; |
Joe Carnuccio | da08ef5 | 2016-01-27 12:03:34 -0500 | [diff] [blame] | 3076 | iter = &stats->link_fail_cnt; |
| 3077 | for ( ; dwords--; iter++) |
| 3078 | le32_to_cpus(iter); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3079 | } |
| 3080 | } else { |
| 3081 | /* Failed. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3082 | ql_dbg(ql_dbg_mbx, vha, 0x108b, "Failed=%x.\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3083 | } |
| 3084 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3085 | return rval; |
| 3086 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3087 | |
| 3088 | int |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3089 | qla24xx_abort_command(srb_t *sp) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3090 | { |
| 3091 | int rval; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3092 | unsigned long flags = 0; |
| 3093 | |
| 3094 | struct abort_entry_24xx *abt; |
| 3095 | dma_addr_t abt_dma; |
| 3096 | uint32_t handle; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3097 | fc_port_t *fcport = sp->fcport; |
| 3098 | struct scsi_qla_host *vha = fcport->vha; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3099 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 3100 | struct req_que *req = vha->req; |
Quinn Tran | 585def9 | 2018-09-04 14:19:20 -0700 | [diff] [blame] | 3101 | struct qla_qpair *qpair = sp->qpair; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3102 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3103 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x108c, |
| 3104 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3105 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3106 | if (vha->flags.qpairs_available && sp->qpair) |
| 3107 | req = sp->qpair->req; |
Quinn Tran | 585def9 | 2018-09-04 14:19:20 -0700 | [diff] [blame] | 3108 | else |
| 3109 | return QLA_FUNCTION_FAILED; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3110 | |
Armen Baloyan | 4440e46 | 2014-02-26 04:15:18 -0500 | [diff] [blame] | 3111 | if (ql2xasynctmfenable) |
| 3112 | return qla24xx_async_abort_command(sp); |
| 3113 | |
Quinn Tran | 585def9 | 2018-09-04 14:19:20 -0700 | [diff] [blame] | 3114 | spin_lock_irqsave(qpair->qp_lock_ptr, flags); |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 3115 | for (handle = 1; handle < req->num_outstanding_cmds; handle++) { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3116 | if (req->outstanding_cmds[handle] == sp) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3117 | break; |
| 3118 | } |
Quinn Tran | 585def9 | 2018-09-04 14:19:20 -0700 | [diff] [blame] | 3119 | spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 3120 | if (handle == req->num_outstanding_cmds) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3121 | /* Command not found. */ |
| 3122 | return QLA_FUNCTION_FAILED; |
| 3123 | } |
| 3124 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 3125 | abt = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &abt_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3126 | if (abt == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3127 | ql_log(ql_log_warn, vha, 0x108d, |
| 3128 | "Failed to allocate abort IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3129 | return QLA_MEMORY_ALLOC_FAILED; |
| 3130 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3131 | |
| 3132 | abt->entry_type = ABORT_IOCB_TYPE; |
| 3133 | abt->entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3134 | abt->handle = MAKE_HANDLE(req->id, abt->handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3135 | abt->nport_handle = cpu_to_le16(fcport->loop_id); |
Mike Hernandez | a74ec14 | 2011-03-30 11:46:20 -0700 | [diff] [blame] | 3136 | abt->handle_to_abort = MAKE_HANDLE(req->id, handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3137 | abt->port_id[0] = fcport->d_id.b.al_pa; |
| 3138 | abt->port_id[1] = fcport->d_id.b.area; |
| 3139 | abt->port_id[2] = fcport->d_id.b.domain; |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3140 | abt->vp_index = fcport->vha->vp_idx; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3141 | |
| 3142 | abt->req_que_no = cpu_to_le16(req->id); |
| 3143 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3144 | rval = qla2x00_issue_iocb(vha, abt, abt_dma, 0); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3145 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3146 | ql_dbg(ql_dbg_mbx, vha, 0x108e, |
| 3147 | "Failed to issue IOCB (%x).\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3148 | } else if (abt->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3149 | ql_dbg(ql_dbg_mbx, vha, 0x108f, |
| 3150 | "Failed to complete IOCB -- error status (%x).\n", |
| 3151 | abt->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3152 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 3153 | } else if (abt->nport_handle != cpu_to_le16(0)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3154 | ql_dbg(ql_dbg_mbx, vha, 0x1090, |
| 3155 | "Failed to complete IOCB -- completion status (%x).\n", |
| 3156 | le16_to_cpu(abt->nport_handle)); |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 3157 | if (abt->nport_handle == CS_IOCB_ERROR) |
| 3158 | rval = QLA_FUNCTION_PARAMETER_ERROR; |
| 3159 | else |
| 3160 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3161 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3162 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1091, |
| 3163 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3164 | } |
| 3165 | |
| 3166 | dma_pool_free(ha->s_dma_pool, abt, abt_dma); |
| 3167 | |
| 3168 | return rval; |
| 3169 | } |
| 3170 | |
| 3171 | struct tsk_mgmt_cmd { |
| 3172 | union { |
| 3173 | struct tsk_mgmt_entry tsk; |
| 3174 | struct sts_entry_24xx sts; |
| 3175 | } p; |
| 3176 | }; |
| 3177 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3178 | static int |
| 3179 | __qla24xx_issue_tmf(char *name, uint32_t type, struct fc_port *fcport, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 3180 | uint64_t l, int tag) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3181 | { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3182 | int rval, rval2; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3183 | struct tsk_mgmt_cmd *tsk; |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 3184 | struct sts_entry_24xx *sts; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3185 | dma_addr_t tsk_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3186 | scsi_qla_host_t *vha; |
| 3187 | struct qla_hw_data *ha; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3188 | struct req_que *req; |
| 3189 | struct rsp_que *rsp; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3190 | struct qla_qpair *qpair; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3191 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3192 | vha = fcport->vha; |
| 3193 | ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3194 | req = vha->req; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3195 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3196 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1092, |
| 3197 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3198 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3199 | if (vha->vp_idx && vha->qpair) { |
| 3200 | /* NPIV port */ |
| 3201 | qpair = vha->qpair; |
| 3202 | rsp = qpair->rsp; |
| 3203 | req = qpair->req; |
| 3204 | } else { |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 3205 | rsp = req->rsp; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3206 | } |
| 3207 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 3208 | tsk = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &tsk_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3209 | if (tsk == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3210 | ql_log(ql_log_warn, vha, 0x1093, |
| 3211 | "Failed to allocate task management IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3212 | return QLA_MEMORY_ALLOC_FAILED; |
| 3213 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3214 | |
| 3215 | tsk->p.tsk.entry_type = TSK_MGMT_IOCB_TYPE; |
| 3216 | tsk->p.tsk.entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3217 | tsk->p.tsk.handle = MAKE_HANDLE(req->id, tsk->p.tsk.handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3218 | tsk->p.tsk.nport_handle = cpu_to_le16(fcport->loop_id); |
Andrew Vasquez | 00a537b | 2008-02-28 14:06:11 -0800 | [diff] [blame] | 3219 | 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] | 3220 | tsk->p.tsk.control_flags = cpu_to_le32(type); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3221 | tsk->p.tsk.port_id[0] = fcport->d_id.b.al_pa; |
| 3222 | tsk->p.tsk.port_id[1] = fcport->d_id.b.area; |
| 3223 | tsk->p.tsk.port_id[2] = fcport->d_id.b.domain; |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3224 | tsk->p.tsk.vp_index = fcport->vha->vp_idx; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3225 | if (type == TCF_LUN_RESET) { |
| 3226 | int_to_scsilun(l, &tsk->p.tsk.lun); |
| 3227 | host_to_fcp_swap((uint8_t *)&tsk->p.tsk.lun, |
| 3228 | sizeof(tsk->p.tsk.lun)); |
| 3229 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3230 | |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 3231 | sts = &tsk->p.sts; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3232 | rval = qla2x00_issue_iocb(vha, tsk, tsk_dma, 0); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3233 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3234 | ql_dbg(ql_dbg_mbx, vha, 0x1094, |
| 3235 | "Failed to issue %s reset IOCB (%x).\n", name, rval); |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 3236 | } else if (sts->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3237 | ql_dbg(ql_dbg_mbx, vha, 0x1095, |
| 3238 | "Failed to complete IOCB -- error status (%x).\n", |
| 3239 | sts->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3240 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 3241 | } else if (sts->comp_status != cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3242 | ql_dbg(ql_dbg_mbx, vha, 0x1096, |
| 3243 | "Failed to complete IOCB -- completion status (%x).\n", |
| 3244 | le16_to_cpu(sts->comp_status)); |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 3245 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 97dec56 | 2011-02-23 15:27:14 -0800 | [diff] [blame] | 3246 | } else if (le16_to_cpu(sts->scsi_status) & |
| 3247 | SS_RESPONSE_INFO_LEN_VALID) { |
| 3248 | if (le32_to_cpu(sts->rsp_data_len) < 4) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3249 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1097, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3250 | "Ignoring inconsistent data length -- not enough " |
| 3251 | "response info (%d).\n", |
| 3252 | le32_to_cpu(sts->rsp_data_len)); |
Andrew Vasquez | 97dec56 | 2011-02-23 15:27:14 -0800 | [diff] [blame] | 3253 | } else if (sts->data[3]) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3254 | ql_dbg(ql_dbg_mbx, vha, 0x1098, |
| 3255 | "Failed to complete IOCB -- response (%x).\n", |
| 3256 | sts->data[3]); |
Andrew Vasquez | 97dec56 | 2011-02-23 15:27:14 -0800 | [diff] [blame] | 3257 | rval = QLA_FUNCTION_FAILED; |
| 3258 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3259 | } |
| 3260 | |
| 3261 | /* Issue marker IOCB. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3262 | rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, l, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3263 | type == TCF_LUN_RESET ? MK_SYNC_ID_LUN: MK_SYNC_ID); |
| 3264 | if (rval2 != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3265 | ql_dbg(ql_dbg_mbx, vha, 0x1099, |
| 3266 | "Failed to issue marker IOCB (%x).\n", rval2); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3267 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3268 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109a, |
| 3269 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3270 | } |
| 3271 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3272 | dma_pool_free(ha->s_dma_pool, tsk, tsk_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3273 | |
| 3274 | return rval; |
| 3275 | } |
| 3276 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3277 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 3278 | qla24xx_abort_target(struct fc_port *fcport, uint64_t l, int tag) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3279 | { |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 3280 | struct qla_hw_data *ha = fcport->vha->hw; |
| 3281 | |
| 3282 | if ((ql2xasynctmfenable) && IS_FWI2_CAPABLE(ha)) |
| 3283 | return qla2x00_async_tm_cmd(fcport, TCF_TARGET_RESET, l, tag); |
| 3284 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3285 | return __qla24xx_issue_tmf("Target", TCF_TARGET_RESET, fcport, l, tag); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3286 | } |
| 3287 | |
| 3288 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 3289 | qla24xx_lun_reset(struct fc_port *fcport, uint64_t l, int tag) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3290 | { |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 3291 | struct qla_hw_data *ha = fcport->vha->hw; |
| 3292 | |
| 3293 | if ((ql2xasynctmfenable) && IS_FWI2_CAPABLE(ha)) |
| 3294 | return qla2x00_async_tm_cmd(fcport, TCF_LUN_RESET, l, tag); |
| 3295 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3296 | return __qla24xx_issue_tmf("Lun", TCF_LUN_RESET, fcport, l, tag); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3297 | } |
| 3298 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3299 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3300 | qla2x00_system_error(scsi_qla_host_t *vha) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3301 | { |
| 3302 | int rval; |
| 3303 | mbx_cmd_t mc; |
| 3304 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3305 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3306 | |
Andrew Vasquez | 68af081 | 2008-05-12 22:21:13 -0700 | [diff] [blame] | 3307 | if (!IS_QLA23XX(ha) && !IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3308 | return QLA_FUNCTION_FAILED; |
| 3309 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3310 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109b, |
| 3311 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3312 | |
| 3313 | mcp->mb[0] = MBC_GEN_SYSTEM_ERROR; |
| 3314 | mcp->out_mb = MBX_0; |
| 3315 | mcp->in_mb = MBX_0; |
| 3316 | mcp->tov = 5; |
| 3317 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3318 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3319 | |
| 3320 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3321 | ql_dbg(ql_dbg_mbx, vha, 0x109c, "Failed=%x.\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3322 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3323 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109d, |
| 3324 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3325 | } |
| 3326 | |
| 3327 | return rval; |
| 3328 | } |
| 3329 | |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 3330 | int |
| 3331 | qla2x00_write_serdes_word(scsi_qla_host_t *vha, uint16_t addr, uint16_t data) |
| 3332 | { |
| 3333 | int rval; |
| 3334 | mbx_cmd_t mc; |
| 3335 | mbx_cmd_t *mcp = &mc; |
| 3336 | |
Joe Carnuccio | f299c7c | 2015-08-04 13:37:51 -0400 | [diff] [blame] | 3337 | if (!IS_QLA25XX(vha->hw) && !IS_QLA2031(vha->hw) && |
| 3338 | !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 3339 | return QLA_FUNCTION_FAILED; |
| 3340 | |
| 3341 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1182, |
| 3342 | "Entered %s.\n", __func__); |
| 3343 | |
| 3344 | mcp->mb[0] = MBC_WRITE_SERDES; |
| 3345 | mcp->mb[1] = addr; |
Andrew Vasquez | 064135e | 2015-04-09 15:00:02 -0400 | [diff] [blame] | 3346 | if (IS_QLA2031(vha->hw)) |
| 3347 | mcp->mb[2] = data & 0xff; |
| 3348 | else |
| 3349 | mcp->mb[2] = data; |
| 3350 | |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 3351 | mcp->mb[3] = 0; |
| 3352 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 3353 | mcp->in_mb = MBX_0; |
| 3354 | mcp->tov = MBX_TOV_SECONDS; |
| 3355 | mcp->flags = 0; |
| 3356 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3357 | |
| 3358 | if (rval != QLA_SUCCESS) { |
| 3359 | ql_dbg(ql_dbg_mbx, vha, 0x1183, |
| 3360 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 3361 | } else { |
| 3362 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1184, |
| 3363 | "Done %s.\n", __func__); |
| 3364 | } |
| 3365 | |
| 3366 | return rval; |
| 3367 | } |
| 3368 | |
| 3369 | int |
| 3370 | qla2x00_read_serdes_word(scsi_qla_host_t *vha, uint16_t addr, uint16_t *data) |
| 3371 | { |
| 3372 | int rval; |
| 3373 | mbx_cmd_t mc; |
| 3374 | mbx_cmd_t *mcp = &mc; |
| 3375 | |
Joe Carnuccio | f299c7c | 2015-08-04 13:37:51 -0400 | [diff] [blame] | 3376 | if (!IS_QLA25XX(vha->hw) && !IS_QLA2031(vha->hw) && |
| 3377 | !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 3378 | return QLA_FUNCTION_FAILED; |
| 3379 | |
| 3380 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1185, |
| 3381 | "Entered %s.\n", __func__); |
| 3382 | |
| 3383 | mcp->mb[0] = MBC_READ_SERDES; |
| 3384 | mcp->mb[1] = addr; |
| 3385 | mcp->mb[3] = 0; |
| 3386 | mcp->out_mb = MBX_3|MBX_1|MBX_0; |
| 3387 | mcp->in_mb = MBX_1|MBX_0; |
| 3388 | mcp->tov = MBX_TOV_SECONDS; |
| 3389 | mcp->flags = 0; |
| 3390 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3391 | |
Andrew Vasquez | 064135e | 2015-04-09 15:00:02 -0400 | [diff] [blame] | 3392 | if (IS_QLA2031(vha->hw)) |
| 3393 | *data = mcp->mb[1] & 0xff; |
| 3394 | else |
| 3395 | *data = mcp->mb[1]; |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 3396 | |
| 3397 | if (rval != QLA_SUCCESS) { |
| 3398 | ql_dbg(ql_dbg_mbx, vha, 0x1186, |
| 3399 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 3400 | } else { |
| 3401 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1187, |
| 3402 | "Done %s.\n", __func__); |
| 3403 | } |
| 3404 | |
| 3405 | return rval; |
| 3406 | } |
| 3407 | |
Joe Carnuccio | e8887c5 | 2014-04-11 16:54:17 -0400 | [diff] [blame] | 3408 | int |
| 3409 | qla8044_write_serdes_word(scsi_qla_host_t *vha, uint32_t addr, uint32_t data) |
| 3410 | { |
| 3411 | int rval; |
| 3412 | mbx_cmd_t mc; |
| 3413 | mbx_cmd_t *mcp = &mc; |
| 3414 | |
| 3415 | if (!IS_QLA8044(vha->hw)) |
| 3416 | return QLA_FUNCTION_FAILED; |
| 3417 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3418 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x11a0, |
Joe Carnuccio | e8887c5 | 2014-04-11 16:54:17 -0400 | [diff] [blame] | 3419 | "Entered %s.\n", __func__); |
| 3420 | |
| 3421 | mcp->mb[0] = MBC_SET_GET_ETH_SERDES_REG; |
| 3422 | mcp->mb[1] = HCS_WRITE_SERDES; |
| 3423 | mcp->mb[3] = LSW(addr); |
| 3424 | mcp->mb[4] = MSW(addr); |
| 3425 | mcp->mb[5] = LSW(data); |
| 3426 | mcp->mb[6] = MSW(data); |
| 3427 | mcp->out_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_1|MBX_0; |
| 3428 | mcp->in_mb = MBX_0; |
| 3429 | mcp->tov = MBX_TOV_SECONDS; |
| 3430 | mcp->flags = 0; |
| 3431 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3432 | |
| 3433 | if (rval != QLA_SUCCESS) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3434 | ql_dbg(ql_dbg_mbx, vha, 0x11a1, |
Joe Carnuccio | e8887c5 | 2014-04-11 16:54:17 -0400 | [diff] [blame] | 3435 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 3436 | } else { |
| 3437 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1188, |
| 3438 | "Done %s.\n", __func__); |
| 3439 | } |
| 3440 | |
| 3441 | return rval; |
| 3442 | } |
| 3443 | |
| 3444 | int |
| 3445 | qla8044_read_serdes_word(scsi_qla_host_t *vha, uint32_t addr, uint32_t *data) |
| 3446 | { |
| 3447 | int rval; |
| 3448 | mbx_cmd_t mc; |
| 3449 | mbx_cmd_t *mcp = &mc; |
| 3450 | |
| 3451 | if (!IS_QLA8044(vha->hw)) |
| 3452 | return QLA_FUNCTION_FAILED; |
| 3453 | |
| 3454 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1189, |
| 3455 | "Entered %s.\n", __func__); |
| 3456 | |
| 3457 | mcp->mb[0] = MBC_SET_GET_ETH_SERDES_REG; |
| 3458 | mcp->mb[1] = HCS_READ_SERDES; |
| 3459 | mcp->mb[3] = LSW(addr); |
| 3460 | mcp->mb[4] = MSW(addr); |
| 3461 | mcp->out_mb = MBX_4|MBX_3|MBX_1|MBX_0; |
| 3462 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 3463 | mcp->tov = MBX_TOV_SECONDS; |
| 3464 | mcp->flags = 0; |
| 3465 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3466 | |
| 3467 | *data = mcp->mb[2] << 16 | mcp->mb[1]; |
| 3468 | |
| 3469 | if (rval != QLA_SUCCESS) { |
| 3470 | ql_dbg(ql_dbg_mbx, vha, 0x118a, |
| 3471 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 3472 | } else { |
| 3473 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x118b, |
| 3474 | "Done %s.\n", __func__); |
| 3475 | } |
| 3476 | |
| 3477 | return rval; |
| 3478 | } |
| 3479 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3480 | /** |
| 3481 | * qla2x00_set_serdes_params() - |
Bart Van Assche | 2db6228 | 2018-01-23 16:33:51 -0800 | [diff] [blame] | 3482 | * @vha: HA context |
Bart Van Assche | 807eb90 | 2018-10-18 15:45:41 -0700 | [diff] [blame] | 3483 | * @sw_em_1g: serial link options |
| 3484 | * @sw_em_2g: serial link options |
| 3485 | * @sw_em_4g: serial link options |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3486 | * |
| 3487 | * Returns |
| 3488 | */ |
| 3489 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3490 | 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] | 3491 | uint16_t sw_em_2g, uint16_t sw_em_4g) |
| 3492 | { |
| 3493 | int rval; |
| 3494 | mbx_cmd_t mc; |
| 3495 | mbx_cmd_t *mcp = &mc; |
| 3496 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3497 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109e, |
| 3498 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3499 | |
| 3500 | mcp->mb[0] = MBC_SERDES_PARAMS; |
| 3501 | mcp->mb[1] = BIT_0; |
andrew.vasquez@qlogic.com | fdbc683 | 2006-03-09 14:27:29 -0800 | [diff] [blame] | 3502 | mcp->mb[2] = sw_em_1g | BIT_15; |
| 3503 | mcp->mb[3] = sw_em_2g | BIT_15; |
| 3504 | mcp->mb[4] = sw_em_4g | BIT_15; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3505 | mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3506 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3507 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3508 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3509 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3510 | |
| 3511 | if (rval != QLA_SUCCESS) { |
| 3512 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3513 | ql_dbg(ql_dbg_mbx, vha, 0x109f, |
| 3514 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3515 | } else { |
| 3516 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3517 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a0, |
| 3518 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3519 | } |
| 3520 | |
| 3521 | return rval; |
| 3522 | } |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3523 | |
| 3524 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3525 | qla2x00_stop_firmware(scsi_qla_host_t *vha) |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3526 | { |
| 3527 | int rval; |
| 3528 | mbx_cmd_t mc; |
| 3529 | mbx_cmd_t *mcp = &mc; |
| 3530 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3531 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3532 | return QLA_FUNCTION_FAILED; |
| 3533 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3534 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a1, |
| 3535 | "Entered %s.\n", __func__); |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3536 | |
| 3537 | mcp->mb[0] = MBC_STOP_FIRMWARE; |
Andrew Vasquez | 4ba988d | 2012-02-09 11:14:06 -0800 | [diff] [blame] | 3538 | mcp->mb[1] = 0; |
| 3539 | mcp->out_mb = MBX_1|MBX_0; |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3540 | mcp->in_mb = MBX_0; |
| 3541 | mcp->tov = 5; |
| 3542 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3543 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3544 | |
| 3545 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3546 | ql_dbg(ql_dbg_mbx, vha, 0x10a2, "Failed=%x.\n", rval); |
Andrew Vasquez | b469a7c | 2009-04-06 22:33:48 -0700 | [diff] [blame] | 3547 | if (mcp->mb[0] == MBS_INVALID_COMMAND) |
| 3548 | rval = QLA_INVALID_COMMAND; |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3549 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3550 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a3, |
| 3551 | "Done %s.\n", __func__); |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3552 | } |
| 3553 | |
| 3554 | return rval; |
| 3555 | } |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3556 | |
| 3557 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3558 | 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] | 3559 | uint16_t buffers) |
| 3560 | { |
| 3561 | int rval; |
| 3562 | mbx_cmd_t mc; |
| 3563 | mbx_cmd_t *mcp = &mc; |
| 3564 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3565 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a4, |
| 3566 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3567 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3568 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3569 | return QLA_FUNCTION_FAILED; |
| 3570 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3571 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3572 | return QLA_FUNCTION_FAILED; |
| 3573 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3574 | mcp->mb[0] = MBC_TRACE_CONTROL; |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3575 | mcp->mb[1] = TC_EFT_ENABLE; |
| 3576 | mcp->mb[2] = LSW(eft_dma); |
| 3577 | mcp->mb[3] = MSW(eft_dma); |
| 3578 | mcp->mb[4] = LSW(MSD(eft_dma)); |
| 3579 | mcp->mb[5] = MSW(MSD(eft_dma)); |
| 3580 | mcp->mb[6] = buffers; |
| 3581 | mcp->mb[7] = TC_AEN_DISABLE; |
| 3582 | 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] | 3583 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3584 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3585 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3586 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3587 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3588 | ql_dbg(ql_dbg_mbx, vha, 0x10a5, |
| 3589 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3590 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3591 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3592 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a6, |
| 3593 | "Done %s.\n", __func__); |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3594 | } |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3595 | |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3596 | return rval; |
| 3597 | } |
| 3598 | |
| 3599 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3600 | qla2x00_disable_eft_trace(scsi_qla_host_t *vha) |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3601 | { |
| 3602 | int rval; |
| 3603 | mbx_cmd_t mc; |
| 3604 | mbx_cmd_t *mcp = &mc; |
| 3605 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3606 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a7, |
| 3607 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3608 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3609 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3610 | return QLA_FUNCTION_FAILED; |
| 3611 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3612 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3613 | return QLA_FUNCTION_FAILED; |
| 3614 | |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3615 | mcp->mb[0] = MBC_TRACE_CONTROL; |
| 3616 | mcp->mb[1] = TC_EFT_DISABLE; |
| 3617 | mcp->out_mb = MBX_1|MBX_0; |
| 3618 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3619 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3620 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3621 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3622 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3623 | ql_dbg(ql_dbg_mbx, vha, 0x10a8, |
| 3624 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3625 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3626 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3627 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a9, |
| 3628 | "Done %s.\n", __func__); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3629 | } |
| 3630 | |
| 3631 | return rval; |
| 3632 | } |
| 3633 | |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 3634 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3635 | 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] | 3636 | uint16_t buffers, uint16_t *mb, uint32_t *dwords) |
| 3637 | { |
| 3638 | int rval; |
| 3639 | mbx_cmd_t mc; |
| 3640 | mbx_cmd_t *mcp = &mc; |
| 3641 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3642 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10aa, |
| 3643 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3644 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3645 | if (!IS_QLA25XX(vha->hw) && !IS_QLA81XX(vha->hw) && |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3646 | !IS_QLA83XX(vha->hw) && !IS_QLA27XX(vha->hw)) |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3647 | return QLA_FUNCTION_FAILED; |
| 3648 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3649 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3650 | return QLA_FUNCTION_FAILED; |
| 3651 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3652 | mcp->mb[0] = MBC_TRACE_CONTROL; |
| 3653 | mcp->mb[1] = TC_FCE_ENABLE; |
| 3654 | mcp->mb[2] = LSW(fce_dma); |
| 3655 | mcp->mb[3] = MSW(fce_dma); |
| 3656 | mcp->mb[4] = LSW(MSD(fce_dma)); |
| 3657 | mcp->mb[5] = MSW(MSD(fce_dma)); |
| 3658 | mcp->mb[6] = buffers; |
| 3659 | mcp->mb[7] = TC_AEN_DISABLE; |
| 3660 | mcp->mb[8] = 0; |
| 3661 | mcp->mb[9] = TC_FCE_DEFAULT_RX_SIZE; |
| 3662 | mcp->mb[10] = TC_FCE_DEFAULT_TX_SIZE; |
| 3663 | mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2| |
| 3664 | MBX_1|MBX_0; |
| 3665 | 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] | 3666 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3667 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3668 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3669 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3670 | ql_dbg(ql_dbg_mbx, vha, 0x10ab, |
| 3671 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3672 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3673 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3674 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ac, |
| 3675 | "Done %s.\n", __func__); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3676 | |
| 3677 | if (mb) |
| 3678 | memcpy(mb, mcp->mb, 8 * sizeof(*mb)); |
| 3679 | if (dwords) |
Andrew Vasquez | fa0926d | 2008-05-12 22:21:12 -0700 | [diff] [blame] | 3680 | *dwords = buffers; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3681 | } |
| 3682 | |
| 3683 | return rval; |
| 3684 | } |
| 3685 | |
| 3686 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3687 | 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] | 3688 | { |
| 3689 | int rval; |
| 3690 | mbx_cmd_t mc; |
| 3691 | mbx_cmd_t *mcp = &mc; |
| 3692 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3693 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ad, |
| 3694 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3695 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3696 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3697 | return QLA_FUNCTION_FAILED; |
| 3698 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3699 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3700 | return QLA_FUNCTION_FAILED; |
| 3701 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3702 | mcp->mb[0] = MBC_TRACE_CONTROL; |
| 3703 | mcp->mb[1] = TC_FCE_DISABLE; |
| 3704 | mcp->mb[2] = TC_FCE_DISABLE_TRACE; |
| 3705 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 3706 | mcp->in_mb = MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2| |
| 3707 | MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3708 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3709 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3710 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3711 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3712 | ql_dbg(ql_dbg_mbx, vha, 0x10ae, |
| 3713 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3714 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3715 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3716 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10af, |
| 3717 | "Done %s.\n", __func__); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3718 | |
| 3719 | if (wr) |
| 3720 | *wr = (uint64_t) mcp->mb[5] << 48 | |
| 3721 | (uint64_t) mcp->mb[4] << 32 | |
| 3722 | (uint64_t) mcp->mb[3] << 16 | |
| 3723 | (uint64_t) mcp->mb[2]; |
| 3724 | if (rd) |
| 3725 | *rd = (uint64_t) mcp->mb[9] << 48 | |
| 3726 | (uint64_t) mcp->mb[8] << 32 | |
| 3727 | (uint64_t) mcp->mb[7] << 16 | |
| 3728 | (uint64_t) mcp->mb[6]; |
| 3729 | } |
| 3730 | |
| 3731 | return rval; |
| 3732 | } |
| 3733 | |
| 3734 | int |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3735 | qla2x00_get_idma_speed(scsi_qla_host_t *vha, uint16_t loop_id, |
| 3736 | uint16_t *port_speed, uint16_t *mb) |
| 3737 | { |
| 3738 | int rval; |
| 3739 | mbx_cmd_t mc; |
| 3740 | mbx_cmd_t *mcp = &mc; |
| 3741 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3742 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b0, |
| 3743 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3744 | |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3745 | if (!IS_IIDMA_CAPABLE(vha->hw)) |
| 3746 | return QLA_FUNCTION_FAILED; |
| 3747 | |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3748 | mcp->mb[0] = MBC_PORT_PARAMS; |
| 3749 | mcp->mb[1] = loop_id; |
| 3750 | mcp->mb[2] = mcp->mb[3] = 0; |
| 3751 | mcp->mb[9] = vha->vp_idx; |
| 3752 | mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3753 | mcp->in_mb = MBX_3|MBX_1|MBX_0; |
| 3754 | mcp->tov = MBX_TOV_SECONDS; |
| 3755 | mcp->flags = 0; |
| 3756 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3757 | |
| 3758 | /* Return mailbox statuses. */ |
| 3759 | if (mb != NULL) { |
| 3760 | mb[0] = mcp->mb[0]; |
| 3761 | mb[1] = mcp->mb[1]; |
| 3762 | mb[3] = mcp->mb[3]; |
| 3763 | } |
| 3764 | |
| 3765 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3766 | ql_dbg(ql_dbg_mbx, vha, 0x10b1, "Failed=%x.\n", rval); |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3767 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3768 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b2, |
| 3769 | "Done %s.\n", __func__); |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3770 | if (port_speed) |
| 3771 | *port_speed = mcp->mb[3]; |
| 3772 | } |
| 3773 | |
| 3774 | return rval; |
| 3775 | } |
| 3776 | |
| 3777 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3778 | 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] | 3779 | uint16_t port_speed, uint16_t *mb) |
| 3780 | { |
| 3781 | int rval; |
| 3782 | mbx_cmd_t mc; |
| 3783 | mbx_cmd_t *mcp = &mc; |
| 3784 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3785 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b3, |
| 3786 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3787 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3788 | if (!IS_IIDMA_CAPABLE(vha->hw)) |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3789 | return QLA_FUNCTION_FAILED; |
| 3790 | |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3791 | mcp->mb[0] = MBC_PORT_PARAMS; |
| 3792 | mcp->mb[1] = loop_id; |
| 3793 | mcp->mb[2] = BIT_0; |
Himanshu Madhani | 4c1458d | 2018-08-31 11:24:27 -0700 | [diff] [blame] | 3794 | mcp->mb[3] = port_speed & (BIT_5|BIT_4|BIT_3|BIT_2|BIT_1|BIT_0); |
Harish Zunjarrao | 1bb3954 | 2009-06-17 10:30:29 -0700 | [diff] [blame] | 3795 | mcp->mb[9] = vha->vp_idx; |
| 3796 | mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3797 | mcp->in_mb = MBX_3|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3798 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3799 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3800 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3801 | |
| 3802 | /* Return mailbox statuses. */ |
| 3803 | if (mb != NULL) { |
| 3804 | mb[0] = mcp->mb[0]; |
| 3805 | mb[1] = mcp->mb[1]; |
| 3806 | mb[3] = mcp->mb[3]; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3807 | } |
| 3808 | |
| 3809 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3810 | ql_dbg(ql_dbg_mbx, vha, 0x10b4, |
| 3811 | "Failed=%x.\n", rval); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3812 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3813 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b5, |
| 3814 | "Done %s.\n", __func__); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3815 | } |
| 3816 | |
| 3817 | return rval; |
| 3818 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3819 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3820 | void |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3821 | qla24xx_report_id_acquisition(scsi_qla_host_t *vha, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3822 | struct vp_rpt_id_entry_24xx *rptid_entry) |
| 3823 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3824 | struct qla_hw_data *ha = vha->hw; |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3825 | scsi_qla_host_t *vp = NULL; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3826 | unsigned long flags; |
Andrew Vasquez | 4ac8d4ca | 2013-02-08 01:57:58 -0500 | [diff] [blame] | 3827 | int found; |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3828 | port_id_t id; |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 3829 | struct fc_port *fcport; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3830 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3831 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b6, |
| 3832 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3833 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3834 | if (rptid_entry->entry_status != 0) |
| 3835 | return; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3836 | |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3837 | id.b.domain = rptid_entry->port_id[2]; |
| 3838 | id.b.area = rptid_entry->port_id[1]; |
| 3839 | id.b.al_pa = rptid_entry->port_id[0]; |
| 3840 | id.b.rsvd_1 = 0; |
Darren Trapp | 1763c1f | 2018-03-20 23:09:34 -0700 | [diff] [blame] | 3841 | ha->flags.n2n_ae = 0; |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3842 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3843 | if (rptid_entry->format == 0) { |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3844 | /* loop */ |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 3845 | ql_dbg(ql_dbg_async, vha, 0x10b7, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3846 | "Format 0 : Number of VPs setup %d, number of " |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3847 | "VPs acquired %d.\n", rptid_entry->vp_setup, |
| 3848 | rptid_entry->vp_acquired); |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 3849 | ql_dbg(ql_dbg_async, vha, 0x10b8, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3850 | "Primary port id %02x%02x%02x.\n", |
| 3851 | rptid_entry->port_id[2], rptid_entry->port_id[1], |
| 3852 | rptid_entry->port_id[0]); |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 3853 | ha->current_topology = ISP_CFG_NL; |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3854 | qlt_update_host_map(vha, id); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3855 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3856 | } else if (rptid_entry->format == 1) { |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3857 | /* fabric */ |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 3858 | ql_dbg(ql_dbg_async, vha, 0x10b9, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3859 | "Format 1: VP[%d] enabled - status %d - with " |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3860 | "port id %02x%02x%02x.\n", rptid_entry->vp_idx, |
| 3861 | rptid_entry->vp_status, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3862 | rptid_entry->port_id[2], rptid_entry->port_id[1], |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3863 | rptid_entry->port_id[0]); |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 3864 | ql_dbg(ql_dbg_async, vha, 0x5075, |
| 3865 | "Format 1: Remote WWPN %8phC.\n", |
| 3866 | rptid_entry->u.f1.port_name); |
| 3867 | |
| 3868 | ql_dbg(ql_dbg_async, vha, 0x5075, |
| 3869 | "Format 1: WWPN %8phC.\n", |
| 3870 | vha->port_name); |
| 3871 | |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 3872 | switch (rptid_entry->u.f1.flags & TOPO_MASK) { |
| 3873 | case TOPO_N2N: |
| 3874 | ha->current_topology = ISP_CFG_N; |
| 3875 | spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); |
| 3876 | fcport = qla2x00_find_fcport_by_wwpn(vha, |
| 3877 | rptid_entry->u.f1.port_name, 1); |
| 3878 | spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); |
| 3879 | |
| 3880 | if (fcport) { |
| 3881 | fcport->plogi_nack_done_deadline = jiffies + HZ; |
| 3882 | fcport->dm_login_expire = jiffies + 3*HZ; |
| 3883 | fcport->scan_state = QLA_FCPORT_FOUND; |
| 3884 | switch (fcport->disc_state) { |
| 3885 | case DSC_DELETED: |
| 3886 | set_bit(RELOGIN_NEEDED, |
| 3887 | &vha->dpc_flags); |
| 3888 | break; |
| 3889 | case DSC_DELETE_PEND: |
| 3890 | break; |
| 3891 | default: |
| 3892 | qlt_schedule_sess_for_deletion(fcport); |
| 3893 | break; |
| 3894 | } |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 3895 | } else { |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 3896 | id.b24 = 0; |
| 3897 | if (wwn_to_u64(vha->port_name) > |
| 3898 | wwn_to_u64(rptid_entry->u.f1.port_name)) { |
| 3899 | vha->d_id.b24 = 0; |
| 3900 | vha->d_id.b.al_pa = 1; |
| 3901 | ha->flags.n2n_bigger = 1; |
| 3902 | |
| 3903 | id.b.al_pa = 2; |
| 3904 | ql_dbg(ql_dbg_async, vha, 0x5075, |
| 3905 | "Format 1: assign local id %x remote id %x\n", |
| 3906 | vha->d_id.b24, id.b24); |
| 3907 | } else { |
| 3908 | ql_dbg(ql_dbg_async, vha, 0x5075, |
| 3909 | "Format 1: Remote login - Waiting for WWPN %8phC.\n", |
| 3910 | rptid_entry->u.f1.port_name); |
| 3911 | ha->flags.n2n_bigger = 0; |
| 3912 | } |
| 3913 | qla24xx_post_newsess_work(vha, &id, |
| 3914 | rptid_entry->u.f1.port_name, |
| 3915 | rptid_entry->u.f1.node_name, |
| 3916 | NULL, |
| 3917 | FC4_TYPE_UNKNOWN); |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 3918 | } |
| 3919 | |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 3920 | /* if our portname is higher then initiate N2N login */ |
| 3921 | |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 3922 | set_bit(N2N_LOGIN_NEEDED, &vha->dpc_flags); |
Darren Trapp | 1763c1f | 2018-03-20 23:09:34 -0700 | [diff] [blame] | 3923 | ha->flags.n2n_ae = 1; |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 3924 | return; |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 3925 | break; |
| 3926 | case TOPO_FL: |
| 3927 | ha->current_topology = ISP_CFG_FL; |
| 3928 | break; |
| 3929 | case TOPO_F: |
| 3930 | ha->current_topology = ISP_CFG_F; |
| 3931 | break; |
| 3932 | default: |
| 3933 | break; |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 3934 | } |
Andrew Vasquez | 531a82d | 2009-10-13 15:16:51 -0700 | [diff] [blame] | 3935 | |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 3936 | ha->flags.gpsc_supported = 1; |
| 3937 | ha->current_topology = ISP_CFG_F; |
Sawan Chandak | 969a619 | 2016-01-27 12:03:32 -0500 | [diff] [blame] | 3938 | /* buffer to buffer credit flag */ |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3939 | vha->flags.bbcr_enable = (rptid_entry->u.f1.bbcr & 0xf) != 0; |
Sawan Chandak | 969a619 | 2016-01-27 12:03:32 -0500 | [diff] [blame] | 3940 | |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3941 | if (rptid_entry->vp_idx == 0) { |
| 3942 | if (rptid_entry->vp_status == VP_STAT_COMPL) { |
| 3943 | /* FA-WWN is only for physical port */ |
| 3944 | if (qla_ini_mode_enabled(vha) && |
| 3945 | ha->flags.fawwpn_enabled && |
| 3946 | (rptid_entry->u.f1.flags & |
Sawan Chandak | fcc5b5c | 2017-08-23 15:05:02 -0700 | [diff] [blame] | 3947 | BIT_6)) { |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3948 | memcpy(vha->port_name, |
| 3949 | rptid_entry->u.f1.port_name, |
| 3950 | WWN_SIZE); |
| 3951 | } |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 3952 | |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3953 | qlt_update_host_map(vha, id); |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 3954 | } |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3955 | |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3956 | set_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags); |
| 3957 | set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags); |
| 3958 | } else { |
| 3959 | if (rptid_entry->vp_status != VP_STAT_COMPL && |
| 3960 | rptid_entry->vp_status != VP_STAT_ID_CHG) { |
| 3961 | ql_dbg(ql_dbg_mbx, vha, 0x10ba, |
| 3962 | "Could not acquire ID for VP[%d].\n", |
| 3963 | rptid_entry->vp_idx); |
| 3964 | return; |
Andrew Vasquez | 4ac8d4ca | 2013-02-08 01:57:58 -0500 | [diff] [blame] | 3965 | } |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3966 | |
| 3967 | found = 0; |
| 3968 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 3969 | list_for_each_entry(vp, &ha->vp_list, list) { |
| 3970 | if (rptid_entry->vp_idx == vp->vp_idx) { |
| 3971 | found = 1; |
| 3972 | break; |
| 3973 | } |
| 3974 | } |
| 3975 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 3976 | |
| 3977 | if (!found) |
| 3978 | return; |
| 3979 | |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3980 | qlt_update_host_map(vp, id); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3981 | |
| 3982 | /* |
| 3983 | * Cannot configure here as we are still sitting on the |
| 3984 | * response queue. Handle it in dpc context. |
| 3985 | */ |
| 3986 | set_bit(VP_IDX_ACQUIRED, &vp->vp_flags); |
| 3987 | set_bit(REGISTER_FC4_NEEDED, &vp->dpc_flags); |
| 3988 | set_bit(REGISTER_FDMI_NEEDED, &vp->dpc_flags); |
Andrew Vasquez | 4ac8d4ca | 2013-02-08 01:57:58 -0500 | [diff] [blame] | 3989 | } |
Andrew Vasquez | 531a82d | 2009-10-13 15:16:51 -0700 | [diff] [blame] | 3990 | set_bit(VP_DPC_NEEDED, &vha->dpc_flags); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3991 | qla2xxx_wake_dpc(vha); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3992 | } else if (rptid_entry->format == 2) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3993 | ql_dbg(ql_dbg_async, vha, 0x505f, |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3994 | "RIDA: format 2/N2N Primary port id %02x%02x%02x.\n", |
| 3995 | rptid_entry->port_id[2], rptid_entry->port_id[1], |
| 3996 | rptid_entry->port_id[0]); |
| 3997 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3998 | ql_dbg(ql_dbg_async, vha, 0x5075, |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3999 | "N2N: Remote WWPN %8phC.\n", |
| 4000 | rptid_entry->u.f2.port_name); |
| 4001 | |
| 4002 | /* N2N. direct connect */ |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 4003 | ha->current_topology = ISP_CFG_N; |
| 4004 | ha->flags.rida_fmt2 = 1; |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4005 | vha->d_id.b.domain = rptid_entry->port_id[2]; |
| 4006 | vha->d_id.b.area = rptid_entry->port_id[1]; |
| 4007 | vha->d_id.b.al_pa = rptid_entry->port_id[0]; |
| 4008 | |
Darren Trapp | 1763c1f | 2018-03-20 23:09:34 -0700 | [diff] [blame] | 4009 | ha->flags.n2n_ae = 1; |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4010 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 4011 | qlt_update_vp_map(vha, SET_AL_PA); |
| 4012 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 4013 | |
| 4014 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 4015 | fcport->scan_state = QLA_FCPORT_SCAN; |
| 4016 | } |
| 4017 | |
| 4018 | fcport = qla2x00_find_fcport_by_wwpn(vha, |
| 4019 | rptid_entry->u.f2.port_name, 1); |
| 4020 | |
| 4021 | if (fcport) { |
Quinn Tran | 23dd98a | 2018-08-02 13:16:45 -0700 | [diff] [blame] | 4022 | fcport->login_retry = vha->hw->login_retry_count; |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 4023 | fcport->plogi_nack_done_deadline = jiffies + HZ; |
| 4024 | fcport->scan_state = QLA_FCPORT_FOUND; |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 4025 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4026 | } |
| 4027 | } |
| 4028 | |
| 4029 | /* |
| 4030 | * qla24xx_modify_vp_config |
| 4031 | * Change VP configuration for vha |
| 4032 | * |
| 4033 | * Input: |
| 4034 | * vha = adapter block pointer. |
| 4035 | * |
| 4036 | * Returns: |
| 4037 | * qla2xxx local function return status code. |
| 4038 | * |
| 4039 | * Context: |
| 4040 | * Kernel context. |
| 4041 | */ |
| 4042 | int |
| 4043 | qla24xx_modify_vp_config(scsi_qla_host_t *vha) |
| 4044 | { |
| 4045 | int rval; |
| 4046 | struct vp_config_entry_24xx *vpmod; |
| 4047 | dma_addr_t vpmod_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4048 | struct qla_hw_data *ha = vha->hw; |
| 4049 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4050 | |
| 4051 | /* This can be called by the parent */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4052 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4053 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10bb, |
| 4054 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4055 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 4056 | vpmod = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &vpmod_dma); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4057 | if (!vpmod) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4058 | ql_log(ql_log_warn, vha, 0x10bc, |
| 4059 | "Failed to allocate modify VP IOCB.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4060 | return QLA_MEMORY_ALLOC_FAILED; |
| 4061 | } |
| 4062 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4063 | vpmod->entry_type = VP_CONFIG_IOCB_TYPE; |
| 4064 | vpmod->entry_count = 1; |
| 4065 | vpmod->command = VCT_COMMAND_MOD_ENABLE_VPS; |
| 4066 | vpmod->vp_count = 1; |
| 4067 | vpmod->vp_index1 = vha->vp_idx; |
| 4068 | vpmod->options_idx1 = BIT_3|BIT_4|BIT_5; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4069 | |
| 4070 | qlt_modify_vp_config(vha, vpmod); |
| 4071 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4072 | memcpy(vpmod->node_name_idx1, vha->node_name, WWN_SIZE); |
| 4073 | memcpy(vpmod->port_name_idx1, vha->port_name, WWN_SIZE); |
| 4074 | vpmod->entry_count = 1; |
| 4075 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4076 | rval = qla2x00_issue_iocb(base_vha, vpmod, vpmod_dma, 0); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4077 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4078 | ql_dbg(ql_dbg_mbx, vha, 0x10bd, |
| 4079 | "Failed to issue VP config IOCB (%x).\n", rval); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4080 | } else if (vpmod->comp_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4081 | ql_dbg(ql_dbg_mbx, vha, 0x10be, |
| 4082 | "Failed to complete IOCB -- error status (%x).\n", |
| 4083 | vpmod->comp_status); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4084 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 4085 | } else if (vpmod->comp_status != cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4086 | ql_dbg(ql_dbg_mbx, vha, 0x10bf, |
| 4087 | "Failed to complete IOCB -- completion status (%x).\n", |
| 4088 | le16_to_cpu(vpmod->comp_status)); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4089 | rval = QLA_FUNCTION_FAILED; |
| 4090 | } else { |
| 4091 | /* EMPTY */ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4092 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c0, |
| 4093 | "Done %s.\n", __func__); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4094 | fc_vport_set_state(vha->fc_vport, FC_VPORT_INITIALIZING); |
| 4095 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4096 | dma_pool_free(ha->s_dma_pool, vpmod, vpmod_dma); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4097 | |
| 4098 | return rval; |
| 4099 | } |
| 4100 | |
| 4101 | /* |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4102 | * qla2x00_send_change_request |
| 4103 | * Receive or disable RSCN request from fabric controller |
| 4104 | * |
| 4105 | * Input: |
| 4106 | * ha = adapter block pointer |
| 4107 | * format = registration format: |
| 4108 | * 0 - Reserved |
| 4109 | * 1 - Fabric detected registration |
| 4110 | * 2 - N_port detected registration |
| 4111 | * 3 - Full registration |
| 4112 | * FF - clear registration |
| 4113 | * vp_idx = Virtual port index |
| 4114 | * |
| 4115 | * Returns: |
| 4116 | * qla2x00 local function return status code. |
| 4117 | * |
| 4118 | * Context: |
| 4119 | * Kernel Context |
| 4120 | */ |
| 4121 | |
| 4122 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4123 | qla2x00_send_change_request(scsi_qla_host_t *vha, uint16_t format, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4124 | uint16_t vp_idx) |
| 4125 | { |
| 4126 | int rval; |
| 4127 | mbx_cmd_t mc; |
| 4128 | mbx_cmd_t *mcp = &mc; |
| 4129 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4130 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c7, |
| 4131 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4132 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4133 | mcp->mb[0] = MBC_SEND_CHANGE_REQUEST; |
| 4134 | mcp->mb[1] = format; |
| 4135 | mcp->mb[9] = vp_idx; |
| 4136 | mcp->out_mb = MBX_9|MBX_1|MBX_0; |
| 4137 | mcp->in_mb = MBX_0|MBX_1; |
| 4138 | mcp->tov = MBX_TOV_SECONDS; |
| 4139 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4140 | rval = qla2x00_mailbox_command(vha, mcp); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4141 | |
| 4142 | if (rval == QLA_SUCCESS) { |
| 4143 | if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { |
| 4144 | rval = BIT_1; |
| 4145 | } |
| 4146 | } else |
| 4147 | rval = BIT_1; |
| 4148 | |
| 4149 | return rval; |
| 4150 | } |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4151 | |
| 4152 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4153 | 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] | 4154 | uint32_t size) |
| 4155 | { |
| 4156 | int rval; |
| 4157 | mbx_cmd_t mc; |
| 4158 | mbx_cmd_t *mcp = &mc; |
| 4159 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4160 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1009, |
| 4161 | "Entered %s.\n", __func__); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4162 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4163 | if (MSW(addr) || IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4164 | mcp->mb[0] = MBC_DUMP_RISC_RAM_EXTENDED; |
| 4165 | mcp->mb[8] = MSW(addr); |
| 4166 | mcp->out_mb = MBX_8|MBX_0; |
| 4167 | } else { |
| 4168 | mcp->mb[0] = MBC_DUMP_RISC_RAM; |
| 4169 | mcp->out_mb = MBX_0; |
| 4170 | } |
| 4171 | mcp->mb[1] = LSW(addr); |
| 4172 | mcp->mb[2] = MSW(req_dma); |
| 4173 | mcp->mb[3] = LSW(req_dma); |
| 4174 | mcp->mb[6] = MSW(MSD(req_dma)); |
| 4175 | mcp->mb[7] = LSW(MSD(req_dma)); |
| 4176 | 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] | 4177 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4178 | mcp->mb[4] = MSW(size); |
| 4179 | mcp->mb[5] = LSW(size); |
| 4180 | mcp->out_mb |= MBX_5|MBX_4; |
| 4181 | } else { |
| 4182 | mcp->mb[4] = LSW(size); |
| 4183 | mcp->out_mb |= MBX_4; |
| 4184 | } |
| 4185 | |
| 4186 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 4187 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4188 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4189 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4190 | |
| 4191 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4192 | ql_dbg(ql_dbg_mbx, vha, 0x1008, |
| 4193 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4194 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4195 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1007, |
| 4196 | "Done %s.\n", __func__); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4197 | } |
| 4198 | |
| 4199 | return rval; |
| 4200 | } |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4201 | /* 84XX Support **************************************************************/ |
| 4202 | |
| 4203 | struct cs84xx_mgmt_cmd { |
| 4204 | union { |
| 4205 | struct verify_chip_entry_84xx req; |
| 4206 | struct verify_chip_rsp_84xx rsp; |
| 4207 | } p; |
| 4208 | }; |
| 4209 | |
| 4210 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4211 | qla84xx_verify_chip(struct scsi_qla_host *vha, uint16_t *status) |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4212 | { |
| 4213 | int rval, retry; |
| 4214 | struct cs84xx_mgmt_cmd *mn; |
| 4215 | dma_addr_t mn_dma; |
| 4216 | uint16_t options; |
| 4217 | unsigned long flags; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4218 | struct qla_hw_data *ha = vha->hw; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4219 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4220 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c8, |
| 4221 | "Entered %s.\n", __func__); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4222 | |
| 4223 | mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma); |
| 4224 | if (mn == NULL) { |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4225 | return QLA_MEMORY_ALLOC_FAILED; |
| 4226 | } |
| 4227 | |
| 4228 | /* Force Update? */ |
| 4229 | options = ha->cs84xx->fw_update ? VCO_FORCE_UPDATE : 0; |
| 4230 | /* Diagnostic firmware? */ |
| 4231 | /* options |= MENLO_DIAG_FW; */ |
| 4232 | /* We update the firmware with only one data sequence. */ |
| 4233 | options |= VCO_END_OF_DATA; |
| 4234 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4235 | do { |
Andrew Vasquez | c1ec1f1 | 2008-04-24 15:21:24 -0700 | [diff] [blame] | 4236 | retry = 0; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4237 | memset(mn, 0, sizeof(*mn)); |
| 4238 | mn->p.req.entry_type = VERIFY_CHIP_IOCB_TYPE; |
| 4239 | mn->p.req.entry_count = 1; |
| 4240 | mn->p.req.options = cpu_to_le16(options); |
| 4241 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4242 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111c, |
| 4243 | "Dump of Verify Request.\n"); |
| 4244 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111e, |
| 4245 | (uint8_t *)mn, sizeof(*mn)); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4246 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4247 | rval = qla2x00_issue_iocb_timeout(vha, mn, mn_dma, 0, 120); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4248 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4249 | ql_dbg(ql_dbg_mbx, vha, 0x10cb, |
| 4250 | "Failed to issue verify IOCB (%x).\n", rval); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4251 | goto verify_done; |
| 4252 | } |
| 4253 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4254 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1110, |
| 4255 | "Dump of Verify Response.\n"); |
| 4256 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1118, |
| 4257 | (uint8_t *)mn, sizeof(*mn)); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4258 | |
| 4259 | status[0] = le16_to_cpu(mn->p.rsp.comp_status); |
| 4260 | status[1] = status[0] == CS_VCS_CHIP_FAILURE ? |
| 4261 | le16_to_cpu(mn->p.rsp.failure_code) : 0; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4262 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ce, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4263 | "cs=%x fc=%x.\n", status[0], status[1]); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4264 | |
| 4265 | if (status[0] != CS_COMPLETE) { |
| 4266 | rval = QLA_FUNCTION_FAILED; |
| 4267 | if (!(options & VCO_DONT_UPDATE_FW)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4268 | ql_dbg(ql_dbg_mbx, vha, 0x10cf, |
| 4269 | "Firmware update failed. Retrying " |
| 4270 | "without update firmware.\n"); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4271 | options |= VCO_DONT_UPDATE_FW; |
| 4272 | options &= ~VCO_FORCE_UPDATE; |
| 4273 | retry = 1; |
| 4274 | } |
| 4275 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4276 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d0, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4277 | "Firmware updated to %x.\n", |
| 4278 | le32_to_cpu(mn->p.rsp.fw_ver)); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4279 | |
| 4280 | /* NOTE: we only update OP firmware. */ |
| 4281 | spin_lock_irqsave(&ha->cs84xx->access_lock, flags); |
| 4282 | ha->cs84xx->op_fw_version = |
| 4283 | le32_to_cpu(mn->p.rsp.fw_ver); |
| 4284 | spin_unlock_irqrestore(&ha->cs84xx->access_lock, |
| 4285 | flags); |
| 4286 | } |
| 4287 | } while (retry); |
| 4288 | |
| 4289 | verify_done: |
| 4290 | dma_pool_free(ha->s_dma_pool, mn, mn_dma); |
| 4291 | |
| 4292 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4293 | ql_dbg(ql_dbg_mbx, vha, 0x10d1, |
| 4294 | "Failed=%x.\n", rval); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4295 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4296 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d2, |
| 4297 | "Done %s.\n", __func__); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4298 | } |
| 4299 | |
| 4300 | return rval; |
| 4301 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4302 | |
| 4303 | int |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4304 | 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] | 4305 | { |
| 4306 | int rval; |
| 4307 | unsigned long flags; |
| 4308 | mbx_cmd_t mc; |
| 4309 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4310 | struct qla_hw_data *ha = vha->hw; |
| 4311 | |
Quinn Tran | 4523502 | 2018-07-18 14:29:53 -0700 | [diff] [blame] | 4312 | if (!ha->flags.fw_started) |
| 4313 | return QLA_SUCCESS; |
| 4314 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4315 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d3, |
| 4316 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4317 | |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 4318 | if (IS_SHADOW_REG_CAPABLE(ha)) |
| 4319 | req->options |= BIT_13; |
| 4320 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4321 | mcp->mb[0] = MBC_INITIALIZE_MULTIQ; |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4322 | mcp->mb[1] = req->options; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4323 | mcp->mb[2] = MSW(LSD(req->dma)); |
| 4324 | mcp->mb[3] = LSW(LSD(req->dma)); |
| 4325 | mcp->mb[6] = MSW(MSD(req->dma)); |
| 4326 | mcp->mb[7] = LSW(MSD(req->dma)); |
| 4327 | mcp->mb[5] = req->length; |
| 4328 | if (req->rsp) |
| 4329 | mcp->mb[10] = req->rsp->id; |
| 4330 | mcp->mb[12] = req->qos; |
| 4331 | mcp->mb[11] = req->vp_idx; |
| 4332 | mcp->mb[13] = req->rid; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4333 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4334 | mcp->mb[15] = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4335 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4336 | mcp->mb[4] = req->id; |
| 4337 | /* que in ptr index */ |
| 4338 | mcp->mb[8] = 0; |
| 4339 | /* que out ptr index */ |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 4340 | mcp->mb[9] = *req->out_ptr = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4341 | mcp->out_mb = MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8|MBX_7| |
| 4342 | MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4343 | mcp->in_mb = MBX_0; |
| 4344 | mcp->flags = MBX_DMA_OUT; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4345 | mcp->tov = MBX_TOV_SECONDS * 2; |
| 4346 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4347 | if (IS_QLA81XX(ha) || IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4348 | mcp->in_mb |= MBX_1; |
Joe Carnuccio | ba4828b | 2014-04-11 16:54:10 -0400 | [diff] [blame] | 4349 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4350 | mcp->out_mb |= MBX_15; |
| 4351 | /* debug q create issue in SR-IOV */ |
| 4352 | mcp->in_mb |= MBX_9 | MBX_8 | MBX_7; |
| 4353 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4354 | |
| 4355 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4356 | if (!(req->options & BIT_0)) { |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 4357 | WRT_REG_DWORD(req->req_q_in, 0); |
Joe Carnuccio | 29db41c | 2014-04-11 16:54:09 -0400 | [diff] [blame] | 4358 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 4359 | WRT_REG_DWORD(req->req_q_out, 0); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4360 | } |
| 4361 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 4362 | |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 4363 | rval = qla2x00_mailbox_command(vha, mcp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4364 | if (rval != QLA_SUCCESS) { |
| 4365 | ql_dbg(ql_dbg_mbx, vha, 0x10d4, |
| 4366 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 4367 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4368 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d5, |
| 4369 | "Done %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4370 | } |
| 4371 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4372 | return rval; |
| 4373 | } |
| 4374 | |
| 4375 | int |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4376 | 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] | 4377 | { |
| 4378 | int rval; |
| 4379 | unsigned long flags; |
| 4380 | mbx_cmd_t mc; |
| 4381 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4382 | struct qla_hw_data *ha = vha->hw; |
| 4383 | |
Quinn Tran | 4523502 | 2018-07-18 14:29:53 -0700 | [diff] [blame] | 4384 | if (!ha->flags.fw_started) |
| 4385 | return QLA_SUCCESS; |
| 4386 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4387 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d6, |
| 4388 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4389 | |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 4390 | if (IS_SHADOW_REG_CAPABLE(ha)) |
| 4391 | rsp->options |= BIT_13; |
| 4392 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4393 | mcp->mb[0] = MBC_INITIALIZE_MULTIQ; |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4394 | mcp->mb[1] = rsp->options; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4395 | mcp->mb[2] = MSW(LSD(rsp->dma)); |
| 4396 | mcp->mb[3] = LSW(LSD(rsp->dma)); |
| 4397 | mcp->mb[6] = MSW(MSD(rsp->dma)); |
| 4398 | mcp->mb[7] = LSW(MSD(rsp->dma)); |
| 4399 | mcp->mb[5] = rsp->length; |
Andrew Vasquez | 444786d | 2009-01-05 11:18:10 -0800 | [diff] [blame] | 4400 | mcp->mb[14] = rsp->msix->entry; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4401 | mcp->mb[13] = rsp->rid; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4402 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4403 | mcp->mb[15] = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4404 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4405 | mcp->mb[4] = rsp->id; |
| 4406 | /* que in ptr index */ |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 4407 | mcp->mb[8] = *rsp->in_ptr = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4408 | /* que out ptr index */ |
| 4409 | mcp->mb[9] = 0; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 4410 | 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] | 4411 | |MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4412 | mcp->in_mb = MBX_0; |
| 4413 | mcp->flags = MBX_DMA_OUT; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4414 | mcp->tov = MBX_TOV_SECONDS * 2; |
| 4415 | |
| 4416 | if (IS_QLA81XX(ha)) { |
| 4417 | mcp->out_mb |= MBX_12|MBX_11|MBX_10; |
| 4418 | mcp->in_mb |= MBX_1; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4419 | } else if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4420 | mcp->out_mb |= MBX_15|MBX_12|MBX_11|MBX_10; |
| 4421 | mcp->in_mb |= MBX_1; |
| 4422 | /* debug q create issue in SR-IOV */ |
| 4423 | mcp->in_mb |= MBX_9 | MBX_8 | MBX_7; |
| 4424 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4425 | |
| 4426 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4427 | if (!(rsp->options & BIT_0)) { |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 4428 | WRT_REG_DWORD(rsp->rsp_q_out, 0); |
Himanshu Madhani | b20f02e | 2015-06-10 11:05:18 -0400 | [diff] [blame] | 4429 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 4430 | WRT_REG_DWORD(rsp->rsp_q_in, 0); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4431 | } |
| 4432 | |
| 4433 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 4434 | |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 4435 | rval = qla2x00_mailbox_command(vha, mcp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4436 | if (rval != QLA_SUCCESS) { |
| 4437 | ql_dbg(ql_dbg_mbx, vha, 0x10d7, |
| 4438 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 4439 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4440 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d8, |
| 4441 | "Done %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4442 | } |
| 4443 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4444 | return rval; |
| 4445 | } |
| 4446 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4447 | int |
| 4448 | qla81xx_idc_ack(scsi_qla_host_t *vha, uint16_t *mb) |
| 4449 | { |
| 4450 | int rval; |
| 4451 | mbx_cmd_t mc; |
| 4452 | mbx_cmd_t *mcp = &mc; |
| 4453 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4454 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d9, |
| 4455 | "Entered %s.\n", __func__); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4456 | |
| 4457 | mcp->mb[0] = MBC_IDC_ACK; |
| 4458 | memcpy(&mcp->mb[1], mb, QLA_IDC_ACK_REGS * sizeof(uint16_t)); |
| 4459 | mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4460 | mcp->in_mb = MBX_0; |
| 4461 | mcp->tov = MBX_TOV_SECONDS; |
| 4462 | mcp->flags = 0; |
| 4463 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4464 | |
| 4465 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4466 | ql_dbg(ql_dbg_mbx, vha, 0x10da, |
| 4467 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4468 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4469 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10db, |
| 4470 | "Done %s.\n", __func__); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4471 | } |
| 4472 | |
| 4473 | return rval; |
| 4474 | } |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4475 | |
| 4476 | int |
| 4477 | qla81xx_fac_get_sector_size(scsi_qla_host_t *vha, uint32_t *sector_size) |
| 4478 | { |
| 4479 | int rval; |
| 4480 | mbx_cmd_t mc; |
| 4481 | mbx_cmd_t *mcp = &mc; |
| 4482 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4483 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10dc, |
| 4484 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4485 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4486 | if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) && |
| 4487 | !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4488 | return QLA_FUNCTION_FAILED; |
| 4489 | |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4490 | mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; |
| 4491 | mcp->mb[1] = FAC_OPT_CMD_GET_SECTOR_SIZE; |
| 4492 | mcp->out_mb = MBX_1|MBX_0; |
| 4493 | mcp->in_mb = MBX_1|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, 0x10dd, |
| 4500 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 4501 | rval, mcp->mb[0], mcp->mb[1]); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4502 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4503 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10de, |
| 4504 | "Done %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4505 | *sector_size = mcp->mb[1]; |
| 4506 | } |
| 4507 | |
| 4508 | return rval; |
| 4509 | } |
| 4510 | |
| 4511 | int |
| 4512 | qla81xx_fac_do_write_enable(scsi_qla_host_t *vha, int enable) |
| 4513 | { |
| 4514 | int rval; |
| 4515 | mbx_cmd_t mc; |
| 4516 | mbx_cmd_t *mcp = &mc; |
| 4517 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4518 | if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) && |
| 4519 | !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4520 | return QLA_FUNCTION_FAILED; |
| 4521 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4522 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10df, |
| 4523 | "Entered %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4524 | |
| 4525 | mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; |
| 4526 | mcp->mb[1] = enable ? FAC_OPT_CMD_WRITE_ENABLE : |
| 4527 | FAC_OPT_CMD_WRITE_PROTECT; |
| 4528 | mcp->out_mb = MBX_1|MBX_0; |
| 4529 | mcp->in_mb = MBX_1|MBX_0; |
| 4530 | mcp->tov = MBX_TOV_SECONDS; |
| 4531 | mcp->flags = 0; |
| 4532 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4533 | |
| 4534 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4535 | ql_dbg(ql_dbg_mbx, vha, 0x10e0, |
| 4536 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 4537 | rval, mcp->mb[0], mcp->mb[1]); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4538 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4539 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e1, |
| 4540 | "Done %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4541 | } |
| 4542 | |
| 4543 | return rval; |
| 4544 | } |
| 4545 | |
| 4546 | int |
| 4547 | qla81xx_fac_erase_sector(scsi_qla_host_t *vha, uint32_t start, uint32_t finish) |
| 4548 | { |
| 4549 | int rval; |
| 4550 | mbx_cmd_t mc; |
| 4551 | mbx_cmd_t *mcp = &mc; |
| 4552 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4553 | if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) && |
| 4554 | !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4555 | return QLA_FUNCTION_FAILED; |
| 4556 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4557 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e2, |
| 4558 | "Entered %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4559 | |
| 4560 | mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; |
| 4561 | mcp->mb[1] = FAC_OPT_CMD_ERASE_SECTOR; |
| 4562 | mcp->mb[2] = LSW(start); |
| 4563 | mcp->mb[3] = MSW(start); |
| 4564 | mcp->mb[4] = LSW(finish); |
| 4565 | mcp->mb[5] = MSW(finish); |
| 4566 | mcp->out_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4567 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 4568 | mcp->tov = MBX_TOV_SECONDS; |
| 4569 | mcp->flags = 0; |
| 4570 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4571 | |
| 4572 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4573 | ql_dbg(ql_dbg_mbx, vha, 0x10e3, |
| 4574 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 4575 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4576 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4577 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e4, |
| 4578 | "Done %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4579 | } |
| 4580 | |
| 4581 | return rval; |
| 4582 | } |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4583 | |
| 4584 | int |
| 4585 | qla81xx_restart_mpi_firmware(scsi_qla_host_t *vha) |
| 4586 | { |
| 4587 | int rval = 0; |
| 4588 | mbx_cmd_t mc; |
| 4589 | mbx_cmd_t *mcp = &mc; |
| 4590 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4591 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e5, |
| 4592 | "Entered %s.\n", __func__); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4593 | |
| 4594 | mcp->mb[0] = MBC_RESTART_MPI_FW; |
| 4595 | mcp->out_mb = MBX_0; |
| 4596 | mcp->in_mb = MBX_0|MBX_1; |
| 4597 | mcp->tov = MBX_TOV_SECONDS; |
| 4598 | mcp->flags = 0; |
| 4599 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4600 | |
| 4601 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4602 | ql_dbg(ql_dbg_mbx, vha, 0x10e6, |
| 4603 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 4604 | rval, mcp->mb[0], mcp->mb[1]); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4605 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4606 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e7, |
| 4607 | "Done %s.\n", __func__); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4608 | } |
| 4609 | |
| 4610 | return rval; |
| 4611 | } |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4612 | |
Joe Carnuccio | c46e65c | 2013-08-27 01:37:35 -0400 | [diff] [blame] | 4613 | int |
| 4614 | qla82xx_set_driver_version(scsi_qla_host_t *vha, char *version) |
| 4615 | { |
| 4616 | int rval; |
| 4617 | mbx_cmd_t mc; |
| 4618 | mbx_cmd_t *mcp = &mc; |
| 4619 | int i; |
| 4620 | int len; |
| 4621 | uint16_t *str; |
| 4622 | struct qla_hw_data *ha = vha->hw; |
| 4623 | |
| 4624 | if (!IS_P3P_TYPE(ha)) |
| 4625 | return QLA_FUNCTION_FAILED; |
| 4626 | |
| 4627 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x117b, |
| 4628 | "Entered %s.\n", __func__); |
| 4629 | |
| 4630 | str = (void *)version; |
| 4631 | len = strlen(version); |
| 4632 | |
| 4633 | mcp->mb[0] = MBC_SET_RNID_PARAMS; |
| 4634 | mcp->mb[1] = RNID_TYPE_SET_VERSION << 8; |
| 4635 | mcp->out_mb = MBX_1|MBX_0; |
| 4636 | for (i = 4; i < 16 && len; i++, str++, len -= 2) { |
| 4637 | mcp->mb[i] = cpu_to_le16p(str); |
| 4638 | mcp->out_mb |= 1<<i; |
| 4639 | } |
| 4640 | for (; i < 16; i++) { |
| 4641 | mcp->mb[i] = 0; |
| 4642 | mcp->out_mb |= 1<<i; |
| 4643 | } |
| 4644 | mcp->in_mb = MBX_1|MBX_0; |
| 4645 | mcp->tov = MBX_TOV_SECONDS; |
| 4646 | mcp->flags = 0; |
| 4647 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4648 | |
| 4649 | if (rval != QLA_SUCCESS) { |
| 4650 | ql_dbg(ql_dbg_mbx, vha, 0x117c, |
| 4651 | "Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]); |
| 4652 | } else { |
| 4653 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x117d, |
| 4654 | "Done %s.\n", __func__); |
| 4655 | } |
| 4656 | |
| 4657 | return rval; |
| 4658 | } |
| 4659 | |
| 4660 | int |
| 4661 | qla25xx_set_driver_version(scsi_qla_host_t *vha, char *version) |
| 4662 | { |
| 4663 | int rval; |
| 4664 | mbx_cmd_t mc; |
| 4665 | mbx_cmd_t *mcp = &mc; |
| 4666 | int len; |
| 4667 | uint16_t dwlen; |
| 4668 | uint8_t *str; |
| 4669 | dma_addr_t str_dma; |
| 4670 | struct qla_hw_data *ha = vha->hw; |
| 4671 | |
| 4672 | if (!IS_FWI2_CAPABLE(ha) || IS_QLA24XX_TYPE(ha) || IS_QLA81XX(ha) || |
| 4673 | IS_P3P_TYPE(ha)) |
| 4674 | return QLA_FUNCTION_FAILED; |
| 4675 | |
| 4676 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x117e, |
| 4677 | "Entered %s.\n", __func__); |
| 4678 | |
| 4679 | str = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &str_dma); |
| 4680 | if (!str) { |
| 4681 | ql_log(ql_log_warn, vha, 0x117f, |
| 4682 | "Failed to allocate driver version param.\n"); |
| 4683 | return QLA_MEMORY_ALLOC_FAILED; |
| 4684 | } |
| 4685 | |
| 4686 | memcpy(str, "\x7\x3\x11\x0", 4); |
| 4687 | dwlen = str[0]; |
| 4688 | len = dwlen * 4 - 4; |
| 4689 | memset(str + 4, 0, len); |
| 4690 | if (len > strlen(version)) |
| 4691 | len = strlen(version); |
| 4692 | memcpy(str + 4, version, len); |
| 4693 | |
| 4694 | mcp->mb[0] = MBC_SET_RNID_PARAMS; |
| 4695 | mcp->mb[1] = RNID_TYPE_SET_VERSION << 8 | dwlen; |
| 4696 | mcp->mb[2] = MSW(LSD(str_dma)); |
| 4697 | mcp->mb[3] = LSW(LSD(str_dma)); |
| 4698 | mcp->mb[6] = MSW(MSD(str_dma)); |
| 4699 | mcp->mb[7] = LSW(MSD(str_dma)); |
| 4700 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4701 | mcp->in_mb = MBX_1|MBX_0; |
| 4702 | mcp->tov = MBX_TOV_SECONDS; |
| 4703 | mcp->flags = 0; |
| 4704 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4705 | |
| 4706 | if (rval != QLA_SUCCESS) { |
| 4707 | ql_dbg(ql_dbg_mbx, vha, 0x1180, |
| 4708 | "Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]); |
| 4709 | } else { |
| 4710 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1181, |
| 4711 | "Done %s.\n", __func__); |
| 4712 | } |
| 4713 | |
| 4714 | dma_pool_free(ha->s_dma_pool, str, str_dma); |
| 4715 | |
| 4716 | return rval; |
| 4717 | } |
| 4718 | |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 4719 | int |
| 4720 | qla24xx_get_port_login_templ(scsi_qla_host_t *vha, dma_addr_t buf_dma, |
| 4721 | void *buf, uint16_t bufsiz) |
| 4722 | { |
| 4723 | int rval, i; |
| 4724 | mbx_cmd_t mc; |
| 4725 | mbx_cmd_t *mcp = &mc; |
| 4726 | uint32_t *bp; |
| 4727 | |
| 4728 | if (!IS_FWI2_CAPABLE(vha->hw)) |
| 4729 | return QLA_FUNCTION_FAILED; |
| 4730 | |
| 4731 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1159, |
| 4732 | "Entered %s.\n", __func__); |
| 4733 | |
| 4734 | mcp->mb[0] = MBC_GET_RNID_PARAMS; |
| 4735 | mcp->mb[1] = RNID_TYPE_PORT_LOGIN << 8; |
| 4736 | mcp->mb[2] = MSW(buf_dma); |
| 4737 | mcp->mb[3] = LSW(buf_dma); |
| 4738 | mcp->mb[6] = MSW(MSD(buf_dma)); |
| 4739 | mcp->mb[7] = LSW(MSD(buf_dma)); |
| 4740 | mcp->mb[8] = bufsiz/4; |
| 4741 | mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4742 | mcp->in_mb = MBX_1|MBX_0; |
| 4743 | mcp->tov = MBX_TOV_SECONDS; |
| 4744 | mcp->flags = 0; |
| 4745 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4746 | |
| 4747 | if (rval != QLA_SUCCESS) { |
| 4748 | ql_dbg(ql_dbg_mbx, vha, 0x115a, |
| 4749 | "Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]); |
| 4750 | } else { |
| 4751 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x115b, |
| 4752 | "Done %s.\n", __func__); |
| 4753 | bp = (uint32_t *) buf; |
| 4754 | for (i = 0; i < (bufsiz-4)/4; i++, bp++) |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 4755 | *bp = le32_to_cpu(*bp); |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 4756 | } |
| 4757 | |
| 4758 | return rval; |
| 4759 | } |
| 4760 | |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 4761 | static int |
| 4762 | qla2x00_read_asic_temperature(scsi_qla_host_t *vha, uint16_t *temp) |
| 4763 | { |
| 4764 | int rval; |
| 4765 | mbx_cmd_t mc; |
| 4766 | mbx_cmd_t *mcp = &mc; |
| 4767 | |
| 4768 | if (!IS_FWI2_CAPABLE(vha->hw)) |
| 4769 | return QLA_FUNCTION_FAILED; |
| 4770 | |
| 4771 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1159, |
| 4772 | "Entered %s.\n", __func__); |
| 4773 | |
| 4774 | mcp->mb[0] = MBC_GET_RNID_PARAMS; |
| 4775 | mcp->mb[1] = RNID_TYPE_ASIC_TEMP << 8; |
| 4776 | mcp->out_mb = MBX_1|MBX_0; |
| 4777 | mcp->in_mb = MBX_1|MBX_0; |
| 4778 | mcp->tov = MBX_TOV_SECONDS; |
| 4779 | mcp->flags = 0; |
| 4780 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4781 | *temp = mcp->mb[1]; |
| 4782 | |
| 4783 | if (rval != QLA_SUCCESS) { |
| 4784 | ql_dbg(ql_dbg_mbx, vha, 0x115a, |
| 4785 | "Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]); |
| 4786 | } else { |
| 4787 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x115b, |
| 4788 | "Done %s.\n", __func__); |
| 4789 | } |
| 4790 | |
| 4791 | return rval; |
| 4792 | } |
| 4793 | |
Joe Carnuccio | 3a11711 | 2013-02-08 01:58:00 -0500 | [diff] [blame] | 4794 | int |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4795 | qla2x00_read_sfp(scsi_qla_host_t *vha, dma_addr_t sfp_dma, uint8_t *sfp, |
| 4796 | uint16_t dev, uint16_t off, uint16_t len, uint16_t opt) |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4797 | { |
| 4798 | int rval; |
| 4799 | mbx_cmd_t mc; |
| 4800 | mbx_cmd_t *mcp = &mc; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4801 | struct qla_hw_data *ha = vha->hw; |
| 4802 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4803 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e8, |
| 4804 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4805 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4806 | if (!IS_FWI2_CAPABLE(ha)) |
| 4807 | return QLA_FUNCTION_FAILED; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4808 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4809 | if (len == 1) |
| 4810 | opt |= BIT_0; |
| 4811 | |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4812 | mcp->mb[0] = MBC_READ_SFP; |
| 4813 | mcp->mb[1] = dev; |
| 4814 | mcp->mb[2] = MSW(sfp_dma); |
| 4815 | mcp->mb[3] = LSW(sfp_dma); |
| 4816 | mcp->mb[6] = MSW(MSD(sfp_dma)); |
| 4817 | mcp->mb[7] = LSW(MSD(sfp_dma)); |
| 4818 | mcp->mb[8] = len; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4819 | mcp->mb[9] = off; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4820 | mcp->mb[10] = opt; |
| 4821 | 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] | 4822 | mcp->in_mb = MBX_1|MBX_0; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4823 | mcp->tov = MBX_TOV_SECONDS; |
| 4824 | mcp->flags = 0; |
| 4825 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4826 | |
| 4827 | if (opt & BIT_0) |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4828 | *sfp = mcp->mb[1]; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4829 | |
| 4830 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4831 | ql_dbg(ql_dbg_mbx, vha, 0x10e9, |
| 4832 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 4833 | if (mcp->mb[0] == MBS_COMMAND_ERROR && |
| 4834 | mcp->mb[1] == 0x22) |
| 4835 | /* sfp is not there */ |
| 4836 | rval = QLA_INTERFACE_ERROR; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4837 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4838 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ea, |
| 4839 | "Done %s.\n", __func__); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4840 | } |
| 4841 | |
| 4842 | return rval; |
| 4843 | } |
| 4844 | |
| 4845 | int |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4846 | qla2x00_write_sfp(scsi_qla_host_t *vha, dma_addr_t sfp_dma, uint8_t *sfp, |
| 4847 | uint16_t dev, uint16_t off, uint16_t len, uint16_t opt) |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4848 | { |
| 4849 | int rval; |
| 4850 | mbx_cmd_t mc; |
| 4851 | mbx_cmd_t *mcp = &mc; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4852 | struct qla_hw_data *ha = vha->hw; |
| 4853 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4854 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10eb, |
| 4855 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4856 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4857 | if (!IS_FWI2_CAPABLE(ha)) |
| 4858 | return QLA_FUNCTION_FAILED; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4859 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4860 | if (len == 1) |
| 4861 | opt |= BIT_0; |
| 4862 | |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4863 | if (opt & BIT_0) |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4864 | len = *sfp; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4865 | |
| 4866 | mcp->mb[0] = MBC_WRITE_SFP; |
| 4867 | mcp->mb[1] = dev; |
| 4868 | mcp->mb[2] = MSW(sfp_dma); |
| 4869 | mcp->mb[3] = LSW(sfp_dma); |
| 4870 | mcp->mb[6] = MSW(MSD(sfp_dma)); |
| 4871 | mcp->mb[7] = LSW(MSD(sfp_dma)); |
| 4872 | mcp->mb[8] = len; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4873 | mcp->mb[9] = off; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4874 | mcp->mb[10] = opt; |
| 4875 | 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] | 4876 | mcp->in_mb = MBX_1|MBX_0; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4877 | mcp->tov = MBX_TOV_SECONDS; |
| 4878 | mcp->flags = 0; |
| 4879 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4880 | |
| 4881 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4882 | ql_dbg(ql_dbg_mbx, vha, 0x10ec, |
| 4883 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4884 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4885 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ed, |
| 4886 | "Done %s.\n", __func__); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4887 | } |
| 4888 | |
| 4889 | return rval; |
| 4890 | } |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4891 | |
| 4892 | int |
| 4893 | qla2x00_get_xgmac_stats(scsi_qla_host_t *vha, dma_addr_t stats_dma, |
| 4894 | uint16_t size_in_bytes, uint16_t *actual_size) |
| 4895 | { |
| 4896 | int rval; |
| 4897 | mbx_cmd_t mc; |
| 4898 | mbx_cmd_t *mcp = &mc; |
| 4899 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4900 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ee, |
| 4901 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4902 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4903 | if (!IS_CNA_CAPABLE(vha->hw)) |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4904 | return QLA_FUNCTION_FAILED; |
| 4905 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4906 | mcp->mb[0] = MBC_GET_XGMAC_STATS; |
| 4907 | mcp->mb[2] = MSW(stats_dma); |
| 4908 | mcp->mb[3] = LSW(stats_dma); |
| 4909 | mcp->mb[6] = MSW(MSD(stats_dma)); |
| 4910 | mcp->mb[7] = LSW(MSD(stats_dma)); |
| 4911 | mcp->mb[8] = size_in_bytes >> 2; |
| 4912 | mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; |
| 4913 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 4914 | mcp->tov = MBX_TOV_SECONDS; |
| 4915 | mcp->flags = 0; |
| 4916 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4917 | |
| 4918 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4919 | ql_dbg(ql_dbg_mbx, vha, 0x10ef, |
| 4920 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 4921 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4922 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4923 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f0, |
| 4924 | "Done %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4925 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4926 | |
| 4927 | *actual_size = mcp->mb[2] << 2; |
| 4928 | } |
| 4929 | |
| 4930 | return rval; |
| 4931 | } |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4932 | |
| 4933 | int |
| 4934 | qla2x00_get_dcbx_params(scsi_qla_host_t *vha, dma_addr_t tlv_dma, |
| 4935 | uint16_t size) |
| 4936 | { |
| 4937 | int rval; |
| 4938 | mbx_cmd_t mc; |
| 4939 | mbx_cmd_t *mcp = &mc; |
| 4940 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4941 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f1, |
| 4942 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4943 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4944 | if (!IS_CNA_CAPABLE(vha->hw)) |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4945 | return QLA_FUNCTION_FAILED; |
| 4946 | |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4947 | mcp->mb[0] = MBC_GET_DCBX_PARAMS; |
| 4948 | mcp->mb[1] = 0; |
| 4949 | mcp->mb[2] = MSW(tlv_dma); |
| 4950 | mcp->mb[3] = LSW(tlv_dma); |
| 4951 | mcp->mb[6] = MSW(MSD(tlv_dma)); |
| 4952 | mcp->mb[7] = LSW(MSD(tlv_dma)); |
| 4953 | mcp->mb[8] = size; |
| 4954 | mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4955 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 4956 | mcp->tov = MBX_TOV_SECONDS; |
| 4957 | mcp->flags = 0; |
| 4958 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4959 | |
| 4960 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4961 | ql_dbg(ql_dbg_mbx, vha, 0x10f2, |
| 4962 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 4963 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4964 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4965 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f3, |
| 4966 | "Done %s.\n", __func__); |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4967 | } |
| 4968 | |
| 4969 | return rval; |
| 4970 | } |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4971 | |
| 4972 | int |
| 4973 | qla2x00_read_ram_word(scsi_qla_host_t *vha, uint32_t risc_addr, uint32_t *data) |
| 4974 | { |
| 4975 | int rval; |
| 4976 | mbx_cmd_t mc; |
| 4977 | mbx_cmd_t *mcp = &mc; |
| 4978 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4979 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f4, |
| 4980 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4981 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4982 | if (!IS_FWI2_CAPABLE(vha->hw)) |
| 4983 | return QLA_FUNCTION_FAILED; |
| 4984 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4985 | mcp->mb[0] = MBC_READ_RAM_EXTENDED; |
| 4986 | mcp->mb[1] = LSW(risc_addr); |
| 4987 | mcp->mb[8] = MSW(risc_addr); |
| 4988 | mcp->out_mb = MBX_8|MBX_1|MBX_0; |
| 4989 | mcp->in_mb = MBX_3|MBX_2|MBX_0; |
| 4990 | mcp->tov = 30; |
| 4991 | mcp->flags = 0; |
| 4992 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4993 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4994 | ql_dbg(ql_dbg_mbx, vha, 0x10f5, |
| 4995 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4996 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4997 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f6, |
| 4998 | "Done %s.\n", __func__); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4999 | *data = mcp->mb[3] << 16 | mcp->mb[2]; |
| 5000 | } |
| 5001 | |
| 5002 | return rval; |
| 5003 | } |
| 5004 | |
| 5005 | int |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5006 | qla2x00_loopback_test(scsi_qla_host_t *vha, struct msg_echo_lb *mreq, |
| 5007 | uint16_t *mresp) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5008 | { |
| 5009 | int rval; |
| 5010 | mbx_cmd_t mc; |
| 5011 | mbx_cmd_t *mcp = &mc; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5012 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5013 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f7, |
| 5014 | "Entered %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5015 | |
| 5016 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 5017 | mcp->mb[0] = MBC_DIAGNOSTIC_LOOP_BACK; |
| 5018 | mcp->mb[1] = mreq->options | BIT_6; // BIT_6 specifies 64 bit addressing |
| 5019 | |
| 5020 | /* transfer count */ |
| 5021 | mcp->mb[10] = LSW(mreq->transfer_size); |
| 5022 | mcp->mb[11] = MSW(mreq->transfer_size); |
| 5023 | |
| 5024 | /* send data address */ |
| 5025 | mcp->mb[14] = LSW(mreq->send_dma); |
| 5026 | mcp->mb[15] = MSW(mreq->send_dma); |
| 5027 | mcp->mb[20] = LSW(MSD(mreq->send_dma)); |
| 5028 | mcp->mb[21] = MSW(MSD(mreq->send_dma)); |
| 5029 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 5030 | /* receive data address */ |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5031 | mcp->mb[16] = LSW(mreq->rcv_dma); |
| 5032 | mcp->mb[17] = MSW(mreq->rcv_dma); |
| 5033 | mcp->mb[6] = LSW(MSD(mreq->rcv_dma)); |
| 5034 | mcp->mb[7] = MSW(MSD(mreq->rcv_dma)); |
| 5035 | |
| 5036 | /* Iteration count */ |
Joe Carnuccio | 1b98b42 | 2013-03-28 08:21:26 -0400 | [diff] [blame] | 5037 | mcp->mb[18] = LSW(mreq->iteration_count); |
| 5038 | mcp->mb[19] = MSW(mreq->iteration_count); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5039 | |
| 5040 | mcp->out_mb = MBX_21|MBX_20|MBX_19|MBX_18|MBX_17|MBX_16|MBX_15| |
| 5041 | 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] | 5042 | if (IS_CNA_CAPABLE(vha->hw)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5043 | mcp->out_mb |= MBX_2; |
| 5044 | mcp->in_mb = MBX_19|MBX_18|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5045 | |
| 5046 | mcp->buf_size = mreq->transfer_size; |
| 5047 | mcp->tov = MBX_TOV_SECONDS; |
| 5048 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 5049 | |
| 5050 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5051 | |
| 5052 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5053 | ql_dbg(ql_dbg_mbx, vha, 0x10f8, |
| 5054 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[3]=%x mb[18]=%x " |
| 5055 | "mb[19]=%x.\n", rval, mcp->mb[0], mcp->mb[1], mcp->mb[2], |
| 5056 | mcp->mb[3], mcp->mb[18], mcp->mb[19]); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5057 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5058 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f9, |
| 5059 | "Done %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5060 | } |
| 5061 | |
| 5062 | /* Copy mailbox information */ |
| 5063 | memcpy( mresp, mcp->mb, 64); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5064 | return rval; |
| 5065 | } |
| 5066 | |
| 5067 | int |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5068 | qla2x00_echo_test(scsi_qla_host_t *vha, struct msg_echo_lb *mreq, |
| 5069 | uint16_t *mresp) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5070 | { |
| 5071 | int rval; |
| 5072 | mbx_cmd_t mc; |
| 5073 | mbx_cmd_t *mcp = &mc; |
| 5074 | struct qla_hw_data *ha = vha->hw; |
| 5075 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5076 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10fa, |
| 5077 | "Entered %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5078 | |
| 5079 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 5080 | mcp->mb[0] = MBC_DIAGNOSTIC_ECHO; |
Joe Carnuccio | 1d63496 | 2017-05-24 18:06:22 -0700 | [diff] [blame] | 5081 | /* BIT_6 specifies 64bit address */ |
| 5082 | mcp->mb[1] = mreq->options | BIT_15 | BIT_6; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5083 | if (IS_CNA_CAPABLE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5084 | mcp->mb[2] = vha->fcoe_fcf_idx; |
| 5085 | } |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5086 | mcp->mb[16] = LSW(mreq->rcv_dma); |
| 5087 | mcp->mb[17] = MSW(mreq->rcv_dma); |
| 5088 | mcp->mb[6] = LSW(MSD(mreq->rcv_dma)); |
| 5089 | mcp->mb[7] = MSW(MSD(mreq->rcv_dma)); |
| 5090 | |
| 5091 | mcp->mb[10] = LSW(mreq->transfer_size); |
| 5092 | |
| 5093 | mcp->mb[14] = LSW(mreq->send_dma); |
| 5094 | mcp->mb[15] = MSW(mreq->send_dma); |
| 5095 | mcp->mb[20] = LSW(MSD(mreq->send_dma)); |
| 5096 | mcp->mb[21] = MSW(MSD(mreq->send_dma)); |
| 5097 | |
| 5098 | mcp->out_mb = MBX_21|MBX_20|MBX_17|MBX_16|MBX_15| |
| 5099 | MBX_14|MBX_10|MBX_7|MBX_6|MBX_1|MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5100 | if (IS_CNA_CAPABLE(ha)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5101 | mcp->out_mb |= MBX_2; |
| 5102 | |
| 5103 | mcp->in_mb = MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5104 | if (IS_QLA24XX_TYPE(ha) || IS_QLA25XX(ha) || |
| 5105 | IS_CNA_CAPABLE(ha) || IS_QLA2031(ha)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5106 | mcp->in_mb |= MBX_1; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5107 | if (IS_CNA_CAPABLE(ha) || IS_QLA2031(ha)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5108 | mcp->in_mb |= MBX_3; |
| 5109 | |
| 5110 | mcp->tov = MBX_TOV_SECONDS; |
| 5111 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 5112 | mcp->buf_size = mreq->transfer_size; |
| 5113 | |
| 5114 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5115 | |
| 5116 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5117 | ql_dbg(ql_dbg_mbx, vha, 0x10fb, |
| 5118 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 5119 | rval, mcp->mb[0], mcp->mb[1]); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5120 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5121 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10fc, |
| 5122 | "Done %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5123 | } |
| 5124 | |
| 5125 | /* Copy mailbox information */ |
Giridhar Malavali | 6dbdda4 | 2010-09-03 15:20:49 -0700 | [diff] [blame] | 5126 | memcpy(mresp, mcp->mb, 64); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5127 | return rval; |
| 5128 | } |
Giridhar Malavali | 6dbdda4 | 2010-09-03 15:20:49 -0700 | [diff] [blame] | 5129 | |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5130 | int |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5131 | qla84xx_reset_chip(scsi_qla_host_t *vha, uint16_t enable_diagnostic) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5132 | { |
| 5133 | int rval; |
| 5134 | mbx_cmd_t mc; |
| 5135 | mbx_cmd_t *mcp = &mc; |
| 5136 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5137 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10fd, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5138 | "Entered %s enable_diag=%d.\n", __func__, enable_diagnostic); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5139 | |
| 5140 | mcp->mb[0] = MBC_ISP84XX_RESET; |
| 5141 | mcp->mb[1] = enable_diagnostic; |
| 5142 | mcp->out_mb = MBX_1|MBX_0; |
| 5143 | mcp->in_mb = MBX_1|MBX_0; |
| 5144 | mcp->tov = MBX_TOV_SECONDS; |
| 5145 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5146 | rval = qla2x00_mailbox_command(vha, mcp); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5147 | |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5148 | if (rval != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5149 | ql_dbg(ql_dbg_mbx, vha, 0x10fe, "Failed=%x.\n", rval); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5150 | else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5151 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ff, |
| 5152 | "Done %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5153 | |
| 5154 | return rval; |
| 5155 | } |
| 5156 | |
| 5157 | int |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5158 | qla2x00_write_ram_word(scsi_qla_host_t *vha, uint32_t risc_addr, uint32_t data) |
| 5159 | { |
| 5160 | int rval; |
| 5161 | mbx_cmd_t mc; |
| 5162 | mbx_cmd_t *mcp = &mc; |
| 5163 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5164 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1100, |
| 5165 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5166 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5167 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | 6c452a4 | 2010-03-19 17:04:02 -0700 | [diff] [blame] | 5168 | return QLA_FUNCTION_FAILED; |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5169 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5170 | mcp->mb[0] = MBC_WRITE_RAM_WORD_EXTENDED; |
| 5171 | mcp->mb[1] = LSW(risc_addr); |
| 5172 | mcp->mb[2] = LSW(data); |
| 5173 | mcp->mb[3] = MSW(data); |
| 5174 | mcp->mb[8] = MSW(risc_addr); |
| 5175 | mcp->out_mb = MBX_8|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5176 | mcp->in_mb = MBX_0; |
| 5177 | mcp->tov = 30; |
| 5178 | mcp->flags = 0; |
| 5179 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5180 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5181 | ql_dbg(ql_dbg_mbx, vha, 0x1101, |
| 5182 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5183 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5184 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1102, |
| 5185 | "Done %s.\n", __func__); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5186 | } |
| 5187 | |
| 5188 | return rval; |
| 5189 | } |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5190 | |
| 5191 | int |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 5192 | qla81xx_write_mpi_register(scsi_qla_host_t *vha, uint16_t *mb) |
| 5193 | { |
| 5194 | int rval; |
| 5195 | uint32_t stat, timer; |
| 5196 | uint16_t mb0 = 0; |
| 5197 | struct qla_hw_data *ha = vha->hw; |
| 5198 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 5199 | |
| 5200 | rval = QLA_SUCCESS; |
| 5201 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5202 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1103, |
| 5203 | "Entered %s.\n", __func__); |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 5204 | |
| 5205 | clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
| 5206 | |
| 5207 | /* Write the MBC data to the registers */ |
| 5208 | WRT_REG_WORD(®->mailbox0, MBC_WRITE_MPI_REGISTER); |
| 5209 | WRT_REG_WORD(®->mailbox1, mb[0]); |
| 5210 | WRT_REG_WORD(®->mailbox2, mb[1]); |
| 5211 | WRT_REG_WORD(®->mailbox3, mb[2]); |
| 5212 | WRT_REG_WORD(®->mailbox4, mb[3]); |
| 5213 | |
| 5214 | WRT_REG_DWORD(®->hccr, HCCRX_SET_HOST_INT); |
| 5215 | |
| 5216 | /* Poll for MBC interrupt */ |
| 5217 | for (timer = 6000000; timer; timer--) { |
| 5218 | /* Check for pending interrupts. */ |
| 5219 | stat = RD_REG_DWORD(®->host_status); |
| 5220 | if (stat & HSRX_RISC_INT) { |
| 5221 | stat &= 0xff; |
| 5222 | |
| 5223 | if (stat == 0x1 || stat == 0x2 || |
| 5224 | stat == 0x10 || stat == 0x11) { |
| 5225 | set_bit(MBX_INTERRUPT, |
| 5226 | &ha->mbx_cmd_flags); |
| 5227 | mb0 = RD_REG_WORD(®->mailbox0); |
| 5228 | WRT_REG_DWORD(®->hccr, |
| 5229 | HCCRX_CLR_RISC_INT); |
| 5230 | RD_REG_DWORD(®->hccr); |
| 5231 | break; |
| 5232 | } |
| 5233 | } |
| 5234 | udelay(5); |
| 5235 | } |
| 5236 | |
| 5237 | if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) |
| 5238 | rval = mb0 & MBS_MASK; |
| 5239 | else |
| 5240 | rval = QLA_FUNCTION_FAILED; |
| 5241 | |
| 5242 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5243 | ql_dbg(ql_dbg_mbx, vha, 0x1104, |
| 5244 | "Failed=%x mb[0]=%x.\n", rval, mb[0]); |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 5245 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5246 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1105, |
| 5247 | "Done %s.\n", __func__); |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 5248 | } |
| 5249 | |
| 5250 | return rval; |
| 5251 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5252 | |
Anil Gurumurthy | 4910b52 | 2019-02-15 14:37:17 -0800 | [diff] [blame^] | 5253 | /* Set the specified data rate */ |
| 5254 | int |
| 5255 | qla2x00_set_data_rate(scsi_qla_host_t *vha, uint16_t mode) |
| 5256 | { |
| 5257 | int rval; |
| 5258 | mbx_cmd_t mc; |
| 5259 | mbx_cmd_t *mcp = &mc; |
| 5260 | struct qla_hw_data *ha = vha->hw; |
| 5261 | uint16_t val; |
| 5262 | |
| 5263 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1106, |
| 5264 | "Entered %s speed:0x%x mode:0x%x.\n", __func__, ha->set_data_rate, |
| 5265 | mode); |
| 5266 | |
| 5267 | if (!IS_FWI2_CAPABLE(ha)) |
| 5268 | return QLA_FUNCTION_FAILED; |
| 5269 | |
| 5270 | memset(mcp, 0, sizeof(*mcp)); |
| 5271 | switch (ha->set_data_rate) { |
| 5272 | case PORT_SPEED_AUTO: |
| 5273 | case PORT_SPEED_4GB: |
| 5274 | case PORT_SPEED_8GB: |
| 5275 | case PORT_SPEED_16GB: |
| 5276 | case PORT_SPEED_32GB: |
| 5277 | val = ha->set_data_rate; |
| 5278 | break; |
| 5279 | default: |
| 5280 | ql_log(ql_log_warn, vha, 0x1199, |
| 5281 | "Unrecognized speed setting:%d. Setting Autoneg\n", |
| 5282 | ha->set_data_rate); |
| 5283 | val = ha->set_data_rate = PORT_SPEED_AUTO; |
| 5284 | break; |
| 5285 | } |
| 5286 | |
| 5287 | mcp->mb[0] = MBC_DATA_RATE; |
| 5288 | mcp->mb[1] = mode; |
| 5289 | mcp->mb[2] = val; |
| 5290 | |
| 5291 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 5292 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 5293 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
| 5294 | mcp->in_mb |= MBX_4|MBX_3; |
| 5295 | mcp->tov = MBX_TOV_SECONDS; |
| 5296 | mcp->flags = 0; |
| 5297 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5298 | if (rval != QLA_SUCCESS) { |
| 5299 | ql_dbg(ql_dbg_mbx, vha, 0x1107, |
| 5300 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5301 | } else { |
| 5302 | if (mcp->mb[1] != 0x7) |
| 5303 | ql_dbg(ql_dbg_mbx, vha, 0x1179, |
| 5304 | "Speed set:0x%x\n", mcp->mb[1]); |
| 5305 | |
| 5306 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1108, |
| 5307 | "Done %s.\n", __func__); |
| 5308 | } |
| 5309 | |
| 5310 | return rval; |
| 5311 | } |
| 5312 | |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 5313 | int |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5314 | qla2x00_get_data_rate(scsi_qla_host_t *vha) |
| 5315 | { |
| 5316 | int rval; |
| 5317 | mbx_cmd_t mc; |
| 5318 | mbx_cmd_t *mcp = &mc; |
| 5319 | struct qla_hw_data *ha = vha->hw; |
| 5320 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5321 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1106, |
| 5322 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5323 | |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5324 | if (!IS_FWI2_CAPABLE(ha)) |
| 5325 | return QLA_FUNCTION_FAILED; |
| 5326 | |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5327 | mcp->mb[0] = MBC_DATA_RATE; |
Anil Gurumurthy | 4910b52 | 2019-02-15 14:37:17 -0800 | [diff] [blame^] | 5328 | mcp->mb[1] = QLA_GET_DATA_RATE; |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5329 | mcp->out_mb = MBX_1|MBX_0; |
| 5330 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5331 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5332 | mcp->in_mb |= MBX_3; |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5333 | mcp->tov = MBX_TOV_SECONDS; |
| 5334 | mcp->flags = 0; |
| 5335 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5336 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5337 | ql_dbg(ql_dbg_mbx, vha, 0x1107, |
| 5338 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5339 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5340 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1108, |
| 5341 | "Done %s.\n", __func__); |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5342 | if (mcp->mb[1] != 0x7) |
| 5343 | ha->link_data_rate = mcp->mb[1]; |
| 5344 | } |
| 5345 | |
| 5346 | return rval; |
| 5347 | } |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5348 | |
| 5349 | int |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5350 | qla81xx_get_port_config(scsi_qla_host_t *vha, uint16_t *mb) |
| 5351 | { |
| 5352 | int rval; |
| 5353 | mbx_cmd_t mc; |
| 5354 | mbx_cmd_t *mcp = &mc; |
| 5355 | struct qla_hw_data *ha = vha->hw; |
| 5356 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5357 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1109, |
| 5358 | "Entered %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5359 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5360 | if (!IS_QLA81XX(ha) && !IS_QLA83XX(ha) && !IS_QLA8044(ha) && |
| 5361 | !IS_QLA27XX(ha)) |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5362 | return QLA_FUNCTION_FAILED; |
| 5363 | mcp->mb[0] = MBC_GET_PORT_CONFIG; |
| 5364 | mcp->out_mb = MBX_0; |
| 5365 | mcp->in_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5366 | mcp->tov = MBX_TOV_SECONDS; |
| 5367 | mcp->flags = 0; |
| 5368 | |
| 5369 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5370 | |
| 5371 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5372 | ql_dbg(ql_dbg_mbx, vha, 0x110a, |
| 5373 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5374 | } else { |
| 5375 | /* Copy all bits to preserve original value */ |
| 5376 | memcpy(mb, &mcp->mb[1], sizeof(uint16_t) * 4); |
| 5377 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5378 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110b, |
| 5379 | "Done %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5380 | } |
| 5381 | return rval; |
| 5382 | } |
| 5383 | |
| 5384 | int |
| 5385 | qla81xx_set_port_config(scsi_qla_host_t *vha, uint16_t *mb) |
| 5386 | { |
| 5387 | int rval; |
| 5388 | mbx_cmd_t mc; |
| 5389 | mbx_cmd_t *mcp = &mc; |
| 5390 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5391 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110c, |
| 5392 | "Entered %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5393 | |
| 5394 | mcp->mb[0] = MBC_SET_PORT_CONFIG; |
| 5395 | /* Copy all bits to preserve original setting */ |
| 5396 | memcpy(&mcp->mb[1], mb, sizeof(uint16_t) * 4); |
| 5397 | mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5398 | mcp->in_mb = MBX_0; |
| 5399 | mcp->tov = MBX_TOV_SECONDS; |
| 5400 | mcp->flags = 0; |
| 5401 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5402 | |
| 5403 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5404 | ql_dbg(ql_dbg_mbx, vha, 0x110d, |
| 5405 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5406 | } else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5407 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110e, |
| 5408 | "Done %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5409 | |
| 5410 | return rval; |
| 5411 | } |
| 5412 | |
| 5413 | |
| 5414 | int |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5415 | qla24xx_set_fcp_prio(scsi_qla_host_t *vha, uint16_t loop_id, uint16_t priority, |
| 5416 | uint16_t *mb) |
| 5417 | { |
| 5418 | int rval; |
| 5419 | mbx_cmd_t mc; |
| 5420 | mbx_cmd_t *mcp = &mc; |
| 5421 | struct qla_hw_data *ha = vha->hw; |
| 5422 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5423 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110f, |
| 5424 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5425 | |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5426 | if (!IS_QLA24XX_TYPE(ha) && !IS_QLA25XX(ha)) |
| 5427 | return QLA_FUNCTION_FAILED; |
| 5428 | |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5429 | mcp->mb[0] = MBC_PORT_PARAMS; |
| 5430 | mcp->mb[1] = loop_id; |
| 5431 | if (ha->flags.fcp_prio_enabled) |
| 5432 | mcp->mb[2] = BIT_1; |
| 5433 | else |
| 5434 | mcp->mb[2] = BIT_2; |
| 5435 | mcp->mb[4] = priority & 0xf; |
| 5436 | mcp->mb[9] = vha->vp_idx; |
| 5437 | mcp->out_mb = MBX_9|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5438 | mcp->in_mb = MBX_4|MBX_3|MBX_1|MBX_0; |
| 5439 | mcp->tov = 30; |
| 5440 | mcp->flags = 0; |
| 5441 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5442 | if (mb != NULL) { |
| 5443 | mb[0] = mcp->mb[0]; |
| 5444 | mb[1] = mcp->mb[1]; |
| 5445 | mb[3] = mcp->mb[3]; |
| 5446 | mb[4] = mcp->mb[4]; |
| 5447 | } |
| 5448 | |
| 5449 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5450 | ql_dbg(ql_dbg_mbx, vha, 0x10cd, "Failed=%x.\n", rval); |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5451 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5452 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10cc, |
| 5453 | "Done %s.\n", __func__); |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5454 | } |
| 5455 | |
| 5456 | return rval; |
| 5457 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5458 | |
| 5459 | int |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 5460 | qla2x00_get_thermal_temp(scsi_qla_host_t *vha, uint16_t *temp) |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5461 | { |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 5462 | int rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5463 | struct qla_hw_data *ha = vha->hw; |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 5464 | uint8_t byte; |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5465 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 5466 | if (!IS_FWI2_CAPABLE(ha) || IS_QLA24XX_TYPE(ha) || IS_QLA81XX(ha)) { |
| 5467 | ql_dbg(ql_dbg_mbx, vha, 0x1150, |
| 5468 | "Thermal not supported by this card.\n"); |
| 5469 | return rval; |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5470 | } |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5471 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 5472 | if (IS_QLA25XX(ha)) { |
| 5473 | if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC && |
| 5474 | ha->pdev->subsystem_device == 0x0175) { |
| 5475 | rval = qla2x00_read_sfp(vha, 0, &byte, |
| 5476 | 0x98, 0x1, 1, BIT_13|BIT_0); |
| 5477 | *temp = byte; |
| 5478 | return rval; |
| 5479 | } |
| 5480 | if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_HP && |
| 5481 | ha->pdev->subsystem_device == 0x338e) { |
| 5482 | rval = qla2x00_read_sfp(vha, 0, &byte, |
| 5483 | 0x98, 0x1, 1, BIT_15|BIT_14|BIT_0); |
| 5484 | *temp = byte; |
| 5485 | return rval; |
| 5486 | } |
| 5487 | ql_dbg(ql_dbg_mbx, vha, 0x10c9, |
| 5488 | "Thermal not supported by this card.\n"); |
| 5489 | return rval; |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 5490 | } |
| 5491 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 5492 | if (IS_QLA82XX(ha)) { |
| 5493 | *temp = qla82xx_read_temperature(vha); |
| 5494 | rval = QLA_SUCCESS; |
| 5495 | return rval; |
| 5496 | } else if (IS_QLA8044(ha)) { |
| 5497 | *temp = qla8044_read_temperature(vha); |
| 5498 | rval = QLA_SUCCESS; |
| 5499 | return rval; |
| 5500 | } |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 5501 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 5502 | rval = qla2x00_read_asic_temperature(vha, temp); |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5503 | return rval; |
| 5504 | } |
| 5505 | |
| 5506 | int |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5507 | qla82xx_mbx_intr_enable(scsi_qla_host_t *vha) |
| 5508 | { |
| 5509 | int rval; |
| 5510 | struct qla_hw_data *ha = vha->hw; |
| 5511 | mbx_cmd_t mc; |
| 5512 | mbx_cmd_t *mcp = &mc; |
| 5513 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5514 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1017, |
| 5515 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5516 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5517 | if (!IS_FWI2_CAPABLE(ha)) |
| 5518 | return QLA_FUNCTION_FAILED; |
| 5519 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5520 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
Giridhar Malavali | 3711333 | 2010-07-23 15:28:34 +0500 | [diff] [blame] | 5521 | mcp->mb[0] = MBC_TOGGLE_INTERRUPT; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5522 | mcp->mb[1] = 1; |
| 5523 | |
| 5524 | mcp->out_mb = MBX_1|MBX_0; |
| 5525 | mcp->in_mb = MBX_0; |
| 5526 | mcp->tov = 30; |
| 5527 | mcp->flags = 0; |
| 5528 | |
| 5529 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5530 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5531 | ql_dbg(ql_dbg_mbx, vha, 0x1016, |
| 5532 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5533 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5534 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x100e, |
| 5535 | "Done %s.\n", __func__); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5536 | } |
| 5537 | |
| 5538 | return rval; |
| 5539 | } |
| 5540 | |
| 5541 | int |
| 5542 | qla82xx_mbx_intr_disable(scsi_qla_host_t *vha) |
| 5543 | { |
| 5544 | int rval; |
| 5545 | struct qla_hw_data *ha = vha->hw; |
| 5546 | mbx_cmd_t mc; |
| 5547 | mbx_cmd_t *mcp = &mc; |
| 5548 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5549 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x100d, |
| 5550 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5551 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5552 | if (!IS_P3P_TYPE(ha)) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5553 | return QLA_FUNCTION_FAILED; |
| 5554 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5555 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
Giridhar Malavali | 3711333 | 2010-07-23 15:28:34 +0500 | [diff] [blame] | 5556 | mcp->mb[0] = MBC_TOGGLE_INTERRUPT; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5557 | mcp->mb[1] = 0; |
| 5558 | |
| 5559 | mcp->out_mb = MBX_1|MBX_0; |
| 5560 | mcp->in_mb = MBX_0; |
| 5561 | mcp->tov = 30; |
| 5562 | mcp->flags = 0; |
| 5563 | |
| 5564 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5565 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5566 | ql_dbg(ql_dbg_mbx, vha, 0x100c, |
| 5567 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5568 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5569 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x100b, |
| 5570 | "Done %s.\n", __func__); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5571 | } |
| 5572 | |
| 5573 | return rval; |
| 5574 | } |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5575 | |
| 5576 | int |
| 5577 | qla82xx_md_get_template_size(scsi_qla_host_t *vha) |
| 5578 | { |
| 5579 | struct qla_hw_data *ha = vha->hw; |
| 5580 | mbx_cmd_t mc; |
| 5581 | mbx_cmd_t *mcp = &mc; |
| 5582 | int rval = QLA_FUNCTION_FAILED; |
| 5583 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5584 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x111f, |
| 5585 | "Entered %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5586 | |
| 5587 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 5588 | mcp->mb[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5589 | mcp->mb[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5590 | mcp->mb[2] = LSW(RQST_TMPLT_SIZE); |
| 5591 | mcp->mb[3] = MSW(RQST_TMPLT_SIZE); |
| 5592 | |
| 5593 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 5594 | mcp->in_mb = MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8| |
| 5595 | MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5596 | |
| 5597 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 5598 | mcp->tov = MBX_TOV_SECONDS; |
| 5599 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5600 | |
| 5601 | /* Always copy back return mailbox values. */ |
| 5602 | if (rval != QLA_SUCCESS) { |
| 5603 | ql_dbg(ql_dbg_mbx, vha, 0x1120, |
| 5604 | "mailbox command FAILED=0x%x, subcode=%x.\n", |
| 5605 | (mcp->mb[1] << 16) | mcp->mb[0], |
| 5606 | (mcp->mb[3] << 16) | mcp->mb[2]); |
| 5607 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5608 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1121, |
| 5609 | "Done %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5610 | ha->md_template_size = ((mcp->mb[3] << 16) | mcp->mb[2]); |
| 5611 | if (!ha->md_template_size) { |
| 5612 | ql_dbg(ql_dbg_mbx, vha, 0x1122, |
| 5613 | "Null template size obtained.\n"); |
| 5614 | rval = QLA_FUNCTION_FAILED; |
| 5615 | } |
| 5616 | } |
| 5617 | return rval; |
| 5618 | } |
| 5619 | |
| 5620 | int |
| 5621 | qla82xx_md_get_template(scsi_qla_host_t *vha) |
| 5622 | { |
| 5623 | struct qla_hw_data *ha = vha->hw; |
| 5624 | mbx_cmd_t mc; |
| 5625 | mbx_cmd_t *mcp = &mc; |
| 5626 | int rval = QLA_FUNCTION_FAILED; |
| 5627 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5628 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1123, |
| 5629 | "Entered %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5630 | |
| 5631 | ha->md_tmplt_hdr = dma_alloc_coherent(&ha->pdev->dev, |
| 5632 | ha->md_template_size, &ha->md_tmplt_hdr_dma, GFP_KERNEL); |
| 5633 | if (!ha->md_tmplt_hdr) { |
| 5634 | ql_log(ql_log_warn, vha, 0x1124, |
| 5635 | "Unable to allocate memory for Minidump template.\n"); |
| 5636 | return rval; |
| 5637 | } |
| 5638 | |
| 5639 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 5640 | mcp->mb[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5641 | mcp->mb[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5642 | mcp->mb[2] = LSW(RQST_TMPLT); |
| 5643 | mcp->mb[3] = MSW(RQST_TMPLT); |
| 5644 | mcp->mb[4] = LSW(LSD(ha->md_tmplt_hdr_dma)); |
| 5645 | mcp->mb[5] = MSW(LSD(ha->md_tmplt_hdr_dma)); |
| 5646 | mcp->mb[6] = LSW(MSD(ha->md_tmplt_hdr_dma)); |
| 5647 | mcp->mb[7] = MSW(MSD(ha->md_tmplt_hdr_dma)); |
| 5648 | mcp->mb[8] = LSW(ha->md_template_size); |
| 5649 | mcp->mb[9] = MSW(ha->md_template_size); |
| 5650 | |
| 5651 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 5652 | mcp->tov = MBX_TOV_SECONDS; |
| 5653 | mcp->out_mb = MBX_11|MBX_10|MBX_9|MBX_8| |
| 5654 | MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5655 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 5656 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5657 | |
| 5658 | if (rval != QLA_SUCCESS) { |
| 5659 | ql_dbg(ql_dbg_mbx, vha, 0x1125, |
| 5660 | "mailbox command FAILED=0x%x, subcode=%x.\n", |
| 5661 | ((mcp->mb[1] << 16) | mcp->mb[0]), |
| 5662 | ((mcp->mb[3] << 16) | mcp->mb[2])); |
| 5663 | } else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5664 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1126, |
| 5665 | "Done %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5666 | return rval; |
| 5667 | } |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5668 | |
| 5669 | int |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5670 | qla8044_md_get_template(scsi_qla_host_t *vha) |
| 5671 | { |
| 5672 | struct qla_hw_data *ha = vha->hw; |
| 5673 | mbx_cmd_t mc; |
| 5674 | mbx_cmd_t *mcp = &mc; |
| 5675 | int rval = QLA_FUNCTION_FAILED; |
| 5676 | int offset = 0, size = MINIDUMP_SIZE_36K; |
| 5677 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0xb11f, |
| 5678 | "Entered %s.\n", __func__); |
| 5679 | |
| 5680 | ha->md_tmplt_hdr = dma_alloc_coherent(&ha->pdev->dev, |
| 5681 | ha->md_template_size, &ha->md_tmplt_hdr_dma, GFP_KERNEL); |
| 5682 | if (!ha->md_tmplt_hdr) { |
| 5683 | ql_log(ql_log_warn, vha, 0xb11b, |
| 5684 | "Unable to allocate memory for Minidump template.\n"); |
| 5685 | return rval; |
| 5686 | } |
| 5687 | |
| 5688 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 5689 | while (offset < ha->md_template_size) { |
| 5690 | mcp->mb[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5691 | mcp->mb[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5692 | mcp->mb[2] = LSW(RQST_TMPLT); |
| 5693 | mcp->mb[3] = MSW(RQST_TMPLT); |
| 5694 | mcp->mb[4] = LSW(LSD(ha->md_tmplt_hdr_dma + offset)); |
| 5695 | mcp->mb[5] = MSW(LSD(ha->md_tmplt_hdr_dma + offset)); |
| 5696 | mcp->mb[6] = LSW(MSD(ha->md_tmplt_hdr_dma + offset)); |
| 5697 | mcp->mb[7] = MSW(MSD(ha->md_tmplt_hdr_dma + offset)); |
| 5698 | mcp->mb[8] = LSW(size); |
| 5699 | mcp->mb[9] = MSW(size); |
| 5700 | mcp->mb[10] = offset & 0x0000FFFF; |
| 5701 | mcp->mb[11] = offset & 0xFFFF0000; |
| 5702 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 5703 | mcp->tov = MBX_TOV_SECONDS; |
| 5704 | mcp->out_mb = MBX_11|MBX_10|MBX_9|MBX_8| |
| 5705 | MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5706 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 5707 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5708 | |
| 5709 | if (rval != QLA_SUCCESS) { |
| 5710 | ql_dbg(ql_dbg_mbx, vha, 0xb11c, |
| 5711 | "mailbox command FAILED=0x%x, subcode=%x.\n", |
| 5712 | ((mcp->mb[1] << 16) | mcp->mb[0]), |
| 5713 | ((mcp->mb[3] << 16) | mcp->mb[2])); |
| 5714 | return rval; |
| 5715 | } else |
| 5716 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0xb11d, |
| 5717 | "Done %s.\n", __func__); |
| 5718 | offset = offset + size; |
| 5719 | } |
| 5720 | return rval; |
| 5721 | } |
| 5722 | |
| 5723 | int |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5724 | qla81xx_set_led_config(scsi_qla_host_t *vha, uint16_t *led_cfg) |
| 5725 | { |
| 5726 | int rval; |
| 5727 | struct qla_hw_data *ha = vha->hw; |
| 5728 | mbx_cmd_t mc; |
| 5729 | mbx_cmd_t *mcp = &mc; |
| 5730 | |
| 5731 | if (!IS_QLA81XX(ha) && !IS_QLA8031(ha)) |
| 5732 | return QLA_FUNCTION_FAILED; |
| 5733 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5734 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1133, |
| 5735 | "Entered %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5736 | |
| 5737 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
| 5738 | mcp->mb[0] = MBC_SET_LED_CONFIG; |
| 5739 | mcp->mb[1] = led_cfg[0]; |
| 5740 | mcp->mb[2] = led_cfg[1]; |
| 5741 | if (IS_QLA8031(ha)) { |
| 5742 | mcp->mb[3] = led_cfg[2]; |
| 5743 | mcp->mb[4] = led_cfg[3]; |
| 5744 | mcp->mb[5] = led_cfg[4]; |
| 5745 | mcp->mb[6] = led_cfg[5]; |
| 5746 | } |
| 5747 | |
| 5748 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 5749 | if (IS_QLA8031(ha)) |
| 5750 | mcp->out_mb |= MBX_6|MBX_5|MBX_4|MBX_3; |
| 5751 | mcp->in_mb = MBX_0; |
| 5752 | mcp->tov = 30; |
| 5753 | mcp->flags = 0; |
| 5754 | |
| 5755 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5756 | if (rval != QLA_SUCCESS) { |
| 5757 | ql_dbg(ql_dbg_mbx, vha, 0x1134, |
| 5758 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5759 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5760 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1135, |
| 5761 | "Done %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5762 | } |
| 5763 | |
| 5764 | return rval; |
| 5765 | } |
| 5766 | |
| 5767 | int |
| 5768 | qla81xx_get_led_config(scsi_qla_host_t *vha, uint16_t *led_cfg) |
| 5769 | { |
| 5770 | int rval; |
| 5771 | struct qla_hw_data *ha = vha->hw; |
| 5772 | mbx_cmd_t mc; |
| 5773 | mbx_cmd_t *mcp = &mc; |
| 5774 | |
| 5775 | if (!IS_QLA81XX(ha) && !IS_QLA8031(ha)) |
| 5776 | return QLA_FUNCTION_FAILED; |
| 5777 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5778 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1136, |
| 5779 | "Entered %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5780 | |
| 5781 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
| 5782 | mcp->mb[0] = MBC_GET_LED_CONFIG; |
| 5783 | |
| 5784 | mcp->out_mb = MBX_0; |
| 5785 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 5786 | if (IS_QLA8031(ha)) |
| 5787 | mcp->in_mb |= MBX_6|MBX_5|MBX_4|MBX_3; |
| 5788 | mcp->tov = 30; |
| 5789 | mcp->flags = 0; |
| 5790 | |
| 5791 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5792 | if (rval != QLA_SUCCESS) { |
| 5793 | ql_dbg(ql_dbg_mbx, vha, 0x1137, |
| 5794 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5795 | } else { |
| 5796 | led_cfg[0] = mcp->mb[1]; |
| 5797 | led_cfg[1] = mcp->mb[2]; |
| 5798 | if (IS_QLA8031(ha)) { |
| 5799 | led_cfg[2] = mcp->mb[3]; |
| 5800 | led_cfg[3] = mcp->mb[4]; |
| 5801 | led_cfg[4] = mcp->mb[5]; |
| 5802 | led_cfg[5] = mcp->mb[6]; |
| 5803 | } |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5804 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1138, |
| 5805 | "Done %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5806 | } |
| 5807 | |
| 5808 | return rval; |
| 5809 | } |
| 5810 | |
| 5811 | int |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5812 | qla82xx_mbx_beacon_ctl(scsi_qla_host_t *vha, int enable) |
| 5813 | { |
| 5814 | int rval; |
| 5815 | struct qla_hw_data *ha = vha->hw; |
| 5816 | mbx_cmd_t mc; |
| 5817 | mbx_cmd_t *mcp = &mc; |
| 5818 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5819 | if (!IS_P3P_TYPE(ha)) |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5820 | return QLA_FUNCTION_FAILED; |
| 5821 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5822 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1127, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5823 | "Entered %s.\n", __func__); |
| 5824 | |
| 5825 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
| 5826 | mcp->mb[0] = MBC_SET_LED_CONFIG; |
| 5827 | if (enable) |
| 5828 | mcp->mb[7] = 0xE; |
| 5829 | else |
| 5830 | mcp->mb[7] = 0xD; |
| 5831 | |
| 5832 | mcp->out_mb = MBX_7|MBX_0; |
| 5833 | mcp->in_mb = MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5834 | mcp->tov = MBX_TOV_SECONDS; |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5835 | mcp->flags = 0; |
| 5836 | |
| 5837 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5838 | if (rval != QLA_SUCCESS) { |
| 5839 | ql_dbg(ql_dbg_mbx, vha, 0x1128, |
| 5840 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5841 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5842 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1129, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5843 | "Done %s.\n", __func__); |
| 5844 | } |
| 5845 | |
| 5846 | return rval; |
| 5847 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5848 | |
| 5849 | int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5850 | 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] | 5851 | { |
| 5852 | int rval; |
| 5853 | struct qla_hw_data *ha = vha->hw; |
| 5854 | mbx_cmd_t mc; |
| 5855 | mbx_cmd_t *mcp = &mc; |
| 5856 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5857 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5858 | return QLA_FUNCTION_FAILED; |
| 5859 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5860 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1130, |
| 5861 | "Entered %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5862 | |
| 5863 | mcp->mb[0] = MBC_WRITE_REMOTE_REG; |
| 5864 | mcp->mb[1] = LSW(reg); |
| 5865 | mcp->mb[2] = MSW(reg); |
| 5866 | mcp->mb[3] = LSW(data); |
| 5867 | mcp->mb[4] = MSW(data); |
| 5868 | mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5869 | |
| 5870 | mcp->in_mb = MBX_1|MBX_0; |
| 5871 | mcp->tov = MBX_TOV_SECONDS; |
| 5872 | mcp->flags = 0; |
| 5873 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5874 | |
| 5875 | if (rval != QLA_SUCCESS) { |
| 5876 | ql_dbg(ql_dbg_mbx, vha, 0x1131, |
| 5877 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5878 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5879 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1132, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5880 | "Done %s.\n", __func__); |
| 5881 | } |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5882 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5883 | return rval; |
| 5884 | } |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5885 | |
| 5886 | int |
| 5887 | qla2x00_port_logout(scsi_qla_host_t *vha, struct fc_port *fcport) |
| 5888 | { |
| 5889 | int rval; |
| 5890 | struct qla_hw_data *ha = vha->hw; |
| 5891 | mbx_cmd_t mc; |
| 5892 | mbx_cmd_t *mcp = &mc; |
| 5893 | |
| 5894 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5895 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x113b, |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5896 | "Implicit LOGO Unsupported.\n"); |
| 5897 | return QLA_FUNCTION_FAILED; |
| 5898 | } |
| 5899 | |
| 5900 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5901 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x113c, |
| 5902 | "Entering %s.\n", __func__); |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5903 | |
| 5904 | /* Perform Implicit LOGO. */ |
| 5905 | mcp->mb[0] = MBC_PORT_LOGOUT; |
| 5906 | mcp->mb[1] = fcport->loop_id; |
| 5907 | mcp->mb[10] = BIT_15; |
| 5908 | mcp->out_mb = MBX_10|MBX_1|MBX_0; |
| 5909 | mcp->in_mb = MBX_0; |
| 5910 | mcp->tov = MBX_TOV_SECONDS; |
| 5911 | mcp->flags = 0; |
| 5912 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5913 | if (rval != QLA_SUCCESS) |
| 5914 | ql_dbg(ql_dbg_mbx, vha, 0x113d, |
| 5915 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5916 | else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5917 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x113e, |
| 5918 | "Done %s.\n", __func__); |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5919 | |
| 5920 | return rval; |
| 5921 | } |
| 5922 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5923 | int |
| 5924 | qla83xx_rd_reg(scsi_qla_host_t *vha, uint32_t reg, uint32_t *data) |
| 5925 | { |
| 5926 | int rval; |
| 5927 | mbx_cmd_t mc; |
| 5928 | mbx_cmd_t *mcp = &mc; |
| 5929 | struct qla_hw_data *ha = vha->hw; |
| 5930 | unsigned long retry_max_time = jiffies + (2 * HZ); |
| 5931 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5932 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5933 | return QLA_FUNCTION_FAILED; |
| 5934 | |
| 5935 | ql_dbg(ql_dbg_mbx, vha, 0x114b, "Entered %s.\n", __func__); |
| 5936 | |
| 5937 | retry_rd_reg: |
| 5938 | mcp->mb[0] = MBC_READ_REMOTE_REG; |
| 5939 | mcp->mb[1] = LSW(reg); |
| 5940 | mcp->mb[2] = MSW(reg); |
| 5941 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 5942 | mcp->in_mb = MBX_4|MBX_3|MBX_1|MBX_0; |
| 5943 | mcp->tov = MBX_TOV_SECONDS; |
| 5944 | mcp->flags = 0; |
| 5945 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5946 | |
| 5947 | if (rval != QLA_SUCCESS) { |
| 5948 | ql_dbg(ql_dbg_mbx, vha, 0x114c, |
| 5949 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 5950 | rval, mcp->mb[0], mcp->mb[1]); |
| 5951 | } else { |
| 5952 | *data = (mcp->mb[3] | (mcp->mb[4] << 16)); |
| 5953 | if (*data == QLA8XXX_BAD_VALUE) { |
| 5954 | /* |
| 5955 | * During soft-reset CAMRAM register reads might |
| 5956 | * return 0xbad0bad0. So retry for MAX of 2 sec |
| 5957 | * while reading camram registers. |
| 5958 | */ |
| 5959 | if (time_after(jiffies, retry_max_time)) { |
| 5960 | ql_dbg(ql_dbg_mbx, vha, 0x1141, |
| 5961 | "Failure to read CAMRAM register. " |
| 5962 | "data=0x%x.\n", *data); |
| 5963 | return QLA_FUNCTION_FAILED; |
| 5964 | } |
| 5965 | msleep(100); |
| 5966 | goto retry_rd_reg; |
| 5967 | } |
| 5968 | ql_dbg(ql_dbg_mbx, vha, 0x1142, "Done %s.\n", __func__); |
| 5969 | } |
| 5970 | |
| 5971 | return rval; |
| 5972 | } |
| 5973 | |
| 5974 | int |
| 5975 | qla83xx_restart_nic_firmware(scsi_qla_host_t *vha) |
| 5976 | { |
| 5977 | int rval; |
| 5978 | mbx_cmd_t mc; |
| 5979 | mbx_cmd_t *mcp = &mc; |
| 5980 | struct qla_hw_data *ha = vha->hw; |
| 5981 | |
Himanshu Madhani | b20f02e | 2015-06-10 11:05:18 -0400 | [diff] [blame] | 5982 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5983 | return QLA_FUNCTION_FAILED; |
| 5984 | |
| 5985 | ql_dbg(ql_dbg_mbx, vha, 0x1143, "Entered %s.\n", __func__); |
| 5986 | |
| 5987 | mcp->mb[0] = MBC_RESTART_NIC_FIRMWARE; |
| 5988 | mcp->out_mb = MBX_0; |
| 5989 | mcp->in_mb = MBX_1|MBX_0; |
| 5990 | mcp->tov = MBX_TOV_SECONDS; |
| 5991 | mcp->flags = 0; |
| 5992 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5993 | |
| 5994 | if (rval != QLA_SUCCESS) { |
| 5995 | ql_dbg(ql_dbg_mbx, vha, 0x1144, |
| 5996 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 5997 | rval, mcp->mb[0], mcp->mb[1]); |
| 5998 | ha->isp_ops->fw_dump(vha, 0); |
| 5999 | } else { |
| 6000 | ql_dbg(ql_dbg_mbx, vha, 0x1145, "Done %s.\n", __func__); |
| 6001 | } |
| 6002 | |
| 6003 | return rval; |
| 6004 | } |
| 6005 | |
| 6006 | int |
| 6007 | qla83xx_access_control(scsi_qla_host_t *vha, uint16_t options, |
| 6008 | uint32_t start_addr, uint32_t end_addr, uint16_t *sector_size) |
| 6009 | { |
| 6010 | int rval; |
| 6011 | mbx_cmd_t mc; |
| 6012 | mbx_cmd_t *mcp = &mc; |
| 6013 | uint8_t subcode = (uint8_t)options; |
| 6014 | struct qla_hw_data *ha = vha->hw; |
| 6015 | |
| 6016 | if (!IS_QLA8031(ha)) |
| 6017 | return QLA_FUNCTION_FAILED; |
| 6018 | |
| 6019 | ql_dbg(ql_dbg_mbx, vha, 0x1146, "Entered %s.\n", __func__); |
| 6020 | |
| 6021 | mcp->mb[0] = MBC_SET_ACCESS_CONTROL; |
| 6022 | mcp->mb[1] = options; |
| 6023 | mcp->out_mb = MBX_1|MBX_0; |
| 6024 | if (subcode & BIT_2) { |
| 6025 | mcp->mb[2] = LSW(start_addr); |
| 6026 | mcp->mb[3] = MSW(start_addr); |
| 6027 | mcp->mb[4] = LSW(end_addr); |
| 6028 | mcp->mb[5] = MSW(end_addr); |
| 6029 | mcp->out_mb |= MBX_5|MBX_4|MBX_3|MBX_2; |
| 6030 | } |
| 6031 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 6032 | if (!(subcode & (BIT_2 | BIT_5))) |
| 6033 | mcp->in_mb |= MBX_4|MBX_3; |
| 6034 | mcp->tov = MBX_TOV_SECONDS; |
| 6035 | mcp->flags = 0; |
| 6036 | rval = qla2x00_mailbox_command(vha, mcp); |
| 6037 | |
| 6038 | if (rval != QLA_SUCCESS) { |
| 6039 | ql_dbg(ql_dbg_mbx, vha, 0x1147, |
| 6040 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[3]=%x mb[4]=%x.\n", |
| 6041 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2], mcp->mb[3], |
| 6042 | mcp->mb[4]); |
| 6043 | ha->isp_ops->fw_dump(vha, 0); |
| 6044 | } else { |
| 6045 | if (subcode & BIT_5) |
| 6046 | *sector_size = mcp->mb[1]; |
| 6047 | else if (subcode & (BIT_6 | BIT_7)) { |
| 6048 | ql_dbg(ql_dbg_mbx, vha, 0x1148, |
| 6049 | "Driver-lock id=%x%x", mcp->mb[4], mcp->mb[3]); |
| 6050 | } else if (subcode & (BIT_3 | BIT_4)) { |
| 6051 | ql_dbg(ql_dbg_mbx, vha, 0x1149, |
| 6052 | "Flash-lock id=%x%x", mcp->mb[4], mcp->mb[3]); |
| 6053 | } |
| 6054 | ql_dbg(ql_dbg_mbx, vha, 0x114a, "Done %s.\n", __func__); |
| 6055 | } |
| 6056 | |
| 6057 | return rval; |
| 6058 | } |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 6059 | |
| 6060 | int |
| 6061 | qla2x00_dump_mctp_data(scsi_qla_host_t *vha, dma_addr_t req_dma, uint32_t addr, |
| 6062 | uint32_t size) |
| 6063 | { |
| 6064 | int rval; |
| 6065 | mbx_cmd_t mc; |
| 6066 | mbx_cmd_t *mcp = &mc; |
| 6067 | |
| 6068 | if (!IS_MCTP_CAPABLE(vha->hw)) |
| 6069 | return QLA_FUNCTION_FAILED; |
| 6070 | |
| 6071 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x114f, |
| 6072 | "Entered %s.\n", __func__); |
| 6073 | |
| 6074 | mcp->mb[0] = MBC_DUMP_RISC_RAM_EXTENDED; |
| 6075 | mcp->mb[1] = LSW(addr); |
| 6076 | mcp->mb[2] = MSW(req_dma); |
| 6077 | mcp->mb[3] = LSW(req_dma); |
| 6078 | mcp->mb[4] = MSW(size); |
| 6079 | mcp->mb[5] = LSW(size); |
| 6080 | mcp->mb[6] = MSW(MSD(req_dma)); |
| 6081 | mcp->mb[7] = LSW(MSD(req_dma)); |
| 6082 | mcp->mb[8] = MSW(addr); |
| 6083 | /* Setting RAM ID to valid */ |
| 6084 | mcp->mb[10] |= BIT_7; |
| 6085 | /* For MCTP RAM ID is 0x40 */ |
| 6086 | mcp->mb[10] |= 0x40; |
| 6087 | |
| 6088 | mcp->out_mb |= MBX_10|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1| |
| 6089 | MBX_0; |
| 6090 | |
| 6091 | mcp->in_mb = MBX_0; |
| 6092 | mcp->tov = MBX_TOV_SECONDS; |
| 6093 | mcp->flags = 0; |
| 6094 | rval = qla2x00_mailbox_command(vha, mcp); |
| 6095 | |
| 6096 | if (rval != QLA_SUCCESS) { |
| 6097 | ql_dbg(ql_dbg_mbx, vha, 0x114e, |
| 6098 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 6099 | } else { |
| 6100 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x114d, |
| 6101 | "Done %s.\n", __func__); |
| 6102 | } |
| 6103 | |
| 6104 | return rval; |
| 6105 | } |
Joe Carnuccio | ec89146 | 2016-07-06 11:14:26 -0400 | [diff] [blame] | 6106 | |
| 6107 | int |
| 6108 | qla26xx_dport_diagnostics(scsi_qla_host_t *vha, |
| 6109 | void *dd_buf, uint size, uint options) |
| 6110 | { |
| 6111 | int rval; |
| 6112 | mbx_cmd_t mc; |
| 6113 | mbx_cmd_t *mcp = &mc; |
| 6114 | dma_addr_t dd_dma; |
| 6115 | |
| 6116 | if (!IS_QLA83XX(vha->hw) && !IS_QLA27XX(vha->hw)) |
| 6117 | return QLA_FUNCTION_FAILED; |
| 6118 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6119 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x119f, |
Joe Carnuccio | ec89146 | 2016-07-06 11:14:26 -0400 | [diff] [blame] | 6120 | "Entered %s.\n", __func__); |
| 6121 | |
Joe Carnuccio | ec89146 | 2016-07-06 11:14:26 -0400 | [diff] [blame] | 6122 | dd_dma = dma_map_single(&vha->hw->pdev->dev, |
| 6123 | dd_buf, size, DMA_FROM_DEVICE); |
Pan Bian | 0b2ce19 | 2017-08-08 21:55:30 +0800 | [diff] [blame] | 6124 | if (dma_mapping_error(&vha->hw->pdev->dev, dd_dma)) { |
Joe Carnuccio | ec89146 | 2016-07-06 11:14:26 -0400 | [diff] [blame] | 6125 | ql_log(ql_log_warn, vha, 0x1194, "Failed to map dma buffer.\n"); |
| 6126 | return QLA_MEMORY_ALLOC_FAILED; |
| 6127 | } |
| 6128 | |
| 6129 | memset(dd_buf, 0, size); |
| 6130 | |
| 6131 | mcp->mb[0] = MBC_DPORT_DIAGNOSTICS; |
| 6132 | mcp->mb[1] = options; |
| 6133 | mcp->mb[2] = MSW(LSD(dd_dma)); |
| 6134 | mcp->mb[3] = LSW(LSD(dd_dma)); |
| 6135 | mcp->mb[6] = MSW(MSD(dd_dma)); |
| 6136 | mcp->mb[7] = LSW(MSD(dd_dma)); |
| 6137 | mcp->mb[8] = size; |
| 6138 | mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 6139 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 6140 | mcp->buf_size = size; |
| 6141 | mcp->flags = MBX_DMA_IN; |
| 6142 | mcp->tov = MBX_TOV_SECONDS * 4; |
| 6143 | rval = qla2x00_mailbox_command(vha, mcp); |
| 6144 | |
| 6145 | if (rval != QLA_SUCCESS) { |
| 6146 | ql_dbg(ql_dbg_mbx, vha, 0x1195, "Failed=%x.\n", rval); |
| 6147 | } else { |
| 6148 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1196, |
| 6149 | "Done %s.\n", __func__); |
| 6150 | } |
| 6151 | |
| 6152 | dma_unmap_single(&vha->hw->pdev->dev, dd_dma, |
| 6153 | size, DMA_FROM_DEVICE); |
| 6154 | |
| 6155 | return rval; |
| 6156 | } |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6157 | |
| 6158 | static void qla2x00_async_mb_sp_done(void *s, int res) |
| 6159 | { |
| 6160 | struct srb *sp = s; |
| 6161 | |
| 6162 | sp->u.iocb_cmd.u.mbx.rc = res; |
| 6163 | |
| 6164 | complete(&sp->u.iocb_cmd.u.mbx.comp); |
| 6165 | /* don't free sp here. Let the caller do the free */ |
| 6166 | } |
| 6167 | |
| 6168 | /* |
| 6169 | * This mailbox uses the iocb interface to send MB command. |
| 6170 | * This allows non-critial (non chip setup) command to go |
| 6171 | * out in parrallel. |
| 6172 | */ |
| 6173 | int qla24xx_send_mb_cmd(struct scsi_qla_host *vha, mbx_cmd_t *mcp) |
| 6174 | { |
| 6175 | int rval = QLA_FUNCTION_FAILED; |
| 6176 | srb_t *sp; |
| 6177 | struct srb_iocb *c; |
| 6178 | |
| 6179 | if (!vha->hw->flags.fw_started) |
| 6180 | goto done; |
| 6181 | |
| 6182 | sp = qla2x00_get_sp(vha, NULL, GFP_KERNEL); |
| 6183 | if (!sp) |
| 6184 | goto done; |
| 6185 | |
| 6186 | sp->type = SRB_MB_IOCB; |
| 6187 | sp->name = mb_to_str(mcp->mb[0]); |
| 6188 | |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6189 | c = &sp->u.iocb_cmd; |
| 6190 | c->timeout = qla2x00_async_iocb_timeout; |
| 6191 | init_completion(&c->u.mbx.comp); |
| 6192 | |
Ben Hutchings | e74e7d9 | 2018-03-20 21:36:14 +0000 | [diff] [blame] | 6193 | qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); |
| 6194 | |
| 6195 | memcpy(sp->u.iocb_cmd.u.mbx.out_mb, mcp->mb, SIZEOF_IOCB_MB_REG); |
| 6196 | |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6197 | sp->done = qla2x00_async_mb_sp_done; |
| 6198 | |
| 6199 | rval = qla2x00_start_sp(sp); |
| 6200 | if (rval != QLA_SUCCESS) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6201 | ql_dbg(ql_dbg_mbx, vha, 0x1018, |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6202 | "%s: %s Failed submission. %x.\n", |
| 6203 | __func__, sp->name, rval); |
| 6204 | goto done_free_sp; |
| 6205 | } |
| 6206 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6207 | 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] | 6208 | sp->name, sp->handle); |
| 6209 | |
| 6210 | wait_for_completion(&c->u.mbx.comp); |
| 6211 | memcpy(mcp->mb, sp->u.iocb_cmd.u.mbx.in_mb, SIZEOF_IOCB_MB_REG); |
| 6212 | |
| 6213 | rval = c->u.mbx.rc; |
| 6214 | switch (rval) { |
| 6215 | case QLA_FUNCTION_TIMEOUT: |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6216 | ql_dbg(ql_dbg_mbx, vha, 0x1140, "%s: %s Timeout. %x.\n", |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6217 | __func__, sp->name, rval); |
| 6218 | break; |
| 6219 | case QLA_SUCCESS: |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6220 | ql_dbg(ql_dbg_mbx, vha, 0x119d, "%s: %s done.\n", |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6221 | __func__, sp->name); |
| 6222 | sp->free(sp); |
| 6223 | break; |
| 6224 | default: |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6225 | ql_dbg(ql_dbg_mbx, vha, 0x119e, "%s: %s Failed. %x.\n", |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6226 | __func__, sp->name, rval); |
| 6227 | sp->free(sp); |
| 6228 | break; |
| 6229 | } |
| 6230 | |
| 6231 | return rval; |
| 6232 | |
| 6233 | done_free_sp: |
| 6234 | sp->free(sp); |
| 6235 | done: |
| 6236 | return rval; |
| 6237 | } |
| 6238 | |
| 6239 | /* |
| 6240 | * qla24xx_gpdb_wait |
| 6241 | * NOTE: Do not call this routine from DPC thread |
| 6242 | */ |
| 6243 | int qla24xx_gpdb_wait(struct scsi_qla_host *vha, fc_port_t *fcport, u8 opt) |
| 6244 | { |
| 6245 | int rval = QLA_FUNCTION_FAILED; |
| 6246 | dma_addr_t pd_dma; |
| 6247 | struct port_database_24xx *pd; |
| 6248 | struct qla_hw_data *ha = vha->hw; |
| 6249 | mbx_cmd_t mc; |
| 6250 | |
| 6251 | if (!vha->hw->flags.fw_started) |
| 6252 | goto done; |
| 6253 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 6254 | pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6255 | if (pd == NULL) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6256 | ql_log(ql_log_warn, vha, 0xd047, |
| 6257 | "Failed to allocate port database structure.\n"); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6258 | goto done_free_sp; |
| 6259 | } |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6260 | |
| 6261 | memset(&mc, 0, sizeof(mc)); |
| 6262 | mc.mb[0] = MBC_GET_PORT_DATABASE; |
| 6263 | mc.mb[1] = cpu_to_le16(fcport->loop_id); |
| 6264 | mc.mb[2] = MSW(pd_dma); |
| 6265 | mc.mb[3] = LSW(pd_dma); |
| 6266 | mc.mb[6] = MSW(MSD(pd_dma)); |
| 6267 | mc.mb[7] = LSW(MSD(pd_dma)); |
| 6268 | mc.mb[9] = cpu_to_le16(vha->vp_idx); |
| 6269 | mc.mb[10] = cpu_to_le16((uint16_t)opt); |
| 6270 | |
| 6271 | rval = qla24xx_send_mb_cmd(vha, &mc); |
| 6272 | if (rval != QLA_SUCCESS) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6273 | ql_dbg(ql_dbg_mbx, vha, 0x1193, |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6274 | "%s: %8phC fail\n", __func__, fcport->port_name); |
| 6275 | goto done_free_sp; |
| 6276 | } |
| 6277 | |
| 6278 | rval = __qla24xx_parse_gpdb(vha, fcport, pd); |
| 6279 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6280 | ql_dbg(ql_dbg_mbx, vha, 0x1197, "%s: %8phC done\n", |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6281 | __func__, fcport->port_name); |
| 6282 | |
| 6283 | done_free_sp: |
| 6284 | if (pd) |
| 6285 | dma_pool_free(ha->s_dma_pool, pd, pd_dma); |
| 6286 | done: |
| 6287 | return rval; |
| 6288 | } |
| 6289 | |
| 6290 | int __qla24xx_parse_gpdb(struct scsi_qla_host *vha, fc_port_t *fcport, |
| 6291 | struct port_database_24xx *pd) |
| 6292 | { |
| 6293 | int rval = QLA_SUCCESS; |
| 6294 | uint64_t zero = 0; |
Duane Grigsby | a5d42f4 | 2017-06-21 13:48:41 -0700 | [diff] [blame] | 6295 | u8 current_login_state, last_login_state; |
| 6296 | |
| 6297 | if (fcport->fc4f_nvme) { |
| 6298 | current_login_state = pd->current_login_state >> 4; |
| 6299 | last_login_state = pd->last_login_state >> 4; |
| 6300 | } else { |
| 6301 | current_login_state = pd->current_login_state & 0xf; |
| 6302 | last_login_state = pd->last_login_state & 0xf; |
| 6303 | } |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6304 | |
| 6305 | /* Check for logged in state. */ |
Quinn Tran | 23c6455 | 2017-12-04 14:45:08 -0800 | [diff] [blame] | 6306 | if (current_login_state != PDS_PRLI_COMPLETE) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6307 | ql_dbg(ql_dbg_mbx, vha, 0x119a, |
| 6308 | "Unable to verify login-state (%x/%x) for loop_id %x.\n", |
Duane Grigsby | a5d42f4 | 2017-06-21 13:48:41 -0700 | [diff] [blame] | 6309 | current_login_state, last_login_state, fcport->loop_id); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6310 | rval = QLA_FUNCTION_FAILED; |
| 6311 | goto gpd_error_out; |
| 6312 | } |
| 6313 | |
| 6314 | if (fcport->loop_id == FC_NO_LOOP_ID || |
| 6315 | (memcmp(fcport->port_name, (uint8_t *)&zero, 8) && |
| 6316 | memcmp(fcport->port_name, pd->port_name, 8))) { |
| 6317 | /* We lost the device mid way. */ |
| 6318 | rval = QLA_NOT_LOGGED_IN; |
| 6319 | goto gpd_error_out; |
| 6320 | } |
| 6321 | |
| 6322 | /* Names are little-endian. */ |
| 6323 | memcpy(fcport->node_name, pd->node_name, WWN_SIZE); |
| 6324 | memcpy(fcport->port_name, pd->port_name, WWN_SIZE); |
| 6325 | |
| 6326 | /* Get port_id of device. */ |
| 6327 | fcport->d_id.b.domain = pd->port_id[0]; |
| 6328 | fcport->d_id.b.area = pd->port_id[1]; |
| 6329 | fcport->d_id.b.al_pa = pd->port_id[2]; |
| 6330 | fcport->d_id.b.rsvd_1 = 0; |
| 6331 | |
Duane Grigsby | a5d42f4 | 2017-06-21 13:48:41 -0700 | [diff] [blame] | 6332 | if (fcport->fc4f_nvme) { |
Duane Grigsby | a5d42f4 | 2017-06-21 13:48:41 -0700 | [diff] [blame] | 6333 | fcport->port_type = FCT_NVME; |
| 6334 | } else { |
| 6335 | /* If not target must be initiator or unknown type. */ |
| 6336 | if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0) |
| 6337 | fcport->port_type = FCT_INITIATOR; |
| 6338 | else |
| 6339 | fcport->port_type = FCT_TARGET; |
| 6340 | } |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6341 | /* Passback COS information. */ |
| 6342 | fcport->supported_classes = (pd->flags & PDF_CLASS_2) ? |
| 6343 | FC_COS_CLASS2 : FC_COS_CLASS3; |
| 6344 | |
| 6345 | if (pd->prli_svc_param_word_3[0] & BIT_7) { |
| 6346 | fcport->flags |= FCF_CONF_COMP_SUPPORTED; |
| 6347 | fcport->conf_compl_supported = 1; |
| 6348 | } |
| 6349 | |
| 6350 | gpd_error_out: |
| 6351 | return rval; |
| 6352 | } |
| 6353 | |
| 6354 | /* |
| 6355 | * qla24xx_gidlist__wait |
| 6356 | * NOTE: don't call this routine from DPC thread. |
| 6357 | */ |
| 6358 | int qla24xx_gidlist_wait(struct scsi_qla_host *vha, |
| 6359 | void *id_list, dma_addr_t id_list_dma, uint16_t *entries) |
| 6360 | { |
| 6361 | int rval = QLA_FUNCTION_FAILED; |
| 6362 | mbx_cmd_t mc; |
| 6363 | |
| 6364 | if (!vha->hw->flags.fw_started) |
| 6365 | goto done; |
| 6366 | |
| 6367 | memset(&mc, 0, sizeof(mc)); |
| 6368 | mc.mb[0] = MBC_GET_ID_LIST; |
| 6369 | mc.mb[2] = MSW(id_list_dma); |
| 6370 | mc.mb[3] = LSW(id_list_dma); |
| 6371 | mc.mb[6] = MSW(MSD(id_list_dma)); |
| 6372 | mc.mb[7] = LSW(MSD(id_list_dma)); |
| 6373 | mc.mb[8] = 0; |
| 6374 | mc.mb[9] = cpu_to_le16(vha->vp_idx); |
| 6375 | |
| 6376 | rval = qla24xx_send_mb_cmd(vha, &mc); |
| 6377 | if (rval != QLA_SUCCESS) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6378 | ql_dbg(ql_dbg_mbx, vha, 0x119b, |
| 6379 | "%s: fail\n", __func__); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6380 | } else { |
| 6381 | *entries = mc.mb[1]; |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6382 | ql_dbg(ql_dbg_mbx, vha, 0x119c, |
| 6383 | "%s: done\n", __func__); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6384 | } |
| 6385 | done: |
| 6386 | return rval; |
| 6387 | } |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 6388 | |
| 6389 | int qla27xx_set_zio_threshold(scsi_qla_host_t *vha, uint16_t value) |
| 6390 | { |
| 6391 | int rval; |
| 6392 | mbx_cmd_t mc; |
| 6393 | mbx_cmd_t *mcp = &mc; |
| 6394 | |
| 6395 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1200, |
| 6396 | "Entered %s\n", __func__); |
| 6397 | |
| 6398 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 6399 | mcp->mb[0] = MBC_GET_SET_ZIO_THRESHOLD; |
| 6400 | mcp->mb[1] = cpu_to_le16(1); |
| 6401 | mcp->mb[2] = cpu_to_le16(value); |
| 6402 | mcp->out_mb = MBX_2 | MBX_1 | MBX_0; |
| 6403 | mcp->in_mb = MBX_2 | MBX_0; |
| 6404 | mcp->tov = MBX_TOV_SECONDS; |
| 6405 | mcp->flags = 0; |
| 6406 | |
| 6407 | rval = qla2x00_mailbox_command(vha, mcp); |
| 6408 | |
| 6409 | ql_dbg(ql_dbg_mbx, vha, 0x1201, "%s %x\n", |
| 6410 | (rval != QLA_SUCCESS) ? "Failed" : "Done", rval); |
| 6411 | |
| 6412 | return rval; |
| 6413 | } |
| 6414 | |
| 6415 | int qla27xx_get_zio_threshold(scsi_qla_host_t *vha, uint16_t *value) |
| 6416 | { |
| 6417 | int rval; |
| 6418 | mbx_cmd_t mc; |
| 6419 | mbx_cmd_t *mcp = &mc; |
| 6420 | |
| 6421 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1203, |
| 6422 | "Entered %s\n", __func__); |
| 6423 | |
| 6424 | memset(mcp->mb, 0, sizeof(mcp->mb)); |
| 6425 | mcp->mb[0] = MBC_GET_SET_ZIO_THRESHOLD; |
| 6426 | mcp->mb[1] = cpu_to_le16(0); |
| 6427 | mcp->out_mb = MBX_1 | MBX_0; |
| 6428 | mcp->in_mb = MBX_2 | MBX_0; |
| 6429 | mcp->tov = MBX_TOV_SECONDS; |
| 6430 | mcp->flags = 0; |
| 6431 | |
| 6432 | rval = qla2x00_mailbox_command(vha, mcp); |
| 6433 | if (rval == QLA_SUCCESS) |
| 6434 | *value = mc.mb[2]; |
| 6435 | |
| 6436 | ql_dbg(ql_dbg_mbx, vha, 0x1205, "%s %x\n", |
| 6437 | (rval != QLA_SUCCESS) ? "Failed" : "Done", rval); |
| 6438 | |
| 6439 | return rval; |
| 6440 | } |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 6441 | |
| 6442 | int |
| 6443 | qla2x00_read_sfp_dev(struct scsi_qla_host *vha, char *buf, int count) |
| 6444 | { |
| 6445 | struct qla_hw_data *ha = vha->hw; |
| 6446 | uint16_t iter, addr, offset; |
| 6447 | dma_addr_t phys_addr; |
| 6448 | int rval, c; |
| 6449 | u8 *sfp_data; |
| 6450 | |
| 6451 | memset(ha->sfp_data, 0, SFP_DEV_SIZE); |
| 6452 | addr = 0xa0; |
| 6453 | phys_addr = ha->sfp_data_dma; |
| 6454 | sfp_data = ha->sfp_data; |
| 6455 | offset = c = 0; |
| 6456 | |
| 6457 | for (iter = 0; iter < SFP_DEV_SIZE / SFP_BLOCK_SIZE; iter++) { |
| 6458 | if (iter == 4) { |
| 6459 | /* Skip to next device address. */ |
| 6460 | addr = 0xa2; |
| 6461 | offset = 0; |
| 6462 | } |
| 6463 | |
| 6464 | rval = qla2x00_read_sfp(vha, phys_addr, sfp_data, |
| 6465 | addr, offset, SFP_BLOCK_SIZE, BIT_1); |
| 6466 | if (rval != QLA_SUCCESS) { |
| 6467 | ql_log(ql_log_warn, vha, 0x706d, |
| 6468 | "Unable to read SFP data (%x/%x/%x).\n", rval, |
| 6469 | addr, offset); |
| 6470 | |
| 6471 | return rval; |
| 6472 | } |
| 6473 | |
| 6474 | if (buf && (c < count)) { |
| 6475 | u16 sz; |
| 6476 | |
| 6477 | if ((count - c) >= SFP_BLOCK_SIZE) |
| 6478 | sz = SFP_BLOCK_SIZE; |
| 6479 | else |
| 6480 | sz = count - c; |
| 6481 | |
| 6482 | memcpy(buf, sfp_data, sz); |
| 6483 | buf += SFP_BLOCK_SIZE; |
| 6484 | c += sz; |
| 6485 | } |
| 6486 | phys_addr += SFP_BLOCK_SIZE; |
| 6487 | sfp_data += SFP_BLOCK_SIZE; |
| 6488 | offset += SFP_BLOCK_SIZE; |
| 6489 | } |
| 6490 | |
| 6491 | return rval; |
| 6492 | } |
Quinn Tran | 94d83e3 | 2017-12-28 12:33:23 -0800 | [diff] [blame] | 6493 | |
| 6494 | int qla24xx_res_count_wait(struct scsi_qla_host *vha, |
| 6495 | uint16_t *out_mb, int out_mb_sz) |
| 6496 | { |
| 6497 | int rval = QLA_FUNCTION_FAILED; |
| 6498 | mbx_cmd_t mc; |
| 6499 | |
| 6500 | if (!vha->hw->flags.fw_started) |
| 6501 | goto done; |
| 6502 | |
| 6503 | memset(&mc, 0, sizeof(mc)); |
| 6504 | mc.mb[0] = MBC_GET_RESOURCE_COUNTS; |
| 6505 | |
| 6506 | rval = qla24xx_send_mb_cmd(vha, &mc); |
| 6507 | if (rval != QLA_SUCCESS) { |
| 6508 | ql_dbg(ql_dbg_mbx, vha, 0xffff, |
| 6509 | "%s: fail\n", __func__); |
| 6510 | } else { |
| 6511 | if (out_mb_sz <= SIZEOF_IOCB_MB_REG) |
| 6512 | memcpy(out_mb, mc.mb, out_mb_sz); |
| 6513 | else |
| 6514 | memcpy(out_mb, mc.mb, SIZEOF_IOCB_MB_REG); |
| 6515 | |
| 6516 | ql_dbg(ql_dbg_mbx, vha, 0xffff, |
| 6517 | "%s: done\n", __func__); |
| 6518 | } |
| 6519 | done: |
| 6520 | return rval; |
| 6521 | } |