Skip to content

Commit 967db35

Browse files
Naveen Mamindlapallidavem330
authored andcommitted
octeontx2-af: add support for multicast/promisc packet replication feature
Currently, multicast packet filtering is accomplished by installing MCAM rule that matches all-multicast MAC address and has its NPC_RX_ACTION set to unicast to PF. Similarly promisc feature is achieved by installing MCAM rule that matches all the traffic received by the channel and unicast the packets to PF. This approach only applies to PF and is not scalable across VFs. This patch adds support for PF/VF multicast and promisc feature by reserving NIX_RX_MCE_S entries from the global MCE list allocated during NIX block initialization. The NIX_RX_MCE_S entries create a linked list with a flag indicating the end of the list, and each entry points to a PF_FUNC (either PF or VF). When a packet NPC_RX_ACTION is set to MCAST, the corresponding NIX_RX_MCE_S list is traversed and the packet is queued to each PF_FUNC available on the list. The PF or VF driver adds the multicast/promisc packet match entry and updates the MCE list with correspondng PF_FUNC. When a PF or VF interface is disabled, the corresponding NIX_RX_MCE_S entry is removed from the MCE list and the MCAM entry will be disabled if the list is empty. Signed-off-by: Naveen Mamindlapalli <[email protected]> Signed-off-by: Sunil Kovvuri Goutham <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 52e597d commit 967db35

File tree

9 files changed

+482
-158
lines changed

9 files changed

