Daniel Wagner 2bd7c9
From: Quinn Tran <qutran@marvell.com>
Daniel Wagner 2bd7c9
Date: Wed, 8 Jun 2022 04:58:47 -0700
Daniel Wagner 2bd7c9
Subject: scsi: qla2xxx: edif: Reduce N2N thrashing at app_start time
Denis Kirjanov 718367
Patch-mainline: v5.20-rc1
Daniel Wagner 2bd7c9
Git-commit: 37be3f9d6993a721bc019f03c97ea0fe66319997
Daniel Wagner 2bd7c9
References: bsc#1201958
Daniel Wagner 2bd7c9
Daniel Wagner 2bd7c9
For N2N + remote WWPN is bigger than local adapter, remote adapter will
Daniel Wagner 2bd7c9
login to local adapter while authentication application is not running.
Daniel Wagner 2bd7c9
When authentication application starts, the current session in FW needs to
Daniel Wagner 2bd7c9
to be invalidated.
Daniel Wagner 2bd7c9
Daniel Wagner 2bd7c9
Make sure the old session is torn down before triggering a relogin.
Daniel Wagner 2bd7c9
Daniel Wagner 2bd7c9
Link: https://lore.kernel.org/r/20220608115849.16693-9-njavali@marvell.com
Daniel Wagner 2bd7c9
Fixes: 4de067e5df12 ("scsi: qla2xxx: edif: Add N2N support for EDIF")
Daniel Wagner 2bd7c9
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Daniel Wagner 2bd7c9
Signed-off-by: Quinn Tran <qutran@marvell.com>
Daniel Wagner 2bd7c9
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Daniel Wagner 2bd7c9
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Daniel Wagner 2bd7c9
Acked-by: Daniel Wagner <dwagner@suse.de>
Daniel Wagner 2bd7c9
---
Daniel Wagner 2bd7c9
 drivers/scsi/qla2xxx/qla_edif.c |   51 ++++++++++++++++++++++++++++------------
Daniel Wagner 2bd7c9
 1 file changed, 36 insertions(+), 15 deletions(-)
