Netdev List
 help / color / mirror / Atom feed
From: Ratheesh Kannoth <rkannoth@marvell.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: <sbhatta@marvell.com>, <edumazet@google.com>,
	<andrew+netdev@lunn.ch>, <netdev@vger.kernel.org>,
	<sgoutham@marvell.com>, <sumang@marvell.com>, <pabeni@redhat.com>,
	<davem@davemloft.net>, <linux-kernel@vger.kernel.org>
Subject: Re: [net-next,v5,09/13] octeontx2-af: npc: cn20k: virtual index support
Date: Wed, 28 Jan 2026 09:05:49 +0530	[thread overview]
Message-ID: <aXmEFX1HUKa448Ih@rkannoth-OptiPlex-7090> (raw)
In-Reply-To: <20260128022928.4153136-1-kuba@kernel.org>

On 2026-01-28 at 07:59: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-af: npc: cn20k: virtual index support
>
> This patch adds support for virtual MCAM index allocation and improves
> CN20K MCAM defragmentation handling.  Virtual indexes allow the hardware
> to move mapped MCAM entries internally, enabling defragmentation.
>
> > diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c b/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c
> > index 8b77ac053d8d..d1a927f3d5db 100644
> > --- a/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c
> > +++ b/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c
>
> [ ... ]
>
> > +static int npc_vidx_maps_modify(struct rvu *rvu, u16 vidx, u16 new_midx)
> > +{
> > +	u16 old_midx;
> > +	void *map;
> > +	int rc;
> > +
> > +	if (!npc_is_vidx(vidx)) {
> > +		dev_err(rvu->dev,
> > +			"%s: vidx(%u) does not map to proper mcam idx\n",
> > +			__func__, vidx);
> > +		return -ESRCH;
> > +	}
> > +
> > +	map = xa_erase(&npc_priv.xa_vidx2idx_map, vidx);
> > +	if (!map) {
> > +		dev_err(rvu->dev,
> > +			"%s: vidx(%u) could not be deleted from vidx2idx map\n",
> > +			__func__, vidx);
> > +		return -ESRCH;
> > +	}
> > +
> > +	old_midx = xa_to_value(map);
> > +
> > +	rc = xa_insert(&npc_priv.xa_vidx2idx_map, vidx,
> > +		       xa_mk_value(new_midx), GFP_KERNEL);
> > +	if (rc) {
> > +		dev_err(rvu->dev,
> > +			"%s: vidx(%u) cannot be added to vidx2idx map\n",
> > +			__func__, vidx);
> > +		return rc;
> > +	}
> > +
> > +	map = xa_erase(&npc_priv.xa_idx2vidx_map, old_midx);
> > +	if (!map) {
> > +		dev_err(rvu->dev,
> > +			"%s: old_midx(%u, vidx(%u)) cannot be added to idx2vidx map\n",
> > +			__func__, old_midx, vidx);
> > +		return -ESRCH;
>
> If this error path is taken, xa_vidx2idx_map now has vidx pointing to
> new_midx, but xa_idx2vidx_map still has old_midx pointing back to vidx.
> The bidirectional mapping becomes inconsistent.  Can this leave the maps
> in a corrupted state?
ACK.

>
> > +	}
> > +
> > +	rc = xa_insert(&npc_priv.xa_idx2vidx_map, new_midx,
> > +		       xa_mk_value(vidx), GFP_KERNEL);
> > +	if (rc) {
> > +		dev_err(rvu->dev,
> > +			"%s: new_midx(%u, vidx(%u)) cannot be added to idx2vidx map\n",
> > +			__func__, new_midx, vidx);
> > +		return rc;
>
> Similarly here, if xa_insert fails (e.g., memory pressure), the maps are
> left inconsistent: xa_vidx2idx_map has vidx -> new_midx but xa_idx2vidx_map
> has neither old_midx nor new_midx pointing to vidx.  Subsequent lookups
> via npc_idx2vidx() for new_midx would fail to find the correct vidx.
> Should these error paths restore the previous map state?
ACK.

>
> > +	}
> > +
> > +	return 0;
> > +}
>
> [ ... ]
>
> > +static int npc_defrag_process(struct rvu *rvu, struct list_head *lh)
> > +{
>
> [ ... ]
>
> > +err:
> > +	/* TODO: how to go back to old state ? */
> > +	return rc;
> > +}
>
> The TODO comment here suggests awareness that error recovery is incomplete.
> Given that npc_defrag_move_vdx_to_free() calls npc_vidx_maps_modify() which
> can fail mid-operation, should the defragmentation be made atomic or have
> proper rollback?
Whole defragmentation process is done under lock. We cannot roll back as roll back
can also fail.

