netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <simon.horman@corigine.com>
To: David Miller <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, oss-drivers@corigine.com
Subject: [PATCH net-next 01/10] nfp: calculate ring masks without conditionals
Date: Fri, 18 Mar 2022 11:12:53 +0100	[thread overview]
Message-ID: <20220318101302.113419-2-simon.horman@corigine.com> (raw)
In-Reply-To: <20220318101302.113419-1-simon.horman@corigine.com>

From: Jakub Kicinski <jakub.kicinski@netronome.com>

Ring enable masks are 64bit long.  Replace mask calculation from:
  block_cnt == 64 ? 0xffffffffffffffffULL : (1 << block_cnt) - 1
with:
  (U64_MAX >> (64 - block_cnt))
to simplify the code.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Fei Qin <fei.qin@corigine.com>
Signed-off-by: Simon Horman <simon.horman@corigine.com>
---
 drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
index ef8645b77e79..50f7ada0dedd 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
@@ -2959,11 +2959,11 @@ static int nfp_net_set_config_and_enable(struct nfp_net *nn)
 	for (r = 0; r < nn->dp.num_rx_rings; r++)
 		nfp_net_rx_ring_hw_cfg_write(nn, &nn->dp.rx_rings[r], r);
 
-	nn_writeq(nn, NFP_NET_CFG_TXRS_ENABLE, nn->dp.num_tx_rings == 64 ?
-		  0xffffffffffffffffULL : ((u64)1 << nn->dp.num_tx_rings) - 1);
+	nn_writeq(nn, NFP_NET_CFG_TXRS_ENABLE,
+		  U64_MAX >> (64 - nn->dp.num_tx_rings));
 
-	nn_writeq(nn, NFP_NET_CFG_RXRS_ENABLE, nn->dp.num_rx_rings == 64 ?
-		  0xffffffffffffffffULL : ((u64)1 << nn->dp.num_rx_rings) - 1);
+	nn_writeq(nn, NFP_NET_CFG_RXRS_ENABLE,
+		  U64_MAX >> (64 - nn->dp.num_rx_rings));
 
 	if (nn->dp.netdev)
 		nfp_net_write_mac_addr(nn, nn->dp.netdev->dev_addr);
-- 
2.30.2


  reply	other threads:[~2022-03-18 10:13 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-18 10:12 [PATCH net-next 00/10] nfp: support for NFP-3800 Simon Horman
2022-03-18 10:12 ` Simon Horman [this message]
2022-03-18 10:12 ` [PATCH net-next 02/10] nfp: move the fast path code to separate files Simon Horman
2022-03-18 10:12 ` [PATCH net-next 03/10] nfp: use callbacks for slow path ring related functions Simon Horman
2022-03-18 10:12 ` [PATCH net-next 04/10] nfp: prepare for multi-part descriptors Simon Horman
2022-03-18 10:12 ` [PATCH net-next 05/10] nfp: move tx_ring->qcidx into cold data Simon Horman
2022-03-18 10:12 ` [PATCH net-next 06/10] nfp: use TX ring pointer write back Simon Horman
2022-03-18 10:12 ` [PATCH net-next 07/10] nfp: add per-data path feature mask Simon Horman
2022-03-18 10:13 ` [PATCH net-next 08/10] nfp: choose data path based on version Simon Horman
2022-03-18 10:13 ` [PATCH net-next 09/10] nfp: add support for NFDK data path Simon Horman
2022-03-18 17:56   ` Jakub Kicinski
2022-03-19  1:50     ` Yinjun Zhang
2022-03-18 10:13 ` [PATCH net-next 10/10] nfp: nfdk: implement xdp tx path for NFDK Simon Horman
2022-03-18 17:56   ` Jakub Kicinski
2022-03-19  1:55     ` Yinjun Zhang
2022-03-19  3:15       ` Yinjun Zhang
2022-03-19  4:30       ` Jakub Kicinski
2022-03-19  6:26         ` Yinjun Zhang

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=20220318101302.113419-2-simon.horman@corigine.com \
    --to=simon.horman@corigine.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@corigine.com \
    /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).