All of lore.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,10/13] octeontx2-af: npc: cn20k: Allocate MCAM entry for flow installation
Date: Wed, 28 Jan 2026 21:13:09 -0800	[thread overview]
Message-ID: <20260129051309.376665-1-kuba@kernel.org> (raw)
In-Reply-To: <20260128071235.3577206-11-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: Allocate MCAM entry for flow installation

This patch extends the install_flow mailbox request message with
additional fields that allow the AF driver to determine the required
NPC MCAM entry type, allocate the entry, and install the flow in a
single step for CN20K.

> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c
> index 82afb4993346..7a48ba1db5e9 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c

[ ... ]

> @@ -1642,6 +1643,75 @@ static int npc_install_flow(struct rvu *rvu, int blkaddr, u16 target,
>  	return 0;
>  }
>
> +static int
> +rvu_npc_free_entry_for_flow_install(struct rvu *rvu, u16 pcifunc,
> +				    bool free_entry, int mcam_idx)
> +{

[ ... ]

> +static int
> +rvu_npc_alloc_entry_for_flow_install(struct rvu *rvu,
> +				     struct npc_install_flow_req *fl_req,
> +				     u16 *mcam_idx, u8 *kw_type,
> +				     bool *allocated)
> +{

[ ... ]

> +	if (!is_cn20k(rvu->pdev))
> +		return 0;
> +
> +	if (!fl_req->alloc_entry)
> +		return 0;

[ ... ]

>  int rvu_mbox_handler_npc_install_flow(struct rvu *rvu,
>  				      struct npc_install_flow_req *req,
>  				      struct npc_install_flow_rsp *rsp)
>  {

[ ... ]

> +	bool allocated = false;
>  	bool enable = true;
> +	u8 kw_type;
>  	u16 target;

[ ... ]

> +	err = rvu_npc_alloc_entry_for_flow_install(rvu, req, &req->entry,
> +						   &kw_type, &allocated);
> +	if (err) {
> +		dev_err(rvu->dev,
> +			"%s: Error to alloc mcam entry for pcifunc=%#x\n",
> +			__func__, req->hdr.pcifunc);
> +		return err;
> +	}

[ ... ]

>  	mutex_lock(&rswitch->switch_lock);
>  	err = npc_install_flow(rvu, blkaddr, target, nixlf, pfvf,
>  			       req, rsp, enable, pf_set_vfs_mac);
> +	if (err)
> +		rvu_npc_free_entry_for_flow_install(rvu, req->hdr.pcifunc,
> +						    allocated, req->entry);
> +
> +	rsp->kw_type = kw_type;
> +	rsp->entry = req->entry;
            ^^^^^^^^

Is kw_type initialized in all paths here?

When rvu_npc_alloc_entry_for_flow_install() returns early because either
is_cn20k() is false or alloc_entry is not set, kw_type is never written.
The function returns 0 without setting *kw_type, leaving the local variable
uninitialized.

The uninitialized stack value then gets copied to rsp->kw_type.

Should this be initialized to 0 at declaration?

>  	mutex_unlock(&rswitch->switch_lock);
>
>  	return err;
>  }

  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   ` Jakub Kicinski [this message]
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=20260129051309.376665-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.