Skip to contentSkip to conversation

octeontx2-af: Tc flower offload support for inner VLAN

PATCH Superseded Suman Ghosh 2 participants 3 messages Jul 25, 2023 – Jul 27, 2023

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 octeontx2-af: Tc flower offload support for inner VLAN

This patch extends current TC flower offload support to allow filters involving inner VLAN matching, to be offloaded to HW.

Example command:
tc filter add dev eth2 protocol 802.1AD parent ffff: flower vlan_id 10 vlan_ethtype 802.1Q cvlan_id 20 skip_sw action drop

---
 .../net/ethernet/marvell/octeontx2/af/mbox.h  |   1 +
 .../net/ethernet/marvell/octeontx2/af/npc.h   |   3 +
 .../marvell/octeontx2/af/rvu_debugfs.c        |   5 +
 .../marvell/octeontx2/af/rvu_npc_fs.c         |  13 +++
 .../ethernet/marvell/octeontx2/nic/otx2_tc.c  | 106 +++++++++++-------
 5 files changed, 90 insertions(+), 38 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +1 -0
index ed66c5989102..382764f39702 100644
@@ -1461,6 +1461,7 @@ struct flow_msg {
 		u8 ip_flag;
 		u8 next_header;
 	};
+	__be16 vlan_itci;
 };
 
 struct npc_install_flow_req {
drivers/net/ethernet/marvell/octeontx2/af/npc.h +3 -0
index 9beeead56d7b..5b6a1b941ccc 100644
@@ -184,6 +184,7 @@ enum key_fields {
 	NPC_VLAN_ETYPE_CTAG, /* 0x8100 */
 	NPC_VLAN_ETYPE_STAG, /* 0x88A8 */
 	NPC_OUTER_VID,
+	NPC_INNER_VID,
 	NPC_TOS,
 	NPC_IPFRAG_IPV4,
 	NPC_SIP_IPV4,
@@ -229,6 +230,8 @@ enum key_fields {
 	NPC_VLAN_TAG1,
 	/* outer vlan tci for double tagged frame */
 	NPC_VLAN_TAG2,
+	/* inner vlan tci for double tagged frame */
+	NPC_VLAN_TAG3,
 	/* other header fields programmed to extract but not of our interest */
 	NPC_UNKNOWN,
 	NPC_KEY_FIELDS_MAX,
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +5 -0
index 3b26893efdf8..3d0825c0685a 100644
@@ -2787,6 +2787,11 @@ static void rvu_dbg_npc_mcam_show_flows(struct seq_file *s,
 			seq_printf(s, "mask 0x%x\n",
 				   ntohs(rule->mask.vlan_tci));
 			break;
+		case NPC_INNER_VID:
+			seq_printf(s, "0x%x ", ntohs(rule->packet.vlan_itci));
+			seq_printf(s, "mask 0x%x\n",
+				   ntohs(rule->mask.vlan_itci));
+			break;
 		case NPC_TOS:
 			seq_printf(s, "%d ", rule->packet.tos);
 			seq_printf(s, "mask 0x%x\n", rule->mask.tos);
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +13 -0
index 9c365cc3e736..f2a7599aa9de 100644
@@ -20,6 +20,7 @@ static const char * const npc_flow_names[] = {
 	[NPC_VLAN_ETYPE_CTAG] = "vlan ether type ctag",
 	[NPC_VLAN_ETYPE_STAG] = "vlan ether type stag",
 	[NPC_OUTER_VID]	= "outer vlan id",
+	[NPC_INNER_VID]	= "inner vlan id",
 	[NPC_TOS]	= "tos",
 	[NPC_IPFRAG_IPV4] = "fragmented IPv4 header ",
 	[NPC_SIP_IPV4]	= "ipv4 source ip",
@@ -327,6 +328,8 @@ static void npc_handle_multi_layer_fields(struct rvu *rvu, int blkaddr, u8 intf)
 	 */
 	struct npc_key_field *vlan_tag1;
 	struct npc_key_field *vlan_tag2;
+	/* Inner VLAN TCI for double tagged frames */
+	struct npc_key_field *vlan_tag3;
 	u64 *features;
 	u8 start_lid;
 	int i;
@@ -349,6 +352,7 @@ static void npc_handle_multi_layer_fields(struct rvu *rvu, int blkaddr, u8 intf)
 	etype_tag2 = &key_fields[NPC_ETYPE_TAG2];
 	vlan_tag1 = &key_fields[NPC_VLAN_TAG1];
 	vlan_tag2 = &key_fields[NPC_VLAN_TAG2];
+	vlan_tag3 = &key_fields[NPC_VLAN_TAG3];
 
 	/* if key profile programmed does not extract Ethertype at all */
 	if (!etype_ether->nr_kws && !etype_tag1->nr_kws && !etype_tag2->nr_kws) {
@@ -430,6 +434,12 @@ static void npc_handle_multi_layer_fields(struct rvu *rvu, int blkaddr, u8 intf)
 		goto done;
 	}
 	*features |= BIT_ULL(NPC_OUTER_VID);
+
+	/* If key profile extracts inner vlan tci */
+	if (vlan_tag3->nr_kws) {
+		key_fields[NPC_INNER_VID] = *vlan_tag3;
+		*features |= BIT_ULL(NPC_INNER_VID);
+	}
 done:
 	return;
 }
@@ -512,6 +522,7 @@ do {									       \
 	NPC_SCAN_HDR(NPC_ETYPE_TAG2, NPC_LID_LB, NPC_LT_LB_STAG_QINQ, 8, 2);
 	NPC_SCAN_HDR(NPC_VLAN_TAG1, NPC_LID_LB, NPC_LT_LB_CTAG, 2, 2);
 	NPC_SCAN_HDR(NPC_VLAN_TAG2, NPC_LID_LB, NPC_LT_LB_STAG_QINQ, 2, 2);
+	NPC_SCAN_HDR(NPC_VLAN_TAG3, NPC_LID_LB, NPC_LT_LB_STAG_QINQ, 6, 2);
 	NPC_SCAN_HDR(NPC_DMAC, NPC_LID_LA, la_ltype, la_start, 6);
 	/* SMAC follows the DMAC(which is 6 bytes) */
 	NPC_SCAN_HDR(NPC_SMAC, NPC_LID_LA, la_ltype, la_start + 6, 6);
@@ -932,6 +943,8 @@ do {									      \
 
 	NPC_WRITE_FLOW(NPC_OUTER_VID, vlan_tci, ntohs(pkt->vlan_tci), 0,
 		       ntohs(mask->vlan_tci), 0);
+	NPC_WRITE_FLOW(NPC_INNER_VID, vlan_itci, ntohs(pkt->vlan_itci), 0,
+		       ntohs(mask->vlan_itci), 0);
 
 	NPC_WRITE_FLOW(NPC_IPFRAG_IPV6, next_header, pkt->next_header, 0,
 		       mask->next_header, 0);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c +68 -38

127 lines not on this page · raw message

Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Suman Ghosh

This patch extends current TC flower offload support to allow filters involving inner VLAN matching, to be offloaded to HW.

Example command:
tc filter add dev eth2 protocol 802.1AD parent ffff: flower vlan_id 10 vlan_ethtype 802.1Q cvlan_id 20 skip_sw action drop

---
 .../net/ethernet/marvell/octeontx2/af/mbox.h  |   1 +
 .../net/ethernet/marvell/octeontx2/af/npc.h   |   3 +
 .../marvell/octeontx2/af/rvu_debugfs.c        |   5 +
 .../marvell/octeontx2/af/rvu_npc_fs.c         |  13 +++
 .../ethernet/marvell/octeontx2/nic/otx2_tc.c  | 106 +++++++++++-------
 5 files changed, 90 insertions(+), 38 deletions(-)

<...>

Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c +4 -0
+	if (!is_inner)
+		flow_rule_match_vlan(rule, &match);
+	else
+		flow_rule_match_cvlan(rule, &match);

<...>

drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c static int otx2_tc_parse_actions(struct otx2_nic *nic, · line 493

Quoted 9 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c +9 -0
+		if (!is_inner) {
+			flow_spec->vlan_tci = htons(vlan_tci);
+			flow_mask->vlan_tci = htons(vlan_tci_mask);
+			req->features |= BIT_ULL(NPC_OUTER_VID);
+		} else {
+			flow_spec->vlan_itci = htons(vlan_tci);
+			flow_mask->vlan_itci = htons(vlan_tci_mask);
+			req->features |= BIT_ULL(NPC_INNER_VID);
+		}

Slightly better approach will be to reverse these checks from "if (!is_inner)" to be "f (is_inner)".

Other than that,

#2 lore raw
Quoted 39 lines
Quoted 16 lines

This patch extends current TC flower offload support to allow filters involving inner VLAN matching, to be offloaded to HW.

Example command:
tc filter add dev eth2 protocol 802.1AD parent ffff: flower vlan_id 10 vlan_ethtype 802.1Q cvlan_id 20 skip_sw action drop

---
 .../net/ethernet/marvell/octeontx2/af/mbox.h  |   1 +
 .../net/ethernet/marvell/octeontx2/af/npc.h   |   3 +
 .../marvell/octeontx2/af/rvu_debugfs.c        |   5 +
 .../marvell/octeontx2/af/rvu_npc_fs.c         |  13 +++
 .../ethernet/marvell/octeontx2/nic/otx2_tc.c  | 106
+++++++++++-------
 5 files changed, 90 insertions(+), 38 deletions(-)

<...>

Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c +4 -0
+	if (!is_inner)
+		flow_rule_match_vlan(rule, &match);
+	else
+		flow_rule_match_cvlan(rule, &match);

<...>

drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c static int otx2_tc_parse_actions(struct otx2_nic *nic, · line 493

Quoted 9 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c +9 -0
+		if (!is_inner) {
+			flow_spec->vlan_tci = htons(vlan_tci);
+			flow_mask->vlan_tci = htons(vlan_tci_mask);
+			req->features |= BIT_ULL(NPC_OUTER_VID);
+		} else {
+			flow_spec->vlan_itci = htons(vlan_tci);
+			flow_mask->vlan_itci = htons(vlan_tci_mask);
+			req->features |= BIT_ULL(NPC_INNER_VID);
+		}

Slightly better approach will be to reverse these checks from "if (!is_inner)" to be "f (is_inner)".

Quoted 1 line

Other than that,

[Suman] Sure Leon. Will push a v2 addressing the same.

Quoted 1 line