Re: [net-next,v4,11/13] octeontx2-pf: cn20k: Add TC rules support

Ratheesh Kannoth
2026-01-19T03:39:25Z

On 2026-01-18 at 06:10:28, Jakub Kicinski (kuba@kernel.org) wrote:
> This is an AI-generated review of your patch. The human sending this
> email has considered the AI review valid, or at least plausible.
>
> For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
> ---
> octeontx2-pf: cn20k: Add TC rules support
>
> This patch adds dynamic MCAM entry allocation for TC rules on CN20K
> silicon, with support for X2/X4 key widths and entry shifting based on
> rule priorities.
>
> > diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c
> > index 26a08d2cfbb1..866d9451f5d6 100644
> > --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c
> > +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c
>
> [ ... ]
>
> > @@ -1292,7 +1277,23 @@ static int otx2_tc_add_flow(struct otx2_nic *nic,
> > if (old_node)
> > otx2_tc_del_flow(nic, tc_flow_cmd);
> >
> > + if (is_cn20k(nic->pdev)) {
> > + rc = cn20k_tc_alloc_entry(nic, tc_flow_cmd, new_node, &dummy);
> > + if (rc) {
> > + NL_SET_ERR_MSG_MOD(extack,
> > + "MCAM rule allocation failed");
> > + kfree_rcu(new_node, rcu);
> > + return rc;
> > + }
> > + }
> > +
> > + entry = otx2_tc_update_mcam_table(nic, flow_cfg, new_node, true);
> > + if (entry < 0) {
> > + NL_SET_ERR_MSG_MOD(extack, "Adding rule failed");
> > + rc = entry;
> > + goto free_leaf;
> > + }
> > +
> > mutex_lock(&nic->mbox.lock);
> > req = otx2_mbox_alloc_msg_npc_install_flow(&nic->mbox);
> > if (!req) {
> > mutex_unlock(&nic->mbox.lock);
> > rc = -ENOMEM;
> > goto free_leaf;
> ^^^^^^^^^^^^^^
>
> For CN20K, if cn20k_tc_alloc_entry() succeeds (allocating an MCAM entry
> from AF) but then otx2_mbox_alloc_msg_npc_install_flow() or
> otx2_sync_mbox_msg() fails, the code goes to free_leaf. Looking at the
> free_leaf cleanup path below, it calls otx2_tc_del_from_flow_list() and
> kfree_rcu() but does not call cn20k_tc_free_mcam_entry() to return the
> AF-allocated entry.
>
> Is this leaking the MCAM entry on CN20K when these error paths are taken?
>
> The cn20k_tc_update_mcam_table_add_req() function does call
> cn20k_tc_free_mcam_entry() when it fails internally (due to X2/X4 mix),
> suggesting MCAM entry cleanup is expected.
ACK.
>
> > @@ -1304,7 +1305,7 @@ static int otx2_tc_add_flow(struct otx2_nic *nic,
> > memcpy(&dummy.hdr, &req->hdr, sizeof(struct mbox_msghdr));
> > memcpy(req, &dummy, sizeof(struct npc_install_flow_req));
>
> [ ... ]