Re: [PATCH v3 net 04/11] octeontx2-af: npc: cn20k: Make default entries as x4.

Ratheesh Kannoth
2026-04-24T08:26:29Z

On 2026-04-23 at 16:13:10, Ratheesh Kannoth (rkannoth@marvell.com) wrote:
> X4 profile users won't alloc x2 entries. Allocating x2 entries
> would cause under utilized subbanks(X2). Avoid this in X4 kex
> profile, all allocations will be from x4 subbank.
>
> Fixes: 09d3b7a1403f ("octeontx2-af: npc: cn20k: Allocate default MCAM indexes")
> Signed-off-by: Ratheesh Kannoth <rkannoth@marvell.com>

>> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c b/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c
>> index 8630a6a73387..97acba77ff88 100644
>> --- a/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c
>> +++ b/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c
>
>[ ... ]
>
>> @@ -4274,10 +4289,16 @@ int npc_cn20k_dft_rules_alloc(struct rvu *rvu, u16 pcifunc)
>> pfvf = rvu_get_pfvf(rvu, pcifunc);
>> pfvf->hw_prio = NPC_DFT_RULE_PRIO;
>>
>> + if (npc_priv.kw == NPC_MCAM_KEY_X4) {
>> + req.kw_type = NPC_MCAM_KEY_X4;
>> + req.ref_entry = eidx & (npc_priv.bank_depth - 1);
>> + } else {
>> + req.kw_type = NPC_MCAM_KEY_X2;
>> + req.ref_entry = eidx;
>> + }
>> +
>> req.contig = false;
>> req.ref_prio = NPC_MCAM_HIGHER_PRIO;
>> - req.ref_entry = eidx;
>> - req.kw_type = NPC_MCAM_KEY_X2;
>> req.count = cnt;
>> req.hdr.pcifunc = pcifunc;
>>
>> @@ -4299,8 +4320,9 @@ int npc_cn20k_dft_rules_alloc(struct rvu *rvu, u16 pcifunc)
>>
>> req = otx2_mbox_alloc_msg_npc_mcam_alloc_entry(&pf->mbox);
>> req->contig = false;
>> - req->ref_entry = eidx + 1;
>> req->kw_type = NPC_MCAM_KEY_X2;
>> + req->ref_entry = eidx + 1;
>
>The VF fallback path still hardcodes req.kw_type = NPC_MCAM_KEY_X2. Does this
>violate the commit message's claim that "X4 profile users won't alloc x2
>entries"? When the first allocation attempt fails for a VF on an X4 system,
>wouldn't this retry path still allocate from X2 subbanks?
>
>Also, should the ref_entry here be masked with (npc_priv.bank_depth - 1)
>similar to the primary allocation path for X4 profiles?

AI review report: https://netdev-ai.bots.linux.dev/ai-review.html?id=9923f145-31df-46b0-84e8-b15f1e307ad2#patch-10
pw-bot: changes-requested

Simon suggested to remove this from net, and post it as enhancement when net-next opens. So Dropping it for now.
Will post it in net-next after fixing this comment.