nfp: calculate ring masks without conditionals
authorJakub Kicinski <jakub.kicinski@netronome.com>
Mon, 21 Mar 2022 10:42:00 +0000 (11:42 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 21 Mar 2022 13:21:16 +0000 (13:21 +0000)
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/netronome/nfp/nfp_net_common.c

index ef8645b..50f7ada 100644 (file)
@@ -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);