From: Alvin Zhang <alvinx.zh...@intel.com>

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

Signed-off-by: Junfeng Guo <junfeng....@intel.com>
Signed-off-by: Alvin Zhang <alvinx.zh...@intel.com>
Signed-off-by: Kevin Liu <kevinx....@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(-)

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;
-- 
2.33.1

Reply via email to