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