netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Alexander Lobakin <alexandr.lobakin@intel.com>
Cc: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
	netdev@vger.kernel.org, magnus.karlsson@intel.com,
	bjorn@kernel.org
Subject: Re: [PATCH v2 bpf-next 01/10] ice: allow toggling loopback mode via ndo_set_features callback
Date: Wed, 15 Jun 2022 16:01:49 +0200	[thread overview]
Message-ID: <YqnmTUpTgquVOsP5@boxer> (raw)
In-Reply-To: <20220615103804.1260221-1-alexandr.lobakin@intel.com>

On Wed, Jun 15, 2022 at 12:38:04PM +0200, Alexander Lobakin wrote:
> From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> Date: Tue, 14 Jun 2022 19:47:40 +0200
> 
> > Add support for NETIF_F_LOOPBACK. Also, simplify checks throughout whole
> > ice_set_features().
> > 
> > CC: Alexandr Lobakin <alexandr.lobakin@intel.com>
> > Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> > ---
> >  drivers/net/ethernet/intel/ice/ice_main.c | 54 ++++++++++++++---------
> >  1 file changed, 34 insertions(+), 20 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
> > index e1cae253412c..ab00b0361e87 100644
> > --- a/drivers/net/ethernet/intel/ice/ice_main.c
> > +++ b/drivers/net/ethernet/intel/ice/ice_main.c
> > @@ -3358,6 +3358,7 @@ static void ice_set_netdev_features(struct net_device *netdev)
> >  	netdev->features |= netdev->hw_features;
> >  
> >  	netdev->hw_features |= NETIF_F_HW_TC;
> > +	netdev->hw_features |= NETIF_F_LOOPBACK;
> >  
> >  	/* encap and VLAN devices inherit default, csumo and tso features */
> >  	netdev->hw_enc_features |= dflt_features | csumo_features |
> > @@ -5902,6 +5903,18 @@ ice_set_vlan_features(struct net_device *netdev, netdev_features_t features)
> >  	return 0;
> >  }
> >  
> > +static void ice_set_loopback(struct ice_pf *pf, struct net_device *netdev, bool ena)
> 
> I feel like the first argument is redundant in here since we can do
> 
> 	const struct ice_netdev_priv *np = netdev_priv(netdev);
> 	struct ice_pf *pf = np->vsi->back;
> 
> But at the same time one function argument can be cheaper than two
> jumps, so up to you.
> 
> > +{
> > +	bool if_running = netif_running(netdev);
> > +
> > +	if (if_running)
> > +		ice_stop(netdev);
> > +	if (ice_aq_set_mac_loopback(&pf->hw, ena, NULL))
> > +		dev_err(ice_pf_to_dev(pf), "Failed to toggle loopback state\n");
> 
> netdev_err() instead probably? I guess dev_err() is used for
> consistency with the rest of ice_set_features(), but I'd recommend
> using the former anyways.

So let's use netdev_err and drop the pf from arguments that are passed

> 
> > +	if (if_running)
> > +		ice_open(netdev);
> > +}
> > +
> >  /**
> >   * ice_set_features - set the netdev feature flags
> >   * @netdev: ptr to the netdev being adjusted
> > @@ -5910,6 +5923,7 @@ ice_set_vlan_features(struct net_device *netdev, netdev_features_t features)
> >  static int
> >  ice_set_features(struct net_device *netdev, netdev_features_t features)
> >  {
> > +	netdev_features_t changed = netdev->features ^ features;
> >  	struct ice_netdev_priv *np = netdev_priv(netdev);
> >  	struct ice_vsi *vsi = np->vsi;
> >  	struct ice_pf *pf = vsi->back;
> > @@ -5917,37 +5931,33 @@ ice_set_features(struct net_device *netdev, netdev_features_t features)
> >  
> >  	/* Don't set any netdev advanced features with device in Safe Mode */
> >  	if (ice_is_safe_mode(vsi->back)) {
> > -		dev_err(ice_pf_to_dev(vsi->back), "Device is in Safe Mode - not enabling advanced netdev features\n");
> > +		dev_err(ice_pf_to_dev(vsi->back),
> > +			"Device is in Safe Mode - not enabling advanced netdev features\n");
> 
> This (I mean the whole ice_set_features() cleanup) deserves to be in
> a separate patch to me. In can be a past of this series for sure.

ack, will pull out this to a standalone patch followed by loopback
enablement

> 
> >  		return ret;
> >  	}
> >  
> >  	/* Do not change setting during reset */
> >  	if (ice_is_reset_in_progress(pf->state)) {
> > -		dev_err(ice_pf_to_dev(vsi->back), "Device is resetting, changing advanced netdev features temporarily unavailable.\n");
> > +		dev_err(ice_pf_to_dev(vsi->back),
> > +			"Device is resetting, changing advanced netdev features temporarily unavailable.\n");
> >  		return -EBUSY;
> >  	}
> >  
> >  	/* Multiple features can be changed in one call so keep features in
> >  	 * separate if/else statements to guarantee each feature is checked
> >  	 */
> > -	if (features & NETIF_F_RXHASH && !(netdev->features & NETIF_F_RXHASH))
> > -		ice_vsi_manage_rss_lut(vsi, true);
> > -	else if (!(features & NETIF_F_RXHASH) &&
> > -		 netdev->features & NETIF_F_RXHASH)
> > -		ice_vsi_manage_rss_lut(vsi, false);
> > +	if (changed & NETIF_F_RXHASH)
> > +		ice_vsi_manage_rss_lut(vsi, !!(features & NETIF_F_RXHASH));
> >  
> >  	ret = ice_set_vlan_features(netdev, features);
> >  	if (ret)
> >  		return ret;
> >  
> > -	if ((features & NETIF_F_NTUPLE) &&
> > -	    !(netdev->features & NETIF_F_NTUPLE)) {
> > -		ice_vsi_manage_fdir(vsi, true);
> > -		ice_init_arfs(vsi);
> > -	} else if (!(features & NETIF_F_NTUPLE) &&
> > -		 (netdev->features & NETIF_F_NTUPLE)) {
> > -		ice_vsi_manage_fdir(vsi, false);
> > -		ice_clear_arfs(vsi);
> > +	if (changed & NETIF_F_NTUPLE) {
> > +		bool ena = !!(features & NETIF_F_NTUPLE);
> > +
> > +		ice_vsi_manage_fdir(vsi, ena);
> > +		ena ? ice_init_arfs(vsi) : ice_clear_arfs(vsi);
> >  	}
> >  
> >  	/* don't turn off hw_tc_offload when ADQ is already enabled */
> > @@ -5956,11 +5966,15 @@ ice_set_features(struct net_device *netdev, netdev_features_t features)
> >  		return -EACCES;
> >  	}
> >  
> > -	if ((features & NETIF_F_HW_TC) &&
> > -	    !(netdev->features & NETIF_F_HW_TC))
> > -		set_bit(ICE_FLAG_CLS_FLOWER, pf->flags);
> > -	else
> > -		clear_bit(ICE_FLAG_CLS_FLOWER, pf->flags);
> > +	if (changed & NETIF_F_HW_TC) {
> > +		bool ena = !!(features & NETIF_F_HW_TC);
> > +
> > +		ena ? set_bit(ICE_FLAG_CLS_FLOWER, pf->flags) :
> > +		      clear_bit(ICE_FLAG_CLS_FLOWER, pf->flags);
> > +	}
> > +
> > +	if (changed & NETIF_F_LOOPBACK)
> > +		ice_set_loopback(pf, netdev, !!(features & NETIF_F_LOOPBACK));
> >  
> >  	return 0;
> >  }
> > -- 
> > 2.27.0
> 
> The rest is good, I like wiring up standard interfaces with the
> existing hardware functionality :) Loopback mode is useful for
> testing stuff.

