[v2,15/33] net/ice/base: support IPv6 GRE UDP pattern

Message ID 20220413160932.2074781-16-kevinx.liu@intel.com (mailing list archive)
State Superseded, archived
Headers
Series support full function of DCF |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Kevin Liu April 13, 2022, 4:09 p.m. UTC
  From: Alvin Zhang <alvinx.zhang@intel.com>

Add supports(trainer packet and it's offsets, definitions,
pattern matching) for IPv6 GRE UDP pattern.

Signed-off-by: Junfeng Guo <junfeng.guo@intel.com>
Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
Signed-off-by: Kevin Liu <kevinx.liu@intel.com>
---
 drivers/net/ice/base/ice_protocol_type.h |  1 +
 drivers/net/ice/base/ice_switch.c        | 43 +++++++++++++++++++++++-
 2 files changed, 43 insertions(+), 1 deletion(-)
  

Patch

diff --git a/drivers/net/ice/base/ice_protocol_type.h b/drivers/net/ice/base/ice_protocol_type.h
index d6332c5690..eec9f27823 100644
--- a/drivers/net/ice/base/ice_protocol_type.h
+++ b/drivers/net/ice/base/ice_protocol_type.h
@@ -44,6 +44,7 @@  enum ice_protocol_type {
 	ICE_GENEVE,
 	ICE_VXLAN_GPE,
 	ICE_NVGRE,
+	ICE_GRE,
 	ICE_GTP,
 	ICE_PPPOE,
 	ICE_PFCP,
diff --git a/drivers/net/ice/base/ice_switch.c b/drivers/net/ice/base/ice_switch.c
index b0c50c8f40..f444a2da07 100644
--- a/drivers/net/ice/base/ice_switch.c
+++ b/drivers/net/ice/base/ice_switch.c
@@ -12,6 +12,7 @@ 
 #define ICE_MAX_VLAN_ID			0xFFF
 #define ICE_IPV6_ETHER_ID		0x86DD
 #define ICE_IPV4_NVGRE_PROTO_ID		0x002F
+#define ICE_IPV6_GRE_PROTO_ID		0x002F
 #define ICE_PPP_IPV6_PROTO_ID		0x0057
 #define ICE_TCP_PROTO_ID		0x06
 #define ICE_GTPU_PROFILE		24
@@ -129,6 +130,34 @@  static const u8 dummy_gre_udp_packet[] = {
 	0x00, 0x08, 0x00, 0x00,
 };
 
+static const struct ice_dummy_pkt_offsets
+dummy_ipv6_gre_udp_packet_offsets[] = {
+	{ ICE_MAC_OFOS,         0 },
+	{ ICE_ETYPE_OL,         12 },
+	{ ICE_IPV6_OFOS,        14 },
+	{ ICE_GRE,              54 },
+	{ ICE_IPV6_IL,          58 },
+	{ ICE_UDP_ILOS,         98 },
+	{ ICE_PROTOCOL_LAST,    0 },
+};
+
+static const u8 dummy_ipv6_gre_udp_packet[] = {
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x86, 0xdd, 0x60, 0x00,
+	0x00, 0x00, 0x00, 0x36, 0x2f, 0x40, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+	0x86, 0xdd, 0x60, 0x00, 0x00, 0x00, 0x00, 0x0a,
+	0x11, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a,
+	0xff, 0xd8, 0x00, 0x00,
+};
+
 static const struct ice_dummy_pkt_offsets dummy_udp_tun_tcp_packet_offsets[] = {
 	{ ICE_MAC_OFOS,		0 },
 	{ ICE_ETYPE_OL,		12 },
@@ -8207,8 +8236,13 @@  ice_find_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt,
 			udp = true;
 		else if (lkups[i].type == ICE_TCP_IL)
 			tcp = true;
-		else if (lkups[i].type == ICE_IPV6_OFOS)
+		else if (lkups[i].type == ICE_IPV6_OFOS) {
 			ipv6 = true;
+			if (lkups[i].h_u.ipv6_hdr.next_hdr ==
+			    ICE_IPV6_GRE_PROTO_ID &&
+			    lkups[i].m_u.ipv6_hdr.next_hdr == 0xFF)
+				gre = true;
+		}
 		else if (lkups[i].type == ICE_VLAN_OFOS)
 			vlan = true;
 		else if (lkups[i].type == ICE_ETYPE_OL &&
@@ -8568,6 +8602,13 @@  ice_find_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt,
 		return;
 	}
 
+	if (ipv6 && gre) {
+		*pkt = dummy_ipv6_gre_udp_packet;
+		*pkt_len = sizeof(dummy_ipv6_gre_udp_packet);
+		*offsets = dummy_ipv6_gre_udp_packet_offsets;
+		return;
+	}
+
 	if (tun_type == ICE_SW_TUN_NVGRE || gre) {
 		if (tcp) {
 			*pkt = dummy_gre_tcp_packet;