list_for_each_entry_safe(fcport, tf, &vha->vp_fcports, list)
                        fcport->n2n_link_reset_cnt = 0;
 
-               if (vha->hw->flags.n2n_fw_acc_sec)
-                       set_bit(N2N_LINK_RESET, &vha->dpc_flags);
-               else
+               if (vha->hw->flags.n2n_fw_acc_sec) {
+                       list_for_each_entry_safe(fcport, tf, &vha->vp_fcports, list)
+                               qla_edif_sa_ctl_init(vha, fcport);
+
+                       /*
+                        * While authentication app was not running, remote device
+                        * could still try to login with this local port.  Let's
+                        * clear the state and try again.
+                        */
+                       qla2x00_wait_for_sess_deletion(vha);
+
+                       /* bounce the link to get the other guy to relogin */
+                       if (!vha->hw->flags.n2n_bigger) {
+                               set_bit(N2N_LINK_RESET, &vha->dpc_flags);
+                               qla2xxx_wake_dpc(vha);
+                       }
+               } else {
+                       qla2x00_wait_for_hba_online(vha);
                        set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
-               qla2xxx_wake_dpc(vha);
+                       qla2xxx_wake_dpc(vha);
+                       qla2x00_wait_for_hba_online(vha);
+               }
        } else {
                list_for_each_entry_safe(fcport, tf, &vha->vp_fcports, list) {
                        ql_dbg(ql_dbg_edif, vha, 0x2058,
                        if (tdid.b24 != 0 && tdid.b24 != fcport->d_id.b24)
                                continue;
 
-                       if (fcport->scan_state != QLA_FCPORT_FOUND)
-                               continue;
+                       if (!N2N_TOPO(vha->hw)) {
+                               if (fcport->scan_state != QLA_FCPORT_FOUND)
+                                       continue;
 
-                       if (fcport->port_type == FCT_UNKNOWN && !fcport->fc4_features)
-                               rval = qla24xx_async_gffid(vha, fcport, true);
+                               if (fcport->port_type == FCT_UNKNOWN &&
+                                   !fcport->fc4_features)
+                                       rval = qla24xx_async_gffid(vha, fcport,
+                                                                  true);
 
-                       if (!rval &&
-                           !(fcport->fc4_features & FC4_FF_TARGET ||
-                             fcport->port_type &
-                             (FCT_TARGET | FCT_NVME_TARGET)))
-                               continue;
+                               if (!rval &&
+                                   !(fcport->fc4_features & FC4_FF_TARGET ||
+                                     fcport->port_type &
+                                     (FCT_TARGET | FCT_NVME_TARGET)))
+                                       continue;
+                       }
 
                        rval = 0;