Daniel Wagner 2bd7c9
Daniel Wagner 2bd7c9
--- a/drivers/scsi/qla2xxx/qla_edif.c
Daniel Wagner 2bd7c9
+++ b/drivers/scsi/qla2xxx/qla_edif.c
Daniel Wagner 2bd7c9
@@ -517,11 +517,28 @@ qla_edif_app_start(scsi_qla_host_t *vha,
Daniel Wagner 2bd7c9
 		list_for_each_entry_safe(fcport, tf, &vha->vp_fcports, list)
Daniel Wagner 2bd7c9
 			fcport->n2n_link_reset_cnt = 0;
Daniel Wagner 2bd7c9
 
Daniel Wagner 2bd7c9
-		if (vha->hw->flags.n2n_fw_acc_sec)
Daniel Wagner 2bd7c9
-			set_bit(N2N_LINK_RESET, &vha->dpc_flags);
Daniel Wagner 2bd7c9
-		else
Daniel Wagner 2bd7c9
+		if (vha->hw->flags.n2n_fw_acc_sec) {
Daniel Wagner 2bd7c9
+			list_for_each_entry_safe(fcport, tf, &vha->vp_fcports, list)
Daniel Wagner 2bd7c9
+				qla_edif_sa_ctl_init(vha, fcport);
Daniel Wagner 2bd7c9
+
Daniel Wagner 2bd7c9
+			/*
Daniel Wagner 2bd7c9
+			 * While authentication app was not running, remote device
Daniel Wagner 2bd7c9
+			 * could still try to login with this local port.  Let's
Daniel Wagner 2bd7c9
+			 * clear the state and try again.
Daniel Wagner 2bd7c9
+			 */
Daniel Wagner 2bd7c9
+			qla2x00_wait_for_sess_deletion(vha);
Daniel Wagner 2bd7c9
+
Daniel Wagner 2bd7c9
+			/* bounce the link to get the other guy to relogin */
Daniel Wagner 2bd7c9
+			if (!vha->hw->flags.n2n_bigger) {
Daniel Wagner 2bd7c9
+				set_bit(N2N_LINK_RESET, &vha->dpc_flags);
Daniel Wagner 2bd7c9
+				qla2xxx_wake_dpc(vha);
Daniel Wagner 2bd7c9
+			}
Daniel Wagner 2bd7c9
+		} else {
Daniel Wagner 2bd7c9
+			qla2x00_wait_for_hba_online(vha);
Daniel Wagner 2bd7c9
 			set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
Daniel Wagner 2bd7c9
-		qla2xxx_wake_dpc(vha);
Daniel Wagner 2bd7c9
+			qla2xxx_wake_dpc(vha);
Daniel Wagner 2bd7c9
+			qla2x00_wait_for_hba_online(vha);
Daniel Wagner 2bd7c9
+		}
Daniel Wagner 2bd7c9
 	} else {
Daniel Wagner 2bd7c9
 		list_for_each_entry_safe(fcport, tf, &vha->vp_fcports, list) {
Daniel Wagner 2bd7c9
 			ql_dbg(ql_dbg_edif, vha, 0x2058,
Daniel Wagner 2bd7c9
@@ -920,17 +937,21 @@ qla_edif_app_getfcinfo(scsi_qla_host_t *
Daniel Wagner 2bd7c9
 			if (tdid.b24 != 0 && tdid.b24 != fcport->d_id.b24)
Daniel Wagner 2bd7c9
 				continue;
Daniel Wagner 2bd7c9
 
Daniel Wagner 2bd7c9
-			if (fcport->scan_state != QLA_FCPORT_FOUND)
Daniel Wagner 2bd7c9
-				continue;
Daniel Wagner 2bd7c9
-
Daniel Wagner 2bd7c9
-			if (fcport->port_type == FCT_UNKNOWN && !fcport->fc4_features)
Daniel Wagner 2bd7c9
-				rval = qla24xx_async_gffid(vha, fcport, true);
Daniel Wagner 2bd7c9
-
Daniel Wagner 2bd7c9
-			if (!rval &&
Daniel Wagner 2bd7c9
-			    !(fcport->fc4_features & FC4_FF_TARGET ||
Daniel Wagner 2bd7c9
-			      fcport->port_type &
Daniel Wagner 2bd7c9
-			      (FCT_TARGET | FCT_NVME_TARGET)))
Daniel Wagner 2bd7c9
-				continue;
Daniel Wagner 2bd7c9
+			if (!N2N_TOPO(vha->hw)) {
Daniel Wagner 2bd7c9
+				if (fcport->scan_state != QLA_FCPORT_FOUND)
Daniel Wagner 2bd7c9
+					continue;
Daniel Wagner 2bd7c9
+
Daniel Wagner 2bd7c9
+				if (fcport->port_type == FCT_UNKNOWN &&
Daniel Wagner 2bd7c9
+				    !fcport->fc4_features)
Daniel Wagner 2bd7c9
+					rval = qla24xx_async_gffid(vha, fcport,
Daniel Wagner 2bd7c9
+								   true);
Daniel Wagner 2bd7c9
+
Daniel Wagner 2bd7c9
+				if (!rval &&
Daniel Wagner 2bd7c9
+				    !(fcport->fc4_features & FC4_FF_TARGET ||
Daniel Wagner 2bd7c9
+				      fcport->port_type &
Daniel Wagner 2bd7c9
+				      (FCT_TARGET | FCT_NVME_TARGET)))
Daniel Wagner 2bd7c9
+					continue;
Daniel Wagner 2bd7c9
+			}
Daniel Wagner 2bd7c9
 
Daniel Wagner 2bd7c9
 			rval = 0;
Daniel Wagner 2bd7c9