+482
-158
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ enum nix_scheduler {
197197

198198
#define SDP_CHANNELS 256
199199

200+
/* The mask is to extract lower 10-bits of channel number
201+
* which CPT will pass to X2P.
202+
*/
203+
#define NIX_CHAN_CPT_X2P_MASK (0x3ffull)
204+
200205
/* NIX LSO format indices.
201206
* As of now TSO is the only one using, so statically assigning indices.
202207
*/

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,9 @@ enum nix_af_status {
611611
NIX_AF_INVAL_SSO_PF_FUNC = -420,
612612
NIX_AF_ERR_TX_VTAG_NOSPC = -421,
613613
NIX_AF_ERR_RX_VTAG_INUSE = -422,
614-
NIX_AF_ERR_NPC_KEY_NOT_SUPP = -423,
614+
NIX_AF_ERR_PTP_CONFIG_FAIL = -423,
615+
NIX_AF_ERR_NPC_KEY_NOT_SUPP = -424,
616+
NIX_AF_ERR_INVALID_NIXBLK = -425,
615617
};
616618

617619
/* For NIX RX vtag action */
@@ -913,6 +915,7 @@ struct nix_rx_mode {
913915
#define NIX_RX_MODE_UCAST BIT(0)
914916
#define NIX_RX_MODE_PROMISC BIT(1)
915917
#define NIX_RX_MODE_ALLMULTI BIT(2)
918+
#define NIX_RX_MODE_USE_MCE BIT(3)
916919
u16 mode;
917920
};
918921

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,8 @@ struct nix_tx_action {
438438
/* NPC MCAM reserved entry index per nixlf */
439439
#define NIXLF_UCAST_ENTRY 0
440440
#define NIXLF_BCAST_ENTRY 1
441-
#define NIXLF_PROMISC_ENTRY 2
441+
#define NIXLF_ALLMULTI_ENTRY 2
442+
#define NIXLF_PROMISC_ENTRY 3
442443

443444
struct npc_coalesced_kpu_prfl {
444445
#define NPC_SIGN 0x00666f727063706e

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

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,14 @@ struct rvu_pfvf {
227227
u8 mac_addr[ETH_ALEN]; /* MAC address of this PF/VF */
228228
u8 default_mac[ETH_ALEN]; /* MAC address from FWdata */
229229

230-
/* Broadcast pkt replication info */
230+
/* Broadcast/Multicast/Promisc pkt replication info */
231231
u16 bcast_mce_idx;
232+
u16 mcast_mce_idx;
233+
u16 promisc_mce_idx;
232234
struct nix_mce_list bcast_mce_list;
235+
struct nix_mce_list mcast_mce_list;
236+
struct nix_mce_list promisc_mce_list;
237+
bool use_mce_list;
233238

234239
struct rvu_npc_mcam_rule *def_ucast_rule;
235240

@@ -239,6 +244,11 @@ struct rvu_pfvf {
239244
u8 nix_blkaddr; /* BLKADDR_NIX0/1 assigned to this PF */
240245
u8 nix_rx_intf; /* NIX0_RX/NIX1_RX interface to NPC */
241246
u8 nix_tx_intf; /* NIX0_TX/NIX1_TX interface to NPC */
247+
unsigned long flags;
248+
};
249+
250+
enum rvu_pfvf_flags {
251+
NIXLF_INITIALIZED = 0,
242252
};
243253

244254
struct nix_txsch {
@@ -548,11 +558,16 @@ static inline u16 rvu_nix_chan_cpt(struct rvu *rvu, u8 chan)
548558
/* Function Prototypes
549559
* RVU
550560
*/
551-
static inline int is_afvf(u16 pcifunc)
561+
static inline bool is_afvf(u16 pcifunc)
552562
{
553563
return !(pcifunc & ~RVU_PFVF_FUNC_MASK);
554564
}
555565

566+
static inline bool is_vf(u16 pcifunc)
567+
{
568+
return !!(pcifunc & RVU_PFVF_FUNC_MASK);
569+
}
570+
556571
/* check if PF_FUNC is AF */
557572
static inline bool is_pffunc_af(u16 pcifunc)
558573
{
@@ -608,6 +623,12 @@ static inline void rvu_get_cgx_lmac_id(u8 map, u8 *cgx_id, u8 *lmac_id)
608623
*lmac_id = (map & 0xF);
609624
}
610625

626+
static inline bool is_cgx_vf(struct rvu *rvu, u16 pcifunc)
627+
{
628+
return ((pcifunc & RVU_PFVF_FUNC_MASK) &&
629+
is_pf_cgxmapped(rvu, rvu_get_pf(pcifunc)));
630+
}
631+
611632
#define M(_name, _id, fn_name, req, rsp) \
612633
int rvu_mbox_handler_ ## fn_name(struct rvu *, struct req *, struct rsp *);
613634
MBOX_MESSAGES
@@ -637,10 +658,16 @@ void rvu_nix_freemem(struct rvu *rvu);
637658
int rvu_get_nixlf_count(struct rvu *rvu);
638659
void rvu_nix_lf_teardown(struct rvu *rvu, u16 pcifunc, int blkaddr, int npalf);
639660
int nix_get_nixlf(struct rvu *rvu, u16 pcifunc, int *nixlf, int *nix_blkaddr);
640-
int nix_update_bcast_mce_list(struct rvu *rvu, u16 pcifunc, bool add);
661+
int nix_update_mce_list(struct rvu *rvu, u16 pcifunc,
662+
struct nix_mce_list *mce_list,
663+
int mce_idx, int mcam_index, bool add);
664+
void nix_get_mce_list(struct rvu *rvu, u16 pcifunc, int type,
665+
struct nix_mce_list **mce_list, int *mce_idx);
641666
struct nix_hw *get_nix_hw(struct rvu_hwinfo *hw, int blkaddr);
642667
int rvu_get_next_nix_blkaddr(struct rvu *rvu, int blkaddr);
643668
void rvu_nix_reset_mac(struct rvu_pfvf *pfvf, int pcifunc);
669+
int nix_get_struct_ptrs(struct rvu *rvu, u16 pcifunc,
670+
struct nix_hw **nix_hw, int *blkaddr);
644671

645672
/* NPC APIs */
646673
int rvu_npc_init(struct rvu *rvu);
@@ -651,13 +678,19 @@ int npc_config_ts_kpuaction(struct rvu *rvu, int pf, u16 pcifunc, bool en);
651678
void rvu_npc_install_ucast_entry(struct rvu *rvu, u16 pcifunc,
652679
int nixlf, u64 chan, u8 *mac_addr);
653680
void rvu_npc_install_promisc_entry(struct rvu *rvu, u16 pcifunc,
654-
int nixlf, u64 chan, u8 chan_cnt,
655-
bool allmulti);
656-
void rvu_npc_disable_promisc_entry(struct rvu *rvu, u16 pcifunc, int nixlf);
657-
void rvu_npc_enable_promisc_entry(struct rvu *rvu, u16 pcifunc, int nixlf);
681+
int nixlf, u64 chan, u8 chan_cnt);
682+
void rvu_npc_enable_promisc_entry(struct rvu *rvu, u16 pcifunc, int nixlf,
683+
bool enable);
658684
void rvu_npc_install_bcast_match_entry(struct rvu *rvu, u16 pcifunc,
659685
int nixlf, u64 chan);
660-
void rvu_npc_enable_bcast_entry(struct rvu *rvu, u16 pcifunc, bool enable);
686+
void rvu_npc_enable_bcast_entry(struct rvu *rvu, u16 pcifunc, int nixlf,
687+
bool enable);
688+
void rvu_npc_install_allmulti_entry(struct rvu *rvu, u16 pcifunc, int nixlf,
689+
u64 chan);
690+
void rvu_npc_enable_allmulti_entry(struct rvu *rvu, u16 pcifunc, int nixlf,
691+
bool enable);
692+
void npc_enadis_default_mce_entry(struct rvu *rvu, u16 pcifunc,
693+
int nixlf, int type, bool enable);
661694
void rvu_npc_disable_mcam_entries(struct rvu *rvu, u16 pcifunc, int nixlf);
662695
void rvu_npc_free_mcam_entries(struct rvu *rvu, u16 pcifunc, int nixlf);
663696
void rvu_npc_disable_default_entries(struct rvu *rvu, u16 pcifunc, int nixlf);

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2132,6 +2132,7 @@ static int rvu_dbg_npc_mcam_show_rules(struct seq_file *s, void *unused)
21322132
struct rvu *rvu = s->private;
21332133
struct npc_mcam *mcam;
21342134
int pf, vf = -1;
2135+
bool enabled;
21352136
int blkaddr;
21362137
u16 target;
21372138
u64 hits;
@@ -2173,7 +2174,9 @@ static int rvu_dbg_npc_mcam_show_rules(struct seq_file *s, void *unused)
21732174
}
21742175

21752176
rvu_dbg_npc_mcam_show_action(s, iter);
2176-
seq_printf(s, "\tenabled: %s\n", iter->enable ? "yes" : "no");
2177+
2178+
enabled = is_mcam_entry_enabled(rvu, mcam, blkaddr, iter->entry);
2179+
seq_printf(s, "\tenabled: %s\n", enabled ? "yes" : "no");
21772180

21782181
if (!iter->has_cntr)
21792182
continue;

0 commit comments

Comments
 (0)