Enable support for adding TC rules that filter on the inner
EtherType field of tunneled packet headers.

Signed-off-by: Martyna Szapar-Mudlaw <martyna.szapar-mud...@intel.com>
Signed-off-by: Qiming Yang <qiming.y...@intel.com>
---
 drivers/net/ice/base/ice_protocol_type.h |   2 +
 drivers/net/ice/base/ice_switch.c        | 270 ++++++++++++++++++++++-
 2 files changed, 268 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ice/base/ice_protocol_type.h 
b/drivers/net/ice/base/ice_protocol_type.h
index eeaf044059..8c57cd2081 100644
--- a/drivers/net/ice/base/ice_protocol_type.h
+++ b/drivers/net/ice/base/ice_protocol_type.h
@@ -31,6 +31,7 @@ enum ice_protocol_type {
        ICE_MAC_OFOS = 0,
        ICE_MAC_IL,
        ICE_ETYPE_OL,
+       ICE_ETYPE_IL,
        ICE_VLAN_OFOS,
        ICE_IPV4_OFOS,
        ICE_IPV4_IL,
@@ -197,6 +198,7 @@ enum ice_prot_id {
 #define ICE_MAC_OFOS_HW                1
 #define ICE_MAC_IL_HW          4
 #define ICE_ETYPE_OL_HW                9
+#define ICE_ETYPE_IL_HW                10
 #define ICE_VLAN_OF_HW         16
 #define ICE_VLAN_OL_HW         17
 #define ICE_IPV4_OFOS_HW       32
diff --git a/drivers/net/ice/base/ice_switch.c 
b/drivers/net/ice/base/ice_switch.c
index f201c287fc..a9f3ae5bf5 100644
--- a/drivers/net/ice/base/ice_switch.c
+++ b/drivers/net/ice/base/ice_switch.c
@@ -49,6 +49,7 @@ static const struct ice_dummy_pkt_offsets 
dummy_gre_tcp_packet_offsets[] = {
        { ICE_IPV4_OFOS,        14 },
        { ICE_NVGRE,            34 },
        { ICE_MAC_IL,           42 },
+       { ICE_ETYPE_IL,         54 },
        { ICE_IPV4_IL,          56 },
        { ICE_TCP_IL,           76 },
        { ICE_PROTOCOL_LAST,    0 },
@@ -73,7 +74,8 @@ static const u8 dummy_gre_tcp_packet[] = {
        0x00, 0x00, 0x00, 0x00, /* ICE_MAC_IL 42 */
        0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00,
-       0x08, 0x00,
+
+       0x08, 0x00,             /* ICE_ETYPE_IL 54 */
 
        0x45, 0x00, 0x00, 0x14, /* ICE_IPV4_IL 56 */
        0x00, 0x00, 0x00, 0x00,
@@ -94,6 +96,7 @@ static const struct ice_dummy_pkt_offsets 
dummy_gre_udp_packet_offsets[] = {
        { ICE_IPV4_OFOS,        14 },
        { ICE_NVGRE,            34 },
        { ICE_MAC_IL,           42 },
+       { ICE_ETYPE_IL,         54 },
        { ICE_IPV4_IL,          56 },
        { ICE_UDP_ILOS,         76 },
        { ICE_PROTOCOL_LAST,    0 },
@@ -118,7 +121,8 @@ static const u8 dummy_gre_udp_packet[] = {
        0x00, 0x00, 0x00, 0x00, /* ICE_MAC_IL 42 */
        0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00,
-       0x08, 0x00,
+
+       0x08, 0x00,             /* ICE_ETYPE_IL 54 */
 
        0x45, 0x00, 0x00, 0x14, /* ICE_IPV4_IL 56 */
        0x00, 0x00, 0x00, 0x00,
@@ -139,6 +143,7 @@ static const struct ice_dummy_pkt_offsets 
dummy_udp_tun_tcp_packet_offsets[] = {
        { ICE_GENEVE,           42 },
        { ICE_VXLAN_GPE,        42 },
        { ICE_MAC_IL,           50 },
+       { ICE_ETYPE_IL,         62 },
        { ICE_IPV4_IL,          64 },
        { ICE_TCP_IL,           84 },
        { ICE_PROTOCOL_LAST,    0 },
@@ -166,7 +171,8 @@ static const u8 dummy_udp_tun_tcp_packet[] = {
        0x00, 0x00, 0x00, 0x00, /* ICE_MAC_IL 50 */
        0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00,
-       0x08, 0x00,
+
+       0x08, 0x00,             /* ICE_ETYPE_IL 62*/
 
        0x45, 0x00, 0x00, 0x28, /* ICE_IPV4_IL 64 */
        0x00, 0x01, 0x00, 0x00,
@@ -190,6 +196,7 @@ static const struct ice_dummy_pkt_offsets 
dummy_udp_tun_udp_packet_offsets[] = {
        { ICE_GENEVE,           42 },
        { ICE_VXLAN_GPE,        42 },
        { ICE_MAC_IL,           50 },
+       { ICE_ETYPE_IL,         62 },
        { ICE_IPV4_IL,          64 },
        { ICE_UDP_ILOS,         84 },
        { ICE_PROTOCOL_LAST,    0 },
@@ -217,7 +224,8 @@ static const u8 dummy_udp_tun_udp_packet[] = {
        0x00, 0x00, 0x00, 0x00, /* ICE_MAC_IL 50 */
        0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00,
-       0x08, 0x00,
+
+       0x08, 0x00,             /* ICE_ETYPE_IL 62 */
 
        0x45, 0x00, 0x00, 0x1c, /* ICE_IPV4_IL 64 */
        0x00, 0x01, 0x00, 0x00,
@@ -229,6 +237,224 @@ static const u8 dummy_udp_tun_udp_packet[] = {
        0x00, 0x08, 0x00, 0x00,
 };
 
+static const struct ice_dummy_pkt_offsets
+dummy_gre_ipv6_tcp_packet_offsets[] = {
+       { ICE_MAC_OFOS,         0 },
+       { ICE_ETYPE_OL,         12 },
+       { ICE_IPV4_OFOS,        14 },
+       { ICE_NVGRE,            34 },
+       { ICE_MAC_IL,           42 },
+       { ICE_ETYPE_IL,         54 },
+       { ICE_IPV6_IL,          56 },
+       { ICE_TCP_IL,           96 },
+       { ICE_PROTOCOL_LAST,    0 },
+};
+
+static const u8 dummy_gre_ipv6_tcp_packet[] = {
+       0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x08, 0x00,             /* ICE_ETYPE_OL 12 */
+
+       0x45, 0x00, 0x00, 0x66, /* ICE_IPV4_OFOS 14 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x2F, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x80, 0x00, 0x65, 0x58, /* ICE_NVGRE 34 */
+       0x00, 0x00, 0x00, 0x00,
+
+       0x00, 0x00, 0x00, 0x00, /* ICE_MAC_IL 42 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x86, 0xdd,             /* ICE_ETYPE_IL 54 */
+
+       0x60, 0x00, 0x00, 0x00, /* ICE_IPV6_IL 56 */
+       0x00, 0x08, 0x06, 0x40,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x00, 0x00, 0x00, 0x00, /* ICE_TCP_IL 96 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x50, 0x02, 0x20, 0x00,
+       0x00, 0x00, 0x00, 0x00
+};
+
+static const struct ice_dummy_pkt_offsets
+dummy_gre_ipv6_udp_packet_offsets[] = {
+       { ICE_MAC_OFOS,         0 },
+       { ICE_ETYPE_OL,         12 },
+       { ICE_IPV4_OFOS,        14 },
+       { ICE_NVGRE,            34 },
+       { ICE_MAC_IL,           42 },
+       { ICE_ETYPE_IL,         54 },
+       { ICE_IPV6_IL,          56 },
+       { ICE_UDP_ILOS,         96 },
+       { ICE_PROTOCOL_LAST,    0 },
+};
+
+static const u8 dummy_gre_ipv6_udp_packet[] = {
+       0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x08, 0x00,             /* ICE_ETYPE_OL 12 */
+
+       0x45, 0x00, 0x00, 0x5a, /* ICE_IPV4_OFOS 14 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x2F, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x80, 0x00, 0x65, 0x58, /* ICE_NVGRE 34 */
+       0x00, 0x00, 0x00, 0x00,
+
+       0x00, 0x00, 0x00, 0x00, /* ICE_MAC_IL 42 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x86, 0xdd,             /* ICE_ETYPE_IL 54 */
+
+       0x60, 0x00, 0x00, 0x00, /* ICE_IPV6_IL 56 */
+       0x00, 0x08, 0x11, 0x40,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x00, 0x00, 0x00, 0x00, /* ICE_UDP_ILOS 96 */
+       0x00, 0x08, 0x00, 0x00,
+};
+
+static const struct ice_dummy_pkt_offsets
+dummy_udp_tun_ipv6_tcp_packet_offsets[] = {
+       { ICE_MAC_OFOS,         0 },
+       { ICE_ETYPE_OL,         12 },
+       { ICE_IPV4_OFOS,        14 },
+       { ICE_UDP_OF,           34 },
+       { ICE_VXLAN,            42 },
+       { ICE_GENEVE,           42 },
+       { ICE_VXLAN_GPE,        42 },
+       { ICE_MAC_IL,           50 },
+       { ICE_ETYPE_IL,         62 },
+       { ICE_IPV6_IL,          64 },
+       { ICE_TCP_IL,           104 },
+       { ICE_PROTOCOL_LAST,    0 },
+};
+
+static const u8 dummy_udp_tun_ipv6_tcp_packet[] = {
+       0x00, 0x00, 0x00, 0x00,  /* ICE_MAC_OFOS 0 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x08, 0x00,             /* ICE_ETYPE_OL 12 */
+
+       0x45, 0x00, 0x00, 0x6e, /* ICE_IPV4_OFOS 14 */
+       0x00, 0x01, 0x00, 0x00,
+       0x40, 0x11, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x00, 0x00, 0x12, 0xb5, /* ICE_UDP_OF 34 */
+       0x00, 0x5a, 0x00, 0x00,
+
+       0x00, 0x00, 0x65, 0x58, /* ICE_VXLAN 42 */
+       0x00, 0x00, 0x00, 0x00,
+
+       0x00, 0x00, 0x00, 0x00, /* ICE_MAC_IL 50 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x86, 0xdd,             /* ICE_ETYPE_IL 62 */
+
+       0x60, 0x00, 0x00, 0x00, /* ICE_IPV6_IL 64 */
+       0x00, 0x08, 0x06, 0x40,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x00, 0x00, 0x00, 0x00, /* ICE_TCP_IL 104 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x50, 0x02, 0x20, 0x00,
+       0x00, 0x00, 0x00, 0x00
+};
+
+static const struct ice_dummy_pkt_offsets
+dummy_udp_tun_ipv6_udp_packet_offsets[] = {
+       { ICE_MAC_OFOS,         0 },
+       { ICE_ETYPE_OL,         12 },
+       { ICE_IPV4_OFOS,        14 },
+       { ICE_UDP_OF,           34 },
+       { ICE_VXLAN,            42 },
+       { ICE_GENEVE,           42 },
+       { ICE_VXLAN_GPE,        42 },
+       { ICE_MAC_IL,           50 },
+       { ICE_ETYPE_IL,         62 },
+       { ICE_IPV6_IL,          64 },
+       { ICE_UDP_ILOS,         104 },
+       { ICE_PROTOCOL_LAST,    0 },
+};
+
+static const u8 dummy_udp_tun_ipv6_udp_packet[] = {
+       0x00, 0x00, 0x00, 0x00,  /* ICE_MAC_OFOS 0 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x08, 0x00,             /* ICE_ETYPE_OL 12 */
+
+       0x45, 0x00, 0x00, 0x62, /* ICE_IPV4_OFOS 14 */
+       0x00, 0x01, 0x00, 0x00,
+       0x00, 0x11, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x00, 0x00, 0x12, 0xb5, /* ICE_UDP_OF 34 */
+       0x00, 0x4e, 0x00, 0x00,
+
+       0x00, 0x00, 0x65, 0x58, /* ICE_VXLAN 42 */
+       0x00, 0x00, 0x00, 0x00,
+
+       0x00, 0x00, 0x00, 0x00, /* ICE_MAC_IL 50 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x86, 0xdd,             /* ICE_ETYPE_IL 62 */
+
+       0x60, 0x00, 0x00, 0x00, /* ICE_IPV6_IL 64 */
+       0x00, 0x08, 0x11, 0x40,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x00, 0x00, 0x00, 0x00, /* ICE_UDP_ILOS 104 */
+       0x00, 0x08, 0x00, 0x00,
+};
+
 /* offset info for MAC + IPv4 + UDP dummy packet */
 static const struct ice_dummy_pkt_offsets dummy_udp_packet_offsets[] = {
        { ICE_MAC_OFOS,         0 },
@@ -8065,6 +8291,7 @@ ice_find_dummy_packet(struct ice_adv_lkup_elem *lkups, 
u16 lkups_cnt,
                      const struct ice_dummy_pkt_offsets **offsets)
 {
        bool tcp = false, udp = false, outer_ipv6 = false, vlan = false;
+       bool inner_ipv6 = false;
        bool cvlan = false;
        bool gre = false, mpls = false;
        u16 i;
@@ -8088,6 +8315,12 @@ ice_find_dummy_packet(struct ice_adv_lkup_elem *lkups, 
u16 lkups_cnt,
                         lkups[i].m_u.ethertype.ethtype_id ==
                                CPU_TO_BE16(0xFFFF))
                        outer_ipv6 = true;
+               else if (lkups[i].type == ICE_ETYPE_IL &&
+                        lkups[i].h_u.ethertype.ethtype_id ==
+                               CPU_TO_BE16(ICE_IPV6_ETHER_ID) &&
+                        lkups[i].m_u.ethertype.ethtype_id ==
+                               CPU_TO_BE16(0xFFFF))
+                       inner_ipv6 = true;
                else if (lkups[i].type == ICE_IPV4_OFOS &&
                         lkups[i].h_u.ipv4_hdr.protocol ==
                                ICE_IPV4_NVGRE_PROTO_ID &&
@@ -8441,6 +8674,13 @@ ice_find_dummy_packet(struct ice_adv_lkup_elem *lkups, 
u16 lkups_cnt,
        }
 
        if (tun_type == ICE_SW_TUN_NVGRE || gre) {
+               if (tcp && inner_ipv6) {
+                       *pkt = dummy_gre_ipv6_tcp_packet;
+                       *pkt_len = sizeof(dummy_gre_ipv6_tcp_packet);
+                       *offsets = dummy_gre_ipv6_tcp_packet_offsets;
+                       return;
+               }
+
                if (tcp) {
                        *pkt = dummy_gre_tcp_packet;
                        *pkt_len = sizeof(dummy_gre_tcp_packet);
@@ -8448,6 +8688,13 @@ ice_find_dummy_packet(struct ice_adv_lkup_elem *lkups, 
u16 lkups_cnt,
                        return;
                }
 
+               if (inner_ipv6) {
+                       *pkt = dummy_gre_ipv6_udp_packet;
+                       *pkt_len = sizeof(dummy_gre_ipv6_udp_packet);
+                       *offsets = dummy_gre_ipv6_udp_packet_offsets;
+                       return;
+               }
+
                *pkt = dummy_gre_udp_packet;
                *pkt_len = sizeof(dummy_gre_udp_packet);
                *offsets = dummy_gre_udp_packet_offsets;
@@ -8458,6 +8705,13 @@ ice_find_dummy_packet(struct ice_adv_lkup_elem *lkups, 
u16 lkups_cnt,
            tun_type == ICE_SW_TUN_VXLAN_GPE || tun_type == ICE_SW_TUN_UDP ||
            tun_type == ICE_SW_TUN_GENEVE_VLAN ||
            tun_type == ICE_SW_TUN_VXLAN_VLAN) {
+               if (tcp && inner_ipv6) {
+                       *pkt = dummy_udp_tun_ipv6_tcp_packet;
+                       *pkt_len = sizeof(dummy_udp_tun_ipv6_tcp_packet);
+                       *offsets = dummy_udp_tun_ipv6_tcp_packet_offsets;
+                       return;
+               }
+
                if (tcp) {
                        *pkt = dummy_udp_tun_tcp_packet;
                        *pkt_len = sizeof(dummy_udp_tun_tcp_packet);
@@ -8465,6 +8719,13 @@ ice_find_dummy_packet(struct ice_adv_lkup_elem *lkups, 
u16 lkups_cnt,
                        return;
                }
 
+               if (inner_ipv6) {
+                       *pkt = dummy_udp_tun_ipv6_udp_packet;
+                       *pkt_len = sizeof(dummy_udp_tun_ipv6_udp_packet);
+                       *offsets = dummy_udp_tun_ipv6_udp_packet_offsets;
+                       return;
+               }
+
                *pkt = dummy_udp_tun_udp_packet;
                *pkt_len = sizeof(dummy_udp_tun_udp_packet);
                *offsets = dummy_udp_tun_udp_packet_offsets;
@@ -8574,6 +8835,7 @@ ice_fill_adv_dummy_packet(struct ice_adv_lkup_elem 
*lkups, u16 lkups_cnt,
                        len = sizeof(struct ice_ether_hdr);
                        break;
                case ICE_ETYPE_OL:
+               case ICE_ETYPE_IL:
                        len = sizeof(struct ice_ethtype_hdr);
                        break;
                case ICE_VLAN_OFOS:
-- 
2.25.1

Reply via email to