Skip to content

Commit 28e6a60

Browse files
committed
Merge branch 'octeontx2-af-tc-flower-offload-changes'
Suman Ghosh says: ==================== octeontx2-af: TC flower offload changes This patchset includes minor code restructuring related to TC flower offload for outer vlan and adding support for TC inner vlan offload. Patch #1 Code restructure to handle TC flower outer vlan offload Patch #2 Add TC flower offload support for inner vlan ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 6624433 + 21e7483 commit 28e6a60

File tree

5 files changed

+89
-38
lines changed

5 files changed

+89
-38
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,6 +1465,7 @@ struct flow_msg {
14651465
u8 ip_flag;
14661466
u8 next_header;
14671467
};
1468+
__be16 vlan_itci;
14681469
};
14691470

14701471
struct npc_install_flow_req {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ enum key_fields {
184184
NPC_VLAN_ETYPE_CTAG, /* 0x8100 */
185185
NPC_VLAN_ETYPE_STAG, /* 0x88A8 */
186186
NPC_OUTER_VID,
187+
NPC_INNER_VID,
187188
NPC_TOS,
188189
NPC_IPFRAG_IPV4,
189190
NPC_SIP_IPV4,
@@ -230,6 +231,8 @@ enum key_fields {
230231
NPC_VLAN_TAG1,
231232
/* outer vlan tci for double tagged frame */
232233
NPC_VLAN_TAG2,
234+
/* inner vlan tci for double tagged frame */
235+
NPC_VLAN_TAG3,
233236
/* other header fields programmed to extract but not of our interest */
234237
NPC_UNKNOWN,
235238
NPC_KEY_FIELDS_MAX,

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2787,6 +2787,11 @@ static void rvu_dbg_npc_mcam_show_flows(struct seq_file *s,
27872787
seq_printf(s, "mask 0x%x\n",
27882788
ntohs(rule->mask.vlan_tci));
27892789
break;
2790+
case NPC_INNER_VID:
2791+
seq_printf(s, "0x%x ", ntohs(rule->packet.vlan_itci));
2792+
seq_printf(s, "mask 0x%x\n",
2793+
ntohs(rule->mask.vlan_itci));
2794+
break;
27902795
case NPC_TOS:
27912796
seq_printf(s, "%d ", rule->packet.tos);
27922797
seq_printf(s, "mask 0x%x\n", rule->mask.tos);

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ static const char * const npc_flow_names[] = {
2020
[NPC_VLAN_ETYPE_CTAG] = "vlan ether type ctag",
2121
[NPC_VLAN_ETYPE_STAG] = "vlan ether type stag",
2222
[NPC_OUTER_VID] = "outer vlan id",
23+
[NPC_INNER_VID] = "inner vlan id",
2324
[NPC_TOS] = "tos",
2425
[NPC_IPFRAG_IPV4] = "fragmented IPv4 header ",
2526
[NPC_SIP_IPV4] = "ipv4 source ip",
@@ -328,6 +329,8 @@ static void npc_handle_multi_layer_fields(struct rvu *rvu, int blkaddr, u8 intf)
328329
*/
329330
struct npc_key_field *vlan_tag1;
330331
struct npc_key_field *vlan_tag2;
332+
/* Inner VLAN TCI for double tagged frames */
333+
struct npc_key_field *vlan_tag3;
331334
u64 *features;
332335
u8 start_lid;
333336
int i;
@@ -350,6 +353,7 @@ static void npc_handle_multi_layer_fields(struct rvu *rvu, int blkaddr, u8 intf)
350353
etype_tag2 = &key_fields[NPC_ETYPE_TAG2];
351354
vlan_tag1 = &key_fields[NPC_VLAN_TAG1];
352355
vlan_tag2 = &key_fields[NPC_VLAN_TAG2];
356+
vlan_tag3 = &key_fields[NPC_VLAN_TAG3];
353357

354358
/* if key profile programmed does not extract Ethertype at all */
355359
if (!etype_ether->nr_kws && !etype_tag1->nr_kws && !etype_tag2->nr_kws) {
@@ -431,6 +435,12 @@ static void npc_handle_multi_layer_fields(struct rvu *rvu, int blkaddr, u8 intf)
431435
goto done;
432436
}
433437
*features |= BIT_ULL(NPC_OUTER_VID);
438+
439+
/* If key profile extracts inner vlan tci */
440+
if (vlan_tag3->nr_kws) {
441+
key_fields[NPC_INNER_VID] = *vlan_tag3;
442+
*features |= BIT_ULL(NPC_INNER_VID);
443+
}
434444
done:
435445
return;
436446
}
@@ -513,6 +523,7 @@ do { \
513523
NPC_SCAN_HDR(NPC_ETYPE_TAG2, NPC_LID_LB, NPC_LT_LB_STAG_QINQ, 8, 2);
514524
NPC_SCAN_HDR(NPC_VLAN_TAG1, NPC_LID_LB, NPC_LT_LB_CTAG, 2, 2);
515525
NPC_SCAN_HDR(NPC_VLAN_TAG2, NPC_LID_LB, NPC_LT_LB_STAG_QINQ, 2, 2);
526+
NPC_SCAN_HDR(NPC_VLAN_TAG3, NPC_LID_LB, NPC_LT_LB_STAG_QINQ, 6, 2);
516527
NPC_SCAN_HDR(NPC_DMAC, NPC_LID_LA, la_ltype, la_start, 6);
517528

518529
NPC_SCAN_HDR(NPC_IPSEC_SPI, NPC_LID_LD, NPC_LT_LD_AH, 4, 4);
@@ -943,6 +954,8 @@ do { \
943954

944955
NPC_WRITE_FLOW(NPC_OUTER_VID, vlan_tci, ntohs(pkt->vlan_tci), 0,
945956
ntohs(mask->vlan_tci), 0);
957+
NPC_WRITE_FLOW(NPC_INNER_VID, vlan_itci, ntohs(pkt->vlan_itci), 0,
958+
ntohs(mask->vlan_itci), 0);
946959

947960
NPC_WRITE_FLOW(NPC_IPFRAG_IPV6, next_header, pkt->next_header, 0,
948961
mask->next_header, 0);

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

Lines changed: 67 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,62 @@ static int otx2_tc_parse_actions(struct otx2_nic *nic,
439439
return 0;
440440
}
441441

442+
static int otx2_tc_process_vlan(struct otx2_nic *nic, struct flow_msg *flow_spec,
443+
struct flow_msg *flow_mask, struct flow_rule *rule,
444+
struct npc_install_flow_req *req, bool is_inner)
445+
{
446+
struct flow_match_vlan match;
447+
u16 vlan_tci, vlan_tci_mask;
448+
449+
if (is_inner)
450+
flow_rule_match_cvlan(rule, &match);
451+
else
452+
flow_rule_match_vlan(rule, &match);
453+
454+
if (!eth_type_vlan(match.key->vlan_tpid)) {
455+
netdev_err(nic->netdev, "vlan tpid 0x%x not supported\n",
456+
ntohs(match.key->vlan_tpid));
457+
return -EOPNOTSUPP;
458+
}
459+
460+
if (!match.mask->vlan_id) {
461+
struct flow_action_entry *act;
462+
int i;
463+
464+
flow_action_for_each(i, act, &rule->action) {
465+
if (act->id == FLOW_ACTION_DROP) {
466+
netdev_err(nic->netdev,
467+
"vlan tpid 0x%x with vlan_id %d is not supported for DROP rule.\n",
468+
ntohs(match.key->vlan_tpid), match.key->vlan_id);
469+
return -EOPNOTSUPP;
470+
}
471+
}
472+
}
473+
474+
if (match.mask->vlan_id ||
475+
match.mask->vlan_dei ||
476+
match.mask->vlan_priority) {
477+
vlan_tci = match.key->vlan_id |
478+
match.key->vlan_dei << 12 |
479+
match.key->vlan_priority << 13;
480+
481+
vlan_tci_mask = match.mask->vlan_id |
482+
match.mask->vlan_dei << 12 |
483+
match.mask->vlan_priority << 13;
484+
if (is_inner) {
485+
flow_spec->vlan_itci = htons(vlan_tci);
486+
flow_mask->vlan_itci = htons(vlan_tci_mask);
487+
req->features |= BIT_ULL(NPC_INNER_VID);
488+
} else {
489+
flow_spec->vlan_tci = htons(vlan_tci);
490+
flow_mask->vlan_tci = htons(vlan_tci_mask);
491+
req->features |= BIT_ULL(NPC_OUTER_VID);
492+
}
493+
}
494+
495+
return 0;
496+
}
497+
442498
static int otx2_tc_prepare_flow(struct otx2_nic *nic, struct otx2_tc_flow *node,
443499
struct flow_cls_offload *f,
444500
struct npc_install_flow_req *req)
@@ -458,6 +514,7 @@ static int otx2_tc_prepare_flow(struct otx2_nic *nic, struct otx2_tc_flow *node,
458514
BIT_ULL(FLOW_DISSECTOR_KEY_BASIC) |
459515
BIT_ULL(FLOW_DISSECTOR_KEY_ETH_ADDRS) |
460516
BIT_ULL(FLOW_DISSECTOR_KEY_VLAN) |
517+
BIT(FLOW_DISSECTOR_KEY_CVLAN) |
461518
BIT_ULL(FLOW_DISSECTOR_KEY_IPV4_ADDRS) |
462519
BIT_ULL(FLOW_DISSECTOR_KEY_IPV6_ADDRS) |
463520
BIT_ULL(FLOW_DISSECTOR_KEY_PORTS) |
@@ -591,47 +648,19 @@ static int otx2_tc_prepare_flow(struct otx2_nic *nic, struct otx2_tc_flow *node,
591648
}
592649

593650
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_VLAN)) {
594-
struct flow_match_vlan match;
595-
u16 vlan_tci, vlan_tci_mask;
596-
597-
flow_rule_match_vlan(rule, &match);
598-
599-
if (ntohs(match.key->vlan_tpid) != ETH_P_8021Q) {
600-
netdev_err(nic->netdev, "vlan tpid 0x%x not supported\n",
601-
ntohs(match.key->vlan_tpid));
602-
return -EOPNOTSUPP;
603-
}
651+
int ret;
604652

605-
if (!match.mask->vlan_id) {
606-
struct flow_action_entry *act;
607-
int i;
608-
609-
flow_action_for_each(i, act, &rule->action) {
610-
if (act->id == FLOW_ACTION_DROP) {
611-
netdev_err(nic->netdev,
612-
"vlan tpid 0x%x with vlan_id %d is not supported for DROP rule.\n",
613-
ntohs(match.key->vlan_tpid),
614-
match.key->vlan_id);
615-
return -EOPNOTSUPP;
616-
}
617-
}
618-
}
619-
620-
if (match.mask->vlan_id ||
621-
match.mask->vlan_dei ||
622-
match.mask->vlan_priority) {
623-
vlan_tci = match.key->vlan_id |
624-
match.key->vlan_dei << 12 |
625-
match.key->vlan_priority << 13;
653+
ret = otx2_tc_process_vlan(nic, flow_spec, flow_mask, rule, req, false);
654+
if (ret)
655+
return ret;
656+
}
626657

627-
vlan_tci_mask = match.mask->vlan_id |
628-
match.mask->vlan_dei << 12 |
629-
match.mask->vlan_priority << 13;
658+
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_CVLAN)) {
659+
int ret;
630660

631-
flow_spec->vlan_tci = htons(vlan_tci);
632-
flow_mask->vlan_tci = htons(vlan_tci_mask);
633-
req->features |= BIT_ULL(NPC_OUTER_VID);
634-
}
661+
ret = otx2_tc_process_vlan(nic, flow_spec, flow_mask, rule, req, true);
662+
if (ret)
663+
return ret;
635664
}
636665

637666
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IPV4_ADDRS)) {

0 commit comments

Comments
 (0)