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 |
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 --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 */
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(+)