Subject: [PATCH net-next 05/11] eth: bnxt: remove rss_ctx_bmap

From: Jakub Kicinski <[email-masked]>
Date: Thu, 11 Jul 2024 15:07:07 -0700

Core will allocate IDs for the driver, from the range
[1, BNXT_MAX_ETH_RSS_CTX], no need to track the allocations.

Signed-off-by: Jakub Kicinski <[email-masked]>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c         | 13 ++-----------
 drivers/net/ethernet/broadcom/bnxt/bnxt.h         |  2 --
 drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c |  5 -----
 3 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index bd087c85af5c..026ceaa0b329 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -10239,7 +10239,6 @@ void bnxt_del_one_rss_ctx(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx,
 	kfree(rss_ctx->rss_indir_tbl);
 	list_del(&rss_ctx->list);
 	bp->num_rss_ctx--;
-	clear_bit(rss_ctx->index, bp->rss_ctx_bmap);
 	kfree(rss_ctx);
 }
 
@@ -10281,20 +10280,12 @@ void bnxt_clear_rss_ctxs(struct bnxt *bp, bool all)
 
 	list_for_each_entry_safe(rss_ctx, tmp, &bp->rss_ctx_list, list)
 		bnxt_del_one_rss_ctx(bp, rss_ctx, all);
-
-	if (all)
-		bitmap_free(bp->rss_ctx_bmap);
 }
 
 static void bnxt_init_multi_rss_ctx(struct bnxt *bp)
 {
-	bp->rss_ctx_bmap = bitmap_zalloc(BNXT_RSS_CTX_BMAP_LEN, GFP_KERNEL);
-	if (bp->rss_ctx_bmap) {
-		/* burn index 0 since we cannot have context 0 */
-		__set_bit(0, bp->rss_ctx_bmap);
-		INIT_LIST_HEAD(&bp->rss_ctx_list);
-		bp->rss_cap |= BNXT_RSS_CAP_MULTI_RSS_CTX;
-	}
+	INIT_LIST_HEAD(&bp->rss_ctx_list);
+	bp->rss_cap |= BNXT_RSS_CAP_MULTI_RSS_CTX;
 }
 
 /* Allow PF, trusted VFs and VFs with default VLAN to be in promiscuous mode */
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index 3c8826875ceb..9b0c6656ce27 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -1298,7 +1298,6 @@ struct bnxt_rss_ctx {
 };
 
 #define BNXT_MAX_ETH_RSS_CTX	32
-#define BNXT_RSS_CTX_BMAP_LEN	(BNXT_MAX_ETH_RSS_CTX + 1)
 #define BNXT_VNIC_ID_INVALID	0xffffffff
 
 struct bnxt_hw_rings {
@@ -2332,7 +2331,6 @@ struct bnxt {
 	struct bnxt_ring_grp_info	*grp_info;
 	struct bnxt_vnic_info	*vnic_info;
 	struct list_head	rss_ctx_list;
-	unsigned long		*rss_ctx_bmap;
 	u32			num_rss_ctx;
 	int			nr_vnics;
 	u16			*rss_indir_tbl;
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
index afbb7546ee14..04855846b5f6 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
@@ -1902,11 +1902,6 @@ static int bnxt_create_rxfh_context(struct net_device *dev,
 		return -EINVAL;
 	}
 
-	if (test_and_set_bit(rxfh->rss_context, bp->rss_ctx_bmap)) {
-		NL_SET_ERR_MSG_MOD(extack, "Context ID conflict");
-		return -EINVAL;
-	}
-
 	if (!bnxt_rfs_capable(bp, true)) {
 		NL_SET_ERR_MSG_MOD(extack, "Out hardware resources");
 		return -ENOMEM;
-- 
2.45.2