From: Paolo Abeni <pabeni@redhat.com>
To: Ratheesh Kannoth <rkannoth@marvell.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-rdma@vger.kernel.org
Cc: sgoutham@marvell.com, andrew+netdev@lunn.ch, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, donald.hunter@gmail.com,
horms@kernel.org, jiri@resnulli.us, chuck.lever@oracle.com,
matttbe@kernel.org, cjubran@nvidia.com, saeedm@nvidia.com,
leon@kernel.org, tariqt@nvidia.com, mbloch@nvidia.com,
dtatulea@nvidia.com
Subject: Re: [PATCH v11 net-next 5/7] octeontx2-af: npc: cn20k: add subbank search order control
Date: Mon, 13 Apr 2026 14:56:00 +0200 [thread overview]
Message-ID: <b9ffa72d-ebe2-4fd1-b668-93620f206179@redhat.com> (raw)
In-Reply-To: <20260409025055.1664053-6-rkannoth@marvell.com>
On 4/9/26 4:50 AM, Ratheesh Kannoth wrote:
> CN20K NPC MCAM is split into 32 subbanks that are searched in a
> predefined order during allocation. Lower-numbered subbanks have
> higher priority than higher-numbered ones.
>
> Add a runtime devlink parameter "srch_order" (
> DEVLINK_PARAM_TYPE_U32_ARRAY) to control the order in which
> subbanks are searched during MCAM allocation.
>
> Signed-off-by: Ratheesh Kannoth <rkannoth@marvell.com>
> ---
> .../ethernet/marvell/octeontx2/af/cn20k/npc.c | 91 +++++++++++++++++-
> .../ethernet/marvell/octeontx2/af/cn20k/npc.h | 2 +
> .../marvell/octeontx2/af/rvu_devlink.c | 92 +++++++++++++++++--
> 3 files changed, 173 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c b/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c
> index e854b85ced9e..153765b3e504 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c
> @@ -3317,7 +3317,7 @@ rvu_mbox_handler_npc_cn20k_get_kex_cfg(struct rvu *rvu,
> return 0;
> }
>
> -static int *subbank_srch_order;
> +static u32 *subbank_srch_order;
>
> static void npc_populate_restricted_idxs(int num_subbanks)
> {
> @@ -3329,7 +3329,7 @@ static int npc_create_srch_order(int cnt)
> {
> int val = 0;
>
> - subbank_srch_order = kcalloc(cnt, sizeof(int),
> + subbank_srch_order = kcalloc(cnt, sizeof(u32),
> GFP_KERNEL);
> if (!subbank_srch_order)
> return -ENOMEM;
> @@ -3809,6 +3809,93 @@ static void npc_unlock_all_subbank(void)
> mutex_unlock(&npc_priv.sb[i].lock);
> }
>
> +int npc_cn20k_search_order_set(struct rvu *rvu,
> + u64 arr[MAX_NUM_SUB_BANKS], int cnt)
> +{
> + struct npc_mcam *mcam = &rvu->hw->mcam;
> + u32 fslots[MAX_NUM_SUB_BANKS][2];
> + u32 uslots[MAX_NUM_SUB_BANKS][2];
> + int fcnt = 0, ucnt = 0;
> + struct npc_subbank *sb;
> + int idx, val, rc = 0;
> +
> + unsigned long index;
> + void *v;
> +
> + if (cnt != npc_priv.num_subbanks) {
> + dev_err(rvu->dev, "Number of entries(%u) != %u\n",
> + cnt, npc_priv.num_subbanks);
> + return -EINVAL;
> + }
> +
> + mutex_lock(&mcam->lock);
> + npc_lock_all_subbank();
> + restrict_valid = false;
> +
> + for (int i = 0; i < cnt; i++)
> + subbank_srch_order[i] = (u32)arr[i];
> +
> + xa_for_each(&npc_priv.xa_sb_used, index, v) {
> + val = xa_to_value(v);
> + uslots[ucnt][0] = index;
> + uslots[ucnt][1] = val;
> + xa_erase(&npc_priv.xa_sb_used, index);
> + ucnt++;
> + }
> +
> + xa_for_each(&npc_priv.xa_sb_free, index, v) {
> + val = xa_to_value(v);
> + fslots[fcnt][0] = index;
> + fslots[fcnt][1] = val;
> + xa_erase(&npc_priv.xa_sb_free, index);
> + fcnt++;
> + }
> +
> + /* xa_store() is done under lock. If xa_store fails
> + * ,no rollback is planned as it might also fail.
Why do you need to go throuh erase and add loop? Why can't you directly
xa_store() the new value? Note that xa_store() can fail due to memory
pressure.
Avoiding the previous erase will prevent deallocation and re allocation
and will avoid any reasonable xa_store() failure.
AFAICS there are a few more items reported by sashiko, please have a look:
https://sashiko.dev/#/patchset/20260409025055.1664053-1-rkannoth%40marvell.com
/P
next prev parent reply other threads:[~2026-04-13 12:56 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 2:50 [PATCH v11 net-next 0/7] octeontx2-af: npc: Enhancements Ratheesh Kannoth
2026-04-09 2:50 ` [PATCH v11 net-next 1/7] octeontx2-af: npc: cn20k: debugfs enhancements Ratheesh Kannoth
2026-04-09 2:50 ` [PATCH v11 net-next 2/7] net/mlx5e: heap-allocate devlink param values Ratheesh Kannoth
2026-04-09 2:50 ` [PATCH v11 net-next 3/7] devlink: Change function syntax Ratheesh Kannoth
2026-04-09 2:50 ` [PATCH v11 net-next 4/7] devlink: Implement devlink param multi attribute nested data values Ratheesh Kannoth
2026-04-13 10:54 ` Paolo Abeni
2026-04-13 11:00 ` Ratheesh Kannoth
2026-04-13 13:18 ` Paolo Abeni
2026-04-13 12:08 ` Jiri Pirko
2026-04-09 2:50 ` [PATCH v11 net-next 5/7] octeontx2-af: npc: cn20k: add subbank search order control Ratheesh Kannoth
2026-04-13 12:56 ` Paolo Abeni [this message]
2026-04-14 3:46 ` Ratheesh Kannoth
2026-04-09 2:50 ` [PATCH v11 net-next 6/7] octeontx2-af: npc: cn20k: dynamically allocate and free default MCAM entries Ratheesh Kannoth
2026-04-09 2:50 ` [PATCH v11 net-next 7/7] octeontx2-af: npc: Support for custom KPU profile from filesystem 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=b9ffa72d-ebe2-4fd1-b668-93620f206179@redhat.com \
--to=pabeni@redhat.com \
--cc=andrew+netdev@lunn.ch \
--cc=chuck.lever@oracle.com \
--cc=cjubran@nvidia.com \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=dtatulea@nvidia.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=matttbe@kernel.org \
--cc=mbloch@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=rkannoth@marvell.com \
--cc=saeedm@nvidia.com \
--cc=sgoutham@marvell.com \
--cc=tariqt@nvidia.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