[SCSI] ibmvscsi: convert to use the data buffer accessors
[safe/jmp/linux-2.6] / drivers / scsi / qla2xxx / qla_mbx.c
index 267435f..2cd0cff 100644 (file)
@@ -13,13 +13,13 @@ qla2x00_mbx_sem_timeout(unsigned long data)
 {
        struct semaphore        *sem_ptr = (struct semaphore *)data;
 
-       DEBUG11(printk("qla2x00_sem_timeout: entered.\n");)
+       DEBUG11(printk("qla2x00_sem_timeout: entered.\n"));
 
        if (sem_ptr != NULL) {
                up(sem_ptr);
        }
 
-       DEBUG11(printk("qla2x00_mbx_sem_timeout: exiting.\n");)
+       DEBUG11(printk("qla2x00_mbx_sem_timeout: exiting.\n"));
 }
 
 /*
@@ -42,26 +42,29 @@ qla2x00_mbx_sem_timeout(unsigned long data)
  *     Kernel context.
  */
 static int
-qla2x00_mailbox_command(scsi_qla_host_t *ha, mbx_cmd_t *mcp)
+qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
 {
        int             rval;
        unsigned long    flags = 0;
-       device_reg_t __iomem *reg = ha->iobase;
+       device_reg_t __iomem *reg;
        struct timer_list       tmp_intr_timer;
        uint8_t         abort_active;
-       uint8_t         io_lock_on = ha->flags.init_done;
+       uint8_t         io_lock_on;
        uint16_t        command;
        uint16_t        *iptr;
        uint16_t __iomem *optr;
        uint32_t        cnt;
        uint32_t        mboxes;
-       unsigned long   mbx_flags = 0;
        unsigned long   wait_time;
+       scsi_qla_host_t *ha = to_qla_parent(pvha);
+
+       reg = ha->iobase;
+       io_lock_on = ha->flags.init_done;
 
        rval = QLA_SUCCESS;
        abort_active = test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags);
 
-       DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no);)
+       DEBUG11(printk("%s(%ld): entered.\n", __func__, pvha->host_no));
 
        /*
         * Wait for active mailbox commands to finish by waiting at most tov
@@ -72,7 +75,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *ha, mbx_cmd_t *mcp)
                if (qla2x00_down_timeout(&ha->mbx_cmd_sem, mcp->tov * HZ)) {
                        /* Timeout occurred. Return error. */
                        DEBUG2_3_11(printk("%s(%ld): cmd access timeout. "
-                           "Exiting.\n", __func__, ha->host_no);)
+                           "Exiting.\n", __func__, ha->host_no));
                        return QLA_FUNCTION_TIMEOUT;
                }
        }
@@ -81,12 +84,8 @@ qla2x00_mailbox_command(scsi_qla_host_t *ha, mbx_cmd_t *mcp)
        /* Save mailbox command for debug */
        ha->mcp = mcp;
 
-       /* Try to get mailbox register access */
-       if (!abort_active)
-               spin_lock_irqsave(&ha->mbx_reg_lock, mbx_flags);
-
        DEBUG11(printk("scsi(%ld): prepare to issue mbox cmd=0x%x.\n",
-           ha->host_no, mcp->mb[0]);)
+           ha->host_no, mcp->mb[0]));
 
        spin_lock_irqsave(&ha->hardware_lock, flags);
 
@@ -131,14 +130,14 @@ qla2x00_mailbox_command(scsi_qla_host_t *ha, mbx_cmd_t *mcp)
 
        /* Unlock mbx registers and wait for interrupt */
        DEBUG11(printk("%s(%ld): going to unlock irq & waiting for interrupt. "
-           "jiffies=%lx.\n", __func__, ha->host_no, jiffies);)
+           "jiffies=%lx.\n", __func__, ha->host_no, jiffies));
 
        /* Wait for mbx cmd completion until timeout */
 
        if (!abort_active && io_lock_on) {
                /* sleep on completion semaphore */
                DEBUG11(printk("%s(%ld): INTERRUPT MODE. Initializing timer.\n",
-                   __func__, ha->host_no);)
+                   __func__, ha->host_no));
 
                init_timer(&tmp_intr_timer);
                tmp_intr_timer.data = (unsigned long)&ha->mbx_intr_sem;
@@ -147,11 +146,11 @@ qla2x00_mailbox_command(scsi_qla_host_t *ha, mbx_cmd_t *mcp)
                    (void (*)(unsigned long))qla2x00_mbx_sem_timeout;
 
                DEBUG11(printk("%s(%ld): Adding timer.\n", __func__,
-                   ha->host_no);)
+                   ha->host_no));
                add_timer(&tmp_intr_timer);
 
                DEBUG11(printk("%s(%ld): going to unlock & sleep. "
-                   "time=0x%lx.\n", __func__, ha->host_no, jiffies);)
+                   "time=0x%lx.\n", __func__, ha->host_no, jiffies));
 
                set_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags);
 
@@ -161,31 +160,26 @@ qla2x00_mailbox_command(scsi_qla_host_t *ha, mbx_cmd_t *mcp)
                        WRT_REG_WORD(&reg->isp.hccr, HCCR_SET_HOST_INT);
                spin_unlock_irqrestore(&ha->hardware_lock, flags);
 
-               if (!abort_active)
-                       spin_unlock_irqrestore(&ha->mbx_reg_lock, mbx_flags);
-
                /* Wait for either the timer to expire
                 * or the mbox completion interrupt
                 */
                down(&ha->mbx_intr_sem);
 
                DEBUG11(printk("%s(%ld): waking up. time=0x%lx\n", __func__,
-                   ha->host_no, jiffies);)
+                   ha->host_no, jiffies));
                clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags);
 
                /* delete the timer */
                del_timer(&tmp_intr_timer);
        } else {
                DEBUG3_11(printk("%s(%ld): cmd=%x POLLING MODE.\n", __func__,
-                   ha->host_no, command);)
+                   ha->host_no, command));
 
                if (IS_QLA24XX(ha) || IS_QLA54XX(ha))
                        WRT_REG_DWORD(&reg->isp24.hccr, HCCRX_SET_HOST_INT);
                else
                        WRT_REG_WORD(&reg->isp.hccr, HCCR_SET_HOST_INT);
                spin_unlock_irqrestore(&ha->hardware_lock, flags);
-               if (!abort_active)
-                       spin_unlock_irqrestore(&ha->mbx_reg_lock, mbx_flags);
 
                wait_time = jiffies + mcp->tov * HZ; /* wait at most tov secs */
                while (!ha->flags.mbox_int) {
@@ -201,15 +195,12 @@ qla2x00_mailbox_command(scsi_qla_host_t *ha, mbx_cmd_t *mcp)
                } /* while */
        }
 
-       if (!abort_active)
-               spin_lock_irqsave(&ha->mbx_reg_lock, mbx_flags);
-
        /* Check whether we timed out */
        if (ha->flags.mbox_int) {
                uint16_t *iptr2;
 
                DEBUG3_11(printk("%s(%ld): cmd %x completed.\n", __func__,
-                   ha->host_no, command);)
+                   ha->host_no, command));
 
                /* Got interrupt. Clear the flag. */
                ha->flags.mbox_int = 0;
@@ -256,9 +247,6 @@ qla2x00_mailbox_command(scsi_qla_host_t *ha, mbx_cmd_t *mcp)
                rval = QLA_FUNCTION_TIMEOUT;
        }
 
-       if (!abort_active)
-               spin_unlock_irqrestore(&ha->mbx_reg_lock, mbx_flags);
-
        ha->flags.mbox_busy = 0;
 
        /* Clean up */
@@ -266,7 +254,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *ha, mbx_cmd_t *mcp)
 
        if (!abort_active) {
                DEBUG11(printk("%s(%ld): checking for additional resp "
-                   "interrupt.\n", __func__, ha->host_no);)
+                   "interrupt.\n", __func__, ha->host_no));
 
                /* polling mode for non isp_abort commands. */
                qla2x00_poll(ha);
