public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
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,09/13] octeontx2-af: npc: cn20k: virtual index support
Date: Wed, 28 Jan 2026 21:13:07 -0800	[thread overview]
Message-ID: <20260129051307.376632-1-kuba@kernel.org> (raw)
In-Reply-To: <20260128071235.3577206-10-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-af: npc: cn20k: virtual index support

This patch adds virtual MCAM index allocation support for CN20K,
enabling defragmentation by allowing entries to be moved while
maintaining stable virtual indexes for callers.

> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c b/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c
> index 62b4d657c369..642336b0d476 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);
> +		goto fail1;
> +	}
> +
> +	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);
> +		rc = -ESRCH;
> +		goto fail2;
> +	}
> +
> +	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);
> +		goto fail3;
> +	}
> +
> +	return 0;
> +
> +fail3:
> +	if (xa_insert(&npc_priv.xa_idx2vidx_map, old_midx,
> +		      xa_mk_value(vidx), GFP_KERNEL))
> +		dev_err(rvu->dev,
> +			"%s: Error to roll back idx2vidx old_midx=%u vidx=%u\n",
> +			__func__, old_midx, vidx);
> +fail2:
> +	if (xa_erase(&npc_priv.xa_vidx2idx_map, vidx))
> +		dev_err(rvu->dev,
> +			"%s: Failed to roll back vidx2idx vidx=%u\n",
> +			__func__, vidx);
> +
> +fail1:
> +	if (xa_insert(&npc_priv.xa_idx2vidx_map, old_midx,
> +		      xa_mk_value(vidx), GFP_KERNEL))

The rollback at fail1 appears to operate on the wrong XArray. When
xa_insert() fails above and we jump to fail1, the xa_idx2vidx_map still
contains old_midx since the erase of xa_idx2vidx_map has not executed yet.
This xa_insert() will return -EBUSY because the key already exists.

Should this instead restore vidx to xa_vidx2idx_map with the original
old_midx value, since that was the map modified before the failure?

> +		dev_err(rvu->dev,
> +			"%s: Faled to roll back idx2vidx to old_midx=%u, vidx=%u\n",
> +			__func__, old_midx, vidx);
> +
> +	return rc;
> +}

[ ... ]

  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   ` Jakub Kicinski [this message]
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   ` [net-next,v6,11/13] " Jakub Kicinski
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=20260129051307.376632-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