Skip to content

Commit 674b3e1

Browse files
sumang-mrvlPaolo Abeni
authored andcommitted
octeontx2-pf: Add additional checks while configuring ucast/bcast/mcast rules
1. If a profile does not support DMAC extraction then avoid installing NPC flow rules for unicast. Similarly, if LXMB(L2 and L3) extraction is not supported by the profile then avoid installing broadcast and multicast rules. 2. Allow MCAM entry insertion for promiscuous mode. 3. For the profiles where DMAC is not extracted in MKEX key default unicast entry installed by AF is not valid. Hence do not use action from the AF installed default unicast entry for such cases. 4. Adjacent packet header fields in a packet like IP header source and destination addresses or UDP/TCP header source port and destination can be extracted together in MKEX profile. Therefore MKEX profile can be configured to in two ways: a. Total of 4 bytes from start of UDP header(src port + destination port) or b. Two bytes from start and two bytes from offset 2 Signed-off-by: Suman Ghosh <[email protected]> Signed-off-by: Subbaraya Sundeep <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 696450c commit 674b3e1

File tree

5 files changed

+124
-16
lines changed

5 files changed

+124
-16
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ M(NPC_MCAM_GET_STATS, 0x6012, npc_mcam_entry_stats, \
245245
M(NPC_GET_SECRET_KEY, 0x6013, npc_get_secret_key, \
246246
npc_get_secret_key_req, \
247247
npc_get_secret_key_rsp) \
248+
M(NPC_GET_FIELD_STATUS, 0x6014, npc_get_field_status, \
249+
npc_get_field_status_req, \
250+
npc_get_field_status_rsp) \
248251
/* NIX mbox IDs (range 0x8000 - 0xFFFF) */ \
249252
M(NIX_LF_ALLOC, 0x8000, nix_lf_alloc, \
250253
nix_lf_alloc_req, nix_lf_alloc_rsp) \
@@ -1541,6 +1544,17 @@ struct ptp_rsp {
15411544
u64 clk;
15421545
};
15431546

1547+
struct npc_get_field_status_req {
1548+
struct mbox_msghdr hdr;
1549+
u8 intf;
1550+
u8 field;
1551+
};
1552+
1553+
struct npc_get_field_status_rsp {
1554+
struct mbox_msghdr hdr;
1555+
u8 enable;
1556+
};
1557+
15441558
struct set_vf_perm {
15451559
struct mbox_msghdr hdr;
15461560
u16 vf;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,7 @@ int npc_install_mcam_drop_rule(struct rvu *rvu, int mcam_idx, u16 *counter_idx,
851851
u64 chan_val, u64 chan_mask, u64 exact_val, u64 exact_mask,
852852
u64 bcast_mcast_val, u64 bcast_mcast_mask);
853853
void npc_mcam_rsrcs_reserve(struct rvu *rvu, int blkaddr, int entry_idx);
854+
bool npc_is_feature_supported(struct rvu *rvu, u64 features, u8 intf);
854855

855856
/* CPT APIs */
856857
int rvu_cpt_register_interrupts(struct rvu *rvu);

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,12 @@ void rvu_npc_install_ucast_entry(struct rvu *rvu, u16 pcifunc,
617617
if (blkaddr < 0)
618618
return;
619619

620+
/* Ucast rule should not be installed if DMAC
621+
* extraction is not supported by the profile.
622+
*/
623+
if (!npc_is_feature_supported(rvu, BIT_ULL(NPC_DMAC), pfvf->nix_rx_intf))
624+
return;
625+
620626
index = npc_get_nixlf_mcam_index(mcam, pcifunc,
621627
nixlf, NIXLF_UCAST_ENTRY);
622628

@@ -778,6 +784,14 @@ void rvu_npc_install_bcast_match_entry(struct rvu *rvu, u16 pcifunc,
778784
/* Get 'pcifunc' of PF device */
779785
pcifunc = pcifunc & ~RVU_PFVF_FUNC_MASK;
780786
pfvf = rvu_get_pfvf(rvu, pcifunc);
787+
788+
/* Bcast rule should not be installed if both DMAC
789+
* and LXMB extraction is not supported by the profile.
790+
*/
791+
if (!npc_is_feature_supported(rvu, BIT_ULL(NPC_DMAC), pfvf->nix_rx_intf) &&
792+
!npc_is_feature_supported(rvu, BIT_ULL(NPC_LXMB), pfvf->nix_rx_intf))
793+
return;
794+
781795
index = npc_get_nixlf_mcam_index(mcam, pcifunc,
782796
nixlf, NIXLF_BCAST_ENTRY);
783797

@@ -848,6 +862,14 @@ void rvu_npc_install_allmulti_entry(struct rvu *rvu, u16 pcifunc, int nixlf,
848862
vf_func = pcifunc & RVU_PFVF_FUNC_MASK;
849863
pcifunc = pcifunc & ~RVU_PFVF_FUNC_MASK;
850864
pfvf = rvu_get_pfvf(rvu, pcifunc);
865+
866+
/* Mcast rule should not be installed if both DMAC
867+
* and LXMB extraction is not supported by the profile.
868+
*/
869+
if (!npc_is_feature_supported(rvu, BIT_ULL(NPC_DMAC), pfvf->nix_rx_intf) &&
870+
!npc_is_feature_supported(rvu, BIT_ULL(NPC_LXMB), pfvf->nix_rx_intf))
871+
return;
872+
851873
index = npc_get_nixlf_mcam_index(mcam, pcifunc,
852874
nixlf, NIXLF_ALLMULTI_ENTRY);
853875

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

Lines changed: 62 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,19 @@ static const char * const npc_flow_names[] = {
4747
[NPC_UNKNOWN] = "unknown",
4848
};
4949

50+
bool npc_is_feature_supported(struct rvu *rvu, u64 features, u8 intf)
51+
{
52+
struct npc_mcam *mcam = &rvu->hw->mcam;
53+
u64 mcam_features;
54+
u64 unsupported;
55+
56+
mcam_features = is_npc_intf_tx(intf) ? mcam->tx_features : mcam->rx_features;
57+
unsupported = (mcam_features ^ features) & ~mcam_features;
58+
59+
/* Return false if at least one of the input flows is not extracted */
60+
return !unsupported;
61+
}
62+
5063
const char *npc_get_field_name(u8 hdr)
5164
{
5265
if (hdr >= ARRAY_SIZE(npc_flow_names))
@@ -436,8 +449,6 @@ static void npc_scan_ldata(struct rvu *rvu, int blkaddr, u8 lid,
436449
nr_bytes = FIELD_GET(NPC_BYTESM, cfg) + 1;
437450
hdr = FIELD_GET(NPC_HDR_OFFSET, cfg);
438451
key = FIELD_GET(NPC_KEY_OFFSET, cfg);
439-
start_kwi = key / 8;
440-
offset = (key * 8) % 64;
441452

442453
/* For Tx, Layer A has NIX_INST_HDR_S(64 bytes) preceding
443454
* ethernet header.
@@ -452,13 +463,18 @@ static void npc_scan_ldata(struct rvu *rvu, int blkaddr, u8 lid,
452463

453464
#define NPC_SCAN_HDR(name, hlid, hlt, hstart, hlen) \
454465
do { \
466+
start_kwi = key / 8; \
467+
offset = (key * 8) % 64; \
455468
if (lid == (hlid) && lt == (hlt)) { \
456469
if ((hstart) >= hdr && \
457470
((hstart) + (hlen)) <= (hdr + nr_bytes)) { \
458471
bit_offset = (hdr + nr_bytes - (hstart) - (hlen)) * 8; \
459472
npc_set_layer_mdata(mcam, (name), cfg, lid, lt, intf); \
473+
offset += bit_offset; \
474+
start_kwi += offset / 64; \
475+
offset %= 64; \
460476
npc_set_kw_masks(mcam, (name), (hlen) * 8, \
461-
start_kwi, offset + bit_offset, intf);\
477+
start_kwi, offset, intf); \
462478
} \
463479
} \
464480
} while (0)
@@ -650,9 +666,9 @@ static int npc_check_unsupported_flows(struct rvu *rvu, u64 features, u8 intf)
650666

651667
unsupported = (*mcam_features ^ features) & ~(*mcam_features);
652668
if (unsupported) {
653-
dev_info(rvu->dev, "Unsupported flow(s):\n");
669+
dev_warn(rvu->dev, "Unsupported flow(s):\n");
654670
for_each_set_bit(bit, (unsigned long *)&unsupported, 64)
655-
dev_info(rvu->dev, "%s ", npc_get_field_name(bit));
671+
dev_warn(rvu->dev, "%s ", npc_get_field_name(bit));
656672
return -EOPNOTSUPP;
657673
}
658674

@@ -1007,8 +1023,20 @@ static void npc_update_rx_entry(struct rvu *rvu, struct rvu_pfvf *pfvf,
10071023
action.match_id = req->match_id;
10081024
action.flow_key_alg = req->flow_key_alg;
10091025

1010-
if (req->op == NIX_RX_ACTION_DEFAULT && pfvf->def_ucast_rule)
1011-
action = pfvf->def_ucast_rule->rx_action;
1026+
if (req->op == NIX_RX_ACTION_DEFAULT) {
1027+
if (pfvf->def_ucast_rule) {
1028+
action = pfvf->def_ucast_rule->rx_action;
1029+
} else {
1030+
/* For profiles which do not extract DMAC, the default
1031+
* unicast entry is unused. Hence modify action for the
1032+
* requests which use same action as default unicast
1033+
* entry
1034+
*/
1035+
*(u64 *)&action = 0;
1036+
action.pf_func = target;
1037+
action.op = NIX_RX_ACTIONOP_UCAST;
1038+
}
1039+
}
10121040

10131041
entry->action = *(u64 *)&action;
10141042

@@ -1239,18 +1267,19 @@ int rvu_mbox_handler_npc_install_flow(struct rvu *rvu,
12391267
if (npc_check_field(rvu, blkaddr, NPC_DMAC, req->intf))
12401268
goto process_flow;
12411269

1242-
if (is_pffunc_af(req->hdr.pcifunc)) {
1270+
if (is_pffunc_af(req->hdr.pcifunc) &&
1271+
req->features & BIT_ULL(NPC_DMAC)) {
12431272
if (is_unicast_ether_addr(req->packet.dmac)) {
1244-
dev_err(rvu->dev,
1245-
"%s: mkex profile does not support ucast flow\n",
1246-
__func__);
1273+
dev_warn(rvu->dev,
1274+
"%s: mkex profile does not support ucast flow\n",
1275+
__func__);
12471276
return NPC_FLOW_NOT_SUPPORTED;
12481277
}
12491278

12501279
if (!npc_is_field_present(rvu, NPC_LXMB, req->intf)) {
1251-
dev_err(rvu->dev,
1252-
"%s: mkex profile does not support bcast/mcast flow",
1253-
__func__);
1280+
dev_warn(rvu->dev,
1281+
"%s: mkex profile does not support bcast/mcast flow",
1282+
__func__);
12541283
return NPC_FLOW_NOT_SUPPORTED;
12551284
}
12561285

@@ -1603,3 +1632,22 @@ int npc_install_mcam_drop_rule(struct rvu *rvu, int mcam_idx, u16 *counter_idx,
16031632

16041633
return 0;
16051634
}
1635+
1636+
int rvu_mbox_handler_npc_get_field_status(struct rvu *rvu,
1637+
struct npc_get_field_status_req *req,
1638+
struct npc_get_field_status_rsp *rsp)
1639+
{
1640+
int blkaddr;
1641+
1642+
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NPC, 0);
1643+
if (blkaddr < 0)
1644+
return NPC_MCAM_INVALID_REQ;
1645+
1646+
if (!is_npc_interface_valid(rvu, req->intf))
1647+
return NPC_FLOW_INTF_INVALID;
1648+
1649+
if (npc_check_field(rvu, blkaddr, req->field, req->intf))
1650+
rsp->enable = 1;
1651+
1652+
return 0;
1653+
}

drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ EXPORT_SYMBOL(otx2_alloc_mcam_entries);
164164
static int otx2_mcam_entry_init(struct otx2_nic *pfvf)
165165
{
166166
struct otx2_flow_config *flow_cfg = pfvf->flow_cfg;
167+
struct npc_get_field_status_req *freq;
168+
struct npc_get_field_status_rsp *frsp;
167169
struct npc_mcam_alloc_entry_req *req;
168170
struct npc_mcam_alloc_entry_rsp *rsp;
169171
int vf_vlan_max_flows;
@@ -214,8 +216,29 @@ static int otx2_mcam_entry_init(struct otx2_nic *pfvf)
214216
flow_cfg->rx_vlan_offset = flow_cfg->unicast_offset +
215217
OTX2_MAX_UNICAST_FLOWS;
216218
pfvf->flags |= OTX2_FLAG_UCAST_FLTR_SUPPORT;
217-
pfvf->flags |= OTX2_FLAG_RX_VLAN_SUPPORT;
218-
pfvf->flags |= OTX2_FLAG_VF_VLAN_SUPPORT;
219+
220+
/* Check if NPC_DMAC field is supported
221+
* by the mkex profile before setting VLAN support flag.
222+
*/
223+
freq = otx2_mbox_alloc_msg_npc_get_field_status(&pfvf->mbox);
224+
if (!freq) {
225+
mutex_unlock(&pfvf->mbox.lock);
226+
return -ENOMEM;
227+
}
228+
229+
freq->field = NPC_DMAC;
230+
if (otx2_sync_mbox_msg(&pfvf->mbox)) {
231+
mutex_unlock(&pfvf->mbox.lock);
232+
return -EINVAL;
233+
}
234+
235+
frsp = (struct npc_get_field_status_rsp *)otx2_mbox_get_rsp
236+
(&pfvf->mbox.mbox, 0, &freq->hdr);
237+
238+
if (frsp->enable) {
239+
pfvf->flags |= OTX2_FLAG_RX_VLAN_SUPPORT;
240+
pfvf->flags |= OTX2_FLAG_VF_VLAN_SUPPORT;
241+
}
219242

220243
pfvf->flags |= OTX2_FLAG_MCAM_ENTRIES_ALLOC;
221244
mutex_unlock(&pfvf->mbox.lock);

0 commit comments

Comments
 (0)