@@ -277,9 +265,9 @@ qla2x00_mailbox_command(scsi_qla_host_t *ha, mbx_cmd_t *mcp)
                if (!io_lock_on || (mcp->flags & IOCTL_CMD)) {
                        /* not in dpc. schedule it for dpc to take over. */
                        DEBUG(printk("%s(%ld): timeout schedule "
-                           "isp_abort_needed.\n", __func__, ha->host_no);)
+                           "isp_abort_needed.\n", __func__, ha->host_no));
                        DEBUG2_3_11(printk("%s(%ld): timeout schedule "
-                           "isp_abort_needed.\n", __func__, ha->host_no);)
+                           "isp_abort_needed.\n", __func__, ha->host_no));
                        qla_printk(KERN_WARNING, ha,
                            "Mailbox command timeout occured. Scheduling ISP "
                            "abort.\n");
@@ -288,9 +276,9 @@ qla2x00_mailbox_command(scsi_qla_host_t *ha, mbx_cmd_t *mcp)
                } else if (!abort_active) {
                        /* call abort directly since we are in the DPC thread */
                        DEBUG(printk("%s(%ld): timeout calling abort_isp\n",
-                           __func__, ha->host_no);)
+                           __func__, ha->host_no));
                        DEBUG2_3_11(printk("%s(%ld): timeout calling "
-                           "abort_isp\n", __func__, ha->host_no);)
+                           "abort_isp\n", __func__, ha->host_no));
                        qla_printk(KERN_WARNING, ha,
                            "Mailbox command timeout occured. Issuing ISP "
                            "abort.\n");
@@ -303,9 +291,9 @@ qla2x00_mailbox_command(scsi_qla_host_t *ha, mbx_cmd_t *mcp)
                        }
                        clear_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags);
                        DEBUG(printk("%s(%ld): finished abort_isp\n", __func__,
-                           ha->host_no);)
+                           ha->host_no));
                        DEBUG2_3_11(printk("%s(%ld): finished abort_isp\n",
-                           __func__, ha->host_no);)
+                           __func__, ha->host_no));
                }
        }
 
@@ -316,9 +304,9 @@ qla2x00_mailbox_command(scsi_qla_host_t *ha, mbx_cmd_t *mcp)
        if (rval) {
                DEBUG2_3_11(printk("%s(%ld): **** FAILED. mbx0=%x, mbx1=%x, "
                    "mbx2=%x, cmd=%x ****\n", __func__, ha->host_no,
-                   mcp->mb[0], mcp->mb[1], mcp->mb[2], command);)
+                   mcp->mb[0], mcp->mb[1], mcp->mb[2], command));
        } else {
-               DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no);)
+               DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
        }
 
        return rval;
@@ -394,7 +382,7 @@ qla2x00_execute_fw(scsi_qla_host_t *ha, uint32_t risc_addr)
        mbx_cmd_t mc;
        mbx_cmd_t *mcp = &mc;
 
-       DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no);)
+       DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
 
        mcp->mb[0] = MBC_EXECUTE_FIRMWARE;
        mcp->out_mb = MBX_0;
@@ -424,10 +412,10 @@ qla2x00_execute_fw(scsi_qla_host_t *ha, uint32_t risc_addr)
        } else {
                if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) {
                        DEBUG11(printk("%s(%ld): done exchanges=%x.\n",
-                           __func__, ha->host_no, mcp->mb[1]);)
+                           __func__, ha->host_no, mcp->mb[1]));
                } else {
                        DEBUG11(printk("%s(%ld): done.\n", __func__,
-                           ha->host_no);)
+                           ha->host_no));
                }
        }
 
@@ -611,7 +599,7 @@ qla2x00_mbx_reg_test(scsi_qla_host_t *ha)
        mbx_cmd_t mc;
        mbx_cmd_t *mcp = &mc;
 
-       DEBUG11(printk("qla2x00_mbx_reg_test(%ld): entered.\n", ha->host_no);)
+       DEBUG11(printk("qla2x00_mbx_reg_test(%ld): entered.\n", ha->host_no));
 
        mcp->mb[0] = MBC_MAILBOX_REGISTER_TEST;
        mcp->mb[1] = 0xAAAA;
@@ -639,11 +627,11 @@ qla2x00_mbx_reg_test(scsi_qla_host_t *ha)
        if (rval != QLA_SUCCESS) {
                /*EMPTY*/
                DEBUG2_3_11(printk("qla2x00_mbx_reg_test(%ld): failed=%x.\n",
-                   ha->host_no, rval);)
+                   ha->host_no, rval));
        } else {
                /*EMPTY*/
                DEBUG11(printk("qla2x00_mbx_reg_test(%ld): done.\n",
-                   ha->host_no);)
+                   ha->host_no));
        }
 
        return rval;
@@ -671,7 +659,7 @@ qla2x00_verify_checksum(scsi_qla_host_t *ha, uint32_t risc_addr)
        mbx_cmd_t mc;
        mbx_cmd_t *mcp = &mc;
 
-       DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no);)
+       DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
 
        mcp->mb[0] = MBC_VERIFY_CHECKSUM;
        mcp->out_mb = MBX_0;
@@ -694,9 +682,9 @@ qla2x00_verify_checksum(scsi_qla_host_t *ha, uint32_t risc_addr)
        if (rval != QLA_SUCCESS) {
                DEBUG2_3_11(printk("%s(%ld): failed=%x chk sum=%x.\n", __func__,
                    ha->host_no, rval, (IS_QLA24XX(ha) || IS_QLA54XX(ha) ?
-                   (mcp->mb[2] << 16) | mcp->mb[1]: mcp->mb[1]));)
+                   (mcp->mb[2] << 16) | mcp->mb[1]: mcp->mb[1])));
        } else {
-               DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no);)
+               DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
        }
 
        return rval;
@@ -743,9 +731,9 @@ qla2x00_issue_iocb(scsi_qla_host_t *ha, void*  buffer, dma_addr_t phys_addr,
        if (rval != QLA_SUCCESS) {
                /*EMPTY*/
                DEBUG(printk("qla2x00_issue_iocb(%ld): failed rval 0x%x\n",
-                   ha->host_no, rval);)
+                   ha->host_no, rval));
                DEBUG2(printk("qla2x00_issue_iocb(%ld): failed rval 0x%x\n",
-                   ha->host_no, rval);)
+                   ha->host_no, rval));
        } else {
                sts_entry_t *sts_entry = (sts_entry_t *) buffer;
 
@@ -781,7 +769,7 @@ qla2x00_abort_command(scsi_qla_host_t *ha, srb_t *sp)
        mbx_cmd_t       mc;
        mbx_cmd_t       *mcp = &mc;
 
-       DEBUG11(printk("qla2x00_abort_command(%ld): entered.\n", ha->host_no);)
+       DEBUG11(printk("qla2x00_abort_command(%ld): entered.\n", ha->host_no));
 
        fcport = sp->fcport;
 
@@ -813,11 +801,11 @@ qla2x00_abort_command(scsi_qla_host_t *ha, srb_t *sp)
 
        if (rval != QLA_SUCCESS) {
                DEBUG2_3_11(printk("qla2x00_abort_command(%ld): failed=%x.\n",
-                   ha->host_no, rval);)
+                   ha->host_no, rval));
        } else {
                sp->flags |= SRB_ABORT_PENDING;
                DEBUG11(printk("qla2x00_abort_command(%ld): done.\n",
-                   ha->host_no);)
+                   ha->host_no));
        }
 
        return rval;
@@ -848,7 +836,7 @@ qla2x00_abort_target(fc_port_t *fcport)
        if (fcport == NULL)
                return 0;
 
-       DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->ha->host_no);)
+       DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->ha->host_no));
 
        ha = fcport->ha;
        mcp->mb[0] = MBC_ABORT_TARGET;
@@ -872,11 +860,11 @@ qla2x00_abort_target(fc_port_t *fcport)
 
        if (rval != QLA_SUCCESS) {
                DEBUG2_3_11(printk("qla2x00_abort_target(%ld): failed=%x.\n",
-                   ha->host_no, rval);)
+                   ha->host_no, rval));
        } else {
                /*EMPTY*/
                DEBUG11(printk("qla2x00_abort_target(%ld): done.\n",
-                   ha->host_no);)
+                   ha->host_no));
        }
 
        return rval;
