]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
octeontx2-af: npc: cn20k: Fix target map and rule
authorRatheesh Kannoth <rkannoth@marvell.com>
Wed, 29 Apr 2026 02:27:16 +0000 (07:57 +0530)
committerJakub Kicinski <kuba@kernel.org>
Fri, 1 May 2026 01:50:16 +0000 (18:50 -0700)
npc_defrag_move_vdx_to_free() disables, copies, and enables the MCAM entry
at a new index but previously left entry2target_pffunc[] and the mcam_rules
list still keyed to the old index. Copy the target PF association to the
new slot, clear the old one, and retarget the rule entry so software state
matches the relocated hardware context.

Fixes: 645c6e3c1999 ("octeontx2-af: npc: cn20k: virtual index support")
Signed-off-by: Ratheesh Kannoth <rkannoth@marvell.com>
Link: https://patch.msgid.link/20260429022722.1110289-5-rkannoth@marvell.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c

index 87da43088b675fbb4e2b96e87b9108c9bcfafdb6..70ce3f49adc1a82b298c03fee8ec085700b31f4b 100644 (file)
@@ -3602,9 +3602,10 @@ int npc_defrag_move_vdx_to_free(struct rvu *rvu,
                                struct npc_defrag_node *v,
                                int cnt, u16 *save)
 {
+       u16 new_midx, old_midx, vidx, target_pf;
        struct npc_mcam *mcam = &rvu->hw->mcam;
+       struct rvu_npc_mcam_rule *rule, *tmp;
        int i, vidx_cnt, rc, sb_off;
-       u16 new_midx, old_midx, vidx;
        struct npc_subbank *sb;
        bool deleted;
        u16 pcifunc;
@@ -3723,8 +3724,21 @@ int npc_defrag_move_vdx_to_free(struct rvu *rvu,
                mcam->entry2pfvf_map[new_midx] = pcifunc;
                /* Counter is not preserved */
                mcam->entry2cntr_map[new_midx] = new_midx;
+               target_pf = mcam->entry2target_pffunc[old_midx];
+               mcam->entry2target_pffunc[new_midx] = target_pf;
+               mcam->entry2target_pffunc[old_midx] = NPC_MCAM_INVALID_MAP;
+
                npc_mcam_set_bit(mcam, new_midx);
 
+               /* Note: list order is not functionally required for mcam_rules */
+               list_for_each_entry_safe(rule, tmp, &mcam->mcam_rules, list) {
+                       if (rule->entry != old_midx)
+                               continue;
+
+                       rule->entry = new_midx;
+                       break;
+               }
+
                /* Mark as invalid */
                v->vidx[vidx_cnt - i - 1] = -1;
                save[cnt - i - 1] = -1;