Re: [PATCH v20 net-next 8/9] octeontx2: cn20k: Respect NPC MCAM X2/X4 profile in flows and DFT alloc
From: Ratheesh Kannoth
Date: Wed Jun 10 2026 - 01:34:07 EST
On 2026-06-09 at 09:34:52, Ratheesh Kannoth (rkannoth@xxxxxxxxxxx) wrote:
> Default CN20K NPC rule allocation now keys off the active MCAM keyword
> width: use X4 with a bank-masked reference index when the silicon uses
> X4 keys, and X2 with the raw index otherwise (replacing the previous
> always-X2 / eidx + 1 behaviour).
>
> In the AF flow-install path, flows that need more than 256 key bits
> query the NPC profile; if the platform is fixed to X2 entries, fail
> with -EOPNOTSUPP instead of requesting X4. Otherwise select X4 for the
> MCAM alloc.
>
> On the PF, cache and pass the profile kw_type from npc_get_pfl_info
> through otx2_mcam_pfl_info_get(), and use it when allocating MCAM
> entries for RSS/defaults and when installing ethtool flows on CN20K,
> including masking the reference index for X4 slot layout.
>
> Signed-off-by: Ratheesh Kannoth <rkannoth@xxxxxxxxxxx>
> ---
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260609040453.711932-1-rkannoth%40marvell.com says:
>> 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;
>> + }
>> +
>How is the X1/DYN profile expected to be handled here? In
>include/.../mbox.h the enum sets:
DYN profile can request X2/X4 entry.
>
>> *kw_type = NPC_MCAM_KEY_X2;
>> - if (kw_bits > 256)
>> + if (kw_bits > 256) {
>> + rvu_mbox_handler_npc_get_pfl_info(rvu, &req, &rsp);
>> + if (rsp.kw_type == NPC_MCAM_KEY_X2) {
>> + dev_err(rvu->dev,
>> + "Only X2 entries are supported in X2 profile\n");
>> + return -EOPNOTSUPP;
>> + }
>> +
>> *kw_type = NPC_MCAM_KEY_X4;
>> + }
>On a DYN-configured platform rsp.kw_type is NPC_MCAM_KEY_DYN (== 0), so
>the equality check rsp.kw_type == NPC_MCAM_KEY_X2 is false and the
>function proceeds to set *kw_type = NPC_MCAM_KEY_X4.
>The commit log says:
> if the platform is fixed to X2 entries, fail with -EOPNOTSUPP
> instead of requesting X4
>Is the intent for this rejection to also fire on DYN, or to only fire
>on X2? As written, the dft-rule path in npc_cn20k_dft_rules_alloc()
>buckets DYN with X2, while this flow-install path treats DYN as X4-
>capable, so the same npc_priv.kw == DYN value drives different kw_type
>choices in the two callers.
>Could the patch handle DYN explicitly (or document why it cannot occur
>on the paths reached here) so the two sites agree?
This is intentional. if profile is X2, we can't alloc an X4 entry.