@@ -905,18 +893,19 @@ qla2x00_abort_target(fc_port_t *fcport)
  */
 int
 qla2x00_get_adapter_id(scsi_qla_host_t *ha, uint16_t *id, uint8_t *al_pa,
-    uint8_t *area, uint8_t *domain, uint16_t *top)
+    uint8_t *area, uint8_t *domain, uint16_t *top, uint16_t *sw_cap)
 {
        int rval;
        mbx_cmd_t mc;
        mbx_cmd_t *mcp = &mc;
 
        DEBUG11(printk("qla2x00_get_adapter_id(%ld): entered.\n",
-           ha->host_no);)
+           ha->host_no));
 
        mcp->mb[0] = MBC_GET_ADAPTER_LOOP_ID;
+       mcp->mb[9] = ha->vp_idx;
        mcp->out_mb = MBX_0;
-       mcp->in_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
+       mcp->in_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
        mcp->tov = 30;
        mcp->flags = 0;
        rval = qla2x00_mailbox_command(ha, mcp);
@@ -929,15 +918,16 @@ qla2x00_get_adapter_id(scsi_qla_host_t *ha, uint16_t *id, uint8_t *al_pa,
        *area = MSB(mcp->mb[2]);
        *domain = LSB(mcp->mb[3]);
        *top = mcp->mb[6];
+       *sw_cap = mcp->mb[7];
 
        if (rval != QLA_SUCCESS) {
                /*EMPTY*/
                DEBUG2_3_11(printk("qla2x00_get_adapter_id(%ld): failed=%x.\n",
-                   ha->host_no, rval);)
+                   ha->host_no, rval));
        } else {
                /*EMPTY*/
                DEBUG11(printk("qla2x00_get_adapter_id(%ld): done.\n",
-                   ha->host_no);)
+                   ha->host_no));
        }
 
        return rval;
@@ -968,7 +958,7 @@ qla2x00_get_retry_cnt(scsi_qla_host_t *ha, uint8_t *retry_cnt, uint8_t *tov,
        mbx_cmd_t *mcp = &mc;
 
        DEBUG11(printk("qla2x00_get_retry_cnt(%ld): entered.\n",
-                       ha->host_no);)
+                       ha->host_no));
 
        mcp->mb[0] = MBC_GET_RETRY_COUNT;
        mcp->out_mb = MBX_0;
@@ -980,7 +970,7 @@ qla2x00_get_retry_cnt(scsi_qla_host_t *ha, uint8_t *retry_cnt, uint8_t *tov,
        if (rval != QLA_SUCCESS) {
                /*EMPTY*/
                DEBUG2_3_11(printk("qla2x00_get_retry_cnt(%ld): failed = %x.\n",
-                   ha->host_no, mcp->mb[0]);)
+                   ha->host_no, mcp->mb[0]));
        } else {
                /* Convert returned data and check our values. */
                *r_a_tov = mcp->mb[3] / 2;
@@ -992,7 +982,7 @@ qla2x00_get_retry_cnt(scsi_qla_host_t *ha, uint8_t *retry_cnt, uint8_t *tov,
                }
 
                DEBUG11(printk("qla2x00_get_retry_cnt(%ld): done. mb3=%d "
-                   "ratov=%d.\n", ha->host_no, mcp->mb[3], ratov);)
+                   "ratov=%d.\n", ha->host_no, mcp->mb[3], ratov));
        }
 
        return rval;
@@ -1023,9 +1013,13 @@ qla2x00_init_firmware(scsi_qla_host_t *ha, uint16_t size)
        mbx_cmd_t *mcp = &mc;
 
        DEBUG11(printk("qla2x00_init_firmware(%ld): entered.\n",
-           ha->host_no);)
+           ha->host_no));
+
+       if (ha->flags.npiv_supported)
+               mcp->mb[0] = MBC_MID_INITIALIZE_FIRMWARE;
+       else
+               mcp->mb[0] = MBC_INITIALIZE_FIRMWARE;
 
-       mcp->mb[0] = MBC_INITIALIZE_FIRMWARE;
        mcp->mb[2] = MSW(ha->init_cb_dma);
        mcp->mb[3] = LSW(ha->init_cb_dma);
        mcp->mb[4] = 0;
@@ -1043,11 +1037,11 @@ qla2x00_init_firmware(scsi_qla_host_t *ha, uint16_t size)
                /*EMPTY*/
                DEBUG2_3_11(printk("qla2x00_init_firmware(%ld): failed=%x "
                    "mb0=%x.\n",
-                   ha->host_no, rval, mcp->mb[0]);)
+                   ha->host_no, rval, mcp->mb[0]));
        } else {
                /*EMPTY*/
                DEBUG11(printk("qla2x00_init_firmware(%ld): done.\n",
-                   ha->host_no);)
+                   ha->host_no));
        }
 
        return rval;
@@ -1079,7 +1073,7 @@ qla2x00_get_port_database(scsi_qla_host_t *ha, fc_port_t *fcport, uint8_t opt)
        struct port_database_24xx *pd24;
        dma_addr_t pd_dma;
 
-       DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no);)
+       DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
 
        pd24 = NULL;
        pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma);
@@ -1097,7 +1091,8 @@ qla2x00_get_port_database(scsi_qla_host_t *ha, fc_port_t *fcport, uint8_t opt)
        mcp->mb[3] = LSW(pd_dma);
        mcp->mb[6] = MSW(MSD(pd_dma));
        mcp->mb[7] = LSW(MSD(pd_dma));
-       mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
+       mcp->mb[9] = ha->vp_idx;
+       mcp->out_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
        mcp->in_mb = MBX_0;
        if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) {
                mcp->mb[1] = fcport->loop_id;
@@ -1220,7 +1215,7 @@ qla2x00_get_firmware_state(scsi_qla_host_t *ha, uint16_t *dptr)
        mbx_cmd_t *mcp = &mc;
 
        DEBUG11(printk("qla2x00_get_firmware_state(%ld): entered.\n",
-           ha->host_no);)
+           ha->host_no));
 
        mcp->mb[0] = MBC_GET_FIRMWARE_STATE;
        mcp->out_mb = MBX_0;
@@ -1235,11 +1230,11 @@ qla2x00_get_firmware_state(scsi_qla_host_t *ha, uint16_t *dptr)
        if (rval != QLA_SUCCESS) {
                /*EMPTY*/
                DEBUG2_3_11(printk("qla2x00_get_firmware_state(%ld): "
-                   "failed=%x.\n", ha->host_no, rval);)
+                   "failed=%x.\n", ha->host_no, rval));
        } else {
                /*EMPTY*/
                DEBUG11(printk("qla2x00_get_firmware_state(%ld): done.\n",
-                   ha->host_no);)
+                   ha->host_no));
        }
 
        return rval;
@@ -1272,10 +1267,11 @@ qla2x00_get_port_name(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t *name,
        mbx_cmd_t *mcp = &mc;
 
        DEBUG11(printk("qla2x00_get_port_name(%ld): entered.\n",
-           ha->host_no);)
+           ha->host_no));
 
        mcp->mb[0] = MBC_GET_PORT_NAME;
-       mcp->out_mb = MBX_1|MBX_0;
+       mcp->mb[9] = ha->vp_idx;
+       mcp->out_mb = MBX_9|MBX_1|MBX_0;
        if (HAS_EXTENDED_IDS(ha)) {
                mcp->mb[1] = loop_id;
                mcp->mb[10] = opt;
@@ -1292,22 +1288,22 @@ qla2x00_get_port_name(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t *name,
        if (rval != QLA_SUCCESS) {
                /*EMPTY*/
                DEBUG2_3_11(printk("qla2x00_get_port_name(%ld): failed=%x.\n",
-                   ha->host_no, rval);)
+                   ha->host_no, rval));
        } else {
                if (name != NULL) {
                        /* This function returns name in big endian. */
-                       name[0] = LSB(mcp->mb[2]);
-                       name[1] = MSB(mcp->mb[2]);
-                       name[2] = LSB(mcp->mb[3]);
-                       name[3] = MSB(mcp->mb[3]);
-                       name[4] = LSB(mcp->mb[6]);
-                       name[5] = MSB(mcp->mb[6]);
-                       name[6] = LSB(mcp->mb[7]);
-                       name[7] = MSB(mcp->mb[7]);
+                       name[0] = MSB(mcp->mb[2]);
+                       name[1] = LSB(mcp->mb[2]);
+                       name[2] = MSB(mcp->mb[3]);
+                       name[3] = LSB(mcp->mb[3]);
+                       name[4] = MSB(mcp->mb[6]);
+                       name[5] = LSB(mcp->mb[6]);
+                       name[6] = MSB(mcp->mb[7]);
+                       name[7] = LSB(mcp->mb[7]);
                }
 
                DEBUG11(printk("qla2x00_get_port_name(%ld): done.\n",
-                   ha->host_no);)
+                   ha->host_no));
        }
 
        return rval;
