From: Jakub Kicinski <kuba@kernel.org>
To: rkannoth@marvell.com
Cc: Jakub Kicinski <kuba@kernel.org>,
edumazet@google.com, sumang@marvell.com,
linux-kernel@vger.kernel.org, sbhatta@marvell.com,
davem@davemloft.net, netdev@vger.kernel.org, pabeni@redhat.com,
andrew+netdev@lunn.ch, sgoutham@marvell.com
Subject: Re: [net-next,v6,11/13] octeontx2-pf: cn20k: Add TC rules support
Date: Wed, 28 Jan 2026 21:13:11 -0800 [thread overview]
Message-ID: <20260129051311.376689-1-kuba@kernel.org> (raw)
In-Reply-To: <20260128071235.3577206-12-rkannoth@marvell.com>
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. The AF driver allocates entries on the fly when the user
installs a rule.
> 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, cn20k_tc_alloc_entry() allocates an MCAM entry from the AF
driver and stores it in new_node->entry. If otx2_mbox_alloc_msg_npc_install_flow()
or otx2_sync_mbox_msg() later fails, the code jumps 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 release the AF-allocated entry.
Can this leak 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),
which suggests MCAM entry cleanup is expected on error.
[ ... ]
> @@ -1328,0 +1328,24 @@ free_leaf:
> +free_leaf:
> + otx2_tc_del_from_flow_list(flow_cfg, new_node);
> + if (new_node->is_act_police) {
[ ... ]
> + kfree_rcu(new_node, rcu);
^^^^^^^^
The node is freed here without first calling cn20k_tc_free_mcam_entry()
to return the MCAM entry to the AF driver.
This was previously noted during review:
https://lore.kernel.org/netdev/20260118004028.1044419-1-kuba@kernel.org/
next prev parent reply other threads:[~2026-01-29 5:13 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-28 7:12 [PATCH net-next v6 00/13] NPC HW block support for cn20k Ratheesh Kannoth
2026-01-28 7:12 ` [PATCH net-next v6 01/13] octeontx2-af: npc: cn20k: Index management Ratheesh Kannoth
2026-01-28 11:27 ` ALOK TIWARI
2026-01-29 5:13 ` [net-next,v6,01/13] " Jakub Kicinski
2026-01-29 5:23 ` Ratheesh Kannoth
2026-01-29 23:50 ` Jakub Kicinski
2026-01-28 7:12 ` [PATCH net-next v6 02/13] octeontx2-af: npc: cn20k: KPM profile changes Ratheesh Kannoth
2026-01-29 5:13 ` [net-next,v6,02/13] " Jakub Kicinski
2026-01-28 7:12 ` [PATCH net-next v6 03/13] octeontx2-af: npc: cn20k: Add default profile Ratheesh Kannoth
2026-01-28 7:12 ` [PATCH net-next v6 04/13] octeontx2-af: npc: cn20k: MKEX profile support Ratheesh Kannoth
2026-01-28 7:12 ` [PATCH net-next v6 05/13] octeontx2-af: npc: cn20k: Allocate default MCAM indexes Ratheesh Kannoth
2026-01-28 7:12 ` [PATCH net-next v6 06/13] octeontx2-af: npc: cn20k: Use common APIs Ratheesh Kannoth
2026-01-28 7:12 ` [PATCH net-next v6 07/13] octeontx2-af: npc: cn20k: Prepare for new SoC Ratheesh Kannoth
2026-01-28 7:12 ` [PATCH net-next v6 08/13] octeontx2-af: npc: cn20k: Add new mailboxes for CN20K silicon Ratheesh Kannoth
2026-01-29 5:13 ` [net-next,v6,08/13] " Jakub Kicinski
2026-01-28 7:12 ` [PATCH net-next v6 09/13] octeontx2-af: npc: cn20k: virtual index support Ratheesh Kannoth
2026-01-29 5:13 ` [net-next,v6,09/13] " Jakub Kicinski
2026-01-28 7:12 ` [PATCH net-next v6 10/13] octeontx2-af: npc: cn20k: Allocate MCAM entry for flow installation Ratheesh Kannoth
2026-01-29 5:13 ` [net-next,v6,10/13] " Jakub Kicinski
2026-01-28 7:12 ` [PATCH net-next v6 11/13] octeontx2-pf: cn20k: Add TC rules support Ratheesh Kannoth
2026-01-29 5:13 ` Jakub Kicinski [this message]
2026-01-28 7:12 ` [PATCH net-next v6 12/13] octeontx2-af: npc: cn20k: add debugfs support Ratheesh Kannoth
2026-01-28 7:12 ` [PATCH net-next v6 13/13] octeontx2-af: npc: Use common structures Ratheesh Kannoth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260129051311.376689-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rkannoth@marvell.com \
--cc=sbhatta@marvell.com \
--cc=sgoutham@marvell.com \
--cc=sumang@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox