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 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | } else if (!abort_active) { |
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 | */ |
Darren Trapp | 1cbc0ef | 2018-03-20 23:09:37 -0700 | [diff] [blame] | 1112 | if ((ha->fw_attributes_h & 0x400) && ql2xnvmeenable) { |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 1113 | vha->flags.nvme_enabled = 1; |
Darren Trapp | 1cbc0ef | 2018-03-20 23:09:37 -0700 | [diff] [blame] | 1114 | ql_log(ql_log_info, vha, 0xd302, |
| 1115 | "%s: FC-NVMe is Enabled (0x%x)\n", |
| 1116 | __func__, ha->fw_attributes_h); |
| 1117 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1118 | } |
Sawan Chandak | 03aa868 | 2015-08-04 13:37:59 -0400 | [diff] [blame] | 1119 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 1120 | if (IS_QLA27XX(ha)) { |
Sawan Chandak | 03aa868 | 2015-08-04 13:37:59 -0400 | [diff] [blame] | 1121 | ha->mpi_version[0] = mcp->mb[10] & 0xff; |
| 1122 | ha->mpi_version[1] = mcp->mb[11] >> 8; |
| 1123 | ha->mpi_version[2] = mcp->mb[11] & 0xff; |
| 1124 | ha->pep_version[0] = mcp->mb[13] & 0xff; |
| 1125 | ha->pep_version[1] = mcp->mb[14] >> 8; |
| 1126 | ha->pep_version[2] = mcp->mb[14] & 0xff; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 1127 | ha->fw_shared_ram_start = (mcp->mb[19] << 16) | mcp->mb[18]; |
| 1128 | ha->fw_shared_ram_end = (mcp->mb[21] << 16) | mcp->mb[20]; |
Joe Carnuccio | ad1ef17 | 2016-07-06 11:14:18 -0400 | [diff] [blame] | 1129 | ha->fw_ddr_ram_start = (mcp->mb[23] << 16) | mcp->mb[22]; |
| 1130 | ha->fw_ddr_ram_end = (mcp->mb[25] << 16) | mcp->mb[24]; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 1131 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1132 | |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 1133 | failed: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1134 | if (rval != QLA_SUCCESS) { |
| 1135 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1136 | ql_dbg(ql_dbg_mbx, vha, 0x102a, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1137 | } else { |
| 1138 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1139 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102b, |
| 1140 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1141 | } |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 1142 | return rval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1143 | } |
| 1144 | |
| 1145 | /* |
| 1146 | * qla2x00_get_fw_options |
| 1147 | * Set firmware options. |
| 1148 | * |
| 1149 | * Input: |
| 1150 | * ha = adapter block pointer. |
| 1151 | * fwopt = pointer for firmware options. |
| 1152 | * |
| 1153 | * Returns: |
| 1154 | * qla2x00 local function return status code. |
| 1155 | * |
| 1156 | * Context: |
| 1157 | * Kernel context. |
| 1158 | */ |
| 1159 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1160 | qla2x00_get_fw_options(scsi_qla_host_t *vha, uint16_t *fwopts) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1161 | { |
| 1162 | int rval; |
| 1163 | mbx_cmd_t mc; |
| 1164 | mbx_cmd_t *mcp = &mc; |
| 1165 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1166 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102c, |
| 1167 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1168 | |
| 1169 | mcp->mb[0] = MBC_GET_FIRMWARE_OPTION; |
| 1170 | mcp->out_mb = MBX_0; |
| 1171 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1172 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1173 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1174 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1175 | |
| 1176 | if (rval != QLA_SUCCESS) { |
| 1177 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1178 | ql_dbg(ql_dbg_mbx, vha, 0x102d, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1179 | } else { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1180 | fwopts[0] = mcp->mb[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1181 | fwopts[1] = mcp->mb[1]; |
| 1182 | fwopts[2] = mcp->mb[2]; |
| 1183 | fwopts[3] = mcp->mb[3]; |
| 1184 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1185 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102e, |
| 1186 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1187 | } |
| 1188 | |
| 1189 | return rval; |
| 1190 | } |
| 1191 | |
| 1192 | |
| 1193 | /* |
| 1194 | * qla2x00_set_fw_options |
| 1195 | * Set firmware options. |
| 1196 | * |
| 1197 | * Input: |
| 1198 | * ha = adapter block pointer. |
| 1199 | * fwopt = pointer for firmware options. |
| 1200 | * |
| 1201 | * Returns: |
| 1202 | * qla2x00 local function return status code. |
| 1203 | * |
| 1204 | * Context: |
| 1205 | * Kernel context. |
| 1206 | */ |
| 1207 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1208 | qla2x00_set_fw_options(scsi_qla_host_t *vha, uint16_t *fwopts) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1209 | { |
| 1210 | int rval; |
| 1211 | mbx_cmd_t mc; |
| 1212 | mbx_cmd_t *mcp = &mc; |
| 1213 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1214 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102f, |
| 1215 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1216 | |
| 1217 | mcp->mb[0] = MBC_SET_FIRMWARE_OPTION; |
| 1218 | mcp->mb[1] = fwopts[1]; |
| 1219 | mcp->mb[2] = fwopts[2]; |
| 1220 | mcp->mb[3] = fwopts[3]; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1221 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1222 | mcp->in_mb = MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1223 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1224 | mcp->in_mb |= MBX_1; |
Quinn Tran | 2da5273 | 2017-06-02 09:12:05 -0700 | [diff] [blame] | 1225 | mcp->mb[10] = fwopts[10]; |
| 1226 | mcp->out_mb |= MBX_10; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1227 | } else { |
| 1228 | mcp->mb[10] = fwopts[10]; |
| 1229 | mcp->mb[11] = fwopts[11]; |
| 1230 | mcp->mb[12] = 0; /* Undocumented, but used */ |
| 1231 | mcp->out_mb |= MBX_12|MBX_11|MBX_10; |
| 1232 | } |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1233 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1234 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1235 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1236 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1237 | fwopts[0] = mcp->mb[0]; |
| 1238 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1239 | if (rval != QLA_SUCCESS) { |
| 1240 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1241 | ql_dbg(ql_dbg_mbx, vha, 0x1030, |
| 1242 | "Failed=%x (%x/%x).\n", rval, mcp->mb[0], mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1243 | } else { |
| 1244 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1245 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1031, |
| 1246 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1247 | } |
| 1248 | |
| 1249 | return rval; |
| 1250 | } |
| 1251 | |
| 1252 | /* |
| 1253 | * qla2x00_mbx_reg_test |
| 1254 | * Mailbox register wrap test. |
| 1255 | * |
| 1256 | * Input: |
| 1257 | * ha = adapter block pointer. |
| 1258 | * TARGET_QUEUE_LOCK must be released. |
| 1259 | * ADAPTER_STATE_LOCK must be released. |
| 1260 | * |
| 1261 | * Returns: |
| 1262 | * qla2x00 local function return status code. |
| 1263 | * |
| 1264 | * Context: |
| 1265 | * Kernel context. |
| 1266 | */ |
| 1267 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1268 | qla2x00_mbx_reg_test(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1269 | { |
| 1270 | int rval; |
| 1271 | mbx_cmd_t mc; |
| 1272 | mbx_cmd_t *mcp = &mc; |
| 1273 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1274 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1032, |
| 1275 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1276 | |
| 1277 | mcp->mb[0] = MBC_MAILBOX_REGISTER_TEST; |
| 1278 | mcp->mb[1] = 0xAAAA; |
| 1279 | mcp->mb[2] = 0x5555; |
| 1280 | mcp->mb[3] = 0xAA55; |
| 1281 | mcp->mb[4] = 0x55AA; |
| 1282 | mcp->mb[5] = 0xA5A5; |
| 1283 | mcp->mb[6] = 0x5A5A; |
| 1284 | mcp->mb[7] = 0x2525; |
| 1285 | mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 1286 | 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] | 1287 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1288 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1289 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1290 | |
| 1291 | if (rval == QLA_SUCCESS) { |
| 1292 | if (mcp->mb[1] != 0xAAAA || mcp->mb[2] != 0x5555 || |
| 1293 | mcp->mb[3] != 0xAA55 || mcp->mb[4] != 0x55AA) |
| 1294 | rval = QLA_FUNCTION_FAILED; |
| 1295 | if (mcp->mb[5] != 0xA5A5 || mcp->mb[6] != 0x5A5A || |
| 1296 | mcp->mb[7] != 0x2525) |
| 1297 | rval = QLA_FUNCTION_FAILED; |
| 1298 | } |
| 1299 | |
| 1300 | if (rval != QLA_SUCCESS) { |
| 1301 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1302 | ql_dbg(ql_dbg_mbx, vha, 0x1033, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1303 | } else { |
| 1304 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1305 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1034, |
| 1306 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1307 | } |
| 1308 | |
| 1309 | return rval; |
| 1310 | } |
| 1311 | |
| 1312 | /* |
| 1313 | * qla2x00_verify_checksum |
| 1314 | * Verify firmware checksum. |
| 1315 | * |
| 1316 | * Input: |
| 1317 | * ha = adapter block pointer. |
| 1318 | * TARGET_QUEUE_LOCK must be released. |
| 1319 | * ADAPTER_STATE_LOCK must be released. |
| 1320 | * |
| 1321 | * Returns: |
| 1322 | * qla2x00 local function return status code. |
| 1323 | * |
| 1324 | * Context: |
| 1325 | * Kernel context. |
| 1326 | */ |
| 1327 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1328 | qla2x00_verify_checksum(scsi_qla_host_t *vha, uint32_t risc_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1329 | { |
| 1330 | int rval; |
| 1331 | mbx_cmd_t mc; |
| 1332 | mbx_cmd_t *mcp = &mc; |
| 1333 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1334 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1035, |
| 1335 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1336 | |
| 1337 | mcp->mb[0] = MBC_VERIFY_CHECKSUM; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1338 | mcp->out_mb = MBX_0; |
| 1339 | mcp->in_mb = MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1340 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1341 | mcp->mb[1] = MSW(risc_addr); |
| 1342 | mcp->mb[2] = LSW(risc_addr); |
| 1343 | mcp->out_mb |= MBX_2|MBX_1; |
| 1344 | mcp->in_mb |= MBX_2|MBX_1; |
| 1345 | } else { |
| 1346 | mcp->mb[1] = LSW(risc_addr); |
| 1347 | mcp->out_mb |= MBX_1; |
| 1348 | mcp->in_mb |= MBX_1; |
| 1349 | } |
| 1350 | |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1351 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1352 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1353 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1354 | |
| 1355 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1356 | ql_dbg(ql_dbg_mbx, vha, 0x1036, |
| 1357 | "Failed=%x chm sum=%x.\n", rval, IS_FWI2_CAPABLE(vha->hw) ? |
| 1358 | (mcp->mb[2] << 16) | mcp->mb[1] : mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1359 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1360 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1037, |
| 1361 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1362 | } |
| 1363 | |
| 1364 | return rval; |
| 1365 | } |
| 1366 | |
| 1367 | /* |
| 1368 | * qla2x00_issue_iocb |
| 1369 | * Issue IOCB using mailbox command |
| 1370 | * |
| 1371 | * Input: |
| 1372 | * ha = adapter state pointer. |
| 1373 | * buffer = buffer pointer. |
| 1374 | * phys_addr = physical address of buffer. |
| 1375 | * size = size of buffer. |
| 1376 | * TARGET_QUEUE_LOCK must be released. |
| 1377 | * ADAPTER_STATE_LOCK must be released. |
| 1378 | * |
| 1379 | * Returns: |
| 1380 | * qla2x00 local function return status code. |
| 1381 | * |
| 1382 | * Context: |
| 1383 | * Kernel context. |
| 1384 | */ |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 1385 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1386 | qla2x00_issue_iocb_timeout(scsi_qla_host_t *vha, void *buffer, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1387 | dma_addr_t phys_addr, size_t size, uint32_t tov) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1388 | { |
| 1389 | int rval; |
| 1390 | mbx_cmd_t mc; |
| 1391 | mbx_cmd_t *mcp = &mc; |
| 1392 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1393 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1038, |
| 1394 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1395 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1396 | mcp->mb[0] = MBC_IOCB_COMMAND_A64; |
| 1397 | mcp->mb[1] = 0; |
| 1398 | mcp->mb[2] = MSW(phys_addr); |
| 1399 | mcp->mb[3] = LSW(phys_addr); |
| 1400 | mcp->mb[6] = MSW(MSD(phys_addr)); |
| 1401 | mcp->mb[7] = LSW(MSD(phys_addr)); |
| 1402 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 1403 | mcp->in_mb = MBX_2|MBX_0; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1404 | mcp->tov = tov; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1405 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1406 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1407 | |
| 1408 | if (rval != QLA_SUCCESS) { |
| 1409 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1410 | ql_dbg(ql_dbg_mbx, vha, 0x1039, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1411 | } else { |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 1412 | sts_entry_t *sts_entry = (sts_entry_t *) buffer; |
| 1413 | |
| 1414 | /* Mask reserved bits. */ |
| 1415 | sts_entry->entry_status &= |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1416 | IS_FWI2_CAPABLE(vha->hw) ? RF_MASK_24XX : RF_MASK; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1417 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103a, |
| 1418 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1419 | } |
| 1420 | |
| 1421 | return rval; |
| 1422 | } |
| 1423 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1424 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1425 | 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] | 1426 | size_t size) |
| 1427 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1428 | return qla2x00_issue_iocb_timeout(vha, buffer, phys_addr, size, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1429 | MBX_TOV_SECONDS); |
| 1430 | } |
| 1431 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1432 | /* |
| 1433 | * qla2x00_abort_command |
| 1434 | * Abort command aborts a specified IOCB. |
| 1435 | * |
| 1436 | * Input: |
| 1437 | * ha = adapter block pointer. |
| 1438 | * sp = SB structure pointer. |
| 1439 | * |
| 1440 | * Returns: |
| 1441 | * qla2x00 local function return status code. |
| 1442 | * |
| 1443 | * Context: |
| 1444 | * Kernel context. |
| 1445 | */ |
| 1446 | int |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1447 | qla2x00_abort_command(srb_t *sp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1448 | { |
| 1449 | unsigned long flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1450 | int rval; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1451 | uint32_t handle = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1452 | mbx_cmd_t mc; |
| 1453 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1454 | fc_port_t *fcport = sp->fcport; |
| 1455 | scsi_qla_host_t *vha = fcport->vha; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1456 | struct qla_hw_data *ha = vha->hw; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1457 | struct req_que *req; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1458 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1459 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1460 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103b, |
| 1461 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1462 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1463 | if (vha->flags.qpairs_available && sp->qpair) |
| 1464 | req = sp->qpair->req; |
| 1465 | else |
| 1466 | req = vha->req; |
| 1467 | |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 1468 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1469 | for (handle = 1; handle < req->num_outstanding_cmds; handle++) { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1470 | if (req->outstanding_cmds[handle] == sp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1471 | break; |
| 1472 | } |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 1473 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1474 | |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1475 | if (handle == req->num_outstanding_cmds) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1476 | /* command not found */ |
| 1477 | return QLA_FUNCTION_FAILED; |
| 1478 | } |
| 1479 | |
| 1480 | mcp->mb[0] = MBC_ABORT_COMMAND; |
| 1481 | if (HAS_EXTENDED_IDS(ha)) |
| 1482 | mcp->mb[1] = fcport->loop_id; |
| 1483 | else |
| 1484 | mcp->mb[1] = fcport->loop_id << 8; |
| 1485 | mcp->mb[2] = (uint16_t)handle; |
| 1486 | mcp->mb[3] = (uint16_t)(handle >> 16); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1487 | mcp->mb[6] = (uint16_t)cmd->device->lun; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1488 | mcp->out_mb = MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 1489 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1490 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1491 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1492 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1493 | |
| 1494 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1495 | ql_dbg(ql_dbg_mbx, vha, 0x103c, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1496 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1497 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103d, |
| 1498 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1499 | } |
| 1500 | |
| 1501 | return rval; |
| 1502 | } |
| 1503 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1504 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1505 | qla2x00_abort_target(struct fc_port *fcport, uint64_t l, int tag) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1506 | { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1507 | int rval, rval2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1508 | mbx_cmd_t mc; |
| 1509 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1510 | scsi_qla_host_t *vha; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1511 | struct req_que *req; |
| 1512 | struct rsp_que *rsp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1513 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1514 | l = l; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1515 | vha = fcport->vha; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1516 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1517 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103e, |
| 1518 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1519 | |
Giridhar Malavali | 7e2b895 | 2010-05-28 15:08:17 -0700 | [diff] [blame] | 1520 | req = vha->hw->req_q_map[0]; |
| 1521 | rsp = req->rsp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1522 | mcp->mb[0] = MBC_ABORT_TARGET; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1523 | mcp->out_mb = MBX_9|MBX_2|MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1524 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1525 | mcp->mb[1] = fcport->loop_id; |
| 1526 | mcp->mb[10] = 0; |
| 1527 | mcp->out_mb |= MBX_10; |
| 1528 | } else { |
| 1529 | mcp->mb[1] = fcport->loop_id << 8; |
| 1530 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1531 | mcp->mb[2] = vha->hw->loop_reset_delay; |
| 1532 | mcp->mb[9] = vha->vp_idx; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1533 | |
| 1534 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1535 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1536 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1537 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1538 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1539 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103f, |
| 1540 | "Failed=%x.\n", rval); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1541 | } |
| 1542 | |
| 1543 | /* Issue marker IOCB. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1544 | rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, 0, |
| 1545 | MK_SYNC_ID); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1546 | if (rval2 != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1547 | ql_dbg(ql_dbg_mbx, vha, 0x1040, |
| 1548 | "Failed to issue marker IOCB (%x).\n", rval2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1549 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1550 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1041, |
| 1551 | "Done %s.\n", __func__); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1552 | } |
| 1553 | |
| 1554 | return rval; |
| 1555 | } |
| 1556 | |
| 1557 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1558 | qla2x00_lun_reset(struct fc_port *fcport, uint64_t l, int tag) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1559 | { |
| 1560 | int rval, rval2; |
| 1561 | mbx_cmd_t mc; |
| 1562 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1563 | scsi_qla_host_t *vha; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1564 | struct req_que *req; |
| 1565 | struct rsp_que *rsp; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1566 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1567 | vha = fcport->vha; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1568 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1569 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1042, |
| 1570 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1571 | |
Giridhar Malavali | 7e2b895 | 2010-05-28 15:08:17 -0700 | [diff] [blame] | 1572 | req = vha->hw->req_q_map[0]; |
| 1573 | rsp = req->rsp; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1574 | mcp->mb[0] = MBC_LUN_RESET; |
| 1575 | 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] | 1576 | if (HAS_EXTENDED_IDS(vha->hw)) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1577 | mcp->mb[1] = fcport->loop_id; |
| 1578 | else |
| 1579 | mcp->mb[1] = fcport->loop_id << 8; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1580 | mcp->mb[2] = (u32)l; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1581 | mcp->mb[3] = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1582 | mcp->mb[9] = vha->vp_idx; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1583 | |
| 1584 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1585 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1586 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1587 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1588 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1589 | ql_dbg(ql_dbg_mbx, vha, 0x1043, "Failed=%x.\n", rval); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1590 | } |
| 1591 | |
| 1592 | /* Issue marker IOCB. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1593 | rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, l, |
| 1594 | MK_SYNC_ID_LUN); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1595 | if (rval2 != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1596 | ql_dbg(ql_dbg_mbx, vha, 0x1044, |
| 1597 | "Failed to issue marker IOCB (%x).\n", rval2); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1598 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1599 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1045, |
| 1600 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1601 | } |
| 1602 | |
| 1603 | return rval; |
| 1604 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1605 | |
| 1606 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1607 | * qla2x00_get_adapter_id |
| 1608 | * Get adapter ID and topology. |
| 1609 | * |
| 1610 | * Input: |
| 1611 | * ha = adapter block pointer. |
| 1612 | * id = pointer for loop ID. |
| 1613 | * al_pa = pointer for AL_PA. |
| 1614 | * area = pointer for area. |
| 1615 | * domain = pointer for domain. |
| 1616 | * top = pointer for topology. |
| 1617 | * TARGET_QUEUE_LOCK must be released. |
| 1618 | * ADAPTER_STATE_LOCK must be released. |
| 1619 | * |
| 1620 | * Returns: |
| 1621 | * qla2x00 local function return status code. |
| 1622 | * |
| 1623 | * Context: |
| 1624 | * Kernel context. |
| 1625 | */ |
| 1626 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1627 | 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] | 1628 | 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] | 1629 | { |
| 1630 | int rval; |
| 1631 | mbx_cmd_t mc; |
| 1632 | mbx_cmd_t *mcp = &mc; |
| 1633 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1634 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1046, |
| 1635 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1636 | |
| 1637 | mcp->mb[0] = MBC_GET_ADAPTER_LOOP_ID; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1638 | mcp->mb[9] = vha->vp_idx; |
Andrew Vasquez | eb66dc6 | 2007-11-12 10:30:58 -0800 | [diff] [blame] | 1639 | mcp->out_mb = MBX_9|MBX_0; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1640 | 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] | 1641 | if (IS_CNA_CAPABLE(vha->hw)) |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1642 | mcp->in_mb |= MBX_13|MBX_12|MBX_11|MBX_10; |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 1643 | if (IS_FWI2_CAPABLE(vha->hw)) |
| 1644 | mcp->in_mb |= MBX_19|MBX_18|MBX_17|MBX_16; |
Sawan Chandak | 969a619 | 2016-01-27 12:03:32 -0500 | [diff] [blame] | 1645 | if (IS_QLA27XX(vha->hw)) |
| 1646 | mcp->in_mb |= MBX_15; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1647 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1648 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1649 | rval = qla2x00_mailbox_command(vha, mcp); |
Ravi Anand | 33135aa | 2005-11-08 14:37:20 -0800 | [diff] [blame] | 1650 | if (mcp->mb[0] == MBS_COMMAND_ERROR) |
| 1651 | rval = QLA_COMMAND_ERROR; |
Andrew Vasquez | 42e421b | 2008-07-10 16:56:01 -0700 | [diff] [blame] | 1652 | else if (mcp->mb[0] == MBS_INVALID_COMMAND) |
| 1653 | rval = QLA_INVALID_COMMAND; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1654 | |
| 1655 | /* Return data. */ |
| 1656 | *id = mcp->mb[1]; |
| 1657 | *al_pa = LSB(mcp->mb[2]); |
| 1658 | *area = MSB(mcp->mb[2]); |
| 1659 | *domain = LSB(mcp->mb[3]); |
| 1660 | *top = mcp->mb[6]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1661 | *sw_cap = mcp->mb[7]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1662 | |
| 1663 | if (rval != QLA_SUCCESS) { |
| 1664 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1665 | ql_dbg(ql_dbg_mbx, vha, 0x1047, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1666 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1667 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1048, |
| 1668 | "Done %s.\n", __func__); |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1669 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1670 | if (IS_CNA_CAPABLE(vha->hw)) { |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1671 | vha->fcoe_vlan_id = mcp->mb[9] & 0xfff; |
| 1672 | vha->fcoe_fcf_idx = mcp->mb[10]; |
| 1673 | vha->fcoe_vn_port_mac[5] = mcp->mb[11] >> 8; |
| 1674 | vha->fcoe_vn_port_mac[4] = mcp->mb[11] & 0xff; |
| 1675 | vha->fcoe_vn_port_mac[3] = mcp->mb[12] >> 8; |
| 1676 | vha->fcoe_vn_port_mac[2] = mcp->mb[12] & 0xff; |
| 1677 | vha->fcoe_vn_port_mac[1] = mcp->mb[13] >> 8; |
| 1678 | vha->fcoe_vn_port_mac[0] = mcp->mb[13] & 0xff; |
| 1679 | } |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 1680 | /* If FA-WWN supported */ |
Saurav Kashyap | d6b9b42 | 2015-08-04 13:37:55 -0400 | [diff] [blame] | 1681 | if (IS_FAWWN_CAPABLE(vha->hw)) { |
| 1682 | if (mcp->mb[7] & BIT_14) { |
| 1683 | vha->port_name[0] = MSB(mcp->mb[16]); |
| 1684 | vha->port_name[1] = LSB(mcp->mb[16]); |
| 1685 | vha->port_name[2] = MSB(mcp->mb[17]); |
| 1686 | vha->port_name[3] = LSB(mcp->mb[17]); |
| 1687 | vha->port_name[4] = MSB(mcp->mb[18]); |
| 1688 | vha->port_name[5] = LSB(mcp->mb[18]); |
| 1689 | vha->port_name[6] = MSB(mcp->mb[19]); |
| 1690 | vha->port_name[7] = LSB(mcp->mb[19]); |
| 1691 | fc_host_port_name(vha->host) = |
| 1692 | wwn_to_u64(vha->port_name); |
| 1693 | ql_dbg(ql_dbg_mbx, vha, 0x10ca, |
| 1694 | "FA-WWN acquired %016llx\n", |
| 1695 | wwn_to_u64(vha->port_name)); |
| 1696 | } |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 1697 | } |
Sawan Chandak | 969a619 | 2016-01-27 12:03:32 -0500 | [diff] [blame] | 1698 | |
| 1699 | if (IS_QLA27XX(vha->hw)) |
| 1700 | vha->bbcr = mcp->mb[15]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1701 | } |
| 1702 | |
| 1703 | return rval; |
| 1704 | } |
| 1705 | |
| 1706 | /* |
| 1707 | * qla2x00_get_retry_cnt |
| 1708 | * Get current firmware login retry count and delay. |
| 1709 | * |
| 1710 | * Input: |
| 1711 | * ha = adapter block pointer. |
| 1712 | * retry_cnt = pointer to login retry count. |
| 1713 | * tov = pointer to login timeout value. |
| 1714 | * |
| 1715 | * Returns: |
| 1716 | * qla2x00 local function return status code. |
| 1717 | * |
| 1718 | * Context: |
| 1719 | * Kernel context. |
| 1720 | */ |
| 1721 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1722 | 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] | 1723 | uint16_t *r_a_tov) |
| 1724 | { |
| 1725 | int rval; |
| 1726 | uint16_t ratov; |
| 1727 | mbx_cmd_t mc; |
| 1728 | mbx_cmd_t *mcp = &mc; |
| 1729 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1730 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1049, |
| 1731 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1732 | |
| 1733 | mcp->mb[0] = MBC_GET_RETRY_COUNT; |
| 1734 | mcp->out_mb = MBX_0; |
| 1735 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1736 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1737 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1738 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1739 | |
| 1740 | if (rval != QLA_SUCCESS) { |
| 1741 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1742 | ql_dbg(ql_dbg_mbx, vha, 0x104a, |
| 1743 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1744 | } else { |
| 1745 | /* Convert returned data and check our values. */ |
| 1746 | *r_a_tov = mcp->mb[3] / 2; |
| 1747 | ratov = (mcp->mb[3]/2) / 10; /* mb[3] value is in 100ms */ |
| 1748 | if (mcp->mb[1] * ratov > (*retry_cnt) * (*tov)) { |
| 1749 | /* Update to the larger values */ |
| 1750 | *retry_cnt = (uint8_t)mcp->mb[1]; |
| 1751 | *tov = ratov; |
| 1752 | } |
| 1753 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1754 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104b, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1755 | "Done %s mb3=%d ratov=%d.\n", __func__, mcp->mb[3], ratov); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1756 | } |
| 1757 | |
| 1758 | return rval; |
| 1759 | } |
| 1760 | |
| 1761 | /* |
| 1762 | * qla2x00_init_firmware |
| 1763 | * Initialize adapter firmware. |
| 1764 | * |
| 1765 | * Input: |
| 1766 | * ha = adapter block pointer. |
| 1767 | * dptr = Initialization control block pointer. |
| 1768 | * size = size of initialization control block. |
| 1769 | * TARGET_QUEUE_LOCK must be released. |
| 1770 | * ADAPTER_STATE_LOCK must be released. |
| 1771 | * |
| 1772 | * Returns: |
| 1773 | * qla2x00 local function return status code. |
| 1774 | * |
| 1775 | * Context: |
| 1776 | * Kernel context. |
| 1777 | */ |
| 1778 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1779 | qla2x00_init_firmware(scsi_qla_host_t *vha, uint16_t size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1780 | { |
| 1781 | int rval; |
| 1782 | mbx_cmd_t mc; |
| 1783 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1784 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1785 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1786 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104c, |
| 1787 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1788 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1789 | if (IS_P3P_TYPE(ha) && ql2xdbwr) |
Bart Van Assche | 8dfa4b5a | 2015-07-09 07:24:50 -0700 | [diff] [blame] | 1790 | qla82xx_wr_32(ha, (uintptr_t __force)ha->nxdb_wr_ptr, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1791 | (0x04 | (ha->portnum << 5) | (0 << 8) | (0 << 16))); |
| 1792 | |
Andrew Vasquez | e6e074f | 2008-01-31 12:33:53 -0800 | [diff] [blame] | 1793 | if (ha->flags.npiv_supported) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1794 | mcp->mb[0] = MBC_MID_INITIALIZE_FIRMWARE; |
| 1795 | else |
| 1796 | mcp->mb[0] = MBC_INITIALIZE_FIRMWARE; |
| 1797 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 1798 | mcp->mb[1] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1799 | mcp->mb[2] = MSW(ha->init_cb_dma); |
| 1800 | mcp->mb[3] = LSW(ha->init_cb_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1801 | mcp->mb[6] = MSW(MSD(ha->init_cb_dma)); |
| 1802 | mcp->mb[7] = LSW(MSD(ha->init_cb_dma)); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 1803 | 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] | 1804 | if (ha->ex_init_cb && ha->ex_init_cb->ex_version) { |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 1805 | mcp->mb[1] = BIT_0; |
| 1806 | mcp->mb[10] = MSW(ha->ex_init_cb_dma); |
| 1807 | mcp->mb[11] = LSW(ha->ex_init_cb_dma); |
| 1808 | mcp->mb[12] = MSW(MSD(ha->ex_init_cb_dma)); |
| 1809 | mcp->mb[13] = LSW(MSD(ha->ex_init_cb_dma)); |
| 1810 | mcp->mb[14] = sizeof(*ha->ex_init_cb); |
| 1811 | mcp->out_mb |= MBX_14|MBX_13|MBX_12|MBX_11|MBX_10; |
| 1812 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1813 | /* 1 and 2 should normally be captured. */ |
| 1814 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 1815 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1816 | /* mb3 is additional info about the installed SFP. */ |
| 1817 | mcp->in_mb |= MBX_3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1818 | mcp->buf_size = size; |
| 1819 | mcp->flags = MBX_DMA_OUT; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1820 | mcp->tov = MBX_TOV_SECONDS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1821 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1822 | |
| 1823 | if (rval != QLA_SUCCESS) { |
| 1824 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1825 | ql_dbg(ql_dbg_mbx, vha, 0x104d, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1826 | "Failed=%x mb[0]=%x, mb[1]=%x, mb[2]=%x, mb[3]=%x,.\n", |
| 1827 | 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] | 1828 | } else { |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 1829 | if (IS_QLA27XX(ha)) { |
| 1830 | if (mcp->mb[2] == 6 || mcp->mb[3] == 2) |
| 1831 | ql_dbg(ql_dbg_mbx, vha, 0x119d, |
| 1832 | "Invalid SFP/Validation Failed\n"); |
| 1833 | } |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1834 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104e, |
| 1835 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1836 | } |
| 1837 | |
| 1838 | return rval; |
| 1839 | } |
| 1840 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 1841 | |
| 1842 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1843 | * qla2x00_get_port_database |
| 1844 | * Issue normal/enhanced get port database mailbox command |
| 1845 | * and copy device name as necessary. |
| 1846 | * |
| 1847 | * Input: |
| 1848 | * ha = adapter state pointer. |
| 1849 | * dev = structure pointer. |
| 1850 | * opt = enhanced cmd option byte. |
| 1851 | * |
| 1852 | * Returns: |
| 1853 | * qla2x00 local function return status code. |
| 1854 | * |
| 1855 | * Context: |
| 1856 | * Kernel context. |
| 1857 | */ |
| 1858 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1859 | 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] | 1860 | { |
| 1861 | int rval; |
| 1862 | mbx_cmd_t mc; |
| 1863 | mbx_cmd_t *mcp = &mc; |
| 1864 | port_database_t *pd; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1865 | struct port_database_24xx *pd24; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1866 | dma_addr_t pd_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1867 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1868 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1869 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104f, |
| 1870 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1871 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1872 | pd24 = NULL; |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 1873 | pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1874 | if (pd == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1875 | ql_log(ql_log_warn, vha, 0x1050, |
| 1876 | "Failed to allocate port database structure.\n"); |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 1877 | fcport->query = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1878 | return QLA_MEMORY_ALLOC_FAILED; |
| 1879 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1880 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1881 | mcp->mb[0] = MBC_GET_PORT_DATABASE; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1882 | if (opt != 0 && !IS_FWI2_CAPABLE(ha)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1883 | mcp->mb[0] = MBC_ENHANCED_GET_PORT_DATABASE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1884 | mcp->mb[2] = MSW(pd_dma); |
| 1885 | mcp->mb[3] = LSW(pd_dma); |
| 1886 | mcp->mb[6] = MSW(MSD(pd_dma)); |
| 1887 | mcp->mb[7] = LSW(MSD(pd_dma)); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1888 | mcp->mb[9] = vha->vp_idx; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1889 | 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] | 1890 | mcp->in_mb = MBX_0; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1891 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1892 | mcp->mb[1] = fcport->loop_id; |
| 1893 | mcp->mb[10] = opt; |
| 1894 | mcp->out_mb |= MBX_10|MBX_1; |
| 1895 | mcp->in_mb |= MBX_1; |
| 1896 | } else if (HAS_EXTENDED_IDS(ha)) { |
| 1897 | mcp->mb[1] = fcport->loop_id; |
| 1898 | mcp->mb[10] = opt; |
| 1899 | mcp->out_mb |= MBX_10|MBX_1; |
| 1900 | } else { |
| 1901 | mcp->mb[1] = fcport->loop_id << 8 | opt; |
| 1902 | mcp->out_mb |= MBX_1; |
| 1903 | } |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1904 | mcp->buf_size = IS_FWI2_CAPABLE(ha) ? |
| 1905 | PORT_DATABASE_24XX_SIZE : PORT_DATABASE_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1906 | mcp->flags = MBX_DMA_IN; |
| 1907 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1908 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1909 | if (rval != QLA_SUCCESS) |
| 1910 | goto gpd_error_out; |
| 1911 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1912 | if (IS_FWI2_CAPABLE(ha)) { |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1913 | uint64_t zero = 0; |
Duane Grigsby | c0c462c | 2017-10-13 09:34:05 -0700 | [diff] [blame] | 1914 | u8 current_login_state, last_login_state; |
| 1915 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1916 | pd24 = (struct port_database_24xx *) pd; |
| 1917 | |
| 1918 | /* Check for logged in state. */ |
Duane Grigsby | c0c462c | 2017-10-13 09:34:05 -0700 | [diff] [blame] | 1919 | if (fcport->fc4f_nvme) { |
| 1920 | current_login_state = pd24->current_login_state >> 4; |
| 1921 | last_login_state = pd24->last_login_state >> 4; |
| 1922 | } else { |
| 1923 | current_login_state = pd24->current_login_state & 0xf; |
| 1924 | last_login_state = pd24->last_login_state & 0xf; |
| 1925 | } |
| 1926 | fcport->current_login_state = pd24->current_login_state; |
| 1927 | fcport->last_login_state = pd24->last_login_state; |
| 1928 | |
| 1929 | /* Check for logged in state. */ |
| 1930 | if (current_login_state != PDS_PRLI_COMPLETE && |
| 1931 | last_login_state != PDS_PRLI_COMPLETE) { |
| 1932 | ql_dbg(ql_dbg_mbx, vha, 0x119a, |
| 1933 | "Unable to verify login-state (%x/%x) for loop_id %x.\n", |
| 1934 | current_login_state, last_login_state, |
| 1935 | fcport->loop_id); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1936 | rval = QLA_FUNCTION_FAILED; |
Duane Grigsby | c0c462c | 2017-10-13 09:34:05 -0700 | [diff] [blame] | 1937 | |
| 1938 | if (!fcport->query) |
| 1939 | goto gpd_error_out; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1940 | } |
| 1941 | |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1942 | if (fcport->loop_id == FC_NO_LOOP_ID || |
| 1943 | (memcmp(fcport->port_name, (uint8_t *)&zero, 8) && |
| 1944 | memcmp(fcport->port_name, pd24->port_name, 8))) { |
| 1945 | /* We lost the device mid way. */ |
| 1946 | rval = QLA_NOT_LOGGED_IN; |
| 1947 | goto gpd_error_out; |
| 1948 | } |
| 1949 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1950 | /* Names are little-endian. */ |
| 1951 | memcpy(fcport->node_name, pd24->node_name, WWN_SIZE); |
| 1952 | memcpy(fcport->port_name, pd24->port_name, WWN_SIZE); |
| 1953 | |
| 1954 | /* Get port_id of device. */ |
| 1955 | fcport->d_id.b.domain = pd24->port_id[0]; |
| 1956 | fcport->d_id.b.area = pd24->port_id[1]; |
| 1957 | fcport->d_id.b.al_pa = pd24->port_id[2]; |
| 1958 | fcport->d_id.b.rsvd_1 = 0; |
| 1959 | |
| 1960 | /* If not target must be initiator or unknown type. */ |
| 1961 | if ((pd24->prli_svc_param_word_3[0] & BIT_4) == 0) |
| 1962 | fcport->port_type = FCT_INITIATOR; |
| 1963 | else |
| 1964 | fcport->port_type = FCT_TARGET; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 1965 | |
| 1966 | /* Passback COS information. */ |
| 1967 | fcport->supported_classes = (pd24->flags & PDF_CLASS_2) ? |
| 1968 | FC_COS_CLASS2 : FC_COS_CLASS3; |
| 1969 | |
| 1970 | if (pd24->prli_svc_param_word_3[0] & BIT_7) |
| 1971 | fcport->flags |= FCF_CONF_COMP_SUPPORTED; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1972 | } else { |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1973 | uint64_t zero = 0; |
| 1974 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1975 | /* Check for logged in state. */ |
| 1976 | if (pd->master_state != PD_STATE_PORT_LOGGED_IN && |
| 1977 | pd->slave_state != PD_STATE_PORT_LOGGED_IN) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1978 | ql_dbg(ql_dbg_mbx, vha, 0x100a, |
| 1979 | "Unable to verify login-state (%x/%x) - " |
| 1980 | "portid=%02x%02x%02x.\n", pd->master_state, |
| 1981 | pd->slave_state, fcport->d_id.b.domain, |
| 1982 | fcport->d_id.b.area, fcport->d_id.b.al_pa); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1983 | rval = QLA_FUNCTION_FAILED; |
| 1984 | goto gpd_error_out; |
| 1985 | } |
| 1986 | |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1987 | if (fcport->loop_id == FC_NO_LOOP_ID || |
| 1988 | (memcmp(fcport->port_name, (uint8_t *)&zero, 8) && |
| 1989 | memcmp(fcport->port_name, pd->port_name, 8))) { |
| 1990 | /* We lost the device mid way. */ |
| 1991 | rval = QLA_NOT_LOGGED_IN; |
| 1992 | goto gpd_error_out; |
| 1993 | } |
| 1994 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1995 | /* Names are little-endian. */ |
| 1996 | memcpy(fcport->node_name, pd->node_name, WWN_SIZE); |
| 1997 | memcpy(fcport->port_name, pd->port_name, WWN_SIZE); |
| 1998 | |
| 1999 | /* Get port_id of device. */ |
| 2000 | fcport->d_id.b.domain = pd->port_id[0]; |
| 2001 | fcport->d_id.b.area = pd->port_id[3]; |
| 2002 | fcport->d_id.b.al_pa = pd->port_id[2]; |
| 2003 | fcport->d_id.b.rsvd_1 = 0; |
| 2004 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2005 | /* If not target must be initiator or unknown type. */ |
| 2006 | if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0) |
| 2007 | fcport->port_type = FCT_INITIATOR; |
| 2008 | else |
| 2009 | fcport->port_type = FCT_TARGET; |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 2010 | |
| 2011 | /* Passback COS information. */ |
| 2012 | fcport->supported_classes = (pd->options & BIT_4) ? |
| 2013 | FC_COS_CLASS2: FC_COS_CLASS3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2014 | } |
| 2015 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2016 | gpd_error_out: |
| 2017 | dma_pool_free(ha->s_dma_pool, pd, pd_dma); |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 2018 | fcport->query = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2019 | |
| 2020 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2021 | ql_dbg(ql_dbg_mbx, vha, 0x1052, |
| 2022 | "Failed=%x mb[0]=%x mb[1]=%x.\n", rval, |
| 2023 | mcp->mb[0], mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2024 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2025 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1053, |
| 2026 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2027 | } |
| 2028 | |
| 2029 | return rval; |
| 2030 | } |
| 2031 | |
| 2032 | /* |
| 2033 | * qla2x00_get_firmware_state |
| 2034 | * Get adapter firmware state. |
| 2035 | * |
| 2036 | * Input: |
| 2037 | * ha = adapter block pointer. |
| 2038 | * dptr = pointer for firmware state. |
| 2039 | * TARGET_QUEUE_LOCK must be released. |
| 2040 | * ADAPTER_STATE_LOCK must be released. |
| 2041 | * |
| 2042 | * Returns: |
| 2043 | * qla2x00 local function return status code. |
| 2044 | * |
| 2045 | * Context: |
| 2046 | * Kernel context. |
| 2047 | */ |
| 2048 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2049 | qla2x00_get_firmware_state(scsi_qla_host_t *vha, uint16_t *states) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2050 | { |
| 2051 | int rval; |
| 2052 | mbx_cmd_t mc; |
| 2053 | mbx_cmd_t *mcp = &mc; |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 2054 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2055 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2056 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1054, |
| 2057 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2058 | |
| 2059 | mcp->mb[0] = MBC_GET_FIRMWARE_STATE; |
| 2060 | mcp->out_mb = MBX_0; |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 2061 | if (IS_FWI2_CAPABLE(vha->hw)) |
Joe Carnuccio | b5a340d | 2014-09-25 05:16:48 -0400 | [diff] [blame] | 2062 | 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] | 2063 | else |
| 2064 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2065 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2066 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2067 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2068 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2069 | /* Return firmware states. */ |
| 2070 | states[0] = mcp->mb[1]; |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 2071 | if (IS_FWI2_CAPABLE(vha->hw)) { |
| 2072 | states[1] = mcp->mb[2]; |
Joe Carnuccio | ec89146 | 2016-07-06 11:14:26 -0400 | [diff] [blame] | 2073 | states[2] = mcp->mb[3]; /* SFP info */ |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 2074 | states[3] = mcp->mb[4]; |
| 2075 | states[4] = mcp->mb[5]; |
Joe Carnuccio | b5a340d | 2014-09-25 05:16:48 -0400 | [diff] [blame] | 2076 | states[5] = mcp->mb[6]; /* DPORT status */ |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 2077 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2078 | |
| 2079 | if (rval != QLA_SUCCESS) { |
| 2080 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2081 | ql_dbg(ql_dbg_mbx, vha, 0x1055, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2082 | } else { |
Sawan Chandak | 92d4408 | 2017-08-23 15:05:16 -0700 | [diff] [blame] | 2083 | if (IS_QLA27XX(ha)) { |
| 2084 | if (mcp->mb[2] == 6 || mcp->mb[3] == 2) |
| 2085 | ql_dbg(ql_dbg_mbx, vha, 0x119e, |
| 2086 | "Invalid SFP/Validation Failed\n"); |
| 2087 | } |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2088 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1056, |
| 2089 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2090 | } |
| 2091 | |
| 2092 | return rval; |
| 2093 | } |
| 2094 | |
| 2095 | /* |
| 2096 | * qla2x00_get_port_name |
| 2097 | * Issue get port name mailbox command. |
| 2098 | * Returned name is in big endian format. |
| 2099 | * |
| 2100 | * Input: |
| 2101 | * ha = adapter block pointer. |
| 2102 | * loop_id = loop ID of device. |
| 2103 | * name = pointer for name. |
| 2104 | * TARGET_QUEUE_LOCK must be released. |
| 2105 | * ADAPTER_STATE_LOCK must be released. |
| 2106 | * |
| 2107 | * Returns: |
| 2108 | * qla2x00 local function return status code. |
| 2109 | * |
| 2110 | * Context: |
| 2111 | * Kernel context. |
| 2112 | */ |
| 2113 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2114 | 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] | 2115 | uint8_t opt) |
| 2116 | { |
| 2117 | int rval; |
| 2118 | mbx_cmd_t mc; |
| 2119 | mbx_cmd_t *mcp = &mc; |
| 2120 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2121 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1057, |
| 2122 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2123 | |
| 2124 | mcp->mb[0] = MBC_GET_PORT_NAME; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2125 | mcp->mb[9] = vha->vp_idx; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2126 | mcp->out_mb = MBX_9|MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2127 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2128 | mcp->mb[1] = loop_id; |
| 2129 | mcp->mb[10] = opt; |
| 2130 | mcp->out_mb |= MBX_10; |
| 2131 | } else { |
| 2132 | mcp->mb[1] = loop_id << 8 | opt; |
| 2133 | } |
| 2134 | |
| 2135 | 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] | 2136 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2137 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2138 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2139 | |
| 2140 | if (rval != QLA_SUCCESS) { |
| 2141 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2142 | ql_dbg(ql_dbg_mbx, vha, 0x1058, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2143 | } else { |
| 2144 | if (name != NULL) { |
| 2145 | /* This function returns name in big endian. */ |
Richard Lary | 1196ae0 | 2007-03-22 10:53:19 -0500 | [diff] [blame] | 2146 | name[0] = MSB(mcp->mb[2]); |
| 2147 | name[1] = LSB(mcp->mb[2]); |
| 2148 | name[2] = MSB(mcp->mb[3]); |
| 2149 | name[3] = LSB(mcp->mb[3]); |
| 2150 | name[4] = MSB(mcp->mb[6]); |
| 2151 | name[5] = LSB(mcp->mb[6]); |
| 2152 | name[6] = MSB(mcp->mb[7]); |
| 2153 | name[7] = LSB(mcp->mb[7]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2154 | } |
| 2155 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2156 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1059, |
| 2157 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2158 | } |
| 2159 | |
| 2160 | return rval; |
| 2161 | } |
| 2162 | |
| 2163 | /* |
Joe Carnuccio | 61e1b26 | 2013-02-08 01:57:48 -0500 | [diff] [blame] | 2164 | * qla24xx_link_initialization |
| 2165 | * Issue link initialization mailbox command. |
| 2166 | * |
| 2167 | * Input: |
| 2168 | * ha = adapter block pointer. |
| 2169 | * TARGET_QUEUE_LOCK must be released. |
| 2170 | * ADAPTER_STATE_LOCK must be released. |
| 2171 | * |
| 2172 | * Returns: |
| 2173 | * qla2x00 local function return status code. |
| 2174 | * |
| 2175 | * Context: |
| 2176 | * Kernel context. |
| 2177 | */ |
| 2178 | int |
| 2179 | qla24xx_link_initialize(scsi_qla_host_t *vha) |
| 2180 | { |
| 2181 | int rval; |
| 2182 | mbx_cmd_t mc; |
| 2183 | mbx_cmd_t *mcp = &mc; |
| 2184 | |
| 2185 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1152, |
| 2186 | "Entered %s.\n", __func__); |
| 2187 | |
| 2188 | if (!IS_FWI2_CAPABLE(vha->hw) || IS_CNA_CAPABLE(vha->hw)) |
| 2189 | return QLA_FUNCTION_FAILED; |
| 2190 | |
| 2191 | mcp->mb[0] = MBC_LINK_INITIALIZATION; |
Joe Carnuccio | 5a5c27b | 2013-08-27 01:37:49 -0400 | [diff] [blame] | 2192 | mcp->mb[1] = BIT_4; |
| 2193 | if (vha->hw->operating_mode == LOOP) |
| 2194 | mcp->mb[1] |= BIT_6; |
| 2195 | else |
| 2196 | mcp->mb[1] |= BIT_5; |
Joe Carnuccio | 61e1b26 | 2013-02-08 01:57:48 -0500 | [diff] [blame] | 2197 | mcp->mb[2] = 0; |
| 2198 | mcp->mb[3] = 0; |
| 2199 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 2200 | mcp->in_mb = MBX_0; |
| 2201 | mcp->tov = MBX_TOV_SECONDS; |
| 2202 | mcp->flags = 0; |
| 2203 | rval = qla2x00_mailbox_command(vha, mcp); |
| 2204 | |
| 2205 | if (rval != QLA_SUCCESS) { |
| 2206 | ql_dbg(ql_dbg_mbx, vha, 0x1153, "Failed=%x.\n", rval); |
| 2207 | } else { |
| 2208 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1154, |
| 2209 | "Done %s.\n", __func__); |
| 2210 | } |
| 2211 | |
| 2212 | return rval; |
| 2213 | } |
| 2214 | |
| 2215 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2216 | * qla2x00_lip_reset |
| 2217 | * Issue LIP reset mailbox command. |
| 2218 | * |
| 2219 | * Input: |
| 2220 | * ha = adapter block pointer. |
| 2221 | * TARGET_QUEUE_LOCK must be released. |
| 2222 | * ADAPTER_STATE_LOCK must be released. |
| 2223 | * |
| 2224 | * Returns: |
| 2225 | * qla2x00 local function return status code. |
| 2226 | * |
| 2227 | * Context: |
| 2228 | * Kernel context. |
| 2229 | */ |
| 2230 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2231 | qla2x00_lip_reset(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2232 | { |
| 2233 | int rval; |
| 2234 | mbx_cmd_t mc; |
| 2235 | mbx_cmd_t *mcp = &mc; |
| 2236 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2237 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105a, |
| 2238 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2239 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2240 | if (IS_CNA_CAPABLE(vha->hw)) { |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2241 | /* Logout across all FCFs. */ |
| 2242 | mcp->mb[0] = MBC_LIP_FULL_LOGIN; |
| 2243 | mcp->mb[1] = BIT_1; |
| 2244 | mcp->mb[2] = 0; |
| 2245 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 2246 | } else if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2247 | mcp->mb[0] = MBC_LIP_FULL_LOGIN; |
Quinn Tran | 48acad0 | 2018-08-02 13:16:44 -0700 | [diff] [blame] | 2248 | if (N2N_TOPO(vha->hw)) |
| 2249 | mcp->mb[1] = BIT_4; /* re-init */ |
| 2250 | else |
| 2251 | mcp->mb[1] = BIT_6; /* LIP */ |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 2252 | mcp->mb[2] = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2253 | mcp->mb[3] = vha->hw->loop_reset_delay; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2254 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2255 | } else { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2256 | mcp->mb[0] = MBC_LIP_RESET; |
| 2257 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2258 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2259 | mcp->mb[1] = 0x00ff; |
| 2260 | mcp->mb[10] = 0; |
| 2261 | mcp->out_mb |= MBX_10; |
| 2262 | } else { |
| 2263 | mcp->mb[1] = 0xff00; |
| 2264 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2265 | mcp->mb[2] = vha->hw->loop_reset_delay; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2266 | mcp->mb[3] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2267 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2268 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2269 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2270 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2271 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2272 | |
| 2273 | if (rval != QLA_SUCCESS) { |
| 2274 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2275 | ql_dbg(ql_dbg_mbx, vha, 0x105b, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2276 | } else { |
| 2277 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2278 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105c, |
| 2279 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2280 | } |
| 2281 | |
| 2282 | return rval; |
| 2283 | } |
| 2284 | |
| 2285 | /* |
| 2286 | * qla2x00_send_sns |
| 2287 | * Send SNS command. |
| 2288 | * |
| 2289 | * Input: |
| 2290 | * ha = adapter block pointer. |
| 2291 | * sns = pointer for command. |
| 2292 | * cmd_size = command size. |
| 2293 | * buf_size = response/command size. |
| 2294 | * TARGET_QUEUE_LOCK must be released. |
| 2295 | * ADAPTER_STATE_LOCK must be released. |
| 2296 | * |
| 2297 | * Returns: |
| 2298 | * qla2x00 local function return status code. |
| 2299 | * |
| 2300 | * Context: |
| 2301 | * Kernel context. |
| 2302 | */ |
| 2303 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2304 | 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] | 2305 | uint16_t cmd_size, size_t buf_size) |
| 2306 | { |
| 2307 | int rval; |
| 2308 | mbx_cmd_t mc; |
| 2309 | mbx_cmd_t *mcp = &mc; |
| 2310 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2311 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105d, |
| 2312 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2313 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2314 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105e, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2315 | "Retry cnt=%d ratov=%d total tov=%d.\n", |
| 2316 | vha->hw->retry_count, vha->hw->login_timeout, mcp->tov); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2317 | |
| 2318 | mcp->mb[0] = MBC_SEND_SNS_COMMAND; |
| 2319 | mcp->mb[1] = cmd_size; |
| 2320 | mcp->mb[2] = MSW(sns_phys_address); |
| 2321 | mcp->mb[3] = LSW(sns_phys_address); |
| 2322 | mcp->mb[6] = MSW(MSD(sns_phys_address)); |
| 2323 | mcp->mb[7] = LSW(MSD(sns_phys_address)); |
| 2324 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 2325 | mcp->in_mb = MBX_0|MBX_1; |
| 2326 | mcp->buf_size = buf_size; |
| 2327 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2328 | mcp->tov = (vha->hw->login_timeout * 2) + (vha->hw->login_timeout / 2); |
| 2329 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2330 | |
| 2331 | if (rval != QLA_SUCCESS) { |
| 2332 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2333 | ql_dbg(ql_dbg_mbx, vha, 0x105f, |
| 2334 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 2335 | rval, mcp->mb[0], mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2336 | } else { |
| 2337 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2338 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1060, |
| 2339 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2340 | } |
| 2341 | |
| 2342 | return rval; |
| 2343 | } |
| 2344 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2345 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2346 | 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] | 2347 | uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt) |
| 2348 | { |
| 2349 | int rval; |
| 2350 | |
| 2351 | struct logio_entry_24xx *lg; |
| 2352 | dma_addr_t lg_dma; |
| 2353 | uint32_t iop[2]; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2354 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2355 | struct req_que *req; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2356 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2357 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1061, |
| 2358 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2359 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2360 | if (vha->vp_idx && vha->qpair) |
| 2361 | req = vha->qpair->req; |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2362 | else |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2363 | req = ha->req_q_map[0]; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2364 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 2365 | lg = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2366 | if (lg == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2367 | ql_log(ql_log_warn, vha, 0x1062, |
| 2368 | "Failed to allocate login IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2369 | return QLA_MEMORY_ALLOC_FAILED; |
| 2370 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2371 | |
| 2372 | lg->entry_type = LOGINOUT_PORT_IOCB_TYPE; |
| 2373 | lg->entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2374 | lg->handle = MAKE_HANDLE(req->id, lg->handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2375 | lg->nport_handle = cpu_to_le16(loop_id); |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2376 | lg->control_flags = cpu_to_le16(LCF_COMMAND_PLOGI); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2377 | if (opt & BIT_0) |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2378 | lg->control_flags |= cpu_to_le16(LCF_COND_PLOGI); |
Andrew Vasquez | 8baa51a | 2006-06-23 16:10:44 -0700 | [diff] [blame] | 2379 | if (opt & BIT_1) |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2380 | lg->control_flags |= cpu_to_le16(LCF_SKIP_PRLI); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2381 | lg->port_id[0] = al_pa; |
| 2382 | lg->port_id[1] = area; |
| 2383 | lg->port_id[2] = domain; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2384 | lg->vp_index = vha->vp_idx; |
Andrew Vasquez | 7f45dd0 | 2012-02-09 11:15:45 -0800 | [diff] [blame] | 2385 | rval = qla2x00_issue_iocb_timeout(vha, lg, lg_dma, 0, |
| 2386 | (ha->r_a_tov / 10 * 2) + 2); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2387 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2388 | ql_dbg(ql_dbg_mbx, vha, 0x1063, |
| 2389 | "Failed to issue login IOCB (%x).\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2390 | } else if (lg->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2391 | ql_dbg(ql_dbg_mbx, vha, 0x1064, |
| 2392 | "Failed to complete IOCB -- error status (%x).\n", |
| 2393 | lg->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2394 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2395 | } else if (lg->comp_status != cpu_to_le16(CS_COMPLETE)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2396 | iop[0] = le32_to_cpu(lg->io_parameter[0]); |
| 2397 | iop[1] = le32_to_cpu(lg->io_parameter[1]); |
| 2398 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2399 | ql_dbg(ql_dbg_mbx, vha, 0x1065, |
| 2400 | "Failed to complete IOCB -- completion status (%x) " |
| 2401 | "ioparam=%x/%x.\n", le16_to_cpu(lg->comp_status), |
| 2402 | iop[0], iop[1]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2403 | |
| 2404 | switch (iop[0]) { |
| 2405 | case LSC_SCODE_PORTID_USED: |
| 2406 | mb[0] = MBS_PORT_ID_USED; |
| 2407 | mb[1] = LSW(iop[1]); |
| 2408 | break; |
| 2409 | case LSC_SCODE_NPORT_USED: |
| 2410 | mb[0] = MBS_LOOP_ID_USED; |
| 2411 | break; |
| 2412 | case LSC_SCODE_NOLINK: |
| 2413 | case LSC_SCODE_NOIOCB: |
| 2414 | case LSC_SCODE_NOXCB: |
| 2415 | case LSC_SCODE_CMD_FAILED: |
| 2416 | case LSC_SCODE_NOFABRIC: |
| 2417 | case LSC_SCODE_FW_NOT_READY: |
| 2418 | case LSC_SCODE_NOT_LOGGED_IN: |
| 2419 | case LSC_SCODE_NOPCB: |
| 2420 | case LSC_SCODE_ELS_REJECT: |
| 2421 | case LSC_SCODE_CMD_PARAM_ERR: |
| 2422 | case LSC_SCODE_NONPORT: |
| 2423 | case LSC_SCODE_LOGGED_IN: |
| 2424 | case LSC_SCODE_NOFLOGI_ACC: |
| 2425 | default: |
| 2426 | mb[0] = MBS_COMMAND_ERROR; |
| 2427 | break; |
| 2428 | } |
| 2429 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2430 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1066, |
| 2431 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2432 | |
| 2433 | iop[0] = le32_to_cpu(lg->io_parameter[0]); |
| 2434 | |
| 2435 | mb[0] = MBS_COMMAND_COMPLETE; |
| 2436 | mb[1] = 0; |
| 2437 | if (iop[0] & BIT_4) { |
| 2438 | if (iop[0] & BIT_8) |
| 2439 | mb[1] |= BIT_1; |
| 2440 | } else |
| 2441 | mb[1] = BIT_0; |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 2442 | |
| 2443 | /* Passback COS information. */ |
| 2444 | mb[10] = 0; |
| 2445 | if (lg->io_parameter[7] || lg->io_parameter[8]) |
| 2446 | mb[10] |= BIT_0; /* Class 2. */ |
| 2447 | if (lg->io_parameter[9] || lg->io_parameter[10]) |
| 2448 | mb[10] |= BIT_1; /* Class 3. */ |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2449 | if (lg->io_parameter[0] & cpu_to_le32(BIT_7)) |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2450 | mb[10] |= BIT_7; /* Confirmed Completion |
| 2451 | * Allowed |
| 2452 | */ |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2453 | } |
| 2454 | |
| 2455 | dma_pool_free(ha->s_dma_pool, lg, lg_dma); |
| 2456 | |
| 2457 | return rval; |
| 2458 | } |
| 2459 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2460 | /* |
| 2461 | * qla2x00_login_fabric |
| 2462 | * Issue login fabric port mailbox command. |
| 2463 | * |
| 2464 | * Input: |
| 2465 | * ha = adapter block pointer. |
| 2466 | * loop_id = device loop ID. |
| 2467 | * domain = device domain. |
| 2468 | * area = device area. |
| 2469 | * al_pa = device AL_PA. |
| 2470 | * status = pointer for return status. |
| 2471 | * opt = command options. |
| 2472 | * TARGET_QUEUE_LOCK must be released. |
| 2473 | * ADAPTER_STATE_LOCK must be released. |
| 2474 | * |
| 2475 | * Returns: |
| 2476 | * qla2x00 local function return status code. |
| 2477 | * |
| 2478 | * Context: |
| 2479 | * Kernel context. |
| 2480 | */ |
| 2481 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2482 | 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] | 2483 | uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt) |
| 2484 | { |
| 2485 | int rval; |
| 2486 | mbx_cmd_t mc; |
| 2487 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2488 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2489 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2490 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1067, |
| 2491 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2492 | |
| 2493 | mcp->mb[0] = MBC_LOGIN_FABRIC_PORT; |
| 2494 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 2495 | if (HAS_EXTENDED_IDS(ha)) { |
| 2496 | mcp->mb[1] = loop_id; |
| 2497 | mcp->mb[10] = opt; |
| 2498 | mcp->out_mb |= MBX_10; |
| 2499 | } else { |
| 2500 | mcp->mb[1] = (loop_id << 8) | opt; |
| 2501 | } |
| 2502 | mcp->mb[2] = domain; |
| 2503 | mcp->mb[3] = area << 8 | al_pa; |
| 2504 | |
| 2505 | mcp->in_mb = MBX_7|MBX_6|MBX_2|MBX_1|MBX_0; |
| 2506 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
| 2507 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2508 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2509 | |
| 2510 | /* Return mailbox statuses. */ |
| 2511 | if (mb != NULL) { |
| 2512 | mb[0] = mcp->mb[0]; |
| 2513 | mb[1] = mcp->mb[1]; |
| 2514 | mb[2] = mcp->mb[2]; |
| 2515 | mb[6] = mcp->mb[6]; |
| 2516 | mb[7] = mcp->mb[7]; |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 2517 | /* COS retrieved from Get-Port-Database mailbox command. */ |
| 2518 | mb[10] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2519 | } |
| 2520 | |
| 2521 | if (rval != QLA_SUCCESS) { |
| 2522 | /* RLU tmp code: need to change main mailbox_command function to |
| 2523 | * return ok even when the mailbox completion value is not |
| 2524 | * SUCCESS. The caller needs to be responsible to interpret |
| 2525 | * the return values of this mailbox command if we're not |
| 2526 | * to change too much of the existing code. |
| 2527 | */ |
| 2528 | if (mcp->mb[0] == 0x4001 || mcp->mb[0] == 0x4002 || |
| 2529 | mcp->mb[0] == 0x4003 || mcp->mb[0] == 0x4005 || |
| 2530 | mcp->mb[0] == 0x4006) |
| 2531 | rval = QLA_SUCCESS; |
| 2532 | |
| 2533 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2534 | ql_dbg(ql_dbg_mbx, vha, 0x1068, |
| 2535 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 2536 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2537 | } else { |
| 2538 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2539 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1069, |
| 2540 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2541 | } |
| 2542 | |
| 2543 | return rval; |
| 2544 | } |
| 2545 | |
| 2546 | /* |
| 2547 | * qla2x00_login_local_device |
| 2548 | * Issue login loop port mailbox command. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2549 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2550 | * Input: |
| 2551 | * ha = adapter block pointer. |
| 2552 | * loop_id = device loop ID. |
| 2553 | * opt = command options. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2554 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2555 | * Returns: |
| 2556 | * Return status code. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2557 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2558 | * Context: |
| 2559 | * Kernel context. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2560 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2561 | */ |
| 2562 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2563 | 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] | 2564 | uint16_t *mb_ret, uint8_t opt) |
| 2565 | { |
| 2566 | int rval; |
| 2567 | mbx_cmd_t mc; |
| 2568 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2569 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2570 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2571 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106a, |
| 2572 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2573 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2574 | if (IS_FWI2_CAPABLE(ha)) |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2575 | return qla24xx_login_fabric(vha, fcport->loop_id, |
andrew.vasquez@qlogic.com | 9a52a57c | 2006-03-09 14:27:44 -0800 | [diff] [blame] | 2576 | fcport->d_id.b.domain, fcport->d_id.b.area, |
| 2577 | fcport->d_id.b.al_pa, mb_ret, opt); |
| 2578 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2579 | mcp->mb[0] = MBC_LOGIN_LOOP_PORT; |
| 2580 | if (HAS_EXTENDED_IDS(ha)) |
andrew.vasquez@qlogic.com | 9a52a57c | 2006-03-09 14:27:44 -0800 | [diff] [blame] | 2581 | mcp->mb[1] = fcport->loop_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2582 | else |
andrew.vasquez@qlogic.com | 9a52a57c | 2006-03-09 14:27:44 -0800 | [diff] [blame] | 2583 | mcp->mb[1] = fcport->loop_id << 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2584 | mcp->mb[2] = opt; |
| 2585 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 2586 | mcp->in_mb = MBX_7|MBX_6|MBX_1|MBX_0; |
| 2587 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
| 2588 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2589 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2590 | |
| 2591 | /* Return mailbox statuses. */ |
| 2592 | if (mb_ret != NULL) { |
| 2593 | mb_ret[0] = mcp->mb[0]; |
| 2594 | mb_ret[1] = mcp->mb[1]; |
| 2595 | mb_ret[6] = mcp->mb[6]; |
| 2596 | mb_ret[7] = mcp->mb[7]; |
| 2597 | } |
| 2598 | |
| 2599 | if (rval != QLA_SUCCESS) { |
| 2600 | /* AV tmp code: need to change main mailbox_command function to |
| 2601 | * return ok even when the mailbox completion value is not |
| 2602 | * SUCCESS. The caller needs to be responsible to interpret |
| 2603 | * the return values of this mailbox command if we're not |
| 2604 | * to change too much of the existing code. |
| 2605 | */ |
| 2606 | if (mcp->mb[0] == 0x4005 || mcp->mb[0] == 0x4006) |
| 2607 | rval = QLA_SUCCESS; |
| 2608 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2609 | ql_dbg(ql_dbg_mbx, vha, 0x106b, |
| 2610 | "Failed=%x mb[0]=%x mb[1]=%x mb[6]=%x mb[7]=%x.\n", |
| 2611 | 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] | 2612 | } else { |
| 2613 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2614 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106c, |
| 2615 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2616 | } |
| 2617 | |
| 2618 | return (rval); |
| 2619 | } |
| 2620 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2621 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2622 | 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] | 2623 | uint8_t area, uint8_t al_pa) |
| 2624 | { |
| 2625 | int rval; |
| 2626 | struct logio_entry_24xx *lg; |
| 2627 | dma_addr_t lg_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2628 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2629 | struct req_que *req; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2630 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2631 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106d, |
| 2632 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2633 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 2634 | lg = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2635 | if (lg == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2636 | ql_log(ql_log_warn, vha, 0x106e, |
| 2637 | "Failed to allocate logout IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2638 | return QLA_MEMORY_ALLOC_FAILED; |
| 2639 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2640 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2641 | req = vha->req; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2642 | lg->entry_type = LOGINOUT_PORT_IOCB_TYPE; |
| 2643 | lg->entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2644 | lg->handle = MAKE_HANDLE(req->id, lg->handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2645 | lg->nport_handle = cpu_to_le16(loop_id); |
| 2646 | lg->control_flags = |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2647 | cpu_to_le16(LCF_COMMAND_LOGO|LCF_IMPL_LOGO| |
Andrew Vasquez | c8d6691 | 2011-03-30 11:46:21 -0700 | [diff] [blame] | 2648 | LCF_FREE_NPORT); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2649 | lg->port_id[0] = al_pa; |
| 2650 | lg->port_id[1] = area; |
| 2651 | lg->port_id[2] = domain; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2652 | lg->vp_index = vha->vp_idx; |
Andrew Vasquez | 7f45dd0 | 2012-02-09 11:15:45 -0800 | [diff] [blame] | 2653 | rval = qla2x00_issue_iocb_timeout(vha, lg, lg_dma, 0, |
| 2654 | (ha->r_a_tov / 10 * 2) + 2); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2655 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2656 | ql_dbg(ql_dbg_mbx, vha, 0x106f, |
| 2657 | "Failed to issue logout IOCB (%x).\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2658 | } else if (lg->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2659 | ql_dbg(ql_dbg_mbx, vha, 0x1070, |
| 2660 | "Failed to complete IOCB -- error status (%x).\n", |
| 2661 | lg->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2662 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2663 | } else if (lg->comp_status != cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2664 | ql_dbg(ql_dbg_mbx, vha, 0x1071, |
| 2665 | "Failed to complete IOCB -- completion status (%x) " |
| 2666 | "ioparam=%x/%x.\n", le16_to_cpu(lg->comp_status), |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2667 | le32_to_cpu(lg->io_parameter[0]), |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2668 | le32_to_cpu(lg->io_parameter[1])); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2669 | } else { |
| 2670 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2671 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1072, |
| 2672 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2673 | } |
| 2674 | |
| 2675 | dma_pool_free(ha->s_dma_pool, lg, lg_dma); |
| 2676 | |
| 2677 | return rval; |
| 2678 | } |
| 2679 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2680 | /* |
| 2681 | * qla2x00_fabric_logout |
| 2682 | * Issue logout fabric port mailbox command. |
| 2683 | * |
| 2684 | * Input: |
| 2685 | * ha = adapter block pointer. |
| 2686 | * loop_id = device loop ID. |
| 2687 | * TARGET_QUEUE_LOCK must be released. |
| 2688 | * ADAPTER_STATE_LOCK must be released. |
| 2689 | * |
| 2690 | * Returns: |
| 2691 | * qla2x00 local function return status code. |
| 2692 | * |
| 2693 | * Context: |
| 2694 | * Kernel context. |
| 2695 | */ |
| 2696 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2697 | 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] | 2698 | uint8_t area, uint8_t al_pa) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2699 | { |
| 2700 | int rval; |
| 2701 | mbx_cmd_t mc; |
| 2702 | mbx_cmd_t *mcp = &mc; |
| 2703 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2704 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1073, |
| 2705 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2706 | |
| 2707 | mcp->mb[0] = MBC_LOGOUT_FABRIC_PORT; |
| 2708 | mcp->out_mb = MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2709 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2710 | mcp->mb[1] = loop_id; |
| 2711 | mcp->mb[10] = 0; |
| 2712 | mcp->out_mb |= MBX_10; |
| 2713 | } else { |
| 2714 | mcp->mb[1] = loop_id << 8; |
| 2715 | } |
| 2716 | |
| 2717 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2718 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2719 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2720 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2721 | |
| 2722 | if (rval != QLA_SUCCESS) { |
| 2723 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2724 | ql_dbg(ql_dbg_mbx, vha, 0x1074, |
| 2725 | "Failed=%x mb[1]=%x.\n", rval, mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2726 | } else { |
| 2727 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2728 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1075, |
| 2729 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2730 | } |
| 2731 | |
| 2732 | return rval; |
| 2733 | } |
| 2734 | |
| 2735 | /* |
| 2736 | * qla2x00_full_login_lip |
| 2737 | * Issue full login LIP mailbox command. |
| 2738 | * |
| 2739 | * Input: |
| 2740 | * ha = adapter block pointer. |
| 2741 | * TARGET_QUEUE_LOCK must be released. |
| 2742 | * ADAPTER_STATE_LOCK must be released. |
| 2743 | * |
| 2744 | * Returns: |
| 2745 | * qla2x00 local function return status code. |
| 2746 | * |
| 2747 | * Context: |
| 2748 | * Kernel context. |
| 2749 | */ |
| 2750 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2751 | qla2x00_full_login_lip(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2752 | { |
| 2753 | int rval; |
| 2754 | mbx_cmd_t mc; |
| 2755 | mbx_cmd_t *mcp = &mc; |
| 2756 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2757 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1076, |
| 2758 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2759 | |
| 2760 | mcp->mb[0] = MBC_LIP_FULL_LOGIN; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2761 | mcp->mb[1] = IS_FWI2_CAPABLE(vha->hw) ? BIT_3 : 0; |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 2762 | mcp->mb[2] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2763 | mcp->mb[3] = 0; |
| 2764 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 2765 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2766 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2767 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2768 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2769 | |
| 2770 | if (rval != QLA_SUCCESS) { |
| 2771 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2772 | ql_dbg(ql_dbg_mbx, vha, 0x1077, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2773 | } else { |
| 2774 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2775 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1078, |
| 2776 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2777 | } |
| 2778 | |
| 2779 | return rval; |
| 2780 | } |
| 2781 | |
| 2782 | /* |
| 2783 | * qla2x00_get_id_list |
| 2784 | * |
| 2785 | * Input: |
| 2786 | * ha = adapter block pointer. |
| 2787 | * |
| 2788 | * Returns: |
| 2789 | * qla2x00 local function return status code. |
| 2790 | * |
| 2791 | * Context: |
| 2792 | * Kernel context. |
| 2793 | */ |
| 2794 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2795 | 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] | 2796 | uint16_t *entries) |
| 2797 | { |
| 2798 | int rval; |
| 2799 | mbx_cmd_t mc; |
| 2800 | mbx_cmd_t *mcp = &mc; |
| 2801 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2802 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1079, |
| 2803 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2804 | |
| 2805 | if (id_list == NULL) |
| 2806 | return QLA_FUNCTION_FAILED; |
| 2807 | |
| 2808 | mcp->mb[0] = MBC_GET_ID_LIST; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2809 | mcp->out_mb = MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2810 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2811 | mcp->mb[2] = MSW(id_list_dma); |
| 2812 | mcp->mb[3] = LSW(id_list_dma); |
| 2813 | mcp->mb[6] = MSW(MSD(id_list_dma)); |
| 2814 | mcp->mb[7] = LSW(MSD(id_list_dma)); |
andrew.vasquez@qlogic.com | 247ec45 | 2006-02-07 08:45:40 -0800 | [diff] [blame] | 2815 | mcp->mb[8] = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2816 | mcp->mb[9] = vha->vp_idx; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2817 | 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] | 2818 | } else { |
| 2819 | mcp->mb[1] = MSW(id_list_dma); |
| 2820 | mcp->mb[2] = LSW(id_list_dma); |
| 2821 | mcp->mb[3] = MSW(MSD(id_list_dma)); |
| 2822 | mcp->mb[6] = LSW(MSD(id_list_dma)); |
| 2823 | mcp->out_mb |= MBX_6|MBX_3|MBX_2|MBX_1; |
| 2824 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2825 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2826 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2827 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2828 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2829 | |
| 2830 | if (rval != QLA_SUCCESS) { |
| 2831 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2832 | ql_dbg(ql_dbg_mbx, vha, 0x107a, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2833 | } else { |
| 2834 | *entries = mcp->mb[1]; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2835 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107b, |
| 2836 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2837 | } |
| 2838 | |
| 2839 | return rval; |
| 2840 | } |
| 2841 | |
| 2842 | /* |
| 2843 | * qla2x00_get_resource_cnts |
| 2844 | * Get current firmware resource counts. |
| 2845 | * |
| 2846 | * Input: |
| 2847 | * ha = adapter block pointer. |
| 2848 | * |
| 2849 | * Returns: |
| 2850 | * qla2x00 local function return status code. |
| 2851 | * |
| 2852 | * Context: |
| 2853 | * Kernel context. |
| 2854 | */ |
| 2855 | int |
Quinn Tran | 03e8c68 | 2015-12-17 14:56:59 -0500 | [diff] [blame] | 2856 | qla2x00_get_resource_cnts(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2857 | { |
Quinn Tran | 03e8c68 | 2015-12-17 14:56:59 -0500 | [diff] [blame] | 2858 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2859 | int rval; |
| 2860 | mbx_cmd_t mc; |
| 2861 | mbx_cmd_t *mcp = &mc; |
| 2862 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2863 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107c, |
| 2864 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2865 | |
| 2866 | mcp->mb[0] = MBC_GET_RESOURCE_COUNTS; |
| 2867 | mcp->out_mb = MBX_0; |
Seokmann Ju | 4d0ea24 | 2007-09-20 14:07:43 -0700 | [diff] [blame] | 2868 | 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] | 2869 | 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] | 2870 | mcp->in_mb |= MBX_12; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2871 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2872 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2873 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2874 | |
| 2875 | if (rval != QLA_SUCCESS) { |
| 2876 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2877 | ql_dbg(ql_dbg_mbx, vha, 0x107d, |
| 2878 | "Failed mb[0]=%x.\n", mcp->mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2879 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2880 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107e, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2881 | "Done %s mb1=%x mb2=%x mb3=%x mb6=%x mb7=%x mb10=%x " |
| 2882 | "mb11=%x mb12=%x.\n", __func__, mcp->mb[1], mcp->mb[2], |
| 2883 | mcp->mb[3], mcp->mb[6], mcp->mb[7], mcp->mb[10], |
| 2884 | mcp->mb[11], mcp->mb[12]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2885 | |
Quinn Tran | 03e8c68 | 2015-12-17 14:56:59 -0500 | [diff] [blame] | 2886 | ha->orig_fw_tgt_xcb_count = mcp->mb[1]; |
| 2887 | ha->cur_fw_tgt_xcb_count = mcp->mb[2]; |
| 2888 | ha->cur_fw_xcb_count = mcp->mb[3]; |
| 2889 | ha->orig_fw_xcb_count = mcp->mb[6]; |
| 2890 | ha->cur_fw_iocb_count = mcp->mb[7]; |
| 2891 | ha->orig_fw_iocb_count = mcp->mb[10]; |
| 2892 | if (ha->flags.npiv_supported) |
| 2893 | ha->max_npiv_vports = mcp->mb[11]; |
| 2894 | if (IS_QLA81XX(ha) || IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
| 2895 | ha->fw_max_fcf_count = mcp->mb[12]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2896 | } |
| 2897 | |
| 2898 | return (rval); |
| 2899 | } |
| 2900 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2901 | /* |
| 2902 | * qla2x00_get_fcal_position_map |
| 2903 | * Get FCAL (LILP) position map using mailbox command |
| 2904 | * |
| 2905 | * Input: |
| 2906 | * ha = adapter state pointer. |
| 2907 | * pos_map = buffer pointer (can be NULL). |
| 2908 | * |
| 2909 | * Returns: |
| 2910 | * qla2x00 local function return status code. |
| 2911 | * |
| 2912 | * Context: |
| 2913 | * Kernel context. |
| 2914 | */ |
| 2915 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2916 | 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] | 2917 | { |
| 2918 | int rval; |
| 2919 | mbx_cmd_t mc; |
| 2920 | mbx_cmd_t *mcp = &mc; |
| 2921 | char *pmap; |
| 2922 | dma_addr_t pmap_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2923 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2924 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2925 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107f, |
| 2926 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2927 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 2928 | pmap = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pmap_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2929 | if (pmap == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2930 | ql_log(ql_log_warn, vha, 0x1080, |
| 2931 | "Memory alloc failed.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2932 | return QLA_MEMORY_ALLOC_FAILED; |
| 2933 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2934 | |
| 2935 | mcp->mb[0] = MBC_GET_FC_AL_POSITION_MAP; |
| 2936 | mcp->mb[2] = MSW(pmap_dma); |
| 2937 | mcp->mb[3] = LSW(pmap_dma); |
| 2938 | mcp->mb[6] = MSW(MSD(pmap_dma)); |
| 2939 | mcp->mb[7] = LSW(MSD(pmap_dma)); |
| 2940 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; |
| 2941 | mcp->in_mb = MBX_1|MBX_0; |
| 2942 | mcp->buf_size = FCAL_MAP_SIZE; |
| 2943 | mcp->flags = MBX_DMA_IN; |
| 2944 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2945 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2946 | |
| 2947 | if (rval == QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2948 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1081, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2949 | "mb0/mb1=%x/%X FC/AL position map size (%x).\n", |
| 2950 | mcp->mb[0], mcp->mb[1], (unsigned)pmap[0]); |
| 2951 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111d, |
| 2952 | pmap, pmap[0] + 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2953 | |
| 2954 | if (pos_map) |
| 2955 | memcpy(pos_map, pmap, FCAL_MAP_SIZE); |
| 2956 | } |
| 2957 | dma_pool_free(ha->s_dma_pool, pmap, pmap_dma); |
| 2958 | |
| 2959 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2960 | ql_dbg(ql_dbg_mbx, vha, 0x1082, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2961 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2962 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1083, |
| 2963 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2964 | } |
| 2965 | |
| 2966 | return rval; |
| 2967 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2968 | |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2969 | /* |
| 2970 | * qla2x00_get_link_status |
| 2971 | * |
| 2972 | * Input: |
| 2973 | * ha = adapter block pointer. |
| 2974 | * loop_id = device loop ID. |
| 2975 | * ret_buf = pointer to link status return buffer. |
| 2976 | * |
| 2977 | * Returns: |
| 2978 | * 0 = success. |
| 2979 | * BIT_0 = mem alloc error. |
| 2980 | * BIT_1 = mailbox error. |
| 2981 | */ |
| 2982 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2983 | 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] | 2984 | struct link_statistics *stats, dma_addr_t stats_dma) |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2985 | { |
| 2986 | int rval; |
| 2987 | mbx_cmd_t mc; |
| 2988 | mbx_cmd_t *mcp = &mc; |
Joe Carnuccio | c6dc990 | 2016-07-06 11:14:24 -0400 | [diff] [blame] | 2989 | uint32_t *iter = (void *)stats; |
| 2990 | ushort dwords = offsetof(typeof(*stats), link_up_cnt)/sizeof(*iter); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2991 | struct qla_hw_data *ha = vha->hw; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2992 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2993 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1084, |
| 2994 | "Entered %s.\n", __func__); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2995 | |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2996 | mcp->mb[0] = MBC_GET_LINK_STATUS; |
Joe Carnuccio | c6dc990 | 2016-07-06 11:14:24 -0400 | [diff] [blame] | 2997 | mcp->mb[2] = MSW(LSD(stats_dma)); |
| 2998 | mcp->mb[3] = LSW(LSD(stats_dma)); |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2999 | mcp->mb[6] = MSW(MSD(stats_dma)); |
| 3000 | mcp->mb[7] = LSW(MSD(stats_dma)); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 3001 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; |
| 3002 | mcp->in_mb = MBX_0; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 3003 | if (IS_FWI2_CAPABLE(ha)) { |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 3004 | mcp->mb[1] = loop_id; |
| 3005 | mcp->mb[4] = 0; |
| 3006 | mcp->mb[10] = 0; |
| 3007 | mcp->out_mb |= MBX_10|MBX_4|MBX_1; |
| 3008 | mcp->in_mb |= MBX_1; |
| 3009 | } else if (HAS_EXTENDED_IDS(ha)) { |
| 3010 | mcp->mb[1] = loop_id; |
| 3011 | mcp->mb[10] = 0; |
| 3012 | mcp->out_mb |= MBX_10|MBX_1; |
| 3013 | } else { |
| 3014 | mcp->mb[1] = loop_id << 8; |
| 3015 | mcp->out_mb |= MBX_1; |
| 3016 | } |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3017 | mcp->tov = MBX_TOV_SECONDS; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 3018 | mcp->flags = IOCTL_CMD; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3019 | rval = qla2x00_mailbox_command(vha, mcp); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 3020 | |
| 3021 | if (rval == QLA_SUCCESS) { |
| 3022 | if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3023 | ql_dbg(ql_dbg_mbx, vha, 0x1085, |
| 3024 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 3025 | rval = QLA_FUNCTION_FAILED; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 3026 | } else { |
Joe Carnuccio | c6dc990 | 2016-07-06 11:14:24 -0400 | [diff] [blame] | 3027 | /* Re-endianize - firmware data is le32. */ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3028 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1086, |
| 3029 | "Done %s.\n", __func__); |
Joe Carnuccio | da08ef5 | 2016-01-27 12:03:34 -0500 | [diff] [blame] | 3030 | for ( ; dwords--; iter++) |
| 3031 | le32_to_cpus(iter); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 3032 | } |
| 3033 | } else { |
| 3034 | /* Failed. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3035 | 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] | 3036 | } |
| 3037 | |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 3038 | return rval; |
| 3039 | } |
| 3040 | |
| 3041 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3042 | 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] | 3043 | dma_addr_t stats_dma, uint16_t options) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3044 | { |
| 3045 | int rval; |
| 3046 | mbx_cmd_t mc; |
| 3047 | mbx_cmd_t *mcp = &mc; |
Joe Carnuccio | da08ef5 | 2016-01-27 12:03:34 -0500 | [diff] [blame] | 3048 | uint32_t *iter, dwords; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3049 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3050 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1088, |
| 3051 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3052 | |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 3053 | memset(&mc, 0, sizeof(mc)); |
| 3054 | mc.mb[0] = MBC_GET_LINK_PRIV_STATS; |
| 3055 | mc.mb[2] = MSW(stats_dma); |
| 3056 | mc.mb[3] = LSW(stats_dma); |
| 3057 | mc.mb[6] = MSW(MSD(stats_dma)); |
| 3058 | mc.mb[7] = LSW(MSD(stats_dma)); |
| 3059 | mc.mb[8] = sizeof(struct link_statistics) / 4; |
| 3060 | mc.mb[9] = cpu_to_le16(vha->vp_idx); |
| 3061 | mc.mb[10] = cpu_to_le16(options); |
| 3062 | |
| 3063 | rval = qla24xx_send_mb_cmd(vha, &mc); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3064 | |
| 3065 | if (rval == QLA_SUCCESS) { |
| 3066 | if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3067 | ql_dbg(ql_dbg_mbx, vha, 0x1089, |
| 3068 | "Failed mb[0]=%x.\n", mcp->mb[0]); |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 3069 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3070 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3071 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x108a, |
| 3072 | "Done %s.\n", __func__); |
Joe Carnuccio | c6dc990 | 2016-07-06 11:14:24 -0400 | [diff] [blame] | 3073 | /* Re-endianize - firmware data is le32. */ |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 3074 | dwords = sizeof(struct link_statistics) / 4; |
Joe Carnuccio | da08ef5 | 2016-01-27 12:03:34 -0500 | [diff] [blame] | 3075 | iter = &stats->link_fail_cnt; |
| 3076 | for ( ; dwords--; iter++) |
| 3077 | le32_to_cpus(iter); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3078 | } |
| 3079 | } else { |
| 3080 | /* Failed. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3081 | ql_dbg(ql_dbg_mbx, vha, 0x108b, "Failed=%x.\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3082 | } |
| 3083 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3084 | return rval; |
| 3085 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3086 | |
| 3087 | int |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3088 | qla24xx_abort_command(srb_t *sp) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3089 | { |
| 3090 | int rval; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3091 | unsigned long flags = 0; |
| 3092 | |
| 3093 | struct abort_entry_24xx *abt; |
| 3094 | dma_addr_t abt_dma; |
| 3095 | uint32_t handle; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3096 | fc_port_t *fcport = sp->fcport; |
| 3097 | struct scsi_qla_host *vha = fcport->vha; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3098 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 3099 | struct req_que *req = vha->req; |
Quinn Tran | 585def9 | 2018-09-04 14:19:20 -0700 | [diff] [blame^] | 3100 | struct qla_qpair *qpair = sp->qpair; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3101 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3102 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x108c, |
| 3103 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3104 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3105 | if (vha->flags.qpairs_available && sp->qpair) |
| 3106 | req = sp->qpair->req; |
Quinn Tran | 585def9 | 2018-09-04 14:19:20 -0700 | [diff] [blame^] | 3107 | else |
| 3108 | return QLA_FUNCTION_FAILED; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3109 | |
Armen Baloyan | 4440e46 | 2014-02-26 04:15:18 -0500 | [diff] [blame] | 3110 | if (ql2xasynctmfenable) |
| 3111 | return qla24xx_async_abort_command(sp); |
| 3112 | |
Quinn Tran | 585def9 | 2018-09-04 14:19:20 -0700 | [diff] [blame^] | 3113 | spin_lock_irqsave(qpair->qp_lock_ptr, flags); |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 3114 | for (handle = 1; handle < req->num_outstanding_cmds; handle++) { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3115 | if (req->outstanding_cmds[handle] == sp) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3116 | break; |
| 3117 | } |
Quinn Tran | 585def9 | 2018-09-04 14:19:20 -0700 | [diff] [blame^] | 3118 | spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 3119 | if (handle == req->num_outstanding_cmds) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3120 | /* Command not found. */ |
| 3121 | return QLA_FUNCTION_FAILED; |
| 3122 | } |
| 3123 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 3124 | abt = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &abt_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3125 | if (abt == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3126 | ql_log(ql_log_warn, vha, 0x108d, |
| 3127 | "Failed to allocate abort IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3128 | return QLA_MEMORY_ALLOC_FAILED; |
| 3129 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3130 | |
| 3131 | abt->entry_type = ABORT_IOCB_TYPE; |
| 3132 | abt->entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3133 | abt->handle = MAKE_HANDLE(req->id, abt->handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3134 | abt->nport_handle = cpu_to_le16(fcport->loop_id); |
Mike Hernandez | a74ec14 | 2011-03-30 11:46:20 -0700 | [diff] [blame] | 3135 | abt->handle_to_abort = MAKE_HANDLE(req->id, handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3136 | abt->port_id[0] = fcport->d_id.b.al_pa; |
| 3137 | abt->port_id[1] = fcport->d_id.b.area; |
| 3138 | abt->port_id[2] = fcport->d_id.b.domain; |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3139 | abt->vp_index = fcport->vha->vp_idx; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3140 | |
| 3141 | abt->req_que_no = cpu_to_le16(req->id); |
| 3142 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3143 | rval = qla2x00_issue_iocb(vha, abt, abt_dma, 0); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3144 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3145 | ql_dbg(ql_dbg_mbx, vha, 0x108e, |
| 3146 | "Failed to issue IOCB (%x).\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3147 | } else if (abt->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3148 | ql_dbg(ql_dbg_mbx, vha, 0x108f, |
| 3149 | "Failed to complete IOCB -- error status (%x).\n", |
| 3150 | abt->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3151 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 3152 | } else if (abt->nport_handle != cpu_to_le16(0)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3153 | ql_dbg(ql_dbg_mbx, vha, 0x1090, |
| 3154 | "Failed to complete IOCB -- completion status (%x).\n", |
| 3155 | le16_to_cpu(abt->nport_handle)); |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 3156 | if (abt->nport_handle == CS_IOCB_ERROR) |
| 3157 | rval = QLA_FUNCTION_PARAMETER_ERROR; |
| 3158 | else |
| 3159 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3160 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3161 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1091, |
| 3162 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3163 | } |
| 3164 | |
| 3165 | dma_pool_free(ha->s_dma_pool, abt, abt_dma); |
| 3166 | |
| 3167 | return rval; |
| 3168 | } |
| 3169 | |
| 3170 | struct tsk_mgmt_cmd { |
| 3171 | union { |
| 3172 | struct tsk_mgmt_entry tsk; |
| 3173 | struct sts_entry_24xx sts; |
| 3174 | } p; |
| 3175 | }; |
| 3176 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3177 | static int |
| 3178 | __qla24xx_issue_tmf(char *name, uint32_t type, struct fc_port *fcport, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 3179 | uint64_t l, int tag) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3180 | { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3181 | int rval, rval2; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3182 | struct tsk_mgmt_cmd *tsk; |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 3183 | struct sts_entry_24xx *sts; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3184 | dma_addr_t tsk_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3185 | scsi_qla_host_t *vha; |
| 3186 | struct qla_hw_data *ha; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3187 | struct req_que *req; |
| 3188 | struct rsp_que *rsp; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3189 | struct qla_qpair *qpair; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3190 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3191 | vha = fcport->vha; |
| 3192 | ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3193 | req = vha->req; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3194 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3195 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1092, |
| 3196 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3197 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3198 | if (vha->vp_idx && vha->qpair) { |
| 3199 | /* NPIV port */ |
| 3200 | qpair = vha->qpair; |
| 3201 | rsp = qpair->rsp; |
| 3202 | req = qpair->req; |
| 3203 | } else { |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 3204 | rsp = req->rsp; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3205 | } |
| 3206 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 3207 | tsk = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &tsk_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3208 | if (tsk == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3209 | ql_log(ql_log_warn, vha, 0x1093, |
| 3210 | "Failed to allocate task management IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3211 | return QLA_MEMORY_ALLOC_FAILED; |
| 3212 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3213 | |
| 3214 | tsk->p.tsk.entry_type = TSK_MGMT_IOCB_TYPE; |
| 3215 | tsk->p.tsk.entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3216 | tsk->p.tsk.handle = MAKE_HANDLE(req->id, tsk->p.tsk.handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3217 | tsk->p.tsk.nport_handle = cpu_to_le16(fcport->loop_id); |
Andrew Vasquez | 00a537b | 2008-02-28 14:06:11 -0800 | [diff] [blame] | 3218 | 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] | 3219 | tsk->p.tsk.control_flags = cpu_to_le32(type); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3220 | tsk->p.tsk.port_id[0] = fcport->d_id.b.al_pa; |
| 3221 | tsk->p.tsk.port_id[1] = fcport->d_id.b.area; |
| 3222 | tsk->p.tsk.port_id[2] = fcport->d_id.b.domain; |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3223 | tsk->p.tsk.vp_index = fcport->vha->vp_idx; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3224 | if (type == TCF_LUN_RESET) { |
| 3225 | int_to_scsilun(l, &tsk->p.tsk.lun); |
| 3226 | host_to_fcp_swap((uint8_t *)&tsk->p.tsk.lun, |
| 3227 | sizeof(tsk->p.tsk.lun)); |
| 3228 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3229 | |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 3230 | sts = &tsk->p.sts; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3231 | rval = qla2x00_issue_iocb(vha, tsk, tsk_dma, 0); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3232 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3233 | ql_dbg(ql_dbg_mbx, vha, 0x1094, |
| 3234 | "Failed to issue %s reset IOCB (%x).\n", name, rval); |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 3235 | } else if (sts->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3236 | ql_dbg(ql_dbg_mbx, vha, 0x1095, |
| 3237 | "Failed to complete IOCB -- error status (%x).\n", |
| 3238 | sts->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3239 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 3240 | } else if (sts->comp_status != cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3241 | ql_dbg(ql_dbg_mbx, vha, 0x1096, |
| 3242 | "Failed to complete IOCB -- completion status (%x).\n", |
| 3243 | le16_to_cpu(sts->comp_status)); |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 3244 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 97dec56 | 2011-02-23 15:27:14 -0800 | [diff] [blame] | 3245 | } else if (le16_to_cpu(sts->scsi_status) & |
| 3246 | SS_RESPONSE_INFO_LEN_VALID) { |
| 3247 | if (le32_to_cpu(sts->rsp_data_len) < 4) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3248 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1097, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3249 | "Ignoring inconsistent data length -- not enough " |
| 3250 | "response info (%d).\n", |
| 3251 | le32_to_cpu(sts->rsp_data_len)); |
Andrew Vasquez | 97dec56 | 2011-02-23 15:27:14 -0800 | [diff] [blame] | 3252 | } else if (sts->data[3]) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3253 | ql_dbg(ql_dbg_mbx, vha, 0x1098, |
| 3254 | "Failed to complete IOCB -- response (%x).\n", |
| 3255 | sts->data[3]); |
Andrew Vasquez | 97dec56 | 2011-02-23 15:27:14 -0800 | [diff] [blame] | 3256 | rval = QLA_FUNCTION_FAILED; |
| 3257 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3258 | } |
| 3259 | |
| 3260 | /* Issue marker IOCB. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3261 | rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, l, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3262 | type == TCF_LUN_RESET ? MK_SYNC_ID_LUN: MK_SYNC_ID); |
| 3263 | if (rval2 != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3264 | ql_dbg(ql_dbg_mbx, vha, 0x1099, |
| 3265 | "Failed to issue marker IOCB (%x).\n", rval2); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3266 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3267 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109a, |
| 3268 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3269 | } |
| 3270 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3271 | dma_pool_free(ha->s_dma_pool, tsk, tsk_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3272 | |
| 3273 | return rval; |
| 3274 | } |
| 3275 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3276 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 3277 | qla24xx_abort_target(struct fc_port *fcport, uint64_t l, int tag) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3278 | { |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 3279 | struct qla_hw_data *ha = fcport->vha->hw; |
| 3280 | |
| 3281 | if ((ql2xasynctmfenable) && IS_FWI2_CAPABLE(ha)) |
| 3282 | return qla2x00_async_tm_cmd(fcport, TCF_TARGET_RESET, l, tag); |
| 3283 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3284 | return __qla24xx_issue_tmf("Target", TCF_TARGET_RESET, fcport, l, tag); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3285 | } |
| 3286 | |
| 3287 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 3288 | qla24xx_lun_reset(struct fc_port *fcport, uint64_t l, int tag) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3289 | { |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 3290 | struct qla_hw_data *ha = fcport->vha->hw; |
| 3291 | |
| 3292 | if ((ql2xasynctmfenable) && IS_FWI2_CAPABLE(ha)) |
| 3293 | return qla2x00_async_tm_cmd(fcport, TCF_LUN_RESET, l, tag); |
| 3294 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3295 | return __qla24xx_issue_tmf("Lun", TCF_LUN_RESET, fcport, l, tag); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 3296 | } |
| 3297 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3298 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3299 | qla2x00_system_error(scsi_qla_host_t *vha) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3300 | { |
| 3301 | int rval; |
| 3302 | mbx_cmd_t mc; |
| 3303 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3304 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3305 | |
Andrew Vasquez | 68af081 | 2008-05-12 22:21:13 -0700 | [diff] [blame] | 3306 | if (!IS_QLA23XX(ha) && !IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3307 | return QLA_FUNCTION_FAILED; |
| 3308 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3309 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109b, |
| 3310 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3311 | |
| 3312 | mcp->mb[0] = MBC_GEN_SYSTEM_ERROR; |
| 3313 | mcp->out_mb = MBX_0; |
| 3314 | mcp->in_mb = MBX_0; |
| 3315 | mcp->tov = 5; |
| 3316 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3317 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3318 | |
| 3319 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3320 | ql_dbg(ql_dbg_mbx, vha, 0x109c, "Failed=%x.\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3321 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3322 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109d, |
| 3323 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3324 | } |
| 3325 | |
| 3326 | return rval; |
| 3327 | } |
| 3328 | |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 3329 | int |
| 3330 | qla2x00_write_serdes_word(scsi_qla_host_t *vha, uint16_t addr, uint16_t data) |
| 3331 | { |
| 3332 | int rval; |
| 3333 | mbx_cmd_t mc; |
| 3334 | mbx_cmd_t *mcp = &mc; |
| 3335 | |
Joe Carnuccio | f299c7c | 2015-08-04 13:37:51 -0400 | [diff] [blame] | 3336 | if (!IS_QLA25XX(vha->hw) && !IS_QLA2031(vha->hw) && |
| 3337 | !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 3338 | return QLA_FUNCTION_FAILED; |
| 3339 | |
| 3340 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1182, |
| 3341 | "Entered %s.\n", __func__); |
| 3342 | |
| 3343 | mcp->mb[0] = MBC_WRITE_SERDES; |
| 3344 | mcp->mb[1] = addr; |
Andrew Vasquez | 064135e | 2015-04-09 15:00:02 -0400 | [diff] [blame] | 3345 | if (IS_QLA2031(vha->hw)) |
| 3346 | mcp->mb[2] = data & 0xff; |
| 3347 | else |
| 3348 | mcp->mb[2] = data; |
| 3349 | |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 3350 | mcp->mb[3] = 0; |
| 3351 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 3352 | mcp->in_mb = MBX_0; |
| 3353 | mcp->tov = MBX_TOV_SECONDS; |
| 3354 | mcp->flags = 0; |
| 3355 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3356 | |
| 3357 | if (rval != QLA_SUCCESS) { |
| 3358 | ql_dbg(ql_dbg_mbx, vha, 0x1183, |
| 3359 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 3360 | } else { |
| 3361 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1184, |
| 3362 | "Done %s.\n", __func__); |
| 3363 | } |
| 3364 | |
| 3365 | return rval; |
| 3366 | } |
| 3367 | |
| 3368 | int |
| 3369 | qla2x00_read_serdes_word(scsi_qla_host_t *vha, uint16_t addr, uint16_t *data) |
| 3370 | { |
| 3371 | int rval; |
| 3372 | mbx_cmd_t mc; |
| 3373 | mbx_cmd_t *mcp = &mc; |
| 3374 | |
Joe Carnuccio | f299c7c | 2015-08-04 13:37:51 -0400 | [diff] [blame] | 3375 | if (!IS_QLA25XX(vha->hw) && !IS_QLA2031(vha->hw) && |
| 3376 | !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 3377 | return QLA_FUNCTION_FAILED; |
| 3378 | |
| 3379 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1185, |
| 3380 | "Entered %s.\n", __func__); |
| 3381 | |
| 3382 | mcp->mb[0] = MBC_READ_SERDES; |
| 3383 | mcp->mb[1] = addr; |
| 3384 | mcp->mb[3] = 0; |
| 3385 | mcp->out_mb = MBX_3|MBX_1|MBX_0; |
| 3386 | mcp->in_mb = MBX_1|MBX_0; |
| 3387 | mcp->tov = MBX_TOV_SECONDS; |
| 3388 | mcp->flags = 0; |
| 3389 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3390 | |
Andrew Vasquez | 064135e | 2015-04-09 15:00:02 -0400 | [diff] [blame] | 3391 | if (IS_QLA2031(vha->hw)) |
| 3392 | *data = mcp->mb[1] & 0xff; |
| 3393 | else |
| 3394 | *data = mcp->mb[1]; |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 3395 | |
| 3396 | if (rval != QLA_SUCCESS) { |
| 3397 | ql_dbg(ql_dbg_mbx, vha, 0x1186, |
| 3398 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 3399 | } else { |
| 3400 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1187, |
| 3401 | "Done %s.\n", __func__); |
| 3402 | } |
| 3403 | |
| 3404 | return rval; |
| 3405 | } |
| 3406 | |
Joe Carnuccio | e8887c5 | 2014-04-11 16:54:17 -0400 | [diff] [blame] | 3407 | int |
| 3408 | qla8044_write_serdes_word(scsi_qla_host_t *vha, uint32_t addr, uint32_t data) |
| 3409 | { |
| 3410 | int rval; |
| 3411 | mbx_cmd_t mc; |
| 3412 | mbx_cmd_t *mcp = &mc; |
| 3413 | |
| 3414 | if (!IS_QLA8044(vha->hw)) |
| 3415 | return QLA_FUNCTION_FAILED; |
| 3416 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3417 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x11a0, |
Joe Carnuccio | e8887c5 | 2014-04-11 16:54:17 -0400 | [diff] [blame] | 3418 | "Entered %s.\n", __func__); |
| 3419 | |
| 3420 | mcp->mb[0] = MBC_SET_GET_ETH_SERDES_REG; |
| 3421 | mcp->mb[1] = HCS_WRITE_SERDES; |
| 3422 | mcp->mb[3] = LSW(addr); |
| 3423 | mcp->mb[4] = MSW(addr); |
| 3424 | mcp->mb[5] = LSW(data); |
| 3425 | mcp->mb[6] = MSW(data); |
| 3426 | mcp->out_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_1|MBX_0; |
| 3427 | mcp->in_mb = MBX_0; |
| 3428 | mcp->tov = MBX_TOV_SECONDS; |
| 3429 | mcp->flags = 0; |
| 3430 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3431 | |
| 3432 | if (rval != QLA_SUCCESS) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3433 | ql_dbg(ql_dbg_mbx, vha, 0x11a1, |
Joe Carnuccio | e8887c5 | 2014-04-11 16:54:17 -0400 | [diff] [blame] | 3434 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 3435 | } else { |
| 3436 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1188, |
| 3437 | "Done %s.\n", __func__); |
| 3438 | } |
| 3439 | |
| 3440 | return rval; |
| 3441 | } |
| 3442 | |
| 3443 | int |
| 3444 | qla8044_read_serdes_word(scsi_qla_host_t *vha, uint32_t addr, uint32_t *data) |
| 3445 | { |
| 3446 | int rval; |
| 3447 | mbx_cmd_t mc; |
| 3448 | mbx_cmd_t *mcp = &mc; |
| 3449 | |
| 3450 | if (!IS_QLA8044(vha->hw)) |
| 3451 | return QLA_FUNCTION_FAILED; |
| 3452 | |
| 3453 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1189, |
| 3454 | "Entered %s.\n", __func__); |
| 3455 | |
| 3456 | mcp->mb[0] = MBC_SET_GET_ETH_SERDES_REG; |
| 3457 | mcp->mb[1] = HCS_READ_SERDES; |
| 3458 | mcp->mb[3] = LSW(addr); |
| 3459 | mcp->mb[4] = MSW(addr); |
| 3460 | mcp->out_mb = MBX_4|MBX_3|MBX_1|MBX_0; |
| 3461 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 3462 | mcp->tov = MBX_TOV_SECONDS; |
| 3463 | mcp->flags = 0; |
| 3464 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3465 | |
| 3466 | *data = mcp->mb[2] << 16 | mcp->mb[1]; |
| 3467 | |
| 3468 | if (rval != QLA_SUCCESS) { |
| 3469 | ql_dbg(ql_dbg_mbx, vha, 0x118a, |
| 3470 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 3471 | } else { |
| 3472 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x118b, |
| 3473 | "Done %s.\n", __func__); |
| 3474 | } |
| 3475 | |
| 3476 | return rval; |
| 3477 | } |
| 3478 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3479 | /** |
| 3480 | * qla2x00_set_serdes_params() - |
Bart Van Assche | 2db6228 | 2018-01-23 16:33:51 -0800 | [diff] [blame] | 3481 | * @vha: HA context |
| 3482 | * @sw_em_1g: |
| 3483 | * @sw_em_2g: |
| 3484 | * @sw_em_4g: |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3485 | * |
| 3486 | * Returns |
| 3487 | */ |
| 3488 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3489 | 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] | 3490 | uint16_t sw_em_2g, uint16_t sw_em_4g) |
| 3491 | { |
| 3492 | int rval; |
| 3493 | mbx_cmd_t mc; |
| 3494 | mbx_cmd_t *mcp = &mc; |
| 3495 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3496 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109e, |
| 3497 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3498 | |
| 3499 | mcp->mb[0] = MBC_SERDES_PARAMS; |
| 3500 | mcp->mb[1] = BIT_0; |
andrew.vasquez@qlogic.com | fdbc683 | 2006-03-09 14:27:29 -0800 | [diff] [blame] | 3501 | mcp->mb[2] = sw_em_1g | BIT_15; |
| 3502 | mcp->mb[3] = sw_em_2g | BIT_15; |
| 3503 | mcp->mb[4] = sw_em_4g | BIT_15; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3504 | mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3505 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3506 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3507 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3508 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3509 | |
| 3510 | if (rval != QLA_SUCCESS) { |
| 3511 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3512 | ql_dbg(ql_dbg_mbx, vha, 0x109f, |
| 3513 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3514 | } else { |
| 3515 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3516 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a0, |
| 3517 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3518 | } |
| 3519 | |
| 3520 | return rval; |
| 3521 | } |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3522 | |
| 3523 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3524 | qla2x00_stop_firmware(scsi_qla_host_t *vha) |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3525 | { |
| 3526 | int rval; |
| 3527 | mbx_cmd_t mc; |
| 3528 | mbx_cmd_t *mcp = &mc; |
| 3529 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3530 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3531 | return QLA_FUNCTION_FAILED; |
| 3532 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3533 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a1, |
| 3534 | "Entered %s.\n", __func__); |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3535 | |
| 3536 | mcp->mb[0] = MBC_STOP_FIRMWARE; |
Andrew Vasquez | 4ba988d | 2012-02-09 11:14:06 -0800 | [diff] [blame] | 3537 | mcp->mb[1] = 0; |
| 3538 | mcp->out_mb = MBX_1|MBX_0; |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3539 | mcp->in_mb = MBX_0; |
| 3540 | mcp->tov = 5; |
| 3541 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3542 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3543 | |
| 3544 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3545 | ql_dbg(ql_dbg_mbx, vha, 0x10a2, "Failed=%x.\n", rval); |
Andrew Vasquez | b469a7c | 2009-04-06 22:33:48 -0700 | [diff] [blame] | 3546 | if (mcp->mb[0] == MBS_INVALID_COMMAND) |
| 3547 | rval = QLA_INVALID_COMMAND; |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3548 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3549 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a3, |
| 3550 | "Done %s.\n", __func__); |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3551 | } |
| 3552 | |
| 3553 | return rval; |
| 3554 | } |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3555 | |
| 3556 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3557 | 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] | 3558 | uint16_t buffers) |
| 3559 | { |
| 3560 | int rval; |
| 3561 | mbx_cmd_t mc; |
| 3562 | mbx_cmd_t *mcp = &mc; |
| 3563 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3564 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a4, |
| 3565 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3566 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3567 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3568 | return QLA_FUNCTION_FAILED; |
| 3569 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3570 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3571 | return QLA_FUNCTION_FAILED; |
| 3572 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3573 | mcp->mb[0] = MBC_TRACE_CONTROL; |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3574 | mcp->mb[1] = TC_EFT_ENABLE; |
| 3575 | mcp->mb[2] = LSW(eft_dma); |
| 3576 | mcp->mb[3] = MSW(eft_dma); |
| 3577 | mcp->mb[4] = LSW(MSD(eft_dma)); |
| 3578 | mcp->mb[5] = MSW(MSD(eft_dma)); |
| 3579 | mcp->mb[6] = buffers; |
| 3580 | mcp->mb[7] = TC_AEN_DISABLE; |
| 3581 | 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] | 3582 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3583 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3584 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3585 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3586 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3587 | ql_dbg(ql_dbg_mbx, vha, 0x10a5, |
| 3588 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3589 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3590 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3591 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a6, |
| 3592 | "Done %s.\n", __func__); |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3593 | } |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3594 | |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3595 | return rval; |
| 3596 | } |
| 3597 | |
| 3598 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3599 | qla2x00_disable_eft_trace(scsi_qla_host_t *vha) |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3600 | { |
| 3601 | int rval; |
| 3602 | mbx_cmd_t mc; |
| 3603 | mbx_cmd_t *mcp = &mc; |
| 3604 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3605 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a7, |
| 3606 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3607 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3608 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3609 | return QLA_FUNCTION_FAILED; |
| 3610 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3611 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3612 | return QLA_FUNCTION_FAILED; |
| 3613 | |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3614 | mcp->mb[0] = MBC_TRACE_CONTROL; |
| 3615 | mcp->mb[1] = TC_EFT_DISABLE; |
| 3616 | mcp->out_mb = MBX_1|MBX_0; |
| 3617 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3618 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3619 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3620 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3621 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3622 | ql_dbg(ql_dbg_mbx, vha, 0x10a8, |
| 3623 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3624 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3625 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3626 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a9, |
| 3627 | "Done %s.\n", __func__); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3628 | } |
| 3629 | |
| 3630 | return rval; |
| 3631 | } |
| 3632 | |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 3633 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3634 | 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] | 3635 | uint16_t buffers, uint16_t *mb, uint32_t *dwords) |
| 3636 | { |
| 3637 | int rval; |
| 3638 | mbx_cmd_t mc; |
| 3639 | mbx_cmd_t *mcp = &mc; |
| 3640 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3641 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10aa, |
| 3642 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3643 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3644 | if (!IS_QLA25XX(vha->hw) && !IS_QLA81XX(vha->hw) && |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3645 | !IS_QLA83XX(vha->hw) && !IS_QLA27XX(vha->hw)) |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3646 | return QLA_FUNCTION_FAILED; |
| 3647 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3648 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3649 | return QLA_FUNCTION_FAILED; |
| 3650 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3651 | mcp->mb[0] = MBC_TRACE_CONTROL; |
| 3652 | mcp->mb[1] = TC_FCE_ENABLE; |
| 3653 | mcp->mb[2] = LSW(fce_dma); |
| 3654 | mcp->mb[3] = MSW(fce_dma); |
| 3655 | mcp->mb[4] = LSW(MSD(fce_dma)); |
| 3656 | mcp->mb[5] = MSW(MSD(fce_dma)); |
| 3657 | mcp->mb[6] = buffers; |
| 3658 | mcp->mb[7] = TC_AEN_DISABLE; |
| 3659 | mcp->mb[8] = 0; |
| 3660 | mcp->mb[9] = TC_FCE_DEFAULT_RX_SIZE; |
| 3661 | mcp->mb[10] = TC_FCE_DEFAULT_TX_SIZE; |
| 3662 | mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2| |
| 3663 | MBX_1|MBX_0; |
| 3664 | 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] | 3665 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3666 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3667 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3668 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3669 | ql_dbg(ql_dbg_mbx, vha, 0x10ab, |
| 3670 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3671 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3672 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3673 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ac, |
| 3674 | "Done %s.\n", __func__); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3675 | |
| 3676 | if (mb) |
| 3677 | memcpy(mb, mcp->mb, 8 * sizeof(*mb)); |
| 3678 | if (dwords) |
Andrew Vasquez | fa0926d | 2008-05-12 22:21:12 -0700 | [diff] [blame] | 3679 | *dwords = buffers; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3680 | } |
| 3681 | |
| 3682 | return rval; |
| 3683 | } |
| 3684 | |
| 3685 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3686 | 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] | 3687 | { |
| 3688 | int rval; |
| 3689 | mbx_cmd_t mc; |
| 3690 | mbx_cmd_t *mcp = &mc; |
| 3691 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3692 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ad, |
| 3693 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3694 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3695 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3696 | return QLA_FUNCTION_FAILED; |
| 3697 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3698 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3699 | return QLA_FUNCTION_FAILED; |
| 3700 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3701 | mcp->mb[0] = MBC_TRACE_CONTROL; |
| 3702 | mcp->mb[1] = TC_FCE_DISABLE; |
| 3703 | mcp->mb[2] = TC_FCE_DISABLE_TRACE; |
| 3704 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 3705 | mcp->in_mb = MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2| |
| 3706 | MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3707 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3708 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3709 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3710 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3711 | ql_dbg(ql_dbg_mbx, vha, 0x10ae, |
| 3712 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3713 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3714 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3715 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10af, |
| 3716 | "Done %s.\n", __func__); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3717 | |
| 3718 | if (wr) |
| 3719 | *wr = (uint64_t) mcp->mb[5] << 48 | |
| 3720 | (uint64_t) mcp->mb[4] << 32 | |
| 3721 | (uint64_t) mcp->mb[3] << 16 | |
| 3722 | (uint64_t) mcp->mb[2]; |
| 3723 | if (rd) |
| 3724 | *rd = (uint64_t) mcp->mb[9] << 48 | |
| 3725 | (uint64_t) mcp->mb[8] << 32 | |
| 3726 | (uint64_t) mcp->mb[7] << 16 | |
| 3727 | (uint64_t) mcp->mb[6]; |
| 3728 | } |
| 3729 | |
| 3730 | return rval; |
| 3731 | } |
| 3732 | |
| 3733 | int |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3734 | qla2x00_get_idma_speed(scsi_qla_host_t *vha, uint16_t loop_id, |
| 3735 | uint16_t *port_speed, uint16_t *mb) |
| 3736 | { |
| 3737 | int rval; |
| 3738 | mbx_cmd_t mc; |
| 3739 | mbx_cmd_t *mcp = &mc; |
| 3740 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3741 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b0, |
| 3742 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3743 | |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3744 | if (!IS_IIDMA_CAPABLE(vha->hw)) |
| 3745 | return QLA_FUNCTION_FAILED; |
| 3746 | |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3747 | mcp->mb[0] = MBC_PORT_PARAMS; |
| 3748 | mcp->mb[1] = loop_id; |
| 3749 | mcp->mb[2] = mcp->mb[3] = 0; |
| 3750 | mcp->mb[9] = vha->vp_idx; |
| 3751 | mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3752 | mcp->in_mb = MBX_3|MBX_1|MBX_0; |
| 3753 | mcp->tov = MBX_TOV_SECONDS; |
| 3754 | mcp->flags = 0; |
| 3755 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3756 | |
| 3757 | /* Return mailbox statuses. */ |
| 3758 | if (mb != NULL) { |
| 3759 | mb[0] = mcp->mb[0]; |
| 3760 | mb[1] = mcp->mb[1]; |
| 3761 | mb[3] = mcp->mb[3]; |
| 3762 | } |
| 3763 | |
| 3764 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3765 | ql_dbg(ql_dbg_mbx, vha, 0x10b1, "Failed=%x.\n", rval); |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3766 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3767 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b2, |
| 3768 | "Done %s.\n", __func__); |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3769 | if (port_speed) |
| 3770 | *port_speed = mcp->mb[3]; |
| 3771 | } |
| 3772 | |
| 3773 | return rval; |
| 3774 | } |
| 3775 | |
| 3776 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3777 | 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] | 3778 | uint16_t port_speed, uint16_t *mb) |
| 3779 | { |
| 3780 | int rval; |
| 3781 | mbx_cmd_t mc; |
| 3782 | mbx_cmd_t *mcp = &mc; |
| 3783 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3784 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b3, |
| 3785 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3786 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3787 | if (!IS_IIDMA_CAPABLE(vha->hw)) |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3788 | return QLA_FUNCTION_FAILED; |
| 3789 | |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3790 | mcp->mb[0] = MBC_PORT_PARAMS; |
| 3791 | mcp->mb[1] = loop_id; |
| 3792 | mcp->mb[2] = BIT_0; |
Himanshu Madhani | 4c1458d | 2018-08-31 11:24:27 -0700 | [diff] [blame] | 3793 | 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] | 3794 | mcp->mb[9] = vha->vp_idx; |
| 3795 | mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3796 | mcp->in_mb = MBX_3|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3797 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3798 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3799 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3800 | |
| 3801 | /* Return mailbox statuses. */ |
| 3802 | if (mb != NULL) { |
| 3803 | mb[0] = mcp->mb[0]; |
| 3804 | mb[1] = mcp->mb[1]; |
| 3805 | mb[3] = mcp->mb[3]; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3806 | } |
| 3807 | |
| 3808 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3809 | ql_dbg(ql_dbg_mbx, vha, 0x10b4, |
| 3810 | "Failed=%x.\n", rval); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3811 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3812 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b5, |
| 3813 | "Done %s.\n", __func__); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3814 | } |
| 3815 | |
| 3816 | return rval; |
| 3817 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3818 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3819 | void |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3820 | qla24xx_report_id_acquisition(scsi_qla_host_t *vha, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3821 | struct vp_rpt_id_entry_24xx *rptid_entry) |
| 3822 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3823 | struct qla_hw_data *ha = vha->hw; |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3824 | scsi_qla_host_t *vp = NULL; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3825 | unsigned long flags; |
Andrew Vasquez | 4ac8d4ca | 2013-02-08 01:57:58 -0500 | [diff] [blame] | 3826 | int found; |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3827 | port_id_t id; |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 3828 | struct fc_port *fcport; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3829 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3830 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b6, |
| 3831 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3832 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3833 | if (rptid_entry->entry_status != 0) |
| 3834 | return; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3835 | |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3836 | id.b.domain = rptid_entry->port_id[2]; |
| 3837 | id.b.area = rptid_entry->port_id[1]; |
| 3838 | id.b.al_pa = rptid_entry->port_id[0]; |
| 3839 | id.b.rsvd_1 = 0; |
Darren Trapp | 1763c1f | 2018-03-20 23:09:34 -0700 | [diff] [blame] | 3840 | ha->flags.n2n_ae = 0; |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3841 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3842 | if (rptid_entry->format == 0) { |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3843 | /* loop */ |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 3844 | ql_dbg(ql_dbg_async, vha, 0x10b7, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3845 | "Format 0 : Number of VPs setup %d, number of " |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3846 | "VPs acquired %d.\n", rptid_entry->vp_setup, |
| 3847 | rptid_entry->vp_acquired); |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 3848 | ql_dbg(ql_dbg_async, vha, 0x10b8, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3849 | "Primary port id %02x%02x%02x.\n", |
| 3850 | rptid_entry->port_id[2], rptid_entry->port_id[1], |
| 3851 | rptid_entry->port_id[0]); |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 3852 | ha->current_topology = ISP_CFG_NL; |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3853 | qlt_update_host_map(vha, id); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3854 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3855 | } else if (rptid_entry->format == 1) { |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3856 | /* fabric */ |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 3857 | ql_dbg(ql_dbg_async, vha, 0x10b9, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3858 | "Format 1: VP[%d] enabled - status %d - with " |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3859 | "port id %02x%02x%02x.\n", rptid_entry->vp_idx, |
| 3860 | rptid_entry->vp_status, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3861 | rptid_entry->port_id[2], rptid_entry->port_id[1], |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3862 | rptid_entry->port_id[0]); |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 3863 | ql_dbg(ql_dbg_async, vha, 0x5075, |
| 3864 | "Format 1: Remote WWPN %8phC.\n", |
| 3865 | rptid_entry->u.f1.port_name); |
| 3866 | |
| 3867 | ql_dbg(ql_dbg_async, vha, 0x5075, |
| 3868 | "Format 1: WWPN %8phC.\n", |
| 3869 | vha->port_name); |
| 3870 | |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 3871 | switch (rptid_entry->u.f1.flags & TOPO_MASK) { |
| 3872 | case TOPO_N2N: |
| 3873 | ha->current_topology = ISP_CFG_N; |
| 3874 | spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); |
| 3875 | fcport = qla2x00_find_fcport_by_wwpn(vha, |
| 3876 | rptid_entry->u.f1.port_name, 1); |
| 3877 | spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); |
| 3878 | |
| 3879 | if (fcport) { |
| 3880 | fcport->plogi_nack_done_deadline = jiffies + HZ; |
| 3881 | fcport->dm_login_expire = jiffies + 3*HZ; |
| 3882 | fcport->scan_state = QLA_FCPORT_FOUND; |
| 3883 | switch (fcport->disc_state) { |
| 3884 | case DSC_DELETED: |
| 3885 | set_bit(RELOGIN_NEEDED, |
| 3886 | &vha->dpc_flags); |
| 3887 | break; |
| 3888 | case DSC_DELETE_PEND: |
| 3889 | break; |
| 3890 | default: |
| 3891 | qlt_schedule_sess_for_deletion(fcport); |
| 3892 | break; |
| 3893 | } |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 3894 | } else { |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 3895 | id.b24 = 0; |
| 3896 | if (wwn_to_u64(vha->port_name) > |
| 3897 | wwn_to_u64(rptid_entry->u.f1.port_name)) { |
| 3898 | vha->d_id.b24 = 0; |
| 3899 | vha->d_id.b.al_pa = 1; |
| 3900 | ha->flags.n2n_bigger = 1; |
| 3901 | |
| 3902 | id.b.al_pa = 2; |
| 3903 | ql_dbg(ql_dbg_async, vha, 0x5075, |
| 3904 | "Format 1: assign local id %x remote id %x\n", |
| 3905 | vha->d_id.b24, id.b24); |
| 3906 | } else { |
| 3907 | ql_dbg(ql_dbg_async, vha, 0x5075, |
| 3908 | "Format 1: Remote login - Waiting for WWPN %8phC.\n", |
| 3909 | rptid_entry->u.f1.port_name); |
| 3910 | ha->flags.n2n_bigger = 0; |
| 3911 | } |
| 3912 | qla24xx_post_newsess_work(vha, &id, |
| 3913 | rptid_entry->u.f1.port_name, |
| 3914 | rptid_entry->u.f1.node_name, |
| 3915 | NULL, |
| 3916 | FC4_TYPE_UNKNOWN); |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 3917 | } |
| 3918 | |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 3919 | /* if our portname is higher then initiate N2N login */ |
| 3920 | |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 3921 | set_bit(N2N_LOGIN_NEEDED, &vha->dpc_flags); |
Darren Trapp | 1763c1f | 2018-03-20 23:09:34 -0700 | [diff] [blame] | 3922 | ha->flags.n2n_ae = 1; |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 3923 | return; |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 3924 | break; |
| 3925 | case TOPO_FL: |
| 3926 | ha->current_topology = ISP_CFG_FL; |
| 3927 | break; |
| 3928 | case TOPO_F: |
| 3929 | ha->current_topology = ISP_CFG_F; |
| 3930 | break; |
| 3931 | default: |
| 3932 | break; |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 3933 | } |
Andrew Vasquez | 531a82d | 2009-10-13 15:16:51 -0700 | [diff] [blame] | 3934 | |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 3935 | ha->flags.gpsc_supported = 1; |
| 3936 | ha->current_topology = ISP_CFG_F; |
Sawan Chandak | 969a619 | 2016-01-27 12:03:32 -0500 | [diff] [blame] | 3937 | /* buffer to buffer credit flag */ |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3938 | vha->flags.bbcr_enable = (rptid_entry->u.f1.bbcr & 0xf) != 0; |
Sawan Chandak | 969a619 | 2016-01-27 12:03:32 -0500 | [diff] [blame] | 3939 | |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3940 | if (rptid_entry->vp_idx == 0) { |
| 3941 | if (rptid_entry->vp_status == VP_STAT_COMPL) { |
| 3942 | /* FA-WWN is only for physical port */ |
| 3943 | if (qla_ini_mode_enabled(vha) && |
| 3944 | ha->flags.fawwpn_enabled && |
| 3945 | (rptid_entry->u.f1.flags & |
Sawan Chandak | fcc5b5c | 2017-08-23 15:05:02 -0700 | [diff] [blame] | 3946 | BIT_6)) { |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3947 | memcpy(vha->port_name, |
| 3948 | rptid_entry->u.f1.port_name, |
| 3949 | WWN_SIZE); |
| 3950 | } |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 3951 | |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3952 | qlt_update_host_map(vha, id); |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 3953 | } |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3954 | |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3955 | set_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags); |
| 3956 | set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags); |
| 3957 | } else { |
| 3958 | if (rptid_entry->vp_status != VP_STAT_COMPL && |
| 3959 | rptid_entry->vp_status != VP_STAT_ID_CHG) { |
| 3960 | ql_dbg(ql_dbg_mbx, vha, 0x10ba, |
| 3961 | "Could not acquire ID for VP[%d].\n", |
| 3962 | rptid_entry->vp_idx); |
| 3963 | return; |
Andrew Vasquez | 4ac8d4ca | 2013-02-08 01:57:58 -0500 | [diff] [blame] | 3964 | } |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3965 | |
| 3966 | found = 0; |
| 3967 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 3968 | list_for_each_entry(vp, &ha->vp_list, list) { |
| 3969 | if (rptid_entry->vp_idx == vp->vp_idx) { |
| 3970 | found = 1; |
| 3971 | break; |
| 3972 | } |
| 3973 | } |
| 3974 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 3975 | |
| 3976 | if (!found) |
| 3977 | return; |
| 3978 | |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3979 | qlt_update_host_map(vp, id); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3980 | |
| 3981 | /* |
| 3982 | * Cannot configure here as we are still sitting on the |
| 3983 | * response queue. Handle it in dpc context. |
| 3984 | */ |
| 3985 | set_bit(VP_IDX_ACQUIRED, &vp->vp_flags); |
| 3986 | set_bit(REGISTER_FC4_NEEDED, &vp->dpc_flags); |
| 3987 | set_bit(REGISTER_FDMI_NEEDED, &vp->dpc_flags); |
Andrew Vasquez | 4ac8d4ca | 2013-02-08 01:57:58 -0500 | [diff] [blame] | 3988 | } |
Andrew Vasquez | 531a82d | 2009-10-13 15:16:51 -0700 | [diff] [blame] | 3989 | set_bit(VP_DPC_NEEDED, &vha->dpc_flags); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3990 | qla2xxx_wake_dpc(vha); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3991 | } else if (rptid_entry->format == 2) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3992 | ql_dbg(ql_dbg_async, vha, 0x505f, |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3993 | "RIDA: format 2/N2N Primary port id %02x%02x%02x.\n", |
| 3994 | rptid_entry->port_id[2], rptid_entry->port_id[1], |
| 3995 | rptid_entry->port_id[0]); |
| 3996 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3997 | ql_dbg(ql_dbg_async, vha, 0x5075, |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 3998 | "N2N: Remote WWPN %8phC.\n", |
| 3999 | rptid_entry->u.f2.port_name); |
| 4000 | |
| 4001 | /* N2N. direct connect */ |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 4002 | ha->current_topology = ISP_CFG_N; |
| 4003 | ha->flags.rida_fmt2 = 1; |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4004 | vha->d_id.b.domain = rptid_entry->port_id[2]; |
| 4005 | vha->d_id.b.area = rptid_entry->port_id[1]; |
| 4006 | vha->d_id.b.al_pa = rptid_entry->port_id[0]; |
| 4007 | |
Darren Trapp | 1763c1f | 2018-03-20 23:09:34 -0700 | [diff] [blame] | 4008 | ha->flags.n2n_ae = 1; |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4009 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 4010 | qlt_update_vp_map(vha, SET_AL_PA); |
| 4011 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 4012 | |
| 4013 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 4014 | fcport->scan_state = QLA_FCPORT_SCAN; |
| 4015 | } |
| 4016 | |
| 4017 | fcport = qla2x00_find_fcport_by_wwpn(vha, |
| 4018 | rptid_entry->u.f2.port_name, 1); |
| 4019 | |
| 4020 | if (fcport) { |
Quinn Tran | 23dd98a | 2018-08-02 13:16:45 -0700 | [diff] [blame] | 4021 | fcport->login_retry = vha->hw->login_retry_count; |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 4022 | fcport->plogi_nack_done_deadline = jiffies + HZ; |
| 4023 | fcport->scan_state = QLA_FCPORT_FOUND; |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 4024 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4025 | } |
| 4026 | } |
| 4027 | |
| 4028 | /* |
| 4029 | * qla24xx_modify_vp_config |
| 4030 | * Change VP configuration for vha |
| 4031 | * |
| 4032 | * Input: |
| 4033 | * vha = adapter block pointer. |
| 4034 | * |
| 4035 | * Returns: |
| 4036 | * qla2xxx local function return status code. |
| 4037 | * |
| 4038 | * Context: |
| 4039 | * Kernel context. |
| 4040 | */ |
| 4041 | int |
| 4042 | qla24xx_modify_vp_config(scsi_qla_host_t *vha) |
| 4043 | { |
| 4044 | int rval; |
| 4045 | struct vp_config_entry_24xx *vpmod; |
| 4046 | dma_addr_t vpmod_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4047 | struct qla_hw_data *ha = vha->hw; |
| 4048 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4049 | |
| 4050 | /* This can be called by the parent */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4051 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4052 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10bb, |
| 4053 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4054 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 4055 | vpmod = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &vpmod_dma); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4056 | if (!vpmod) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4057 | ql_log(ql_log_warn, vha, 0x10bc, |
| 4058 | "Failed to allocate modify VP IOCB.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4059 | return QLA_MEMORY_ALLOC_FAILED; |
| 4060 | } |
| 4061 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4062 | vpmod->entry_type = VP_CONFIG_IOCB_TYPE; |
| 4063 | vpmod->entry_count = 1; |
| 4064 | vpmod->command = VCT_COMMAND_MOD_ENABLE_VPS; |
| 4065 | vpmod->vp_count = 1; |
| 4066 | vpmod->vp_index1 = vha->vp_idx; |
| 4067 | vpmod->options_idx1 = BIT_3|BIT_4|BIT_5; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4068 | |
| 4069 | qlt_modify_vp_config(vha, vpmod); |
| 4070 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4071 | memcpy(vpmod->node_name_idx1, vha->node_name, WWN_SIZE); |
| 4072 | memcpy(vpmod->port_name_idx1, vha->port_name, WWN_SIZE); |
| 4073 | vpmod->entry_count = 1; |
| 4074 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4075 | rval = qla2x00_issue_iocb(base_vha, vpmod, vpmod_dma, 0); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4076 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4077 | ql_dbg(ql_dbg_mbx, vha, 0x10bd, |
| 4078 | "Failed to issue VP config IOCB (%x).\n", rval); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4079 | } else if (vpmod->comp_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4080 | ql_dbg(ql_dbg_mbx, vha, 0x10be, |
| 4081 | "Failed to complete IOCB -- error status (%x).\n", |
| 4082 | vpmod->comp_status); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4083 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 4084 | } else if (vpmod->comp_status != cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4085 | ql_dbg(ql_dbg_mbx, vha, 0x10bf, |
| 4086 | "Failed to complete IOCB -- completion status (%x).\n", |
| 4087 | le16_to_cpu(vpmod->comp_status)); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4088 | rval = QLA_FUNCTION_FAILED; |
| 4089 | } else { |
| 4090 | /* EMPTY */ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4091 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c0, |
| 4092 | "Done %s.\n", __func__); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4093 | fc_vport_set_state(vha->fc_vport, FC_VPORT_INITIALIZING); |
| 4094 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4095 | dma_pool_free(ha->s_dma_pool, vpmod, vpmod_dma); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4096 | |
| 4097 | return rval; |
| 4098 | } |
| 4099 | |
| 4100 | /* |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4101 | * qla2x00_send_change_request |
| 4102 | * Receive or disable RSCN request from fabric controller |
| 4103 | * |
| 4104 | * Input: |
| 4105 | * ha = adapter block pointer |
| 4106 | * format = registration format: |
| 4107 | * 0 - Reserved |
| 4108 | * 1 - Fabric detected registration |
| 4109 | * 2 - N_port detected registration |
| 4110 | * 3 - Full registration |
| 4111 | * FF - clear registration |
| 4112 | * vp_idx = Virtual port index |
| 4113 | * |
| 4114 | * Returns: |
| 4115 | * qla2x00 local function return status code. |
| 4116 | * |
| 4117 | * Context: |
| 4118 | * Kernel Context |
| 4119 | */ |
| 4120 | |
| 4121 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4122 | qla2x00_send_change_request(scsi_qla_host_t *vha, uint16_t format, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4123 | uint16_t vp_idx) |
| 4124 | { |
| 4125 | int rval; |
| 4126 | mbx_cmd_t mc; |
| 4127 | mbx_cmd_t *mcp = &mc; |
| 4128 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4129 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c7, |
| 4130 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4131 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4132 | mcp->mb[0] = MBC_SEND_CHANGE_REQUEST; |
| 4133 | mcp->mb[1] = format; |
| 4134 | mcp->mb[9] = vp_idx; |
| 4135 | mcp->out_mb = MBX_9|MBX_1|MBX_0; |
| 4136 | mcp->in_mb = MBX_0|MBX_1; |
| 4137 | mcp->tov = MBX_TOV_SECONDS; |
| 4138 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4139 | rval = qla2x00_mailbox_command(vha, mcp); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4140 | |
| 4141 | if (rval == QLA_SUCCESS) { |
| 4142 | if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { |
| 4143 | rval = BIT_1; |
| 4144 | } |
| 4145 | } else |
| 4146 | rval = BIT_1; |
| 4147 | |
| 4148 | return rval; |
| 4149 | } |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4150 | |
| 4151 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4152 | 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] | 4153 | uint32_t size) |
| 4154 | { |
| 4155 | int rval; |
| 4156 | mbx_cmd_t mc; |
| 4157 | mbx_cmd_t *mcp = &mc; |
| 4158 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4159 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1009, |
| 4160 | "Entered %s.\n", __func__); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4161 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4162 | if (MSW(addr) || IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4163 | mcp->mb[0] = MBC_DUMP_RISC_RAM_EXTENDED; |
| 4164 | mcp->mb[8] = MSW(addr); |
| 4165 | mcp->out_mb = MBX_8|MBX_0; |
| 4166 | } else { |
| 4167 | mcp->mb[0] = MBC_DUMP_RISC_RAM; |
| 4168 | mcp->out_mb = MBX_0; |
| 4169 | } |
| 4170 | mcp->mb[1] = LSW(addr); |
| 4171 | mcp->mb[2] = MSW(req_dma); |
| 4172 | mcp->mb[3] = LSW(req_dma); |
| 4173 | mcp->mb[6] = MSW(MSD(req_dma)); |
| 4174 | mcp->mb[7] = LSW(MSD(req_dma)); |
| 4175 | 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] | 4176 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4177 | mcp->mb[4] = MSW(size); |
| 4178 | mcp->mb[5] = LSW(size); |
| 4179 | mcp->out_mb |= MBX_5|MBX_4; |
| 4180 | } else { |
| 4181 | mcp->mb[4] = LSW(size); |
| 4182 | mcp->out_mb |= MBX_4; |
| 4183 | } |
| 4184 | |
| 4185 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 4186 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4187 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4188 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4189 | |
| 4190 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4191 | ql_dbg(ql_dbg_mbx, vha, 0x1008, |
| 4192 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4193 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4194 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1007, |
| 4195 | "Done %s.\n", __func__); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 4196 | } |
| 4197 | |
| 4198 | return rval; |
| 4199 | } |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4200 | /* 84XX Support **************************************************************/ |
| 4201 | |
| 4202 | struct cs84xx_mgmt_cmd { |
| 4203 | union { |
| 4204 | struct verify_chip_entry_84xx req; |
| 4205 | struct verify_chip_rsp_84xx rsp; |
| 4206 | } p; |
| 4207 | }; |
| 4208 | |
| 4209 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4210 | qla84xx_verify_chip(struct scsi_qla_host *vha, uint16_t *status) |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4211 | { |
| 4212 | int rval, retry; |
| 4213 | struct cs84xx_mgmt_cmd *mn; |
| 4214 | dma_addr_t mn_dma; |
| 4215 | uint16_t options; |
| 4216 | unsigned long flags; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4217 | struct qla_hw_data *ha = vha->hw; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4218 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4219 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c8, |
| 4220 | "Entered %s.\n", __func__); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4221 | |
| 4222 | mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma); |
| 4223 | if (mn == NULL) { |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4224 | return QLA_MEMORY_ALLOC_FAILED; |
| 4225 | } |
| 4226 | |
| 4227 | /* Force Update? */ |
| 4228 | options = ha->cs84xx->fw_update ? VCO_FORCE_UPDATE : 0; |
| 4229 | /* Diagnostic firmware? */ |
| 4230 | /* options |= MENLO_DIAG_FW; */ |
| 4231 | /* We update the firmware with only one data sequence. */ |
| 4232 | options |= VCO_END_OF_DATA; |
| 4233 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4234 | do { |
Andrew Vasquez | c1ec1f1 | 2008-04-24 15:21:24 -0700 | [diff] [blame] | 4235 | retry = 0; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4236 | memset(mn, 0, sizeof(*mn)); |
| 4237 | mn->p.req.entry_type = VERIFY_CHIP_IOCB_TYPE; |
| 4238 | mn->p.req.entry_count = 1; |
| 4239 | mn->p.req.options = cpu_to_le16(options); |
| 4240 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4241 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111c, |
| 4242 | "Dump of Verify Request.\n"); |
| 4243 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111e, |
| 4244 | (uint8_t *)mn, sizeof(*mn)); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4245 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 4246 | rval = qla2x00_issue_iocb_timeout(vha, mn, mn_dma, 0, 120); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4247 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4248 | ql_dbg(ql_dbg_mbx, vha, 0x10cb, |
| 4249 | "Failed to issue verify IOCB (%x).\n", rval); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4250 | goto verify_done; |
| 4251 | } |
| 4252 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4253 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1110, |
| 4254 | "Dump of Verify Response.\n"); |
| 4255 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1118, |
| 4256 | (uint8_t *)mn, sizeof(*mn)); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4257 | |
| 4258 | status[0] = le16_to_cpu(mn->p.rsp.comp_status); |
| 4259 | status[1] = status[0] == CS_VCS_CHIP_FAILURE ? |
| 4260 | le16_to_cpu(mn->p.rsp.failure_code) : 0; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4261 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ce, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4262 | "cs=%x fc=%x.\n", status[0], status[1]); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4263 | |
| 4264 | if (status[0] != CS_COMPLETE) { |
| 4265 | rval = QLA_FUNCTION_FAILED; |
| 4266 | if (!(options & VCO_DONT_UPDATE_FW)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4267 | ql_dbg(ql_dbg_mbx, vha, 0x10cf, |
| 4268 | "Firmware update failed. Retrying " |
| 4269 | "without update firmware.\n"); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4270 | options |= VCO_DONT_UPDATE_FW; |
| 4271 | options &= ~VCO_FORCE_UPDATE; |
| 4272 | retry = 1; |
| 4273 | } |
| 4274 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4275 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d0, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4276 | "Firmware updated to %x.\n", |
| 4277 | le32_to_cpu(mn->p.rsp.fw_ver)); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4278 | |
| 4279 | /* NOTE: we only update OP firmware. */ |
| 4280 | spin_lock_irqsave(&ha->cs84xx->access_lock, flags); |
| 4281 | ha->cs84xx->op_fw_version = |
| 4282 | le32_to_cpu(mn->p.rsp.fw_ver); |
| 4283 | spin_unlock_irqrestore(&ha->cs84xx->access_lock, |
| 4284 | flags); |
| 4285 | } |
| 4286 | } while (retry); |
| 4287 | |
| 4288 | verify_done: |
| 4289 | dma_pool_free(ha->s_dma_pool, mn, mn_dma); |
| 4290 | |
| 4291 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4292 | ql_dbg(ql_dbg_mbx, vha, 0x10d1, |
| 4293 | "Failed=%x.\n", rval); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4294 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4295 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d2, |
| 4296 | "Done %s.\n", __func__); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4297 | } |
| 4298 | |
| 4299 | return rval; |
| 4300 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4301 | |
| 4302 | int |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4303 | 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] | 4304 | { |
| 4305 | int rval; |
| 4306 | unsigned long flags; |
| 4307 | mbx_cmd_t mc; |
| 4308 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4309 | struct qla_hw_data *ha = vha->hw; |
| 4310 | |
Quinn Tran | 4523502 | 2018-07-18 14:29:53 -0700 | [diff] [blame] | 4311 | if (!ha->flags.fw_started) |
| 4312 | return QLA_SUCCESS; |
| 4313 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4314 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d3, |
| 4315 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4316 | |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 4317 | if (IS_SHADOW_REG_CAPABLE(ha)) |
| 4318 | req->options |= BIT_13; |
| 4319 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4320 | mcp->mb[0] = MBC_INITIALIZE_MULTIQ; |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4321 | mcp->mb[1] = req->options; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4322 | mcp->mb[2] = MSW(LSD(req->dma)); |
| 4323 | mcp->mb[3] = LSW(LSD(req->dma)); |
| 4324 | mcp->mb[6] = MSW(MSD(req->dma)); |
| 4325 | mcp->mb[7] = LSW(MSD(req->dma)); |
| 4326 | mcp->mb[5] = req->length; |
| 4327 | if (req->rsp) |
| 4328 | mcp->mb[10] = req->rsp->id; |
| 4329 | mcp->mb[12] = req->qos; |
| 4330 | mcp->mb[11] = req->vp_idx; |
| 4331 | mcp->mb[13] = req->rid; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4332 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4333 | mcp->mb[15] = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4334 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4335 | mcp->mb[4] = req->id; |
| 4336 | /* que in ptr index */ |
| 4337 | mcp->mb[8] = 0; |
| 4338 | /* que out ptr index */ |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 4339 | mcp->mb[9] = *req->out_ptr = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4340 | mcp->out_mb = MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8|MBX_7| |
| 4341 | MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4342 | mcp->in_mb = MBX_0; |
| 4343 | mcp->flags = MBX_DMA_OUT; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4344 | mcp->tov = MBX_TOV_SECONDS * 2; |
| 4345 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4346 | if (IS_QLA81XX(ha) || IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4347 | mcp->in_mb |= MBX_1; |
Joe Carnuccio | ba4828b | 2014-04-11 16:54:10 -0400 | [diff] [blame] | 4348 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4349 | mcp->out_mb |= MBX_15; |
| 4350 | /* debug q create issue in SR-IOV */ |
| 4351 | mcp->in_mb |= MBX_9 | MBX_8 | MBX_7; |
| 4352 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4353 | |
| 4354 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4355 | if (!(req->options & BIT_0)) { |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 4356 | WRT_REG_DWORD(req->req_q_in, 0); |
Joe Carnuccio | 29db41c | 2014-04-11 16:54:09 -0400 | [diff] [blame] | 4357 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 4358 | WRT_REG_DWORD(req->req_q_out, 0); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4359 | } |
| 4360 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 4361 | |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 4362 | rval = qla2x00_mailbox_command(vha, mcp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4363 | if (rval != QLA_SUCCESS) { |
| 4364 | ql_dbg(ql_dbg_mbx, vha, 0x10d4, |
| 4365 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 4366 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4367 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d5, |
| 4368 | "Done %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4369 | } |
| 4370 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4371 | return rval; |
| 4372 | } |
| 4373 | |
| 4374 | int |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4375 | 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] | 4376 | { |
| 4377 | int rval; |
| 4378 | unsigned long flags; |
| 4379 | mbx_cmd_t mc; |
| 4380 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4381 | struct qla_hw_data *ha = vha->hw; |
| 4382 | |
Quinn Tran | 4523502 | 2018-07-18 14:29:53 -0700 | [diff] [blame] | 4383 | if (!ha->flags.fw_started) |
| 4384 | return QLA_SUCCESS; |
| 4385 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4386 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d6, |
| 4387 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4388 | |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 4389 | if (IS_SHADOW_REG_CAPABLE(ha)) |
| 4390 | rsp->options |= BIT_13; |
| 4391 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4392 | mcp->mb[0] = MBC_INITIALIZE_MULTIQ; |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4393 | mcp->mb[1] = rsp->options; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4394 | mcp->mb[2] = MSW(LSD(rsp->dma)); |
| 4395 | mcp->mb[3] = LSW(LSD(rsp->dma)); |
| 4396 | mcp->mb[6] = MSW(MSD(rsp->dma)); |
| 4397 | mcp->mb[7] = LSW(MSD(rsp->dma)); |
| 4398 | mcp->mb[5] = rsp->length; |
Andrew Vasquez | 444786d | 2009-01-05 11:18:10 -0800 | [diff] [blame] | 4399 | mcp->mb[14] = rsp->msix->entry; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4400 | mcp->mb[13] = rsp->rid; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4401 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4402 | mcp->mb[15] = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4403 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4404 | mcp->mb[4] = rsp->id; |
| 4405 | /* que in ptr index */ |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 4406 | mcp->mb[8] = *rsp->in_ptr = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4407 | /* que out ptr index */ |
| 4408 | mcp->mb[9] = 0; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 4409 | 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] | 4410 | |MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4411 | mcp->in_mb = MBX_0; |
| 4412 | mcp->flags = MBX_DMA_OUT; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4413 | mcp->tov = MBX_TOV_SECONDS * 2; |
| 4414 | |
| 4415 | if (IS_QLA81XX(ha)) { |
| 4416 | mcp->out_mb |= MBX_12|MBX_11|MBX_10; |
| 4417 | mcp->in_mb |= MBX_1; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4418 | } else if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4419 | mcp->out_mb |= MBX_15|MBX_12|MBX_11|MBX_10; |
| 4420 | mcp->in_mb |= MBX_1; |
| 4421 | /* debug q create issue in SR-IOV */ |
| 4422 | mcp->in_mb |= MBX_9 | MBX_8 | MBX_7; |
| 4423 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4424 | |
| 4425 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4426 | if (!(rsp->options & BIT_0)) { |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 4427 | WRT_REG_DWORD(rsp->rsp_q_out, 0); |
Himanshu Madhani | b20f02e | 2015-06-10 11:05:18 -0400 | [diff] [blame] | 4428 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 4429 | WRT_REG_DWORD(rsp->rsp_q_in, 0); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4430 | } |
| 4431 | |
| 4432 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 4433 | |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 4434 | rval = qla2x00_mailbox_command(vha, mcp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4435 | if (rval != QLA_SUCCESS) { |
| 4436 | ql_dbg(ql_dbg_mbx, vha, 0x10d7, |
| 4437 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 4438 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4439 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d8, |
| 4440 | "Done %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4441 | } |
| 4442 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4443 | return rval; |
| 4444 | } |
| 4445 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4446 | int |
| 4447 | qla81xx_idc_ack(scsi_qla_host_t *vha, uint16_t *mb) |
| 4448 | { |
| 4449 | int rval; |
| 4450 | mbx_cmd_t mc; |
| 4451 | mbx_cmd_t *mcp = &mc; |
| 4452 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4453 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d9, |
| 4454 | "Entered %s.\n", __func__); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4455 | |
| 4456 | mcp->mb[0] = MBC_IDC_ACK; |
| 4457 | memcpy(&mcp->mb[1], mb, QLA_IDC_ACK_REGS * sizeof(uint16_t)); |
| 4458 | mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4459 | mcp->in_mb = MBX_0; |
| 4460 | mcp->tov = MBX_TOV_SECONDS; |
| 4461 | mcp->flags = 0; |
| 4462 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4463 | |
| 4464 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4465 | ql_dbg(ql_dbg_mbx, vha, 0x10da, |
| 4466 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4467 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4468 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10db, |
| 4469 | "Done %s.\n", __func__); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4470 | } |
| 4471 | |
| 4472 | return rval; |
| 4473 | } |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4474 | |
| 4475 | int |
| 4476 | qla81xx_fac_get_sector_size(scsi_qla_host_t *vha, uint32_t *sector_size) |
| 4477 | { |
| 4478 | int rval; |
| 4479 | mbx_cmd_t mc; |
| 4480 | mbx_cmd_t *mcp = &mc; |
| 4481 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4482 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10dc, |
| 4483 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4484 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4485 | if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) && |
| 4486 | !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4487 | return QLA_FUNCTION_FAILED; |
| 4488 | |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4489 | mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; |
| 4490 | mcp->mb[1] = FAC_OPT_CMD_GET_SECTOR_SIZE; |
| 4491 | mcp->out_mb = MBX_1|MBX_0; |
| 4492 | mcp->in_mb = MBX_1|MBX_0; |
| 4493 | mcp->tov = MBX_TOV_SECONDS; |
| 4494 | mcp->flags = 0; |
| 4495 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4496 | |
| 4497 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4498 | ql_dbg(ql_dbg_mbx, vha, 0x10dd, |
| 4499 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 4500 | rval, mcp->mb[0], mcp->mb[1]); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4501 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4502 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10de, |
| 4503 | "Done %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4504 | *sector_size = mcp->mb[1]; |
| 4505 | } |
| 4506 | |
| 4507 | return rval; |
| 4508 | } |
| 4509 | |
| 4510 | int |
| 4511 | qla81xx_fac_do_write_enable(scsi_qla_host_t *vha, int enable) |
| 4512 | { |
| 4513 | int rval; |
| 4514 | mbx_cmd_t mc; |
| 4515 | mbx_cmd_t *mcp = &mc; |
| 4516 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4517 | if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) && |
| 4518 | !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4519 | return QLA_FUNCTION_FAILED; |
| 4520 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4521 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10df, |
| 4522 | "Entered %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4523 | |
| 4524 | mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; |
| 4525 | mcp->mb[1] = enable ? FAC_OPT_CMD_WRITE_ENABLE : |
| 4526 | FAC_OPT_CMD_WRITE_PROTECT; |
| 4527 | mcp->out_mb = MBX_1|MBX_0; |
| 4528 | mcp->in_mb = MBX_1|MBX_0; |
| 4529 | mcp->tov = MBX_TOV_SECONDS; |
| 4530 | mcp->flags = 0; |
| 4531 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4532 | |
| 4533 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4534 | ql_dbg(ql_dbg_mbx, vha, 0x10e0, |
| 4535 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 4536 | rval, mcp->mb[0], mcp->mb[1]); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4537 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4538 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e1, |
| 4539 | "Done %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4540 | } |
| 4541 | |
| 4542 | return rval; |
| 4543 | } |
| 4544 | |
| 4545 | int |
| 4546 | qla81xx_fac_erase_sector(scsi_qla_host_t *vha, uint32_t start, uint32_t finish) |
| 4547 | { |
| 4548 | int rval; |
| 4549 | mbx_cmd_t mc; |
| 4550 | mbx_cmd_t *mcp = &mc; |
| 4551 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4552 | if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) && |
| 4553 | !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4554 | return QLA_FUNCTION_FAILED; |
| 4555 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4556 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e2, |
| 4557 | "Entered %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4558 | |
| 4559 | mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; |
| 4560 | mcp->mb[1] = FAC_OPT_CMD_ERASE_SECTOR; |
| 4561 | mcp->mb[2] = LSW(start); |
| 4562 | mcp->mb[3] = MSW(start); |
| 4563 | mcp->mb[4] = LSW(finish); |
| 4564 | mcp->mb[5] = MSW(finish); |
| 4565 | mcp->out_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4566 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 4567 | mcp->tov = MBX_TOV_SECONDS; |
| 4568 | mcp->flags = 0; |
| 4569 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4570 | |
| 4571 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4572 | ql_dbg(ql_dbg_mbx, vha, 0x10e3, |
| 4573 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 4574 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4575 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4576 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e4, |
| 4577 | "Done %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4578 | } |
| 4579 | |
| 4580 | return rval; |
| 4581 | } |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4582 | |
| 4583 | int |
| 4584 | qla81xx_restart_mpi_firmware(scsi_qla_host_t *vha) |
| 4585 | { |
| 4586 | int rval = 0; |
| 4587 | mbx_cmd_t mc; |
| 4588 | mbx_cmd_t *mcp = &mc; |
| 4589 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4590 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e5, |
| 4591 | "Entered %s.\n", __func__); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4592 | |
| 4593 | mcp->mb[0] = MBC_RESTART_MPI_FW; |
| 4594 | mcp->out_mb = MBX_0; |
| 4595 | mcp->in_mb = MBX_0|MBX_1; |
| 4596 | mcp->tov = MBX_TOV_SECONDS; |
| 4597 | mcp->flags = 0; |
| 4598 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4599 | |
| 4600 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4601 | ql_dbg(ql_dbg_mbx, vha, 0x10e6, |
| 4602 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 4603 | rval, mcp->mb[0], mcp->mb[1]); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4604 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4605 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e7, |
| 4606 | "Done %s.\n", __func__); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4607 | } |
| 4608 | |
| 4609 | return rval; |
| 4610 | } |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4611 | |
Joe Carnuccio | c46e65c | 2013-08-27 01:37:35 -0400 | [diff] [blame] | 4612 | int |
| 4613 | qla82xx_set_driver_version(scsi_qla_host_t *vha, char *version) |
| 4614 | { |
| 4615 | int rval; |
| 4616 | mbx_cmd_t mc; |
| 4617 | mbx_cmd_t *mcp = &mc; |
| 4618 | int i; |
| 4619 | int len; |
| 4620 | uint16_t *str; |
| 4621 | struct qla_hw_data *ha = vha->hw; |
| 4622 | |
| 4623 | if (!IS_P3P_TYPE(ha)) |
| 4624 | return QLA_FUNCTION_FAILED; |
| 4625 | |
| 4626 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x117b, |
| 4627 | "Entered %s.\n", __func__); |
| 4628 | |
| 4629 | str = (void *)version; |
| 4630 | len = strlen(version); |
| 4631 | |
| 4632 | mcp->mb[0] = MBC_SET_RNID_PARAMS; |
| 4633 | mcp->mb[1] = RNID_TYPE_SET_VERSION << 8; |
| 4634 | mcp->out_mb = MBX_1|MBX_0; |
| 4635 | for (i = 4; i < 16 && len; i++, str++, len -= 2) { |
| 4636 | mcp->mb[i] = cpu_to_le16p(str); |
| 4637 | mcp->out_mb |= 1<<i; |
| 4638 | } |
| 4639 | for (; i < 16; i++) { |
| 4640 | mcp->mb[i] = 0; |
| 4641 | mcp->out_mb |= 1<<i; |
| 4642 | } |
| 4643 | mcp->in_mb = MBX_1|MBX_0; |
| 4644 | mcp->tov = MBX_TOV_SECONDS; |
| 4645 | mcp->flags = 0; |
| 4646 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4647 | |
| 4648 | if (rval != QLA_SUCCESS) { |
| 4649 | ql_dbg(ql_dbg_mbx, vha, 0x117c, |
| 4650 | "Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]); |
| 4651 | } else { |
| 4652 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x117d, |
| 4653 | "Done %s.\n", __func__); |
| 4654 | } |
| 4655 | |
| 4656 | return rval; |
| 4657 | } |
| 4658 | |
| 4659 | int |
| 4660 | qla25xx_set_driver_version(scsi_qla_host_t *vha, char *version) |
| 4661 | { |
| 4662 | int rval; |
| 4663 | mbx_cmd_t mc; |
| 4664 | mbx_cmd_t *mcp = &mc; |
| 4665 | int len; |
| 4666 | uint16_t dwlen; |
| 4667 | uint8_t *str; |
| 4668 | dma_addr_t str_dma; |
| 4669 | struct qla_hw_data *ha = vha->hw; |
| 4670 | |
| 4671 | if (!IS_FWI2_CAPABLE(ha) || IS_QLA24XX_TYPE(ha) || IS_QLA81XX(ha) || |
| 4672 | IS_P3P_TYPE(ha)) |
| 4673 | return QLA_FUNCTION_FAILED; |
| 4674 | |
| 4675 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x117e, |
| 4676 | "Entered %s.\n", __func__); |
| 4677 | |
| 4678 | str = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &str_dma); |
| 4679 | if (!str) { |
| 4680 | ql_log(ql_log_warn, vha, 0x117f, |
| 4681 | "Failed to allocate driver version param.\n"); |
| 4682 | return QLA_MEMORY_ALLOC_FAILED; |
| 4683 | } |
| 4684 | |
| 4685 | memcpy(str, "\x7\x3\x11\x0", 4); |
| 4686 | dwlen = str[0]; |
| 4687 | len = dwlen * 4 - 4; |
| 4688 | memset(str + 4, 0, len); |
| 4689 | if (len > strlen(version)) |
| 4690 | len = strlen(version); |
| 4691 | memcpy(str + 4, version, len); |
| 4692 | |
| 4693 | mcp->mb[0] = MBC_SET_RNID_PARAMS; |
| 4694 | mcp->mb[1] = RNID_TYPE_SET_VERSION << 8 | dwlen; |
| 4695 | mcp->mb[2] = MSW(LSD(str_dma)); |
| 4696 | mcp->mb[3] = LSW(LSD(str_dma)); |
| 4697 | mcp->mb[6] = MSW(MSD(str_dma)); |
| 4698 | mcp->mb[7] = LSW(MSD(str_dma)); |
| 4699 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4700 | mcp->in_mb = MBX_1|MBX_0; |
| 4701 | mcp->tov = MBX_TOV_SECONDS; |
| 4702 | mcp->flags = 0; |
| 4703 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4704 | |
| 4705 | if (rval != QLA_SUCCESS) { |
| 4706 | ql_dbg(ql_dbg_mbx, vha, 0x1180, |
| 4707 | "Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]); |
| 4708 | } else { |
| 4709 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1181, |
| 4710 | "Done %s.\n", __func__); |
| 4711 | } |
| 4712 | |
| 4713 | dma_pool_free(ha->s_dma_pool, str, str_dma); |
| 4714 | |
| 4715 | return rval; |
| 4716 | } |
| 4717 | |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 4718 | int |
| 4719 | qla24xx_get_port_login_templ(scsi_qla_host_t *vha, dma_addr_t buf_dma, |
| 4720 | void *buf, uint16_t bufsiz) |
| 4721 | { |
| 4722 | int rval, i; |
| 4723 | mbx_cmd_t mc; |
| 4724 | mbx_cmd_t *mcp = &mc; |
| 4725 | uint32_t *bp; |
| 4726 | |
| 4727 | if (!IS_FWI2_CAPABLE(vha->hw)) |
| 4728 | return QLA_FUNCTION_FAILED; |
| 4729 | |
| 4730 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1159, |
| 4731 | "Entered %s.\n", __func__); |
| 4732 | |
| 4733 | mcp->mb[0] = MBC_GET_RNID_PARAMS; |
| 4734 | mcp->mb[1] = RNID_TYPE_PORT_LOGIN << 8; |
| 4735 | mcp->mb[2] = MSW(buf_dma); |
| 4736 | mcp->mb[3] = LSW(buf_dma); |
| 4737 | mcp->mb[6] = MSW(MSD(buf_dma)); |
| 4738 | mcp->mb[7] = LSW(MSD(buf_dma)); |
| 4739 | mcp->mb[8] = bufsiz/4; |
| 4740 | mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4741 | mcp->in_mb = MBX_1|MBX_0; |
| 4742 | mcp->tov = MBX_TOV_SECONDS; |
| 4743 | mcp->flags = 0; |
| 4744 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4745 | |
| 4746 | if (rval != QLA_SUCCESS) { |
| 4747 | ql_dbg(ql_dbg_mbx, vha, 0x115a, |
| 4748 | "Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]); |
| 4749 | } else { |
| 4750 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x115b, |
| 4751 | "Done %s.\n", __func__); |
| 4752 | bp = (uint32_t *) buf; |
| 4753 | for (i = 0; i < (bufsiz-4)/4; i++, bp++) |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 4754 | *bp = le32_to_cpu(*bp); |
Duane Grigsby | edd05de | 2017-10-13 09:34:06 -0700 | [diff] [blame] | 4755 | } |
| 4756 | |
| 4757 | return rval; |
| 4758 | } |
| 4759 | |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 4760 | static int |
| 4761 | qla2x00_read_asic_temperature(scsi_qla_host_t *vha, uint16_t *temp) |
| 4762 | { |
| 4763 | int rval; |
| 4764 | mbx_cmd_t mc; |
| 4765 | mbx_cmd_t *mcp = &mc; |
| 4766 | |
| 4767 | if (!IS_FWI2_CAPABLE(vha->hw)) |
| 4768 | return QLA_FUNCTION_FAILED; |
| 4769 | |
| 4770 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1159, |
| 4771 | "Entered %s.\n", __func__); |
| 4772 | |
| 4773 | mcp->mb[0] = MBC_GET_RNID_PARAMS; |
| 4774 | mcp->mb[1] = RNID_TYPE_ASIC_TEMP << 8; |
| 4775 | mcp->out_mb = MBX_1|MBX_0; |
| 4776 | mcp->in_mb = MBX_1|MBX_0; |
| 4777 | mcp->tov = MBX_TOV_SECONDS; |
| 4778 | mcp->flags = 0; |
| 4779 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4780 | *temp = mcp->mb[1]; |
| 4781 | |
| 4782 | if (rval != QLA_SUCCESS) { |
| 4783 | ql_dbg(ql_dbg_mbx, vha, 0x115a, |
| 4784 | "Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]); |
| 4785 | } else { |
| 4786 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x115b, |
| 4787 | "Done %s.\n", __func__); |
| 4788 | } |
| 4789 | |
| 4790 | return rval; |
| 4791 | } |
| 4792 | |
Joe Carnuccio | 3a11711 | 2013-02-08 01:58:00 -0500 | [diff] [blame] | 4793 | int |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4794 | qla2x00_read_sfp(scsi_qla_host_t *vha, dma_addr_t sfp_dma, uint8_t *sfp, |
| 4795 | uint16_t dev, uint16_t off, uint16_t len, uint16_t opt) |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4796 | { |
| 4797 | int rval; |
| 4798 | mbx_cmd_t mc; |
| 4799 | mbx_cmd_t *mcp = &mc; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4800 | struct qla_hw_data *ha = vha->hw; |
| 4801 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4802 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e8, |
| 4803 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4804 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4805 | if (!IS_FWI2_CAPABLE(ha)) |
| 4806 | return QLA_FUNCTION_FAILED; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4807 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4808 | if (len == 1) |
| 4809 | opt |= BIT_0; |
| 4810 | |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4811 | mcp->mb[0] = MBC_READ_SFP; |
| 4812 | mcp->mb[1] = dev; |
| 4813 | mcp->mb[2] = MSW(sfp_dma); |
| 4814 | mcp->mb[3] = LSW(sfp_dma); |
| 4815 | mcp->mb[6] = MSW(MSD(sfp_dma)); |
| 4816 | mcp->mb[7] = LSW(MSD(sfp_dma)); |
| 4817 | mcp->mb[8] = len; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4818 | mcp->mb[9] = off; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4819 | mcp->mb[10] = opt; |
| 4820 | 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] | 4821 | mcp->in_mb = MBX_1|MBX_0; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4822 | mcp->tov = MBX_TOV_SECONDS; |
| 4823 | mcp->flags = 0; |
| 4824 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4825 | |
| 4826 | if (opt & BIT_0) |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4827 | *sfp = mcp->mb[1]; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4828 | |
| 4829 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4830 | ql_dbg(ql_dbg_mbx, vha, 0x10e9, |
| 4831 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 4832 | if (mcp->mb[0] == MBS_COMMAND_ERROR && |
| 4833 | mcp->mb[1] == 0x22) |
| 4834 | /* sfp is not there */ |
| 4835 | rval = QLA_INTERFACE_ERROR; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4836 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4837 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ea, |
| 4838 | "Done %s.\n", __func__); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4839 | } |
| 4840 | |
| 4841 | return rval; |
| 4842 | } |
| 4843 | |
| 4844 | int |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4845 | qla2x00_write_sfp(scsi_qla_host_t *vha, dma_addr_t sfp_dma, uint8_t *sfp, |
| 4846 | uint16_t dev, uint16_t off, uint16_t len, uint16_t opt) |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4847 | { |
| 4848 | int rval; |
| 4849 | mbx_cmd_t mc; |
| 4850 | mbx_cmd_t *mcp = &mc; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4851 | struct qla_hw_data *ha = vha->hw; |
| 4852 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4853 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10eb, |
| 4854 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4855 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4856 | if (!IS_FWI2_CAPABLE(ha)) |
| 4857 | return QLA_FUNCTION_FAILED; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4858 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4859 | if (len == 1) |
| 4860 | opt |= BIT_0; |
| 4861 | |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4862 | if (opt & BIT_0) |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4863 | len = *sfp; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4864 | |
| 4865 | mcp->mb[0] = MBC_WRITE_SFP; |
| 4866 | mcp->mb[1] = dev; |
| 4867 | mcp->mb[2] = MSW(sfp_dma); |
| 4868 | mcp->mb[3] = LSW(sfp_dma); |
| 4869 | mcp->mb[6] = MSW(MSD(sfp_dma)); |
| 4870 | mcp->mb[7] = LSW(MSD(sfp_dma)); |
| 4871 | mcp->mb[8] = len; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4872 | mcp->mb[9] = off; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4873 | mcp->mb[10] = opt; |
| 4874 | 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] | 4875 | mcp->in_mb = MBX_1|MBX_0; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4876 | mcp->tov = MBX_TOV_SECONDS; |
| 4877 | mcp->flags = 0; |
| 4878 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4879 | |
| 4880 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4881 | ql_dbg(ql_dbg_mbx, vha, 0x10ec, |
| 4882 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4883 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4884 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ed, |
| 4885 | "Done %s.\n", __func__); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4886 | } |
| 4887 | |
| 4888 | return rval; |
| 4889 | } |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4890 | |
| 4891 | int |
| 4892 | qla2x00_get_xgmac_stats(scsi_qla_host_t *vha, dma_addr_t stats_dma, |
| 4893 | uint16_t size_in_bytes, uint16_t *actual_size) |
| 4894 | { |
| 4895 | int rval; |
| 4896 | mbx_cmd_t mc; |
| 4897 | mbx_cmd_t *mcp = &mc; |
| 4898 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4899 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ee, |
| 4900 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4901 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4902 | if (!IS_CNA_CAPABLE(vha->hw)) |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4903 | return QLA_FUNCTION_FAILED; |
| 4904 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4905 | mcp->mb[0] = MBC_GET_XGMAC_STATS; |
| 4906 | mcp->mb[2] = MSW(stats_dma); |
| 4907 | mcp->mb[3] = LSW(stats_dma); |
| 4908 | mcp->mb[6] = MSW(MSD(stats_dma)); |
| 4909 | mcp->mb[7] = LSW(MSD(stats_dma)); |
| 4910 | mcp->mb[8] = size_in_bytes >> 2; |
| 4911 | mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; |
| 4912 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 4913 | mcp->tov = MBX_TOV_SECONDS; |
| 4914 | mcp->flags = 0; |
| 4915 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4916 | |
| 4917 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4918 | ql_dbg(ql_dbg_mbx, vha, 0x10ef, |
| 4919 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 4920 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4921 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4922 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f0, |
| 4923 | "Done %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4924 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4925 | |
| 4926 | *actual_size = mcp->mb[2] << 2; |
| 4927 | } |
| 4928 | |
| 4929 | return rval; |
| 4930 | } |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4931 | |
| 4932 | int |
| 4933 | qla2x00_get_dcbx_params(scsi_qla_host_t *vha, dma_addr_t tlv_dma, |
| 4934 | uint16_t size) |
| 4935 | { |
| 4936 | int rval; |
| 4937 | mbx_cmd_t mc; |
| 4938 | mbx_cmd_t *mcp = &mc; |
| 4939 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4940 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f1, |
| 4941 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4942 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4943 | if (!IS_CNA_CAPABLE(vha->hw)) |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4944 | return QLA_FUNCTION_FAILED; |
| 4945 | |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4946 | mcp->mb[0] = MBC_GET_DCBX_PARAMS; |
| 4947 | mcp->mb[1] = 0; |
| 4948 | mcp->mb[2] = MSW(tlv_dma); |
| 4949 | mcp->mb[3] = LSW(tlv_dma); |
| 4950 | mcp->mb[6] = MSW(MSD(tlv_dma)); |
| 4951 | mcp->mb[7] = LSW(MSD(tlv_dma)); |
| 4952 | mcp->mb[8] = size; |
| 4953 | mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4954 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 4955 | mcp->tov = MBX_TOV_SECONDS; |
| 4956 | mcp->flags = 0; |
| 4957 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4958 | |
| 4959 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4960 | ql_dbg(ql_dbg_mbx, vha, 0x10f2, |
| 4961 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 4962 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4963 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4964 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f3, |
| 4965 | "Done %s.\n", __func__); |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4966 | } |
| 4967 | |
| 4968 | return rval; |
| 4969 | } |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4970 | |
| 4971 | int |
| 4972 | qla2x00_read_ram_word(scsi_qla_host_t *vha, uint32_t risc_addr, uint32_t *data) |
| 4973 | { |
| 4974 | int rval; |
| 4975 | mbx_cmd_t mc; |
| 4976 | mbx_cmd_t *mcp = &mc; |
| 4977 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4978 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f4, |
| 4979 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4980 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4981 | if (!IS_FWI2_CAPABLE(vha->hw)) |
| 4982 | return QLA_FUNCTION_FAILED; |
| 4983 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4984 | mcp->mb[0] = MBC_READ_RAM_EXTENDED; |
| 4985 | mcp->mb[1] = LSW(risc_addr); |
| 4986 | mcp->mb[8] = MSW(risc_addr); |
| 4987 | mcp->out_mb = MBX_8|MBX_1|MBX_0; |
| 4988 | mcp->in_mb = MBX_3|MBX_2|MBX_0; |
| 4989 | mcp->tov = 30; |
| 4990 | mcp->flags = 0; |
| 4991 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4992 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4993 | ql_dbg(ql_dbg_mbx, vha, 0x10f5, |
| 4994 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4995 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4996 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f6, |
| 4997 | "Done %s.\n", __func__); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4998 | *data = mcp->mb[3] << 16 | mcp->mb[2]; |
| 4999 | } |
| 5000 | |
| 5001 | return rval; |
| 5002 | } |
| 5003 | |
| 5004 | int |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5005 | qla2x00_loopback_test(scsi_qla_host_t *vha, struct msg_echo_lb *mreq, |
| 5006 | uint16_t *mresp) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5007 | { |
| 5008 | int rval; |
| 5009 | mbx_cmd_t mc; |
| 5010 | mbx_cmd_t *mcp = &mc; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5011 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5012 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f7, |
| 5013 | "Entered %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5014 | |
| 5015 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 5016 | mcp->mb[0] = MBC_DIAGNOSTIC_LOOP_BACK; |
| 5017 | mcp->mb[1] = mreq->options | BIT_6; // BIT_6 specifies 64 bit addressing |
| 5018 | |
| 5019 | /* transfer count */ |
| 5020 | mcp->mb[10] = LSW(mreq->transfer_size); |
| 5021 | mcp->mb[11] = MSW(mreq->transfer_size); |
| 5022 | |
| 5023 | /* send data address */ |
| 5024 | mcp->mb[14] = LSW(mreq->send_dma); |
| 5025 | mcp->mb[15] = MSW(mreq->send_dma); |
| 5026 | mcp->mb[20] = LSW(MSD(mreq->send_dma)); |
| 5027 | mcp->mb[21] = MSW(MSD(mreq->send_dma)); |
| 5028 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 5029 | /* receive data address */ |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5030 | mcp->mb[16] = LSW(mreq->rcv_dma); |
| 5031 | mcp->mb[17] = MSW(mreq->rcv_dma); |
| 5032 | mcp->mb[6] = LSW(MSD(mreq->rcv_dma)); |
| 5033 | mcp->mb[7] = MSW(MSD(mreq->rcv_dma)); |
| 5034 | |
| 5035 | /* Iteration count */ |
Joe Carnuccio | 1b98b42 | 2013-03-28 08:21:26 -0400 | [diff] [blame] | 5036 | mcp->mb[18] = LSW(mreq->iteration_count); |
| 5037 | mcp->mb[19] = MSW(mreq->iteration_count); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5038 | |
| 5039 | mcp->out_mb = MBX_21|MBX_20|MBX_19|MBX_18|MBX_17|MBX_16|MBX_15| |
| 5040 | 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] | 5041 | if (IS_CNA_CAPABLE(vha->hw)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5042 | mcp->out_mb |= MBX_2; |
| 5043 | mcp->in_mb = MBX_19|MBX_18|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5044 | |
| 5045 | mcp->buf_size = mreq->transfer_size; |
| 5046 | mcp->tov = MBX_TOV_SECONDS; |
| 5047 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 5048 | |
| 5049 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5050 | |
| 5051 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5052 | ql_dbg(ql_dbg_mbx, vha, 0x10f8, |
| 5053 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[3]=%x mb[18]=%x " |
| 5054 | "mb[19]=%x.\n", rval, mcp->mb[0], mcp->mb[1], mcp->mb[2], |
| 5055 | mcp->mb[3], mcp->mb[18], mcp->mb[19]); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5056 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5057 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f9, |
| 5058 | "Done %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5059 | } |
| 5060 | |
| 5061 | /* Copy mailbox information */ |
| 5062 | memcpy( mresp, mcp->mb, 64); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5063 | return rval; |
| 5064 | } |
| 5065 | |
| 5066 | int |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5067 | qla2x00_echo_test(scsi_qla_host_t *vha, struct msg_echo_lb *mreq, |
| 5068 | uint16_t *mresp) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5069 | { |
| 5070 | int rval; |
| 5071 | mbx_cmd_t mc; |
| 5072 | mbx_cmd_t *mcp = &mc; |
| 5073 | struct qla_hw_data *ha = vha->hw; |
| 5074 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5075 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10fa, |
| 5076 | "Entered %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5077 | |
| 5078 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 5079 | mcp->mb[0] = MBC_DIAGNOSTIC_ECHO; |
Joe Carnuccio | 1d63496 | 2017-05-24 18:06:22 -0700 | [diff] [blame] | 5080 | /* BIT_6 specifies 64bit address */ |
| 5081 | mcp->mb[1] = mreq->options | BIT_15 | BIT_6; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5082 | if (IS_CNA_CAPABLE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5083 | mcp->mb[2] = vha->fcoe_fcf_idx; |
| 5084 | } |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5085 | mcp->mb[16] = LSW(mreq->rcv_dma); |
| 5086 | mcp->mb[17] = MSW(mreq->rcv_dma); |
| 5087 | mcp->mb[6] = LSW(MSD(mreq->rcv_dma)); |
| 5088 | mcp->mb[7] = MSW(MSD(mreq->rcv_dma)); |
| 5089 | |
| 5090 | mcp->mb[10] = LSW(mreq->transfer_size); |
| 5091 | |
| 5092 | mcp->mb[14] = LSW(mreq->send_dma); |
| 5093 | mcp->mb[15] = MSW(mreq->send_dma); |
| 5094 | mcp->mb[20] = LSW(MSD(mreq->send_dma)); |
| 5095 | mcp->mb[21] = MSW(MSD(mreq->send_dma)); |
| 5096 | |
| 5097 | mcp->out_mb = MBX_21|MBX_20|MBX_17|MBX_16|MBX_15| |
| 5098 | MBX_14|MBX_10|MBX_7|MBX_6|MBX_1|MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5099 | if (IS_CNA_CAPABLE(ha)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5100 | mcp->out_mb |= MBX_2; |
| 5101 | |
| 5102 | mcp->in_mb = MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5103 | if (IS_QLA24XX_TYPE(ha) || IS_QLA25XX(ha) || |
| 5104 | IS_CNA_CAPABLE(ha) || IS_QLA2031(ha)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5105 | mcp->in_mb |= MBX_1; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5106 | if (IS_CNA_CAPABLE(ha) || IS_QLA2031(ha)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5107 | mcp->in_mb |= MBX_3; |
| 5108 | |
| 5109 | mcp->tov = MBX_TOV_SECONDS; |
| 5110 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 5111 | mcp->buf_size = mreq->transfer_size; |
| 5112 | |
| 5113 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5114 | |
| 5115 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5116 | ql_dbg(ql_dbg_mbx, vha, 0x10fb, |
| 5117 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 5118 | rval, mcp->mb[0], mcp->mb[1]); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5119 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5120 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10fc, |
| 5121 | "Done %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5122 | } |
| 5123 | |
| 5124 | /* Copy mailbox information */ |
Giridhar Malavali | 6dbdda4 | 2010-09-03 15:20:49 -0700 | [diff] [blame] | 5125 | memcpy(mresp, mcp->mb, 64); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5126 | return rval; |
| 5127 | } |
Giridhar Malavali | 6dbdda4 | 2010-09-03 15:20:49 -0700 | [diff] [blame] | 5128 | |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5129 | int |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5130 | qla84xx_reset_chip(scsi_qla_host_t *vha, uint16_t enable_diagnostic) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5131 | { |
| 5132 | int rval; |
| 5133 | mbx_cmd_t mc; |
| 5134 | mbx_cmd_t *mcp = &mc; |
| 5135 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5136 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10fd, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5137 | "Entered %s enable_diag=%d.\n", __func__, enable_diagnostic); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5138 | |
| 5139 | mcp->mb[0] = MBC_ISP84XX_RESET; |
| 5140 | mcp->mb[1] = enable_diagnostic; |
| 5141 | mcp->out_mb = MBX_1|MBX_0; |
| 5142 | mcp->in_mb = MBX_1|MBX_0; |
| 5143 | mcp->tov = MBX_TOV_SECONDS; |
| 5144 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5145 | rval = qla2x00_mailbox_command(vha, mcp); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5146 | |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5147 | if (rval != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5148 | ql_dbg(ql_dbg_mbx, vha, 0x10fe, "Failed=%x.\n", rval); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5149 | else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5150 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ff, |
| 5151 | "Done %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 5152 | |
| 5153 | return rval; |
| 5154 | } |
| 5155 | |
| 5156 | int |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5157 | qla2x00_write_ram_word(scsi_qla_host_t *vha, uint32_t risc_addr, uint32_t data) |
| 5158 | { |
| 5159 | int rval; |
| 5160 | mbx_cmd_t mc; |
| 5161 | mbx_cmd_t *mcp = &mc; |
| 5162 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5163 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1100, |
| 5164 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5165 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5166 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | 6c452a4 | 2010-03-19 17:04:02 -0700 | [diff] [blame] | 5167 | return QLA_FUNCTION_FAILED; |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5168 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5169 | mcp->mb[0] = MBC_WRITE_RAM_WORD_EXTENDED; |
| 5170 | mcp->mb[1] = LSW(risc_addr); |
| 5171 | mcp->mb[2] = LSW(data); |
| 5172 | mcp->mb[3] = MSW(data); |
| 5173 | mcp->mb[8] = MSW(risc_addr); |
| 5174 | mcp->out_mb = MBX_8|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5175 | mcp->in_mb = MBX_0; |
| 5176 | mcp->tov = 30; |
| 5177 | mcp->flags = 0; |
| 5178 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5179 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5180 | ql_dbg(ql_dbg_mbx, vha, 0x1101, |
| 5181 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5182 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5183 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1102, |
| 5184 | "Done %s.\n", __func__); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 5185 | } |
| 5186 | |
| 5187 | return rval; |
| 5188 | } |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5189 | |
| 5190 | int |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 5191 | qla81xx_write_mpi_register(scsi_qla_host_t *vha, uint16_t *mb) |
| 5192 | { |
| 5193 | int rval; |
| 5194 | uint32_t stat, timer; |
| 5195 | uint16_t mb0 = 0; |
| 5196 | struct qla_hw_data *ha = vha->hw; |
| 5197 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 5198 | |
| 5199 | rval = QLA_SUCCESS; |
| 5200 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5201 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1103, |
| 5202 | "Entered %s.\n", __func__); |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 5203 | |
| 5204 | clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
| 5205 | |
| 5206 | /* Write the MBC data to the registers */ |
| 5207 | WRT_REG_WORD(®->mailbox0, MBC_WRITE_MPI_REGISTER); |
| 5208 | WRT_REG_WORD(®->mailbox1, mb[0]); |
| 5209 | WRT_REG_WORD(®->mailbox2, mb[1]); |
| 5210 | WRT_REG_WORD(®->mailbox3, mb[2]); |
| 5211 | WRT_REG_WORD(®->mailbox4, mb[3]); |
| 5212 | |
| 5213 | WRT_REG_DWORD(®->hccr, HCCRX_SET_HOST_INT); |
| 5214 | |
| 5215 | /* Poll for MBC interrupt */ |
| 5216 | for (timer = 6000000; timer; timer--) { |
| 5217 | /* Check for pending interrupts. */ |
| 5218 | stat = RD_REG_DWORD(®->host_status); |
| 5219 | if (stat & HSRX_RISC_INT) { |
| 5220 | stat &= 0xff; |
| 5221 | |
| 5222 | if (stat == 0x1 || stat == 0x2 || |
| 5223 | stat == 0x10 || stat == 0x11) { |
| 5224 | set_bit(MBX_INTERRUPT, |
| 5225 | &ha->mbx_cmd_flags); |
| 5226 | mb0 = RD_REG_WORD(®->mailbox0); |
| 5227 | WRT_REG_DWORD(®->hccr, |
| 5228 | HCCRX_CLR_RISC_INT); |
| 5229 | RD_REG_DWORD(®->hccr); |
| 5230 | break; |
| 5231 | } |
| 5232 | } |
| 5233 | udelay(5); |
| 5234 | } |
| 5235 | |
| 5236 | if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) |
| 5237 | rval = mb0 & MBS_MASK; |
| 5238 | else |
| 5239 | rval = QLA_FUNCTION_FAILED; |
| 5240 | |
| 5241 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5242 | ql_dbg(ql_dbg_mbx, vha, 0x1104, |
| 5243 | "Failed=%x mb[0]=%x.\n", rval, mb[0]); |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 5244 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5245 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1105, |
| 5246 | "Done %s.\n", __func__); |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 5247 | } |
| 5248 | |
| 5249 | return rval; |
| 5250 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5251 | |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 5252 | int |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5253 | qla2x00_get_data_rate(scsi_qla_host_t *vha) |
| 5254 | { |
| 5255 | int rval; |
| 5256 | mbx_cmd_t mc; |
| 5257 | mbx_cmd_t *mcp = &mc; |
| 5258 | struct qla_hw_data *ha = vha->hw; |
| 5259 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5260 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1106, |
| 5261 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5262 | |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5263 | if (!IS_FWI2_CAPABLE(ha)) |
| 5264 | return QLA_FUNCTION_FAILED; |
| 5265 | |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5266 | mcp->mb[0] = MBC_DATA_RATE; |
| 5267 | mcp->mb[1] = 0; |
| 5268 | mcp->out_mb = MBX_1|MBX_0; |
| 5269 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5270 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5271 | mcp->in_mb |= MBX_3; |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5272 | mcp->tov = MBX_TOV_SECONDS; |
| 5273 | mcp->flags = 0; |
| 5274 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5275 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5276 | ql_dbg(ql_dbg_mbx, vha, 0x1107, |
| 5277 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5278 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5279 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1108, |
| 5280 | "Done %s.\n", __func__); |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 5281 | if (mcp->mb[1] != 0x7) |
| 5282 | ha->link_data_rate = mcp->mb[1]; |
| 5283 | } |
| 5284 | |
| 5285 | return rval; |
| 5286 | } |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5287 | |
| 5288 | int |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5289 | qla81xx_get_port_config(scsi_qla_host_t *vha, uint16_t *mb) |
| 5290 | { |
| 5291 | int rval; |
| 5292 | mbx_cmd_t mc; |
| 5293 | mbx_cmd_t *mcp = &mc; |
| 5294 | struct qla_hw_data *ha = vha->hw; |
| 5295 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5296 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1109, |
| 5297 | "Entered %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5298 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5299 | if (!IS_QLA81XX(ha) && !IS_QLA83XX(ha) && !IS_QLA8044(ha) && |
| 5300 | !IS_QLA27XX(ha)) |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5301 | return QLA_FUNCTION_FAILED; |
| 5302 | mcp->mb[0] = MBC_GET_PORT_CONFIG; |
| 5303 | mcp->out_mb = MBX_0; |
| 5304 | mcp->in_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5305 | mcp->tov = MBX_TOV_SECONDS; |
| 5306 | mcp->flags = 0; |
| 5307 | |
| 5308 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5309 | |
| 5310 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5311 | ql_dbg(ql_dbg_mbx, vha, 0x110a, |
| 5312 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5313 | } else { |
| 5314 | /* Copy all bits to preserve original value */ |
| 5315 | memcpy(mb, &mcp->mb[1], sizeof(uint16_t) * 4); |
| 5316 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5317 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110b, |
| 5318 | "Done %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5319 | } |
| 5320 | return rval; |
| 5321 | } |
| 5322 | |
| 5323 | int |
| 5324 | qla81xx_set_port_config(scsi_qla_host_t *vha, uint16_t *mb) |
| 5325 | { |
| 5326 | int rval; |
| 5327 | mbx_cmd_t mc; |
| 5328 | mbx_cmd_t *mcp = &mc; |
| 5329 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5330 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110c, |
| 5331 | "Entered %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5332 | |
| 5333 | mcp->mb[0] = MBC_SET_PORT_CONFIG; |
| 5334 | /* Copy all bits to preserve original setting */ |
| 5335 | memcpy(&mcp->mb[1], mb, sizeof(uint16_t) * 4); |
| 5336 | mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5337 | mcp->in_mb = MBX_0; |
| 5338 | mcp->tov = MBX_TOV_SECONDS; |
| 5339 | mcp->flags = 0; |
| 5340 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5341 | |
| 5342 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5343 | ql_dbg(ql_dbg_mbx, vha, 0x110d, |
| 5344 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5345 | } else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5346 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110e, |
| 5347 | "Done %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 5348 | |
| 5349 | return rval; |
| 5350 | } |
| 5351 | |
| 5352 | |
| 5353 | int |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5354 | qla24xx_set_fcp_prio(scsi_qla_host_t *vha, uint16_t loop_id, uint16_t priority, |
| 5355 | uint16_t *mb) |
| 5356 | { |
| 5357 | int rval; |
| 5358 | mbx_cmd_t mc; |
| 5359 | mbx_cmd_t *mcp = &mc; |
| 5360 | struct qla_hw_data *ha = vha->hw; |
| 5361 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5362 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110f, |
| 5363 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5364 | |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5365 | if (!IS_QLA24XX_TYPE(ha) && !IS_QLA25XX(ha)) |
| 5366 | return QLA_FUNCTION_FAILED; |
| 5367 | |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5368 | mcp->mb[0] = MBC_PORT_PARAMS; |
| 5369 | mcp->mb[1] = loop_id; |
| 5370 | if (ha->flags.fcp_prio_enabled) |
| 5371 | mcp->mb[2] = BIT_1; |
| 5372 | else |
| 5373 | mcp->mb[2] = BIT_2; |
| 5374 | mcp->mb[4] = priority & 0xf; |
| 5375 | mcp->mb[9] = vha->vp_idx; |
| 5376 | mcp->out_mb = MBX_9|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5377 | mcp->in_mb = MBX_4|MBX_3|MBX_1|MBX_0; |
| 5378 | mcp->tov = 30; |
| 5379 | mcp->flags = 0; |
| 5380 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5381 | if (mb != NULL) { |
| 5382 | mb[0] = mcp->mb[0]; |
| 5383 | mb[1] = mcp->mb[1]; |
| 5384 | mb[3] = mcp->mb[3]; |
| 5385 | mb[4] = mcp->mb[4]; |
| 5386 | } |
| 5387 | |
| 5388 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5389 | ql_dbg(ql_dbg_mbx, vha, 0x10cd, "Failed=%x.\n", rval); |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5390 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5391 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10cc, |
| 5392 | "Done %s.\n", __func__); |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5393 | } |
| 5394 | |
| 5395 | return rval; |
| 5396 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5397 | |
| 5398 | int |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 5399 | qla2x00_get_thermal_temp(scsi_qla_host_t *vha, uint16_t *temp) |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5400 | { |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 5401 | int rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5402 | struct qla_hw_data *ha = vha->hw; |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 5403 | uint8_t byte; |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5404 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 5405 | if (!IS_FWI2_CAPABLE(ha) || IS_QLA24XX_TYPE(ha) || IS_QLA81XX(ha)) { |
| 5406 | ql_dbg(ql_dbg_mbx, vha, 0x1150, |
| 5407 | "Thermal not supported by this card.\n"); |
| 5408 | return rval; |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5409 | } |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5410 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 5411 | if (IS_QLA25XX(ha)) { |
| 5412 | if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC && |
| 5413 | ha->pdev->subsystem_device == 0x0175) { |
| 5414 | rval = qla2x00_read_sfp(vha, 0, &byte, |
| 5415 | 0x98, 0x1, 1, BIT_13|BIT_0); |
| 5416 | *temp = byte; |
| 5417 | return rval; |
| 5418 | } |
| 5419 | if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_HP && |
| 5420 | ha->pdev->subsystem_device == 0x338e) { |
| 5421 | rval = qla2x00_read_sfp(vha, 0, &byte, |
| 5422 | 0x98, 0x1, 1, BIT_15|BIT_14|BIT_0); |
| 5423 | *temp = byte; |
| 5424 | return rval; |
| 5425 | } |
| 5426 | ql_dbg(ql_dbg_mbx, vha, 0x10c9, |
| 5427 | "Thermal not supported by this card.\n"); |
| 5428 | return rval; |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 5429 | } |
| 5430 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 5431 | if (IS_QLA82XX(ha)) { |
| 5432 | *temp = qla82xx_read_temperature(vha); |
| 5433 | rval = QLA_SUCCESS; |
| 5434 | return rval; |
| 5435 | } else if (IS_QLA8044(ha)) { |
| 5436 | *temp = qla8044_read_temperature(vha); |
| 5437 | rval = QLA_SUCCESS; |
| 5438 | return rval; |
| 5439 | } |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 5440 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 5441 | rval = qla2x00_read_asic_temperature(vha, temp); |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 5442 | return rval; |
| 5443 | } |
| 5444 | |
| 5445 | int |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5446 | qla82xx_mbx_intr_enable(scsi_qla_host_t *vha) |
| 5447 | { |
| 5448 | int rval; |
| 5449 | struct qla_hw_data *ha = vha->hw; |
| 5450 | mbx_cmd_t mc; |
| 5451 | mbx_cmd_t *mcp = &mc; |
| 5452 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5453 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1017, |
| 5454 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5455 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5456 | if (!IS_FWI2_CAPABLE(ha)) |
| 5457 | return QLA_FUNCTION_FAILED; |
| 5458 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5459 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
Giridhar Malavali | 3711333 | 2010-07-23 15:28:34 +0500 | [diff] [blame] | 5460 | mcp->mb[0] = MBC_TOGGLE_INTERRUPT; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5461 | mcp->mb[1] = 1; |
| 5462 | |
| 5463 | mcp->out_mb = MBX_1|MBX_0; |
| 5464 | mcp->in_mb = MBX_0; |
| 5465 | mcp->tov = 30; |
| 5466 | mcp->flags = 0; |
| 5467 | |
| 5468 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5469 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5470 | ql_dbg(ql_dbg_mbx, vha, 0x1016, |
| 5471 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5472 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5473 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x100e, |
| 5474 | "Done %s.\n", __func__); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5475 | } |
| 5476 | |
| 5477 | return rval; |
| 5478 | } |
| 5479 | |
| 5480 | int |
| 5481 | qla82xx_mbx_intr_disable(scsi_qla_host_t *vha) |
| 5482 | { |
| 5483 | int rval; |
| 5484 | struct qla_hw_data *ha = vha->hw; |
| 5485 | mbx_cmd_t mc; |
| 5486 | mbx_cmd_t *mcp = &mc; |
| 5487 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5488 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x100d, |
| 5489 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5490 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5491 | if (!IS_P3P_TYPE(ha)) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5492 | return QLA_FUNCTION_FAILED; |
| 5493 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5494 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
Giridhar Malavali | 3711333 | 2010-07-23 15:28:34 +0500 | [diff] [blame] | 5495 | mcp->mb[0] = MBC_TOGGLE_INTERRUPT; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5496 | mcp->mb[1] = 0; |
| 5497 | |
| 5498 | mcp->out_mb = MBX_1|MBX_0; |
| 5499 | mcp->in_mb = MBX_0; |
| 5500 | mcp->tov = 30; |
| 5501 | mcp->flags = 0; |
| 5502 | |
| 5503 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5504 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5505 | ql_dbg(ql_dbg_mbx, vha, 0x100c, |
| 5506 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5507 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5508 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x100b, |
| 5509 | "Done %s.\n", __func__); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5510 | } |
| 5511 | |
| 5512 | return rval; |
| 5513 | } |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5514 | |
| 5515 | int |
| 5516 | qla82xx_md_get_template_size(scsi_qla_host_t *vha) |
| 5517 | { |
| 5518 | struct qla_hw_data *ha = vha->hw; |
| 5519 | mbx_cmd_t mc; |
| 5520 | mbx_cmd_t *mcp = &mc; |
| 5521 | int rval = QLA_FUNCTION_FAILED; |
| 5522 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5523 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x111f, |
| 5524 | "Entered %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5525 | |
| 5526 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 5527 | mcp->mb[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5528 | mcp->mb[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5529 | mcp->mb[2] = LSW(RQST_TMPLT_SIZE); |
| 5530 | mcp->mb[3] = MSW(RQST_TMPLT_SIZE); |
| 5531 | |
| 5532 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 5533 | mcp->in_mb = MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8| |
| 5534 | MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5535 | |
| 5536 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 5537 | mcp->tov = MBX_TOV_SECONDS; |
| 5538 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5539 | |
| 5540 | /* Always copy back return mailbox values. */ |
| 5541 | if (rval != QLA_SUCCESS) { |
| 5542 | ql_dbg(ql_dbg_mbx, vha, 0x1120, |
| 5543 | "mailbox command FAILED=0x%x, subcode=%x.\n", |
| 5544 | (mcp->mb[1] << 16) | mcp->mb[0], |
| 5545 | (mcp->mb[3] << 16) | mcp->mb[2]); |
| 5546 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5547 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1121, |
| 5548 | "Done %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5549 | ha->md_template_size = ((mcp->mb[3] << 16) | mcp->mb[2]); |
| 5550 | if (!ha->md_template_size) { |
| 5551 | ql_dbg(ql_dbg_mbx, vha, 0x1122, |
| 5552 | "Null template size obtained.\n"); |
| 5553 | rval = QLA_FUNCTION_FAILED; |
| 5554 | } |
| 5555 | } |
| 5556 | return rval; |
| 5557 | } |
| 5558 | |
| 5559 | int |
| 5560 | qla82xx_md_get_template(scsi_qla_host_t *vha) |
| 5561 | { |
| 5562 | struct qla_hw_data *ha = vha->hw; |
| 5563 | mbx_cmd_t mc; |
| 5564 | mbx_cmd_t *mcp = &mc; |
| 5565 | int rval = QLA_FUNCTION_FAILED; |
| 5566 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5567 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1123, |
| 5568 | "Entered %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5569 | |
| 5570 | ha->md_tmplt_hdr = dma_alloc_coherent(&ha->pdev->dev, |
| 5571 | ha->md_template_size, &ha->md_tmplt_hdr_dma, GFP_KERNEL); |
| 5572 | if (!ha->md_tmplt_hdr) { |
| 5573 | ql_log(ql_log_warn, vha, 0x1124, |
| 5574 | "Unable to allocate memory for Minidump template.\n"); |
| 5575 | return rval; |
| 5576 | } |
| 5577 | |
| 5578 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 5579 | mcp->mb[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5580 | mcp->mb[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5581 | mcp->mb[2] = LSW(RQST_TMPLT); |
| 5582 | mcp->mb[3] = MSW(RQST_TMPLT); |
| 5583 | mcp->mb[4] = LSW(LSD(ha->md_tmplt_hdr_dma)); |
| 5584 | mcp->mb[5] = MSW(LSD(ha->md_tmplt_hdr_dma)); |
| 5585 | mcp->mb[6] = LSW(MSD(ha->md_tmplt_hdr_dma)); |
| 5586 | mcp->mb[7] = MSW(MSD(ha->md_tmplt_hdr_dma)); |
| 5587 | mcp->mb[8] = LSW(ha->md_template_size); |
| 5588 | mcp->mb[9] = MSW(ha->md_template_size); |
| 5589 | |
| 5590 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 5591 | mcp->tov = MBX_TOV_SECONDS; |
| 5592 | mcp->out_mb = MBX_11|MBX_10|MBX_9|MBX_8| |
| 5593 | MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5594 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 5595 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5596 | |
| 5597 | if (rval != QLA_SUCCESS) { |
| 5598 | ql_dbg(ql_dbg_mbx, vha, 0x1125, |
| 5599 | "mailbox command FAILED=0x%x, subcode=%x.\n", |
| 5600 | ((mcp->mb[1] << 16) | mcp->mb[0]), |
| 5601 | ((mcp->mb[3] << 16) | mcp->mb[2])); |
| 5602 | } else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5603 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1126, |
| 5604 | "Done %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5605 | return rval; |
| 5606 | } |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5607 | |
| 5608 | int |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5609 | qla8044_md_get_template(scsi_qla_host_t *vha) |
| 5610 | { |
| 5611 | struct qla_hw_data *ha = vha->hw; |
| 5612 | mbx_cmd_t mc; |
| 5613 | mbx_cmd_t *mcp = &mc; |
| 5614 | int rval = QLA_FUNCTION_FAILED; |
| 5615 | int offset = 0, size = MINIDUMP_SIZE_36K; |
| 5616 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0xb11f, |
| 5617 | "Entered %s.\n", __func__); |
| 5618 | |
| 5619 | ha->md_tmplt_hdr = dma_alloc_coherent(&ha->pdev->dev, |
| 5620 | ha->md_template_size, &ha->md_tmplt_hdr_dma, GFP_KERNEL); |
| 5621 | if (!ha->md_tmplt_hdr) { |
| 5622 | ql_log(ql_log_warn, vha, 0xb11b, |
| 5623 | "Unable to allocate memory for Minidump template.\n"); |
| 5624 | return rval; |
| 5625 | } |
| 5626 | |
| 5627 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 5628 | while (offset < ha->md_template_size) { |
| 5629 | mcp->mb[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5630 | mcp->mb[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5631 | mcp->mb[2] = LSW(RQST_TMPLT); |
| 5632 | mcp->mb[3] = MSW(RQST_TMPLT); |
| 5633 | mcp->mb[4] = LSW(LSD(ha->md_tmplt_hdr_dma + offset)); |
| 5634 | mcp->mb[5] = MSW(LSD(ha->md_tmplt_hdr_dma + offset)); |
| 5635 | mcp->mb[6] = LSW(MSD(ha->md_tmplt_hdr_dma + offset)); |
| 5636 | mcp->mb[7] = MSW(MSD(ha->md_tmplt_hdr_dma + offset)); |
| 5637 | mcp->mb[8] = LSW(size); |
| 5638 | mcp->mb[9] = MSW(size); |
| 5639 | mcp->mb[10] = offset & 0x0000FFFF; |
| 5640 | mcp->mb[11] = offset & 0xFFFF0000; |
| 5641 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 5642 | mcp->tov = MBX_TOV_SECONDS; |
| 5643 | mcp->out_mb = MBX_11|MBX_10|MBX_9|MBX_8| |
| 5644 | MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5645 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 5646 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5647 | |
| 5648 | if (rval != QLA_SUCCESS) { |
| 5649 | ql_dbg(ql_dbg_mbx, vha, 0xb11c, |
| 5650 | "mailbox command FAILED=0x%x, subcode=%x.\n", |
| 5651 | ((mcp->mb[1] << 16) | mcp->mb[0]), |
| 5652 | ((mcp->mb[3] << 16) | mcp->mb[2])); |
| 5653 | return rval; |
| 5654 | } else |
| 5655 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0xb11d, |
| 5656 | "Done %s.\n", __func__); |
| 5657 | offset = offset + size; |
| 5658 | } |
| 5659 | return rval; |
| 5660 | } |
| 5661 | |
| 5662 | int |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5663 | qla81xx_set_led_config(scsi_qla_host_t *vha, uint16_t *led_cfg) |
| 5664 | { |
| 5665 | int rval; |
| 5666 | struct qla_hw_data *ha = vha->hw; |
| 5667 | mbx_cmd_t mc; |
| 5668 | mbx_cmd_t *mcp = &mc; |
| 5669 | |
| 5670 | if (!IS_QLA81XX(ha) && !IS_QLA8031(ha)) |
| 5671 | return QLA_FUNCTION_FAILED; |
| 5672 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5673 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1133, |
| 5674 | "Entered %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5675 | |
| 5676 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
| 5677 | mcp->mb[0] = MBC_SET_LED_CONFIG; |
| 5678 | mcp->mb[1] = led_cfg[0]; |
| 5679 | mcp->mb[2] = led_cfg[1]; |
| 5680 | if (IS_QLA8031(ha)) { |
| 5681 | mcp->mb[3] = led_cfg[2]; |
| 5682 | mcp->mb[4] = led_cfg[3]; |
| 5683 | mcp->mb[5] = led_cfg[4]; |
| 5684 | mcp->mb[6] = led_cfg[5]; |
| 5685 | } |
| 5686 | |
| 5687 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 5688 | if (IS_QLA8031(ha)) |
| 5689 | mcp->out_mb |= MBX_6|MBX_5|MBX_4|MBX_3; |
| 5690 | mcp->in_mb = MBX_0; |
| 5691 | mcp->tov = 30; |
| 5692 | mcp->flags = 0; |
| 5693 | |
| 5694 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5695 | if (rval != QLA_SUCCESS) { |
| 5696 | ql_dbg(ql_dbg_mbx, vha, 0x1134, |
| 5697 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5698 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5699 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1135, |
| 5700 | "Done %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5701 | } |
| 5702 | |
| 5703 | return rval; |
| 5704 | } |
| 5705 | |
| 5706 | int |
| 5707 | qla81xx_get_led_config(scsi_qla_host_t *vha, uint16_t *led_cfg) |
| 5708 | { |
| 5709 | int rval; |
| 5710 | struct qla_hw_data *ha = vha->hw; |
| 5711 | mbx_cmd_t mc; |
| 5712 | mbx_cmd_t *mcp = &mc; |
| 5713 | |
| 5714 | if (!IS_QLA81XX(ha) && !IS_QLA8031(ha)) |
| 5715 | return QLA_FUNCTION_FAILED; |
| 5716 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5717 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1136, |
| 5718 | "Entered %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5719 | |
| 5720 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
| 5721 | mcp->mb[0] = MBC_GET_LED_CONFIG; |
| 5722 | |
| 5723 | mcp->out_mb = MBX_0; |
| 5724 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 5725 | if (IS_QLA8031(ha)) |
| 5726 | mcp->in_mb |= MBX_6|MBX_5|MBX_4|MBX_3; |
| 5727 | mcp->tov = 30; |
| 5728 | mcp->flags = 0; |
| 5729 | |
| 5730 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5731 | if (rval != QLA_SUCCESS) { |
| 5732 | ql_dbg(ql_dbg_mbx, vha, 0x1137, |
| 5733 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5734 | } else { |
| 5735 | led_cfg[0] = mcp->mb[1]; |
| 5736 | led_cfg[1] = mcp->mb[2]; |
| 5737 | if (IS_QLA8031(ha)) { |
| 5738 | led_cfg[2] = mcp->mb[3]; |
| 5739 | led_cfg[3] = mcp->mb[4]; |
| 5740 | led_cfg[4] = mcp->mb[5]; |
| 5741 | led_cfg[5] = mcp->mb[6]; |
| 5742 | } |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5743 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1138, |
| 5744 | "Done %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5745 | } |
| 5746 | |
| 5747 | return rval; |
| 5748 | } |
| 5749 | |
| 5750 | int |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5751 | qla82xx_mbx_beacon_ctl(scsi_qla_host_t *vha, int enable) |
| 5752 | { |
| 5753 | int rval; |
| 5754 | struct qla_hw_data *ha = vha->hw; |
| 5755 | mbx_cmd_t mc; |
| 5756 | mbx_cmd_t *mcp = &mc; |
| 5757 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5758 | if (!IS_P3P_TYPE(ha)) |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5759 | return QLA_FUNCTION_FAILED; |
| 5760 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5761 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1127, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5762 | "Entered %s.\n", __func__); |
| 5763 | |
| 5764 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
| 5765 | mcp->mb[0] = MBC_SET_LED_CONFIG; |
| 5766 | if (enable) |
| 5767 | mcp->mb[7] = 0xE; |
| 5768 | else |
| 5769 | mcp->mb[7] = 0xD; |
| 5770 | |
| 5771 | mcp->out_mb = MBX_7|MBX_0; |
| 5772 | mcp->in_mb = MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5773 | mcp->tov = MBX_TOV_SECONDS; |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5774 | mcp->flags = 0; |
| 5775 | |
| 5776 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5777 | if (rval != QLA_SUCCESS) { |
| 5778 | ql_dbg(ql_dbg_mbx, vha, 0x1128, |
| 5779 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5780 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5781 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1129, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5782 | "Done %s.\n", __func__); |
| 5783 | } |
| 5784 | |
| 5785 | return rval; |
| 5786 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5787 | |
| 5788 | int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5789 | 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] | 5790 | { |
| 5791 | int rval; |
| 5792 | struct qla_hw_data *ha = vha->hw; |
| 5793 | mbx_cmd_t mc; |
| 5794 | mbx_cmd_t *mcp = &mc; |
| 5795 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5796 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5797 | return QLA_FUNCTION_FAILED; |
| 5798 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5799 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1130, |
| 5800 | "Entered %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5801 | |
| 5802 | mcp->mb[0] = MBC_WRITE_REMOTE_REG; |
| 5803 | mcp->mb[1] = LSW(reg); |
| 5804 | mcp->mb[2] = MSW(reg); |
| 5805 | mcp->mb[3] = LSW(data); |
| 5806 | mcp->mb[4] = MSW(data); |
| 5807 | mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5808 | |
| 5809 | mcp->in_mb = MBX_1|MBX_0; |
| 5810 | mcp->tov = MBX_TOV_SECONDS; |
| 5811 | mcp->flags = 0; |
| 5812 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5813 | |
| 5814 | if (rval != QLA_SUCCESS) { |
| 5815 | ql_dbg(ql_dbg_mbx, vha, 0x1131, |
| 5816 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5817 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5818 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1132, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5819 | "Done %s.\n", __func__); |
| 5820 | } |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5821 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5822 | return rval; |
| 5823 | } |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5824 | |
| 5825 | int |
| 5826 | qla2x00_port_logout(scsi_qla_host_t *vha, struct fc_port *fcport) |
| 5827 | { |
| 5828 | int rval; |
| 5829 | struct qla_hw_data *ha = vha->hw; |
| 5830 | mbx_cmd_t mc; |
| 5831 | mbx_cmd_t *mcp = &mc; |
| 5832 | |
| 5833 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5834 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x113b, |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5835 | "Implicit LOGO Unsupported.\n"); |
| 5836 | return QLA_FUNCTION_FAILED; |
| 5837 | } |
| 5838 | |
| 5839 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5840 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x113c, |
| 5841 | "Entering %s.\n", __func__); |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5842 | |
| 5843 | /* Perform Implicit LOGO. */ |
| 5844 | mcp->mb[0] = MBC_PORT_LOGOUT; |
| 5845 | mcp->mb[1] = fcport->loop_id; |
| 5846 | mcp->mb[10] = BIT_15; |
| 5847 | mcp->out_mb = MBX_10|MBX_1|MBX_0; |
| 5848 | mcp->in_mb = MBX_0; |
| 5849 | mcp->tov = MBX_TOV_SECONDS; |
| 5850 | mcp->flags = 0; |
| 5851 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5852 | if (rval != QLA_SUCCESS) |
| 5853 | ql_dbg(ql_dbg_mbx, vha, 0x113d, |
| 5854 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5855 | else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5856 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x113e, |
| 5857 | "Done %s.\n", __func__); |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5858 | |
| 5859 | return rval; |
| 5860 | } |
| 5861 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5862 | int |
| 5863 | qla83xx_rd_reg(scsi_qla_host_t *vha, uint32_t reg, uint32_t *data) |
| 5864 | { |
| 5865 | int rval; |
| 5866 | mbx_cmd_t mc; |
| 5867 | mbx_cmd_t *mcp = &mc; |
| 5868 | struct qla_hw_data *ha = vha->hw; |
| 5869 | unsigned long retry_max_time = jiffies + (2 * HZ); |
| 5870 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5871 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5872 | return QLA_FUNCTION_FAILED; |
| 5873 | |
| 5874 | ql_dbg(ql_dbg_mbx, vha, 0x114b, "Entered %s.\n", __func__); |
| 5875 | |
| 5876 | retry_rd_reg: |
| 5877 | mcp->mb[0] = MBC_READ_REMOTE_REG; |
| 5878 | mcp->mb[1] = LSW(reg); |
| 5879 | mcp->mb[2] = MSW(reg); |
| 5880 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 5881 | mcp->in_mb = MBX_4|MBX_3|MBX_1|MBX_0; |
| 5882 | mcp->tov = MBX_TOV_SECONDS; |
| 5883 | mcp->flags = 0; |
| 5884 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5885 | |
| 5886 | if (rval != QLA_SUCCESS) { |
| 5887 | ql_dbg(ql_dbg_mbx, vha, 0x114c, |
| 5888 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 5889 | rval, mcp->mb[0], mcp->mb[1]); |
| 5890 | } else { |
| 5891 | *data = (mcp->mb[3] | (mcp->mb[4] << 16)); |
| 5892 | if (*data == QLA8XXX_BAD_VALUE) { |
| 5893 | /* |
| 5894 | * During soft-reset CAMRAM register reads might |
| 5895 | * return 0xbad0bad0. So retry for MAX of 2 sec |
| 5896 | * while reading camram registers. |
| 5897 | */ |
| 5898 | if (time_after(jiffies, retry_max_time)) { |
| 5899 | ql_dbg(ql_dbg_mbx, vha, 0x1141, |
| 5900 | "Failure to read CAMRAM register. " |
| 5901 | "data=0x%x.\n", *data); |
| 5902 | return QLA_FUNCTION_FAILED; |
| 5903 | } |
| 5904 | msleep(100); |
| 5905 | goto retry_rd_reg; |
| 5906 | } |
| 5907 | ql_dbg(ql_dbg_mbx, vha, 0x1142, "Done %s.\n", __func__); |
| 5908 | } |
| 5909 | |
| 5910 | return rval; |
| 5911 | } |
| 5912 | |
| 5913 | int |
| 5914 | qla83xx_restart_nic_firmware(scsi_qla_host_t *vha) |
| 5915 | { |
| 5916 | int rval; |
| 5917 | mbx_cmd_t mc; |
| 5918 | mbx_cmd_t *mcp = &mc; |
| 5919 | struct qla_hw_data *ha = vha->hw; |
| 5920 | |
Himanshu Madhani | b20f02e | 2015-06-10 11:05:18 -0400 | [diff] [blame] | 5921 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5922 | return QLA_FUNCTION_FAILED; |
| 5923 | |
| 5924 | ql_dbg(ql_dbg_mbx, vha, 0x1143, "Entered %s.\n", __func__); |
| 5925 | |
| 5926 | mcp->mb[0] = MBC_RESTART_NIC_FIRMWARE; |
| 5927 | mcp->out_mb = MBX_0; |
| 5928 | mcp->in_mb = MBX_1|MBX_0; |
| 5929 | mcp->tov = MBX_TOV_SECONDS; |
| 5930 | mcp->flags = 0; |
| 5931 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5932 | |
| 5933 | if (rval != QLA_SUCCESS) { |
| 5934 | ql_dbg(ql_dbg_mbx, vha, 0x1144, |
| 5935 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 5936 | rval, mcp->mb[0], mcp->mb[1]); |
| 5937 | ha->isp_ops->fw_dump(vha, 0); |
| 5938 | } else { |
| 5939 | ql_dbg(ql_dbg_mbx, vha, 0x1145, "Done %s.\n", __func__); |
| 5940 | } |
| 5941 | |
| 5942 | return rval; |
| 5943 | } |
| 5944 | |
| 5945 | int |
| 5946 | qla83xx_access_control(scsi_qla_host_t *vha, uint16_t options, |
| 5947 | uint32_t start_addr, uint32_t end_addr, uint16_t *sector_size) |
| 5948 | { |
| 5949 | int rval; |
| 5950 | mbx_cmd_t mc; |
| 5951 | mbx_cmd_t *mcp = &mc; |
| 5952 | uint8_t subcode = (uint8_t)options; |
| 5953 | struct qla_hw_data *ha = vha->hw; |
| 5954 | |
| 5955 | if (!IS_QLA8031(ha)) |
| 5956 | return QLA_FUNCTION_FAILED; |
| 5957 | |
| 5958 | ql_dbg(ql_dbg_mbx, vha, 0x1146, "Entered %s.\n", __func__); |
| 5959 | |
| 5960 | mcp->mb[0] = MBC_SET_ACCESS_CONTROL; |
| 5961 | mcp->mb[1] = options; |
| 5962 | mcp->out_mb = MBX_1|MBX_0; |
| 5963 | if (subcode & BIT_2) { |
| 5964 | mcp->mb[2] = LSW(start_addr); |
| 5965 | mcp->mb[3] = MSW(start_addr); |
| 5966 | mcp->mb[4] = LSW(end_addr); |
| 5967 | mcp->mb[5] = MSW(end_addr); |
| 5968 | mcp->out_mb |= MBX_5|MBX_4|MBX_3|MBX_2; |
| 5969 | } |
| 5970 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 5971 | if (!(subcode & (BIT_2 | BIT_5))) |
| 5972 | mcp->in_mb |= MBX_4|MBX_3; |
| 5973 | mcp->tov = MBX_TOV_SECONDS; |
| 5974 | mcp->flags = 0; |
| 5975 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5976 | |
| 5977 | if (rval != QLA_SUCCESS) { |
| 5978 | ql_dbg(ql_dbg_mbx, vha, 0x1147, |
| 5979 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[3]=%x mb[4]=%x.\n", |
| 5980 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2], mcp->mb[3], |
| 5981 | mcp->mb[4]); |
| 5982 | ha->isp_ops->fw_dump(vha, 0); |
| 5983 | } else { |
| 5984 | if (subcode & BIT_5) |
| 5985 | *sector_size = mcp->mb[1]; |
| 5986 | else if (subcode & (BIT_6 | BIT_7)) { |
| 5987 | ql_dbg(ql_dbg_mbx, vha, 0x1148, |
| 5988 | "Driver-lock id=%x%x", mcp->mb[4], mcp->mb[3]); |
| 5989 | } else if (subcode & (BIT_3 | BIT_4)) { |
| 5990 | ql_dbg(ql_dbg_mbx, vha, 0x1149, |
| 5991 | "Flash-lock id=%x%x", mcp->mb[4], mcp->mb[3]); |
| 5992 | } |
| 5993 | ql_dbg(ql_dbg_mbx, vha, 0x114a, "Done %s.\n", __func__); |
| 5994 | } |
| 5995 | |
| 5996 | return rval; |
| 5997 | } |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 5998 | |
| 5999 | int |
| 6000 | qla2x00_dump_mctp_data(scsi_qla_host_t *vha, dma_addr_t req_dma, uint32_t addr, |
| 6001 | uint32_t size) |
| 6002 | { |
| 6003 | int rval; |
| 6004 | mbx_cmd_t mc; |
| 6005 | mbx_cmd_t *mcp = &mc; |
| 6006 | |
| 6007 | if (!IS_MCTP_CAPABLE(vha->hw)) |
| 6008 | return QLA_FUNCTION_FAILED; |
| 6009 | |
| 6010 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x114f, |
| 6011 | "Entered %s.\n", __func__); |
| 6012 | |
| 6013 | mcp->mb[0] = MBC_DUMP_RISC_RAM_EXTENDED; |
| 6014 | mcp->mb[1] = LSW(addr); |
| 6015 | mcp->mb[2] = MSW(req_dma); |
| 6016 | mcp->mb[3] = LSW(req_dma); |
| 6017 | mcp->mb[4] = MSW(size); |
| 6018 | mcp->mb[5] = LSW(size); |
| 6019 | mcp->mb[6] = MSW(MSD(req_dma)); |
| 6020 | mcp->mb[7] = LSW(MSD(req_dma)); |
| 6021 | mcp->mb[8] = MSW(addr); |
| 6022 | /* Setting RAM ID to valid */ |
| 6023 | mcp->mb[10] |= BIT_7; |
| 6024 | /* For MCTP RAM ID is 0x40 */ |
| 6025 | mcp->mb[10] |= 0x40; |
| 6026 | |
| 6027 | mcp->out_mb |= MBX_10|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1| |
| 6028 | MBX_0; |
| 6029 | |
| 6030 | mcp->in_mb = MBX_0; |
| 6031 | mcp->tov = MBX_TOV_SECONDS; |
| 6032 | mcp->flags = 0; |
| 6033 | rval = qla2x00_mailbox_command(vha, mcp); |
| 6034 | |
| 6035 | if (rval != QLA_SUCCESS) { |
| 6036 | ql_dbg(ql_dbg_mbx, vha, 0x114e, |
| 6037 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 6038 | } else { |
| 6039 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x114d, |
| 6040 | "Done %s.\n", __func__); |
| 6041 | } |
| 6042 | |
| 6043 | return rval; |
| 6044 | } |
Joe Carnuccio | ec89146 | 2016-07-06 11:14:26 -0400 | [diff] [blame] | 6045 | |
| 6046 | int |
| 6047 | qla26xx_dport_diagnostics(scsi_qla_host_t *vha, |
| 6048 | void *dd_buf, uint size, uint options) |
| 6049 | { |
| 6050 | int rval; |
| 6051 | mbx_cmd_t mc; |
| 6052 | mbx_cmd_t *mcp = &mc; |
| 6053 | dma_addr_t dd_dma; |
| 6054 | |
| 6055 | if (!IS_QLA83XX(vha->hw) && !IS_QLA27XX(vha->hw)) |
| 6056 | return QLA_FUNCTION_FAILED; |
| 6057 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6058 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x119f, |
Joe Carnuccio | ec89146 | 2016-07-06 11:14:26 -0400 | [diff] [blame] | 6059 | "Entered %s.\n", __func__); |
| 6060 | |
Joe Carnuccio | ec89146 | 2016-07-06 11:14:26 -0400 | [diff] [blame] | 6061 | dd_dma = dma_map_single(&vha->hw->pdev->dev, |
| 6062 | dd_buf, size, DMA_FROM_DEVICE); |
Pan Bian | 0b2ce19 | 2017-08-08 21:55:30 +0800 | [diff] [blame] | 6063 | if (dma_mapping_error(&vha->hw->pdev->dev, dd_dma)) { |
Joe Carnuccio | ec89146 | 2016-07-06 11:14:26 -0400 | [diff] [blame] | 6064 | ql_log(ql_log_warn, vha, 0x1194, "Failed to map dma buffer.\n"); |
| 6065 | return QLA_MEMORY_ALLOC_FAILED; |
| 6066 | } |
| 6067 | |
| 6068 | memset(dd_buf, 0, size); |
| 6069 | |
| 6070 | mcp->mb[0] = MBC_DPORT_DIAGNOSTICS; |
| 6071 | mcp->mb[1] = options; |
| 6072 | mcp->mb[2] = MSW(LSD(dd_dma)); |
| 6073 | mcp->mb[3] = LSW(LSD(dd_dma)); |
| 6074 | mcp->mb[6] = MSW(MSD(dd_dma)); |
| 6075 | mcp->mb[7] = LSW(MSD(dd_dma)); |
| 6076 | mcp->mb[8] = size; |
| 6077 | mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 6078 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 6079 | mcp->buf_size = size; |
| 6080 | mcp->flags = MBX_DMA_IN; |
| 6081 | mcp->tov = MBX_TOV_SECONDS * 4; |
| 6082 | rval = qla2x00_mailbox_command(vha, mcp); |
| 6083 | |
| 6084 | if (rval != QLA_SUCCESS) { |
| 6085 | ql_dbg(ql_dbg_mbx, vha, 0x1195, "Failed=%x.\n", rval); |
| 6086 | } else { |
| 6087 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1196, |
| 6088 | "Done %s.\n", __func__); |
| 6089 | } |
| 6090 | |
| 6091 | dma_unmap_single(&vha->hw->pdev->dev, dd_dma, |
| 6092 | size, DMA_FROM_DEVICE); |
| 6093 | |
| 6094 | return rval; |
| 6095 | } |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6096 | |
| 6097 | static void qla2x00_async_mb_sp_done(void *s, int res) |
| 6098 | { |
| 6099 | struct srb *sp = s; |
| 6100 | |
| 6101 | sp->u.iocb_cmd.u.mbx.rc = res; |
| 6102 | |
| 6103 | complete(&sp->u.iocb_cmd.u.mbx.comp); |
| 6104 | /* don't free sp here. Let the caller do the free */ |
| 6105 | } |
| 6106 | |
| 6107 | /* |
| 6108 | * This mailbox uses the iocb interface to send MB command. |
| 6109 | * This allows non-critial (non chip setup) command to go |
| 6110 | * out in parrallel. |
| 6111 | */ |
| 6112 | int qla24xx_send_mb_cmd(struct scsi_qla_host *vha, mbx_cmd_t *mcp) |
| 6113 | { |
| 6114 | int rval = QLA_FUNCTION_FAILED; |
| 6115 | srb_t *sp; |
| 6116 | struct srb_iocb *c; |
| 6117 | |
| 6118 | if (!vha->hw->flags.fw_started) |
| 6119 | goto done; |
| 6120 | |
| 6121 | sp = qla2x00_get_sp(vha, NULL, GFP_KERNEL); |
| 6122 | if (!sp) |
| 6123 | goto done; |
| 6124 | |
| 6125 | sp->type = SRB_MB_IOCB; |
| 6126 | sp->name = mb_to_str(mcp->mb[0]); |
| 6127 | |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6128 | c = &sp->u.iocb_cmd; |
| 6129 | c->timeout = qla2x00_async_iocb_timeout; |
| 6130 | init_completion(&c->u.mbx.comp); |
| 6131 | |
Ben Hutchings | e74e7d9 | 2018-03-20 21:36:14 +0000 | [diff] [blame] | 6132 | qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); |
| 6133 | |
| 6134 | memcpy(sp->u.iocb_cmd.u.mbx.out_mb, mcp->mb, SIZEOF_IOCB_MB_REG); |
| 6135 | |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6136 | sp->done = qla2x00_async_mb_sp_done; |
| 6137 | |
| 6138 | rval = qla2x00_start_sp(sp); |
| 6139 | if (rval != QLA_SUCCESS) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6140 | ql_dbg(ql_dbg_mbx, vha, 0x1018, |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6141 | "%s: %s Failed submission. %x.\n", |
| 6142 | __func__, sp->name, rval); |
| 6143 | goto done_free_sp; |
| 6144 | } |
| 6145 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6146 | 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] | 6147 | sp->name, sp->handle); |
| 6148 | |
| 6149 | wait_for_completion(&c->u.mbx.comp); |
| 6150 | memcpy(mcp->mb, sp->u.iocb_cmd.u.mbx.in_mb, SIZEOF_IOCB_MB_REG); |
| 6151 | |
| 6152 | rval = c->u.mbx.rc; |
| 6153 | switch (rval) { |
| 6154 | case QLA_FUNCTION_TIMEOUT: |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6155 | ql_dbg(ql_dbg_mbx, vha, 0x1140, "%s: %s Timeout. %x.\n", |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6156 | __func__, sp->name, rval); |
| 6157 | break; |
| 6158 | case QLA_SUCCESS: |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6159 | ql_dbg(ql_dbg_mbx, vha, 0x119d, "%s: %s done.\n", |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6160 | __func__, sp->name); |
| 6161 | sp->free(sp); |
| 6162 | break; |
| 6163 | default: |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6164 | ql_dbg(ql_dbg_mbx, vha, 0x119e, "%s: %s Failed. %x.\n", |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6165 | __func__, sp->name, rval); |
| 6166 | sp->free(sp); |
| 6167 | break; |
| 6168 | } |
| 6169 | |
| 6170 | return rval; |
| 6171 | |
| 6172 | done_free_sp: |
| 6173 | sp->free(sp); |
| 6174 | done: |
| 6175 | return rval; |
| 6176 | } |
| 6177 | |
| 6178 | /* |
| 6179 | * qla24xx_gpdb_wait |
| 6180 | * NOTE: Do not call this routine from DPC thread |
| 6181 | */ |
| 6182 | int qla24xx_gpdb_wait(struct scsi_qla_host *vha, fc_port_t *fcport, u8 opt) |
| 6183 | { |
| 6184 | int rval = QLA_FUNCTION_FAILED; |
| 6185 | dma_addr_t pd_dma; |
| 6186 | struct port_database_24xx *pd; |
| 6187 | struct qla_hw_data *ha = vha->hw; |
| 6188 | mbx_cmd_t mc; |
| 6189 | |
| 6190 | if (!vha->hw->flags.fw_started) |
| 6191 | goto done; |
| 6192 | |
Thomas Meyer | 08eb7f4 | 2017-09-21 08:15:26 +0200 | [diff] [blame] | 6193 | pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6194 | if (pd == NULL) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6195 | ql_log(ql_log_warn, vha, 0xd047, |
| 6196 | "Failed to allocate port database structure.\n"); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6197 | goto done_free_sp; |
| 6198 | } |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6199 | |
| 6200 | memset(&mc, 0, sizeof(mc)); |
| 6201 | mc.mb[0] = MBC_GET_PORT_DATABASE; |
| 6202 | mc.mb[1] = cpu_to_le16(fcport->loop_id); |
| 6203 | mc.mb[2] = MSW(pd_dma); |
| 6204 | mc.mb[3] = LSW(pd_dma); |
| 6205 | mc.mb[6] = MSW(MSD(pd_dma)); |
| 6206 | mc.mb[7] = LSW(MSD(pd_dma)); |
| 6207 | mc.mb[9] = cpu_to_le16(vha->vp_idx); |
| 6208 | mc.mb[10] = cpu_to_le16((uint16_t)opt); |
| 6209 | |
| 6210 | rval = qla24xx_send_mb_cmd(vha, &mc); |
| 6211 | if (rval != QLA_SUCCESS) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6212 | ql_dbg(ql_dbg_mbx, vha, 0x1193, |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6213 | "%s: %8phC fail\n", __func__, fcport->port_name); |
| 6214 | goto done_free_sp; |
| 6215 | } |
| 6216 | |
| 6217 | rval = __qla24xx_parse_gpdb(vha, fcport, pd); |
| 6218 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6219 | ql_dbg(ql_dbg_mbx, vha, 0x1197, "%s: %8phC done\n", |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6220 | __func__, fcport->port_name); |
| 6221 | |
| 6222 | done_free_sp: |
| 6223 | if (pd) |
| 6224 | dma_pool_free(ha->s_dma_pool, pd, pd_dma); |
| 6225 | done: |
| 6226 | return rval; |
| 6227 | } |
| 6228 | |
| 6229 | int __qla24xx_parse_gpdb(struct scsi_qla_host *vha, fc_port_t *fcport, |
| 6230 | struct port_database_24xx *pd) |
| 6231 | { |
| 6232 | int rval = QLA_SUCCESS; |
| 6233 | uint64_t zero = 0; |
Duane Grigsby | a5d42f4 | 2017-06-21 13:48:41 -0700 | [diff] [blame] | 6234 | u8 current_login_state, last_login_state; |
| 6235 | |
| 6236 | if (fcport->fc4f_nvme) { |
| 6237 | current_login_state = pd->current_login_state >> 4; |
| 6238 | last_login_state = pd->last_login_state >> 4; |
| 6239 | } else { |
| 6240 | current_login_state = pd->current_login_state & 0xf; |
| 6241 | last_login_state = pd->last_login_state & 0xf; |
| 6242 | } |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6243 | |
| 6244 | /* Check for logged in state. */ |
Quinn Tran | 23c6455 | 2017-12-04 14:45:08 -0800 | [diff] [blame] | 6245 | if (current_login_state != PDS_PRLI_COMPLETE) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6246 | ql_dbg(ql_dbg_mbx, vha, 0x119a, |
| 6247 | "Unable to verify login-state (%x/%x) for loop_id %x.\n", |
Duane Grigsby | a5d42f4 | 2017-06-21 13:48:41 -0700 | [diff] [blame] | 6248 | current_login_state, last_login_state, fcport->loop_id); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6249 | rval = QLA_FUNCTION_FAILED; |
| 6250 | goto gpd_error_out; |
| 6251 | } |
| 6252 | |
| 6253 | if (fcport->loop_id == FC_NO_LOOP_ID || |
| 6254 | (memcmp(fcport->port_name, (uint8_t *)&zero, 8) && |
| 6255 | memcmp(fcport->port_name, pd->port_name, 8))) { |
| 6256 | /* We lost the device mid way. */ |
| 6257 | rval = QLA_NOT_LOGGED_IN; |
| 6258 | goto gpd_error_out; |
| 6259 | } |
| 6260 | |
| 6261 | /* Names are little-endian. */ |
| 6262 | memcpy(fcport->node_name, pd->node_name, WWN_SIZE); |
| 6263 | memcpy(fcport->port_name, pd->port_name, WWN_SIZE); |
| 6264 | |
| 6265 | /* Get port_id of device. */ |
| 6266 | fcport->d_id.b.domain = pd->port_id[0]; |
| 6267 | fcport->d_id.b.area = pd->port_id[1]; |
| 6268 | fcport->d_id.b.al_pa = pd->port_id[2]; |
| 6269 | fcport->d_id.b.rsvd_1 = 0; |
| 6270 | |
Duane Grigsby | a5d42f4 | 2017-06-21 13:48:41 -0700 | [diff] [blame] | 6271 | if (fcport->fc4f_nvme) { |
| 6272 | fcport->nvme_prli_service_param = |
| 6273 | pd->prli_nvme_svc_param_word_3; |
| 6274 | fcport->port_type = FCT_NVME; |
| 6275 | } else { |
| 6276 | /* If not target must be initiator or unknown type. */ |
| 6277 | if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0) |
| 6278 | fcport->port_type = FCT_INITIATOR; |
| 6279 | else |
| 6280 | fcport->port_type = FCT_TARGET; |
| 6281 | } |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6282 | /* Passback COS information. */ |
| 6283 | fcport->supported_classes = (pd->flags & PDF_CLASS_2) ? |
| 6284 | FC_COS_CLASS2 : FC_COS_CLASS3; |
| 6285 | |
| 6286 | if (pd->prli_svc_param_word_3[0] & BIT_7) { |
| 6287 | fcport->flags |= FCF_CONF_COMP_SUPPORTED; |
| 6288 | fcport->conf_compl_supported = 1; |
| 6289 | } |
| 6290 | |
| 6291 | gpd_error_out: |
| 6292 | return rval; |
| 6293 | } |
| 6294 | |
| 6295 | /* |
| 6296 | * qla24xx_gidlist__wait |
| 6297 | * NOTE: don't call this routine from DPC thread. |
| 6298 | */ |
| 6299 | int qla24xx_gidlist_wait(struct scsi_qla_host *vha, |
| 6300 | void *id_list, dma_addr_t id_list_dma, uint16_t *entries) |
| 6301 | { |
| 6302 | int rval = QLA_FUNCTION_FAILED; |
| 6303 | mbx_cmd_t mc; |
| 6304 | |
| 6305 | if (!vha->hw->flags.fw_started) |
| 6306 | goto done; |
| 6307 | |
| 6308 | memset(&mc, 0, sizeof(mc)); |
| 6309 | mc.mb[0] = MBC_GET_ID_LIST; |
| 6310 | mc.mb[2] = MSW(id_list_dma); |
| 6311 | mc.mb[3] = LSW(id_list_dma); |
| 6312 | mc.mb[6] = MSW(MSD(id_list_dma)); |
| 6313 | mc.mb[7] = LSW(MSD(id_list_dma)); |
| 6314 | mc.mb[8] = 0; |
| 6315 | mc.mb[9] = cpu_to_le16(vha->vp_idx); |
| 6316 | |
| 6317 | rval = qla24xx_send_mb_cmd(vha, &mc); |
| 6318 | if (rval != QLA_SUCCESS) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6319 | ql_dbg(ql_dbg_mbx, vha, 0x119b, |
| 6320 | "%s: fail\n", __func__); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6321 | } else { |
| 6322 | *entries = mc.mb[1]; |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 6323 | ql_dbg(ql_dbg_mbx, vha, 0x119c, |
| 6324 | "%s: done\n", __func__); |
Quinn Tran | 15f30a5 | 2017-03-15 09:48:52 -0700 | [diff] [blame] | 6325 | } |
| 6326 | done: |
| 6327 | return rval; |
| 6328 | } |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 6329 | |
| 6330 | int qla27xx_set_zio_threshold(scsi_qla_host_t *vha, uint16_t value) |
| 6331 | { |
| 6332 | int rval; |
| 6333 | mbx_cmd_t mc; |
| 6334 | mbx_cmd_t *mcp = &mc; |
| 6335 | |
| 6336 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1200, |
| 6337 | "Entered %s\n", __func__); |
| 6338 | |
| 6339 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 6340 | mcp->mb[0] = MBC_GET_SET_ZIO_THRESHOLD; |
| 6341 | mcp->mb[1] = cpu_to_le16(1); |
| 6342 | mcp->mb[2] = cpu_to_le16(value); |
| 6343 | mcp->out_mb = MBX_2 | MBX_1 | MBX_0; |
| 6344 | mcp->in_mb = MBX_2 | MBX_0; |
| 6345 | mcp->tov = MBX_TOV_SECONDS; |
| 6346 | mcp->flags = 0; |
| 6347 | |
| 6348 | rval = qla2x00_mailbox_command(vha, mcp); |
| 6349 | |
| 6350 | ql_dbg(ql_dbg_mbx, vha, 0x1201, "%s %x\n", |
| 6351 | (rval != QLA_SUCCESS) ? "Failed" : "Done", rval); |
| 6352 | |
| 6353 | return rval; |
| 6354 | } |
| 6355 | |
| 6356 | int qla27xx_get_zio_threshold(scsi_qla_host_t *vha, uint16_t *value) |
| 6357 | { |
| 6358 | int rval; |
| 6359 | mbx_cmd_t mc; |
| 6360 | mbx_cmd_t *mcp = &mc; |
| 6361 | |
| 6362 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1203, |
| 6363 | "Entered %s\n", __func__); |
| 6364 | |
| 6365 | memset(mcp->mb, 0, sizeof(mcp->mb)); |
| 6366 | mcp->mb[0] = MBC_GET_SET_ZIO_THRESHOLD; |
| 6367 | mcp->mb[1] = cpu_to_le16(0); |
| 6368 | mcp->out_mb = MBX_1 | MBX_0; |
| 6369 | mcp->in_mb = MBX_2 | MBX_0; |
| 6370 | mcp->tov = MBX_TOV_SECONDS; |
| 6371 | mcp->flags = 0; |
| 6372 | |
| 6373 | rval = qla2x00_mailbox_command(vha, mcp); |
| 6374 | if (rval == QLA_SUCCESS) |
| 6375 | *value = mc.mb[2]; |
| 6376 | |
| 6377 | ql_dbg(ql_dbg_mbx, vha, 0x1205, "%s %x\n", |
| 6378 | (rval != QLA_SUCCESS) ? "Failed" : "Done", rval); |
| 6379 | |
| 6380 | return rval; |
| 6381 | } |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 6382 | |
| 6383 | int |
| 6384 | qla2x00_read_sfp_dev(struct scsi_qla_host *vha, char *buf, int count) |
| 6385 | { |
| 6386 | struct qla_hw_data *ha = vha->hw; |
| 6387 | uint16_t iter, addr, offset; |
| 6388 | dma_addr_t phys_addr; |
| 6389 | int rval, c; |
| 6390 | u8 *sfp_data; |
| 6391 | |
| 6392 | memset(ha->sfp_data, 0, SFP_DEV_SIZE); |
| 6393 | addr = 0xa0; |
| 6394 | phys_addr = ha->sfp_data_dma; |
| 6395 | sfp_data = ha->sfp_data; |
| 6396 | offset = c = 0; |
| 6397 | |
| 6398 | for (iter = 0; iter < SFP_DEV_SIZE / SFP_BLOCK_SIZE; iter++) { |
| 6399 | if (iter == 4) { |
| 6400 | /* Skip to next device address. */ |
| 6401 | addr = 0xa2; |
| 6402 | offset = 0; |
| 6403 | } |
| 6404 | |
| 6405 | rval = qla2x00_read_sfp(vha, phys_addr, sfp_data, |
| 6406 | addr, offset, SFP_BLOCK_SIZE, BIT_1); |
| 6407 | if (rval != QLA_SUCCESS) { |
| 6408 | ql_log(ql_log_warn, vha, 0x706d, |
| 6409 | "Unable to read SFP data (%x/%x/%x).\n", rval, |
| 6410 | addr, offset); |
| 6411 | |
| 6412 | return rval; |
| 6413 | } |
| 6414 | |
| 6415 | if (buf && (c < count)) { |
| 6416 | u16 sz; |
| 6417 | |
| 6418 | if ((count - c) >= SFP_BLOCK_SIZE) |
| 6419 | sz = SFP_BLOCK_SIZE; |
| 6420 | else |
| 6421 | sz = count - c; |
| 6422 | |
| 6423 | memcpy(buf, sfp_data, sz); |
| 6424 | buf += SFP_BLOCK_SIZE; |
| 6425 | c += sz; |
| 6426 | } |
| 6427 | phys_addr += SFP_BLOCK_SIZE; |
| 6428 | sfp_data += SFP_BLOCK_SIZE; |
| 6429 | offset += SFP_BLOCK_SIZE; |
| 6430 | } |
| 6431 | |
| 6432 | return rval; |
| 6433 | } |
Quinn Tran | 94d83e3 | 2017-12-28 12:33:23 -0800 | [diff] [blame] | 6434 | |
| 6435 | int qla24xx_res_count_wait(struct scsi_qla_host *vha, |
| 6436 | uint16_t *out_mb, int out_mb_sz) |
| 6437 | { |
| 6438 | int rval = QLA_FUNCTION_FAILED; |
| 6439 | mbx_cmd_t mc; |
| 6440 | |
| 6441 | if (!vha->hw->flags.fw_started) |
| 6442 | goto done; |
| 6443 | |
| 6444 | memset(&mc, 0, sizeof(mc)); |
| 6445 | mc.mb[0] = MBC_GET_RESOURCE_COUNTS; |
| 6446 | |
| 6447 | rval = qla24xx_send_mb_cmd(vha, &mc); |
| 6448 | if (rval != QLA_SUCCESS) { |
| 6449 | ql_dbg(ql_dbg_mbx, vha, 0xffff, |
| 6450 | "%s: fail\n", __func__); |
| 6451 | } else { |
| 6452 | if (out_mb_sz <= SIZEOF_IOCB_MB_REG) |
| 6453 | memcpy(out_mb, mc.mb, out_mb_sz); |
| 6454 | else |
| 6455 | memcpy(out_mb, mc.mb, SIZEOF_IOCB_MB_REG); |
| 6456 | |
| 6457 | ql_dbg(ql_dbg_mbx, vha, 0xffff, |
| 6458 | "%s: done\n", __func__); |
| 6459 | } |
| 6460 | done: |
| 6461 | return rval; |
| 6462 | } |