2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2008 QLogic Corporation
5 * See LICENSE.qla2xxx for copyright and licensing details.
9 #include <linux/delay.h>
13 * qla2x00_mailbox_command
14 * Issue mailbox command and waits for completion.
17 * ha = adapter block pointer.
18 * mcp = driver internal mbx struct pointer.
21 * mb[MAX_MAILBOX_REGISTER_COUNT] = returned mailbox data.
24 * 0 : QLA_SUCCESS = cmd performed success
25 * 1 : QLA_FUNCTION_FAILED (error encountered)
26 * 6 : QLA_FUNCTION_TIMEOUT (timeout condition encountered)
32 qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
35 unsigned long flags = 0;
36 device_reg_t __iomem *reg;
41 uint16_t __iomem *optr;
44 unsigned long wait_time;
45 struct qla_hw_data *ha = vha->hw;
46 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
48 if (ha->pdev->error_state > pci_channel_io_frozen)
49 return QLA_FUNCTION_TIMEOUT;
52 io_lock_on = base_vha->flags.init_done;
55 abort_active = test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
57 DEBUG11(printk("%s(%ld): entered.\n", __func__, base_vha->host_no));
60 * Wait for active mailbox commands to finish by waiting at most tov
61 * seconds. This is to serialize actual issuing of mailbox cmds during
64 if (!wait_for_completion_timeout(&ha->mbx_cmd_comp, mcp->tov * HZ)) {
65 /* Timeout occurred. Return error. */
66 DEBUG2_3_11(printk("%s(%ld): cmd access timeout. "
67 "Exiting.\n", __func__, base_vha->host_no));
68 return QLA_FUNCTION_TIMEOUT;
71 ha->flags.mbox_busy = 1;
72 /* Save mailbox command for debug */
75 DEBUG11(printk("scsi(%ld): prepare to issue mbox cmd=0x%x.\n",
76 base_vha->host_no, mcp->mb[0]));
78 spin_lock_irqsave(&ha->hardware_lock, flags);
80 /* Load mailbox registers. */
81 if (IS_FWI2_CAPABLE(ha))
82 optr = (uint16_t __iomem *)®->isp24.mailbox0;
84 optr = (uint16_t __iomem *)MAILBOX_REG(ha, ®->isp, 0);
90 for (cnt = 0; cnt < ha->mbx_count; cnt++) {
91 if (IS_QLA2200(ha) && cnt == 8)
93 (uint16_t __iomem *)MAILBOX_REG(ha, ®->isp, 8);
95 WRT_REG_WORD(optr, *iptr);
102 #if defined(QL_DEBUG_LEVEL_1)
103 printk("%s(%ld): Loaded MBX registers (displayed in bytes) = \n",
104 __func__, base_vha->host_no);
105 qla2x00_dump_buffer((uint8_t *)mcp->mb, 16);
107 qla2x00_dump_buffer(((uint8_t *)mcp->mb + 0x10), 16);
109 qla2x00_dump_buffer(((uint8_t *)mcp->mb + 0x20), 8);
111 printk("%s(%ld): I/O address = %p.\n", __func__, base_vha->host_no,
113 qla2x00_dump_regs(base_vha);
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);
120 /* Unlock mbx registers and wait for interrupt */
121 DEBUG11(printk("%s(%ld): going to unlock irq & waiting for interrupt. "
122 "jiffies=%lx.\n", __func__, base_vha->host_no, jiffies));
124 /* Wait for mbx cmd completion until timeout */
126 if ((!abort_active && io_lock_on) || IS_NOPOLLING_TYPE(ha)) {
127 set_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags);
129 if (IS_FWI2_CAPABLE(ha))
130 WRT_REG_DWORD(®->isp24.hccr, HCCRX_SET_HOST_INT);
132 WRT_REG_WORD(®->isp.hccr, HCCR_SET_HOST_INT);
133 spin_unlock_irqrestore(&ha->hardware_lock, flags);
135 wait_for_completion_timeout(&ha->mbx_intr_comp, mcp->tov * HZ);
137 clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags);
140 DEBUG3_11(printk("%s(%ld): cmd=%x POLLING MODE.\n", __func__,
141 base_vha->host_no, command));
143 if (IS_FWI2_CAPABLE(ha))
144 WRT_REG_DWORD(®->isp24.hccr, HCCRX_SET_HOST_INT);
146 WRT_REG_WORD(®->isp.hccr, HCCR_SET_HOST_INT);
147 spin_unlock_irqrestore(&ha->hardware_lock, flags);
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))
154 /* Check for pending interrupts. */
155 qla2x00_poll(ha->rsp_q_map[0]);
157 if (command != MBC_LOAD_RISC_RAM_EXTENDED &&
163 /* Check whether we timed out */
164 if (ha->flags.mbox_int) {
167 DEBUG3_11(printk("%s(%ld): cmd %x completed.\n", __func__,
168 base_vha->host_no, command));
170 /* Got interrupt. Clear the flag. */
171 ha->flags.mbox_int = 0;
172 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
174 if (ha->mailbox_out[0] != MBS_COMMAND_COMPLETE)
175 rval = QLA_FUNCTION_FAILED;
177 /* Load return mailbox registers. */
179 iptr = (uint16_t *)&ha->mailbox_out[0];
181 for (cnt = 0; cnt < ha->mbx_count; cnt++) {
191 #if defined(QL_DEBUG_LEVEL_2) || defined(QL_DEBUG_LEVEL_3) || \
192 defined(QL_DEBUG_LEVEL_11)
196 if (IS_FWI2_CAPABLE(ha)) {
197 mb0 = RD_REG_WORD(®->isp24.mailbox0);
198 ictrl = RD_REG_DWORD(®->isp24.ictrl);
200 mb0 = RD_MAILBOX_REG(ha, ®->isp, 0);
201 ictrl = RD_REG_WORD(®->isp.ictrl);
203 printk("%s(%ld): **** MB Command Timeout for cmd %x ****\n",
204 __func__, base_vha->host_no, command);
205 printk("%s(%ld): icontrol=%x jiffies=%lx\n", __func__,
206 base_vha->host_no, ictrl, jiffies);
207 printk("%s(%ld): *** mailbox[0] = 0x%x ***\n", __func__,
208 base_vha->host_no, mb0);
209 qla2x00_dump_regs(base_vha);
212 rval = QLA_FUNCTION_TIMEOUT;
215 ha->flags.mbox_busy = 0;
220 if ((abort_active || !io_lock_on) && !IS_NOPOLLING_TYPE(ha)) {
221 DEBUG11(printk("%s(%ld): checking for additional resp "
222 "interrupt.\n", __func__, base_vha->host_no));
224 /* polling mode for non isp_abort commands. */
225 qla2x00_poll(ha->rsp_q_map[0]);
228 if (rval == QLA_FUNCTION_TIMEOUT &&
229 mcp->mb[0] != MBC_GEN_SYSTEM_ERROR) {
230 if (!io_lock_on || (mcp->flags & IOCTL_CMD)) {
231 /* not in dpc. schedule it for dpc to take over. */
232 DEBUG(printk("%s(%ld): timeout schedule "
233 "isp_abort_needed.\n", __func__,
235 DEBUG2_3_11(printk("%s(%ld): timeout schedule "
236 "isp_abort_needed.\n", __func__,
238 qla_printk(KERN_WARNING, ha,
239 "Mailbox command timeout occurred. Scheduling ISP "
241 set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags);
242 qla2xxx_wake_dpc(vha);
243 } else if (!abort_active) {
244 /* call abort directly since we are in the DPC thread */
245 DEBUG(printk("%s(%ld): timeout calling abort_isp\n",
246 __func__, base_vha->host_no));
247 DEBUG2_3_11(printk("%s(%ld): timeout calling "
248 "abort_isp\n", __func__, base_vha->host_no));
249 qla_printk(KERN_WARNING, ha,
250 "Mailbox command timeout occurred. Issuing ISP "
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)) {
256 /* Failed. retry later. */
257 set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags);
259 clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
260 DEBUG(printk("%s(%ld): finished abort_isp\n", __func__,
262 DEBUG2_3_11(printk("%s(%ld): finished abort_isp\n",
263 __func__, base_vha->host_no));
267 /* Allow next mbx cmd to come in. */
268 complete(&ha->mbx_cmd_comp);
271 DEBUG2_3_11(printk("%s(%ld): **** FAILED. mbx0=%x, mbx1=%x, "
272 "mbx2=%x, cmd=%x ****\n", __func__, base_vha->host_no,
273 mcp->mb[0], mcp->mb[1], mcp->mb[2], command));
275 DEBUG11(printk("%s(%ld): done.\n", __func__,
283 qla2x00_load_ram(scsi_qla_host_t *vha, dma_addr_t req_dma, uint32_t risc_addr,
284 uint32_t risc_code_size)
287 struct qla_hw_data *ha = vha->hw;
289 mbx_cmd_t *mcp = &mc;
291 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
293 if (MSW(risc_addr) || IS_FWI2_CAPABLE(ha)) {
294 mcp->mb[0] = MBC_LOAD_RISC_RAM_EXTENDED;
295 mcp->mb[8] = MSW(risc_addr);
296 mcp->out_mb = MBX_8|MBX_0;
298 mcp->mb[0] = MBC_LOAD_RISC_RAM;
301 mcp->mb[1] = LSW(risc_addr);
302 mcp->mb[2] = MSW(req_dma);
303 mcp->mb[3] = LSW(req_dma);
304 mcp->mb[6] = MSW(MSD(req_dma));
305 mcp->mb[7] = LSW(MSD(req_dma));
306 mcp->out_mb |= MBX_7|MBX_6|MBX_3|MBX_2|MBX_1;
307 if (IS_FWI2_CAPABLE(ha)) {
308 mcp->mb[4] = MSW(risc_code_size);
309 mcp->mb[5] = LSW(risc_code_size);
310 mcp->out_mb |= MBX_5|MBX_4;
312 mcp->mb[4] = LSW(risc_code_size);
313 mcp->out_mb |= MBX_4;
317 mcp->tov = MBX_TOV_SECONDS;
319 rval = qla2x00_mailbox_command(vha, mcp);
321 if (rval != QLA_SUCCESS) {
322 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__,
323 vha->host_no, rval, mcp->mb[0]));
325 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
333 * Start adapter firmware.
336 * ha = adapter block pointer.
337 * TARGET_QUEUE_LOCK must be released.
338 * ADAPTER_STATE_LOCK must be released.
341 * qla2x00 local function return status code.
347 qla2x00_execute_fw(scsi_qla_host_t *vha, uint32_t risc_addr)
350 struct qla_hw_data *ha = vha->hw;
352 mbx_cmd_t *mcp = &mc;
354 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
356 mcp->mb[0] = MBC_EXECUTE_FIRMWARE;
359 if (IS_FWI2_CAPABLE(ha)) {
360 mcp->mb[1] = MSW(risc_addr);
361 mcp->mb[2] = LSW(risc_addr);
364 mcp->out_mb |= MBX_4|MBX_3|MBX_2|MBX_1;
367 mcp->mb[1] = LSW(risc_addr);
368 mcp->out_mb |= MBX_1;
369 if (IS_QLA2322(ha) || IS_QLA6322(ha)) {
371 mcp->out_mb |= MBX_2;
375 mcp->tov = MBX_TOV_SECONDS;
377 rval = qla2x00_mailbox_command(vha, mcp);
379 if (rval != QLA_SUCCESS) {
380 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__,
381 vha->host_no, rval, mcp->mb[0]));
383 if (IS_FWI2_CAPABLE(ha)) {
384 DEBUG11(printk("%s(%ld): done exchanges=%x.\n",
385 __func__, vha->host_no, mcp->mb[1]));
387 DEBUG11(printk("%s(%ld): done.\n", __func__,
396 * qla2x00_get_fw_version
397 * Get firmware version.
400 * ha: adapter state pointer.
401 * major: pointer for major number.
402 * minor: pointer for minor number.
403 * subminor: pointer for subminor number.
406 * qla2x00 local function return status code.
412 qla2x00_get_fw_version(scsi_qla_host_t *vha, uint16_t *major, uint16_t *minor,
413 uint16_t *subminor, uint16_t *attributes, uint32_t *memory, uint8_t *mpi,
414 uint32_t *mpi_caps, uint8_t *phy)
418 mbx_cmd_t *mcp = &mc;
420 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
422 mcp->mb[0] = MBC_GET_FIRMWARE_VERSION;
424 mcp->in_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
425 if (IS_QLA81XX(vha->hw))
426 mcp->in_mb |= MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8;
428 mcp->tov = MBX_TOV_SECONDS;
429 rval = qla2x00_mailbox_command(vha, mcp);
431 /* Return mailbox data. */
434 *subminor = mcp->mb[3];
435 *attributes = mcp->mb[6];
436 if (IS_QLA2100(vha->hw) || IS_QLA2200(vha->hw))
437 *memory = 0x1FFFF; /* Defaults to 128KB. */
439 *memory = (mcp->mb[5] << 16) | mcp->mb[4];
440 if (IS_QLA81XX(vha->hw)) {
441 mpi[0] = mcp->mb[10] & 0xff;
442 mpi[1] = mcp->mb[11] >> 8;
443 mpi[2] = mcp->mb[11] & 0xff;
444 *mpi_caps = (mcp->mb[12] << 16) | mcp->mb[13];
445 phy[0] = mcp->mb[8] & 0xff;
446 phy[1] = mcp->mb[9] >> 8;
447 phy[2] = mcp->mb[9] & 0xff;
450 if (rval != QLA_SUCCESS) {
452 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
453 vha->host_no, rval));
456 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
461 * qla2x00_get_fw_options
462 * Set firmware options.
465 * ha = adapter block pointer.
466 * fwopt = pointer for firmware options.
469 * qla2x00 local function return status code.
475 qla2x00_get_fw_options(scsi_qla_host_t *vha, uint16_t *fwopts)
479 mbx_cmd_t *mcp = &mc;
481 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
483 mcp->mb[0] = MBC_GET_FIRMWARE_OPTION;
485 mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0;
486 mcp->tov = MBX_TOV_SECONDS;
488 rval = qla2x00_mailbox_command(vha, mcp);
490 if (rval != QLA_SUCCESS) {
492 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
493 vha->host_no, rval));
495 fwopts[0] = mcp->mb[0];
496 fwopts[1] = mcp->mb[1];
497 fwopts[2] = mcp->mb[2];
498 fwopts[3] = mcp->mb[3];
500 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
508 * qla2x00_set_fw_options
509 * Set firmware options.
512 * ha = adapter block pointer.
513 * fwopt = pointer for firmware options.
516 * qla2x00 local function return status code.
522 qla2x00_set_fw_options(scsi_qla_host_t *vha, uint16_t *fwopts)
526 mbx_cmd_t *mcp = &mc;
528 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
530 mcp->mb[0] = MBC_SET_FIRMWARE_OPTION;
531 mcp->mb[1] = fwopts[1];
532 mcp->mb[2] = fwopts[2];
533 mcp->mb[3] = fwopts[3];
534 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
536 if (IS_FWI2_CAPABLE(vha->hw)) {
539 mcp->mb[10] = fwopts[10];
540 mcp->mb[11] = fwopts[11];
541 mcp->mb[12] = 0; /* Undocumented, but used */
542 mcp->out_mb |= MBX_12|MBX_11|MBX_10;
544 mcp->tov = MBX_TOV_SECONDS;
546 rval = qla2x00_mailbox_command(vha, mcp);
548 fwopts[0] = mcp->mb[0];
550 if (rval != QLA_SUCCESS) {
552 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x/%x).\n", __func__,
553 vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
556 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
563 * qla2x00_mbx_reg_test
564 * Mailbox register wrap test.
567 * ha = adapter block pointer.
568 * TARGET_QUEUE_LOCK must be released.
569 * ADAPTER_STATE_LOCK must be released.
572 * qla2x00 local function return status code.
578 qla2x00_mbx_reg_test(scsi_qla_host_t *vha)
582 mbx_cmd_t *mcp = &mc;
584 DEBUG11(printk("qla2x00_mbx_reg_test(%ld): entered.\n", vha->host_no));
586 mcp->mb[0] = MBC_MAILBOX_REGISTER_TEST;
594 mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
595 mcp->in_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
596 mcp->tov = MBX_TOV_SECONDS;
598 rval = qla2x00_mailbox_command(vha, mcp);
600 if (rval == QLA_SUCCESS) {
601 if (mcp->mb[1] != 0xAAAA || mcp->mb[2] != 0x5555 ||
602 mcp->mb[3] != 0xAA55 || mcp->mb[4] != 0x55AA)
603 rval = QLA_FUNCTION_FAILED;
604 if (mcp->mb[5] != 0xA5A5 || mcp->mb[6] != 0x5A5A ||
605 mcp->mb[7] != 0x2525)
606 rval = QLA_FUNCTION_FAILED;
609 if (rval != QLA_SUCCESS) {
611 DEBUG2_3_11(printk("qla2x00_mbx_reg_test(%ld): failed=%x.\n",
612 vha->host_no, rval));
615 DEBUG11(printk("qla2x00_mbx_reg_test(%ld): done.\n",
623 * qla2x00_verify_checksum
624 * Verify firmware checksum.
627 * ha = adapter block pointer.
628 * TARGET_QUEUE_LOCK must be released.
629 * ADAPTER_STATE_LOCK must be released.
632 * qla2x00 local function return status code.
638 qla2x00_verify_checksum(scsi_qla_host_t *vha, uint32_t risc_addr)
642 mbx_cmd_t *mcp = &mc;
644 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
646 mcp->mb[0] = MBC_VERIFY_CHECKSUM;
649 if (IS_FWI2_CAPABLE(vha->hw)) {
650 mcp->mb[1] = MSW(risc_addr);
651 mcp->mb[2] = LSW(risc_addr);
652 mcp->out_mb |= MBX_2|MBX_1;
653 mcp->in_mb |= MBX_2|MBX_1;
655 mcp->mb[1] = LSW(risc_addr);
656 mcp->out_mb |= MBX_1;
660 mcp->tov = MBX_TOV_SECONDS;
662 rval = qla2x00_mailbox_command(vha, mcp);
664 if (rval != QLA_SUCCESS) {
665 DEBUG2_3_11(printk("%s(%ld): failed=%x chk sum=%x.\n", __func__,
666 vha->host_no, rval, IS_FWI2_CAPABLE(vha->hw) ?
667 (mcp->mb[2] << 16) | mcp->mb[1]: mcp->mb[1]));
669 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
677 * Issue IOCB using mailbox command
680 * ha = adapter state pointer.
681 * buffer = buffer pointer.
682 * phys_addr = physical address of buffer.
683 * size = size of buffer.
684 * TARGET_QUEUE_LOCK must be released.
685 * ADAPTER_STATE_LOCK must be released.
688 * qla2x00 local function return status code.
694 qla2x00_issue_iocb_timeout(scsi_qla_host_t *vha, void *buffer,
695 dma_addr_t phys_addr, size_t size, uint32_t tov)
699 mbx_cmd_t *mcp = &mc;
701 mcp->mb[0] = MBC_IOCB_COMMAND_A64;
703 mcp->mb[2] = MSW(phys_addr);
704 mcp->mb[3] = LSW(phys_addr);
705 mcp->mb[6] = MSW(MSD(phys_addr));
706 mcp->mb[7] = LSW(MSD(phys_addr));
707 mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
708 mcp->in_mb = MBX_2|MBX_0;
711 rval = qla2x00_mailbox_command(vha, mcp);
713 if (rval != QLA_SUCCESS) {
715 DEBUG(printk("qla2x00_issue_iocb(%ld): failed rval 0x%x\n",
716 vha->host_no, rval));
718 sts_entry_t *sts_entry = (sts_entry_t *) buffer;
720 /* Mask reserved bits. */
721 sts_entry->entry_status &=
722 IS_FWI2_CAPABLE(vha->hw) ? RF_MASK_24XX : RF_MASK;
729 qla2x00_issue_iocb(scsi_qla_host_t *vha, void *buffer, dma_addr_t phys_addr,
732 return qla2x00_issue_iocb_timeout(vha, buffer, phys_addr, size,
737 * qla2x00_abort_command
738 * Abort command aborts a specified IOCB.
741 * ha = adapter block pointer.
742 * sp = SB structure pointer.
745 * qla2x00 local function return status code.
751 qla2x00_abort_command(srb_t *sp)
753 unsigned long flags = 0;
757 mbx_cmd_t *mcp = &mc;
758 fc_port_t *fcport = sp->fcport;
759 scsi_qla_host_t *vha = fcport->vha;
760 struct qla_hw_data *ha = vha->hw;
761 struct req_que *req = vha->req;
763 DEBUG11(printk("qla2x00_abort_command(%ld): entered.\n", vha->host_no));
765 spin_lock_irqsave(&ha->hardware_lock, flags);
766 for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) {
767 if (req->outstanding_cmds[handle] == sp)
770 spin_unlock_irqrestore(&ha->hardware_lock, flags);
772 if (handle == MAX_OUTSTANDING_COMMANDS) {
773 /* command not found */
774 return QLA_FUNCTION_FAILED;
777 mcp->mb[0] = MBC_ABORT_COMMAND;
778 if (HAS_EXTENDED_IDS(ha))
779 mcp->mb[1] = fcport->loop_id;
781 mcp->mb[1] = fcport->loop_id << 8;
782 mcp->mb[2] = (uint16_t)handle;
783 mcp->mb[3] = (uint16_t)(handle >> 16);
784 mcp->mb[6] = (uint16_t)sp->cmd->device->lun;
785 mcp->out_mb = MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
787 mcp->tov = MBX_TOV_SECONDS;
789 rval = qla2x00_mailbox_command(vha, mcp);
791 if (rval != QLA_SUCCESS) {
792 DEBUG2_3_11(printk("qla2x00_abort_command(%ld): failed=%x.\n",
793 vha->host_no, rval));
795 DEBUG11(printk("qla2x00_abort_command(%ld): done.\n",
803 qla2x00_abort_target(struct fc_port *fcport, unsigned int l, int tag)
807 mbx_cmd_t *mcp = &mc;
808 scsi_qla_host_t *vha;
812 DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->vha->host_no));
816 req = vha->hw->req_q_map[tag];
817 rsp = vha->hw->rsp_q_map[tag];
818 mcp->mb[0] = MBC_ABORT_TARGET;
819 mcp->out_mb = MBX_9|MBX_2|MBX_1|MBX_0;
820 if (HAS_EXTENDED_IDS(vha->hw)) {
821 mcp->mb[1] = fcport->loop_id;
823 mcp->out_mb |= MBX_10;
825 mcp->mb[1] = fcport->loop_id << 8;
827 mcp->mb[2] = vha->hw->loop_reset_delay;
828 mcp->mb[9] = vha->vp_idx;
831 mcp->tov = MBX_TOV_SECONDS;
833 rval = qla2x00_mailbox_command(vha, mcp);
834 if (rval != QLA_SUCCESS) {
835 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
836 vha->host_no, rval));
839 /* Issue marker IOCB. */
840 rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, 0,
842 if (rval2 != QLA_SUCCESS) {
843 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB "
844 "(%x).\n", __func__, vha->host_no, rval2));
846 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
853 qla2x00_lun_reset(struct fc_port *fcport, unsigned int l, int tag)
857 mbx_cmd_t *mcp = &mc;
858 scsi_qla_host_t *vha;
862 DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->vha->host_no));
865 req = vha->hw->req_q_map[tag];
866 rsp = vha->hw->rsp_q_map[tag];
867 mcp->mb[0] = MBC_LUN_RESET;
868 mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0;
869 if (HAS_EXTENDED_IDS(vha->hw))
870 mcp->mb[1] = fcport->loop_id;
872 mcp->mb[1] = fcport->loop_id << 8;
875 mcp->mb[9] = vha->vp_idx;
878 mcp->tov = MBX_TOV_SECONDS;
880 rval = qla2x00_mailbox_command(vha, mcp);
881 if (rval != QLA_SUCCESS) {
882 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
883 vha->host_no, rval));
886 /* Issue marker IOCB. */
887 rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, l,
889 if (rval2 != QLA_SUCCESS) {
890 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB "
891 "(%x).\n", __func__, vha->host_no, rval2));
893 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
900 * qla2x00_get_adapter_id
901 * Get adapter ID and topology.
904 * ha = adapter block pointer.
905 * id = pointer for loop ID.
906 * al_pa = pointer for AL_PA.
907 * area = pointer for area.
908 * domain = pointer for domain.
909 * top = pointer for topology.
910 * TARGET_QUEUE_LOCK must be released.
911 * ADAPTER_STATE_LOCK must be released.
914 * qla2x00 local function return status code.
920 qla2x00_get_adapter_id(scsi_qla_host_t *vha, uint16_t *id, uint8_t *al_pa,
921 uint8_t *area, uint8_t *domain, uint16_t *top, uint16_t *sw_cap)
925 mbx_cmd_t *mcp = &mc;
927 DEBUG11(printk("qla2x00_get_adapter_id(%ld): entered.\n",
930 mcp->mb[0] = MBC_GET_ADAPTER_LOOP_ID;
931 mcp->mb[9] = vha->vp_idx;
932 mcp->out_mb = MBX_9|MBX_0;
933 mcp->in_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
934 if (IS_QLA81XX(vha->hw))
935 mcp->in_mb |= MBX_13|MBX_12|MBX_11|MBX_10;
936 mcp->tov = MBX_TOV_SECONDS;
938 rval = qla2x00_mailbox_command(vha, mcp);
939 if (mcp->mb[0] == MBS_COMMAND_ERROR)
940 rval = QLA_COMMAND_ERROR;
941 else if (mcp->mb[0] == MBS_INVALID_COMMAND)
942 rval = QLA_INVALID_COMMAND;
946 *al_pa = LSB(mcp->mb[2]);
947 *area = MSB(mcp->mb[2]);
948 *domain = LSB(mcp->mb[3]);
950 *sw_cap = mcp->mb[7];
952 if (rval != QLA_SUCCESS) {
954 DEBUG2_3_11(printk("qla2x00_get_adapter_id(%ld): failed=%x.\n",
955 vha->host_no, rval));
957 DEBUG11(printk("qla2x00_get_adapter_id(%ld): done.\n",
960 if (IS_QLA81XX(vha->hw)) {
961 vha->fcoe_vlan_id = mcp->mb[9] & 0xfff;
962 vha->fcoe_fcf_idx = mcp->mb[10];
963 vha->fcoe_vn_port_mac[5] = mcp->mb[11] >> 8;
964 vha->fcoe_vn_port_mac[4] = mcp->mb[11] & 0xff;
965 vha->fcoe_vn_port_mac[3] = mcp->mb[12] >> 8;
966 vha->fcoe_vn_port_mac[2] = mcp->mb[12] & 0xff;
967 vha->fcoe_vn_port_mac[1] = mcp->mb[13] >> 8;
968 vha->fcoe_vn_port_mac[0] = mcp->mb[13] & 0xff;
976 * qla2x00_get_retry_cnt
977 * Get current firmware login retry count and delay.
980 * ha = adapter block pointer.
981 * retry_cnt = pointer to login retry count.
982 * tov = pointer to login timeout value.
985 * qla2x00 local function return status code.
991 qla2x00_get_retry_cnt(scsi_qla_host_t *vha, uint8_t *retry_cnt, uint8_t *tov,
997 mbx_cmd_t *mcp = &mc;
999 DEBUG11(printk("qla2x00_get_retry_cnt(%ld): entered.\n",
1002 mcp->mb[0] = MBC_GET_RETRY_COUNT;
1003 mcp->out_mb = MBX_0;
1004 mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0;
1005 mcp->tov = MBX_TOV_SECONDS;
1007 rval = qla2x00_mailbox_command(vha, mcp);
1009 if (rval != QLA_SUCCESS) {
1011 DEBUG2_3_11(printk("qla2x00_get_retry_cnt(%ld): failed = %x.\n",
1012 vha->host_no, mcp->mb[0]));
1014 /* Convert returned data and check our values. */
1015 *r_a_tov = mcp->mb[3] / 2;
1016 ratov = (mcp->mb[3]/2) / 10; /* mb[3] value is in 100ms */
1017 if (mcp->mb[1] * ratov > (*retry_cnt) * (*tov)) {
1018 /* Update to the larger values */
1019 *retry_cnt = (uint8_t)mcp->mb[1];
1023 DEBUG11(printk("qla2x00_get_retry_cnt(%ld): done. mb3=%d "
1024 "ratov=%d.\n", vha->host_no, mcp->mb[3], ratov));
1031 * qla2x00_init_firmware
1032 * Initialize adapter firmware.
1035 * ha = adapter block pointer.
1036 * dptr = Initialization control block pointer.
1037 * size = size of initialization control block.
1038 * TARGET_QUEUE_LOCK must be released.
1039 * ADAPTER_STATE_LOCK must be released.
1042 * qla2x00 local function return status code.
1048 qla2x00_init_firmware(scsi_qla_host_t *vha, uint16_t size)
1052 mbx_cmd_t *mcp = &mc;
1053 struct qla_hw_data *ha = vha->hw;
1055 DEBUG11(printk("qla2x00_init_firmware(%ld): entered.\n",
1058 if (ha->flags.npiv_supported)
1059 mcp->mb[0] = MBC_MID_INITIALIZE_FIRMWARE;
1061 mcp->mb[0] = MBC_INITIALIZE_FIRMWARE;
1064 mcp->mb[2] = MSW(ha->init_cb_dma);
1065 mcp->mb[3] = LSW(ha->init_cb_dma);
1066 mcp->mb[6] = MSW(MSD(ha->init_cb_dma));
1067 mcp->mb[7] = LSW(MSD(ha->init_cb_dma));
1068 mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
1069 if (IS_QLA81XX(ha) && ha->ex_init_cb->ex_version) {
1071 mcp->mb[10] = MSW(ha->ex_init_cb_dma);
1072 mcp->mb[11] = LSW(ha->ex_init_cb_dma);
1073 mcp->mb[12] = MSW(MSD(ha->ex_init_cb_dma));
1074 mcp->mb[13] = LSW(MSD(ha->ex_init_cb_dma));
1075 mcp->mb[14] = sizeof(*ha->ex_init_cb);
1076 mcp->out_mb |= MBX_14|MBX_13|MBX_12|MBX_11|MBX_10;
1079 mcp->buf_size = size;
1080 mcp->flags = MBX_DMA_OUT;
1081 mcp->tov = MBX_TOV_SECONDS;
1082 rval = qla2x00_mailbox_command(vha, mcp);
1084 if (rval != QLA_SUCCESS) {
1086 DEBUG2_3_11(printk("qla2x00_init_firmware(%ld): failed=%x "
1088 vha->host_no, rval, mcp->mb[0]));
1091 DEBUG11(printk("qla2x00_init_firmware(%ld): done.\n",
1099 * qla2x00_get_port_database
1100 * Issue normal/enhanced get port database mailbox command
1101 * and copy device name as necessary.
1104 * ha = adapter state pointer.
1105 * dev = structure pointer.
1106 * opt = enhanced cmd option byte.
1109 * qla2x00 local function return status code.
1115 qla2x00_get_port_database(scsi_qla_host_t *vha, fc_port_t *fcport, uint8_t opt)
1119 mbx_cmd_t *mcp = &mc;
1120 port_database_t *pd;
1121 struct port_database_24xx *pd24;
1123 struct qla_hw_data *ha = vha->hw;
1125 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
1128 pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma);
1130 DEBUG2_3(printk("%s(%ld): failed to allocate Port Database "
1131 "structure.\n", __func__, vha->host_no));
1132 return QLA_MEMORY_ALLOC_FAILED;
1134 memset(pd, 0, max(PORT_DATABASE_SIZE, PORT_DATABASE_24XX_SIZE));
1136 mcp->mb[0] = MBC_GET_PORT_DATABASE;
1137 if (opt != 0 && !IS_FWI2_CAPABLE(ha))
1138 mcp->mb[0] = MBC_ENHANCED_GET_PORT_DATABASE;
1139 mcp->mb[2] = MSW(pd_dma);
1140 mcp->mb[3] = LSW(pd_dma);
1141 mcp->mb[6] = MSW(MSD(pd_dma));
1142 mcp->mb[7] = LSW(MSD(pd_dma));
1143 mcp->mb[9] = vha->vp_idx;
1144 mcp->out_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
1146 if (IS_FWI2_CAPABLE(ha)) {
1147 mcp->mb[1] = fcport->loop_id;
1149 mcp->out_mb |= MBX_10|MBX_1;
1150 mcp->in_mb |= MBX_1;
1151 } else if (HAS_EXTENDED_IDS(ha)) {
1152 mcp->mb[1] = fcport->loop_id;
1154 mcp->out_mb |= MBX_10|MBX_1;
1156 mcp->mb[1] = fcport->loop_id << 8 | opt;
1157 mcp->out_mb |= MBX_1;
1159 mcp->buf_size = IS_FWI2_CAPABLE(ha) ?
1160 PORT_DATABASE_24XX_SIZE : PORT_DATABASE_SIZE;
1161 mcp->flags = MBX_DMA_IN;
1162 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2);
1163 rval = qla2x00_mailbox_command(vha, mcp);
1164 if (rval != QLA_SUCCESS)
1167 if (IS_FWI2_CAPABLE(ha)) {
1168 pd24 = (struct port_database_24xx *) pd;
1170 /* Check for logged in state. */
1171 if (pd24->current_login_state != PDS_PRLI_COMPLETE &&
1172 pd24->last_login_state != PDS_PRLI_COMPLETE) {
1173 DEBUG2(printk("%s(%ld): Unable to verify "
1174 "login-state (%x/%x) for loop_id %x\n",
1175 __func__, vha->host_no,
1176 pd24->current_login_state,
1177 pd24->last_login_state, fcport->loop_id));
1178 rval = QLA_FUNCTION_FAILED;
1182 /* Names are little-endian. */
1183 memcpy(fcport->node_name, pd24->node_name, WWN_SIZE);
1184 memcpy(fcport->port_name, pd24->port_name, WWN_SIZE);
1186 /* Get port_id of device. */
1187 fcport->d_id.b.domain = pd24->port_id[0];
1188 fcport->d_id.b.area = pd24->port_id[1];
1189 fcport->d_id.b.al_pa = pd24->port_id[2];
1190 fcport->d_id.b.rsvd_1 = 0;
1192 /* If not target must be initiator or unknown type. */
1193 if ((pd24->prli_svc_param_word_3[0] & BIT_4) == 0)
1194 fcport->port_type = FCT_INITIATOR;
1196 fcport->port_type = FCT_TARGET;
1198 /* Check for logged in state. */
1199 if (pd->master_state != PD_STATE_PORT_LOGGED_IN &&
1200 pd->slave_state != PD_STATE_PORT_LOGGED_IN) {
1201 rval = QLA_FUNCTION_FAILED;
1205 /* Names are little-endian. */
1206 memcpy(fcport->node_name, pd->node_name, WWN_SIZE);
1207 memcpy(fcport->port_name, pd->port_name, WWN_SIZE);
1209 /* Get port_id of device. */
1210 fcport->d_id.b.domain = pd->port_id[0];
1211 fcport->d_id.b.area = pd->port_id[3];
1212 fcport->d_id.b.al_pa = pd->port_id[2];
1213 fcport->d_id.b.rsvd_1 = 0;
1215 /* If not target must be initiator or unknown type. */
1216 if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0)
1217 fcport->port_type = FCT_INITIATOR;
1219 fcport->port_type = FCT_TARGET;
1221 /* Passback COS information. */
1222 fcport->supported_classes = (pd->options & BIT_4) ?
1223 FC_COS_CLASS2: FC_COS_CLASS3;
1227 dma_pool_free(ha->s_dma_pool, pd, pd_dma);
1229 if (rval != QLA_SUCCESS) {
1230 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
1231 __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
1233 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
1240 * qla2x00_get_firmware_state
1241 * Get adapter firmware state.
1244 * ha = adapter block pointer.
1245 * dptr = pointer for firmware state.
1246 * TARGET_QUEUE_LOCK must be released.
1247 * ADAPTER_STATE_LOCK must be released.
1250 * qla2x00 local function return status code.
1256 qla2x00_get_firmware_state(scsi_qla_host_t *vha, uint16_t *states)
1260 mbx_cmd_t *mcp = &mc;
1262 DEBUG11(printk("qla2x00_get_firmware_state(%ld): entered.\n",
1265 mcp->mb[0] = MBC_GET_FIRMWARE_STATE;
1266 mcp->out_mb = MBX_0;
1267 mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0;
1268 mcp->tov = MBX_TOV_SECONDS;
1270 rval = qla2x00_mailbox_command(vha, mcp);
1272 /* Return firmware states. */
1273 states[0] = mcp->mb[1];
1274 states[1] = mcp->mb[2];
1275 states[2] = mcp->mb[3];
1277 if (rval != QLA_SUCCESS) {
1279 DEBUG2_3_11(printk("qla2x00_get_firmware_state(%ld): "
1280 "failed=%x.\n", vha->host_no, rval));
1283 DEBUG11(printk("qla2x00_get_firmware_state(%ld): done.\n",
1291 * qla2x00_get_port_name
1292 * Issue get port name mailbox command.
1293 * Returned name is in big endian format.
1296 * ha = adapter block pointer.
1297 * loop_id = loop ID of device.
1298 * name = pointer for name.
1299 * TARGET_QUEUE_LOCK must be released.
1300 * ADAPTER_STATE_LOCK must be released.
1303 * qla2x00 local function return status code.
1309 qla2x00_get_port_name(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t *name,
1314 mbx_cmd_t *mcp = &mc;
1316 DEBUG11(printk("qla2x00_get_port_name(%ld): entered.\n",
1319 mcp->mb[0] = MBC_GET_PORT_NAME;
1320 mcp->mb[9] = vha->vp_idx;
1321 mcp->out_mb = MBX_9|MBX_1|MBX_0;
1322 if (HAS_EXTENDED_IDS(vha->hw)) {
1323 mcp->mb[1] = loop_id;
1325 mcp->out_mb |= MBX_10;
1327 mcp->mb[1] = loop_id << 8 | opt;
1330 mcp->in_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
1331 mcp->tov = MBX_TOV_SECONDS;
1333 rval = qla2x00_mailbox_command(vha, mcp);
1335 if (rval != QLA_SUCCESS) {
1337 DEBUG2_3_11(printk("qla2x00_get_port_name(%ld): failed=%x.\n",
1338 vha->host_no, rval));
1341 /* This function returns name in big endian. */
1342 name[0] = MSB(mcp->mb[2]);
1343 name[1] = LSB(mcp->mb[2]);
1344 name[2] = MSB(mcp->mb[3]);
1345 name[3] = LSB(mcp->mb[3]);
1346 name[4] = MSB(mcp->mb[6]);
1347 name[5] = LSB(mcp->mb[6]);
1348 name[6] = MSB(mcp->mb[7]);
1349 name[7] = LSB(mcp->mb[7]);
1352 DEBUG11(printk("qla2x00_get_port_name(%ld): done.\n",
1361 * Issue LIP reset mailbox command.
1364 * ha = adapter block pointer.
1365 * TARGET_QUEUE_LOCK must be released.
1366 * ADAPTER_STATE_LOCK must be released.
1369 * qla2x00 local function return status code.
1375 qla2x00_lip_reset(scsi_qla_host_t *vha)
1379 mbx_cmd_t *mcp = &mc;
1381 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
1383 if (IS_QLA81XX(vha->hw)) {
1384 /* Logout across all FCFs. */
1385 mcp->mb[0] = MBC_LIP_FULL_LOGIN;
1388 mcp->out_mb = MBX_2|MBX_1|MBX_0;
1389 } else if (IS_FWI2_CAPABLE(vha->hw)) {
1390 mcp->mb[0] = MBC_LIP_FULL_LOGIN;
1393 mcp->mb[3] = vha->hw->loop_reset_delay;
1394 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
1396 mcp->mb[0] = MBC_LIP_RESET;
1397 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
1398 if (HAS_EXTENDED_IDS(vha->hw)) {
1399 mcp->mb[1] = 0x00ff;
1401 mcp->out_mb |= MBX_10;
1403 mcp->mb[1] = 0xff00;
1405 mcp->mb[2] = vha->hw->loop_reset_delay;
1409 mcp->tov = MBX_TOV_SECONDS;
1411 rval = qla2x00_mailbox_command(vha, mcp);
1413 if (rval != QLA_SUCCESS) {
1415 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n",
1416 __func__, vha->host_no, rval));
1419 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
1430 * ha = adapter block pointer.
1431 * sns = pointer for command.
1432 * cmd_size = command size.
1433 * buf_size = response/command size.
1434 * TARGET_QUEUE_LOCK must be released.
1435 * ADAPTER_STATE_LOCK must be released.
1438 * qla2x00 local function return status code.
1444 qla2x00_send_sns(scsi_qla_host_t *vha, dma_addr_t sns_phys_address,
1445 uint16_t cmd_size, size_t buf_size)
1449 mbx_cmd_t *mcp = &mc;
1451 DEBUG11(printk("qla2x00_send_sns(%ld): entered.\n",
1454 DEBUG11(printk("qla2x00_send_sns: retry cnt=%d ratov=%d total "
1455 "tov=%d.\n", vha->hw->retry_count, vha->hw->login_timeout,
1458 mcp->mb[0] = MBC_SEND_SNS_COMMAND;
1459 mcp->mb[1] = cmd_size;
1460 mcp->mb[2] = MSW(sns_phys_address);
1461 mcp->mb[3] = LSW(sns_phys_address);
1462 mcp->mb[6] = MSW(MSD(sns_phys_address));
1463 mcp->mb[7] = LSW(MSD(sns_phys_address));
1464 mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
1465 mcp->in_mb = MBX_0|MBX_1;
1466 mcp->buf_size = buf_size;
1467 mcp->flags = MBX_DMA_OUT|MBX_DMA_IN;
1468 mcp->tov = (vha->hw->login_timeout * 2) + (vha->hw->login_timeout / 2);
1469 rval = qla2x00_mailbox_command(vha, mcp);
1471 if (rval != QLA_SUCCESS) {
1473 DEBUG(printk("qla2x00_send_sns(%ld): failed=%x mb[0]=%x "
1474 "mb[1]=%x.\n", vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
1475 DEBUG2_3_11(printk("qla2x00_send_sns(%ld): failed=%x mb[0]=%x "
1476 "mb[1]=%x.\n", vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
1479 DEBUG11(printk("qla2x00_send_sns(%ld): done.\n", vha->host_no));
1486 qla24xx_login_fabric(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain,
1487 uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt)
1491 struct logio_entry_24xx *lg;
1494 struct qla_hw_data *ha = vha->hw;
1495 struct req_que *req;
1496 struct rsp_que *rsp;
1498 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
1500 if (ql2xmultique_tag)
1501 req = ha->req_q_map[0];
1506 lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma);
1508 DEBUG2_3(printk("%s(%ld): failed to allocate Login IOCB.\n",
1509 __func__, vha->host_no));
1510 return QLA_MEMORY_ALLOC_FAILED;
1512 memset(lg, 0, sizeof(struct logio_entry_24xx));
1514 lg->entry_type = LOGINOUT_PORT_IOCB_TYPE;
1515 lg->entry_count = 1;
1516 lg->handle = MAKE_HANDLE(req->id, lg->handle);
1517 lg->nport_handle = cpu_to_le16(loop_id);
1518 lg->control_flags = __constant_cpu_to_le16(LCF_COMMAND_PLOGI);
1520 lg->control_flags |= __constant_cpu_to_le16(LCF_COND_PLOGI);
1522 lg->control_flags |= __constant_cpu_to_le16(LCF_SKIP_PRLI);
1523 lg->port_id[0] = al_pa;
1524 lg->port_id[1] = area;
1525 lg->port_id[2] = domain;
1526 lg->vp_index = vha->vp_idx;
1527 rval = qla2x00_issue_iocb(vha, lg, lg_dma, 0);
1528 if (rval != QLA_SUCCESS) {
1529 DEBUG2_3_11(printk("%s(%ld): failed to issue Login IOCB "
1530 "(%x).\n", __func__, vha->host_no, rval));
1531 } else if (lg->entry_status != 0) {
1532 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
1533 "-- error status (%x).\n", __func__, vha->host_no,
1535 rval = QLA_FUNCTION_FAILED;
1536 } else if (lg->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) {
1537 iop[0] = le32_to_cpu(lg->io_parameter[0]);
1538 iop[1] = le32_to_cpu(lg->io_parameter[1]);
1540 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
1541 "-- completion status (%x) ioparam=%x/%x.\n", __func__,
1542 vha->host_no, le16_to_cpu(lg->comp_status), iop[0],
1546 case LSC_SCODE_PORTID_USED:
1547 mb[0] = MBS_PORT_ID_USED;
1548 mb[1] = LSW(iop[1]);
1550 case LSC_SCODE_NPORT_USED:
1551 mb[0] = MBS_LOOP_ID_USED;
1553 case LSC_SCODE_NOLINK:
1554 case LSC_SCODE_NOIOCB:
1555 case LSC_SCODE_NOXCB:
1556 case LSC_SCODE_CMD_FAILED:
1557 case LSC_SCODE_NOFABRIC:
1558 case LSC_SCODE_FW_NOT_READY:
1559 case LSC_SCODE_NOT_LOGGED_IN:
1560 case LSC_SCODE_NOPCB:
1561 case LSC_SCODE_ELS_REJECT:
1562 case LSC_SCODE_CMD_PARAM_ERR:
1563 case LSC_SCODE_NONPORT:
1564 case LSC_SCODE_LOGGED_IN:
1565 case LSC_SCODE_NOFLOGI_ACC:
1567 mb[0] = MBS_COMMAND_ERROR;
1571 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
1573 iop[0] = le32_to_cpu(lg->io_parameter[0]);
1575 mb[0] = MBS_COMMAND_COMPLETE;
1577 if (iop[0] & BIT_4) {
1583 /* Passback COS information. */
1585 if (lg->io_parameter[7] || lg->io_parameter[8])
1586 mb[10] |= BIT_0; /* Class 2. */
1587 if (lg->io_parameter[9] || lg->io_parameter[10])
1588 mb[10] |= BIT_1; /* Class 3. */
1591 dma_pool_free(ha->s_dma_pool, lg, lg_dma);
1597 * qla2x00_login_fabric
1598 * Issue login fabric port mailbox command.
1601 * ha = adapter block pointer.
1602 * loop_id = device loop ID.
1603 * domain = device domain.
1604 * area = device area.
1605 * al_pa = device AL_PA.
1606 * status = pointer for return status.
1607 * opt = command options.
1608 * TARGET_QUEUE_LOCK must be released.
1609 * ADAPTER_STATE_LOCK must be released.
1612 * qla2x00 local function return status code.
1618 qla2x00_login_fabric(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain,
1619 uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt)
1623 mbx_cmd_t *mcp = &mc;
1624 struct qla_hw_data *ha = vha->hw;
1626 DEBUG11(printk("qla2x00_login_fabric(%ld): entered.\n", vha->host_no));
1628 mcp->mb[0] = MBC_LOGIN_FABRIC_PORT;
1629 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
1630 if (HAS_EXTENDED_IDS(ha)) {
1631 mcp->mb[1] = loop_id;
1633 mcp->out_mb |= MBX_10;
1635 mcp->mb[1] = (loop_id << 8) | opt;
1637 mcp->mb[2] = domain;
1638 mcp->mb[3] = area << 8 | al_pa;
1640 mcp->in_mb = MBX_7|MBX_6|MBX_2|MBX_1|MBX_0;
1641 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2);
1643 rval = qla2x00_mailbox_command(vha, mcp);
1645 /* Return mailbox statuses. */
1652 /* COS retrieved from Get-Port-Database mailbox command. */
1656 if (rval != QLA_SUCCESS) {
1657 /* RLU tmp code: need to change main mailbox_command function to
1658 * return ok even when the mailbox completion value is not
1659 * SUCCESS. The caller needs to be responsible to interpret
1660 * the return values of this mailbox command if we're not
1661 * to change too much of the existing code.
1663 if (mcp->mb[0] == 0x4001 || mcp->mb[0] == 0x4002 ||
1664 mcp->mb[0] == 0x4003 || mcp->mb[0] == 0x4005 ||
1665 mcp->mb[0] == 0x4006)
1669 DEBUG2_3_11(printk("qla2x00_login_fabric(%ld): failed=%x "
1670 "mb[0]=%x mb[1]=%x mb[2]=%x.\n", vha->host_no, rval,
1671 mcp->mb[0], mcp->mb[1], mcp->mb[2]));
1674 DEBUG11(printk("qla2x00_login_fabric(%ld): done.\n",
1682 * qla2x00_login_local_device
1683 * Issue login loop port mailbox command.
1686 * ha = adapter block pointer.
1687 * loop_id = device loop ID.
1688 * opt = command options.
1691 * Return status code.
1698 qla2x00_login_local_device(scsi_qla_host_t *vha, fc_port_t *fcport,
1699 uint16_t *mb_ret, uint8_t opt)
1703 mbx_cmd_t *mcp = &mc;
1704 struct qla_hw_data *ha = vha->hw;
1706 if (IS_FWI2_CAPABLE(ha))
1707 return qla24xx_login_fabric(vha, fcport->loop_id,
1708 fcport->d_id.b.domain, fcport->d_id.b.area,
1709 fcport->d_id.b.al_pa, mb_ret, opt);
1711 DEBUG3(printk("%s(%ld): entered.\n", __func__, vha->host_no));
1713 mcp->mb[0] = MBC_LOGIN_LOOP_PORT;
1714 if (HAS_EXTENDED_IDS(ha))
1715 mcp->mb[1] = fcport->loop_id;
1717 mcp->mb[1] = fcport->loop_id << 8;
1719 mcp->out_mb = MBX_2|MBX_1|MBX_0;
1720 mcp->in_mb = MBX_7|MBX_6|MBX_1|MBX_0;
1721 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2);
1723 rval = qla2x00_mailbox_command(vha, mcp);
1725 /* Return mailbox statuses. */
1726 if (mb_ret != NULL) {
1727 mb_ret[0] = mcp->mb[0];
1728 mb_ret[1] = mcp->mb[1];
1729 mb_ret[6] = mcp->mb[6];
1730 mb_ret[7] = mcp->mb[7];
1733 if (rval != QLA_SUCCESS) {
1734 /* AV tmp code: need to change main mailbox_command function to
1735 * return ok even when the mailbox completion value is not
1736 * SUCCESS. The caller needs to be responsible to interpret
1737 * the return values of this mailbox command if we're not
1738 * to change too much of the existing code.
1740 if (mcp->mb[0] == 0x4005 || mcp->mb[0] == 0x4006)
1743 DEBUG(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x "
1744 "mb[6]=%x mb[7]=%x.\n", __func__, vha->host_no, rval,
1745 mcp->mb[0], mcp->mb[1], mcp->mb[6], mcp->mb[7]));
1746 DEBUG2_3(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x "
1747 "mb[6]=%x mb[7]=%x.\n", __func__, vha->host_no, rval,
1748 mcp->mb[0], mcp->mb[1], mcp->mb[6], mcp->mb[7]));
1751 DEBUG3(printk("%s(%ld): done.\n", __func__, vha->host_no));
1758 qla24xx_fabric_logout(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain,
1759 uint8_t area, uint8_t al_pa)
1762 struct logio_entry_24xx *lg;
1764 struct qla_hw_data *ha = vha->hw;
1765 struct req_que *req;
1766 struct rsp_que *rsp;
1768 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
1770 lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma);
1772 DEBUG2_3(printk("%s(%ld): failed to allocate Logout IOCB.\n",
1773 __func__, vha->host_no));
1774 return QLA_MEMORY_ALLOC_FAILED;
1776 memset(lg, 0, sizeof(struct logio_entry_24xx));
1778 if (ql2xmaxqueues > 1)
1779 req = ha->req_q_map[0];
1783 lg->entry_type = LOGINOUT_PORT_IOCB_TYPE;
1784 lg->entry_count = 1;
1785 lg->handle = MAKE_HANDLE(req->id, lg->handle);
1786 lg->nport_handle = cpu_to_le16(loop_id);
1788 __constant_cpu_to_le16(LCF_COMMAND_LOGO|LCF_IMPL_LOGO);
1789 lg->port_id[0] = al_pa;
1790 lg->port_id[1] = area;
1791 lg->port_id[2] = domain;
1792 lg->vp_index = vha->vp_idx;
1794 rval = qla2x00_issue_iocb(vha, lg, lg_dma, 0);
1795 if (rval != QLA_SUCCESS) {
1796 DEBUG2_3_11(printk("%s(%ld): failed to issue Logout IOCB "
1797 "(%x).\n", __func__, vha->host_no, rval));
1798 } else if (lg->entry_status != 0) {
1799 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
1800 "-- error status (%x).\n", __func__, vha->host_no,
1802 rval = QLA_FUNCTION_FAILED;
1803 } else if (lg->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) {
1804 DEBUG2_3_11(printk("%s(%ld %d): failed to complete IOCB "
1805 "-- completion status (%x) ioparam=%x/%x.\n", __func__,
1806 vha->host_no, vha->vp_idx, le16_to_cpu(lg->comp_status),
1807 le32_to_cpu(lg->io_parameter[0]),
1808 le32_to_cpu(lg->io_parameter[1])));
1811 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
1814 dma_pool_free(ha->s_dma_pool, lg, lg_dma);
1820 * qla2x00_fabric_logout
1821 * Issue logout fabric port mailbox command.
1824 * ha = adapter block pointer.
1825 * loop_id = device loop ID.
1826 * TARGET_QUEUE_LOCK must be released.
1827 * ADAPTER_STATE_LOCK must be released.
1830 * qla2x00 local function return status code.
1836 qla2x00_fabric_logout(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain,
1837 uint8_t area, uint8_t al_pa)
1841 mbx_cmd_t *mcp = &mc;
1843 DEBUG11(printk("qla2x00_fabric_logout(%ld): entered.\n",
1846 mcp->mb[0] = MBC_LOGOUT_FABRIC_PORT;
1847 mcp->out_mb = MBX_1|MBX_0;
1848 if (HAS_EXTENDED_IDS(vha->hw)) {
1849 mcp->mb[1] = loop_id;
1851 mcp->out_mb |= MBX_10;
1853 mcp->mb[1] = loop_id << 8;
1856 mcp->in_mb = MBX_1|MBX_0;
1857 mcp->tov = MBX_TOV_SECONDS;
1859 rval = qla2x00_mailbox_command(vha, mcp);
1861 if (rval != QLA_SUCCESS) {
1863 DEBUG2_3_11(printk("qla2x00_fabric_logout(%ld): failed=%x "
1864 "mbx1=%x.\n", vha->host_no, rval, mcp->mb[1]));
1867 DEBUG11(printk("qla2x00_fabric_logout(%ld): done.\n",
1875 * qla2x00_full_login_lip
1876 * Issue full login LIP mailbox command.
1879 * ha = adapter block pointer.
1880 * TARGET_QUEUE_LOCK must be released.
1881 * ADAPTER_STATE_LOCK must be released.
1884 * qla2x00 local function return status code.
1890 qla2x00_full_login_lip(scsi_qla_host_t *vha)
1894 mbx_cmd_t *mcp = &mc;
1896 DEBUG11(printk("qla2x00_full_login_lip(%ld): entered.\n",
1899 mcp->mb[0] = MBC_LIP_FULL_LOGIN;
1900 mcp->mb[1] = IS_FWI2_CAPABLE(vha->hw) ? BIT_3 : 0;
1903 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
1905 mcp->tov = MBX_TOV_SECONDS;
1907 rval = qla2x00_mailbox_command(vha, mcp);
1909 if (rval != QLA_SUCCESS) {
1911 DEBUG2_3_11(printk("qla2x00_full_login_lip(%ld): failed=%x.\n",
1912 vha->host_no, rval));
1915 DEBUG11(printk("qla2x00_full_login_lip(%ld): done.\n",
1923 * qla2x00_get_id_list
1926 * ha = adapter block pointer.
1929 * qla2x00 local function return status code.
1935 qla2x00_get_id_list(scsi_qla_host_t *vha, void *id_list, dma_addr_t id_list_dma,
1940 mbx_cmd_t *mcp = &mc;
1942 DEBUG11(printk("qla2x00_get_id_list(%ld): entered.\n",
1945 if (id_list == NULL)
1946 return QLA_FUNCTION_FAILED;
1948 mcp->mb[0] = MBC_GET_ID_LIST;
1949 mcp->out_mb = MBX_0;
1950 if (IS_FWI2_CAPABLE(vha->hw)) {
1951 mcp->mb[2] = MSW(id_list_dma);
1952 mcp->mb[3] = LSW(id_list_dma);
1953 mcp->mb[6] = MSW(MSD(id_list_dma));
1954 mcp->mb[7] = LSW(MSD(id_list_dma));
1956 mcp->mb[9] = vha->vp_idx;
1957 mcp->out_mb |= MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2;
1959 mcp->mb[1] = MSW(id_list_dma);
1960 mcp->mb[2] = LSW(id_list_dma);
1961 mcp->mb[3] = MSW(MSD(id_list_dma));
1962 mcp->mb[6] = LSW(MSD(id_list_dma));
1963 mcp->out_mb |= MBX_6|MBX_3|MBX_2|MBX_1;
1965 mcp->in_mb = MBX_1|MBX_0;
1966 mcp->tov = MBX_TOV_SECONDS;
1968 rval = qla2x00_mailbox_command(vha, mcp);
1970 if (rval != QLA_SUCCESS) {
1972 DEBUG2_3_11(printk("qla2x00_get_id_list(%ld): failed=%x.\n",
1973 vha->host_no, rval));
1975 *entries = mcp->mb[1];
1976 DEBUG11(printk("qla2x00_get_id_list(%ld): done.\n",
1984 * qla2x00_get_resource_cnts
1985 * Get current firmware resource counts.
1988 * ha = adapter block pointer.
1991 * qla2x00 local function return status code.
1997 qla2x00_get_resource_cnts(scsi_qla_host_t *vha, uint16_t *cur_xchg_cnt,
1998 uint16_t *orig_xchg_cnt, uint16_t *cur_iocb_cnt,
1999 uint16_t *orig_iocb_cnt, uint16_t *max_npiv_vports)
2003 mbx_cmd_t *mcp = &mc;
2005 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2007 mcp->mb[0] = MBC_GET_RESOURCE_COUNTS;
2008 mcp->out_mb = MBX_0;
2009 mcp->in_mb = MBX_11|MBX_10|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
2010 mcp->tov = MBX_TOV_SECONDS;
2012 rval = qla2x00_mailbox_command(vha, mcp);
2014 if (rval != QLA_SUCCESS) {
2016 DEBUG2_3_11(printk("%s(%ld): failed = %x.\n", __func__,
2017 vha->host_no, mcp->mb[0]));
2019 DEBUG11(printk("%s(%ld): done. mb1=%x mb2=%x mb3=%x mb6=%x "
2020 "mb7=%x mb10=%x mb11=%x.\n", __func__, vha->host_no,
2021 mcp->mb[1], mcp->mb[2], mcp->mb[3], mcp->mb[6], mcp->mb[7],
2022 mcp->mb[10], mcp->mb[11]));
2025 *cur_xchg_cnt = mcp->mb[3];
2027 *orig_xchg_cnt = mcp->mb[6];
2029 *cur_iocb_cnt = mcp->mb[7];
2031 *orig_iocb_cnt = mcp->mb[10];
2032 if (vha->hw->flags.npiv_supported && max_npiv_vports)
2033 *max_npiv_vports = mcp->mb[11];
2039 #if defined(QL_DEBUG_LEVEL_3)
2041 * qla2x00_get_fcal_position_map
2042 * Get FCAL (LILP) position map using mailbox command
2045 * ha = adapter state pointer.
2046 * pos_map = buffer pointer (can be NULL).
2049 * qla2x00 local function return status code.
2055 qla2x00_get_fcal_position_map(scsi_qla_host_t *vha, char *pos_map)
2059 mbx_cmd_t *mcp = &mc;
2061 dma_addr_t pmap_dma;
2062 struct qla_hw_data *ha = vha->hw;
2064 pmap = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pmap_dma);
2066 DEBUG2_3_11(printk("%s(%ld): **** Mem Alloc Failed ****",
2067 __func__, vha->host_no));
2068 return QLA_MEMORY_ALLOC_FAILED;
2070 memset(pmap, 0, FCAL_MAP_SIZE);
2072 mcp->mb[0] = MBC_GET_FC_AL_POSITION_MAP;
2073 mcp->mb[2] = MSW(pmap_dma);
2074 mcp->mb[3] = LSW(pmap_dma);
2075 mcp->mb[6] = MSW(MSD(pmap_dma));
2076 mcp->mb[7] = LSW(MSD(pmap_dma));
2077 mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
2078 mcp->in_mb = MBX_1|MBX_0;
2079 mcp->buf_size = FCAL_MAP_SIZE;
2080 mcp->flags = MBX_DMA_IN;
2081 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2);
2082 rval = qla2x00_mailbox_command(vha, mcp);
2084 if (rval == QLA_SUCCESS) {
2085 DEBUG11(printk("%s(%ld): (mb0=%x/mb1=%x) FC/AL Position Map "
2086 "size (%x)\n", __func__, vha->host_no, mcp->mb[0],
2087 mcp->mb[1], (unsigned)pmap[0]));
2088 DEBUG11(qla2x00_dump_buffer(pmap, pmap[0] + 1));
2091 memcpy(pos_map, pmap, FCAL_MAP_SIZE);
2093 dma_pool_free(ha->s_dma_pool, pmap, pmap_dma);
2095 if (rval != QLA_SUCCESS) {
2096 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
2097 vha->host_no, rval));
2099 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2107 * qla2x00_get_link_status
2110 * ha = adapter block pointer.
2111 * loop_id = device loop ID.
2112 * ret_buf = pointer to link status return buffer.
2116 * BIT_0 = mem alloc error.
2117 * BIT_1 = mailbox error.
2120 qla2x00_get_link_status(scsi_qla_host_t *vha, uint16_t loop_id,
2121 struct link_statistics *stats, dma_addr_t stats_dma)
2125 mbx_cmd_t *mcp = &mc;
2126 uint32_t *siter, *diter, dwords;
2127 struct qla_hw_data *ha = vha->hw;
2129 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2131 mcp->mb[0] = MBC_GET_LINK_STATUS;
2132 mcp->mb[2] = MSW(stats_dma);
2133 mcp->mb[3] = LSW(stats_dma);
2134 mcp->mb[6] = MSW(MSD(stats_dma));
2135 mcp->mb[7] = LSW(MSD(stats_dma));
2136 mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
2138 if (IS_FWI2_CAPABLE(ha)) {
2139 mcp->mb[1] = loop_id;
2142 mcp->out_mb |= MBX_10|MBX_4|MBX_1;
2143 mcp->in_mb |= MBX_1;
2144 } else if (HAS_EXTENDED_IDS(ha)) {
2145 mcp->mb[1] = loop_id;
2147 mcp->out_mb |= MBX_10|MBX_1;
2149 mcp->mb[1] = loop_id << 8;
2150 mcp->out_mb |= MBX_1;
2152 mcp->tov = MBX_TOV_SECONDS;
2153 mcp->flags = IOCTL_CMD;
2154 rval = qla2x00_mailbox_command(vha, mcp);
2156 if (rval == QLA_SUCCESS) {
2157 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) {
2158 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n",
2159 __func__, vha->host_no, mcp->mb[0]));
2160 rval = QLA_FUNCTION_FAILED;
2162 /* Copy over data -- firmware data is LE. */
2163 dwords = offsetof(struct link_statistics, unused1) / 4;
2164 siter = diter = &stats->link_fail_cnt;
2166 *diter++ = le32_to_cpu(*siter++);
2170 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
2171 vha->host_no, rval));
2178 qla24xx_get_isp_stats(scsi_qla_host_t *vha, struct link_statistics *stats,
2179 dma_addr_t stats_dma)
2183 mbx_cmd_t *mcp = &mc;
2184 uint32_t *siter, *diter, dwords;
2186 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2188 mcp->mb[0] = MBC_GET_LINK_PRIV_STATS;
2189 mcp->mb[2] = MSW(stats_dma);
2190 mcp->mb[3] = LSW(stats_dma);
2191 mcp->mb[6] = MSW(MSD(stats_dma));
2192 mcp->mb[7] = LSW(MSD(stats_dma));
2193 mcp->mb[8] = sizeof(struct link_statistics) / 4;
2194 mcp->mb[9] = vha->vp_idx;
2196 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
2197 mcp->in_mb = MBX_2|MBX_1|MBX_0;
2198 mcp->tov = MBX_TOV_SECONDS;
2199 mcp->flags = IOCTL_CMD;
2200 rval = qla2x00_mailbox_command(vha, mcp);
2202 if (rval == QLA_SUCCESS) {
2203 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) {
2204 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n",
2205 __func__, vha->host_no, mcp->mb[0]));
2206 rval = QLA_FUNCTION_FAILED;
2208 /* Copy over data -- firmware data is LE. */
2209 dwords = sizeof(struct link_statistics) / 4;
2210 siter = diter = &stats->link_fail_cnt;
2212 *diter++ = le32_to_cpu(*siter++);
2216 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
2217 vha->host_no, rval));
2224 qla24xx_abort_command(srb_t *sp)
2227 unsigned long flags = 0;
2229 struct abort_entry_24xx *abt;
2232 fc_port_t *fcport = sp->fcport;
2233 struct scsi_qla_host *vha = fcport->vha;
2234 struct qla_hw_data *ha = vha->hw;
2235 struct req_que *req = vha->req;
2237 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2239 spin_lock_irqsave(&ha->hardware_lock, flags);
2240 for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) {
2241 if (req->outstanding_cmds[handle] == sp)
2244 spin_unlock_irqrestore(&ha->hardware_lock, flags);
2245 if (handle == MAX_OUTSTANDING_COMMANDS) {
2246 /* Command not found. */
2247 return QLA_FUNCTION_FAILED;
2250 abt = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &abt_dma);
2252 DEBUG2_3(printk("%s(%ld): failed to allocate Abort IOCB.\n",
2253 __func__, vha->host_no));
2254 return QLA_MEMORY_ALLOC_FAILED;
2256 memset(abt, 0, sizeof(struct abort_entry_24xx));
2258 abt->entry_type = ABORT_IOCB_TYPE;
2259 abt->entry_count = 1;
2260 abt->handle = MAKE_HANDLE(req->id, abt->handle);
2261 abt->nport_handle = cpu_to_le16(fcport->loop_id);
2262 abt->handle_to_abort = handle;
2263 abt->port_id[0] = fcport->d_id.b.al_pa;
2264 abt->port_id[1] = fcport->d_id.b.area;
2265 abt->port_id[2] = fcport->d_id.b.domain;
2266 abt->vp_index = fcport->vp_idx;
2268 abt->req_que_no = cpu_to_le16(req->id);
2270 rval = qla2x00_issue_iocb(vha, abt, abt_dma, 0);
2271 if (rval != QLA_SUCCESS) {
2272 DEBUG2_3_11(printk("%s(%ld): failed to issue IOCB (%x).\n",
2273 __func__, vha->host_no, rval));
2274 } else if (abt->entry_status != 0) {
2275 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2276 "-- error status (%x).\n", __func__, vha->host_no,
2277 abt->entry_status));
2278 rval = QLA_FUNCTION_FAILED;
2279 } else if (abt->nport_handle != __constant_cpu_to_le16(0)) {
2280 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2281 "-- completion status (%x).\n", __func__, vha->host_no,
2282 le16_to_cpu(abt->nport_handle)));
2283 rval = QLA_FUNCTION_FAILED;
2285 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2288 dma_pool_free(ha->s_dma_pool, abt, abt_dma);
2293 struct tsk_mgmt_cmd {
2295 struct tsk_mgmt_entry tsk;
2296 struct sts_entry_24xx sts;
2301 __qla24xx_issue_tmf(char *name, uint32_t type, struct fc_port *fcport,
2302 unsigned int l, int tag)
2305 struct tsk_mgmt_cmd *tsk;
2307 scsi_qla_host_t *vha;
2308 struct qla_hw_data *ha;
2309 struct req_que *req;
2310 struct rsp_que *rsp;
2312 DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->vha->host_no));
2317 if (ql2xmultique_tag)
2318 rsp = ha->rsp_q_map[tag + 1];
2321 tsk = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &tsk_dma);
2323 DEBUG2_3(printk("%s(%ld): failed to allocate Task Management "
2324 "IOCB.\n", __func__, vha->host_no));
2325 return QLA_MEMORY_ALLOC_FAILED;
2327 memset(tsk, 0, sizeof(struct tsk_mgmt_cmd));
2329 tsk->p.tsk.entry_type = TSK_MGMT_IOCB_TYPE;
2330 tsk->p.tsk.entry_count = 1;
2331 tsk->p.tsk.handle = MAKE_HANDLE(req->id, tsk->p.tsk.handle);
2332 tsk->p.tsk.nport_handle = cpu_to_le16(fcport->loop_id);
2333 tsk->p.tsk.timeout = cpu_to_le16(ha->r_a_tov / 10 * 2);
2334 tsk->p.tsk.control_flags = cpu_to_le32(type);
2335 tsk->p.tsk.port_id[0] = fcport->d_id.b.al_pa;
2336 tsk->p.tsk.port_id[1] = fcport->d_id.b.area;
2337 tsk->p.tsk.port_id[2] = fcport->d_id.b.domain;
2338 tsk->p.tsk.vp_index = fcport->vp_idx;
2339 if (type == TCF_LUN_RESET) {
2340 int_to_scsilun(l, &tsk->p.tsk.lun);
2341 host_to_fcp_swap((uint8_t *)&tsk->p.tsk.lun,
2342 sizeof(tsk->p.tsk.lun));
2345 rval = qla2x00_issue_iocb(vha, tsk, tsk_dma, 0);
2346 if (rval != QLA_SUCCESS) {
2347 DEBUG2_3_11(printk("%s(%ld): failed to issue %s Reset IOCB "
2348 "(%x).\n", __func__, vha->host_no, name, rval));
2349 } else if (tsk->p.sts.entry_status != 0) {
2350 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2351 "-- error status (%x).\n", __func__, vha->host_no,
2352 tsk->p.sts.entry_status));
2353 rval = QLA_FUNCTION_FAILED;
2354 } else if (tsk->p.sts.comp_status !=
2355 __constant_cpu_to_le16(CS_COMPLETE)) {
2356 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2357 "-- completion status (%x).\n", __func__,
2358 vha->host_no, le16_to_cpu(tsk->p.sts.comp_status)));
2359 rval = QLA_FUNCTION_FAILED;
2362 /* Issue marker IOCB. */
2363 rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, l,
2364 type == TCF_LUN_RESET ? MK_SYNC_ID_LUN: MK_SYNC_ID);
2365 if (rval2 != QLA_SUCCESS) {
2366 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB "
2367 "(%x).\n", __func__, vha->host_no, rval2));
2369 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2372 dma_pool_free(ha->s_dma_pool, tsk, tsk_dma);
2378 qla24xx_abort_target(struct fc_port *fcport, unsigned int l, int tag)
2380 return __qla24xx_issue_tmf("Target", TCF_TARGET_RESET, fcport, l, tag);
2384 qla24xx_lun_reset(struct fc_port *fcport, unsigned int l, int tag)
2386 return __qla24xx_issue_tmf("Lun", TCF_LUN_RESET, fcport, l, tag);
2390 qla2x00_system_error(scsi_qla_host_t *vha)
2394 mbx_cmd_t *mcp = &mc;
2395 struct qla_hw_data *ha = vha->hw;
2397 if (!IS_QLA23XX(ha) && !IS_FWI2_CAPABLE(ha))
2398 return QLA_FUNCTION_FAILED;
2400 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2402 mcp->mb[0] = MBC_GEN_SYSTEM_ERROR;
2403 mcp->out_mb = MBX_0;
2407 rval = qla2x00_mailbox_command(vha, mcp);
2409 if (rval != QLA_SUCCESS) {
2410 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
2411 vha->host_no, rval));
2413 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2420 * qla2x00_set_serdes_params() -
2426 qla2x00_set_serdes_params(scsi_qla_host_t *vha, uint16_t sw_em_1g,
2427 uint16_t sw_em_2g, uint16_t sw_em_4g)
2431 mbx_cmd_t *mcp = &mc;
2433 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2435 mcp->mb[0] = MBC_SERDES_PARAMS;
2437 mcp->mb[2] = sw_em_1g | BIT_15;
2438 mcp->mb[3] = sw_em_2g | BIT_15;
2439 mcp->mb[4] = sw_em_4g | BIT_15;
2440 mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
2442 mcp->tov = MBX_TOV_SECONDS;
2444 rval = qla2x00_mailbox_command(vha, mcp);
2446 if (rval != QLA_SUCCESS) {
2448 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__,
2449 vha->host_no, rval, mcp->mb[0]));
2452 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2459 qla2x00_stop_firmware(scsi_qla_host_t *vha)
2463 mbx_cmd_t *mcp = &mc;
2465 if (!IS_FWI2_CAPABLE(vha->hw))
2466 return QLA_FUNCTION_FAILED;
2468 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2470 mcp->mb[0] = MBC_STOP_FIRMWARE;
2471 mcp->out_mb = MBX_0;
2475 rval = qla2x00_mailbox_command(vha, mcp);
2477 if (rval != QLA_SUCCESS) {
2478 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
2479 vha->host_no, rval));
2480 if (mcp->mb[0] == MBS_INVALID_COMMAND)
2481 rval = QLA_INVALID_COMMAND;
2483 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2490 qla2x00_enable_eft_trace(scsi_qla_host_t *vha, dma_addr_t eft_dma,
2495 mbx_cmd_t *mcp = &mc;
2497 if (!IS_FWI2_CAPABLE(vha->hw))
2498 return QLA_FUNCTION_FAILED;
2500 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2502 mcp->mb[0] = MBC_TRACE_CONTROL;
2503 mcp->mb[1] = TC_EFT_ENABLE;
2504 mcp->mb[2] = LSW(eft_dma);
2505 mcp->mb[3] = MSW(eft_dma);
2506 mcp->mb[4] = LSW(MSD(eft_dma));
2507 mcp->mb[5] = MSW(MSD(eft_dma));
2508 mcp->mb[6] = buffers;
2509 mcp->mb[7] = TC_AEN_DISABLE;
2510 mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
2511 mcp->in_mb = MBX_1|MBX_0;
2512 mcp->tov = MBX_TOV_SECONDS;
2514 rval = qla2x00_mailbox_command(vha, mcp);
2515 if (rval != QLA_SUCCESS) {
2516 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
2517 __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
2519 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2526 qla2x00_disable_eft_trace(scsi_qla_host_t *vha)
2530 mbx_cmd_t *mcp = &mc;
2532 if (!IS_FWI2_CAPABLE(vha->hw))
2533 return QLA_FUNCTION_FAILED;
2535 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2537 mcp->mb[0] = MBC_TRACE_CONTROL;
2538 mcp->mb[1] = TC_EFT_DISABLE;
2539 mcp->out_mb = MBX_1|MBX_0;
2540 mcp->in_mb = MBX_1|MBX_0;
2541 mcp->tov = MBX_TOV_SECONDS;
2543 rval = qla2x00_mailbox_command(vha, mcp);
2544 if (rval != QLA_SUCCESS) {
2545 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
2546 __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
2548 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2555 qla2x00_enable_fce_trace(scsi_qla_host_t *vha, dma_addr_t fce_dma,
2556 uint16_t buffers, uint16_t *mb, uint32_t *dwords)
2560 mbx_cmd_t *mcp = &mc;
2562 if (!IS_QLA25XX(vha->hw) && !IS_QLA81XX(vha->hw))
2563 return QLA_FUNCTION_FAILED;
2565 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2567 mcp->mb[0] = MBC_TRACE_CONTROL;
2568 mcp->mb[1] = TC_FCE_ENABLE;
2569 mcp->mb[2] = LSW(fce_dma);
2570 mcp->mb[3] = MSW(fce_dma);
2571 mcp->mb[4] = LSW(MSD(fce_dma));
2572 mcp->mb[5] = MSW(MSD(fce_dma));
2573 mcp->mb[6] = buffers;
2574 mcp->mb[7] = TC_AEN_DISABLE;
2576 mcp->mb[9] = TC_FCE_DEFAULT_RX_SIZE;
2577 mcp->mb[10] = TC_FCE_DEFAULT_TX_SIZE;
2578 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|
2580 mcp->in_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
2581 mcp->tov = MBX_TOV_SECONDS;
2583 rval = qla2x00_mailbox_command(vha, mcp);
2584 if (rval != QLA_SUCCESS) {
2585 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
2586 __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
2588 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2591 memcpy(mb, mcp->mb, 8 * sizeof(*mb));
2600 qla2x00_disable_fce_trace(scsi_qla_host_t *vha, uint64_t *wr, uint64_t *rd)
2604 mbx_cmd_t *mcp = &mc;
2606 if (!IS_FWI2_CAPABLE(vha->hw))
2607 return QLA_FUNCTION_FAILED;
2609 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2611 mcp->mb[0] = MBC_TRACE_CONTROL;
2612 mcp->mb[1] = TC_FCE_DISABLE;
2613 mcp->mb[2] = TC_FCE_DISABLE_TRACE;
2614 mcp->out_mb = MBX_2|MBX_1|MBX_0;
2615 mcp->in_mb = MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|
2617 mcp->tov = MBX_TOV_SECONDS;
2619 rval = qla2x00_mailbox_command(vha, mcp);
2620 if (rval != QLA_SUCCESS) {
2621 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
2622 __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
2624 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2627 *wr = (uint64_t) mcp->mb[5] << 48 |
2628 (uint64_t) mcp->mb[4] << 32 |
2629 (uint64_t) mcp->mb[3] << 16 |
2630 (uint64_t) mcp->mb[2];
2632 *rd = (uint64_t) mcp->mb[9] << 48 |
2633 (uint64_t) mcp->mb[8] << 32 |
2634 (uint64_t) mcp->mb[7] << 16 |
2635 (uint64_t) mcp->mb[6];
2642 qla2x00_read_sfp(scsi_qla_host_t *vha, dma_addr_t sfp_dma, uint16_t addr,
2643 uint16_t off, uint16_t count)
2647 mbx_cmd_t *mcp = &mc;
2649 if (!IS_FWI2_CAPABLE(vha->hw))
2650 return QLA_FUNCTION_FAILED;
2652 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2654 mcp->mb[0] = MBC_READ_SFP;
2656 mcp->mb[2] = MSW(sfp_dma);
2657 mcp->mb[3] = LSW(sfp_dma);
2658 mcp->mb[6] = MSW(MSD(sfp_dma));
2659 mcp->mb[7] = LSW(MSD(sfp_dma));
2663 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
2665 mcp->tov = MBX_TOV_SECONDS;
2667 rval = qla2x00_mailbox_command(vha, mcp);
2669 if (rval != QLA_SUCCESS) {
2670 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__,
2671 vha->host_no, rval, mcp->mb[0]));
2673 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2680 qla2x00_set_idma_speed(scsi_qla_host_t *vha, uint16_t loop_id,
2681 uint16_t port_speed, uint16_t *mb)
2685 mbx_cmd_t *mcp = &mc;
2687 if (!IS_IIDMA_CAPABLE(vha->hw))
2688 return QLA_FUNCTION_FAILED;
2690 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2692 mcp->mb[0] = MBC_PORT_PARAMS;
2693 mcp->mb[1] = loop_id;
2695 mcp->mb[3] = port_speed & (BIT_2|BIT_1|BIT_0);
2696 mcp->mb[4] = mcp->mb[5] = 0;
2697 mcp->out_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
2698 mcp->in_mb = MBX_5|MBX_4|MBX_3|MBX_1|MBX_0;
2699 mcp->tov = MBX_TOV_SECONDS;
2701 rval = qla2x00_mailbox_command(vha, mcp);
2703 /* Return mailbox statuses. */
2712 if (rval != QLA_SUCCESS) {
2713 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
2714 vha->host_no, rval));
2716 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2723 qla24xx_report_id_acquisition(scsi_qla_host_t *vha,
2724 struct vp_rpt_id_entry_24xx *rptid_entry)
2727 uint16_t stat = le16_to_cpu(rptid_entry->vp_idx);
2728 struct qla_hw_data *ha = vha->hw;
2729 scsi_qla_host_t *vp;
2730 scsi_qla_host_t *tvp;
2732 if (rptid_entry->entry_status != 0)
2735 if (rptid_entry->format == 0) {
2736 DEBUG15(printk("%s:format 0 : scsi(%ld) number of VPs setup %d,"
2737 " number of VPs acquired %d\n", __func__, vha->host_no,
2738 MSB(rptid_entry->vp_count), LSB(rptid_entry->vp_count)));
2739 DEBUG15(printk("%s primary port id %02x%02x%02x\n", __func__,
2740 rptid_entry->port_id[2], rptid_entry->port_id[1],
2741 rptid_entry->port_id[0]));
2742 } else if (rptid_entry->format == 1) {
2744 DEBUG15(printk("%s:format 1: scsi(%ld): VP[%d] enabled "
2746 "with port id %02x%02x%02x\n", __func__, vha->host_no,
2748 rptid_entry->port_id[2], rptid_entry->port_id[1],
2749 rptid_entry->port_id[0]));
2756 list_for_each_entry_safe(vp, tvp, &ha->vp_list, list)
2757 if (vp_idx == vp->vp_idx)
2762 vp->d_id.b.domain = rptid_entry->port_id[2];
2763 vp->d_id.b.area = rptid_entry->port_id[1];
2764 vp->d_id.b.al_pa = rptid_entry->port_id[0];
2767 * Cannot configure here as we are still sitting on the
2768 * response queue. Handle it in dpc context.
2770 set_bit(VP_IDX_ACQUIRED, &vp->vp_flags);
2771 set_bit(VP_DPC_NEEDED, &vha->dpc_flags);
2773 qla2xxx_wake_dpc(vha);
2778 * qla24xx_modify_vp_config
2779 * Change VP configuration for vha
2782 * vha = adapter block pointer.
2785 * qla2xxx local function return status code.
2791 qla24xx_modify_vp_config(scsi_qla_host_t *vha)
2794 struct vp_config_entry_24xx *vpmod;
2795 dma_addr_t vpmod_dma;
2796 struct qla_hw_data *ha = vha->hw;
2797 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
2799 /* This can be called by the parent */
2801 vpmod = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &vpmod_dma);
2803 DEBUG2_3(printk("%s(%ld): failed to allocate Modify VP "
2804 "IOCB.\n", __func__, vha->host_no));
2805 return QLA_MEMORY_ALLOC_FAILED;
2808 memset(vpmod, 0, sizeof(struct vp_config_entry_24xx));
2809 vpmod->entry_type = VP_CONFIG_IOCB_TYPE;
2810 vpmod->entry_count = 1;
2811 vpmod->command = VCT_COMMAND_MOD_ENABLE_VPS;
2812 vpmod->vp_count = 1;
2813 vpmod->vp_index1 = vha->vp_idx;
2814 vpmod->options_idx1 = BIT_3|BIT_4|BIT_5;
2815 memcpy(vpmod->node_name_idx1, vha->node_name, WWN_SIZE);
2816 memcpy(vpmod->port_name_idx1, vha->port_name, WWN_SIZE);
2817 vpmod->entry_count = 1;
2819 rval = qla2x00_issue_iocb(base_vha, vpmod, vpmod_dma, 0);
2820 if (rval != QLA_SUCCESS) {
2821 DEBUG2_3_11(printk("%s(%ld): failed to issue VP config IOCB"
2822 "(%x).\n", __func__, base_vha->host_no, rval));
2823 } else if (vpmod->comp_status != 0) {
2824 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2825 "-- error status (%x).\n", __func__, base_vha->host_no,
2826 vpmod->comp_status));
2827 rval = QLA_FUNCTION_FAILED;
2828 } else if (vpmod->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) {
2829 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2830 "-- completion status (%x).\n", __func__, base_vha->host_no,
2831 le16_to_cpu(vpmod->comp_status)));
2832 rval = QLA_FUNCTION_FAILED;
2835 DEBUG11(printk("%s(%ld): done.\n", __func__,
2836 base_vha->host_no));
2837 fc_vport_set_state(vha->fc_vport, FC_VPORT_INITIALIZING);
2839 dma_pool_free(ha->s_dma_pool, vpmod, vpmod_dma);
2845 * qla24xx_control_vp
2846 * Enable a virtual port for given host
2849 * ha = adapter block pointer.
2850 * vhba = virtual adapter (unused)
2851 * index = index number for enabled VP
2854 * qla2xxx local function return status code.
2860 qla24xx_control_vp(scsi_qla_host_t *vha, int cmd)
2864 struct vp_ctrl_entry_24xx *vce;
2866 struct qla_hw_data *ha = vha->hw;
2867 int vp_index = vha->vp_idx;
2868 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
2870 DEBUG11(printk("%s(%ld): entered. Enabling index %d\n", __func__,
2871 vha->host_no, vp_index));
2873 if (vp_index == 0 || vp_index >= ha->max_npiv_vports)
2874 return QLA_PARAMETER_ERROR;
2876 vce = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &vce_dma);
2878 DEBUG2_3(printk("%s(%ld): "
2879 "failed to allocate VP Control IOCB.\n", __func__,
2880 base_vha->host_no));
2881 return QLA_MEMORY_ALLOC_FAILED;
2883 memset(vce, 0, sizeof(struct vp_ctrl_entry_24xx));
2885 vce->entry_type = VP_CTRL_IOCB_TYPE;
2886 vce->entry_count = 1;
2887 vce->command = cpu_to_le16(cmd);
2888 vce->vp_count = __constant_cpu_to_le16(1);
2890 /* index map in firmware starts with 1; decrement index
2891 * this is ok as we never use index 0
2893 map = (vp_index - 1) / 8;
2894 pos = (vp_index - 1) & 7;
2895 mutex_lock(&ha->vport_lock);
2896 vce->vp_idx_map[map] |= 1 << pos;
2897 mutex_unlock(&ha->vport_lock);
2899 rval = qla2x00_issue_iocb(base_vha, vce, vce_dma, 0);
2900 if (rval != QLA_SUCCESS) {
2901 DEBUG2_3_11(printk("%s(%ld): failed to issue VP control IOCB"
2902 "(%x).\n", __func__, base_vha->host_no, rval));
2903 printk("%s(%ld): failed to issue VP control IOCB"
2904 "(%x).\n", __func__, base_vha->host_no, rval);
2905 } else if (vce->entry_status != 0) {
2906 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2907 "-- error status (%x).\n", __func__, base_vha->host_no,
2908 vce->entry_status));
2909 printk("%s(%ld): failed to complete IOCB "
2910 "-- error status (%x).\n", __func__, base_vha->host_no,
2912 rval = QLA_FUNCTION_FAILED;
2913 } else if (vce->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) {
2914 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2915 "-- completion status (%x).\n", __func__, base_vha->host_no,
2916 le16_to_cpu(vce->comp_status)));
2917 printk("%s(%ld): failed to complete IOCB "
2918 "-- completion status (%x).\n", __func__, base_vha->host_no,
2919 le16_to_cpu(vce->comp_status));
2920 rval = QLA_FUNCTION_FAILED;
2922 DEBUG2(printk("%s(%ld): done.\n", __func__, base_vha->host_no));
2925 dma_pool_free(ha->s_dma_pool, vce, vce_dma);
2931 * qla2x00_send_change_request
2932 * Receive or disable RSCN request from fabric controller
2935 * ha = adapter block pointer
2936 * format = registration format:
2938 * 1 - Fabric detected registration
2939 * 2 - N_port detected registration
2940 * 3 - Full registration
2941 * FF - clear registration
2942 * vp_idx = Virtual port index
2945 * qla2x00 local function return status code.
2952 qla2x00_send_change_request(scsi_qla_host_t *vha, uint16_t format,
2957 mbx_cmd_t *mcp = &mc;
2960 * This command is implicitly executed by firmware during login for the
2964 return QLA_FUNCTION_FAILED;
2966 mcp->mb[0] = MBC_SEND_CHANGE_REQUEST;
2967 mcp->mb[1] = format;
2968 mcp->mb[9] = vp_idx;
2969 mcp->out_mb = MBX_9|MBX_1|MBX_0;
2970 mcp->in_mb = MBX_0|MBX_1;
2971 mcp->tov = MBX_TOV_SECONDS;
2973 rval = qla2x00_mailbox_command(vha, mcp);
2975 if (rval == QLA_SUCCESS) {
2976 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) {
2986 qla2x00_dump_ram(scsi_qla_host_t *vha, dma_addr_t req_dma, uint32_t addr,
2991 mbx_cmd_t *mcp = &mc;
2993 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2995 if (MSW(addr) || IS_FWI2_CAPABLE(vha->hw)) {
2996 mcp->mb[0] = MBC_DUMP_RISC_RAM_EXTENDED;
2997 mcp->mb[8] = MSW(addr);
2998 mcp->out_mb = MBX_8|MBX_0;
3000 mcp->mb[0] = MBC_DUMP_RISC_RAM;
3001 mcp->out_mb = MBX_0;
3003 mcp->mb[1] = LSW(addr);
3004 mcp->mb[2] = MSW(req_dma);
3005 mcp->mb[3] = LSW(req_dma);
3006 mcp->mb[6] = MSW(MSD(req_dma));
3007 mcp->mb[7] = LSW(MSD(req_dma));
3008 mcp->out_mb |= MBX_7|MBX_6|MBX_3|MBX_2|MBX_1;
3009 if (IS_FWI2_CAPABLE(vha->hw)) {
3010 mcp->mb[4] = MSW(size);
3011 mcp->mb[5] = LSW(size);
3012 mcp->out_mb |= MBX_5|MBX_4;
3014 mcp->mb[4] = LSW(size);
3015 mcp->out_mb |= MBX_4;
3019 mcp->tov = MBX_TOV_SECONDS;
3021 rval = qla2x00_mailbox_command(vha, mcp);
3023 if (rval != QLA_SUCCESS) {
3024 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__,
3025 vha->host_no, rval, mcp->mb[0]));
3027 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
3033 /* 84XX Support **************************************************************/
3035 struct cs84xx_mgmt_cmd {
3037 struct verify_chip_entry_84xx req;
3038 struct verify_chip_rsp_84xx rsp;
3043 qla84xx_verify_chip(struct scsi_qla_host *vha, uint16_t *status)
3046 struct cs84xx_mgmt_cmd *mn;
3049 unsigned long flags;
3050 struct qla_hw_data *ha = vha->hw;
3052 DEBUG16(printk("%s(%ld): entered.\n", __func__, vha->host_no));
3054 mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma);
3056 DEBUG2_3(printk("%s(%ld): failed to allocate Verify ISP84XX "
3057 "IOCB.\n", __func__, vha->host_no));
3058 return QLA_MEMORY_ALLOC_FAILED;
3062 options = ha->cs84xx->fw_update ? VCO_FORCE_UPDATE : 0;
3063 /* Diagnostic firmware? */
3064 /* options |= MENLO_DIAG_FW; */
3065 /* We update the firmware with only one data sequence. */
3066 options |= VCO_END_OF_DATA;
3070 memset(mn, 0, sizeof(*mn));
3071 mn->p.req.entry_type = VERIFY_CHIP_IOCB_TYPE;
3072 mn->p.req.entry_count = 1;
3073 mn->p.req.options = cpu_to_le16(options);
3075 DEBUG16(printk("%s(%ld): Dump of Verify Request.\n", __func__,
3077 DEBUG16(qla2x00_dump_buffer((uint8_t *)mn,
3080 rval = qla2x00_issue_iocb_timeout(vha, mn, mn_dma, 0, 120);
3081 if (rval != QLA_SUCCESS) {
3082 DEBUG2_16(printk("%s(%ld): failed to issue Verify "
3083 "IOCB (%x).\n", __func__, vha->host_no, rval));
3087 DEBUG16(printk("%s(%ld): Dump of Verify Response.\n", __func__,
3089 DEBUG16(qla2x00_dump_buffer((uint8_t *)mn,
3092 status[0] = le16_to_cpu(mn->p.rsp.comp_status);
3093 status[1] = status[0] == CS_VCS_CHIP_FAILURE ?
3094 le16_to_cpu(mn->p.rsp.failure_code) : 0;
3095 DEBUG2_16(printk("%s(%ld): cs=%x fc=%x\n", __func__,
3096 vha->host_no, status[0], status[1]));
3098 if (status[0] != CS_COMPLETE) {
3099 rval = QLA_FUNCTION_FAILED;
3100 if (!(options & VCO_DONT_UPDATE_FW)) {
3101 DEBUG2_16(printk("%s(%ld): Firmware update "
3102 "failed. Retrying without update "
3103 "firmware.\n", __func__, vha->host_no));
3104 options |= VCO_DONT_UPDATE_FW;
3105 options &= ~VCO_FORCE_UPDATE;
3109 DEBUG2_16(printk("%s(%ld): firmware updated to %x.\n",
3110 __func__, vha->host_no,
3111 le32_to_cpu(mn->p.rsp.fw_ver)));
3113 /* NOTE: we only update OP firmware. */
3114 spin_lock_irqsave(&ha->cs84xx->access_lock, flags);
3115 ha->cs84xx->op_fw_version =
3116 le32_to_cpu(mn->p.rsp.fw_ver);
3117 spin_unlock_irqrestore(&ha->cs84xx->access_lock,
3123 dma_pool_free(ha->s_dma_pool, mn, mn_dma);
3125 if (rval != QLA_SUCCESS) {
3126 DEBUG2_16(printk("%s(%ld): failed=%x.\n", __func__,
3127 vha->host_no, rval));
3129 DEBUG16(printk("%s(%ld): done.\n", __func__, vha->host_no));
3136 qla25xx_init_req_que(struct scsi_qla_host *vha, struct req_que *req)
3139 unsigned long flags;
3141 mbx_cmd_t *mcp = &mc;
3142 struct device_reg_25xxmq __iomem *reg;
3143 struct qla_hw_data *ha = vha->hw;
3145 mcp->mb[0] = MBC_INITIALIZE_MULTIQ;
3146 mcp->mb[1] = req->options;
3147 mcp->mb[2] = MSW(LSD(req->dma));
3148 mcp->mb[3] = LSW(LSD(req->dma));
3149 mcp->mb[6] = MSW(MSD(req->dma));
3150 mcp->mb[7] = LSW(MSD(req->dma));
3151 mcp->mb[5] = req->length;
3153 mcp->mb[10] = req->rsp->id;
3154 mcp->mb[12] = req->qos;
3155 mcp->mb[11] = req->vp_idx;
3156 mcp->mb[13] = req->rid;
3158 reg = (struct device_reg_25xxmq *)((void *)(ha->mqiobase) +
3159 QLA_QUE_PAGE * req->id);
3161 mcp->mb[4] = req->id;
3162 /* que in ptr index */
3164 /* que out ptr index */
3166 mcp->out_mb = MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8|MBX_7|
3167 MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
3169 mcp->flags = MBX_DMA_OUT;
3172 spin_lock_irqsave(&ha->hardware_lock, flags);
3173 if (!(req->options & BIT_0)) {
3174 WRT_REG_DWORD(®->req_q_in, 0);
3175 WRT_REG_DWORD(®->req_q_out, 0);
3177 req->req_q_in = ®->req_q_in;
3178 req->req_q_out = ®->req_q_out;
3179 spin_unlock_irqrestore(&ha->hardware_lock, flags);
3181 rval = qla2x00_mailbox_command(vha, mcp);
3182 if (rval != QLA_SUCCESS)
3183 DEBUG2_3_11(printk(KERN_WARNING "%s(%ld): failed=%x mb0=%x.\n",
3184 __func__, vha->host_no, rval, mcp->mb[0]));
3189 qla25xx_init_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp)
3192 unsigned long flags;
3194 mbx_cmd_t *mcp = &mc;
3195 struct device_reg_25xxmq __iomem *reg;
3196 struct qla_hw_data *ha = vha->hw;
3198 mcp->mb[0] = MBC_INITIALIZE_MULTIQ;
3199 mcp->mb[1] = rsp->options;
3200 mcp->mb[2] = MSW(LSD(rsp->dma));
3201 mcp->mb[3] = LSW(LSD(rsp->dma));
3202 mcp->mb[6] = MSW(MSD(rsp->dma));
3203 mcp->mb[7] = LSW(MSD(rsp->dma));
3204 mcp->mb[5] = rsp->length;
3205 mcp->mb[14] = rsp->msix->entry;
3206 mcp->mb[13] = rsp->rid;
3208 reg = (struct device_reg_25xxmq *)((void *)(ha->mqiobase) +
3209 QLA_QUE_PAGE * rsp->id);
3211 mcp->mb[4] = rsp->id;
3212 /* que in ptr index */
3214 /* que out ptr index */
3216 mcp->out_mb = MBX_14|MBX_13|MBX_9|MBX_8|MBX_7
3217 |MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
3219 mcp->flags = MBX_DMA_OUT;
3222 spin_lock_irqsave(&ha->hardware_lock, flags);
3223 if (!(rsp->options & BIT_0)) {
3224 WRT_REG_DWORD(®->rsp_q_out, 0);
3225 WRT_REG_DWORD(®->rsp_q_in, 0);
3228 spin_unlock_irqrestore(&ha->hardware_lock, flags);
3230 rval = qla2x00_mailbox_command(vha, mcp);
3231 if (rval != QLA_SUCCESS)
3232 DEBUG2_3_11(printk(KERN_WARNING "%s(%ld): failed=%x "
3233 "mb0=%x.\n", __func__,
3234 vha->host_no, rval, mcp->mb[0]));
3239 qla81xx_idc_ack(scsi_qla_host_t *vha, uint16_t *mb)
3243 mbx_cmd_t *mcp = &mc;
3245 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
3247 mcp->mb[0] = MBC_IDC_ACK;
3248 memcpy(&mcp->mb[1], mb, QLA_IDC_ACK_REGS * sizeof(uint16_t));
3249 mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
3251 mcp->tov = MBX_TOV_SECONDS;
3253 rval = qla2x00_mailbox_command(vha, mcp);
3255 if (rval != QLA_SUCCESS) {
3256 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__,
3257 vha->host_no, rval, mcp->mb[0]));
3259 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
3266 qla81xx_fac_get_sector_size(scsi_qla_host_t *vha, uint32_t *sector_size)
3270 mbx_cmd_t *mcp = &mc;
3272 if (!IS_QLA81XX(vha->hw))
3273 return QLA_FUNCTION_FAILED;
3275 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
3277 mcp->mb[0] = MBC_FLASH_ACCESS_CTRL;
3278 mcp->mb[1] = FAC_OPT_CMD_GET_SECTOR_SIZE;
3279 mcp->out_mb = MBX_1|MBX_0;
3280 mcp->in_mb = MBX_1|MBX_0;
3281 mcp->tov = MBX_TOV_SECONDS;
3283 rval = qla2x00_mailbox_command(vha, mcp);
3285 if (rval != QLA_SUCCESS) {
3286 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
3287 __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
3289 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
3290 *sector_size = mcp->mb[1];
3297 qla81xx_fac_do_write_enable(scsi_qla_host_t *vha, int enable)
3301 mbx_cmd_t *mcp = &mc;
3303 if (!IS_QLA81XX(vha->hw))
3304 return QLA_FUNCTION_FAILED;
3306 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
3308 mcp->mb[0] = MBC_FLASH_ACCESS_CTRL;
3309 mcp->mb[1] = enable ? FAC_OPT_CMD_WRITE_ENABLE :
3310 FAC_OPT_CMD_WRITE_PROTECT;
3311 mcp->out_mb = MBX_1|MBX_0;
3312 mcp->in_mb = MBX_1|MBX_0;
3313 mcp->tov = MBX_TOV_SECONDS;
3315 rval = qla2x00_mailbox_command(vha, mcp);
3317 if (rval != QLA_SUCCESS) {
3318 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
3319 __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
3321 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
3328 qla81xx_fac_erase_sector(scsi_qla_host_t *vha, uint32_t start, uint32_t finish)
3332 mbx_cmd_t *mcp = &mc;
3334 if (!IS_QLA81XX(vha->hw))
3335 return QLA_FUNCTION_FAILED;
3337 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
3339 mcp->mb[0] = MBC_FLASH_ACCESS_CTRL;
3340 mcp->mb[1] = FAC_OPT_CMD_ERASE_SECTOR;
3341 mcp->mb[2] = LSW(start);
3342 mcp->mb[3] = MSW(start);
3343 mcp->mb[4] = LSW(finish);
3344 mcp->mb[5] = MSW(finish);
3345 mcp->out_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
3346 mcp->in_mb = MBX_2|MBX_1|MBX_0;
3347 mcp->tov = MBX_TOV_SECONDS;
3349 rval = qla2x00_mailbox_command(vha, mcp);
3351 if (rval != QLA_SUCCESS) {
3352 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x "
3353 "mb[2]=%x.\n", __func__, vha->host_no, rval, mcp->mb[0],
3354 mcp->mb[1], mcp->mb[2]));
3356 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
3363 qla81xx_restart_mpi_firmware(scsi_qla_host_t *vha)
3367 mbx_cmd_t *mcp = &mc;
3369 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
3371 mcp->mb[0] = MBC_RESTART_MPI_FW;
3372 mcp->out_mb = MBX_0;
3373 mcp->in_mb = MBX_0|MBX_1;
3374 mcp->tov = MBX_TOV_SECONDS;
3376 rval = qla2x00_mailbox_command(vha, mcp);
3378 if (rval != QLA_SUCCESS) {
3379 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=0x%x mb[1]=0x%x.\n",
3380 __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
3382 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
3389 qla2x00_read_edc(scsi_qla_host_t *vha, uint16_t dev, uint16_t adr,
3390 dma_addr_t sfp_dma, uint8_t *sfp, uint16_t len, uint16_t opt)
3394 mbx_cmd_t *mcp = &mc;
3396 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
3398 mcp->mb[0] = MBC_READ_SFP;
3400 mcp->mb[2] = MSW(sfp_dma);
3401 mcp->mb[3] = LSW(sfp_dma);
3402 mcp->mb[6] = MSW(MSD(sfp_dma));
3403 mcp->mb[7] = LSW(MSD(sfp_dma));
3407 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
3409 mcp->tov = MBX_TOV_SECONDS;
3411 rval = qla2x00_mailbox_command(vha, mcp);
3417 if (rval != QLA_SUCCESS) {
3418 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__,
3419 vha->host_no, rval, mcp->mb[0]));
3421 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
3428 qla2x00_write_edc(scsi_qla_host_t *vha, uint16_t dev, uint16_t adr,
3429 dma_addr_t sfp_dma, uint8_t *sfp, uint16_t len, uint16_t opt)
3433 mbx_cmd_t *mcp = &mc;
3435 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
3441 mcp->mb[0] = MBC_WRITE_SFP;
3443 mcp->mb[2] = MSW(sfp_dma);
3444 mcp->mb[3] = LSW(sfp_dma);
3445 mcp->mb[6] = MSW(MSD(sfp_dma));
3446 mcp->mb[7] = LSW(MSD(sfp_dma));
3450 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
3452 mcp->tov = MBX_TOV_SECONDS;
3454 rval = qla2x00_mailbox_command(vha, mcp);
3456 if (rval != QLA_SUCCESS) {
3457 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__,
3458 vha->host_no, rval, mcp->mb[0]));
3460 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
3467 qla2x00_get_xgmac_stats(scsi_qla_host_t *vha, dma_addr_t stats_dma,
3468 uint16_t size_in_bytes, uint16_t *actual_size)
3472 mbx_cmd_t *mcp = &mc;
3474 if (!IS_QLA81XX(vha->hw))
3475 return QLA_FUNCTION_FAILED;
3477 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
3479 mcp->mb[0] = MBC_GET_XGMAC_STATS;
3480 mcp->mb[2] = MSW(stats_dma);
3481 mcp->mb[3] = LSW(stats_dma);
3482 mcp->mb[6] = MSW(MSD(stats_dma));
3483 mcp->mb[7] = LSW(MSD(stats_dma));
3484 mcp->mb[8] = size_in_bytes >> 2;
3485 mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
3486 mcp->in_mb = MBX_2|MBX_1|MBX_0;
3487 mcp->tov = MBX_TOV_SECONDS;
3489 rval = qla2x00_mailbox_command(vha, mcp);
3491 if (rval != QLA_SUCCESS) {
3492 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=0x%x "
3493 "mb[1]=0x%x mb[2]=0x%x.\n", __func__, vha->host_no, rval,
3494 mcp->mb[0], mcp->mb[1], mcp->mb[2]));
3496 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
3498 *actual_size = mcp->mb[2] << 2;
3505 qla2x00_get_dcbx_params(scsi_qla_host_t *vha, dma_addr_t tlv_dma,
3510 mbx_cmd_t *mcp = &mc;
3512 if (!IS_QLA81XX(vha->hw))
3513 return QLA_FUNCTION_FAILED;
3515 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
3517 mcp->mb[0] = MBC_GET_DCBX_PARAMS;
3519 mcp->mb[2] = MSW(tlv_dma);
3520 mcp->mb[3] = LSW(tlv_dma);
3521 mcp->mb[6] = MSW(MSD(tlv_dma));
3522 mcp->mb[7] = LSW(MSD(tlv_dma));
3524 mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
3525 mcp->in_mb = MBX_2|MBX_1|MBX_0;
3526 mcp->tov = MBX_TOV_SECONDS;
3528 rval = qla2x00_mailbox_command(vha, mcp);
3530 if (rval != QLA_SUCCESS) {
3531 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=0x%x "
3532 "mb[1]=0x%x mb[2]=0x%x.\n", __func__, vha->host_no, rval,
3533 mcp->mb[0], mcp->mb[1], mcp->mb[2]));
3535 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));