Skip to content

Commit 40df309

Browse files
sgoutham-marvelldavem330
authored andcommitted
octeontx2-af: Support to enable/disable default MCAM entries
For a PF/VF with a NIXLF attached has default/reserved MCAM entries for receiving Ucast/Bcast/Promisc traffic. Ideally traffic should be forwarded to NIXLF only after it's contexts are initialized. This patch keeps these default entries disabled and adds mbox messages for a PF/VF to enable these once NPA/NIXLF initialization is done. Likewise while PF/VF is being teared down, it can send the disable mailbox message to stop receiving traffic. Signed-off-by: Sunil Goutham <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 631e70b commit 40df309

File tree

4 files changed

+122
-28
lines changed

4 files changed

+122
-28
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,9 @@ M(NIX_RSS_FLOWKEY_CFG, 0x8009, nix_rss_flowkey_cfg, \
195195
nix_rss_flowkey_cfg, msg_rsp) \
196196
M(NIX_SET_MAC_ADDR, 0x800a, nix_set_mac_addr, nix_set_mac_addr, msg_rsp) \
197197
M(NIX_SET_RX_MODE, 0x800b, nix_set_rx_mode, nix_rx_mode, msg_rsp) \
198-
M(NIX_SET_HW_FRS, 0x800c, nix_set_hw_frs, nix_frs_cfg, msg_rsp)
198+
M(NIX_SET_HW_FRS, 0x800c, nix_set_hw_frs, nix_frs_cfg, msg_rsp) \
199+
M(NIX_LF_START_RX, 0x800d, nix_lf_start_rx, msg_req, msg_rsp) \
200+
M(NIX_LF_STOP_RX, 0x800e, nix_lf_stop_rx, msg_req, msg_rsp)
199201

200202
/* Messages initiated by AF (range 0xC00 - 0xDFF) */
201203
#define MBOX_UP_CGX_MESSAGES \

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,10 @@ int rvu_mbox_handler_nix_set_rx_mode(struct rvu *rvu, struct nix_rx_mode *req,
366366
struct msg_rsp *rsp);
367367
int rvu_mbox_handler_nix_set_hw_frs(struct rvu *rvu, struct nix_frs_cfg *req,
368368
struct msg_rsp *rsp);
369+
int rvu_mbox_handler_nix_lf_start_rx(struct rvu *rvu, struct msg_req *req,
370+
struct msg_rsp *rsp);
371+
int rvu_mbox_handler_nix_lf_stop_rx(struct rvu *rvu, struct msg_req *req,
372+
struct msg_rsp *rsp);
369373

