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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
| 14 | /* |
| 15 | * qla2x00_mailbox_command |
| 16 | * Issue mailbox command and waits for completion. |
| 17 | * |
| 18 | * Input: |
| 19 | * ha = adapter block pointer. |
| 20 | * mcp = driver internal mbx struct pointer. |
| 21 | * |
| 22 | * Output: |
| 23 | * mb[MAX_MAILBOX_REGISTER_COUNT] = returned mailbox data. |
| 24 | * |
| 25 | * Returns: |
| 26 | * 0 : QLA_SUCCESS = cmd performed success |
| 27 | * 1 : QLA_FUNCTION_FAILED (error encountered) |
| 28 | * 6 : QLA_FUNCTION_TIMEOUT (timeout condition encountered) |
| 29 | * |
| 30 | * Context: |
| 31 | * Kernel context. |
| 32 | */ |
| 33 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 34 | qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | { |
Himanshu Madhani | d14e72f | 2015-04-09 15:00:03 -0400 | [diff] [blame] | 36 | int rval, i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | unsigned long flags = 0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 38 | device_reg_t *reg; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 39 | uint8_t abort_active; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 40 | uint8_t io_lock_on; |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 41 | uint16_t command = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | uint16_t *iptr; |
| 43 | uint16_t __iomem *optr; |
| 44 | uint32_t cnt; |
| 45 | uint32_t mboxes; |
Himanshu Madhani | d14e72f | 2015-04-09 15:00:03 -0400 | [diff] [blame] | 46 | uint16_t __iomem *mbx_reg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | unsigned long wait_time; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 48 | struct qla_hw_data *ha = vha->hw; |
| 49 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 50 | |
Himanshu Madhani | d14e72f | 2015-04-09 15:00:03 -0400 | [diff] [blame] | 51 | |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 52 | ql_dbg(ql_dbg_mbx, vha, 0x1000, "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 53 | |
| 54 | if (ha->pdev->error_state > pci_channel_io_frozen) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 55 | ql_log(ql_log_warn, vha, 0x1001, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 56 | "error_state is greater than pci_channel_io_frozen, " |
| 57 | "exiting.\n"); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 58 | return QLA_FUNCTION_TIMEOUT; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 59 | } |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 60 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 61 | if (vha->device_flags & DFLG_DEV_FAILED) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 62 | ql_log(ql_log_warn, vha, 0x1002, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 63 | "Device in failed state, exiting.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 64 | return QLA_FUNCTION_TIMEOUT; |
| 65 | } |
| 66 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 67 | reg = ha->iobase; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 68 | io_lock_on = base_vha->flags.init_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
| 70 | rval = QLA_SUCCESS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 71 | abort_active = test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 73 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 74 | if (ha->flags.pci_channel_io_perm_failure) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 75 | ql_log(ql_log_warn, vha, 0x1003, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 76 | "Perm failure on EEH timeout MBX, exiting.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 77 | return QLA_FUNCTION_TIMEOUT; |
| 78 | } |
| 79 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 80 | if (IS_P3P_TYPE(ha) && ha->flags.isp82xx_fw_hung) { |
Giridhar Malavali | 862cd01 | 2011-02-23 15:27:11 -0800 | [diff] [blame] | 81 | /* Setting Link-Down error */ |
| 82 | mcp->mb[0] = MBS_LINK_DOWN_ERROR; |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 83 | ql_log(ql_log_warn, vha, 0x1004, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 84 | "FW hung = %d.\n", ha->flags.isp82xx_fw_hung); |
Andrew Vasquez | 1806fcd | 2011-11-18 09:02:15 -0800 | [diff] [blame] | 85 | return QLA_FUNCTION_TIMEOUT; |
Giridhar Malavali | 862cd01 | 2011-02-23 15:27:11 -0800 | [diff] [blame] | 86 | } |
| 87 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | /* |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 89 | * Wait for active mailbox commands to finish by waiting at most tov |
| 90 | * seconds. This is to serialize actual issuing of mailbox cmds during |
| 91 | * non ISP abort time. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | */ |
Andrew Vasquez | 8eca3f3 | 2009-01-22 09:45:31 -0800 | [diff] [blame] | 93 | if (!wait_for_completion_timeout(&ha->mbx_cmd_comp, mcp->tov * HZ)) { |
| 94 | /* Timeout occurred. Return error. */ |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 95 | ql_log(ql_log_warn, vha, 0x1005, |
Chad Dupuis | d8c0d54 | 2012-02-09 11:15:46 -0800 | [diff] [blame] | 96 | "Cmd access timeout, cmd=0x%x, Exiting.\n", |
| 97 | mcp->mb[0]); |
Andrew Vasquez | 8eca3f3 | 2009-01-22 09:45:31 -0800 | [diff] [blame] | 98 | return QLA_FUNCTION_TIMEOUT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | ha->flags.mbox_busy = 1; |
| 102 | /* Save mailbox command for debug */ |
| 103 | ha->mcp = mcp; |
| 104 | |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 105 | ql_dbg(ql_dbg_mbx, vha, 0x1006, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 106 | "Prepare to issue mbox cmd=0x%x.\n", mcp->mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | |
| 108 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 109 | |
| 110 | /* Load mailbox registers. */ |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 111 | if (IS_P3P_TYPE(ha)) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 112 | optr = (uint16_t __iomem *)®->isp82.mailbox_in[0]; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 113 | else if (IS_FWI2_CAPABLE(ha) && !(IS_P3P_TYPE(ha))) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 114 | optr = (uint16_t __iomem *)®->isp24.mailbox0; |
| 115 | else |
| 116 | optr = (uint16_t __iomem *)MAILBOX_REG(ha, ®->isp, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | |
| 118 | iptr = mcp->mb; |
| 119 | command = mcp->mb[0]; |
| 120 | mboxes = mcp->out_mb; |
| 121 | |
Joe Carnuccio | 7b71162 | 2014-09-25 05:16:43 -0400 | [diff] [blame] | 122 | ql_dbg(ql_dbg_mbx, vha, 0x1111, |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 123 | "Mailbox registers (OUT):\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | for (cnt = 0; cnt < ha->mbx_count; cnt++) { |
| 125 | if (IS_QLA2200(ha) && cnt == 8) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 126 | optr = |
| 127 | (uint16_t __iomem *)MAILBOX_REG(ha, ®->isp, 8); |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 128 | if (mboxes & BIT_0) { |
| 129 | ql_dbg(ql_dbg_mbx, vha, 0x1112, |
| 130 | "mbox[%d]<-0x%04x\n", cnt, *iptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | WRT_REG_WORD(optr, *iptr); |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 132 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | |
| 134 | mboxes >>= 1; |
| 135 | optr++; |
| 136 | iptr++; |
| 137 | } |
| 138 | |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 139 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1117, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 140 | "I/O Address = %p.\n", optr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | |
| 142 | /* Issue set host interrupt command to send cmd out. */ |
| 143 | ha->flags.mbox_int = 0; |
| 144 | clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
| 145 | |
| 146 | /* Unlock mbx registers and wait for interrupt */ |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 147 | ql_dbg(ql_dbg_mbx, vha, 0x100f, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 148 | "Going to unlock irq & waiting for interrupts. " |
| 149 | "jiffies=%lx.\n", jiffies); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | |
| 151 | /* Wait for mbx cmd completion until timeout */ |
| 152 | |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 153 | if ((!abort_active && io_lock_on) || IS_NOPOLLING_TYPE(ha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | set_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); |
| 155 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 156 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 157 | if (RD_REG_DWORD(®->isp82.hint) & |
| 158 | HINT_MBX_INT_PENDING) { |
| 159 | spin_unlock_irqrestore(&ha->hardware_lock, |
| 160 | flags); |
Giridhar Malavali | 8937f2f | 2011-11-18 09:02:18 -0800 | [diff] [blame] | 161 | ha->flags.mbox_busy = 0; |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 162 | ql_dbg(ql_dbg_mbx, vha, 0x1010, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 163 | "Pending mailbox timeout, exiting.\n"); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 164 | rval = QLA_FUNCTION_TIMEOUT; |
| 165 | goto premature_exit; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 166 | } |
| 167 | WRT_REG_DWORD(®->isp82.hint, HINT_MBX_INT_PENDING); |
| 168 | } else if (IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 169 | WRT_REG_DWORD(®->isp24.hccr, HCCRX_SET_HOST_INT); |
| 170 | else |
| 171 | WRT_REG_WORD(®->isp.hccr, HCCR_SET_HOST_INT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 173 | |
Giridhar Malavali | 754d124 | 2013-06-25 11:27:16 -0400 | [diff] [blame] | 174 | if (!wait_for_completion_timeout(&ha->mbx_intr_comp, |
| 175 | mcp->tov * HZ)) { |
| 176 | ql_dbg(ql_dbg_mbx, vha, 0x117a, |
| 177 | "cmd=%x Timeout.\n", command); |
| 178 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 179 | clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); |
| 180 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 181 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | } else { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 183 | ql_dbg(ql_dbg_mbx, vha, 0x1011, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 184 | "Cmd=%x Polling Mode.\n", command); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 186 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 187 | if (RD_REG_DWORD(®->isp82.hint) & |
| 188 | HINT_MBX_INT_PENDING) { |
| 189 | spin_unlock_irqrestore(&ha->hardware_lock, |
| 190 | flags); |
Giridhar Malavali | 8937f2f | 2011-11-18 09:02:18 -0800 | [diff] [blame] | 191 | ha->flags.mbox_busy = 0; |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 192 | ql_dbg(ql_dbg_mbx, vha, 0x1012, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 193 | "Pending mailbox timeout, exiting.\n"); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 194 | rval = QLA_FUNCTION_TIMEOUT; |
| 195 | goto premature_exit; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 196 | } |
| 197 | WRT_REG_DWORD(®->isp82.hint, HINT_MBX_INT_PENDING); |
| 198 | } else if (IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 199 | WRT_REG_DWORD(®->isp24.hccr, HCCRX_SET_HOST_INT); |
| 200 | else |
| 201 | WRT_REG_WORD(®->isp.hccr, HCCR_SET_HOST_INT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | |
| 204 | wait_time = jiffies + mcp->tov * HZ; /* wait at most tov secs */ |
| 205 | while (!ha->flags.mbox_int) { |
| 206 | if (time_after(jiffies, wait_time)) |
| 207 | break; |
| 208 | |
| 209 | /* Check for pending interrupts. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 210 | qla2x00_poll(ha->rsp_q_map[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 212 | if (!ha->flags.mbox_int && |
| 213 | !(IS_QLA2200(ha) && |
| 214 | command == MBC_LOAD_RISC_RAM_EXTENDED)) |
andrew.vasquez@qlogic.com | 5998983 | 2006-01-13 17:05:10 -0800 | [diff] [blame] | 215 | msleep(10); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | } /* while */ |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 217 | ql_dbg(ql_dbg_mbx, vha, 0x1013, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 218 | "Waited %d sec.\n", |
| 219 | (uint)((jiffies - (wait_time - (mcp->tov * HZ)))/HZ)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | } |
| 221 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | /* Check whether we timed out */ |
| 223 | if (ha->flags.mbox_int) { |
| 224 | uint16_t *iptr2; |
| 225 | |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 226 | ql_dbg(ql_dbg_mbx, vha, 0x1014, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 227 | "Cmd=%x completed.\n", command); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | |
| 229 | /* Got interrupt. Clear the flag. */ |
| 230 | ha->flags.mbox_int = 0; |
| 231 | clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
| 232 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 233 | if (IS_P3P_TYPE(ha) && ha->flags.isp82xx_fw_hung) { |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 234 | ha->flags.mbox_busy = 0; |
| 235 | /* Setting Link-Down error */ |
| 236 | mcp->mb[0] = MBS_LINK_DOWN_ERROR; |
| 237 | ha->mcp = NULL; |
| 238 | rval = QLA_FUNCTION_FAILED; |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 239 | ql_log(ql_log_warn, vha, 0x1015, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 240 | "FW hung = %d.\n", ha->flags.isp82xx_fw_hung); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 241 | goto premature_exit; |
| 242 | } |
| 243 | |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 244 | if (ha->mailbox_out[0] != MBS_COMMAND_COMPLETE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | rval = QLA_FUNCTION_FAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | |
| 247 | /* Load return mailbox registers. */ |
| 248 | iptr2 = mcp->mb; |
| 249 | iptr = (uint16_t *)&ha->mailbox_out[0]; |
| 250 | mboxes = mcp->in_mb; |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 251 | |
| 252 | ql_dbg(ql_dbg_mbx, vha, 0x1113, |
| 253 | "Mailbox registers (IN):\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | for (cnt = 0; cnt < ha->mbx_count; cnt++) { |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 255 | if (mboxes & BIT_0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | *iptr2 = *iptr; |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 257 | ql_dbg(ql_dbg_mbx, vha, 0x1114, |
| 258 | "mbox[%d]->0x%04x\n", cnt, *iptr2); |
| 259 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | |
| 261 | mboxes >>= 1; |
| 262 | iptr2++; |
| 263 | iptr++; |
| 264 | } |
| 265 | } else { |
| 266 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 267 | uint16_t mb0; |
| 268 | uint32_t ictrl; |
| 269 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 270 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 271 | mb0 = RD_REG_WORD(®->isp24.mailbox0); |
| 272 | ictrl = RD_REG_DWORD(®->isp24.ictrl); |
| 273 | } else { |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 274 | mb0 = RD_MAILBOX_REG(ha, ®->isp, 0); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 275 | ictrl = RD_REG_WORD(®->isp.ictrl); |
| 276 | } |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 277 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1119, |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 278 | "MBX Command timeout for cmd %x, iocontrol=%x jiffies=%lx " |
| 279 | "mb[0]=0x%x\n", command, ictrl, jiffies, mb0); |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 280 | ql_dump_regs(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1019); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | |
Chad Dupuis | f55bfc8 | 2012-02-09 11:15:53 -0800 | [diff] [blame] | 282 | /* |
| 283 | * Attempt to capture a firmware dump for further analysis |
Chad Dupuis | b8eb413 | 2013-06-25 11:27:20 -0400 | [diff] [blame] | 284 | * of the current firmware state. We do not need to do this |
| 285 | * if we are intentionally generating a dump. |
Chad Dupuis | f55bfc8 | 2012-02-09 11:15:53 -0800 | [diff] [blame] | 286 | */ |
Chad Dupuis | b8eb413 | 2013-06-25 11:27:20 -0400 | [diff] [blame] | 287 | if (mcp->mb[0] != MBC_GEN_SYSTEM_ERROR) |
| 288 | ha->isp_ops->fw_dump(vha, 0); |
Chad Dupuis | f55bfc8 | 2012-02-09 11:15:53 -0800 | [diff] [blame] | 289 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | rval = QLA_FUNCTION_TIMEOUT; |
| 291 | } |
| 292 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | ha->flags.mbox_busy = 0; |
| 294 | |
| 295 | /* Clean up */ |
| 296 | ha->mcp = NULL; |
| 297 | |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 298 | if ((abort_active || !io_lock_on) && !IS_NOPOLLING_TYPE(ha)) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 299 | ql_dbg(ql_dbg_mbx, vha, 0x101a, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 300 | "Checking for additional resp interrupt.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | |
| 302 | /* polling mode for non isp_abort commands. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 303 | qla2x00_poll(ha->rsp_q_map[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | } |
| 305 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 306 | if (rval == QLA_FUNCTION_TIMEOUT && |
| 307 | mcp->mb[0] != MBC_GEN_SYSTEM_ERROR) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 308 | if (!io_lock_on || (mcp->flags & IOCTL_CMD) || |
| 309 | ha->flags.eeh_busy) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | /* not in dpc. schedule it for dpc to take over. */ |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 311 | ql_dbg(ql_dbg_mbx, vha, 0x101b, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 312 | "Timeout, schedule isp_abort_needed.\n"); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 313 | |
| 314 | if (!test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) && |
| 315 | !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) && |
| 316 | !test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) { |
Giridhar Malavali | 6315491 | 2011-11-18 09:02:19 -0800 | [diff] [blame] | 317 | if (IS_QLA82XX(ha)) { |
| 318 | ql_dbg(ql_dbg_mbx, vha, 0x112a, |
| 319 | "disabling pause transmit on port " |
| 320 | "0 & 1.\n"); |
| 321 | qla82xx_wr_32(ha, |
| 322 | QLA82XX_CRB_NIU + 0x98, |
| 323 | CRB_NIU_XG_PAUSE_CTL_P0| |
| 324 | CRB_NIU_XG_PAUSE_CTL_P1); |
| 325 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 326 | ql_log(ql_log_info, base_vha, 0x101c, |
Masanari Iida | 24d9ee8 | 2012-05-15 14:34:10 -0400 | [diff] [blame] | 327 | "Mailbox cmd timeout occurred, cmd=0x%x, " |
Chad Dupuis | d8c0d54 | 2012-02-09 11:15:46 -0800 | [diff] [blame] | 328 | "mb[0]=0x%x, eeh_busy=0x%x. Scheduling ISP " |
| 329 | "abort.\n", command, mcp->mb[0], |
| 330 | ha->flags.eeh_busy); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 331 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 332 | qla2xxx_wake_dpc(vha); |
| 333 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | } else if (!abort_active) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | /* call abort directly since we are in the DPC thread */ |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 336 | ql_dbg(ql_dbg_mbx, vha, 0x101d, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 337 | "Timeout, calling abort_isp.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 339 | if (!test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) && |
| 340 | !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) && |
| 341 | !test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) { |
Giridhar Malavali | 6315491 | 2011-11-18 09:02:19 -0800 | [diff] [blame] | 342 | if (IS_QLA82XX(ha)) { |
| 343 | ql_dbg(ql_dbg_mbx, vha, 0x112b, |
| 344 | "disabling pause transmit on port " |
| 345 | "0 & 1.\n"); |
| 346 | qla82xx_wr_32(ha, |
| 347 | QLA82XX_CRB_NIU + 0x98, |
| 348 | CRB_NIU_XG_PAUSE_CTL_P0| |
| 349 | CRB_NIU_XG_PAUSE_CTL_P1); |
| 350 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 351 | ql_log(ql_log_info, base_vha, 0x101e, |
Masanari Iida | 24d9ee8 | 2012-05-15 14:34:10 -0400 | [diff] [blame] | 352 | "Mailbox cmd timeout occurred, cmd=0x%x, " |
Chad Dupuis | d8c0d54 | 2012-02-09 11:15:46 -0800 | [diff] [blame] | 353 | "mb[0]=0x%x. Scheduling ISP abort ", |
| 354 | command, mcp->mb[0]); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 355 | set_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags); |
| 356 | clear_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Giridhar Malavali | d336096 | 2012-02-09 11:14:10 -0800 | [diff] [blame] | 357 | /* Allow next mbx cmd to come in. */ |
| 358 | complete(&ha->mbx_cmd_comp); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 359 | if (ha->isp_ops->abort_isp(vha)) { |
| 360 | /* Failed. retry later. */ |
| 361 | set_bit(ISP_ABORT_NEEDED, |
| 362 | &vha->dpc_flags); |
| 363 | } |
| 364 | clear_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags); |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 365 | ql_dbg(ql_dbg_mbx, vha, 0x101f, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 366 | "Finished abort_isp.\n"); |
Giridhar Malavali | d336096 | 2012-02-09 11:14:10 -0800 | [diff] [blame] | 367 | goto mbx_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | } |
| 370 | } |
| 371 | |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 372 | premature_exit: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | /* Allow next mbx cmd to come in. */ |
Andrew Vasquez | 8eca3f3 | 2009-01-22 09:45:31 -0800 | [diff] [blame] | 374 | complete(&ha->mbx_cmd_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | |
Giridhar Malavali | d336096 | 2012-02-09 11:14:10 -0800 | [diff] [blame] | 376 | mbx_done: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | if (rval) { |
Chad Dupuis | 34c5801 | 2014-08-08 07:38:08 -0400 | [diff] [blame] | 378 | ql_dbg(ql_dbg_disc, base_vha, 0x1020, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 379 | "**** Failed mbx[0]=%x, mb[1]=%x, mb[2]=%x, mb[3]=%x, cmd=%x ****.\n", |
| 380 | mcp->mb[0], mcp->mb[1], mcp->mb[2], mcp->mb[3], command); |
Himanshu Madhani | d14e72f | 2015-04-09 15:00:03 -0400 | [diff] [blame] | 381 | |
| 382 | ql_dbg(ql_dbg_disc, vha, 0x1115, |
| 383 | "host status: 0x%x, flags:0x%lx, intr ctrl reg:0x%x, intr status:0x%x\n", |
| 384 | RD_REG_DWORD(®->isp24.host_status), |
| 385 | ha->fw_dump_cap_flags, |
| 386 | RD_REG_DWORD(®->isp24.ictrl), |
| 387 | RD_REG_DWORD(®->isp24.istatus)); |
| 388 | |
| 389 | mbx_reg = ®->isp24.mailbox0; |
| 390 | for (i = 0; i < 6; i++) |
| 391 | ql_dbg(ql_dbg_disc + ql_dbg_verbose, vha, 0x1116, |
| 392 | "mbox[%d] 0x%04x\n", i, RD_REG_WORD(mbx_reg++)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 394 | ql_dbg(ql_dbg_mbx, base_vha, 0x1021, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | } |
| 396 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | return rval; |
| 398 | } |
| 399 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 401 | 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] | 402 | uint32_t risc_code_size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | { |
| 404 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 405 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | mbx_cmd_t mc; |
| 407 | mbx_cmd_t *mcp = &mc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 409 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1022, |
| 410 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 412 | if (MSW(risc_addr) || IS_FWI2_CAPABLE(ha)) { |
andrew.vasquez@qlogic.com | 590f98e | 2006-01-13 17:05:37 -0800 | [diff] [blame] | 413 | mcp->mb[0] = MBC_LOAD_RISC_RAM_EXTENDED; |
| 414 | mcp->mb[8] = MSW(risc_addr); |
| 415 | mcp->out_mb = MBX_8|MBX_0; |
| 416 | } else { |
| 417 | mcp->mb[0] = MBC_LOAD_RISC_RAM; |
| 418 | mcp->out_mb = MBX_0; |
| 419 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | mcp->mb[1] = LSW(risc_addr); |
| 421 | mcp->mb[2] = MSW(req_dma); |
| 422 | mcp->mb[3] = LSW(req_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | mcp->mb[6] = MSW(MSD(req_dma)); |
| 424 | mcp->mb[7] = LSW(MSD(req_dma)); |
andrew.vasquez@qlogic.com | 590f98e | 2006-01-13 17:05:37 -0800 | [diff] [blame] | 425 | 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] | 426 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 427 | mcp->mb[4] = MSW(risc_code_size); |
| 428 | mcp->mb[5] = LSW(risc_code_size); |
| 429 | mcp->out_mb |= MBX_5|MBX_4; |
| 430 | } else { |
| 431 | mcp->mb[4] = LSW(risc_code_size); |
| 432 | mcp->out_mb |= MBX_4; |
| 433 | } |
| 434 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 436 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 438 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 441 | ql_dbg(ql_dbg_mbx, vha, 0x1023, |
| 442 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 444 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1024, |
| 445 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | } |
| 447 | |
| 448 | return rval; |
| 449 | } |
| 450 | |
Santosh Vernekar | cad454b | 2010-03-19 16:59:16 -0700 | [diff] [blame] | 451 | #define EXTENDED_BB_CREDITS BIT_0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | /* |
| 453 | * qla2x00_execute_fw |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 454 | * Start adapter firmware. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | * |
| 456 | * Input: |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 457 | * ha = adapter block pointer. |
| 458 | * TARGET_QUEUE_LOCK must be released. |
| 459 | * ADAPTER_STATE_LOCK must be released. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | * |
| 461 | * Returns: |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 462 | * qla2x00 local function return status code. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | * |
| 464 | * Context: |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 465 | * Kernel context. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | */ |
| 467 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 468 | qla2x00_execute_fw(scsi_qla_host_t *vha, uint32_t risc_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | { |
| 470 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 471 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | mbx_cmd_t mc; |
| 473 | mbx_cmd_t *mcp = &mc; |
| 474 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 475 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1025, |
| 476 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | |
| 478 | mcp->mb[0] = MBC_EXECUTE_FIRMWARE; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 479 | mcp->out_mb = MBX_0; |
| 480 | mcp->in_mb = MBX_0; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 481 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 482 | mcp->mb[1] = MSW(risc_addr); |
| 483 | mcp->mb[2] = LSW(risc_addr); |
| 484 | mcp->mb[3] = 0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 485 | if (IS_QLA25XX(ha) || IS_QLA81XX(ha) || IS_QLA83XX(ha) || |
| 486 | IS_QLA27XX(ha)) { |
Santosh Vernekar | cad454b | 2010-03-19 16:59:16 -0700 | [diff] [blame] | 487 | struct nvram_81xx *nv = ha->nvram; |
| 488 | mcp->mb[4] = (nv->enhanced_features & |
| 489 | EXTENDED_BB_CREDITS); |
| 490 | } else |
| 491 | mcp->mb[4] = 0; |
Andrew Vasquez | 8b3253d | 2007-09-20 14:07:48 -0700 | [diff] [blame] | 492 | mcp->out_mb |= MBX_4|MBX_3|MBX_2|MBX_1; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 493 | mcp->in_mb |= MBX_1; |
| 494 | } else { |
| 495 | mcp->mb[1] = LSW(risc_addr); |
| 496 | mcp->out_mb |= MBX_1; |
| 497 | if (IS_QLA2322(ha) || IS_QLA6322(ha)) { |
| 498 | mcp->mb[2] = 0; |
| 499 | mcp->out_mb |= MBX_2; |
| 500 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | } |
| 502 | |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 503 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 504 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 505 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 507 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 508 | ql_dbg(ql_dbg_mbx, vha, 0x1026, |
| 509 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 510 | } else { |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 511 | if (IS_FWI2_CAPABLE(ha)) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 512 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1027, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 513 | "Done exchanges=%x.\n", mcp->mb[1]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 514 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 515 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1028, |
| 516 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 517 | } |
| 518 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | |
| 520 | return rval; |
| 521 | } |
| 522 | |
| 523 | /* |
| 524 | * qla2x00_get_fw_version |
| 525 | * Get firmware version. |
| 526 | * |
| 527 | * Input: |
| 528 | * ha: adapter state pointer. |
| 529 | * major: pointer for major number. |
| 530 | * minor: pointer for minor number. |
| 531 | * subminor: pointer for subminor number. |
| 532 | * |
| 533 | * Returns: |
| 534 | * qla2x00 local function return status code. |
| 535 | * |
| 536 | * Context: |
| 537 | * Kernel context. |
| 538 | */ |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 539 | int |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 540 | qla2x00_get_fw_version(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | { |
| 542 | int rval; |
| 543 | mbx_cmd_t mc; |
| 544 | mbx_cmd_t *mcp = &mc; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 545 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 546 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 547 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1029, |
| 548 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | |
| 550 | mcp->mb[0] = MBC_GET_FIRMWARE_VERSION; |
| 551 | mcp->out_mb = MBX_0; |
| 552 | 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] | 553 | if (IS_QLA81XX(vha->hw) || IS_QLA8031(ha) || IS_QLA8044(ha)) |
Andrew Vasquez | 55a9615 | 2009-03-24 09:08:03 -0700 | [diff] [blame] | 554 | 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] | 555 | if (IS_FWI2_CAPABLE(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 556 | mcp->in_mb |= MBX_17|MBX_16|MBX_15; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 557 | if (IS_QLA27XX(ha)) |
| 558 | mcp->in_mb |= MBX_21|MBX_20|MBX_19|MBX_18; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | mcp->flags = 0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 560 | mcp->tov = MBX_TOV_SECONDS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 561 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 562 | if (rval != QLA_SUCCESS) |
| 563 | goto failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 564 | |
| 565 | /* Return mailbox data. */ |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 566 | ha->fw_major_version = mcp->mb[1]; |
| 567 | ha->fw_minor_version = mcp->mb[2]; |
| 568 | ha->fw_subminor_version = mcp->mb[3]; |
| 569 | ha->fw_attributes = mcp->mb[6]; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 570 | if (IS_QLA2100(vha->hw) || IS_QLA2200(vha->hw)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 571 | ha->fw_memory_size = 0x1FFFF; /* Defaults to 128KB. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 572 | else |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 573 | ha->fw_memory_size = (mcp->mb[5] << 16) | mcp->mb[4]; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 574 | if (IS_QLA81XX(vha->hw) || IS_QLA8031(vha->hw) || IS_QLA8044(ha)) { |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 575 | ha->mpi_version[0] = mcp->mb[10] & 0xff; |
| 576 | ha->mpi_version[1] = mcp->mb[11] >> 8; |
| 577 | ha->mpi_version[2] = mcp->mb[11] & 0xff; |
| 578 | ha->mpi_capabilities = (mcp->mb[12] << 16) | mcp->mb[13]; |
| 579 | ha->phy_version[0] = mcp->mb[8] & 0xff; |
| 580 | ha->phy_version[1] = mcp->mb[9] >> 8; |
| 581 | ha->phy_version[2] = mcp->mb[9] & 0xff; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 582 | } |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 583 | if (IS_FWI2_CAPABLE(ha)) { |
| 584 | ha->fw_attributes_h = mcp->mb[15]; |
| 585 | ha->fw_attributes_ext[0] = mcp->mb[16]; |
| 586 | ha->fw_attributes_ext[1] = mcp->mb[17]; |
| 587 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1139, |
| 588 | "%s: FW_attributes Upper: 0x%x, Lower: 0x%x.\n", |
| 589 | __func__, mcp->mb[15], mcp->mb[6]); |
| 590 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x112f, |
| 591 | "%s: Ext_FwAttributes Upper: 0x%x, Lower: 0x%x.\n", |
| 592 | __func__, mcp->mb[17], mcp->mb[16]); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 593 | } |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 594 | if (IS_QLA27XX(ha)) { |
| 595 | ha->fw_shared_ram_start = (mcp->mb[19] << 16) | mcp->mb[18]; |
| 596 | ha->fw_shared_ram_end = (mcp->mb[21] << 16) | mcp->mb[20]; |
| 597 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 598 | |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 599 | failed: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | if (rval != QLA_SUCCESS) { |
| 601 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 602 | ql_dbg(ql_dbg_mbx, vha, 0x102a, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | } else { |
| 604 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 605 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102b, |
| 606 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | } |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 608 | return rval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | } |
| 610 | |
| 611 | /* |
| 612 | * qla2x00_get_fw_options |
| 613 | * Set firmware options. |
| 614 | * |
| 615 | * Input: |
| 616 | * ha = adapter block pointer. |
| 617 | * fwopt = pointer for firmware options. |
| 618 | * |
| 619 | * Returns: |
| 620 | * qla2x00 local function return status code. |
| 621 | * |
| 622 | * Context: |
| 623 | * Kernel context. |
| 624 | */ |
| 625 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 626 | qla2x00_get_fw_options(scsi_qla_host_t *vha, uint16_t *fwopts) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | { |
| 628 | int rval; |
| 629 | mbx_cmd_t mc; |
| 630 | mbx_cmd_t *mcp = &mc; |
| 631 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 632 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102c, |
| 633 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | |
| 635 | mcp->mb[0] = MBC_GET_FIRMWARE_OPTION; |
| 636 | mcp->out_mb = MBX_0; |
| 637 | mcp->in_mb = MBX_3|MBX_2|MBX_1|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 | |
| 642 | if (rval != QLA_SUCCESS) { |
| 643 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 644 | ql_dbg(ql_dbg_mbx, vha, 0x102d, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | } else { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 646 | fwopts[0] = mcp->mb[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | fwopts[1] = mcp->mb[1]; |
| 648 | fwopts[2] = mcp->mb[2]; |
| 649 | fwopts[3] = mcp->mb[3]; |
| 650 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 651 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102e, |
| 652 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | } |
| 654 | |
| 655 | return rval; |
| 656 | } |
| 657 | |
| 658 | |
| 659 | /* |
| 660 | * qla2x00_set_fw_options |
| 661 | * Set firmware options. |
| 662 | * |
| 663 | * Input: |
| 664 | * ha = adapter block pointer. |
| 665 | * fwopt = pointer for firmware options. |
| 666 | * |
| 667 | * Returns: |
| 668 | * qla2x00 local function return status code. |
| 669 | * |
| 670 | * Context: |
| 671 | * Kernel context. |
| 672 | */ |
| 673 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 674 | qla2x00_set_fw_options(scsi_qla_host_t *vha, uint16_t *fwopts) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | { |
| 676 | int rval; |
| 677 | mbx_cmd_t mc; |
| 678 | mbx_cmd_t *mcp = &mc; |
| 679 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 680 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102f, |
| 681 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | |
| 683 | mcp->mb[0] = MBC_SET_FIRMWARE_OPTION; |
| 684 | mcp->mb[1] = fwopts[1]; |
| 685 | mcp->mb[2] = fwopts[2]; |
| 686 | mcp->mb[3] = fwopts[3]; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 687 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 688 | mcp->in_mb = MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 689 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 690 | mcp->in_mb |= MBX_1; |
| 691 | } else { |
| 692 | mcp->mb[10] = fwopts[10]; |
| 693 | mcp->mb[11] = fwopts[11]; |
| 694 | mcp->mb[12] = 0; /* Undocumented, but used */ |
| 695 | mcp->out_mb |= MBX_12|MBX_11|MBX_10; |
| 696 | } |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 697 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 698 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 699 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 701 | fwopts[0] = mcp->mb[0]; |
| 702 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 703 | if (rval != QLA_SUCCESS) { |
| 704 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 705 | ql_dbg(ql_dbg_mbx, vha, 0x1030, |
| 706 | "Failed=%x (%x/%x).\n", rval, mcp->mb[0], mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | } else { |
| 708 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 709 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1031, |
| 710 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 711 | } |
| 712 | |
| 713 | return rval; |
| 714 | } |
| 715 | |
| 716 | /* |
| 717 | * qla2x00_mbx_reg_test |
| 718 | * Mailbox register wrap test. |
| 719 | * |
| 720 | * Input: |
| 721 | * ha = adapter block pointer. |
| 722 | * TARGET_QUEUE_LOCK must be released. |
| 723 | * ADAPTER_STATE_LOCK must be released. |
| 724 | * |
| 725 | * Returns: |
| 726 | * qla2x00 local function return status code. |
| 727 | * |
| 728 | * Context: |
| 729 | * Kernel context. |
| 730 | */ |
| 731 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 732 | qla2x00_mbx_reg_test(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 733 | { |
| 734 | int rval; |
| 735 | mbx_cmd_t mc; |
| 736 | mbx_cmd_t *mcp = &mc; |
| 737 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 738 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1032, |
| 739 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 740 | |
| 741 | mcp->mb[0] = MBC_MAILBOX_REGISTER_TEST; |
| 742 | mcp->mb[1] = 0xAAAA; |
| 743 | mcp->mb[2] = 0x5555; |
| 744 | mcp->mb[3] = 0xAA55; |
| 745 | mcp->mb[4] = 0x55AA; |
| 746 | mcp->mb[5] = 0xA5A5; |
| 747 | mcp->mb[6] = 0x5A5A; |
| 748 | mcp->mb[7] = 0x2525; |
| 749 | mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 750 | 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] | 751 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 752 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 753 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 754 | |
| 755 | if (rval == QLA_SUCCESS) { |
| 756 | if (mcp->mb[1] != 0xAAAA || mcp->mb[2] != 0x5555 || |
| 757 | mcp->mb[3] != 0xAA55 || mcp->mb[4] != 0x55AA) |
| 758 | rval = QLA_FUNCTION_FAILED; |
| 759 | if (mcp->mb[5] != 0xA5A5 || mcp->mb[6] != 0x5A5A || |
| 760 | mcp->mb[7] != 0x2525) |
| 761 | rval = QLA_FUNCTION_FAILED; |
| 762 | } |
| 763 | |
| 764 | if (rval != QLA_SUCCESS) { |
| 765 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 766 | ql_dbg(ql_dbg_mbx, vha, 0x1033, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 767 | } else { |
| 768 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 769 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1034, |
| 770 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 771 | } |
| 772 | |
| 773 | return rval; |
| 774 | } |
| 775 | |
| 776 | /* |
| 777 | * qla2x00_verify_checksum |
| 778 | * Verify firmware checksum. |
| 779 | * |
| 780 | * Input: |
| 781 | * ha = adapter block pointer. |
| 782 | * TARGET_QUEUE_LOCK must be released. |
| 783 | * ADAPTER_STATE_LOCK must be released. |
| 784 | * |
| 785 | * Returns: |
| 786 | * qla2x00 local function return status code. |
| 787 | * |
| 788 | * Context: |
| 789 | * Kernel context. |
| 790 | */ |
| 791 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 792 | qla2x00_verify_checksum(scsi_qla_host_t *vha, uint32_t risc_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 793 | { |
| 794 | int rval; |
| 795 | mbx_cmd_t mc; |
| 796 | mbx_cmd_t *mcp = &mc; |
| 797 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 798 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1035, |
| 799 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 800 | |
| 801 | mcp->mb[0] = MBC_VERIFY_CHECKSUM; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 802 | mcp->out_mb = MBX_0; |
| 803 | mcp->in_mb = MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 804 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 805 | mcp->mb[1] = MSW(risc_addr); |
| 806 | mcp->mb[2] = LSW(risc_addr); |
| 807 | mcp->out_mb |= MBX_2|MBX_1; |
| 808 | mcp->in_mb |= MBX_2|MBX_1; |
| 809 | } else { |
| 810 | mcp->mb[1] = LSW(risc_addr); |
| 811 | mcp->out_mb |= MBX_1; |
| 812 | mcp->in_mb |= MBX_1; |
| 813 | } |
| 814 | |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 815 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 816 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 817 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 818 | |
| 819 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 820 | ql_dbg(ql_dbg_mbx, vha, 0x1036, |
| 821 | "Failed=%x chm sum=%x.\n", rval, IS_FWI2_CAPABLE(vha->hw) ? |
| 822 | (mcp->mb[2] << 16) | mcp->mb[1] : mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 823 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 824 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1037, |
| 825 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 826 | } |
| 827 | |
| 828 | return rval; |
| 829 | } |
| 830 | |
| 831 | /* |
| 832 | * qla2x00_issue_iocb |
| 833 | * Issue IOCB using mailbox command |
| 834 | * |
| 835 | * Input: |
| 836 | * ha = adapter state pointer. |
| 837 | * buffer = buffer pointer. |
| 838 | * phys_addr = physical address of buffer. |
| 839 | * size = size of buffer. |
| 840 | * TARGET_QUEUE_LOCK must be released. |
| 841 | * ADAPTER_STATE_LOCK must be released. |
| 842 | * |
| 843 | * Returns: |
| 844 | * qla2x00 local function return status code. |
| 845 | * |
| 846 | * Context: |
| 847 | * Kernel context. |
| 848 | */ |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 849 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 850 | qla2x00_issue_iocb_timeout(scsi_qla_host_t *vha, void *buffer, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 851 | dma_addr_t phys_addr, size_t size, uint32_t tov) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 852 | { |
| 853 | int rval; |
| 854 | mbx_cmd_t mc; |
| 855 | mbx_cmd_t *mcp = &mc; |
| 856 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 857 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1038, |
| 858 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 859 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 860 | mcp->mb[0] = MBC_IOCB_COMMAND_A64; |
| 861 | mcp->mb[1] = 0; |
| 862 | mcp->mb[2] = MSW(phys_addr); |
| 863 | mcp->mb[3] = LSW(phys_addr); |
| 864 | mcp->mb[6] = MSW(MSD(phys_addr)); |
| 865 | mcp->mb[7] = LSW(MSD(phys_addr)); |
| 866 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 867 | mcp->in_mb = MBX_2|MBX_0; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 868 | mcp->tov = tov; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 869 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 870 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 871 | |
| 872 | if (rval != QLA_SUCCESS) { |
| 873 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 874 | ql_dbg(ql_dbg_mbx, vha, 0x1039, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 875 | } else { |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 876 | sts_entry_t *sts_entry = (sts_entry_t *) buffer; |
| 877 | |
| 878 | /* Mask reserved bits. */ |
| 879 | sts_entry->entry_status &= |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 880 | IS_FWI2_CAPABLE(vha->hw) ? RF_MASK_24XX : RF_MASK; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 881 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103a, |
| 882 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 883 | } |
| 884 | |
| 885 | return rval; |
| 886 | } |
| 887 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 888 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 889 | 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] | 890 | size_t size) |
| 891 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 892 | return qla2x00_issue_iocb_timeout(vha, buffer, phys_addr, size, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 893 | MBX_TOV_SECONDS); |
| 894 | } |
| 895 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 896 | /* |
| 897 | * qla2x00_abort_command |
| 898 | * Abort command aborts a specified IOCB. |
| 899 | * |
| 900 | * Input: |
| 901 | * ha = adapter block pointer. |
| 902 | * sp = SB structure pointer. |
| 903 | * |
| 904 | * Returns: |
| 905 | * qla2x00 local function return status code. |
| 906 | * |
| 907 | * Context: |
| 908 | * Kernel context. |
| 909 | */ |
| 910 | int |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 911 | qla2x00_abort_command(srb_t *sp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 912 | { |
| 913 | unsigned long flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 914 | int rval; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 915 | uint32_t handle = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 916 | mbx_cmd_t mc; |
| 917 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 918 | fc_port_t *fcport = sp->fcport; |
| 919 | scsi_qla_host_t *vha = fcport->vha; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 920 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 921 | struct req_que *req = vha->req; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 922 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 923 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 924 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103b, |
| 925 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 926 | |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 927 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 928 | for (handle = 1; handle < req->num_outstanding_cmds; handle++) { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 929 | if (req->outstanding_cmds[handle] == sp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 930 | break; |
| 931 | } |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 932 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 933 | |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 934 | if (handle == req->num_outstanding_cmds) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 935 | /* command not found */ |
| 936 | return QLA_FUNCTION_FAILED; |
| 937 | } |
| 938 | |
| 939 | mcp->mb[0] = MBC_ABORT_COMMAND; |
| 940 | if (HAS_EXTENDED_IDS(ha)) |
| 941 | mcp->mb[1] = fcport->loop_id; |
| 942 | else |
| 943 | mcp->mb[1] = fcport->loop_id << 8; |
| 944 | mcp->mb[2] = (uint16_t)handle; |
| 945 | mcp->mb[3] = (uint16_t)(handle >> 16); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 946 | mcp->mb[6] = (uint16_t)cmd->device->lun; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 947 | mcp->out_mb = MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 948 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 949 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 950 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 951 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 952 | |
| 953 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 954 | ql_dbg(ql_dbg_mbx, vha, 0x103c, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 955 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 956 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103d, |
| 957 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 958 | } |
| 959 | |
| 960 | return rval; |
| 961 | } |
| 962 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 963 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 964 | qla2x00_abort_target(struct fc_port *fcport, uint64_t l, int tag) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 965 | { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 966 | int rval, rval2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 967 | mbx_cmd_t mc; |
| 968 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 969 | scsi_qla_host_t *vha; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 970 | struct req_que *req; |
| 971 | struct rsp_que *rsp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 972 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 973 | l = l; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 974 | vha = fcport->vha; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 975 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 976 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103e, |
| 977 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 978 | |
Giridhar Malavali | 7e2b895 | 2010-05-28 15:08:17 -0700 | [diff] [blame] | 979 | req = vha->hw->req_q_map[0]; |
| 980 | rsp = req->rsp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 981 | mcp->mb[0] = MBC_ABORT_TARGET; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 982 | mcp->out_mb = MBX_9|MBX_2|MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 983 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 984 | mcp->mb[1] = fcport->loop_id; |
| 985 | mcp->mb[10] = 0; |
| 986 | mcp->out_mb |= MBX_10; |
| 987 | } else { |
| 988 | mcp->mb[1] = fcport->loop_id << 8; |
| 989 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 990 | mcp->mb[2] = vha->hw->loop_reset_delay; |
| 991 | mcp->mb[9] = vha->vp_idx; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 992 | |
| 993 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 994 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 995 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 996 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 997 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 998 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103f, |
| 999 | "Failed=%x.\n", rval); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1000 | } |
| 1001 | |
| 1002 | /* Issue marker IOCB. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1003 | rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, 0, |
| 1004 | MK_SYNC_ID); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1005 | if (rval2 != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1006 | ql_dbg(ql_dbg_mbx, vha, 0x1040, |
| 1007 | "Failed to issue marker IOCB (%x).\n", rval2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1008 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1009 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1041, |
| 1010 | "Done %s.\n", __func__); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1011 | } |
| 1012 | |
| 1013 | return rval; |
| 1014 | } |
| 1015 | |
| 1016 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1017 | qla2x00_lun_reset(struct fc_port *fcport, uint64_t l, int tag) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1018 | { |
| 1019 | int rval, rval2; |
| 1020 | mbx_cmd_t mc; |
| 1021 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1022 | scsi_qla_host_t *vha; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1023 | struct req_que *req; |
| 1024 | struct rsp_que *rsp; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1025 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1026 | vha = fcport->vha; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1027 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1028 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1042, |
| 1029 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1030 | |
Giridhar Malavali | 7e2b895 | 2010-05-28 15:08:17 -0700 | [diff] [blame] | 1031 | req = vha->hw->req_q_map[0]; |
| 1032 | rsp = req->rsp; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1033 | mcp->mb[0] = MBC_LUN_RESET; |
| 1034 | 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] | 1035 | if (HAS_EXTENDED_IDS(vha->hw)) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1036 | mcp->mb[1] = fcport->loop_id; |
| 1037 | else |
| 1038 | mcp->mb[1] = fcport->loop_id << 8; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1039 | mcp->mb[2] = (u32)l; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1040 | mcp->mb[3] = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1041 | mcp->mb[9] = vha->vp_idx; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1042 | |
| 1043 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1044 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1045 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1046 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1047 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1048 | ql_dbg(ql_dbg_mbx, vha, 0x1043, "Failed=%x.\n", rval); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1049 | } |
| 1050 | |
| 1051 | /* Issue marker IOCB. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1052 | rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, l, |
| 1053 | MK_SYNC_ID_LUN); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1054 | if (rval2 != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1055 | ql_dbg(ql_dbg_mbx, vha, 0x1044, |
| 1056 | "Failed to issue marker IOCB (%x).\n", rval2); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1057 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1058 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1045, |
| 1059 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1060 | } |
| 1061 | |
| 1062 | return rval; |
| 1063 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1064 | |
| 1065 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1066 | * qla2x00_get_adapter_id |
| 1067 | * Get adapter ID and topology. |
| 1068 | * |
| 1069 | * Input: |
| 1070 | * ha = adapter block pointer. |
| 1071 | * id = pointer for loop ID. |
| 1072 | * al_pa = pointer for AL_PA. |
| 1073 | * area = pointer for area. |
| 1074 | * domain = pointer for domain. |
| 1075 | * top = pointer for topology. |
| 1076 | * TARGET_QUEUE_LOCK must be released. |
| 1077 | * ADAPTER_STATE_LOCK must be released. |
| 1078 | * |
| 1079 | * Returns: |
| 1080 | * qla2x00 local function return status code. |
| 1081 | * |
| 1082 | * Context: |
| 1083 | * Kernel context. |
| 1084 | */ |
| 1085 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1086 | 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] | 1087 | 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] | 1088 | { |
| 1089 | int rval; |
| 1090 | mbx_cmd_t mc; |
| 1091 | mbx_cmd_t *mcp = &mc; |
| 1092 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1093 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1046, |
| 1094 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1095 | |
| 1096 | mcp->mb[0] = MBC_GET_ADAPTER_LOOP_ID; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1097 | mcp->mb[9] = vha->vp_idx; |
Andrew Vasquez | eb66dc6 | 2007-11-12 10:30:58 -0800 | [diff] [blame] | 1098 | mcp->out_mb = MBX_9|MBX_0; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1099 | 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] | 1100 | if (IS_CNA_CAPABLE(vha->hw)) |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1101 | mcp->in_mb |= MBX_13|MBX_12|MBX_11|MBX_10; |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 1102 | if (IS_FWI2_CAPABLE(vha->hw)) |
| 1103 | mcp->in_mb |= MBX_19|MBX_18|MBX_17|MBX_16; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1104 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1105 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1106 | rval = qla2x00_mailbox_command(vha, mcp); |
Ravi Anand | 33135aa | 2005-11-08 14:37:20 -0800 | [diff] [blame] | 1107 | if (mcp->mb[0] == MBS_COMMAND_ERROR) |
| 1108 | rval = QLA_COMMAND_ERROR; |
Andrew Vasquez | 42e421b | 2008-07-10 16:56:01 -0700 | [diff] [blame] | 1109 | else if (mcp->mb[0] == MBS_INVALID_COMMAND) |
| 1110 | rval = QLA_INVALID_COMMAND; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1111 | |
| 1112 | /* Return data. */ |
| 1113 | *id = mcp->mb[1]; |
| 1114 | *al_pa = LSB(mcp->mb[2]); |
| 1115 | *area = MSB(mcp->mb[2]); |
| 1116 | *domain = LSB(mcp->mb[3]); |
| 1117 | *top = mcp->mb[6]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1118 | *sw_cap = mcp->mb[7]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1119 | |
| 1120 | if (rval != QLA_SUCCESS) { |
| 1121 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1122 | ql_dbg(ql_dbg_mbx, vha, 0x1047, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1123 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1124 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1048, |
| 1125 | "Done %s.\n", __func__); |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1126 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1127 | if (IS_CNA_CAPABLE(vha->hw)) { |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1128 | vha->fcoe_vlan_id = mcp->mb[9] & 0xfff; |
| 1129 | vha->fcoe_fcf_idx = mcp->mb[10]; |
| 1130 | vha->fcoe_vn_port_mac[5] = mcp->mb[11] >> 8; |
| 1131 | vha->fcoe_vn_port_mac[4] = mcp->mb[11] & 0xff; |
| 1132 | vha->fcoe_vn_port_mac[3] = mcp->mb[12] >> 8; |
| 1133 | vha->fcoe_vn_port_mac[2] = mcp->mb[12] & 0xff; |
| 1134 | vha->fcoe_vn_port_mac[1] = mcp->mb[13] >> 8; |
| 1135 | vha->fcoe_vn_port_mac[0] = mcp->mb[13] & 0xff; |
| 1136 | } |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 1137 | /* If FA-WWN supported */ |
| 1138 | if (mcp->mb[7] & BIT_14) { |
| 1139 | vha->port_name[0] = MSB(mcp->mb[16]); |
| 1140 | vha->port_name[1] = LSB(mcp->mb[16]); |
| 1141 | vha->port_name[2] = MSB(mcp->mb[17]); |
| 1142 | vha->port_name[3] = LSB(mcp->mb[17]); |
| 1143 | vha->port_name[4] = MSB(mcp->mb[18]); |
| 1144 | vha->port_name[5] = LSB(mcp->mb[18]); |
| 1145 | vha->port_name[6] = MSB(mcp->mb[19]); |
| 1146 | vha->port_name[7] = LSB(mcp->mb[19]); |
| 1147 | fc_host_port_name(vha->host) = |
| 1148 | wwn_to_u64(vha->port_name); |
| 1149 | ql_dbg(ql_dbg_mbx, vha, 0x10ca, |
| 1150 | "FA-WWN acquired %016llx\n", |
| 1151 | wwn_to_u64(vha->port_name)); |
| 1152 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1153 | } |
| 1154 | |
| 1155 | return rval; |
| 1156 | } |
| 1157 | |
| 1158 | /* |
| 1159 | * qla2x00_get_retry_cnt |
| 1160 | * Get current firmware login retry count and delay. |
| 1161 | * |
| 1162 | * Input: |
| 1163 | * ha = adapter block pointer. |
| 1164 | * retry_cnt = pointer to login retry count. |
| 1165 | * tov = pointer to login timeout value. |
| 1166 | * |
| 1167 | * Returns: |
| 1168 | * qla2x00 local function return status code. |
| 1169 | * |
| 1170 | * Context: |
| 1171 | * Kernel context. |
| 1172 | */ |
| 1173 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1174 | 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] | 1175 | uint16_t *r_a_tov) |
| 1176 | { |
| 1177 | int rval; |
| 1178 | uint16_t ratov; |
| 1179 | mbx_cmd_t mc; |
| 1180 | mbx_cmd_t *mcp = &mc; |
| 1181 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1182 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1049, |
| 1183 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1184 | |
| 1185 | mcp->mb[0] = MBC_GET_RETRY_COUNT; |
| 1186 | mcp->out_mb = MBX_0; |
| 1187 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1188 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1189 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1190 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1191 | |
| 1192 | if (rval != QLA_SUCCESS) { |
| 1193 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1194 | ql_dbg(ql_dbg_mbx, vha, 0x104a, |
| 1195 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1196 | } else { |
| 1197 | /* Convert returned data and check our values. */ |
| 1198 | *r_a_tov = mcp->mb[3] / 2; |
| 1199 | ratov = (mcp->mb[3]/2) / 10; /* mb[3] value is in 100ms */ |
| 1200 | if (mcp->mb[1] * ratov > (*retry_cnt) * (*tov)) { |
| 1201 | /* Update to the larger values */ |
| 1202 | *retry_cnt = (uint8_t)mcp->mb[1]; |
| 1203 | *tov = ratov; |
| 1204 | } |
| 1205 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1206 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104b, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1207 | "Done %s mb3=%d ratov=%d.\n", __func__, mcp->mb[3], ratov); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1208 | } |
| 1209 | |
| 1210 | return rval; |
| 1211 | } |
| 1212 | |
| 1213 | /* |
| 1214 | * qla2x00_init_firmware |
| 1215 | * Initialize adapter firmware. |
| 1216 | * |
| 1217 | * Input: |
| 1218 | * ha = adapter block pointer. |
| 1219 | * dptr = Initialization control block pointer. |
| 1220 | * size = size of initialization control block. |
| 1221 | * TARGET_QUEUE_LOCK must be released. |
| 1222 | * ADAPTER_STATE_LOCK must be released. |
| 1223 | * |
| 1224 | * Returns: |
| 1225 | * qla2x00 local function return status code. |
| 1226 | * |
| 1227 | * Context: |
| 1228 | * Kernel context. |
| 1229 | */ |
| 1230 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1231 | qla2x00_init_firmware(scsi_qla_host_t *vha, uint16_t size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1232 | { |
| 1233 | int rval; |
| 1234 | mbx_cmd_t mc; |
| 1235 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1236 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1237 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1238 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104c, |
| 1239 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1240 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1241 | if (IS_P3P_TYPE(ha) && ql2xdbwr) |
Bart Van Assche | 8dfa4b5a | 2015-07-09 07:24:50 -0700 | [diff] [blame^] | 1242 | qla82xx_wr_32(ha, (uintptr_t __force)ha->nxdb_wr_ptr, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1243 | (0x04 | (ha->portnum << 5) | (0 << 8) | (0 << 16))); |
| 1244 | |
Andrew Vasquez | e6e074f | 2008-01-31 12:33:53 -0800 | [diff] [blame] | 1245 | if (ha->flags.npiv_supported) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1246 | mcp->mb[0] = MBC_MID_INITIALIZE_FIRMWARE; |
| 1247 | else |
| 1248 | mcp->mb[0] = MBC_INITIALIZE_FIRMWARE; |
| 1249 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 1250 | mcp->mb[1] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1251 | mcp->mb[2] = MSW(ha->init_cb_dma); |
| 1252 | mcp->mb[3] = LSW(ha->init_cb_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1253 | mcp->mb[6] = MSW(MSD(ha->init_cb_dma)); |
| 1254 | mcp->mb[7] = LSW(MSD(ha->init_cb_dma)); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 1255 | 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] | 1256 | if (ha->ex_init_cb && ha->ex_init_cb->ex_version) { |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 1257 | mcp->mb[1] = BIT_0; |
| 1258 | mcp->mb[10] = MSW(ha->ex_init_cb_dma); |
| 1259 | mcp->mb[11] = LSW(ha->ex_init_cb_dma); |
| 1260 | mcp->mb[12] = MSW(MSD(ha->ex_init_cb_dma)); |
| 1261 | mcp->mb[13] = LSW(MSD(ha->ex_init_cb_dma)); |
| 1262 | mcp->mb[14] = sizeof(*ha->ex_init_cb); |
| 1263 | mcp->out_mb |= MBX_14|MBX_13|MBX_12|MBX_11|MBX_10; |
| 1264 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1265 | /* 1 and 2 should normally be captured. */ |
| 1266 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 1267 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1268 | /* mb3 is additional info about the installed SFP. */ |
| 1269 | mcp->in_mb |= MBX_3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1270 | mcp->buf_size = size; |
| 1271 | mcp->flags = MBX_DMA_OUT; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1272 | mcp->tov = MBX_TOV_SECONDS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1273 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1274 | |
| 1275 | if (rval != QLA_SUCCESS) { |
| 1276 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1277 | ql_dbg(ql_dbg_mbx, vha, 0x104d, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1278 | "Failed=%x mb[0]=%x, mb[1]=%x, mb[2]=%x, mb[3]=%x,.\n", |
| 1279 | 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] | 1280 | } else { |
| 1281 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1282 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104e, |
| 1283 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1284 | } |
| 1285 | |
| 1286 | return rval; |
| 1287 | } |
| 1288 | |
| 1289 | /* |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 1290 | * qla2x00_get_node_name_list |
| 1291 | * Issue get node name list mailbox command, kmalloc() |
| 1292 | * and return the resulting list. Caller must kfree() it! |
| 1293 | * |
| 1294 | * Input: |
| 1295 | * ha = adapter state pointer. |
| 1296 | * out_data = resulting list |
| 1297 | * out_len = length of the resulting list |
| 1298 | * |
| 1299 | * Returns: |
| 1300 | * qla2x00 local function return status code. |
| 1301 | * |
| 1302 | * Context: |
| 1303 | * Kernel context. |
| 1304 | */ |
| 1305 | int |
| 1306 | qla2x00_get_node_name_list(scsi_qla_host_t *vha, void **out_data, int *out_len) |
| 1307 | { |
| 1308 | struct qla_hw_data *ha = vha->hw; |
| 1309 | struct qla_port_24xx_data *list = NULL; |
| 1310 | void *pmap; |
| 1311 | mbx_cmd_t mc; |
| 1312 | dma_addr_t pmap_dma; |
| 1313 | ulong dma_size; |
| 1314 | int rval, left; |
| 1315 | |
| 1316 | left = 1; |
| 1317 | while (left > 0) { |
| 1318 | dma_size = left * sizeof(*list); |
| 1319 | pmap = dma_alloc_coherent(&ha->pdev->dev, dma_size, |
| 1320 | &pmap_dma, GFP_KERNEL); |
| 1321 | if (!pmap) { |
| 1322 | ql_log(ql_log_warn, vha, 0x113f, |
| 1323 | "%s(%ld): DMA Alloc failed of %ld\n", |
| 1324 | __func__, vha->host_no, dma_size); |
| 1325 | rval = QLA_MEMORY_ALLOC_FAILED; |
| 1326 | goto out; |
| 1327 | } |
| 1328 | |
| 1329 | mc.mb[0] = MBC_PORT_NODE_NAME_LIST; |
| 1330 | mc.mb[1] = BIT_1 | BIT_3; |
| 1331 | mc.mb[2] = MSW(pmap_dma); |
| 1332 | mc.mb[3] = LSW(pmap_dma); |
| 1333 | mc.mb[6] = MSW(MSD(pmap_dma)); |
| 1334 | mc.mb[7] = LSW(MSD(pmap_dma)); |
| 1335 | mc.mb[8] = dma_size; |
| 1336 | mc.out_mb = MBX_0|MBX_1|MBX_2|MBX_3|MBX_6|MBX_7|MBX_8; |
| 1337 | mc.in_mb = MBX_0|MBX_1; |
| 1338 | mc.tov = 30; |
| 1339 | mc.flags = MBX_DMA_IN; |
| 1340 | |
| 1341 | rval = qla2x00_mailbox_command(vha, &mc); |
| 1342 | if (rval != QLA_SUCCESS) { |
| 1343 | if ((mc.mb[0] == MBS_COMMAND_ERROR) && |
| 1344 | (mc.mb[1] == 0xA)) { |
| 1345 | left += le16_to_cpu(mc.mb[2]) / |
| 1346 | sizeof(struct qla_port_24xx_data); |
| 1347 | goto restart; |
| 1348 | } |
| 1349 | goto out_free; |
| 1350 | } |
| 1351 | |
| 1352 | left = 0; |
| 1353 | |
Benoit Taine | c1818f1 | 2014-05-26 17:21:16 +0200 | [diff] [blame] | 1354 | list = kmemdup(pmap, dma_size, GFP_KERNEL); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 1355 | if (!list) { |
| 1356 | ql_log(ql_log_warn, vha, 0x1140, |
| 1357 | "%s(%ld): failed to allocate node names list " |
| 1358 | "structure.\n", __func__, vha->host_no); |
| 1359 | rval = QLA_MEMORY_ALLOC_FAILED; |
| 1360 | goto out_free; |
| 1361 | } |
| 1362 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 1363 | restart: |
| 1364 | dma_free_coherent(&ha->pdev->dev, dma_size, pmap, pmap_dma); |
| 1365 | } |
| 1366 | |
| 1367 | *out_data = list; |
| 1368 | *out_len = dma_size; |
| 1369 | |
| 1370 | out: |
| 1371 | return rval; |
| 1372 | |
| 1373 | out_free: |
| 1374 | dma_free_coherent(&ha->pdev->dev, dma_size, pmap, pmap_dma); |
| 1375 | return rval; |
| 1376 | } |
| 1377 | |
| 1378 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1379 | * qla2x00_get_port_database |
| 1380 | * Issue normal/enhanced get port database mailbox command |
| 1381 | * and copy device name as necessary. |
| 1382 | * |
| 1383 | * Input: |
| 1384 | * ha = adapter state pointer. |
| 1385 | * dev = structure pointer. |
| 1386 | * opt = enhanced cmd option byte. |
| 1387 | * |
| 1388 | * Returns: |
| 1389 | * qla2x00 local function return status code. |
| 1390 | * |
| 1391 | * Context: |
| 1392 | * Kernel context. |
| 1393 | */ |
| 1394 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1395 | 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] | 1396 | { |
| 1397 | int rval; |
| 1398 | mbx_cmd_t mc; |
| 1399 | mbx_cmd_t *mcp = &mc; |
| 1400 | port_database_t *pd; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1401 | struct port_database_24xx *pd24; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1402 | dma_addr_t pd_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1403 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1404 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1405 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104f, |
| 1406 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1407 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1408 | pd24 = NULL; |
| 1409 | pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1410 | if (pd == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1411 | ql_log(ql_log_warn, vha, 0x1050, |
| 1412 | "Failed to allocate port database structure.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1413 | return QLA_MEMORY_ALLOC_FAILED; |
| 1414 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1415 | memset(pd, 0, max(PORT_DATABASE_SIZE, PORT_DATABASE_24XX_SIZE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1416 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1417 | mcp->mb[0] = MBC_GET_PORT_DATABASE; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1418 | if (opt != 0 && !IS_FWI2_CAPABLE(ha)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1419 | mcp->mb[0] = MBC_ENHANCED_GET_PORT_DATABASE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1420 | mcp->mb[2] = MSW(pd_dma); |
| 1421 | mcp->mb[3] = LSW(pd_dma); |
| 1422 | mcp->mb[6] = MSW(MSD(pd_dma)); |
| 1423 | mcp->mb[7] = LSW(MSD(pd_dma)); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1424 | mcp->mb[9] = vha->vp_idx; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1425 | 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] | 1426 | mcp->in_mb = MBX_0; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1427 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1428 | mcp->mb[1] = fcport->loop_id; |
| 1429 | mcp->mb[10] = opt; |
| 1430 | mcp->out_mb |= MBX_10|MBX_1; |
| 1431 | mcp->in_mb |= MBX_1; |
| 1432 | } else if (HAS_EXTENDED_IDS(ha)) { |
| 1433 | mcp->mb[1] = fcport->loop_id; |
| 1434 | mcp->mb[10] = opt; |
| 1435 | mcp->out_mb |= MBX_10|MBX_1; |
| 1436 | } else { |
| 1437 | mcp->mb[1] = fcport->loop_id << 8 | opt; |
| 1438 | mcp->out_mb |= MBX_1; |
| 1439 | } |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1440 | mcp->buf_size = IS_FWI2_CAPABLE(ha) ? |
| 1441 | PORT_DATABASE_24XX_SIZE : PORT_DATABASE_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1442 | mcp->flags = MBX_DMA_IN; |
| 1443 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1444 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1445 | if (rval != QLA_SUCCESS) |
| 1446 | goto gpd_error_out; |
| 1447 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1448 | if (IS_FWI2_CAPABLE(ha)) { |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1449 | uint64_t zero = 0; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1450 | pd24 = (struct port_database_24xx *) pd; |
| 1451 | |
| 1452 | /* Check for logged in state. */ |
| 1453 | if (pd24->current_login_state != PDS_PRLI_COMPLETE && |
| 1454 | pd24->last_login_state != PDS_PRLI_COMPLETE) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1455 | ql_dbg(ql_dbg_mbx, vha, 0x1051, |
| 1456 | "Unable to verify login-state (%x/%x) for " |
| 1457 | "loop_id %x.\n", pd24->current_login_state, |
| 1458 | pd24->last_login_state, fcport->loop_id); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1459 | rval = QLA_FUNCTION_FAILED; |
| 1460 | goto gpd_error_out; |
| 1461 | } |
| 1462 | |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1463 | if (fcport->loop_id == FC_NO_LOOP_ID || |
| 1464 | (memcmp(fcport->port_name, (uint8_t *)&zero, 8) && |
| 1465 | memcmp(fcport->port_name, pd24->port_name, 8))) { |
| 1466 | /* We lost the device mid way. */ |
| 1467 | rval = QLA_NOT_LOGGED_IN; |
| 1468 | goto gpd_error_out; |
| 1469 | } |
| 1470 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1471 | /* Names are little-endian. */ |
| 1472 | memcpy(fcport->node_name, pd24->node_name, WWN_SIZE); |
| 1473 | memcpy(fcport->port_name, pd24->port_name, WWN_SIZE); |
| 1474 | |
| 1475 | /* Get port_id of device. */ |
| 1476 | fcport->d_id.b.domain = pd24->port_id[0]; |
| 1477 | fcport->d_id.b.area = pd24->port_id[1]; |
| 1478 | fcport->d_id.b.al_pa = pd24->port_id[2]; |
| 1479 | fcport->d_id.b.rsvd_1 = 0; |
| 1480 | |
| 1481 | /* If not target must be initiator or unknown type. */ |
| 1482 | if ((pd24->prli_svc_param_word_3[0] & BIT_4) == 0) |
| 1483 | fcport->port_type = FCT_INITIATOR; |
| 1484 | else |
| 1485 | fcport->port_type = FCT_TARGET; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 1486 | |
| 1487 | /* Passback COS information. */ |
| 1488 | fcport->supported_classes = (pd24->flags & PDF_CLASS_2) ? |
| 1489 | FC_COS_CLASS2 : FC_COS_CLASS3; |
| 1490 | |
| 1491 | if (pd24->prli_svc_param_word_3[0] & BIT_7) |
| 1492 | fcport->flags |= FCF_CONF_COMP_SUPPORTED; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1493 | } else { |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1494 | uint64_t zero = 0; |
| 1495 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1496 | /* Check for logged in state. */ |
| 1497 | if (pd->master_state != PD_STATE_PORT_LOGGED_IN && |
| 1498 | pd->slave_state != PD_STATE_PORT_LOGGED_IN) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1499 | ql_dbg(ql_dbg_mbx, vha, 0x100a, |
| 1500 | "Unable to verify login-state (%x/%x) - " |
| 1501 | "portid=%02x%02x%02x.\n", pd->master_state, |
| 1502 | pd->slave_state, fcport->d_id.b.domain, |
| 1503 | fcport->d_id.b.area, fcport->d_id.b.al_pa); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1504 | rval = QLA_FUNCTION_FAILED; |
| 1505 | goto gpd_error_out; |
| 1506 | } |
| 1507 | |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1508 | if (fcport->loop_id == FC_NO_LOOP_ID || |
| 1509 | (memcmp(fcport->port_name, (uint8_t *)&zero, 8) && |
| 1510 | memcmp(fcport->port_name, pd->port_name, 8))) { |
| 1511 | /* We lost the device mid way. */ |
| 1512 | rval = QLA_NOT_LOGGED_IN; |
| 1513 | goto gpd_error_out; |
| 1514 | } |
| 1515 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1516 | /* Names are little-endian. */ |
| 1517 | memcpy(fcport->node_name, pd->node_name, WWN_SIZE); |
| 1518 | memcpy(fcport->port_name, pd->port_name, WWN_SIZE); |
| 1519 | |
| 1520 | /* Get port_id of device. */ |
| 1521 | fcport->d_id.b.domain = pd->port_id[0]; |
| 1522 | fcport->d_id.b.area = pd->port_id[3]; |
| 1523 | fcport->d_id.b.al_pa = pd->port_id[2]; |
| 1524 | fcport->d_id.b.rsvd_1 = 0; |
| 1525 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1526 | /* If not target must be initiator or unknown type. */ |
| 1527 | if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0) |
| 1528 | fcport->port_type = FCT_INITIATOR; |
| 1529 | else |
| 1530 | fcport->port_type = FCT_TARGET; |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 1531 | |
| 1532 | /* Passback COS information. */ |
| 1533 | fcport->supported_classes = (pd->options & BIT_4) ? |
| 1534 | FC_COS_CLASS2: FC_COS_CLASS3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1535 | } |
| 1536 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1537 | gpd_error_out: |
| 1538 | dma_pool_free(ha->s_dma_pool, pd, pd_dma); |
| 1539 | |
| 1540 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1541 | ql_dbg(ql_dbg_mbx, vha, 0x1052, |
| 1542 | "Failed=%x mb[0]=%x mb[1]=%x.\n", rval, |
| 1543 | mcp->mb[0], mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1544 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1545 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1053, |
| 1546 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1547 | } |
| 1548 | |
| 1549 | return rval; |
| 1550 | } |
| 1551 | |
| 1552 | /* |
| 1553 | * qla2x00_get_firmware_state |
| 1554 | * Get adapter firmware state. |
| 1555 | * |
| 1556 | * Input: |
| 1557 | * ha = adapter block pointer. |
| 1558 | * dptr = pointer for firmware state. |
| 1559 | * TARGET_QUEUE_LOCK must be released. |
| 1560 | * ADAPTER_STATE_LOCK must be released. |
| 1561 | * |
| 1562 | * Returns: |
| 1563 | * qla2x00 local function return status code. |
| 1564 | * |
| 1565 | * Context: |
| 1566 | * Kernel context. |
| 1567 | */ |
| 1568 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1569 | qla2x00_get_firmware_state(scsi_qla_host_t *vha, uint16_t *states) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1570 | { |
| 1571 | int rval; |
| 1572 | mbx_cmd_t mc; |
| 1573 | mbx_cmd_t *mcp = &mc; |
| 1574 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1575 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1054, |
| 1576 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1577 | |
| 1578 | mcp->mb[0] = MBC_GET_FIRMWARE_STATE; |
| 1579 | mcp->out_mb = MBX_0; |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 1580 | if (IS_FWI2_CAPABLE(vha->hw)) |
Joe Carnuccio | b5a340d | 2014-09-25 05:16:48 -0400 | [diff] [blame] | 1581 | 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] | 1582 | else |
| 1583 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1584 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1585 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1586 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1587 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1588 | /* Return firmware states. */ |
| 1589 | states[0] = mcp->mb[1]; |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 1590 | if (IS_FWI2_CAPABLE(vha->hw)) { |
| 1591 | states[1] = mcp->mb[2]; |
| 1592 | states[2] = mcp->mb[3]; |
| 1593 | states[3] = mcp->mb[4]; |
| 1594 | states[4] = mcp->mb[5]; |
Joe Carnuccio | b5a340d | 2014-09-25 05:16:48 -0400 | [diff] [blame] | 1595 | states[5] = mcp->mb[6]; /* DPORT status */ |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 1596 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1597 | |
| 1598 | if (rval != QLA_SUCCESS) { |
| 1599 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1600 | ql_dbg(ql_dbg_mbx, vha, 0x1055, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1601 | } else { |
| 1602 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1603 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1056, |
| 1604 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1605 | } |
| 1606 | |
| 1607 | return rval; |
| 1608 | } |
| 1609 | |
| 1610 | /* |
| 1611 | * qla2x00_get_port_name |
| 1612 | * Issue get port name mailbox command. |
| 1613 | * Returned name is in big endian format. |
| 1614 | * |
| 1615 | * Input: |
| 1616 | * ha = adapter block pointer. |
| 1617 | * loop_id = loop ID of device. |
| 1618 | * name = pointer for name. |
| 1619 | * TARGET_QUEUE_LOCK must be released. |
| 1620 | * ADAPTER_STATE_LOCK must be released. |
| 1621 | * |
| 1622 | * Returns: |
| 1623 | * qla2x00 local function return status code. |
| 1624 | * |
| 1625 | * Context: |
| 1626 | * Kernel context. |
| 1627 | */ |
| 1628 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1629 | 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] | 1630 | uint8_t opt) |
| 1631 | { |
| 1632 | int rval; |
| 1633 | mbx_cmd_t mc; |
| 1634 | mbx_cmd_t *mcp = &mc; |
| 1635 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1636 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1057, |
| 1637 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1638 | |
| 1639 | mcp->mb[0] = MBC_GET_PORT_NAME; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1640 | mcp->mb[9] = vha->vp_idx; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1641 | mcp->out_mb = MBX_9|MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1642 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1643 | mcp->mb[1] = loop_id; |
| 1644 | mcp->mb[10] = opt; |
| 1645 | mcp->out_mb |= MBX_10; |
| 1646 | } else { |
| 1647 | mcp->mb[1] = loop_id << 8 | opt; |
| 1648 | } |
| 1649 | |
| 1650 | 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] | 1651 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1652 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1653 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1654 | |
| 1655 | if (rval != QLA_SUCCESS) { |
| 1656 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1657 | ql_dbg(ql_dbg_mbx, vha, 0x1058, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1658 | } else { |
| 1659 | if (name != NULL) { |
| 1660 | /* This function returns name in big endian. */ |
Richard Lary | 1196ae0 | 2007-03-22 10:53:19 -0500 | [diff] [blame] | 1661 | name[0] = MSB(mcp->mb[2]); |
| 1662 | name[1] = LSB(mcp->mb[2]); |
| 1663 | name[2] = MSB(mcp->mb[3]); |
| 1664 | name[3] = LSB(mcp->mb[3]); |
| 1665 | name[4] = MSB(mcp->mb[6]); |
| 1666 | name[5] = LSB(mcp->mb[6]); |
| 1667 | name[6] = MSB(mcp->mb[7]); |
| 1668 | name[7] = LSB(mcp->mb[7]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1669 | } |
| 1670 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1671 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1059, |
| 1672 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1673 | } |
| 1674 | |
| 1675 | return rval; |
| 1676 | } |
| 1677 | |
| 1678 | /* |
Joe Carnuccio | 61e1b26 | 2013-02-08 01:57:48 -0500 | [diff] [blame] | 1679 | * qla24xx_link_initialization |
| 1680 | * Issue link initialization mailbox command. |
| 1681 | * |
| 1682 | * Input: |
| 1683 | * ha = adapter block pointer. |
| 1684 | * TARGET_QUEUE_LOCK must be released. |
| 1685 | * ADAPTER_STATE_LOCK must be released. |
| 1686 | * |
| 1687 | * Returns: |
| 1688 | * qla2x00 local function return status code. |
| 1689 | * |
| 1690 | * Context: |
| 1691 | * Kernel context. |
| 1692 | */ |
| 1693 | int |
| 1694 | qla24xx_link_initialize(scsi_qla_host_t *vha) |
| 1695 | { |
| 1696 | int rval; |
| 1697 | mbx_cmd_t mc; |
| 1698 | mbx_cmd_t *mcp = &mc; |
| 1699 | |
| 1700 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1152, |
| 1701 | "Entered %s.\n", __func__); |
| 1702 | |
| 1703 | if (!IS_FWI2_CAPABLE(vha->hw) || IS_CNA_CAPABLE(vha->hw)) |
| 1704 | return QLA_FUNCTION_FAILED; |
| 1705 | |
| 1706 | mcp->mb[0] = MBC_LINK_INITIALIZATION; |
Joe Carnuccio | 5a5c27b | 2013-08-27 01:37:49 -0400 | [diff] [blame] | 1707 | mcp->mb[1] = BIT_4; |
| 1708 | if (vha->hw->operating_mode == LOOP) |
| 1709 | mcp->mb[1] |= BIT_6; |
| 1710 | else |
| 1711 | mcp->mb[1] |= BIT_5; |
Joe Carnuccio | 61e1b26 | 2013-02-08 01:57:48 -0500 | [diff] [blame] | 1712 | mcp->mb[2] = 0; |
| 1713 | mcp->mb[3] = 0; |
| 1714 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 1715 | mcp->in_mb = MBX_0; |
| 1716 | mcp->tov = MBX_TOV_SECONDS; |
| 1717 | mcp->flags = 0; |
| 1718 | rval = qla2x00_mailbox_command(vha, mcp); |
| 1719 | |
| 1720 | if (rval != QLA_SUCCESS) { |
| 1721 | ql_dbg(ql_dbg_mbx, vha, 0x1153, "Failed=%x.\n", rval); |
| 1722 | } else { |
| 1723 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1154, |
| 1724 | "Done %s.\n", __func__); |
| 1725 | } |
| 1726 | |
| 1727 | return rval; |
| 1728 | } |
| 1729 | |
| 1730 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1731 | * qla2x00_lip_reset |
| 1732 | * Issue LIP reset mailbox command. |
| 1733 | * |
| 1734 | * Input: |
| 1735 | * ha = adapter block pointer. |
| 1736 | * TARGET_QUEUE_LOCK must be released. |
| 1737 | * ADAPTER_STATE_LOCK must be released. |
| 1738 | * |
| 1739 | * Returns: |
| 1740 | * qla2x00 local function return status code. |
| 1741 | * |
| 1742 | * Context: |
| 1743 | * Kernel context. |
| 1744 | */ |
| 1745 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1746 | qla2x00_lip_reset(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1747 | { |
| 1748 | int rval; |
| 1749 | mbx_cmd_t mc; |
| 1750 | mbx_cmd_t *mcp = &mc; |
| 1751 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1752 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105a, |
| 1753 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1754 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1755 | if (IS_CNA_CAPABLE(vha->hw)) { |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1756 | /* Logout across all FCFs. */ |
| 1757 | mcp->mb[0] = MBC_LIP_FULL_LOGIN; |
| 1758 | mcp->mb[1] = BIT_1; |
| 1759 | mcp->mb[2] = 0; |
| 1760 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 1761 | } else if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1762 | mcp->mb[0] = MBC_LIP_FULL_LOGIN; |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1763 | mcp->mb[1] = BIT_6; |
| 1764 | mcp->mb[2] = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1765 | mcp->mb[3] = vha->hw->loop_reset_delay; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1766 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1767 | } else { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1768 | mcp->mb[0] = MBC_LIP_RESET; |
| 1769 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1770 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1771 | mcp->mb[1] = 0x00ff; |
| 1772 | mcp->mb[10] = 0; |
| 1773 | mcp->out_mb |= MBX_10; |
| 1774 | } else { |
| 1775 | mcp->mb[1] = 0xff00; |
| 1776 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1777 | mcp->mb[2] = vha->hw->loop_reset_delay; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1778 | mcp->mb[3] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1779 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1780 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1781 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1782 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1783 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1784 | |
| 1785 | if (rval != QLA_SUCCESS) { |
| 1786 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1787 | ql_dbg(ql_dbg_mbx, vha, 0x105b, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1788 | } else { |
| 1789 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1790 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105c, |
| 1791 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1792 | } |
| 1793 | |
| 1794 | return rval; |
| 1795 | } |
| 1796 | |
| 1797 | /* |
| 1798 | * qla2x00_send_sns |
| 1799 | * Send SNS command. |
| 1800 | * |
| 1801 | * Input: |
| 1802 | * ha = adapter block pointer. |
| 1803 | * sns = pointer for command. |
| 1804 | * cmd_size = command size. |
| 1805 | * buf_size = response/command size. |
| 1806 | * TARGET_QUEUE_LOCK must be released. |
| 1807 | * ADAPTER_STATE_LOCK must be released. |
| 1808 | * |
| 1809 | * Returns: |
| 1810 | * qla2x00 local function return status code. |
| 1811 | * |
| 1812 | * Context: |
| 1813 | * Kernel context. |
| 1814 | */ |
| 1815 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1816 | 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] | 1817 | uint16_t cmd_size, size_t buf_size) |
| 1818 | { |
| 1819 | int rval; |
| 1820 | mbx_cmd_t mc; |
| 1821 | mbx_cmd_t *mcp = &mc; |
| 1822 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1823 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105d, |
| 1824 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1825 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1826 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105e, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1827 | "Retry cnt=%d ratov=%d total tov=%d.\n", |
| 1828 | vha->hw->retry_count, vha->hw->login_timeout, mcp->tov); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1829 | |
| 1830 | mcp->mb[0] = MBC_SEND_SNS_COMMAND; |
| 1831 | mcp->mb[1] = cmd_size; |
| 1832 | mcp->mb[2] = MSW(sns_phys_address); |
| 1833 | mcp->mb[3] = LSW(sns_phys_address); |
| 1834 | mcp->mb[6] = MSW(MSD(sns_phys_address)); |
| 1835 | mcp->mb[7] = LSW(MSD(sns_phys_address)); |
| 1836 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 1837 | mcp->in_mb = MBX_0|MBX_1; |
| 1838 | mcp->buf_size = buf_size; |
| 1839 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1840 | mcp->tov = (vha->hw->login_timeout * 2) + (vha->hw->login_timeout / 2); |
| 1841 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1842 | |
| 1843 | if (rval != QLA_SUCCESS) { |
| 1844 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1845 | ql_dbg(ql_dbg_mbx, vha, 0x105f, |
| 1846 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 1847 | rval, mcp->mb[0], mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1848 | } else { |
| 1849 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1850 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1060, |
| 1851 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1852 | } |
| 1853 | |
| 1854 | return rval; |
| 1855 | } |
| 1856 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1857 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1858 | 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] | 1859 | uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt) |
| 1860 | { |
| 1861 | int rval; |
| 1862 | |
| 1863 | struct logio_entry_24xx *lg; |
| 1864 | dma_addr_t lg_dma; |
| 1865 | uint32_t iop[2]; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1866 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1867 | struct req_que *req; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -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, 0x1061, |
| 1870 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1871 | |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 1872 | if (ha->flags.cpu_affinity_enabled) |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 1873 | req = ha->req_q_map[0]; |
| 1874 | else |
| 1875 | req = vha->req; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1876 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1877 | lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); |
| 1878 | if (lg == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1879 | ql_log(ql_log_warn, vha, 0x1062, |
| 1880 | "Failed to allocate login IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1881 | return QLA_MEMORY_ALLOC_FAILED; |
| 1882 | } |
| 1883 | memset(lg, 0, sizeof(struct logio_entry_24xx)); |
| 1884 | |
| 1885 | lg->entry_type = LOGINOUT_PORT_IOCB_TYPE; |
| 1886 | lg->entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1887 | lg->handle = MAKE_HANDLE(req->id, lg->handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1888 | lg->nport_handle = cpu_to_le16(loop_id); |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 1889 | lg->control_flags = cpu_to_le16(LCF_COMMAND_PLOGI); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1890 | if (opt & BIT_0) |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 1891 | lg->control_flags |= cpu_to_le16(LCF_COND_PLOGI); |
Andrew Vasquez | 8baa51a | 2006-06-23 16:10:44 -0700 | [diff] [blame] | 1892 | if (opt & BIT_1) |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 1893 | lg->control_flags |= cpu_to_le16(LCF_SKIP_PRLI); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1894 | lg->port_id[0] = al_pa; |
| 1895 | lg->port_id[1] = area; |
| 1896 | lg->port_id[2] = domain; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1897 | lg->vp_index = vha->vp_idx; |
Andrew Vasquez | 7f45dd0 | 2012-02-09 11:15:45 -0800 | [diff] [blame] | 1898 | rval = qla2x00_issue_iocb_timeout(vha, lg, lg_dma, 0, |
| 1899 | (ha->r_a_tov / 10 * 2) + 2); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1900 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1901 | ql_dbg(ql_dbg_mbx, vha, 0x1063, |
| 1902 | "Failed to issue login IOCB (%x).\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1903 | } else if (lg->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1904 | ql_dbg(ql_dbg_mbx, vha, 0x1064, |
| 1905 | "Failed to complete IOCB -- error status (%x).\n", |
| 1906 | lg->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1907 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 1908 | } else if (lg->comp_status != cpu_to_le16(CS_COMPLETE)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1909 | iop[0] = le32_to_cpu(lg->io_parameter[0]); |
| 1910 | iop[1] = le32_to_cpu(lg->io_parameter[1]); |
| 1911 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1912 | ql_dbg(ql_dbg_mbx, vha, 0x1065, |
| 1913 | "Failed to complete IOCB -- completion status (%x) " |
| 1914 | "ioparam=%x/%x.\n", le16_to_cpu(lg->comp_status), |
| 1915 | iop[0], iop[1]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1916 | |
| 1917 | switch (iop[0]) { |
| 1918 | case LSC_SCODE_PORTID_USED: |
| 1919 | mb[0] = MBS_PORT_ID_USED; |
| 1920 | mb[1] = LSW(iop[1]); |
| 1921 | break; |
| 1922 | case LSC_SCODE_NPORT_USED: |
| 1923 | mb[0] = MBS_LOOP_ID_USED; |
| 1924 | break; |
| 1925 | case LSC_SCODE_NOLINK: |
| 1926 | case LSC_SCODE_NOIOCB: |
| 1927 | case LSC_SCODE_NOXCB: |
| 1928 | case LSC_SCODE_CMD_FAILED: |
| 1929 | case LSC_SCODE_NOFABRIC: |
| 1930 | case LSC_SCODE_FW_NOT_READY: |
| 1931 | case LSC_SCODE_NOT_LOGGED_IN: |
| 1932 | case LSC_SCODE_NOPCB: |
| 1933 | case LSC_SCODE_ELS_REJECT: |
| 1934 | case LSC_SCODE_CMD_PARAM_ERR: |
| 1935 | case LSC_SCODE_NONPORT: |
| 1936 | case LSC_SCODE_LOGGED_IN: |
| 1937 | case LSC_SCODE_NOFLOGI_ACC: |
| 1938 | default: |
| 1939 | mb[0] = MBS_COMMAND_ERROR; |
| 1940 | break; |
| 1941 | } |
| 1942 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1943 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1066, |
| 1944 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1945 | |
| 1946 | iop[0] = le32_to_cpu(lg->io_parameter[0]); |
| 1947 | |
| 1948 | mb[0] = MBS_COMMAND_COMPLETE; |
| 1949 | mb[1] = 0; |
| 1950 | if (iop[0] & BIT_4) { |
| 1951 | if (iop[0] & BIT_8) |
| 1952 | mb[1] |= BIT_1; |
| 1953 | } else |
| 1954 | mb[1] = BIT_0; |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 1955 | |
| 1956 | /* Passback COS information. */ |
| 1957 | mb[10] = 0; |
| 1958 | if (lg->io_parameter[7] || lg->io_parameter[8]) |
| 1959 | mb[10] |= BIT_0; /* Class 2. */ |
| 1960 | if (lg->io_parameter[9] || lg->io_parameter[10]) |
| 1961 | mb[10] |= BIT_1; /* Class 3. */ |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 1962 | if (lg->io_parameter[0] & cpu_to_le32(BIT_7)) |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 1963 | mb[10] |= BIT_7; /* Confirmed Completion |
| 1964 | * Allowed |
| 1965 | */ |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1966 | } |
| 1967 | |
| 1968 | dma_pool_free(ha->s_dma_pool, lg, lg_dma); |
| 1969 | |
| 1970 | return rval; |
| 1971 | } |
| 1972 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1973 | /* |
| 1974 | * qla2x00_login_fabric |
| 1975 | * Issue login fabric port mailbox command. |
| 1976 | * |
| 1977 | * Input: |
| 1978 | * ha = adapter block pointer. |
| 1979 | * loop_id = device loop ID. |
| 1980 | * domain = device domain. |
| 1981 | * area = device area. |
| 1982 | * al_pa = device AL_PA. |
| 1983 | * status = pointer for return status. |
| 1984 | * opt = command options. |
| 1985 | * TARGET_QUEUE_LOCK must be released. |
| 1986 | * ADAPTER_STATE_LOCK must be released. |
| 1987 | * |
| 1988 | * Returns: |
| 1989 | * qla2x00 local function return status code. |
| 1990 | * |
| 1991 | * Context: |
| 1992 | * Kernel context. |
| 1993 | */ |
| 1994 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1995 | 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] | 1996 | uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt) |
| 1997 | { |
| 1998 | int rval; |
| 1999 | mbx_cmd_t mc; |
| 2000 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2001 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2002 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2003 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1067, |
| 2004 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2005 | |
| 2006 | mcp->mb[0] = MBC_LOGIN_FABRIC_PORT; |
| 2007 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 2008 | if (HAS_EXTENDED_IDS(ha)) { |
| 2009 | mcp->mb[1] = loop_id; |
| 2010 | mcp->mb[10] = opt; |
| 2011 | mcp->out_mb |= MBX_10; |
| 2012 | } else { |
| 2013 | mcp->mb[1] = (loop_id << 8) | opt; |
| 2014 | } |
| 2015 | mcp->mb[2] = domain; |
| 2016 | mcp->mb[3] = area << 8 | al_pa; |
| 2017 | |
| 2018 | mcp->in_mb = MBX_7|MBX_6|MBX_2|MBX_1|MBX_0; |
| 2019 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
| 2020 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2021 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2022 | |
| 2023 | /* Return mailbox statuses. */ |
| 2024 | if (mb != NULL) { |
| 2025 | mb[0] = mcp->mb[0]; |
| 2026 | mb[1] = mcp->mb[1]; |
| 2027 | mb[2] = mcp->mb[2]; |
| 2028 | mb[6] = mcp->mb[6]; |
| 2029 | mb[7] = mcp->mb[7]; |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 2030 | /* COS retrieved from Get-Port-Database mailbox command. */ |
| 2031 | mb[10] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2032 | } |
| 2033 | |
| 2034 | if (rval != QLA_SUCCESS) { |
| 2035 | /* RLU tmp code: need to change main mailbox_command function to |
| 2036 | * return ok even when the mailbox completion value is not |
| 2037 | * SUCCESS. The caller needs to be responsible to interpret |
| 2038 | * the return values of this mailbox command if we're not |
| 2039 | * to change too much of the existing code. |
| 2040 | */ |
| 2041 | if (mcp->mb[0] == 0x4001 || mcp->mb[0] == 0x4002 || |
| 2042 | mcp->mb[0] == 0x4003 || mcp->mb[0] == 0x4005 || |
| 2043 | mcp->mb[0] == 0x4006) |
| 2044 | rval = QLA_SUCCESS; |
| 2045 | |
| 2046 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2047 | ql_dbg(ql_dbg_mbx, vha, 0x1068, |
| 2048 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 2049 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2050 | } else { |
| 2051 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2052 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1069, |
| 2053 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2054 | } |
| 2055 | |
| 2056 | return rval; |
| 2057 | } |
| 2058 | |
| 2059 | /* |
| 2060 | * qla2x00_login_local_device |
| 2061 | * Issue login loop port mailbox command. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2062 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2063 | * Input: |
| 2064 | * ha = adapter block pointer. |
| 2065 | * loop_id = device loop ID. |
| 2066 | * opt = command options. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2067 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2068 | * Returns: |
| 2069 | * Return status code. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2070 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2071 | * Context: |
| 2072 | * Kernel context. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2073 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2074 | */ |
| 2075 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2076 | 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] | 2077 | uint16_t *mb_ret, uint8_t opt) |
| 2078 | { |
| 2079 | int rval; |
| 2080 | mbx_cmd_t mc; |
| 2081 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2082 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2083 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2084 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106a, |
| 2085 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2086 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2087 | if (IS_FWI2_CAPABLE(ha)) |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2088 | return qla24xx_login_fabric(vha, fcport->loop_id, |
andrew.vasquez@qlogic.com | 9a52a57c | 2006-03-09 14:27:44 -0800 | [diff] [blame] | 2089 | fcport->d_id.b.domain, fcport->d_id.b.area, |
| 2090 | fcport->d_id.b.al_pa, mb_ret, opt); |
| 2091 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2092 | mcp->mb[0] = MBC_LOGIN_LOOP_PORT; |
| 2093 | if (HAS_EXTENDED_IDS(ha)) |
andrew.vasquez@qlogic.com | 9a52a57c | 2006-03-09 14:27:44 -0800 | [diff] [blame] | 2094 | mcp->mb[1] = fcport->loop_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2095 | else |
andrew.vasquez@qlogic.com | 9a52a57c | 2006-03-09 14:27:44 -0800 | [diff] [blame] | 2096 | mcp->mb[1] = fcport->loop_id << 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2097 | mcp->mb[2] = opt; |
| 2098 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 2099 | mcp->in_mb = MBX_7|MBX_6|MBX_1|MBX_0; |
| 2100 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
| 2101 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2102 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2103 | |
| 2104 | /* Return mailbox statuses. */ |
| 2105 | if (mb_ret != NULL) { |
| 2106 | mb_ret[0] = mcp->mb[0]; |
| 2107 | mb_ret[1] = mcp->mb[1]; |
| 2108 | mb_ret[6] = mcp->mb[6]; |
| 2109 | mb_ret[7] = mcp->mb[7]; |
| 2110 | } |
| 2111 | |
| 2112 | if (rval != QLA_SUCCESS) { |
| 2113 | /* AV tmp code: need to change main mailbox_command function to |
| 2114 | * return ok even when the mailbox completion value is not |
| 2115 | * SUCCESS. The caller needs to be responsible to interpret |
| 2116 | * the return values of this mailbox command if we're not |
| 2117 | * to change too much of the existing code. |
| 2118 | */ |
| 2119 | if (mcp->mb[0] == 0x4005 || mcp->mb[0] == 0x4006) |
| 2120 | rval = QLA_SUCCESS; |
| 2121 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2122 | ql_dbg(ql_dbg_mbx, vha, 0x106b, |
| 2123 | "Failed=%x mb[0]=%x mb[1]=%x mb[6]=%x mb[7]=%x.\n", |
| 2124 | 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] | 2125 | } else { |
| 2126 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2127 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106c, |
| 2128 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2129 | } |
| 2130 | |
| 2131 | return (rval); |
| 2132 | } |
| 2133 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2134 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2135 | 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] | 2136 | uint8_t area, uint8_t al_pa) |
| 2137 | { |
| 2138 | int rval; |
| 2139 | struct logio_entry_24xx *lg; |
| 2140 | dma_addr_t lg_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2141 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2142 | struct req_que *req; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2143 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2144 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106d, |
| 2145 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2146 | |
| 2147 | lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); |
| 2148 | if (lg == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2149 | ql_log(ql_log_warn, vha, 0x106e, |
| 2150 | "Failed to allocate logout IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2151 | return QLA_MEMORY_ALLOC_FAILED; |
| 2152 | } |
| 2153 | memset(lg, 0, sizeof(struct logio_entry_24xx)); |
| 2154 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2155 | if (ql2xmaxqueues > 1) |
| 2156 | req = ha->req_q_map[0]; |
| 2157 | else |
| 2158 | req = vha->req; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2159 | lg->entry_type = LOGINOUT_PORT_IOCB_TYPE; |
| 2160 | lg->entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2161 | lg->handle = MAKE_HANDLE(req->id, lg->handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2162 | lg->nport_handle = cpu_to_le16(loop_id); |
| 2163 | lg->control_flags = |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2164 | cpu_to_le16(LCF_COMMAND_LOGO|LCF_IMPL_LOGO| |
Andrew Vasquez | c8d6691 | 2011-03-30 11:46:21 -0700 | [diff] [blame] | 2165 | LCF_FREE_NPORT); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2166 | lg->port_id[0] = al_pa; |
| 2167 | lg->port_id[1] = area; |
| 2168 | lg->port_id[2] = domain; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2169 | lg->vp_index = vha->vp_idx; |
Andrew Vasquez | 7f45dd0 | 2012-02-09 11:15:45 -0800 | [diff] [blame] | 2170 | rval = qla2x00_issue_iocb_timeout(vha, lg, lg_dma, 0, |
| 2171 | (ha->r_a_tov / 10 * 2) + 2); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2172 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2173 | ql_dbg(ql_dbg_mbx, vha, 0x106f, |
| 2174 | "Failed to issue logout IOCB (%x).\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2175 | } else if (lg->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2176 | ql_dbg(ql_dbg_mbx, vha, 0x1070, |
| 2177 | "Failed to complete IOCB -- error status (%x).\n", |
| 2178 | lg->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2179 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2180 | } else if (lg->comp_status != cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2181 | ql_dbg(ql_dbg_mbx, vha, 0x1071, |
| 2182 | "Failed to complete IOCB -- completion status (%x) " |
| 2183 | "ioparam=%x/%x.\n", le16_to_cpu(lg->comp_status), |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2184 | le32_to_cpu(lg->io_parameter[0]), |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2185 | le32_to_cpu(lg->io_parameter[1])); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2186 | } else { |
| 2187 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2188 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1072, |
| 2189 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2190 | } |
| 2191 | |
| 2192 | dma_pool_free(ha->s_dma_pool, lg, lg_dma); |
| 2193 | |
| 2194 | return rval; |
| 2195 | } |
| 2196 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2197 | /* |
| 2198 | * qla2x00_fabric_logout |
| 2199 | * Issue logout fabric port mailbox command. |
| 2200 | * |
| 2201 | * Input: |
| 2202 | * ha = adapter block pointer. |
| 2203 | * loop_id = device loop ID. |
| 2204 | * TARGET_QUEUE_LOCK must be released. |
| 2205 | * ADAPTER_STATE_LOCK must be released. |
| 2206 | * |
| 2207 | * Returns: |
| 2208 | * qla2x00 local function return status code. |
| 2209 | * |
| 2210 | * Context: |
| 2211 | * Kernel context. |
| 2212 | */ |
| 2213 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2214 | qla2x00_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] | 2215 | uint8_t area, uint8_t al_pa) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2216 | { |
| 2217 | int rval; |
| 2218 | mbx_cmd_t mc; |
| 2219 | mbx_cmd_t *mcp = &mc; |
| 2220 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2221 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1073, |
| 2222 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2223 | |
| 2224 | mcp->mb[0] = MBC_LOGOUT_FABRIC_PORT; |
| 2225 | mcp->out_mb = MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2226 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2227 | mcp->mb[1] = loop_id; |
| 2228 | mcp->mb[10] = 0; |
| 2229 | mcp->out_mb |= MBX_10; |
| 2230 | } else { |
| 2231 | mcp->mb[1] = loop_id << 8; |
| 2232 | } |
| 2233 | |
| 2234 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2235 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2236 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2237 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2238 | |
| 2239 | if (rval != QLA_SUCCESS) { |
| 2240 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2241 | ql_dbg(ql_dbg_mbx, vha, 0x1074, |
| 2242 | "Failed=%x mb[1]=%x.\n", rval, mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2243 | } else { |
| 2244 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2245 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1075, |
| 2246 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2247 | } |
| 2248 | |
| 2249 | return rval; |
| 2250 | } |
| 2251 | |
| 2252 | /* |
| 2253 | * qla2x00_full_login_lip |
| 2254 | * Issue full login LIP mailbox command. |
| 2255 | * |
| 2256 | * Input: |
| 2257 | * ha = adapter block pointer. |
| 2258 | * TARGET_QUEUE_LOCK must be released. |
| 2259 | * ADAPTER_STATE_LOCK must be released. |
| 2260 | * |
| 2261 | * Returns: |
| 2262 | * qla2x00 local function return status code. |
| 2263 | * |
| 2264 | * Context: |
| 2265 | * Kernel context. |
| 2266 | */ |
| 2267 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2268 | qla2x00_full_login_lip(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2269 | { |
| 2270 | int rval; |
| 2271 | mbx_cmd_t mc; |
| 2272 | mbx_cmd_t *mcp = &mc; |
| 2273 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2274 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1076, |
| 2275 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2276 | |
| 2277 | mcp->mb[0] = MBC_LIP_FULL_LOGIN; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2278 | mcp->mb[1] = IS_FWI2_CAPABLE(vha->hw) ? BIT_3 : 0; |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 2279 | mcp->mb[2] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2280 | mcp->mb[3] = 0; |
| 2281 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 2282 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2283 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2284 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2285 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2286 | |
| 2287 | if (rval != QLA_SUCCESS) { |
| 2288 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2289 | ql_dbg(ql_dbg_mbx, vha, 0x1077, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2290 | } else { |
| 2291 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2292 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1078, |
| 2293 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2294 | } |
| 2295 | |
| 2296 | return rval; |
| 2297 | } |
| 2298 | |
| 2299 | /* |
| 2300 | * qla2x00_get_id_list |
| 2301 | * |
| 2302 | * Input: |
| 2303 | * ha = adapter block pointer. |
| 2304 | * |
| 2305 | * Returns: |
| 2306 | * qla2x00 local function return status code. |
| 2307 | * |
| 2308 | * Context: |
| 2309 | * Kernel context. |
| 2310 | */ |
| 2311 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2312 | 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] | 2313 | uint16_t *entries) |
| 2314 | { |
| 2315 | int rval; |
| 2316 | mbx_cmd_t mc; |
| 2317 | mbx_cmd_t *mcp = &mc; |
| 2318 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2319 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1079, |
| 2320 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2321 | |
| 2322 | if (id_list == NULL) |
| 2323 | return QLA_FUNCTION_FAILED; |
| 2324 | |
| 2325 | mcp->mb[0] = MBC_GET_ID_LIST; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2326 | mcp->out_mb = MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2327 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2328 | mcp->mb[2] = MSW(id_list_dma); |
| 2329 | mcp->mb[3] = LSW(id_list_dma); |
| 2330 | mcp->mb[6] = MSW(MSD(id_list_dma)); |
| 2331 | mcp->mb[7] = LSW(MSD(id_list_dma)); |
andrew.vasquez@qlogic.com | 247ec45 | 2006-02-07 08:45:40 -0800 | [diff] [blame] | 2332 | mcp->mb[8] = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2333 | mcp->mb[9] = vha->vp_idx; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2334 | 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] | 2335 | } else { |
| 2336 | mcp->mb[1] = MSW(id_list_dma); |
| 2337 | mcp->mb[2] = LSW(id_list_dma); |
| 2338 | mcp->mb[3] = MSW(MSD(id_list_dma)); |
| 2339 | mcp->mb[6] = LSW(MSD(id_list_dma)); |
| 2340 | mcp->out_mb |= MBX_6|MBX_3|MBX_2|MBX_1; |
| 2341 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2342 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2343 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2344 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2345 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2346 | |
| 2347 | if (rval != QLA_SUCCESS) { |
| 2348 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2349 | ql_dbg(ql_dbg_mbx, vha, 0x107a, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2350 | } else { |
| 2351 | *entries = mcp->mb[1]; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2352 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107b, |
| 2353 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2354 | } |
| 2355 | |
| 2356 | return rval; |
| 2357 | } |
| 2358 | |
| 2359 | /* |
| 2360 | * qla2x00_get_resource_cnts |
| 2361 | * Get current firmware resource counts. |
| 2362 | * |
| 2363 | * Input: |
| 2364 | * ha = adapter block pointer. |
| 2365 | * |
| 2366 | * Returns: |
| 2367 | * qla2x00 local function return status code. |
| 2368 | * |
| 2369 | * Context: |
| 2370 | * Kernel context. |
| 2371 | */ |
| 2372 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2373 | qla2x00_get_resource_cnts(scsi_qla_host_t *vha, uint16_t *cur_xchg_cnt, |
Seokmann Ju | 4d0ea24 | 2007-09-20 14:07:43 -0700 | [diff] [blame] | 2374 | uint16_t *orig_xchg_cnt, uint16_t *cur_iocb_cnt, |
Andrew Vasquez | f3a0a77 | 2009-10-13 15:16:49 -0700 | [diff] [blame] | 2375 | uint16_t *orig_iocb_cnt, uint16_t *max_npiv_vports, uint16_t *max_fcfs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2376 | { |
| 2377 | int rval; |
| 2378 | mbx_cmd_t mc; |
| 2379 | mbx_cmd_t *mcp = &mc; |
| 2380 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2381 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107c, |
| 2382 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2383 | |
| 2384 | mcp->mb[0] = MBC_GET_RESOURCE_COUNTS; |
| 2385 | mcp->out_mb = MBX_0; |
Seokmann Ju | 4d0ea24 | 2007-09-20 14:07:43 -0700 | [diff] [blame] | 2386 | 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] | 2387 | 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] | 2388 | mcp->in_mb |= MBX_12; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2389 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2390 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2391 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2392 | |
| 2393 | if (rval != QLA_SUCCESS) { |
| 2394 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2395 | ql_dbg(ql_dbg_mbx, vha, 0x107d, |
| 2396 | "Failed mb[0]=%x.\n", mcp->mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2397 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2398 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107e, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2399 | "Done %s mb1=%x mb2=%x mb3=%x mb6=%x mb7=%x mb10=%x " |
| 2400 | "mb11=%x mb12=%x.\n", __func__, mcp->mb[1], mcp->mb[2], |
| 2401 | mcp->mb[3], mcp->mb[6], mcp->mb[7], mcp->mb[10], |
| 2402 | mcp->mb[11], mcp->mb[12]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2403 | |
| 2404 | if (cur_xchg_cnt) |
| 2405 | *cur_xchg_cnt = mcp->mb[3]; |
| 2406 | if (orig_xchg_cnt) |
| 2407 | *orig_xchg_cnt = mcp->mb[6]; |
| 2408 | if (cur_iocb_cnt) |
| 2409 | *cur_iocb_cnt = mcp->mb[7]; |
| 2410 | if (orig_iocb_cnt) |
| 2411 | *orig_iocb_cnt = mcp->mb[10]; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2412 | if (vha->hw->flags.npiv_supported && max_npiv_vports) |
Seokmann Ju | 4d0ea24 | 2007-09-20 14:07:43 -0700 | [diff] [blame] | 2413 | *max_npiv_vports = mcp->mb[11]; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2414 | if ((IS_QLA81XX(vha->hw) || IS_QLA83XX(vha->hw)) && max_fcfs) |
Andrew Vasquez | f3a0a77 | 2009-10-13 15:16:49 -0700 | [diff] [blame] | 2415 | *max_fcfs = mcp->mb[12]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2416 | } |
| 2417 | |
| 2418 | return (rval); |
| 2419 | } |
| 2420 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2421 | /* |
| 2422 | * qla2x00_get_fcal_position_map |
| 2423 | * Get FCAL (LILP) position map using mailbox command |
| 2424 | * |
| 2425 | * Input: |
| 2426 | * ha = adapter state pointer. |
| 2427 | * pos_map = buffer pointer (can be NULL). |
| 2428 | * |
| 2429 | * Returns: |
| 2430 | * qla2x00 local function return status code. |
| 2431 | * |
| 2432 | * Context: |
| 2433 | * Kernel context. |
| 2434 | */ |
| 2435 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2436 | 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] | 2437 | { |
| 2438 | int rval; |
| 2439 | mbx_cmd_t mc; |
| 2440 | mbx_cmd_t *mcp = &mc; |
| 2441 | char *pmap; |
| 2442 | dma_addr_t pmap_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2443 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2444 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2445 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107f, |
| 2446 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2447 | |
Andrew Vasquez | 4b89258 | 2008-09-11 21:22:48 -0700 | [diff] [blame] | 2448 | pmap = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pmap_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2449 | if (pmap == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2450 | ql_log(ql_log_warn, vha, 0x1080, |
| 2451 | "Memory alloc failed.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2452 | return QLA_MEMORY_ALLOC_FAILED; |
| 2453 | } |
| 2454 | memset(pmap, 0, FCAL_MAP_SIZE); |
| 2455 | |
| 2456 | mcp->mb[0] = MBC_GET_FC_AL_POSITION_MAP; |
| 2457 | mcp->mb[2] = MSW(pmap_dma); |
| 2458 | mcp->mb[3] = LSW(pmap_dma); |
| 2459 | mcp->mb[6] = MSW(MSD(pmap_dma)); |
| 2460 | mcp->mb[7] = LSW(MSD(pmap_dma)); |
| 2461 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; |
| 2462 | mcp->in_mb = MBX_1|MBX_0; |
| 2463 | mcp->buf_size = FCAL_MAP_SIZE; |
| 2464 | mcp->flags = MBX_DMA_IN; |
| 2465 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2466 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2467 | |
| 2468 | if (rval == QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2469 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1081, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2470 | "mb0/mb1=%x/%X FC/AL position map size (%x).\n", |
| 2471 | mcp->mb[0], mcp->mb[1], (unsigned)pmap[0]); |
| 2472 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111d, |
| 2473 | pmap, pmap[0] + 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2474 | |
| 2475 | if (pos_map) |
| 2476 | memcpy(pos_map, pmap, FCAL_MAP_SIZE); |
| 2477 | } |
| 2478 | dma_pool_free(ha->s_dma_pool, pmap, pmap_dma); |
| 2479 | |
| 2480 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2481 | ql_dbg(ql_dbg_mbx, vha, 0x1082, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2482 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2483 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1083, |
| 2484 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2485 | } |
| 2486 | |
| 2487 | return rval; |
| 2488 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2489 | |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2490 | /* |
| 2491 | * qla2x00_get_link_status |
| 2492 | * |
| 2493 | * Input: |
| 2494 | * ha = adapter block pointer. |
| 2495 | * loop_id = device loop ID. |
| 2496 | * ret_buf = pointer to link status return buffer. |
| 2497 | * |
| 2498 | * Returns: |
| 2499 | * 0 = success. |
| 2500 | * BIT_0 = mem alloc error. |
| 2501 | * BIT_1 = mailbox error. |
| 2502 | */ |
| 2503 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2504 | 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] | 2505 | struct link_statistics *stats, dma_addr_t stats_dma) |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2506 | { |
| 2507 | int rval; |
| 2508 | mbx_cmd_t mc; |
| 2509 | mbx_cmd_t *mcp = &mc; |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2510 | uint32_t *siter, *diter, dwords; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2511 | struct qla_hw_data *ha = vha->hw; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2512 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2513 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1084, |
| 2514 | "Entered %s.\n", __func__); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2515 | |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2516 | mcp->mb[0] = MBC_GET_LINK_STATUS; |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2517 | mcp->mb[2] = MSW(stats_dma); |
| 2518 | mcp->mb[3] = LSW(stats_dma); |
| 2519 | mcp->mb[6] = MSW(MSD(stats_dma)); |
| 2520 | mcp->mb[7] = LSW(MSD(stats_dma)); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2521 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; |
| 2522 | mcp->in_mb = MBX_0; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2523 | if (IS_FWI2_CAPABLE(ha)) { |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2524 | mcp->mb[1] = loop_id; |
| 2525 | mcp->mb[4] = 0; |
| 2526 | mcp->mb[10] = 0; |
| 2527 | mcp->out_mb |= MBX_10|MBX_4|MBX_1; |
| 2528 | mcp->in_mb |= MBX_1; |
| 2529 | } else if (HAS_EXTENDED_IDS(ha)) { |
| 2530 | mcp->mb[1] = loop_id; |
| 2531 | mcp->mb[10] = 0; |
| 2532 | mcp->out_mb |= MBX_10|MBX_1; |
| 2533 | } else { |
| 2534 | mcp->mb[1] = loop_id << 8; |
| 2535 | mcp->out_mb |= MBX_1; |
| 2536 | } |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2537 | mcp->tov = MBX_TOV_SECONDS; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2538 | mcp->flags = IOCTL_CMD; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2539 | rval = qla2x00_mailbox_command(vha, mcp); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2540 | |
| 2541 | if (rval == QLA_SUCCESS) { |
| 2542 | if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2543 | ql_dbg(ql_dbg_mbx, vha, 0x1085, |
| 2544 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2545 | rval = QLA_FUNCTION_FAILED; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2546 | } else { |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2547 | /* Copy over data -- firmware data is LE. */ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2548 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1086, |
| 2549 | "Done %s.\n", __func__); |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2550 | dwords = offsetof(struct link_statistics, unused1) / 4; |
| 2551 | siter = diter = &stats->link_fail_cnt; |
| 2552 | while (dwords--) |
| 2553 | *diter++ = le32_to_cpu(*siter++); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2554 | } |
| 2555 | } else { |
| 2556 | /* Failed. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2557 | 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] | 2558 | } |
| 2559 | |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2560 | return rval; |
| 2561 | } |
| 2562 | |
| 2563 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2564 | qla24xx_get_isp_stats(scsi_qla_host_t *vha, struct link_statistics *stats, |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2565 | dma_addr_t stats_dma) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2566 | { |
| 2567 | int rval; |
| 2568 | mbx_cmd_t mc; |
| 2569 | mbx_cmd_t *mcp = &mc; |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2570 | uint32_t *siter, *diter, dwords; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2571 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2572 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1088, |
| 2573 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2574 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2575 | mcp->mb[0] = MBC_GET_LINK_PRIV_STATS; |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2576 | mcp->mb[2] = MSW(stats_dma); |
| 2577 | mcp->mb[3] = LSW(stats_dma); |
| 2578 | mcp->mb[6] = MSW(MSD(stats_dma)); |
| 2579 | mcp->mb[7] = LSW(MSD(stats_dma)); |
| 2580 | mcp->mb[8] = sizeof(struct link_statistics) / 4; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2581 | mcp->mb[9] = vha->vp_idx; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2582 | mcp->mb[10] = 0; |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2583 | mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2584 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2585 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2586 | mcp->flags = IOCTL_CMD; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2587 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2588 | |
| 2589 | if (rval == QLA_SUCCESS) { |
| 2590 | if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2591 | ql_dbg(ql_dbg_mbx, vha, 0x1089, |
| 2592 | "Failed mb[0]=%x.\n", mcp->mb[0]); |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2593 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2594 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2595 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x108a, |
| 2596 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2597 | /* Copy over data -- firmware data is LE. */ |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2598 | dwords = sizeof(struct link_statistics) / 4; |
| 2599 | siter = diter = &stats->link_fail_cnt; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2600 | while (dwords--) |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2601 | *diter++ = le32_to_cpu(*siter++); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2602 | } |
| 2603 | } else { |
| 2604 | /* Failed. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2605 | ql_dbg(ql_dbg_mbx, vha, 0x108b, "Failed=%x.\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2606 | } |
| 2607 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2608 | return rval; |
| 2609 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2610 | |
| 2611 | int |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2612 | qla24xx_abort_command(srb_t *sp) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2613 | { |
| 2614 | int rval; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2615 | unsigned long flags = 0; |
| 2616 | |
| 2617 | struct abort_entry_24xx *abt; |
| 2618 | dma_addr_t abt_dma; |
| 2619 | uint32_t handle; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2620 | fc_port_t *fcport = sp->fcport; |
| 2621 | struct scsi_qla_host *vha = fcport->vha; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2622 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 2623 | struct req_que *req = vha->req; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2624 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2625 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x108c, |
| 2626 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2627 | |
Armen Baloyan | 4440e46 | 2014-02-26 04:15:18 -0500 | [diff] [blame] | 2628 | if (ql2xasynctmfenable) |
| 2629 | return qla24xx_async_abort_command(sp); |
| 2630 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2631 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 2632 | for (handle = 1; handle < req->num_outstanding_cmds; handle++) { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2633 | if (req->outstanding_cmds[handle] == sp) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2634 | break; |
| 2635 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2636 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 2637 | if (handle == req->num_outstanding_cmds) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2638 | /* Command not found. */ |
| 2639 | return QLA_FUNCTION_FAILED; |
| 2640 | } |
| 2641 | |
| 2642 | abt = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &abt_dma); |
| 2643 | if (abt == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2644 | ql_log(ql_log_warn, vha, 0x108d, |
| 2645 | "Failed to allocate abort IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2646 | return QLA_MEMORY_ALLOC_FAILED; |
| 2647 | } |
| 2648 | memset(abt, 0, sizeof(struct abort_entry_24xx)); |
| 2649 | |
| 2650 | abt->entry_type = ABORT_IOCB_TYPE; |
| 2651 | abt->entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2652 | abt->handle = MAKE_HANDLE(req->id, abt->handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2653 | abt->nport_handle = cpu_to_le16(fcport->loop_id); |
Mike Hernandez | a74ec14 | 2011-03-30 11:46:20 -0700 | [diff] [blame] | 2654 | abt->handle_to_abort = MAKE_HANDLE(req->id, handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2655 | abt->port_id[0] = fcport->d_id.b.al_pa; |
| 2656 | abt->port_id[1] = fcport->d_id.b.area; |
| 2657 | abt->port_id[2] = fcport->d_id.b.domain; |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 2658 | abt->vp_index = fcport->vha->vp_idx; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2659 | |
| 2660 | abt->req_que_no = cpu_to_le16(req->id); |
| 2661 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2662 | rval = qla2x00_issue_iocb(vha, abt, abt_dma, 0); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2663 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2664 | ql_dbg(ql_dbg_mbx, vha, 0x108e, |
| 2665 | "Failed to issue IOCB (%x).\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2666 | } else if (abt->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2667 | ql_dbg(ql_dbg_mbx, vha, 0x108f, |
| 2668 | "Failed to complete IOCB -- error status (%x).\n", |
| 2669 | abt->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2670 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2671 | } else if (abt->nport_handle != cpu_to_le16(0)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2672 | ql_dbg(ql_dbg_mbx, vha, 0x1090, |
| 2673 | "Failed to complete IOCB -- completion status (%x).\n", |
| 2674 | le16_to_cpu(abt->nport_handle)); |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 2675 | if (abt->nport_handle == CS_IOCB_ERROR) |
| 2676 | rval = QLA_FUNCTION_PARAMETER_ERROR; |
| 2677 | else |
| 2678 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2679 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2680 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1091, |
| 2681 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2682 | } |
| 2683 | |
| 2684 | dma_pool_free(ha->s_dma_pool, abt, abt_dma); |
| 2685 | |
| 2686 | return rval; |
| 2687 | } |
| 2688 | |
| 2689 | struct tsk_mgmt_cmd { |
| 2690 | union { |
| 2691 | struct tsk_mgmt_entry tsk; |
| 2692 | struct sts_entry_24xx sts; |
| 2693 | } p; |
| 2694 | }; |
| 2695 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2696 | static int |
| 2697 | __qla24xx_issue_tmf(char *name, uint32_t type, struct fc_port *fcport, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 2698 | uint64_t l, int tag) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2699 | { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2700 | int rval, rval2; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2701 | struct tsk_mgmt_cmd *tsk; |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 2702 | struct sts_entry_24xx *sts; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2703 | dma_addr_t tsk_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2704 | scsi_qla_host_t *vha; |
| 2705 | struct qla_hw_data *ha; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2706 | struct req_que *req; |
| 2707 | struct rsp_que *rsp; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2708 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2709 | vha = fcport->vha; |
| 2710 | ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2711 | req = vha->req; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2712 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2713 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1092, |
| 2714 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2715 | |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 2716 | if (ha->flags.cpu_affinity_enabled) |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2717 | rsp = ha->rsp_q_map[tag + 1]; |
| 2718 | else |
| 2719 | rsp = req->rsp; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2720 | tsk = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &tsk_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2721 | if (tsk == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2722 | ql_log(ql_log_warn, vha, 0x1093, |
| 2723 | "Failed to allocate task management IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2724 | return QLA_MEMORY_ALLOC_FAILED; |
| 2725 | } |
| 2726 | memset(tsk, 0, sizeof(struct tsk_mgmt_cmd)); |
| 2727 | |
| 2728 | tsk->p.tsk.entry_type = TSK_MGMT_IOCB_TYPE; |
| 2729 | tsk->p.tsk.entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2730 | tsk->p.tsk.handle = MAKE_HANDLE(req->id, tsk->p.tsk.handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2731 | tsk->p.tsk.nport_handle = cpu_to_le16(fcport->loop_id); |
Andrew Vasquez | 00a537b | 2008-02-28 14:06:11 -0800 | [diff] [blame] | 2732 | 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] | 2733 | tsk->p.tsk.control_flags = cpu_to_le32(type); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2734 | tsk->p.tsk.port_id[0] = fcport->d_id.b.al_pa; |
| 2735 | tsk->p.tsk.port_id[1] = fcport->d_id.b.area; |
| 2736 | tsk->p.tsk.port_id[2] = fcport->d_id.b.domain; |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 2737 | tsk->p.tsk.vp_index = fcport->vha->vp_idx; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2738 | if (type == TCF_LUN_RESET) { |
| 2739 | int_to_scsilun(l, &tsk->p.tsk.lun); |
| 2740 | host_to_fcp_swap((uint8_t *)&tsk->p.tsk.lun, |
| 2741 | sizeof(tsk->p.tsk.lun)); |
| 2742 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2743 | |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 2744 | sts = &tsk->p.sts; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2745 | rval = qla2x00_issue_iocb(vha, tsk, tsk_dma, 0); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2746 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2747 | ql_dbg(ql_dbg_mbx, vha, 0x1094, |
| 2748 | "Failed to issue %s reset IOCB (%x).\n", name, rval); |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 2749 | } else if (sts->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2750 | ql_dbg(ql_dbg_mbx, vha, 0x1095, |
| 2751 | "Failed to complete IOCB -- error status (%x).\n", |
| 2752 | sts->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2753 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 2754 | } else if (sts->comp_status != cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2755 | ql_dbg(ql_dbg_mbx, vha, 0x1096, |
| 2756 | "Failed to complete IOCB -- completion status (%x).\n", |
| 2757 | le16_to_cpu(sts->comp_status)); |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 2758 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 97dec56 | 2011-02-23 15:27:14 -0800 | [diff] [blame] | 2759 | } else if (le16_to_cpu(sts->scsi_status) & |
| 2760 | SS_RESPONSE_INFO_LEN_VALID) { |
| 2761 | if (le32_to_cpu(sts->rsp_data_len) < 4) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2762 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1097, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2763 | "Ignoring inconsistent data length -- not enough " |
| 2764 | "response info (%d).\n", |
| 2765 | le32_to_cpu(sts->rsp_data_len)); |
Andrew Vasquez | 97dec56 | 2011-02-23 15:27:14 -0800 | [diff] [blame] | 2766 | } else if (sts->data[3]) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2767 | ql_dbg(ql_dbg_mbx, vha, 0x1098, |
| 2768 | "Failed to complete IOCB -- response (%x).\n", |
| 2769 | sts->data[3]); |
Andrew Vasquez | 97dec56 | 2011-02-23 15:27:14 -0800 | [diff] [blame] | 2770 | rval = QLA_FUNCTION_FAILED; |
| 2771 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2772 | } |
| 2773 | |
| 2774 | /* Issue marker IOCB. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2775 | rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, l, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2776 | type == TCF_LUN_RESET ? MK_SYNC_ID_LUN: MK_SYNC_ID); |
| 2777 | if (rval2 != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2778 | ql_dbg(ql_dbg_mbx, vha, 0x1099, |
| 2779 | "Failed to issue marker IOCB (%x).\n", rval2); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2780 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2781 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109a, |
| 2782 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2783 | } |
| 2784 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2785 | dma_pool_free(ha->s_dma_pool, tsk, tsk_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2786 | |
| 2787 | return rval; |
| 2788 | } |
| 2789 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2790 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 2791 | qla24xx_abort_target(struct fc_port *fcport, uint64_t l, int tag) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2792 | { |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 2793 | struct qla_hw_data *ha = fcport->vha->hw; |
| 2794 | |
| 2795 | if ((ql2xasynctmfenable) && IS_FWI2_CAPABLE(ha)) |
| 2796 | return qla2x00_async_tm_cmd(fcport, TCF_TARGET_RESET, l, tag); |
| 2797 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2798 | return __qla24xx_issue_tmf("Target", TCF_TARGET_RESET, fcport, l, tag); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2799 | } |
| 2800 | |
| 2801 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 2802 | qla24xx_lun_reset(struct fc_port *fcport, uint64_t l, int tag) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2803 | { |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 2804 | struct qla_hw_data *ha = fcport->vha->hw; |
| 2805 | |
| 2806 | if ((ql2xasynctmfenable) && IS_FWI2_CAPABLE(ha)) |
| 2807 | return qla2x00_async_tm_cmd(fcport, TCF_LUN_RESET, l, tag); |
| 2808 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2809 | return __qla24xx_issue_tmf("Lun", TCF_LUN_RESET, fcport, l, tag); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2810 | } |
| 2811 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2812 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2813 | qla2x00_system_error(scsi_qla_host_t *vha) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2814 | { |
| 2815 | int rval; |
| 2816 | mbx_cmd_t mc; |
| 2817 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2818 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2819 | |
Andrew Vasquez | 68af081 | 2008-05-12 22:21:13 -0700 | [diff] [blame] | 2820 | if (!IS_QLA23XX(ha) && !IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2821 | return QLA_FUNCTION_FAILED; |
| 2822 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2823 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109b, |
| 2824 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2825 | |
| 2826 | mcp->mb[0] = MBC_GEN_SYSTEM_ERROR; |
| 2827 | mcp->out_mb = MBX_0; |
| 2828 | mcp->in_mb = MBX_0; |
| 2829 | mcp->tov = 5; |
| 2830 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2831 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2832 | |
| 2833 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2834 | ql_dbg(ql_dbg_mbx, vha, 0x109c, "Failed=%x.\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2835 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2836 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109d, |
| 2837 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2838 | } |
| 2839 | |
| 2840 | return rval; |
| 2841 | } |
| 2842 | |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 2843 | int |
| 2844 | qla2x00_write_serdes_word(scsi_qla_host_t *vha, uint16_t addr, uint16_t data) |
| 2845 | { |
| 2846 | int rval; |
| 2847 | mbx_cmd_t mc; |
| 2848 | mbx_cmd_t *mcp = &mc; |
| 2849 | |
Andrew Vasquez | 064135e | 2015-04-09 15:00:02 -0400 | [diff] [blame] | 2850 | if (!IS_QLA2031(vha->hw) && !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 2851 | return QLA_FUNCTION_FAILED; |
| 2852 | |
| 2853 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1182, |
| 2854 | "Entered %s.\n", __func__); |
| 2855 | |
| 2856 | mcp->mb[0] = MBC_WRITE_SERDES; |
| 2857 | mcp->mb[1] = addr; |
Andrew Vasquez | 064135e | 2015-04-09 15:00:02 -0400 | [diff] [blame] | 2858 | if (IS_QLA2031(vha->hw)) |
| 2859 | mcp->mb[2] = data & 0xff; |
| 2860 | else |
| 2861 | mcp->mb[2] = data; |
| 2862 | |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 2863 | mcp->mb[3] = 0; |
| 2864 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 2865 | mcp->in_mb = MBX_0; |
| 2866 | mcp->tov = MBX_TOV_SECONDS; |
| 2867 | mcp->flags = 0; |
| 2868 | rval = qla2x00_mailbox_command(vha, mcp); |
| 2869 | |
| 2870 | if (rval != QLA_SUCCESS) { |
| 2871 | ql_dbg(ql_dbg_mbx, vha, 0x1183, |
| 2872 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 2873 | } else { |
| 2874 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1184, |
| 2875 | "Done %s.\n", __func__); |
| 2876 | } |
| 2877 | |
| 2878 | return rval; |
| 2879 | } |
| 2880 | |
| 2881 | int |
| 2882 | qla2x00_read_serdes_word(scsi_qla_host_t *vha, uint16_t addr, uint16_t *data) |
| 2883 | { |
| 2884 | int rval; |
| 2885 | mbx_cmd_t mc; |
| 2886 | mbx_cmd_t *mcp = &mc; |
| 2887 | |
Andrew Vasquez | 064135e | 2015-04-09 15:00:02 -0400 | [diff] [blame] | 2888 | if (!IS_QLA2031(vha->hw) && !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 2889 | return QLA_FUNCTION_FAILED; |
| 2890 | |
| 2891 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1185, |
| 2892 | "Entered %s.\n", __func__); |
| 2893 | |
| 2894 | mcp->mb[0] = MBC_READ_SERDES; |
| 2895 | mcp->mb[1] = addr; |
| 2896 | mcp->mb[3] = 0; |
| 2897 | mcp->out_mb = MBX_3|MBX_1|MBX_0; |
| 2898 | mcp->in_mb = MBX_1|MBX_0; |
| 2899 | mcp->tov = MBX_TOV_SECONDS; |
| 2900 | mcp->flags = 0; |
| 2901 | rval = qla2x00_mailbox_command(vha, mcp); |
| 2902 | |
Andrew Vasquez | 064135e | 2015-04-09 15:00:02 -0400 | [diff] [blame] | 2903 | if (IS_QLA2031(vha->hw)) |
| 2904 | *data = mcp->mb[1] & 0xff; |
| 2905 | else |
| 2906 | *data = mcp->mb[1]; |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 2907 | |
| 2908 | if (rval != QLA_SUCCESS) { |
| 2909 | ql_dbg(ql_dbg_mbx, vha, 0x1186, |
| 2910 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 2911 | } else { |
| 2912 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1187, |
| 2913 | "Done %s.\n", __func__); |
| 2914 | } |
| 2915 | |
| 2916 | return rval; |
| 2917 | } |
| 2918 | |
Joe Carnuccio | e8887c5 | 2014-04-11 16:54:17 -0400 | [diff] [blame] | 2919 | int |
| 2920 | qla8044_write_serdes_word(scsi_qla_host_t *vha, uint32_t addr, uint32_t data) |
| 2921 | { |
| 2922 | int rval; |
| 2923 | mbx_cmd_t mc; |
| 2924 | mbx_cmd_t *mcp = &mc; |
| 2925 | |
| 2926 | if (!IS_QLA8044(vha->hw)) |
| 2927 | return QLA_FUNCTION_FAILED; |
| 2928 | |
| 2929 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1186, |
| 2930 | "Entered %s.\n", __func__); |
| 2931 | |
| 2932 | mcp->mb[0] = MBC_SET_GET_ETH_SERDES_REG; |
| 2933 | mcp->mb[1] = HCS_WRITE_SERDES; |
| 2934 | mcp->mb[3] = LSW(addr); |
| 2935 | mcp->mb[4] = MSW(addr); |
| 2936 | mcp->mb[5] = LSW(data); |
| 2937 | mcp->mb[6] = MSW(data); |
| 2938 | mcp->out_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_1|MBX_0; |
| 2939 | mcp->in_mb = MBX_0; |
| 2940 | mcp->tov = MBX_TOV_SECONDS; |
| 2941 | mcp->flags = 0; |
| 2942 | rval = qla2x00_mailbox_command(vha, mcp); |
| 2943 | |
| 2944 | if (rval != QLA_SUCCESS) { |
| 2945 | ql_dbg(ql_dbg_mbx, vha, 0x1187, |
| 2946 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 2947 | } else { |
| 2948 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1188, |
| 2949 | "Done %s.\n", __func__); |
| 2950 | } |
| 2951 | |
| 2952 | return rval; |
| 2953 | } |
| 2954 | |
| 2955 | int |
| 2956 | qla8044_read_serdes_word(scsi_qla_host_t *vha, uint32_t addr, uint32_t *data) |
| 2957 | { |
| 2958 | int rval; |
| 2959 | mbx_cmd_t mc; |
| 2960 | mbx_cmd_t *mcp = &mc; |
| 2961 | |
| 2962 | if (!IS_QLA8044(vha->hw)) |
| 2963 | return QLA_FUNCTION_FAILED; |
| 2964 | |
| 2965 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1189, |
| 2966 | "Entered %s.\n", __func__); |
| 2967 | |
| 2968 | mcp->mb[0] = MBC_SET_GET_ETH_SERDES_REG; |
| 2969 | mcp->mb[1] = HCS_READ_SERDES; |
| 2970 | mcp->mb[3] = LSW(addr); |
| 2971 | mcp->mb[4] = MSW(addr); |
| 2972 | mcp->out_mb = MBX_4|MBX_3|MBX_1|MBX_0; |
| 2973 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 2974 | mcp->tov = MBX_TOV_SECONDS; |
| 2975 | mcp->flags = 0; |
| 2976 | rval = qla2x00_mailbox_command(vha, mcp); |
| 2977 | |
| 2978 | *data = mcp->mb[2] << 16 | mcp->mb[1]; |
| 2979 | |
| 2980 | if (rval != QLA_SUCCESS) { |
| 2981 | ql_dbg(ql_dbg_mbx, vha, 0x118a, |
| 2982 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 2983 | } else { |
| 2984 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x118b, |
| 2985 | "Done %s.\n", __func__); |
| 2986 | } |
| 2987 | |
| 2988 | return rval; |
| 2989 | } |
| 2990 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2991 | /** |
| 2992 | * qla2x00_set_serdes_params() - |
| 2993 | * @ha: HA context |
| 2994 | * |
| 2995 | * Returns |
| 2996 | */ |
| 2997 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2998 | 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] | 2999 | uint16_t sw_em_2g, uint16_t sw_em_4g) |
| 3000 | { |
| 3001 | int rval; |
| 3002 | mbx_cmd_t mc; |
| 3003 | mbx_cmd_t *mcp = &mc; |
| 3004 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3005 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109e, |
| 3006 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3007 | |
| 3008 | mcp->mb[0] = MBC_SERDES_PARAMS; |
| 3009 | mcp->mb[1] = BIT_0; |
andrew.vasquez@qlogic.com | fdbc683 | 2006-03-09 14:27:29 -0800 | [diff] [blame] | 3010 | mcp->mb[2] = sw_em_1g | BIT_15; |
| 3011 | mcp->mb[3] = sw_em_2g | BIT_15; |
| 3012 | mcp->mb[4] = sw_em_4g | BIT_15; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3013 | mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3014 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3015 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3016 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3017 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3018 | |
| 3019 | if (rval != QLA_SUCCESS) { |
| 3020 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3021 | ql_dbg(ql_dbg_mbx, vha, 0x109f, |
| 3022 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3023 | } else { |
| 3024 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3025 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a0, |
| 3026 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3027 | } |
| 3028 | |
| 3029 | return rval; |
| 3030 | } |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3031 | |
| 3032 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3033 | qla2x00_stop_firmware(scsi_qla_host_t *vha) |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3034 | { |
| 3035 | int rval; |
| 3036 | mbx_cmd_t mc; |
| 3037 | mbx_cmd_t *mcp = &mc; |
| 3038 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3039 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3040 | return QLA_FUNCTION_FAILED; |
| 3041 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3042 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a1, |
| 3043 | "Entered %s.\n", __func__); |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3044 | |
| 3045 | mcp->mb[0] = MBC_STOP_FIRMWARE; |
Andrew Vasquez | 4ba988d | 2012-02-09 11:14:06 -0800 | [diff] [blame] | 3046 | mcp->mb[1] = 0; |
| 3047 | mcp->out_mb = MBX_1|MBX_0; |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3048 | mcp->in_mb = MBX_0; |
| 3049 | mcp->tov = 5; |
| 3050 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3051 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3052 | |
| 3053 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3054 | ql_dbg(ql_dbg_mbx, vha, 0x10a2, "Failed=%x.\n", rval); |
Andrew Vasquez | b469a7c | 2009-04-06 22:33:48 -0700 | [diff] [blame] | 3055 | if (mcp->mb[0] == MBS_INVALID_COMMAND) |
| 3056 | rval = QLA_INVALID_COMMAND; |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3057 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3058 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a3, |
| 3059 | "Done %s.\n", __func__); |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3060 | } |
| 3061 | |
| 3062 | return rval; |
| 3063 | } |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3064 | |
| 3065 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3066 | 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] | 3067 | uint16_t buffers) |
| 3068 | { |
| 3069 | int rval; |
| 3070 | mbx_cmd_t mc; |
| 3071 | mbx_cmd_t *mcp = &mc; |
| 3072 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3073 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a4, |
| 3074 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3075 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3076 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3077 | return QLA_FUNCTION_FAILED; |
| 3078 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3079 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3080 | return QLA_FUNCTION_FAILED; |
| 3081 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3082 | mcp->mb[0] = MBC_TRACE_CONTROL; |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3083 | mcp->mb[1] = TC_EFT_ENABLE; |
| 3084 | mcp->mb[2] = LSW(eft_dma); |
| 3085 | mcp->mb[3] = MSW(eft_dma); |
| 3086 | mcp->mb[4] = LSW(MSD(eft_dma)); |
| 3087 | mcp->mb[5] = MSW(MSD(eft_dma)); |
| 3088 | mcp->mb[6] = buffers; |
| 3089 | mcp->mb[7] = TC_AEN_DISABLE; |
| 3090 | 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] | 3091 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3092 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3093 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3094 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3095 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3096 | ql_dbg(ql_dbg_mbx, vha, 0x10a5, |
| 3097 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3098 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3099 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3100 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a6, |
| 3101 | "Done %s.\n", __func__); |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3102 | } |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3103 | |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3104 | return rval; |
| 3105 | } |
| 3106 | |
| 3107 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3108 | qla2x00_disable_eft_trace(scsi_qla_host_t *vha) |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3109 | { |
| 3110 | int rval; |
| 3111 | mbx_cmd_t mc; |
| 3112 | mbx_cmd_t *mcp = &mc; |
| 3113 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3114 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a7, |
| 3115 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3116 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3117 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3118 | return QLA_FUNCTION_FAILED; |
| 3119 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3120 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3121 | return QLA_FUNCTION_FAILED; |
| 3122 | |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3123 | mcp->mb[0] = MBC_TRACE_CONTROL; |
| 3124 | mcp->mb[1] = TC_EFT_DISABLE; |
| 3125 | mcp->out_mb = MBX_1|MBX_0; |
| 3126 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3127 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3128 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3129 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3130 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3131 | ql_dbg(ql_dbg_mbx, vha, 0x10a8, |
| 3132 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3133 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3134 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3135 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a9, |
| 3136 | "Done %s.\n", __func__); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3137 | } |
| 3138 | |
| 3139 | return rval; |
| 3140 | } |
| 3141 | |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 3142 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3143 | 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] | 3144 | uint16_t buffers, uint16_t *mb, uint32_t *dwords) |
| 3145 | { |
| 3146 | int rval; |
| 3147 | mbx_cmd_t mc; |
| 3148 | mbx_cmd_t *mcp = &mc; |
| 3149 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3150 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10aa, |
| 3151 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3152 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3153 | if (!IS_QLA25XX(vha->hw) && !IS_QLA81XX(vha->hw) && |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3154 | !IS_QLA83XX(vha->hw) && !IS_QLA27XX(vha->hw)) |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3155 | return QLA_FUNCTION_FAILED; |
| 3156 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3157 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3158 | return QLA_FUNCTION_FAILED; |
| 3159 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3160 | mcp->mb[0] = MBC_TRACE_CONTROL; |
| 3161 | mcp->mb[1] = TC_FCE_ENABLE; |
| 3162 | mcp->mb[2] = LSW(fce_dma); |
| 3163 | mcp->mb[3] = MSW(fce_dma); |
| 3164 | mcp->mb[4] = LSW(MSD(fce_dma)); |
| 3165 | mcp->mb[5] = MSW(MSD(fce_dma)); |
| 3166 | mcp->mb[6] = buffers; |
| 3167 | mcp->mb[7] = TC_AEN_DISABLE; |
| 3168 | mcp->mb[8] = 0; |
| 3169 | mcp->mb[9] = TC_FCE_DEFAULT_RX_SIZE; |
| 3170 | mcp->mb[10] = TC_FCE_DEFAULT_TX_SIZE; |
| 3171 | mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2| |
| 3172 | MBX_1|MBX_0; |
| 3173 | 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] | 3174 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3175 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3176 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3177 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3178 | ql_dbg(ql_dbg_mbx, vha, 0x10ab, |
| 3179 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3180 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3181 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3182 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ac, |
| 3183 | "Done %s.\n", __func__); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3184 | |
| 3185 | if (mb) |
| 3186 | memcpy(mb, mcp->mb, 8 * sizeof(*mb)); |
| 3187 | if (dwords) |
Andrew Vasquez | fa0926d | 2008-05-12 22:21:12 -0700 | [diff] [blame] | 3188 | *dwords = buffers; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3189 | } |
| 3190 | |
| 3191 | return rval; |
| 3192 | } |
| 3193 | |
| 3194 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3195 | 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] | 3196 | { |
| 3197 | int rval; |
| 3198 | mbx_cmd_t mc; |
| 3199 | mbx_cmd_t *mcp = &mc; |
| 3200 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3201 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ad, |
| 3202 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3203 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3204 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3205 | return QLA_FUNCTION_FAILED; |
| 3206 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3207 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3208 | return QLA_FUNCTION_FAILED; |
| 3209 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3210 | mcp->mb[0] = MBC_TRACE_CONTROL; |
| 3211 | mcp->mb[1] = TC_FCE_DISABLE; |
| 3212 | mcp->mb[2] = TC_FCE_DISABLE_TRACE; |
| 3213 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 3214 | mcp->in_mb = MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2| |
| 3215 | MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3216 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3217 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3218 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3219 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3220 | ql_dbg(ql_dbg_mbx, vha, 0x10ae, |
| 3221 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3222 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3223 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3224 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10af, |
| 3225 | "Done %s.\n", __func__); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3226 | |
| 3227 | if (wr) |
| 3228 | *wr = (uint64_t) mcp->mb[5] << 48 | |
| 3229 | (uint64_t) mcp->mb[4] << 32 | |
| 3230 | (uint64_t) mcp->mb[3] << 16 | |
| 3231 | (uint64_t) mcp->mb[2]; |
| 3232 | if (rd) |
| 3233 | *rd = (uint64_t) mcp->mb[9] << 48 | |
| 3234 | (uint64_t) mcp->mb[8] << 32 | |
| 3235 | (uint64_t) mcp->mb[7] << 16 | |
| 3236 | (uint64_t) mcp->mb[6]; |
| 3237 | } |
| 3238 | |
| 3239 | return rval; |
| 3240 | } |
| 3241 | |
| 3242 | int |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3243 | qla2x00_get_idma_speed(scsi_qla_host_t *vha, uint16_t loop_id, |
| 3244 | uint16_t *port_speed, uint16_t *mb) |
| 3245 | { |
| 3246 | int rval; |
| 3247 | mbx_cmd_t mc; |
| 3248 | mbx_cmd_t *mcp = &mc; |
| 3249 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3250 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b0, |
| 3251 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3252 | |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3253 | if (!IS_IIDMA_CAPABLE(vha->hw)) |
| 3254 | return QLA_FUNCTION_FAILED; |
| 3255 | |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3256 | mcp->mb[0] = MBC_PORT_PARAMS; |
| 3257 | mcp->mb[1] = loop_id; |
| 3258 | mcp->mb[2] = mcp->mb[3] = 0; |
| 3259 | mcp->mb[9] = vha->vp_idx; |
| 3260 | mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3261 | mcp->in_mb = MBX_3|MBX_1|MBX_0; |
| 3262 | mcp->tov = MBX_TOV_SECONDS; |
| 3263 | mcp->flags = 0; |
| 3264 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3265 | |
| 3266 | /* Return mailbox statuses. */ |
| 3267 | if (mb != NULL) { |
| 3268 | mb[0] = mcp->mb[0]; |
| 3269 | mb[1] = mcp->mb[1]; |
| 3270 | mb[3] = mcp->mb[3]; |
| 3271 | } |
| 3272 | |
| 3273 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3274 | ql_dbg(ql_dbg_mbx, vha, 0x10b1, "Failed=%x.\n", rval); |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3275 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3276 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b2, |
| 3277 | "Done %s.\n", __func__); |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3278 | if (port_speed) |
| 3279 | *port_speed = mcp->mb[3]; |
| 3280 | } |
| 3281 | |
| 3282 | return rval; |
| 3283 | } |
| 3284 | |
| 3285 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3286 | 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] | 3287 | uint16_t port_speed, uint16_t *mb) |
| 3288 | { |
| 3289 | int rval; |
| 3290 | mbx_cmd_t mc; |
| 3291 | mbx_cmd_t *mcp = &mc; |
| 3292 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3293 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b3, |
| 3294 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3295 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3296 | if (!IS_IIDMA_CAPABLE(vha->hw)) |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3297 | return QLA_FUNCTION_FAILED; |
| 3298 | |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3299 | mcp->mb[0] = MBC_PORT_PARAMS; |
| 3300 | mcp->mb[1] = loop_id; |
| 3301 | mcp->mb[2] = BIT_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3302 | if (IS_CNA_CAPABLE(vha->hw)) |
Harish Zunjarrao | 1bb3954 | 2009-06-17 10:30:29 -0700 | [diff] [blame] | 3303 | mcp->mb[3] = port_speed & (BIT_5|BIT_4|BIT_3|BIT_2|BIT_1|BIT_0); |
| 3304 | else |
| 3305 | mcp->mb[3] = port_speed & (BIT_2|BIT_1|BIT_0); |
| 3306 | mcp->mb[9] = vha->vp_idx; |
| 3307 | mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3308 | mcp->in_mb = MBX_3|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3309 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3310 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3311 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3312 | |
| 3313 | /* Return mailbox statuses. */ |
| 3314 | if (mb != NULL) { |
| 3315 | mb[0] = mcp->mb[0]; |
| 3316 | mb[1] = mcp->mb[1]; |
| 3317 | mb[3] = mcp->mb[3]; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3318 | } |
| 3319 | |
| 3320 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3321 | ql_dbg(ql_dbg_mbx, vha, 0x10b4, |
| 3322 | "Failed=%x.\n", rval); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3323 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3324 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b5, |
| 3325 | "Done %s.\n", __func__); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3326 | } |
| 3327 | |
| 3328 | return rval; |
| 3329 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3330 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3331 | void |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3332 | qla24xx_report_id_acquisition(scsi_qla_host_t *vha, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3333 | struct vp_rpt_id_entry_24xx *rptid_entry) |
| 3334 | { |
| 3335 | uint8_t vp_idx; |
Seokmann Ju | c6852c4 | 2008-04-24 15:21:29 -0700 | [diff] [blame] | 3336 | uint16_t stat = le16_to_cpu(rptid_entry->vp_idx); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3337 | struct qla_hw_data *ha = vha->hw; |
| 3338 | scsi_qla_host_t *vp; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3339 | unsigned long flags; |
Andrew Vasquez | 4ac8d4ca | 2013-02-08 01:57:58 -0500 | [diff] [blame] | 3340 | int found; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3341 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3342 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b6, |
| 3343 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3344 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3345 | if (rptid_entry->entry_status != 0) |
| 3346 | return; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3347 | |
| 3348 | if (rptid_entry->format == 0) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3349 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b7, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3350 | "Format 0 : Number of VPs setup %d, number of " |
| 3351 | "VPs acquired %d.\n", |
| 3352 | MSB(le16_to_cpu(rptid_entry->vp_count)), |
| 3353 | LSB(le16_to_cpu(rptid_entry->vp_count))); |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3354 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b8, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3355 | "Primary port id %02x%02x%02x.\n", |
| 3356 | rptid_entry->port_id[2], rptid_entry->port_id[1], |
| 3357 | rptid_entry->port_id[0]); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3358 | } else if (rptid_entry->format == 1) { |
Seokmann Ju | c6852c4 | 2008-04-24 15:21:29 -0700 | [diff] [blame] | 3359 | vp_idx = LSB(stat); |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3360 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b9, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3361 | "Format 1: VP[%d] enabled - status %d - with " |
| 3362 | "port id %02x%02x%02x.\n", vp_idx, MSB(stat), |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3363 | rptid_entry->port_id[2], rptid_entry->port_id[1], |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3364 | rptid_entry->port_id[0]); |
Andrew Vasquez | 531a82d | 2009-10-13 15:16:51 -0700 | [diff] [blame] | 3365 | |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 3366 | /* FA-WWN is only for physical port */ |
| 3367 | if (!vp_idx) { |
| 3368 | void *wwpn = ha->init_cb->port_name; |
| 3369 | |
| 3370 | if (!MSB(stat)) { |
| 3371 | if (rptid_entry->vp_idx_map[1] & BIT_6) |
| 3372 | wwpn = rptid_entry->reserved_4 + 8; |
| 3373 | } |
| 3374 | memcpy(vha->port_name, wwpn, WWN_SIZE); |
| 3375 | fc_host_port_name(vha->host) = |
| 3376 | wwn_to_u64(vha->port_name); |
| 3377 | ql_dbg(ql_dbg_mbx, vha, 0x1018, |
| 3378 | "FA-WWN portname %016llx (%x)\n", |
| 3379 | fc_host_port_name(vha->host), MSB(stat)); |
| 3380 | } |
| 3381 | |
Andrew Vasquez | 531a82d | 2009-10-13 15:16:51 -0700 | [diff] [blame] | 3382 | vp = vha; |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 3383 | if (vp_idx == 0) |
Andrew Vasquez | 531a82d | 2009-10-13 15:16:51 -0700 | [diff] [blame] | 3384 | goto reg_needed; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3385 | |
Saurav Kashyap | 681e014 | 2012-11-21 02:40:28 -0500 | [diff] [blame] | 3386 | if (MSB(stat) != 0 && MSB(stat) != 2) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3387 | ql_dbg(ql_dbg_mbx, vha, 0x10ba, |
| 3388 | "Could not acquire ID for VP[%d].\n", vp_idx); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3389 | return; |
Andrew Vasquez | 81eb9b4 | 2009-06-03 09:55:23 -0700 | [diff] [blame] | 3390 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3391 | |
Andrew Vasquez | 4ac8d4ca | 2013-02-08 01:57:58 -0500 | [diff] [blame] | 3392 | found = 0; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3393 | spin_lock_irqsave(&ha->vport_slock, flags); |
Andrew Vasquez | 4ac8d4ca | 2013-02-08 01:57:58 -0500 | [diff] [blame] | 3394 | list_for_each_entry(vp, &ha->vp_list, list) { |
| 3395 | if (vp_idx == vp->vp_idx) { |
| 3396 | found = 1; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3397 | break; |
Andrew Vasquez | 4ac8d4ca | 2013-02-08 01:57:58 -0500 | [diff] [blame] | 3398 | } |
| 3399 | } |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3400 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 3401 | |
Andrew Vasquez | 4ac8d4ca | 2013-02-08 01:57:58 -0500 | [diff] [blame] | 3402 | if (!found) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3403 | return; |
| 3404 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3405 | vp->d_id.b.domain = rptid_entry->port_id[2]; |
| 3406 | vp->d_id.b.area = rptid_entry->port_id[1]; |
| 3407 | vp->d_id.b.al_pa = rptid_entry->port_id[0]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3408 | |
| 3409 | /* |
| 3410 | * Cannot configure here as we are still sitting on the |
| 3411 | * response queue. Handle it in dpc context. |
| 3412 | */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3413 | set_bit(VP_IDX_ACQUIRED, &vp->vp_flags); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3414 | |
Andrew Vasquez | 531a82d | 2009-10-13 15:16:51 -0700 | [diff] [blame] | 3415 | reg_needed: |
| 3416 | set_bit(REGISTER_FC4_NEEDED, &vp->dpc_flags); |
| 3417 | set_bit(REGISTER_FDMI_NEEDED, &vp->dpc_flags); |
| 3418 | set_bit(VP_DPC_NEEDED, &vha->dpc_flags); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3419 | qla2xxx_wake_dpc(vha); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3420 | } |
| 3421 | } |
| 3422 | |
| 3423 | /* |
| 3424 | * qla24xx_modify_vp_config |
| 3425 | * Change VP configuration for vha |
| 3426 | * |
| 3427 | * Input: |
| 3428 | * vha = adapter block pointer. |
| 3429 | * |
| 3430 | * Returns: |
| 3431 | * qla2xxx local function return status code. |
| 3432 | * |
| 3433 | * Context: |
| 3434 | * Kernel context. |
| 3435 | */ |
| 3436 | int |
| 3437 | qla24xx_modify_vp_config(scsi_qla_host_t *vha) |
| 3438 | { |
| 3439 | int rval; |
| 3440 | struct vp_config_entry_24xx *vpmod; |
| 3441 | dma_addr_t vpmod_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3442 | struct qla_hw_data *ha = vha->hw; |
| 3443 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3444 | |
| 3445 | /* This can be called by the parent */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3446 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3447 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10bb, |
| 3448 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3449 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3450 | vpmod = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &vpmod_dma); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3451 | if (!vpmod) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3452 | ql_log(ql_log_warn, vha, 0x10bc, |
| 3453 | "Failed to allocate modify VP IOCB.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3454 | return QLA_MEMORY_ALLOC_FAILED; |
| 3455 | } |
| 3456 | |
| 3457 | memset(vpmod, 0, sizeof(struct vp_config_entry_24xx)); |
| 3458 | vpmod->entry_type = VP_CONFIG_IOCB_TYPE; |
| 3459 | vpmod->entry_count = 1; |
| 3460 | vpmod->command = VCT_COMMAND_MOD_ENABLE_VPS; |
| 3461 | vpmod->vp_count = 1; |
| 3462 | vpmod->vp_index1 = vha->vp_idx; |
| 3463 | vpmod->options_idx1 = BIT_3|BIT_4|BIT_5; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3464 | |
| 3465 | qlt_modify_vp_config(vha, vpmod); |
| 3466 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3467 | memcpy(vpmod->node_name_idx1, vha->node_name, WWN_SIZE); |
| 3468 | memcpy(vpmod->port_name_idx1, vha->port_name, WWN_SIZE); |
| 3469 | vpmod->entry_count = 1; |
| 3470 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3471 | rval = qla2x00_issue_iocb(base_vha, vpmod, vpmod_dma, 0); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3472 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3473 | ql_dbg(ql_dbg_mbx, vha, 0x10bd, |
| 3474 | "Failed to issue VP config IOCB (%x).\n", rval); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3475 | } else if (vpmod->comp_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3476 | ql_dbg(ql_dbg_mbx, vha, 0x10be, |
| 3477 | "Failed to complete IOCB -- error status (%x).\n", |
| 3478 | vpmod->comp_status); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3479 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 3480 | } else if (vpmod->comp_status != cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3481 | ql_dbg(ql_dbg_mbx, vha, 0x10bf, |
| 3482 | "Failed to complete IOCB -- completion status (%x).\n", |
| 3483 | le16_to_cpu(vpmod->comp_status)); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3484 | rval = QLA_FUNCTION_FAILED; |
| 3485 | } else { |
| 3486 | /* EMPTY */ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3487 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c0, |
| 3488 | "Done %s.\n", __func__); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3489 | fc_vport_set_state(vha->fc_vport, FC_VPORT_INITIALIZING); |
| 3490 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3491 | dma_pool_free(ha->s_dma_pool, vpmod, vpmod_dma); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3492 | |
| 3493 | return rval; |
| 3494 | } |
| 3495 | |
| 3496 | /* |
| 3497 | * qla24xx_control_vp |
| 3498 | * Enable a virtual port for given host |
| 3499 | * |
| 3500 | * Input: |
| 3501 | * ha = adapter block pointer. |
| 3502 | * vhba = virtual adapter (unused) |
| 3503 | * index = index number for enabled VP |
| 3504 | * |
| 3505 | * Returns: |
| 3506 | * qla2xxx local function return status code. |
| 3507 | * |
| 3508 | * Context: |
| 3509 | * Kernel context. |
| 3510 | */ |
| 3511 | int |
| 3512 | qla24xx_control_vp(scsi_qla_host_t *vha, int cmd) |
| 3513 | { |
| 3514 | int rval; |
| 3515 | int map, pos; |
| 3516 | struct vp_ctrl_entry_24xx *vce; |
| 3517 | dma_addr_t vce_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3518 | struct qla_hw_data *ha = vha->hw; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3519 | int vp_index = vha->vp_idx; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3520 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3521 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3522 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c1, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3523 | "Entered %s enabling index %d.\n", __func__, vp_index); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3524 | |
Andrew Vasquez | eb66dc6 | 2007-11-12 10:30:58 -0800 | [diff] [blame] | 3525 | if (vp_index == 0 || vp_index >= ha->max_npiv_vports) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3526 | return QLA_PARAMETER_ERROR; |
| 3527 | |
| 3528 | vce = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &vce_dma); |
| 3529 | if (!vce) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3530 | ql_log(ql_log_warn, vha, 0x10c2, |
| 3531 | "Failed to allocate VP control IOCB.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3532 | return QLA_MEMORY_ALLOC_FAILED; |
| 3533 | } |
| 3534 | memset(vce, 0, sizeof(struct vp_ctrl_entry_24xx)); |
| 3535 | |
| 3536 | vce->entry_type = VP_CTRL_IOCB_TYPE; |
| 3537 | vce->entry_count = 1; |
| 3538 | vce->command = cpu_to_le16(cmd); |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 3539 | vce->vp_count = cpu_to_le16(1); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3540 | |
| 3541 | /* index map in firmware starts with 1; decrement index |
| 3542 | * this is ok as we never use index 0 |
| 3543 | */ |
| 3544 | map = (vp_index - 1) / 8; |
| 3545 | pos = (vp_index - 1) & 7; |
matthias@kaehlcke.net | 6c2f527 | 2008-05-12 22:21:11 -0700 | [diff] [blame] | 3546 | mutex_lock(&ha->vport_lock); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3547 | vce->vp_idx_map[map] |= 1 << pos; |
matthias@kaehlcke.net | 6c2f527 | 2008-05-12 22:21:11 -0700 | [diff] [blame] | 3548 | mutex_unlock(&ha->vport_lock); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3549 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3550 | rval = qla2x00_issue_iocb(base_vha, vce, vce_dma, 0); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3551 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3552 | ql_dbg(ql_dbg_mbx, vha, 0x10c3, |
| 3553 | "Failed to issue VP control IOCB (%x).\n", rval); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3554 | } else if (vce->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3555 | ql_dbg(ql_dbg_mbx, vha, 0x10c4, |
| 3556 | "Failed to complete IOCB -- error status (%x).\n", |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3557 | vce->entry_status); |
| 3558 | rval = QLA_FUNCTION_FAILED; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 3559 | } else if (vce->comp_status != cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3560 | ql_dbg(ql_dbg_mbx, vha, 0x10c5, |
| 3561 | "Failed to complet IOCB -- completion status (%x).\n", |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3562 | le16_to_cpu(vce->comp_status)); |
| 3563 | rval = QLA_FUNCTION_FAILED; |
| 3564 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3565 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c6, |
| 3566 | "Done %s.\n", __func__); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3567 | } |
| 3568 | |
| 3569 | dma_pool_free(ha->s_dma_pool, vce, vce_dma); |
| 3570 | |
| 3571 | return rval; |
| 3572 | } |
| 3573 | |
| 3574 | /* |
| 3575 | * qla2x00_send_change_request |
| 3576 | * Receive or disable RSCN request from fabric controller |
| 3577 | * |
| 3578 | * Input: |
| 3579 | * ha = adapter block pointer |
| 3580 | * format = registration format: |
| 3581 | * 0 - Reserved |
| 3582 | * 1 - Fabric detected registration |
| 3583 | * 2 - N_port detected registration |
| 3584 | * 3 - Full registration |
| 3585 | * FF - clear registration |
| 3586 | * vp_idx = Virtual port index |
| 3587 | * |
| 3588 | * Returns: |
| 3589 | * qla2x00 local function return status code. |
| 3590 | * |
| 3591 | * Context: |
| 3592 | * Kernel Context |
| 3593 | */ |
| 3594 | |
| 3595 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3596 | qla2x00_send_change_request(scsi_qla_host_t *vha, uint16_t format, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3597 | uint16_t vp_idx) |
| 3598 | { |
| 3599 | int rval; |
| 3600 | mbx_cmd_t mc; |
| 3601 | mbx_cmd_t *mcp = &mc; |
| 3602 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3603 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c7, |
| 3604 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3605 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3606 | mcp->mb[0] = MBC_SEND_CHANGE_REQUEST; |
| 3607 | mcp->mb[1] = format; |
| 3608 | mcp->mb[9] = vp_idx; |
| 3609 | mcp->out_mb = MBX_9|MBX_1|MBX_0; |
| 3610 | mcp->in_mb = MBX_0|MBX_1; |
| 3611 | mcp->tov = MBX_TOV_SECONDS; |
| 3612 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3613 | rval = qla2x00_mailbox_command(vha, mcp); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3614 | |
| 3615 | if (rval == QLA_SUCCESS) { |
| 3616 | if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { |
| 3617 | rval = BIT_1; |
| 3618 | } |
| 3619 | } else |
| 3620 | rval = BIT_1; |
| 3621 | |
| 3622 | return rval; |
| 3623 | } |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 3624 | |
| 3625 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3626 | 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] | 3627 | uint32_t size) |
| 3628 | { |
| 3629 | int rval; |
| 3630 | mbx_cmd_t mc; |
| 3631 | mbx_cmd_t *mcp = &mc; |
| 3632 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3633 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1009, |
| 3634 | "Entered %s.\n", __func__); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 3635 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3636 | if (MSW(addr) || IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 3637 | mcp->mb[0] = MBC_DUMP_RISC_RAM_EXTENDED; |
| 3638 | mcp->mb[8] = MSW(addr); |
| 3639 | mcp->out_mb = MBX_8|MBX_0; |
| 3640 | } else { |
| 3641 | mcp->mb[0] = MBC_DUMP_RISC_RAM; |
| 3642 | mcp->out_mb = MBX_0; |
| 3643 | } |
| 3644 | mcp->mb[1] = LSW(addr); |
| 3645 | mcp->mb[2] = MSW(req_dma); |
| 3646 | mcp->mb[3] = LSW(req_dma); |
| 3647 | mcp->mb[6] = MSW(MSD(req_dma)); |
| 3648 | mcp->mb[7] = LSW(MSD(req_dma)); |
| 3649 | 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] | 3650 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 3651 | mcp->mb[4] = MSW(size); |
| 3652 | mcp->mb[5] = LSW(size); |
| 3653 | mcp->out_mb |= MBX_5|MBX_4; |
| 3654 | } else { |
| 3655 | mcp->mb[4] = LSW(size); |
| 3656 | mcp->out_mb |= MBX_4; |
| 3657 | } |
| 3658 | |
| 3659 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3660 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 3661 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3662 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 3663 | |
| 3664 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3665 | ql_dbg(ql_dbg_mbx, vha, 0x1008, |
| 3666 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 3667 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3668 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1007, |
| 3669 | "Done %s.\n", __func__); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 3670 | } |
| 3671 | |
| 3672 | return rval; |
| 3673 | } |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3674 | /* 84XX Support **************************************************************/ |
| 3675 | |
| 3676 | struct cs84xx_mgmt_cmd { |
| 3677 | union { |
| 3678 | struct verify_chip_entry_84xx req; |
| 3679 | struct verify_chip_rsp_84xx rsp; |
| 3680 | } p; |
| 3681 | }; |
| 3682 | |
| 3683 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3684 | qla84xx_verify_chip(struct scsi_qla_host *vha, uint16_t *status) |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3685 | { |
| 3686 | int rval, retry; |
| 3687 | struct cs84xx_mgmt_cmd *mn; |
| 3688 | dma_addr_t mn_dma; |
| 3689 | uint16_t options; |
| 3690 | unsigned long flags; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3691 | struct qla_hw_data *ha = vha->hw; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3692 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3693 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c8, |
| 3694 | "Entered %s.\n", __func__); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3695 | |
| 3696 | mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma); |
| 3697 | if (mn == NULL) { |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3698 | return QLA_MEMORY_ALLOC_FAILED; |
| 3699 | } |
| 3700 | |
| 3701 | /* Force Update? */ |
| 3702 | options = ha->cs84xx->fw_update ? VCO_FORCE_UPDATE : 0; |
| 3703 | /* Diagnostic firmware? */ |
| 3704 | /* options |= MENLO_DIAG_FW; */ |
| 3705 | /* We update the firmware with only one data sequence. */ |
| 3706 | options |= VCO_END_OF_DATA; |
| 3707 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3708 | do { |
Andrew Vasquez | c1ec1f1 | 2008-04-24 15:21:24 -0700 | [diff] [blame] | 3709 | retry = 0; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3710 | memset(mn, 0, sizeof(*mn)); |
| 3711 | mn->p.req.entry_type = VERIFY_CHIP_IOCB_TYPE; |
| 3712 | mn->p.req.entry_count = 1; |
| 3713 | mn->p.req.options = cpu_to_le16(options); |
| 3714 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3715 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111c, |
| 3716 | "Dump of Verify Request.\n"); |
| 3717 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111e, |
| 3718 | (uint8_t *)mn, sizeof(*mn)); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3719 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3720 | rval = qla2x00_issue_iocb_timeout(vha, mn, mn_dma, 0, 120); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3721 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3722 | ql_dbg(ql_dbg_mbx, vha, 0x10cb, |
| 3723 | "Failed to issue verify IOCB (%x).\n", rval); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3724 | goto verify_done; |
| 3725 | } |
| 3726 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3727 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1110, |
| 3728 | "Dump of Verify Response.\n"); |
| 3729 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1118, |
| 3730 | (uint8_t *)mn, sizeof(*mn)); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3731 | |
| 3732 | status[0] = le16_to_cpu(mn->p.rsp.comp_status); |
| 3733 | status[1] = status[0] == CS_VCS_CHIP_FAILURE ? |
| 3734 | le16_to_cpu(mn->p.rsp.failure_code) : 0; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3735 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ce, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3736 | "cs=%x fc=%x.\n", status[0], status[1]); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3737 | |
| 3738 | if (status[0] != CS_COMPLETE) { |
| 3739 | rval = QLA_FUNCTION_FAILED; |
| 3740 | if (!(options & VCO_DONT_UPDATE_FW)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3741 | ql_dbg(ql_dbg_mbx, vha, 0x10cf, |
| 3742 | "Firmware update failed. Retrying " |
| 3743 | "without update firmware.\n"); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3744 | options |= VCO_DONT_UPDATE_FW; |
| 3745 | options &= ~VCO_FORCE_UPDATE; |
| 3746 | retry = 1; |
| 3747 | } |
| 3748 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3749 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d0, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3750 | "Firmware updated to %x.\n", |
| 3751 | le32_to_cpu(mn->p.rsp.fw_ver)); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3752 | |
| 3753 | /* NOTE: we only update OP firmware. */ |
| 3754 | spin_lock_irqsave(&ha->cs84xx->access_lock, flags); |
| 3755 | ha->cs84xx->op_fw_version = |
| 3756 | le32_to_cpu(mn->p.rsp.fw_ver); |
| 3757 | spin_unlock_irqrestore(&ha->cs84xx->access_lock, |
| 3758 | flags); |
| 3759 | } |
| 3760 | } while (retry); |
| 3761 | |
| 3762 | verify_done: |
| 3763 | dma_pool_free(ha->s_dma_pool, mn, mn_dma); |
| 3764 | |
| 3765 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3766 | ql_dbg(ql_dbg_mbx, vha, 0x10d1, |
| 3767 | "Failed=%x.\n", rval); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3768 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3769 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d2, |
| 3770 | "Done %s.\n", __func__); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3771 | } |
| 3772 | |
| 3773 | return rval; |
| 3774 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3775 | |
| 3776 | int |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 3777 | 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] | 3778 | { |
| 3779 | int rval; |
| 3780 | unsigned long flags; |
| 3781 | mbx_cmd_t mc; |
| 3782 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3783 | struct qla_hw_data *ha = vha->hw; |
| 3784 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3785 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d3, |
| 3786 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3787 | |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 3788 | if (IS_SHADOW_REG_CAPABLE(ha)) |
| 3789 | req->options |= BIT_13; |
| 3790 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3791 | mcp->mb[0] = MBC_INITIALIZE_MULTIQ; |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 3792 | mcp->mb[1] = req->options; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3793 | mcp->mb[2] = MSW(LSD(req->dma)); |
| 3794 | mcp->mb[3] = LSW(LSD(req->dma)); |
| 3795 | mcp->mb[6] = MSW(MSD(req->dma)); |
| 3796 | mcp->mb[7] = LSW(MSD(req->dma)); |
| 3797 | mcp->mb[5] = req->length; |
| 3798 | if (req->rsp) |
| 3799 | mcp->mb[10] = req->rsp->id; |
| 3800 | mcp->mb[12] = req->qos; |
| 3801 | mcp->mb[11] = req->vp_idx; |
| 3802 | mcp->mb[13] = req->rid; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3803 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3804 | mcp->mb[15] = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3805 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3806 | mcp->mb[4] = req->id; |
| 3807 | /* que in ptr index */ |
| 3808 | mcp->mb[8] = 0; |
| 3809 | /* que out ptr index */ |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 3810 | mcp->mb[9] = *req->out_ptr = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3811 | mcp->out_mb = MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8|MBX_7| |
| 3812 | MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3813 | mcp->in_mb = MBX_0; |
| 3814 | mcp->flags = MBX_DMA_OUT; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3815 | mcp->tov = MBX_TOV_SECONDS * 2; |
| 3816 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3817 | if (IS_QLA81XX(ha) || IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3818 | mcp->in_mb |= MBX_1; |
Joe Carnuccio | ba4828b | 2014-04-11 16:54:10 -0400 | [diff] [blame] | 3819 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3820 | mcp->out_mb |= MBX_15; |
| 3821 | /* debug q create issue in SR-IOV */ |
| 3822 | mcp->in_mb |= MBX_9 | MBX_8 | MBX_7; |
| 3823 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3824 | |
| 3825 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 3826 | if (!(req->options & BIT_0)) { |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 3827 | WRT_REG_DWORD(req->req_q_in, 0); |
Joe Carnuccio | 29db41c | 2014-04-11 16:54:09 -0400 | [diff] [blame] | 3828 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 3829 | WRT_REG_DWORD(req->req_q_out, 0); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3830 | } |
| 3831 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 3832 | |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 3833 | rval = qla2x00_mailbox_command(vha, mcp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3834 | if (rval != QLA_SUCCESS) { |
| 3835 | ql_dbg(ql_dbg_mbx, vha, 0x10d4, |
| 3836 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 3837 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3838 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d5, |
| 3839 | "Done %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3840 | } |
| 3841 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3842 | return rval; |
| 3843 | } |
| 3844 | |
| 3845 | int |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 3846 | 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] | 3847 | { |
| 3848 | int rval; |
| 3849 | unsigned long flags; |
| 3850 | mbx_cmd_t mc; |
| 3851 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3852 | struct qla_hw_data *ha = vha->hw; |
| 3853 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3854 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d6, |
| 3855 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3856 | |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 3857 | if (IS_SHADOW_REG_CAPABLE(ha)) |
| 3858 | rsp->options |= BIT_13; |
| 3859 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3860 | mcp->mb[0] = MBC_INITIALIZE_MULTIQ; |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 3861 | mcp->mb[1] = rsp->options; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3862 | mcp->mb[2] = MSW(LSD(rsp->dma)); |
| 3863 | mcp->mb[3] = LSW(LSD(rsp->dma)); |
| 3864 | mcp->mb[6] = MSW(MSD(rsp->dma)); |
| 3865 | mcp->mb[7] = LSW(MSD(rsp->dma)); |
| 3866 | mcp->mb[5] = rsp->length; |
Andrew Vasquez | 444786d | 2009-01-05 11:18:10 -0800 | [diff] [blame] | 3867 | mcp->mb[14] = rsp->msix->entry; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3868 | mcp->mb[13] = rsp->rid; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3869 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3870 | mcp->mb[15] = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3871 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3872 | mcp->mb[4] = rsp->id; |
| 3873 | /* que in ptr index */ |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 3874 | mcp->mb[8] = *rsp->in_ptr = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3875 | /* que out ptr index */ |
| 3876 | mcp->mb[9] = 0; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3877 | 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] | 3878 | |MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3879 | mcp->in_mb = MBX_0; |
| 3880 | mcp->flags = MBX_DMA_OUT; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3881 | mcp->tov = MBX_TOV_SECONDS * 2; |
| 3882 | |
| 3883 | if (IS_QLA81XX(ha)) { |
| 3884 | mcp->out_mb |= MBX_12|MBX_11|MBX_10; |
| 3885 | mcp->in_mb |= MBX_1; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3886 | } else if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3887 | mcp->out_mb |= MBX_15|MBX_12|MBX_11|MBX_10; |
| 3888 | mcp->in_mb |= MBX_1; |
| 3889 | /* debug q create issue in SR-IOV */ |
| 3890 | mcp->in_mb |= MBX_9 | MBX_8 | MBX_7; |
| 3891 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3892 | |
| 3893 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 3894 | if (!(rsp->options & BIT_0)) { |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 3895 | WRT_REG_DWORD(rsp->rsp_q_out, 0); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3896 | if (!IS_QLA83XX(ha)) |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 3897 | WRT_REG_DWORD(rsp->rsp_q_in, 0); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3898 | } |
| 3899 | |
| 3900 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 3901 | |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 3902 | rval = qla2x00_mailbox_command(vha, mcp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3903 | if (rval != QLA_SUCCESS) { |
| 3904 | ql_dbg(ql_dbg_mbx, vha, 0x10d7, |
| 3905 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 3906 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3907 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d8, |
| 3908 | "Done %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3909 | } |
| 3910 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3911 | return rval; |
| 3912 | } |
| 3913 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3914 | int |
| 3915 | qla81xx_idc_ack(scsi_qla_host_t *vha, uint16_t *mb) |
| 3916 | { |
| 3917 | int rval; |
| 3918 | mbx_cmd_t mc; |
| 3919 | mbx_cmd_t *mcp = &mc; |
| 3920 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3921 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d9, |
| 3922 | "Entered %s.\n", __func__); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3923 | |
| 3924 | mcp->mb[0] = MBC_IDC_ACK; |
| 3925 | memcpy(&mcp->mb[1], mb, QLA_IDC_ACK_REGS * sizeof(uint16_t)); |
| 3926 | mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3927 | mcp->in_mb = MBX_0; |
| 3928 | mcp->tov = MBX_TOV_SECONDS; |
| 3929 | mcp->flags = 0; |
| 3930 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3931 | |
| 3932 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3933 | ql_dbg(ql_dbg_mbx, vha, 0x10da, |
| 3934 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3935 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3936 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10db, |
| 3937 | "Done %s.\n", __func__); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3938 | } |
| 3939 | |
| 3940 | return rval; |
| 3941 | } |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3942 | |
| 3943 | int |
| 3944 | qla81xx_fac_get_sector_size(scsi_qla_host_t *vha, uint32_t *sector_size) |
| 3945 | { |
| 3946 | int rval; |
| 3947 | mbx_cmd_t mc; |
| 3948 | mbx_cmd_t *mcp = &mc; |
| 3949 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3950 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10dc, |
| 3951 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3952 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3953 | if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) && |
| 3954 | !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3955 | return QLA_FUNCTION_FAILED; |
| 3956 | |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3957 | mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; |
| 3958 | mcp->mb[1] = FAC_OPT_CMD_GET_SECTOR_SIZE; |
| 3959 | mcp->out_mb = MBX_1|MBX_0; |
| 3960 | mcp->in_mb = MBX_1|MBX_0; |
| 3961 | mcp->tov = MBX_TOV_SECONDS; |
| 3962 | mcp->flags = 0; |
| 3963 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3964 | |
| 3965 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3966 | ql_dbg(ql_dbg_mbx, vha, 0x10dd, |
| 3967 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3968 | rval, mcp->mb[0], mcp->mb[1]); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3969 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3970 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10de, |
| 3971 | "Done %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3972 | *sector_size = mcp->mb[1]; |
| 3973 | } |
| 3974 | |
| 3975 | return rval; |
| 3976 | } |
| 3977 | |
| 3978 | int |
| 3979 | qla81xx_fac_do_write_enable(scsi_qla_host_t *vha, int enable) |
| 3980 | { |
| 3981 | int rval; |
| 3982 | mbx_cmd_t mc; |
| 3983 | mbx_cmd_t *mcp = &mc; |
| 3984 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3985 | if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) && |
| 3986 | !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3987 | return QLA_FUNCTION_FAILED; |
| 3988 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3989 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10df, |
| 3990 | "Entered %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3991 | |
| 3992 | mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; |
| 3993 | mcp->mb[1] = enable ? FAC_OPT_CMD_WRITE_ENABLE : |
| 3994 | FAC_OPT_CMD_WRITE_PROTECT; |
| 3995 | mcp->out_mb = MBX_1|MBX_0; |
| 3996 | mcp->in_mb = MBX_1|MBX_0; |
| 3997 | mcp->tov = MBX_TOV_SECONDS; |
| 3998 | mcp->flags = 0; |
| 3999 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4000 | |
| 4001 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4002 | ql_dbg(ql_dbg_mbx, vha, 0x10e0, |
| 4003 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 4004 | rval, mcp->mb[0], mcp->mb[1]); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4005 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4006 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e1, |
| 4007 | "Done %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4008 | } |
| 4009 | |
| 4010 | return rval; |
| 4011 | } |
| 4012 | |
| 4013 | int |
| 4014 | qla81xx_fac_erase_sector(scsi_qla_host_t *vha, uint32_t start, uint32_t finish) |
| 4015 | { |
| 4016 | int rval; |
| 4017 | mbx_cmd_t mc; |
| 4018 | mbx_cmd_t *mcp = &mc; |
| 4019 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4020 | if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) && |
| 4021 | !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4022 | return QLA_FUNCTION_FAILED; |
| 4023 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4024 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e2, |
| 4025 | "Entered %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4026 | |
| 4027 | mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; |
| 4028 | mcp->mb[1] = FAC_OPT_CMD_ERASE_SECTOR; |
| 4029 | mcp->mb[2] = LSW(start); |
| 4030 | mcp->mb[3] = MSW(start); |
| 4031 | mcp->mb[4] = LSW(finish); |
| 4032 | mcp->mb[5] = MSW(finish); |
| 4033 | mcp->out_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4034 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 4035 | mcp->tov = MBX_TOV_SECONDS; |
| 4036 | mcp->flags = 0; |
| 4037 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4038 | |
| 4039 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4040 | ql_dbg(ql_dbg_mbx, vha, 0x10e3, |
| 4041 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 4042 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4043 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4044 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e4, |
| 4045 | "Done %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4046 | } |
| 4047 | |
| 4048 | return rval; |
| 4049 | } |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4050 | |
| 4051 | int |
| 4052 | qla81xx_restart_mpi_firmware(scsi_qla_host_t *vha) |
| 4053 | { |
| 4054 | int rval = 0; |
| 4055 | mbx_cmd_t mc; |
| 4056 | mbx_cmd_t *mcp = &mc; |
| 4057 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4058 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e5, |
| 4059 | "Entered %s.\n", __func__); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4060 | |
| 4061 | mcp->mb[0] = MBC_RESTART_MPI_FW; |
| 4062 | mcp->out_mb = MBX_0; |
| 4063 | mcp->in_mb = MBX_0|MBX_1; |
| 4064 | mcp->tov = MBX_TOV_SECONDS; |
| 4065 | mcp->flags = 0; |
| 4066 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4067 | |
| 4068 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4069 | ql_dbg(ql_dbg_mbx, vha, 0x10e6, |
| 4070 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 4071 | rval, mcp->mb[0], mcp->mb[1]); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4072 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4073 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e7, |
| 4074 | "Done %s.\n", __func__); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4075 | } |
| 4076 | |
| 4077 | return rval; |
| 4078 | } |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4079 | |
Joe Carnuccio | c46e65c | 2013-08-27 01:37:35 -0400 | [diff] [blame] | 4080 | int |
| 4081 | qla82xx_set_driver_version(scsi_qla_host_t *vha, char *version) |
| 4082 | { |
| 4083 | int rval; |
| 4084 | mbx_cmd_t mc; |
| 4085 | mbx_cmd_t *mcp = &mc; |
| 4086 | int i; |
| 4087 | int len; |
| 4088 | uint16_t *str; |
| 4089 | struct qla_hw_data *ha = vha->hw; |
| 4090 | |
| 4091 | if (!IS_P3P_TYPE(ha)) |
| 4092 | return QLA_FUNCTION_FAILED; |
| 4093 | |
| 4094 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x117b, |
| 4095 | "Entered %s.\n", __func__); |
| 4096 | |
| 4097 | str = (void *)version; |
| 4098 | len = strlen(version); |
| 4099 | |
| 4100 | mcp->mb[0] = MBC_SET_RNID_PARAMS; |
| 4101 | mcp->mb[1] = RNID_TYPE_SET_VERSION << 8; |
| 4102 | mcp->out_mb = MBX_1|MBX_0; |
| 4103 | for (i = 4; i < 16 && len; i++, str++, len -= 2) { |
| 4104 | mcp->mb[i] = cpu_to_le16p(str); |
| 4105 | mcp->out_mb |= 1<<i; |
| 4106 | } |
| 4107 | for (; i < 16; i++) { |
| 4108 | mcp->mb[i] = 0; |
| 4109 | mcp->out_mb |= 1<<i; |
| 4110 | } |
| 4111 | mcp->in_mb = MBX_1|MBX_0; |
| 4112 | mcp->tov = MBX_TOV_SECONDS; |
| 4113 | mcp->flags = 0; |
| 4114 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4115 | |
| 4116 | if (rval != QLA_SUCCESS) { |
| 4117 | ql_dbg(ql_dbg_mbx, vha, 0x117c, |
| 4118 | "Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]); |
| 4119 | } else { |
| 4120 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x117d, |
| 4121 | "Done %s.\n", __func__); |
| 4122 | } |
| 4123 | |
| 4124 | return rval; |
| 4125 | } |
| 4126 | |
| 4127 | int |
| 4128 | qla25xx_set_driver_version(scsi_qla_host_t *vha, char *version) |
| 4129 | { |
| 4130 | int rval; |
| 4131 | mbx_cmd_t mc; |
| 4132 | mbx_cmd_t *mcp = &mc; |
| 4133 | int len; |
| 4134 | uint16_t dwlen; |
| 4135 | uint8_t *str; |
| 4136 | dma_addr_t str_dma; |
| 4137 | struct qla_hw_data *ha = vha->hw; |
| 4138 | |
| 4139 | if (!IS_FWI2_CAPABLE(ha) || IS_QLA24XX_TYPE(ha) || IS_QLA81XX(ha) || |
| 4140 | IS_P3P_TYPE(ha)) |
| 4141 | return QLA_FUNCTION_FAILED; |
| 4142 | |
| 4143 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x117e, |
| 4144 | "Entered %s.\n", __func__); |
| 4145 | |
| 4146 | str = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &str_dma); |
| 4147 | if (!str) { |
| 4148 | ql_log(ql_log_warn, vha, 0x117f, |
| 4149 | "Failed to allocate driver version param.\n"); |
| 4150 | return QLA_MEMORY_ALLOC_FAILED; |
| 4151 | } |
| 4152 | |
| 4153 | memcpy(str, "\x7\x3\x11\x0", 4); |
| 4154 | dwlen = str[0]; |
| 4155 | len = dwlen * 4 - 4; |
| 4156 | memset(str + 4, 0, len); |
| 4157 | if (len > strlen(version)) |
| 4158 | len = strlen(version); |
| 4159 | memcpy(str + 4, version, len); |
| 4160 | |
| 4161 | mcp->mb[0] = MBC_SET_RNID_PARAMS; |
| 4162 | mcp->mb[1] = RNID_TYPE_SET_VERSION << 8 | dwlen; |
| 4163 | mcp->mb[2] = MSW(LSD(str_dma)); |
| 4164 | mcp->mb[3] = LSW(LSD(str_dma)); |
| 4165 | mcp->mb[6] = MSW(MSD(str_dma)); |
| 4166 | mcp->mb[7] = LSW(MSD(str_dma)); |
| 4167 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4168 | mcp->in_mb = MBX_1|MBX_0; |
| 4169 | mcp->tov = MBX_TOV_SECONDS; |
| 4170 | mcp->flags = 0; |
| 4171 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4172 | |
| 4173 | if (rval != QLA_SUCCESS) { |
| 4174 | ql_dbg(ql_dbg_mbx, vha, 0x1180, |
| 4175 | "Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]); |
| 4176 | } else { |
| 4177 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1181, |
| 4178 | "Done %s.\n", __func__); |
| 4179 | } |
| 4180 | |
| 4181 | dma_pool_free(ha->s_dma_pool, str, str_dma); |
| 4182 | |
| 4183 | return rval; |
| 4184 | } |
| 4185 | |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 4186 | static int |
| 4187 | qla2x00_read_asic_temperature(scsi_qla_host_t *vha, uint16_t *temp) |
| 4188 | { |
| 4189 | int rval; |
| 4190 | mbx_cmd_t mc; |
| 4191 | mbx_cmd_t *mcp = &mc; |
| 4192 | |
| 4193 | if (!IS_FWI2_CAPABLE(vha->hw)) |
| 4194 | return QLA_FUNCTION_FAILED; |
| 4195 | |
| 4196 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1159, |
| 4197 | "Entered %s.\n", __func__); |
| 4198 | |
| 4199 | mcp->mb[0] = MBC_GET_RNID_PARAMS; |
| 4200 | mcp->mb[1] = RNID_TYPE_ASIC_TEMP << 8; |
| 4201 | mcp->out_mb = MBX_1|MBX_0; |
| 4202 | mcp->in_mb = MBX_1|MBX_0; |
| 4203 | mcp->tov = MBX_TOV_SECONDS; |
| 4204 | mcp->flags = 0; |
| 4205 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4206 | *temp = mcp->mb[1]; |
| 4207 | |
| 4208 | if (rval != QLA_SUCCESS) { |
| 4209 | ql_dbg(ql_dbg_mbx, vha, 0x115a, |
| 4210 | "Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]); |
| 4211 | } else { |
| 4212 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x115b, |
| 4213 | "Done %s.\n", __func__); |
| 4214 | } |
| 4215 | |
| 4216 | return rval; |
| 4217 | } |
| 4218 | |
Joe Carnuccio | 3a11711 | 2013-02-08 01:58:00 -0500 | [diff] [blame] | 4219 | int |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4220 | qla2x00_read_sfp(scsi_qla_host_t *vha, dma_addr_t sfp_dma, uint8_t *sfp, |
| 4221 | uint16_t dev, uint16_t off, uint16_t len, uint16_t opt) |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4222 | { |
| 4223 | int rval; |
| 4224 | mbx_cmd_t mc; |
| 4225 | mbx_cmd_t *mcp = &mc; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4226 | struct qla_hw_data *ha = vha->hw; |
| 4227 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4228 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e8, |
| 4229 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4230 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4231 | if (!IS_FWI2_CAPABLE(ha)) |
| 4232 | return QLA_FUNCTION_FAILED; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4233 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4234 | if (len == 1) |
| 4235 | opt |= BIT_0; |
| 4236 | |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4237 | mcp->mb[0] = MBC_READ_SFP; |
| 4238 | mcp->mb[1] = dev; |
| 4239 | mcp->mb[2] = MSW(sfp_dma); |
| 4240 | mcp->mb[3] = LSW(sfp_dma); |
| 4241 | mcp->mb[6] = MSW(MSD(sfp_dma)); |
| 4242 | mcp->mb[7] = LSW(MSD(sfp_dma)); |
| 4243 | mcp->mb[8] = len; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4244 | mcp->mb[9] = off; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4245 | mcp->mb[10] = opt; |
| 4246 | 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] | 4247 | mcp->in_mb = MBX_1|MBX_0; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4248 | mcp->tov = MBX_TOV_SECONDS; |
| 4249 | mcp->flags = 0; |
| 4250 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4251 | |
| 4252 | if (opt & BIT_0) |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4253 | *sfp = mcp->mb[1]; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4254 | |
| 4255 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4256 | ql_dbg(ql_dbg_mbx, vha, 0x10e9, |
| 4257 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4258 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4259 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ea, |
| 4260 | "Done %s.\n", __func__); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4261 | } |
| 4262 | |
| 4263 | return rval; |
| 4264 | } |
| 4265 | |
| 4266 | int |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4267 | qla2x00_write_sfp(scsi_qla_host_t *vha, dma_addr_t sfp_dma, uint8_t *sfp, |
| 4268 | uint16_t dev, uint16_t off, uint16_t len, uint16_t opt) |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4269 | { |
| 4270 | int rval; |
| 4271 | mbx_cmd_t mc; |
| 4272 | mbx_cmd_t *mcp = &mc; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4273 | struct qla_hw_data *ha = vha->hw; |
| 4274 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4275 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10eb, |
| 4276 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4277 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4278 | if (!IS_FWI2_CAPABLE(ha)) |
| 4279 | return QLA_FUNCTION_FAILED; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4280 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4281 | if (len == 1) |
| 4282 | opt |= BIT_0; |
| 4283 | |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4284 | if (opt & BIT_0) |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4285 | len = *sfp; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4286 | |
| 4287 | mcp->mb[0] = MBC_WRITE_SFP; |
| 4288 | mcp->mb[1] = dev; |
| 4289 | mcp->mb[2] = MSW(sfp_dma); |
| 4290 | mcp->mb[3] = LSW(sfp_dma); |
| 4291 | mcp->mb[6] = MSW(MSD(sfp_dma)); |
| 4292 | mcp->mb[7] = LSW(MSD(sfp_dma)); |
| 4293 | mcp->mb[8] = len; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4294 | mcp->mb[9] = off; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4295 | mcp->mb[10] = opt; |
| 4296 | 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] | 4297 | mcp->in_mb = MBX_1|MBX_0; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4298 | mcp->tov = MBX_TOV_SECONDS; |
| 4299 | mcp->flags = 0; |
| 4300 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4301 | |
| 4302 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4303 | ql_dbg(ql_dbg_mbx, vha, 0x10ec, |
| 4304 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4305 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4306 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ed, |
| 4307 | "Done %s.\n", __func__); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4308 | } |
| 4309 | |
| 4310 | return rval; |
| 4311 | } |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4312 | |
| 4313 | int |
| 4314 | qla2x00_get_xgmac_stats(scsi_qla_host_t *vha, dma_addr_t stats_dma, |
| 4315 | uint16_t size_in_bytes, uint16_t *actual_size) |
| 4316 | { |
| 4317 | int rval; |
| 4318 | mbx_cmd_t mc; |
| 4319 | mbx_cmd_t *mcp = &mc; |
| 4320 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4321 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ee, |
| 4322 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4323 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4324 | if (!IS_CNA_CAPABLE(vha->hw)) |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4325 | return QLA_FUNCTION_FAILED; |
| 4326 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4327 | mcp->mb[0] = MBC_GET_XGMAC_STATS; |
| 4328 | mcp->mb[2] = MSW(stats_dma); |
| 4329 | mcp->mb[3] = LSW(stats_dma); |
| 4330 | mcp->mb[6] = MSW(MSD(stats_dma)); |
| 4331 | mcp->mb[7] = LSW(MSD(stats_dma)); |
| 4332 | mcp->mb[8] = size_in_bytes >> 2; |
| 4333 | mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; |
| 4334 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 4335 | mcp->tov = MBX_TOV_SECONDS; |
| 4336 | mcp->flags = 0; |
| 4337 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4338 | |
| 4339 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4340 | ql_dbg(ql_dbg_mbx, vha, 0x10ef, |
| 4341 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 4342 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4343 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4344 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f0, |
| 4345 | "Done %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4346 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4347 | |
| 4348 | *actual_size = mcp->mb[2] << 2; |
| 4349 | } |
| 4350 | |
| 4351 | return rval; |
| 4352 | } |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4353 | |
| 4354 | int |
| 4355 | qla2x00_get_dcbx_params(scsi_qla_host_t *vha, dma_addr_t tlv_dma, |
| 4356 | uint16_t size) |
| 4357 | { |
| 4358 | int rval; |
| 4359 | mbx_cmd_t mc; |
| 4360 | mbx_cmd_t *mcp = &mc; |
| 4361 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4362 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f1, |
| 4363 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4364 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4365 | if (!IS_CNA_CAPABLE(vha->hw)) |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4366 | return QLA_FUNCTION_FAILED; |
| 4367 | |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4368 | mcp->mb[0] = MBC_GET_DCBX_PARAMS; |
| 4369 | mcp->mb[1] = 0; |
| 4370 | mcp->mb[2] = MSW(tlv_dma); |
| 4371 | mcp->mb[3] = LSW(tlv_dma); |
| 4372 | mcp->mb[6] = MSW(MSD(tlv_dma)); |
| 4373 | mcp->mb[7] = LSW(MSD(tlv_dma)); |
| 4374 | mcp->mb[8] = size; |
| 4375 | mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4376 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 4377 | mcp->tov = MBX_TOV_SECONDS; |
| 4378 | mcp->flags = 0; |
| 4379 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4380 | |
| 4381 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4382 | ql_dbg(ql_dbg_mbx, vha, 0x10f2, |
| 4383 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 4384 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4385 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4386 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f3, |
| 4387 | "Done %s.\n", __func__); |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4388 | } |
| 4389 | |
| 4390 | return rval; |
| 4391 | } |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4392 | |
| 4393 | int |
| 4394 | qla2x00_read_ram_word(scsi_qla_host_t *vha, uint32_t risc_addr, uint32_t *data) |
| 4395 | { |
| 4396 | int rval; |
| 4397 | mbx_cmd_t mc; |
| 4398 | mbx_cmd_t *mcp = &mc; |
| 4399 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4400 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f4, |
| 4401 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4402 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4403 | if (!IS_FWI2_CAPABLE(vha->hw)) |
| 4404 | return QLA_FUNCTION_FAILED; |
| 4405 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4406 | mcp->mb[0] = MBC_READ_RAM_EXTENDED; |
| 4407 | mcp->mb[1] = LSW(risc_addr); |
| 4408 | mcp->mb[8] = MSW(risc_addr); |
| 4409 | mcp->out_mb = MBX_8|MBX_1|MBX_0; |
| 4410 | mcp->in_mb = MBX_3|MBX_2|MBX_0; |
| 4411 | mcp->tov = 30; |
| 4412 | mcp->flags = 0; |
| 4413 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4414 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4415 | ql_dbg(ql_dbg_mbx, vha, 0x10f5, |
| 4416 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4417 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4418 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f6, |
| 4419 | "Done %s.\n", __func__); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4420 | *data = mcp->mb[3] << 16 | mcp->mb[2]; |
| 4421 | } |
| 4422 | |
| 4423 | return rval; |
| 4424 | } |
| 4425 | |
| 4426 | int |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4427 | qla2x00_loopback_test(scsi_qla_host_t *vha, struct msg_echo_lb *mreq, |
| 4428 | uint16_t *mresp) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4429 | { |
| 4430 | int rval; |
| 4431 | mbx_cmd_t mc; |
| 4432 | mbx_cmd_t *mcp = &mc; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4433 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4434 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f7, |
| 4435 | "Entered %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4436 | |
| 4437 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 4438 | mcp->mb[0] = MBC_DIAGNOSTIC_LOOP_BACK; |
| 4439 | mcp->mb[1] = mreq->options | BIT_6; // BIT_6 specifies 64 bit addressing |
| 4440 | |
| 4441 | /* transfer count */ |
| 4442 | mcp->mb[10] = LSW(mreq->transfer_size); |
| 4443 | mcp->mb[11] = MSW(mreq->transfer_size); |
| 4444 | |
| 4445 | /* send data address */ |
| 4446 | mcp->mb[14] = LSW(mreq->send_dma); |
| 4447 | mcp->mb[15] = MSW(mreq->send_dma); |
| 4448 | mcp->mb[20] = LSW(MSD(mreq->send_dma)); |
| 4449 | mcp->mb[21] = MSW(MSD(mreq->send_dma)); |
| 4450 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 4451 | /* receive data address */ |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4452 | mcp->mb[16] = LSW(mreq->rcv_dma); |
| 4453 | mcp->mb[17] = MSW(mreq->rcv_dma); |
| 4454 | mcp->mb[6] = LSW(MSD(mreq->rcv_dma)); |
| 4455 | mcp->mb[7] = MSW(MSD(mreq->rcv_dma)); |
| 4456 | |
| 4457 | /* Iteration count */ |
Joe Carnuccio | 1b98b42 | 2013-03-28 08:21:26 -0400 | [diff] [blame] | 4458 | mcp->mb[18] = LSW(mreq->iteration_count); |
| 4459 | mcp->mb[19] = MSW(mreq->iteration_count); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4460 | |
| 4461 | mcp->out_mb = MBX_21|MBX_20|MBX_19|MBX_18|MBX_17|MBX_16|MBX_15| |
| 4462 | 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] | 4463 | if (IS_CNA_CAPABLE(vha->hw)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4464 | mcp->out_mb |= MBX_2; |
| 4465 | mcp->in_mb = MBX_19|MBX_18|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4466 | |
| 4467 | mcp->buf_size = mreq->transfer_size; |
| 4468 | mcp->tov = MBX_TOV_SECONDS; |
| 4469 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 4470 | |
| 4471 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4472 | |
| 4473 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4474 | ql_dbg(ql_dbg_mbx, vha, 0x10f8, |
| 4475 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[3]=%x mb[18]=%x " |
| 4476 | "mb[19]=%x.\n", rval, mcp->mb[0], mcp->mb[1], mcp->mb[2], |
| 4477 | mcp->mb[3], mcp->mb[18], mcp->mb[19]); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4478 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4479 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f9, |
| 4480 | "Done %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4481 | } |
| 4482 | |
| 4483 | /* Copy mailbox information */ |
| 4484 | memcpy( mresp, mcp->mb, 64); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4485 | return rval; |
| 4486 | } |
| 4487 | |
| 4488 | int |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4489 | qla2x00_echo_test(scsi_qla_host_t *vha, struct msg_echo_lb *mreq, |
| 4490 | uint16_t *mresp) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4491 | { |
| 4492 | int rval; |
| 4493 | mbx_cmd_t mc; |
| 4494 | mbx_cmd_t *mcp = &mc; |
| 4495 | struct qla_hw_data *ha = vha->hw; |
| 4496 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4497 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10fa, |
| 4498 | "Entered %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4499 | |
| 4500 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 4501 | mcp->mb[0] = MBC_DIAGNOSTIC_ECHO; |
| 4502 | mcp->mb[1] = mreq->options | BIT_6; /* BIT_6 specifies 64bit address */ |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4503 | if (IS_CNA_CAPABLE(ha)) { |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4504 | mcp->mb[1] |= BIT_15; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4505 | mcp->mb[2] = vha->fcoe_fcf_idx; |
| 4506 | } |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4507 | mcp->mb[16] = LSW(mreq->rcv_dma); |
| 4508 | mcp->mb[17] = MSW(mreq->rcv_dma); |
| 4509 | mcp->mb[6] = LSW(MSD(mreq->rcv_dma)); |
| 4510 | mcp->mb[7] = MSW(MSD(mreq->rcv_dma)); |
| 4511 | |
| 4512 | mcp->mb[10] = LSW(mreq->transfer_size); |
| 4513 | |
| 4514 | mcp->mb[14] = LSW(mreq->send_dma); |
| 4515 | mcp->mb[15] = MSW(mreq->send_dma); |
| 4516 | mcp->mb[20] = LSW(MSD(mreq->send_dma)); |
| 4517 | mcp->mb[21] = MSW(MSD(mreq->send_dma)); |
| 4518 | |
| 4519 | mcp->out_mb = MBX_21|MBX_20|MBX_17|MBX_16|MBX_15| |
| 4520 | MBX_14|MBX_10|MBX_7|MBX_6|MBX_1|MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4521 | if (IS_CNA_CAPABLE(ha)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4522 | mcp->out_mb |= MBX_2; |
| 4523 | |
| 4524 | mcp->in_mb = MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4525 | if (IS_QLA24XX_TYPE(ha) || IS_QLA25XX(ha) || |
| 4526 | IS_CNA_CAPABLE(ha) || IS_QLA2031(ha)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4527 | mcp->in_mb |= MBX_1; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4528 | if (IS_CNA_CAPABLE(ha) || IS_QLA2031(ha)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4529 | mcp->in_mb |= MBX_3; |
| 4530 | |
| 4531 | mcp->tov = MBX_TOV_SECONDS; |
| 4532 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 4533 | mcp->buf_size = mreq->transfer_size; |
| 4534 | |
| 4535 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4536 | |
| 4537 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4538 | ql_dbg(ql_dbg_mbx, vha, 0x10fb, |
| 4539 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 4540 | rval, mcp->mb[0], mcp->mb[1]); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4541 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4542 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10fc, |
| 4543 | "Done %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4544 | } |
| 4545 | |
| 4546 | /* Copy mailbox information */ |
Giridhar Malavali | 6dbdda4 | 2010-09-03 15:20:49 -0700 | [diff] [blame] | 4547 | memcpy(mresp, mcp->mb, 64); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4548 | return rval; |
| 4549 | } |
Giridhar Malavali | 6dbdda4 | 2010-09-03 15:20:49 -0700 | [diff] [blame] | 4550 | |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4551 | int |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4552 | qla84xx_reset_chip(scsi_qla_host_t *vha, uint16_t enable_diagnostic) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4553 | { |
| 4554 | int rval; |
| 4555 | mbx_cmd_t mc; |
| 4556 | mbx_cmd_t *mcp = &mc; |
| 4557 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4558 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10fd, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4559 | "Entered %s enable_diag=%d.\n", __func__, enable_diagnostic); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4560 | |
| 4561 | mcp->mb[0] = MBC_ISP84XX_RESET; |
| 4562 | mcp->mb[1] = enable_diagnostic; |
| 4563 | mcp->out_mb = MBX_1|MBX_0; |
| 4564 | mcp->in_mb = MBX_1|MBX_0; |
| 4565 | mcp->tov = MBX_TOV_SECONDS; |
| 4566 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4567 | rval = qla2x00_mailbox_command(vha, mcp); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4568 | |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4569 | if (rval != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4570 | ql_dbg(ql_dbg_mbx, vha, 0x10fe, "Failed=%x.\n", rval); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4571 | else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4572 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ff, |
| 4573 | "Done %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4574 | |
| 4575 | return rval; |
| 4576 | } |
| 4577 | |
| 4578 | int |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4579 | qla2x00_write_ram_word(scsi_qla_host_t *vha, uint32_t risc_addr, uint32_t data) |
| 4580 | { |
| 4581 | int rval; |
| 4582 | mbx_cmd_t mc; |
| 4583 | mbx_cmd_t *mcp = &mc; |
| 4584 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4585 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1100, |
| 4586 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4587 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4588 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | 6c452a4 | 2010-03-19 17:04:02 -0700 | [diff] [blame] | 4589 | return QLA_FUNCTION_FAILED; |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4590 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4591 | mcp->mb[0] = MBC_WRITE_RAM_WORD_EXTENDED; |
| 4592 | mcp->mb[1] = LSW(risc_addr); |
| 4593 | mcp->mb[2] = LSW(data); |
| 4594 | mcp->mb[3] = MSW(data); |
| 4595 | mcp->mb[8] = MSW(risc_addr); |
| 4596 | mcp->out_mb = MBX_8|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4597 | mcp->in_mb = MBX_0; |
| 4598 | mcp->tov = 30; |
| 4599 | mcp->flags = 0; |
| 4600 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4601 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4602 | ql_dbg(ql_dbg_mbx, vha, 0x1101, |
| 4603 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -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, 0x1102, |
| 4606 | "Done %s.\n", __func__); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4607 | } |
| 4608 | |
| 4609 | return rval; |
| 4610 | } |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 4611 | |
| 4612 | int |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 4613 | qla81xx_write_mpi_register(scsi_qla_host_t *vha, uint16_t *mb) |
| 4614 | { |
| 4615 | int rval; |
| 4616 | uint32_t stat, timer; |
| 4617 | uint16_t mb0 = 0; |
| 4618 | struct qla_hw_data *ha = vha->hw; |
| 4619 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 4620 | |
| 4621 | rval = QLA_SUCCESS; |
| 4622 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4623 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1103, |
| 4624 | "Entered %s.\n", __func__); |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 4625 | |
| 4626 | clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
| 4627 | |
| 4628 | /* Write the MBC data to the registers */ |
| 4629 | WRT_REG_WORD(®->mailbox0, MBC_WRITE_MPI_REGISTER); |
| 4630 | WRT_REG_WORD(®->mailbox1, mb[0]); |
| 4631 | WRT_REG_WORD(®->mailbox2, mb[1]); |
| 4632 | WRT_REG_WORD(®->mailbox3, mb[2]); |
| 4633 | WRT_REG_WORD(®->mailbox4, mb[3]); |
| 4634 | |
| 4635 | WRT_REG_DWORD(®->hccr, HCCRX_SET_HOST_INT); |
| 4636 | |
| 4637 | /* Poll for MBC interrupt */ |
| 4638 | for (timer = 6000000; timer; timer--) { |
| 4639 | /* Check for pending interrupts. */ |
| 4640 | stat = RD_REG_DWORD(®->host_status); |
| 4641 | if (stat & HSRX_RISC_INT) { |
| 4642 | stat &= 0xff; |
| 4643 | |
| 4644 | if (stat == 0x1 || stat == 0x2 || |
| 4645 | stat == 0x10 || stat == 0x11) { |
| 4646 | set_bit(MBX_INTERRUPT, |
| 4647 | &ha->mbx_cmd_flags); |
| 4648 | mb0 = RD_REG_WORD(®->mailbox0); |
| 4649 | WRT_REG_DWORD(®->hccr, |
| 4650 | HCCRX_CLR_RISC_INT); |
| 4651 | RD_REG_DWORD(®->hccr); |
| 4652 | break; |
| 4653 | } |
| 4654 | } |
| 4655 | udelay(5); |
| 4656 | } |
| 4657 | |
| 4658 | if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) |
| 4659 | rval = mb0 & MBS_MASK; |
| 4660 | else |
| 4661 | rval = QLA_FUNCTION_FAILED; |
| 4662 | |
| 4663 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4664 | ql_dbg(ql_dbg_mbx, vha, 0x1104, |
| 4665 | "Failed=%x mb[0]=%x.\n", rval, mb[0]); |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 4666 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4667 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1105, |
| 4668 | "Done %s.\n", __func__); |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 4669 | } |
| 4670 | |
| 4671 | return rval; |
| 4672 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4673 | |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 4674 | int |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 4675 | qla2x00_get_data_rate(scsi_qla_host_t *vha) |
| 4676 | { |
| 4677 | int rval; |
| 4678 | mbx_cmd_t mc; |
| 4679 | mbx_cmd_t *mcp = &mc; |
| 4680 | struct qla_hw_data *ha = vha->hw; |
| 4681 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4682 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1106, |
| 4683 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4684 | |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 4685 | if (!IS_FWI2_CAPABLE(ha)) |
| 4686 | return QLA_FUNCTION_FAILED; |
| 4687 | |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 4688 | mcp->mb[0] = MBC_DATA_RATE; |
| 4689 | mcp->mb[1] = 0; |
| 4690 | mcp->out_mb = MBX_1|MBX_0; |
| 4691 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4692 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4693 | mcp->in_mb |= MBX_3; |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 4694 | mcp->tov = MBX_TOV_SECONDS; |
| 4695 | mcp->flags = 0; |
| 4696 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4697 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4698 | ql_dbg(ql_dbg_mbx, vha, 0x1107, |
| 4699 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 4700 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4701 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1108, |
| 4702 | "Done %s.\n", __func__); |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 4703 | if (mcp->mb[1] != 0x7) |
| 4704 | ha->link_data_rate = mcp->mb[1]; |
| 4705 | } |
| 4706 | |
| 4707 | return rval; |
| 4708 | } |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 4709 | |
| 4710 | int |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 4711 | qla81xx_get_port_config(scsi_qla_host_t *vha, uint16_t *mb) |
| 4712 | { |
| 4713 | int rval; |
| 4714 | mbx_cmd_t mc; |
| 4715 | mbx_cmd_t *mcp = &mc; |
| 4716 | struct qla_hw_data *ha = vha->hw; |
| 4717 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4718 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1109, |
| 4719 | "Entered %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 4720 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4721 | if (!IS_QLA81XX(ha) && !IS_QLA83XX(ha) && !IS_QLA8044(ha) && |
| 4722 | !IS_QLA27XX(ha)) |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 4723 | return QLA_FUNCTION_FAILED; |
| 4724 | mcp->mb[0] = MBC_GET_PORT_CONFIG; |
| 4725 | mcp->out_mb = MBX_0; |
| 4726 | mcp->in_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4727 | mcp->tov = MBX_TOV_SECONDS; |
| 4728 | mcp->flags = 0; |
| 4729 | |
| 4730 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4731 | |
| 4732 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4733 | ql_dbg(ql_dbg_mbx, vha, 0x110a, |
| 4734 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 4735 | } else { |
| 4736 | /* Copy all bits to preserve original value */ |
| 4737 | memcpy(mb, &mcp->mb[1], sizeof(uint16_t) * 4); |
| 4738 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4739 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110b, |
| 4740 | "Done %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 4741 | } |
| 4742 | return rval; |
| 4743 | } |
| 4744 | |
| 4745 | int |
| 4746 | qla81xx_set_port_config(scsi_qla_host_t *vha, uint16_t *mb) |
| 4747 | { |
| 4748 | int rval; |
| 4749 | mbx_cmd_t mc; |
| 4750 | mbx_cmd_t *mcp = &mc; |
| 4751 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4752 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110c, |
| 4753 | "Entered %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 4754 | |
| 4755 | mcp->mb[0] = MBC_SET_PORT_CONFIG; |
| 4756 | /* Copy all bits to preserve original setting */ |
| 4757 | memcpy(&mcp->mb[1], mb, sizeof(uint16_t) * 4); |
| 4758 | mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4759 | mcp->in_mb = MBX_0; |
| 4760 | mcp->tov = MBX_TOV_SECONDS; |
| 4761 | mcp->flags = 0; |
| 4762 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4763 | |
| 4764 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4765 | ql_dbg(ql_dbg_mbx, vha, 0x110d, |
| 4766 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 4767 | } else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4768 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110e, |
| 4769 | "Done %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 4770 | |
| 4771 | return rval; |
| 4772 | } |
| 4773 | |
| 4774 | |
| 4775 | int |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 4776 | qla24xx_set_fcp_prio(scsi_qla_host_t *vha, uint16_t loop_id, uint16_t priority, |
| 4777 | uint16_t *mb) |
| 4778 | { |
| 4779 | int rval; |
| 4780 | mbx_cmd_t mc; |
| 4781 | mbx_cmd_t *mcp = &mc; |
| 4782 | struct qla_hw_data *ha = vha->hw; |
| 4783 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4784 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110f, |
| 4785 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4786 | |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 4787 | if (!IS_QLA24XX_TYPE(ha) && !IS_QLA25XX(ha)) |
| 4788 | return QLA_FUNCTION_FAILED; |
| 4789 | |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 4790 | mcp->mb[0] = MBC_PORT_PARAMS; |
| 4791 | mcp->mb[1] = loop_id; |
| 4792 | if (ha->flags.fcp_prio_enabled) |
| 4793 | mcp->mb[2] = BIT_1; |
| 4794 | else |
| 4795 | mcp->mb[2] = BIT_2; |
| 4796 | mcp->mb[4] = priority & 0xf; |
| 4797 | mcp->mb[9] = vha->vp_idx; |
| 4798 | mcp->out_mb = MBX_9|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4799 | mcp->in_mb = MBX_4|MBX_3|MBX_1|MBX_0; |
| 4800 | mcp->tov = 30; |
| 4801 | mcp->flags = 0; |
| 4802 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4803 | if (mb != NULL) { |
| 4804 | mb[0] = mcp->mb[0]; |
| 4805 | mb[1] = mcp->mb[1]; |
| 4806 | mb[3] = mcp->mb[3]; |
| 4807 | mb[4] = mcp->mb[4]; |
| 4808 | } |
| 4809 | |
| 4810 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4811 | ql_dbg(ql_dbg_mbx, vha, 0x10cd, "Failed=%x.\n", rval); |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 4812 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4813 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10cc, |
| 4814 | "Done %s.\n", __func__); |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 4815 | } |
| 4816 | |
| 4817 | return rval; |
| 4818 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4819 | |
| 4820 | int |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 4821 | qla2x00_get_thermal_temp(scsi_qla_host_t *vha, uint16_t *temp) |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 4822 | { |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 4823 | int rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 4824 | struct qla_hw_data *ha = vha->hw; |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 4825 | uint8_t byte; |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 4826 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 4827 | if (!IS_FWI2_CAPABLE(ha) || IS_QLA24XX_TYPE(ha) || IS_QLA81XX(ha)) { |
| 4828 | ql_dbg(ql_dbg_mbx, vha, 0x1150, |
| 4829 | "Thermal not supported by this card.\n"); |
| 4830 | return rval; |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 4831 | } |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 4832 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 4833 | if (IS_QLA25XX(ha)) { |
| 4834 | if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC && |
| 4835 | ha->pdev->subsystem_device == 0x0175) { |
| 4836 | rval = qla2x00_read_sfp(vha, 0, &byte, |
| 4837 | 0x98, 0x1, 1, BIT_13|BIT_0); |
| 4838 | *temp = byte; |
| 4839 | return rval; |
| 4840 | } |
| 4841 | if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_HP && |
| 4842 | ha->pdev->subsystem_device == 0x338e) { |
| 4843 | rval = qla2x00_read_sfp(vha, 0, &byte, |
| 4844 | 0x98, 0x1, 1, BIT_15|BIT_14|BIT_0); |
| 4845 | *temp = byte; |
| 4846 | return rval; |
| 4847 | } |
| 4848 | ql_dbg(ql_dbg_mbx, vha, 0x10c9, |
| 4849 | "Thermal not supported by this card.\n"); |
| 4850 | return rval; |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 4851 | } |
| 4852 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 4853 | if (IS_QLA82XX(ha)) { |
| 4854 | *temp = qla82xx_read_temperature(vha); |
| 4855 | rval = QLA_SUCCESS; |
| 4856 | return rval; |
| 4857 | } else if (IS_QLA8044(ha)) { |
| 4858 | *temp = qla8044_read_temperature(vha); |
| 4859 | rval = QLA_SUCCESS; |
| 4860 | return rval; |
| 4861 | } |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 4862 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 4863 | rval = qla2x00_read_asic_temperature(vha, temp); |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 4864 | return rval; |
| 4865 | } |
| 4866 | |
| 4867 | int |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4868 | qla82xx_mbx_intr_enable(scsi_qla_host_t *vha) |
| 4869 | { |
| 4870 | int rval; |
| 4871 | struct qla_hw_data *ha = vha->hw; |
| 4872 | mbx_cmd_t mc; |
| 4873 | mbx_cmd_t *mcp = &mc; |
| 4874 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4875 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1017, |
| 4876 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4877 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4878 | if (!IS_FWI2_CAPABLE(ha)) |
| 4879 | return QLA_FUNCTION_FAILED; |
| 4880 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4881 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
Giridhar Malavali | 3711333 | 2010-07-23 15:28:34 +0500 | [diff] [blame] | 4882 | mcp->mb[0] = MBC_TOGGLE_INTERRUPT; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4883 | mcp->mb[1] = 1; |
| 4884 | |
| 4885 | mcp->out_mb = MBX_1|MBX_0; |
| 4886 | mcp->in_mb = MBX_0; |
| 4887 | mcp->tov = 30; |
| 4888 | mcp->flags = 0; |
| 4889 | |
| 4890 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4891 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4892 | ql_dbg(ql_dbg_mbx, vha, 0x1016, |
| 4893 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4894 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4895 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x100e, |
| 4896 | "Done %s.\n", __func__); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4897 | } |
| 4898 | |
| 4899 | return rval; |
| 4900 | } |
| 4901 | |
| 4902 | int |
| 4903 | qla82xx_mbx_intr_disable(scsi_qla_host_t *vha) |
| 4904 | { |
| 4905 | int rval; |
| 4906 | struct qla_hw_data *ha = vha->hw; |
| 4907 | mbx_cmd_t mc; |
| 4908 | mbx_cmd_t *mcp = &mc; |
| 4909 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4910 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x100d, |
| 4911 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4912 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 4913 | if (!IS_P3P_TYPE(ha)) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4914 | return QLA_FUNCTION_FAILED; |
| 4915 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4916 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
Giridhar Malavali | 3711333 | 2010-07-23 15:28:34 +0500 | [diff] [blame] | 4917 | mcp->mb[0] = MBC_TOGGLE_INTERRUPT; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4918 | mcp->mb[1] = 0; |
| 4919 | |
| 4920 | mcp->out_mb = MBX_1|MBX_0; |
| 4921 | mcp->in_mb = MBX_0; |
| 4922 | mcp->tov = 30; |
| 4923 | mcp->flags = 0; |
| 4924 | |
| 4925 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4926 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4927 | ql_dbg(ql_dbg_mbx, vha, 0x100c, |
| 4928 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4929 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4930 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x100b, |
| 4931 | "Done %s.\n", __func__); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4932 | } |
| 4933 | |
| 4934 | return rval; |
| 4935 | } |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 4936 | |
| 4937 | int |
| 4938 | qla82xx_md_get_template_size(scsi_qla_host_t *vha) |
| 4939 | { |
| 4940 | struct qla_hw_data *ha = vha->hw; |
| 4941 | mbx_cmd_t mc; |
| 4942 | mbx_cmd_t *mcp = &mc; |
| 4943 | int rval = QLA_FUNCTION_FAILED; |
| 4944 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4945 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x111f, |
| 4946 | "Entered %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 4947 | |
| 4948 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 4949 | mcp->mb[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 4950 | mcp->mb[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 4951 | mcp->mb[2] = LSW(RQST_TMPLT_SIZE); |
| 4952 | mcp->mb[3] = MSW(RQST_TMPLT_SIZE); |
| 4953 | |
| 4954 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 4955 | mcp->in_mb = MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8| |
| 4956 | MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4957 | |
| 4958 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 4959 | mcp->tov = MBX_TOV_SECONDS; |
| 4960 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4961 | |
| 4962 | /* Always copy back return mailbox values. */ |
| 4963 | if (rval != QLA_SUCCESS) { |
| 4964 | ql_dbg(ql_dbg_mbx, vha, 0x1120, |
| 4965 | "mailbox command FAILED=0x%x, subcode=%x.\n", |
| 4966 | (mcp->mb[1] << 16) | mcp->mb[0], |
| 4967 | (mcp->mb[3] << 16) | mcp->mb[2]); |
| 4968 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4969 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1121, |
| 4970 | "Done %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 4971 | ha->md_template_size = ((mcp->mb[3] << 16) | mcp->mb[2]); |
| 4972 | if (!ha->md_template_size) { |
| 4973 | ql_dbg(ql_dbg_mbx, vha, 0x1122, |
| 4974 | "Null template size obtained.\n"); |
| 4975 | rval = QLA_FUNCTION_FAILED; |
| 4976 | } |
| 4977 | } |
| 4978 | return rval; |
| 4979 | } |
| 4980 | |
| 4981 | int |
| 4982 | qla82xx_md_get_template(scsi_qla_host_t *vha) |
| 4983 | { |
| 4984 | struct qla_hw_data *ha = vha->hw; |
| 4985 | mbx_cmd_t mc; |
| 4986 | mbx_cmd_t *mcp = &mc; |
| 4987 | int rval = QLA_FUNCTION_FAILED; |
| 4988 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4989 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1123, |
| 4990 | "Entered %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 4991 | |
| 4992 | ha->md_tmplt_hdr = dma_alloc_coherent(&ha->pdev->dev, |
| 4993 | ha->md_template_size, &ha->md_tmplt_hdr_dma, GFP_KERNEL); |
| 4994 | if (!ha->md_tmplt_hdr) { |
| 4995 | ql_log(ql_log_warn, vha, 0x1124, |
| 4996 | "Unable to allocate memory for Minidump template.\n"); |
| 4997 | return rval; |
| 4998 | } |
| 4999 | |
| 5000 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 5001 | mcp->mb[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5002 | mcp->mb[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5003 | mcp->mb[2] = LSW(RQST_TMPLT); |
| 5004 | mcp->mb[3] = MSW(RQST_TMPLT); |
| 5005 | mcp->mb[4] = LSW(LSD(ha->md_tmplt_hdr_dma)); |
| 5006 | mcp->mb[5] = MSW(LSD(ha->md_tmplt_hdr_dma)); |
| 5007 | mcp->mb[6] = LSW(MSD(ha->md_tmplt_hdr_dma)); |
| 5008 | mcp->mb[7] = MSW(MSD(ha->md_tmplt_hdr_dma)); |
| 5009 | mcp->mb[8] = LSW(ha->md_template_size); |
| 5010 | mcp->mb[9] = MSW(ha->md_template_size); |
| 5011 | |
| 5012 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 5013 | mcp->tov = MBX_TOV_SECONDS; |
| 5014 | mcp->out_mb = MBX_11|MBX_10|MBX_9|MBX_8| |
| 5015 | MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5016 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 5017 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5018 | |
| 5019 | if (rval != QLA_SUCCESS) { |
| 5020 | ql_dbg(ql_dbg_mbx, vha, 0x1125, |
| 5021 | "mailbox command FAILED=0x%x, subcode=%x.\n", |
| 5022 | ((mcp->mb[1] << 16) | mcp->mb[0]), |
| 5023 | ((mcp->mb[3] << 16) | mcp->mb[2])); |
| 5024 | } else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5025 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1126, |
| 5026 | "Done %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5027 | return rval; |
| 5028 | } |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5029 | |
| 5030 | int |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5031 | qla8044_md_get_template(scsi_qla_host_t *vha) |
| 5032 | { |
| 5033 | struct qla_hw_data *ha = vha->hw; |
| 5034 | mbx_cmd_t mc; |
| 5035 | mbx_cmd_t *mcp = &mc; |
| 5036 | int rval = QLA_FUNCTION_FAILED; |
| 5037 | int offset = 0, size = MINIDUMP_SIZE_36K; |
| 5038 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0xb11f, |
| 5039 | "Entered %s.\n", __func__); |
| 5040 | |
| 5041 | ha->md_tmplt_hdr = dma_alloc_coherent(&ha->pdev->dev, |
| 5042 | ha->md_template_size, &ha->md_tmplt_hdr_dma, GFP_KERNEL); |
| 5043 | if (!ha->md_tmplt_hdr) { |
| 5044 | ql_log(ql_log_warn, vha, 0xb11b, |
| 5045 | "Unable to allocate memory for Minidump template.\n"); |
| 5046 | return rval; |
| 5047 | } |
| 5048 | |
| 5049 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 5050 | while (offset < ha->md_template_size) { |
| 5051 | mcp->mb[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5052 | mcp->mb[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5053 | mcp->mb[2] = LSW(RQST_TMPLT); |
| 5054 | mcp->mb[3] = MSW(RQST_TMPLT); |
| 5055 | mcp->mb[4] = LSW(LSD(ha->md_tmplt_hdr_dma + offset)); |
| 5056 | mcp->mb[5] = MSW(LSD(ha->md_tmplt_hdr_dma + offset)); |
| 5057 | mcp->mb[6] = LSW(MSD(ha->md_tmplt_hdr_dma + offset)); |
| 5058 | mcp->mb[7] = MSW(MSD(ha->md_tmplt_hdr_dma + offset)); |
| 5059 | mcp->mb[8] = LSW(size); |
| 5060 | mcp->mb[9] = MSW(size); |
| 5061 | mcp->mb[10] = offset & 0x0000FFFF; |
| 5062 | mcp->mb[11] = offset & 0xFFFF0000; |
| 5063 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 5064 | mcp->tov = MBX_TOV_SECONDS; |
| 5065 | mcp->out_mb = MBX_11|MBX_10|MBX_9|MBX_8| |
| 5066 | MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5067 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 5068 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5069 | |
| 5070 | if (rval != QLA_SUCCESS) { |
| 5071 | ql_dbg(ql_dbg_mbx, vha, 0xb11c, |
| 5072 | "mailbox command FAILED=0x%x, subcode=%x.\n", |
| 5073 | ((mcp->mb[1] << 16) | mcp->mb[0]), |
| 5074 | ((mcp->mb[3] << 16) | mcp->mb[2])); |
| 5075 | return rval; |
| 5076 | } else |
| 5077 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0xb11d, |
| 5078 | "Done %s.\n", __func__); |
| 5079 | offset = offset + size; |
| 5080 | } |
| 5081 | return rval; |
| 5082 | } |
| 5083 | |
| 5084 | int |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5085 | qla81xx_set_led_config(scsi_qla_host_t *vha, uint16_t *led_cfg) |
| 5086 | { |
| 5087 | int rval; |
| 5088 | struct qla_hw_data *ha = vha->hw; |
| 5089 | mbx_cmd_t mc; |
| 5090 | mbx_cmd_t *mcp = &mc; |
| 5091 | |
| 5092 | if (!IS_QLA81XX(ha) && !IS_QLA8031(ha)) |
| 5093 | return QLA_FUNCTION_FAILED; |
| 5094 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5095 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1133, |
| 5096 | "Entered %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5097 | |
| 5098 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
| 5099 | mcp->mb[0] = MBC_SET_LED_CONFIG; |
| 5100 | mcp->mb[1] = led_cfg[0]; |
| 5101 | mcp->mb[2] = led_cfg[1]; |
| 5102 | if (IS_QLA8031(ha)) { |
| 5103 | mcp->mb[3] = led_cfg[2]; |
| 5104 | mcp->mb[4] = led_cfg[3]; |
| 5105 | mcp->mb[5] = led_cfg[4]; |
| 5106 | mcp->mb[6] = led_cfg[5]; |
| 5107 | } |
| 5108 | |
| 5109 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 5110 | if (IS_QLA8031(ha)) |
| 5111 | mcp->out_mb |= MBX_6|MBX_5|MBX_4|MBX_3; |
| 5112 | mcp->in_mb = MBX_0; |
| 5113 | mcp->tov = 30; |
| 5114 | mcp->flags = 0; |
| 5115 | |
| 5116 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5117 | if (rval != QLA_SUCCESS) { |
| 5118 | ql_dbg(ql_dbg_mbx, vha, 0x1134, |
| 5119 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5120 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5121 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1135, |
| 5122 | "Done %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5123 | } |
| 5124 | |
| 5125 | return rval; |
| 5126 | } |
| 5127 | |
| 5128 | int |
| 5129 | qla81xx_get_led_config(scsi_qla_host_t *vha, uint16_t *led_cfg) |
| 5130 | { |
| 5131 | int rval; |
| 5132 | struct qla_hw_data *ha = vha->hw; |
| 5133 | mbx_cmd_t mc; |
| 5134 | mbx_cmd_t *mcp = &mc; |
| 5135 | |
| 5136 | if (!IS_QLA81XX(ha) && !IS_QLA8031(ha)) |
| 5137 | return QLA_FUNCTION_FAILED; |
| 5138 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5139 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1136, |
| 5140 | "Entered %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5141 | |
| 5142 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
| 5143 | mcp->mb[0] = MBC_GET_LED_CONFIG; |
| 5144 | |
| 5145 | mcp->out_mb = MBX_0; |
| 5146 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 5147 | if (IS_QLA8031(ha)) |
| 5148 | mcp->in_mb |= MBX_6|MBX_5|MBX_4|MBX_3; |
| 5149 | mcp->tov = 30; |
| 5150 | mcp->flags = 0; |
| 5151 | |
| 5152 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5153 | if (rval != QLA_SUCCESS) { |
| 5154 | ql_dbg(ql_dbg_mbx, vha, 0x1137, |
| 5155 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5156 | } else { |
| 5157 | led_cfg[0] = mcp->mb[1]; |
| 5158 | led_cfg[1] = mcp->mb[2]; |
| 5159 | if (IS_QLA8031(ha)) { |
| 5160 | led_cfg[2] = mcp->mb[3]; |
| 5161 | led_cfg[3] = mcp->mb[4]; |
| 5162 | led_cfg[4] = mcp->mb[5]; |
| 5163 | led_cfg[5] = mcp->mb[6]; |
| 5164 | } |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5165 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1138, |
| 5166 | "Done %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5167 | } |
| 5168 | |
| 5169 | return rval; |
| 5170 | } |
| 5171 | |
| 5172 | int |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5173 | qla82xx_mbx_beacon_ctl(scsi_qla_host_t *vha, int enable) |
| 5174 | { |
| 5175 | int rval; |
| 5176 | struct qla_hw_data *ha = vha->hw; |
| 5177 | mbx_cmd_t mc; |
| 5178 | mbx_cmd_t *mcp = &mc; |
| 5179 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5180 | if (!IS_P3P_TYPE(ha)) |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5181 | return QLA_FUNCTION_FAILED; |
| 5182 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5183 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1127, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5184 | "Entered %s.\n", __func__); |
| 5185 | |
| 5186 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
| 5187 | mcp->mb[0] = MBC_SET_LED_CONFIG; |
| 5188 | if (enable) |
| 5189 | mcp->mb[7] = 0xE; |
| 5190 | else |
| 5191 | mcp->mb[7] = 0xD; |
| 5192 | |
| 5193 | mcp->out_mb = MBX_7|MBX_0; |
| 5194 | mcp->in_mb = MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5195 | mcp->tov = MBX_TOV_SECONDS; |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5196 | mcp->flags = 0; |
| 5197 | |
| 5198 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5199 | if (rval != QLA_SUCCESS) { |
| 5200 | ql_dbg(ql_dbg_mbx, vha, 0x1128, |
| 5201 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5202 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5203 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1129, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5204 | "Done %s.\n", __func__); |
| 5205 | } |
| 5206 | |
| 5207 | return rval; |
| 5208 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5209 | |
| 5210 | int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5211 | 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] | 5212 | { |
| 5213 | int rval; |
| 5214 | struct qla_hw_data *ha = vha->hw; |
| 5215 | mbx_cmd_t mc; |
| 5216 | mbx_cmd_t *mcp = &mc; |
| 5217 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5218 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5219 | return QLA_FUNCTION_FAILED; |
| 5220 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5221 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1130, |
| 5222 | "Entered %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5223 | |
| 5224 | mcp->mb[0] = MBC_WRITE_REMOTE_REG; |
| 5225 | mcp->mb[1] = LSW(reg); |
| 5226 | mcp->mb[2] = MSW(reg); |
| 5227 | mcp->mb[3] = LSW(data); |
| 5228 | mcp->mb[4] = MSW(data); |
| 5229 | mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5230 | |
| 5231 | mcp->in_mb = MBX_1|MBX_0; |
| 5232 | mcp->tov = MBX_TOV_SECONDS; |
| 5233 | mcp->flags = 0; |
| 5234 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5235 | |
| 5236 | if (rval != QLA_SUCCESS) { |
| 5237 | ql_dbg(ql_dbg_mbx, vha, 0x1131, |
| 5238 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5239 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5240 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1132, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5241 | "Done %s.\n", __func__); |
| 5242 | } |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5243 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5244 | return rval; |
| 5245 | } |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5246 | |
| 5247 | int |
| 5248 | qla2x00_port_logout(scsi_qla_host_t *vha, struct fc_port *fcport) |
| 5249 | { |
| 5250 | int rval; |
| 5251 | struct qla_hw_data *ha = vha->hw; |
| 5252 | mbx_cmd_t mc; |
| 5253 | mbx_cmd_t *mcp = &mc; |
| 5254 | |
| 5255 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5256 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x113b, |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5257 | "Implicit LOGO Unsupported.\n"); |
| 5258 | return QLA_FUNCTION_FAILED; |
| 5259 | } |
| 5260 | |
| 5261 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5262 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x113c, |
| 5263 | "Entering %s.\n", __func__); |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5264 | |
| 5265 | /* Perform Implicit LOGO. */ |
| 5266 | mcp->mb[0] = MBC_PORT_LOGOUT; |
| 5267 | mcp->mb[1] = fcport->loop_id; |
| 5268 | mcp->mb[10] = BIT_15; |
| 5269 | mcp->out_mb = MBX_10|MBX_1|MBX_0; |
| 5270 | mcp->in_mb = MBX_0; |
| 5271 | mcp->tov = MBX_TOV_SECONDS; |
| 5272 | mcp->flags = 0; |
| 5273 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5274 | if (rval != QLA_SUCCESS) |
| 5275 | ql_dbg(ql_dbg_mbx, vha, 0x113d, |
| 5276 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5277 | else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5278 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x113e, |
| 5279 | "Done %s.\n", __func__); |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5280 | |
| 5281 | return rval; |
| 5282 | } |
| 5283 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5284 | int |
| 5285 | qla83xx_rd_reg(scsi_qla_host_t *vha, uint32_t reg, uint32_t *data) |
| 5286 | { |
| 5287 | int rval; |
| 5288 | mbx_cmd_t mc; |
| 5289 | mbx_cmd_t *mcp = &mc; |
| 5290 | struct qla_hw_data *ha = vha->hw; |
| 5291 | unsigned long retry_max_time = jiffies + (2 * HZ); |
| 5292 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5293 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5294 | return QLA_FUNCTION_FAILED; |
| 5295 | |
| 5296 | ql_dbg(ql_dbg_mbx, vha, 0x114b, "Entered %s.\n", __func__); |
| 5297 | |
| 5298 | retry_rd_reg: |
| 5299 | mcp->mb[0] = MBC_READ_REMOTE_REG; |
| 5300 | mcp->mb[1] = LSW(reg); |
| 5301 | mcp->mb[2] = MSW(reg); |
| 5302 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 5303 | mcp->in_mb = MBX_4|MBX_3|MBX_1|MBX_0; |
| 5304 | mcp->tov = MBX_TOV_SECONDS; |
| 5305 | mcp->flags = 0; |
| 5306 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5307 | |
| 5308 | if (rval != QLA_SUCCESS) { |
| 5309 | ql_dbg(ql_dbg_mbx, vha, 0x114c, |
| 5310 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 5311 | rval, mcp->mb[0], mcp->mb[1]); |
| 5312 | } else { |
| 5313 | *data = (mcp->mb[3] | (mcp->mb[4] << 16)); |
| 5314 | if (*data == QLA8XXX_BAD_VALUE) { |
| 5315 | /* |
| 5316 | * During soft-reset CAMRAM register reads might |
| 5317 | * return 0xbad0bad0. So retry for MAX of 2 sec |
| 5318 | * while reading camram registers. |
| 5319 | */ |
| 5320 | if (time_after(jiffies, retry_max_time)) { |
| 5321 | ql_dbg(ql_dbg_mbx, vha, 0x1141, |
| 5322 | "Failure to read CAMRAM register. " |
| 5323 | "data=0x%x.\n", *data); |
| 5324 | return QLA_FUNCTION_FAILED; |
| 5325 | } |
| 5326 | msleep(100); |
| 5327 | goto retry_rd_reg; |
| 5328 | } |
| 5329 | ql_dbg(ql_dbg_mbx, vha, 0x1142, "Done %s.\n", __func__); |
| 5330 | } |
| 5331 | |
| 5332 | return rval; |
| 5333 | } |
| 5334 | |
| 5335 | int |
| 5336 | qla83xx_restart_nic_firmware(scsi_qla_host_t *vha) |
| 5337 | { |
| 5338 | int rval; |
| 5339 | mbx_cmd_t mc; |
| 5340 | mbx_cmd_t *mcp = &mc; |
| 5341 | struct qla_hw_data *ha = vha->hw; |
| 5342 | |
| 5343 | if (!IS_QLA83XX(ha)) |
| 5344 | return QLA_FUNCTION_FAILED; |
| 5345 | |
| 5346 | ql_dbg(ql_dbg_mbx, vha, 0x1143, "Entered %s.\n", __func__); |
| 5347 | |
| 5348 | mcp->mb[0] = MBC_RESTART_NIC_FIRMWARE; |
| 5349 | mcp->out_mb = MBX_0; |
| 5350 | mcp->in_mb = MBX_1|MBX_0; |
| 5351 | mcp->tov = MBX_TOV_SECONDS; |
| 5352 | mcp->flags = 0; |
| 5353 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5354 | |
| 5355 | if (rval != QLA_SUCCESS) { |
| 5356 | ql_dbg(ql_dbg_mbx, vha, 0x1144, |
| 5357 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 5358 | rval, mcp->mb[0], mcp->mb[1]); |
| 5359 | ha->isp_ops->fw_dump(vha, 0); |
| 5360 | } else { |
| 5361 | ql_dbg(ql_dbg_mbx, vha, 0x1145, "Done %s.\n", __func__); |
| 5362 | } |
| 5363 | |
| 5364 | return rval; |
| 5365 | } |
| 5366 | |
| 5367 | int |
| 5368 | qla83xx_access_control(scsi_qla_host_t *vha, uint16_t options, |
| 5369 | uint32_t start_addr, uint32_t end_addr, uint16_t *sector_size) |
| 5370 | { |
| 5371 | int rval; |
| 5372 | mbx_cmd_t mc; |
| 5373 | mbx_cmd_t *mcp = &mc; |
| 5374 | uint8_t subcode = (uint8_t)options; |
| 5375 | struct qla_hw_data *ha = vha->hw; |
| 5376 | |
| 5377 | if (!IS_QLA8031(ha)) |
| 5378 | return QLA_FUNCTION_FAILED; |
| 5379 | |
| 5380 | ql_dbg(ql_dbg_mbx, vha, 0x1146, "Entered %s.\n", __func__); |
| 5381 | |
| 5382 | mcp->mb[0] = MBC_SET_ACCESS_CONTROL; |
| 5383 | mcp->mb[1] = options; |
| 5384 | mcp->out_mb = MBX_1|MBX_0; |
| 5385 | if (subcode & BIT_2) { |
| 5386 | mcp->mb[2] = LSW(start_addr); |
| 5387 | mcp->mb[3] = MSW(start_addr); |
| 5388 | mcp->mb[4] = LSW(end_addr); |
| 5389 | mcp->mb[5] = MSW(end_addr); |
| 5390 | mcp->out_mb |= MBX_5|MBX_4|MBX_3|MBX_2; |
| 5391 | } |
| 5392 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 5393 | if (!(subcode & (BIT_2 | BIT_5))) |
| 5394 | mcp->in_mb |= MBX_4|MBX_3; |
| 5395 | mcp->tov = MBX_TOV_SECONDS; |
| 5396 | mcp->flags = 0; |
| 5397 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5398 | |
| 5399 | if (rval != QLA_SUCCESS) { |
| 5400 | ql_dbg(ql_dbg_mbx, vha, 0x1147, |
| 5401 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[3]=%x mb[4]=%x.\n", |
| 5402 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2], mcp->mb[3], |
| 5403 | mcp->mb[4]); |
| 5404 | ha->isp_ops->fw_dump(vha, 0); |
| 5405 | } else { |
| 5406 | if (subcode & BIT_5) |
| 5407 | *sector_size = mcp->mb[1]; |
| 5408 | else if (subcode & (BIT_6 | BIT_7)) { |
| 5409 | ql_dbg(ql_dbg_mbx, vha, 0x1148, |
| 5410 | "Driver-lock id=%x%x", mcp->mb[4], mcp->mb[3]); |
| 5411 | } else if (subcode & (BIT_3 | BIT_4)) { |
| 5412 | ql_dbg(ql_dbg_mbx, vha, 0x1149, |
| 5413 | "Flash-lock id=%x%x", mcp->mb[4], mcp->mb[3]); |
| 5414 | } |
| 5415 | ql_dbg(ql_dbg_mbx, vha, 0x114a, "Done %s.\n", __func__); |
| 5416 | } |
| 5417 | |
| 5418 | return rval; |
| 5419 | } |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 5420 | |
| 5421 | int |
| 5422 | qla2x00_dump_mctp_data(scsi_qla_host_t *vha, dma_addr_t req_dma, uint32_t addr, |
| 5423 | uint32_t size) |
| 5424 | { |
| 5425 | int rval; |
| 5426 | mbx_cmd_t mc; |
| 5427 | mbx_cmd_t *mcp = &mc; |
| 5428 | |
| 5429 | if (!IS_MCTP_CAPABLE(vha->hw)) |
| 5430 | return QLA_FUNCTION_FAILED; |
| 5431 | |
| 5432 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x114f, |
| 5433 | "Entered %s.\n", __func__); |
| 5434 | |
| 5435 | mcp->mb[0] = MBC_DUMP_RISC_RAM_EXTENDED; |
| 5436 | mcp->mb[1] = LSW(addr); |
| 5437 | mcp->mb[2] = MSW(req_dma); |
| 5438 | mcp->mb[3] = LSW(req_dma); |
| 5439 | mcp->mb[4] = MSW(size); |
| 5440 | mcp->mb[5] = LSW(size); |
| 5441 | mcp->mb[6] = MSW(MSD(req_dma)); |
| 5442 | mcp->mb[7] = LSW(MSD(req_dma)); |
| 5443 | mcp->mb[8] = MSW(addr); |
| 5444 | /* Setting RAM ID to valid */ |
| 5445 | mcp->mb[10] |= BIT_7; |
| 5446 | /* For MCTP RAM ID is 0x40 */ |
| 5447 | mcp->mb[10] |= 0x40; |
| 5448 | |
| 5449 | mcp->out_mb |= MBX_10|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1| |
| 5450 | MBX_0; |
| 5451 | |
| 5452 | mcp->in_mb = MBX_0; |
| 5453 | mcp->tov = MBX_TOV_SECONDS; |
| 5454 | mcp->flags = 0; |
| 5455 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5456 | |
| 5457 | if (rval != QLA_SUCCESS) { |
| 5458 | ql_dbg(ql_dbg_mbx, vha, 0x114e, |
| 5459 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5460 | } else { |
| 5461 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x114d, |
| 5462 | "Done %s.\n", __func__); |
| 5463 | } |
| 5464 | |
| 5465 | return rval; |
| 5466 | } |