Skip to content

Commit 55307fc

Browse files
Subbaraya Sundeepkuba-moo
authored andcommitted
octeontx2-af: Add mbox messages to install and delete MCAM rules
Added new mailbox messages to install and delete MCAM rules. These mailbox messages will be used for adding/deleting ethtool n-tuple filters by NIX PF. The installed MCAM rules are stored in a list that will be traversed later to delete the MCAM entries when the interface is brought down or when PCIe FLR is received. The delete mailbox supports deleting a single MCAM entry or range of entries or all the MCAM entries owned by the pcifunc. Each MCAM entry can be associated with a HW match stat entry if the mailbox requester wants to check the hit count for debugging. Modified adding default unicast DMAC match rule using install flow API. The default unicast DMAC match entry installed by Administrative Function is saved and can be changed later by the mailbox user to fit additional fields, or the default MCAM entry rule action can be used for other flow rules installed later. Modified rvu_mbox_handler_nix_lf_free mailbox to add a flag to disable or delete the MCAM entries. The MCAM entries are disabled when the interface is brought down and deleted in FLR handler. The disabled MCAM entries will be re-enabled when the interface is brought up again. Signed-off-by: Subbaraya Sundeep <[email protected]> Signed-off-by: Sunil Goutham <[email protected]> Signed-off-by: Naveen Mamindlapalli <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 9b179a9 commit 55307fc

File tree

8 files changed

+1064
-52
lines changed

8 files changed

