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 | { |
| 36 | int rval; |
| 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; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | unsigned long wait_time; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 47 | struct qla_hw_data *ha = vha->hw; |
| 48 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 49 | |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 50 | ql_dbg(ql_dbg_mbx, vha, 0x1000, "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 51 | |
| 52 | if (ha->pdev->error_state > pci_channel_io_frozen) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 53 | ql_log(ql_log_warn, vha, 0x1001, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 54 | "error_state is greater than pci_channel_io_frozen, " |
| 55 | "exiting.\n"); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 56 | return QLA_FUNCTION_TIMEOUT; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 57 | } |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 58 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 59 | if (vha->device_flags & DFLG_DEV_FAILED) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 60 | ql_log(ql_log_warn, vha, 0x1002, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 61 | "Device in failed state, exiting.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 62 | return QLA_FUNCTION_TIMEOUT; |
| 63 | } |
| 64 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 65 | reg = ha->iobase; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 66 | io_lock_on = base_vha->flags.init_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | |
| 68 | rval = QLA_SUCCESS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 69 | abort_active = test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 71 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 72 | if (ha->flags.pci_channel_io_perm_failure) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 73 | ql_log(ql_log_warn, vha, 0x1003, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 74 | "Perm failure on EEH timeout MBX, exiting.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 75 | return QLA_FUNCTION_TIMEOUT; |
| 76 | } |
| 77 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 78 | if (IS_P3P_TYPE(ha) && ha->flags.isp82xx_fw_hung) { |
Giridhar Malavali | 862cd01 | 2011-02-23 15:27:11 -0800 | [diff] [blame] | 79 | /* Setting Link-Down error */ |
| 80 | mcp->mb[0] = MBS_LINK_DOWN_ERROR; |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 81 | ql_log(ql_log_warn, vha, 0x1004, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 82 | "FW hung = %d.\n", ha->flags.isp82xx_fw_hung); |
Andrew Vasquez | 1806fcd | 2011-11-18 09:02:15 -0800 | [diff] [blame] | 83 | return QLA_FUNCTION_TIMEOUT; |
Giridhar Malavali | 862cd01 | 2011-02-23 15:27:11 -0800 | [diff] [blame] | 84 | } |
| 85 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | /* |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 87 | * Wait for active mailbox commands to finish by waiting at most tov |
| 88 | * seconds. This is to serialize actual issuing of mailbox cmds during |
| 89 | * non ISP abort time. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | */ |
Andrew Vasquez | 8eca3f3 | 2009-01-22 09:45:31 -0800 | [diff] [blame] | 91 | if (!wait_for_completion_timeout(&ha->mbx_cmd_comp, mcp->tov * HZ)) { |
| 92 | /* Timeout occurred. Return error. */ |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 93 | ql_log(ql_log_warn, vha, 0x1005, |
Chad Dupuis | d8c0d54 | 2012-02-09 11:15:46 -0800 | [diff] [blame] | 94 | "Cmd access timeout, cmd=0x%x, Exiting.\n", |
| 95 | mcp->mb[0]); |
Andrew Vasquez | 8eca3f3 | 2009-01-22 09:45:31 -0800 | [diff] [blame] | 96 | return QLA_FUNCTION_TIMEOUT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | ha->flags.mbox_busy = 1; |
| 100 | /* Save mailbox command for debug */ |
| 101 | ha->mcp = mcp; |
| 102 | |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 103 | ql_dbg(ql_dbg_mbx, vha, 0x1006, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 104 | "Prepare to issue mbox cmd=0x%x.\n", mcp->mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | |
| 106 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 107 | |
| 108 | /* Load mailbox registers. */ |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 109 | if (IS_P3P_TYPE(ha)) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 110 | optr = (uint16_t __iomem *)®->isp82.mailbox_in[0]; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 111 | else if (IS_FWI2_CAPABLE(ha) && !(IS_P3P_TYPE(ha))) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 112 | optr = (uint16_t __iomem *)®->isp24.mailbox0; |
| 113 | else |
| 114 | optr = (uint16_t __iomem *)MAILBOX_REG(ha, ®->isp, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | |
| 116 | iptr = mcp->mb; |
| 117 | command = mcp->mb[0]; |
| 118 | mboxes = mcp->out_mb; |
| 119 | |
Joe Carnuccio | 7b71162 | 2014-09-25 05:16:43 -0400 | [diff] [blame] | 120 | ql_dbg(ql_dbg_mbx, vha, 0x1111, |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 121 | "Mailbox registers (OUT):\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | for (cnt = 0; cnt < ha->mbx_count; cnt++) { |
| 123 | if (IS_QLA2200(ha) && cnt == 8) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 124 | optr = |
| 125 | (uint16_t __iomem *)MAILBOX_REG(ha, ®->isp, 8); |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 126 | if (mboxes & BIT_0) { |
| 127 | ql_dbg(ql_dbg_mbx, vha, 0x1112, |
| 128 | "mbox[%d]<-0x%04x\n", cnt, *iptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | WRT_REG_WORD(optr, *iptr); |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 130 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | |
| 132 | mboxes >>= 1; |
| 133 | optr++; |
| 134 | iptr++; |
| 135 | } |
| 136 | |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 137 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1117, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 138 | "I/O Address = %p.\n", optr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | |
| 140 | /* Issue set host interrupt command to send cmd out. */ |
| 141 | ha->flags.mbox_int = 0; |
| 142 | clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
| 143 | |
| 144 | /* Unlock mbx registers and wait for interrupt */ |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 145 | ql_dbg(ql_dbg_mbx, vha, 0x100f, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 146 | "Going to unlock irq & waiting for interrupts. " |
| 147 | "jiffies=%lx.\n", jiffies); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | |
| 149 | /* Wait for mbx cmd completion until timeout */ |
| 150 | |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 151 | if ((!abort_active && io_lock_on) || IS_NOPOLLING_TYPE(ha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | set_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); |
| 153 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 154 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 155 | if (RD_REG_DWORD(®->isp82.hint) & |
| 156 | HINT_MBX_INT_PENDING) { |
| 157 | spin_unlock_irqrestore(&ha->hardware_lock, |
| 158 | flags); |
Giridhar Malavali | 8937f2f | 2011-11-18 09:02:18 -0800 | [diff] [blame] | 159 | ha->flags.mbox_busy = 0; |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 160 | ql_dbg(ql_dbg_mbx, vha, 0x1010, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 161 | "Pending mailbox timeout, exiting.\n"); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 162 | rval = QLA_FUNCTION_TIMEOUT; |
| 163 | goto premature_exit; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 164 | } |
| 165 | WRT_REG_DWORD(®->isp82.hint, HINT_MBX_INT_PENDING); |
| 166 | } else if (IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 167 | WRT_REG_DWORD(®->isp24.hccr, HCCRX_SET_HOST_INT); |
| 168 | else |
| 169 | WRT_REG_WORD(®->isp.hccr, HCCR_SET_HOST_INT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 171 | |
Giridhar Malavali | 754d124 | 2013-06-25 11:27:16 -0400 | [diff] [blame] | 172 | if (!wait_for_completion_timeout(&ha->mbx_intr_comp, |
| 173 | mcp->tov * HZ)) { |
| 174 | ql_dbg(ql_dbg_mbx, vha, 0x117a, |
| 175 | "cmd=%x Timeout.\n", command); |
| 176 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 177 | clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); |
| 178 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 179 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | } else { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 181 | ql_dbg(ql_dbg_mbx, vha, 0x1011, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 182 | "Cmd=%x Polling Mode.\n", command); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 184 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 185 | if (RD_REG_DWORD(®->isp82.hint) & |
| 186 | HINT_MBX_INT_PENDING) { |
| 187 | spin_unlock_irqrestore(&ha->hardware_lock, |
| 188 | flags); |
Giridhar Malavali | 8937f2f | 2011-11-18 09:02:18 -0800 | [diff] [blame] | 189 | ha->flags.mbox_busy = 0; |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 190 | ql_dbg(ql_dbg_mbx, vha, 0x1012, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 191 | "Pending mailbox timeout, exiting.\n"); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 192 | rval = QLA_FUNCTION_TIMEOUT; |
| 193 | goto premature_exit; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 194 | } |
| 195 | WRT_REG_DWORD(®->isp82.hint, HINT_MBX_INT_PENDING); |
| 196 | } else if (IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 197 | WRT_REG_DWORD(®->isp24.hccr, HCCRX_SET_HOST_INT); |
| 198 | else |
| 199 | WRT_REG_WORD(®->isp.hccr, HCCR_SET_HOST_INT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | |
| 202 | wait_time = jiffies + mcp->tov * HZ; /* wait at most tov secs */ |
| 203 | while (!ha->flags.mbox_int) { |
| 204 | if (time_after(jiffies, wait_time)) |
| 205 | break; |
| 206 | |
| 207 | /* Check for pending interrupts. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 208 | qla2x00_poll(ha->rsp_q_map[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 210 | if (!ha->flags.mbox_int && |
| 211 | !(IS_QLA2200(ha) && |
| 212 | command == MBC_LOAD_RISC_RAM_EXTENDED)) |
andrew.vasquez@qlogic.com | 5998983 | 2006-01-13 17:05:10 -0800 | [diff] [blame] | 213 | msleep(10); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | } /* while */ |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 215 | ql_dbg(ql_dbg_mbx, vha, 0x1013, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 216 | "Waited %d sec.\n", |
| 217 | (uint)((jiffies - (wait_time - (mcp->tov * HZ)))/HZ)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | } |
| 219 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | /* Check whether we timed out */ |
| 221 | if (ha->flags.mbox_int) { |
| 222 | uint16_t *iptr2; |
| 223 | |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 224 | ql_dbg(ql_dbg_mbx, vha, 0x1014, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 225 | "Cmd=%x completed.\n", command); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | |
| 227 | /* Got interrupt. Clear the flag. */ |
| 228 | ha->flags.mbox_int = 0; |
| 229 | clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
| 230 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 231 | if (IS_P3P_TYPE(ha) && ha->flags.isp82xx_fw_hung) { |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 232 | ha->flags.mbox_busy = 0; |
| 233 | /* Setting Link-Down error */ |
| 234 | mcp->mb[0] = MBS_LINK_DOWN_ERROR; |
| 235 | ha->mcp = NULL; |
| 236 | rval = QLA_FUNCTION_FAILED; |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 237 | ql_log(ql_log_warn, vha, 0x1015, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 238 | "FW hung = %d.\n", ha->flags.isp82xx_fw_hung); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 239 | goto premature_exit; |
| 240 | } |
| 241 | |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 242 | if (ha->mailbox_out[0] != MBS_COMMAND_COMPLETE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | rval = QLA_FUNCTION_FAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | |
| 245 | /* Load return mailbox registers. */ |
| 246 | iptr2 = mcp->mb; |
| 247 | iptr = (uint16_t *)&ha->mailbox_out[0]; |
| 248 | mboxes = mcp->in_mb; |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 249 | |
| 250 | ql_dbg(ql_dbg_mbx, vha, 0x1113, |
| 251 | "Mailbox registers (IN):\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | for (cnt = 0; cnt < ha->mbx_count; cnt++) { |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 253 | if (mboxes & BIT_0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | *iptr2 = *iptr; |
Joe Carnuccio | 0e31a2c | 2013-08-23 07:25:37 -0700 | [diff] [blame] | 255 | ql_dbg(ql_dbg_mbx, vha, 0x1114, |
| 256 | "mbox[%d]->0x%04x\n", cnt, *iptr2); |
| 257 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | |
| 259 | mboxes >>= 1; |
| 260 | iptr2++; |
| 261 | iptr++; |
| 262 | } |
| 263 | } else { |
| 264 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 265 | uint16_t mb0; |
| 266 | uint32_t ictrl; |
| 267 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 268 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 269 | mb0 = RD_REG_WORD(®->isp24.mailbox0); |
| 270 | ictrl = RD_REG_DWORD(®->isp24.ictrl); |
| 271 | } else { |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 272 | mb0 = RD_MAILBOX_REG(ha, ®->isp, 0); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 273 | ictrl = RD_REG_WORD(®->isp.ictrl); |
| 274 | } |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 275 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1119, |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 276 | "MBX Command timeout for cmd %x, iocontrol=%x jiffies=%lx " |
| 277 | "mb[0]=0x%x\n", command, ictrl, jiffies, mb0); |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 278 | ql_dump_regs(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1019); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | |
Chad Dupuis | f55bfc8 | 2012-02-09 11:15:53 -0800 | [diff] [blame] | 280 | /* |
| 281 | * Attempt to capture a firmware dump for further analysis |
Chad Dupuis | b8eb413 | 2013-06-25 11:27:20 -0400 | [diff] [blame] | 282 | * of the current firmware state. We do not need to do this |
| 283 | * if we are intentionally generating a dump. |
Chad Dupuis | f55bfc8 | 2012-02-09 11:15:53 -0800 | [diff] [blame] | 284 | */ |
Chad Dupuis | b8eb413 | 2013-06-25 11:27:20 -0400 | [diff] [blame] | 285 | if (mcp->mb[0] != MBC_GEN_SYSTEM_ERROR) |
| 286 | ha->isp_ops->fw_dump(vha, 0); |
Chad Dupuis | f55bfc8 | 2012-02-09 11:15:53 -0800 | [diff] [blame] | 287 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | rval = QLA_FUNCTION_TIMEOUT; |
| 289 | } |
| 290 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | ha->flags.mbox_busy = 0; |
| 292 | |
| 293 | /* Clean up */ |
| 294 | ha->mcp = NULL; |
| 295 | |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 296 | if ((abort_active || !io_lock_on) && !IS_NOPOLLING_TYPE(ha)) { |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 297 | ql_dbg(ql_dbg_mbx, vha, 0x101a, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 298 | "Checking for additional resp interrupt.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | |
| 300 | /* polling mode for non isp_abort commands. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 301 | qla2x00_poll(ha->rsp_q_map[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | } |
| 303 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 304 | if (rval == QLA_FUNCTION_TIMEOUT && |
| 305 | mcp->mb[0] != MBC_GEN_SYSTEM_ERROR) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 306 | if (!io_lock_on || (mcp->flags & IOCTL_CMD) || |
| 307 | ha->flags.eeh_busy) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | /* not in dpc. schedule it for dpc to take over. */ |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 309 | ql_dbg(ql_dbg_mbx, vha, 0x101b, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 310 | "Timeout, schedule isp_abort_needed.\n"); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 311 | |
| 312 | if (!test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) && |
| 313 | !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) && |
| 314 | !test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) { |
Giridhar Malavali | 6315491 | 2011-11-18 09:02:19 -0800 | [diff] [blame] | 315 | if (IS_QLA82XX(ha)) { |
| 316 | ql_dbg(ql_dbg_mbx, vha, 0x112a, |
| 317 | "disabling pause transmit on port " |
| 318 | "0 & 1.\n"); |
| 319 | qla82xx_wr_32(ha, |
| 320 | QLA82XX_CRB_NIU + 0x98, |
| 321 | CRB_NIU_XG_PAUSE_CTL_P0| |
| 322 | CRB_NIU_XG_PAUSE_CTL_P1); |
| 323 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 324 | ql_log(ql_log_info, base_vha, 0x101c, |
Masanari Iida | 24d9ee8 | 2012-05-15 14:34:10 -0400 | [diff] [blame] | 325 | "Mailbox cmd timeout occurred, cmd=0x%x, " |
Chad Dupuis | d8c0d54 | 2012-02-09 11:15:46 -0800 | [diff] [blame] | 326 | "mb[0]=0x%x, eeh_busy=0x%x. Scheduling ISP " |
| 327 | "abort.\n", command, mcp->mb[0], |
| 328 | ha->flags.eeh_busy); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 329 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 330 | qla2xxx_wake_dpc(vha); |
| 331 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | } else if (!abort_active) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | /* call abort directly since we are in the DPC thread */ |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 334 | ql_dbg(ql_dbg_mbx, vha, 0x101d, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 335 | "Timeout, calling abort_isp.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 337 | if (!test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) && |
| 338 | !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) && |
| 339 | !test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) { |
Giridhar Malavali | 6315491 | 2011-11-18 09:02:19 -0800 | [diff] [blame] | 340 | if (IS_QLA82XX(ha)) { |
| 341 | ql_dbg(ql_dbg_mbx, vha, 0x112b, |
| 342 | "disabling pause transmit on port " |
| 343 | "0 & 1.\n"); |
| 344 | qla82xx_wr_32(ha, |
| 345 | QLA82XX_CRB_NIU + 0x98, |
| 346 | CRB_NIU_XG_PAUSE_CTL_P0| |
| 347 | CRB_NIU_XG_PAUSE_CTL_P1); |
| 348 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 349 | ql_log(ql_log_info, base_vha, 0x101e, |
Masanari Iida | 24d9ee8 | 2012-05-15 14:34:10 -0400 | [diff] [blame] | 350 | "Mailbox cmd timeout occurred, cmd=0x%x, " |
Chad Dupuis | d8c0d54 | 2012-02-09 11:15:46 -0800 | [diff] [blame] | 351 | "mb[0]=0x%x. Scheduling ISP abort ", |
| 352 | command, mcp->mb[0]); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 353 | set_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags); |
| 354 | clear_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Giridhar Malavali | d336096 | 2012-02-09 11:14:10 -0800 | [diff] [blame] | 355 | /* Allow next mbx cmd to come in. */ |
| 356 | complete(&ha->mbx_cmd_comp); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 357 | if (ha->isp_ops->abort_isp(vha)) { |
| 358 | /* Failed. retry later. */ |
| 359 | set_bit(ISP_ABORT_NEEDED, |
| 360 | &vha->dpc_flags); |
| 361 | } |
| 362 | clear_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags); |
Arun Easi | 5e19ed9 | 2012-02-09 11:15:51 -0800 | [diff] [blame] | 363 | ql_dbg(ql_dbg_mbx, vha, 0x101f, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 364 | "Finished abort_isp.\n"); |
Giridhar Malavali | d336096 | 2012-02-09 11:14:10 -0800 | [diff] [blame] | 365 | goto mbx_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | } |
| 368 | } |
| 369 | |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 370 | premature_exit: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | /* Allow next mbx cmd to come in. */ |
Andrew Vasquez | 8eca3f3 | 2009-01-22 09:45:31 -0800 | [diff] [blame] | 372 | complete(&ha->mbx_cmd_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | |
Giridhar Malavali | d336096 | 2012-02-09 11:14:10 -0800 | [diff] [blame] | 374 | mbx_done: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | if (rval) { |
Chad Dupuis | 34c5801 | 2014-08-08 07:38:08 -0400 | [diff] [blame] | 376 | ql_dbg(ql_dbg_disc, base_vha, 0x1020, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 377 | "**** Failed mbx[0]=%x, mb[1]=%x, mb[2]=%x, mb[3]=%x, cmd=%x ****.\n", |
| 378 | mcp->mb[0], mcp->mb[1], mcp->mb[2], mcp->mb[3], command); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 380 | ql_dbg(ql_dbg_mbx, base_vha, 0x1021, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | } |
| 382 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | return rval; |
| 384 | } |
| 385 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 387 | 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] | 388 | uint32_t risc_code_size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | { |
| 390 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 391 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | mbx_cmd_t mc; |
| 393 | mbx_cmd_t *mcp = &mc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 395 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1022, |
| 396 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 398 | if (MSW(risc_addr) || IS_FWI2_CAPABLE(ha)) { |
andrew.vasquez@qlogic.com | 590f98e | 2006-01-13 17:05:37 -0800 | [diff] [blame] | 399 | mcp->mb[0] = MBC_LOAD_RISC_RAM_EXTENDED; |
| 400 | mcp->mb[8] = MSW(risc_addr); |
| 401 | mcp->out_mb = MBX_8|MBX_0; |
| 402 | } else { |
| 403 | mcp->mb[0] = MBC_LOAD_RISC_RAM; |
| 404 | mcp->out_mb = MBX_0; |
| 405 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | mcp->mb[1] = LSW(risc_addr); |
| 407 | mcp->mb[2] = MSW(req_dma); |
| 408 | mcp->mb[3] = LSW(req_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | mcp->mb[6] = MSW(MSD(req_dma)); |
| 410 | mcp->mb[7] = LSW(MSD(req_dma)); |
andrew.vasquez@qlogic.com | 590f98e | 2006-01-13 17:05:37 -0800 | [diff] [blame] | 411 | 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] | 412 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 413 | mcp->mb[4] = MSW(risc_code_size); |
| 414 | mcp->mb[5] = LSW(risc_code_size); |
| 415 | mcp->out_mb |= MBX_5|MBX_4; |
| 416 | } else { |
| 417 | mcp->mb[4] = LSW(risc_code_size); |
| 418 | mcp->out_mb |= MBX_4; |
| 419 | } |
| 420 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 422 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 424 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 427 | ql_dbg(ql_dbg_mbx, vha, 0x1023, |
| 428 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 430 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1024, |
| 431 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | } |
| 433 | |
| 434 | return rval; |
| 435 | } |
| 436 | |
Santosh Vernekar | cad454b | 2010-03-19 16:59:16 -0700 | [diff] [blame] | 437 | #define EXTENDED_BB_CREDITS BIT_0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | /* |
| 439 | * qla2x00_execute_fw |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 440 | * Start adapter firmware. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | * |
| 442 | * Input: |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 443 | * ha = adapter block pointer. |
| 444 | * TARGET_QUEUE_LOCK must be released. |
| 445 | * ADAPTER_STATE_LOCK must be released. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | * |
| 447 | * Returns: |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 448 | * qla2x00 local function return status code. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | * |
| 450 | * Context: |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 451 | * Kernel context. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | */ |
| 453 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 454 | qla2x00_execute_fw(scsi_qla_host_t *vha, uint32_t risc_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | { |
| 456 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 457 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | mbx_cmd_t mc; |
| 459 | mbx_cmd_t *mcp = &mc; |
| 460 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 461 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1025, |
| 462 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | |
| 464 | mcp->mb[0] = MBC_EXECUTE_FIRMWARE; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 465 | mcp->out_mb = MBX_0; |
| 466 | mcp->in_mb = MBX_0; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 467 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 468 | mcp->mb[1] = MSW(risc_addr); |
| 469 | mcp->mb[2] = LSW(risc_addr); |
| 470 | mcp->mb[3] = 0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 471 | if (IS_QLA25XX(ha) || IS_QLA81XX(ha) || IS_QLA83XX(ha) || |
| 472 | IS_QLA27XX(ha)) { |
Santosh Vernekar | cad454b | 2010-03-19 16:59:16 -0700 | [diff] [blame] | 473 | struct nvram_81xx *nv = ha->nvram; |
| 474 | mcp->mb[4] = (nv->enhanced_features & |
| 475 | EXTENDED_BB_CREDITS); |
| 476 | } else |
| 477 | mcp->mb[4] = 0; |
Andrew Vasquez | 8b3253d | 2007-09-20 14:07:48 -0700 | [diff] [blame] | 478 | mcp->out_mb |= MBX_4|MBX_3|MBX_2|MBX_1; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 479 | mcp->in_mb |= MBX_1; |
| 480 | } else { |
| 481 | mcp->mb[1] = LSW(risc_addr); |
| 482 | mcp->out_mb |= MBX_1; |
| 483 | if (IS_QLA2322(ha) || IS_QLA6322(ha)) { |
| 484 | mcp->mb[2] = 0; |
| 485 | mcp->out_mb |= MBX_2; |
| 486 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 | } |
| 488 | |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 489 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 491 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 493 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 494 | ql_dbg(ql_dbg_mbx, vha, 0x1026, |
| 495 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 496 | } else { |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 497 | if (IS_FWI2_CAPABLE(ha)) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 498 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1027, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 499 | "Done exchanges=%x.\n", mcp->mb[1]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 500 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 501 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1028, |
| 502 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 503 | } |
| 504 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | |
| 506 | return rval; |
| 507 | } |
| 508 | |
| 509 | /* |
| 510 | * qla2x00_get_fw_version |
| 511 | * Get firmware version. |
| 512 | * |
| 513 | * Input: |
| 514 | * ha: adapter state pointer. |
| 515 | * major: pointer for major number. |
| 516 | * minor: pointer for minor number. |
| 517 | * subminor: pointer for subminor number. |
| 518 | * |
| 519 | * Returns: |
| 520 | * qla2x00 local function return status code. |
| 521 | * |
| 522 | * Context: |
| 523 | * Kernel context. |
| 524 | */ |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 525 | int |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 526 | qla2x00_get_fw_version(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | { |
| 528 | int rval; |
| 529 | mbx_cmd_t mc; |
| 530 | mbx_cmd_t *mcp = &mc; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 531 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 532 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 533 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1029, |
| 534 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 535 | |
| 536 | mcp->mb[0] = MBC_GET_FIRMWARE_VERSION; |
| 537 | mcp->out_mb = MBX_0; |
| 538 | 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] | 539 | if (IS_QLA81XX(vha->hw) || IS_QLA8031(ha) || IS_QLA8044(ha)) |
Andrew Vasquez | 55a9615 | 2009-03-24 09:08:03 -0700 | [diff] [blame] | 540 | 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] | 541 | if (IS_FWI2_CAPABLE(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 542 | mcp->in_mb |= MBX_17|MBX_16|MBX_15; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 543 | if (IS_QLA27XX(ha)) |
| 544 | mcp->in_mb |= MBX_21|MBX_20|MBX_19|MBX_18; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | mcp->flags = 0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 546 | mcp->tov = MBX_TOV_SECONDS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 547 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 548 | if (rval != QLA_SUCCESS) |
| 549 | goto failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | |
| 551 | /* Return mailbox data. */ |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 552 | ha->fw_major_version = mcp->mb[1]; |
| 553 | ha->fw_minor_version = mcp->mb[2]; |
| 554 | ha->fw_subminor_version = mcp->mb[3]; |
| 555 | ha->fw_attributes = mcp->mb[6]; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 556 | if (IS_QLA2100(vha->hw) || IS_QLA2200(vha->hw)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 557 | ha->fw_memory_size = 0x1FFFF; /* Defaults to 128KB. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | else |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 559 | ha->fw_memory_size = (mcp->mb[5] << 16) | mcp->mb[4]; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 560 | if (IS_QLA81XX(vha->hw) || IS_QLA8031(vha->hw) || IS_QLA8044(ha)) { |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 561 | ha->mpi_version[0] = mcp->mb[10] & 0xff; |
| 562 | ha->mpi_version[1] = mcp->mb[11] >> 8; |
| 563 | ha->mpi_version[2] = mcp->mb[11] & 0xff; |
| 564 | ha->mpi_capabilities = (mcp->mb[12] << 16) | mcp->mb[13]; |
| 565 | ha->phy_version[0] = mcp->mb[8] & 0xff; |
| 566 | ha->phy_version[1] = mcp->mb[9] >> 8; |
| 567 | ha->phy_version[2] = mcp->mb[9] & 0xff; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 568 | } |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 569 | if (IS_FWI2_CAPABLE(ha)) { |
| 570 | ha->fw_attributes_h = mcp->mb[15]; |
| 571 | ha->fw_attributes_ext[0] = mcp->mb[16]; |
| 572 | ha->fw_attributes_ext[1] = mcp->mb[17]; |
| 573 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1139, |
| 574 | "%s: FW_attributes Upper: 0x%x, Lower: 0x%x.\n", |
| 575 | __func__, mcp->mb[15], mcp->mb[6]); |
| 576 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x112f, |
| 577 | "%s: Ext_FwAttributes Upper: 0x%x, Lower: 0x%x.\n", |
| 578 | __func__, mcp->mb[17], mcp->mb[16]); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 579 | } |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 580 | if (IS_QLA27XX(ha)) { |
| 581 | ha->fw_shared_ram_start = (mcp->mb[19] << 16) | mcp->mb[18]; |
| 582 | ha->fw_shared_ram_end = (mcp->mb[21] << 16) | mcp->mb[20]; |
| 583 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 584 | |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 585 | failed: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 586 | if (rval != QLA_SUCCESS) { |
| 587 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 588 | ql_dbg(ql_dbg_mbx, vha, 0x102a, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | } else { |
| 590 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 591 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102b, |
| 592 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | } |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 594 | return rval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | } |
| 596 | |
| 597 | /* |
| 598 | * qla2x00_get_fw_options |
| 599 | * Set firmware options. |
| 600 | * |
| 601 | * Input: |
| 602 | * ha = adapter block pointer. |
| 603 | * fwopt = pointer for firmware options. |
| 604 | * |
| 605 | * Returns: |
| 606 | * qla2x00 local function return status code. |
| 607 | * |
| 608 | * Context: |
| 609 | * Kernel context. |
| 610 | */ |
| 611 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 612 | qla2x00_get_fw_options(scsi_qla_host_t *vha, uint16_t *fwopts) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | { |
| 614 | int rval; |
| 615 | mbx_cmd_t mc; |
| 616 | mbx_cmd_t *mcp = &mc; |
| 617 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 618 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102c, |
| 619 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | |
| 621 | mcp->mb[0] = MBC_GET_FIRMWARE_OPTION; |
| 622 | mcp->out_mb = MBX_0; |
| 623 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 624 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 625 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 626 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | |
| 628 | if (rval != QLA_SUCCESS) { |
| 629 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 630 | ql_dbg(ql_dbg_mbx, vha, 0x102d, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | } else { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 632 | fwopts[0] = mcp->mb[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | fwopts[1] = mcp->mb[1]; |
| 634 | fwopts[2] = mcp->mb[2]; |
| 635 | fwopts[3] = mcp->mb[3]; |
| 636 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 637 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102e, |
| 638 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | } |
| 640 | |
| 641 | return rval; |
| 642 | } |
| 643 | |
| 644 | |
| 645 | /* |
| 646 | * qla2x00_set_fw_options |
| 647 | * Set firmware options. |
| 648 | * |
| 649 | * Input: |
| 650 | * ha = adapter block pointer. |
| 651 | * fwopt = pointer for firmware options. |
| 652 | * |
| 653 | * Returns: |
| 654 | * qla2x00 local function return status code. |
| 655 | * |
| 656 | * Context: |
| 657 | * Kernel context. |
| 658 | */ |
| 659 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 660 | qla2x00_set_fw_options(scsi_qla_host_t *vha, uint16_t *fwopts) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 661 | { |
| 662 | int rval; |
| 663 | mbx_cmd_t mc; |
| 664 | mbx_cmd_t *mcp = &mc; |
| 665 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 666 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x102f, |
| 667 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | |
| 669 | mcp->mb[0] = MBC_SET_FIRMWARE_OPTION; |
| 670 | mcp->mb[1] = fwopts[1]; |
| 671 | mcp->mb[2] = fwopts[2]; |
| 672 | mcp->mb[3] = fwopts[3]; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 673 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 674 | mcp->in_mb = MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 675 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 676 | mcp->in_mb |= MBX_1; |
| 677 | } else { |
| 678 | mcp->mb[10] = fwopts[10]; |
| 679 | mcp->mb[11] = fwopts[11]; |
| 680 | mcp->mb[12] = 0; /* Undocumented, but used */ |
| 681 | mcp->out_mb |= MBX_12|MBX_11|MBX_10; |
| 682 | } |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 683 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 684 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 685 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 687 | fwopts[0] = mcp->mb[0]; |
| 688 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | if (rval != QLA_SUCCESS) { |
| 690 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 691 | ql_dbg(ql_dbg_mbx, vha, 0x1030, |
| 692 | "Failed=%x (%x/%x).\n", rval, mcp->mb[0], mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | } else { |
| 694 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 695 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1031, |
| 696 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 697 | } |
| 698 | |
| 699 | return rval; |
| 700 | } |
| 701 | |
| 702 | /* |
| 703 | * qla2x00_mbx_reg_test |
| 704 | * Mailbox register wrap test. |
| 705 | * |
| 706 | * Input: |
| 707 | * ha = adapter block pointer. |
| 708 | * TARGET_QUEUE_LOCK must be released. |
| 709 | * ADAPTER_STATE_LOCK must be released. |
| 710 | * |
| 711 | * Returns: |
| 712 | * qla2x00 local function return status code. |
| 713 | * |
| 714 | * Context: |
| 715 | * Kernel context. |
| 716 | */ |
| 717 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 718 | qla2x00_mbx_reg_test(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 719 | { |
| 720 | int rval; |
| 721 | mbx_cmd_t mc; |
| 722 | mbx_cmd_t *mcp = &mc; |
| 723 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 724 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1032, |
| 725 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 726 | |
| 727 | mcp->mb[0] = MBC_MAILBOX_REGISTER_TEST; |
| 728 | mcp->mb[1] = 0xAAAA; |
| 729 | mcp->mb[2] = 0x5555; |
| 730 | mcp->mb[3] = 0xAA55; |
| 731 | mcp->mb[4] = 0x55AA; |
| 732 | mcp->mb[5] = 0xA5A5; |
| 733 | mcp->mb[6] = 0x5A5A; |
| 734 | mcp->mb[7] = 0x2525; |
| 735 | mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 736 | 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] | 737 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 738 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 739 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 740 | |
| 741 | if (rval == QLA_SUCCESS) { |
| 742 | if (mcp->mb[1] != 0xAAAA || mcp->mb[2] != 0x5555 || |
| 743 | mcp->mb[3] != 0xAA55 || mcp->mb[4] != 0x55AA) |
| 744 | rval = QLA_FUNCTION_FAILED; |
| 745 | if (mcp->mb[5] != 0xA5A5 || mcp->mb[6] != 0x5A5A || |
| 746 | mcp->mb[7] != 0x2525) |
| 747 | rval = QLA_FUNCTION_FAILED; |
| 748 | } |
| 749 | |
| 750 | if (rval != QLA_SUCCESS) { |
| 751 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 752 | ql_dbg(ql_dbg_mbx, vha, 0x1033, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 753 | } else { |
| 754 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 755 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1034, |
| 756 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 757 | } |
| 758 | |
| 759 | return rval; |
| 760 | } |
| 761 | |
| 762 | /* |
| 763 | * qla2x00_verify_checksum |
| 764 | * Verify firmware checksum. |
| 765 | * |
| 766 | * Input: |
| 767 | * ha = adapter block pointer. |
| 768 | * TARGET_QUEUE_LOCK must be released. |
| 769 | * ADAPTER_STATE_LOCK must be released. |
| 770 | * |
| 771 | * Returns: |
| 772 | * qla2x00 local function return status code. |
| 773 | * |
| 774 | * Context: |
| 775 | * Kernel context. |
| 776 | */ |
| 777 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 778 | qla2x00_verify_checksum(scsi_qla_host_t *vha, uint32_t risc_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 779 | { |
| 780 | int rval; |
| 781 | mbx_cmd_t mc; |
| 782 | mbx_cmd_t *mcp = &mc; |
| 783 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 784 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1035, |
| 785 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 786 | |
| 787 | mcp->mb[0] = MBC_VERIFY_CHECKSUM; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 788 | mcp->out_mb = MBX_0; |
| 789 | mcp->in_mb = MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 790 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 791 | mcp->mb[1] = MSW(risc_addr); |
| 792 | mcp->mb[2] = LSW(risc_addr); |
| 793 | mcp->out_mb |= MBX_2|MBX_1; |
| 794 | mcp->in_mb |= MBX_2|MBX_1; |
| 795 | } else { |
| 796 | mcp->mb[1] = LSW(risc_addr); |
| 797 | mcp->out_mb |= MBX_1; |
| 798 | mcp->in_mb |= MBX_1; |
| 799 | } |
| 800 | |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 801 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 802 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 803 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 804 | |
| 805 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 806 | ql_dbg(ql_dbg_mbx, vha, 0x1036, |
| 807 | "Failed=%x chm sum=%x.\n", rval, IS_FWI2_CAPABLE(vha->hw) ? |
| 808 | (mcp->mb[2] << 16) | mcp->mb[1] : mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 809 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 810 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1037, |
| 811 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 812 | } |
| 813 | |
| 814 | return rval; |
| 815 | } |
| 816 | |
| 817 | /* |
| 818 | * qla2x00_issue_iocb |
| 819 | * Issue IOCB using mailbox command |
| 820 | * |
| 821 | * Input: |
| 822 | * ha = adapter state pointer. |
| 823 | * buffer = buffer pointer. |
| 824 | * phys_addr = physical address of buffer. |
| 825 | * size = size of buffer. |
| 826 | * TARGET_QUEUE_LOCK must be released. |
| 827 | * ADAPTER_STATE_LOCK must be released. |
| 828 | * |
| 829 | * Returns: |
| 830 | * qla2x00 local function return status code. |
| 831 | * |
| 832 | * Context: |
| 833 | * Kernel context. |
| 834 | */ |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 835 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 836 | qla2x00_issue_iocb_timeout(scsi_qla_host_t *vha, void *buffer, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 837 | dma_addr_t phys_addr, size_t size, uint32_t tov) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 838 | { |
| 839 | int rval; |
| 840 | mbx_cmd_t mc; |
| 841 | mbx_cmd_t *mcp = &mc; |
| 842 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 843 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1038, |
| 844 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 845 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 846 | mcp->mb[0] = MBC_IOCB_COMMAND_A64; |
| 847 | mcp->mb[1] = 0; |
| 848 | mcp->mb[2] = MSW(phys_addr); |
| 849 | mcp->mb[3] = LSW(phys_addr); |
| 850 | mcp->mb[6] = MSW(MSD(phys_addr)); |
| 851 | mcp->mb[7] = LSW(MSD(phys_addr)); |
| 852 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 853 | mcp->in_mb = MBX_2|MBX_0; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 854 | mcp->tov = tov; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 855 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 856 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 857 | |
| 858 | if (rval != QLA_SUCCESS) { |
| 859 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 860 | ql_dbg(ql_dbg_mbx, vha, 0x1039, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 861 | } else { |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 862 | sts_entry_t *sts_entry = (sts_entry_t *) buffer; |
| 863 | |
| 864 | /* Mask reserved bits. */ |
| 865 | sts_entry->entry_status &= |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 866 | IS_FWI2_CAPABLE(vha->hw) ? RF_MASK_24XX : RF_MASK; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 867 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103a, |
| 868 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 869 | } |
| 870 | |
| 871 | return rval; |
| 872 | } |
| 873 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 874 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 875 | 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] | 876 | size_t size) |
| 877 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 878 | return qla2x00_issue_iocb_timeout(vha, buffer, phys_addr, size, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 879 | MBX_TOV_SECONDS); |
| 880 | } |
| 881 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 882 | /* |
| 883 | * qla2x00_abort_command |
| 884 | * Abort command aborts a specified IOCB. |
| 885 | * |
| 886 | * Input: |
| 887 | * ha = adapter block pointer. |
| 888 | * sp = SB structure pointer. |
| 889 | * |
| 890 | * Returns: |
| 891 | * qla2x00 local function return status code. |
| 892 | * |
| 893 | * Context: |
| 894 | * Kernel context. |
| 895 | */ |
| 896 | int |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 897 | qla2x00_abort_command(srb_t *sp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 898 | { |
| 899 | unsigned long flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 900 | int rval; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 901 | uint32_t handle = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 902 | mbx_cmd_t mc; |
| 903 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 904 | fc_port_t *fcport = sp->fcport; |
| 905 | scsi_qla_host_t *vha = fcport->vha; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 906 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 907 | struct req_que *req = vha->req; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 908 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 909 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 910 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103b, |
| 911 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 912 | |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 913 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 914 | for (handle = 1; handle < req->num_outstanding_cmds; handle++) { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 915 | if (req->outstanding_cmds[handle] == sp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 916 | break; |
| 917 | } |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 918 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 919 | |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 920 | if (handle == req->num_outstanding_cmds) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 921 | /* command not found */ |
| 922 | return QLA_FUNCTION_FAILED; |
| 923 | } |
| 924 | |
| 925 | mcp->mb[0] = MBC_ABORT_COMMAND; |
| 926 | if (HAS_EXTENDED_IDS(ha)) |
| 927 | mcp->mb[1] = fcport->loop_id; |
| 928 | else |
| 929 | mcp->mb[1] = fcport->loop_id << 8; |
| 930 | mcp->mb[2] = (uint16_t)handle; |
| 931 | mcp->mb[3] = (uint16_t)(handle >> 16); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 932 | mcp->mb[6] = (uint16_t)cmd->device->lun; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 933 | mcp->out_mb = MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 934 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 935 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 936 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 937 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 938 | |
| 939 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 940 | ql_dbg(ql_dbg_mbx, vha, 0x103c, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 941 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 942 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103d, |
| 943 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 944 | } |
| 945 | |
| 946 | return rval; |
| 947 | } |
| 948 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 949 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 950 | qla2x00_abort_target(struct fc_port *fcport, uint64_t l, int tag) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 951 | { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 952 | int rval, rval2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 953 | mbx_cmd_t mc; |
| 954 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 955 | scsi_qla_host_t *vha; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 956 | struct req_que *req; |
| 957 | struct rsp_que *rsp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 958 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 959 | l = l; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 960 | vha = fcport->vha; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 961 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 962 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103e, |
| 963 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 964 | |
Giridhar Malavali | 7e2b895 | 2010-05-28 15:08:17 -0700 | [diff] [blame] | 965 | req = vha->hw->req_q_map[0]; |
| 966 | rsp = req->rsp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 967 | mcp->mb[0] = MBC_ABORT_TARGET; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 968 | mcp->out_mb = MBX_9|MBX_2|MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 969 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 970 | mcp->mb[1] = fcport->loop_id; |
| 971 | mcp->mb[10] = 0; |
| 972 | mcp->out_mb |= MBX_10; |
| 973 | } else { |
| 974 | mcp->mb[1] = fcport->loop_id << 8; |
| 975 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 976 | mcp->mb[2] = vha->hw->loop_reset_delay; |
| 977 | mcp->mb[9] = vha->vp_idx; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 978 | |
| 979 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 980 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 981 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 982 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 983 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 984 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103f, |
| 985 | "Failed=%x.\n", rval); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 986 | } |
| 987 | |
| 988 | /* Issue marker IOCB. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 989 | rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, 0, |
| 990 | MK_SYNC_ID); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 991 | if (rval2 != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 992 | ql_dbg(ql_dbg_mbx, vha, 0x1040, |
| 993 | "Failed to issue marker IOCB (%x).\n", rval2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 994 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 995 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1041, |
| 996 | "Done %s.\n", __func__); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 997 | } |
| 998 | |
| 999 | return rval; |
| 1000 | } |
| 1001 | |
| 1002 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1003 | qla2x00_lun_reset(struct fc_port *fcport, uint64_t l, int tag) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1004 | { |
| 1005 | int rval, rval2; |
| 1006 | mbx_cmd_t mc; |
| 1007 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1008 | scsi_qla_host_t *vha; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1009 | struct req_que *req; |
| 1010 | struct rsp_que *rsp; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1011 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1012 | vha = fcport->vha; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1013 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1014 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1042, |
| 1015 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1016 | |
Giridhar Malavali | 7e2b895 | 2010-05-28 15:08:17 -0700 | [diff] [blame] | 1017 | req = vha->hw->req_q_map[0]; |
| 1018 | rsp = req->rsp; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1019 | mcp->mb[0] = MBC_LUN_RESET; |
| 1020 | 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] | 1021 | if (HAS_EXTENDED_IDS(vha->hw)) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1022 | mcp->mb[1] = fcport->loop_id; |
| 1023 | else |
| 1024 | mcp->mb[1] = fcport->loop_id << 8; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1025 | mcp->mb[2] = (u32)l; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1026 | mcp->mb[3] = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1027 | mcp->mb[9] = vha->vp_idx; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1028 | |
| 1029 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1030 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1031 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1032 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1033 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1034 | ql_dbg(ql_dbg_mbx, vha, 0x1043, "Failed=%x.\n", rval); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1035 | } |
| 1036 | |
| 1037 | /* Issue marker IOCB. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1038 | rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, l, |
| 1039 | MK_SYNC_ID_LUN); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1040 | if (rval2 != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1041 | ql_dbg(ql_dbg_mbx, vha, 0x1044, |
| 1042 | "Failed to issue marker IOCB (%x).\n", rval2); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1043 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1044 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1045, |
| 1045 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1046 | } |
| 1047 | |
| 1048 | return rval; |
| 1049 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1050 | |
| 1051 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1052 | * qla2x00_get_adapter_id |
| 1053 | * Get adapter ID and topology. |
| 1054 | * |
| 1055 | * Input: |
| 1056 | * ha = adapter block pointer. |
| 1057 | * id = pointer for loop ID. |
| 1058 | * al_pa = pointer for AL_PA. |
| 1059 | * area = pointer for area. |
| 1060 | * domain = pointer for domain. |
| 1061 | * top = pointer for topology. |
| 1062 | * TARGET_QUEUE_LOCK must be released. |
| 1063 | * ADAPTER_STATE_LOCK must be released. |
| 1064 | * |
| 1065 | * Returns: |
| 1066 | * qla2x00 local function return status code. |
| 1067 | * |
| 1068 | * Context: |
| 1069 | * Kernel context. |
| 1070 | */ |
| 1071 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1072 | 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] | 1073 | 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] | 1074 | { |
| 1075 | int rval; |
| 1076 | mbx_cmd_t mc; |
| 1077 | mbx_cmd_t *mcp = &mc; |
| 1078 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1079 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1046, |
| 1080 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1081 | |
| 1082 | mcp->mb[0] = MBC_GET_ADAPTER_LOOP_ID; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1083 | mcp->mb[9] = vha->vp_idx; |
Andrew Vasquez | eb66dc6 | 2007-11-12 10:30:58 -0800 | [diff] [blame] | 1084 | mcp->out_mb = MBX_9|MBX_0; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1085 | 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] | 1086 | if (IS_CNA_CAPABLE(vha->hw)) |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1087 | mcp->in_mb |= MBX_13|MBX_12|MBX_11|MBX_10; |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 1088 | if (IS_FWI2_CAPABLE(vha->hw)) |
| 1089 | mcp->in_mb |= MBX_19|MBX_18|MBX_17|MBX_16; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1090 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1091 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1092 | rval = qla2x00_mailbox_command(vha, mcp); |
Ravi Anand | 33135aa | 2005-11-08 14:37:20 -0800 | [diff] [blame] | 1093 | if (mcp->mb[0] == MBS_COMMAND_ERROR) |
| 1094 | rval = QLA_COMMAND_ERROR; |
Andrew Vasquez | 42e421b | 2008-07-10 16:56:01 -0700 | [diff] [blame] | 1095 | else if (mcp->mb[0] == MBS_INVALID_COMMAND) |
| 1096 | rval = QLA_INVALID_COMMAND; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1097 | |
| 1098 | /* Return data. */ |
| 1099 | *id = mcp->mb[1]; |
| 1100 | *al_pa = LSB(mcp->mb[2]); |
| 1101 | *area = MSB(mcp->mb[2]); |
| 1102 | *domain = LSB(mcp->mb[3]); |
| 1103 | *top = mcp->mb[6]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1104 | *sw_cap = mcp->mb[7]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1105 | |
| 1106 | if (rval != QLA_SUCCESS) { |
| 1107 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1108 | ql_dbg(ql_dbg_mbx, vha, 0x1047, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1109 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1110 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1048, |
| 1111 | "Done %s.\n", __func__); |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1112 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1113 | if (IS_CNA_CAPABLE(vha->hw)) { |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1114 | vha->fcoe_vlan_id = mcp->mb[9] & 0xfff; |
| 1115 | vha->fcoe_fcf_idx = mcp->mb[10]; |
| 1116 | vha->fcoe_vn_port_mac[5] = mcp->mb[11] >> 8; |
| 1117 | vha->fcoe_vn_port_mac[4] = mcp->mb[11] & 0xff; |
| 1118 | vha->fcoe_vn_port_mac[3] = mcp->mb[12] >> 8; |
| 1119 | vha->fcoe_vn_port_mac[2] = mcp->mb[12] & 0xff; |
| 1120 | vha->fcoe_vn_port_mac[1] = mcp->mb[13] >> 8; |
| 1121 | vha->fcoe_vn_port_mac[0] = mcp->mb[13] & 0xff; |
| 1122 | } |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 1123 | /* If FA-WWN supported */ |
| 1124 | if (mcp->mb[7] & BIT_14) { |
| 1125 | vha->port_name[0] = MSB(mcp->mb[16]); |
| 1126 | vha->port_name[1] = LSB(mcp->mb[16]); |
| 1127 | vha->port_name[2] = MSB(mcp->mb[17]); |
| 1128 | vha->port_name[3] = LSB(mcp->mb[17]); |
| 1129 | vha->port_name[4] = MSB(mcp->mb[18]); |
| 1130 | vha->port_name[5] = LSB(mcp->mb[18]); |
| 1131 | vha->port_name[6] = MSB(mcp->mb[19]); |
| 1132 | vha->port_name[7] = LSB(mcp->mb[19]); |
| 1133 | fc_host_port_name(vha->host) = |
| 1134 | wwn_to_u64(vha->port_name); |
| 1135 | ql_dbg(ql_dbg_mbx, vha, 0x10ca, |
| 1136 | "FA-WWN acquired %016llx\n", |
| 1137 | wwn_to_u64(vha->port_name)); |
| 1138 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1139 | } |
| 1140 | |
| 1141 | return rval; |
| 1142 | } |
| 1143 | |
| 1144 | /* |
| 1145 | * qla2x00_get_retry_cnt |
| 1146 | * Get current firmware login retry count and delay. |
| 1147 | * |
| 1148 | * Input: |
| 1149 | * ha = adapter block pointer. |
| 1150 | * retry_cnt = pointer to login retry count. |
| 1151 | * tov = pointer to login timeout value. |
| 1152 | * |
| 1153 | * Returns: |
| 1154 | * qla2x00 local function return status code. |
| 1155 | * |
| 1156 | * Context: |
| 1157 | * Kernel context. |
| 1158 | */ |
| 1159 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1160 | qla2x00_get_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] | 1161 | uint16_t *r_a_tov) |
| 1162 | { |
| 1163 | int rval; |
| 1164 | uint16_t ratov; |
| 1165 | mbx_cmd_t mc; |
| 1166 | mbx_cmd_t *mcp = &mc; |
| 1167 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1168 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1049, |
| 1169 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1170 | |
| 1171 | mcp->mb[0] = MBC_GET_RETRY_COUNT; |
| 1172 | mcp->out_mb = MBX_0; |
| 1173 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1174 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1175 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1176 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1177 | |
| 1178 | if (rval != QLA_SUCCESS) { |
| 1179 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1180 | ql_dbg(ql_dbg_mbx, vha, 0x104a, |
| 1181 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1182 | } else { |
| 1183 | /* Convert returned data and check our values. */ |
| 1184 | *r_a_tov = mcp->mb[3] / 2; |
| 1185 | ratov = (mcp->mb[3]/2) / 10; /* mb[3] value is in 100ms */ |
| 1186 | if (mcp->mb[1] * ratov > (*retry_cnt) * (*tov)) { |
| 1187 | /* Update to the larger values */ |
| 1188 | *retry_cnt = (uint8_t)mcp->mb[1]; |
| 1189 | *tov = ratov; |
| 1190 | } |
| 1191 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1192 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104b, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1193 | "Done %s mb3=%d ratov=%d.\n", __func__, mcp->mb[3], ratov); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1194 | } |
| 1195 | |
| 1196 | return rval; |
| 1197 | } |
| 1198 | |
| 1199 | /* |
| 1200 | * qla2x00_init_firmware |
| 1201 | * Initialize adapter firmware. |
| 1202 | * |
| 1203 | * Input: |
| 1204 | * ha = adapter block pointer. |
| 1205 | * dptr = Initialization control block pointer. |
| 1206 | * size = size of initialization control block. |
| 1207 | * TARGET_QUEUE_LOCK must be released. |
| 1208 | * ADAPTER_STATE_LOCK must be released. |
| 1209 | * |
| 1210 | * Returns: |
| 1211 | * qla2x00 local function return status code. |
| 1212 | * |
| 1213 | * Context: |
| 1214 | * Kernel context. |
| 1215 | */ |
| 1216 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1217 | qla2x00_init_firmware(scsi_qla_host_t *vha, uint16_t size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1218 | { |
| 1219 | int rval; |
| 1220 | mbx_cmd_t mc; |
| 1221 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1222 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1223 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1224 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104c, |
| 1225 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1226 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1227 | if (IS_P3P_TYPE(ha) && ql2xdbwr) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1228 | qla82xx_wr_32(ha, ha->nxdb_wr_ptr, |
| 1229 | (0x04 | (ha->portnum << 5) | (0 << 8) | (0 << 16))); |
| 1230 | |
Andrew Vasquez | e6e074f | 2008-01-31 12:33:53 -0800 | [diff] [blame] | 1231 | if (ha->flags.npiv_supported) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1232 | mcp->mb[0] = MBC_MID_INITIALIZE_FIRMWARE; |
| 1233 | else |
| 1234 | mcp->mb[0] = MBC_INITIALIZE_FIRMWARE; |
| 1235 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 1236 | mcp->mb[1] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1237 | mcp->mb[2] = MSW(ha->init_cb_dma); |
| 1238 | mcp->mb[3] = LSW(ha->init_cb_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1239 | mcp->mb[6] = MSW(MSD(ha->init_cb_dma)); |
| 1240 | mcp->mb[7] = LSW(MSD(ha->init_cb_dma)); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 1241 | 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] | 1242 | if (ha->ex_init_cb && ha->ex_init_cb->ex_version) { |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 1243 | mcp->mb[1] = BIT_0; |
| 1244 | mcp->mb[10] = MSW(ha->ex_init_cb_dma); |
| 1245 | mcp->mb[11] = LSW(ha->ex_init_cb_dma); |
| 1246 | mcp->mb[12] = MSW(MSD(ha->ex_init_cb_dma)); |
| 1247 | mcp->mb[13] = LSW(MSD(ha->ex_init_cb_dma)); |
| 1248 | mcp->mb[14] = sizeof(*ha->ex_init_cb); |
| 1249 | mcp->out_mb |= MBX_14|MBX_13|MBX_12|MBX_11|MBX_10; |
| 1250 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1251 | /* 1 and 2 should normally be captured. */ |
| 1252 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 1253 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1254 | /* mb3 is additional info about the installed SFP. */ |
| 1255 | mcp->in_mb |= MBX_3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1256 | mcp->buf_size = size; |
| 1257 | mcp->flags = MBX_DMA_OUT; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1258 | mcp->tov = MBX_TOV_SECONDS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1259 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1260 | |
| 1261 | if (rval != QLA_SUCCESS) { |
| 1262 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1263 | ql_dbg(ql_dbg_mbx, vha, 0x104d, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1264 | "Failed=%x mb[0]=%x, mb[1]=%x, mb[2]=%x, mb[3]=%x,.\n", |
| 1265 | 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] | 1266 | } else { |
| 1267 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1268 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104e, |
| 1269 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1270 | } |
| 1271 | |
| 1272 | return rval; |
| 1273 | } |
| 1274 | |
| 1275 | /* |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 1276 | * qla2x00_get_node_name_list |
| 1277 | * Issue get node name list mailbox command, kmalloc() |
| 1278 | * and return the resulting list. Caller must kfree() it! |
| 1279 | * |
| 1280 | * Input: |
| 1281 | * ha = adapter state pointer. |
| 1282 | * out_data = resulting list |
| 1283 | * out_len = length of the resulting list |
| 1284 | * |
| 1285 | * Returns: |
| 1286 | * qla2x00 local function return status code. |
| 1287 | * |
| 1288 | * Context: |
| 1289 | * Kernel context. |
| 1290 | */ |
| 1291 | int |
| 1292 | qla2x00_get_node_name_list(scsi_qla_host_t *vha, void **out_data, int *out_len) |
| 1293 | { |
| 1294 | struct qla_hw_data *ha = vha->hw; |
| 1295 | struct qla_port_24xx_data *list = NULL; |
| 1296 | void *pmap; |
| 1297 | mbx_cmd_t mc; |
| 1298 | dma_addr_t pmap_dma; |
| 1299 | ulong dma_size; |
| 1300 | int rval, left; |
| 1301 | |
| 1302 | left = 1; |
| 1303 | while (left > 0) { |
| 1304 | dma_size = left * sizeof(*list); |
| 1305 | pmap = dma_alloc_coherent(&ha->pdev->dev, dma_size, |
| 1306 | &pmap_dma, GFP_KERNEL); |
| 1307 | if (!pmap) { |
| 1308 | ql_log(ql_log_warn, vha, 0x113f, |
| 1309 | "%s(%ld): DMA Alloc failed of %ld\n", |
| 1310 | __func__, vha->host_no, dma_size); |
| 1311 | rval = QLA_MEMORY_ALLOC_FAILED; |
| 1312 | goto out; |
| 1313 | } |
| 1314 | |
| 1315 | mc.mb[0] = MBC_PORT_NODE_NAME_LIST; |
| 1316 | mc.mb[1] = BIT_1 | BIT_3; |
| 1317 | mc.mb[2] = MSW(pmap_dma); |
| 1318 | mc.mb[3] = LSW(pmap_dma); |
| 1319 | mc.mb[6] = MSW(MSD(pmap_dma)); |
| 1320 | mc.mb[7] = LSW(MSD(pmap_dma)); |
| 1321 | mc.mb[8] = dma_size; |
| 1322 | mc.out_mb = MBX_0|MBX_1|MBX_2|MBX_3|MBX_6|MBX_7|MBX_8; |
| 1323 | mc.in_mb = MBX_0|MBX_1; |
| 1324 | mc.tov = 30; |
| 1325 | mc.flags = MBX_DMA_IN; |
| 1326 | |
| 1327 | rval = qla2x00_mailbox_command(vha, &mc); |
| 1328 | if (rval != QLA_SUCCESS) { |
| 1329 | if ((mc.mb[0] == MBS_COMMAND_ERROR) && |
| 1330 | (mc.mb[1] == 0xA)) { |
| 1331 | left += le16_to_cpu(mc.mb[2]) / |
| 1332 | sizeof(struct qla_port_24xx_data); |
| 1333 | goto restart; |
| 1334 | } |
| 1335 | goto out_free; |
| 1336 | } |
| 1337 | |
| 1338 | left = 0; |
| 1339 | |
Benoit Taine | c1818f1 | 2014-05-26 17:21:16 +0200 | [diff] [blame] | 1340 | list = kmemdup(pmap, dma_size, GFP_KERNEL); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 1341 | if (!list) { |
| 1342 | ql_log(ql_log_warn, vha, 0x1140, |
| 1343 | "%s(%ld): failed to allocate node names list " |
| 1344 | "structure.\n", __func__, vha->host_no); |
| 1345 | rval = QLA_MEMORY_ALLOC_FAILED; |
| 1346 | goto out_free; |
| 1347 | } |
| 1348 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 1349 | restart: |
| 1350 | dma_free_coherent(&ha->pdev->dev, dma_size, pmap, pmap_dma); |
| 1351 | } |
| 1352 | |
| 1353 | *out_data = list; |
| 1354 | *out_len = dma_size; |
| 1355 | |
| 1356 | out: |
| 1357 | return rval; |
| 1358 | |
| 1359 | out_free: |
| 1360 | dma_free_coherent(&ha->pdev->dev, dma_size, pmap, pmap_dma); |
| 1361 | return rval; |
| 1362 | } |
| 1363 | |
| 1364 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1365 | * qla2x00_get_port_database |
| 1366 | * Issue normal/enhanced get port database mailbox command |
| 1367 | * and copy device name as necessary. |
| 1368 | * |
| 1369 | * Input: |
| 1370 | * ha = adapter state pointer. |
| 1371 | * dev = structure pointer. |
| 1372 | * opt = enhanced cmd option byte. |
| 1373 | * |
| 1374 | * Returns: |
| 1375 | * qla2x00 local function return status code. |
| 1376 | * |
| 1377 | * Context: |
| 1378 | * Kernel context. |
| 1379 | */ |
| 1380 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1381 | 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] | 1382 | { |
| 1383 | int rval; |
| 1384 | mbx_cmd_t mc; |
| 1385 | mbx_cmd_t *mcp = &mc; |
| 1386 | port_database_t *pd; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1387 | struct port_database_24xx *pd24; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1388 | dma_addr_t pd_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1389 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1390 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1391 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x104f, |
| 1392 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1393 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1394 | pd24 = NULL; |
| 1395 | pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1396 | if (pd == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1397 | ql_log(ql_log_warn, vha, 0x1050, |
| 1398 | "Failed to allocate port database structure.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1399 | return QLA_MEMORY_ALLOC_FAILED; |
| 1400 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1401 | memset(pd, 0, max(PORT_DATABASE_SIZE, PORT_DATABASE_24XX_SIZE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1402 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1403 | mcp->mb[0] = MBC_GET_PORT_DATABASE; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1404 | if (opt != 0 && !IS_FWI2_CAPABLE(ha)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1405 | mcp->mb[0] = MBC_ENHANCED_GET_PORT_DATABASE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1406 | mcp->mb[2] = MSW(pd_dma); |
| 1407 | mcp->mb[3] = LSW(pd_dma); |
| 1408 | mcp->mb[6] = MSW(MSD(pd_dma)); |
| 1409 | mcp->mb[7] = LSW(MSD(pd_dma)); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1410 | mcp->mb[9] = vha->vp_idx; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1411 | 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] | 1412 | mcp->in_mb = MBX_0; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1413 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1414 | mcp->mb[1] = fcport->loop_id; |
| 1415 | mcp->mb[10] = opt; |
| 1416 | mcp->out_mb |= MBX_10|MBX_1; |
| 1417 | mcp->in_mb |= MBX_1; |
| 1418 | } else if (HAS_EXTENDED_IDS(ha)) { |
| 1419 | mcp->mb[1] = fcport->loop_id; |
| 1420 | mcp->mb[10] = opt; |
| 1421 | mcp->out_mb |= MBX_10|MBX_1; |
| 1422 | } else { |
| 1423 | mcp->mb[1] = fcport->loop_id << 8 | opt; |
| 1424 | mcp->out_mb |= MBX_1; |
| 1425 | } |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1426 | mcp->buf_size = IS_FWI2_CAPABLE(ha) ? |
| 1427 | PORT_DATABASE_24XX_SIZE : PORT_DATABASE_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1428 | mcp->flags = MBX_DMA_IN; |
| 1429 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1430 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1431 | if (rval != QLA_SUCCESS) |
| 1432 | goto gpd_error_out; |
| 1433 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1434 | if (IS_FWI2_CAPABLE(ha)) { |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1435 | uint64_t zero = 0; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1436 | pd24 = (struct port_database_24xx *) pd; |
| 1437 | |
| 1438 | /* Check for logged in state. */ |
| 1439 | if (pd24->current_login_state != PDS_PRLI_COMPLETE && |
| 1440 | pd24->last_login_state != PDS_PRLI_COMPLETE) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1441 | ql_dbg(ql_dbg_mbx, vha, 0x1051, |
| 1442 | "Unable to verify login-state (%x/%x) for " |
| 1443 | "loop_id %x.\n", pd24->current_login_state, |
| 1444 | pd24->last_login_state, fcport->loop_id); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1445 | rval = QLA_FUNCTION_FAILED; |
| 1446 | goto gpd_error_out; |
| 1447 | } |
| 1448 | |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1449 | if (fcport->loop_id == FC_NO_LOOP_ID || |
| 1450 | (memcmp(fcport->port_name, (uint8_t *)&zero, 8) && |
| 1451 | memcmp(fcport->port_name, pd24->port_name, 8))) { |
| 1452 | /* We lost the device mid way. */ |
| 1453 | rval = QLA_NOT_LOGGED_IN; |
| 1454 | goto gpd_error_out; |
| 1455 | } |
| 1456 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1457 | /* Names are little-endian. */ |
| 1458 | memcpy(fcport->node_name, pd24->node_name, WWN_SIZE); |
| 1459 | memcpy(fcport->port_name, pd24->port_name, WWN_SIZE); |
| 1460 | |
| 1461 | /* Get port_id of device. */ |
| 1462 | fcport->d_id.b.domain = pd24->port_id[0]; |
| 1463 | fcport->d_id.b.area = pd24->port_id[1]; |
| 1464 | fcport->d_id.b.al_pa = pd24->port_id[2]; |
| 1465 | fcport->d_id.b.rsvd_1 = 0; |
| 1466 | |
| 1467 | /* If not target must be initiator or unknown type. */ |
| 1468 | if ((pd24->prli_svc_param_word_3[0] & BIT_4) == 0) |
| 1469 | fcport->port_type = FCT_INITIATOR; |
| 1470 | else |
| 1471 | fcport->port_type = FCT_TARGET; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 1472 | |
| 1473 | /* Passback COS information. */ |
| 1474 | fcport->supported_classes = (pd24->flags & PDF_CLASS_2) ? |
| 1475 | FC_COS_CLASS2 : FC_COS_CLASS3; |
| 1476 | |
| 1477 | if (pd24->prli_svc_param_word_3[0] & BIT_7) |
| 1478 | fcport->flags |= FCF_CONF_COMP_SUPPORTED; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1479 | } else { |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1480 | uint64_t zero = 0; |
| 1481 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1482 | /* Check for logged in state. */ |
| 1483 | if (pd->master_state != PD_STATE_PORT_LOGGED_IN && |
| 1484 | pd->slave_state != PD_STATE_PORT_LOGGED_IN) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1485 | ql_dbg(ql_dbg_mbx, vha, 0x100a, |
| 1486 | "Unable to verify login-state (%x/%x) - " |
| 1487 | "portid=%02x%02x%02x.\n", pd->master_state, |
| 1488 | pd->slave_state, fcport->d_id.b.domain, |
| 1489 | fcport->d_id.b.area, fcport->d_id.b.al_pa); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1490 | rval = QLA_FUNCTION_FAILED; |
| 1491 | goto gpd_error_out; |
| 1492 | } |
| 1493 | |
Arun Easi | 0eba25d | 2012-02-09 11:15:58 -0800 | [diff] [blame] | 1494 | if (fcport->loop_id == FC_NO_LOOP_ID || |
| 1495 | (memcmp(fcport->port_name, (uint8_t *)&zero, 8) && |
| 1496 | memcmp(fcport->port_name, pd->port_name, 8))) { |
| 1497 | /* We lost the device mid way. */ |
| 1498 | rval = QLA_NOT_LOGGED_IN; |
| 1499 | goto gpd_error_out; |
| 1500 | } |
| 1501 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1502 | /* Names are little-endian. */ |
| 1503 | memcpy(fcport->node_name, pd->node_name, WWN_SIZE); |
| 1504 | memcpy(fcport->port_name, pd->port_name, WWN_SIZE); |
| 1505 | |
| 1506 | /* Get port_id of device. */ |
| 1507 | fcport->d_id.b.domain = pd->port_id[0]; |
| 1508 | fcport->d_id.b.area = pd->port_id[3]; |
| 1509 | fcport->d_id.b.al_pa = pd->port_id[2]; |
| 1510 | fcport->d_id.b.rsvd_1 = 0; |
| 1511 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1512 | /* If not target must be initiator or unknown type. */ |
| 1513 | if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0) |
| 1514 | fcport->port_type = FCT_INITIATOR; |
| 1515 | else |
| 1516 | fcport->port_type = FCT_TARGET; |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 1517 | |
| 1518 | /* Passback COS information. */ |
| 1519 | fcport->supported_classes = (pd->options & BIT_4) ? |
| 1520 | FC_COS_CLASS2: FC_COS_CLASS3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1521 | } |
| 1522 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1523 | gpd_error_out: |
| 1524 | dma_pool_free(ha->s_dma_pool, pd, pd_dma); |
| 1525 | |
| 1526 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1527 | ql_dbg(ql_dbg_mbx, vha, 0x1052, |
| 1528 | "Failed=%x mb[0]=%x mb[1]=%x.\n", rval, |
| 1529 | mcp->mb[0], mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1530 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1531 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1053, |
| 1532 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1533 | } |
| 1534 | |
| 1535 | return rval; |
| 1536 | } |
| 1537 | |
| 1538 | /* |
| 1539 | * qla2x00_get_firmware_state |
| 1540 | * Get adapter firmware state. |
| 1541 | * |
| 1542 | * Input: |
| 1543 | * ha = adapter block pointer. |
| 1544 | * dptr = pointer for firmware state. |
| 1545 | * TARGET_QUEUE_LOCK must be released. |
| 1546 | * ADAPTER_STATE_LOCK must be released. |
| 1547 | * |
| 1548 | * Returns: |
| 1549 | * qla2x00 local function return status code. |
| 1550 | * |
| 1551 | * Context: |
| 1552 | * Kernel context. |
| 1553 | */ |
| 1554 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1555 | qla2x00_get_firmware_state(scsi_qla_host_t *vha, uint16_t *states) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1556 | { |
| 1557 | int rval; |
| 1558 | mbx_cmd_t mc; |
| 1559 | mbx_cmd_t *mcp = &mc; |
| 1560 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1561 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1054, |
| 1562 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1563 | |
| 1564 | mcp->mb[0] = MBC_GET_FIRMWARE_STATE; |
| 1565 | mcp->out_mb = MBX_0; |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 1566 | if (IS_FWI2_CAPABLE(vha->hw)) |
Joe Carnuccio | b5a340d | 2014-09-25 05:16:48 -0400 | [diff] [blame] | 1567 | 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] | 1568 | else |
| 1569 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1570 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1571 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1572 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1573 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1574 | /* Return firmware states. */ |
| 1575 | states[0] = mcp->mb[1]; |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 1576 | if (IS_FWI2_CAPABLE(vha->hw)) { |
| 1577 | states[1] = mcp->mb[2]; |
| 1578 | states[2] = mcp->mb[3]; |
| 1579 | states[3] = mcp->mb[4]; |
| 1580 | states[4] = mcp->mb[5]; |
Joe Carnuccio | b5a340d | 2014-09-25 05:16:48 -0400 | [diff] [blame] | 1581 | states[5] = mcp->mb[6]; /* DPORT status */ |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 1582 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1583 | |
| 1584 | if (rval != QLA_SUCCESS) { |
| 1585 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1586 | ql_dbg(ql_dbg_mbx, vha, 0x1055, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1587 | } else { |
| 1588 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1589 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1056, |
| 1590 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1591 | } |
| 1592 | |
| 1593 | return rval; |
| 1594 | } |
| 1595 | |
| 1596 | /* |
| 1597 | * qla2x00_get_port_name |
| 1598 | * Issue get port name mailbox command. |
| 1599 | * Returned name is in big endian format. |
| 1600 | * |
| 1601 | * Input: |
| 1602 | * ha = adapter block pointer. |
| 1603 | * loop_id = loop ID of device. |
| 1604 | * name = pointer for name. |
| 1605 | * TARGET_QUEUE_LOCK must be released. |
| 1606 | * ADAPTER_STATE_LOCK must be released. |
| 1607 | * |
| 1608 | * Returns: |
| 1609 | * qla2x00 local function return status code. |
| 1610 | * |
| 1611 | * Context: |
| 1612 | * Kernel context. |
| 1613 | */ |
| 1614 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1615 | 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] | 1616 | uint8_t opt) |
| 1617 | { |
| 1618 | int rval; |
| 1619 | mbx_cmd_t mc; |
| 1620 | mbx_cmd_t *mcp = &mc; |
| 1621 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1622 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1057, |
| 1623 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1624 | |
| 1625 | mcp->mb[0] = MBC_GET_PORT_NAME; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1626 | mcp->mb[9] = vha->vp_idx; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1627 | mcp->out_mb = MBX_9|MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1628 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1629 | mcp->mb[1] = loop_id; |
| 1630 | mcp->mb[10] = opt; |
| 1631 | mcp->out_mb |= MBX_10; |
| 1632 | } else { |
| 1633 | mcp->mb[1] = loop_id << 8 | opt; |
| 1634 | } |
| 1635 | |
| 1636 | 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] | 1637 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1638 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1639 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1640 | |
| 1641 | if (rval != QLA_SUCCESS) { |
| 1642 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1643 | ql_dbg(ql_dbg_mbx, vha, 0x1058, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1644 | } else { |
| 1645 | if (name != NULL) { |
| 1646 | /* This function returns name in big endian. */ |
Richard Lary | 1196ae0 | 2007-03-22 10:53:19 -0500 | [diff] [blame] | 1647 | name[0] = MSB(mcp->mb[2]); |
| 1648 | name[1] = LSB(mcp->mb[2]); |
| 1649 | name[2] = MSB(mcp->mb[3]); |
| 1650 | name[3] = LSB(mcp->mb[3]); |
| 1651 | name[4] = MSB(mcp->mb[6]); |
| 1652 | name[5] = LSB(mcp->mb[6]); |
| 1653 | name[6] = MSB(mcp->mb[7]); |
| 1654 | name[7] = LSB(mcp->mb[7]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1655 | } |
| 1656 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1657 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1059, |
| 1658 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1659 | } |
| 1660 | |
| 1661 | return rval; |
| 1662 | } |
| 1663 | |
| 1664 | /* |
Joe Carnuccio | 61e1b26 | 2013-02-08 01:57:48 -0500 | [diff] [blame] | 1665 | * qla24xx_link_initialization |
| 1666 | * Issue link initialization mailbox command. |
| 1667 | * |
| 1668 | * Input: |
| 1669 | * ha = adapter block pointer. |
| 1670 | * TARGET_QUEUE_LOCK must be released. |
| 1671 | * ADAPTER_STATE_LOCK must be released. |
| 1672 | * |
| 1673 | * Returns: |
| 1674 | * qla2x00 local function return status code. |
| 1675 | * |
| 1676 | * Context: |
| 1677 | * Kernel context. |
| 1678 | */ |
| 1679 | int |
| 1680 | qla24xx_link_initialize(scsi_qla_host_t *vha) |
| 1681 | { |
| 1682 | int rval; |
| 1683 | mbx_cmd_t mc; |
| 1684 | mbx_cmd_t *mcp = &mc; |
| 1685 | |
| 1686 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1152, |
| 1687 | "Entered %s.\n", __func__); |
| 1688 | |
| 1689 | if (!IS_FWI2_CAPABLE(vha->hw) || IS_CNA_CAPABLE(vha->hw)) |
| 1690 | return QLA_FUNCTION_FAILED; |
| 1691 | |
| 1692 | mcp->mb[0] = MBC_LINK_INITIALIZATION; |
Joe Carnuccio | 5a5c27b | 2013-08-27 01:37:49 -0400 | [diff] [blame] | 1693 | mcp->mb[1] = BIT_4; |
| 1694 | if (vha->hw->operating_mode == LOOP) |
| 1695 | mcp->mb[1] |= BIT_6; |
| 1696 | else |
| 1697 | mcp->mb[1] |= BIT_5; |
Joe Carnuccio | 61e1b26 | 2013-02-08 01:57:48 -0500 | [diff] [blame] | 1698 | mcp->mb[2] = 0; |
| 1699 | mcp->mb[3] = 0; |
| 1700 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 1701 | mcp->in_mb = MBX_0; |
| 1702 | mcp->tov = MBX_TOV_SECONDS; |
| 1703 | mcp->flags = 0; |
| 1704 | rval = qla2x00_mailbox_command(vha, mcp); |
| 1705 | |
| 1706 | if (rval != QLA_SUCCESS) { |
| 1707 | ql_dbg(ql_dbg_mbx, vha, 0x1153, "Failed=%x.\n", rval); |
| 1708 | } else { |
| 1709 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1154, |
| 1710 | "Done %s.\n", __func__); |
| 1711 | } |
| 1712 | |
| 1713 | return rval; |
| 1714 | } |
| 1715 | |
| 1716 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1717 | * qla2x00_lip_reset |
| 1718 | * Issue LIP reset mailbox command. |
| 1719 | * |
| 1720 | * Input: |
| 1721 | * ha = adapter block pointer. |
| 1722 | * TARGET_QUEUE_LOCK must be released. |
| 1723 | * ADAPTER_STATE_LOCK must be released. |
| 1724 | * |
| 1725 | * Returns: |
| 1726 | * qla2x00 local function return status code. |
| 1727 | * |
| 1728 | * Context: |
| 1729 | * Kernel context. |
| 1730 | */ |
| 1731 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1732 | qla2x00_lip_reset(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1733 | { |
| 1734 | int rval; |
| 1735 | mbx_cmd_t mc; |
| 1736 | mbx_cmd_t *mcp = &mc; |
| 1737 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1738 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105a, |
| 1739 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1740 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1741 | if (IS_CNA_CAPABLE(vha->hw)) { |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1742 | /* Logout across all FCFs. */ |
| 1743 | mcp->mb[0] = MBC_LIP_FULL_LOGIN; |
| 1744 | mcp->mb[1] = BIT_1; |
| 1745 | mcp->mb[2] = 0; |
| 1746 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 1747 | } else if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1748 | mcp->mb[0] = MBC_LIP_FULL_LOGIN; |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1749 | mcp->mb[1] = BIT_6; |
| 1750 | mcp->mb[2] = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1751 | mcp->mb[3] = vha->hw->loop_reset_delay; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1752 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1753 | } else { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1754 | mcp->mb[0] = MBC_LIP_RESET; |
| 1755 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1756 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1757 | mcp->mb[1] = 0x00ff; |
| 1758 | mcp->mb[10] = 0; |
| 1759 | mcp->out_mb |= MBX_10; |
| 1760 | } else { |
| 1761 | mcp->mb[1] = 0xff00; |
| 1762 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1763 | mcp->mb[2] = vha->hw->loop_reset_delay; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1764 | mcp->mb[3] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1765 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1766 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1767 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1768 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1769 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1770 | |
| 1771 | if (rval != QLA_SUCCESS) { |
| 1772 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1773 | ql_dbg(ql_dbg_mbx, vha, 0x105b, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1774 | } else { |
| 1775 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1776 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105c, |
| 1777 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1778 | } |
| 1779 | |
| 1780 | return rval; |
| 1781 | } |
| 1782 | |
| 1783 | /* |
| 1784 | * qla2x00_send_sns |
| 1785 | * Send SNS command. |
| 1786 | * |
| 1787 | * Input: |
| 1788 | * ha = adapter block pointer. |
| 1789 | * sns = pointer for command. |
| 1790 | * cmd_size = command size. |
| 1791 | * buf_size = response/command size. |
| 1792 | * TARGET_QUEUE_LOCK must be released. |
| 1793 | * ADAPTER_STATE_LOCK must be released. |
| 1794 | * |
| 1795 | * Returns: |
| 1796 | * qla2x00 local function return status code. |
| 1797 | * |
| 1798 | * Context: |
| 1799 | * Kernel context. |
| 1800 | */ |
| 1801 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1802 | 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] | 1803 | uint16_t cmd_size, size_t buf_size) |
| 1804 | { |
| 1805 | int rval; |
| 1806 | mbx_cmd_t mc; |
| 1807 | mbx_cmd_t *mcp = &mc; |
| 1808 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1809 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105d, |
| 1810 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1811 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1812 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105e, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1813 | "Retry cnt=%d ratov=%d total tov=%d.\n", |
| 1814 | vha->hw->retry_count, vha->hw->login_timeout, mcp->tov); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1815 | |
| 1816 | mcp->mb[0] = MBC_SEND_SNS_COMMAND; |
| 1817 | mcp->mb[1] = cmd_size; |
| 1818 | mcp->mb[2] = MSW(sns_phys_address); |
| 1819 | mcp->mb[3] = LSW(sns_phys_address); |
| 1820 | mcp->mb[6] = MSW(MSD(sns_phys_address)); |
| 1821 | mcp->mb[7] = LSW(MSD(sns_phys_address)); |
| 1822 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 1823 | mcp->in_mb = MBX_0|MBX_1; |
| 1824 | mcp->buf_size = buf_size; |
| 1825 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1826 | mcp->tov = (vha->hw->login_timeout * 2) + (vha->hw->login_timeout / 2); |
| 1827 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1828 | |
| 1829 | if (rval != QLA_SUCCESS) { |
| 1830 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1831 | ql_dbg(ql_dbg_mbx, vha, 0x105f, |
| 1832 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 1833 | rval, mcp->mb[0], mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1834 | } else { |
| 1835 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1836 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1060, |
| 1837 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1838 | } |
| 1839 | |
| 1840 | return rval; |
| 1841 | } |
| 1842 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1843 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1844 | 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] | 1845 | uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt) |
| 1846 | { |
| 1847 | int rval; |
| 1848 | |
| 1849 | struct logio_entry_24xx *lg; |
| 1850 | dma_addr_t lg_dma; |
| 1851 | uint32_t iop[2]; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1852 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1853 | struct req_que *req; |
| 1854 | struct rsp_que *rsp; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1855 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1856 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1061, |
| 1857 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1858 | |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 1859 | if (ha->flags.cpu_affinity_enabled) |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 1860 | req = ha->req_q_map[0]; |
| 1861 | else |
| 1862 | req = vha->req; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1863 | rsp = req->rsp; |
| 1864 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1865 | lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); |
| 1866 | if (lg == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1867 | ql_log(ql_log_warn, vha, 0x1062, |
| 1868 | "Failed to allocate login IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1869 | return QLA_MEMORY_ALLOC_FAILED; |
| 1870 | } |
| 1871 | memset(lg, 0, sizeof(struct logio_entry_24xx)); |
| 1872 | |
| 1873 | lg->entry_type = LOGINOUT_PORT_IOCB_TYPE; |
| 1874 | lg->entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1875 | lg->handle = MAKE_HANDLE(req->id, lg->handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1876 | lg->nport_handle = cpu_to_le16(loop_id); |
| 1877 | lg->control_flags = __constant_cpu_to_le16(LCF_COMMAND_PLOGI); |
| 1878 | if (opt & BIT_0) |
| 1879 | lg->control_flags |= __constant_cpu_to_le16(LCF_COND_PLOGI); |
Andrew Vasquez | 8baa51a | 2006-06-23 16:10:44 -0700 | [diff] [blame] | 1880 | if (opt & BIT_1) |
| 1881 | lg->control_flags |= __constant_cpu_to_le16(LCF_SKIP_PRLI); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1882 | lg->port_id[0] = al_pa; |
| 1883 | lg->port_id[1] = area; |
| 1884 | lg->port_id[2] = domain; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1885 | lg->vp_index = vha->vp_idx; |
Andrew Vasquez | 7f45dd0 | 2012-02-09 11:15:45 -0800 | [diff] [blame] | 1886 | rval = qla2x00_issue_iocb_timeout(vha, lg, lg_dma, 0, |
| 1887 | (ha->r_a_tov / 10 * 2) + 2); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1888 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1889 | ql_dbg(ql_dbg_mbx, vha, 0x1063, |
| 1890 | "Failed to issue login IOCB (%x).\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1891 | } else if (lg->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1892 | ql_dbg(ql_dbg_mbx, vha, 0x1064, |
| 1893 | "Failed to complete IOCB -- error status (%x).\n", |
| 1894 | lg->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1895 | rval = QLA_FUNCTION_FAILED; |
| 1896 | } else if (lg->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) { |
| 1897 | iop[0] = le32_to_cpu(lg->io_parameter[0]); |
| 1898 | iop[1] = le32_to_cpu(lg->io_parameter[1]); |
| 1899 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1900 | ql_dbg(ql_dbg_mbx, vha, 0x1065, |
| 1901 | "Failed to complete IOCB -- completion status (%x) " |
| 1902 | "ioparam=%x/%x.\n", le16_to_cpu(lg->comp_status), |
| 1903 | iop[0], iop[1]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1904 | |
| 1905 | switch (iop[0]) { |
| 1906 | case LSC_SCODE_PORTID_USED: |
| 1907 | mb[0] = MBS_PORT_ID_USED; |
| 1908 | mb[1] = LSW(iop[1]); |
| 1909 | break; |
| 1910 | case LSC_SCODE_NPORT_USED: |
| 1911 | mb[0] = MBS_LOOP_ID_USED; |
| 1912 | break; |
| 1913 | case LSC_SCODE_NOLINK: |
| 1914 | case LSC_SCODE_NOIOCB: |
| 1915 | case LSC_SCODE_NOXCB: |
| 1916 | case LSC_SCODE_CMD_FAILED: |
| 1917 | case LSC_SCODE_NOFABRIC: |
| 1918 | case LSC_SCODE_FW_NOT_READY: |
| 1919 | case LSC_SCODE_NOT_LOGGED_IN: |
| 1920 | case LSC_SCODE_NOPCB: |
| 1921 | case LSC_SCODE_ELS_REJECT: |
| 1922 | case LSC_SCODE_CMD_PARAM_ERR: |
| 1923 | case LSC_SCODE_NONPORT: |
| 1924 | case LSC_SCODE_LOGGED_IN: |
| 1925 | case LSC_SCODE_NOFLOGI_ACC: |
| 1926 | default: |
| 1927 | mb[0] = MBS_COMMAND_ERROR; |
| 1928 | break; |
| 1929 | } |
| 1930 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1931 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1066, |
| 1932 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1933 | |
| 1934 | iop[0] = le32_to_cpu(lg->io_parameter[0]); |
| 1935 | |
| 1936 | mb[0] = MBS_COMMAND_COMPLETE; |
| 1937 | mb[1] = 0; |
| 1938 | if (iop[0] & BIT_4) { |
| 1939 | if (iop[0] & BIT_8) |
| 1940 | mb[1] |= BIT_1; |
| 1941 | } else |
| 1942 | mb[1] = BIT_0; |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 1943 | |
| 1944 | /* Passback COS information. */ |
| 1945 | mb[10] = 0; |
| 1946 | if (lg->io_parameter[7] || lg->io_parameter[8]) |
| 1947 | mb[10] |= BIT_0; /* Class 2. */ |
| 1948 | if (lg->io_parameter[9] || lg->io_parameter[10]) |
| 1949 | mb[10] |= BIT_1; /* Class 3. */ |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 1950 | if (lg->io_parameter[0] & __constant_cpu_to_le32(BIT_7)) |
| 1951 | mb[10] |= BIT_7; /* Confirmed Completion |
| 1952 | * Allowed |
| 1953 | */ |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1954 | } |
| 1955 | |
| 1956 | dma_pool_free(ha->s_dma_pool, lg, lg_dma); |
| 1957 | |
| 1958 | return rval; |
| 1959 | } |
| 1960 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1961 | /* |
| 1962 | * qla2x00_login_fabric |
| 1963 | * Issue login fabric port mailbox command. |
| 1964 | * |
| 1965 | * Input: |
| 1966 | * ha = adapter block pointer. |
| 1967 | * loop_id = device loop ID. |
| 1968 | * domain = device domain. |
| 1969 | * area = device area. |
| 1970 | * al_pa = device AL_PA. |
| 1971 | * status = pointer for return status. |
| 1972 | * opt = command options. |
| 1973 | * TARGET_QUEUE_LOCK must be released. |
| 1974 | * ADAPTER_STATE_LOCK must be released. |
| 1975 | * |
| 1976 | * Returns: |
| 1977 | * qla2x00 local function return status code. |
| 1978 | * |
| 1979 | * Context: |
| 1980 | * Kernel context. |
| 1981 | */ |
| 1982 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1983 | 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] | 1984 | uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt) |
| 1985 | { |
| 1986 | int rval; |
| 1987 | mbx_cmd_t mc; |
| 1988 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1989 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1990 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 1991 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1067, |
| 1992 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1993 | |
| 1994 | mcp->mb[0] = MBC_LOGIN_FABRIC_PORT; |
| 1995 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 1996 | if (HAS_EXTENDED_IDS(ha)) { |
| 1997 | mcp->mb[1] = loop_id; |
| 1998 | mcp->mb[10] = opt; |
| 1999 | mcp->out_mb |= MBX_10; |
| 2000 | } else { |
| 2001 | mcp->mb[1] = (loop_id << 8) | opt; |
| 2002 | } |
| 2003 | mcp->mb[2] = domain; |
| 2004 | mcp->mb[3] = area << 8 | al_pa; |
| 2005 | |
| 2006 | mcp->in_mb = MBX_7|MBX_6|MBX_2|MBX_1|MBX_0; |
| 2007 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
| 2008 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2009 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2010 | |
| 2011 | /* Return mailbox statuses. */ |
| 2012 | if (mb != NULL) { |
| 2013 | mb[0] = mcp->mb[0]; |
| 2014 | mb[1] = mcp->mb[1]; |
| 2015 | mb[2] = mcp->mb[2]; |
| 2016 | mb[6] = mcp->mb[6]; |
| 2017 | mb[7] = mcp->mb[7]; |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 2018 | /* COS retrieved from Get-Port-Database mailbox command. */ |
| 2019 | mb[10] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2020 | } |
| 2021 | |
| 2022 | if (rval != QLA_SUCCESS) { |
| 2023 | /* RLU tmp code: need to change main mailbox_command function to |
| 2024 | * return ok even when the mailbox completion value is not |
| 2025 | * SUCCESS. The caller needs to be responsible to interpret |
| 2026 | * the return values of this mailbox command if we're not |
| 2027 | * to change too much of the existing code. |
| 2028 | */ |
| 2029 | if (mcp->mb[0] == 0x4001 || mcp->mb[0] == 0x4002 || |
| 2030 | mcp->mb[0] == 0x4003 || mcp->mb[0] == 0x4005 || |
| 2031 | mcp->mb[0] == 0x4006) |
| 2032 | rval = QLA_SUCCESS; |
| 2033 | |
| 2034 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2035 | ql_dbg(ql_dbg_mbx, vha, 0x1068, |
| 2036 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 2037 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2038 | } else { |
| 2039 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2040 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1069, |
| 2041 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2042 | } |
| 2043 | |
| 2044 | return rval; |
| 2045 | } |
| 2046 | |
| 2047 | /* |
| 2048 | * qla2x00_login_local_device |
| 2049 | * Issue login loop port mailbox command. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2050 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2051 | * Input: |
| 2052 | * ha = adapter block pointer. |
| 2053 | * loop_id = device loop ID. |
| 2054 | * opt = command options. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2055 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2056 | * Returns: |
| 2057 | * Return status code. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2058 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2059 | * Context: |
| 2060 | * Kernel context. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2061 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2062 | */ |
| 2063 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2064 | 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] | 2065 | uint16_t *mb_ret, uint8_t opt) |
| 2066 | { |
| 2067 | int rval; |
| 2068 | mbx_cmd_t mc; |
| 2069 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2070 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2071 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2072 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106a, |
| 2073 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2074 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2075 | if (IS_FWI2_CAPABLE(ha)) |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2076 | return qla24xx_login_fabric(vha, fcport->loop_id, |
andrew.vasquez@qlogic.com | 9a52a57c | 2006-03-09 14:27:44 -0800 | [diff] [blame] | 2077 | fcport->d_id.b.domain, fcport->d_id.b.area, |
| 2078 | fcport->d_id.b.al_pa, mb_ret, opt); |
| 2079 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2080 | mcp->mb[0] = MBC_LOGIN_LOOP_PORT; |
| 2081 | if (HAS_EXTENDED_IDS(ha)) |
andrew.vasquez@qlogic.com | 9a52a57c | 2006-03-09 14:27:44 -0800 | [diff] [blame] | 2082 | mcp->mb[1] = fcport->loop_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2083 | else |
andrew.vasquez@qlogic.com | 9a52a57c | 2006-03-09 14:27:44 -0800 | [diff] [blame] | 2084 | mcp->mb[1] = fcport->loop_id << 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2085 | mcp->mb[2] = opt; |
| 2086 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 2087 | mcp->in_mb = MBX_7|MBX_6|MBX_1|MBX_0; |
| 2088 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
| 2089 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2090 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2091 | |
| 2092 | /* Return mailbox statuses. */ |
| 2093 | if (mb_ret != NULL) { |
| 2094 | mb_ret[0] = mcp->mb[0]; |
| 2095 | mb_ret[1] = mcp->mb[1]; |
| 2096 | mb_ret[6] = mcp->mb[6]; |
| 2097 | mb_ret[7] = mcp->mb[7]; |
| 2098 | } |
| 2099 | |
| 2100 | if (rval != QLA_SUCCESS) { |
| 2101 | /* AV tmp code: need to change main mailbox_command function to |
| 2102 | * return ok even when the mailbox completion value is not |
| 2103 | * SUCCESS. The caller needs to be responsible to interpret |
| 2104 | * the return values of this mailbox command if we're not |
| 2105 | * to change too much of the existing code. |
| 2106 | */ |
| 2107 | if (mcp->mb[0] == 0x4005 || mcp->mb[0] == 0x4006) |
| 2108 | rval = QLA_SUCCESS; |
| 2109 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2110 | ql_dbg(ql_dbg_mbx, vha, 0x106b, |
| 2111 | "Failed=%x mb[0]=%x mb[1]=%x mb[6]=%x mb[7]=%x.\n", |
| 2112 | 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] | 2113 | } else { |
| 2114 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2115 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106c, |
| 2116 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2117 | } |
| 2118 | |
| 2119 | return (rval); |
| 2120 | } |
| 2121 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2122 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2123 | 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] | 2124 | uint8_t area, uint8_t al_pa) |
| 2125 | { |
| 2126 | int rval; |
| 2127 | struct logio_entry_24xx *lg; |
| 2128 | dma_addr_t lg_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2129 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2130 | struct req_que *req; |
| 2131 | struct rsp_que *rsp; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2132 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2133 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106d, |
| 2134 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2135 | |
| 2136 | lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); |
| 2137 | if (lg == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2138 | ql_log(ql_log_warn, vha, 0x106e, |
| 2139 | "Failed to allocate logout IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2140 | return QLA_MEMORY_ALLOC_FAILED; |
| 2141 | } |
| 2142 | memset(lg, 0, sizeof(struct logio_entry_24xx)); |
| 2143 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2144 | if (ql2xmaxqueues > 1) |
| 2145 | req = ha->req_q_map[0]; |
| 2146 | else |
| 2147 | req = vha->req; |
| 2148 | rsp = req->rsp; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2149 | lg->entry_type = LOGINOUT_PORT_IOCB_TYPE; |
| 2150 | lg->entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2151 | lg->handle = MAKE_HANDLE(req->id, lg->handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2152 | lg->nport_handle = cpu_to_le16(loop_id); |
| 2153 | lg->control_flags = |
Andrew Vasquez | c8d6691 | 2011-03-30 11:46:21 -0700 | [diff] [blame] | 2154 | __constant_cpu_to_le16(LCF_COMMAND_LOGO|LCF_IMPL_LOGO| |
| 2155 | LCF_FREE_NPORT); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2156 | lg->port_id[0] = al_pa; |
| 2157 | lg->port_id[1] = area; |
| 2158 | lg->port_id[2] = domain; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2159 | lg->vp_index = vha->vp_idx; |
Andrew Vasquez | 7f45dd0 | 2012-02-09 11:15:45 -0800 | [diff] [blame] | 2160 | rval = qla2x00_issue_iocb_timeout(vha, lg, lg_dma, 0, |
| 2161 | (ha->r_a_tov / 10 * 2) + 2); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2162 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2163 | ql_dbg(ql_dbg_mbx, vha, 0x106f, |
| 2164 | "Failed to issue logout IOCB (%x).\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2165 | } else if (lg->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2166 | ql_dbg(ql_dbg_mbx, vha, 0x1070, |
| 2167 | "Failed to complete IOCB -- error status (%x).\n", |
| 2168 | lg->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2169 | rval = QLA_FUNCTION_FAILED; |
| 2170 | } else if (lg->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2171 | ql_dbg(ql_dbg_mbx, vha, 0x1071, |
| 2172 | "Failed to complete IOCB -- completion status (%x) " |
| 2173 | "ioparam=%x/%x.\n", le16_to_cpu(lg->comp_status), |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2174 | le32_to_cpu(lg->io_parameter[0]), |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2175 | le32_to_cpu(lg->io_parameter[1])); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2176 | } else { |
| 2177 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2178 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1072, |
| 2179 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2180 | } |
| 2181 | |
| 2182 | dma_pool_free(ha->s_dma_pool, lg, lg_dma); |
| 2183 | |
| 2184 | return rval; |
| 2185 | } |
| 2186 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2187 | /* |
| 2188 | * qla2x00_fabric_logout |
| 2189 | * Issue logout fabric port mailbox command. |
| 2190 | * |
| 2191 | * Input: |
| 2192 | * ha = adapter block pointer. |
| 2193 | * loop_id = device loop ID. |
| 2194 | * TARGET_QUEUE_LOCK must be released. |
| 2195 | * ADAPTER_STATE_LOCK must be released. |
| 2196 | * |
| 2197 | * Returns: |
| 2198 | * qla2x00 local function return status code. |
| 2199 | * |
| 2200 | * Context: |
| 2201 | * Kernel context. |
| 2202 | */ |
| 2203 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2204 | 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] | 2205 | uint8_t area, uint8_t al_pa) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2206 | { |
| 2207 | int rval; |
| 2208 | mbx_cmd_t mc; |
| 2209 | mbx_cmd_t *mcp = &mc; |
| 2210 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2211 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1073, |
| 2212 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2213 | |
| 2214 | mcp->mb[0] = MBC_LOGOUT_FABRIC_PORT; |
| 2215 | mcp->out_mb = MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2216 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2217 | mcp->mb[1] = loop_id; |
| 2218 | mcp->mb[10] = 0; |
| 2219 | mcp->out_mb |= MBX_10; |
| 2220 | } else { |
| 2221 | mcp->mb[1] = loop_id << 8; |
| 2222 | } |
| 2223 | |
| 2224 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2225 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2226 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2227 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2228 | |
| 2229 | if (rval != QLA_SUCCESS) { |
| 2230 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2231 | ql_dbg(ql_dbg_mbx, vha, 0x1074, |
| 2232 | "Failed=%x mb[1]=%x.\n", rval, mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2233 | } else { |
| 2234 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2235 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1075, |
| 2236 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2237 | } |
| 2238 | |
| 2239 | return rval; |
| 2240 | } |
| 2241 | |
| 2242 | /* |
| 2243 | * qla2x00_full_login_lip |
| 2244 | * Issue full login LIP mailbox command. |
| 2245 | * |
| 2246 | * Input: |
| 2247 | * ha = adapter block pointer. |
| 2248 | * TARGET_QUEUE_LOCK must be released. |
| 2249 | * ADAPTER_STATE_LOCK must be released. |
| 2250 | * |
| 2251 | * Returns: |
| 2252 | * qla2x00 local function return status code. |
| 2253 | * |
| 2254 | * Context: |
| 2255 | * Kernel context. |
| 2256 | */ |
| 2257 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2258 | qla2x00_full_login_lip(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2259 | { |
| 2260 | int rval; |
| 2261 | mbx_cmd_t mc; |
| 2262 | mbx_cmd_t *mcp = &mc; |
| 2263 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2264 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1076, |
| 2265 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2266 | |
| 2267 | mcp->mb[0] = MBC_LIP_FULL_LOGIN; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2268 | mcp->mb[1] = IS_FWI2_CAPABLE(vha->hw) ? BIT_3 : 0; |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 2269 | mcp->mb[2] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2270 | mcp->mb[3] = 0; |
| 2271 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 2272 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2273 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2274 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2275 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2276 | |
| 2277 | if (rval != QLA_SUCCESS) { |
| 2278 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2279 | ql_dbg(ql_dbg_mbx, vha, 0x1077, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2280 | } else { |
| 2281 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2282 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1078, |
| 2283 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2284 | } |
| 2285 | |
| 2286 | return rval; |
| 2287 | } |
| 2288 | |
| 2289 | /* |
| 2290 | * qla2x00_get_id_list |
| 2291 | * |
| 2292 | * Input: |
| 2293 | * ha = adapter block pointer. |
| 2294 | * |
| 2295 | * Returns: |
| 2296 | * qla2x00 local function return status code. |
| 2297 | * |
| 2298 | * Context: |
| 2299 | * Kernel context. |
| 2300 | */ |
| 2301 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2302 | 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] | 2303 | uint16_t *entries) |
| 2304 | { |
| 2305 | int rval; |
| 2306 | mbx_cmd_t mc; |
| 2307 | mbx_cmd_t *mcp = &mc; |
| 2308 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2309 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1079, |
| 2310 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2311 | |
| 2312 | if (id_list == NULL) |
| 2313 | return QLA_FUNCTION_FAILED; |
| 2314 | |
| 2315 | mcp->mb[0] = MBC_GET_ID_LIST; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2316 | mcp->out_mb = MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2317 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2318 | mcp->mb[2] = MSW(id_list_dma); |
| 2319 | mcp->mb[3] = LSW(id_list_dma); |
| 2320 | mcp->mb[6] = MSW(MSD(id_list_dma)); |
| 2321 | mcp->mb[7] = LSW(MSD(id_list_dma)); |
andrew.vasquez@qlogic.com | 247ec45 | 2006-02-07 08:45:40 -0800 | [diff] [blame] | 2322 | mcp->mb[8] = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2323 | mcp->mb[9] = vha->vp_idx; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2324 | 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] | 2325 | } else { |
| 2326 | mcp->mb[1] = MSW(id_list_dma); |
| 2327 | mcp->mb[2] = LSW(id_list_dma); |
| 2328 | mcp->mb[3] = MSW(MSD(id_list_dma)); |
| 2329 | mcp->mb[6] = LSW(MSD(id_list_dma)); |
| 2330 | mcp->out_mb |= MBX_6|MBX_3|MBX_2|MBX_1; |
| 2331 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2332 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2333 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2334 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2335 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2336 | |
| 2337 | if (rval != QLA_SUCCESS) { |
| 2338 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2339 | ql_dbg(ql_dbg_mbx, vha, 0x107a, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2340 | } else { |
| 2341 | *entries = mcp->mb[1]; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2342 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107b, |
| 2343 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2344 | } |
| 2345 | |
| 2346 | return rval; |
| 2347 | } |
| 2348 | |
| 2349 | /* |
| 2350 | * qla2x00_get_resource_cnts |
| 2351 | * Get current firmware resource counts. |
| 2352 | * |
| 2353 | * Input: |
| 2354 | * ha = adapter block pointer. |
| 2355 | * |
| 2356 | * Returns: |
| 2357 | * qla2x00 local function return status code. |
| 2358 | * |
| 2359 | * Context: |
| 2360 | * Kernel context. |
| 2361 | */ |
| 2362 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2363 | 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] | 2364 | uint16_t *orig_xchg_cnt, uint16_t *cur_iocb_cnt, |
Andrew Vasquez | f3a0a77 | 2009-10-13 15:16:49 -0700 | [diff] [blame] | 2365 | 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] | 2366 | { |
| 2367 | int rval; |
| 2368 | mbx_cmd_t mc; |
| 2369 | mbx_cmd_t *mcp = &mc; |
| 2370 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2371 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107c, |
| 2372 | "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2373 | |
| 2374 | mcp->mb[0] = MBC_GET_RESOURCE_COUNTS; |
| 2375 | mcp->out_mb = MBX_0; |
Seokmann Ju | 4d0ea24 | 2007-09-20 14:07:43 -0700 | [diff] [blame] | 2376 | 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] | 2377 | 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] | 2378 | mcp->in_mb |= MBX_12; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2379 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2380 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2381 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2382 | |
| 2383 | if (rval != QLA_SUCCESS) { |
| 2384 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2385 | ql_dbg(ql_dbg_mbx, vha, 0x107d, |
| 2386 | "Failed mb[0]=%x.\n", mcp->mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2387 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2388 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107e, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2389 | "Done %s mb1=%x mb2=%x mb3=%x mb6=%x mb7=%x mb10=%x " |
| 2390 | "mb11=%x mb12=%x.\n", __func__, mcp->mb[1], mcp->mb[2], |
| 2391 | mcp->mb[3], mcp->mb[6], mcp->mb[7], mcp->mb[10], |
| 2392 | mcp->mb[11], mcp->mb[12]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2393 | |
| 2394 | if (cur_xchg_cnt) |
| 2395 | *cur_xchg_cnt = mcp->mb[3]; |
| 2396 | if (orig_xchg_cnt) |
| 2397 | *orig_xchg_cnt = mcp->mb[6]; |
| 2398 | if (cur_iocb_cnt) |
| 2399 | *cur_iocb_cnt = mcp->mb[7]; |
| 2400 | if (orig_iocb_cnt) |
| 2401 | *orig_iocb_cnt = mcp->mb[10]; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2402 | if (vha->hw->flags.npiv_supported && max_npiv_vports) |
Seokmann Ju | 4d0ea24 | 2007-09-20 14:07:43 -0700 | [diff] [blame] | 2403 | *max_npiv_vports = mcp->mb[11]; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2404 | if ((IS_QLA81XX(vha->hw) || IS_QLA83XX(vha->hw)) && max_fcfs) |
Andrew Vasquez | f3a0a77 | 2009-10-13 15:16:49 -0700 | [diff] [blame] | 2405 | *max_fcfs = mcp->mb[12]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2406 | } |
| 2407 | |
| 2408 | return (rval); |
| 2409 | } |
| 2410 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2411 | /* |
| 2412 | * qla2x00_get_fcal_position_map |
| 2413 | * Get FCAL (LILP) position map using mailbox command |
| 2414 | * |
| 2415 | * Input: |
| 2416 | * ha = adapter state pointer. |
| 2417 | * pos_map = buffer pointer (can be NULL). |
| 2418 | * |
| 2419 | * Returns: |
| 2420 | * qla2x00 local function return status code. |
| 2421 | * |
| 2422 | * Context: |
| 2423 | * Kernel context. |
| 2424 | */ |
| 2425 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2426 | 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] | 2427 | { |
| 2428 | int rval; |
| 2429 | mbx_cmd_t mc; |
| 2430 | mbx_cmd_t *mcp = &mc; |
| 2431 | char *pmap; |
| 2432 | dma_addr_t pmap_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2433 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2434 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2435 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107f, |
| 2436 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2437 | |
Andrew Vasquez | 4b89258 | 2008-09-11 21:22:48 -0700 | [diff] [blame] | 2438 | pmap = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pmap_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2439 | if (pmap == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2440 | ql_log(ql_log_warn, vha, 0x1080, |
| 2441 | "Memory alloc failed.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2442 | return QLA_MEMORY_ALLOC_FAILED; |
| 2443 | } |
| 2444 | memset(pmap, 0, FCAL_MAP_SIZE); |
| 2445 | |
| 2446 | mcp->mb[0] = MBC_GET_FC_AL_POSITION_MAP; |
| 2447 | mcp->mb[2] = MSW(pmap_dma); |
| 2448 | mcp->mb[3] = LSW(pmap_dma); |
| 2449 | mcp->mb[6] = MSW(MSD(pmap_dma)); |
| 2450 | mcp->mb[7] = LSW(MSD(pmap_dma)); |
| 2451 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; |
| 2452 | mcp->in_mb = MBX_1|MBX_0; |
| 2453 | mcp->buf_size = FCAL_MAP_SIZE; |
| 2454 | mcp->flags = MBX_DMA_IN; |
| 2455 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2456 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2457 | |
| 2458 | if (rval == QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2459 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1081, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2460 | "mb0/mb1=%x/%X FC/AL position map size (%x).\n", |
| 2461 | mcp->mb[0], mcp->mb[1], (unsigned)pmap[0]); |
| 2462 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111d, |
| 2463 | pmap, pmap[0] + 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2464 | |
| 2465 | if (pos_map) |
| 2466 | memcpy(pos_map, pmap, FCAL_MAP_SIZE); |
| 2467 | } |
| 2468 | dma_pool_free(ha->s_dma_pool, pmap, pmap_dma); |
| 2469 | |
| 2470 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2471 | ql_dbg(ql_dbg_mbx, vha, 0x1082, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2472 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2473 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1083, |
| 2474 | "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2475 | } |
| 2476 | |
| 2477 | return rval; |
| 2478 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2479 | |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2480 | /* |
| 2481 | * qla2x00_get_link_status |
| 2482 | * |
| 2483 | * Input: |
| 2484 | * ha = adapter block pointer. |
| 2485 | * loop_id = device loop ID. |
| 2486 | * ret_buf = pointer to link status return buffer. |
| 2487 | * |
| 2488 | * Returns: |
| 2489 | * 0 = success. |
| 2490 | * BIT_0 = mem alloc error. |
| 2491 | * BIT_1 = mailbox error. |
| 2492 | */ |
| 2493 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2494 | 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] | 2495 | struct link_statistics *stats, dma_addr_t stats_dma) |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2496 | { |
| 2497 | int rval; |
| 2498 | mbx_cmd_t mc; |
| 2499 | mbx_cmd_t *mcp = &mc; |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2500 | uint32_t *siter, *diter, dwords; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2501 | struct qla_hw_data *ha = vha->hw; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2502 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2503 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1084, |
| 2504 | "Entered %s.\n", __func__); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2505 | |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2506 | mcp->mb[0] = MBC_GET_LINK_STATUS; |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2507 | mcp->mb[2] = MSW(stats_dma); |
| 2508 | mcp->mb[3] = LSW(stats_dma); |
| 2509 | mcp->mb[6] = MSW(MSD(stats_dma)); |
| 2510 | mcp->mb[7] = LSW(MSD(stats_dma)); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2511 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; |
| 2512 | mcp->in_mb = MBX_0; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2513 | if (IS_FWI2_CAPABLE(ha)) { |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2514 | mcp->mb[1] = loop_id; |
| 2515 | mcp->mb[4] = 0; |
| 2516 | mcp->mb[10] = 0; |
| 2517 | mcp->out_mb |= MBX_10|MBX_4|MBX_1; |
| 2518 | mcp->in_mb |= MBX_1; |
| 2519 | } else if (HAS_EXTENDED_IDS(ha)) { |
| 2520 | mcp->mb[1] = loop_id; |
| 2521 | mcp->mb[10] = 0; |
| 2522 | mcp->out_mb |= MBX_10|MBX_1; |
| 2523 | } else { |
| 2524 | mcp->mb[1] = loop_id << 8; |
| 2525 | mcp->out_mb |= MBX_1; |
| 2526 | } |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2527 | mcp->tov = MBX_TOV_SECONDS; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2528 | mcp->flags = IOCTL_CMD; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2529 | rval = qla2x00_mailbox_command(vha, mcp); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2530 | |
| 2531 | if (rval == QLA_SUCCESS) { |
| 2532 | if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2533 | ql_dbg(ql_dbg_mbx, vha, 0x1085, |
| 2534 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2535 | rval = QLA_FUNCTION_FAILED; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2536 | } else { |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2537 | /* Copy over data -- firmware data is LE. */ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2538 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1086, |
| 2539 | "Done %s.\n", __func__); |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2540 | dwords = offsetof(struct link_statistics, unused1) / 4; |
| 2541 | siter = diter = &stats->link_fail_cnt; |
| 2542 | while (dwords--) |
| 2543 | *diter++ = le32_to_cpu(*siter++); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2544 | } |
| 2545 | } else { |
| 2546 | /* Failed. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2547 | 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] | 2548 | } |
| 2549 | |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2550 | return rval; |
| 2551 | } |
| 2552 | |
| 2553 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2554 | 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] | 2555 | dma_addr_t stats_dma) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2556 | { |
| 2557 | int rval; |
| 2558 | mbx_cmd_t mc; |
| 2559 | mbx_cmd_t *mcp = &mc; |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2560 | uint32_t *siter, *diter, dwords; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2561 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2562 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1088, |
| 2563 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2564 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2565 | mcp->mb[0] = MBC_GET_LINK_PRIV_STATS; |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2566 | mcp->mb[2] = MSW(stats_dma); |
| 2567 | mcp->mb[3] = LSW(stats_dma); |
| 2568 | mcp->mb[6] = MSW(MSD(stats_dma)); |
| 2569 | mcp->mb[7] = LSW(MSD(stats_dma)); |
| 2570 | mcp->mb[8] = sizeof(struct link_statistics) / 4; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2571 | mcp->mb[9] = vha->vp_idx; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2572 | mcp->mb[10] = 0; |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2573 | 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] | 2574 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2575 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2576 | mcp->flags = IOCTL_CMD; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2577 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2578 | |
| 2579 | if (rval == QLA_SUCCESS) { |
| 2580 | if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2581 | ql_dbg(ql_dbg_mbx, vha, 0x1089, |
| 2582 | "Failed mb[0]=%x.\n", mcp->mb[0]); |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2583 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2584 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2585 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x108a, |
| 2586 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2587 | /* Copy over data -- firmware data is LE. */ |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2588 | dwords = sizeof(struct link_statistics) / 4; |
| 2589 | siter = diter = &stats->link_fail_cnt; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2590 | while (dwords--) |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2591 | *diter++ = le32_to_cpu(*siter++); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2592 | } |
| 2593 | } else { |
| 2594 | /* Failed. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2595 | ql_dbg(ql_dbg_mbx, vha, 0x108b, "Failed=%x.\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2596 | } |
| 2597 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2598 | return rval; |
| 2599 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2600 | |
| 2601 | int |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2602 | qla24xx_abort_command(srb_t *sp) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2603 | { |
| 2604 | int rval; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2605 | unsigned long flags = 0; |
| 2606 | |
| 2607 | struct abort_entry_24xx *abt; |
| 2608 | dma_addr_t abt_dma; |
| 2609 | uint32_t handle; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2610 | fc_port_t *fcport = sp->fcport; |
| 2611 | struct scsi_qla_host *vha = fcport->vha; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2612 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 2613 | struct req_que *req = vha->req; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2614 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2615 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x108c, |
| 2616 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2617 | |
Armen Baloyan | 4440e46 | 2014-02-26 04:15:18 -0500 | [diff] [blame] | 2618 | if (ql2xasynctmfenable) |
| 2619 | return qla24xx_async_abort_command(sp); |
| 2620 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2621 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 2622 | for (handle = 1; handle < req->num_outstanding_cmds; handle++) { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2623 | if (req->outstanding_cmds[handle] == sp) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2624 | break; |
| 2625 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2626 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 2627 | if (handle == req->num_outstanding_cmds) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2628 | /* Command not found. */ |
| 2629 | return QLA_FUNCTION_FAILED; |
| 2630 | } |
| 2631 | |
| 2632 | abt = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &abt_dma); |
| 2633 | if (abt == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2634 | ql_log(ql_log_warn, vha, 0x108d, |
| 2635 | "Failed to allocate abort IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2636 | return QLA_MEMORY_ALLOC_FAILED; |
| 2637 | } |
| 2638 | memset(abt, 0, sizeof(struct abort_entry_24xx)); |
| 2639 | |
| 2640 | abt->entry_type = ABORT_IOCB_TYPE; |
| 2641 | abt->entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2642 | abt->handle = MAKE_HANDLE(req->id, abt->handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2643 | abt->nport_handle = cpu_to_le16(fcport->loop_id); |
Mike Hernandez | a74ec14 | 2011-03-30 11:46:20 -0700 | [diff] [blame] | 2644 | abt->handle_to_abort = MAKE_HANDLE(req->id, handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2645 | abt->port_id[0] = fcport->d_id.b.al_pa; |
| 2646 | abt->port_id[1] = fcport->d_id.b.area; |
| 2647 | abt->port_id[2] = fcport->d_id.b.domain; |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 2648 | abt->vp_index = fcport->vha->vp_idx; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2649 | |
| 2650 | abt->req_que_no = cpu_to_le16(req->id); |
| 2651 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2652 | rval = qla2x00_issue_iocb(vha, abt, abt_dma, 0); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2653 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2654 | ql_dbg(ql_dbg_mbx, vha, 0x108e, |
| 2655 | "Failed to issue IOCB (%x).\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2656 | } else if (abt->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2657 | ql_dbg(ql_dbg_mbx, vha, 0x108f, |
| 2658 | "Failed to complete IOCB -- error status (%x).\n", |
| 2659 | abt->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2660 | rval = QLA_FUNCTION_FAILED; |
| 2661 | } else if (abt->nport_handle != __constant_cpu_to_le16(0)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2662 | ql_dbg(ql_dbg_mbx, vha, 0x1090, |
| 2663 | "Failed to complete IOCB -- completion status (%x).\n", |
| 2664 | le16_to_cpu(abt->nport_handle)); |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 2665 | if (abt->nport_handle == CS_IOCB_ERROR) |
| 2666 | rval = QLA_FUNCTION_PARAMETER_ERROR; |
| 2667 | else |
| 2668 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2669 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2670 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1091, |
| 2671 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2672 | } |
| 2673 | |
| 2674 | dma_pool_free(ha->s_dma_pool, abt, abt_dma); |
| 2675 | |
| 2676 | return rval; |
| 2677 | } |
| 2678 | |
| 2679 | struct tsk_mgmt_cmd { |
| 2680 | union { |
| 2681 | struct tsk_mgmt_entry tsk; |
| 2682 | struct sts_entry_24xx sts; |
| 2683 | } p; |
| 2684 | }; |
| 2685 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2686 | static int |
| 2687 | __qla24xx_issue_tmf(char *name, uint32_t type, struct fc_port *fcport, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 2688 | uint64_t l, int tag) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2689 | { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2690 | int rval, rval2; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2691 | struct tsk_mgmt_cmd *tsk; |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 2692 | struct sts_entry_24xx *sts; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2693 | dma_addr_t tsk_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2694 | scsi_qla_host_t *vha; |
| 2695 | struct qla_hw_data *ha; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2696 | struct req_que *req; |
| 2697 | struct rsp_que *rsp; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2698 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2699 | vha = fcport->vha; |
| 2700 | ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2701 | req = vha->req; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2702 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2703 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1092, |
| 2704 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2705 | |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 2706 | if (ha->flags.cpu_affinity_enabled) |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2707 | rsp = ha->rsp_q_map[tag + 1]; |
| 2708 | else |
| 2709 | rsp = req->rsp; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2710 | tsk = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &tsk_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2711 | if (tsk == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2712 | ql_log(ql_log_warn, vha, 0x1093, |
| 2713 | "Failed to allocate task management IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2714 | return QLA_MEMORY_ALLOC_FAILED; |
| 2715 | } |
| 2716 | memset(tsk, 0, sizeof(struct tsk_mgmt_cmd)); |
| 2717 | |
| 2718 | tsk->p.tsk.entry_type = TSK_MGMT_IOCB_TYPE; |
| 2719 | tsk->p.tsk.entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2720 | tsk->p.tsk.handle = MAKE_HANDLE(req->id, tsk->p.tsk.handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2721 | tsk->p.tsk.nport_handle = cpu_to_le16(fcport->loop_id); |
Andrew Vasquez | 00a537b | 2008-02-28 14:06:11 -0800 | [diff] [blame] | 2722 | 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] | 2723 | tsk->p.tsk.control_flags = cpu_to_le32(type); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2724 | tsk->p.tsk.port_id[0] = fcport->d_id.b.al_pa; |
| 2725 | tsk->p.tsk.port_id[1] = fcport->d_id.b.area; |
| 2726 | tsk->p.tsk.port_id[2] = fcport->d_id.b.domain; |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 2727 | tsk->p.tsk.vp_index = fcport->vha->vp_idx; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2728 | if (type == TCF_LUN_RESET) { |
| 2729 | int_to_scsilun(l, &tsk->p.tsk.lun); |
| 2730 | host_to_fcp_swap((uint8_t *)&tsk->p.tsk.lun, |
| 2731 | sizeof(tsk->p.tsk.lun)); |
| 2732 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2733 | |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 2734 | sts = &tsk->p.sts; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2735 | rval = qla2x00_issue_iocb(vha, tsk, tsk_dma, 0); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2736 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2737 | ql_dbg(ql_dbg_mbx, vha, 0x1094, |
| 2738 | "Failed to issue %s reset IOCB (%x).\n", name, rval); |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 2739 | } else if (sts->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2740 | ql_dbg(ql_dbg_mbx, vha, 0x1095, |
| 2741 | "Failed to complete IOCB -- error status (%x).\n", |
| 2742 | sts->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2743 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 2744 | } else if (sts->comp_status != |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2745 | __constant_cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2746 | ql_dbg(ql_dbg_mbx, vha, 0x1096, |
| 2747 | "Failed to complete IOCB -- completion status (%x).\n", |
| 2748 | le16_to_cpu(sts->comp_status)); |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 2749 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 97dec56 | 2011-02-23 15:27:14 -0800 | [diff] [blame] | 2750 | } else if (le16_to_cpu(sts->scsi_status) & |
| 2751 | SS_RESPONSE_INFO_LEN_VALID) { |
| 2752 | if (le32_to_cpu(sts->rsp_data_len) < 4) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2753 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1097, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2754 | "Ignoring inconsistent data length -- not enough " |
| 2755 | "response info (%d).\n", |
| 2756 | le32_to_cpu(sts->rsp_data_len)); |
Andrew Vasquez | 97dec56 | 2011-02-23 15:27:14 -0800 | [diff] [blame] | 2757 | } else if (sts->data[3]) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2758 | ql_dbg(ql_dbg_mbx, vha, 0x1098, |
| 2759 | "Failed to complete IOCB -- response (%x).\n", |
| 2760 | sts->data[3]); |
Andrew Vasquez | 97dec56 | 2011-02-23 15:27:14 -0800 | [diff] [blame] | 2761 | rval = QLA_FUNCTION_FAILED; |
| 2762 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2763 | } |
| 2764 | |
| 2765 | /* Issue marker IOCB. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2766 | rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, l, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2767 | type == TCF_LUN_RESET ? MK_SYNC_ID_LUN: MK_SYNC_ID); |
| 2768 | if (rval2 != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2769 | ql_dbg(ql_dbg_mbx, vha, 0x1099, |
| 2770 | "Failed to issue marker IOCB (%x).\n", rval2); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2771 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2772 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109a, |
| 2773 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2774 | } |
| 2775 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2776 | dma_pool_free(ha->s_dma_pool, tsk, tsk_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2777 | |
| 2778 | return rval; |
| 2779 | } |
| 2780 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2781 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 2782 | qla24xx_abort_target(struct fc_port *fcport, uint64_t l, int tag) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2783 | { |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 2784 | struct qla_hw_data *ha = fcport->vha->hw; |
| 2785 | |
| 2786 | if ((ql2xasynctmfenable) && IS_FWI2_CAPABLE(ha)) |
| 2787 | return qla2x00_async_tm_cmd(fcport, TCF_TARGET_RESET, l, tag); |
| 2788 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2789 | return __qla24xx_issue_tmf("Target", TCF_TARGET_RESET, fcport, l, tag); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2790 | } |
| 2791 | |
| 2792 | int |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 2793 | qla24xx_lun_reset(struct fc_port *fcport, uint64_t l, int tag) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2794 | { |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 2795 | struct qla_hw_data *ha = fcport->vha->hw; |
| 2796 | |
| 2797 | if ((ql2xasynctmfenable) && IS_FWI2_CAPABLE(ha)) |
| 2798 | return qla2x00_async_tm_cmd(fcport, TCF_LUN_RESET, l, tag); |
| 2799 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2800 | return __qla24xx_issue_tmf("Lun", TCF_LUN_RESET, fcport, l, tag); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2801 | } |
| 2802 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2803 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2804 | qla2x00_system_error(scsi_qla_host_t *vha) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2805 | { |
| 2806 | int rval; |
| 2807 | mbx_cmd_t mc; |
| 2808 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2809 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2810 | |
Andrew Vasquez | 68af081 | 2008-05-12 22:21:13 -0700 | [diff] [blame] | 2811 | if (!IS_QLA23XX(ha) && !IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2812 | return QLA_FUNCTION_FAILED; |
| 2813 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2814 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109b, |
| 2815 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2816 | |
| 2817 | mcp->mb[0] = MBC_GEN_SYSTEM_ERROR; |
| 2818 | mcp->out_mb = MBX_0; |
| 2819 | mcp->in_mb = MBX_0; |
| 2820 | mcp->tov = 5; |
| 2821 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2822 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2823 | |
| 2824 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2825 | ql_dbg(ql_dbg_mbx, vha, 0x109c, "Failed=%x.\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2826 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2827 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109d, |
| 2828 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2829 | } |
| 2830 | |
| 2831 | return rval; |
| 2832 | } |
| 2833 | |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 2834 | int |
| 2835 | qla2x00_write_serdes_word(scsi_qla_host_t *vha, uint16_t addr, uint16_t data) |
| 2836 | { |
| 2837 | int rval; |
| 2838 | mbx_cmd_t mc; |
| 2839 | mbx_cmd_t *mcp = &mc; |
| 2840 | |
Andrew Vasquez | 064135e | 2015-04-09 15:00:02 -0400 | [diff] [blame^] | 2841 | if (!IS_QLA2031(vha->hw) && !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 2842 | return QLA_FUNCTION_FAILED; |
| 2843 | |
| 2844 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1182, |
| 2845 | "Entered %s.\n", __func__); |
| 2846 | |
| 2847 | mcp->mb[0] = MBC_WRITE_SERDES; |
| 2848 | mcp->mb[1] = addr; |
Andrew Vasquez | 064135e | 2015-04-09 15:00:02 -0400 | [diff] [blame^] | 2849 | if (IS_QLA2031(vha->hw)) |
| 2850 | mcp->mb[2] = data & 0xff; |
| 2851 | else |
| 2852 | mcp->mb[2] = data; |
| 2853 | |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 2854 | mcp->mb[3] = 0; |
| 2855 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 2856 | mcp->in_mb = MBX_0; |
| 2857 | mcp->tov = MBX_TOV_SECONDS; |
| 2858 | mcp->flags = 0; |
| 2859 | rval = qla2x00_mailbox_command(vha, mcp); |
| 2860 | |
| 2861 | if (rval != QLA_SUCCESS) { |
| 2862 | ql_dbg(ql_dbg_mbx, vha, 0x1183, |
| 2863 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 2864 | } else { |
| 2865 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1184, |
| 2866 | "Done %s.\n", __func__); |
| 2867 | } |
| 2868 | |
| 2869 | return rval; |
| 2870 | } |
| 2871 | |
| 2872 | int |
| 2873 | qla2x00_read_serdes_word(scsi_qla_host_t *vha, uint16_t addr, uint16_t *data) |
| 2874 | { |
| 2875 | int rval; |
| 2876 | mbx_cmd_t mc; |
| 2877 | mbx_cmd_t *mcp = &mc; |
| 2878 | |
Andrew Vasquez | 064135e | 2015-04-09 15:00:02 -0400 | [diff] [blame^] | 2879 | if (!IS_QLA2031(vha->hw) && !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 2880 | return QLA_FUNCTION_FAILED; |
| 2881 | |
| 2882 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1185, |
| 2883 | "Entered %s.\n", __func__); |
| 2884 | |
| 2885 | mcp->mb[0] = MBC_READ_SERDES; |
| 2886 | mcp->mb[1] = addr; |
| 2887 | mcp->mb[3] = 0; |
| 2888 | mcp->out_mb = MBX_3|MBX_1|MBX_0; |
| 2889 | mcp->in_mb = MBX_1|MBX_0; |
| 2890 | mcp->tov = MBX_TOV_SECONDS; |
| 2891 | mcp->flags = 0; |
| 2892 | rval = qla2x00_mailbox_command(vha, mcp); |
| 2893 | |
Andrew Vasquez | 064135e | 2015-04-09 15:00:02 -0400 | [diff] [blame^] | 2894 | if (IS_QLA2031(vha->hw)) |
| 2895 | *data = mcp->mb[1] & 0xff; |
| 2896 | else |
| 2897 | *data = mcp->mb[1]; |
Joe Carnuccio | db64e93 | 2013-10-30 03:38:18 -0400 | [diff] [blame] | 2898 | |
| 2899 | if (rval != QLA_SUCCESS) { |
| 2900 | ql_dbg(ql_dbg_mbx, vha, 0x1186, |
| 2901 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 2902 | } else { |
| 2903 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1187, |
| 2904 | "Done %s.\n", __func__); |
| 2905 | } |
| 2906 | |
| 2907 | return rval; |
| 2908 | } |
| 2909 | |
Joe Carnuccio | e8887c5 | 2014-04-11 16:54:17 -0400 | [diff] [blame] | 2910 | int |
| 2911 | qla8044_write_serdes_word(scsi_qla_host_t *vha, uint32_t addr, uint32_t data) |
| 2912 | { |
| 2913 | int rval; |
| 2914 | mbx_cmd_t mc; |
| 2915 | mbx_cmd_t *mcp = &mc; |
| 2916 | |
| 2917 | if (!IS_QLA8044(vha->hw)) |
| 2918 | return QLA_FUNCTION_FAILED; |
| 2919 | |
| 2920 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1186, |
| 2921 | "Entered %s.\n", __func__); |
| 2922 | |
| 2923 | mcp->mb[0] = MBC_SET_GET_ETH_SERDES_REG; |
| 2924 | mcp->mb[1] = HCS_WRITE_SERDES; |
| 2925 | mcp->mb[3] = LSW(addr); |
| 2926 | mcp->mb[4] = MSW(addr); |
| 2927 | mcp->mb[5] = LSW(data); |
| 2928 | mcp->mb[6] = MSW(data); |
| 2929 | mcp->out_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_1|MBX_0; |
| 2930 | mcp->in_mb = MBX_0; |
| 2931 | mcp->tov = MBX_TOV_SECONDS; |
| 2932 | mcp->flags = 0; |
| 2933 | rval = qla2x00_mailbox_command(vha, mcp); |
| 2934 | |
| 2935 | if (rval != QLA_SUCCESS) { |
| 2936 | ql_dbg(ql_dbg_mbx, vha, 0x1187, |
| 2937 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 2938 | } else { |
| 2939 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1188, |
| 2940 | "Done %s.\n", __func__); |
| 2941 | } |
| 2942 | |
| 2943 | return rval; |
| 2944 | } |
| 2945 | |
| 2946 | int |
| 2947 | qla8044_read_serdes_word(scsi_qla_host_t *vha, uint32_t addr, uint32_t *data) |
| 2948 | { |
| 2949 | int rval; |
| 2950 | mbx_cmd_t mc; |
| 2951 | mbx_cmd_t *mcp = &mc; |
| 2952 | |
| 2953 | if (!IS_QLA8044(vha->hw)) |
| 2954 | return QLA_FUNCTION_FAILED; |
| 2955 | |
| 2956 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1189, |
| 2957 | "Entered %s.\n", __func__); |
| 2958 | |
| 2959 | mcp->mb[0] = MBC_SET_GET_ETH_SERDES_REG; |
| 2960 | mcp->mb[1] = HCS_READ_SERDES; |
| 2961 | mcp->mb[3] = LSW(addr); |
| 2962 | mcp->mb[4] = MSW(addr); |
| 2963 | mcp->out_mb = MBX_4|MBX_3|MBX_1|MBX_0; |
| 2964 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 2965 | mcp->tov = MBX_TOV_SECONDS; |
| 2966 | mcp->flags = 0; |
| 2967 | rval = qla2x00_mailbox_command(vha, mcp); |
| 2968 | |
| 2969 | *data = mcp->mb[2] << 16 | mcp->mb[1]; |
| 2970 | |
| 2971 | if (rval != QLA_SUCCESS) { |
| 2972 | ql_dbg(ql_dbg_mbx, vha, 0x118a, |
| 2973 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 2974 | } else { |
| 2975 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x118b, |
| 2976 | "Done %s.\n", __func__); |
| 2977 | } |
| 2978 | |
| 2979 | return rval; |
| 2980 | } |
| 2981 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2982 | /** |
| 2983 | * qla2x00_set_serdes_params() - |
| 2984 | * @ha: HA context |
| 2985 | * |
| 2986 | * Returns |
| 2987 | */ |
| 2988 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2989 | 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] | 2990 | uint16_t sw_em_2g, uint16_t sw_em_4g) |
| 2991 | { |
| 2992 | int rval; |
| 2993 | mbx_cmd_t mc; |
| 2994 | mbx_cmd_t *mcp = &mc; |
| 2995 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 2996 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x109e, |
| 2997 | "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2998 | |
| 2999 | mcp->mb[0] = MBC_SERDES_PARAMS; |
| 3000 | mcp->mb[1] = BIT_0; |
andrew.vasquez@qlogic.com | fdbc683 | 2006-03-09 14:27:29 -0800 | [diff] [blame] | 3001 | mcp->mb[2] = sw_em_1g | BIT_15; |
| 3002 | mcp->mb[3] = sw_em_2g | BIT_15; |
| 3003 | mcp->mb[4] = sw_em_4g | BIT_15; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3004 | mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3005 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3006 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3007 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3008 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3009 | |
| 3010 | if (rval != QLA_SUCCESS) { |
| 3011 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3012 | ql_dbg(ql_dbg_mbx, vha, 0x109f, |
| 3013 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3014 | } else { |
| 3015 | /*EMPTY*/ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3016 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a0, |
| 3017 | "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3018 | } |
| 3019 | |
| 3020 | return rval; |
| 3021 | } |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3022 | |
| 3023 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3024 | qla2x00_stop_firmware(scsi_qla_host_t *vha) |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3025 | { |
| 3026 | int rval; |
| 3027 | mbx_cmd_t mc; |
| 3028 | mbx_cmd_t *mcp = &mc; |
| 3029 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3030 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3031 | return QLA_FUNCTION_FAILED; |
| 3032 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3033 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a1, |
| 3034 | "Entered %s.\n", __func__); |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3035 | |
| 3036 | mcp->mb[0] = MBC_STOP_FIRMWARE; |
Andrew Vasquez | 4ba988d | 2012-02-09 11:14:06 -0800 | [diff] [blame] | 3037 | mcp->mb[1] = 0; |
| 3038 | mcp->out_mb = MBX_1|MBX_0; |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3039 | mcp->in_mb = MBX_0; |
| 3040 | mcp->tov = 5; |
| 3041 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3042 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3043 | |
| 3044 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3045 | ql_dbg(ql_dbg_mbx, vha, 0x10a2, "Failed=%x.\n", rval); |
Andrew Vasquez | b469a7c | 2009-04-06 22:33:48 -0700 | [diff] [blame] | 3046 | if (mcp->mb[0] == MBS_INVALID_COMMAND) |
| 3047 | rval = QLA_INVALID_COMMAND; |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3048 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3049 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a3, |
| 3050 | "Done %s.\n", __func__); |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3051 | } |
| 3052 | |
| 3053 | return rval; |
| 3054 | } |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3055 | |
| 3056 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3057 | 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] | 3058 | uint16_t buffers) |
| 3059 | { |
| 3060 | int rval; |
| 3061 | mbx_cmd_t mc; |
| 3062 | mbx_cmd_t *mcp = &mc; |
| 3063 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3064 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a4, |
| 3065 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3066 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3067 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3068 | return QLA_FUNCTION_FAILED; |
| 3069 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3070 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3071 | return QLA_FUNCTION_FAILED; |
| 3072 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3073 | mcp->mb[0] = MBC_TRACE_CONTROL; |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3074 | mcp->mb[1] = TC_EFT_ENABLE; |
| 3075 | mcp->mb[2] = LSW(eft_dma); |
| 3076 | mcp->mb[3] = MSW(eft_dma); |
| 3077 | mcp->mb[4] = LSW(MSD(eft_dma)); |
| 3078 | mcp->mb[5] = MSW(MSD(eft_dma)); |
| 3079 | mcp->mb[6] = buffers; |
| 3080 | mcp->mb[7] = TC_AEN_DISABLE; |
| 3081 | 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] | 3082 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3083 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3084 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3085 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3086 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3087 | ql_dbg(ql_dbg_mbx, vha, 0x10a5, |
| 3088 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3089 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3090 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3091 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a6, |
| 3092 | "Done %s.\n", __func__); |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3093 | } |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3094 | |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3095 | return rval; |
| 3096 | } |
| 3097 | |
| 3098 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3099 | qla2x00_disable_eft_trace(scsi_qla_host_t *vha) |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3100 | { |
| 3101 | int rval; |
| 3102 | mbx_cmd_t mc; |
| 3103 | mbx_cmd_t *mcp = &mc; |
| 3104 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3105 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a7, |
| 3106 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3107 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3108 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3109 | return QLA_FUNCTION_FAILED; |
| 3110 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3111 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3112 | return QLA_FUNCTION_FAILED; |
| 3113 | |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3114 | mcp->mb[0] = MBC_TRACE_CONTROL; |
| 3115 | mcp->mb[1] = TC_EFT_DISABLE; |
| 3116 | mcp->out_mb = MBX_1|MBX_0; |
| 3117 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3118 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 3119 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3120 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3121 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3122 | ql_dbg(ql_dbg_mbx, vha, 0x10a8, |
| 3123 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3124 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3125 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3126 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10a9, |
| 3127 | "Done %s.\n", __func__); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3128 | } |
| 3129 | |
| 3130 | return rval; |
| 3131 | } |
| 3132 | |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 3133 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3134 | 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] | 3135 | uint16_t buffers, uint16_t *mb, uint32_t *dwords) |
| 3136 | { |
| 3137 | int rval; |
| 3138 | mbx_cmd_t mc; |
| 3139 | mbx_cmd_t *mcp = &mc; |
| 3140 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3141 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10aa, |
| 3142 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3143 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3144 | if (!IS_QLA25XX(vha->hw) && !IS_QLA81XX(vha->hw) && |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3145 | !IS_QLA83XX(vha->hw) && !IS_QLA27XX(vha->hw)) |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3146 | return QLA_FUNCTION_FAILED; |
| 3147 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3148 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3149 | return QLA_FUNCTION_FAILED; |
| 3150 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3151 | mcp->mb[0] = MBC_TRACE_CONTROL; |
| 3152 | mcp->mb[1] = TC_FCE_ENABLE; |
| 3153 | mcp->mb[2] = LSW(fce_dma); |
| 3154 | mcp->mb[3] = MSW(fce_dma); |
| 3155 | mcp->mb[4] = LSW(MSD(fce_dma)); |
| 3156 | mcp->mb[5] = MSW(MSD(fce_dma)); |
| 3157 | mcp->mb[6] = buffers; |
| 3158 | mcp->mb[7] = TC_AEN_DISABLE; |
| 3159 | mcp->mb[8] = 0; |
| 3160 | mcp->mb[9] = TC_FCE_DEFAULT_RX_SIZE; |
| 3161 | mcp->mb[10] = TC_FCE_DEFAULT_TX_SIZE; |
| 3162 | mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2| |
| 3163 | MBX_1|MBX_0; |
| 3164 | 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] | 3165 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3166 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3167 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3168 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3169 | ql_dbg(ql_dbg_mbx, vha, 0x10ab, |
| 3170 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3171 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3172 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3173 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ac, |
| 3174 | "Done %s.\n", __func__); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3175 | |
| 3176 | if (mb) |
| 3177 | memcpy(mb, mcp->mb, 8 * sizeof(*mb)); |
| 3178 | if (dwords) |
Andrew Vasquez | fa0926d | 2008-05-12 22:21:12 -0700 | [diff] [blame] | 3179 | *dwords = buffers; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3180 | } |
| 3181 | |
| 3182 | return rval; |
| 3183 | } |
| 3184 | |
| 3185 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3186 | 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] | 3187 | { |
| 3188 | int rval; |
| 3189 | mbx_cmd_t mc; |
| 3190 | mbx_cmd_t *mcp = &mc; |
| 3191 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3192 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ad, |
| 3193 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3194 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3195 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3196 | return QLA_FUNCTION_FAILED; |
| 3197 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3198 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 3199 | return QLA_FUNCTION_FAILED; |
| 3200 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3201 | mcp->mb[0] = MBC_TRACE_CONTROL; |
| 3202 | mcp->mb[1] = TC_FCE_DISABLE; |
| 3203 | mcp->mb[2] = TC_FCE_DISABLE_TRACE; |
| 3204 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 3205 | mcp->in_mb = MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2| |
| 3206 | MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3207 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3208 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3209 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3210 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3211 | ql_dbg(ql_dbg_mbx, vha, 0x10ae, |
| 3212 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3213 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3214 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3215 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10af, |
| 3216 | "Done %s.\n", __func__); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3217 | |
| 3218 | if (wr) |
| 3219 | *wr = (uint64_t) mcp->mb[5] << 48 | |
| 3220 | (uint64_t) mcp->mb[4] << 32 | |
| 3221 | (uint64_t) mcp->mb[3] << 16 | |
| 3222 | (uint64_t) mcp->mb[2]; |
| 3223 | if (rd) |
| 3224 | *rd = (uint64_t) mcp->mb[9] << 48 | |
| 3225 | (uint64_t) mcp->mb[8] << 32 | |
| 3226 | (uint64_t) mcp->mb[7] << 16 | |
| 3227 | (uint64_t) mcp->mb[6]; |
| 3228 | } |
| 3229 | |
| 3230 | return rval; |
| 3231 | } |
| 3232 | |
| 3233 | int |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3234 | qla2x00_get_idma_speed(scsi_qla_host_t *vha, uint16_t loop_id, |
| 3235 | uint16_t *port_speed, uint16_t *mb) |
| 3236 | { |
| 3237 | int rval; |
| 3238 | mbx_cmd_t mc; |
| 3239 | mbx_cmd_t *mcp = &mc; |
| 3240 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3241 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b0, |
| 3242 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3243 | |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3244 | if (!IS_IIDMA_CAPABLE(vha->hw)) |
| 3245 | return QLA_FUNCTION_FAILED; |
| 3246 | |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3247 | mcp->mb[0] = MBC_PORT_PARAMS; |
| 3248 | mcp->mb[1] = loop_id; |
| 3249 | mcp->mb[2] = mcp->mb[3] = 0; |
| 3250 | mcp->mb[9] = vha->vp_idx; |
| 3251 | mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3252 | mcp->in_mb = MBX_3|MBX_1|MBX_0; |
| 3253 | mcp->tov = MBX_TOV_SECONDS; |
| 3254 | mcp->flags = 0; |
| 3255 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3256 | |
| 3257 | /* Return mailbox statuses. */ |
| 3258 | if (mb != NULL) { |
| 3259 | mb[0] = mcp->mb[0]; |
| 3260 | mb[1] = mcp->mb[1]; |
| 3261 | mb[3] = mcp->mb[3]; |
| 3262 | } |
| 3263 | |
| 3264 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3265 | ql_dbg(ql_dbg_mbx, vha, 0x10b1, "Failed=%x.\n", rval); |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3266 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3267 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b2, |
| 3268 | "Done %s.\n", __func__); |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 3269 | if (port_speed) |
| 3270 | *port_speed = mcp->mb[3]; |
| 3271 | } |
| 3272 | |
| 3273 | return rval; |
| 3274 | } |
| 3275 | |
| 3276 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3277 | 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] | 3278 | uint16_t port_speed, uint16_t *mb) |
| 3279 | { |
| 3280 | int rval; |
| 3281 | mbx_cmd_t mc; |
| 3282 | mbx_cmd_t *mcp = &mc; |
| 3283 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3284 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b3, |
| 3285 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3286 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3287 | if (!IS_IIDMA_CAPABLE(vha->hw)) |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3288 | return QLA_FUNCTION_FAILED; |
| 3289 | |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3290 | mcp->mb[0] = MBC_PORT_PARAMS; |
| 3291 | mcp->mb[1] = loop_id; |
| 3292 | mcp->mb[2] = BIT_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3293 | if (IS_CNA_CAPABLE(vha->hw)) |
Harish Zunjarrao | 1bb3954 | 2009-06-17 10:30:29 -0700 | [diff] [blame] | 3294 | mcp->mb[3] = port_speed & (BIT_5|BIT_4|BIT_3|BIT_2|BIT_1|BIT_0); |
| 3295 | else |
| 3296 | mcp->mb[3] = port_speed & (BIT_2|BIT_1|BIT_0); |
| 3297 | mcp->mb[9] = vha->vp_idx; |
| 3298 | mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3299 | mcp->in_mb = MBX_3|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3300 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3301 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3302 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3303 | |
| 3304 | /* Return mailbox statuses. */ |
| 3305 | if (mb != NULL) { |
| 3306 | mb[0] = mcp->mb[0]; |
| 3307 | mb[1] = mcp->mb[1]; |
| 3308 | mb[3] = mcp->mb[3]; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3309 | } |
| 3310 | |
| 3311 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3312 | ql_dbg(ql_dbg_mbx, vha, 0x10b4, |
| 3313 | "Failed=%x.\n", rval); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3314 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3315 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b5, |
| 3316 | "Done %s.\n", __func__); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3317 | } |
| 3318 | |
| 3319 | return rval; |
| 3320 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3321 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3322 | void |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3323 | qla24xx_report_id_acquisition(scsi_qla_host_t *vha, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3324 | struct vp_rpt_id_entry_24xx *rptid_entry) |
| 3325 | { |
| 3326 | uint8_t vp_idx; |
Seokmann Ju | c6852c4 | 2008-04-24 15:21:29 -0700 | [diff] [blame] | 3327 | uint16_t stat = le16_to_cpu(rptid_entry->vp_idx); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3328 | struct qla_hw_data *ha = vha->hw; |
| 3329 | scsi_qla_host_t *vp; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3330 | unsigned long flags; |
Andrew Vasquez | 4ac8d4ca | 2013-02-08 01:57:58 -0500 | [diff] [blame] | 3331 | int found; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3332 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3333 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b6, |
| 3334 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3335 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3336 | if (rptid_entry->entry_status != 0) |
| 3337 | return; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3338 | |
| 3339 | if (rptid_entry->format == 0) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3340 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b7, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3341 | "Format 0 : Number of VPs setup %d, number of " |
| 3342 | "VPs acquired %d.\n", |
| 3343 | MSB(le16_to_cpu(rptid_entry->vp_count)), |
| 3344 | LSB(le16_to_cpu(rptid_entry->vp_count))); |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3345 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b8, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3346 | "Primary port id %02x%02x%02x.\n", |
| 3347 | rptid_entry->port_id[2], rptid_entry->port_id[1], |
| 3348 | rptid_entry->port_id[0]); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3349 | } else if (rptid_entry->format == 1) { |
Seokmann Ju | c6852c4 | 2008-04-24 15:21:29 -0700 | [diff] [blame] | 3350 | vp_idx = LSB(stat); |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3351 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b9, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3352 | "Format 1: VP[%d] enabled - status %d - with " |
| 3353 | "port id %02x%02x%02x.\n", vp_idx, MSB(stat), |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3354 | rptid_entry->port_id[2], rptid_entry->port_id[1], |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3355 | rptid_entry->port_id[0]); |
Andrew Vasquez | 531a82d | 2009-10-13 15:16:51 -0700 | [diff] [blame] | 3356 | |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 3357 | /* FA-WWN is only for physical port */ |
| 3358 | if (!vp_idx) { |
| 3359 | void *wwpn = ha->init_cb->port_name; |
| 3360 | |
| 3361 | if (!MSB(stat)) { |
| 3362 | if (rptid_entry->vp_idx_map[1] & BIT_6) |
| 3363 | wwpn = rptid_entry->reserved_4 + 8; |
| 3364 | } |
| 3365 | memcpy(vha->port_name, wwpn, WWN_SIZE); |
| 3366 | fc_host_port_name(vha->host) = |
| 3367 | wwn_to_u64(vha->port_name); |
| 3368 | ql_dbg(ql_dbg_mbx, vha, 0x1018, |
| 3369 | "FA-WWN portname %016llx (%x)\n", |
| 3370 | fc_host_port_name(vha->host), MSB(stat)); |
| 3371 | } |
| 3372 | |
Andrew Vasquez | 531a82d | 2009-10-13 15:16:51 -0700 | [diff] [blame] | 3373 | vp = vha; |
Joe Carnuccio | 7c9c476 | 2014-09-25 05:16:47 -0400 | [diff] [blame] | 3374 | if (vp_idx == 0) |
Andrew Vasquez | 531a82d | 2009-10-13 15:16:51 -0700 | [diff] [blame] | 3375 | goto reg_needed; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3376 | |
Saurav Kashyap | 681e014 | 2012-11-21 02:40:28 -0500 | [diff] [blame] | 3377 | if (MSB(stat) != 0 && MSB(stat) != 2) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3378 | ql_dbg(ql_dbg_mbx, vha, 0x10ba, |
| 3379 | "Could not acquire ID for VP[%d].\n", vp_idx); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3380 | return; |
Andrew Vasquez | 81eb9b4 | 2009-06-03 09:55:23 -0700 | [diff] [blame] | 3381 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3382 | |
Andrew Vasquez | 4ac8d4ca | 2013-02-08 01:57:58 -0500 | [diff] [blame] | 3383 | found = 0; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3384 | spin_lock_irqsave(&ha->vport_slock, flags); |
Andrew Vasquez | 4ac8d4ca | 2013-02-08 01:57:58 -0500 | [diff] [blame] | 3385 | list_for_each_entry(vp, &ha->vp_list, list) { |
| 3386 | if (vp_idx == vp->vp_idx) { |
| 3387 | found = 1; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3388 | break; |
Andrew Vasquez | 4ac8d4ca | 2013-02-08 01:57:58 -0500 | [diff] [blame] | 3389 | } |
| 3390 | } |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3391 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 3392 | |
Andrew Vasquez | 4ac8d4ca | 2013-02-08 01:57:58 -0500 | [diff] [blame] | 3393 | if (!found) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3394 | return; |
| 3395 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3396 | vp->d_id.b.domain = rptid_entry->port_id[2]; |
| 3397 | vp->d_id.b.area = rptid_entry->port_id[1]; |
| 3398 | vp->d_id.b.al_pa = rptid_entry->port_id[0]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3399 | |
| 3400 | /* |
| 3401 | * Cannot configure here as we are still sitting on the |
| 3402 | * response queue. Handle it in dpc context. |
| 3403 | */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3404 | set_bit(VP_IDX_ACQUIRED, &vp->vp_flags); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3405 | |
Andrew Vasquez | 531a82d | 2009-10-13 15:16:51 -0700 | [diff] [blame] | 3406 | reg_needed: |
| 3407 | set_bit(REGISTER_FC4_NEEDED, &vp->dpc_flags); |
| 3408 | set_bit(REGISTER_FDMI_NEEDED, &vp->dpc_flags); |
| 3409 | set_bit(VP_DPC_NEEDED, &vha->dpc_flags); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3410 | qla2xxx_wake_dpc(vha); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3411 | } |
| 3412 | } |
| 3413 | |
| 3414 | /* |
| 3415 | * qla24xx_modify_vp_config |
| 3416 | * Change VP configuration for vha |
| 3417 | * |
| 3418 | * Input: |
| 3419 | * vha = adapter block pointer. |
| 3420 | * |
| 3421 | * Returns: |
| 3422 | * qla2xxx local function return status code. |
| 3423 | * |
| 3424 | * Context: |
| 3425 | * Kernel context. |
| 3426 | */ |
| 3427 | int |
| 3428 | qla24xx_modify_vp_config(scsi_qla_host_t *vha) |
| 3429 | { |
| 3430 | int rval; |
| 3431 | struct vp_config_entry_24xx *vpmod; |
| 3432 | dma_addr_t vpmod_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3433 | struct qla_hw_data *ha = vha->hw; |
| 3434 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3435 | |
| 3436 | /* This can be called by the parent */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3437 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3438 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10bb, |
| 3439 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3440 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3441 | vpmod = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &vpmod_dma); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3442 | if (!vpmod) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3443 | ql_log(ql_log_warn, vha, 0x10bc, |
| 3444 | "Failed to allocate modify VP IOCB.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3445 | return QLA_MEMORY_ALLOC_FAILED; |
| 3446 | } |
| 3447 | |
| 3448 | memset(vpmod, 0, sizeof(struct vp_config_entry_24xx)); |
| 3449 | vpmod->entry_type = VP_CONFIG_IOCB_TYPE; |
| 3450 | vpmod->entry_count = 1; |
| 3451 | vpmod->command = VCT_COMMAND_MOD_ENABLE_VPS; |
| 3452 | vpmod->vp_count = 1; |
| 3453 | vpmod->vp_index1 = vha->vp_idx; |
| 3454 | vpmod->options_idx1 = BIT_3|BIT_4|BIT_5; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3455 | |
| 3456 | qlt_modify_vp_config(vha, vpmod); |
| 3457 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3458 | memcpy(vpmod->node_name_idx1, vha->node_name, WWN_SIZE); |
| 3459 | memcpy(vpmod->port_name_idx1, vha->port_name, WWN_SIZE); |
| 3460 | vpmod->entry_count = 1; |
| 3461 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3462 | rval = qla2x00_issue_iocb(base_vha, vpmod, vpmod_dma, 0); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3463 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3464 | ql_dbg(ql_dbg_mbx, vha, 0x10bd, |
| 3465 | "Failed to issue VP config IOCB (%x).\n", rval); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3466 | } else if (vpmod->comp_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3467 | ql_dbg(ql_dbg_mbx, vha, 0x10be, |
| 3468 | "Failed to complete IOCB -- error status (%x).\n", |
| 3469 | vpmod->comp_status); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3470 | rval = QLA_FUNCTION_FAILED; |
| 3471 | } else if (vpmod->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3472 | ql_dbg(ql_dbg_mbx, vha, 0x10bf, |
| 3473 | "Failed to complete IOCB -- completion status (%x).\n", |
| 3474 | le16_to_cpu(vpmod->comp_status)); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3475 | rval = QLA_FUNCTION_FAILED; |
| 3476 | } else { |
| 3477 | /* EMPTY */ |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3478 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c0, |
| 3479 | "Done %s.\n", __func__); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3480 | fc_vport_set_state(vha->fc_vport, FC_VPORT_INITIALIZING); |
| 3481 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3482 | dma_pool_free(ha->s_dma_pool, vpmod, vpmod_dma); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3483 | |
| 3484 | return rval; |
| 3485 | } |
| 3486 | |
| 3487 | /* |
| 3488 | * qla24xx_control_vp |
| 3489 | * Enable a virtual port for given host |
| 3490 | * |
| 3491 | * Input: |
| 3492 | * ha = adapter block pointer. |
| 3493 | * vhba = virtual adapter (unused) |
| 3494 | * index = index number for enabled VP |
| 3495 | * |
| 3496 | * Returns: |
| 3497 | * qla2xxx local function return status code. |
| 3498 | * |
| 3499 | * Context: |
| 3500 | * Kernel context. |
| 3501 | */ |
| 3502 | int |
| 3503 | qla24xx_control_vp(scsi_qla_host_t *vha, int cmd) |
| 3504 | { |
| 3505 | int rval; |
| 3506 | int map, pos; |
| 3507 | struct vp_ctrl_entry_24xx *vce; |
| 3508 | dma_addr_t vce_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3509 | struct qla_hw_data *ha = vha->hw; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3510 | int vp_index = vha->vp_idx; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3511 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3512 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3513 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c1, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3514 | "Entered %s enabling index %d.\n", __func__, vp_index); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3515 | |
Andrew Vasquez | eb66dc6 | 2007-11-12 10:30:58 -0800 | [diff] [blame] | 3516 | if (vp_index == 0 || vp_index >= ha->max_npiv_vports) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3517 | return QLA_PARAMETER_ERROR; |
| 3518 | |
| 3519 | vce = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &vce_dma); |
| 3520 | if (!vce) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3521 | ql_log(ql_log_warn, vha, 0x10c2, |
| 3522 | "Failed to allocate VP control IOCB.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3523 | return QLA_MEMORY_ALLOC_FAILED; |
| 3524 | } |
| 3525 | memset(vce, 0, sizeof(struct vp_ctrl_entry_24xx)); |
| 3526 | |
| 3527 | vce->entry_type = VP_CTRL_IOCB_TYPE; |
| 3528 | vce->entry_count = 1; |
| 3529 | vce->command = cpu_to_le16(cmd); |
| 3530 | vce->vp_count = __constant_cpu_to_le16(1); |
| 3531 | |
| 3532 | /* index map in firmware starts with 1; decrement index |
| 3533 | * this is ok as we never use index 0 |
| 3534 | */ |
| 3535 | map = (vp_index - 1) / 8; |
| 3536 | pos = (vp_index - 1) & 7; |
matthias@kaehlcke.net | 6c2f527 | 2008-05-12 22:21:11 -0700 | [diff] [blame] | 3537 | mutex_lock(&ha->vport_lock); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3538 | vce->vp_idx_map[map] |= 1 << pos; |
matthias@kaehlcke.net | 6c2f527 | 2008-05-12 22:21:11 -0700 | [diff] [blame] | 3539 | mutex_unlock(&ha->vport_lock); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3540 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3541 | rval = qla2x00_issue_iocb(base_vha, vce, vce_dma, 0); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3542 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3543 | ql_dbg(ql_dbg_mbx, vha, 0x10c3, |
| 3544 | "Failed to issue VP control IOCB (%x).\n", rval); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3545 | } else if (vce->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3546 | ql_dbg(ql_dbg_mbx, vha, 0x10c4, |
| 3547 | "Failed to complete IOCB -- error status (%x).\n", |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3548 | vce->entry_status); |
| 3549 | rval = QLA_FUNCTION_FAILED; |
| 3550 | } else if (vce->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3551 | ql_dbg(ql_dbg_mbx, vha, 0x10c5, |
| 3552 | "Failed to complet IOCB -- completion status (%x).\n", |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3553 | le16_to_cpu(vce->comp_status)); |
| 3554 | rval = QLA_FUNCTION_FAILED; |
| 3555 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3556 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c6, |
| 3557 | "Done %s.\n", __func__); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3558 | } |
| 3559 | |
| 3560 | dma_pool_free(ha->s_dma_pool, vce, vce_dma); |
| 3561 | |
| 3562 | return rval; |
| 3563 | } |
| 3564 | |
| 3565 | /* |
| 3566 | * qla2x00_send_change_request |
| 3567 | * Receive or disable RSCN request from fabric controller |
| 3568 | * |
| 3569 | * Input: |
| 3570 | * ha = adapter block pointer |
| 3571 | * format = registration format: |
| 3572 | * 0 - Reserved |
| 3573 | * 1 - Fabric detected registration |
| 3574 | * 2 - N_port detected registration |
| 3575 | * 3 - Full registration |
| 3576 | * FF - clear registration |
| 3577 | * vp_idx = Virtual port index |
| 3578 | * |
| 3579 | * Returns: |
| 3580 | * qla2x00 local function return status code. |
| 3581 | * |
| 3582 | * Context: |
| 3583 | * Kernel Context |
| 3584 | */ |
| 3585 | |
| 3586 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3587 | qla2x00_send_change_request(scsi_qla_host_t *vha, uint16_t format, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3588 | uint16_t vp_idx) |
| 3589 | { |
| 3590 | int rval; |
| 3591 | mbx_cmd_t mc; |
| 3592 | mbx_cmd_t *mcp = &mc; |
| 3593 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3594 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c7, |
| 3595 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3596 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3597 | mcp->mb[0] = MBC_SEND_CHANGE_REQUEST; |
| 3598 | mcp->mb[1] = format; |
| 3599 | mcp->mb[9] = vp_idx; |
| 3600 | mcp->out_mb = MBX_9|MBX_1|MBX_0; |
| 3601 | mcp->in_mb = MBX_0|MBX_1; |
| 3602 | mcp->tov = MBX_TOV_SECONDS; |
| 3603 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3604 | rval = qla2x00_mailbox_command(vha, mcp); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3605 | |
| 3606 | if (rval == QLA_SUCCESS) { |
| 3607 | if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { |
| 3608 | rval = BIT_1; |
| 3609 | } |
| 3610 | } else |
| 3611 | rval = BIT_1; |
| 3612 | |
| 3613 | return rval; |
| 3614 | } |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 3615 | |
| 3616 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3617 | 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] | 3618 | uint32_t size) |
| 3619 | { |
| 3620 | int rval; |
| 3621 | mbx_cmd_t mc; |
| 3622 | mbx_cmd_t *mcp = &mc; |
| 3623 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3624 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1009, |
| 3625 | "Entered %s.\n", __func__); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 3626 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3627 | if (MSW(addr) || IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 3628 | mcp->mb[0] = MBC_DUMP_RISC_RAM_EXTENDED; |
| 3629 | mcp->mb[8] = MSW(addr); |
| 3630 | mcp->out_mb = MBX_8|MBX_0; |
| 3631 | } else { |
| 3632 | mcp->mb[0] = MBC_DUMP_RISC_RAM; |
| 3633 | mcp->out_mb = MBX_0; |
| 3634 | } |
| 3635 | mcp->mb[1] = LSW(addr); |
| 3636 | mcp->mb[2] = MSW(req_dma); |
| 3637 | mcp->mb[3] = LSW(req_dma); |
| 3638 | mcp->mb[6] = MSW(MSD(req_dma)); |
| 3639 | mcp->mb[7] = LSW(MSD(req_dma)); |
| 3640 | 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] | 3641 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 3642 | mcp->mb[4] = MSW(size); |
| 3643 | mcp->mb[5] = LSW(size); |
| 3644 | mcp->out_mb |= MBX_5|MBX_4; |
| 3645 | } else { |
| 3646 | mcp->mb[4] = LSW(size); |
| 3647 | mcp->out_mb |= MBX_4; |
| 3648 | } |
| 3649 | |
| 3650 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3651 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 3652 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3653 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 3654 | |
| 3655 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3656 | ql_dbg(ql_dbg_mbx, vha, 0x1008, |
| 3657 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 3658 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3659 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1007, |
| 3660 | "Done %s.\n", __func__); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 3661 | } |
| 3662 | |
| 3663 | return rval; |
| 3664 | } |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3665 | /* 84XX Support **************************************************************/ |
| 3666 | |
| 3667 | struct cs84xx_mgmt_cmd { |
| 3668 | union { |
| 3669 | struct verify_chip_entry_84xx req; |
| 3670 | struct verify_chip_rsp_84xx rsp; |
| 3671 | } p; |
| 3672 | }; |
| 3673 | |
| 3674 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3675 | qla84xx_verify_chip(struct scsi_qla_host *vha, uint16_t *status) |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3676 | { |
| 3677 | int rval, retry; |
| 3678 | struct cs84xx_mgmt_cmd *mn; |
| 3679 | dma_addr_t mn_dma; |
| 3680 | uint16_t options; |
| 3681 | unsigned long flags; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3682 | struct qla_hw_data *ha = vha->hw; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3683 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3684 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c8, |
| 3685 | "Entered %s.\n", __func__); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3686 | |
| 3687 | mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma); |
| 3688 | if (mn == NULL) { |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3689 | return QLA_MEMORY_ALLOC_FAILED; |
| 3690 | } |
| 3691 | |
| 3692 | /* Force Update? */ |
| 3693 | options = ha->cs84xx->fw_update ? VCO_FORCE_UPDATE : 0; |
| 3694 | /* Diagnostic firmware? */ |
| 3695 | /* options |= MENLO_DIAG_FW; */ |
| 3696 | /* We update the firmware with only one data sequence. */ |
| 3697 | options |= VCO_END_OF_DATA; |
| 3698 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3699 | do { |
Andrew Vasquez | c1ec1f1 | 2008-04-24 15:21:24 -0700 | [diff] [blame] | 3700 | retry = 0; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3701 | memset(mn, 0, sizeof(*mn)); |
| 3702 | mn->p.req.entry_type = VERIFY_CHIP_IOCB_TYPE; |
| 3703 | mn->p.req.entry_count = 1; |
| 3704 | mn->p.req.options = cpu_to_le16(options); |
| 3705 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3706 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111c, |
| 3707 | "Dump of Verify Request.\n"); |
| 3708 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111e, |
| 3709 | (uint8_t *)mn, sizeof(*mn)); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3710 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3711 | rval = qla2x00_issue_iocb_timeout(vha, mn, mn_dma, 0, 120); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3712 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3713 | ql_dbg(ql_dbg_mbx, vha, 0x10cb, |
| 3714 | "Failed to issue verify IOCB (%x).\n", rval); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3715 | goto verify_done; |
| 3716 | } |
| 3717 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3718 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1110, |
| 3719 | "Dump of Verify Response.\n"); |
| 3720 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1118, |
| 3721 | (uint8_t *)mn, sizeof(*mn)); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3722 | |
| 3723 | status[0] = le16_to_cpu(mn->p.rsp.comp_status); |
| 3724 | status[1] = status[0] == CS_VCS_CHIP_FAILURE ? |
| 3725 | le16_to_cpu(mn->p.rsp.failure_code) : 0; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3726 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ce, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3727 | "cs=%x fc=%x.\n", status[0], status[1]); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3728 | |
| 3729 | if (status[0] != CS_COMPLETE) { |
| 3730 | rval = QLA_FUNCTION_FAILED; |
| 3731 | if (!(options & VCO_DONT_UPDATE_FW)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3732 | ql_dbg(ql_dbg_mbx, vha, 0x10cf, |
| 3733 | "Firmware update failed. Retrying " |
| 3734 | "without update firmware.\n"); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3735 | options |= VCO_DONT_UPDATE_FW; |
| 3736 | options &= ~VCO_FORCE_UPDATE; |
| 3737 | retry = 1; |
| 3738 | } |
| 3739 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3740 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d0, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3741 | "Firmware updated to %x.\n", |
| 3742 | le32_to_cpu(mn->p.rsp.fw_ver)); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3743 | |
| 3744 | /* NOTE: we only update OP firmware. */ |
| 3745 | spin_lock_irqsave(&ha->cs84xx->access_lock, flags); |
| 3746 | ha->cs84xx->op_fw_version = |
| 3747 | le32_to_cpu(mn->p.rsp.fw_ver); |
| 3748 | spin_unlock_irqrestore(&ha->cs84xx->access_lock, |
| 3749 | flags); |
| 3750 | } |
| 3751 | } while (retry); |
| 3752 | |
| 3753 | verify_done: |
| 3754 | dma_pool_free(ha->s_dma_pool, mn, mn_dma); |
| 3755 | |
| 3756 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3757 | ql_dbg(ql_dbg_mbx, vha, 0x10d1, |
| 3758 | "Failed=%x.\n", rval); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3759 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3760 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d2, |
| 3761 | "Done %s.\n", __func__); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3762 | } |
| 3763 | |
| 3764 | return rval; |
| 3765 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3766 | |
| 3767 | int |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 3768 | 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] | 3769 | { |
| 3770 | int rval; |
| 3771 | unsigned long flags; |
| 3772 | mbx_cmd_t mc; |
| 3773 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3774 | struct qla_hw_data *ha = vha->hw; |
| 3775 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3776 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d3, |
| 3777 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3778 | |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 3779 | if (IS_SHADOW_REG_CAPABLE(ha)) |
| 3780 | req->options |= BIT_13; |
| 3781 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3782 | mcp->mb[0] = MBC_INITIALIZE_MULTIQ; |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 3783 | mcp->mb[1] = req->options; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3784 | mcp->mb[2] = MSW(LSD(req->dma)); |
| 3785 | mcp->mb[3] = LSW(LSD(req->dma)); |
| 3786 | mcp->mb[6] = MSW(MSD(req->dma)); |
| 3787 | mcp->mb[7] = LSW(MSD(req->dma)); |
| 3788 | mcp->mb[5] = req->length; |
| 3789 | if (req->rsp) |
| 3790 | mcp->mb[10] = req->rsp->id; |
| 3791 | mcp->mb[12] = req->qos; |
| 3792 | mcp->mb[11] = req->vp_idx; |
| 3793 | mcp->mb[13] = req->rid; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3794 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3795 | mcp->mb[15] = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3796 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3797 | mcp->mb[4] = req->id; |
| 3798 | /* que in ptr index */ |
| 3799 | mcp->mb[8] = 0; |
| 3800 | /* que out ptr index */ |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 3801 | mcp->mb[9] = *req->out_ptr = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3802 | mcp->out_mb = MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8|MBX_7| |
| 3803 | MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3804 | mcp->in_mb = MBX_0; |
| 3805 | mcp->flags = MBX_DMA_OUT; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3806 | mcp->tov = MBX_TOV_SECONDS * 2; |
| 3807 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3808 | if (IS_QLA81XX(ha) || IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3809 | mcp->in_mb |= MBX_1; |
Joe Carnuccio | ba4828b | 2014-04-11 16:54:10 -0400 | [diff] [blame] | 3810 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3811 | mcp->out_mb |= MBX_15; |
| 3812 | /* debug q create issue in SR-IOV */ |
| 3813 | mcp->in_mb |= MBX_9 | MBX_8 | MBX_7; |
| 3814 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3815 | |
| 3816 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 3817 | if (!(req->options & BIT_0)) { |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 3818 | WRT_REG_DWORD(req->req_q_in, 0); |
Joe Carnuccio | 29db41c | 2014-04-11 16:54:09 -0400 | [diff] [blame] | 3819 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 3820 | WRT_REG_DWORD(req->req_q_out, 0); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3821 | } |
| 3822 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 3823 | |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 3824 | rval = qla2x00_mailbox_command(vha, mcp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3825 | if (rval != QLA_SUCCESS) { |
| 3826 | ql_dbg(ql_dbg_mbx, vha, 0x10d4, |
| 3827 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 3828 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3829 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d5, |
| 3830 | "Done %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3831 | } |
| 3832 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3833 | return rval; |
| 3834 | } |
| 3835 | |
| 3836 | int |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 3837 | 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] | 3838 | { |
| 3839 | int rval; |
| 3840 | unsigned long flags; |
| 3841 | mbx_cmd_t mc; |
| 3842 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3843 | struct qla_hw_data *ha = vha->hw; |
| 3844 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3845 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d6, |
| 3846 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3847 | |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 3848 | if (IS_SHADOW_REG_CAPABLE(ha)) |
| 3849 | rsp->options |= BIT_13; |
| 3850 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3851 | mcp->mb[0] = MBC_INITIALIZE_MULTIQ; |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 3852 | mcp->mb[1] = rsp->options; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3853 | mcp->mb[2] = MSW(LSD(rsp->dma)); |
| 3854 | mcp->mb[3] = LSW(LSD(rsp->dma)); |
| 3855 | mcp->mb[6] = MSW(MSD(rsp->dma)); |
| 3856 | mcp->mb[7] = LSW(MSD(rsp->dma)); |
| 3857 | mcp->mb[5] = rsp->length; |
Andrew Vasquez | 444786d | 2009-01-05 11:18:10 -0800 | [diff] [blame] | 3858 | mcp->mb[14] = rsp->msix->entry; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3859 | mcp->mb[13] = rsp->rid; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3860 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3861 | mcp->mb[15] = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3862 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3863 | mcp->mb[4] = rsp->id; |
| 3864 | /* que in ptr index */ |
Joe Carnuccio | 7c6300e | 2014-04-11 16:54:37 -0400 | [diff] [blame] | 3865 | mcp->mb[8] = *rsp->in_ptr = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3866 | /* que out ptr index */ |
| 3867 | mcp->mb[9] = 0; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3868 | 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] | 3869 | |MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3870 | mcp->in_mb = MBX_0; |
| 3871 | mcp->flags = MBX_DMA_OUT; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3872 | mcp->tov = MBX_TOV_SECONDS * 2; |
| 3873 | |
| 3874 | if (IS_QLA81XX(ha)) { |
| 3875 | mcp->out_mb |= MBX_12|MBX_11|MBX_10; |
| 3876 | mcp->in_mb |= MBX_1; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3877 | } else if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3878 | mcp->out_mb |= MBX_15|MBX_12|MBX_11|MBX_10; |
| 3879 | mcp->in_mb |= MBX_1; |
| 3880 | /* debug q create issue in SR-IOV */ |
| 3881 | mcp->in_mb |= MBX_9 | MBX_8 | MBX_7; |
| 3882 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3883 | |
| 3884 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 3885 | if (!(rsp->options & BIT_0)) { |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 3886 | WRT_REG_DWORD(rsp->rsp_q_out, 0); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3887 | if (!IS_QLA83XX(ha)) |
Andrew Vasquez | da9b1d5 | 2013-08-27 01:37:30 -0400 | [diff] [blame] | 3888 | WRT_REG_DWORD(rsp->rsp_q_in, 0); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3889 | } |
| 3890 | |
| 3891 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 3892 | |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 3893 | rval = qla2x00_mailbox_command(vha, mcp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3894 | if (rval != QLA_SUCCESS) { |
| 3895 | ql_dbg(ql_dbg_mbx, vha, 0x10d7, |
| 3896 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 3897 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3898 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d8, |
| 3899 | "Done %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3900 | } |
| 3901 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3902 | return rval; |
| 3903 | } |
| 3904 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3905 | int |
| 3906 | qla81xx_idc_ack(scsi_qla_host_t *vha, uint16_t *mb) |
| 3907 | { |
| 3908 | int rval; |
| 3909 | mbx_cmd_t mc; |
| 3910 | mbx_cmd_t *mcp = &mc; |
| 3911 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3912 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d9, |
| 3913 | "Entered %s.\n", __func__); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3914 | |
| 3915 | mcp->mb[0] = MBC_IDC_ACK; |
| 3916 | memcpy(&mcp->mb[1], mb, QLA_IDC_ACK_REGS * sizeof(uint16_t)); |
| 3917 | mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3918 | mcp->in_mb = MBX_0; |
| 3919 | mcp->tov = MBX_TOV_SECONDS; |
| 3920 | mcp->flags = 0; |
| 3921 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3922 | |
| 3923 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3924 | ql_dbg(ql_dbg_mbx, vha, 0x10da, |
| 3925 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3926 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3927 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10db, |
| 3928 | "Done %s.\n", __func__); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3929 | } |
| 3930 | |
| 3931 | return rval; |
| 3932 | } |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3933 | |
| 3934 | int |
| 3935 | qla81xx_fac_get_sector_size(scsi_qla_host_t *vha, uint32_t *sector_size) |
| 3936 | { |
| 3937 | int rval; |
| 3938 | mbx_cmd_t mc; |
| 3939 | mbx_cmd_t *mcp = &mc; |
| 3940 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3941 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10dc, |
| 3942 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3943 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3944 | if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) && |
| 3945 | !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3946 | return QLA_FUNCTION_FAILED; |
| 3947 | |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3948 | mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; |
| 3949 | mcp->mb[1] = FAC_OPT_CMD_GET_SECTOR_SIZE; |
| 3950 | mcp->out_mb = MBX_1|MBX_0; |
| 3951 | mcp->in_mb = MBX_1|MBX_0; |
| 3952 | mcp->tov = MBX_TOV_SECONDS; |
| 3953 | mcp->flags = 0; |
| 3954 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3955 | |
| 3956 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3957 | ql_dbg(ql_dbg_mbx, vha, 0x10dd, |
| 3958 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3959 | rval, mcp->mb[0], mcp->mb[1]); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3960 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3961 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10de, |
| 3962 | "Done %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3963 | *sector_size = mcp->mb[1]; |
| 3964 | } |
| 3965 | |
| 3966 | return rval; |
| 3967 | } |
| 3968 | |
| 3969 | int |
| 3970 | qla81xx_fac_do_write_enable(scsi_qla_host_t *vha, int enable) |
| 3971 | { |
| 3972 | int rval; |
| 3973 | mbx_cmd_t mc; |
| 3974 | mbx_cmd_t *mcp = &mc; |
| 3975 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3976 | if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) && |
| 3977 | !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3978 | return QLA_FUNCTION_FAILED; |
| 3979 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3980 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10df, |
| 3981 | "Entered %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3982 | |
| 3983 | mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; |
| 3984 | mcp->mb[1] = enable ? FAC_OPT_CMD_WRITE_ENABLE : |
| 3985 | FAC_OPT_CMD_WRITE_PROTECT; |
| 3986 | mcp->out_mb = MBX_1|MBX_0; |
| 3987 | mcp->in_mb = MBX_1|MBX_0; |
| 3988 | mcp->tov = MBX_TOV_SECONDS; |
| 3989 | mcp->flags = 0; |
| 3990 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3991 | |
| 3992 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3993 | ql_dbg(ql_dbg_mbx, vha, 0x10e0, |
| 3994 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3995 | rval, mcp->mb[0], mcp->mb[1]); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3996 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 3997 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e1, |
| 3998 | "Done %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3999 | } |
| 4000 | |
| 4001 | return rval; |
| 4002 | } |
| 4003 | |
| 4004 | int |
| 4005 | qla81xx_fac_erase_sector(scsi_qla_host_t *vha, uint32_t start, uint32_t finish) |
| 4006 | { |
| 4007 | int rval; |
| 4008 | mbx_cmd_t mc; |
| 4009 | mbx_cmd_t *mcp = &mc; |
| 4010 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4011 | if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) && |
| 4012 | !IS_QLA27XX(vha->hw)) |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4013 | return QLA_FUNCTION_FAILED; |
| 4014 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4015 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e2, |
| 4016 | "Entered %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4017 | |
| 4018 | mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; |
| 4019 | mcp->mb[1] = FAC_OPT_CMD_ERASE_SECTOR; |
| 4020 | mcp->mb[2] = LSW(start); |
| 4021 | mcp->mb[3] = MSW(start); |
| 4022 | mcp->mb[4] = LSW(finish); |
| 4023 | mcp->mb[5] = MSW(finish); |
| 4024 | mcp->out_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4025 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 4026 | mcp->tov = MBX_TOV_SECONDS; |
| 4027 | mcp->flags = 0; |
| 4028 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4029 | |
| 4030 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4031 | ql_dbg(ql_dbg_mbx, vha, 0x10e3, |
| 4032 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 4033 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4034 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4035 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e4, |
| 4036 | "Done %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 4037 | } |
| 4038 | |
| 4039 | return rval; |
| 4040 | } |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4041 | |
| 4042 | int |
| 4043 | qla81xx_restart_mpi_firmware(scsi_qla_host_t *vha) |
| 4044 | { |
| 4045 | int rval = 0; |
| 4046 | mbx_cmd_t mc; |
| 4047 | mbx_cmd_t *mcp = &mc; |
| 4048 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4049 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e5, |
| 4050 | "Entered %s.\n", __func__); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4051 | |
| 4052 | mcp->mb[0] = MBC_RESTART_MPI_FW; |
| 4053 | mcp->out_mb = MBX_0; |
| 4054 | mcp->in_mb = MBX_0|MBX_1; |
| 4055 | mcp->tov = MBX_TOV_SECONDS; |
| 4056 | mcp->flags = 0; |
| 4057 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4058 | |
| 4059 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4060 | ql_dbg(ql_dbg_mbx, vha, 0x10e6, |
| 4061 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 4062 | rval, mcp->mb[0], mcp->mb[1]); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4063 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4064 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e7, |
| 4065 | "Done %s.\n", __func__); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 4066 | } |
| 4067 | |
| 4068 | return rval; |
| 4069 | } |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4070 | |
Joe Carnuccio | c46e65c | 2013-08-27 01:37:35 -0400 | [diff] [blame] | 4071 | int |
| 4072 | qla82xx_set_driver_version(scsi_qla_host_t *vha, char *version) |
| 4073 | { |
| 4074 | int rval; |
| 4075 | mbx_cmd_t mc; |
| 4076 | mbx_cmd_t *mcp = &mc; |
| 4077 | int i; |
| 4078 | int len; |
| 4079 | uint16_t *str; |
| 4080 | struct qla_hw_data *ha = vha->hw; |
| 4081 | |
| 4082 | if (!IS_P3P_TYPE(ha)) |
| 4083 | return QLA_FUNCTION_FAILED; |
| 4084 | |
| 4085 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x117b, |
| 4086 | "Entered %s.\n", __func__); |
| 4087 | |
| 4088 | str = (void *)version; |
| 4089 | len = strlen(version); |
| 4090 | |
| 4091 | mcp->mb[0] = MBC_SET_RNID_PARAMS; |
| 4092 | mcp->mb[1] = RNID_TYPE_SET_VERSION << 8; |
| 4093 | mcp->out_mb = MBX_1|MBX_0; |
| 4094 | for (i = 4; i < 16 && len; i++, str++, len -= 2) { |
| 4095 | mcp->mb[i] = cpu_to_le16p(str); |
| 4096 | mcp->out_mb |= 1<<i; |
| 4097 | } |
| 4098 | for (; i < 16; i++) { |
| 4099 | mcp->mb[i] = 0; |
| 4100 | mcp->out_mb |= 1<<i; |
| 4101 | } |
| 4102 | mcp->in_mb = MBX_1|MBX_0; |
| 4103 | mcp->tov = MBX_TOV_SECONDS; |
| 4104 | mcp->flags = 0; |
| 4105 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4106 | |
| 4107 | if (rval != QLA_SUCCESS) { |
| 4108 | ql_dbg(ql_dbg_mbx, vha, 0x117c, |
| 4109 | "Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]); |
| 4110 | } else { |
| 4111 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x117d, |
| 4112 | "Done %s.\n", __func__); |
| 4113 | } |
| 4114 | |
| 4115 | return rval; |
| 4116 | } |
| 4117 | |
| 4118 | int |
| 4119 | qla25xx_set_driver_version(scsi_qla_host_t *vha, char *version) |
| 4120 | { |
| 4121 | int rval; |
| 4122 | mbx_cmd_t mc; |
| 4123 | mbx_cmd_t *mcp = &mc; |
| 4124 | int len; |
| 4125 | uint16_t dwlen; |
| 4126 | uint8_t *str; |
| 4127 | dma_addr_t str_dma; |
| 4128 | struct qla_hw_data *ha = vha->hw; |
| 4129 | |
| 4130 | if (!IS_FWI2_CAPABLE(ha) || IS_QLA24XX_TYPE(ha) || IS_QLA81XX(ha) || |
| 4131 | IS_P3P_TYPE(ha)) |
| 4132 | return QLA_FUNCTION_FAILED; |
| 4133 | |
| 4134 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x117e, |
| 4135 | "Entered %s.\n", __func__); |
| 4136 | |
| 4137 | str = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &str_dma); |
| 4138 | if (!str) { |
| 4139 | ql_log(ql_log_warn, vha, 0x117f, |
| 4140 | "Failed to allocate driver version param.\n"); |
| 4141 | return QLA_MEMORY_ALLOC_FAILED; |
| 4142 | } |
| 4143 | |
| 4144 | memcpy(str, "\x7\x3\x11\x0", 4); |
| 4145 | dwlen = str[0]; |
| 4146 | len = dwlen * 4 - 4; |
| 4147 | memset(str + 4, 0, len); |
| 4148 | if (len > strlen(version)) |
| 4149 | len = strlen(version); |
| 4150 | memcpy(str + 4, version, len); |
| 4151 | |
| 4152 | mcp->mb[0] = MBC_SET_RNID_PARAMS; |
| 4153 | mcp->mb[1] = RNID_TYPE_SET_VERSION << 8 | dwlen; |
| 4154 | mcp->mb[2] = MSW(LSD(str_dma)); |
| 4155 | mcp->mb[3] = LSW(LSD(str_dma)); |
| 4156 | mcp->mb[6] = MSW(MSD(str_dma)); |
| 4157 | mcp->mb[7] = LSW(MSD(str_dma)); |
| 4158 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4159 | mcp->in_mb = MBX_1|MBX_0; |
| 4160 | mcp->tov = MBX_TOV_SECONDS; |
| 4161 | mcp->flags = 0; |
| 4162 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4163 | |
| 4164 | if (rval != QLA_SUCCESS) { |
| 4165 | ql_dbg(ql_dbg_mbx, vha, 0x1180, |
| 4166 | "Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]); |
| 4167 | } else { |
| 4168 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1181, |
| 4169 | "Done %s.\n", __func__); |
| 4170 | } |
| 4171 | |
| 4172 | dma_pool_free(ha->s_dma_pool, str, str_dma); |
| 4173 | |
| 4174 | return rval; |
| 4175 | } |
| 4176 | |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 4177 | static int |
| 4178 | qla2x00_read_asic_temperature(scsi_qla_host_t *vha, uint16_t *temp) |
| 4179 | { |
| 4180 | int rval; |
| 4181 | mbx_cmd_t mc; |
| 4182 | mbx_cmd_t *mcp = &mc; |
| 4183 | |
| 4184 | if (!IS_FWI2_CAPABLE(vha->hw)) |
| 4185 | return QLA_FUNCTION_FAILED; |
| 4186 | |
| 4187 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1159, |
| 4188 | "Entered %s.\n", __func__); |
| 4189 | |
| 4190 | mcp->mb[0] = MBC_GET_RNID_PARAMS; |
| 4191 | mcp->mb[1] = RNID_TYPE_ASIC_TEMP << 8; |
| 4192 | mcp->out_mb = MBX_1|MBX_0; |
| 4193 | mcp->in_mb = MBX_1|MBX_0; |
| 4194 | mcp->tov = MBX_TOV_SECONDS; |
| 4195 | mcp->flags = 0; |
| 4196 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4197 | *temp = mcp->mb[1]; |
| 4198 | |
| 4199 | if (rval != QLA_SUCCESS) { |
| 4200 | ql_dbg(ql_dbg_mbx, vha, 0x115a, |
| 4201 | "Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]); |
| 4202 | } else { |
| 4203 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x115b, |
| 4204 | "Done %s.\n", __func__); |
| 4205 | } |
| 4206 | |
| 4207 | return rval; |
| 4208 | } |
| 4209 | |
Joe Carnuccio | 3a11711 | 2013-02-08 01:58:00 -0500 | [diff] [blame] | 4210 | int |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4211 | qla2x00_read_sfp(scsi_qla_host_t *vha, dma_addr_t sfp_dma, uint8_t *sfp, |
| 4212 | uint16_t dev, uint16_t off, uint16_t len, uint16_t opt) |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4213 | { |
| 4214 | int rval; |
| 4215 | mbx_cmd_t mc; |
| 4216 | mbx_cmd_t *mcp = &mc; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4217 | struct qla_hw_data *ha = vha->hw; |
| 4218 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4219 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e8, |
| 4220 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4221 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4222 | if (!IS_FWI2_CAPABLE(ha)) |
| 4223 | return QLA_FUNCTION_FAILED; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4224 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4225 | if (len == 1) |
| 4226 | opt |= BIT_0; |
| 4227 | |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4228 | mcp->mb[0] = MBC_READ_SFP; |
| 4229 | mcp->mb[1] = dev; |
| 4230 | mcp->mb[2] = MSW(sfp_dma); |
| 4231 | mcp->mb[3] = LSW(sfp_dma); |
| 4232 | mcp->mb[6] = MSW(MSD(sfp_dma)); |
| 4233 | mcp->mb[7] = LSW(MSD(sfp_dma)); |
| 4234 | mcp->mb[8] = len; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4235 | mcp->mb[9] = off; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4236 | mcp->mb[10] = opt; |
| 4237 | 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] | 4238 | mcp->in_mb = MBX_1|MBX_0; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4239 | mcp->tov = MBX_TOV_SECONDS; |
| 4240 | mcp->flags = 0; |
| 4241 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4242 | |
| 4243 | if (opt & BIT_0) |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4244 | *sfp = mcp->mb[1]; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4245 | |
| 4246 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4247 | ql_dbg(ql_dbg_mbx, vha, 0x10e9, |
| 4248 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4249 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4250 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ea, |
| 4251 | "Done %s.\n", __func__); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4252 | } |
| 4253 | |
| 4254 | return rval; |
| 4255 | } |
| 4256 | |
| 4257 | int |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4258 | qla2x00_write_sfp(scsi_qla_host_t *vha, dma_addr_t sfp_dma, uint8_t *sfp, |
| 4259 | uint16_t dev, uint16_t off, uint16_t len, uint16_t opt) |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4260 | { |
| 4261 | int rval; |
| 4262 | mbx_cmd_t mc; |
| 4263 | mbx_cmd_t *mcp = &mc; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4264 | struct qla_hw_data *ha = vha->hw; |
| 4265 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4266 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10eb, |
| 4267 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4268 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4269 | if (!IS_FWI2_CAPABLE(ha)) |
| 4270 | return QLA_FUNCTION_FAILED; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4271 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4272 | if (len == 1) |
| 4273 | opt |= BIT_0; |
| 4274 | |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4275 | if (opt & BIT_0) |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4276 | len = *sfp; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4277 | |
| 4278 | mcp->mb[0] = MBC_WRITE_SFP; |
| 4279 | mcp->mb[1] = dev; |
| 4280 | mcp->mb[2] = MSW(sfp_dma); |
| 4281 | mcp->mb[3] = LSW(sfp_dma); |
| 4282 | mcp->mb[6] = MSW(MSD(sfp_dma)); |
| 4283 | mcp->mb[7] = LSW(MSD(sfp_dma)); |
| 4284 | mcp->mb[8] = len; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 4285 | mcp->mb[9] = off; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4286 | mcp->mb[10] = opt; |
| 4287 | 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] | 4288 | mcp->in_mb = MBX_1|MBX_0; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4289 | mcp->tov = MBX_TOV_SECONDS; |
| 4290 | mcp->flags = 0; |
| 4291 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4292 | |
| 4293 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4294 | ql_dbg(ql_dbg_mbx, vha, 0x10ec, |
| 4295 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4296 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4297 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ed, |
| 4298 | "Done %s.\n", __func__); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 4299 | } |
| 4300 | |
| 4301 | return rval; |
| 4302 | } |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4303 | |
| 4304 | int |
| 4305 | qla2x00_get_xgmac_stats(scsi_qla_host_t *vha, dma_addr_t stats_dma, |
| 4306 | uint16_t size_in_bytes, uint16_t *actual_size) |
| 4307 | { |
| 4308 | int rval; |
| 4309 | mbx_cmd_t mc; |
| 4310 | mbx_cmd_t *mcp = &mc; |
| 4311 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4312 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ee, |
| 4313 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4314 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4315 | if (!IS_CNA_CAPABLE(vha->hw)) |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4316 | return QLA_FUNCTION_FAILED; |
| 4317 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4318 | mcp->mb[0] = MBC_GET_XGMAC_STATS; |
| 4319 | mcp->mb[2] = MSW(stats_dma); |
| 4320 | mcp->mb[3] = LSW(stats_dma); |
| 4321 | mcp->mb[6] = MSW(MSD(stats_dma)); |
| 4322 | mcp->mb[7] = LSW(MSD(stats_dma)); |
| 4323 | mcp->mb[8] = size_in_bytes >> 2; |
| 4324 | mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; |
| 4325 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 4326 | mcp->tov = MBX_TOV_SECONDS; |
| 4327 | mcp->flags = 0; |
| 4328 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4329 | |
| 4330 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4331 | ql_dbg(ql_dbg_mbx, vha, 0x10ef, |
| 4332 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 4333 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4334 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4335 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f0, |
| 4336 | "Done %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4337 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4338 | |
| 4339 | *actual_size = mcp->mb[2] << 2; |
| 4340 | } |
| 4341 | |
| 4342 | return rval; |
| 4343 | } |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4344 | |
| 4345 | int |
| 4346 | qla2x00_get_dcbx_params(scsi_qla_host_t *vha, dma_addr_t tlv_dma, |
| 4347 | uint16_t size) |
| 4348 | { |
| 4349 | int rval; |
| 4350 | mbx_cmd_t mc; |
| 4351 | mbx_cmd_t *mcp = &mc; |
| 4352 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4353 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f1, |
| 4354 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4355 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4356 | if (!IS_CNA_CAPABLE(vha->hw)) |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4357 | return QLA_FUNCTION_FAILED; |
| 4358 | |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4359 | mcp->mb[0] = MBC_GET_DCBX_PARAMS; |
| 4360 | mcp->mb[1] = 0; |
| 4361 | mcp->mb[2] = MSW(tlv_dma); |
| 4362 | mcp->mb[3] = LSW(tlv_dma); |
| 4363 | mcp->mb[6] = MSW(MSD(tlv_dma)); |
| 4364 | mcp->mb[7] = LSW(MSD(tlv_dma)); |
| 4365 | mcp->mb[8] = size; |
| 4366 | mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4367 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 4368 | mcp->tov = MBX_TOV_SECONDS; |
| 4369 | mcp->flags = 0; |
| 4370 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4371 | |
| 4372 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4373 | ql_dbg(ql_dbg_mbx, vha, 0x10f2, |
| 4374 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 4375 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4376 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4377 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f3, |
| 4378 | "Done %s.\n", __func__); |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4379 | } |
| 4380 | |
| 4381 | return rval; |
| 4382 | } |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4383 | |
| 4384 | int |
| 4385 | qla2x00_read_ram_word(scsi_qla_host_t *vha, uint32_t risc_addr, uint32_t *data) |
| 4386 | { |
| 4387 | int rval; |
| 4388 | mbx_cmd_t mc; |
| 4389 | mbx_cmd_t *mcp = &mc; |
| 4390 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4391 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f4, |
| 4392 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4393 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4394 | if (!IS_FWI2_CAPABLE(vha->hw)) |
| 4395 | return QLA_FUNCTION_FAILED; |
| 4396 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4397 | mcp->mb[0] = MBC_READ_RAM_EXTENDED; |
| 4398 | mcp->mb[1] = LSW(risc_addr); |
| 4399 | mcp->mb[8] = MSW(risc_addr); |
| 4400 | mcp->out_mb = MBX_8|MBX_1|MBX_0; |
| 4401 | mcp->in_mb = MBX_3|MBX_2|MBX_0; |
| 4402 | mcp->tov = 30; |
| 4403 | mcp->flags = 0; |
| 4404 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4405 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4406 | ql_dbg(ql_dbg_mbx, vha, 0x10f5, |
| 4407 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4408 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4409 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f6, |
| 4410 | "Done %s.\n", __func__); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4411 | *data = mcp->mb[3] << 16 | mcp->mb[2]; |
| 4412 | } |
| 4413 | |
| 4414 | return rval; |
| 4415 | } |
| 4416 | |
| 4417 | int |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4418 | qla2x00_loopback_test(scsi_qla_host_t *vha, struct msg_echo_lb *mreq, |
| 4419 | uint16_t *mresp) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4420 | { |
| 4421 | int rval; |
| 4422 | mbx_cmd_t mc; |
| 4423 | mbx_cmd_t *mcp = &mc; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4424 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4425 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f7, |
| 4426 | "Entered %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4427 | |
| 4428 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 4429 | mcp->mb[0] = MBC_DIAGNOSTIC_LOOP_BACK; |
| 4430 | mcp->mb[1] = mreq->options | BIT_6; // BIT_6 specifies 64 bit addressing |
| 4431 | |
| 4432 | /* transfer count */ |
| 4433 | mcp->mb[10] = LSW(mreq->transfer_size); |
| 4434 | mcp->mb[11] = MSW(mreq->transfer_size); |
| 4435 | |
| 4436 | /* send data address */ |
| 4437 | mcp->mb[14] = LSW(mreq->send_dma); |
| 4438 | mcp->mb[15] = MSW(mreq->send_dma); |
| 4439 | mcp->mb[20] = LSW(MSD(mreq->send_dma)); |
| 4440 | mcp->mb[21] = MSW(MSD(mreq->send_dma)); |
| 4441 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 4442 | /* receive data address */ |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4443 | mcp->mb[16] = LSW(mreq->rcv_dma); |
| 4444 | mcp->mb[17] = MSW(mreq->rcv_dma); |
| 4445 | mcp->mb[6] = LSW(MSD(mreq->rcv_dma)); |
| 4446 | mcp->mb[7] = MSW(MSD(mreq->rcv_dma)); |
| 4447 | |
| 4448 | /* Iteration count */ |
Joe Carnuccio | 1b98b42 | 2013-03-28 08:21:26 -0400 | [diff] [blame] | 4449 | mcp->mb[18] = LSW(mreq->iteration_count); |
| 4450 | mcp->mb[19] = MSW(mreq->iteration_count); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4451 | |
| 4452 | mcp->out_mb = MBX_21|MBX_20|MBX_19|MBX_18|MBX_17|MBX_16|MBX_15| |
| 4453 | 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] | 4454 | if (IS_CNA_CAPABLE(vha->hw)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4455 | mcp->out_mb |= MBX_2; |
| 4456 | mcp->in_mb = MBX_19|MBX_18|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4457 | |
| 4458 | mcp->buf_size = mreq->transfer_size; |
| 4459 | mcp->tov = MBX_TOV_SECONDS; |
| 4460 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 4461 | |
| 4462 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4463 | |
| 4464 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4465 | ql_dbg(ql_dbg_mbx, vha, 0x10f8, |
| 4466 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[3]=%x mb[18]=%x " |
| 4467 | "mb[19]=%x.\n", rval, mcp->mb[0], mcp->mb[1], mcp->mb[2], |
| 4468 | mcp->mb[3], mcp->mb[18], mcp->mb[19]); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4469 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4470 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10f9, |
| 4471 | "Done %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4472 | } |
| 4473 | |
| 4474 | /* Copy mailbox information */ |
| 4475 | memcpy( mresp, mcp->mb, 64); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4476 | return rval; |
| 4477 | } |
| 4478 | |
| 4479 | int |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4480 | qla2x00_echo_test(scsi_qla_host_t *vha, struct msg_echo_lb *mreq, |
| 4481 | uint16_t *mresp) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4482 | { |
| 4483 | int rval; |
| 4484 | mbx_cmd_t mc; |
| 4485 | mbx_cmd_t *mcp = &mc; |
| 4486 | struct qla_hw_data *ha = vha->hw; |
| 4487 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4488 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10fa, |
| 4489 | "Entered %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4490 | |
| 4491 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 4492 | mcp->mb[0] = MBC_DIAGNOSTIC_ECHO; |
| 4493 | mcp->mb[1] = mreq->options | BIT_6; /* BIT_6 specifies 64bit address */ |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4494 | if (IS_CNA_CAPABLE(ha)) { |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4495 | mcp->mb[1] |= BIT_15; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4496 | mcp->mb[2] = vha->fcoe_fcf_idx; |
| 4497 | } |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4498 | mcp->mb[16] = LSW(mreq->rcv_dma); |
| 4499 | mcp->mb[17] = MSW(mreq->rcv_dma); |
| 4500 | mcp->mb[6] = LSW(MSD(mreq->rcv_dma)); |
| 4501 | mcp->mb[7] = MSW(MSD(mreq->rcv_dma)); |
| 4502 | |
| 4503 | mcp->mb[10] = LSW(mreq->transfer_size); |
| 4504 | |
| 4505 | mcp->mb[14] = LSW(mreq->send_dma); |
| 4506 | mcp->mb[15] = MSW(mreq->send_dma); |
| 4507 | mcp->mb[20] = LSW(MSD(mreq->send_dma)); |
| 4508 | mcp->mb[21] = MSW(MSD(mreq->send_dma)); |
| 4509 | |
| 4510 | mcp->out_mb = MBX_21|MBX_20|MBX_17|MBX_16|MBX_15| |
| 4511 | MBX_14|MBX_10|MBX_7|MBX_6|MBX_1|MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4512 | if (IS_CNA_CAPABLE(ha)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4513 | mcp->out_mb |= MBX_2; |
| 4514 | |
| 4515 | mcp->in_mb = MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4516 | if (IS_QLA24XX_TYPE(ha) || IS_QLA25XX(ha) || |
| 4517 | IS_CNA_CAPABLE(ha) || IS_QLA2031(ha)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4518 | mcp->in_mb |= MBX_1; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4519 | if (IS_CNA_CAPABLE(ha) || IS_QLA2031(ha)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4520 | mcp->in_mb |= MBX_3; |
| 4521 | |
| 4522 | mcp->tov = MBX_TOV_SECONDS; |
| 4523 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 4524 | mcp->buf_size = mreq->transfer_size; |
| 4525 | |
| 4526 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4527 | |
| 4528 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4529 | ql_dbg(ql_dbg_mbx, vha, 0x10fb, |
| 4530 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 4531 | rval, mcp->mb[0], mcp->mb[1]); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4532 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4533 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10fc, |
| 4534 | "Done %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4535 | } |
| 4536 | |
| 4537 | /* Copy mailbox information */ |
Giridhar Malavali | 6dbdda4 | 2010-09-03 15:20:49 -0700 | [diff] [blame] | 4538 | memcpy(mresp, mcp->mb, 64); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4539 | return rval; |
| 4540 | } |
Giridhar Malavali | 6dbdda4 | 2010-09-03 15:20:49 -0700 | [diff] [blame] | 4541 | |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4542 | int |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4543 | qla84xx_reset_chip(scsi_qla_host_t *vha, uint16_t enable_diagnostic) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4544 | { |
| 4545 | int rval; |
| 4546 | mbx_cmd_t mc; |
| 4547 | mbx_cmd_t *mcp = &mc; |
| 4548 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4549 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10fd, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4550 | "Entered %s enable_diag=%d.\n", __func__, enable_diagnostic); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4551 | |
| 4552 | mcp->mb[0] = MBC_ISP84XX_RESET; |
| 4553 | mcp->mb[1] = enable_diagnostic; |
| 4554 | mcp->out_mb = MBX_1|MBX_0; |
| 4555 | mcp->in_mb = MBX_1|MBX_0; |
| 4556 | mcp->tov = MBX_TOV_SECONDS; |
| 4557 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4558 | rval = qla2x00_mailbox_command(vha, mcp); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4559 | |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4560 | if (rval != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4561 | ql_dbg(ql_dbg_mbx, vha, 0x10fe, "Failed=%x.\n", rval); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4562 | else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4563 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ff, |
| 4564 | "Done %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 4565 | |
| 4566 | return rval; |
| 4567 | } |
| 4568 | |
| 4569 | int |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4570 | qla2x00_write_ram_word(scsi_qla_host_t *vha, uint32_t risc_addr, uint32_t data) |
| 4571 | { |
| 4572 | int rval; |
| 4573 | mbx_cmd_t mc; |
| 4574 | mbx_cmd_t *mcp = &mc; |
| 4575 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4576 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1100, |
| 4577 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4578 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4579 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | 6c452a4 | 2010-03-19 17:04:02 -0700 | [diff] [blame] | 4580 | return QLA_FUNCTION_FAILED; |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4581 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4582 | mcp->mb[0] = MBC_WRITE_RAM_WORD_EXTENDED; |
| 4583 | mcp->mb[1] = LSW(risc_addr); |
| 4584 | mcp->mb[2] = LSW(data); |
| 4585 | mcp->mb[3] = MSW(data); |
| 4586 | mcp->mb[8] = MSW(risc_addr); |
| 4587 | mcp->out_mb = MBX_8|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4588 | mcp->in_mb = MBX_0; |
| 4589 | mcp->tov = 30; |
| 4590 | mcp->flags = 0; |
| 4591 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4592 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4593 | ql_dbg(ql_dbg_mbx, vha, 0x1101, |
| 4594 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4595 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4596 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1102, |
| 4597 | "Done %s.\n", __func__); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 4598 | } |
| 4599 | |
| 4600 | return rval; |
| 4601 | } |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 4602 | |
| 4603 | int |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 4604 | qla81xx_write_mpi_register(scsi_qla_host_t *vha, uint16_t *mb) |
| 4605 | { |
| 4606 | int rval; |
| 4607 | uint32_t stat, timer; |
| 4608 | uint16_t mb0 = 0; |
| 4609 | struct qla_hw_data *ha = vha->hw; |
| 4610 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 4611 | |
| 4612 | rval = QLA_SUCCESS; |
| 4613 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4614 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1103, |
| 4615 | "Entered %s.\n", __func__); |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 4616 | |
| 4617 | clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
| 4618 | |
| 4619 | /* Write the MBC data to the registers */ |
| 4620 | WRT_REG_WORD(®->mailbox0, MBC_WRITE_MPI_REGISTER); |
| 4621 | WRT_REG_WORD(®->mailbox1, mb[0]); |
| 4622 | WRT_REG_WORD(®->mailbox2, mb[1]); |
| 4623 | WRT_REG_WORD(®->mailbox3, mb[2]); |
| 4624 | WRT_REG_WORD(®->mailbox4, mb[3]); |
| 4625 | |
| 4626 | WRT_REG_DWORD(®->hccr, HCCRX_SET_HOST_INT); |
| 4627 | |
| 4628 | /* Poll for MBC interrupt */ |
| 4629 | for (timer = 6000000; timer; timer--) { |
| 4630 | /* Check for pending interrupts. */ |
| 4631 | stat = RD_REG_DWORD(®->host_status); |
| 4632 | if (stat & HSRX_RISC_INT) { |
| 4633 | stat &= 0xff; |
| 4634 | |
| 4635 | if (stat == 0x1 || stat == 0x2 || |
| 4636 | stat == 0x10 || stat == 0x11) { |
| 4637 | set_bit(MBX_INTERRUPT, |
| 4638 | &ha->mbx_cmd_flags); |
| 4639 | mb0 = RD_REG_WORD(®->mailbox0); |
| 4640 | WRT_REG_DWORD(®->hccr, |
| 4641 | HCCRX_CLR_RISC_INT); |
| 4642 | RD_REG_DWORD(®->hccr); |
| 4643 | break; |
| 4644 | } |
| 4645 | } |
| 4646 | udelay(5); |
| 4647 | } |
| 4648 | |
| 4649 | if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) |
| 4650 | rval = mb0 & MBS_MASK; |
| 4651 | else |
| 4652 | rval = QLA_FUNCTION_FAILED; |
| 4653 | |
| 4654 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4655 | ql_dbg(ql_dbg_mbx, vha, 0x1104, |
| 4656 | "Failed=%x mb[0]=%x.\n", rval, mb[0]); |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 4657 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4658 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1105, |
| 4659 | "Done %s.\n", __func__); |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 4660 | } |
| 4661 | |
| 4662 | return rval; |
| 4663 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4664 | |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 4665 | int |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 4666 | qla2x00_get_data_rate(scsi_qla_host_t *vha) |
| 4667 | { |
| 4668 | int rval; |
| 4669 | mbx_cmd_t mc; |
| 4670 | mbx_cmd_t *mcp = &mc; |
| 4671 | struct qla_hw_data *ha = vha->hw; |
| 4672 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4673 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1106, |
| 4674 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4675 | |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 4676 | if (!IS_FWI2_CAPABLE(ha)) |
| 4677 | return QLA_FUNCTION_FAILED; |
| 4678 | |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 4679 | mcp->mb[0] = MBC_DATA_RATE; |
| 4680 | mcp->mb[1] = 0; |
| 4681 | mcp->out_mb = MBX_1|MBX_0; |
| 4682 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4683 | if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4684 | mcp->in_mb |= MBX_3; |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 4685 | mcp->tov = MBX_TOV_SECONDS; |
| 4686 | mcp->flags = 0; |
| 4687 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4688 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4689 | ql_dbg(ql_dbg_mbx, vha, 0x1107, |
| 4690 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 4691 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4692 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1108, |
| 4693 | "Done %s.\n", __func__); |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 4694 | if (mcp->mb[1] != 0x7) |
| 4695 | ha->link_data_rate = mcp->mb[1]; |
| 4696 | } |
| 4697 | |
| 4698 | return rval; |
| 4699 | } |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 4700 | |
| 4701 | int |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 4702 | qla81xx_get_port_config(scsi_qla_host_t *vha, uint16_t *mb) |
| 4703 | { |
| 4704 | int rval; |
| 4705 | mbx_cmd_t mc; |
| 4706 | mbx_cmd_t *mcp = &mc; |
| 4707 | struct qla_hw_data *ha = vha->hw; |
| 4708 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4709 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1109, |
| 4710 | "Entered %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 4711 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4712 | if (!IS_QLA81XX(ha) && !IS_QLA83XX(ha) && !IS_QLA8044(ha) && |
| 4713 | !IS_QLA27XX(ha)) |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 4714 | return QLA_FUNCTION_FAILED; |
| 4715 | mcp->mb[0] = MBC_GET_PORT_CONFIG; |
| 4716 | mcp->out_mb = MBX_0; |
| 4717 | mcp->in_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4718 | mcp->tov = MBX_TOV_SECONDS; |
| 4719 | mcp->flags = 0; |
| 4720 | |
| 4721 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4722 | |
| 4723 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4724 | ql_dbg(ql_dbg_mbx, vha, 0x110a, |
| 4725 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 4726 | } else { |
| 4727 | /* Copy all bits to preserve original value */ |
| 4728 | memcpy(mb, &mcp->mb[1], sizeof(uint16_t) * 4); |
| 4729 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4730 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110b, |
| 4731 | "Done %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 4732 | } |
| 4733 | return rval; |
| 4734 | } |
| 4735 | |
| 4736 | int |
| 4737 | qla81xx_set_port_config(scsi_qla_host_t *vha, uint16_t *mb) |
| 4738 | { |
| 4739 | int rval; |
| 4740 | mbx_cmd_t mc; |
| 4741 | mbx_cmd_t *mcp = &mc; |
| 4742 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4743 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110c, |
| 4744 | "Entered %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 4745 | |
| 4746 | mcp->mb[0] = MBC_SET_PORT_CONFIG; |
| 4747 | /* Copy all bits to preserve original setting */ |
| 4748 | memcpy(&mcp->mb[1], mb, sizeof(uint16_t) * 4); |
| 4749 | mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4750 | mcp->in_mb = MBX_0; |
| 4751 | mcp->tov = MBX_TOV_SECONDS; |
| 4752 | mcp->flags = 0; |
| 4753 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4754 | |
| 4755 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4756 | ql_dbg(ql_dbg_mbx, vha, 0x110d, |
| 4757 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 4758 | } else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4759 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110e, |
| 4760 | "Done %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 4761 | |
| 4762 | return rval; |
| 4763 | } |
| 4764 | |
| 4765 | |
| 4766 | int |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 4767 | qla24xx_set_fcp_prio(scsi_qla_host_t *vha, uint16_t loop_id, uint16_t priority, |
| 4768 | uint16_t *mb) |
| 4769 | { |
| 4770 | int rval; |
| 4771 | mbx_cmd_t mc; |
| 4772 | mbx_cmd_t *mcp = &mc; |
| 4773 | struct qla_hw_data *ha = vha->hw; |
| 4774 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4775 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x110f, |
| 4776 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4777 | |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 4778 | if (!IS_QLA24XX_TYPE(ha) && !IS_QLA25XX(ha)) |
| 4779 | return QLA_FUNCTION_FAILED; |
| 4780 | |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 4781 | mcp->mb[0] = MBC_PORT_PARAMS; |
| 4782 | mcp->mb[1] = loop_id; |
| 4783 | if (ha->flags.fcp_prio_enabled) |
| 4784 | mcp->mb[2] = BIT_1; |
| 4785 | else |
| 4786 | mcp->mb[2] = BIT_2; |
| 4787 | mcp->mb[4] = priority & 0xf; |
| 4788 | mcp->mb[9] = vha->vp_idx; |
| 4789 | mcp->out_mb = MBX_9|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4790 | mcp->in_mb = MBX_4|MBX_3|MBX_1|MBX_0; |
| 4791 | mcp->tov = 30; |
| 4792 | mcp->flags = 0; |
| 4793 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4794 | if (mb != NULL) { |
| 4795 | mb[0] = mcp->mb[0]; |
| 4796 | mb[1] = mcp->mb[1]; |
| 4797 | mb[3] = mcp->mb[3]; |
| 4798 | mb[4] = mcp->mb[4]; |
| 4799 | } |
| 4800 | |
| 4801 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4802 | ql_dbg(ql_dbg_mbx, vha, 0x10cd, "Failed=%x.\n", rval); |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 4803 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4804 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10cc, |
| 4805 | "Done %s.\n", __func__); |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 4806 | } |
| 4807 | |
| 4808 | return rval; |
| 4809 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4810 | |
| 4811 | int |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 4812 | qla2x00_get_thermal_temp(scsi_qla_host_t *vha, uint16_t *temp) |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 4813 | { |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 4814 | int rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 4815 | struct qla_hw_data *ha = vha->hw; |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 4816 | uint8_t byte; |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 4817 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 4818 | if (!IS_FWI2_CAPABLE(ha) || IS_QLA24XX_TYPE(ha) || IS_QLA81XX(ha)) { |
| 4819 | ql_dbg(ql_dbg_mbx, vha, 0x1150, |
| 4820 | "Thermal not supported by this card.\n"); |
| 4821 | return rval; |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 4822 | } |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 4823 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 4824 | if (IS_QLA25XX(ha)) { |
| 4825 | if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC && |
| 4826 | ha->pdev->subsystem_device == 0x0175) { |
| 4827 | rval = qla2x00_read_sfp(vha, 0, &byte, |
| 4828 | 0x98, 0x1, 1, BIT_13|BIT_0); |
| 4829 | *temp = byte; |
| 4830 | return rval; |
| 4831 | } |
| 4832 | if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_HP && |
| 4833 | ha->pdev->subsystem_device == 0x338e) { |
| 4834 | rval = qla2x00_read_sfp(vha, 0, &byte, |
| 4835 | 0x98, 0x1, 1, BIT_15|BIT_14|BIT_0); |
| 4836 | *temp = byte; |
| 4837 | return rval; |
| 4838 | } |
| 4839 | ql_dbg(ql_dbg_mbx, vha, 0x10c9, |
| 4840 | "Thermal not supported by this card.\n"); |
| 4841 | return rval; |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 4842 | } |
| 4843 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 4844 | if (IS_QLA82XX(ha)) { |
| 4845 | *temp = qla82xx_read_temperature(vha); |
| 4846 | rval = QLA_SUCCESS; |
| 4847 | return rval; |
| 4848 | } else if (IS_QLA8044(ha)) { |
| 4849 | *temp = qla8044_read_temperature(vha); |
| 4850 | rval = QLA_SUCCESS; |
| 4851 | return rval; |
| 4852 | } |
Joe Carnuccio | fe52f6e | 2013-02-08 01:58:03 -0500 | [diff] [blame] | 4853 | |
Joe Carnuccio | 1ae47cf | 2013-08-27 01:37:36 -0400 | [diff] [blame] | 4854 | rval = qla2x00_read_asic_temperature(vha, temp); |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 4855 | return rval; |
| 4856 | } |
| 4857 | |
| 4858 | int |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4859 | qla82xx_mbx_intr_enable(scsi_qla_host_t *vha) |
| 4860 | { |
| 4861 | int rval; |
| 4862 | struct qla_hw_data *ha = vha->hw; |
| 4863 | mbx_cmd_t mc; |
| 4864 | mbx_cmd_t *mcp = &mc; |
| 4865 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4866 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1017, |
| 4867 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4868 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4869 | if (!IS_FWI2_CAPABLE(ha)) |
| 4870 | return QLA_FUNCTION_FAILED; |
| 4871 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4872 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
Giridhar Malavali | 3711333 | 2010-07-23 15:28:34 +0500 | [diff] [blame] | 4873 | mcp->mb[0] = MBC_TOGGLE_INTERRUPT; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4874 | mcp->mb[1] = 1; |
| 4875 | |
| 4876 | mcp->out_mb = MBX_1|MBX_0; |
| 4877 | mcp->in_mb = MBX_0; |
| 4878 | mcp->tov = 30; |
| 4879 | mcp->flags = 0; |
| 4880 | |
| 4881 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4882 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4883 | ql_dbg(ql_dbg_mbx, vha, 0x1016, |
| 4884 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4885 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4886 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x100e, |
| 4887 | "Done %s.\n", __func__); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4888 | } |
| 4889 | |
| 4890 | return rval; |
| 4891 | } |
| 4892 | |
| 4893 | int |
| 4894 | qla82xx_mbx_intr_disable(scsi_qla_host_t *vha) |
| 4895 | { |
| 4896 | int rval; |
| 4897 | struct qla_hw_data *ha = vha->hw; |
| 4898 | mbx_cmd_t mc; |
| 4899 | mbx_cmd_t *mcp = &mc; |
| 4900 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4901 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x100d, |
| 4902 | "Entered %s.\n", __func__); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4903 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 4904 | if (!IS_P3P_TYPE(ha)) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4905 | return QLA_FUNCTION_FAILED; |
| 4906 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4907 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
Giridhar Malavali | 3711333 | 2010-07-23 15:28:34 +0500 | [diff] [blame] | 4908 | mcp->mb[0] = MBC_TOGGLE_INTERRUPT; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4909 | mcp->mb[1] = 0; |
| 4910 | |
| 4911 | mcp->out_mb = MBX_1|MBX_0; |
| 4912 | mcp->in_mb = MBX_0; |
| 4913 | mcp->tov = 30; |
| 4914 | mcp->flags = 0; |
| 4915 | |
| 4916 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4917 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4918 | ql_dbg(ql_dbg_mbx, vha, 0x100c, |
| 4919 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4920 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4921 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x100b, |
| 4922 | "Done %s.\n", __func__); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4923 | } |
| 4924 | |
| 4925 | return rval; |
| 4926 | } |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 4927 | |
| 4928 | int |
| 4929 | qla82xx_md_get_template_size(scsi_qla_host_t *vha) |
| 4930 | { |
| 4931 | struct qla_hw_data *ha = vha->hw; |
| 4932 | mbx_cmd_t mc; |
| 4933 | mbx_cmd_t *mcp = &mc; |
| 4934 | int rval = QLA_FUNCTION_FAILED; |
| 4935 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4936 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x111f, |
| 4937 | "Entered %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 4938 | |
| 4939 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 4940 | mcp->mb[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 4941 | mcp->mb[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 4942 | mcp->mb[2] = LSW(RQST_TMPLT_SIZE); |
| 4943 | mcp->mb[3] = MSW(RQST_TMPLT_SIZE); |
| 4944 | |
| 4945 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 4946 | mcp->in_mb = MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8| |
| 4947 | MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4948 | |
| 4949 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 4950 | mcp->tov = MBX_TOV_SECONDS; |
| 4951 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4952 | |
| 4953 | /* Always copy back return mailbox values. */ |
| 4954 | if (rval != QLA_SUCCESS) { |
| 4955 | ql_dbg(ql_dbg_mbx, vha, 0x1120, |
| 4956 | "mailbox command FAILED=0x%x, subcode=%x.\n", |
| 4957 | (mcp->mb[1] << 16) | mcp->mb[0], |
| 4958 | (mcp->mb[3] << 16) | mcp->mb[2]); |
| 4959 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4960 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1121, |
| 4961 | "Done %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 4962 | ha->md_template_size = ((mcp->mb[3] << 16) | mcp->mb[2]); |
| 4963 | if (!ha->md_template_size) { |
| 4964 | ql_dbg(ql_dbg_mbx, vha, 0x1122, |
| 4965 | "Null template size obtained.\n"); |
| 4966 | rval = QLA_FUNCTION_FAILED; |
| 4967 | } |
| 4968 | } |
| 4969 | return rval; |
| 4970 | } |
| 4971 | |
| 4972 | int |
| 4973 | qla82xx_md_get_template(scsi_qla_host_t *vha) |
| 4974 | { |
| 4975 | struct qla_hw_data *ha = vha->hw; |
| 4976 | mbx_cmd_t mc; |
| 4977 | mbx_cmd_t *mcp = &mc; |
| 4978 | int rval = QLA_FUNCTION_FAILED; |
| 4979 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4980 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1123, |
| 4981 | "Entered %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 4982 | |
| 4983 | ha->md_tmplt_hdr = dma_alloc_coherent(&ha->pdev->dev, |
| 4984 | ha->md_template_size, &ha->md_tmplt_hdr_dma, GFP_KERNEL); |
| 4985 | if (!ha->md_tmplt_hdr) { |
| 4986 | ql_log(ql_log_warn, vha, 0x1124, |
| 4987 | "Unable to allocate memory for Minidump template.\n"); |
| 4988 | return rval; |
| 4989 | } |
| 4990 | |
| 4991 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 4992 | mcp->mb[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 4993 | mcp->mb[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 4994 | mcp->mb[2] = LSW(RQST_TMPLT); |
| 4995 | mcp->mb[3] = MSW(RQST_TMPLT); |
| 4996 | mcp->mb[4] = LSW(LSD(ha->md_tmplt_hdr_dma)); |
| 4997 | mcp->mb[5] = MSW(LSD(ha->md_tmplt_hdr_dma)); |
| 4998 | mcp->mb[6] = LSW(MSD(ha->md_tmplt_hdr_dma)); |
| 4999 | mcp->mb[7] = MSW(MSD(ha->md_tmplt_hdr_dma)); |
| 5000 | mcp->mb[8] = LSW(ha->md_template_size); |
| 5001 | mcp->mb[9] = MSW(ha->md_template_size); |
| 5002 | |
| 5003 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 5004 | mcp->tov = MBX_TOV_SECONDS; |
| 5005 | mcp->out_mb = MBX_11|MBX_10|MBX_9|MBX_8| |
| 5006 | MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5007 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 5008 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5009 | |
| 5010 | if (rval != QLA_SUCCESS) { |
| 5011 | ql_dbg(ql_dbg_mbx, vha, 0x1125, |
| 5012 | "mailbox command FAILED=0x%x, subcode=%x.\n", |
| 5013 | ((mcp->mb[1] << 16) | mcp->mb[0]), |
| 5014 | ((mcp->mb[3] << 16) | mcp->mb[2])); |
| 5015 | } else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5016 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1126, |
| 5017 | "Done %s.\n", __func__); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 5018 | return rval; |
| 5019 | } |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5020 | |
| 5021 | int |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5022 | qla8044_md_get_template(scsi_qla_host_t *vha) |
| 5023 | { |
| 5024 | struct qla_hw_data *ha = vha->hw; |
| 5025 | mbx_cmd_t mc; |
| 5026 | mbx_cmd_t *mcp = &mc; |
| 5027 | int rval = QLA_FUNCTION_FAILED; |
| 5028 | int offset = 0, size = MINIDUMP_SIZE_36K; |
| 5029 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0xb11f, |
| 5030 | "Entered %s.\n", __func__); |
| 5031 | |
| 5032 | ha->md_tmplt_hdr = dma_alloc_coherent(&ha->pdev->dev, |
| 5033 | ha->md_template_size, &ha->md_tmplt_hdr_dma, GFP_KERNEL); |
| 5034 | if (!ha->md_tmplt_hdr) { |
| 5035 | ql_log(ql_log_warn, vha, 0xb11b, |
| 5036 | "Unable to allocate memory for Minidump template.\n"); |
| 5037 | return rval; |
| 5038 | } |
| 5039 | |
| 5040 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 5041 | while (offset < ha->md_template_size) { |
| 5042 | mcp->mb[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5043 | mcp->mb[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 5044 | mcp->mb[2] = LSW(RQST_TMPLT); |
| 5045 | mcp->mb[3] = MSW(RQST_TMPLT); |
| 5046 | mcp->mb[4] = LSW(LSD(ha->md_tmplt_hdr_dma + offset)); |
| 5047 | mcp->mb[5] = MSW(LSD(ha->md_tmplt_hdr_dma + offset)); |
| 5048 | mcp->mb[6] = LSW(MSD(ha->md_tmplt_hdr_dma + offset)); |
| 5049 | mcp->mb[7] = MSW(MSD(ha->md_tmplt_hdr_dma + offset)); |
| 5050 | mcp->mb[8] = LSW(size); |
| 5051 | mcp->mb[9] = MSW(size); |
| 5052 | mcp->mb[10] = offset & 0x0000FFFF; |
| 5053 | mcp->mb[11] = offset & 0xFFFF0000; |
| 5054 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 5055 | mcp->tov = MBX_TOV_SECONDS; |
| 5056 | mcp->out_mb = MBX_11|MBX_10|MBX_9|MBX_8| |
| 5057 | MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5058 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 5059 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5060 | |
| 5061 | if (rval != QLA_SUCCESS) { |
| 5062 | ql_dbg(ql_dbg_mbx, vha, 0xb11c, |
| 5063 | "mailbox command FAILED=0x%x, subcode=%x.\n", |
| 5064 | ((mcp->mb[1] << 16) | mcp->mb[0]), |
| 5065 | ((mcp->mb[3] << 16) | mcp->mb[2])); |
| 5066 | return rval; |
| 5067 | } else |
| 5068 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0xb11d, |
| 5069 | "Done %s.\n", __func__); |
| 5070 | offset = offset + size; |
| 5071 | } |
| 5072 | return rval; |
| 5073 | } |
| 5074 | |
| 5075 | int |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5076 | qla81xx_set_led_config(scsi_qla_host_t *vha, uint16_t *led_cfg) |
| 5077 | { |
| 5078 | int rval; |
| 5079 | struct qla_hw_data *ha = vha->hw; |
| 5080 | mbx_cmd_t mc; |
| 5081 | mbx_cmd_t *mcp = &mc; |
| 5082 | |
| 5083 | if (!IS_QLA81XX(ha) && !IS_QLA8031(ha)) |
| 5084 | return QLA_FUNCTION_FAILED; |
| 5085 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5086 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1133, |
| 5087 | "Entered %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5088 | |
| 5089 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
| 5090 | mcp->mb[0] = MBC_SET_LED_CONFIG; |
| 5091 | mcp->mb[1] = led_cfg[0]; |
| 5092 | mcp->mb[2] = led_cfg[1]; |
| 5093 | if (IS_QLA8031(ha)) { |
| 5094 | mcp->mb[3] = led_cfg[2]; |
| 5095 | mcp->mb[4] = led_cfg[3]; |
| 5096 | mcp->mb[5] = led_cfg[4]; |
| 5097 | mcp->mb[6] = led_cfg[5]; |
| 5098 | } |
| 5099 | |
| 5100 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 5101 | if (IS_QLA8031(ha)) |
| 5102 | mcp->out_mb |= MBX_6|MBX_5|MBX_4|MBX_3; |
| 5103 | mcp->in_mb = MBX_0; |
| 5104 | mcp->tov = 30; |
| 5105 | mcp->flags = 0; |
| 5106 | |
| 5107 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5108 | if (rval != QLA_SUCCESS) { |
| 5109 | ql_dbg(ql_dbg_mbx, vha, 0x1134, |
| 5110 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5111 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5112 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1135, |
| 5113 | "Done %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5114 | } |
| 5115 | |
| 5116 | return rval; |
| 5117 | } |
| 5118 | |
| 5119 | int |
| 5120 | qla81xx_get_led_config(scsi_qla_host_t *vha, uint16_t *led_cfg) |
| 5121 | { |
| 5122 | int rval; |
| 5123 | struct qla_hw_data *ha = vha->hw; |
| 5124 | mbx_cmd_t mc; |
| 5125 | mbx_cmd_t *mcp = &mc; |
| 5126 | |
| 5127 | if (!IS_QLA81XX(ha) && !IS_QLA8031(ha)) |
| 5128 | return QLA_FUNCTION_FAILED; |
| 5129 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5130 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1136, |
| 5131 | "Entered %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5132 | |
| 5133 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
| 5134 | mcp->mb[0] = MBC_GET_LED_CONFIG; |
| 5135 | |
| 5136 | mcp->out_mb = MBX_0; |
| 5137 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 5138 | if (IS_QLA8031(ha)) |
| 5139 | mcp->in_mb |= MBX_6|MBX_5|MBX_4|MBX_3; |
| 5140 | mcp->tov = 30; |
| 5141 | mcp->flags = 0; |
| 5142 | |
| 5143 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5144 | if (rval != QLA_SUCCESS) { |
| 5145 | ql_dbg(ql_dbg_mbx, vha, 0x1137, |
| 5146 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5147 | } else { |
| 5148 | led_cfg[0] = mcp->mb[1]; |
| 5149 | led_cfg[1] = mcp->mb[2]; |
| 5150 | if (IS_QLA8031(ha)) { |
| 5151 | led_cfg[2] = mcp->mb[3]; |
| 5152 | led_cfg[3] = mcp->mb[4]; |
| 5153 | led_cfg[4] = mcp->mb[5]; |
| 5154 | led_cfg[5] = mcp->mb[6]; |
| 5155 | } |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5156 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1138, |
| 5157 | "Done %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5158 | } |
| 5159 | |
| 5160 | return rval; |
| 5161 | } |
| 5162 | |
| 5163 | int |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5164 | qla82xx_mbx_beacon_ctl(scsi_qla_host_t *vha, int enable) |
| 5165 | { |
| 5166 | int rval; |
| 5167 | struct qla_hw_data *ha = vha->hw; |
| 5168 | mbx_cmd_t mc; |
| 5169 | mbx_cmd_t *mcp = &mc; |
| 5170 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5171 | if (!IS_P3P_TYPE(ha)) |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5172 | return QLA_FUNCTION_FAILED; |
| 5173 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5174 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1127, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5175 | "Entered %s.\n", __func__); |
| 5176 | |
| 5177 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
| 5178 | mcp->mb[0] = MBC_SET_LED_CONFIG; |
| 5179 | if (enable) |
| 5180 | mcp->mb[7] = 0xE; |
| 5181 | else |
| 5182 | mcp->mb[7] = 0xD; |
| 5183 | |
| 5184 | mcp->out_mb = MBX_7|MBX_0; |
| 5185 | mcp->in_mb = MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5186 | mcp->tov = MBX_TOV_SECONDS; |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5187 | mcp->flags = 0; |
| 5188 | |
| 5189 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5190 | if (rval != QLA_SUCCESS) { |
| 5191 | ql_dbg(ql_dbg_mbx, vha, 0x1128, |
| 5192 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5193 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5194 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1129, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5195 | "Done %s.\n", __func__); |
| 5196 | } |
| 5197 | |
| 5198 | return rval; |
| 5199 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5200 | |
| 5201 | int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5202 | 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] | 5203 | { |
| 5204 | int rval; |
| 5205 | struct qla_hw_data *ha = vha->hw; |
| 5206 | mbx_cmd_t mc; |
| 5207 | mbx_cmd_t *mcp = &mc; |
| 5208 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5209 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5210 | return QLA_FUNCTION_FAILED; |
| 5211 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5212 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1130, |
| 5213 | "Entered %s.\n", __func__); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5214 | |
| 5215 | mcp->mb[0] = MBC_WRITE_REMOTE_REG; |
| 5216 | mcp->mb[1] = LSW(reg); |
| 5217 | mcp->mb[2] = MSW(reg); |
| 5218 | mcp->mb[3] = LSW(data); |
| 5219 | mcp->mb[4] = MSW(data); |
| 5220 | mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 5221 | |
| 5222 | mcp->in_mb = MBX_1|MBX_0; |
| 5223 | mcp->tov = MBX_TOV_SECONDS; |
| 5224 | mcp->flags = 0; |
| 5225 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5226 | |
| 5227 | if (rval != QLA_SUCCESS) { |
| 5228 | ql_dbg(ql_dbg_mbx, vha, 0x1131, |
| 5229 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5230 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5231 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1132, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5232 | "Done %s.\n", __func__); |
| 5233 | } |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5234 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5235 | return rval; |
| 5236 | } |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5237 | |
| 5238 | int |
| 5239 | qla2x00_port_logout(scsi_qla_host_t *vha, struct fc_port *fcport) |
| 5240 | { |
| 5241 | int rval; |
| 5242 | struct qla_hw_data *ha = vha->hw; |
| 5243 | mbx_cmd_t mc; |
| 5244 | mbx_cmd_t *mcp = &mc; |
| 5245 | |
| 5246 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5247 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x113b, |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5248 | "Implicit LOGO Unsupported.\n"); |
| 5249 | return QLA_FUNCTION_FAILED; |
| 5250 | } |
| 5251 | |
| 5252 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5253 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x113c, |
| 5254 | "Entering %s.\n", __func__); |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5255 | |
| 5256 | /* Perform Implicit LOGO. */ |
| 5257 | mcp->mb[0] = MBC_PORT_LOGOUT; |
| 5258 | mcp->mb[1] = fcport->loop_id; |
| 5259 | mcp->mb[10] = BIT_15; |
| 5260 | mcp->out_mb = MBX_10|MBX_1|MBX_0; |
| 5261 | mcp->in_mb = MBX_0; |
| 5262 | mcp->tov = MBX_TOV_SECONDS; |
| 5263 | mcp->flags = 0; |
| 5264 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5265 | if (rval != QLA_SUCCESS) |
| 5266 | ql_dbg(ql_dbg_mbx, vha, 0x113d, |
| 5267 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5268 | else |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5269 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x113e, |
| 5270 | "Done %s.\n", __func__); |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 5271 | |
| 5272 | return rval; |
| 5273 | } |
| 5274 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5275 | int |
| 5276 | qla83xx_rd_reg(scsi_qla_host_t *vha, uint32_t reg, uint32_t *data) |
| 5277 | { |
| 5278 | int rval; |
| 5279 | mbx_cmd_t mc; |
| 5280 | mbx_cmd_t *mcp = &mc; |
| 5281 | struct qla_hw_data *ha = vha->hw; |
| 5282 | unsigned long retry_max_time = jiffies + (2 * HZ); |
| 5283 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5284 | if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5285 | return QLA_FUNCTION_FAILED; |
| 5286 | |
| 5287 | ql_dbg(ql_dbg_mbx, vha, 0x114b, "Entered %s.\n", __func__); |
| 5288 | |
| 5289 | retry_rd_reg: |
| 5290 | mcp->mb[0] = MBC_READ_REMOTE_REG; |
| 5291 | mcp->mb[1] = LSW(reg); |
| 5292 | mcp->mb[2] = MSW(reg); |
| 5293 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 5294 | mcp->in_mb = MBX_4|MBX_3|MBX_1|MBX_0; |
| 5295 | mcp->tov = MBX_TOV_SECONDS; |
| 5296 | mcp->flags = 0; |
| 5297 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5298 | |
| 5299 | if (rval != QLA_SUCCESS) { |
| 5300 | ql_dbg(ql_dbg_mbx, vha, 0x114c, |
| 5301 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 5302 | rval, mcp->mb[0], mcp->mb[1]); |
| 5303 | } else { |
| 5304 | *data = (mcp->mb[3] | (mcp->mb[4] << 16)); |
| 5305 | if (*data == QLA8XXX_BAD_VALUE) { |
| 5306 | /* |
| 5307 | * During soft-reset CAMRAM register reads might |
| 5308 | * return 0xbad0bad0. So retry for MAX of 2 sec |
| 5309 | * while reading camram registers. |
| 5310 | */ |
| 5311 | if (time_after(jiffies, retry_max_time)) { |
| 5312 | ql_dbg(ql_dbg_mbx, vha, 0x1141, |
| 5313 | "Failure to read CAMRAM register. " |
| 5314 | "data=0x%x.\n", *data); |
| 5315 | return QLA_FUNCTION_FAILED; |
| 5316 | } |
| 5317 | msleep(100); |
| 5318 | goto retry_rd_reg; |
| 5319 | } |
| 5320 | ql_dbg(ql_dbg_mbx, vha, 0x1142, "Done %s.\n", __func__); |
| 5321 | } |
| 5322 | |
| 5323 | return rval; |
| 5324 | } |
| 5325 | |
| 5326 | int |
| 5327 | qla83xx_restart_nic_firmware(scsi_qla_host_t *vha) |
| 5328 | { |
| 5329 | int rval; |
| 5330 | mbx_cmd_t mc; |
| 5331 | mbx_cmd_t *mcp = &mc; |
| 5332 | struct qla_hw_data *ha = vha->hw; |
| 5333 | |
| 5334 | if (!IS_QLA83XX(ha)) |
| 5335 | return QLA_FUNCTION_FAILED; |
| 5336 | |
| 5337 | ql_dbg(ql_dbg_mbx, vha, 0x1143, "Entered %s.\n", __func__); |
| 5338 | |
| 5339 | mcp->mb[0] = MBC_RESTART_NIC_FIRMWARE; |
| 5340 | mcp->out_mb = MBX_0; |
| 5341 | mcp->in_mb = MBX_1|MBX_0; |
| 5342 | mcp->tov = MBX_TOV_SECONDS; |
| 5343 | mcp->flags = 0; |
| 5344 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5345 | |
| 5346 | if (rval != QLA_SUCCESS) { |
| 5347 | ql_dbg(ql_dbg_mbx, vha, 0x1144, |
| 5348 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 5349 | rval, mcp->mb[0], mcp->mb[1]); |
| 5350 | ha->isp_ops->fw_dump(vha, 0); |
| 5351 | } else { |
| 5352 | ql_dbg(ql_dbg_mbx, vha, 0x1145, "Done %s.\n", __func__); |
| 5353 | } |
| 5354 | |
| 5355 | return rval; |
| 5356 | } |
| 5357 | |
| 5358 | int |
| 5359 | qla83xx_access_control(scsi_qla_host_t *vha, uint16_t options, |
| 5360 | uint32_t start_addr, uint32_t end_addr, uint16_t *sector_size) |
| 5361 | { |
| 5362 | int rval; |
| 5363 | mbx_cmd_t mc; |
| 5364 | mbx_cmd_t *mcp = &mc; |
| 5365 | uint8_t subcode = (uint8_t)options; |
| 5366 | struct qla_hw_data *ha = vha->hw; |
| 5367 | |
| 5368 | if (!IS_QLA8031(ha)) |
| 5369 | return QLA_FUNCTION_FAILED; |
| 5370 | |
| 5371 | ql_dbg(ql_dbg_mbx, vha, 0x1146, "Entered %s.\n", __func__); |
| 5372 | |
| 5373 | mcp->mb[0] = MBC_SET_ACCESS_CONTROL; |
| 5374 | mcp->mb[1] = options; |
| 5375 | mcp->out_mb = MBX_1|MBX_0; |
| 5376 | if (subcode & BIT_2) { |
| 5377 | mcp->mb[2] = LSW(start_addr); |
| 5378 | mcp->mb[3] = MSW(start_addr); |
| 5379 | mcp->mb[4] = LSW(end_addr); |
| 5380 | mcp->mb[5] = MSW(end_addr); |
| 5381 | mcp->out_mb |= MBX_5|MBX_4|MBX_3|MBX_2; |
| 5382 | } |
| 5383 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 5384 | if (!(subcode & (BIT_2 | BIT_5))) |
| 5385 | mcp->in_mb |= MBX_4|MBX_3; |
| 5386 | mcp->tov = MBX_TOV_SECONDS; |
| 5387 | mcp->flags = 0; |
| 5388 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5389 | |
| 5390 | if (rval != QLA_SUCCESS) { |
| 5391 | ql_dbg(ql_dbg_mbx, vha, 0x1147, |
| 5392 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[3]=%x mb[4]=%x.\n", |
| 5393 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2], mcp->mb[3], |
| 5394 | mcp->mb[4]); |
| 5395 | ha->isp_ops->fw_dump(vha, 0); |
| 5396 | } else { |
| 5397 | if (subcode & BIT_5) |
| 5398 | *sector_size = mcp->mb[1]; |
| 5399 | else if (subcode & (BIT_6 | BIT_7)) { |
| 5400 | ql_dbg(ql_dbg_mbx, vha, 0x1148, |
| 5401 | "Driver-lock id=%x%x", mcp->mb[4], mcp->mb[3]); |
| 5402 | } else if (subcode & (BIT_3 | BIT_4)) { |
| 5403 | ql_dbg(ql_dbg_mbx, vha, 0x1149, |
| 5404 | "Flash-lock id=%x%x", mcp->mb[4], mcp->mb[3]); |
| 5405 | } |
| 5406 | ql_dbg(ql_dbg_mbx, vha, 0x114a, "Done %s.\n", __func__); |
| 5407 | } |
| 5408 | |
| 5409 | return rval; |
| 5410 | } |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 5411 | |
| 5412 | int |
| 5413 | qla2x00_dump_mctp_data(scsi_qla_host_t *vha, dma_addr_t req_dma, uint32_t addr, |
| 5414 | uint32_t size) |
| 5415 | { |
| 5416 | int rval; |
| 5417 | mbx_cmd_t mc; |
| 5418 | mbx_cmd_t *mcp = &mc; |
| 5419 | |
| 5420 | if (!IS_MCTP_CAPABLE(vha->hw)) |
| 5421 | return QLA_FUNCTION_FAILED; |
| 5422 | |
| 5423 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x114f, |
| 5424 | "Entered %s.\n", __func__); |
| 5425 | |
| 5426 | mcp->mb[0] = MBC_DUMP_RISC_RAM_EXTENDED; |
| 5427 | mcp->mb[1] = LSW(addr); |
| 5428 | mcp->mb[2] = MSW(req_dma); |
| 5429 | mcp->mb[3] = LSW(req_dma); |
| 5430 | mcp->mb[4] = MSW(size); |
| 5431 | mcp->mb[5] = LSW(size); |
| 5432 | mcp->mb[6] = MSW(MSD(req_dma)); |
| 5433 | mcp->mb[7] = LSW(MSD(req_dma)); |
| 5434 | mcp->mb[8] = MSW(addr); |
| 5435 | /* Setting RAM ID to valid */ |
| 5436 | mcp->mb[10] |= BIT_7; |
| 5437 | /* For MCTP RAM ID is 0x40 */ |
| 5438 | mcp->mb[10] |= 0x40; |
| 5439 | |
| 5440 | mcp->out_mb |= MBX_10|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1| |
| 5441 | MBX_0; |
| 5442 | |
| 5443 | mcp->in_mb = MBX_0; |
| 5444 | mcp->tov = MBX_TOV_SECONDS; |
| 5445 | mcp->flags = 0; |
| 5446 | rval = qla2x00_mailbox_command(vha, mcp); |
| 5447 | |
| 5448 | if (rval != QLA_SUCCESS) { |
| 5449 | ql_dbg(ql_dbg_mbx, vha, 0x114e, |
| 5450 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 5451 | } else { |
| 5452 | ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x114d, |
| 5453 | "Done %s.\n", __func__); |
| 5454 | } |
| 5455 | |
| 5456 | return rval; |
| 5457 | } |