@@ -1335,13 +1331,13 @@ qla2x00_lip_reset(scsi_qla_host_t *ha)
        mbx_cmd_t mc;
        mbx_cmd_t *mcp = &mc;
 
-       DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no);)
+       DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
 
        if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) {
                mcp->mb[0] = MBC_LIP_FULL_LOGIN;
-               mcp->mb[1] = BIT_0;
-               mcp->mb[2] = 0xff;
-               mcp->mb[3] = 0;
+               mcp->mb[1] = BIT_6;
+               mcp->mb[2] = 0;
+               mcp->mb[3] = ha->loop_reset_delay;
                mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
        } else {
                mcp->mb[0] = MBC_LIP_RESET;
@@ -1364,10 +1360,10 @@ qla2x00_lip_reset(scsi_qla_host_t *ha)
        if (rval != QLA_SUCCESS) {
                /*EMPTY*/
                DEBUG2_3_11(printk("%s(%ld): failed=%x.\n",
-                   __func__, ha->host_no, rval);)
+                   __func__, ha->host_no, rval));
        } else {
                /*EMPTY*/
-               DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no);)
+               DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
        }
 
        return rval;
@@ -1400,10 +1396,10 @@ qla2x00_send_sns(scsi_qla_host_t *ha, dma_addr_t sns_phys_address,
        mbx_cmd_t *mcp = &mc;
 
        DEBUG11(printk("qla2x00_send_sns(%ld): entered.\n",
-           ha->host_no);)
+           ha->host_no));
 
        DEBUG11(printk("qla2x00_send_sns: retry cnt=%d ratov=%d total "
-           "tov=%d.\n", ha->retry_count, ha->login_timeout, mcp->tov);)
+           "tov=%d.\n", ha->retry_count, ha->login_timeout, mcp->tov));
 
        mcp->mb[0] = MBC_SEND_SNS_COMMAND;
        mcp->mb[1] = cmd_size;
@@ -1421,12 +1417,12 @@ qla2x00_send_sns(scsi_qla_host_t *ha, dma_addr_t sns_phys_address,
        if (rval != QLA_SUCCESS) {
                /*EMPTY*/
                DEBUG(printk("qla2x00_send_sns(%ld): failed=%x mb[0]=%x "
-                   "mb[1]=%x.\n", ha->host_no, rval, mcp->mb[0], mcp->mb[1]);)
+                   "mb[1]=%x.\n", ha->host_no, rval, mcp->mb[0], mcp->mb[1]));
                DEBUG2_3_11(printk("qla2x00_send_sns(%ld): failed=%x mb[0]=%x "
-                   "mb[1]=%x.\n", ha->host_no, rval, mcp->mb[0], mcp->mb[1]);)
+                   "mb[1]=%x.\n", ha->host_no, rval, mcp->mb[0], mcp->mb[1]));
        } else {
                /*EMPTY*/
-               DEBUG11(printk("qla2x00_send_sns(%ld): done.\n", ha->host_no);)
+               DEBUG11(printk("qla2x00_send_sns(%ld): done.\n", ha->host_no));
        }
 
        return rval;
@@ -1442,7 +1438,7 @@ qla24xx_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
        dma_addr_t      lg_dma;
        uint32_t        iop[2];
 
-       DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no);)
+       DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
 
        lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma);
        if (lg == NULL) {
@@ -1458,13 +1454,16 @@ qla24xx_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
        lg->control_flags = __constant_cpu_to_le16(LCF_COMMAND_PLOGI);
        if (opt & BIT_0)
                lg->control_flags |= __constant_cpu_to_le16(LCF_COND_PLOGI);
+       if (opt & BIT_1)
+               lg->control_flags |= __constant_cpu_to_le16(LCF_SKIP_PRLI);
        lg->port_id[0] = al_pa;
        lg->port_id[1] = area;
        lg->port_id[2] = domain;
+       lg->vp_index = cpu_to_le16(ha->vp_idx);
        rval = qla2x00_issue_iocb(ha, lg, lg_dma, 0);
        if (rval != QLA_SUCCESS) {
                DEBUG2_3_11(printk("%s(%ld): failed to issue Login IOCB "
-                   "(%x).\n", __func__, ha->host_no, rval);)
+                   "(%x).\n", __func__, ha->host_no, rval));
        } else if (lg->entry_status != 0) {
                DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
                    "-- error status (%x).\n", __func__, ha->host_no,
@@ -1505,7 +1504,7 @@ qla24xx_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
                        break;
                }
        } else {
-               DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no);)
+               DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
 
                iop[0] = le32_to_cpu(lg->io_parameter[0]);
 
@@ -1559,7 +1558,7 @@ qla2x00_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
        mbx_cmd_t mc;
        mbx_cmd_t *mcp = &mc;
 
-       DEBUG11(printk("qla2x00_login_fabric(%ld): entered.\n", ha->host_no);)
+       DEBUG11(printk("qla2x00_login_fabric(%ld): entered.\n", ha->host_no));
 
        mcp->mb[0] = MBC_LOGIN_FABRIC_PORT;
        mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
@@ -1604,11 +1603,11 @@ qla2x00_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
                /*EMPTY*/
                DEBUG2_3_11(printk("qla2x00_login_fabric(%ld): failed=%x "
                    "mb[0]=%x mb[1]=%x mb[2]=%x.\n", ha->host_no, rval,
-                   mcp->mb[0], mcp->mb[1], mcp->mb[2]);)
+                   mcp->mb[0], mcp->mb[1], mcp->mb[2]));
        } else {
                /*EMPTY*/
                DEBUG11(printk("qla2x00_login_fabric(%ld): done.\n",
-                   ha->host_no);)
+                   ha->host_no));
        }
 
        return rval;
@@ -1631,20 +1630,25 @@ qla2x00_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
  *
  */
 int
-qla2x00_login_local_device(scsi_qla_host_t *ha, uint16_t loop_id,
+qla2x00_login_local_device(scsi_qla_host_t *ha, fc_port_t *fcport,
     uint16_t *mb_ret, uint8_t opt)
 {
        int rval;
        mbx_cmd_t mc;
        mbx_cmd_t *mcp = &mc;
 
-       DEBUG3(printk("%s(%ld): entered.\n", __func__, ha->host_no);)
+       if (IS_QLA24XX(ha) || IS_QLA54XX(ha))
+               return qla24xx_login_fabric(ha, fcport->loop_id,
+                   fcport->d_id.b.domain, fcport->d_id.b.area,
+                   fcport->d_id.b.al_pa, mb_ret, opt);
+
+       DEBUG3(printk("%s(%ld): entered.\n", __func__, ha->host_no));
 
        mcp->mb[0] = MBC_LOGIN_LOOP_PORT;
        if (HAS_EXTENDED_IDS(ha))
-               mcp->mb[1] = loop_id;
+               mcp->mb[1] = fcport->loop_id;
        else
-               mcp->mb[1] = loop_id << 8;
+               mcp->mb[1] = fcport->loop_id << 8;
        mcp->mb[2] = opt;
        mcp->out_mb = MBX_2|MBX_1|MBX_0;
        mcp->in_mb = MBX_7|MBX_6|MBX_1|MBX_0;
@@ -1672,13 +1676,13 @@ qla2x00_login_local_device(scsi_qla_host_t *ha, uint16_t loop_id,
 
                DEBUG(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x "
                    "mb[6]=%x mb[7]=%x.\n", __func__, ha->host_no, rval,
-                   mcp->mb[0], mcp->mb[1], mcp->mb[6], mcp->mb[7]);)
+                   mcp->mb[0], mcp->mb[1], mcp->mb[6], mcp->mb[7]));
                DEBUG2_3(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x "
                    "mb[6]=%x mb[7]=%x.\n", __func__, ha->host_no, rval,
-                   mcp->mb[0], mcp->mb[1], mcp->mb[6], mcp->mb[7]);)
+                   mcp->mb[0], mcp->mb[1], mcp->mb[6], mcp->mb[7]));
        } else {
                /*EMPTY*/
-               DEBUG3(printk("%s(%ld): done.\n", __func__, ha->host_no);)
+               DEBUG3(printk("%s(%ld): done.\n", __func__, ha->host_no));
        }
 
        return (rval);
