Skip to content

Commit 4ff6540

Browse files
Hariprasad KelamNipaLocal
Hariprasad Kelam
authored and
NipaLocal
committed
octeontx2-af: NPC: Clear Unicast rule on nixlf detach
The AF driver assigns reserved MCAM entries (for unicast, broadcast, etc.) based on the NIXLF number. When a NIXLF is detached, these entries are disabled. For example, PF NIXLF -------------------- PF0 0 SDP-VF0 1 If the user unbinds both PF0 and SDP-VF0 interfaces and then binds them in reverse order PF NIXLF --------------------- SDP-VF0 0 PF0 1 In this scenario, the PF0 unicast entry is getting corrupted because the MCAM entry contains stale data (SDP-VF0 ucast data) This patch resolves the issue by clearing the unicast MCAM entry during NIXLF detach Signed-off-by: Hariprasad Kelam <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 3122aea commit 4ff6540

File tree

3 files changed

+43
-5
lines changed

3 files changed

+43
-5
lines changed

drivers/net/ethernet/marvell/octeontx2/af/rvu.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,8 +1393,6 @@ static void rvu_detach_block(struct rvu *rvu, int pcifunc, int blktype)
13931393
if (blkaddr < 0)
13941394
return;
13951395

1396-
if (blktype == BLKTYPE_NIX)
1397-
rvu_nix_reset_mac(pfvf, pcifunc);
13981396

13991397
block = &hw->block[blkaddr];
14001398

@@ -1407,6 +1405,10 @@ static void rvu_detach_block(struct rvu *rvu, int pcifunc, int blktype)
14071405
if (lf < 0) /* This should never happen */
14081406
continue;
14091407

1408+
if (blktype == BLKTYPE_NIX) {
1409+
rvu_nix_reset_mac(pfvf, pcifunc);
1410+
rvu_npc_clear_ucast_entry(rvu, pcifunc, lf);
1411+
}
14101412
/* Disable the LF */
14111413
rvu_write64(rvu, blkaddr, block->lfcfg_reg |
14121414
(lf << block->lfshift), 0x00ULL);

drivers/net/ethernet/marvell/octeontx2/af/rvu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,8 @@ void rvu_npc_get_mcam_entry_alloc_info(struct rvu *rvu, u16 pcifunc,
994994
void rvu_npc_get_mcam_counter_alloc_info(struct rvu *rvu, u16 pcifunc,
995995
int blkaddr, int *alloc_cnt,
996996
int *enable_cnt);
997+
void rvu_npc_clear_ucast_entry(struct rvu *rvu, int pcifunc, int nixlf);
998+
997999
bool is_npc_intf_tx(u8 intf);
9981000
bool is_npc_intf_rx(u8 intf);
9991001
bool is_npc_interface_valid(struct rvu *rvu, u8 intf);

drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,7 @@ void npc_enadis_default_mce_entry(struct rvu *rvu, u16 pcifunc,
11071107
static void npc_enadis_default_entries(struct rvu *rvu, u16 pcifunc,
11081108
int nixlf, bool enable)
11091109
{
1110+
struct rvu_pfvf *pfvf = rvu_get_pfvf(rvu, pcifunc);
11101111
struct npc_mcam *mcam = &rvu->hw->mcam;
11111112
int index, blkaddr;
11121113

@@ -1115,9 +1116,12 @@ static void npc_enadis_default_entries(struct rvu *rvu, u16 pcifunc,
11151116
return;
11161117

11171118
/* Ucast MCAM match entry of this PF/VF */
1118-
index = npc_get_nixlf_mcam_index(mcam, pcifunc,
1119-
nixlf, NIXLF_UCAST_ENTRY);
1120-
npc_enable_mcam_entry(rvu, mcam, blkaddr, index, enable);
1119+
if (npc_is_feature_supported(rvu, BIT_ULL(NPC_DMAC),
1120+
pfvf->nix_rx_intf)) {
1121+
index = npc_get_nixlf_mcam_index(mcam, pcifunc,
1122+
nixlf, NIXLF_UCAST_ENTRY);
1123+
npc_enable_mcam_entry(rvu, mcam, blkaddr, index, enable);
1124+
}
11211125

11221126
/* Nothing to do for VFs, on platforms where pkt replication
11231127
* is not supported
@@ -3570,3 +3574,33 @@ int rvu_mbox_handler_npc_mcam_entry_stats(struct rvu *rvu,
35703574

35713575
return 0;
35723576
}
3577+
3578+
void rvu_npc_clear_ucast_entry(struct rvu *rvu, int pcifunc, int nixlf)
3579+
{
3580+
struct npc_mcam *mcam = &rvu->hw->mcam;
3581+
struct rvu_npc_mcam_rule *rule;
3582+
int ucast_idx, blkaddr;
3583+
3584+
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NPC, 0);
3585+
if (blkaddr < 0)
3586+
return;
3587+
3588+
ucast_idx = npc_get_nixlf_mcam_index(mcam, pcifunc,
3589+
nixlf, NIXLF_UCAST_ENTRY);
3590+
3591+
npc_enable_mcam_entry(rvu, mcam, blkaddr, ucast_idx, false);
3592+
3593+
npc_set_mcam_action(rvu, mcam, blkaddr, ucast_idx, 0);
3594+
3595+
npc_clear_mcam_entry(rvu, mcam, blkaddr, ucast_idx);
3596+
3597+
mutex_lock(&mcam->lock);
3598+
list_for_each_entry(rule, &mcam->mcam_rules, list) {
3599+
if (rule->entry == ucast_idx) {
3600+
list_del(&rule->list);
3601+
kfree(rule);
3602+
break;
3603+
}
3604+
}
3605+
mutex_unlock(&mcam->lock);
3606+
}

0 commit comments

Comments
 (0)