370374
/* NPC APIs */
371375
int rvu_npc_init(struct rvu *rvu);
@@ -377,9 +381,12 @@ void rvu_npc_install_ucast_entry(struct rvu *rvu, u16 pcifunc,
377381
void rvu_npc_install_promisc_entry(struct rvu *rvu, u16 pcifunc,
378382
int nixlf, u64 chan, bool allmulti);
379383
void rvu_npc_disable_promisc_entry(struct rvu *rvu, u16 pcifunc, int nixlf);
384+
void rvu_npc_enable_promisc_entry(struct rvu *rvu, u16 pcifunc, int nixlf);
380385
void rvu_npc_install_bcast_match_entry(struct rvu *rvu, u16 pcifunc,
381386
int nixlf, u64 chan);
382387
void rvu_npc_disable_mcam_entries(struct rvu *rvu, u16 pcifunc, int nixlf);
388+
void rvu_npc_disable_default_entries(struct rvu *rvu, u16 pcifunc, int nixlf);
389+
void rvu_npc_enable_default_entries(struct rvu *rvu, u16 pcifunc, int nixlf);
383390
void rvu_npc_update_flowkey_alg_idx(struct rvu *rvu, u16 pcifunc, int nixlf,
384391
int group, int alg_idx, int mcam_index);
385392
int rvu_mbox_handler_npc_mcam_alloc_entry(struct rvu *rvu,

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

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,9 @@ int rvu_mbox_handler_nix_lf_alloc(struct rvu *rvu,
821821
if (err)
822822
goto free_mem;
823823

824+
/* Disable NPC entries as NIXLF's contexts are not initialized yet */
825+
rvu_npc_disable_default_entries(rvu, pcifunc, nixlf);
826+
824827
goto exit;
825828

826829
free_mem:
@@ -2176,3 +2179,48 @@ void rvu_nix_freemem(struct rvu *rvu)
21762179
mutex_destroy(&mcast->mce_lock);
21772180
}
21782181
}
2182+
2183+
static int nix_get_nixlf(struct rvu *rvu, u16 pcifunc, int *nixlf)
2184+
{
2185+
struct rvu_pfvf *pfvf = rvu_get_pfvf(rvu, pcifunc);
2186+
struct rvu_hwinfo *hw = rvu->hw;
2187+
int blkaddr;
2188+
2189+
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, pcifunc);
2190+
if (!pfvf->nixlf || blkaddr < 0)
2191+
return NIX_AF_ERR_AF_LF_INVALID;
2192+
2193+
*nixlf = rvu_get_lf(rvu, &hw->block[blkaddr], pcifunc, 0);
2194+
if (*nixlf < 0)
2195+
return NIX_AF_ERR_AF_LF_INVALID;
2196+
2197+
return 0;
2198+
}
2199+
2200+
int rvu_mbox_handler_nix_lf_start_rx(struct rvu *rvu, struct msg_req *req,
2201+
struct msg_rsp *rsp)
2202+
{
2203+
u16 pcifunc = req->hdr.pcifunc;
2204+
int nixlf, err;
2205+
2206+
err = nix_get_nixlf(rvu, pcifunc, &nixlf);
2207+
if (err)
2208+
return err;
2209+
2210+
rvu_npc_enable_default_entries(rvu, pcifunc, nixlf);
2211+
return 0;
2212+
}
2213+
2214+
int rvu_mbox_handler_nix_lf_stop_rx(struct rvu *rvu, struct msg_req *req,
2215+
struct msg_rsp *rsp)
2216+
{
2217+
u16 pcifunc = req->hdr.pcifunc;
2218+
int nixlf, err;
2219+
2220+
err = nix_get_nixlf(rvu, pcifunc, &nixlf);
2221+
if (err)
2222+
return err;
2223+
2224+
rvu_npc_disable_default_entries(rvu, pcifunc, nixlf);
2225+
return 0;
2226+
}

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

Lines changed: 64 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,8 @@ void rvu_npc_install_promisc_entry(struct rvu *rvu, u16 pcifunc,
384384
NIX_INTF_RX, &entry, true);
385385
}
386386

387-
void rvu_npc_disable_promisc_entry(struct rvu *rvu, u16 pcifunc, int nixlf)
387+
static void npc_enadis_promisc_entry(struct rvu *rvu, u16 pcifunc,
388+
int nixlf, bool enable)
388389
{
389390
struct npc_mcam *mcam = &rvu->hw->mcam;
390391
int blkaddr, index;
@@ -399,7 +400,17 @@ void rvu_npc_disable_promisc_entry(struct rvu *rvu, u16 pcifunc, int nixlf)
399400

400401
index = npc_get_nixlf_mcam_index(mcam, pcifunc,
401402
nixlf, NIXLF_PROMISC_ENTRY);
402-
npc_enable_mcam_entry(rvu, mcam, blkaddr, index, false);
403+
npc_enable_mcam_entry(rvu, mcam, blkaddr, index, enable);
404+
}
405+
406+
void rvu_npc_disable_promisc_entry(struct rvu *rvu, u16 pcifunc, int nixlf)
407+
{
408+
npc_enadis_promisc_entry(rvu, pcifunc, nixlf, false);
409+
}
410+
411+
void rvu_npc_enable_promisc_entry(struct rvu *rvu, u16 pcifunc, int nixlf)
412+
{
413+
npc_enadis_promisc_entry(rvu, pcifunc, nixlf, true);
403414
}
404415

405416
void rvu_npc_install_bcast_match_entry(struct rvu *rvu, u16 pcifunc,
@@ -512,11 +523,59 @@ void rvu_npc_update_flowkey_alg_idx(struct rvu *rvu, u16 pcifunc, int nixlf,
512523
NPC_AF_MCAMEX_BANKX_ACTION(index, bank), *(u64 *)&action);
513524
}
514525

