[PATCH bpf-next 01/10] ice: introduce priv-flag for toggling loopback mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a knob that will allow user to turn the underlying net device into
loopback mode. The use case for this will be the AF_XDP ZC tests. Once
the device is in loopback mode, then it will be possible from AF_XDP
perspective to see if zero copy implementations in drivers work
properly.

The code for interaction with admin queue is reused from ethtool's
loopback test.

Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@xxxxxxxxx>
---
 drivers/net/ethernet/intel/ice/ice.h         |  1 +
 drivers/net/ethernet/intel/ice/ice_ethtool.c | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h
index 60453b3b8d23..90c066f3782b 100644
--- a/drivers/net/ethernet/intel/ice/ice.h
+++ b/drivers/net/ethernet/intel/ice/ice.h
@@ -487,6 +487,7 @@ enum ice_pf_flags {
 	ICE_FLAG_PLUG_AUX_DEV,
 	ICE_FLAG_MTU_CHANGED,
 	ICE_FLAG_GNSS,			/* GNSS successfully initialized */
+	ICE_FLAG_LOOPBACK,
 	ICE_PF_FLAGS_NBITS		/* must be last */
 };
 
diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c
index 1e71b70f0e52..cfc3c5e36907 100644
--- a/drivers/net/ethernet/intel/ice/ice_ethtool.c
+++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c
@@ -166,6 +166,7 @@ static const struct ice_priv_flag ice_gstrings_priv_flags[] = {
 	ICE_PRIV_FLAG("mdd-auto-reset-vf", ICE_FLAG_MDD_AUTO_RESET_VF),
 	ICE_PRIV_FLAG("vf-vlan-pruning", ICE_FLAG_VF_VLAN_PRUNING),
 	ICE_PRIV_FLAG("legacy-rx", ICE_FLAG_LEGACY_RX),
+	ICE_PRIV_FLAG("loopback", ICE_FLAG_LOOPBACK),
 };
 
 #define ICE_PRIV_FLAG_ARRAY_SIZE	ARRAY_SIZE(ice_gstrings_priv_flags)
@@ -1288,6 +1289,22 @@ static int ice_set_priv_flags(struct net_device *netdev, u32 flags)
 			ice_up(vsi);
 		}
 	}
+
+	if (test_bit(ICE_FLAG_LOOPBACK, change_flags)) {
+		if (!test_bit(ICE_FLAG_LOOPBACK, orig_flags)) {
+			/* Enable MAC loopback in firmware */
+			if (ice_aq_set_mac_loopback(&pf->hw, true, NULL)) {
+				dev_err(dev, "Failed to enable loopback\n");
+				ret = -ENXIO;
+			}
+		} else {
+			/* Disable MAC loopback in firmware */
+			if (ice_aq_set_mac_loopback(&pf->hw, false, NULL)) {
+				dev_err(dev, "Failed to disable loopback\n");
+				ret = -ENXIO;
+			}
+		}
+	}
 	/* don't allow modification of this flag when a single VF is in
 	 * promiscuous mode because it's not supported
 	 */
-- 
2.27.0




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux