]> git.baikalelectronics.ru Git - kernel.git/commitdiff
octeontx2-pf: replace bitmap_weight with bitmap_empty where appropriate
authorYury Norov <yury.norov@gmail.com>
Sun, 23 Jan 2022 18:38:40 +0000 (10:38 -0800)
committerYury Norov <yury.norov@gmail.com>
Mon, 2 May 2022 13:30:39 +0000 (06:30 -0700)
In some places, octeontx2 code calls bitmap_weight() to check if any bit of
a given bitmap is set. It's better to use bitmap_empty() in that case
because bitmap_empty() stops traversing the bitmap as soon as it finds
first set bit, while bitmap_weight() counts all bits unconditionally.

Signed-off-by: Yury Norov <yury.norov@gmail.com>
drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c

index 54f235c216a96520907d070afd60d73b5ef93128..2dd192b5e4e081b02c3f99feecf424b53f571431 100644 (file)
@@ -355,7 +355,7 @@ int otx2_add_macfilter(struct net_device *netdev, const u8 *mac)
 {
        struct otx2_nic *pf = netdev_priv(netdev);
 
-       if (bitmap_weight(&pf->flow_cfg->dmacflt_bmap,
+       if (!bitmap_empty(&pf->flow_cfg->dmacflt_bmap,
                          pf->flow_cfg->dmacflt_max_flows))
                netdev_warn(netdev,
                            "Add %pM to CGX/RPM DMAC filters list as well\n",
@@ -438,7 +438,7 @@ int otx2_get_maxflows(struct otx2_flow_config *flow_cfg)
                return 0;
 
        if (flow_cfg->nr_flows == flow_cfg->max_flows ||
-           bitmap_weight(&flow_cfg->dmacflt_bmap,
+           !bitmap_empty(&flow_cfg->dmacflt_bmap,
                          flow_cfg->dmacflt_max_flows))
                return flow_cfg->max_flows + flow_cfg->dmacflt_max_flows;
        else
index 441aafc26a08ea5680aecfb0d2580225f2c02ac6..184e2279568575c500a2da59112b314b2a7f802f 100644 (file)
@@ -1120,7 +1120,7 @@ static int otx2_cgx_config_loopback(struct otx2_nic *pf, bool enable)
        struct msg_req *msg;
        int err;
 
-       if (enable && bitmap_weight(&pf->flow_cfg->dmacflt_bmap,
+       if (enable && !bitmap_empty(&pf->flow_cfg->dmacflt_bmap,
                                    pf->flow_cfg->dmacflt_max_flows))
                netdev_warn(pf->netdev,
                            "CGX/RPM internal loopback might not work as DMAC filters are active\n");