Commit 0d6e61bc authored by Andrew Vasquez's avatar Andrew Vasquez Committed by James Bottomley

[SCSI] qla2xxx: Correct various NPIV issues.

* 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: default avatarAndrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: default avatarGiridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent d970432c
...@@ -1736,6 +1736,11 @@ qla24xx_vport_delete(struct fc_vport *fc_vport) ...@@ -1736,6 +1736,11 @@ qla24xx_vport_delete(struct fc_vport *fc_vport)
qla24xx_deallocate_vp_id(vha); 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) { if (vha->timer_active) {
qla2x00_vp_stop_timer(vha); qla2x00_vp_stop_timer(vha);
DEBUG15(printk ("scsi(%ld): timer for the vport[%d] = %p " DEBUG15(printk ("scsi(%ld): timer for the vport[%d] = %p "
......
...@@ -3540,8 +3540,6 @@ qla2x00_abort_isp(scsi_qla_host_t *vha) ...@@ -3540,8 +3540,6 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)
if (atomic_read(&vha->loop_state) != LOOP_DOWN) { if (atomic_read(&vha->loop_state) != LOOP_DOWN) {
atomic_set(&vha->loop_state, LOOP_DOWN); atomic_set(&vha->loop_state, LOOP_DOWN);
qla2x00_mark_all_devices_lost(vha, 0); 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 { } else {
if (!atomic_read(&vha->loop_down_timer)) if (!atomic_read(&vha->loop_down_timer))
atomic_set(&vha->loop_down_timer, atomic_set(&vha->loop_down_timer,
......
...@@ -685,8 +685,9 @@ qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que *rsp, uint16_t *mb) ...@@ -685,8 +685,9 @@ qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que *rsp, uint16_t *mb)
if (vha->vp_idx && test_bit(VP_SCR_NEEDED, &vha->vp_flags)) if (vha->vp_idx && test_bit(VP_SCR_NEEDED, &vha->vp_flags))
break; break;
/* Only handle SCNs for our Vport index. */ /* 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; break;
DEBUG2(printk("scsi(%ld): Asynchronous RSCR UPDATE.\n", DEBUG2(printk("scsi(%ld): Asynchronous RSCR UPDATE.\n",
vha->host_no)); vha->host_no));
DEBUG(printk(KERN_INFO DEBUG(printk(KERN_INFO
......
...@@ -42,7 +42,6 @@ qla24xx_allocate_vp_id(scsi_qla_host_t *vha) ...@@ -42,7 +42,6 @@ qla24xx_allocate_vp_id(scsi_qla_host_t *vha)
set_bit(vp_id, ha->vp_idx_map); set_bit(vp_id, ha->vp_idx_map);
ha->num_vhosts++; ha->num_vhosts++;
ha->cur_vport_count++;
vha->vp_idx = vp_id; vha->vp_idx = vp_id;
list_add_tail(&vha->list, &ha->vp_list); list_add_tail(&vha->list, &ha->vp_list);
mutex_unlock(&ha->vport_lock); mutex_unlock(&ha->vport_lock);
...@@ -58,7 +57,6 @@ qla24xx_deallocate_vp_id(scsi_qla_host_t *vha) ...@@ -58,7 +57,6 @@ qla24xx_deallocate_vp_id(scsi_qla_host_t *vha)
mutex_lock(&ha->vport_lock); mutex_lock(&ha->vport_lock);
vp_id = vha->vp_idx; vp_id = vha->vp_idx;
ha->num_vhosts--; ha->num_vhosts--;
ha->cur_vport_count--;
clear_bit(vp_id, ha->vp_idx_map); clear_bit(vp_id, ha->vp_idx_map);
list_del(&vha->list); list_del(&vha->list);
mutex_unlock(&ha->vport_lock); mutex_unlock(&ha->vport_lock);
...@@ -235,7 +233,11 @@ qla2x00_vp_abort_isp(scsi_qla_host_t *vha) ...@@ -235,7 +233,11 @@ qla2x00_vp_abort_isp(scsi_qla_host_t *vha)
atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); 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)) if (!test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))
qla24xx_control_vp(vha, VCE_COMMAND_DISABLE_VPS_LOGO_ALL); qla24xx_control_vp(vha, VCE_COMMAND_DISABLE_VPS_LOGO_ALL);
...@@ -247,23 +249,11 @@ qla2x00_vp_abort_isp(scsi_qla_host_t *vha) ...@@ -247,23 +249,11 @@ qla2x00_vp_abort_isp(scsi_qla_host_t *vha)
static int static int
qla2x00_do_dpc_vp(scsi_qla_host_t *vha) 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); qla2x00_do_work(vha);
if (test_and_clear_bit(VP_IDX_ACQUIRED, &vha->vp_flags)) { if (test_and_clear_bit(VP_IDX_ACQUIRED, &vha->vp_flags)) {
/* VP acquired. complete port configuration */ /* VP acquired. complete port configuration */
if (atomic_read(&base_vha->loop_state) == LOOP_READY) {
qla24xx_configure_vp(vha); qla24xx_configure_vp(vha);
} else {
set_bit(VP_IDX_ACQUIRED, &vha->vp_flags);
set_bit(VP_DPC_NEEDED, &base_vha->dpc_flags);
}
return 0; return 0;
} }
...@@ -314,6 +304,9 @@ qla2x00_do_dpc_all_vps(scsi_qla_host_t *vha) ...@@ -314,6 +304,9 @@ qla2x00_do_dpc_all_vps(scsi_qla_host_t *vha)
clear_bit(VP_DPC_NEEDED, &vha->dpc_flags); 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) { list_for_each_entry_safe(vp, tvp, &ha->vp_list, list) {
if (vp->vp_idx) if (vp->vp_idx)
ret = qla2x00_do_dpc_vp(vp); ret = qla2x00_do_dpc_vp(vp);
...@@ -418,6 +411,11 @@ qla24xx_create_vhost(struct fc_vport *fc_vport) ...@@ -418,6 +411,11 @@ qla24xx_create_vhost(struct fc_vport *fc_vport)
vha->flags.init_done = 1; 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; return vha;
create_vhost_failed: create_vhost_failed:
......
...@@ -1119,8 +1119,7 @@ qla2x00_loop_reset(scsi_qla_host_t *vha) ...@@ -1119,8 +1119,7 @@ qla2x00_loop_reset(scsi_qla_host_t *vha)
struct fc_port *fcport; struct fc_port *fcport;
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
if (ha->flags.enable_lip_full_login && !vha->vp_idx && if (ha->flags.enable_lip_full_login && !IS_QLA81XX(ha)) {
!IS_QLA81XX(ha)) {
ret = qla2x00_full_login_lip(vha); ret = qla2x00_full_login_lip(vha);
if (ret != QLA_SUCCESS) { if (ret != QLA_SUCCESS) {
DEBUG2_3(printk("%s(%ld): failed: " DEBUG2_3(printk("%s(%ld): failed: "
...@@ -1133,7 +1132,7 @@ qla2x00_loop_reset(scsi_qla_host_t *vha) ...@@ -1133,7 +1132,7 @@ qla2x00_loop_reset(scsi_qla_host_t *vha)
qla2x00_wait_for_loop_ready(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); ret = qla2x00_lip_reset(vha);
if (ret != QLA_SUCCESS) { if (ret != QLA_SUCCESS) {
DEBUG2_3(printk("%s(%ld): failed: " DEBUG2_3(printk("%s(%ld): failed: "
...@@ -2264,8 +2263,9 @@ qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha, int defer) ...@@ -2264,8 +2263,9 @@ qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha, int defer)
fc_port_t *fcport; fc_port_t *fcport;
list_for_each_entry(fcport, &vha->vp_fcports, list) { 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; continue;
/* /*
* No point in marking the device as lost, if the device is * No point in marking the device as lost, if the device is
* already DEAD. * already DEAD.
...@@ -2273,9 +2273,11 @@ qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha, int defer) ...@@ -2273,9 +2273,11 @@ qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha, int defer)
if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD) if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD)
continue; continue;
if (atomic_read(&fcport->state) == FCS_ONLINE) { if (atomic_read(&fcport->state) == FCS_ONLINE) {
atomic_set(&fcport->state, FCS_DEVICE_LOST); if (defer)
qla2x00_schedule_rport_del(vha, fcport, defer); qla2x00_schedule_rport_del(vha, fcport, defer);
} else else if (vha->vp_idx == fcport->vp_idx)
qla2x00_schedule_rport_del(vha, fcport, defer);
}
atomic_set(&fcport->state, FCS_DEVICE_LOST); atomic_set(&fcport->state, FCS_DEVICE_LOST);
} }
} }
...@@ -3069,8 +3071,7 @@ qla2x00_timer(scsi_qla_host_t *vha) ...@@ -3069,8 +3071,7 @@ qla2x00_timer(scsi_qla_host_t *vha)
/* if the loop has been down for 4 minutes, reinit adapter */ /* if the loop has been down for 4 minutes, reinit adapter */
if (atomic_dec_and_test(&vha->loop_down_timer) != 0) { if (atomic_dec_and_test(&vha->loop_down_timer) != 0) {
if (!(vha->device_flags & DFLG_NO_CABLE) && if (!(vha->device_flags & DFLG_NO_CABLE)) {
!vha->vp_idx) {
DEBUG(printk("scsi(%ld): Loop down - " DEBUG(printk("scsi(%ld): Loop down - "
"aborting ISP.\n", "aborting ISP.\n",
vha->host_no)); vha->host_no));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment