diff mbox series

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

Message ID 20220610150923.583202-2-maciej.fijalkowski@intel.com (mailing list archive)
State Superseded
Delegated to: BPF
Headers show
Series AF_XDP ZC selftests | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-PR fail PR summary
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 13 maintainers not CCed: kafai@fb.com intel-wired-lan@lists.osuosl.org songliubraving@fb.com anthony.l.nguyen@intel.com jesse.brandeburg@intel.com pabeni@redhat.com kuba@kernel.org edumazet@google.com davem@davemloft.net yhs@fb.com john.fastabend@gmail.com andrii@kernel.org kpsingh@kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 36 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-VM_Test-1 fail Logs for Kernel LATEST on ubuntu-latest with gcc
bpf/vmtest-bpf-next-VM_Test-2 fail Logs for Kernel LATEST on ubuntu-latest with llvm-15
bpf/vmtest-bpf-next-VM_Test-3 fail Logs for Kernel LATEST on z15 with gcc

Commit Message

Maciej Fijalkowski June 10, 2022, 3:09 p.m. UTC
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@intel.com>
---
 drivers/net/ethernet/intel/ice/ice.h         |  1 +
 drivers/net/ethernet/intel/ice/ice_ethtool.c | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)

Comments

Alexander Lobakin June 10, 2022, 3:22 p.m. UTC | #1
From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Date: Fri, 10 Jun 2022 17:09:14 +0200

> 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@intel.com>
> ---
>  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,

I'do for %NETIF_F_LOOPBACK, should work in here, too :)

>  	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

Thanks,
Olek
diff mbox series

Patch

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
 	 */