@@ -1692,7 +1696,7 @@ qla24xx_fabric_logout(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
        struct logio_entry_24xx *lg;
        dma_addr_t      lg_dma;
 
-       DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no);)
+       DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
 
        lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma);
        if (lg == NULL) {
@@ -1706,14 +1710,15 @@ qla24xx_fabric_logout(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
        lg->entry_count = 1;
        lg->nport_handle = cpu_to_le16(loop_id);
        lg->control_flags =
-           __constant_cpu_to_le16(LCF_COMMAND_LOGO|LCF_EXPL_LOGO);
+           __constant_cpu_to_le16(LCF_COMMAND_LOGO|LCF_IMPL_LOGO);
        lg->port_id[0] = al_pa;
        lg->port_id[1] = area;
        lg->port_id[2] = domain;
+       lg->vp_index = cpu_to_le16(ha->vp_idx);
        rval = qla2x00_issue_iocb(ha, lg, lg_dma, 0);
        if (rval != QLA_SUCCESS) {
                DEBUG2_3_11(printk("%s(%ld): failed to issue Logout IOCB "
-                   "(%x).\n", __func__, ha->host_no, rval);)
+                   "(%x).\n", __func__, ha->host_no, rval));
        } else if (lg->entry_status != 0) {
                DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
                    "-- error status (%x).\n", __func__, ha->host_no,
@@ -1724,10 +1729,10 @@ qla24xx_fabric_logout(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
                    "-- completion status (%x)  ioparam=%x/%x.\n", __func__,
                    ha->host_no, le16_to_cpu(lg->comp_status),
                    le32_to_cpu(lg->io_parameter[0]),
-                   le32_to_cpu(lg->io_parameter[1]));)
+                   le32_to_cpu(lg->io_parameter[1])));
        } else {
                /*EMPTY*/
-               DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no);)
+               DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
        }
 
        dma_pool_free(ha->s_dma_pool, lg, lg_dma);
@@ -1760,7 +1765,7 @@ qla2x00_fabric_logout(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
        mbx_cmd_t *mcp = &mc;
 
        DEBUG11(printk("qla2x00_fabric_logout(%ld): entered.\n",
-           ha->host_no);)
+           ha->host_no));
 
        mcp->mb[0] = MBC_LOGOUT_FABRIC_PORT;
        mcp->out_mb = MBX_1|MBX_0;
@@ -1780,11 +1785,11 @@ qla2x00_fabric_logout(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
        if (rval != QLA_SUCCESS) {
                /*EMPTY*/
                DEBUG2_3_11(printk("qla2x00_fabric_logout(%ld): failed=%x "
-                   "mbx1=%x.\n", ha->host_no, rval, mcp->mb[1]);)
+                   "mbx1=%x.\n", ha->host_no, rval, mcp->mb[1]));
        } else {
                /*EMPTY*/
                DEBUG11(printk("qla2x00_fabric_logout(%ld): done.\n",
-                   ha->host_no);)
+                   ha->host_no));
        }
 
        return rval;
@@ -1813,11 +1818,11 @@ qla2x00_full_login_lip(scsi_qla_host_t *ha)
        mbx_cmd_t *mcp = &mc;
 
        DEBUG11(printk("qla2x00_full_login_lip(%ld): entered.\n",
-           ha->host_no);)
+           ha->host_no));
 
        mcp->mb[0] = MBC_LIP_FULL_LOGIN;
-       mcp->mb[1] = 0;
-       mcp->mb[2] = 0xff;
+       mcp->mb[1] = IS_QLA24XX(ha) || IS_QLA54XX(ha) ? BIT_3: 0;
+       mcp->mb[2] = 0;
        mcp->mb[3] = 0;
        mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
        mcp->in_mb = MBX_0;
@@ -1828,11 +1833,11 @@ qla2x00_full_login_lip(scsi_qla_host_t *ha)
        if (rval != QLA_SUCCESS) {
                /*EMPTY*/
                DEBUG2_3_11(printk("qla2x00_full_login_lip(%ld): failed=%x.\n",
-                   ha->host_no, rval);)
+                   ha->host_no, rval));
        } else {
                /*EMPTY*/
                DEBUG11(printk("qla2x00_full_login_lip(%ld): done.\n",
-                   ha->host_no);)
+                   ha->host_no));
        }
 
        return rval;
@@ -1859,7 +1864,7 @@ qla2x00_get_id_list(scsi_qla_host_t *ha, void *id_list, dma_addr_t id_list_dma,
        mbx_cmd_t *mcp = &mc;
 
        DEBUG11(printk("qla2x00_get_id_list(%ld): entered.\n",
-           ha->host_no);)
+           ha->host_no));
 
        if (id_list == NULL)
                return QLA_FUNCTION_FAILED;
@@ -1872,7 +1877,8 @@ qla2x00_get_id_list(scsi_qla_host_t *ha, void *id_list, dma_addr_t id_list_dma,
                mcp->mb[6] = MSW(MSD(id_list_dma));
                mcp->mb[7] = LSW(MSD(id_list_dma));
                mcp->mb[8] = 0;
-               mcp->out_mb |= MBX_8|MBX_7|MBX_6|MBX_3|MBX_2;
+               mcp->mb[9] = ha->vp_idx;
+               mcp->out_mb |= MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2;
        } else {
                mcp->mb[1] = MSW(id_list_dma);
                mcp->mb[2] = LSW(id_list_dma);
@@ -1888,11 +1894,11 @@ qla2x00_get_id_list(scsi_qla_host_t *ha, void *id_list, dma_addr_t id_list_dma,
        if (rval != QLA_SUCCESS) {
                /*EMPTY*/
                DEBUG2_3_11(printk("qla2x00_get_id_list(%ld): failed=%x.\n",
-                   ha->host_no, rval);)
+                   ha->host_no, rval));
        } else {
                *entries = mcp->mb[1];
                DEBUG11(printk("qla2x00_get_id_list(%ld): done.\n",
-                   ha->host_no);)
+                   ha->host_no));
        }
 
        return rval;
@@ -1931,7 +1937,7 @@ qla2x00_get_resource_cnts(scsi_qla_host_t *ha, uint16_t *cur_xchg_cnt,
        if (rval != QLA_SUCCESS) {
                /*EMPTY*/
                DEBUG2_3_11(printk("%s(%ld): failed = %x.\n", __func__,
-                   ha->host_no, mcp->mb[0]);)
+                   ha->host_no, mcp->mb[0]));
        } else {
                DEBUG11(printk("%s(%ld): done. mb1=%x mb2=%x mb3=%x mb6=%x "
                    "mb7=%x mb10=%x.\n", __func__, ha->host_no,
@@ -2040,7 +2046,7 @@ qla2x00_get_link_status(scsi_qla_host_t *ha, uint16_t loop_id,
        link_stat_t *stat_buf;
        dma_addr_t stat_buf_dma;
 
-       DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no);)
+       DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
 
        stat_buf = dma_pool_alloc(ha->s_dma_pool, GFP_ATOMIC, &stat_buf_dma);
        if (stat_buf == NULL) {
@@ -2078,7 +2084,7 @@ qla2x00_get_link_status(scsi_qla_host_t *ha, uint16_t loop_id,
        if (rval == QLA_SUCCESS) {
                if (mcp->mb[0] != MBS_COMMAND_COMPLETE) {
                        DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n",
-                           __func__, ha->host_no, mcp->mb[0]);)
+                           __func__, ha->host_no, mcp->mb[0]));
                        status[0] = mcp->mb[0];
                        rval = BIT_1;
                } else {
@@ -2103,12 +2109,12 @@ qla2x00_get_link_status(scsi_qla_host_t *ha, uint16_t loop_id,
                            stat_buf->loss_sync_cnt, stat_buf->loss_sig_cnt,
                            stat_buf->prim_seq_err_cnt,
                            stat_buf->inval_xmit_word_cnt,
-                           stat_buf->inval_crc_cnt);)
+                           stat_buf->inval_crc_cnt));
                }
        } else {
                /* Failed. */
                DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
-                   ha->host_no, rval);)
+                   ha->host_no, rval));
                rval = BIT_1;
        }
 