thanks for review!

> 
> Thanks!
> Olek

  reply	other threads:[~2022-06-15 14:02 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-14 17:47 [PATCH v2 bpf-next 00/10] AF_XDP ZC selftests Maciej Fijalkowski
2022-06-14 17:47 ` [PATCH v2 bpf-next 01/10] ice: allow toggling loopback mode via ndo_set_features callback Maciej Fijalkowski
2022-06-15 10:38   ` Alexander Lobakin
2022-06-15 14:01     ` Maciej Fijalkowski [this message]
2022-06-15 16:09       ` Maciej Fijalkowski
2022-06-15 23:47   ` Jakub Kicinski
2022-06-16 16:00     ` Maciej Fijalkowski
2022-06-16 16:47       ` Jakub Kicinski
2022-06-16 17:00         ` Maciej Fijalkowski
2022-06-14 17:47 ` [PATCH v2 bpf-next 02/10] ice: check DD bit on Rx descriptor rather than (EOP | RS) Maciej Fijalkowski
2022-06-14 17:47 ` [PATCH v2 bpf-next 03/10] ice: do not setup vlan for loopback VSI Maciej Fijalkowski
2022-06-14 17:47 ` [PATCH v2 bpf-next 04/10] selftests: xsk: query for native XDP support Maciej Fijalkowski
2022-06-15  7:07   ` Magnus Karlsson
2022-06-14 17:47 ` [PATCH v2 bpf-next 05/10] selftests: xsk: add missing close() on netns fd Maciej Fijalkowski
2022-06-14 17:47 ` [PATCH v2 bpf-next 06/10] selftests: xsk: introduce default Rx pkt stream Maciej Fijalkowski
2022-06-14 17:47 ` [PATCH v2 bpf-next 07/10] selftests: xsk: add support for executing tests on physical device Maciej Fijalkowski
2022-06-14 17:47 ` [PATCH v2 bpf-next 08/10] selftests: xsk: rely on pkts_in_flight in wait_for_tx_completion() Maciej Fijalkowski
2022-06-14 17:47 ` [PATCH v2 bpf-next 09/10] selftests: xsk: remove struct xsk_socket_info::outstanding_tx Maciej Fijalkowski
2022-06-14 17:47 ` [PATCH v2 bpf-next 10/10] selftests: xsk: add support for zero copy testing Maciej Fijalkowski
2022-06-15  7:09   ` Magnus Karlsson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YqnmTUpTgquVOsP5@boxer \
    --to=maciej.fijalkowski@intel.com \
    --cc=alexandr.lobakin@intel.com \
    --cc=ast@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).