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