Skip to contentSkip to conversation

octeontx2-af: Add new devlink param to configure maximum usable NIX block LFs

PATCH Applied Suman Ghosh 3 participants 5 messages Dec 15, 2023 – Dec 18, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 octeontx2-af: Add new devlink param to configure maximum usable NIX block LFs

On some silicon variants the number of available CAM entries are less. Reserving one entry for each NIX-LF for default DMAC based pkt forwarding rules will reduce the number of available CAM entries further. Hence add configurability via devlink to set maximum number of NIX-LFs needed which inturn frees up some CAM entries.

---
 .../net/ethernet/marvell/octeontx2/af/rvu.h   |  2 +
 .../marvell/octeontx2/af/rvu_devlink.c        | 80 +++++++++++++++++++
 .../ethernet/marvell/octeontx2/af/rvu_npc.c   | 75 +++++++++++------
 3 files changed, 133 insertions(+), 24 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +2 -0
index 1f3ff4bb8753..6446dc389989 100644
@@ -949,6 +949,8 @@ int npc_install_mcam_drop_rule(struct rvu *rvu, int mcam_idx, u16 *counter_idx,
 			       u64 bcast_mcast_val, u64 bcast_mcast_mask);
 void npc_mcam_rsrcs_reserve(struct rvu *rvu, int blkaddr, int entry_idx);
 bool npc_is_feature_supported(struct rvu *rvu, u64 features, u8 intf);
+int npc_mcam_rsrcs_init(struct rvu *rvu, int blkaddr);
+void npc_mcam_rsrcs_deinit(struct rvu *rvu);
 
 /* CPT APIs */
 int rvu_cpt_register_interrupts(struct rvu *rvu);
drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c +80 -0

98 lines not on this page · raw message

drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +51 -24

127 lines not on this page · raw message

Signature · 1 line
2.25.1
#1 lore raw
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:

Quoted 9 lines · On Fri, 15 Dec 2023 17:31:49 +0530 you wrote:

On some silicon variants the number of available CAM entries are less. Reserving one entry for each NIX-LF for default DMAC based pkt forwarding rules will reduce the number of available CAM entries further. Hence add configurability via devlink to set maximum number of NIX-LFs needed which inturn frees up some CAM entries.

[...]

Here is the summary with links:
- [net-next] octeontx2-af: Add new devlink param to configure maximum usable NIX block LFs

    https://git.kernel.org/netdev/net-next/c/dd7842878633

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
reviewer
#2 lore raw
In reply to Suman Ghosh
Quoted 7 lines · Suman Ghosh

On some silicon variants the number of available CAM entries are less. Reserving one entry for each NIX-LF for default DMAC based pkt forwarding rules will reduce the number of available CAM entries further. Hence add configurability via devlink to set maximum number of NIX-LFs needed which inturn frees up some CAM entries.

...

Quoted 13 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +8 -1
@@ -1964,8 +1977,21 @@ static int npc_mcam_rsrcs_init(struct rvu *rvu, int blkaddr)
 
 	return 0;
 
-free_mem:
+free_cntr_refcnt:
+	kfree(mcam->cntr_refcnt);
+free_entry_cntr_map:
+	kfree(mcam->entry2cntr_map);
+free_cntr_map:
+	kfree(mcam->cntr2pfvf_map);
+free_cntr_bmap:
+	kfree(mcam->counters.bmap);

drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c static int npc_mcam_rsrcs_init(struct rvu *rvu, int blkaddr) · line 1997

Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +6 -0
+free_entry_map:
+	kfree(mcam->entry2pfvf_map);
+free_bmap_reverse:
+	kfree(mcam->bmap_reverse);
+free_bmap:
 	kfree(mcam->counters.bmap);
+
 	return -ENOMEM;
 }
 

Hi Suman,

I realise that this patch has been accepted. But I believe there is a double-free problem above as mcam->counters.bmap may be freed twice. And mcam->bmap seems to be leaked.

Perhaps the last part of the unwind ladder should be:

free_bmap:

	kfree(mcam->bmap);

Double-free flagged by Smatch and Coccinelle.

#3 lore raw
Quoted 5 lines

Hi Suman,

I realise that this patch has been accepted.
But I believe there is a double-free problem above as mcam-

Quoted 1 line

counters.bmap may be freed twice.

Quoted 8 lines

And mcam->bmap seems to be leaked.

Perhaps the last part of the unwind ladder should be:

free_bmap:

	kfree(mcam->bmap);

Double-free flagged by Smatch and Coccinelle.

[Suman] Thanks Simon for finding it. I have pushed a follow-up patch as a fix.

reviewer
#4 lore raw
Quoted 7 lines · Suman Ghosh
Quoted 7 lines

Hi Suman,

I realise that this patch has been accepted.
But I believe there is a double-free problem above as mcam-

Quoted 1 line

counters.bmap may be freed twice.

And mcam->bmap seems to be leaked.

Quoted 7 lines
Quoted 6 lines

Perhaps the last part of the unwind ladder should be:

free_bmap:

	kfree(mcam->bmap);

Double-free flagged by Smatch and Coccinelle.

[Suman] Thanks Simon for finding it. I have pushed a follow-up patch as a fix.

Likewise, thanks. The fix patch looks good.