The defragmentation process failure indicate a bug in index management code.

I removed the "TODO" comment and added an explantion.

  reply	other threads:[~2026-01-28  3:36 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-26 12:32 [PATCH net-next v5 00/13] NPC HW block support for cn20k Ratheesh Kannoth
2026-01-26 12:32 ` [PATCH net-next v5 01/13] octeontx2-af: npc: cn20k: Index management Ratheesh Kannoth
2026-01-26 12:32 ` [PATCH net-next v5 02/13] octeontx2-af: npc: cn20k: KPM profile changes Ratheesh Kannoth
2026-01-26 12:32 ` [PATCH net-next v5 03/13] octeontx2-af: npc: cn20k: Add default profile Ratheesh Kannoth
2026-01-26 12:32 ` [PATCH net-next v5 04/13] octeontx2-af: npc: cn20k: MKEX profile support Ratheesh Kannoth
2026-01-26 12:32 ` [PATCH net-next v5 05/13] octeontx2-af: npc: cn20k: Allocate default MCAM indexes Ratheesh Kannoth
2026-01-28  2:29   ` [net-next,v5,05/13] " Jakub Kicinski
2026-01-28  3:29     ` Ratheesh Kannoth
2026-01-29  2:11       ` Jakub Kicinski
2026-01-26 12:32 ` [PATCH net-next v5 06/13] octeontx2-af: npc: cn20k: Use common APIs Ratheesh Kannoth
2026-01-28  2:29   ` [net-next,v5,06/13] " Jakub Kicinski
2026-01-28  3:31     ` Ratheesh Kannoth
2026-01-26 12:32 ` [PATCH net-next v5 07/13] octeontx2-af: npc: cn20k: Prepare for new SoC Ratheesh Kannoth
2026-01-26 12:32 ` [PATCH net-next v5 08/13] octeontx2-af: npc: cn20k: Add new mailboxes for CN20K silicon Ratheesh Kannoth
2026-01-28  2:29   ` [net-next,v5,08/13] " Jakub Kicinski
2026-01-28  3:31     ` Ratheesh Kannoth
2026-01-26 12:32 ` [PATCH net-next v5 09/13] octeontx2-af: npc: cn20k: virtual index support Ratheesh Kannoth
2026-01-28  2:29   ` [net-next,v5,09/13] " Jakub Kicinski
2026-01-28  3:35     ` Ratheesh Kannoth [this message]
2026-01-26 12:32 ` [PATCH net-next v5 10/13] octeontx2-af: npc: cn20k: Allocate MCAM entry for flow installation Ratheesh Kannoth
2026-01-28  2:29   ` [net-next,v5,10/13] " Jakub Kicinski
2026-01-28  3:36     ` Ratheesh Kannoth
2026-01-26 12:32 ` [PATCH net-next v5 11/13] octeontx2-pf: cn20k: Add TC rules support Ratheesh Kannoth
2026-01-26 12:32 ` [PATCH net-next v5 12/13] octeontx2-af: npc: cn20k: add debugfs support Ratheesh Kannoth
2026-01-26 12:32 ` [PATCH net-next v5 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=aXmEFX1HUKa448Ih@rkannoth-OptiPlex-7090 \
    --to=rkannoth@marvell.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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