Re: [PATCH v8 net-next 5/6] octeontx2-af: npc: cn20k: dynamically allocate and free default MCAM entries

From: Simon Horman

Date: Fri Mar 27 2026 - 09:38:21 EST


On Wed, Mar 25, 2026 at 12:51:58PM +0530, Ratheesh Kannoth wrote:
> Improve MCAM utilization by tying default (broadcast, multicast,
> promisc, ucast) entry lifetime to NIX LF usage.
>
> - On NIX LF alloc (e.g. kernel or DPDK), allocate default MCAM entries
> if missing; on NIX LF free, release them so they return to the pool.
> - Add NIX_LF_DONT_FREE_DFT_IDXS so the kernel PF driver can free the
> NIX LF without releasing default entries (e.g. across suspend/resume).
> - When NIX LF is used by DPDK, default entries are allocated on first
> use and freed when the LF is released if NIX_LF_DONT_FREE_DFT_IDXS is
> not set
>
> Signed-off-by: Ratheesh Kannoth <rkannoth@xxxxxxxxxxx>

...

> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
> index ef5b081162eb..bd671b553df5 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
> @@ -16,6 +16,7 @@
> #include "cgx.h"
> #include "lmac_common.h"
> #include "rvu_npc_hash.h"
> +#include "cn20k/npc.h"
>
> static void nix_free_tx_vtag_entries(struct rvu *rvu, u16 pcifunc);
> static int rvu_nix_get_bpid(struct rvu *rvu, struct nix_bp_cfg_req *req,
> @@ -1684,10 +1685,16 @@ int rvu_mbox_handler_nix_lf_alloc(struct rvu *rvu,
> if (is_sdp_pfvf(rvu, pcifunc))
> intf = NIX_INTF_TYPE_SDP;
>
> + if (is_cn20k(rvu->pdev)) {
> + rc = npc_cn20k_dft_rules_alloc(rvu, pcifunc);
> + if (rc)
> + goto free_mem;
> + }
> +
> err = nix_interface_init(rvu, pcifunc, intf, nixlf, rsp,
> !!(req->flags & NIX_LF_LBK_BLK_SEL));
> if (err)
> - goto free_mem;
> + goto free_dft;
>
> /* Disable NPC entries as NIXLF's contexts are not initialized yet */
> rvu_npc_disable_default_entries(rvu, pcifunc, nixlf);

> @@ -1699,6 +1706,10 @@ int rvu_mbox_handler_nix_lf_alloc(struct rvu *rvu,
>
> goto exit;
>
> +free_dft:
> + if (is_cn20k(rvu->pdev))
> + npc_cn20k_dft_rules_free(rvu, pcifunc);
> +
> free_mem:
> nix_ctx_free(rvu, pfvf);
> rc = -ENOMEM;

It seems like a nit to me. But AI review flags that the rc value will be
overwritten when jumping to the free_mem label. And thus the error
returned by npc_cn20k_dft_rules_alloc won't be returned to the caller.

...

> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c

...

> @@ -1926,7 +1925,6 @@ int otx2_alloc_queue_mem(struct otx2_nic *pf)
> struct otx2_qset *qset = &pf->qset;
> struct otx2_cq_poll *cq_poll;
>
> -
> /* RQ and SQs are mapped to different CQs,
> * so find out max CQ IRQs (i.e CINTs) needed.
> */

nit: this hunk seems unrelated to the rest of the patch.