515-
void rvu_npc_disable_mcam_entries(struct rvu *rvu, u16 pcifunc, int nixlf)
526+
static void npc_enadis_default_entries(struct rvu *rvu, u16 pcifunc,
527+
int nixlf, bool enable)
516528
{
517529
struct npc_mcam *mcam = &rvu->hw->mcam;
518530
struct nix_rx_action action;
519-
int blkaddr, index, bank;
531+
int index, bank, blkaddr;
532+
533+
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NPC, 0);
534+
if (blkaddr < 0)
535+
return;
536+
537+
/* Ucast MCAM match entry of this PF/VF */
538+
index = npc_get_nixlf_mcam_index(mcam, pcifunc,
539+
nixlf, NIXLF_UCAST_ENTRY);
540+
npc_enable_mcam_entry(rvu, mcam, blkaddr, index, enable);
541+
542+
/* For PF, ena/dis promisc and bcast MCAM match entries */
543+
if (pcifunc & RVU_PFVF_FUNC_MASK)
544+
return;
545+
546+
/* For bcast, enable/disable only if it's action is not
547+
* packet replication, incase if action is replication
548+
* then this PF's nixlf is removed from bcast replication
549+
* list.
550+
*/
551+
index = npc_get_nixlf_mcam_index(mcam, pcifunc,
552+
nixlf, NIXLF_BCAST_ENTRY);
553+
bank = npc_get_bank(mcam, index);
554+
*(u64 *)&action = rvu_read64(rvu, blkaddr,
555+
NPC_AF_MCAMEX_BANKX_ACTION(index & (mcam->banksize - 1), bank));
556+
if (action.op != NIX_RX_ACTIONOP_MCAST)
557+
npc_enable_mcam_entry(rvu, mcam,
558+
blkaddr, index, enable);
559+
if (enable)
560+
rvu_npc_enable_promisc_entry(rvu, pcifunc, nixlf);
561+
else
562+
rvu_npc_disable_promisc_entry(rvu, pcifunc, nixlf);
563+
}
564+
565+
void rvu_npc_disable_default_entries(struct rvu *rvu, u16 pcifunc, int nixlf)
566+
{
567+
npc_enadis_default_entries(rvu, pcifunc, nixlf, false);
568+
}
569+
570+
void rvu_npc_enable_default_entries(struct rvu *rvu, u16 pcifunc, int nixlf)
571+
{
572+
npc_enadis_default_entries(rvu, pcifunc, nixlf, true);
573+
}
574+
575+
void rvu_npc_disable_mcam_entries(struct rvu *rvu, u16 pcifunc, int nixlf)
576+
{
577+
struct npc_mcam *mcam = &rvu->hw->mcam;
578+
int blkaddr;
520579

521580
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NPC, 0);
522581
if (blkaddr < 0)
@@ -532,29 +591,7 @@ void rvu_npc_disable_mcam_entries(struct rvu *rvu, u16 pcifunc, int nixlf)
532591

533592
mutex_unlock(&mcam->lock);
534593

535-
/* Disable ucast MCAM match entry of this PF/VF */
536-
index = npc_get_nixlf_mcam_index(mcam, pcifunc,
537-
nixlf, NIXLF_UCAST_ENTRY);
538-
npc_enable_mcam_entry(rvu, mcam, blkaddr, index, false);
539-
540-
/* For PF, disable promisc and bcast MCAM match entries */
541-
if (!(pcifunc & RVU_PFVF_FUNC_MASK)) {
542-
index = npc_get_nixlf_mcam_index(mcam, pcifunc,
543-
nixlf, NIXLF_BCAST_ENTRY);
544-
/* For bcast, disable only if it's action is not
545-
* packet replication, incase if action is replication
546-
* then this PF's nixlf is removed from bcast replication
547-
* list.
548-
*/
549-
bank = npc_get_bank(mcam, index);
550-
index &= (mcam->banksize - 1);
551-
*(u64 *)&action = rvu_read64(rvu, blkaddr,
552-
NPC_AF_MCAMEX_BANKX_ACTION(index, bank));
553-
if (action.op != NIX_RX_ACTIONOP_MCAST)
554-
npc_enable_mcam_entry(rvu, mcam, blkaddr, index, false);
555-
556-
rvu_npc_disable_promisc_entry(rvu, pcifunc, nixlf);
557-
}
594+
rvu_npc_disable_default_entries(rvu, pcifunc, nixlf);
558595
}
559596

560597
#define SET_KEX_LD(intf, lid, ltype, ld, cfg) \

0 commit comments

Comments
 (0)