@@ -2127,7 +2133,7 @@ qla24xx_get_isp_stats(scsi_qla_host_t *ha, uint32_t *dwbuf, uint32_t dwords,
        uint32_t *sbuf, *siter;
        dma_addr_t sbuf_dma;
 
-       DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no);)
+       DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
 
        if (dwords > (DMA_POOL_SIZE / 4)) {
                DEBUG2_3_11(printk("%s(%ld): Unabled to retrieve %d DWORDs "
@@ -2191,7 +2197,7 @@ qla24xx_abort_command(scsi_qla_host_t *ha, srb_t *sp)
        dma_addr_t      abt_dma;
        uint32_t        handle;
 
-       DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no);)
+       DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
 
        fcport = sp->fcport;
 
@@ -2221,10 +2227,11 @@ qla24xx_abort_command(scsi_qla_host_t *ha, srb_t *sp)
        abt->port_id[0] = fcport->d_id.b.al_pa;
        abt->port_id[1] = fcport->d_id.b.area;
        abt->port_id[2] = fcport->d_id.b.domain;
+       abt->vp_index = fcport->vp_idx;
        rval = qla2x00_issue_iocb(ha, abt, abt_dma, 0);
        if (rval != QLA_SUCCESS) {
                DEBUG2_3_11(printk("%s(%ld): failed to issue IOCB (%x).\n",
-                   __func__, ha->host_no, rval);)
+                   __func__, ha->host_no, rval));
        } else if (abt->entry_status != 0) {
                DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
                    "-- error status (%x).\n", __func__, ha->host_no,
@@ -2233,10 +2240,10 @@ qla24xx_abort_command(scsi_qla_host_t *ha, srb_t *sp)
        } else if (abt->nport_handle != __constant_cpu_to_le16(0)) {
                DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
                    "-- completion status (%x).\n", __func__, ha->host_no,
-                   le16_to_cpu(abt->nport_handle));)
+                   le16_to_cpu(abt->nport_handle)));
                rval = QLA_FUNCTION_FAILED;
        } else {
-               DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no);)
+               DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
                sp->flags |= SRB_ABORT_PENDING;
        }
 
@@ -2258,15 +2265,16 @@ qla24xx_abort_target(fc_port_t *fcport)
        int             rval;
        struct tsk_mgmt_cmd *tsk;
        dma_addr_t      tsk_dma;
-       scsi_qla_host_t *ha;
+       scsi_qla_host_t *ha, *pha;
 
        if (fcport == NULL)
                return 0;
 
-       DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->ha->host_no);)
+       DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->ha->host_no));
 
        ha = fcport->ha;
-       tsk = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &tsk_dma);
+       pha = to_qla_parent(ha);
+       tsk = dma_pool_alloc(pha->s_dma_pool, GFP_KERNEL, &tsk_dma);
        if (tsk == NULL) {
                DEBUG2_3(printk("%s(%ld): failed to allocate Task Management "
                    "IOCB.\n", __func__, ha->host_no));
@@ -2282,10 +2290,12 @@ qla24xx_abort_target(fc_port_t *fcport)
        tsk->p.tsk.port_id[0] = fcport->d_id.b.al_pa;
        tsk->p.tsk.port_id[1] = fcport->d_id.b.area;
        tsk->p.tsk.port_id[2] = fcport->d_id.b.domain;
+       tsk->p.tsk.vp_index = fcport->vp_idx;
+
        rval = qla2x00_issue_iocb(ha, tsk, tsk_dma, 0);
        if (rval != QLA_SUCCESS) {
                DEBUG2_3_11(printk("%s(%ld): failed to issue Target Reset IOCB "
-                   "(%x).\n", __func__, ha->host_no, rval);)
+                   "(%x).\n", __func__, ha->host_no, rval));
                goto atarget_done;
        } else if (tsk->p.sts.entry_status != 0) {
                DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
@@ -2297,7 +2307,7 @@ qla24xx_abort_target(fc_port_t *fcport)
            __constant_cpu_to_le16(CS_COMPLETE)) {
                DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
                    "-- completion status (%x).\n", __func__,
-                   ha->host_no, le16_to_cpu(tsk->p.sts.comp_status));)
+                   ha->host_no, le16_to_cpu(tsk->p.sts.comp_status)));
                rval = QLA_FUNCTION_FAILED;
                goto atarget_done;
        }
@@ -2306,13 +2316,13 @@ qla24xx_abort_target(fc_port_t *fcport)
        rval = qla2x00_marker(ha, fcport->loop_id, 0, MK_SYNC_ID);
        if (rval != QLA_SUCCESS) {
                DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB "
-                   "(%x).\n", __func__, ha->host_no, rval);)
+                   "(%x).\n", __func__, ha->host_no, rval));
        } else {
-               DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no);)
+               DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
        }
 
 atarget_done:
-       dma_pool_free(ha->s_dma_pool, tsk, tsk_dma);
+       dma_pool_free(pha->s_dma_pool, tsk, tsk_dma);
 
        return rval;
 }
@@ -2406,9 +2416,9 @@ qla2x00_set_serdes_params(scsi_qla_host_t *ha, uint16_t sw_em_1g,
 
        mcp->mb[0] = MBC_SERDES_PARAMS;
        mcp->mb[1] = BIT_0;
-       mcp->mb[2] = sw_em_1g;
-       mcp->mb[3] = sw_em_2g;
-       mcp->mb[4] = sw_em_4g;
+       mcp->mb[2] = sw_em_1g | BIT_15;
+       mcp->mb[3] = sw_em_2g | BIT_15;
+       mcp->mb[4] = sw_em_4g | BIT_15;
        mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
        mcp->in_mb = MBX_0;
        mcp->tov = 30;
@@ -2455,3 +2465,518 @@ qla2x00_stop_firmware(scsi_qla_host_t *ha)
 
        return rval;
 }
