David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1 | /* |
| 2 | * QLogic iSCSI HBA Driver |
Vikas Chaudhary | 7d01d06 | 2010-12-02 22:12:51 -0800 | [diff] [blame] | 3 | * Copyright (c) 2003-2010 QLogic Corporation |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 4 | * |
| 5 | * See LICENSE.qla4xxx for copyright and licensing details. |
| 6 | */ |
| 7 | |
| 8 | #include "ql4_def.h" |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 9 | #include "ql4_glbl.h" |
| 10 | #include "ql4_dbg.h" |
| 11 | #include "ql4_inline.h" |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 12 | |
| 13 | |
| 14 | /** |
| 15 | * qla4xxx_mailbox_command - issues mailbox commands |
| 16 | * @ha: Pointer to host adapter structure. |
| 17 | * @inCount: number of mailbox registers to load. |
| 18 | * @outCount: number of mailbox registers to return. |
| 19 | * @mbx_cmd: data pointer for mailbox in registers. |
| 20 | * @mbx_sts: data pointer for mailbox out registers. |
| 21 | * |
Justin P. Mattock | 70f23fd | 2011-05-10 10:16:21 +0200 | [diff] [blame] | 22 | * This routine issue mailbox commands and waits for completion. |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 23 | * If outCount is 0, this routine completes successfully WITHOUT waiting |
| 24 | * for the mailbox command to complete. |
| 25 | **/ |
Vikas Chaudhary | f4f5df2 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 26 | int qla4xxx_mailbox_command(struct scsi_qla_host *ha, uint8_t inCount, |
| 27 | uint8_t outCount, uint32_t *mbx_cmd, |
| 28 | uint32_t *mbx_sts) |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 29 | { |
| 30 | int status = QLA_ERROR; |
| 31 | uint8_t i; |
| 32 | u_long wait_count; |
| 33 | uint32_t intr_status; |
| 34 | unsigned long flags = 0; |
Prasanna Mumbai | 99b53bf | 2011-03-21 03:34:25 -0700 | [diff] [blame] | 35 | uint32_t dev_state; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 36 | |
| 37 | /* Make sure that pointers are valid */ |
| 38 | if (!mbx_cmd || !mbx_sts) { |
| 39 | DEBUG2(printk("scsi%ld: %s: Invalid mbx_cmd or mbx_sts " |
| 40 | "pointer\n", ha->host_no, __func__)); |
David C Somayajulu | 477ffb9 | 2007-01-22 12:26:11 -0800 | [diff] [blame] | 41 | return status; |
| 42 | } |
Nilesh Javali | 2103363 | 2010-07-30 14:28:07 +0530 | [diff] [blame] | 43 | |
Prasanna Mumbai | 99b53bf | 2011-03-21 03:34:25 -0700 | [diff] [blame] | 44 | if (is_qla8022(ha)) { |
| 45 | if (test_bit(AF_FW_RECOVERY, &ha->flags)) { |
| 46 | DEBUG2(ql4_printk(KERN_WARNING, ha, "scsi%ld: %s: " |
| 47 | "prematurely completing mbx cmd as firmware " |
| 48 | "recovery detected\n", ha->host_no, __func__)); |
| 49 | return status; |
| 50 | } |
| 51 | /* Do not send any mbx cmd if h/w is in failed state*/ |
| 52 | qla4_8xxx_idc_lock(ha); |
| 53 | dev_state = qla4_8xxx_rd_32(ha, QLA82XX_CRB_DEV_STATE); |
| 54 | qla4_8xxx_idc_unlock(ha); |
| 55 | if (dev_state == QLA82XX_DEV_FAILED) { |
| 56 | ql4_printk(KERN_WARNING, ha, "scsi%ld: %s: H/W is in " |
| 57 | "failed state, do not send any mailbox commands\n", |
| 58 | ha->host_no, __func__); |
| 59 | return status; |
| 60 | } |
Nilesh Javali | 2103363 | 2010-07-30 14:28:07 +0530 | [diff] [blame] | 61 | } |
| 62 | |
Lalit Chandivade | 2232be0 | 2010-07-30 14:38:47 +0530 | [diff] [blame] | 63 | if ((is_aer_supported(ha)) && |
| 64 | (test_bit(AF_PCI_CHANNEL_IO_PERM_FAILURE, &ha->flags))) { |
| 65 | DEBUG2(printk(KERN_WARNING "scsi%ld: %s: Perm failure on EEH, " |
| 66 | "timeout MBX Exiting.\n", ha->host_no, __func__)); |
| 67 | return status; |
| 68 | } |
| 69 | |
David C Somayajulu | 477ffb9 | 2007-01-22 12:26:11 -0800 | [diff] [blame] | 70 | /* Mailbox code active */ |
| 71 | wait_count = MBOX_TOV * 100; |
| 72 | |
| 73 | while (wait_count--) { |
| 74 | mutex_lock(&ha->mbox_sem); |
| 75 | if (!test_bit(AF_MBOX_COMMAND, &ha->flags)) { |
| 76 | set_bit(AF_MBOX_COMMAND, &ha->flags); |
| 77 | mutex_unlock(&ha->mbox_sem); |
| 78 | break; |
| 79 | } |
| 80 | mutex_unlock(&ha->mbox_sem); |
| 81 | if (!wait_count) { |
| 82 | DEBUG2(printk("scsi%ld: %s: mbox_sem failed\n", |
| 83 | ha->host_no, __func__)); |
| 84 | return status; |
| 85 | } |
| 86 | msleep(10); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 87 | } |
| 88 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 89 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Vikas Chaudhary | f4f5df2 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 90 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 91 | ha->mbox_status_count = outCount; |
| 92 | for (i = 0; i < outCount; i++) |
| 93 | ha->mbox_status[i] = 0; |
| 94 | |
Vikas Chaudhary | f4f5df2 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 95 | if (is_qla8022(ha)) { |
| 96 | /* Load all mailbox registers, except mailbox 0. */ |
| 97 | DEBUG5( |
| 98 | printk("scsi%ld: %s: Cmd ", ha->host_no, __func__); |
| 99 | for (i = 0; i < inCount; i++) |
| 100 | printk("mb%d=%04x ", i, mbx_cmd[i]); |
| 101 | printk("\n")); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 102 | |
Vikas Chaudhary | f4f5df2 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 103 | for (i = 1; i < inCount; i++) |
| 104 | writel(mbx_cmd[i], &ha->qla4_8xxx_reg->mailbox_in[i]); |
| 105 | writel(mbx_cmd[0], &ha->qla4_8xxx_reg->mailbox_in[0]); |
| 106 | readl(&ha->qla4_8xxx_reg->mailbox_in[0]); |
| 107 | writel(HINT_MBX_INT_PENDING, &ha->qla4_8xxx_reg->hint); |
| 108 | } else { |
| 109 | /* Load all mailbox registers, except mailbox 0. */ |
| 110 | for (i = 1; i < inCount; i++) |
| 111 | writel(mbx_cmd[i], &ha->reg->mailbox[i]); |
| 112 | |
| 113 | /* Wakeup firmware */ |
| 114 | writel(mbx_cmd[0], &ha->reg->mailbox[0]); |
| 115 | readl(&ha->reg->mailbox[0]); |
| 116 | writel(set_rmask(CSR_INTR_RISC), &ha->reg->ctrl_status); |
| 117 | readl(&ha->reg->ctrl_status); |
| 118 | } |
| 119 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 120 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 121 | |
| 122 | /* Wait for completion */ |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 123 | |
| 124 | /* |
| 125 | * If we don't want status, don't wait for the mailbox command to |
| 126 | * complete. For example, MBOX_CMD_RESET_FW doesn't return status, |
| 127 | * you must poll the inbound Interrupt Mask for completion. |
| 128 | */ |
| 129 | if (outCount == 0) { |
| 130 | status = QLA_SUCCESS; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 131 | goto mbox_exit; |
| 132 | } |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 133 | |
Vikas Chaudhary | f4f5df2 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 134 | /* |
| 135 | * Wait for completion: Poll or completion queue |
| 136 | */ |
| 137 | if (test_bit(AF_IRQ_ATTACHED, &ha->flags) && |
| 138 | test_bit(AF_INTERRUPTS_ON, &ha->flags) && |
| 139 | test_bit(AF_ONLINE, &ha->flags) && |
Karen Higgins | 7eece5a | 2011-03-21 03:34:29 -0700 | [diff] [blame] | 140 | !test_bit(AF_HA_REMOVAL, &ha->flags)) { |
Vikas Chaudhary | f4f5df2 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 141 | /* Do not poll for completion. Use completion queue */ |
| 142 | set_bit(AF_MBOX_COMMAND_NOPOLL, &ha->flags); |
| 143 | wait_for_completion_timeout(&ha->mbx_intr_comp, MBOX_TOV * HZ); |
| 144 | clear_bit(AF_MBOX_COMMAND_NOPOLL, &ha->flags); |
| 145 | } else { |
| 146 | /* Poll for command to complete */ |
| 147 | wait_count = jiffies + MBOX_TOV * HZ; |
| 148 | while (test_bit(AF_MBOX_COMMAND_DONE, &ha->flags) == 0) { |
| 149 | if (time_after_eq(jiffies, wait_count)) |
| 150 | break; |
Lalit Chandivade | 2232be0 | 2010-07-30 14:38:47 +0530 | [diff] [blame] | 151 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 152 | /* |
| 153 | * Service the interrupt. |
| 154 | * The ISR will save the mailbox status registers |
| 155 | * to a temporary storage location in the adapter |
| 156 | * structure. |
| 157 | */ |
Vikas Chaudhary | f4f5df2 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 158 | |
| 159 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 160 | if (is_qla8022(ha)) { |
| 161 | intr_status = |
| 162 | readl(&ha->qla4_8xxx_reg->host_int); |
| 163 | if (intr_status & ISRX_82XX_RISC_INT) { |
| 164 | ha->mbox_status_count = outCount; |
| 165 | intr_status = |
| 166 | readl(&ha->qla4_8xxx_reg->host_status); |
| 167 | ha->isp_ops->interrupt_service_routine( |
| 168 | ha, intr_status); |
| 169 | if (test_bit(AF_INTERRUPTS_ON, |
| 170 | &ha->flags) && |
| 171 | test_bit(AF_INTx_ENABLED, |
| 172 | &ha->flags)) |
| 173 | qla4_8xxx_wr_32(ha, |
| 174 | ha->nx_legacy_intr.tgt_mask_reg, |
| 175 | 0xfbff); |
| 176 | } |
| 177 | } else { |
| 178 | intr_status = readl(&ha->reg->ctrl_status); |
| 179 | if (intr_status & INTR_PENDING) { |
| 180 | /* |
| 181 | * Service the interrupt. |
| 182 | * The ISR will save the mailbox status |
| 183 | * registers to a temporary storage |
| 184 | * location in the adapter structure. |
| 185 | */ |
| 186 | ha->mbox_status_count = outCount; |
| 187 | ha->isp_ops->interrupt_service_routine( |
| 188 | ha, intr_status); |
| 189 | } |
| 190 | } |
| 191 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 192 | msleep(10); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 193 | } |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 194 | } |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 195 | |
| 196 | /* Check for mailbox timeout. */ |
| 197 | if (!test_bit(AF_MBOX_COMMAND_DONE, &ha->flags)) { |
Nilesh Javali | 2103363 | 2010-07-30 14:28:07 +0530 | [diff] [blame] | 198 | if (is_qla8022(ha) && |
| 199 | test_bit(AF_FW_RECOVERY, &ha->flags)) { |
| 200 | DEBUG2(ql4_printk(KERN_INFO, ha, |
| 201 | "scsi%ld: %s: prematurely completing mbx cmd as " |
| 202 | "firmware recovery detected\n", |
| 203 | ha->host_no, __func__)); |
| 204 | goto mbox_exit; |
| 205 | } |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 206 | DEBUG2(printk("scsi%ld: Mailbox Cmd 0x%08X timed out ...," |
| 207 | " Scheduling Adapter Reset\n", ha->host_no, |
| 208 | mbx_cmd[0])); |
| 209 | ha->mailbox_timeout_count++; |
| 210 | mbx_sts[0] = (-1); |
| 211 | set_bit(DPC_RESET_HA, &ha->dpc_flags); |
| 212 | goto mbox_exit; |
| 213 | } |
| 214 | |
| 215 | /* |
| 216 | * Copy the mailbox out registers to the caller's mailbox in/out |
| 217 | * structure. |
| 218 | */ |
| 219 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 220 | for (i = 0; i < outCount; i++) |
| 221 | mbx_sts[i] = ha->mbox_status[i]; |
| 222 | |
| 223 | /* Set return status and error flags (if applicable). */ |
| 224 | switch (ha->mbox_status[0]) { |
| 225 | case MBOX_STS_COMMAND_COMPLETE: |
| 226 | status = QLA_SUCCESS; |
| 227 | break; |
| 228 | |
| 229 | case MBOX_STS_INTERMEDIATE_COMPLETION: |
| 230 | status = QLA_SUCCESS; |
| 231 | break; |
| 232 | |
| 233 | case MBOX_STS_BUSY: |
| 234 | DEBUG2( printk("scsi%ld: %s: Cmd = %08X, ISP BUSY\n", |
| 235 | ha->host_no, __func__, mbx_cmd[0])); |
| 236 | ha->mailbox_timeout_count++; |
| 237 | break; |
| 238 | |
| 239 | default: |
| 240 | DEBUG2(printk("scsi%ld: %s: **** FAILED, cmd = %08X, " |
| 241 | "sts = %08X ****\n", ha->host_no, __func__, |
| 242 | mbx_cmd[0], mbx_sts[0])); |
| 243 | break; |
| 244 | } |
| 245 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 246 | |
| 247 | mbox_exit: |
David C Somayajulu | 477ffb9 | 2007-01-22 12:26:11 -0800 | [diff] [blame] | 248 | mutex_lock(&ha->mbox_sem); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 249 | clear_bit(AF_MBOX_COMMAND, &ha->flags); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 250 | mutex_unlock(&ha->mbox_sem); |
David C Somayajulu | 477ffb9 | 2007-01-22 12:26:11 -0800 | [diff] [blame] | 251 | clear_bit(AF_MBOX_COMMAND_DONE, &ha->flags); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 252 | |
| 253 | return status; |
| 254 | } |
| 255 | |
Nilesh Javali | 2103363 | 2010-07-30 14:28:07 +0530 | [diff] [blame] | 256 | void qla4xxx_mailbox_premature_completion(struct scsi_qla_host *ha) |
| 257 | { |
| 258 | set_bit(AF_FW_RECOVERY, &ha->flags); |
| 259 | ql4_printk(KERN_INFO, ha, "scsi%ld: %s: set FW RECOVERY!\n", |
| 260 | ha->host_no, __func__); |
| 261 | |
| 262 | if (test_bit(AF_MBOX_COMMAND, &ha->flags)) { |
| 263 | if (test_bit(AF_MBOX_COMMAND_NOPOLL, &ha->flags)) { |
| 264 | complete(&ha->mbx_intr_comp); |
| 265 | ql4_printk(KERN_INFO, ha, "scsi%ld: %s: Due to fw " |
| 266 | "recovery, doing premature completion of " |
| 267 | "mbx cmd\n", ha->host_no, __func__); |
| 268 | |
| 269 | } else { |
| 270 | set_bit(AF_MBOX_COMMAND_DONE, &ha->flags); |
| 271 | ql4_printk(KERN_INFO, ha, "scsi%ld: %s: Due to fw " |
| 272 | "recovery, doing premature completion of " |
| 273 | "polling mbx cmd\n", ha->host_no, __func__); |
| 274 | } |
| 275 | } |
| 276 | } |
| 277 | |
Vikas Chaudhary | f4f5df2 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 278 | static uint8_t |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 279 | qla4xxx_set_ifcb(struct scsi_qla_host *ha, uint32_t *mbox_cmd, |
| 280 | uint32_t *mbox_sts, dma_addr_t init_fw_cb_dma) |
| 281 | { |
| 282 | memset(mbox_cmd, 0, sizeof(mbox_cmd[0]) * MBOX_REG_COUNT); |
| 283 | memset(mbox_sts, 0, sizeof(mbox_sts[0]) * MBOX_REG_COUNT); |
Shyam Sundar | 2657c80 | 2010-10-06 22:50:29 -0700 | [diff] [blame] | 284 | |
| 285 | if (is_qla8022(ha)) |
| 286 | qla4_8xxx_wr_32(ha, ha->nx_db_wr_ptr, 0); |
| 287 | |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 288 | mbox_cmd[0] = MBOX_CMD_INITIALIZE_FIRMWARE; |
| 289 | mbox_cmd[1] = 0; |
| 290 | mbox_cmd[2] = LSDW(init_fw_cb_dma); |
| 291 | mbox_cmd[3] = MSDW(init_fw_cb_dma); |
| 292 | mbox_cmd[4] = sizeof(struct addr_ctrl_blk); |
| 293 | mbox_cmd[5] = (IFCB_VER_MAX << 8) | IFCB_VER_MIN; |
| 294 | |
| 295 | if (qla4xxx_mailbox_command(ha, 6, 6, mbox_cmd, mbox_sts) != |
| 296 | QLA_SUCCESS) { |
| 297 | DEBUG2(printk(KERN_WARNING "scsi%ld: %s: " |
| 298 | "MBOX_CMD_INITIALIZE_FIRMWARE" |
| 299 | " failed w/ status %04X\n", |
| 300 | ha->host_no, __func__, mbox_sts[0])); |
| 301 | return QLA_ERROR; |
| 302 | } |
| 303 | return QLA_SUCCESS; |
| 304 | } |
| 305 | |
Mike Christie | d00efe3 | 2011-07-25 13:48:38 -0500 | [diff] [blame] | 306 | uint8_t |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 307 | qla4xxx_get_ifcb(struct scsi_qla_host *ha, uint32_t *mbox_cmd, |
| 308 | uint32_t *mbox_sts, dma_addr_t init_fw_cb_dma) |
| 309 | { |
| 310 | memset(mbox_cmd, 0, sizeof(mbox_cmd[0]) * MBOX_REG_COUNT); |
| 311 | memset(mbox_sts, 0, sizeof(mbox_sts[0]) * MBOX_REG_COUNT); |
| 312 | mbox_cmd[0] = MBOX_CMD_GET_INIT_FW_CTRL_BLOCK; |
| 313 | mbox_cmd[2] = LSDW(init_fw_cb_dma); |
| 314 | mbox_cmd[3] = MSDW(init_fw_cb_dma); |
| 315 | mbox_cmd[4] = sizeof(struct addr_ctrl_blk); |
| 316 | |
| 317 | if (qla4xxx_mailbox_command(ha, 5, 5, mbox_cmd, mbox_sts) != |
| 318 | QLA_SUCCESS) { |
| 319 | DEBUG2(printk(KERN_WARNING "scsi%ld: %s: " |
| 320 | "MBOX_CMD_GET_INIT_FW_CTRL_BLOCK" |
| 321 | " failed w/ status %04X\n", |
| 322 | ha->host_no, __func__, mbox_sts[0])); |
| 323 | return QLA_ERROR; |
| 324 | } |
| 325 | return QLA_SUCCESS; |
| 326 | } |
| 327 | |
Vikas Chaudhary | f4f5df2 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 328 | static void |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 329 | qla4xxx_update_local_ip(struct scsi_qla_host *ha, |
Vikas Chaudhary | 2bab08f | 2011-07-25 13:48:39 -0500 | [diff] [blame^] | 330 | struct addr_ctrl_blk *init_fw_cb) |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 331 | { |
Vikas Chaudhary | 2bab08f | 2011-07-25 13:48:39 -0500 | [diff] [blame^] | 332 | ha->ip_config.tcp_options = le16_to_cpu(init_fw_cb->ipv4_tcp_opts); |
| 333 | ha->ip_config.ipv4_options = le16_to_cpu(init_fw_cb->ipv4_ip_opts); |
| 334 | ha->ip_config.ipv4_addr_state = |
| 335 | le16_to_cpu(init_fw_cb->ipv4_addr_state); |
| 336 | |
| 337 | if (ha->acb_version == ACB_SUPPORTED) { |
| 338 | ha->ip_config.ipv6_options = le16_to_cpu(init_fw_cb->ipv6_opts); |
| 339 | ha->ip_config.ipv6_addl_options = |
| 340 | le16_to_cpu(init_fw_cb->ipv6_addtl_opts); |
| 341 | } |
| 342 | |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 343 | /* Save IPv4 Address Info */ |
Vikas Chaudhary | 2bab08f | 2011-07-25 13:48:39 -0500 | [diff] [blame^] | 344 | memcpy(ha->ip_config.ip_address, init_fw_cb->ipv4_addr, |
| 345 | min(sizeof(ha->ip_config.ip_address), |
| 346 | sizeof(init_fw_cb->ipv4_addr))); |
| 347 | memcpy(ha->ip_config.subnet_mask, init_fw_cb->ipv4_subnet, |
| 348 | min(sizeof(ha->ip_config.subnet_mask), |
| 349 | sizeof(init_fw_cb->ipv4_subnet))); |
| 350 | memcpy(ha->ip_config.gateway, init_fw_cb->ipv4_gw_addr, |
| 351 | min(sizeof(ha->ip_config.gateway), |
| 352 | sizeof(init_fw_cb->ipv4_gw_addr))); |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 353 | |
| 354 | if (is_ipv6_enabled(ha)) { |
| 355 | /* Save IPv6 Address */ |
Vikas Chaudhary | 2bab08f | 2011-07-25 13:48:39 -0500 | [diff] [blame^] | 356 | ha->ip_config.ipv6_link_local_state = |
| 357 | le16_to_cpu(init_fw_cb->ipv6_lnk_lcl_addr_state); |
| 358 | ha->ip_config.ipv6_addr0_state = |
| 359 | le16_to_cpu(init_fw_cb->ipv6_addr0_state); |
| 360 | ha->ip_config.ipv6_addr1_state = |
| 361 | le16_to_cpu(init_fw_cb->ipv6_addr1_state); |
| 362 | ha->ip_config.ipv6_default_router_state = |
| 363 | le16_to_cpu(init_fw_cb->ipv6_dflt_rtr_state); |
| 364 | ha->ip_config.ipv6_link_local_addr.in6_u.u6_addr8[0] = 0xFE; |
| 365 | ha->ip_config.ipv6_link_local_addr.in6_u.u6_addr8[1] = 0x80; |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 366 | |
Vikas Chaudhary | 2bab08f | 2011-07-25 13:48:39 -0500 | [diff] [blame^] | 367 | memcpy(&ha->ip_config.ipv6_link_local_addr.in6_u.u6_addr8[8], |
| 368 | init_fw_cb->ipv6_if_id, |
| 369 | min(sizeof(ha->ip_config.ipv6_link_local_addr)/2, |
| 370 | sizeof(init_fw_cb->ipv6_if_id))); |
| 371 | memcpy(&ha->ip_config.ipv6_addr0, init_fw_cb->ipv6_addr0, |
| 372 | min(sizeof(ha->ip_config.ipv6_addr0), |
| 373 | sizeof(init_fw_cb->ipv6_addr0))); |
| 374 | memcpy(&ha->ip_config.ipv6_addr1, init_fw_cb->ipv6_addr1, |
| 375 | min(sizeof(ha->ip_config.ipv6_addr1), |
| 376 | sizeof(init_fw_cb->ipv6_addr1))); |
| 377 | memcpy(&ha->ip_config.ipv6_default_router_addr, |
| 378 | init_fw_cb->ipv6_dflt_rtr_addr, |
| 379 | min(sizeof(ha->ip_config.ipv6_default_router_addr), |
| 380 | sizeof(init_fw_cb->ipv6_dflt_rtr_addr))); |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 381 | } |
| 382 | } |
| 383 | |
Mike Christie | d00efe3 | 2011-07-25 13:48:38 -0500 | [diff] [blame] | 384 | uint8_t |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 385 | qla4xxx_update_local_ifcb(struct scsi_qla_host *ha, |
| 386 | uint32_t *mbox_cmd, |
| 387 | uint32_t *mbox_sts, |
| 388 | struct addr_ctrl_blk *init_fw_cb, |
| 389 | dma_addr_t init_fw_cb_dma) |
| 390 | { |
| 391 | if (qla4xxx_get_ifcb(ha, mbox_cmd, mbox_sts, init_fw_cb_dma) |
| 392 | != QLA_SUCCESS) { |
| 393 | DEBUG2(printk(KERN_WARNING |
| 394 | "scsi%ld: %s: Failed to get init_fw_ctrl_blk\n", |
| 395 | ha->host_no, __func__)); |
| 396 | return QLA_ERROR; |
| 397 | } |
| 398 | |
| 399 | DEBUG2(qla4xxx_dump_buffer(init_fw_cb, sizeof(struct addr_ctrl_blk))); |
| 400 | |
| 401 | /* Save some info in adapter structure. */ |
| 402 | ha->acb_version = init_fw_cb->acb_version; |
| 403 | ha->firmware_options = le16_to_cpu(init_fw_cb->fw_options); |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 404 | ha->heartbeat_interval = init_fw_cb->hb_interval; |
| 405 | memcpy(ha->name_string, init_fw_cb->iscsi_name, |
| 406 | min(sizeof(ha->name_string), |
| 407 | sizeof(init_fw_cb->iscsi_name))); |
| 408 | /*memcpy(ha->alias, init_fw_cb->Alias, |
| 409 | min(sizeof(ha->alias), sizeof(init_fw_cb->Alias)));*/ |
| 410 | |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 411 | qla4xxx_update_local_ip(ha, init_fw_cb); |
| 412 | |
| 413 | return QLA_SUCCESS; |
| 414 | } |
| 415 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 416 | /** |
| 417 | * qla4xxx_initialize_fw_cb - initializes firmware control block. |
| 418 | * @ha: Pointer to host adapter structure. |
| 419 | **/ |
| 420 | int qla4xxx_initialize_fw_cb(struct scsi_qla_host * ha) |
| 421 | { |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 422 | struct addr_ctrl_blk *init_fw_cb; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 423 | dma_addr_t init_fw_cb_dma; |
| 424 | uint32_t mbox_cmd[MBOX_REG_COUNT]; |
| 425 | uint32_t mbox_sts[MBOX_REG_COUNT]; |
| 426 | int status = QLA_ERROR; |
| 427 | |
| 428 | init_fw_cb = dma_alloc_coherent(&ha->pdev->dev, |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 429 | sizeof(struct addr_ctrl_blk), |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 430 | &init_fw_cb_dma, GFP_KERNEL); |
| 431 | if (init_fw_cb == NULL) { |
| 432 | DEBUG2(printk("scsi%ld: %s: Unable to alloc init_cb\n", |
| 433 | ha->host_no, __func__)); |
Prasanna Mumbai | beabe7c | 2010-07-10 14:49:38 +0530 | [diff] [blame] | 434 | goto exit_init_fw_cb_no_free; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 435 | } |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 436 | memset(init_fw_cb, 0, sizeof(struct addr_ctrl_blk)); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 437 | |
| 438 | /* Get Initialize Firmware Control Block. */ |
| 439 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); |
| 440 | memset(&mbox_sts, 0, sizeof(mbox_sts)); |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 441 | |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 442 | if (qla4xxx_get_ifcb(ha, &mbox_cmd[0], &mbox_sts[0], init_fw_cb_dma) != |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 443 | QLA_SUCCESS) { |
| 444 | dma_free_coherent(&ha->pdev->dev, |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 445 | sizeof(struct addr_ctrl_blk), |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 446 | init_fw_cb, init_fw_cb_dma); |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 447 | goto exit_init_fw_cb; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 448 | } |
| 449 | |
| 450 | /* Initialize request and response queues. */ |
| 451 | qla4xxx_init_rings(ha); |
| 452 | |
| 453 | /* Fill in the request and response queue information. */ |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 454 | init_fw_cb->rqq_consumer_idx = cpu_to_le16(ha->request_out); |
| 455 | init_fw_cb->compq_producer_idx = cpu_to_le16(ha->response_in); |
| 456 | init_fw_cb->rqq_len = __constant_cpu_to_le16(REQUEST_QUEUE_DEPTH); |
| 457 | init_fw_cb->compq_len = __constant_cpu_to_le16(RESPONSE_QUEUE_DEPTH); |
| 458 | init_fw_cb->rqq_addr_lo = cpu_to_le32(LSDW(ha->request_dma)); |
| 459 | init_fw_cb->rqq_addr_hi = cpu_to_le32(MSDW(ha->request_dma)); |
| 460 | init_fw_cb->compq_addr_lo = cpu_to_le32(LSDW(ha->response_dma)); |
| 461 | init_fw_cb->compq_addr_hi = cpu_to_le32(MSDW(ha->response_dma)); |
| 462 | init_fw_cb->shdwreg_addr_lo = cpu_to_le32(LSDW(ha->shadow_regs_dma)); |
| 463 | init_fw_cb->shdwreg_addr_hi = cpu_to_le32(MSDW(ha->shadow_regs_dma)); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 464 | |
| 465 | /* Set up required options. */ |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 466 | init_fw_cb->fw_options |= |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 467 | __constant_cpu_to_le16(FWOPT_SESSION_MODE | |
| 468 | FWOPT_INITIATOR_MODE); |
Shyam Sundar | 2657c80 | 2010-10-06 22:50:29 -0700 | [diff] [blame] | 469 | |
| 470 | if (is_qla8022(ha)) |
| 471 | init_fw_cb->fw_options |= |
| 472 | __constant_cpu_to_le16(FWOPT_ENABLE_CRBDB); |
| 473 | |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 474 | init_fw_cb->fw_options &= __constant_cpu_to_le16(~FWOPT_TARGET_MODE); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 475 | |
Prasanna Mumbai | d32cee3 | 2011-03-21 03:34:35 -0700 | [diff] [blame] | 476 | /* Set bit for "serialize task mgmt" all other bits need to be zero */ |
| 477 | init_fw_cb->add_fw_options = 0; |
| 478 | init_fw_cb->add_fw_options |= |
| 479 | __constant_cpu_to_le16(SERIALIZE_TASK_MGMT); |
| 480 | |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 481 | if (qla4xxx_set_ifcb(ha, &mbox_cmd[0], &mbox_sts[0], init_fw_cb_dma) |
| 482 | != QLA_SUCCESS) { |
| 483 | DEBUG2(printk(KERN_WARNING |
| 484 | "scsi%ld: %s: Failed to set init_fw_ctrl_blk\n", |
| 485 | ha->host_no, __func__)); |
| 486 | goto exit_init_fw_cb; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 487 | } |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 488 | |
| 489 | if (qla4xxx_update_local_ifcb(ha, &mbox_cmd[0], &mbox_sts[0], |
| 490 | init_fw_cb, init_fw_cb_dma) != QLA_SUCCESS) { |
| 491 | DEBUG2(printk("scsi%ld: %s: Failed to update local ifcb\n", |
| 492 | ha->host_no, __func__)); |
| 493 | goto exit_init_fw_cb; |
| 494 | } |
| 495 | status = QLA_SUCCESS; |
| 496 | |
| 497 | exit_init_fw_cb: |
| 498 | dma_free_coherent(&ha->pdev->dev, sizeof(struct addr_ctrl_blk), |
| 499 | init_fw_cb, init_fw_cb_dma); |
Prasanna Mumbai | beabe7c | 2010-07-10 14:49:38 +0530 | [diff] [blame] | 500 | exit_init_fw_cb_no_free: |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 501 | return status; |
| 502 | } |
| 503 | |
| 504 | /** |
| 505 | * qla4xxx_get_dhcp_ip_address - gets HBA ip address via DHCP |
| 506 | * @ha: Pointer to host adapter structure. |
| 507 | **/ |
| 508 | int qla4xxx_get_dhcp_ip_address(struct scsi_qla_host * ha) |
| 509 | { |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 510 | struct addr_ctrl_blk *init_fw_cb; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 511 | dma_addr_t init_fw_cb_dma; |
| 512 | uint32_t mbox_cmd[MBOX_REG_COUNT]; |
| 513 | uint32_t mbox_sts[MBOX_REG_COUNT]; |
| 514 | |
| 515 | init_fw_cb = dma_alloc_coherent(&ha->pdev->dev, |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 516 | sizeof(struct addr_ctrl_blk), |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 517 | &init_fw_cb_dma, GFP_KERNEL); |
| 518 | if (init_fw_cb == NULL) { |
| 519 | printk("scsi%ld: %s: Unable to alloc init_cb\n", ha->host_no, |
| 520 | __func__); |
Prasanna Mumbai | beabe7c | 2010-07-10 14:49:38 +0530 | [diff] [blame] | 521 | return QLA_ERROR; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | /* Get Initialize Firmware Control Block. */ |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 525 | memset(init_fw_cb, 0, sizeof(struct addr_ctrl_blk)); |
| 526 | if (qla4xxx_get_ifcb(ha, &mbox_cmd[0], &mbox_sts[0], init_fw_cb_dma) != |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 527 | QLA_SUCCESS) { |
| 528 | DEBUG2(printk("scsi%ld: %s: Failed to get init_fw_ctrl_blk\n", |
| 529 | ha->host_no, __func__)); |
| 530 | dma_free_coherent(&ha->pdev->dev, |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 531 | sizeof(struct addr_ctrl_blk), |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 532 | init_fw_cb, init_fw_cb_dma); |
| 533 | return QLA_ERROR; |
| 534 | } |
| 535 | |
| 536 | /* Save IP Address. */ |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 537 | qla4xxx_update_local_ip(ha, init_fw_cb); |
| 538 | dma_free_coherent(&ha->pdev->dev, sizeof(struct addr_ctrl_blk), |
| 539 | init_fw_cb, init_fw_cb_dma); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 540 | |
| 541 | return QLA_SUCCESS; |
| 542 | } |
| 543 | |
| 544 | /** |
| 545 | * qla4xxx_get_firmware_state - gets firmware state of HBA |
| 546 | * @ha: Pointer to host adapter structure. |
| 547 | **/ |
| 548 | int qla4xxx_get_firmware_state(struct scsi_qla_host * ha) |
| 549 | { |
| 550 | uint32_t mbox_cmd[MBOX_REG_COUNT]; |
| 551 | uint32_t mbox_sts[MBOX_REG_COUNT]; |
| 552 | |
| 553 | /* Get firmware version */ |
| 554 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); |
| 555 | memset(&mbox_sts, 0, sizeof(mbox_sts)); |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 556 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 557 | mbox_cmd[0] = MBOX_CMD_GET_FW_STATE; |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 558 | |
| 559 | if (qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 4, &mbox_cmd[0], &mbox_sts[0]) != |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 560 | QLA_SUCCESS) { |
| 561 | DEBUG2(printk("scsi%ld: %s: MBOX_CMD_GET_FW_STATE failed w/ " |
| 562 | "status %04X\n", ha->host_no, __func__, |
| 563 | mbox_sts[0])); |
| 564 | return QLA_ERROR; |
| 565 | } |
| 566 | ha->firmware_state = mbox_sts[1]; |
| 567 | ha->board_id = mbox_sts[2]; |
| 568 | ha->addl_fw_state = mbox_sts[3]; |
| 569 | DEBUG2(printk("scsi%ld: %s firmware_state=0x%x\n", |
| 570 | ha->host_no, __func__, ha->firmware_state);) |
| 571 | |
Vikas Chaudhary | f4f5df2 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 572 | return QLA_SUCCESS; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 573 | } |
| 574 | |
| 575 | /** |
| 576 | * qla4xxx_get_firmware_status - retrieves firmware status |
| 577 | * @ha: Pointer to host adapter structure. |
| 578 | **/ |
| 579 | int qla4xxx_get_firmware_status(struct scsi_qla_host * ha) |
| 580 | { |
| 581 | uint32_t mbox_cmd[MBOX_REG_COUNT]; |
| 582 | uint32_t mbox_sts[MBOX_REG_COUNT]; |
| 583 | |
| 584 | /* Get firmware version */ |
| 585 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); |
| 586 | memset(&mbox_sts, 0, sizeof(mbox_sts)); |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 587 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 588 | mbox_cmd[0] = MBOX_CMD_GET_FW_STATUS; |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 589 | |
| 590 | if (qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 3, &mbox_cmd[0], &mbox_sts[0]) != |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 591 | QLA_SUCCESS) { |
| 592 | DEBUG2(printk("scsi%ld: %s: MBOX_CMD_GET_FW_STATUS failed w/ " |
| 593 | "status %04X\n", ha->host_no, __func__, |
| 594 | mbox_sts[0])); |
| 595 | return QLA_ERROR; |
| 596 | } |
Vikas Chaudhary | f4f5df2 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 597 | |
| 598 | ql4_printk(KERN_INFO, ha, "%ld firmare IOCBs available (%d).\n", |
Vikas Chaudhary | f581a3f | 2010-10-06 22:47:48 -0700 | [diff] [blame] | 599 | ha->host_no, mbox_sts[2]); |
Vikas Chaudhary | f4f5df2 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 600 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 601 | return QLA_SUCCESS; |
| 602 | } |
| 603 | |
| 604 | /** |
| 605 | * qla4xxx_get_fwddb_entry - retrieves firmware ddb entry |
| 606 | * @ha: Pointer to host adapter structure. |
| 607 | * @fw_ddb_index: Firmware's device database index |
| 608 | * @fw_ddb_entry: Pointer to firmware's device database entry structure |
| 609 | * @num_valid_ddb_entries: Pointer to number of valid ddb entries |
| 610 | * @next_ddb_index: Pointer to next valid device database index |
| 611 | * @fw_ddb_device_state: Pointer to device state |
| 612 | **/ |
| 613 | int qla4xxx_get_fwddb_entry(struct scsi_qla_host *ha, |
| 614 | uint16_t fw_ddb_index, |
| 615 | struct dev_db_entry *fw_ddb_entry, |
| 616 | dma_addr_t fw_ddb_entry_dma, |
| 617 | uint32_t *num_valid_ddb_entries, |
| 618 | uint32_t *next_ddb_index, |
| 619 | uint32_t *fw_ddb_device_state, |
| 620 | uint32_t *conn_err_detail, |
| 621 | uint16_t *tcp_source_port_num, |
| 622 | uint16_t *connection_id) |
| 623 | { |
| 624 | int status = QLA_ERROR; |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 625 | uint16_t options; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 626 | uint32_t mbox_cmd[MBOX_REG_COUNT]; |
| 627 | uint32_t mbox_sts[MBOX_REG_COUNT]; |
| 628 | |
| 629 | /* Make sure the device index is valid */ |
| 630 | if (fw_ddb_index >= MAX_DDB_ENTRIES) { |
Vikas Chaudhary | f4f5df2 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 631 | DEBUG2(printk("scsi%ld: %s: ddb [%d] out of range.\n", |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 632 | ha->host_no, __func__, fw_ddb_index)); |
| 633 | goto exit_get_fwddb; |
| 634 | } |
| 635 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); |
| 636 | memset(&mbox_sts, 0, sizeof(mbox_sts)); |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 637 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 638 | mbox_cmd[0] = MBOX_CMD_GET_DATABASE_ENTRY; |
| 639 | mbox_cmd[1] = (uint32_t) fw_ddb_index; |
| 640 | mbox_cmd[2] = LSDW(fw_ddb_entry_dma); |
| 641 | mbox_cmd[3] = MSDW(fw_ddb_entry_dma); |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 642 | mbox_cmd[4] = sizeof(struct dev_db_entry); |
| 643 | |
| 644 | if (qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 7, &mbox_cmd[0], &mbox_sts[0]) == |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 645 | QLA_ERROR) { |
| 646 | DEBUG2(printk("scsi%ld: %s: MBOX_CMD_GET_DATABASE_ENTRY failed" |
| 647 | " with status 0x%04X\n", ha->host_no, __func__, |
| 648 | mbox_sts[0])); |
| 649 | goto exit_get_fwddb; |
| 650 | } |
| 651 | if (fw_ddb_index != mbox_sts[1]) { |
Vikas Chaudhary | f4f5df2 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 652 | DEBUG2(printk("scsi%ld: %s: ddb mismatch [%d] != [%d].\n", |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 653 | ha->host_no, __func__, fw_ddb_index, |
| 654 | mbox_sts[1])); |
| 655 | goto exit_get_fwddb; |
| 656 | } |
| 657 | if (fw_ddb_entry) { |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 658 | options = le16_to_cpu(fw_ddb_entry->options); |
| 659 | if (options & DDB_OPT_IPV6_DEVICE) { |
Vikas Chaudhary | c2660df | 2010-07-10 14:51:02 +0530 | [diff] [blame] | 660 | ql4_printk(KERN_INFO, ha, "%s: DDB[%d] MB0 %04x Tot %d " |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 661 | "Next %d State %04x ConnErr %08x %pI6 " |
| 662 | ":%04d \"%s\"\n", __func__, fw_ddb_index, |
| 663 | mbox_sts[0], mbox_sts[2], mbox_sts[3], |
| 664 | mbox_sts[4], mbox_sts[5], |
| 665 | fw_ddb_entry->ip_addr, |
| 666 | le16_to_cpu(fw_ddb_entry->port), |
| 667 | fw_ddb_entry->iscsi_name); |
| 668 | } else { |
Vikas Chaudhary | c2660df | 2010-07-10 14:51:02 +0530 | [diff] [blame] | 669 | ql4_printk(KERN_INFO, ha, "%s: DDB[%d] MB0 %04x Tot %d " |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 670 | "Next %d State %04x ConnErr %08x %pI4 " |
| 671 | ":%04d \"%s\"\n", __func__, fw_ddb_index, |
| 672 | mbox_sts[0], mbox_sts[2], mbox_sts[3], |
| 673 | mbox_sts[4], mbox_sts[5], |
| 674 | fw_ddb_entry->ip_addr, |
| 675 | le16_to_cpu(fw_ddb_entry->port), |
| 676 | fw_ddb_entry->iscsi_name); |
| 677 | } |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 678 | } |
| 679 | if (num_valid_ddb_entries) |
| 680 | *num_valid_ddb_entries = mbox_sts[2]; |
| 681 | if (next_ddb_index) |
| 682 | *next_ddb_index = mbox_sts[3]; |
| 683 | if (fw_ddb_device_state) |
| 684 | *fw_ddb_device_state = mbox_sts[4]; |
| 685 | |
| 686 | /* |
| 687 | * RA: This mailbox has been changed to pass connection error and |
| 688 | * details. Its true for ISP4010 as per Version E - Not sure when it |
| 689 | * was changed. Get the time2wait from the fw_dd_entry field : |
| 690 | * default_time2wait which we call it as minTime2Wait DEV_DB_ENTRY |
| 691 | * struct. |
| 692 | */ |
| 693 | if (conn_err_detail) |
| 694 | *conn_err_detail = mbox_sts[5]; |
| 695 | if (tcp_source_port_num) |
Randy Dunlap | 1482338 | 2010-04-22 11:02:14 -0700 | [diff] [blame] | 696 | *tcp_source_port_num = (uint16_t) (mbox_sts[6] >> 16); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 697 | if (connection_id) |
| 698 | *connection_id = (uint16_t) mbox_sts[6] & 0x00FF; |
| 699 | status = QLA_SUCCESS; |
| 700 | |
| 701 | exit_get_fwddb: |
| 702 | return status; |
| 703 | } |
| 704 | |
| 705 | /** |
| 706 | * qla4xxx_set_fwddb_entry - sets a ddb entry. |
| 707 | * @ha: Pointer to host adapter structure. |
| 708 | * @fw_ddb_index: Firmware's device database index |
| 709 | * @fw_ddb_entry: Pointer to firmware's ddb entry structure, or NULL. |
| 710 | * |
| 711 | * This routine initializes or updates the adapter's device database |
| 712 | * entry for the specified device. It also triggers a login for the |
| 713 | * specified device. Therefore, it may also be used as a secondary |
| 714 | * login routine when a NULL pointer is specified for the fw_ddb_entry. |
| 715 | **/ |
| 716 | int qla4xxx_set_ddb_entry(struct scsi_qla_host * ha, uint16_t fw_ddb_index, |
| 717 | dma_addr_t fw_ddb_entry_dma) |
| 718 | { |
| 719 | uint32_t mbox_cmd[MBOX_REG_COUNT]; |
| 720 | uint32_t mbox_sts[MBOX_REG_COUNT]; |
Vikas Chaudhary | f4f5df2 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 721 | int status; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 722 | |
| 723 | /* Do not wait for completion. The firmware will send us an |
| 724 | * ASTS_DATABASE_CHANGED (0x8014) to notify us of the login status. |
| 725 | */ |
| 726 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); |
| 727 | memset(&mbox_sts, 0, sizeof(mbox_sts)); |
| 728 | |
| 729 | mbox_cmd[0] = MBOX_CMD_SET_DATABASE_ENTRY; |
| 730 | mbox_cmd[1] = (uint32_t) fw_ddb_index; |
| 731 | mbox_cmd[2] = LSDW(fw_ddb_entry_dma); |
| 732 | mbox_cmd[3] = MSDW(fw_ddb_entry_dma); |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 733 | mbox_cmd[4] = sizeof(struct dev_db_entry); |
| 734 | |
Vikas Chaudhary | f4f5df2 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 735 | status = qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 5, &mbox_cmd[0], |
| 736 | &mbox_sts[0]); |
| 737 | DEBUG2(printk("scsi%ld: %s: status=%d mbx0=0x%x mbx4=0x%x\n", |
| 738 | ha->host_no, __func__, status, mbox_sts[0], mbox_sts[4]);) |
| 739 | |
| 740 | return status; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 741 | } |
| 742 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 743 | /** |
| 744 | * qla4xxx_get_crash_record - retrieves crash record. |
| 745 | * @ha: Pointer to host adapter structure. |
| 746 | * |
| 747 | * This routine retrieves a crash record from the QLA4010 after an 8002h aen. |
| 748 | **/ |
| 749 | void qla4xxx_get_crash_record(struct scsi_qla_host * ha) |
| 750 | { |
| 751 | uint32_t mbox_cmd[MBOX_REG_COUNT]; |
| 752 | uint32_t mbox_sts[MBOX_REG_COUNT]; |
| 753 | struct crash_record *crash_record = NULL; |
| 754 | dma_addr_t crash_record_dma = 0; |
| 755 | uint32_t crash_record_size = 0; |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 756 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 757 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); |
| 758 | memset(&mbox_sts, 0, sizeof(mbox_cmd)); |
| 759 | |
| 760 | /* Get size of crash record. */ |
| 761 | mbox_cmd[0] = MBOX_CMD_GET_CRASH_RECORD; |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 762 | |
| 763 | if (qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 5, &mbox_cmd[0], &mbox_sts[0]) != |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 764 | QLA_SUCCESS) { |
| 765 | DEBUG2(printk("scsi%ld: %s: ERROR: Unable to retrieve size!\n", |
| 766 | ha->host_no, __func__)); |
| 767 | goto exit_get_crash_record; |
| 768 | } |
| 769 | crash_record_size = mbox_sts[4]; |
| 770 | if (crash_record_size == 0) { |
| 771 | DEBUG2(printk("scsi%ld: %s: ERROR: Crash record size is 0!\n", |
| 772 | ha->host_no, __func__)); |
| 773 | goto exit_get_crash_record; |
| 774 | } |
| 775 | |
| 776 | /* Alloc Memory for Crash Record. */ |
| 777 | crash_record = dma_alloc_coherent(&ha->pdev->dev, crash_record_size, |
| 778 | &crash_record_dma, GFP_KERNEL); |
| 779 | if (crash_record == NULL) |
| 780 | goto exit_get_crash_record; |
| 781 | |
| 782 | /* Get Crash Record. */ |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 783 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); |
| 784 | memset(&mbox_sts, 0, sizeof(mbox_cmd)); |
| 785 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 786 | mbox_cmd[0] = MBOX_CMD_GET_CRASH_RECORD; |
| 787 | mbox_cmd[2] = LSDW(crash_record_dma); |
| 788 | mbox_cmd[3] = MSDW(crash_record_dma); |
| 789 | mbox_cmd[4] = crash_record_size; |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 790 | |
| 791 | if (qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 5, &mbox_cmd[0], &mbox_sts[0]) != |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 792 | QLA_SUCCESS) |
| 793 | goto exit_get_crash_record; |
| 794 | |
| 795 | /* Dump Crash Record. */ |
| 796 | |
| 797 | exit_get_crash_record: |
| 798 | if (crash_record) |
| 799 | dma_free_coherent(&ha->pdev->dev, crash_record_size, |
| 800 | crash_record, crash_record_dma); |
| 801 | } |
| 802 | |
| 803 | /** |
| 804 | * qla4xxx_get_conn_event_log - retrieves connection event log |
| 805 | * @ha: Pointer to host adapter structure. |
| 806 | **/ |
| 807 | void qla4xxx_get_conn_event_log(struct scsi_qla_host * ha) |
| 808 | { |
| 809 | uint32_t mbox_cmd[MBOX_REG_COUNT]; |
| 810 | uint32_t mbox_sts[MBOX_REG_COUNT]; |
| 811 | struct conn_event_log_entry *event_log = NULL; |
| 812 | dma_addr_t event_log_dma = 0; |
| 813 | uint32_t event_log_size = 0; |
| 814 | uint32_t num_valid_entries; |
| 815 | uint32_t oldest_entry = 0; |
| 816 | uint32_t max_event_log_entries; |
| 817 | uint8_t i; |
| 818 | |
| 819 | |
| 820 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); |
| 821 | memset(&mbox_sts, 0, sizeof(mbox_cmd)); |
| 822 | |
| 823 | /* Get size of crash record. */ |
| 824 | mbox_cmd[0] = MBOX_CMD_GET_CONN_EVENT_LOG; |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 825 | |
| 826 | if (qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 5, &mbox_cmd[0], &mbox_sts[0]) != |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 827 | QLA_SUCCESS) |
| 828 | goto exit_get_event_log; |
| 829 | |
| 830 | event_log_size = mbox_sts[4]; |
| 831 | if (event_log_size == 0) |
| 832 | goto exit_get_event_log; |
| 833 | |
| 834 | /* Alloc Memory for Crash Record. */ |
| 835 | event_log = dma_alloc_coherent(&ha->pdev->dev, event_log_size, |
| 836 | &event_log_dma, GFP_KERNEL); |
| 837 | if (event_log == NULL) |
| 838 | goto exit_get_event_log; |
| 839 | |
| 840 | /* Get Crash Record. */ |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 841 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); |
| 842 | memset(&mbox_sts, 0, sizeof(mbox_cmd)); |
| 843 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 844 | mbox_cmd[0] = MBOX_CMD_GET_CONN_EVENT_LOG; |
| 845 | mbox_cmd[2] = LSDW(event_log_dma); |
| 846 | mbox_cmd[3] = MSDW(event_log_dma); |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 847 | |
| 848 | if (qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 5, &mbox_cmd[0], &mbox_sts[0]) != |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 849 | QLA_SUCCESS) { |
| 850 | DEBUG2(printk("scsi%ld: %s: ERROR: Unable to retrieve event " |
| 851 | "log!\n", ha->host_no, __func__)); |
| 852 | goto exit_get_event_log; |
| 853 | } |
| 854 | |
| 855 | /* Dump Event Log. */ |
| 856 | num_valid_entries = mbox_sts[1]; |
| 857 | |
| 858 | max_event_log_entries = event_log_size / |
| 859 | sizeof(struct conn_event_log_entry); |
| 860 | |
| 861 | if (num_valid_entries > max_event_log_entries) |
| 862 | oldest_entry = num_valid_entries % max_event_log_entries; |
| 863 | |
| 864 | DEBUG3(printk("scsi%ld: Connection Event Log Dump (%d entries):\n", |
| 865 | ha->host_no, num_valid_entries)); |
| 866 | |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 867 | if (ql4xextended_error_logging == 3) { |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 868 | if (oldest_entry == 0) { |
| 869 | /* Circular Buffer has not wrapped around */ |
| 870 | for (i=0; i < num_valid_entries; i++) { |
| 871 | qla4xxx_dump_buffer((uint8_t *)event_log+ |
| 872 | (i*sizeof(*event_log)), |
| 873 | sizeof(*event_log)); |
| 874 | } |
| 875 | } |
| 876 | else { |
| 877 | /* Circular Buffer has wrapped around - |
| 878 | * display accordingly*/ |
| 879 | for (i=oldest_entry; i < max_event_log_entries; i++) { |
| 880 | qla4xxx_dump_buffer((uint8_t *)event_log+ |
| 881 | (i*sizeof(*event_log)), |
| 882 | sizeof(*event_log)); |
| 883 | } |
| 884 | for (i=0; i < oldest_entry; i++) { |
| 885 | qla4xxx_dump_buffer((uint8_t *)event_log+ |
| 886 | (i*sizeof(*event_log)), |
| 887 | sizeof(*event_log)); |
| 888 | } |
| 889 | } |
| 890 | } |
| 891 | |
| 892 | exit_get_event_log: |
| 893 | if (event_log) |
| 894 | dma_free_coherent(&ha->pdev->dev, event_log_size, event_log, |
| 895 | event_log_dma); |
| 896 | } |
| 897 | |
| 898 | /** |
Vikas Chaudhary | 09a0f71 | 2010-04-28 11:42:24 +0530 | [diff] [blame] | 899 | * qla4xxx_abort_task - issues Abort Task |
| 900 | * @ha: Pointer to host adapter structure. |
| 901 | * @srb: Pointer to srb entry |
| 902 | * |
| 903 | * This routine performs a LUN RESET on the specified target/lun. |
| 904 | * The caller must ensure that the ddb_entry and lun_entry pointers |
| 905 | * are valid before calling this routine. |
| 906 | **/ |
| 907 | int qla4xxx_abort_task(struct scsi_qla_host *ha, struct srb *srb) |
| 908 | { |
| 909 | uint32_t mbox_cmd[MBOX_REG_COUNT]; |
| 910 | uint32_t mbox_sts[MBOX_REG_COUNT]; |
| 911 | struct scsi_cmnd *cmd = srb->cmd; |
| 912 | int status = QLA_SUCCESS; |
| 913 | unsigned long flags = 0; |
| 914 | uint32_t index; |
| 915 | |
| 916 | /* |
| 917 | * Send abort task command to ISP, so that the ISP will return |
| 918 | * request with ABORT status |
| 919 | */ |
| 920 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); |
| 921 | memset(&mbox_sts, 0, sizeof(mbox_sts)); |
| 922 | |
| 923 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 924 | index = (unsigned long)(unsigned char *)cmd->host_scribble; |
| 925 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 926 | |
| 927 | /* Firmware already posted completion on response queue */ |
| 928 | if (index == MAX_SRBS) |
| 929 | return status; |
| 930 | |
| 931 | mbox_cmd[0] = MBOX_CMD_ABORT_TASK; |
Karen Higgins | 6790d4f | 2010-12-02 22:12:22 -0800 | [diff] [blame] | 932 | mbox_cmd[1] = srb->ddb->fw_ddb_index; |
Vikas Chaudhary | 09a0f71 | 2010-04-28 11:42:24 +0530 | [diff] [blame] | 933 | mbox_cmd[2] = index; |
| 934 | /* Immediate Command Enable */ |
| 935 | mbox_cmd[5] = 0x01; |
| 936 | |
| 937 | qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 5, &mbox_cmd[0], |
| 938 | &mbox_sts[0]); |
| 939 | if (mbox_sts[0] != MBOX_STS_COMMAND_COMPLETE) { |
| 940 | status = QLA_ERROR; |
| 941 | |
| 942 | DEBUG2(printk(KERN_WARNING "scsi%ld:%d:%d: abort task FAILED: " |
| 943 | "mbx0=%04X, mb1=%04X, mb2=%04X, mb3=%04X, mb4=%04X\n", |
| 944 | ha->host_no, cmd->device->id, cmd->device->lun, mbox_sts[0], |
| 945 | mbox_sts[1], mbox_sts[2], mbox_sts[3], mbox_sts[4])); |
| 946 | } |
| 947 | |
| 948 | return status; |
| 949 | } |
| 950 | |
| 951 | /** |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 952 | * qla4xxx_reset_lun - issues LUN Reset |
| 953 | * @ha: Pointer to host adapter structure. |
Vikas Chaudhary | f4f5df2 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 954 | * @ddb_entry: Pointer to device database entry |
| 955 | * @lun: lun number |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 956 | * |
| 957 | * This routine performs a LUN RESET on the specified target/lun. |
| 958 | * The caller must ensure that the ddb_entry and lun_entry pointers |
| 959 | * are valid before calling this routine. |
| 960 | **/ |
| 961 | int qla4xxx_reset_lun(struct scsi_qla_host * ha, struct ddb_entry * ddb_entry, |
| 962 | int lun) |
| 963 | { |
| 964 | uint32_t mbox_cmd[MBOX_REG_COUNT]; |
| 965 | uint32_t mbox_sts[MBOX_REG_COUNT]; |
| 966 | int status = QLA_SUCCESS; |
| 967 | |
| 968 | DEBUG2(printk("scsi%ld:%d:%d: lun reset issued\n", ha->host_no, |
Vikas Chaudhary | f4f5df2 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 969 | ddb_entry->fw_ddb_index, lun)); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 970 | |
| 971 | /* |
| 972 | * Send lun reset command to ISP, so that the ISP will return all |
| 973 | * outstanding requests with RESET status |
| 974 | */ |
| 975 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); |
| 976 | memset(&mbox_sts, 0, sizeof(mbox_sts)); |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 977 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 978 | mbox_cmd[0] = MBOX_CMD_LUN_RESET; |
| 979 | mbox_cmd[1] = ddb_entry->fw_ddb_index; |
| 980 | mbox_cmd[2] = lun << 8; |
| 981 | mbox_cmd[5] = 0x01; /* Immediate Command Enable */ |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 982 | |
| 983 | qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 1, &mbox_cmd[0], &mbox_sts[0]); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 984 | if (mbox_sts[0] != MBOX_STS_COMMAND_COMPLETE && |
| 985 | mbox_sts[0] != MBOX_STS_COMMAND_ERROR) |
| 986 | status = QLA_ERROR; |
| 987 | |
| 988 | return status; |
| 989 | } |
| 990 | |
Mike Christie | ce54503 | 2008-02-29 18:25:20 -0600 | [diff] [blame] | 991 | /** |
| 992 | * qla4xxx_reset_target - issues target Reset |
| 993 | * @ha: Pointer to host adapter structure. |
| 994 | * @db_entry: Pointer to device database entry |
| 995 | * @un_entry: Pointer to lun entry structure |
| 996 | * |
| 997 | * This routine performs a TARGET RESET on the specified target. |
| 998 | * The caller must ensure that the ddb_entry pointers |
| 999 | * are valid before calling this routine. |
| 1000 | **/ |
| 1001 | int qla4xxx_reset_target(struct scsi_qla_host *ha, |
| 1002 | struct ddb_entry *ddb_entry) |
| 1003 | { |
| 1004 | uint32_t mbox_cmd[MBOX_REG_COUNT]; |
| 1005 | uint32_t mbox_sts[MBOX_REG_COUNT]; |
| 1006 | int status = QLA_SUCCESS; |
| 1007 | |
| 1008 | DEBUG2(printk("scsi%ld:%d: target reset issued\n", ha->host_no, |
Vikas Chaudhary | f4f5df2 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 1009 | ddb_entry->fw_ddb_index)); |
Mike Christie | ce54503 | 2008-02-29 18:25:20 -0600 | [diff] [blame] | 1010 | |
| 1011 | /* |
| 1012 | * Send target reset command to ISP, so that the ISP will return all |
| 1013 | * outstanding requests with RESET status |
| 1014 | */ |
| 1015 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); |
| 1016 | memset(&mbox_sts, 0, sizeof(mbox_sts)); |
| 1017 | |
| 1018 | mbox_cmd[0] = MBOX_CMD_TARGET_WARM_RESET; |
| 1019 | mbox_cmd[1] = ddb_entry->fw_ddb_index; |
| 1020 | mbox_cmd[5] = 0x01; /* Immediate Command Enable */ |
| 1021 | |
| 1022 | qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 1, &mbox_cmd[0], |
| 1023 | &mbox_sts[0]); |
| 1024 | if (mbox_sts[0] != MBOX_STS_COMMAND_COMPLETE && |
| 1025 | mbox_sts[0] != MBOX_STS_COMMAND_ERROR) |
| 1026 | status = QLA_ERROR; |
| 1027 | |
| 1028 | return status; |
| 1029 | } |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1030 | |
| 1031 | int qla4xxx_get_flash(struct scsi_qla_host * ha, dma_addr_t dma_addr, |
| 1032 | uint32_t offset, uint32_t len) |
| 1033 | { |
| 1034 | uint32_t mbox_cmd[MBOX_REG_COUNT]; |
| 1035 | uint32_t mbox_sts[MBOX_REG_COUNT]; |
| 1036 | |
| 1037 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); |
| 1038 | memset(&mbox_sts, 0, sizeof(mbox_sts)); |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 1039 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1040 | mbox_cmd[0] = MBOX_CMD_READ_FLASH; |
| 1041 | mbox_cmd[1] = LSDW(dma_addr); |
| 1042 | mbox_cmd[2] = MSDW(dma_addr); |
| 1043 | mbox_cmd[3] = offset; |
| 1044 | mbox_cmd[4] = len; |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 1045 | |
| 1046 | if (qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 2, &mbox_cmd[0], &mbox_sts[0]) != |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1047 | QLA_SUCCESS) { |
| 1048 | DEBUG2(printk("scsi%ld: %s: MBOX_CMD_READ_FLASH, failed w/ " |
| 1049 | "status %04X %04X, offset %08x, len %08x\n", ha->host_no, |
| 1050 | __func__, mbox_sts[0], mbox_sts[1], offset, len)); |
| 1051 | return QLA_ERROR; |
| 1052 | } |
| 1053 | return QLA_SUCCESS; |
| 1054 | } |
| 1055 | |
| 1056 | /** |
Harish Zunjarrao | 7ad633c | 2011-05-17 23:17:11 -0700 | [diff] [blame] | 1057 | * qla4xxx_about_firmware - gets FW, iscsi draft and boot loader version |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1058 | * @ha: Pointer to host adapter structure. |
| 1059 | * |
Harish Zunjarrao | 7ad633c | 2011-05-17 23:17:11 -0700 | [diff] [blame] | 1060 | * Retrieves the FW version, iSCSI draft version & bootloader version of HBA. |
| 1061 | * Mailboxes 2 & 3 may hold an address for data. Make sure that we write 0 to |
| 1062 | * those mailboxes, if unused. |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1063 | **/ |
Harish Zunjarrao | 7ad633c | 2011-05-17 23:17:11 -0700 | [diff] [blame] | 1064 | int qla4xxx_about_firmware(struct scsi_qla_host *ha) |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1065 | { |
Harish Zunjarrao | 7ad633c | 2011-05-17 23:17:11 -0700 | [diff] [blame] | 1066 | struct about_fw_info *about_fw = NULL; |
| 1067 | dma_addr_t about_fw_dma; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1068 | uint32_t mbox_cmd[MBOX_REG_COUNT]; |
| 1069 | uint32_t mbox_sts[MBOX_REG_COUNT]; |
Harish Zunjarrao | 7ad633c | 2011-05-17 23:17:11 -0700 | [diff] [blame] | 1070 | int status = QLA_ERROR; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1071 | |
Harish Zunjarrao | 7ad633c | 2011-05-17 23:17:11 -0700 | [diff] [blame] | 1072 | about_fw = dma_alloc_coherent(&ha->pdev->dev, |
| 1073 | sizeof(struct about_fw_info), |
| 1074 | &about_fw_dma, GFP_KERNEL); |
| 1075 | if (!about_fw) { |
| 1076 | DEBUG2(ql4_printk(KERN_ERR, ha, "%s: Unable to alloc memory " |
| 1077 | "for about_fw\n", __func__)); |
| 1078 | return status; |
| 1079 | } |
| 1080 | |
| 1081 | memset(about_fw, 0, sizeof(struct about_fw_info)); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1082 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); |
| 1083 | memset(&mbox_sts, 0, sizeof(mbox_sts)); |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 1084 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1085 | mbox_cmd[0] = MBOX_CMD_ABOUT_FW; |
Harish Zunjarrao | 7ad633c | 2011-05-17 23:17:11 -0700 | [diff] [blame] | 1086 | mbox_cmd[2] = LSDW(about_fw_dma); |
| 1087 | mbox_cmd[3] = MSDW(about_fw_dma); |
| 1088 | mbox_cmd[4] = sizeof(struct about_fw_info); |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 1089 | |
Harish Zunjarrao | 7ad633c | 2011-05-17 23:17:11 -0700 | [diff] [blame] | 1090 | status = qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, MBOX_REG_COUNT, |
| 1091 | &mbox_cmd[0], &mbox_sts[0]); |
| 1092 | if (status != QLA_SUCCESS) { |
| 1093 | DEBUG2(ql4_printk(KERN_WARNING, ha, "%s: MBOX_CMD_ABOUT_FW " |
| 1094 | "failed w/ status %04X\n", __func__, |
| 1095 | mbox_sts[0])); |
| 1096 | goto exit_about_fw; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1097 | } |
| 1098 | |
Harish Zunjarrao | 7ad633c | 2011-05-17 23:17:11 -0700 | [diff] [blame] | 1099 | /* Save version information. */ |
| 1100 | ha->firmware_version[0] = le16_to_cpu(about_fw->fw_major); |
| 1101 | ha->firmware_version[1] = le16_to_cpu(about_fw->fw_minor); |
| 1102 | ha->patch_number = le16_to_cpu(about_fw->fw_patch); |
| 1103 | ha->build_number = le16_to_cpu(about_fw->fw_build); |
| 1104 | ha->iscsi_major = le16_to_cpu(about_fw->iscsi_major); |
| 1105 | ha->iscsi_minor = le16_to_cpu(about_fw->iscsi_minor); |
| 1106 | ha->bootload_major = le16_to_cpu(about_fw->bootload_major); |
| 1107 | ha->bootload_minor = le16_to_cpu(about_fw->bootload_minor); |
| 1108 | ha->bootload_patch = le16_to_cpu(about_fw->bootload_patch); |
| 1109 | ha->bootload_build = le16_to_cpu(about_fw->bootload_build); |
| 1110 | status = QLA_SUCCESS; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1111 | |
Harish Zunjarrao | 7ad633c | 2011-05-17 23:17:11 -0700 | [diff] [blame] | 1112 | exit_about_fw: |
| 1113 | dma_free_coherent(&ha->pdev->dev, sizeof(struct about_fw_info), |
| 1114 | about_fw, about_fw_dma); |
| 1115 | return status; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1116 | } |
| 1117 | |
Adrian Bunk | 4797547 | 2007-04-26 00:35:16 -0700 | [diff] [blame] | 1118 | static int qla4xxx_get_default_ddb(struct scsi_qla_host *ha, |
| 1119 | dma_addr_t dma_addr) |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1120 | { |
| 1121 | uint32_t mbox_cmd[MBOX_REG_COUNT]; |
| 1122 | uint32_t mbox_sts[MBOX_REG_COUNT]; |
| 1123 | |
| 1124 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); |
| 1125 | memset(&mbox_sts, 0, sizeof(mbox_sts)); |
| 1126 | |
| 1127 | mbox_cmd[0] = MBOX_CMD_GET_DATABASE_ENTRY_DEFAULTS; |
| 1128 | mbox_cmd[2] = LSDW(dma_addr); |
| 1129 | mbox_cmd[3] = MSDW(dma_addr); |
| 1130 | |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 1131 | if (qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 1, &mbox_cmd[0], &mbox_sts[0]) != |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1132 | QLA_SUCCESS) { |
| 1133 | DEBUG2(printk("scsi%ld: %s: failed status %04X\n", |
| 1134 | ha->host_no, __func__, mbox_sts[0])); |
| 1135 | return QLA_ERROR; |
| 1136 | } |
| 1137 | return QLA_SUCCESS; |
| 1138 | } |
| 1139 | |
Adrian Bunk | 4797547 | 2007-04-26 00:35:16 -0700 | [diff] [blame] | 1140 | static int qla4xxx_req_ddb_entry(struct scsi_qla_host *ha, uint32_t *ddb_index) |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1141 | { |
| 1142 | uint32_t mbox_cmd[MBOX_REG_COUNT]; |
| 1143 | uint32_t mbox_sts[MBOX_REG_COUNT]; |
| 1144 | |
| 1145 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); |
| 1146 | memset(&mbox_sts, 0, sizeof(mbox_sts)); |
| 1147 | |
| 1148 | mbox_cmd[0] = MBOX_CMD_REQUEST_DATABASE_ENTRY; |
| 1149 | mbox_cmd[1] = MAX_PRST_DEV_DB_ENTRIES; |
| 1150 | |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 1151 | if (qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 3, &mbox_cmd[0], &mbox_sts[0]) != |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1152 | QLA_SUCCESS) { |
| 1153 | if (mbox_sts[0] == MBOX_STS_COMMAND_ERROR) { |
| 1154 | *ddb_index = mbox_sts[2]; |
| 1155 | } else { |
| 1156 | DEBUG2(printk("scsi%ld: %s: failed status %04X\n", |
| 1157 | ha->host_no, __func__, mbox_sts[0])); |
| 1158 | return QLA_ERROR; |
| 1159 | } |
| 1160 | } else { |
| 1161 | *ddb_index = MAX_PRST_DEV_DB_ENTRIES; |
| 1162 | } |
| 1163 | |
| 1164 | return QLA_SUCCESS; |
| 1165 | } |
| 1166 | |
| 1167 | |
| 1168 | int qla4xxx_send_tgts(struct scsi_qla_host *ha, char *ip, uint16_t port) |
| 1169 | { |
| 1170 | struct dev_db_entry *fw_ddb_entry; |
| 1171 | dma_addr_t fw_ddb_entry_dma; |
| 1172 | uint32_t ddb_index; |
| 1173 | int ret_val = QLA_SUCCESS; |
| 1174 | |
| 1175 | |
| 1176 | fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, |
| 1177 | sizeof(*fw_ddb_entry), |
| 1178 | &fw_ddb_entry_dma, GFP_KERNEL); |
| 1179 | if (!fw_ddb_entry) { |
| 1180 | DEBUG2(printk("scsi%ld: %s: Unable to allocate dma buffer.\n", |
| 1181 | ha->host_no, __func__)); |
| 1182 | ret_val = QLA_ERROR; |
Prasanna Mumbai | beabe7c | 2010-07-10 14:49:38 +0530 | [diff] [blame] | 1183 | goto exit_send_tgts_no_free; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1184 | } |
| 1185 | |
| 1186 | ret_val = qla4xxx_get_default_ddb(ha, fw_ddb_entry_dma); |
| 1187 | if (ret_val != QLA_SUCCESS) |
Prasanna Mumbai | beabe7c | 2010-07-10 14:49:38 +0530 | [diff] [blame] | 1188 | goto exit_send_tgts; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1189 | |
| 1190 | ret_val = qla4xxx_req_ddb_entry(ha, &ddb_index); |
| 1191 | if (ret_val != QLA_SUCCESS) |
Prasanna Mumbai | beabe7c | 2010-07-10 14:49:38 +0530 | [diff] [blame] | 1192 | goto exit_send_tgts; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1193 | |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 1194 | memset(fw_ddb_entry->iscsi_alias, 0, |
| 1195 | sizeof(fw_ddb_entry->iscsi_alias)); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1196 | |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 1197 | memset(fw_ddb_entry->iscsi_name, 0, |
| 1198 | sizeof(fw_ddb_entry->iscsi_name)); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1199 | |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 1200 | memset(fw_ddb_entry->ip_addr, 0, sizeof(fw_ddb_entry->ip_addr)); |
| 1201 | memset(fw_ddb_entry->tgt_addr, 0, |
| 1202 | sizeof(fw_ddb_entry->tgt_addr)); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1203 | |
| 1204 | fw_ddb_entry->options = (DDB_OPT_DISC_SESSION | DDB_OPT_TARGET); |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 1205 | fw_ddb_entry->port = cpu_to_le16(ntohs(port)); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1206 | |
David C Somayajulu | c0e344c | 2007-05-23 18:03:27 -0700 | [diff] [blame] | 1207 | fw_ddb_entry->ip_addr[0] = *ip; |
| 1208 | fw_ddb_entry->ip_addr[1] = *(ip + 1); |
| 1209 | fw_ddb_entry->ip_addr[2] = *(ip + 2); |
| 1210 | fw_ddb_entry->ip_addr[3] = *(ip + 3); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1211 | |
| 1212 | ret_val = qla4xxx_set_ddb_entry(ha, ddb_index, fw_ddb_entry_dma); |
| 1213 | |
Prasanna Mumbai | beabe7c | 2010-07-10 14:49:38 +0530 | [diff] [blame] | 1214 | exit_send_tgts: |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1215 | dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), |
| 1216 | fw_ddb_entry, fw_ddb_entry_dma); |
Prasanna Mumbai | beabe7c | 2010-07-10 14:49:38 +0530 | [diff] [blame] | 1217 | exit_send_tgts_no_free: |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 1218 | return ret_val; |
| 1219 | } |
| 1220 | |
Mike Christie | d00efe3 | 2011-07-25 13:48:38 -0500 | [diff] [blame] | 1221 | int qla4xxx_set_flash(struct scsi_qla_host *ha, dma_addr_t dma_addr, |
| 1222 | uint32_t offset, uint32_t length, uint32_t options) |
| 1223 | { |
| 1224 | uint32_t mbox_cmd[MBOX_REG_COUNT]; |
| 1225 | uint32_t mbox_sts[MBOX_REG_COUNT]; |
| 1226 | int status = QLA_SUCCESS; |
| 1227 | |
| 1228 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); |
| 1229 | memset(&mbox_sts, 0, sizeof(mbox_sts)); |
| 1230 | |
| 1231 | mbox_cmd[0] = MBOX_CMD_WRITE_FLASH; |
| 1232 | mbox_cmd[1] = LSDW(dma_addr); |
| 1233 | mbox_cmd[2] = MSDW(dma_addr); |
| 1234 | mbox_cmd[3] = offset; |
| 1235 | mbox_cmd[4] = length; |
| 1236 | mbox_cmd[5] = options; |
| 1237 | |
| 1238 | status = qla4xxx_mailbox_command(ha, 6, 2, &mbox_cmd[0], &mbox_sts[0]); |
| 1239 | if (status != QLA_SUCCESS) { |
| 1240 | DEBUG2(ql4_printk(KERN_WARNING, ha, "%s: MBOX_CMD_WRITE_FLASH " |
| 1241 | "failed w/ status %04X, mbx1 %04X\n", |
| 1242 | __func__, mbox_sts[0], mbox_sts[1])); |
| 1243 | } |
| 1244 | return status; |
| 1245 | } |
| 1246 | |
| 1247 | int qla4xxx_conn_close_sess_logout(struct scsi_qla_host *ha, |
| 1248 | uint16_t fw_ddb_index, |
| 1249 | uint16_t connection_id, |
| 1250 | uint16_t option) |
| 1251 | { |
| 1252 | uint32_t mbox_cmd[MBOX_REG_COUNT]; |
| 1253 | uint32_t mbox_sts[MBOX_REG_COUNT]; |
| 1254 | int status = QLA_SUCCESS; |
| 1255 | |
| 1256 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); |
| 1257 | memset(&mbox_sts, 0, sizeof(mbox_sts)); |
| 1258 | |
| 1259 | mbox_cmd[0] = MBOX_CMD_CONN_CLOSE_SESS_LOGOUT; |
| 1260 | mbox_cmd[1] = fw_ddb_index; |
| 1261 | mbox_cmd[2] = connection_id; |
| 1262 | mbox_cmd[3] = option; |
| 1263 | |
| 1264 | status = qla4xxx_mailbox_command(ha, 4, 2, &mbox_cmd[0], &mbox_sts[0]); |
| 1265 | if (status != QLA_SUCCESS) { |
| 1266 | DEBUG2(ql4_printk(KERN_WARNING, ha, "%s: MBOX_CMD_CONN_CLOSE " |
| 1267 | "option %04x failed w/ status %04X %04X\n", |
| 1268 | __func__, option, mbox_sts[0], mbox_sts[1])); |
| 1269 | } |
| 1270 | return status; |
| 1271 | } |
| 1272 | |
| 1273 | int qla4xxx_disable_acb(struct scsi_qla_host *ha) |
| 1274 | { |
| 1275 | uint32_t mbox_cmd[MBOX_REG_COUNT]; |
| 1276 | uint32_t mbox_sts[MBOX_REG_COUNT]; |
| 1277 | int status = QLA_SUCCESS; |
| 1278 | |
| 1279 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); |
| 1280 | memset(&mbox_sts, 0, sizeof(mbox_sts)); |
| 1281 | |
| 1282 | mbox_cmd[0] = MBOX_CMD_DISABLE_ACB; |
| 1283 | |
| 1284 | status = qla4xxx_mailbox_command(ha, 8, 5, &mbox_cmd[0], &mbox_sts[0]); |
| 1285 | if (status != QLA_SUCCESS) { |
| 1286 | DEBUG2(ql4_printk(KERN_WARNING, ha, "%s: MBOX_CMD_DISABLE_ACB " |
| 1287 | "failed w/ status %04X %04X %04X", __func__, |
| 1288 | mbox_sts[0], mbox_sts[1], mbox_sts[2])); |
| 1289 | } |
| 1290 | return status; |
| 1291 | } |
| 1292 | |
| 1293 | int qla4xxx_get_acb(struct scsi_qla_host *ha, uint32_t *mbox_cmd, |
| 1294 | uint32_t *mbox_sts, dma_addr_t acb_dma) |
| 1295 | { |
| 1296 | int status = QLA_SUCCESS; |
| 1297 | |
| 1298 | memset(mbox_cmd, 0, sizeof(mbox_cmd[0]) * MBOX_REG_COUNT); |
| 1299 | memset(mbox_sts, 0, sizeof(mbox_sts[0]) * MBOX_REG_COUNT); |
| 1300 | mbox_cmd[0] = MBOX_CMD_GET_ACB; |
| 1301 | mbox_cmd[1] = 0; /* Primary ACB */ |
| 1302 | mbox_cmd[2] = LSDW(acb_dma); |
| 1303 | mbox_cmd[3] = MSDW(acb_dma); |
| 1304 | mbox_cmd[4] = sizeof(struct addr_ctrl_blk); |
| 1305 | |
| 1306 | status = qla4xxx_mailbox_command(ha, 5, 5, &mbox_cmd[0], &mbox_sts[0]); |
| 1307 | if (status != QLA_SUCCESS) { |
| 1308 | DEBUG2(ql4_printk(KERN_WARNING, ha, "%s: MBOX_CMD_GET_ACB " |
| 1309 | "failed w/ status %04X\n", __func__, |
| 1310 | mbox_sts[0])); |
| 1311 | } |
| 1312 | return status; |
| 1313 | } |
| 1314 | |
| 1315 | int qla4xxx_set_acb(struct scsi_qla_host *ha, uint32_t *mbox_cmd, |
| 1316 | uint32_t *mbox_sts, dma_addr_t acb_dma) |
| 1317 | { |
| 1318 | int status = QLA_SUCCESS; |
| 1319 | |
| 1320 | memset(mbox_cmd, 0, sizeof(mbox_cmd[0]) * MBOX_REG_COUNT); |
| 1321 | memset(mbox_sts, 0, sizeof(mbox_sts[0]) * MBOX_REG_COUNT); |
| 1322 | mbox_cmd[0] = MBOX_CMD_SET_ACB; |
| 1323 | mbox_cmd[1] = 0; /* Primary ACB */ |
| 1324 | mbox_cmd[2] = LSDW(acb_dma); |
| 1325 | mbox_cmd[3] = MSDW(acb_dma); |
| 1326 | mbox_cmd[4] = sizeof(struct addr_ctrl_blk); |
| 1327 | |
| 1328 | status = qla4xxx_mailbox_command(ha, 5, 5, &mbox_cmd[0], &mbox_sts[0]); |
| 1329 | if (status != QLA_SUCCESS) { |
| 1330 | DEBUG2(ql4_printk(KERN_WARNING, ha, "%s: MBOX_CMD_SET_ACB " |
| 1331 | "failed w/ status %04X\n", __func__, |
| 1332 | mbox_sts[0])); |
| 1333 | } |
| 1334 | return status; |
| 1335 | } |