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