+
+int
+qla2x00_trace_control(scsi_qla_host_t *ha, uint16_t ctrl, dma_addr_t eft_dma,
+    uint16_t buffers)
+{
+       int rval;
+       mbx_cmd_t mc;
+       mbx_cmd_t *mcp = &mc;
+
+       if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha))
+               return QLA_FUNCTION_FAILED;
+
+       DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
+
+       mcp->mb[0] = MBC_TRACE_CONTROL;
+       mcp->mb[1] = ctrl;
+       mcp->out_mb = MBX_1|MBX_0;
+       mcp->in_mb = MBX_1|MBX_0;
+       if (ctrl == TC_ENABLE) {
+               mcp->mb[2] = LSW(eft_dma);
+               mcp->mb[3] = MSW(eft_dma);
+               mcp->mb[4] = LSW(MSD(eft_dma));
+               mcp->mb[5] = MSW(MSD(eft_dma));
+               mcp->mb[6] = buffers;
+               mcp->mb[7] = 0;
+               mcp->out_mb |= MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2;
+       }
+       mcp->tov = 30;
+       mcp->flags = 0;
+       rval = qla2x00_mailbox_command(ha, mcp);
+
+       if (rval != QLA_SUCCESS) {
+               DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
+                   __func__, ha->host_no, rval, mcp->mb[0], mcp->mb[1]));
+       } else {
+               DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
+       }
+
+       return rval;
+}
+
+int
+qla2x00_read_sfp(scsi_qla_host_t *ha, dma_addr_t sfp_dma, uint16_t addr,
+    uint16_t off, uint16_t count)
+{
+       int rval;
+       mbx_cmd_t mc;
+       mbx_cmd_t *mcp = &mc;
+
+       if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha))
+               return QLA_FUNCTION_FAILED;
+
+       DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
+
+       mcp->mb[0] = MBC_READ_SFP;
+       mcp->mb[1] = addr;
+       mcp->mb[2] = MSW(sfp_dma);
+       mcp->mb[3] = LSW(sfp_dma);
+       mcp->mb[6] = MSW(MSD(sfp_dma));
+       mcp->mb[7] = LSW(MSD(sfp_dma));
+       mcp->mb[8] = count;
+       mcp->mb[9] = off;
+       mcp->mb[10] = 0;
+       mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
+       mcp->in_mb = MBX_0;
+       mcp->tov = 30;
+       mcp->flags = 0;
+       rval = qla2x00_mailbox_command(ha, mcp);
+
+       if (rval != QLA_SUCCESS) {
+               DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__,
+                   ha->host_no, rval, mcp->mb[0]));
+       } else {
+               DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
+       }
+
+       return rval;
+}
+
+int
+qla2x00_get_idma_speed(scsi_qla_host_t *ha, uint16_t loop_id,
+    uint16_t *port_speed, uint16_t *mb)
+{
+       int rval;
+       mbx_cmd_t mc;
+       mbx_cmd_t *mcp = &mc;
+
+       if (!IS_QLA24XX(ha))
+               return QLA_FUNCTION_FAILED;
+
+       DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
+
+       mcp->mb[0] = MBC_PORT_PARAMS;
+       mcp->mb[1] = loop_id;
+       mcp->mb[2] = mcp->mb[3] = mcp->mb[4] = mcp->mb[5] = 0;
+       mcp->out_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
+       mcp->in_mb = MBX_5|MBX_4|MBX_3|MBX_1|MBX_0;
+       mcp->tov = 30;
+       mcp->flags = 0;
+       rval = qla2x00_mailbox_command(ha, mcp);
+
+       /* Return mailbox statuses. */
+       if (mb != NULL) {
+               mb[0] = mcp->mb[0];
+               mb[1] = mcp->mb[1];
+               mb[3] = mcp->mb[3];
+               mb[4] = mcp->mb[4];
+               mb[5] = mcp->mb[5];
+       }
+
+       if (rval != QLA_SUCCESS) {
+               DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
+                   ha->host_no, rval));
+       } else {
+               DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
+               if (port_speed)
+                       *port_speed = mcp->mb[3];
+       }
+
+       return rval;
+}
+
+int
+qla2x00_set_idma_speed(scsi_qla_host_t *ha, uint16_t loop_id,
+    uint16_t port_speed, uint16_t *mb)
+{
+       int rval;
+       mbx_cmd_t mc;
+       mbx_cmd_t *mcp = &mc;
+
+       if (!IS_QLA24XX(ha))
+               return QLA_FUNCTION_FAILED;
+
+       DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
+
+       mcp->mb[0] = MBC_PORT_PARAMS;
+       mcp->mb[1] = loop_id;
+       mcp->mb[2] = BIT_0;
+       mcp->mb[3] = port_speed & (BIT_2|BIT_1|BIT_0);
+       mcp->mb[4] = mcp->mb[5] = 0;
+       mcp->out_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
+       mcp->in_mb = MBX_5|MBX_4|MBX_3|MBX_1|MBX_0;
+       mcp->tov = 30;
+       mcp->flags = 0;
+       rval = qla2x00_mailbox_command(ha, mcp);
+
+       /* Return mailbox statuses. */
+       if (mb != NULL) {
+               mb[0] = mcp->mb[0];
+               mb[1] = mcp->mb[1];
+               mb[3] = mcp->mb[3];
+               mb[4] = mcp->mb[4];
+               mb[5] = mcp->mb[5];
+       }
+
+       if (rval != QLA_SUCCESS) {
+               DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
+                   ha->host_no, rval));
+       } else {
+               DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
+       }
+
+       return rval;
+}
+
+/*
+ * qla24xx_get_vp_database
+ *     Get the VP's database for all configured ports.
+ *
+ * Input:
+ *     ha = adapter block pointer.
+ *     size = size of initialization control block.
+ *
+ * Returns:
+ *     qla2x00 local function return status code.
+ *
+ * Context:
+ *     Kernel context.
+ */
+int
+qla24xx_get_vp_database(scsi_qla_host_t *ha, uint16_t size)
+{
+       int rval;
+       mbx_cmd_t mc;
+       mbx_cmd_t *mcp = &mc;
+
+       DEBUG11(printk("scsi(%ld):%s - entered.\n",
+           ha->host_no, __func__));
+
+       mcp->mb[0] = MBC_MID_GET_VP_DATABASE;
+       mcp->mb[2] = MSW(ha->init_cb_dma);
+       mcp->mb[3] = LSW(ha->init_cb_dma);
+       mcp->mb[4] = 0;
+       mcp->mb[5] = 0;
+       mcp->mb[6] = MSW(MSD(ha->init_cb_dma));
+       mcp->mb[7] = LSW(MSD(ha->init_cb_dma));
+       mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
+       mcp->in_mb = MBX_1|MBX_0;
+       mcp->buf_size = size;
+       mcp->flags = MBX_DMA_OUT;
+       mcp->tov = MBX_TOV_SECONDS;
+       rval = qla2x00_mailbox_command(ha, mcp);
+
+       if (rval != QLA_SUCCESS) {
+               /*EMPTY*/
+               DEBUG2_3_11(printk("%s(%ld): failed=%x "
+                   "mb0=%x.\n",
+                   __func__, ha->host_no, rval, mcp->mb[0]));
+       } else {
+               /*EMPTY*/
+               DEBUG11(printk("%s(%ld): done.\n",
+                   __func__, ha->host_no));
+       }
+
+       return rval;
+}
+
+int
+qla24xx_get_vp_entry(scsi_qla_host_t *ha, uint16_t size, int vp_id)
+{
+       int rval;
+       mbx_cmd_t mc;
+       mbx_cmd_t *mcp = &mc;
+
+       DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
+
+       mcp->mb[0] = MBC_MID_GET_VP_ENTRY;
+       mcp->mb[2] = MSW(ha->init_cb_dma);
+       mcp->mb[3] = LSW(ha->init_cb_dma);
+       mcp->mb[4] = 0;
+       mcp->mb[5] = 0;
+       mcp->mb[6] = MSW(MSD(ha->init_cb_dma));
+       mcp->mb[7] = LSW(MSD(ha->init_cb_dma));
+       mcp->mb[9] = vp_id;
+       mcp->out_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
+       mcp->in_mb = MBX_0;
+       mcp->buf_size = size;
+       mcp->flags = MBX_DMA_OUT;
+       mcp->tov = 30;
+       rval = qla2x00_mailbox_command(ha, mcp);
+
+       if (rval != QLA_SUCCESS) {
+               /*EMPTY*/
+               DEBUG2_3_11(printk("qla24xx_get_vp_entry(%ld): failed=%x "
+                   "mb0=%x.\n",
+                   ha->host_no, rval, mcp->mb[0]));
+       } else {
+               /*EMPTY*/
+               DEBUG11(printk("qla24xx_get_vp_entry(%ld): done.\n",
+                   ha->host_no));
+       }
+
+       return rval;
+}
+
+void
+qla24xx_report_id_acquisition(scsi_qla_host_t *ha,
+       struct vp_rpt_id_entry_24xx *rptid_entry)
+{
+       uint8_t vp_idx;
+       scsi_qla_host_t *vha;
+
+       if (rptid_entry->entry_status != 0)
+               return;
+       if (rptid_entry->entry_status != __constant_cpu_to_le16(CS_COMPLETE))
+               return;
+
+       if (rptid_entry->format == 0) {
+               DEBUG15(printk("%s:format 0 : scsi(%ld) number of VPs setup %d,"
+                       " number of VPs acquired %d\n", __func__, ha->host_no,
+                       MSB(rptid_entry->vp_count), LSB(rptid_entry->vp_count)));
+               DEBUG15(printk("%s primary port id %02x%02x%02x\n", __func__,
+                       rptid_entry->port_id[2], rptid_entry->port_id[1],
+                       rptid_entry->port_id[0]));
+       } else if (rptid_entry->format == 1) {
+               vp_idx = LSB(rptid_entry->vp_idx);
+               DEBUG15(printk("%s:format 1: scsi(%ld): VP[%d] enabled "
+                   "- status %d - "
+                   "with port id %02x%02x%02x\n",__func__,ha->host_no,
+                   vp_idx, MSB(rptid_entry->vp_idx),
+                   rptid_entry->port_id[2], rptid_entry->port_id[1],
+                   rptid_entry->port_id[0]));
+               if (vp_idx == 0)
+                       return;
+
+               if (MSB(rptid_entry->vp_idx) == 1)
+                       return;
+
+               list_for_each_entry(vha, &ha->vp_list, vp_list)
+                       if (vp_idx == vha->vp_idx)
+                               break;
+
+               if (!vha)
+                       return;
+
+               vha->d_id.b.domain = rptid_entry->port_id[2];
+               vha->d_id.b.area =  rptid_entry->port_id[1];
+               vha->d_id.b.al_pa = rptid_entry->port_id[0];
+
+               /*
+                * Cannot configure here as we are still sitting on the
+                * response queue. Handle it in dpc context.
+                */
+               set_bit(VP_IDX_ACQUIRED, &vha->vp_flags);
+               set_bit(VP_DPC_NEEDED, &ha->dpc_flags);
+
+               wake_up_process(ha->dpc_thread);
+       }
+}
+
+/*
+ * qla24xx_modify_vp_config
+ *     Change VP configuration for vha
+ *
+ * Input:
+ *     vha = adapter block pointer.
+ *
+ * Returns:
+ *     qla2xxx local function return status code.
+ *
+ * Context:
+ *     Kernel context.
+ */
+int
+qla24xx_modify_vp_config(scsi_qla_host_t *vha)
+{
+       int             rval;
+       struct vp_config_entry_24xx *vpmod;
+       dma_addr_t      vpmod_dma;
+       scsi_qla_host_t *pha;
+
+       /* This can be called by the parent */
+       pha = to_qla_parent(vha);
+
+       vpmod = dma_pool_alloc(pha->s_dma_pool, GFP_KERNEL, &vpmod_dma);
+       if (!vpmod) {
+               DEBUG2_3(printk("%s(%ld): failed to allocate Modify VP "
+                   "IOCB.\n", __func__, pha->host_no));
+               return QLA_MEMORY_ALLOC_FAILED;
+       }
+
+       memset(vpmod, 0, sizeof(struct vp_config_entry_24xx));
+       vpmod->entry_type = VP_CONFIG_IOCB_TYPE;
+       vpmod->entry_count = 1;
+       vpmod->command = VCT_COMMAND_MOD_ENABLE_VPS;
+       vpmod->vp_count = 1;
+       vpmod->vp_index1 = vha->vp_idx;
+       vpmod->options_idx1 = BIT_3|BIT_4|BIT_5;
+       memcpy(vpmod->node_name_idx1, vha->node_name, WWN_SIZE);
+       memcpy(vpmod->port_name_idx1, vha->port_name, WWN_SIZE);
+       vpmod->entry_count = 1;
+
+       rval = qla2x00_issue_iocb(pha, vpmod, vpmod_dma, 0);
+       if (rval != QLA_SUCCESS) {
+               DEBUG2_3_11(printk("%s(%ld): failed to issue VP config IOCB"
+                       "(%x).\n", __func__, pha->host_no, rval));
+       } else if (vpmod->comp_status != 0) {
+               DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
+                       "-- error status (%x).\n", __func__, pha->host_no,
+                       vpmod->comp_status));
+               rval = QLA_FUNCTION_FAILED;
+       } else if (vpmod->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) {
+               DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
+                   "-- completion status (%x).\n", __func__, pha->host_no,
+                   le16_to_cpu(vpmod->comp_status)));
+               rval = QLA_FUNCTION_FAILED;
+       } else {
+               /* EMPTY */
+               DEBUG11(printk("%s(%ld): done.\n", __func__, pha->host_no));
+               fc_vport_set_state(vha->fc_vport, FC_VPORT_INITIALIZING);
+       }
+       dma_pool_free(pha->s_dma_pool, vpmod, vpmod_dma);
+
+       return rval;
+}
+
+/*
+ * qla24xx_control_vp
+ *     Enable a virtual port for given host
+ *
+ * Input:
+ *     ha = adapter block pointer.
+ *     vhba = virtual adapter (unused)
+ *     index = index number for enabled VP
+ *
+ * Returns:
+ *     qla2xxx local function return status code.
+ *
+ * Context:
+ *     Kernel context.
+ */
+int
+qla24xx_control_vp(scsi_qla_host_t *vha, int cmd)
+{
+       int             rval;
+       int             map, pos;
+       struct vp_ctrl_entry_24xx   *vce;
+       dma_addr_t      vce_dma;
+       scsi_qla_host_t *ha = vha->parent;
+       int     vp_index = vha->vp_idx;
+
+       DEBUG11(printk("%s(%ld): entered. Enabling index %d\n", __func__,
+           ha->host_no, vp_index));
+
+       if (vp_index == 0 || vp_index >= MAX_MULTI_ID_LOOP)
+               return QLA_PARAMETER_ERROR;
+
+       vce = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &vce_dma);
+       if (!vce) {
+               DEBUG2_3(printk("%s(%ld): "
+                   "failed to allocate VP Control IOCB.\n", __func__,
+                   ha->host_no));
+               return QLA_MEMORY_ALLOC_FAILED;
+       }
+       memset(vce, 0, sizeof(struct vp_ctrl_entry_24xx));
+
+       vce->entry_type = VP_CTRL_IOCB_TYPE;
+       vce->entry_count = 1;
+       vce->command = cpu_to_le16(cmd);
+       vce->vp_count = __constant_cpu_to_le16(1);
+
+       /* index map in firmware starts with 1; decrement index
+        * this is ok as we never use index 0
+        */
+       map = (vp_index - 1) / 8;
+       pos = (vp_index - 1) & 7;
+       down(&ha->vport_sem);
+       vce->vp_idx_map[map] |= 1 << pos;
+       up(&ha->vport_sem);
+
+       rval = qla2x00_issue_iocb(ha, vce, vce_dma, 0);
+       if (rval != QLA_SUCCESS) {
+               DEBUG2_3_11(printk("%s(%ld): failed to issue VP control IOCB"
+                   "(%x).\n", __func__, ha->host_no, rval));
+               printk("%s(%ld): failed to issue VP control IOCB"
+                   "(%x).\n", __func__, ha->host_no, rval);
+       } else if (vce->entry_status != 0) {
+               DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
+                   "-- error status (%x).\n", __func__, ha->host_no,
+                   vce->entry_status));
+               printk("%s(%ld): failed to complete IOCB "
+                   "-- error status (%x).\n", __func__, ha->host_no,
+                   vce->entry_status);
+               rval = QLA_FUNCTION_FAILED;
+       } else if (vce->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) {
+               DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
+                   "-- completion status (%x).\n", __func__, ha->host_no,
+                   le16_to_cpu(vce->comp_status)));
+               printk("%s(%ld): failed to complete IOCB "
+                   "-- completion status (%x).\n", __func__, ha->host_no,
+                   le16_to_cpu(vce->comp_status));
+               rval = QLA_FUNCTION_FAILED;
+       } else {
+               DEBUG2(printk("%s(%ld): done.\n", __func__, ha->host_no));
+       }
+
+       dma_pool_free(ha->s_dma_pool, vce, vce_dma);
+
+       return rval;
+}
+
+/*
+ * qla2x00_send_change_request
+ *     Receive or disable RSCN request from fabric controller
+ *
+ * Input:
+ *     ha = adapter block pointer
+ *     format = registration format:
+ *             0 - Reserved
+ *             1 - Fabric detected registration
+ *             2 - N_port detected registration
+ *             3 - Full registration
+ *             FF - clear registration
+ *     vp_idx = Virtual port index
+ *
+ * Returns:
+ *     qla2x00 local function return status code.
+ *
+ * Context:
+ *     Kernel Context
+ */
+
+int
+qla2x00_send_change_request(scsi_qla_host_t *ha, uint16_t format,
+                           uint16_t vp_idx)
+{
+       int rval;
+       mbx_cmd_t mc;
+       mbx_cmd_t *mcp = &mc;
+
+       /*
+        * This command is implicitly executed by firmware during login for the
+        * physical hosts
+        */
+       if (vp_idx == 0)
+               return QLA_FUNCTION_FAILED;
+
+       mcp->mb[0] = MBC_SEND_CHANGE_REQUEST;
+       mcp->mb[1] = format;
+       mcp->mb[9] = vp_idx;
+       mcp->out_mb = MBX_9|MBX_1|MBX_0;
+       mcp->in_mb = MBX_0|MBX_1;
+       mcp->tov = MBX_TOV_SECONDS;
+       mcp->flags = 0;
+       rval = qla2x00_mailbox_command(ha, mcp);
+
+       if (rval == QLA_SUCCESS) {
+               if (mcp->mb[0] != MBS_COMMAND_COMPLETE) {
+                       rval = BIT_1;
+               }
+       } else
+               rval = BIT_1;
+
+       return rval;
+}