int rval;
        uint16_t comp_status;
        struct qla_hw_data *ha = vha->hw;
+       bool lid_is_sns = false;
 
        rval = QLA_FUNCTION_FAILED;
        if (ms_pkt->entry_status != 0) {
                        } else
                                rval = QLA_SUCCESS;
                        break;
+               case CS_PORT_LOGGED_OUT:
+                       if (IS_FWI2_CAPABLE(ha)) {
+                               if (le16_to_cpu(ms_pkt->loop_id.extended) ==
+                                   NPH_SNS)
+                                       lid_is_sns = true;
+                       } else {
+                               if (le16_to_cpu(ms_pkt->loop_id.extended) ==
+                                   SIMPLE_NAME_SERVER)
+                                       lid_is_sns = true;
+                       }
+                       if (lid_is_sns) {
+                               ql_dbg(ql_dbg_async, vha, 0x502b,
+                                       "%s failed, Name server has logged out",
+                                       routine);
+                               rval = QLA_NOT_LOGGED_IN;
+                               set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
+                               set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags);
+                       }
+                       break;
                default:
                        ql_dbg(ql_dbg_disc, vha, 0x2033,
                            "%s failed, completion status (%x) on port_id: "
 
        uint32_t id = 0, mask, rid;
        int rc;
 
+       switch (ea->event) {
+       case FCME_RELOGIN:
+       case FCME_RSCN:
+       case FCME_GIDPN_DONE:
+       case FCME_GPSC_DONE:
+       case FCME_GPNID_DONE:
+               if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) ||
+                   test_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags))
+                       return;
+               break;
+       default:
+               break;
+       }
+
        switch (ea->event) {
        case FCME_RELOGIN:
                if (test_bit(UNLOADING, &vha->dpc_flags))
                                /* EMPTY */
                                ql_dbg(ql_dbg_disc, vha, 0x2045,
                                    "Register FC-4 TYPE failed.\n");
+                               if (test_bit(LOOP_RESYNC_NEEDED,
+                                   &vha->dpc_flags))
+                                       break;
                        }
                        if (qla2x00_rff_id(vha)) {
                                /* EMPTY */
                                ql_dbg(ql_dbg_disc, vha, 0x2049,
                                    "Register FC-4 Features failed.\n");
+                               if (test_bit(LOOP_RESYNC_NEEDED,
+                                   &vha->dpc_flags))
+                                       break;
                        }
                        if (qla2x00_rnn_id(vha)) {
                                /* EMPTY */
                                ql_dbg(ql_dbg_disc, vha, 0x204f,
                                    "Register Node Name failed.\n");
+                               if (test_bit(LOOP_RESYNC_NEEDED,
+                                   &vha->dpc_flags))
+                                       break;
                        } else if (qla2x00_rsnn_nn(vha)) {
                                /* EMPTY */
                                ql_dbg(ql_dbg_disc, vha, 0x2053,
                                    "Register Symobilic Node Name failed.\n");
+                               if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags))
+                                       break;
                        }
                }
 
                memset(swl, 0, ha->max_fibre_devices * sizeof(sw_info_t));
                if (qla2x00_gid_pt(vha, swl) != QLA_SUCCESS) {
                        swl = NULL;
+                       if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags))
+                               return rval;
                } else if (qla2x00_gpn_id(vha, swl) != QLA_SUCCESS) {
                        swl = NULL;
+                       if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags))
+                               return rval;
                } else if (qla2x00_gnn_id(vha, swl) != QLA_SUCCESS) {
                        swl = NULL;
+                       if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags))
+                               return rval;
                } else if (qla2x00_gfpn_id(vha, swl) != QLA_SUCCESS) {
                        swl = NULL;
+                       if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags))
+                               return rval;
                }
 
                /* If other queries succeeded probe for FC-4 type */
-               if (swl)
+               if (swl) {
                        qla2x00_gff_id(vha, swl);
+                       if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags))
+                               return rval;
+               }
        }
        swl_idx = 0;
 
 
                        if (mb[1] == 0xffff)
                                goto global_port_update;
 
+                       if (mb[1] == NPH_SNS_LID(ha)) {
+                               set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
+                               set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags);
+                               break;
+                       }
+
+                       /* use handle_cnt for loop id/nport handle */
+                       if (IS_FWI2_CAPABLE(ha))
+                               handle_cnt = NPH_SNS;
+                       else
+                               handle_cnt = SIMPLE_NAME_SERVER;
+                       if (mb[1] == handle_cnt) {
+                               set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
+                               set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags);
+                               break;
+                       }
+
                        /* Port logout */
                        fcport = qla2x00_find_fcport_by_loopid(vha, mb[1]);
                        if (!fcport)