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 |
Andrew Vasquez | 07e264b | 2011-03-30 11:46:23 -0700 | [diff] [blame] | 3 | * Copyright (c) 2003-2011 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" |
| 8 | |
| 9 | #include <linux/delay.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 10 | #include <linux/gfp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | |
| 13 | /* |
| 14 | * qla2x00_mailbox_command |
| 15 | * Issue mailbox command and waits for completion. |
| 16 | * |
| 17 | * Input: |
| 18 | * ha = adapter block pointer. |
| 19 | * mcp = driver internal mbx struct pointer. |
| 20 | * |
| 21 | * Output: |
| 22 | * mb[MAX_MAILBOX_REGISTER_COUNT] = returned mailbox data. |
| 23 | * |
| 24 | * Returns: |
| 25 | * 0 : QLA_SUCCESS = cmd performed success |
| 26 | * 1 : QLA_FUNCTION_FAILED (error encountered) |
| 27 | * 6 : QLA_FUNCTION_TIMEOUT (timeout condition encountered) |
| 28 | * |
| 29 | * Context: |
| 30 | * Kernel context. |
| 31 | */ |
| 32 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 33 | qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | { |
| 35 | int rval; |
| 36 | unsigned long flags = 0; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 37 | device_reg_t __iomem *reg; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 38 | uint8_t abort_active; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 39 | uint8_t io_lock_on; |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 40 | uint16_t command = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | uint16_t *iptr; |
| 42 | uint16_t __iomem *optr; |
| 43 | uint32_t cnt; |
| 44 | uint32_t mboxes; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | unsigned long wait_time; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 46 | struct qla_hw_data *ha = vha->hw; |
| 47 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 48 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 49 | ql_dbg(ql_dbg_mbx, base_vha, 0x1000, "Entered %s.\n", __func__); |
| 50 | |
| 51 | if (ha->pdev->error_state > pci_channel_io_frozen) { |
| 52 | ql_log(ql_log_warn, base_vha, 0x1001, |
| 53 | "error_state is greater than pci_channel_io_frozen, " |
| 54 | "exiting.\n"); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 55 | return QLA_FUNCTION_TIMEOUT; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 56 | } |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 57 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 58 | if (vha->device_flags & DFLG_DEV_FAILED) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 59 | ql_log(ql_log_warn, base_vha, 0x1002, |
| 60 | "Device in failed state, exiting.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 61 | return QLA_FUNCTION_TIMEOUT; |
| 62 | } |
| 63 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 64 | reg = ha->iobase; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 65 | io_lock_on = base_vha->flags.init_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | |
| 67 | rval = QLA_SUCCESS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 68 | abort_active = test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 70 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 71 | if (ha->flags.pci_channel_io_perm_failure) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 72 | ql_log(ql_log_warn, base_vha, 0x1003, |
| 73 | "Perm failure on EEH timeout MBX, exiting.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 74 | return QLA_FUNCTION_TIMEOUT; |
| 75 | } |
| 76 | |
Giridhar Malavali | 862cd01 | 2011-02-23 15:27:11 -0800 | [diff] [blame] | 77 | if (ha->flags.isp82xx_fw_hung) { |
| 78 | /* Setting Link-Down error */ |
| 79 | mcp->mb[0] = MBS_LINK_DOWN_ERROR; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 80 | ql_log(ql_log_warn, base_vha, 0x1004, |
| 81 | "FW hung = %d.\n", ha->flags.isp82xx_fw_hung); |
Andrew Vasquez | 1806fcd | 2011-11-18 09:02:15 -0800 | [diff] [blame] | 82 | return QLA_FUNCTION_TIMEOUT; |
Giridhar Malavali | 862cd01 | 2011-02-23 15:27:11 -0800 | [diff] [blame] | 83 | } |
| 84 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | /* |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 86 | * Wait for active mailbox commands to finish by waiting at most tov |
| 87 | * seconds. This is to serialize actual issuing of mailbox cmds during |
| 88 | * non ISP abort time. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | */ |
Andrew Vasquez | 8eca3f3 | 2009-01-22 09:45:31 -0800 | [diff] [blame] | 90 | if (!wait_for_completion_timeout(&ha->mbx_cmd_comp, mcp->tov * HZ)) { |
| 91 | /* Timeout occurred. Return error. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 92 | ql_log(ql_log_warn, base_vha, 0x1005, |
| 93 | "Cmd access timeout, Exiting.\n"); |
Andrew Vasquez | 8eca3f3 | 2009-01-22 09:45:31 -0800 | [diff] [blame] | 94 | return QLA_FUNCTION_TIMEOUT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | ha->flags.mbox_busy = 1; |
| 98 | /* Save mailbox command for debug */ |
| 99 | ha->mcp = mcp; |
| 100 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 101 | ql_dbg(ql_dbg_mbx, base_vha, 0x1006, |
| 102 | "Prepare to issue mbox cmd=0x%x.\n", mcp->mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | |
| 104 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 105 | |
| 106 | /* Load mailbox registers. */ |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 107 | if (IS_QLA82XX(ha)) |
| 108 | optr = (uint16_t __iomem *)®->isp82.mailbox_in[0]; |
| 109 | else if (IS_FWI2_CAPABLE(ha) && !IS_QLA82XX(ha)) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 110 | optr = (uint16_t __iomem *)®->isp24.mailbox0; |
| 111 | else |
| 112 | optr = (uint16_t __iomem *)MAILBOX_REG(ha, ®->isp, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | |
| 114 | iptr = mcp->mb; |
| 115 | command = mcp->mb[0]; |
| 116 | mboxes = mcp->out_mb; |
| 117 | |
| 118 | for (cnt = 0; cnt < ha->mbx_count; cnt++) { |
| 119 | if (IS_QLA2200(ha) && cnt == 8) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 120 | optr = |
| 121 | (uint16_t __iomem *)MAILBOX_REG(ha, ®->isp, 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | if (mboxes & BIT_0) |
| 123 | WRT_REG_WORD(optr, *iptr); |
| 124 | |
| 125 | mboxes >>= 1; |
| 126 | optr++; |
| 127 | iptr++; |
| 128 | } |
| 129 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 130 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, base_vha, 0x1111, |
| 131 | "Loaded MBX registers (displayed in bytes) =.\n"); |
| 132 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, base_vha, 0x1112, |
| 133 | (uint8_t *)mcp->mb, 16); |
| 134 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, base_vha, 0x1113, |
| 135 | ".\n"); |
| 136 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, base_vha, 0x1114, |
| 137 | ((uint8_t *)mcp->mb + 0x10), 16); |
| 138 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, base_vha, 0x1115, |
| 139 | ".\n"); |
| 140 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, base_vha, 0x1116, |
| 141 | ((uint8_t *)mcp->mb + 0x20), 8); |
| 142 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, base_vha, 0x1117, |
| 143 | "I/O Address = %p.\n", optr); |
| 144 | ql_dump_regs(ql_dbg_mbx + ql_dbg_buffer, base_vha, 0x100e); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | |
| 146 | /* Issue set host interrupt command to send cmd out. */ |
| 147 | ha->flags.mbox_int = 0; |
| 148 | clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
| 149 | |
| 150 | /* Unlock mbx registers and wait for interrupt */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 151 | ql_dbg(ql_dbg_mbx, base_vha, 0x100f, |
| 152 | "Going to unlock irq & waiting for interrupts. " |
| 153 | "jiffies=%lx.\n", jiffies); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | |
| 155 | /* Wait for mbx cmd completion until timeout */ |
| 156 | |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 157 | if ((!abort_active && io_lock_on) || IS_NOPOLLING_TYPE(ha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | set_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); |
| 159 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 160 | if (IS_QLA82XX(ha)) { |
| 161 | if (RD_REG_DWORD(®->isp82.hint) & |
| 162 | HINT_MBX_INT_PENDING) { |
| 163 | spin_unlock_irqrestore(&ha->hardware_lock, |
| 164 | flags); |
Giridhar Malavali | 8937f2f | 2011-11-18 09:02:18 -0800 | [diff] [blame] | 165 | ha->flags.mbox_busy = 0; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 166 | ql_dbg(ql_dbg_mbx, base_vha, 0x1010, |
| 167 | "Pending mailbox timeout, exiting.\n"); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 168 | rval = QLA_FUNCTION_TIMEOUT; |
| 169 | goto premature_exit; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 170 | } |
| 171 | WRT_REG_DWORD(®->isp82.hint, HINT_MBX_INT_PENDING); |
| 172 | } else if (IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 173 | WRT_REG_DWORD(®->isp24.hccr, HCCRX_SET_HOST_INT); |
| 174 | else |
| 175 | WRT_REG_WORD(®->isp.hccr, HCCR_SET_HOST_INT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 177 | |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 178 | wait_for_completion_timeout(&ha->mbx_intr_comp, mcp->tov * HZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); |
| 181 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 183 | ql_dbg(ql_dbg_mbx, base_vha, 0x1011, |
| 184 | "Cmd=%x Polling Mode.\n", command); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 186 | if (IS_QLA82XX(ha)) { |
| 187 | if (RD_REG_DWORD(®->isp82.hint) & |
| 188 | HINT_MBX_INT_PENDING) { |
| 189 | spin_unlock_irqrestore(&ha->hardware_lock, |
| 190 | flags); |
Giridhar Malavali | 8937f2f | 2011-11-18 09:02:18 -0800 | [diff] [blame] | 191 | ha->flags.mbox_busy = 0; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 192 | ql_dbg(ql_dbg_mbx, base_vha, 0x1012, |
| 193 | "Pending mailbox timeout, exiting.\n"); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 194 | rval = QLA_FUNCTION_TIMEOUT; |
| 195 | goto premature_exit; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 196 | } |
| 197 | WRT_REG_DWORD(®->isp82.hint, HINT_MBX_INT_PENDING); |
| 198 | } else if (IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 199 | WRT_REG_DWORD(®->isp24.hccr, HCCRX_SET_HOST_INT); |
| 200 | else |
| 201 | WRT_REG_WORD(®->isp.hccr, HCCR_SET_HOST_INT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | |
| 204 | wait_time = jiffies + mcp->tov * HZ; /* wait at most tov secs */ |
| 205 | while (!ha->flags.mbox_int) { |
| 206 | if (time_after(jiffies, wait_time)) |
| 207 | break; |
| 208 | |
| 209 | /* Check for pending interrupts. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 210 | qla2x00_poll(ha->rsp_q_map[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 212 | if (!ha->flags.mbox_int && |
| 213 | !(IS_QLA2200(ha) && |
| 214 | command == MBC_LOAD_RISC_RAM_EXTENDED)) |
andrew.vasquez@qlogic.com | 5998983 | 2006-01-13 17:05:10 -0800 | [diff] [blame] | 215 | msleep(10); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | } /* while */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 217 | ql_dbg(ql_dbg_mbx, base_vha, 0x1013, |
| 218 | "Waited %d sec.\n", |
| 219 | (uint)((jiffies - (wait_time - (mcp->tov * HZ)))/HZ)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | } |
| 221 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | /* Check whether we timed out */ |
| 223 | if (ha->flags.mbox_int) { |
| 224 | uint16_t *iptr2; |
| 225 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 226 | ql_dbg(ql_dbg_mbx, base_vha, 0x1014, |
| 227 | "Cmd=%x completed.\n", command); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | |
| 229 | /* Got interrupt. Clear the flag. */ |
| 230 | ha->flags.mbox_int = 0; |
| 231 | clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
| 232 | |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 233 | if (ha->flags.isp82xx_fw_hung) { |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 234 | ha->flags.mbox_busy = 0; |
| 235 | /* Setting Link-Down error */ |
| 236 | mcp->mb[0] = MBS_LINK_DOWN_ERROR; |
| 237 | ha->mcp = NULL; |
| 238 | rval = QLA_FUNCTION_FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 239 | ql_log(ql_log_warn, base_vha, 0x1015, |
| 240 | "FW hung = %d.\n", ha->flags.isp82xx_fw_hung); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 241 | goto premature_exit; |
| 242 | } |
| 243 | |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 244 | if (ha->mailbox_out[0] != MBS_COMMAND_COMPLETE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | rval = QLA_FUNCTION_FAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | |
| 247 | /* Load return mailbox registers. */ |
| 248 | iptr2 = mcp->mb; |
| 249 | iptr = (uint16_t *)&ha->mailbox_out[0]; |
| 250 | mboxes = mcp->in_mb; |
| 251 | for (cnt = 0; cnt < ha->mbx_count; cnt++) { |
| 252 | if (mboxes & BIT_0) |
| 253 | *iptr2 = *iptr; |
| 254 | |
| 255 | mboxes >>= 1; |
| 256 | iptr2++; |
| 257 | iptr++; |
| 258 | } |
| 259 | } else { |
| 260 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 261 | uint16_t mb0; |
| 262 | uint32_t ictrl; |
| 263 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 264 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 265 | mb0 = RD_REG_WORD(®->isp24.mailbox0); |
| 266 | ictrl = RD_REG_DWORD(®->isp24.ictrl); |
| 267 | } else { |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 268 | mb0 = RD_MAILBOX_REG(ha, ®->isp, 0); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 269 | ictrl = RD_REG_WORD(®->isp.ictrl); |
| 270 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 271 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, base_vha, 0x1119, |
| 272 | "MBX Command timeout for cmd %x.\n", command); |
| 273 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, base_vha, 0x111a, |
| 274 | "iocontrol=%x jiffies=%lx.\n", ictrl, jiffies); |
| 275 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, base_vha, 0x111b, |
| 276 | "mb[0] = 0x%x.\n", mb0); |
| 277 | ql_dump_regs(ql_dbg_mbx + ql_dbg_buffer, base_vha, 0x1019); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | rval = QLA_FUNCTION_TIMEOUT; |
| 280 | } |
| 281 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | ha->flags.mbox_busy = 0; |
| 283 | |
| 284 | /* Clean up */ |
| 285 | ha->mcp = NULL; |
| 286 | |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 287 | if ((abort_active || !io_lock_on) && !IS_NOPOLLING_TYPE(ha)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 288 | ql_dbg(ql_dbg_mbx, base_vha, 0x101a, |
| 289 | "Checking for additional resp interrupt.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | |
| 291 | /* polling mode for non isp_abort commands. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 292 | qla2x00_poll(ha->rsp_q_map[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | } |
| 294 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 295 | if (rval == QLA_FUNCTION_TIMEOUT && |
| 296 | mcp->mb[0] != MBC_GEN_SYSTEM_ERROR) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 297 | if (!io_lock_on || (mcp->flags & IOCTL_CMD) || |
| 298 | ha->flags.eeh_busy) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | /* not in dpc. schedule it for dpc to take over. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 300 | ql_dbg(ql_dbg_mbx, base_vha, 0x101b, |
| 301 | "Timeout, schedule isp_abort_needed.\n"); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 302 | |
| 303 | if (!test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) && |
| 304 | !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) && |
| 305 | !test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) { |
Giridhar Malavali | 6315491 | 2011-11-18 09:02:19 -0800 | [diff] [blame] | 306 | if (IS_QLA82XX(ha)) { |
| 307 | ql_dbg(ql_dbg_mbx, vha, 0x112a, |
| 308 | "disabling pause transmit on port " |
| 309 | "0 & 1.\n"); |
| 310 | qla82xx_wr_32(ha, |
| 311 | QLA82XX_CRB_NIU + 0x98, |
| 312 | CRB_NIU_XG_PAUSE_CTL_P0| |
| 313 | CRB_NIU_XG_PAUSE_CTL_P1); |
| 314 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 315 | ql_log(ql_log_info, base_vha, 0x101c, |
| 316 | "Mailbox cmd timeout occured. " |
| 317 | "Scheduling ISP abort eeh_busy=0x%x.\n", |
| 318 | ha->flags.eeh_busy); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 319 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 320 | qla2xxx_wake_dpc(vha); |
| 321 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | } else if (!abort_active) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | /* call abort directly since we are in the DPC thread */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 324 | ql_dbg(ql_dbg_mbx, base_vha, 0x101d, |
| 325 | "Timeout, calling abort_isp.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 327 | if (!test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) && |
| 328 | !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) && |
| 329 | !test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) { |
Giridhar Malavali | 6315491 | 2011-11-18 09:02:19 -0800 | [diff] [blame] | 330 | if (IS_QLA82XX(ha)) { |
| 331 | ql_dbg(ql_dbg_mbx, vha, 0x112b, |
| 332 | "disabling pause transmit on port " |
| 333 | "0 & 1.\n"); |
| 334 | qla82xx_wr_32(ha, |
| 335 | QLA82XX_CRB_NIU + 0x98, |
| 336 | CRB_NIU_XG_PAUSE_CTL_P0| |
| 337 | CRB_NIU_XG_PAUSE_CTL_P1); |
| 338 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 339 | ql_log(ql_log_info, base_vha, 0x101e, |
| 340 | "Mailbox cmd timeout occured. " |
| 341 | "Scheduling ISP abort.\n"); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 342 | |
| 343 | set_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags); |
| 344 | clear_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Giridhar Malavali | d336096 | 2012-02-09 11:14:10 -0800 | [diff] [blame] | 345 | /* Allow next mbx cmd to come in. */ |
| 346 | complete(&ha->mbx_cmd_comp); |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 347 | if (ha->isp_ops->abort_isp(vha)) { |
| 348 | /* Failed. retry later. */ |
| 349 | set_bit(ISP_ABORT_NEEDED, |
| 350 | &vha->dpc_flags); |
| 351 | } |
| 352 | clear_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 353 | ql_dbg(ql_dbg_mbx, base_vha, 0x101f, |
| 354 | "Finished abort_isp.\n"); |
Giridhar Malavali | d336096 | 2012-02-09 11:14:10 -0800 | [diff] [blame] | 355 | goto mbx_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | } |
| 358 | } |
| 359 | |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 360 | premature_exit: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | /* Allow next mbx cmd to come in. */ |
Andrew Vasquez | 8eca3f3 | 2009-01-22 09:45:31 -0800 | [diff] [blame] | 362 | complete(&ha->mbx_cmd_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | |
Giridhar Malavali | d336096 | 2012-02-09 11:14:10 -0800 | [diff] [blame] | 364 | mbx_done: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 366 | ql_dbg(ql_dbg_mbx, base_vha, 0x1020, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 367 | "**** Failed mbx[0]=%x, mb[1]=%x, mb[2]=%x, mb[3]=%x, cmd=%x ****.\n", |
| 368 | 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] | 369 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 370 | ql_dbg(ql_dbg_mbx, base_vha, 0x1021, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | } |
| 372 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | return rval; |
| 374 | } |
| 375 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 377 | 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] | 378 | uint32_t risc_code_size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | { |
| 380 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 381 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 382 | mbx_cmd_t mc; |
| 383 | mbx_cmd_t *mcp = &mc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 385 | ql_dbg(ql_dbg_mbx, vha, 0x1022, "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 387 | if (MSW(risc_addr) || IS_FWI2_CAPABLE(ha)) { |
andrew.vasquez@qlogic.com | 590f98e | 2006-01-13 17:05:37 -0800 | [diff] [blame] | 388 | mcp->mb[0] = MBC_LOAD_RISC_RAM_EXTENDED; |
| 389 | mcp->mb[8] = MSW(risc_addr); |
| 390 | mcp->out_mb = MBX_8|MBX_0; |
| 391 | } else { |
| 392 | mcp->mb[0] = MBC_LOAD_RISC_RAM; |
| 393 | mcp->out_mb = MBX_0; |
| 394 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | mcp->mb[1] = LSW(risc_addr); |
| 396 | mcp->mb[2] = MSW(req_dma); |
| 397 | mcp->mb[3] = LSW(req_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | mcp->mb[6] = MSW(MSD(req_dma)); |
| 399 | mcp->mb[7] = LSW(MSD(req_dma)); |
andrew.vasquez@qlogic.com | 590f98e | 2006-01-13 17:05:37 -0800 | [diff] [blame] | 400 | 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] | 401 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 402 | mcp->mb[4] = MSW(risc_code_size); |
| 403 | mcp->mb[5] = LSW(risc_code_size); |
| 404 | mcp->out_mb |= MBX_5|MBX_4; |
| 405 | } else { |
| 406 | mcp->mb[4] = LSW(risc_code_size); |
| 407 | mcp->out_mb |= MBX_4; |
| 408 | } |
| 409 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 411 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 413 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 416 | ql_dbg(ql_dbg_mbx, vha, 0x1023, |
| 417 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 419 | ql_dbg(ql_dbg_mbx, vha, 0x1024, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | return rval; |
| 423 | } |
| 424 | |
Santosh Vernekar | cad454b | 2010-03-19 16:59:16 -0700 | [diff] [blame] | 425 | #define EXTENDED_BB_CREDITS BIT_0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | /* |
| 427 | * qla2x00_execute_fw |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 428 | * Start adapter firmware. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | * |
| 430 | * Input: |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 431 | * ha = adapter block pointer. |
| 432 | * TARGET_QUEUE_LOCK must be released. |
| 433 | * ADAPTER_STATE_LOCK must be released. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | * |
| 435 | * Returns: |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 436 | * qla2x00 local function return status code. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | * |
| 438 | * Context: |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 439 | * Kernel context. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | */ |
| 441 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 442 | qla2x00_execute_fw(scsi_qla_host_t *vha, uint32_t risc_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | { |
| 444 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 445 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | mbx_cmd_t mc; |
| 447 | mbx_cmd_t *mcp = &mc; |
| 448 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 449 | ql_dbg(ql_dbg_mbx, vha, 0x1025, "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | |
| 451 | mcp->mb[0] = MBC_EXECUTE_FIRMWARE; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 452 | mcp->out_mb = MBX_0; |
| 453 | mcp->in_mb = MBX_0; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 454 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 455 | mcp->mb[1] = MSW(risc_addr); |
| 456 | mcp->mb[2] = LSW(risc_addr); |
| 457 | mcp->mb[3] = 0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 458 | if (IS_QLA81XX(ha) || IS_QLA83XX(ha)) { |
Santosh Vernekar | cad454b | 2010-03-19 16:59:16 -0700 | [diff] [blame] | 459 | struct nvram_81xx *nv = ha->nvram; |
| 460 | mcp->mb[4] = (nv->enhanced_features & |
| 461 | EXTENDED_BB_CREDITS); |
| 462 | } else |
| 463 | mcp->mb[4] = 0; |
Andrew Vasquez | 8b3253d | 2007-09-20 14:07:48 -0700 | [diff] [blame] | 464 | mcp->out_mb |= MBX_4|MBX_3|MBX_2|MBX_1; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 465 | mcp->in_mb |= MBX_1; |
| 466 | } else { |
| 467 | mcp->mb[1] = LSW(risc_addr); |
| 468 | mcp->out_mb |= MBX_1; |
| 469 | if (IS_QLA2322(ha) || IS_QLA6322(ha)) { |
| 470 | mcp->mb[2] = 0; |
| 471 | mcp->out_mb |= MBX_2; |
| 472 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | } |
| 474 | |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 475 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 477 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 479 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 480 | ql_dbg(ql_dbg_mbx, vha, 0x1026, |
| 481 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 482 | } else { |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 483 | if (IS_FWI2_CAPABLE(ha)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 484 | ql_dbg(ql_dbg_mbx, vha, 0x1027, |
| 485 | "Done exchanges=%x.\n", mcp->mb[1]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 486 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 487 | ql_dbg(ql_dbg_mbx, vha, 0x1028, "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 488 | } |
| 489 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | |
| 491 | return rval; |
| 492 | } |
| 493 | |
| 494 | /* |
| 495 | * qla2x00_get_fw_version |
| 496 | * Get firmware version. |
| 497 | * |
| 498 | * Input: |
| 499 | * ha: adapter state pointer. |
| 500 | * major: pointer for major number. |
| 501 | * minor: pointer for minor number. |
| 502 | * subminor: pointer for subminor number. |
| 503 | * |
| 504 | * Returns: |
| 505 | * qla2x00 local function return status code. |
| 506 | * |
| 507 | * Context: |
| 508 | * Kernel context. |
| 509 | */ |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 510 | int |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 511 | qla2x00_get_fw_version(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | { |
| 513 | int rval; |
| 514 | mbx_cmd_t mc; |
| 515 | mbx_cmd_t *mcp = &mc; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 516 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 517 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 518 | ql_dbg(ql_dbg_mbx, vha, 0x1029, "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | |
| 520 | mcp->mb[0] = MBC_GET_FIRMWARE_VERSION; |
| 521 | mcp->out_mb = MBX_0; |
| 522 | mcp->in_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 523 | if (IS_QLA81XX(vha->hw) || IS_QLA8031(ha)) |
Andrew Vasquez | 55a9615 | 2009-03-24 09:08:03 -0700 | [diff] [blame] | 524 | mcp->in_mb |= MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 525 | if (IS_QLA83XX(vha->hw)) |
| 526 | mcp->in_mb |= MBX_17|MBX_16|MBX_15; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | mcp->flags = 0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 528 | mcp->tov = MBX_TOV_SECONDS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 529 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 530 | if (rval != QLA_SUCCESS) |
| 531 | goto failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 532 | |
| 533 | /* Return mailbox data. */ |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 534 | ha->fw_major_version = mcp->mb[1]; |
| 535 | ha->fw_minor_version = mcp->mb[2]; |
| 536 | ha->fw_subminor_version = mcp->mb[3]; |
| 537 | ha->fw_attributes = mcp->mb[6]; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 538 | if (IS_QLA2100(vha->hw) || IS_QLA2200(vha->hw)) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 539 | ha->fw_memory_size = 0x1FFFF; /* Defaults to 128KB. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | else |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 541 | ha->fw_memory_size = (mcp->mb[5] << 16) | mcp->mb[4]; |
| 542 | if (IS_QLA81XX(vha->hw) || IS_QLA8031(vha->hw)) { |
| 543 | ha->mpi_version[0] = mcp->mb[10] & 0xff; |
| 544 | ha->mpi_version[1] = mcp->mb[11] >> 8; |
| 545 | ha->mpi_version[2] = mcp->mb[11] & 0xff; |
| 546 | ha->mpi_capabilities = (mcp->mb[12] << 16) | mcp->mb[13]; |
| 547 | ha->phy_version[0] = mcp->mb[8] & 0xff; |
| 548 | ha->phy_version[1] = mcp->mb[9] >> 8; |
| 549 | ha->phy_version[2] = mcp->mb[9] & 0xff; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 550 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 551 | if (IS_QLA83XX(ha)) { |
| 552 | if (mcp->mb[6] & BIT_15) { |
| 553 | ha->fw_attributes_h = mcp->mb[15]; |
| 554 | ha->fw_attributes_ext[0] = mcp->mb[16]; |
| 555 | ha->fw_attributes_ext[1] = mcp->mb[17]; |
| 556 | ql_dbg(ql_dbg_mbx, vha, 0x1139, |
| 557 | "%s: FW_attributes Upper: 0x%x, Lower: 0x%x.\n", |
| 558 | __func__, mcp->mb[15], mcp->mb[6]); |
| 559 | } else |
| 560 | ql_dbg(ql_dbg_mbx, vha, 0x112f, |
| 561 | "%s: FwAttributes [Upper] invalid, MB6:%04x\n", |
| 562 | __func__, mcp->mb[6]); |
| 563 | } |
| 564 | |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 565 | failed: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 566 | if (rval != QLA_SUCCESS) { |
| 567 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 568 | ql_dbg(ql_dbg_mbx, vha, 0x102a, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | } else { |
| 570 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 571 | ql_dbg(ql_dbg_mbx, vha, 0x102b, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 572 | } |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 573 | return rval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | } |
| 575 | |
| 576 | /* |
| 577 | * qla2x00_get_fw_options |
| 578 | * Set firmware options. |
| 579 | * |
| 580 | * Input: |
| 581 | * ha = adapter block pointer. |
| 582 | * fwopt = pointer for firmware options. |
| 583 | * |
| 584 | * Returns: |
| 585 | * qla2x00 local function return status code. |
| 586 | * |
| 587 | * Context: |
| 588 | * Kernel context. |
| 589 | */ |
| 590 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 591 | qla2x00_get_fw_options(scsi_qla_host_t *vha, uint16_t *fwopts) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | { |
| 593 | int rval; |
| 594 | mbx_cmd_t mc; |
| 595 | mbx_cmd_t *mcp = &mc; |
| 596 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 597 | ql_dbg(ql_dbg_mbx, vha, 0x102c, "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | |
| 599 | mcp->mb[0] = MBC_GET_FIRMWARE_OPTION; |
| 600 | mcp->out_mb = MBX_0; |
| 601 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 602 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 604 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | |
| 606 | if (rval != QLA_SUCCESS) { |
| 607 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 608 | ql_dbg(ql_dbg_mbx, vha, 0x102d, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | } else { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 610 | fwopts[0] = mcp->mb[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 611 | fwopts[1] = mcp->mb[1]; |
| 612 | fwopts[2] = mcp->mb[2]; |
| 613 | fwopts[3] = mcp->mb[3]; |
| 614 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 615 | ql_dbg(ql_dbg_mbx, vha, 0x102e, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | } |
| 617 | |
| 618 | return rval; |
| 619 | } |
| 620 | |
| 621 | |
| 622 | /* |
| 623 | * qla2x00_set_fw_options |
| 624 | * Set firmware options. |
| 625 | * |
| 626 | * Input: |
| 627 | * ha = adapter block pointer. |
| 628 | * fwopt = pointer for firmware options. |
| 629 | * |
| 630 | * Returns: |
| 631 | * qla2x00 local function return status code. |
| 632 | * |
| 633 | * Context: |
| 634 | * Kernel context. |
| 635 | */ |
| 636 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 637 | qla2x00_set_fw_options(scsi_qla_host_t *vha, uint16_t *fwopts) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 638 | { |
| 639 | int rval; |
| 640 | mbx_cmd_t mc; |
| 641 | mbx_cmd_t *mcp = &mc; |
| 642 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 643 | ql_dbg(ql_dbg_mbx, vha, 0x102f, "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 644 | |
| 645 | mcp->mb[0] = MBC_SET_FIRMWARE_OPTION; |
| 646 | mcp->mb[1] = fwopts[1]; |
| 647 | mcp->mb[2] = fwopts[2]; |
| 648 | mcp->mb[3] = fwopts[3]; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 649 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 650 | mcp->in_mb = MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 651 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 652 | mcp->in_mb |= MBX_1; |
| 653 | } else { |
| 654 | mcp->mb[10] = fwopts[10]; |
| 655 | mcp->mb[11] = fwopts[11]; |
| 656 | mcp->mb[12] = 0; /* Undocumented, but used */ |
| 657 | mcp->out_mb |= MBX_12|MBX_11|MBX_10; |
| 658 | } |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 659 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 661 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 663 | fwopts[0] = mcp->mb[0]; |
| 664 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | if (rval != QLA_SUCCESS) { |
| 666 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 667 | ql_dbg(ql_dbg_mbx, vha, 0x1030, |
| 668 | "Failed=%x (%x/%x).\n", rval, mcp->mb[0], mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 669 | } else { |
| 670 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 671 | ql_dbg(ql_dbg_mbx, vha, 0x1031, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | } |
| 673 | |
| 674 | return rval; |
| 675 | } |
| 676 | |
| 677 | /* |
| 678 | * qla2x00_mbx_reg_test |
| 679 | * Mailbox register wrap test. |
| 680 | * |
| 681 | * Input: |
| 682 | * ha = adapter block pointer. |
| 683 | * TARGET_QUEUE_LOCK must be released. |
| 684 | * ADAPTER_STATE_LOCK must be released. |
| 685 | * |
| 686 | * Returns: |
| 687 | * qla2x00 local function return status code. |
| 688 | * |
| 689 | * Context: |
| 690 | * Kernel context. |
| 691 | */ |
| 692 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 693 | qla2x00_mbx_reg_test(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 694 | { |
| 695 | int rval; |
| 696 | mbx_cmd_t mc; |
| 697 | mbx_cmd_t *mcp = &mc; |
| 698 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 699 | ql_dbg(ql_dbg_mbx, vha, 0x1032, "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | |
| 701 | mcp->mb[0] = MBC_MAILBOX_REGISTER_TEST; |
| 702 | mcp->mb[1] = 0xAAAA; |
| 703 | mcp->mb[2] = 0x5555; |
| 704 | mcp->mb[3] = 0xAA55; |
| 705 | mcp->mb[4] = 0x55AA; |
| 706 | mcp->mb[5] = 0xA5A5; |
| 707 | mcp->mb[6] = 0x5A5A; |
| 708 | mcp->mb[7] = 0x2525; |
| 709 | mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 710 | 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] | 711 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 712 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 713 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 714 | |
| 715 | if (rval == QLA_SUCCESS) { |
| 716 | if (mcp->mb[1] != 0xAAAA || mcp->mb[2] != 0x5555 || |
| 717 | mcp->mb[3] != 0xAA55 || mcp->mb[4] != 0x55AA) |
| 718 | rval = QLA_FUNCTION_FAILED; |
| 719 | if (mcp->mb[5] != 0xA5A5 || mcp->mb[6] != 0x5A5A || |
| 720 | mcp->mb[7] != 0x2525) |
| 721 | rval = QLA_FUNCTION_FAILED; |
| 722 | } |
| 723 | |
| 724 | if (rval != QLA_SUCCESS) { |
| 725 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 726 | ql_dbg(ql_dbg_mbx, vha, 0x1033, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 727 | } else { |
| 728 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 729 | ql_dbg(ql_dbg_mbx, vha, 0x1034, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 730 | } |
| 731 | |
| 732 | return rval; |
| 733 | } |
| 734 | |
| 735 | /* |
| 736 | * qla2x00_verify_checksum |
| 737 | * Verify firmware checksum. |
| 738 | * |
| 739 | * Input: |
| 740 | * ha = adapter block pointer. |
| 741 | * TARGET_QUEUE_LOCK must be released. |
| 742 | * ADAPTER_STATE_LOCK must be released. |
| 743 | * |
| 744 | * Returns: |
| 745 | * qla2x00 local function return status code. |
| 746 | * |
| 747 | * Context: |
| 748 | * Kernel context. |
| 749 | */ |
| 750 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 751 | qla2x00_verify_checksum(scsi_qla_host_t *vha, uint32_t risc_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 752 | { |
| 753 | int rval; |
| 754 | mbx_cmd_t mc; |
| 755 | mbx_cmd_t *mcp = &mc; |
| 756 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 757 | ql_dbg(ql_dbg_mbx, vha, 0x1035, "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 758 | |
| 759 | mcp->mb[0] = MBC_VERIFY_CHECKSUM; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 760 | mcp->out_mb = MBX_0; |
| 761 | mcp->in_mb = MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 762 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 763 | mcp->mb[1] = MSW(risc_addr); |
| 764 | mcp->mb[2] = LSW(risc_addr); |
| 765 | mcp->out_mb |= MBX_2|MBX_1; |
| 766 | mcp->in_mb |= MBX_2|MBX_1; |
| 767 | } else { |
| 768 | mcp->mb[1] = LSW(risc_addr); |
| 769 | mcp->out_mb |= MBX_1; |
| 770 | mcp->in_mb |= MBX_1; |
| 771 | } |
| 772 | |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 773 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 774 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 775 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 776 | |
| 777 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 778 | ql_dbg(ql_dbg_mbx, vha, 0x1036, |
| 779 | "Failed=%x chm sum=%x.\n", rval, IS_FWI2_CAPABLE(vha->hw) ? |
| 780 | (mcp->mb[2] << 16) | mcp->mb[1] : mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 781 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 782 | ql_dbg(ql_dbg_mbx, vha, 0x1037, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 783 | } |
| 784 | |
| 785 | return rval; |
| 786 | } |
| 787 | |
| 788 | /* |
| 789 | * qla2x00_issue_iocb |
| 790 | * Issue IOCB using mailbox command |
| 791 | * |
| 792 | * Input: |
| 793 | * ha = adapter state pointer. |
| 794 | * buffer = buffer pointer. |
| 795 | * phys_addr = physical address of buffer. |
| 796 | * size = size of buffer. |
| 797 | * TARGET_QUEUE_LOCK must be released. |
| 798 | * ADAPTER_STATE_LOCK must be released. |
| 799 | * |
| 800 | * Returns: |
| 801 | * qla2x00 local function return status code. |
| 802 | * |
| 803 | * Context: |
| 804 | * Kernel context. |
| 805 | */ |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 806 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 807 | qla2x00_issue_iocb_timeout(scsi_qla_host_t *vha, void *buffer, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 808 | dma_addr_t phys_addr, size_t size, uint32_t tov) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 809 | { |
| 810 | int rval; |
| 811 | mbx_cmd_t mc; |
| 812 | mbx_cmd_t *mcp = &mc; |
| 813 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 814 | ql_dbg(ql_dbg_mbx, vha, 0x1038, "Entered %s.\n", __func__); |
| 815 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 816 | mcp->mb[0] = MBC_IOCB_COMMAND_A64; |
| 817 | mcp->mb[1] = 0; |
| 818 | mcp->mb[2] = MSW(phys_addr); |
| 819 | mcp->mb[3] = LSW(phys_addr); |
| 820 | mcp->mb[6] = MSW(MSD(phys_addr)); |
| 821 | mcp->mb[7] = LSW(MSD(phys_addr)); |
| 822 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 823 | mcp->in_mb = MBX_2|MBX_0; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 824 | mcp->tov = tov; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 825 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 826 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 827 | |
| 828 | if (rval != QLA_SUCCESS) { |
| 829 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 830 | ql_dbg(ql_dbg_mbx, vha, 0x1039, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 831 | } else { |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 832 | sts_entry_t *sts_entry = (sts_entry_t *) buffer; |
| 833 | |
| 834 | /* Mask reserved bits. */ |
| 835 | sts_entry->entry_status &= |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 836 | IS_FWI2_CAPABLE(vha->hw) ? RF_MASK_24XX : RF_MASK; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 837 | ql_dbg(ql_dbg_mbx, vha, 0x103a, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 838 | } |
| 839 | |
| 840 | return rval; |
| 841 | } |
| 842 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 843 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 844 | 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] | 845 | size_t size) |
| 846 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 847 | return qla2x00_issue_iocb_timeout(vha, buffer, phys_addr, size, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 848 | MBX_TOV_SECONDS); |
| 849 | } |
| 850 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 851 | /* |
| 852 | * qla2x00_abort_command |
| 853 | * Abort command aborts a specified IOCB. |
| 854 | * |
| 855 | * Input: |
| 856 | * ha = adapter block pointer. |
| 857 | * sp = SB structure pointer. |
| 858 | * |
| 859 | * Returns: |
| 860 | * qla2x00 local function return status code. |
| 861 | * |
| 862 | * Context: |
| 863 | * Kernel context. |
| 864 | */ |
| 865 | int |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 866 | qla2x00_abort_command(srb_t *sp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 867 | { |
| 868 | unsigned long flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 869 | int rval; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 870 | uint32_t handle = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 871 | mbx_cmd_t mc; |
| 872 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 873 | fc_port_t *fcport = sp->fcport; |
| 874 | scsi_qla_host_t *vha = fcport->vha; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 875 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 876 | struct req_que *req = vha->req; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 877 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 878 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 879 | ql_dbg(ql_dbg_mbx, vha, 0x103b, "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 880 | |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 881 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 882 | for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 883 | if (req->outstanding_cmds[handle] == sp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 884 | break; |
| 885 | } |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 886 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 887 | |
| 888 | if (handle == MAX_OUTSTANDING_COMMANDS) { |
| 889 | /* command not found */ |
| 890 | return QLA_FUNCTION_FAILED; |
| 891 | } |
| 892 | |
| 893 | mcp->mb[0] = MBC_ABORT_COMMAND; |
| 894 | if (HAS_EXTENDED_IDS(ha)) |
| 895 | mcp->mb[1] = fcport->loop_id; |
| 896 | else |
| 897 | mcp->mb[1] = fcport->loop_id << 8; |
| 898 | mcp->mb[2] = (uint16_t)handle; |
| 899 | mcp->mb[3] = (uint16_t)(handle >> 16); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 900 | mcp->mb[6] = (uint16_t)cmd->device->lun; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 901 | mcp->out_mb = MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 902 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 903 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 904 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 905 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 906 | |
| 907 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 908 | ql_dbg(ql_dbg_mbx, vha, 0x103c, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 909 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 910 | ql_dbg(ql_dbg_mbx, vha, 0x103d, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 911 | } |
| 912 | |
| 913 | return rval; |
| 914 | } |
| 915 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 916 | int |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 917 | qla2x00_abort_target(struct fc_port *fcport, unsigned int l, int tag) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 918 | { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 919 | int rval, rval2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 920 | mbx_cmd_t mc; |
| 921 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 922 | scsi_qla_host_t *vha; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 923 | struct req_que *req; |
| 924 | struct rsp_que *rsp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 925 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 926 | l = l; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 927 | vha = fcport->vha; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 928 | |
| 929 | ql_dbg(ql_dbg_mbx, vha, 0x103e, "Entered %s.\n", __func__); |
| 930 | |
Giridhar Malavali | 7e2b895 | 2010-05-28 15:08:17 -0700 | [diff] [blame] | 931 | req = vha->hw->req_q_map[0]; |
| 932 | rsp = req->rsp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 933 | mcp->mb[0] = MBC_ABORT_TARGET; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 934 | mcp->out_mb = MBX_9|MBX_2|MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 935 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 936 | mcp->mb[1] = fcport->loop_id; |
| 937 | mcp->mb[10] = 0; |
| 938 | mcp->out_mb |= MBX_10; |
| 939 | } else { |
| 940 | mcp->mb[1] = fcport->loop_id << 8; |
| 941 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 942 | mcp->mb[2] = vha->hw->loop_reset_delay; |
| 943 | mcp->mb[9] = vha->vp_idx; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 944 | |
| 945 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 946 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 947 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 948 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 949 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 950 | ql_dbg(ql_dbg_mbx, vha, 0x103f, "Failed=%x.\n", rval); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 951 | } |
| 952 | |
| 953 | /* Issue marker IOCB. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 954 | rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, 0, |
| 955 | MK_SYNC_ID); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 956 | if (rval2 != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 957 | ql_dbg(ql_dbg_mbx, vha, 0x1040, |
| 958 | "Failed to issue marker IOCB (%x).\n", rval2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 959 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 960 | ql_dbg(ql_dbg_mbx, vha, 0x1041, "Done %s.\n", __func__); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 961 | } |
| 962 | |
| 963 | return rval; |
| 964 | } |
| 965 | |
| 966 | int |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 967 | qla2x00_lun_reset(struct fc_port *fcport, unsigned int l, int tag) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 968 | { |
| 969 | int rval, rval2; |
| 970 | mbx_cmd_t mc; |
| 971 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 972 | scsi_qla_host_t *vha; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 973 | struct req_que *req; |
| 974 | struct rsp_que *rsp; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 975 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 976 | vha = fcport->vha; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 977 | |
| 978 | ql_dbg(ql_dbg_mbx, vha, 0x1042, "Entered %s.\n", __func__); |
| 979 | |
Giridhar Malavali | 7e2b895 | 2010-05-28 15:08:17 -0700 | [diff] [blame] | 980 | req = vha->hw->req_q_map[0]; |
| 981 | rsp = req->rsp; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 982 | mcp->mb[0] = MBC_LUN_RESET; |
| 983 | 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] | 984 | if (HAS_EXTENDED_IDS(vha->hw)) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 985 | mcp->mb[1] = fcport->loop_id; |
| 986 | else |
| 987 | mcp->mb[1] = fcport->loop_id << 8; |
| 988 | mcp->mb[2] = l; |
| 989 | mcp->mb[3] = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 990 | mcp->mb[9] = vha->vp_idx; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 991 | |
| 992 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 993 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 994 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 995 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 996 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 997 | ql_dbg(ql_dbg_mbx, vha, 0x1043, "Failed=%x.\n", rval); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 998 | } |
| 999 | |
| 1000 | /* Issue marker IOCB. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1001 | rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, l, |
| 1002 | MK_SYNC_ID_LUN); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1003 | if (rval2 != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1004 | ql_dbg(ql_dbg_mbx, vha, 0x1044, |
| 1005 | "Failed to issue marker IOCB (%x).\n", rval2); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1006 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1007 | ql_dbg(ql_dbg_mbx, vha, 0x1045, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1008 | } |
| 1009 | |
| 1010 | return rval; |
| 1011 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1012 | |
| 1013 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1014 | * qla2x00_get_adapter_id |
| 1015 | * Get adapter ID and topology. |
| 1016 | * |
| 1017 | * Input: |
| 1018 | * ha = adapter block pointer. |
| 1019 | * id = pointer for loop ID. |
| 1020 | * al_pa = pointer for AL_PA. |
| 1021 | * area = pointer for area. |
| 1022 | * domain = pointer for domain. |
| 1023 | * top = pointer for topology. |
| 1024 | * TARGET_QUEUE_LOCK must be released. |
| 1025 | * ADAPTER_STATE_LOCK must be released. |
| 1026 | * |
| 1027 | * Returns: |
| 1028 | * qla2x00 local function return status code. |
| 1029 | * |
| 1030 | * Context: |
| 1031 | * Kernel context. |
| 1032 | */ |
| 1033 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1034 | 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] | 1035 | 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] | 1036 | { |
| 1037 | int rval; |
| 1038 | mbx_cmd_t mc; |
| 1039 | mbx_cmd_t *mcp = &mc; |
| 1040 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1041 | ql_dbg(ql_dbg_mbx, vha, 0x1046, "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1042 | |
| 1043 | mcp->mb[0] = MBC_GET_ADAPTER_LOOP_ID; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1044 | mcp->mb[9] = vha->vp_idx; |
Andrew Vasquez | eb66dc6 | 2007-11-12 10:30:58 -0800 | [diff] [blame] | 1045 | mcp->out_mb = MBX_9|MBX_0; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1046 | 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] | 1047 | if (IS_CNA_CAPABLE(vha->hw)) |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1048 | mcp->in_mb |= MBX_13|MBX_12|MBX_11|MBX_10; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1049 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1050 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1051 | rval = qla2x00_mailbox_command(vha, mcp); |
Ravi Anand | 33135aa | 2005-11-08 14:37:20 -0800 | [diff] [blame] | 1052 | if (mcp->mb[0] == MBS_COMMAND_ERROR) |
| 1053 | rval = QLA_COMMAND_ERROR; |
Andrew Vasquez | 42e421b | 2008-07-10 16:56:01 -0700 | [diff] [blame] | 1054 | else if (mcp->mb[0] == MBS_INVALID_COMMAND) |
| 1055 | rval = QLA_INVALID_COMMAND; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1056 | |
| 1057 | /* Return data. */ |
| 1058 | *id = mcp->mb[1]; |
| 1059 | *al_pa = LSB(mcp->mb[2]); |
| 1060 | *area = MSB(mcp->mb[2]); |
| 1061 | *domain = LSB(mcp->mb[3]); |
| 1062 | *top = mcp->mb[6]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1063 | *sw_cap = mcp->mb[7]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1064 | |
| 1065 | if (rval != QLA_SUCCESS) { |
| 1066 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1067 | ql_dbg(ql_dbg_mbx, vha, 0x1047, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1068 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1069 | ql_dbg(ql_dbg_mbx, vha, 0x1048, "Done %s.\n", __func__); |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1070 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1071 | if (IS_CNA_CAPABLE(vha->hw)) { |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1072 | vha->fcoe_vlan_id = mcp->mb[9] & 0xfff; |
| 1073 | vha->fcoe_fcf_idx = mcp->mb[10]; |
| 1074 | vha->fcoe_vn_port_mac[5] = mcp->mb[11] >> 8; |
| 1075 | vha->fcoe_vn_port_mac[4] = mcp->mb[11] & 0xff; |
| 1076 | vha->fcoe_vn_port_mac[3] = mcp->mb[12] >> 8; |
| 1077 | vha->fcoe_vn_port_mac[2] = mcp->mb[12] & 0xff; |
| 1078 | vha->fcoe_vn_port_mac[1] = mcp->mb[13] >> 8; |
| 1079 | vha->fcoe_vn_port_mac[0] = mcp->mb[13] & 0xff; |
| 1080 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1081 | } |
| 1082 | |
| 1083 | return rval; |
| 1084 | } |
| 1085 | |
| 1086 | /* |
| 1087 | * qla2x00_get_retry_cnt |
| 1088 | * Get current firmware login retry count and delay. |
| 1089 | * |
| 1090 | * Input: |
| 1091 | * ha = adapter block pointer. |
| 1092 | * retry_cnt = pointer to login retry count. |
| 1093 | * tov = pointer to login timeout value. |
| 1094 | * |
| 1095 | * Returns: |
| 1096 | * qla2x00 local function return status code. |
| 1097 | * |
| 1098 | * Context: |
| 1099 | * Kernel context. |
| 1100 | */ |
| 1101 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1102 | 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] | 1103 | uint16_t *r_a_tov) |
| 1104 | { |
| 1105 | int rval; |
| 1106 | uint16_t ratov; |
| 1107 | mbx_cmd_t mc; |
| 1108 | mbx_cmd_t *mcp = &mc; |
| 1109 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1110 | ql_dbg(ql_dbg_mbx, vha, 0x1049, "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1111 | |
| 1112 | mcp->mb[0] = MBC_GET_RETRY_COUNT; |
| 1113 | mcp->out_mb = MBX_0; |
| 1114 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1115 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1116 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1117 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1118 | |
| 1119 | if (rval != QLA_SUCCESS) { |
| 1120 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1121 | ql_dbg(ql_dbg_mbx, vha, 0x104a, |
| 1122 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1123 | } else { |
| 1124 | /* Convert returned data and check our values. */ |
| 1125 | *r_a_tov = mcp->mb[3] / 2; |
| 1126 | ratov = (mcp->mb[3]/2) / 10; /* mb[3] value is in 100ms */ |
| 1127 | if (mcp->mb[1] * ratov > (*retry_cnt) * (*tov)) { |
| 1128 | /* Update to the larger values */ |
| 1129 | *retry_cnt = (uint8_t)mcp->mb[1]; |
| 1130 | *tov = ratov; |
| 1131 | } |
| 1132 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1133 | ql_dbg(ql_dbg_mbx, vha, 0x104b, |
| 1134 | "Done %s mb3=%d ratov=%d.\n", __func__, mcp->mb[3], ratov); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1135 | } |
| 1136 | |
| 1137 | return rval; |
| 1138 | } |
| 1139 | |
| 1140 | /* |
| 1141 | * qla2x00_init_firmware |
| 1142 | * Initialize adapter firmware. |
| 1143 | * |
| 1144 | * Input: |
| 1145 | * ha = adapter block pointer. |
| 1146 | * dptr = Initialization control block pointer. |
| 1147 | * size = size of initialization control block. |
| 1148 | * TARGET_QUEUE_LOCK must be released. |
| 1149 | * ADAPTER_STATE_LOCK must be released. |
| 1150 | * |
| 1151 | * Returns: |
| 1152 | * qla2x00 local function return status code. |
| 1153 | * |
| 1154 | * Context: |
| 1155 | * Kernel context. |
| 1156 | */ |
| 1157 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1158 | qla2x00_init_firmware(scsi_qla_host_t *vha, uint16_t size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1159 | { |
| 1160 | int rval; |
| 1161 | mbx_cmd_t mc; |
| 1162 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1163 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1164 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1165 | ql_dbg(ql_dbg_mbx, vha, 0x104c, "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1166 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1167 | if (IS_QLA82XX(ha) && ql2xdbwr) |
| 1168 | qla82xx_wr_32(ha, ha->nxdb_wr_ptr, |
| 1169 | (0x04 | (ha->portnum << 5) | (0 << 8) | (0 << 16))); |
| 1170 | |
Andrew Vasquez | e6e074f | 2008-01-31 12:33:53 -0800 | [diff] [blame] | 1171 | if (ha->flags.npiv_supported) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1172 | mcp->mb[0] = MBC_MID_INITIALIZE_FIRMWARE; |
| 1173 | else |
| 1174 | mcp->mb[0] = MBC_INITIALIZE_FIRMWARE; |
| 1175 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 1176 | mcp->mb[1] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1177 | mcp->mb[2] = MSW(ha->init_cb_dma); |
| 1178 | mcp->mb[3] = LSW(ha->init_cb_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1179 | mcp->mb[6] = MSW(MSD(ha->init_cb_dma)); |
| 1180 | mcp->mb[7] = LSW(MSD(ha->init_cb_dma)); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 1181 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1182 | if ((IS_QLA81XX(ha) || IS_QLA83XX(ha)) && ha->ex_init_cb->ex_version) { |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 1183 | mcp->mb[1] = BIT_0; |
| 1184 | mcp->mb[10] = MSW(ha->ex_init_cb_dma); |
| 1185 | mcp->mb[11] = LSW(ha->ex_init_cb_dma); |
| 1186 | mcp->mb[12] = MSW(MSD(ha->ex_init_cb_dma)); |
| 1187 | mcp->mb[13] = LSW(MSD(ha->ex_init_cb_dma)); |
| 1188 | mcp->mb[14] = sizeof(*ha->ex_init_cb); |
| 1189 | mcp->out_mb |= MBX_14|MBX_13|MBX_12|MBX_11|MBX_10; |
| 1190 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1191 | /* 1 and 2 should normally be captured. */ |
| 1192 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 1193 | if (IS_QLA83XX(ha)) |
| 1194 | /* mb3 is additional info about the installed SFP. */ |
| 1195 | mcp->in_mb |= MBX_3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1196 | mcp->buf_size = size; |
| 1197 | mcp->flags = MBX_DMA_OUT; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1198 | mcp->tov = MBX_TOV_SECONDS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1199 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1200 | |
| 1201 | if (rval != QLA_SUCCESS) { |
| 1202 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1203 | ql_dbg(ql_dbg_mbx, vha, 0x104d, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1204 | "Failed=%x mb[0]=%x, mb[1]=%x, mb[2]=%x, mb[3]=%x,.\n", |
| 1205 | 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] | 1206 | } else { |
| 1207 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1208 | ql_dbg(ql_dbg_mbx, vha, 0x104e, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1209 | } |
| 1210 | |
| 1211 | return rval; |
| 1212 | } |
| 1213 | |
| 1214 | /* |
| 1215 | * qla2x00_get_port_database |
| 1216 | * Issue normal/enhanced get port database mailbox command |
| 1217 | * and copy device name as necessary. |
| 1218 | * |
| 1219 | * Input: |
| 1220 | * ha = adapter state pointer. |
| 1221 | * dev = structure pointer. |
| 1222 | * opt = enhanced cmd option byte. |
| 1223 | * |
| 1224 | * Returns: |
| 1225 | * qla2x00 local function return status code. |
| 1226 | * |
| 1227 | * Context: |
| 1228 | * Kernel context. |
| 1229 | */ |
| 1230 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1231 | qla2x00_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] | 1232 | { |
| 1233 | int rval; |
| 1234 | mbx_cmd_t mc; |
| 1235 | mbx_cmd_t *mcp = &mc; |
| 1236 | port_database_t *pd; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1237 | struct port_database_24xx *pd24; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1238 | dma_addr_t pd_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1239 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1240 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1241 | ql_dbg(ql_dbg_mbx, vha, 0x104f, "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1242 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1243 | pd24 = NULL; |
| 1244 | pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1245 | if (pd == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1246 | ql_log(ql_log_warn, vha, 0x1050, |
| 1247 | "Failed to allocate port database structure.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1248 | return QLA_MEMORY_ALLOC_FAILED; |
| 1249 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1250 | memset(pd, 0, max(PORT_DATABASE_SIZE, PORT_DATABASE_24XX_SIZE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1251 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1252 | mcp->mb[0] = MBC_GET_PORT_DATABASE; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1253 | if (opt != 0 && !IS_FWI2_CAPABLE(ha)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1254 | mcp->mb[0] = MBC_ENHANCED_GET_PORT_DATABASE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1255 | mcp->mb[2] = MSW(pd_dma); |
| 1256 | mcp->mb[3] = LSW(pd_dma); |
| 1257 | mcp->mb[6] = MSW(MSD(pd_dma)); |
| 1258 | mcp->mb[7] = LSW(MSD(pd_dma)); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1259 | mcp->mb[9] = vha->vp_idx; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1260 | 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] | 1261 | mcp->in_mb = MBX_0; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1262 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1263 | mcp->mb[1] = fcport->loop_id; |
| 1264 | mcp->mb[10] = opt; |
| 1265 | mcp->out_mb |= MBX_10|MBX_1; |
| 1266 | mcp->in_mb |= MBX_1; |
| 1267 | } else if (HAS_EXTENDED_IDS(ha)) { |
| 1268 | mcp->mb[1] = fcport->loop_id; |
| 1269 | mcp->mb[10] = opt; |
| 1270 | mcp->out_mb |= MBX_10|MBX_1; |
| 1271 | } else { |
| 1272 | mcp->mb[1] = fcport->loop_id << 8 | opt; |
| 1273 | mcp->out_mb |= MBX_1; |
| 1274 | } |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1275 | mcp->buf_size = IS_FWI2_CAPABLE(ha) ? |
| 1276 | PORT_DATABASE_24XX_SIZE : PORT_DATABASE_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1277 | mcp->flags = MBX_DMA_IN; |
| 1278 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1279 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1280 | if (rval != QLA_SUCCESS) |
| 1281 | goto gpd_error_out; |
| 1282 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1283 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1284 | pd24 = (struct port_database_24xx *) pd; |
| 1285 | |
| 1286 | /* Check for logged in state. */ |
| 1287 | if (pd24->current_login_state != PDS_PRLI_COMPLETE && |
| 1288 | pd24->last_login_state != PDS_PRLI_COMPLETE) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1289 | ql_dbg(ql_dbg_mbx, vha, 0x1051, |
| 1290 | "Unable to verify login-state (%x/%x) for " |
| 1291 | "loop_id %x.\n", pd24->current_login_state, |
| 1292 | pd24->last_login_state, fcport->loop_id); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1293 | rval = QLA_FUNCTION_FAILED; |
| 1294 | goto gpd_error_out; |
| 1295 | } |
| 1296 | |
| 1297 | /* Names are little-endian. */ |
| 1298 | memcpy(fcport->node_name, pd24->node_name, WWN_SIZE); |
| 1299 | memcpy(fcport->port_name, pd24->port_name, WWN_SIZE); |
| 1300 | |
| 1301 | /* Get port_id of device. */ |
| 1302 | fcport->d_id.b.domain = pd24->port_id[0]; |
| 1303 | fcport->d_id.b.area = pd24->port_id[1]; |
| 1304 | fcport->d_id.b.al_pa = pd24->port_id[2]; |
| 1305 | fcport->d_id.b.rsvd_1 = 0; |
| 1306 | |
| 1307 | /* If not target must be initiator or unknown type. */ |
| 1308 | if ((pd24->prli_svc_param_word_3[0] & BIT_4) == 0) |
| 1309 | fcport->port_type = FCT_INITIATOR; |
| 1310 | else |
| 1311 | fcport->port_type = FCT_TARGET; |
| 1312 | } else { |
| 1313 | /* Check for logged in state. */ |
| 1314 | if (pd->master_state != PD_STATE_PORT_LOGGED_IN && |
| 1315 | pd->slave_state != PD_STATE_PORT_LOGGED_IN) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1316 | ql_dbg(ql_dbg_mbx, vha, 0x100a, |
| 1317 | "Unable to verify login-state (%x/%x) - " |
| 1318 | "portid=%02x%02x%02x.\n", pd->master_state, |
| 1319 | pd->slave_state, fcport->d_id.b.domain, |
| 1320 | fcport->d_id.b.area, fcport->d_id.b.al_pa); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1321 | rval = QLA_FUNCTION_FAILED; |
| 1322 | goto gpd_error_out; |
| 1323 | } |
| 1324 | |
| 1325 | /* Names are little-endian. */ |
| 1326 | memcpy(fcport->node_name, pd->node_name, WWN_SIZE); |
| 1327 | memcpy(fcport->port_name, pd->port_name, WWN_SIZE); |
| 1328 | |
| 1329 | /* Get port_id of device. */ |
| 1330 | fcport->d_id.b.domain = pd->port_id[0]; |
| 1331 | fcport->d_id.b.area = pd->port_id[3]; |
| 1332 | fcport->d_id.b.al_pa = pd->port_id[2]; |
| 1333 | fcport->d_id.b.rsvd_1 = 0; |
| 1334 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1335 | /* If not target must be initiator or unknown type. */ |
| 1336 | if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0) |
| 1337 | fcport->port_type = FCT_INITIATOR; |
| 1338 | else |
| 1339 | fcport->port_type = FCT_TARGET; |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 1340 | |
| 1341 | /* Passback COS information. */ |
| 1342 | fcport->supported_classes = (pd->options & BIT_4) ? |
| 1343 | FC_COS_CLASS2: FC_COS_CLASS3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1344 | } |
| 1345 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1346 | gpd_error_out: |
| 1347 | dma_pool_free(ha->s_dma_pool, pd, pd_dma); |
| 1348 | |
| 1349 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1350 | ql_dbg(ql_dbg_mbx, vha, 0x1052, |
| 1351 | "Failed=%x mb[0]=%x mb[1]=%x.\n", rval, |
| 1352 | mcp->mb[0], mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1353 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1354 | ql_dbg(ql_dbg_mbx, vha, 0x1053, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1355 | } |
| 1356 | |
| 1357 | return rval; |
| 1358 | } |
| 1359 | |
| 1360 | /* |
| 1361 | * qla2x00_get_firmware_state |
| 1362 | * Get adapter firmware state. |
| 1363 | * |
| 1364 | * Input: |
| 1365 | * ha = adapter block pointer. |
| 1366 | * dptr = pointer for firmware state. |
| 1367 | * TARGET_QUEUE_LOCK must be released. |
| 1368 | * ADAPTER_STATE_LOCK must be released. |
| 1369 | * |
| 1370 | * Returns: |
| 1371 | * qla2x00 local function return status code. |
| 1372 | * |
| 1373 | * Context: |
| 1374 | * Kernel context. |
| 1375 | */ |
| 1376 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1377 | qla2x00_get_firmware_state(scsi_qla_host_t *vha, uint16_t *states) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1378 | { |
| 1379 | int rval; |
| 1380 | mbx_cmd_t mc; |
| 1381 | mbx_cmd_t *mcp = &mc; |
| 1382 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1383 | ql_dbg(ql_dbg_mbx, vha, 0x1054, "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1384 | |
| 1385 | mcp->mb[0] = MBC_GET_FIRMWARE_STATE; |
| 1386 | mcp->out_mb = MBX_0; |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 1387 | if (IS_FWI2_CAPABLE(vha->hw)) |
| 1388 | mcp->in_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 1389 | else |
| 1390 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1391 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1392 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1393 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1394 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1395 | /* Return firmware states. */ |
| 1396 | states[0] = mcp->mb[1]; |
Andrew Vasquez | 9d2683c | 2009-06-17 10:30:30 -0700 | [diff] [blame] | 1397 | if (IS_FWI2_CAPABLE(vha->hw)) { |
| 1398 | states[1] = mcp->mb[2]; |
| 1399 | states[2] = mcp->mb[3]; |
| 1400 | states[3] = mcp->mb[4]; |
| 1401 | states[4] = mcp->mb[5]; |
| 1402 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1403 | |
| 1404 | if (rval != QLA_SUCCESS) { |
| 1405 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1406 | ql_dbg(ql_dbg_mbx, vha, 0x1055, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1407 | } else { |
| 1408 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1409 | ql_dbg(ql_dbg_mbx, vha, 0x1056, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1410 | } |
| 1411 | |
| 1412 | return rval; |
| 1413 | } |
| 1414 | |
| 1415 | /* |
| 1416 | * qla2x00_get_port_name |
| 1417 | * Issue get port name mailbox command. |
| 1418 | * Returned name is in big endian format. |
| 1419 | * |
| 1420 | * Input: |
| 1421 | * ha = adapter block pointer. |
| 1422 | * loop_id = loop ID of device. |
| 1423 | * name = pointer for name. |
| 1424 | * TARGET_QUEUE_LOCK must be released. |
| 1425 | * ADAPTER_STATE_LOCK must be released. |
| 1426 | * |
| 1427 | * Returns: |
| 1428 | * qla2x00 local function return status code. |
| 1429 | * |
| 1430 | * Context: |
| 1431 | * Kernel context. |
| 1432 | */ |
| 1433 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1434 | 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] | 1435 | uint8_t opt) |
| 1436 | { |
| 1437 | int rval; |
| 1438 | mbx_cmd_t mc; |
| 1439 | mbx_cmd_t *mcp = &mc; |
| 1440 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1441 | ql_dbg(ql_dbg_mbx, vha, 0x1057, "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1442 | |
| 1443 | mcp->mb[0] = MBC_GET_PORT_NAME; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1444 | mcp->mb[9] = vha->vp_idx; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1445 | mcp->out_mb = MBX_9|MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1446 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1447 | mcp->mb[1] = loop_id; |
| 1448 | mcp->mb[10] = opt; |
| 1449 | mcp->out_mb |= MBX_10; |
| 1450 | } else { |
| 1451 | mcp->mb[1] = loop_id << 8 | opt; |
| 1452 | } |
| 1453 | |
| 1454 | 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] | 1455 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1456 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1457 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1458 | |
| 1459 | if (rval != QLA_SUCCESS) { |
| 1460 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1461 | ql_dbg(ql_dbg_mbx, vha, 0x1058, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1462 | } else { |
| 1463 | if (name != NULL) { |
| 1464 | /* This function returns name in big endian. */ |
Richard Lary | 1196ae0 | 2007-03-22 10:53:19 -0500 | [diff] [blame] | 1465 | name[0] = MSB(mcp->mb[2]); |
| 1466 | name[1] = LSB(mcp->mb[2]); |
| 1467 | name[2] = MSB(mcp->mb[3]); |
| 1468 | name[3] = LSB(mcp->mb[3]); |
| 1469 | name[4] = MSB(mcp->mb[6]); |
| 1470 | name[5] = LSB(mcp->mb[6]); |
| 1471 | name[6] = MSB(mcp->mb[7]); |
| 1472 | name[7] = LSB(mcp->mb[7]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1473 | } |
| 1474 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1475 | ql_dbg(ql_dbg_mbx, vha, 0x1059, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1476 | } |
| 1477 | |
| 1478 | return rval; |
| 1479 | } |
| 1480 | |
| 1481 | /* |
| 1482 | * qla2x00_lip_reset |
| 1483 | * Issue LIP reset mailbox command. |
| 1484 | * |
| 1485 | * Input: |
| 1486 | * ha = adapter block pointer. |
| 1487 | * TARGET_QUEUE_LOCK must be released. |
| 1488 | * ADAPTER_STATE_LOCK must be released. |
| 1489 | * |
| 1490 | * Returns: |
| 1491 | * qla2x00 local function return status code. |
| 1492 | * |
| 1493 | * Context: |
| 1494 | * Kernel context. |
| 1495 | */ |
| 1496 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1497 | qla2x00_lip_reset(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1498 | { |
| 1499 | int rval; |
| 1500 | mbx_cmd_t mc; |
| 1501 | mbx_cmd_t *mcp = &mc; |
| 1502 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1503 | ql_dbg(ql_dbg_mbx, vha, 0x105a, "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1504 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1505 | if (IS_CNA_CAPABLE(vha->hw)) { |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1506 | /* Logout across all FCFs. */ |
| 1507 | mcp->mb[0] = MBC_LIP_FULL_LOGIN; |
| 1508 | mcp->mb[1] = BIT_1; |
| 1509 | mcp->mb[2] = 0; |
| 1510 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 1511 | } else if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1512 | mcp->mb[0] = MBC_LIP_FULL_LOGIN; |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1513 | mcp->mb[1] = BIT_6; |
| 1514 | mcp->mb[2] = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1515 | mcp->mb[3] = vha->hw->loop_reset_delay; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1516 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1517 | } else { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1518 | mcp->mb[0] = MBC_LIP_RESET; |
| 1519 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1520 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1521 | mcp->mb[1] = 0x00ff; |
| 1522 | mcp->mb[10] = 0; |
| 1523 | mcp->out_mb |= MBX_10; |
| 1524 | } else { |
| 1525 | mcp->mb[1] = 0xff00; |
| 1526 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1527 | mcp->mb[2] = vha->hw->loop_reset_delay; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1528 | mcp->mb[3] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1529 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1530 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1531 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1532 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1533 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1534 | |
| 1535 | if (rval != QLA_SUCCESS) { |
| 1536 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1537 | ql_dbg(ql_dbg_mbx, vha, 0x105b, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1538 | } else { |
| 1539 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1540 | ql_dbg(ql_dbg_mbx, vha, 0x105c, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1541 | } |
| 1542 | |
| 1543 | return rval; |
| 1544 | } |
| 1545 | |
| 1546 | /* |
| 1547 | * qla2x00_send_sns |
| 1548 | * Send SNS command. |
| 1549 | * |
| 1550 | * Input: |
| 1551 | * ha = adapter block pointer. |
| 1552 | * sns = pointer for command. |
| 1553 | * cmd_size = command size. |
| 1554 | * buf_size = response/command size. |
| 1555 | * TARGET_QUEUE_LOCK must be released. |
| 1556 | * ADAPTER_STATE_LOCK must be released. |
| 1557 | * |
| 1558 | * Returns: |
| 1559 | * qla2x00 local function return status code. |
| 1560 | * |
| 1561 | * Context: |
| 1562 | * Kernel context. |
| 1563 | */ |
| 1564 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1565 | 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] | 1566 | uint16_t cmd_size, size_t buf_size) |
| 1567 | { |
| 1568 | int rval; |
| 1569 | mbx_cmd_t mc; |
| 1570 | mbx_cmd_t *mcp = &mc; |
| 1571 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1572 | ql_dbg(ql_dbg_mbx, vha, 0x105d, "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1573 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1574 | ql_dbg(ql_dbg_mbx, vha, 0x105e, |
| 1575 | "Retry cnt=%d ratov=%d total tov=%d.\n", |
| 1576 | vha->hw->retry_count, vha->hw->login_timeout, mcp->tov); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1577 | |
| 1578 | mcp->mb[0] = MBC_SEND_SNS_COMMAND; |
| 1579 | mcp->mb[1] = cmd_size; |
| 1580 | mcp->mb[2] = MSW(sns_phys_address); |
| 1581 | mcp->mb[3] = LSW(sns_phys_address); |
| 1582 | mcp->mb[6] = MSW(MSD(sns_phys_address)); |
| 1583 | mcp->mb[7] = LSW(MSD(sns_phys_address)); |
| 1584 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 1585 | mcp->in_mb = MBX_0|MBX_1; |
| 1586 | mcp->buf_size = buf_size; |
| 1587 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1588 | mcp->tov = (vha->hw->login_timeout * 2) + (vha->hw->login_timeout / 2); |
| 1589 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1590 | |
| 1591 | if (rval != QLA_SUCCESS) { |
| 1592 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1593 | ql_dbg(ql_dbg_mbx, vha, 0x105f, |
| 1594 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 1595 | rval, mcp->mb[0], mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1596 | } else { |
| 1597 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1598 | ql_dbg(ql_dbg_mbx, vha, 0x1060, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1599 | } |
| 1600 | |
| 1601 | return rval; |
| 1602 | } |
| 1603 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1604 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1605 | 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] | 1606 | uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt) |
| 1607 | { |
| 1608 | int rval; |
| 1609 | |
| 1610 | struct logio_entry_24xx *lg; |
| 1611 | dma_addr_t lg_dma; |
| 1612 | uint32_t iop[2]; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1613 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1614 | struct req_que *req; |
| 1615 | struct rsp_que *rsp; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1616 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1617 | ql_dbg(ql_dbg_mbx, vha, 0x1061, "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1618 | |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 1619 | if (ha->flags.cpu_affinity_enabled) |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 1620 | req = ha->req_q_map[0]; |
| 1621 | else |
| 1622 | req = vha->req; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1623 | rsp = req->rsp; |
| 1624 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1625 | lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); |
| 1626 | if (lg == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1627 | ql_log(ql_log_warn, vha, 0x1062, |
| 1628 | "Failed to allocate login IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1629 | return QLA_MEMORY_ALLOC_FAILED; |
| 1630 | } |
| 1631 | memset(lg, 0, sizeof(struct logio_entry_24xx)); |
| 1632 | |
| 1633 | lg->entry_type = LOGINOUT_PORT_IOCB_TYPE; |
| 1634 | lg->entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1635 | lg->handle = MAKE_HANDLE(req->id, lg->handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1636 | lg->nport_handle = cpu_to_le16(loop_id); |
| 1637 | lg->control_flags = __constant_cpu_to_le16(LCF_COMMAND_PLOGI); |
| 1638 | if (opt & BIT_0) |
| 1639 | lg->control_flags |= __constant_cpu_to_le16(LCF_COND_PLOGI); |
Andrew Vasquez | 8baa51a | 2006-06-23 16:10:44 -0700 | [diff] [blame] | 1640 | if (opt & BIT_1) |
| 1641 | lg->control_flags |= __constant_cpu_to_le16(LCF_SKIP_PRLI); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1642 | lg->port_id[0] = al_pa; |
| 1643 | lg->port_id[1] = area; |
| 1644 | lg->port_id[2] = domain; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1645 | lg->vp_index = vha->vp_idx; |
| 1646 | rval = qla2x00_issue_iocb(vha, lg, lg_dma, 0); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1647 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1648 | ql_dbg(ql_dbg_mbx, vha, 0x1063, |
| 1649 | "Failed to issue login IOCB (%x).\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1650 | } else if (lg->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1651 | ql_dbg(ql_dbg_mbx, vha, 0x1064, |
| 1652 | "Failed to complete IOCB -- error status (%x).\n", |
| 1653 | lg->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1654 | rval = QLA_FUNCTION_FAILED; |
| 1655 | } else if (lg->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) { |
| 1656 | iop[0] = le32_to_cpu(lg->io_parameter[0]); |
| 1657 | iop[1] = le32_to_cpu(lg->io_parameter[1]); |
| 1658 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1659 | ql_dbg(ql_dbg_mbx, vha, 0x1065, |
| 1660 | "Failed to complete IOCB -- completion status (%x) " |
| 1661 | "ioparam=%x/%x.\n", le16_to_cpu(lg->comp_status), |
| 1662 | iop[0], iop[1]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1663 | |
| 1664 | switch (iop[0]) { |
| 1665 | case LSC_SCODE_PORTID_USED: |
| 1666 | mb[0] = MBS_PORT_ID_USED; |
| 1667 | mb[1] = LSW(iop[1]); |
| 1668 | break; |
| 1669 | case LSC_SCODE_NPORT_USED: |
| 1670 | mb[0] = MBS_LOOP_ID_USED; |
| 1671 | break; |
| 1672 | case LSC_SCODE_NOLINK: |
| 1673 | case LSC_SCODE_NOIOCB: |
| 1674 | case LSC_SCODE_NOXCB: |
| 1675 | case LSC_SCODE_CMD_FAILED: |
| 1676 | case LSC_SCODE_NOFABRIC: |
| 1677 | case LSC_SCODE_FW_NOT_READY: |
| 1678 | case LSC_SCODE_NOT_LOGGED_IN: |
| 1679 | case LSC_SCODE_NOPCB: |
| 1680 | case LSC_SCODE_ELS_REJECT: |
| 1681 | case LSC_SCODE_CMD_PARAM_ERR: |
| 1682 | case LSC_SCODE_NONPORT: |
| 1683 | case LSC_SCODE_LOGGED_IN: |
| 1684 | case LSC_SCODE_NOFLOGI_ACC: |
| 1685 | default: |
| 1686 | mb[0] = MBS_COMMAND_ERROR; |
| 1687 | break; |
| 1688 | } |
| 1689 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1690 | ql_dbg(ql_dbg_mbx, vha, 0x1066, "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1691 | |
| 1692 | iop[0] = le32_to_cpu(lg->io_parameter[0]); |
| 1693 | |
| 1694 | mb[0] = MBS_COMMAND_COMPLETE; |
| 1695 | mb[1] = 0; |
| 1696 | if (iop[0] & BIT_4) { |
| 1697 | if (iop[0] & BIT_8) |
| 1698 | mb[1] |= BIT_1; |
| 1699 | } else |
| 1700 | mb[1] = BIT_0; |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 1701 | |
| 1702 | /* Passback COS information. */ |
| 1703 | mb[10] = 0; |
| 1704 | if (lg->io_parameter[7] || lg->io_parameter[8]) |
| 1705 | mb[10] |= BIT_0; /* Class 2. */ |
| 1706 | if (lg->io_parameter[9] || lg->io_parameter[10]) |
| 1707 | mb[10] |= BIT_1; /* Class 3. */ |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1708 | } |
| 1709 | |
| 1710 | dma_pool_free(ha->s_dma_pool, lg, lg_dma); |
| 1711 | |
| 1712 | return rval; |
| 1713 | } |
| 1714 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1715 | /* |
| 1716 | * qla2x00_login_fabric |
| 1717 | * Issue login fabric port mailbox command. |
| 1718 | * |
| 1719 | * Input: |
| 1720 | * ha = adapter block pointer. |
| 1721 | * loop_id = device loop ID. |
| 1722 | * domain = device domain. |
| 1723 | * area = device area. |
| 1724 | * al_pa = device AL_PA. |
| 1725 | * status = pointer for return status. |
| 1726 | * opt = command options. |
| 1727 | * TARGET_QUEUE_LOCK must be released. |
| 1728 | * ADAPTER_STATE_LOCK must be released. |
| 1729 | * |
| 1730 | * Returns: |
| 1731 | * qla2x00 local function return status code. |
| 1732 | * |
| 1733 | * Context: |
| 1734 | * Kernel context. |
| 1735 | */ |
| 1736 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1737 | 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] | 1738 | uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt) |
| 1739 | { |
| 1740 | int rval; |
| 1741 | mbx_cmd_t mc; |
| 1742 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1743 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1744 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1745 | ql_dbg(ql_dbg_mbx, vha, 0x1067, "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1746 | |
| 1747 | mcp->mb[0] = MBC_LOGIN_FABRIC_PORT; |
| 1748 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 1749 | if (HAS_EXTENDED_IDS(ha)) { |
| 1750 | mcp->mb[1] = loop_id; |
| 1751 | mcp->mb[10] = opt; |
| 1752 | mcp->out_mb |= MBX_10; |
| 1753 | } else { |
| 1754 | mcp->mb[1] = (loop_id << 8) | opt; |
| 1755 | } |
| 1756 | mcp->mb[2] = domain; |
| 1757 | mcp->mb[3] = area << 8 | al_pa; |
| 1758 | |
| 1759 | mcp->in_mb = MBX_7|MBX_6|MBX_2|MBX_1|MBX_0; |
| 1760 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
| 1761 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1762 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1763 | |
| 1764 | /* Return mailbox statuses. */ |
| 1765 | if (mb != NULL) { |
| 1766 | mb[0] = mcp->mb[0]; |
| 1767 | mb[1] = mcp->mb[1]; |
| 1768 | mb[2] = mcp->mb[2]; |
| 1769 | mb[6] = mcp->mb[6]; |
| 1770 | mb[7] = mcp->mb[7]; |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 1771 | /* COS retrieved from Get-Port-Database mailbox command. */ |
| 1772 | mb[10] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1773 | } |
| 1774 | |
| 1775 | if (rval != QLA_SUCCESS) { |
| 1776 | /* RLU tmp code: need to change main mailbox_command function to |
| 1777 | * return ok even when the mailbox completion value is not |
| 1778 | * SUCCESS. The caller needs to be responsible to interpret |
| 1779 | * the return values of this mailbox command if we're not |
| 1780 | * to change too much of the existing code. |
| 1781 | */ |
| 1782 | if (mcp->mb[0] == 0x4001 || mcp->mb[0] == 0x4002 || |
| 1783 | mcp->mb[0] == 0x4003 || mcp->mb[0] == 0x4005 || |
| 1784 | mcp->mb[0] == 0x4006) |
| 1785 | rval = QLA_SUCCESS; |
| 1786 | |
| 1787 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1788 | ql_dbg(ql_dbg_mbx, vha, 0x1068, |
| 1789 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 1790 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1791 | } else { |
| 1792 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1793 | ql_dbg(ql_dbg_mbx, vha, 0x1069, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1794 | } |
| 1795 | |
| 1796 | return rval; |
| 1797 | } |
| 1798 | |
| 1799 | /* |
| 1800 | * qla2x00_login_local_device |
| 1801 | * Issue login loop port mailbox command. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1802 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1803 | * Input: |
| 1804 | * ha = adapter block pointer. |
| 1805 | * loop_id = device loop ID. |
| 1806 | * opt = command options. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1807 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1808 | * Returns: |
| 1809 | * Return status code. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1810 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1811 | * Context: |
| 1812 | * Kernel context. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1813 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1814 | */ |
| 1815 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1816 | 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] | 1817 | uint16_t *mb_ret, uint8_t opt) |
| 1818 | { |
| 1819 | int rval; |
| 1820 | mbx_cmd_t mc; |
| 1821 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1822 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1823 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1824 | ql_dbg(ql_dbg_mbx, vha, 0x106a, "Entered %s.\n", __func__); |
| 1825 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1826 | if (IS_FWI2_CAPABLE(ha)) |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1827 | return qla24xx_login_fabric(vha, fcport->loop_id, |
andrew.vasquez@qlogic.com | 9a52a57 | 2006-03-09 14:27:44 -0800 | [diff] [blame] | 1828 | fcport->d_id.b.domain, fcport->d_id.b.area, |
| 1829 | fcport->d_id.b.al_pa, mb_ret, opt); |
| 1830 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1831 | mcp->mb[0] = MBC_LOGIN_LOOP_PORT; |
| 1832 | if (HAS_EXTENDED_IDS(ha)) |
andrew.vasquez@qlogic.com | 9a52a57 | 2006-03-09 14:27:44 -0800 | [diff] [blame] | 1833 | mcp->mb[1] = fcport->loop_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1834 | else |
andrew.vasquez@qlogic.com | 9a52a57 | 2006-03-09 14:27:44 -0800 | [diff] [blame] | 1835 | mcp->mb[1] = fcport->loop_id << 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1836 | mcp->mb[2] = opt; |
| 1837 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 1838 | mcp->in_mb = MBX_7|MBX_6|MBX_1|MBX_0; |
| 1839 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
| 1840 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1841 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1842 | |
| 1843 | /* Return mailbox statuses. */ |
| 1844 | if (mb_ret != NULL) { |
| 1845 | mb_ret[0] = mcp->mb[0]; |
| 1846 | mb_ret[1] = mcp->mb[1]; |
| 1847 | mb_ret[6] = mcp->mb[6]; |
| 1848 | mb_ret[7] = mcp->mb[7]; |
| 1849 | } |
| 1850 | |
| 1851 | if (rval != QLA_SUCCESS) { |
| 1852 | /* AV tmp code: need to change main mailbox_command function to |
| 1853 | * return ok even when the mailbox completion value is not |
| 1854 | * SUCCESS. The caller needs to be responsible to interpret |
| 1855 | * the return values of this mailbox command if we're not |
| 1856 | * to change too much of the existing code. |
| 1857 | */ |
| 1858 | if (mcp->mb[0] == 0x4005 || mcp->mb[0] == 0x4006) |
| 1859 | rval = QLA_SUCCESS; |
| 1860 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1861 | ql_dbg(ql_dbg_mbx, vha, 0x106b, |
| 1862 | "Failed=%x mb[0]=%x mb[1]=%x mb[6]=%x mb[7]=%x.\n", |
| 1863 | 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] | 1864 | } else { |
| 1865 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1866 | ql_dbg(ql_dbg_mbx, vha, 0x106c, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1867 | } |
| 1868 | |
| 1869 | return (rval); |
| 1870 | } |
| 1871 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1872 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1873 | 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] | 1874 | uint8_t area, uint8_t al_pa) |
| 1875 | { |
| 1876 | int rval; |
| 1877 | struct logio_entry_24xx *lg; |
| 1878 | dma_addr_t lg_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1879 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1880 | struct req_que *req; |
| 1881 | struct rsp_que *rsp; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1882 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1883 | ql_dbg(ql_dbg_mbx, vha, 0x106d, "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1884 | |
| 1885 | lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); |
| 1886 | if (lg == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1887 | ql_log(ql_log_warn, vha, 0x106e, |
| 1888 | "Failed to allocate logout IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1889 | return QLA_MEMORY_ALLOC_FAILED; |
| 1890 | } |
| 1891 | memset(lg, 0, sizeof(struct logio_entry_24xx)); |
| 1892 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1893 | if (ql2xmaxqueues > 1) |
| 1894 | req = ha->req_q_map[0]; |
| 1895 | else |
| 1896 | req = vha->req; |
| 1897 | rsp = req->rsp; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1898 | lg->entry_type = LOGINOUT_PORT_IOCB_TYPE; |
| 1899 | lg->entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1900 | lg->handle = MAKE_HANDLE(req->id, lg->handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1901 | lg->nport_handle = cpu_to_le16(loop_id); |
| 1902 | lg->control_flags = |
Andrew Vasquez | c8d6691 | 2011-03-30 11:46:21 -0700 | [diff] [blame] | 1903 | __constant_cpu_to_le16(LCF_COMMAND_LOGO|LCF_IMPL_LOGO| |
| 1904 | LCF_FREE_NPORT); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1905 | lg->port_id[0] = al_pa; |
| 1906 | lg->port_id[1] = area; |
| 1907 | lg->port_id[2] = domain; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1908 | lg->vp_index = vha->vp_idx; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1909 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1910 | rval = qla2x00_issue_iocb(vha, lg, lg_dma, 0); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1911 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1912 | ql_dbg(ql_dbg_mbx, vha, 0x106f, |
| 1913 | "Failed to issue logout IOCB (%x).\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1914 | } else if (lg->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1915 | ql_dbg(ql_dbg_mbx, vha, 0x1070, |
| 1916 | "Failed to complete IOCB -- error status (%x).\n", |
| 1917 | lg->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1918 | rval = QLA_FUNCTION_FAILED; |
| 1919 | } else if (lg->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1920 | ql_dbg(ql_dbg_mbx, vha, 0x1071, |
| 1921 | "Failed to complete IOCB -- completion status (%x) " |
| 1922 | "ioparam=%x/%x.\n", le16_to_cpu(lg->comp_status), |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1923 | le32_to_cpu(lg->io_parameter[0]), |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1924 | le32_to_cpu(lg->io_parameter[1])); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1925 | } else { |
| 1926 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1927 | ql_dbg(ql_dbg_mbx, vha, 0x1072, "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 1928 | } |
| 1929 | |
| 1930 | dma_pool_free(ha->s_dma_pool, lg, lg_dma); |
| 1931 | |
| 1932 | return rval; |
| 1933 | } |
| 1934 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1935 | /* |
| 1936 | * qla2x00_fabric_logout |
| 1937 | * Issue logout fabric port mailbox command. |
| 1938 | * |
| 1939 | * Input: |
| 1940 | * ha = adapter block pointer. |
| 1941 | * loop_id = device loop ID. |
| 1942 | * TARGET_QUEUE_LOCK must be released. |
| 1943 | * ADAPTER_STATE_LOCK must be released. |
| 1944 | * |
| 1945 | * Returns: |
| 1946 | * qla2x00 local function return status code. |
| 1947 | * |
| 1948 | * Context: |
| 1949 | * Kernel context. |
| 1950 | */ |
| 1951 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1952 | 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] | 1953 | uint8_t area, uint8_t al_pa) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1954 | { |
| 1955 | int rval; |
| 1956 | mbx_cmd_t mc; |
| 1957 | mbx_cmd_t *mcp = &mc; |
| 1958 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1959 | ql_dbg(ql_dbg_mbx, vha, 0x1073, "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1960 | |
| 1961 | mcp->mb[0] = MBC_LOGOUT_FABRIC_PORT; |
| 1962 | mcp->out_mb = MBX_1|MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1963 | if (HAS_EXTENDED_IDS(vha->hw)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1964 | mcp->mb[1] = loop_id; |
| 1965 | mcp->mb[10] = 0; |
| 1966 | mcp->out_mb |= MBX_10; |
| 1967 | } else { |
| 1968 | mcp->mb[1] = loop_id << 8; |
| 1969 | } |
| 1970 | |
| 1971 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 1972 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1973 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1974 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1975 | |
| 1976 | if (rval != QLA_SUCCESS) { |
| 1977 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1978 | ql_dbg(ql_dbg_mbx, vha, 0x1074, |
| 1979 | "Failed=%x mb[1]=%x.\n", rval, mcp->mb[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1980 | } else { |
| 1981 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1982 | ql_dbg(ql_dbg_mbx, vha, 0x1075, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1983 | } |
| 1984 | |
| 1985 | return rval; |
| 1986 | } |
| 1987 | |
| 1988 | /* |
| 1989 | * qla2x00_full_login_lip |
| 1990 | * Issue full login LIP mailbox command. |
| 1991 | * |
| 1992 | * Input: |
| 1993 | * ha = adapter block pointer. |
| 1994 | * TARGET_QUEUE_LOCK must be released. |
| 1995 | * ADAPTER_STATE_LOCK must be released. |
| 1996 | * |
| 1997 | * Returns: |
| 1998 | * qla2x00 local function return status code. |
| 1999 | * |
| 2000 | * Context: |
| 2001 | * Kernel context. |
| 2002 | */ |
| 2003 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2004 | qla2x00_full_login_lip(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2005 | { |
| 2006 | int rval; |
| 2007 | mbx_cmd_t mc; |
| 2008 | mbx_cmd_t *mcp = &mc; |
| 2009 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2010 | ql_dbg(ql_dbg_mbx, vha, 0x1076, "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2011 | |
| 2012 | mcp->mb[0] = MBC_LIP_FULL_LOGIN; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2013 | mcp->mb[1] = IS_FWI2_CAPABLE(vha->hw) ? BIT_3 : 0; |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 2014 | mcp->mb[2] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2015 | mcp->mb[3] = 0; |
| 2016 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 2017 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2018 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2019 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2020 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2021 | |
| 2022 | if (rval != QLA_SUCCESS) { |
| 2023 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2024 | ql_dbg(ql_dbg_mbx, vha, 0x1077, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2025 | } else { |
| 2026 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2027 | ql_dbg(ql_dbg_mbx, vha, 0x1078, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2028 | } |
| 2029 | |
| 2030 | return rval; |
| 2031 | } |
| 2032 | |
| 2033 | /* |
| 2034 | * qla2x00_get_id_list |
| 2035 | * |
| 2036 | * Input: |
| 2037 | * ha = adapter block pointer. |
| 2038 | * |
| 2039 | * Returns: |
| 2040 | * qla2x00 local function return status code. |
| 2041 | * |
| 2042 | * Context: |
| 2043 | * Kernel context. |
| 2044 | */ |
| 2045 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2046 | 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] | 2047 | uint16_t *entries) |
| 2048 | { |
| 2049 | int rval; |
| 2050 | mbx_cmd_t mc; |
| 2051 | mbx_cmd_t *mcp = &mc; |
| 2052 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2053 | ql_dbg(ql_dbg_mbx, vha, 0x1079, "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2054 | |
| 2055 | if (id_list == NULL) |
| 2056 | return QLA_FUNCTION_FAILED; |
| 2057 | |
| 2058 | mcp->mb[0] = MBC_GET_ID_LIST; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2059 | mcp->out_mb = MBX_0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2060 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2061 | mcp->mb[2] = MSW(id_list_dma); |
| 2062 | mcp->mb[3] = LSW(id_list_dma); |
| 2063 | mcp->mb[6] = MSW(MSD(id_list_dma)); |
| 2064 | mcp->mb[7] = LSW(MSD(id_list_dma)); |
andrew.vasquez@qlogic.com | 247ec45 | 2006-02-07 08:45:40 -0800 | [diff] [blame] | 2065 | mcp->mb[8] = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2066 | mcp->mb[9] = vha->vp_idx; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2067 | 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] | 2068 | } else { |
| 2069 | mcp->mb[1] = MSW(id_list_dma); |
| 2070 | mcp->mb[2] = LSW(id_list_dma); |
| 2071 | mcp->mb[3] = MSW(MSD(id_list_dma)); |
| 2072 | mcp->mb[6] = LSW(MSD(id_list_dma)); |
| 2073 | mcp->out_mb |= MBX_6|MBX_3|MBX_2|MBX_1; |
| 2074 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2075 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2076 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2077 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2078 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2079 | |
| 2080 | if (rval != QLA_SUCCESS) { |
| 2081 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2082 | ql_dbg(ql_dbg_mbx, vha, 0x107a, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2083 | } else { |
| 2084 | *entries = mcp->mb[1]; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2085 | ql_dbg(ql_dbg_mbx, vha, 0x107b, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2086 | } |
| 2087 | |
| 2088 | return rval; |
| 2089 | } |
| 2090 | |
| 2091 | /* |
| 2092 | * qla2x00_get_resource_cnts |
| 2093 | * Get current firmware resource counts. |
| 2094 | * |
| 2095 | * Input: |
| 2096 | * ha = adapter block pointer. |
| 2097 | * |
| 2098 | * Returns: |
| 2099 | * qla2x00 local function return status code. |
| 2100 | * |
| 2101 | * Context: |
| 2102 | * Kernel context. |
| 2103 | */ |
| 2104 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2105 | 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] | 2106 | uint16_t *orig_xchg_cnt, uint16_t *cur_iocb_cnt, |
Andrew Vasquez | f3a0a77 | 2009-10-13 15:16:49 -0700 | [diff] [blame] | 2107 | 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] | 2108 | { |
| 2109 | int rval; |
| 2110 | mbx_cmd_t mc; |
| 2111 | mbx_cmd_t *mcp = &mc; |
| 2112 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2113 | ql_dbg(ql_dbg_mbx, vha, 0x107c, "Entered %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2114 | |
| 2115 | mcp->mb[0] = MBC_GET_RESOURCE_COUNTS; |
| 2116 | mcp->out_mb = MBX_0; |
Seokmann Ju | 4d0ea24 | 2007-09-20 14:07:43 -0700 | [diff] [blame] | 2117 | mcp->in_mb = MBX_11|MBX_10|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2118 | if (IS_QLA81XX(vha->hw) || IS_QLA83XX(vha->hw)) |
Andrew Vasquez | f3a0a77 | 2009-10-13 15:16:49 -0700 | [diff] [blame] | 2119 | mcp->in_mb |= MBX_12; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2120 | mcp->tov = MBX_TOV_SECONDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2121 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2122 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2123 | |
| 2124 | if (rval != QLA_SUCCESS) { |
| 2125 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2126 | ql_dbg(ql_dbg_mbx, vha, 0x107d, |
| 2127 | "Failed mb[0]=%x.\n", mcp->mb[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2128 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2129 | ql_dbg(ql_dbg_mbx, vha, 0x107e, |
| 2130 | "Done %s mb1=%x mb2=%x mb3=%x mb6=%x mb7=%x mb10=%x " |
| 2131 | "mb11=%x mb12=%x.\n", __func__, mcp->mb[1], mcp->mb[2], |
| 2132 | mcp->mb[3], mcp->mb[6], mcp->mb[7], mcp->mb[10], |
| 2133 | mcp->mb[11], mcp->mb[12]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2134 | |
| 2135 | if (cur_xchg_cnt) |
| 2136 | *cur_xchg_cnt = mcp->mb[3]; |
| 2137 | if (orig_xchg_cnt) |
| 2138 | *orig_xchg_cnt = mcp->mb[6]; |
| 2139 | if (cur_iocb_cnt) |
| 2140 | *cur_iocb_cnt = mcp->mb[7]; |
| 2141 | if (orig_iocb_cnt) |
| 2142 | *orig_iocb_cnt = mcp->mb[10]; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2143 | if (vha->hw->flags.npiv_supported && max_npiv_vports) |
Seokmann Ju | 4d0ea24 | 2007-09-20 14:07:43 -0700 | [diff] [blame] | 2144 | *max_npiv_vports = mcp->mb[11]; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2145 | if ((IS_QLA81XX(vha->hw) || IS_QLA83XX(vha->hw)) && max_fcfs) |
Andrew Vasquez | f3a0a77 | 2009-10-13 15:16:49 -0700 | [diff] [blame] | 2146 | *max_fcfs = mcp->mb[12]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2147 | } |
| 2148 | |
| 2149 | return (rval); |
| 2150 | } |
| 2151 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2152 | /* |
| 2153 | * qla2x00_get_fcal_position_map |
| 2154 | * Get FCAL (LILP) position map using mailbox command |
| 2155 | * |
| 2156 | * Input: |
| 2157 | * ha = adapter state pointer. |
| 2158 | * pos_map = buffer pointer (can be NULL). |
| 2159 | * |
| 2160 | * Returns: |
| 2161 | * qla2x00 local function return status code. |
| 2162 | * |
| 2163 | * Context: |
| 2164 | * Kernel context. |
| 2165 | */ |
| 2166 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2167 | 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] | 2168 | { |
| 2169 | int rval; |
| 2170 | mbx_cmd_t mc; |
| 2171 | mbx_cmd_t *mcp = &mc; |
| 2172 | char *pmap; |
| 2173 | dma_addr_t pmap_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2174 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2175 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2176 | ql_dbg(ql_dbg_mbx, vha, 0x107f, "Entered %s.\n", __func__); |
| 2177 | |
Andrew Vasquez | 4b89258 | 2008-09-11 21:22:48 -0700 | [diff] [blame] | 2178 | pmap = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pmap_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2179 | if (pmap == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2180 | ql_log(ql_log_warn, vha, 0x1080, |
| 2181 | "Memory alloc failed.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2182 | return QLA_MEMORY_ALLOC_FAILED; |
| 2183 | } |
| 2184 | memset(pmap, 0, FCAL_MAP_SIZE); |
| 2185 | |
| 2186 | mcp->mb[0] = MBC_GET_FC_AL_POSITION_MAP; |
| 2187 | mcp->mb[2] = MSW(pmap_dma); |
| 2188 | mcp->mb[3] = LSW(pmap_dma); |
| 2189 | mcp->mb[6] = MSW(MSD(pmap_dma)); |
| 2190 | mcp->mb[7] = LSW(MSD(pmap_dma)); |
| 2191 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; |
| 2192 | mcp->in_mb = MBX_1|MBX_0; |
| 2193 | mcp->buf_size = FCAL_MAP_SIZE; |
| 2194 | mcp->flags = MBX_DMA_IN; |
| 2195 | mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2196 | rval = qla2x00_mailbox_command(vha, mcp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2197 | |
| 2198 | if (rval == QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2199 | ql_dbg(ql_dbg_mbx, vha, 0x1081, |
| 2200 | "mb0/mb1=%x/%X FC/AL position map size (%x).\n", |
| 2201 | mcp->mb[0], mcp->mb[1], (unsigned)pmap[0]); |
| 2202 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111d, |
| 2203 | pmap, pmap[0] + 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2204 | |
| 2205 | if (pos_map) |
| 2206 | memcpy(pos_map, pmap, FCAL_MAP_SIZE); |
| 2207 | } |
| 2208 | dma_pool_free(ha->s_dma_pool, pmap, pmap_dma); |
| 2209 | |
| 2210 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2211 | ql_dbg(ql_dbg_mbx, vha, 0x1082, "Failed=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2212 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2213 | ql_dbg(ql_dbg_mbx, vha, 0x1083, "Done %s.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2214 | } |
| 2215 | |
| 2216 | return rval; |
| 2217 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2218 | |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2219 | /* |
| 2220 | * qla2x00_get_link_status |
| 2221 | * |
| 2222 | * Input: |
| 2223 | * ha = adapter block pointer. |
| 2224 | * loop_id = device loop ID. |
| 2225 | * ret_buf = pointer to link status return buffer. |
| 2226 | * |
| 2227 | * Returns: |
| 2228 | * 0 = success. |
| 2229 | * BIT_0 = mem alloc error. |
| 2230 | * BIT_1 = mailbox error. |
| 2231 | */ |
| 2232 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2233 | 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] | 2234 | struct link_statistics *stats, dma_addr_t stats_dma) |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2235 | { |
| 2236 | int rval; |
| 2237 | mbx_cmd_t mc; |
| 2238 | mbx_cmd_t *mcp = &mc; |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2239 | uint32_t *siter, *diter, dwords; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2240 | struct qla_hw_data *ha = vha->hw; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2241 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2242 | ql_dbg(ql_dbg_mbx, vha, 0x1084, "Entered %s.\n", __func__); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2243 | |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2244 | mcp->mb[0] = MBC_GET_LINK_STATUS; |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2245 | mcp->mb[2] = MSW(stats_dma); |
| 2246 | mcp->mb[3] = LSW(stats_dma); |
| 2247 | mcp->mb[6] = MSW(MSD(stats_dma)); |
| 2248 | mcp->mb[7] = LSW(MSD(stats_dma)); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2249 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; |
| 2250 | mcp->in_mb = MBX_0; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2251 | if (IS_FWI2_CAPABLE(ha)) { |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2252 | mcp->mb[1] = loop_id; |
| 2253 | mcp->mb[4] = 0; |
| 2254 | mcp->mb[10] = 0; |
| 2255 | mcp->out_mb |= MBX_10|MBX_4|MBX_1; |
| 2256 | mcp->in_mb |= MBX_1; |
| 2257 | } else if (HAS_EXTENDED_IDS(ha)) { |
| 2258 | mcp->mb[1] = loop_id; |
| 2259 | mcp->mb[10] = 0; |
| 2260 | mcp->out_mb |= MBX_10|MBX_1; |
| 2261 | } else { |
| 2262 | mcp->mb[1] = loop_id << 8; |
| 2263 | mcp->out_mb |= MBX_1; |
| 2264 | } |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2265 | mcp->tov = MBX_TOV_SECONDS; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2266 | mcp->flags = IOCTL_CMD; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2267 | rval = qla2x00_mailbox_command(vha, mcp); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2268 | |
| 2269 | if (rval == QLA_SUCCESS) { |
| 2270 | if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2271 | ql_dbg(ql_dbg_mbx, vha, 0x1085, |
| 2272 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2273 | rval = QLA_FUNCTION_FAILED; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2274 | } else { |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2275 | /* Copy over data -- firmware data is LE. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2276 | ql_dbg(ql_dbg_mbx, vha, 0x1086, "Done %s.\n", __func__); |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2277 | dwords = offsetof(struct link_statistics, unused1) / 4; |
| 2278 | siter = diter = &stats->link_fail_cnt; |
| 2279 | while (dwords--) |
| 2280 | *diter++ = le32_to_cpu(*siter++); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2281 | } |
| 2282 | } else { |
| 2283 | /* Failed. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2284 | 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] | 2285 | } |
| 2286 | |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 2287 | return rval; |
| 2288 | } |
| 2289 | |
| 2290 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2291 | 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] | 2292 | dma_addr_t stats_dma) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2293 | { |
| 2294 | int rval; |
| 2295 | mbx_cmd_t mc; |
| 2296 | mbx_cmd_t *mcp = &mc; |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2297 | uint32_t *siter, *diter, dwords; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2298 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2299 | ql_dbg(ql_dbg_mbx, vha, 0x1088, "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2300 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2301 | mcp->mb[0] = MBC_GET_LINK_PRIV_STATS; |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2302 | mcp->mb[2] = MSW(stats_dma); |
| 2303 | mcp->mb[3] = LSW(stats_dma); |
| 2304 | mcp->mb[6] = MSW(MSD(stats_dma)); |
| 2305 | mcp->mb[7] = LSW(MSD(stats_dma)); |
| 2306 | mcp->mb[8] = sizeof(struct link_statistics) / 4; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2307 | mcp->mb[9] = vha->vp_idx; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2308 | mcp->mb[10] = 0; |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2309 | 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] | 2310 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2311 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2312 | mcp->flags = IOCTL_CMD; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2313 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2314 | |
| 2315 | if (rval == QLA_SUCCESS) { |
| 2316 | if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2317 | ql_dbg(ql_dbg_mbx, vha, 0x1089, |
| 2318 | "Failed mb[0]=%x.\n", mcp->mb[0]); |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2319 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2320 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2321 | ql_dbg(ql_dbg_mbx, vha, 0x108a, "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2322 | /* Copy over data -- firmware data is LE. */ |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2323 | dwords = sizeof(struct link_statistics) / 4; |
| 2324 | siter = diter = &stats->link_fail_cnt; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2325 | while (dwords--) |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 2326 | *diter++ = le32_to_cpu(*siter++); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2327 | } |
| 2328 | } else { |
| 2329 | /* Failed. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2330 | ql_dbg(ql_dbg_mbx, vha, 0x108b, "Failed=%x.\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2331 | } |
| 2332 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2333 | return rval; |
| 2334 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2335 | |
| 2336 | int |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2337 | qla24xx_abort_command(srb_t *sp) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2338 | { |
| 2339 | int rval; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2340 | unsigned long flags = 0; |
| 2341 | |
| 2342 | struct abort_entry_24xx *abt; |
| 2343 | dma_addr_t abt_dma; |
| 2344 | uint32_t handle; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2345 | fc_port_t *fcport = sp->fcport; |
| 2346 | struct scsi_qla_host *vha = fcport->vha; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2347 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 2348 | struct req_que *req = vha->req; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2349 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2350 | ql_dbg(ql_dbg_mbx, vha, 0x108c, "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2351 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2352 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2353 | for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2354 | if (req->outstanding_cmds[handle] == sp) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2355 | break; |
| 2356 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2357 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2358 | if (handle == MAX_OUTSTANDING_COMMANDS) { |
| 2359 | /* Command not found. */ |
| 2360 | return QLA_FUNCTION_FAILED; |
| 2361 | } |
| 2362 | |
| 2363 | abt = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &abt_dma); |
| 2364 | if (abt == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2365 | ql_log(ql_log_warn, vha, 0x108d, |
| 2366 | "Failed to allocate abort IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2367 | return QLA_MEMORY_ALLOC_FAILED; |
| 2368 | } |
| 2369 | memset(abt, 0, sizeof(struct abort_entry_24xx)); |
| 2370 | |
| 2371 | abt->entry_type = ABORT_IOCB_TYPE; |
| 2372 | abt->entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2373 | abt->handle = MAKE_HANDLE(req->id, abt->handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2374 | abt->nport_handle = cpu_to_le16(fcport->loop_id); |
Mike Hernandez | a74ec14 | 2011-03-30 11:46:20 -0700 | [diff] [blame] | 2375 | abt->handle_to_abort = MAKE_HANDLE(req->id, handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2376 | abt->port_id[0] = fcport->d_id.b.al_pa; |
| 2377 | abt->port_id[1] = fcport->d_id.b.area; |
| 2378 | abt->port_id[2] = fcport->d_id.b.domain; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2379 | abt->vp_index = fcport->vp_idx; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2380 | |
| 2381 | abt->req_que_no = cpu_to_le16(req->id); |
| 2382 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2383 | rval = qla2x00_issue_iocb(vha, abt, abt_dma, 0); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2384 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2385 | ql_dbg(ql_dbg_mbx, vha, 0x108e, |
| 2386 | "Failed to issue IOCB (%x).\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2387 | } else if (abt->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2388 | ql_dbg(ql_dbg_mbx, vha, 0x108f, |
| 2389 | "Failed to complete IOCB -- error status (%x).\n", |
| 2390 | abt->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2391 | rval = QLA_FUNCTION_FAILED; |
| 2392 | } else if (abt->nport_handle != __constant_cpu_to_le16(0)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2393 | ql_dbg(ql_dbg_mbx, vha, 0x1090, |
| 2394 | "Failed to complete IOCB -- completion status (%x).\n", |
| 2395 | le16_to_cpu(abt->nport_handle)); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2396 | rval = QLA_FUNCTION_FAILED; |
| 2397 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2398 | ql_dbg(ql_dbg_mbx, vha, 0x1091, "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2399 | } |
| 2400 | |
| 2401 | dma_pool_free(ha->s_dma_pool, abt, abt_dma); |
| 2402 | |
| 2403 | return rval; |
| 2404 | } |
| 2405 | |
| 2406 | struct tsk_mgmt_cmd { |
| 2407 | union { |
| 2408 | struct tsk_mgmt_entry tsk; |
| 2409 | struct sts_entry_24xx sts; |
| 2410 | } p; |
| 2411 | }; |
| 2412 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2413 | static int |
| 2414 | __qla24xx_issue_tmf(char *name, uint32_t type, struct fc_port *fcport, |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2415 | unsigned int l, int tag) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2416 | { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2417 | int rval, rval2; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2418 | struct tsk_mgmt_cmd *tsk; |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 2419 | struct sts_entry_24xx *sts; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2420 | dma_addr_t tsk_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2421 | scsi_qla_host_t *vha; |
| 2422 | struct qla_hw_data *ha; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2423 | struct req_que *req; |
| 2424 | struct rsp_que *rsp; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2425 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2426 | vha = fcport->vha; |
| 2427 | ha = vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2428 | req = vha->req; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2429 | |
| 2430 | ql_dbg(ql_dbg_mbx, vha, 0x1092, "Entered %s.\n", __func__); |
| 2431 | |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 2432 | if (ha->flags.cpu_affinity_enabled) |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2433 | rsp = ha->rsp_q_map[tag + 1]; |
| 2434 | else |
| 2435 | rsp = req->rsp; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2436 | tsk = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &tsk_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2437 | if (tsk == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2438 | ql_log(ql_log_warn, vha, 0x1093, |
| 2439 | "Failed to allocate task management IOCB.\n"); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2440 | return QLA_MEMORY_ALLOC_FAILED; |
| 2441 | } |
| 2442 | memset(tsk, 0, sizeof(struct tsk_mgmt_cmd)); |
| 2443 | |
| 2444 | tsk->p.tsk.entry_type = TSK_MGMT_IOCB_TYPE; |
| 2445 | tsk->p.tsk.entry_count = 1; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2446 | tsk->p.tsk.handle = MAKE_HANDLE(req->id, tsk->p.tsk.handle); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2447 | tsk->p.tsk.nport_handle = cpu_to_le16(fcport->loop_id); |
Andrew Vasquez | 00a537b | 2008-02-28 14:06:11 -0800 | [diff] [blame] | 2448 | 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] | 2449 | tsk->p.tsk.control_flags = cpu_to_le32(type); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2450 | tsk->p.tsk.port_id[0] = fcport->d_id.b.al_pa; |
| 2451 | tsk->p.tsk.port_id[1] = fcport->d_id.b.area; |
| 2452 | tsk->p.tsk.port_id[2] = fcport->d_id.b.domain; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2453 | tsk->p.tsk.vp_index = fcport->vp_idx; |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2454 | if (type == TCF_LUN_RESET) { |
| 2455 | int_to_scsilun(l, &tsk->p.tsk.lun); |
| 2456 | host_to_fcp_swap((uint8_t *)&tsk->p.tsk.lun, |
| 2457 | sizeof(tsk->p.tsk.lun)); |
| 2458 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2459 | |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 2460 | sts = &tsk->p.sts; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2461 | rval = qla2x00_issue_iocb(vha, tsk, tsk_dma, 0); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2462 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2463 | ql_dbg(ql_dbg_mbx, vha, 0x1094, |
| 2464 | "Failed to issue %s reset IOCB (%x).\n", name, rval); |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 2465 | } else if (sts->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2466 | ql_dbg(ql_dbg_mbx, vha, 0x1095, |
| 2467 | "Failed to complete IOCB -- error status (%x).\n", |
| 2468 | sts->entry_status); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2469 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 2470 | } else if (sts->comp_status != |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2471 | __constant_cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2472 | ql_dbg(ql_dbg_mbx, vha, 0x1096, |
| 2473 | "Failed to complete IOCB -- completion status (%x).\n", |
| 2474 | le16_to_cpu(sts->comp_status)); |
Andrew Vasquez | 9ca1d01 | 2009-10-13 15:16:50 -0700 | [diff] [blame] | 2475 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 97dec56 | 2011-02-23 15:27:14 -0800 | [diff] [blame] | 2476 | } else if (le16_to_cpu(sts->scsi_status) & |
| 2477 | SS_RESPONSE_INFO_LEN_VALID) { |
| 2478 | if (le32_to_cpu(sts->rsp_data_len) < 4) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2479 | ql_dbg(ql_dbg_mbx, vha, 0x1097, |
| 2480 | "Ignoring inconsistent data length -- not enough " |
| 2481 | "response info (%d).\n", |
| 2482 | le32_to_cpu(sts->rsp_data_len)); |
Andrew Vasquez | 97dec56 | 2011-02-23 15:27:14 -0800 | [diff] [blame] | 2483 | } else if (sts->data[3]) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2484 | ql_dbg(ql_dbg_mbx, vha, 0x1098, |
| 2485 | "Failed to complete IOCB -- response (%x).\n", |
| 2486 | sts->data[3]); |
Andrew Vasquez | 97dec56 | 2011-02-23 15:27:14 -0800 | [diff] [blame] | 2487 | rval = QLA_FUNCTION_FAILED; |
| 2488 | } |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2489 | } |
| 2490 | |
| 2491 | /* Issue marker IOCB. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2492 | rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, l, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2493 | type == TCF_LUN_RESET ? MK_SYNC_ID_LUN: MK_SYNC_ID); |
| 2494 | if (rval2 != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2495 | ql_dbg(ql_dbg_mbx, vha, 0x1099, |
| 2496 | "Failed to issue marker IOCB (%x).\n", rval2); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2497 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2498 | ql_dbg(ql_dbg_mbx, vha, 0x109a, "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2499 | } |
| 2500 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2501 | dma_pool_free(ha->s_dma_pool, tsk, tsk_dma); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2502 | |
| 2503 | return rval; |
| 2504 | } |
| 2505 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2506 | int |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2507 | qla24xx_abort_target(struct fc_port *fcport, unsigned int l, int tag) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2508 | { |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 2509 | struct qla_hw_data *ha = fcport->vha->hw; |
| 2510 | |
| 2511 | if ((ql2xasynctmfenable) && IS_FWI2_CAPABLE(ha)) |
| 2512 | return qla2x00_async_tm_cmd(fcport, TCF_TARGET_RESET, l, tag); |
| 2513 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2514 | return __qla24xx_issue_tmf("Target", TCF_TARGET_RESET, fcport, l, tag); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2515 | } |
| 2516 | |
| 2517 | int |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2518 | qla24xx_lun_reset(struct fc_port *fcport, unsigned int l, int tag) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2519 | { |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 2520 | struct qla_hw_data *ha = fcport->vha->hw; |
| 2521 | |
| 2522 | if ((ql2xasynctmfenable) && IS_FWI2_CAPABLE(ha)) |
| 2523 | return qla2x00_async_tm_cmd(fcport, TCF_LUN_RESET, l, tag); |
| 2524 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2525 | return __qla24xx_issue_tmf("Lun", TCF_LUN_RESET, fcport, l, tag); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2526 | } |
| 2527 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2528 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2529 | qla2x00_system_error(scsi_qla_host_t *vha) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2530 | { |
| 2531 | int rval; |
| 2532 | mbx_cmd_t mc; |
| 2533 | mbx_cmd_t *mcp = &mc; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2534 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2535 | |
Andrew Vasquez | 68af081 | 2008-05-12 22:21:13 -0700 | [diff] [blame] | 2536 | if (!IS_QLA23XX(ha) && !IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2537 | return QLA_FUNCTION_FAILED; |
| 2538 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2539 | ql_dbg(ql_dbg_mbx, vha, 0x109b, "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2540 | |
| 2541 | mcp->mb[0] = MBC_GEN_SYSTEM_ERROR; |
| 2542 | mcp->out_mb = MBX_0; |
| 2543 | mcp->in_mb = MBX_0; |
| 2544 | mcp->tov = 5; |
| 2545 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2546 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2547 | |
| 2548 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2549 | ql_dbg(ql_dbg_mbx, vha, 0x109c, "Failed=%x.\n", rval); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2550 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2551 | ql_dbg(ql_dbg_mbx, vha, 0x109d, "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2552 | } |
| 2553 | |
| 2554 | return rval; |
| 2555 | } |
| 2556 | |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2557 | /** |
| 2558 | * qla2x00_set_serdes_params() - |
| 2559 | * @ha: HA context |
| 2560 | * |
| 2561 | * Returns |
| 2562 | */ |
| 2563 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2564 | 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] | 2565 | uint16_t sw_em_2g, uint16_t sw_em_4g) |
| 2566 | { |
| 2567 | int rval; |
| 2568 | mbx_cmd_t mc; |
| 2569 | mbx_cmd_t *mcp = &mc; |
| 2570 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2571 | ql_dbg(ql_dbg_mbx, vha, 0x109e, "Entered %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2572 | |
| 2573 | mcp->mb[0] = MBC_SERDES_PARAMS; |
| 2574 | mcp->mb[1] = BIT_0; |
andrew.vasquez@qlogic.com | fdbc683 | 2006-03-09 14:27:29 -0800 | [diff] [blame] | 2575 | mcp->mb[2] = sw_em_1g | BIT_15; |
| 2576 | mcp->mb[3] = sw_em_2g | BIT_15; |
| 2577 | mcp->mb[4] = sw_em_4g | BIT_15; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2578 | mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 2579 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2580 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2581 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2582 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2583 | |
| 2584 | if (rval != QLA_SUCCESS) { |
| 2585 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2586 | ql_dbg(ql_dbg_mbx, vha, 0x109f, |
| 2587 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2588 | } else { |
| 2589 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2590 | ql_dbg(ql_dbg_mbx, vha, 0x10a0, "Done %s.\n", __func__); |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 2591 | } |
| 2592 | |
| 2593 | return rval; |
| 2594 | } |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 2595 | |
| 2596 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2597 | qla2x00_stop_firmware(scsi_qla_host_t *vha) |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 2598 | { |
| 2599 | int rval; |
| 2600 | mbx_cmd_t mc; |
| 2601 | mbx_cmd_t *mcp = &mc; |
| 2602 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2603 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 2604 | return QLA_FUNCTION_FAILED; |
| 2605 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2606 | ql_dbg(ql_dbg_mbx, vha, 0x10a1, "Entered %s.\n", __func__); |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 2607 | |
| 2608 | mcp->mb[0] = MBC_STOP_FIRMWARE; |
Andrew Vasquez | 4ba988d | 2012-02-09 11:14:06 -0800 | [diff] [blame] | 2609 | mcp->mb[1] = 0; |
| 2610 | mcp->out_mb = MBX_1|MBX_0; |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 2611 | mcp->in_mb = MBX_0; |
| 2612 | mcp->tov = 5; |
| 2613 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2614 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 2615 | |
| 2616 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2617 | ql_dbg(ql_dbg_mbx, vha, 0x10a2, "Failed=%x.\n", rval); |
Andrew Vasquez | b469a7c | 2009-04-06 22:33:48 -0700 | [diff] [blame] | 2618 | if (mcp->mb[0] == MBS_INVALID_COMMAND) |
| 2619 | rval = QLA_INVALID_COMMAND; |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 2620 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2621 | ql_dbg(ql_dbg_mbx, vha, 0x10a3, "Done %s.\n", __func__); |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 2622 | } |
| 2623 | |
| 2624 | return rval; |
| 2625 | } |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 2626 | |
| 2627 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2628 | 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] | 2629 | uint16_t buffers) |
| 2630 | { |
| 2631 | int rval; |
| 2632 | mbx_cmd_t mc; |
| 2633 | mbx_cmd_t *mcp = &mc; |
| 2634 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2635 | ql_dbg(ql_dbg_mbx, vha, 0x10a4, "Entered %s.\n", __func__); |
| 2636 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2637 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 2638 | return QLA_FUNCTION_FAILED; |
| 2639 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 2640 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 2641 | return QLA_FUNCTION_FAILED; |
| 2642 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 2643 | mcp->mb[0] = MBC_TRACE_CONTROL; |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 2644 | mcp->mb[1] = TC_EFT_ENABLE; |
| 2645 | mcp->mb[2] = LSW(eft_dma); |
| 2646 | mcp->mb[3] = MSW(eft_dma); |
| 2647 | mcp->mb[4] = LSW(MSD(eft_dma)); |
| 2648 | mcp->mb[5] = MSW(MSD(eft_dma)); |
| 2649 | mcp->mb[6] = buffers; |
| 2650 | mcp->mb[7] = TC_AEN_DISABLE; |
| 2651 | 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] | 2652 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2653 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 2654 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2655 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 2656 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2657 | ql_dbg(ql_dbg_mbx, vha, 0x10a5, |
| 2658 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 2659 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 2660 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2661 | ql_dbg(ql_dbg_mbx, vha, 0x10a6, "Done %s.\n", __func__); |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 2662 | } |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 2663 | |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 2664 | return rval; |
| 2665 | } |
| 2666 | |
| 2667 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2668 | qla2x00_disable_eft_trace(scsi_qla_host_t *vha) |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 2669 | { |
| 2670 | int rval; |
| 2671 | mbx_cmd_t mc; |
| 2672 | mbx_cmd_t *mcp = &mc; |
| 2673 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2674 | ql_dbg(ql_dbg_mbx, vha, 0x10a7, "Entered %s.\n", __func__); |
| 2675 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2676 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 2677 | return QLA_FUNCTION_FAILED; |
| 2678 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 2679 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 2680 | return QLA_FUNCTION_FAILED; |
| 2681 | |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 2682 | mcp->mb[0] = MBC_TRACE_CONTROL; |
| 2683 | mcp->mb[1] = TC_EFT_DISABLE; |
| 2684 | mcp->out_mb = MBX_1|MBX_0; |
| 2685 | mcp->in_mb = MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2686 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 00b6bd2 | 2008-01-17 09:02:16 -0800 | [diff] [blame] | 2687 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2688 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 2689 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2690 | ql_dbg(ql_dbg_mbx, vha, 0x10a8, |
| 2691 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 2692 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 2693 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2694 | ql_dbg(ql_dbg_mbx, vha, 0x10a9, "Done %s.\n", __func__); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 2695 | } |
| 2696 | |
| 2697 | return rval; |
| 2698 | } |
| 2699 | |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 2700 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2701 | 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] | 2702 | uint16_t buffers, uint16_t *mb, uint32_t *dwords) |
| 2703 | { |
| 2704 | int rval; |
| 2705 | mbx_cmd_t mc; |
| 2706 | mbx_cmd_t *mcp = &mc; |
| 2707 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2708 | ql_dbg(ql_dbg_mbx, vha, 0x10aa, "Entered %s.\n", __func__); |
| 2709 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2710 | if (!IS_QLA25XX(vha->hw) && !IS_QLA81XX(vha->hw) && |
| 2711 | !IS_QLA83XX(vha->hw)) |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2712 | return QLA_FUNCTION_FAILED; |
| 2713 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 2714 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 2715 | return QLA_FUNCTION_FAILED; |
| 2716 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2717 | mcp->mb[0] = MBC_TRACE_CONTROL; |
| 2718 | mcp->mb[1] = TC_FCE_ENABLE; |
| 2719 | mcp->mb[2] = LSW(fce_dma); |
| 2720 | mcp->mb[3] = MSW(fce_dma); |
| 2721 | mcp->mb[4] = LSW(MSD(fce_dma)); |
| 2722 | mcp->mb[5] = MSW(MSD(fce_dma)); |
| 2723 | mcp->mb[6] = buffers; |
| 2724 | mcp->mb[7] = TC_AEN_DISABLE; |
| 2725 | mcp->mb[8] = 0; |
| 2726 | mcp->mb[9] = TC_FCE_DEFAULT_RX_SIZE; |
| 2727 | mcp->mb[10] = TC_FCE_DEFAULT_TX_SIZE; |
| 2728 | mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2| |
| 2729 | MBX_1|MBX_0; |
| 2730 | 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] | 2731 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2732 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2733 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2734 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2735 | ql_dbg(ql_dbg_mbx, vha, 0x10ab, |
| 2736 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 2737 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2738 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2739 | ql_dbg(ql_dbg_mbx, vha, 0x10ac, "Done %s.\n", __func__); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2740 | |
| 2741 | if (mb) |
| 2742 | memcpy(mb, mcp->mb, 8 * sizeof(*mb)); |
| 2743 | if (dwords) |
Andrew Vasquez | fa0926d | 2008-05-12 22:21:12 -0700 | [diff] [blame] | 2744 | *dwords = buffers; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2745 | } |
| 2746 | |
| 2747 | return rval; |
| 2748 | } |
| 2749 | |
| 2750 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2751 | 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] | 2752 | { |
| 2753 | int rval; |
| 2754 | mbx_cmd_t mc; |
| 2755 | mbx_cmd_t *mcp = &mc; |
| 2756 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2757 | ql_dbg(ql_dbg_mbx, vha, 0x10ad, "Entered %s.\n", __func__); |
| 2758 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2759 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2760 | return QLA_FUNCTION_FAILED; |
| 2761 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 2762 | if (unlikely(pci_channel_offline(vha->hw->pdev))) |
| 2763 | return QLA_FUNCTION_FAILED; |
| 2764 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2765 | mcp->mb[0] = MBC_TRACE_CONTROL; |
| 2766 | mcp->mb[1] = TC_FCE_DISABLE; |
| 2767 | mcp->mb[2] = TC_FCE_DISABLE_TRACE; |
| 2768 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 2769 | mcp->in_mb = MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2| |
| 2770 | MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2771 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2772 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2773 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2774 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2775 | ql_dbg(ql_dbg_mbx, vha, 0x10ae, |
| 2776 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 2777 | rval, mcp->mb[0], mcp->mb[1]); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2778 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2779 | ql_dbg(ql_dbg_mbx, vha, 0x10af, "Done %s.\n", __func__); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2780 | |
| 2781 | if (wr) |
| 2782 | *wr = (uint64_t) mcp->mb[5] << 48 | |
| 2783 | (uint64_t) mcp->mb[4] << 32 | |
| 2784 | (uint64_t) mcp->mb[3] << 16 | |
| 2785 | (uint64_t) mcp->mb[2]; |
| 2786 | if (rd) |
| 2787 | *rd = (uint64_t) mcp->mb[9] << 48 | |
| 2788 | (uint64_t) mcp->mb[8] << 32 | |
| 2789 | (uint64_t) mcp->mb[7] << 16 | |
| 2790 | (uint64_t) mcp->mb[6]; |
| 2791 | } |
| 2792 | |
| 2793 | return rval; |
| 2794 | } |
| 2795 | |
| 2796 | int |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 2797 | qla2x00_get_idma_speed(scsi_qla_host_t *vha, uint16_t loop_id, |
| 2798 | uint16_t *port_speed, uint16_t *mb) |
| 2799 | { |
| 2800 | int rval; |
| 2801 | mbx_cmd_t mc; |
| 2802 | mbx_cmd_t *mcp = &mc; |
| 2803 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2804 | ql_dbg(ql_dbg_mbx, vha, 0x10b0, "Entered %s.\n", __func__); |
| 2805 | |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 2806 | if (!IS_IIDMA_CAPABLE(vha->hw)) |
| 2807 | return QLA_FUNCTION_FAILED; |
| 2808 | |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 2809 | mcp->mb[0] = MBC_PORT_PARAMS; |
| 2810 | mcp->mb[1] = loop_id; |
| 2811 | mcp->mb[2] = mcp->mb[3] = 0; |
| 2812 | mcp->mb[9] = vha->vp_idx; |
| 2813 | mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0; |
| 2814 | mcp->in_mb = MBX_3|MBX_1|MBX_0; |
| 2815 | mcp->tov = MBX_TOV_SECONDS; |
| 2816 | mcp->flags = 0; |
| 2817 | rval = qla2x00_mailbox_command(vha, mcp); |
| 2818 | |
| 2819 | /* Return mailbox statuses. */ |
| 2820 | if (mb != NULL) { |
| 2821 | mb[0] = mcp->mb[0]; |
| 2822 | mb[1] = mcp->mb[1]; |
| 2823 | mb[3] = mcp->mb[3]; |
| 2824 | } |
| 2825 | |
| 2826 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2827 | ql_dbg(ql_dbg_mbx, vha, 0x10b1, "Failed=%x.\n", rval); |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 2828 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2829 | ql_dbg(ql_dbg_mbx, vha, 0x10b2, "Done %s.\n", __func__); |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 2830 | if (port_speed) |
| 2831 | *port_speed = mcp->mb[3]; |
| 2832 | } |
| 2833 | |
| 2834 | return rval; |
| 2835 | } |
| 2836 | |
| 2837 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2838 | 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] | 2839 | uint16_t port_speed, uint16_t *mb) |
| 2840 | { |
| 2841 | int rval; |
| 2842 | mbx_cmd_t mc; |
| 2843 | mbx_cmd_t *mcp = &mc; |
| 2844 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2845 | ql_dbg(ql_dbg_mbx, vha, 0x10b3, "Entered %s.\n", __func__); |
| 2846 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2847 | if (!IS_IIDMA_CAPABLE(vha->hw)) |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2848 | return QLA_FUNCTION_FAILED; |
| 2849 | |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2850 | mcp->mb[0] = MBC_PORT_PARAMS; |
| 2851 | mcp->mb[1] = loop_id; |
| 2852 | mcp->mb[2] = BIT_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2853 | if (IS_CNA_CAPABLE(vha->hw)) |
Harish Zunjarrao | 1bb3954 | 2009-06-17 10:30:29 -0700 | [diff] [blame] | 2854 | mcp->mb[3] = port_speed & (BIT_5|BIT_4|BIT_3|BIT_2|BIT_1|BIT_0); |
| 2855 | else |
| 2856 | mcp->mb[3] = port_speed & (BIT_2|BIT_1|BIT_0); |
| 2857 | mcp->mb[9] = vha->vp_idx; |
| 2858 | mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0; |
| 2859 | mcp->in_mb = MBX_3|MBX_1|MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 2860 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2861 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2862 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2863 | |
| 2864 | /* Return mailbox statuses. */ |
| 2865 | if (mb != NULL) { |
| 2866 | mb[0] = mcp->mb[0]; |
| 2867 | mb[1] = mcp->mb[1]; |
| 2868 | mb[3] = mcp->mb[3]; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2869 | } |
| 2870 | |
| 2871 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2872 | ql_dbg(ql_dbg_mbx, vha, 0x10b4, "Failed=%x.\n", rval); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2873 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2874 | ql_dbg(ql_dbg_mbx, vha, 0x10b5, "Done %s.\n", __func__); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2875 | } |
| 2876 | |
| 2877 | return rval; |
| 2878 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2879 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2880 | void |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2881 | qla24xx_report_id_acquisition(scsi_qla_host_t *vha, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2882 | struct vp_rpt_id_entry_24xx *rptid_entry) |
| 2883 | { |
| 2884 | uint8_t vp_idx; |
Seokmann Ju | c6852c4 | 2008-04-24 15:21:29 -0700 | [diff] [blame] | 2885 | uint16_t stat = le16_to_cpu(rptid_entry->vp_idx); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2886 | struct qla_hw_data *ha = vha->hw; |
| 2887 | scsi_qla_host_t *vp; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 2888 | unsigned long flags; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2889 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2890 | ql_dbg(ql_dbg_mbx, vha, 0x10b6, "Entered %s.\n", __func__); |
| 2891 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2892 | if (rptid_entry->entry_status != 0) |
| 2893 | return; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2894 | |
| 2895 | if (rptid_entry->format == 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2896 | ql_dbg(ql_dbg_mbx, vha, 0x10b7, |
| 2897 | "Format 0 : Number of VPs setup %d, number of " |
| 2898 | "VPs acquired %d.\n", |
| 2899 | MSB(le16_to_cpu(rptid_entry->vp_count)), |
| 2900 | LSB(le16_to_cpu(rptid_entry->vp_count))); |
| 2901 | ql_dbg(ql_dbg_mbx, vha, 0x10b8, |
| 2902 | "Primary port id %02x%02x%02x.\n", |
| 2903 | rptid_entry->port_id[2], rptid_entry->port_id[1], |
| 2904 | rptid_entry->port_id[0]); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2905 | } else if (rptid_entry->format == 1) { |
Seokmann Ju | c6852c4 | 2008-04-24 15:21:29 -0700 | [diff] [blame] | 2906 | vp_idx = LSB(stat); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2907 | ql_dbg(ql_dbg_mbx, vha, 0x10b9, |
| 2908 | "Format 1: VP[%d] enabled - status %d - with " |
| 2909 | "port id %02x%02x%02x.\n", vp_idx, MSB(stat), |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2910 | rptid_entry->port_id[2], rptid_entry->port_id[1], |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2911 | rptid_entry->port_id[0]); |
Andrew Vasquez | 531a82d | 2009-10-13 15:16:51 -0700 | [diff] [blame] | 2912 | |
| 2913 | vp = vha; |
| 2914 | if (vp_idx == 0 && (MSB(stat) != 1)) |
| 2915 | goto reg_needed; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2916 | |
Giridhar Malavali | 882a917 | 2011-11-18 09:03:12 -0800 | [diff] [blame] | 2917 | if (MSB(stat) != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2918 | ql_dbg(ql_dbg_mbx, vha, 0x10ba, |
| 2919 | "Could not acquire ID for VP[%d].\n", vp_idx); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2920 | return; |
Andrew Vasquez | 81eb9b4 | 2009-06-03 09:55:23 -0700 | [diff] [blame] | 2921 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2922 | |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 2923 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 2924 | list_for_each_entry(vp, &ha->vp_list, list) |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2925 | if (vp_idx == vp->vp_idx) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2926 | break; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 2927 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 2928 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2929 | if (!vp) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2930 | return; |
| 2931 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2932 | vp->d_id.b.domain = rptid_entry->port_id[2]; |
| 2933 | vp->d_id.b.area = rptid_entry->port_id[1]; |
| 2934 | vp->d_id.b.al_pa = rptid_entry->port_id[0]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2935 | |
| 2936 | /* |
| 2937 | * Cannot configure here as we are still sitting on the |
| 2938 | * response queue. Handle it in dpc context. |
| 2939 | */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2940 | set_bit(VP_IDX_ACQUIRED, &vp->vp_flags); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2941 | |
Andrew Vasquez | 531a82d | 2009-10-13 15:16:51 -0700 | [diff] [blame] | 2942 | reg_needed: |
| 2943 | set_bit(REGISTER_FC4_NEEDED, &vp->dpc_flags); |
| 2944 | set_bit(REGISTER_FDMI_NEEDED, &vp->dpc_flags); |
| 2945 | set_bit(VP_DPC_NEEDED, &vha->dpc_flags); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2946 | qla2xxx_wake_dpc(vha); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2947 | } |
| 2948 | } |
| 2949 | |
| 2950 | /* |
| 2951 | * qla24xx_modify_vp_config |
| 2952 | * Change VP configuration for vha |
| 2953 | * |
| 2954 | * Input: |
| 2955 | * vha = adapter block pointer. |
| 2956 | * |
| 2957 | * Returns: |
| 2958 | * qla2xxx local function return status code. |
| 2959 | * |
| 2960 | * Context: |
| 2961 | * Kernel context. |
| 2962 | */ |
| 2963 | int |
| 2964 | qla24xx_modify_vp_config(scsi_qla_host_t *vha) |
| 2965 | { |
| 2966 | int rval; |
| 2967 | struct vp_config_entry_24xx *vpmod; |
| 2968 | dma_addr_t vpmod_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2969 | struct qla_hw_data *ha = vha->hw; |
| 2970 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2971 | |
| 2972 | /* This can be called by the parent */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2973 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2974 | ql_dbg(ql_dbg_mbx, vha, 0x10bb, "Entered %s.\n", __func__); |
| 2975 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2976 | vpmod = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &vpmod_dma); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2977 | if (!vpmod) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2978 | ql_log(ql_log_warn, vha, 0x10bc, |
| 2979 | "Failed to allocate modify VP IOCB.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2980 | return QLA_MEMORY_ALLOC_FAILED; |
| 2981 | } |
| 2982 | |
| 2983 | memset(vpmod, 0, sizeof(struct vp_config_entry_24xx)); |
| 2984 | vpmod->entry_type = VP_CONFIG_IOCB_TYPE; |
| 2985 | vpmod->entry_count = 1; |
| 2986 | vpmod->command = VCT_COMMAND_MOD_ENABLE_VPS; |
| 2987 | vpmod->vp_count = 1; |
| 2988 | vpmod->vp_index1 = vha->vp_idx; |
| 2989 | vpmod->options_idx1 = BIT_3|BIT_4|BIT_5; |
| 2990 | memcpy(vpmod->node_name_idx1, vha->node_name, WWN_SIZE); |
| 2991 | memcpy(vpmod->port_name_idx1, vha->port_name, WWN_SIZE); |
| 2992 | vpmod->entry_count = 1; |
| 2993 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2994 | rval = qla2x00_issue_iocb(base_vha, vpmod, vpmod_dma, 0); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2995 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2996 | ql_dbg(ql_dbg_mbx, vha, 0x10bd, |
| 2997 | "Failed to issue VP config IOCB (%x).\n", rval); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2998 | } else if (vpmod->comp_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2999 | ql_dbg(ql_dbg_mbx, vha, 0x10be, |
| 3000 | "Failed to complete IOCB -- error status (%x).\n", |
| 3001 | vpmod->comp_status); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3002 | rval = QLA_FUNCTION_FAILED; |
| 3003 | } else if (vpmod->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3004 | ql_dbg(ql_dbg_mbx, vha, 0x10bf, |
| 3005 | "Failed to complete IOCB -- completion status (%x).\n", |
| 3006 | le16_to_cpu(vpmod->comp_status)); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3007 | rval = QLA_FUNCTION_FAILED; |
| 3008 | } else { |
| 3009 | /* EMPTY */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3010 | ql_dbg(ql_dbg_mbx, vha, 0x10c0, "Done %s.\n", __func__); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3011 | fc_vport_set_state(vha->fc_vport, FC_VPORT_INITIALIZING); |
| 3012 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3013 | dma_pool_free(ha->s_dma_pool, vpmod, vpmod_dma); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3014 | |
| 3015 | return rval; |
| 3016 | } |
| 3017 | |
| 3018 | /* |
| 3019 | * qla24xx_control_vp |
| 3020 | * Enable a virtual port for given host |
| 3021 | * |
| 3022 | * Input: |
| 3023 | * ha = adapter block pointer. |
| 3024 | * vhba = virtual adapter (unused) |
| 3025 | * index = index number for enabled VP |
| 3026 | * |
| 3027 | * Returns: |
| 3028 | * qla2xxx local function return status code. |
| 3029 | * |
| 3030 | * Context: |
| 3031 | * Kernel context. |
| 3032 | */ |
| 3033 | int |
| 3034 | qla24xx_control_vp(scsi_qla_host_t *vha, int cmd) |
| 3035 | { |
| 3036 | int rval; |
| 3037 | int map, pos; |
| 3038 | struct vp_ctrl_entry_24xx *vce; |
| 3039 | dma_addr_t vce_dma; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3040 | struct qla_hw_data *ha = vha->hw; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3041 | int vp_index = vha->vp_idx; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3042 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3043 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3044 | ql_dbg(ql_dbg_mbx, vha, 0x10c1, |
| 3045 | "Entered %s enabling index %d.\n", __func__, vp_index); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3046 | |
Andrew Vasquez | eb66dc6 | 2007-11-12 10:30:58 -0800 | [diff] [blame] | 3047 | if (vp_index == 0 || vp_index >= ha->max_npiv_vports) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3048 | return QLA_PARAMETER_ERROR; |
| 3049 | |
| 3050 | vce = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &vce_dma); |
| 3051 | if (!vce) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3052 | ql_log(ql_log_warn, vha, 0x10c2, |
| 3053 | "Failed to allocate VP control IOCB.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3054 | return QLA_MEMORY_ALLOC_FAILED; |
| 3055 | } |
| 3056 | memset(vce, 0, sizeof(struct vp_ctrl_entry_24xx)); |
| 3057 | |
| 3058 | vce->entry_type = VP_CTRL_IOCB_TYPE; |
| 3059 | vce->entry_count = 1; |
| 3060 | vce->command = cpu_to_le16(cmd); |
| 3061 | vce->vp_count = __constant_cpu_to_le16(1); |
| 3062 | |
| 3063 | /* index map in firmware starts with 1; decrement index |
| 3064 | * this is ok as we never use index 0 |
| 3065 | */ |
| 3066 | map = (vp_index - 1) / 8; |
| 3067 | pos = (vp_index - 1) & 7; |
matthias@kaehlcke.net | 6c2f527 | 2008-05-12 22:21:11 -0700 | [diff] [blame] | 3068 | mutex_lock(&ha->vport_lock); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3069 | vce->vp_idx_map[map] |= 1 << pos; |
matthias@kaehlcke.net | 6c2f527 | 2008-05-12 22:21:11 -0700 | [diff] [blame] | 3070 | mutex_unlock(&ha->vport_lock); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3071 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3072 | rval = qla2x00_issue_iocb(base_vha, vce, vce_dma, 0); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3073 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3074 | ql_dbg(ql_dbg_mbx, vha, 0x10c3, |
| 3075 | "Failed to issue VP control IOCB (%x).\n", rval); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3076 | } else if (vce->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3077 | ql_dbg(ql_dbg_mbx, vha, 0x10c4, |
| 3078 | "Failed to complete IOCB -- error status (%x).\n", |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3079 | vce->entry_status); |
| 3080 | rval = QLA_FUNCTION_FAILED; |
| 3081 | } else if (vce->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3082 | ql_dbg(ql_dbg_mbx, vha, 0x10c5, |
| 3083 | "Failed to complet IOCB -- completion status (%x).\n", |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3084 | le16_to_cpu(vce->comp_status)); |
| 3085 | rval = QLA_FUNCTION_FAILED; |
| 3086 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3087 | ql_dbg(ql_dbg_mbx, vha, 0x10c6, "Done %s.\n", __func__); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3088 | } |
| 3089 | |
| 3090 | dma_pool_free(ha->s_dma_pool, vce, vce_dma); |
| 3091 | |
| 3092 | return rval; |
| 3093 | } |
| 3094 | |
| 3095 | /* |
| 3096 | * qla2x00_send_change_request |
| 3097 | * Receive or disable RSCN request from fabric controller |
| 3098 | * |
| 3099 | * Input: |
| 3100 | * ha = adapter block pointer |
| 3101 | * format = registration format: |
| 3102 | * 0 - Reserved |
| 3103 | * 1 - Fabric detected registration |
| 3104 | * 2 - N_port detected registration |
| 3105 | * 3 - Full registration |
| 3106 | * FF - clear registration |
| 3107 | * vp_idx = Virtual port index |
| 3108 | * |
| 3109 | * Returns: |
| 3110 | * qla2x00 local function return status code. |
| 3111 | * |
| 3112 | * Context: |
| 3113 | * Kernel Context |
| 3114 | */ |
| 3115 | |
| 3116 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3117 | qla2x00_send_change_request(scsi_qla_host_t *vha, uint16_t format, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3118 | uint16_t vp_idx) |
| 3119 | { |
| 3120 | int rval; |
| 3121 | mbx_cmd_t mc; |
| 3122 | mbx_cmd_t *mcp = &mc; |
| 3123 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3124 | ql_dbg(ql_dbg_mbx, vha, 0x10c7, "Entered %s.\n", __func__); |
| 3125 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3126 | /* |
| 3127 | * This command is implicitly executed by firmware during login for the |
| 3128 | * physical hosts |
| 3129 | */ |
| 3130 | if (vp_idx == 0) |
| 3131 | return QLA_FUNCTION_FAILED; |
| 3132 | |
| 3133 | mcp->mb[0] = MBC_SEND_CHANGE_REQUEST; |
| 3134 | mcp->mb[1] = format; |
| 3135 | mcp->mb[9] = vp_idx; |
| 3136 | mcp->out_mb = MBX_9|MBX_1|MBX_0; |
| 3137 | mcp->in_mb = MBX_0|MBX_1; |
| 3138 | mcp->tov = MBX_TOV_SECONDS; |
| 3139 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3140 | rval = qla2x00_mailbox_command(vha, mcp); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3141 | |
| 3142 | if (rval == QLA_SUCCESS) { |
| 3143 | if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { |
| 3144 | rval = BIT_1; |
| 3145 | } |
| 3146 | } else |
| 3147 | rval = BIT_1; |
| 3148 | |
| 3149 | return rval; |
| 3150 | } |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 3151 | |
| 3152 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3153 | 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] | 3154 | uint32_t size) |
| 3155 | { |
| 3156 | int rval; |
| 3157 | mbx_cmd_t mc; |
| 3158 | mbx_cmd_t *mcp = &mc; |
| 3159 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3160 | ql_dbg(ql_dbg_mbx, vha, 0x1009, "Entered %s.\n", __func__); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 3161 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3162 | if (MSW(addr) || IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 3163 | mcp->mb[0] = MBC_DUMP_RISC_RAM_EXTENDED; |
| 3164 | mcp->mb[8] = MSW(addr); |
| 3165 | mcp->out_mb = MBX_8|MBX_0; |
| 3166 | } else { |
| 3167 | mcp->mb[0] = MBC_DUMP_RISC_RAM; |
| 3168 | mcp->out_mb = MBX_0; |
| 3169 | } |
| 3170 | mcp->mb[1] = LSW(addr); |
| 3171 | mcp->mb[2] = MSW(req_dma); |
| 3172 | mcp->mb[3] = LSW(req_dma); |
| 3173 | mcp->mb[6] = MSW(MSD(req_dma)); |
| 3174 | mcp->mb[7] = LSW(MSD(req_dma)); |
| 3175 | 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] | 3176 | if (IS_FWI2_CAPABLE(vha->hw)) { |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 3177 | mcp->mb[4] = MSW(size); |
| 3178 | mcp->mb[5] = LSW(size); |
| 3179 | mcp->out_mb |= MBX_5|MBX_4; |
| 3180 | } else { |
| 3181 | mcp->mb[4] = LSW(size); |
| 3182 | mcp->out_mb |= MBX_4; |
| 3183 | } |
| 3184 | |
| 3185 | mcp->in_mb = MBX_0; |
Ravi Anand | b93480e | 2008-04-03 13:13:25 -0700 | [diff] [blame] | 3186 | mcp->tov = MBX_TOV_SECONDS; |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 3187 | mcp->flags = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3188 | rval = qla2x00_mailbox_command(vha, mcp); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 3189 | |
| 3190 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3191 | ql_dbg(ql_dbg_mbx, vha, 0x1008, |
| 3192 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 3193 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3194 | ql_dbg(ql_dbg_mbx, vha, 0x1007, "Done %s.\n", __func__); |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 3195 | } |
| 3196 | |
| 3197 | return rval; |
| 3198 | } |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3199 | |
| 3200 | /* 84XX Support **************************************************************/ |
| 3201 | |
| 3202 | struct cs84xx_mgmt_cmd { |
| 3203 | union { |
| 3204 | struct verify_chip_entry_84xx req; |
| 3205 | struct verify_chip_rsp_84xx rsp; |
| 3206 | } p; |
| 3207 | }; |
| 3208 | |
| 3209 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3210 | qla84xx_verify_chip(struct scsi_qla_host *vha, uint16_t *status) |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3211 | { |
| 3212 | int rval, retry; |
| 3213 | struct cs84xx_mgmt_cmd *mn; |
| 3214 | dma_addr_t mn_dma; |
| 3215 | uint16_t options; |
| 3216 | unsigned long flags; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3217 | struct qla_hw_data *ha = vha->hw; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3218 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3219 | ql_dbg(ql_dbg_mbx, vha, 0x10c8, "Entered %s.\n", __func__); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3220 | |
| 3221 | mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma); |
| 3222 | if (mn == NULL) { |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3223 | return QLA_MEMORY_ALLOC_FAILED; |
| 3224 | } |
| 3225 | |
| 3226 | /* Force Update? */ |
| 3227 | options = ha->cs84xx->fw_update ? VCO_FORCE_UPDATE : 0; |
| 3228 | /* Diagnostic firmware? */ |
| 3229 | /* options |= MENLO_DIAG_FW; */ |
| 3230 | /* We update the firmware with only one data sequence. */ |
| 3231 | options |= VCO_END_OF_DATA; |
| 3232 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3233 | do { |
Andrew Vasquez | c1ec1f1 | 2008-04-24 15:21:24 -0700 | [diff] [blame] | 3234 | retry = 0; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3235 | memset(mn, 0, sizeof(*mn)); |
| 3236 | mn->p.req.entry_type = VERIFY_CHIP_IOCB_TYPE; |
| 3237 | mn->p.req.entry_count = 1; |
| 3238 | mn->p.req.options = cpu_to_le16(options); |
| 3239 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3240 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111c, |
| 3241 | "Dump of Verify Request.\n"); |
| 3242 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111e, |
| 3243 | (uint8_t *)mn, sizeof(*mn)); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3244 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 3245 | rval = qla2x00_issue_iocb_timeout(vha, mn, mn_dma, 0, 120); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3246 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3247 | ql_dbg(ql_dbg_mbx, vha, 0x10cb, |
| 3248 | "Failed to issue verify IOCB (%x).\n", rval); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3249 | goto verify_done; |
| 3250 | } |
| 3251 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3252 | ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1110, |
| 3253 | "Dump of Verify Response.\n"); |
| 3254 | ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1118, |
| 3255 | (uint8_t *)mn, sizeof(*mn)); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3256 | |
| 3257 | status[0] = le16_to_cpu(mn->p.rsp.comp_status); |
| 3258 | status[1] = status[0] == CS_VCS_CHIP_FAILURE ? |
| 3259 | le16_to_cpu(mn->p.rsp.failure_code) : 0; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3260 | ql_dbg(ql_dbg_mbx, vha, 0x10ce, |
| 3261 | "cs=%x fc=%x.\n", status[0], status[1]); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3262 | |
| 3263 | if (status[0] != CS_COMPLETE) { |
| 3264 | rval = QLA_FUNCTION_FAILED; |
| 3265 | if (!(options & VCO_DONT_UPDATE_FW)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3266 | ql_dbg(ql_dbg_mbx, vha, 0x10cf, |
| 3267 | "Firmware update failed. Retrying " |
| 3268 | "without update firmware.\n"); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3269 | options |= VCO_DONT_UPDATE_FW; |
| 3270 | options &= ~VCO_FORCE_UPDATE; |
| 3271 | retry = 1; |
| 3272 | } |
| 3273 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3274 | ql_dbg(ql_dbg_mbx, vha, 0x10d0, |
| 3275 | "Firmware updated to %x.\n", |
| 3276 | le32_to_cpu(mn->p.rsp.fw_ver)); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3277 | |
| 3278 | /* NOTE: we only update OP firmware. */ |
| 3279 | spin_lock_irqsave(&ha->cs84xx->access_lock, flags); |
| 3280 | ha->cs84xx->op_fw_version = |
| 3281 | le32_to_cpu(mn->p.rsp.fw_ver); |
| 3282 | spin_unlock_irqrestore(&ha->cs84xx->access_lock, |
| 3283 | flags); |
| 3284 | } |
| 3285 | } while (retry); |
| 3286 | |
| 3287 | verify_done: |
| 3288 | dma_pool_free(ha->s_dma_pool, mn, mn_dma); |
| 3289 | |
| 3290 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3291 | ql_dbg(ql_dbg_mbx, vha, 0x10d1, "Failed=%x.\n", rval); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3292 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3293 | ql_dbg(ql_dbg_mbx, vha, 0x10d2, "Done %s.\n", __func__); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3294 | } |
| 3295 | |
| 3296 | return rval; |
| 3297 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3298 | |
| 3299 | int |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 3300 | 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] | 3301 | { |
| 3302 | int rval; |
| 3303 | unsigned long flags; |
| 3304 | mbx_cmd_t mc; |
| 3305 | mbx_cmd_t *mcp = &mc; |
| 3306 | struct device_reg_25xxmq __iomem *reg; |
| 3307 | struct qla_hw_data *ha = vha->hw; |
| 3308 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3309 | ql_dbg(ql_dbg_mbx, vha, 0x10d3, "Entered %s.\n", __func__); |
| 3310 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3311 | mcp->mb[0] = MBC_INITIALIZE_MULTIQ; |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 3312 | mcp->mb[1] = req->options; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3313 | mcp->mb[2] = MSW(LSD(req->dma)); |
| 3314 | mcp->mb[3] = LSW(LSD(req->dma)); |
| 3315 | mcp->mb[6] = MSW(MSD(req->dma)); |
| 3316 | mcp->mb[7] = LSW(MSD(req->dma)); |
| 3317 | mcp->mb[5] = req->length; |
| 3318 | if (req->rsp) |
| 3319 | mcp->mb[10] = req->rsp->id; |
| 3320 | mcp->mb[12] = req->qos; |
| 3321 | mcp->mb[11] = req->vp_idx; |
| 3322 | mcp->mb[13] = req->rid; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3323 | if (IS_QLA83XX(ha)) |
| 3324 | mcp->mb[15] = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3325 | |
| 3326 | reg = (struct device_reg_25xxmq *)((void *)(ha->mqiobase) + |
| 3327 | QLA_QUE_PAGE * req->id); |
| 3328 | |
| 3329 | mcp->mb[4] = req->id; |
| 3330 | /* que in ptr index */ |
| 3331 | mcp->mb[8] = 0; |
| 3332 | /* que out ptr index */ |
| 3333 | mcp->mb[9] = 0; |
| 3334 | mcp->out_mb = MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8|MBX_7| |
| 3335 | MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3336 | mcp->in_mb = MBX_0; |
| 3337 | mcp->flags = MBX_DMA_OUT; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3338 | mcp->tov = MBX_TOV_SECONDS * 2; |
| 3339 | |
| 3340 | if (IS_QLA81XX(ha) || IS_QLA83XX(ha)) |
| 3341 | mcp->in_mb |= MBX_1; |
| 3342 | if (IS_QLA83XX(ha)) { |
| 3343 | mcp->out_mb |= MBX_15; |
| 3344 | /* debug q create issue in SR-IOV */ |
| 3345 | mcp->in_mb |= MBX_9 | MBX_8 | MBX_7; |
| 3346 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3347 | |
| 3348 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 3349 | if (!(req->options & BIT_0)) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3350 | WRT_REG_DWORD(®->req_q_in, 0); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3351 | if (!IS_QLA83XX(ha)) |
| 3352 | WRT_REG_DWORD(®->req_q_out, 0); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3353 | } |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3354 | req->req_q_in = ®->req_q_in; |
| 3355 | req->req_q_out = ®->req_q_out; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3356 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 3357 | |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 3358 | rval = qla2x00_mailbox_command(vha, mcp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3359 | if (rval != QLA_SUCCESS) { |
| 3360 | ql_dbg(ql_dbg_mbx, vha, 0x10d4, |
| 3361 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 3362 | } else { |
| 3363 | ql_dbg(ql_dbg_mbx, vha, 0x10d5, "Done %s.\n", __func__); |
| 3364 | } |
| 3365 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3366 | return rval; |
| 3367 | } |
| 3368 | |
| 3369 | int |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 3370 | 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] | 3371 | { |
| 3372 | int rval; |
| 3373 | unsigned long flags; |
| 3374 | mbx_cmd_t mc; |
| 3375 | mbx_cmd_t *mcp = &mc; |
| 3376 | struct device_reg_25xxmq __iomem *reg; |
| 3377 | struct qla_hw_data *ha = vha->hw; |
| 3378 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3379 | ql_dbg(ql_dbg_mbx, vha, 0x10d6, "Entered %s.\n", __func__); |
| 3380 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3381 | mcp->mb[0] = MBC_INITIALIZE_MULTIQ; |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 3382 | mcp->mb[1] = rsp->options; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3383 | mcp->mb[2] = MSW(LSD(rsp->dma)); |
| 3384 | mcp->mb[3] = LSW(LSD(rsp->dma)); |
| 3385 | mcp->mb[6] = MSW(MSD(rsp->dma)); |
| 3386 | mcp->mb[7] = LSW(MSD(rsp->dma)); |
| 3387 | mcp->mb[5] = rsp->length; |
Andrew Vasquez | 444786d | 2009-01-05 11:18:10 -0800 | [diff] [blame] | 3388 | mcp->mb[14] = rsp->msix->entry; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3389 | mcp->mb[13] = rsp->rid; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3390 | if (IS_QLA83XX(ha)) |
| 3391 | mcp->mb[15] = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3392 | |
| 3393 | reg = (struct device_reg_25xxmq *)((void *)(ha->mqiobase) + |
| 3394 | QLA_QUE_PAGE * rsp->id); |
| 3395 | |
| 3396 | mcp->mb[4] = rsp->id; |
| 3397 | /* que in ptr index */ |
| 3398 | mcp->mb[8] = 0; |
| 3399 | /* que out ptr index */ |
| 3400 | mcp->mb[9] = 0; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3401 | 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] | 3402 | |MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3403 | mcp->in_mb = MBX_0; |
| 3404 | mcp->flags = MBX_DMA_OUT; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3405 | mcp->tov = MBX_TOV_SECONDS * 2; |
| 3406 | |
| 3407 | if (IS_QLA81XX(ha)) { |
| 3408 | mcp->out_mb |= MBX_12|MBX_11|MBX_10; |
| 3409 | mcp->in_mb |= MBX_1; |
| 3410 | } else if (IS_QLA83XX(ha)) { |
| 3411 | mcp->out_mb |= MBX_15|MBX_12|MBX_11|MBX_10; |
| 3412 | mcp->in_mb |= MBX_1; |
| 3413 | /* debug q create issue in SR-IOV */ |
| 3414 | mcp->in_mb |= MBX_9 | MBX_8 | MBX_7; |
| 3415 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3416 | |
| 3417 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 3418 | if (!(rsp->options & BIT_0)) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3419 | WRT_REG_DWORD(®->rsp_q_out, 0); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3420 | if (!IS_QLA83XX(ha)) |
| 3421 | WRT_REG_DWORD(®->rsp_q_in, 0); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3422 | } |
| 3423 | |
| 3424 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 3425 | |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 3426 | rval = qla2x00_mailbox_command(vha, mcp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3427 | if (rval != QLA_SUCCESS) { |
| 3428 | ql_dbg(ql_dbg_mbx, vha, 0x10d7, |
| 3429 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 3430 | } else { |
| 3431 | ql_dbg(ql_dbg_mbx, vha, 0x10d8, "Done %s.\n", __func__); |
| 3432 | } |
| 3433 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3434 | return rval; |
| 3435 | } |
| 3436 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3437 | int |
| 3438 | qla81xx_idc_ack(scsi_qla_host_t *vha, uint16_t *mb) |
| 3439 | { |
| 3440 | int rval; |
| 3441 | mbx_cmd_t mc; |
| 3442 | mbx_cmd_t *mcp = &mc; |
| 3443 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3444 | ql_dbg(ql_dbg_mbx, vha, 0x10d9, "Entered %s.\n", __func__); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3445 | |
| 3446 | mcp->mb[0] = MBC_IDC_ACK; |
| 3447 | memcpy(&mcp->mb[1], mb, QLA_IDC_ACK_REGS * sizeof(uint16_t)); |
| 3448 | mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3449 | mcp->in_mb = MBX_0; |
| 3450 | mcp->tov = MBX_TOV_SECONDS; |
| 3451 | mcp->flags = 0; |
| 3452 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3453 | |
| 3454 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3455 | ql_dbg(ql_dbg_mbx, vha, 0x10da, |
| 3456 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3457 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3458 | ql_dbg(ql_dbg_mbx, vha, 0x10db, "Done %s.\n", __func__); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3459 | } |
| 3460 | |
| 3461 | return rval; |
| 3462 | } |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3463 | |
| 3464 | int |
| 3465 | qla81xx_fac_get_sector_size(scsi_qla_host_t *vha, uint32_t *sector_size) |
| 3466 | { |
| 3467 | int rval; |
| 3468 | mbx_cmd_t mc; |
| 3469 | mbx_cmd_t *mcp = &mc; |
| 3470 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3471 | ql_dbg(ql_dbg_mbx, vha, 0x10dc, "Entered %s.\n", __func__); |
| 3472 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3473 | if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw)) |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3474 | return QLA_FUNCTION_FAILED; |
| 3475 | |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3476 | mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; |
| 3477 | mcp->mb[1] = FAC_OPT_CMD_GET_SECTOR_SIZE; |
| 3478 | mcp->out_mb = MBX_1|MBX_0; |
| 3479 | mcp->in_mb = MBX_1|MBX_0; |
| 3480 | mcp->tov = MBX_TOV_SECONDS; |
| 3481 | mcp->flags = 0; |
| 3482 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3483 | |
| 3484 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3485 | ql_dbg(ql_dbg_mbx, vha, 0x10dd, |
| 3486 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3487 | rval, mcp->mb[0], mcp->mb[1]); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3488 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3489 | ql_dbg(ql_dbg_mbx, vha, 0x10de, "Done %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3490 | *sector_size = mcp->mb[1]; |
| 3491 | } |
| 3492 | |
| 3493 | return rval; |
| 3494 | } |
| 3495 | |
| 3496 | int |
| 3497 | qla81xx_fac_do_write_enable(scsi_qla_host_t *vha, int enable) |
| 3498 | { |
| 3499 | int rval; |
| 3500 | mbx_cmd_t mc; |
| 3501 | mbx_cmd_t *mcp = &mc; |
| 3502 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3503 | if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw)) |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3504 | return QLA_FUNCTION_FAILED; |
| 3505 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3506 | ql_dbg(ql_dbg_mbx, vha, 0x10df, "Entered %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3507 | |
| 3508 | mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; |
| 3509 | mcp->mb[1] = enable ? FAC_OPT_CMD_WRITE_ENABLE : |
| 3510 | FAC_OPT_CMD_WRITE_PROTECT; |
| 3511 | mcp->out_mb = MBX_1|MBX_0; |
| 3512 | mcp->in_mb = MBX_1|MBX_0; |
| 3513 | mcp->tov = MBX_TOV_SECONDS; |
| 3514 | mcp->flags = 0; |
| 3515 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3516 | |
| 3517 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3518 | ql_dbg(ql_dbg_mbx, vha, 0x10e0, |
| 3519 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3520 | rval, mcp->mb[0], mcp->mb[1]); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3521 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3522 | ql_dbg(ql_dbg_mbx, vha, 0x10e1, "Done %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3523 | } |
| 3524 | |
| 3525 | return rval; |
| 3526 | } |
| 3527 | |
| 3528 | int |
| 3529 | qla81xx_fac_erase_sector(scsi_qla_host_t *vha, uint32_t start, uint32_t finish) |
| 3530 | { |
| 3531 | int rval; |
| 3532 | mbx_cmd_t mc; |
| 3533 | mbx_cmd_t *mcp = &mc; |
| 3534 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3535 | if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw)) |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3536 | return QLA_FUNCTION_FAILED; |
| 3537 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3538 | ql_dbg(ql_dbg_mbx, vha, 0x10e2, "Entered %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3539 | |
| 3540 | mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; |
| 3541 | mcp->mb[1] = FAC_OPT_CMD_ERASE_SECTOR; |
| 3542 | mcp->mb[2] = LSW(start); |
| 3543 | mcp->mb[3] = MSW(start); |
| 3544 | mcp->mb[4] = LSW(finish); |
| 3545 | mcp->mb[5] = MSW(finish); |
| 3546 | mcp->out_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3547 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 3548 | mcp->tov = MBX_TOV_SECONDS; |
| 3549 | mcp->flags = 0; |
| 3550 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3551 | |
| 3552 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3553 | ql_dbg(ql_dbg_mbx, vha, 0x10e3, |
| 3554 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 3555 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3556 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3557 | ql_dbg(ql_dbg_mbx, vha, 0x10e4, "Done %s.\n", __func__); |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 3558 | } |
| 3559 | |
| 3560 | return rval; |
| 3561 | } |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 3562 | |
| 3563 | int |
| 3564 | qla81xx_restart_mpi_firmware(scsi_qla_host_t *vha) |
| 3565 | { |
| 3566 | int rval = 0; |
| 3567 | mbx_cmd_t mc; |
| 3568 | mbx_cmd_t *mcp = &mc; |
| 3569 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3570 | ql_dbg(ql_dbg_mbx, vha, 0x10e5, "Entered %s.\n", __func__); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 3571 | |
| 3572 | mcp->mb[0] = MBC_RESTART_MPI_FW; |
| 3573 | mcp->out_mb = MBX_0; |
| 3574 | mcp->in_mb = MBX_0|MBX_1; |
| 3575 | mcp->tov = MBX_TOV_SECONDS; |
| 3576 | mcp->flags = 0; |
| 3577 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3578 | |
| 3579 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3580 | ql_dbg(ql_dbg_mbx, vha, 0x10e6, |
| 3581 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3582 | rval, mcp->mb[0], mcp->mb[1]); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 3583 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3584 | ql_dbg(ql_dbg_mbx, vha, 0x10e7, "Done %s.\n", __func__); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 3585 | } |
| 3586 | |
| 3587 | return rval; |
| 3588 | } |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 3589 | |
| 3590 | int |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 3591 | qla2x00_read_sfp(scsi_qla_host_t *vha, dma_addr_t sfp_dma, uint8_t *sfp, |
| 3592 | uint16_t dev, uint16_t off, uint16_t len, uint16_t opt) |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 3593 | { |
| 3594 | int rval; |
| 3595 | mbx_cmd_t mc; |
| 3596 | mbx_cmd_t *mcp = &mc; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 3597 | struct qla_hw_data *ha = vha->hw; |
| 3598 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3599 | ql_dbg(ql_dbg_mbx, vha, 0x10e8, "Entered %s.\n", __func__); |
| 3600 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 3601 | if (!IS_FWI2_CAPABLE(ha)) |
| 3602 | return QLA_FUNCTION_FAILED; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 3603 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 3604 | if (len == 1) |
| 3605 | opt |= BIT_0; |
| 3606 | |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 3607 | mcp->mb[0] = MBC_READ_SFP; |
| 3608 | mcp->mb[1] = dev; |
| 3609 | mcp->mb[2] = MSW(sfp_dma); |
| 3610 | mcp->mb[3] = LSW(sfp_dma); |
| 3611 | mcp->mb[6] = MSW(MSD(sfp_dma)); |
| 3612 | mcp->mb[7] = LSW(MSD(sfp_dma)); |
| 3613 | mcp->mb[8] = len; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 3614 | mcp->mb[9] = off; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 3615 | mcp->mb[10] = opt; |
| 3616 | 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] | 3617 | mcp->in_mb = MBX_1|MBX_0; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 3618 | mcp->tov = MBX_TOV_SECONDS; |
| 3619 | mcp->flags = 0; |
| 3620 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3621 | |
| 3622 | if (opt & BIT_0) |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 3623 | *sfp = mcp->mb[1]; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 3624 | |
| 3625 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3626 | ql_dbg(ql_dbg_mbx, vha, 0x10e9, |
| 3627 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 3628 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3629 | ql_dbg(ql_dbg_mbx, vha, 0x10ea, "Done %s.\n", __func__); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 3630 | } |
| 3631 | |
| 3632 | return rval; |
| 3633 | } |
| 3634 | |
| 3635 | int |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 3636 | qla2x00_write_sfp(scsi_qla_host_t *vha, dma_addr_t sfp_dma, uint8_t *sfp, |
| 3637 | uint16_t dev, uint16_t off, uint16_t len, uint16_t opt) |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 3638 | { |
| 3639 | int rval; |
| 3640 | mbx_cmd_t mc; |
| 3641 | mbx_cmd_t *mcp = &mc; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 3642 | struct qla_hw_data *ha = vha->hw; |
| 3643 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3644 | ql_dbg(ql_dbg_mbx, vha, 0x10eb, "Entered %s.\n", __func__); |
| 3645 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 3646 | if (!IS_FWI2_CAPABLE(ha)) |
| 3647 | return QLA_FUNCTION_FAILED; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 3648 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 3649 | if (len == 1) |
| 3650 | opt |= BIT_0; |
| 3651 | |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 3652 | if (opt & BIT_0) |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 3653 | len = *sfp; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 3654 | |
| 3655 | mcp->mb[0] = MBC_WRITE_SFP; |
| 3656 | mcp->mb[1] = dev; |
| 3657 | mcp->mb[2] = MSW(sfp_dma); |
| 3658 | mcp->mb[3] = LSW(sfp_dma); |
| 3659 | mcp->mb[6] = MSW(MSD(sfp_dma)); |
| 3660 | mcp->mb[7] = LSW(MSD(sfp_dma)); |
| 3661 | mcp->mb[8] = len; |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 3662 | mcp->mb[9] = off; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 3663 | mcp->mb[10] = opt; |
| 3664 | 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] | 3665 | mcp->in_mb = MBX_1|MBX_0; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 3666 | mcp->tov = MBX_TOV_SECONDS; |
| 3667 | mcp->flags = 0; |
| 3668 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3669 | |
| 3670 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3671 | ql_dbg(ql_dbg_mbx, vha, 0x10ec, |
| 3672 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 3673 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3674 | ql_dbg(ql_dbg_mbx, vha, 0x10ed, "Done %s.\n", __func__); |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 3675 | } |
| 3676 | |
| 3677 | return rval; |
| 3678 | } |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 3679 | |
| 3680 | int |
| 3681 | qla2x00_get_xgmac_stats(scsi_qla_host_t *vha, dma_addr_t stats_dma, |
| 3682 | uint16_t size_in_bytes, uint16_t *actual_size) |
| 3683 | { |
| 3684 | int rval; |
| 3685 | mbx_cmd_t mc; |
| 3686 | mbx_cmd_t *mcp = &mc; |
| 3687 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3688 | ql_dbg(ql_dbg_mbx, vha, 0x10ee, "Entered %s.\n", __func__); |
| 3689 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3690 | if (!IS_CNA_CAPABLE(vha->hw)) |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 3691 | return QLA_FUNCTION_FAILED; |
| 3692 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 3693 | mcp->mb[0] = MBC_GET_XGMAC_STATS; |
| 3694 | mcp->mb[2] = MSW(stats_dma); |
| 3695 | mcp->mb[3] = LSW(stats_dma); |
| 3696 | mcp->mb[6] = MSW(MSD(stats_dma)); |
| 3697 | mcp->mb[7] = LSW(MSD(stats_dma)); |
| 3698 | mcp->mb[8] = size_in_bytes >> 2; |
| 3699 | mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; |
| 3700 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 3701 | mcp->tov = MBX_TOV_SECONDS; |
| 3702 | mcp->flags = 0; |
| 3703 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3704 | |
| 3705 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3706 | ql_dbg(ql_dbg_mbx, vha, 0x10ef, |
| 3707 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 3708 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 3709 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3710 | ql_dbg(ql_dbg_mbx, vha, 0x10f0, "Done %s.\n", __func__); |
| 3711 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 3712 | |
| 3713 | *actual_size = mcp->mb[2] << 2; |
| 3714 | } |
| 3715 | |
| 3716 | return rval; |
| 3717 | } |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 3718 | |
| 3719 | int |
| 3720 | qla2x00_get_dcbx_params(scsi_qla_host_t *vha, dma_addr_t tlv_dma, |
| 3721 | uint16_t size) |
| 3722 | { |
| 3723 | int rval; |
| 3724 | mbx_cmd_t mc; |
| 3725 | mbx_cmd_t *mcp = &mc; |
| 3726 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3727 | ql_dbg(ql_dbg_mbx, vha, 0x10f1, "Entered %s.\n", __func__); |
| 3728 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3729 | if (!IS_CNA_CAPABLE(vha->hw)) |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 3730 | return QLA_FUNCTION_FAILED; |
| 3731 | |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 3732 | mcp->mb[0] = MBC_GET_DCBX_PARAMS; |
| 3733 | mcp->mb[1] = 0; |
| 3734 | mcp->mb[2] = MSW(tlv_dma); |
| 3735 | mcp->mb[3] = LSW(tlv_dma); |
| 3736 | mcp->mb[6] = MSW(MSD(tlv_dma)); |
| 3737 | mcp->mb[7] = LSW(MSD(tlv_dma)); |
| 3738 | mcp->mb[8] = size; |
| 3739 | mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3740 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 3741 | mcp->tov = MBX_TOV_SECONDS; |
| 3742 | mcp->flags = 0; |
| 3743 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3744 | |
| 3745 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3746 | ql_dbg(ql_dbg_mbx, vha, 0x10f2, |
| 3747 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n", |
| 3748 | rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]); |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 3749 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3750 | ql_dbg(ql_dbg_mbx, vha, 0x10f3, "Done %s.\n", __func__); |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 3751 | } |
| 3752 | |
| 3753 | return rval; |
| 3754 | } |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 3755 | |
| 3756 | int |
| 3757 | qla2x00_read_ram_word(scsi_qla_host_t *vha, uint32_t risc_addr, uint32_t *data) |
| 3758 | { |
| 3759 | int rval; |
| 3760 | mbx_cmd_t mc; |
| 3761 | mbx_cmd_t *mcp = &mc; |
| 3762 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3763 | ql_dbg(ql_dbg_mbx, vha, 0x10f4, "Entered %s.\n", __func__); |
| 3764 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 3765 | if (!IS_FWI2_CAPABLE(vha->hw)) |
| 3766 | return QLA_FUNCTION_FAILED; |
| 3767 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 3768 | mcp->mb[0] = MBC_READ_RAM_EXTENDED; |
| 3769 | mcp->mb[1] = LSW(risc_addr); |
| 3770 | mcp->mb[8] = MSW(risc_addr); |
| 3771 | mcp->out_mb = MBX_8|MBX_1|MBX_0; |
| 3772 | mcp->in_mb = MBX_3|MBX_2|MBX_0; |
| 3773 | mcp->tov = 30; |
| 3774 | mcp->flags = 0; |
| 3775 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3776 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3777 | ql_dbg(ql_dbg_mbx, vha, 0x10f5, |
| 3778 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 3779 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3780 | ql_dbg(ql_dbg_mbx, vha, 0x10f6, "Done %s.\n", __func__); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 3781 | *data = mcp->mb[3] << 16 | mcp->mb[2]; |
| 3782 | } |
| 3783 | |
| 3784 | return rval; |
| 3785 | } |
| 3786 | |
| 3787 | int |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3788 | qla2x00_loopback_test(scsi_qla_host_t *vha, struct msg_echo_lb *mreq, |
| 3789 | uint16_t *mresp) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3790 | { |
| 3791 | int rval; |
| 3792 | mbx_cmd_t mc; |
| 3793 | mbx_cmd_t *mcp = &mc; |
| 3794 | uint32_t iter_cnt = 0x1; |
| 3795 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3796 | ql_dbg(ql_dbg_mbx, vha, 0x10f7, "Entered %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3797 | |
| 3798 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 3799 | mcp->mb[0] = MBC_DIAGNOSTIC_LOOP_BACK; |
| 3800 | mcp->mb[1] = mreq->options | BIT_6; // BIT_6 specifies 64 bit addressing |
| 3801 | |
| 3802 | /* transfer count */ |
| 3803 | mcp->mb[10] = LSW(mreq->transfer_size); |
| 3804 | mcp->mb[11] = MSW(mreq->transfer_size); |
| 3805 | |
| 3806 | /* send data address */ |
| 3807 | mcp->mb[14] = LSW(mreq->send_dma); |
| 3808 | mcp->mb[15] = MSW(mreq->send_dma); |
| 3809 | mcp->mb[20] = LSW(MSD(mreq->send_dma)); |
| 3810 | mcp->mb[21] = MSW(MSD(mreq->send_dma)); |
| 3811 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 3812 | /* receive data address */ |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3813 | mcp->mb[16] = LSW(mreq->rcv_dma); |
| 3814 | mcp->mb[17] = MSW(mreq->rcv_dma); |
| 3815 | mcp->mb[6] = LSW(MSD(mreq->rcv_dma)); |
| 3816 | mcp->mb[7] = MSW(MSD(mreq->rcv_dma)); |
| 3817 | |
| 3818 | /* Iteration count */ |
| 3819 | mcp->mb[18] = LSW(iter_cnt); |
| 3820 | mcp->mb[19] = MSW(iter_cnt); |
| 3821 | |
| 3822 | mcp->out_mb = MBX_21|MBX_20|MBX_19|MBX_18|MBX_17|MBX_16|MBX_15| |
| 3823 | 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] | 3824 | if (IS_CNA_CAPABLE(vha->hw)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3825 | mcp->out_mb |= MBX_2; |
| 3826 | mcp->in_mb = MBX_19|MBX_18|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3827 | |
| 3828 | mcp->buf_size = mreq->transfer_size; |
| 3829 | mcp->tov = MBX_TOV_SECONDS; |
| 3830 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 3831 | |
| 3832 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3833 | |
| 3834 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3835 | ql_dbg(ql_dbg_mbx, vha, 0x10f8, |
| 3836 | "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[3]=%x mb[18]=%x " |
| 3837 | "mb[19]=%x.\n", rval, mcp->mb[0], mcp->mb[1], mcp->mb[2], |
| 3838 | mcp->mb[3], mcp->mb[18], mcp->mb[19]); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3839 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3840 | ql_dbg(ql_dbg_mbx, vha, 0x10f9, "Done %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3841 | } |
| 3842 | |
| 3843 | /* Copy mailbox information */ |
| 3844 | memcpy( mresp, mcp->mb, 64); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3845 | return rval; |
| 3846 | } |
| 3847 | |
| 3848 | int |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3849 | qla2x00_echo_test(scsi_qla_host_t *vha, struct msg_echo_lb *mreq, |
| 3850 | uint16_t *mresp) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3851 | { |
| 3852 | int rval; |
| 3853 | mbx_cmd_t mc; |
| 3854 | mbx_cmd_t *mcp = &mc; |
| 3855 | struct qla_hw_data *ha = vha->hw; |
| 3856 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3857 | ql_dbg(ql_dbg_mbx, vha, 0x10fa, "Entered %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3858 | |
| 3859 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 3860 | mcp->mb[0] = MBC_DIAGNOSTIC_ECHO; |
| 3861 | mcp->mb[1] = mreq->options | BIT_6; /* BIT_6 specifies 64bit address */ |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3862 | if (IS_CNA_CAPABLE(ha)) { |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3863 | mcp->mb[1] |= BIT_15; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3864 | mcp->mb[2] = vha->fcoe_fcf_idx; |
| 3865 | } |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3866 | mcp->mb[16] = LSW(mreq->rcv_dma); |
| 3867 | mcp->mb[17] = MSW(mreq->rcv_dma); |
| 3868 | mcp->mb[6] = LSW(MSD(mreq->rcv_dma)); |
| 3869 | mcp->mb[7] = MSW(MSD(mreq->rcv_dma)); |
| 3870 | |
| 3871 | mcp->mb[10] = LSW(mreq->transfer_size); |
| 3872 | |
| 3873 | mcp->mb[14] = LSW(mreq->send_dma); |
| 3874 | mcp->mb[15] = MSW(mreq->send_dma); |
| 3875 | mcp->mb[20] = LSW(MSD(mreq->send_dma)); |
| 3876 | mcp->mb[21] = MSW(MSD(mreq->send_dma)); |
| 3877 | |
| 3878 | mcp->out_mb = MBX_21|MBX_20|MBX_17|MBX_16|MBX_15| |
| 3879 | MBX_14|MBX_10|MBX_7|MBX_6|MBX_1|MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3880 | if (IS_CNA_CAPABLE(ha)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3881 | mcp->out_mb |= MBX_2; |
| 3882 | |
| 3883 | mcp->in_mb = MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3884 | if (IS_QLA24XX_TYPE(ha) || IS_QLA25XX(ha) || |
| 3885 | IS_CNA_CAPABLE(ha) || IS_QLA2031(ha)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3886 | mcp->in_mb |= MBX_1; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3887 | if (IS_CNA_CAPABLE(ha) || IS_QLA2031(ha)) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3888 | mcp->in_mb |= MBX_3; |
| 3889 | |
| 3890 | mcp->tov = MBX_TOV_SECONDS; |
| 3891 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 3892 | mcp->buf_size = mreq->transfer_size; |
| 3893 | |
| 3894 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3895 | |
| 3896 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3897 | ql_dbg(ql_dbg_mbx, vha, 0x10fb, |
| 3898 | "Failed=%x mb[0]=%x mb[1]=%x.\n", |
| 3899 | rval, mcp->mb[0], mcp->mb[1]); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3900 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3901 | ql_dbg(ql_dbg_mbx, vha, 0x10fc, "Done %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3902 | } |
| 3903 | |
| 3904 | /* Copy mailbox information */ |
Giridhar Malavali | 6dbdda4 | 2010-09-03 15:20:49 -0700 | [diff] [blame] | 3905 | memcpy(mresp, mcp->mb, 64); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3906 | return rval; |
| 3907 | } |
Giridhar Malavali | 6dbdda4 | 2010-09-03 15:20:49 -0700 | [diff] [blame] | 3908 | |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3909 | int |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3910 | qla84xx_reset_chip(scsi_qla_host_t *vha, uint16_t enable_diagnostic) |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3911 | { |
| 3912 | int rval; |
| 3913 | mbx_cmd_t mc; |
| 3914 | mbx_cmd_t *mcp = &mc; |
| 3915 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3916 | ql_dbg(ql_dbg_mbx, vha, 0x10fd, |
| 3917 | "Entered %s enable_diag=%d.\n", __func__, enable_diagnostic); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3918 | |
| 3919 | mcp->mb[0] = MBC_ISP84XX_RESET; |
| 3920 | mcp->mb[1] = enable_diagnostic; |
| 3921 | mcp->out_mb = MBX_1|MBX_0; |
| 3922 | mcp->in_mb = MBX_1|MBX_0; |
| 3923 | mcp->tov = MBX_TOV_SECONDS; |
| 3924 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3925 | rval = qla2x00_mailbox_command(vha, mcp); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3926 | |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3927 | if (rval != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3928 | ql_dbg(ql_dbg_mbx, vha, 0x10fe, "Failed=%x.\n", rval); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3929 | else |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3930 | ql_dbg(ql_dbg_mbx, vha, 0x10ff, "Done %s.\n", __func__); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3931 | |
| 3932 | return rval; |
| 3933 | } |
| 3934 | |
| 3935 | int |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 3936 | qla2x00_write_ram_word(scsi_qla_host_t *vha, uint32_t risc_addr, uint32_t data) |
| 3937 | { |
| 3938 | int rval; |
| 3939 | mbx_cmd_t mc; |
| 3940 | mbx_cmd_t *mcp = &mc; |
| 3941 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3942 | ql_dbg(ql_dbg_mbx, vha, 0x1100, "Entered %s.\n", __func__); |
| 3943 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 3944 | if (!IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | 6c452a4 | 2010-03-19 17:04:02 -0700 | [diff] [blame] | 3945 | return QLA_FUNCTION_FAILED; |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 3946 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 3947 | mcp->mb[0] = MBC_WRITE_RAM_WORD_EXTENDED; |
| 3948 | mcp->mb[1] = LSW(risc_addr); |
| 3949 | mcp->mb[2] = LSW(data); |
| 3950 | mcp->mb[3] = MSW(data); |
| 3951 | mcp->mb[8] = MSW(risc_addr); |
| 3952 | mcp->out_mb = MBX_8|MBX_3|MBX_2|MBX_1|MBX_0; |
| 3953 | mcp->in_mb = MBX_0; |
| 3954 | mcp->tov = 30; |
| 3955 | mcp->flags = 0; |
| 3956 | rval = qla2x00_mailbox_command(vha, mcp); |
| 3957 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3958 | ql_dbg(ql_dbg_mbx, vha, 0x1101, |
| 3959 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 3960 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3961 | ql_dbg(ql_dbg_mbx, vha, 0x1102, "Done %s.\n", __func__); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 3962 | } |
| 3963 | |
| 3964 | return rval; |
| 3965 | } |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 3966 | |
| 3967 | int |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 3968 | qla81xx_write_mpi_register(scsi_qla_host_t *vha, uint16_t *mb) |
| 3969 | { |
| 3970 | int rval; |
| 3971 | uint32_t stat, timer; |
| 3972 | uint16_t mb0 = 0; |
| 3973 | struct qla_hw_data *ha = vha->hw; |
| 3974 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 3975 | |
| 3976 | rval = QLA_SUCCESS; |
| 3977 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3978 | ql_dbg(ql_dbg_mbx, vha, 0x1103, "Entered %s.\n", __func__); |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 3979 | |
| 3980 | clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
| 3981 | |
| 3982 | /* Write the MBC data to the registers */ |
| 3983 | WRT_REG_WORD(®->mailbox0, MBC_WRITE_MPI_REGISTER); |
| 3984 | WRT_REG_WORD(®->mailbox1, mb[0]); |
| 3985 | WRT_REG_WORD(®->mailbox2, mb[1]); |
| 3986 | WRT_REG_WORD(®->mailbox3, mb[2]); |
| 3987 | WRT_REG_WORD(®->mailbox4, mb[3]); |
| 3988 | |
| 3989 | WRT_REG_DWORD(®->hccr, HCCRX_SET_HOST_INT); |
| 3990 | |
| 3991 | /* Poll for MBC interrupt */ |
| 3992 | for (timer = 6000000; timer; timer--) { |
| 3993 | /* Check for pending interrupts. */ |
| 3994 | stat = RD_REG_DWORD(®->host_status); |
| 3995 | if (stat & HSRX_RISC_INT) { |
| 3996 | stat &= 0xff; |
| 3997 | |
| 3998 | if (stat == 0x1 || stat == 0x2 || |
| 3999 | stat == 0x10 || stat == 0x11) { |
| 4000 | set_bit(MBX_INTERRUPT, |
| 4001 | &ha->mbx_cmd_flags); |
| 4002 | mb0 = RD_REG_WORD(®->mailbox0); |
| 4003 | WRT_REG_DWORD(®->hccr, |
| 4004 | HCCRX_CLR_RISC_INT); |
| 4005 | RD_REG_DWORD(®->hccr); |
| 4006 | break; |
| 4007 | } |
| 4008 | } |
| 4009 | udelay(5); |
| 4010 | } |
| 4011 | |
| 4012 | if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) |
| 4013 | rval = mb0 & MBS_MASK; |
| 4014 | else |
| 4015 | rval = QLA_FUNCTION_FAILED; |
| 4016 | |
| 4017 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4018 | ql_dbg(ql_dbg_mbx, vha, 0x1104, |
| 4019 | "Failed=%x mb[0]=%x.\n", rval, mb[0]); |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 4020 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4021 | ql_dbg(ql_dbg_mbx, vha, 0x1105, "Done %s.\n", __func__); |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 4022 | } |
| 4023 | |
| 4024 | return rval; |
| 4025 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4026 | |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 4027 | int |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 4028 | qla2x00_get_data_rate(scsi_qla_host_t *vha) |
| 4029 | { |
| 4030 | int rval; |
| 4031 | mbx_cmd_t mc; |
| 4032 | mbx_cmd_t *mcp = &mc; |
| 4033 | struct qla_hw_data *ha = vha->hw; |
| 4034 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4035 | ql_dbg(ql_dbg_mbx, vha, 0x1106, "Entered %s.\n", __func__); |
| 4036 | |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 4037 | if (!IS_FWI2_CAPABLE(ha)) |
| 4038 | return QLA_FUNCTION_FAILED; |
| 4039 | |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 4040 | mcp->mb[0] = MBC_DATA_RATE; |
| 4041 | mcp->mb[1] = 0; |
| 4042 | mcp->out_mb = MBX_1|MBX_0; |
| 4043 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4044 | if (IS_QLA83XX(ha)) |
| 4045 | mcp->in_mb |= MBX_3; |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 4046 | mcp->tov = MBX_TOV_SECONDS; |
| 4047 | mcp->flags = 0; |
| 4048 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4049 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4050 | ql_dbg(ql_dbg_mbx, vha, 0x1107, |
| 4051 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 4052 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4053 | ql_dbg(ql_dbg_mbx, vha, 0x1108, "Done %s.\n", __func__); |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 4054 | if (mcp->mb[1] != 0x7) |
| 4055 | ha->link_data_rate = mcp->mb[1]; |
| 4056 | } |
| 4057 | |
| 4058 | return rval; |
| 4059 | } |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 4060 | |
| 4061 | int |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 4062 | qla81xx_get_port_config(scsi_qla_host_t *vha, uint16_t *mb) |
| 4063 | { |
| 4064 | int rval; |
| 4065 | mbx_cmd_t mc; |
| 4066 | mbx_cmd_t *mcp = &mc; |
| 4067 | struct qla_hw_data *ha = vha->hw; |
| 4068 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4069 | ql_dbg(ql_dbg_mbx, vha, 0x1109, "Entered %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 4070 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4071 | if (!IS_QLA81XX(ha) && !IS_QLA83XX(ha)) |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 4072 | return QLA_FUNCTION_FAILED; |
| 4073 | mcp->mb[0] = MBC_GET_PORT_CONFIG; |
| 4074 | mcp->out_mb = MBX_0; |
| 4075 | mcp->in_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4076 | mcp->tov = MBX_TOV_SECONDS; |
| 4077 | mcp->flags = 0; |
| 4078 | |
| 4079 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4080 | |
| 4081 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4082 | ql_dbg(ql_dbg_mbx, vha, 0x110a, |
| 4083 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 4084 | } else { |
| 4085 | /* Copy all bits to preserve original value */ |
| 4086 | memcpy(mb, &mcp->mb[1], sizeof(uint16_t) * 4); |
| 4087 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4088 | ql_dbg(ql_dbg_mbx, vha, 0x110b, "Done %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 4089 | } |
| 4090 | return rval; |
| 4091 | } |
| 4092 | |
| 4093 | int |
| 4094 | qla81xx_set_port_config(scsi_qla_host_t *vha, uint16_t *mb) |
| 4095 | { |
| 4096 | int rval; |
| 4097 | mbx_cmd_t mc; |
| 4098 | mbx_cmd_t *mcp = &mc; |
| 4099 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4100 | ql_dbg(ql_dbg_mbx, vha, 0x110c, "Entered %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 4101 | |
| 4102 | mcp->mb[0] = MBC_SET_PORT_CONFIG; |
| 4103 | /* Copy all bits to preserve original setting */ |
| 4104 | memcpy(&mcp->mb[1], mb, sizeof(uint16_t) * 4); |
| 4105 | mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4106 | mcp->in_mb = MBX_0; |
| 4107 | mcp->tov = MBX_TOV_SECONDS; |
| 4108 | mcp->flags = 0; |
| 4109 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4110 | |
| 4111 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4112 | ql_dbg(ql_dbg_mbx, vha, 0x110d, |
| 4113 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 4114 | } else |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4115 | ql_dbg(ql_dbg_mbx, vha, 0x110e, "Done %s.\n", __func__); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 4116 | |
| 4117 | return rval; |
| 4118 | } |
| 4119 | |
| 4120 | |
| 4121 | int |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 4122 | qla24xx_set_fcp_prio(scsi_qla_host_t *vha, uint16_t loop_id, uint16_t priority, |
| 4123 | uint16_t *mb) |
| 4124 | { |
| 4125 | int rval; |
| 4126 | mbx_cmd_t mc; |
| 4127 | mbx_cmd_t *mcp = &mc; |
| 4128 | struct qla_hw_data *ha = vha->hw; |
| 4129 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4130 | ql_dbg(ql_dbg_mbx, vha, 0x110f, "Entered %s.\n", __func__); |
| 4131 | |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 4132 | if (!IS_QLA24XX_TYPE(ha) && !IS_QLA25XX(ha)) |
| 4133 | return QLA_FUNCTION_FAILED; |
| 4134 | |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 4135 | mcp->mb[0] = MBC_PORT_PARAMS; |
| 4136 | mcp->mb[1] = loop_id; |
| 4137 | if (ha->flags.fcp_prio_enabled) |
| 4138 | mcp->mb[2] = BIT_1; |
| 4139 | else |
| 4140 | mcp->mb[2] = BIT_2; |
| 4141 | mcp->mb[4] = priority & 0xf; |
| 4142 | mcp->mb[9] = vha->vp_idx; |
| 4143 | mcp->out_mb = MBX_9|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4144 | mcp->in_mb = MBX_4|MBX_3|MBX_1|MBX_0; |
| 4145 | mcp->tov = 30; |
| 4146 | mcp->flags = 0; |
| 4147 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4148 | if (mb != NULL) { |
| 4149 | mb[0] = mcp->mb[0]; |
| 4150 | mb[1] = mcp->mb[1]; |
| 4151 | mb[3] = mcp->mb[3]; |
| 4152 | mb[4] = mcp->mb[4]; |
| 4153 | } |
| 4154 | |
| 4155 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4156 | ql_dbg(ql_dbg_mbx, vha, 0x10cd, "Failed=%x.\n", rval); |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 4157 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4158 | ql_dbg(ql_dbg_mbx, vha, 0x10cc, "Done %s.\n", __func__); |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 4159 | } |
| 4160 | |
| 4161 | return rval; |
| 4162 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4163 | |
| 4164 | int |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 4165 | qla2x00_get_thermal_temp(scsi_qla_host_t *vha, uint16_t *temp, uint16_t *frac) |
| 4166 | { |
| 4167 | int rval; |
Joe Carnuccio | 6ad11ea | 2011-05-10 11:30:16 -0700 | [diff] [blame] | 4168 | uint8_t byte; |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 4169 | struct qla_hw_data *ha = vha->hw; |
| 4170 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4171 | ql_dbg(ql_dbg_mbx, vha, 0x10ca, "Entered %s.\n", __func__); |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 4172 | |
Joe Carnuccio | 6ad11ea | 2011-05-10 11:30:16 -0700 | [diff] [blame] | 4173 | /* Integer part */ |
| 4174 | rval = qla2x00_read_sfp(vha, 0, &byte, 0x98, 0x01, 1, BIT_13|BIT_0); |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 4175 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4176 | ql_dbg(ql_dbg_mbx, vha, 0x10c9, "Failed=%x.\n", rval); |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 4177 | ha->flags.thermal_supported = 0; |
| 4178 | goto fail; |
| 4179 | } |
Joe Carnuccio | 6ad11ea | 2011-05-10 11:30:16 -0700 | [diff] [blame] | 4180 | *temp = byte; |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 4181 | |
Joe Carnuccio | 6ad11ea | 2011-05-10 11:30:16 -0700 | [diff] [blame] | 4182 | /* Fraction part */ |
| 4183 | rval = qla2x00_read_sfp(vha, 0, &byte, 0x98, 0x10, 1, BIT_13|BIT_0); |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 4184 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4185 | ql_dbg(ql_dbg_mbx, vha, 0x1019, "Failed=%x.\n", rval); |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 4186 | ha->flags.thermal_supported = 0; |
| 4187 | goto fail; |
| 4188 | } |
Joe Carnuccio | 6ad11ea | 2011-05-10 11:30:16 -0700 | [diff] [blame] | 4189 | *frac = (byte >> 6) * 25; |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 4190 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4191 | ql_dbg(ql_dbg_mbx, vha, 0x1018, "Done %s.\n", __func__); |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 4192 | fail: |
| 4193 | return rval; |
| 4194 | } |
| 4195 | |
| 4196 | int |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4197 | qla82xx_mbx_intr_enable(scsi_qla_host_t *vha) |
| 4198 | { |
| 4199 | int rval; |
| 4200 | struct qla_hw_data *ha = vha->hw; |
| 4201 | mbx_cmd_t mc; |
| 4202 | mbx_cmd_t *mcp = &mc; |
| 4203 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4204 | ql_dbg(ql_dbg_mbx, vha, 0x1017, "Entered %s.\n", __func__); |
| 4205 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4206 | if (!IS_FWI2_CAPABLE(ha)) |
| 4207 | return QLA_FUNCTION_FAILED; |
| 4208 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4209 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
Giridhar Malavali | 3711333 | 2010-07-23 15:28:34 +0500 | [diff] [blame] | 4210 | mcp->mb[0] = MBC_TOGGLE_INTERRUPT; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4211 | mcp->mb[1] = 1; |
| 4212 | |
| 4213 | mcp->out_mb = MBX_1|MBX_0; |
| 4214 | mcp->in_mb = MBX_0; |
| 4215 | mcp->tov = 30; |
| 4216 | mcp->flags = 0; |
| 4217 | |
| 4218 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4219 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4220 | ql_dbg(ql_dbg_mbx, vha, 0x1016, |
| 4221 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4222 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4223 | ql_dbg(ql_dbg_mbx, vha, 0x100e, "Done %s.\n", __func__); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4224 | } |
| 4225 | |
| 4226 | return rval; |
| 4227 | } |
| 4228 | |
| 4229 | int |
| 4230 | qla82xx_mbx_intr_disable(scsi_qla_host_t *vha) |
| 4231 | { |
| 4232 | int rval; |
| 4233 | struct qla_hw_data *ha = vha->hw; |
| 4234 | mbx_cmd_t mc; |
| 4235 | mbx_cmd_t *mcp = &mc; |
| 4236 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4237 | ql_dbg(ql_dbg_mbx, vha, 0x100d, "Entered %s.\n", __func__); |
| 4238 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4239 | if (!IS_QLA82XX(ha)) |
| 4240 | return QLA_FUNCTION_FAILED; |
| 4241 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4242 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
Giridhar Malavali | 3711333 | 2010-07-23 15:28:34 +0500 | [diff] [blame] | 4243 | mcp->mb[0] = MBC_TOGGLE_INTERRUPT; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4244 | mcp->mb[1] = 0; |
| 4245 | |
| 4246 | mcp->out_mb = MBX_1|MBX_0; |
| 4247 | mcp->in_mb = MBX_0; |
| 4248 | mcp->tov = 30; |
| 4249 | mcp->flags = 0; |
| 4250 | |
| 4251 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4252 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4253 | ql_dbg(ql_dbg_mbx, vha, 0x100c, |
| 4254 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4255 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4256 | ql_dbg(ql_dbg_mbx, vha, 0x100b, "Done %s.\n", __func__); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4257 | } |
| 4258 | |
| 4259 | return rval; |
| 4260 | } |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 4261 | |
| 4262 | int |
| 4263 | qla82xx_md_get_template_size(scsi_qla_host_t *vha) |
| 4264 | { |
| 4265 | struct qla_hw_data *ha = vha->hw; |
| 4266 | mbx_cmd_t mc; |
| 4267 | mbx_cmd_t *mcp = &mc; |
| 4268 | int rval = QLA_FUNCTION_FAILED; |
| 4269 | |
| 4270 | ql_dbg(ql_dbg_mbx, vha, 0x111f, "Entered %s.\n", __func__); |
| 4271 | |
| 4272 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 4273 | mcp->mb[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 4274 | mcp->mb[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 4275 | mcp->mb[2] = LSW(RQST_TMPLT_SIZE); |
| 4276 | mcp->mb[3] = MSW(RQST_TMPLT_SIZE); |
| 4277 | |
| 4278 | mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 4279 | mcp->in_mb = MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8| |
| 4280 | MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4281 | |
| 4282 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 4283 | mcp->tov = MBX_TOV_SECONDS; |
| 4284 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4285 | |
| 4286 | /* Always copy back return mailbox values. */ |
| 4287 | if (rval != QLA_SUCCESS) { |
| 4288 | ql_dbg(ql_dbg_mbx, vha, 0x1120, |
| 4289 | "mailbox command FAILED=0x%x, subcode=%x.\n", |
| 4290 | (mcp->mb[1] << 16) | mcp->mb[0], |
| 4291 | (mcp->mb[3] << 16) | mcp->mb[2]); |
| 4292 | } else { |
| 4293 | ql_dbg(ql_dbg_mbx, vha, 0x1121, "Done %s.\n", __func__); |
| 4294 | ha->md_template_size = ((mcp->mb[3] << 16) | mcp->mb[2]); |
| 4295 | if (!ha->md_template_size) { |
| 4296 | ql_dbg(ql_dbg_mbx, vha, 0x1122, |
| 4297 | "Null template size obtained.\n"); |
| 4298 | rval = QLA_FUNCTION_FAILED; |
| 4299 | } |
| 4300 | } |
| 4301 | return rval; |
| 4302 | } |
| 4303 | |
| 4304 | int |
| 4305 | qla82xx_md_get_template(scsi_qla_host_t *vha) |
| 4306 | { |
| 4307 | struct qla_hw_data *ha = vha->hw; |
| 4308 | mbx_cmd_t mc; |
| 4309 | mbx_cmd_t *mcp = &mc; |
| 4310 | int rval = QLA_FUNCTION_FAILED; |
| 4311 | |
| 4312 | ql_dbg(ql_dbg_mbx, vha, 0x1123, "Entered %s.\n", __func__); |
| 4313 | |
| 4314 | ha->md_tmplt_hdr = dma_alloc_coherent(&ha->pdev->dev, |
| 4315 | ha->md_template_size, &ha->md_tmplt_hdr_dma, GFP_KERNEL); |
| 4316 | if (!ha->md_tmplt_hdr) { |
| 4317 | ql_log(ql_log_warn, vha, 0x1124, |
| 4318 | "Unable to allocate memory for Minidump template.\n"); |
| 4319 | return rval; |
| 4320 | } |
| 4321 | |
| 4322 | memset(mcp->mb, 0 , sizeof(mcp->mb)); |
| 4323 | mcp->mb[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 4324 | mcp->mb[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE); |
| 4325 | mcp->mb[2] = LSW(RQST_TMPLT); |
| 4326 | mcp->mb[3] = MSW(RQST_TMPLT); |
| 4327 | mcp->mb[4] = LSW(LSD(ha->md_tmplt_hdr_dma)); |
| 4328 | mcp->mb[5] = MSW(LSD(ha->md_tmplt_hdr_dma)); |
| 4329 | mcp->mb[6] = LSW(MSD(ha->md_tmplt_hdr_dma)); |
| 4330 | mcp->mb[7] = MSW(MSD(ha->md_tmplt_hdr_dma)); |
| 4331 | mcp->mb[8] = LSW(ha->md_template_size); |
| 4332 | mcp->mb[9] = MSW(ha->md_template_size); |
| 4333 | |
| 4334 | mcp->flags = MBX_DMA_OUT|MBX_DMA_IN|IOCTL_CMD; |
| 4335 | mcp->tov = MBX_TOV_SECONDS; |
| 4336 | mcp->out_mb = MBX_11|MBX_10|MBX_9|MBX_8| |
| 4337 | MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4338 | mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; |
| 4339 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4340 | |
| 4341 | if (rval != QLA_SUCCESS) { |
| 4342 | ql_dbg(ql_dbg_mbx, vha, 0x1125, |
| 4343 | "mailbox command FAILED=0x%x, subcode=%x.\n", |
| 4344 | ((mcp->mb[1] << 16) | mcp->mb[0]), |
| 4345 | ((mcp->mb[3] << 16) | mcp->mb[2])); |
| 4346 | } else |
| 4347 | ql_dbg(ql_dbg_mbx, vha, 0x1126, "Done %s.\n", __func__); |
| 4348 | return rval; |
| 4349 | } |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 4350 | |
| 4351 | int |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4352 | qla81xx_set_led_config(scsi_qla_host_t *vha, uint16_t *led_cfg) |
| 4353 | { |
| 4354 | int rval; |
| 4355 | struct qla_hw_data *ha = vha->hw; |
| 4356 | mbx_cmd_t mc; |
| 4357 | mbx_cmd_t *mcp = &mc; |
| 4358 | |
| 4359 | if (!IS_QLA81XX(ha) && !IS_QLA8031(ha)) |
| 4360 | return QLA_FUNCTION_FAILED; |
| 4361 | |
| 4362 | ql_dbg(ql_dbg_mbx, vha, 0x1133, "Entered %s.\n", __func__); |
| 4363 | |
| 4364 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
| 4365 | mcp->mb[0] = MBC_SET_LED_CONFIG; |
| 4366 | mcp->mb[1] = led_cfg[0]; |
| 4367 | mcp->mb[2] = led_cfg[1]; |
| 4368 | if (IS_QLA8031(ha)) { |
| 4369 | mcp->mb[3] = led_cfg[2]; |
| 4370 | mcp->mb[4] = led_cfg[3]; |
| 4371 | mcp->mb[5] = led_cfg[4]; |
| 4372 | mcp->mb[6] = led_cfg[5]; |
| 4373 | } |
| 4374 | |
| 4375 | mcp->out_mb = MBX_2|MBX_1|MBX_0; |
| 4376 | if (IS_QLA8031(ha)) |
| 4377 | mcp->out_mb |= MBX_6|MBX_5|MBX_4|MBX_3; |
| 4378 | mcp->in_mb = MBX_0; |
| 4379 | mcp->tov = 30; |
| 4380 | mcp->flags = 0; |
| 4381 | |
| 4382 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4383 | if (rval != QLA_SUCCESS) { |
| 4384 | ql_dbg(ql_dbg_mbx, vha, 0x1134, |
| 4385 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 4386 | } else { |
| 4387 | ql_dbg(ql_dbg_mbx, vha, 0x1135, "Done %s.\n", __func__); |
| 4388 | } |
| 4389 | |
| 4390 | return rval; |
| 4391 | } |
| 4392 | |
| 4393 | int |
| 4394 | qla81xx_get_led_config(scsi_qla_host_t *vha, uint16_t *led_cfg) |
| 4395 | { |
| 4396 | int rval; |
| 4397 | struct qla_hw_data *ha = vha->hw; |
| 4398 | mbx_cmd_t mc; |
| 4399 | mbx_cmd_t *mcp = &mc; |
| 4400 | |
| 4401 | if (!IS_QLA81XX(ha) && !IS_QLA8031(ha)) |
| 4402 | return QLA_FUNCTION_FAILED; |
| 4403 | |
| 4404 | ql_dbg(ql_dbg_mbx, vha, 0x1136, "Entered %s.\n", __func__); |
| 4405 | |
| 4406 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
| 4407 | mcp->mb[0] = MBC_GET_LED_CONFIG; |
| 4408 | |
| 4409 | mcp->out_mb = MBX_0; |
| 4410 | mcp->in_mb = MBX_2|MBX_1|MBX_0; |
| 4411 | if (IS_QLA8031(ha)) |
| 4412 | mcp->in_mb |= MBX_6|MBX_5|MBX_4|MBX_3; |
| 4413 | mcp->tov = 30; |
| 4414 | mcp->flags = 0; |
| 4415 | |
| 4416 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4417 | if (rval != QLA_SUCCESS) { |
| 4418 | ql_dbg(ql_dbg_mbx, vha, 0x1137, |
| 4419 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 4420 | } else { |
| 4421 | led_cfg[0] = mcp->mb[1]; |
| 4422 | led_cfg[1] = mcp->mb[2]; |
| 4423 | if (IS_QLA8031(ha)) { |
| 4424 | led_cfg[2] = mcp->mb[3]; |
| 4425 | led_cfg[3] = mcp->mb[4]; |
| 4426 | led_cfg[4] = mcp->mb[5]; |
| 4427 | led_cfg[5] = mcp->mb[6]; |
| 4428 | } |
| 4429 | ql_dbg(ql_dbg_mbx, vha, 0x1138, "Done %s.\n", __func__); |
| 4430 | } |
| 4431 | |
| 4432 | return rval; |
| 4433 | } |
| 4434 | |
| 4435 | int |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 4436 | qla82xx_mbx_beacon_ctl(scsi_qla_host_t *vha, int enable) |
| 4437 | { |
| 4438 | int rval; |
| 4439 | struct qla_hw_data *ha = vha->hw; |
| 4440 | mbx_cmd_t mc; |
| 4441 | mbx_cmd_t *mcp = &mc; |
| 4442 | |
| 4443 | if (!IS_QLA82XX(ha)) |
| 4444 | return QLA_FUNCTION_FAILED; |
| 4445 | |
| 4446 | ql_dbg(ql_dbg_mbx, vha, 0x1127, |
| 4447 | "Entered %s.\n", __func__); |
| 4448 | |
| 4449 | memset(mcp, 0, sizeof(mbx_cmd_t)); |
| 4450 | mcp->mb[0] = MBC_SET_LED_CONFIG; |
| 4451 | if (enable) |
| 4452 | mcp->mb[7] = 0xE; |
| 4453 | else |
| 4454 | mcp->mb[7] = 0xD; |
| 4455 | |
| 4456 | mcp->out_mb = MBX_7|MBX_0; |
| 4457 | mcp->in_mb = MBX_0; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4458 | mcp->tov = MBX_TOV_SECONDS; |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 4459 | mcp->flags = 0; |
| 4460 | |
| 4461 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4462 | if (rval != QLA_SUCCESS) { |
| 4463 | ql_dbg(ql_dbg_mbx, vha, 0x1128, |
| 4464 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 4465 | } else { |
| 4466 | ql_dbg(ql_dbg_mbx, vha, 0x1129, |
| 4467 | "Done %s.\n", __func__); |
| 4468 | } |
| 4469 | |
| 4470 | return rval; |
| 4471 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4472 | |
| 4473 | int |
| 4474 | qla83xx_write_remote_reg(scsi_qla_host_t *vha, uint32_t reg, uint32_t data) |
| 4475 | { |
| 4476 | int rval; |
| 4477 | struct qla_hw_data *ha = vha->hw; |
| 4478 | mbx_cmd_t mc; |
| 4479 | mbx_cmd_t *mcp = &mc; |
| 4480 | |
| 4481 | if (!IS_QLA83XX(ha)) |
| 4482 | return QLA_FUNCTION_FAILED; |
| 4483 | |
| 4484 | ql_dbg(ql_dbg_mbx, vha, 0x1130, "Entered %s.\n", __func__); |
| 4485 | |
| 4486 | mcp->mb[0] = MBC_WRITE_REMOTE_REG; |
| 4487 | mcp->mb[1] = LSW(reg); |
| 4488 | mcp->mb[2] = MSW(reg); |
| 4489 | mcp->mb[3] = LSW(data); |
| 4490 | mcp->mb[4] = MSW(data); |
| 4491 | mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; |
| 4492 | |
| 4493 | mcp->in_mb = MBX_1|MBX_0; |
| 4494 | mcp->tov = MBX_TOV_SECONDS; |
| 4495 | mcp->flags = 0; |
| 4496 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4497 | |
| 4498 | if (rval != QLA_SUCCESS) { |
| 4499 | ql_dbg(ql_dbg_mbx, vha, 0x1131, |
| 4500 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 4501 | } else { |
| 4502 | ql_dbg(ql_dbg_mbx, vha, 0x1132, |
| 4503 | "Done %s.\n", __func__); |
| 4504 | } |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame^] | 4505 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4506 | return rval; |
| 4507 | } |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame^] | 4508 | |
| 4509 | int |
| 4510 | qla2x00_port_logout(scsi_qla_host_t *vha, struct fc_port *fcport) |
| 4511 | { |
| 4512 | int rval; |
| 4513 | struct qla_hw_data *ha = vha->hw; |
| 4514 | mbx_cmd_t mc; |
| 4515 | mbx_cmd_t *mcp = &mc; |
| 4516 | |
| 4517 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
| 4518 | ql_dbg(ql_dbg_mbx, vha, 0x113b, |
| 4519 | "Implicit LOGO Unsupported.\n"); |
| 4520 | return QLA_FUNCTION_FAILED; |
| 4521 | } |
| 4522 | |
| 4523 | |
| 4524 | ql_dbg(ql_dbg_mbx, vha, 0x113c, "Done %s.\n", __func__); |
| 4525 | |
| 4526 | /* Perform Implicit LOGO. */ |
| 4527 | mcp->mb[0] = MBC_PORT_LOGOUT; |
| 4528 | mcp->mb[1] = fcport->loop_id; |
| 4529 | mcp->mb[10] = BIT_15; |
| 4530 | mcp->out_mb = MBX_10|MBX_1|MBX_0; |
| 4531 | mcp->in_mb = MBX_0; |
| 4532 | mcp->tov = MBX_TOV_SECONDS; |
| 4533 | mcp->flags = 0; |
| 4534 | rval = qla2x00_mailbox_command(vha, mcp); |
| 4535 | if (rval != QLA_SUCCESS) |
| 4536 | ql_dbg(ql_dbg_mbx, vha, 0x113d, |
| 4537 | "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); |
| 4538 | else |
| 4539 | ql_dbg(ql_dbg_mbx, vha, 0x113e, "Done %s.\n", __func__); |
| 4540 | |
| 4541 | return rval; |
| 4542 | } |
| 4543 | |