From: John Fastabend <john.fastabend@gmail.com>
To: Maciej Fijalkowski <maciej.fijalkowski@intel.com>,
bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net
Cc: netdev@vger.kernel.org, magnus.karlsson@intel.com,
bjorn@kernel.org, kuba@kernel.org,
Maciej Fijalkowski <maciej.fijalkowski@intel.com>,
Alexandr Lobakin <alexandr.lobakin@intel.com>
Subject: RE: [PATCH v4 bpf-next 01/10] ice: compress branches in ice_set_features()
Date: Fri, 17 Jun 2022 18:46:35 -0700 [thread overview]
Message-ID: <62ad2e7b9ff11_24b342081a@john.notmuch> (raw)
In-Reply-To: <20220616180609.905015-2-maciej.fijalkowski@intel.com>
Maciej Fijalkowski wrote:
> Instead of rather verbose comparison of current netdev->features bits vs
> the incoming ones from user, let us compress them by a helper features
> set that will be the result of netdev->features XOR features. This way,
> current, extensive branches:
>
> if (features & NETIF_F_BIT && !(netdev->features & NETIF_F_BIT))
> set_feature(true);
> else if (!(features & NETIF_F_BIT) && netdev->features & NETIF_F_BIT)
> set_feature(false);
>
> can become:
>
> netdev_features_t changed = netdev->features ^ features;
>
> if (changed & NETIF_F_BIT)
> set_feature(!!(features & NETIF_F_BIT));
>
> This is nothing new as currently several other drivers use this
> approach, which I find much more convenient.
Looks good couple nits below. Up to you if you want to follow through
on them or not I don't have a strong opinion. For what its worth the
other intel drivers also do the 'netdev->features ^ features'
assignment.
Acked-by: John Fastabend <john.fastabend@gmail.com>
>
> CC: Alexandr Lobakin <alexandr.lobakin@intel.com>
> Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_main.c | 40 +++++++++++------------
> 1 file changed, 19 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
> index e1cae253412c..23d1b1fc39fb 100644
> --- a/drivers/net/ethernet/intel/ice/ice_main.c
> +++ b/drivers/net/ethernet/intel/ice/ice_main.c
> @@ -5910,44 +5910,41 @@ 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;
> int ret = 0;
>
> /* 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");
> + if (ice_is_safe_mode(pf)) {
> + dev_err(ice_pf_to_dev(vsi->back),
bit of nitpicking but if you use pf in the 'if' above why not use it here
as well and save a few keys. Also matches below then.
> + "Device is in Safe Mode - not enabling advanced netdev features\n");
> 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(pf),
> + "Device is resetting, changing advanced netdev features temporarily unavailable.\n");
> return -EBUSY;
> }
>
[...]
> @@ -5956,11 +5953,12 @@ 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);
> + }
Just a note you changed the logic slightly here. Above you always
clear the bit. But, it looks like it doesn't matter caveat being
I don't know what might happen in hardware.
>
> return 0;
> }
> --
> 2.27.0
>
next prev parent reply other threads:[~2022-06-18 1:46 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-16 18:05 [PATCH v4 bpf-next 00/10] AF_XDP ZC selftests Maciej Fijalkowski
2022-06-16 18:06 ` [PATCH v4 bpf-next 01/10] ice: compress branches in ice_set_features() Maciej Fijalkowski
2022-06-18 1:46 ` John Fastabend [this message]
2022-06-20 9:48 ` Maciej Fijalkowski
2022-06-16 18:06 ` [PATCH v4 bpf-next 02/10] ice: allow toggling loopback mode via ndo_set_features callback Maciej Fijalkowski
2022-06-16 18:21 ` Jakub Kicinski
2022-06-18 1:57 ` John Fastabend
2022-06-20 9:52 ` Maciej Fijalkowski
2022-06-16 18:06 ` [PATCH v4 bpf-next 03/10] ice: check DD bit on Rx descriptor rather than (EOP | RS) Maciej Fijalkowski
2022-06-18 1:58 ` John Fastabend
2022-06-20 10:53 ` Maciej Fijalkowski
2022-06-16 18:06 ` [PATCH v4 bpf-next 04/10] ice: do not setup vlan for loopback VSI Maciej Fijalkowski
2022-06-18 2:01 ` John Fastabend
2022-06-16 18:06 ` [PATCH v4 bpf-next 05/10] selftests: xsk: query for native XDP support Maciej Fijalkowski
2022-06-18 2:12 ` John Fastabend
2022-06-20 10:55 ` Maciej Fijalkowski
2022-06-16 18:06 ` [PATCH v4 bpf-next 06/10] selftests: xsk: add missing close() on netns fd Maciej Fijalkowski
2022-06-18 2:14 ` John Fastabend
2022-06-16 18:06 ` [PATCH v4 bpf-next 07/10] selftests: xsk: introduce default Rx pkt stream Maciej Fijalkowski
2022-06-18 2:41 ` John Fastabend
2022-06-20 8:41 ` Magnus Karlsson
2022-06-16 18:06 ` [PATCH v4 bpf-next 08/10] selftests: xsk: add support for executing tests on physical device Maciej Fijalkowski
2022-06-16 18:06 ` [PATCH v4 bpf-next 09/10] selftests: xsk: rely on pkts_in_flight in wait_for_tx_completion() Maciej Fijalkowski
2022-06-18 2:56 ` John Fastabend
2022-06-20 12:02 ` Maciej Fijalkowski
2022-06-20 16:36 ` John Fastabend
2022-06-16 18:06 ` [PATCH v4 bpf-next 10/10] selftests: xsk: add support for zero copy testing Maciej Fijalkowski
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=62ad2e7b9ff11_24b342081a@john.notmuch \
--to=john.fastabend@gmail.com \
--cc=alexandr.lobakin@intel.com \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kuba@kernel.org \
--cc=maciej.fijalkowski@intel.com \
--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).