[SCSI] qla2xxx: Correct various NPIV issues.
authorAndrew Vasquez <andrew.vasquez@qlogic.com>
Tue, 25 Aug 2009 18:36:19 +0000 (11:36 -0700)
committerJames Bottomley <James.Bottomley@suse.de>
Sat, 12 Sep 2009 14:35:22 +0000 (09:35 -0500)
* Consolidate vport-count processing.
* Correct vp_idx restrictions during RSCN processing.
* Push topology verification check to qla2x00_do_dpc_all_vps().
* Don't skip vport full-login-lip/lip-reset mailbox handling.

Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
drivers/scsi/qla2xxx/qla_attr.c
drivers/scsi/qla2xxx/qla_init.c
drivers/scsi/qla2xxx/qla_isr.c
drivers/scsi/qla2xxx/qla_mid.c
drivers/scsi/qla2xxx/qla_os.c

index 5b0a222241bbe24ac18f1269d2004c29af7898c8..fbcb82a2f7f4c5b4e8dffc5573c0fa1b64e46719 100644 (file)
@@ -1736,6 +1736,11 @@ qla24xx_vport_delete(struct fc_vport *fc_vport)
 
        qla24xx_deallocate_vp_id(vha);
 
+       mutex_lock(&ha->vport_lock);
+       ha->cur_vport_count--;
+       clear_bit(vha->vp_idx, ha->vp_idx_map);
+       mutex_unlock(&ha->vport_lock);
+
        if (vha->timer_active) {
                qla2x00_vp_stop_timer(vha);
                DEBUG15(printk ("scsi(%ld): timer for the vport[%d] = %p "
index 825700ae50416a5602aafc3324cf87bf86ee9b73..f74d07a9e945d1a090543bc82c4c1a1d77cd7075 100644 (file)
@@ -3540,8 +3540,6 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)
                if (atomic_read(&vha->loop_state) != LOOP_DOWN) {
                        atomic_set(&vha->loop_state, LOOP_DOWN);
                        qla2x00_mark_all_devices_lost(vha, 0);
-                       list_for_each_entry_safe(vp, tvp, &ha->vp_list, list)
-                              qla2x00_mark_all_devices_lost(vp, 0);
                } else {
                        if (!atomic_read(&vha->loop_down_timer))
                                atomic_set(&vha->loop_down_timer,
index 27db6246ca3ec195ad6ce33a0845fea890249846..b20a7169aac28990a2debb7670716668b9815d37 100644 (file)
@@ -685,8 +685,9 @@ skip_rio:
                if (vha->vp_idx && test_bit(VP_SCR_NEEDED, &vha->vp_flags))
                        break;
                /* Only handle SCNs for our Vport index. */
-               if (vha->vp_idx != (mb[3] & 0xff))
+               if (ha->flags.npiv_supported && vha->vp_idx != (mb[3] & 0xff))
                        break;
+
                DEBUG2(printk("scsi(%ld): Asynchronous RSCR UPDATE.\n",
                    vha->host_no));
                DEBUG(printk(KERN_INFO
index a748a95efb10c7487187d56e551563aaa8f411c9..42b799abba57da6bda0dc35b6fcf133d9092da8b 100644 (file)
@@ -42,7 +42,6 @@ qla24xx_allocate_vp_id(scsi_qla_host_t *vha)
 
        set_bit(vp_id, ha->vp_idx_map);
        ha->num_vhosts++;
-       ha->cur_vport_count++;
        vha->vp_idx = vp_id;
        list_add_tail(&vha->list, &ha->vp_list);
        mutex_unlock(&ha->vport_lock);
@@ -58,7 +57,6 @@ qla24xx_deallocate_vp_id(scsi_qla_host_t *vha)
        mutex_lock(&ha->vport_lock);
        vp_id = vha->vp_idx;
        ha->num_vhosts--;
-       ha->cur_vport_count--;
        clear_bit(vp_id, ha->vp_idx_map);
        list_del(&vha->list);
        mutex_unlock(&ha->vport_lock);
@@ -235,7 +233,11 @@ qla2x00_vp_abort_isp(scsi_qla_host_t *vha)
                        atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
        }
 
-       /* To exclusively reset vport, we need to log it out first.*/
+       /*
+        * To exclusively reset vport, we need to log it out first.  Note: this
+        * control_vp can fail if ISP reset is already issued, this is
+        * expected, as the vp would be already logged out due to ISP reset.
+        */
        if (!test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))
                qla24xx_control_vp(vha, VCE_COMMAND_DISABLE_VPS_LOGO_ALL);
 
@@ -247,23 +249,11 @@ qla2x00_vp_abort_isp(scsi_qla_host_t *vha)
 static int
 qla2x00_do_dpc_vp(scsi_qla_host_t *vha)
 {
-       struct qla_hw_data *ha = vha->hw;
-       scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
-
-       if (!(ha->current_topology & ISP_CFG_F))
-               return 0;
-
        qla2x00_do_work(vha);
 
        if (test_and_clear_bit(VP_IDX_ACQUIRED, &vha->vp_flags)) {
                /* VP acquired. complete port configuration */
-               if (atomic_read(&base_vha->loop_state) == LOOP_READY) {
-                       qla24xx_configure_vp(vha);
-               } else {
-                       set_bit(VP_IDX_ACQUIRED, &vha->vp_flags);
-                       set_bit(VP_DPC_NEEDED, &base_vha->dpc_flags);
-               }
-
+               qla24xx_configure_vp(vha);
                return 0;
        }
 
@@ -314,6 +304,9 @@ qla2x00_do_dpc_all_vps(scsi_qla_host_t *vha)
 
        clear_bit(VP_DPC_NEEDED, &vha->dpc_flags);
 
+       if (!(ha->current_topology & ISP_CFG_F))
+               return;
+
        list_for_each_entry_safe(vp, tvp, &ha->vp_list, list) {
                if (vp->vp_idx)
                        ret = qla2x00_do_dpc_vp(vp);
@@ -418,6 +411,11 @@ qla24xx_create_vhost(struct fc_vport *fc_vport)
 
        vha->flags.init_done = 1;
 
+       mutex_lock(&ha->vport_lock);
+       set_bit(vha->vp_idx, ha->vp_idx_map);
+       ha->cur_vport_count++;
+       mutex_unlock(&ha->vport_lock);
+
        return vha;
 
 create_vhost_failed:
index ea9f91756c1e5d48b8b977eebe62f0a7fe39209b..2102290195886ed14c93269e11c6c3853678d359 100644 (file)
@@ -1119,8 +1119,7 @@ qla2x00_loop_reset(scsi_qla_host_t *vha)
        struct fc_port *fcport;
        struct qla_hw_data *ha = vha->hw;
 
-       if (ha->flags.enable_lip_full_login && !vha->vp_idx &&
-           !IS_QLA81XX(ha)) {
+       if (ha->flags.enable_lip_full_login && !IS_QLA81XX(ha)) {
                ret = qla2x00_full_login_lip(vha);
                if (ret != QLA_SUCCESS) {
                        DEBUG2_3(printk("%s(%ld): failed: "
@@ -1133,7 +1132,7 @@ qla2x00_loop_reset(scsi_qla_host_t *vha)
                qla2x00_wait_for_loop_ready(vha);
        }
 
-       if (ha->flags.enable_lip_reset && !vha->vp_idx) {
+       if (ha->flags.enable_lip_reset) {
                ret = qla2x00_lip_reset(vha);
                if (ret != QLA_SUCCESS) {
                        DEBUG2_3(printk("%s(%ld): failed: "
@@ -2264,8 +2263,9 @@ qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha, int defer)
        fc_port_t *fcport;
 
        list_for_each_entry(fcport, &vha->vp_fcports, list) {
-               if (vha->vp_idx != fcport->vp_idx)
+               if (vha->vp_idx != 0 && vha->vp_idx != fcport->vp_idx)
                        continue;
+
                /*
                 * No point in marking the device as lost, if the device is
                 * already DEAD.
@@ -2273,10 +2273,12 @@ qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha, int defer)
                if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD)
                        continue;
                if (atomic_read(&fcport->state) == FCS_ONLINE) {
-                       atomic_set(&fcport->state, FCS_DEVICE_LOST);
-                       qla2x00_schedule_rport_del(vha, fcport, defer);
-               } else
-                       atomic_set(&fcport->state, FCS_DEVICE_LOST);
+                       if (defer)
+                               qla2x00_schedule_rport_del(vha, fcport, defer);
+                       else if (vha->vp_idx == fcport->vp_idx)
+                               qla2x00_schedule_rport_del(vha, fcport, defer);
+               }
+               atomic_set(&fcport->state, FCS_DEVICE_LOST);
        }
 }
 
@@ -3069,8 +3071,7 @@ qla2x00_timer(scsi_qla_host_t *vha)
 
                /* if the loop has been down for 4 minutes, reinit adapter */
                if (atomic_dec_and_test(&vha->loop_down_timer) != 0) {
-                       if (!(vha->device_flags & DFLG_NO_CABLE) &&
-                           !vha->vp_idx) {
+                       if (!(vha->device_flags & DFLG_NO_CABLE)) {
                                DEBUG(printk("scsi(%ld): Loop down - "
                                    "aborting ISP.\n",
                                    vha->host_no));