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