+1064
-52
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ enum nix_scheduler {
162162
#define NIX_RX_ACTIONOP_UCAST_IPSEC (0x2ull)
163163
#define NIX_RX_ACTIONOP_MCAST (0x3ull)
164164
#define NIX_RX_ACTIONOP_RSS (0x4ull)
165+
/* Use the RX action set in the default unicast entry */
166+
#define NIX_RX_ACTION_DEFAULT (0xfull)
165167

166168
/* NIX TX action operation*/
167169
#define NIX_TX_ACTIONOP_DROP (0x0ull)

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

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,14 @@ M(NPC_MCAM_ALLOC_AND_WRITE_ENTRY, 0x600b, npc_mcam_alloc_and_write_entry, \
188188
npc_mcam_alloc_and_write_entry_rsp) \
189189
M(NPC_GET_KEX_CFG, 0x600c, npc_get_kex_cfg, \
190190
msg_req, npc_get_kex_cfg_rsp) \
191+
M(NPC_INSTALL_FLOW, 0x600d, npc_install_flow, \
192+
npc_install_flow_req, npc_install_flow_rsp) \
193+
M(NPC_DELETE_FLOW, 0x600e, npc_delete_flow, \
194+
npc_delete_flow_req, msg_rsp) \
191195
/* NIX mbox IDs (range 0x8000 - 0xFFFF) */ \
192196
M(NIX_LF_ALLOC, 0x8000, nix_lf_alloc, \
193197
nix_lf_alloc_req, nix_lf_alloc_rsp) \
194-
M(NIX_LF_FREE, 0x8001, nix_lf_free, msg_req, msg_rsp) \
198+
M(NIX_LF_FREE, 0x8001, nix_lf_free, nix_lf_free_req, msg_rsp) \
195199
M(NIX_AQ_ENQ, 0x8002, nix_aq_enq, nix_aq_enq_req, nix_aq_enq_rsp) \
196200
M(NIX_HWCTX_DISABLE, 0x8003, nix_hwctx_disable, \
197201
hwctx_disable_req, msg_rsp) \
@@ -510,6 +514,12 @@ struct nix_lf_alloc_rsp {
510514
u8 sdp_links; /* No. of SDP links present in HW */
511515
};
512516

517+
struct nix_lf_free_req {
518+
struct mbox_msghdr hdr;
519+
#define NIX_LF_DISABLE_FLOWS BIT_ULL(0)
520+
u64 flags;
521+
};
522+
513523
/* NIX AQ enqueue msg */
514524
struct nix_aq_enq_req {
515525
struct mbox_msghdr hdr;
@@ -882,6 +892,70 @@ struct npc_get_kex_cfg_rsp {
882892
u8 mkex_pfl_name[MKEX_NAME_LEN];
883893
};
884894

895+
struct flow_msg {
896+
unsigned char dmac[6];
897+
unsigned char smac[6];
898+
__be16 etype;
899+
__be16 vlan_etype;
900+
__be16 vlan_tci;
901+
union {
902+
__be32 ip4src;
903+
__be32 ip6src[4];
904+
};
905+
union {
906+
__be32 ip4dst;
907+
__be32 ip6dst[4];
908+
};
909+
u8 tos;
910+
u8 ip_ver;
911+
u8 ip_proto;
912+
u8 tc;
913+
__be16 sport;
914+
__be16 dport;
915+
};
916+
917+
struct npc_install_flow_req {
918+
struct mbox_msghdr hdr;
919+
struct flow_msg packet;
920+
struct flow_msg mask;
921+
u64 features;
922+
u16 entry;
923+
u16 channel;
924+
u8 intf;
925+
u8 set_cntr; /* If counter is available set counter for this entry ? */
926+
u8 default_rule;
927+
u8 append; /* overwrite(0) or append(1) flow to default rule? */
928+
u16 vf;
929+
/* action */
930+
u32 index;
931+
u16 match_id;
932+
u8 flow_key_alg;
933+
u8 op;
934+
/* vtag rx action */
935+
u8 vtag0_type;
936+
u8 vtag0_valid;
937+
u8 vtag1_type;
938+
u8 vtag1_valid;
939+
/* vtag tx action */
940+
u16 vtag0_def;
941+
u8 vtag0_op;
942+
u16 vtag1_def;
943+
u8 vtag1_op;
944+
};
945+
946+
struct npc_install_flow_rsp {
947+
struct mbox_msghdr hdr;
948+
int counter; /* negative if no counter else counter number */
949+
};
950+
951+
struct npc_delete_flow_req {
952+
struct mbox_msghdr hdr;
953+
u16 entry;
954+
u16 start;/*Disable range of entries */
955+
u16 end;
956+
u8 all; /* PF + VFs */
957+
};
958+
885959
enum ptp_op {
886960
PTP_OP_ADJFINE = 0,
887961
PTP_OP_GET_CLOCK = 1,

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

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,41 @@ struct nix_rx_action {
379379
#define NPC_PARSE_NIBBLE_LH_FLAGS GENMASK_ULL(29, 28)
380380
#define NPC_PARSE_NIBBLE_LH_LTYPE BIT_ULL(30)
381381

382+
struct nix_tx_action {
383+
#if defined(__BIG_ENDIAN_BITFIELD)
384+
u64 rsvd_63_48 :16;
385+
u64 match_id :16;
386+
u64 index :20;
387+
u64 rsvd_11_8 :8;
388+
u64 op :4;
389+
#else
390+
u64 op :4;
391+
u64 rsvd_11_8 :8;
392+
u64 index :20;
393+
u64 match_id :16;
394+
u64 rsvd_63_48 :16;
395+
#endif
396+
};
397+
382398
/* NIX Receive Vtag Action Structure */
383-
#define VTAG0_VALID_BIT BIT_ULL(15)
384-
#define VTAG0_TYPE_MASK GENMASK_ULL(14, 12)
385-
#define VTAG0_LID_MASK GENMASK_ULL(10, 8)
386-
#define VTAG0_RELPTR_MASK GENMASK_ULL(7, 0)
399+
#define RX_VTAG0_VALID_BIT BIT_ULL(15)
400+
#define RX_VTAG0_TYPE_MASK GENMASK_ULL(14, 12)
401+
#define RX_VTAG0_LID_MASK GENMASK_ULL(10, 8)
402+
#define RX_VTAG0_RELPTR_MASK GENMASK_ULL(7, 0)
403+
#define RX_VTAG1_VALID_BIT BIT_ULL(47)
404+
#define RX_VTAG1_TYPE_MASK GENMASK_ULL(46, 44)
405+
#define RX_VTAG1_LID_MASK GENMASK_ULL(42, 40)
406+
#define RX_VTAG1_RELPTR_MASK GENMASK_ULL(39, 32)
407+
408+
/* NIX Transmit Vtag Action Structure */
409+
#define TX_VTAG0_DEF_MASK GENMASK_ULL(25, 16)
410+
#define TX_VTAG0_OP_MASK GENMASK_ULL(13, 12)
411+
#define TX_VTAG0_LID_MASK GENMASK_ULL(10, 8)
412+
#define TX_VTAG0_RELPTR_MASK GENMASK_ULL(7, 0)
413+
#define TX_VTAG1_DEF_MASK GENMASK_ULL(57, 48)
414+
#define TX_VTAG1_OP_MASK GENMASK_ULL(45, 44)
415+
#define TX_VTAG1_LID_MASK GENMASK_ULL(42, 40)
416+
#define TX_VTAG1_RELPTR_MASK GENMASK_ULL(39, 32)
387417

388418
struct npc_mcam_kex {
389419
/* MKEX Profle Header */
@@ -436,4 +466,23 @@ struct npc_lt_def_cfg {
436466
struct npc_lt_def pck_iip4;
437467
};
438468

469+
struct rvu_npc_mcam_rule {
470+
struct flow_msg packet;
471+
struct flow_msg mask;
472+
u8 intf;
473+
union {
474+
struct nix_tx_action tx_action;
475+
struct nix_rx_action rx_action;
476+
};
477+
u64 vtag_action;
478+
struct list_head list;
479+
u64 features;
480+
u16 owner;
481+
u16 entry;
482+
u16 cntr;
483+
bool has_cntr;
484+
u8 default_rule;
485+
bool enable;
486+
};
487+
439488
#endif /* NPC_H */

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ struct npc_mcam {
147147
u16 *entry2cntr_map;
148148
u16 *cntr2pfvf_map;
149149
u16 *cntr_refcnt;
150+
u16 *entry2target_pffunc;
150151
u8 keysize; /* MCAM keysize 112/224/448 bits */
151152
u8 banks; /* Number of MCAM banks */
152153
u8 banks_per_entry;/* Number of keywords in key */
@@ -164,6 +165,7 @@ struct npc_mcam {
164165
struct npc_key_field rx_key_fields[NPC_KEY_FIELDS_MAX];
165166
u64 tx_features;
166167
u64 rx_features;
168+
struct list_head mcam_rules;
167169
};
168170

169171
/* Structure for per RVU func info ie PF/VF */
@@ -218,6 +220,8 @@ struct rvu_pfvf {
218220
int rxvlan_index;
219221
bool rxvlan;
220222

223+
struct rvu_npc_mcam_rule *def_ucast_rule;
224+
221225
bool cgx_in_use; /* this PF/VF using CGX? */
222226
int cgx_users; /* number of cgx users - used only by PFs */
223227

@@ -558,6 +562,7 @@ void rvu_npc_install_bcast_match_entry(struct rvu *rvu, u16 pcifunc,
558562
void rvu_npc_enable_bcast_entry(struct rvu *rvu, u16 pcifunc, bool enable);
559563
int rvu_npc_update_rxvlan(struct rvu *rvu, u16 pcifunc, int nixlf);
560564
void rvu_npc_disable_mcam_entries(struct rvu *rvu, u16 pcifunc, int nixlf);
565+
void rvu_npc_free_mcam_entries(struct rvu *rvu, u16 pcifunc, int nixlf);
561566
void rvu_npc_disable_default_entries(struct rvu *rvu, u16 pcifunc, int nixlf);
562567
void rvu_npc_enable_default_entries(struct rvu *rvu, u16 pcifunc, int nixlf);
563568
void rvu_npc_update_flowkey_alg_idx(struct rvu *rvu, u16 pcifunc, int nixlf,
@@ -575,6 +580,14 @@ int rvu_npc_get_tx_nibble_cfg(struct rvu *rvu, u64 nibble_ena);
575580
int npc_mcam_verify_channel(struct rvu *rvu, u16 pcifunc, u8 intf, u16 channel);
576581
int npc_flow_steering_init(struct rvu *rvu, int blkaddr);
577582
const char *npc_get_field_name(u8 hdr);
583+
bool rvu_npc_write_default_rule(struct rvu *rvu, int blkaddr, int nixlf,
584+
u16 pcifunc, u8 intf, struct mcam_entry *entry,
585+
int *entry_index);
586+
int npc_get_bank(struct npc_mcam *mcam, int index);
587+
void npc_mcam_enable_flows(struct rvu *rvu, u16 target);
588+
void npc_mcam_disable_flows(struct rvu *rvu, u16 target);
589+
void npc_enable_mcam_entry(struct rvu *rvu, struct npc_mcam *mcam,
590+
int blkaddr, int index, bool enable);
578591

579592
#ifdef CONFIG_DEBUG_FS
580593
void rvu_dbg_init(struct rvu *rvu);

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ static void nix_interface_deinit(struct rvu *rvu, u16 pcifunc, u8 nixlf)
302302

303303
pfvf->maxlen = 0;
304304
pfvf->minlen = 0;
305-
pfvf->rxvlan = false;
306305

307306
/* Remove this PF_FUNC from bcast pkt replication list */
308307
err = nix_update_bcast_mce_list(rvu, pcifunc, false);
@@ -1228,7 +1227,7 @@ int rvu_mbox_handler_nix_lf_alloc(struct rvu *rvu,
12281227
return rc;
12291228
}
12301229

1231-
int rvu_mbox_handler_nix_lf_free(struct rvu *rvu, struct msg_req *req,
1230+
int rvu_mbox_handler_nix_lf_free(struct rvu *rvu, struct nix_lf_free_req *req,
12321231
struct msg_rsp *rsp)
12331232
{
12341233
struct rvu_hwinfo *hw = rvu->hw;
@@ -1247,6 +1246,11 @@ int rvu_mbox_handler_nix_lf_free(struct rvu *rvu, struct msg_req *req,
12471246
if (nixlf < 0)
12481247
return NIX_AF_ERR_AF_LF_INVALID;
12491248

1249+
if (req->flags & NIX_LF_DISABLE_FLOWS)
1250+
rvu_npc_disable_mcam_entries(rvu, pcifunc, nixlf);
1251+
else
1252+
rvu_npc_free_mcam_entries(rvu, pcifunc, nixlf);
1253+
12501254
nix_interface_deinit(rvu, pcifunc, nixlf);
12511255

12521256
/* Reset this NIX LF */
@@ -2762,8 +2766,6 @@ int rvu_mbox_handler_nix_set_mac_addr(struct rvu *rvu,
27622766
rvu_npc_install_ucast_entry(rvu, pcifunc, nixlf,
27632767
pfvf->rx_chan_base, req->mac_addr);
27642768

2765-
rvu_npc_update_rxvlan(rvu, pcifunc, nixlf);
2766-
27672769
return 0;
27682770
}
27692771

@@ -2810,9 +2812,6 @@ int rvu_mbox_handler_nix_set_rx_mode(struct rvu *rvu, struct nix_rx_mode *req,
28102812
else
28112813
rvu_npc_install_promisc_entry(rvu, pcifunc, nixlf,
28122814
pfvf->rx_chan_base, allmulti);
2813-
2814-
rvu_npc_update_rxvlan(rvu, pcifunc, nixlf);
2815-
28162815
return 0;
28172816
}
28182817

@@ -3376,6 +3375,8 @@ int rvu_mbox_handler_nix_lf_start_rx(struct rvu *rvu, struct msg_req *req,
33763375

33773376
rvu_npc_enable_default_entries(rvu, pcifunc, nixlf);
33783377

3378+
npc_mcam_enable_flows(rvu, pcifunc);
3379+
33793380
return rvu_cgx_start_stop_io(rvu, pcifunc, true);
33803381
}
33813382

@@ -3391,6 +3392,8 @@ int rvu_mbox_handler_nix_lf_stop_rx(struct rvu *rvu, struct msg_req *req,
33913392

33923393
rvu_npc_disable_default_entries(rvu, pcifunc, nixlf);
33933394

3395+
npc_mcam_disable_flows(rvu, pcifunc);
3396+
33943397
return rvu_cgx_start_stop_io(rvu, pcifunc, false);
33953398
}
33963399

@@ -3403,6 +3406,8 @@ void rvu_nix_lf_teardown(struct rvu *rvu, u16 pcifunc, int blkaddr, int nixlf)
34033406
ctx_req.hdr.pcifunc = pcifunc;
34043407

34053408
/* Cleanup NPC MCAM entries, free Tx scheduler queues being used */
3409+
rvu_npc_disable_mcam_entries(rvu, pcifunc, nixlf);
3410+
rvu_npc_free_mcam_entries(rvu, pcifunc, nixlf);
34063411
nix_interface_deinit(rvu, pcifunc, nixlf);
34073412
nix_rx_sync(rvu, blkaddr);
34083413
nix_txschq_free(rvu, pcifunc);

0 commit comments

Comments
 (0)