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