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