net/ice/base: support tunnel packets
authorQi Zhang <qi.z.zhang@intel.com>
Mon, 23 Sep 2019 07:44:20 +0000 (15:44 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 7 Oct 2019 13:00:55 +0000 (15:00 +0200)
Add VXLAN tunnel training packets to flow director and change the
interface to support tunnel packets.

Signed-off-by: Henry Tieman <henry.w.tieman@intel.com>
Signed-off-by: Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Qiming Yang <qiming.yang@intel.com>
drivers/net/ice/base/ice_fdir.c
drivers/net/ice/base/ice_fdir.h
drivers/net/ice/base/ice_type.h

index 9ef91b3..b92603e 100644 (file)
@@ -5,7 +5,7 @@
 #include "ice_common.h"
 #include "ice_fdir.h"
 
-/* These are dummy packet headers used to program flow director filters. */
+/* These are training packet headers used to program flow director filters. */
 static const u8 ice_fdir_tcpv4_pkt[] = {
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
@@ -88,47 +88,177 @@ static const u8 ice_fdir_ipv6_pkt[] = {
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 };
 
-/* Flow Director dummy packet table */
+static const u8 ice_fdir_tcp4_tun_pkt[] = {
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
+       0x00, 0x5a, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
+       0x45, 0x00, 0x00, 0x28, 0x00, 0x00, 0x40, 0x00,
+       0x40, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x50, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+static const u8 ice_fdir_udp4_tun_pkt[] = {
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
+       0x00, 0x4e, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
+       0x45, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x40, 0x00,
+       0x40, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+};
+
+static const u8 ice_fdir_sctp4_tun_pkt[] = {
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
+       0x00, 0x52, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
+       0x45, 0x00, 0x00, 0x20, 0x00, 0x01, 0x00, 0x00,
+       0x40, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+static const u8 ice_fdir_ip4_tun_pkt[] = {
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
+       0x00, 0x46, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
+       0x45, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00,
+       0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+};
+
+static const u8 ice_fdir_tcp6_tun_pkt[] = {
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
+       0x00, 0x6e, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0xdd,
+       0x60, 0x00, 0x00, 0x00, 0x00, 0x14, 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, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x20, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+};
+
+static const u8 ice_fdir_udp6_tun_pkt[] = {
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
+       0x00, 0x62, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0xdd,
+       0x60, 0x00, 0x00, 0x00, 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, 0x00, 0x00, 0x00, 0x00,
+};
+
+static const u8 ice_fdir_sctp6_tun_pkt[] = {
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
+       0x00, 0x66, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0xdd,
+       0x60, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x84, 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, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+};
+
+static const u8 ice_fdir_ip6_tun_pkt[] = {
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
+       0x00, 0x5a, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0xdd,
+       0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b, 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,
+};
+
+/* Flow Director no-op training packet table */
 static const struct ice_fdir_base_pkt ice_fdir_pkt[] = {
        {
                ICE_FLTR_PTYPE_NONF_IPV4_TCP,
-               sizeof(ice_fdir_tcpv4_pkt),
-               ice_fdir_tcpv4_pkt,
+               sizeof(ice_fdir_tcpv4_pkt), ice_fdir_tcpv4_pkt,
+               sizeof(ice_fdir_tcp4_tun_pkt), ice_fdir_tcp4_tun_pkt,
        },
        {
                ICE_FLTR_PTYPE_NONF_IPV4_UDP,
-               sizeof(ice_fdir_udpv4_pkt),
-               ice_fdir_udpv4_pkt,
+               sizeof(ice_fdir_udpv4_pkt), ice_fdir_udpv4_pkt,
+               sizeof(ice_fdir_udp4_tun_pkt), ice_fdir_udp4_tun_pkt,
        },
        {
                ICE_FLTR_PTYPE_NONF_IPV4_SCTP,
-               sizeof(ice_fdir_sctpv4_pkt),
-               ice_fdir_sctpv4_pkt,
+               sizeof(ice_fdir_sctpv4_pkt), ice_fdir_sctpv4_pkt,
+               sizeof(ice_fdir_sctp4_tun_pkt), ice_fdir_sctp4_tun_pkt,
        },
        {
                ICE_FLTR_PTYPE_NONF_IPV4_OTHER,
-               sizeof(ice_fdir_ipv4_pkt),
-               ice_fdir_ipv4_pkt,
+               sizeof(ice_fdir_ipv4_pkt), ice_fdir_ipv4_pkt,
+               sizeof(ice_fdir_ip4_tun_pkt), ice_fdir_ip4_tun_pkt,
        },
        {
                ICE_FLTR_PTYPE_NONF_IPV6_TCP,
-               sizeof(ice_fdir_tcpv6_pkt),
-               ice_fdir_tcpv6_pkt,
+               sizeof(ice_fdir_tcpv6_pkt), ice_fdir_tcpv6_pkt,
+               sizeof(ice_fdir_tcp6_tun_pkt), ice_fdir_tcp6_tun_pkt,
        },
        {
                ICE_FLTR_PTYPE_NONF_IPV6_UDP,
-               sizeof(ice_fdir_udpv6_pkt),
-               ice_fdir_udpv6_pkt,
+               sizeof(ice_fdir_udpv6_pkt), ice_fdir_udpv6_pkt,
+               sizeof(ice_fdir_udp6_tun_pkt), ice_fdir_udp6_tun_pkt,
        },
        {
                ICE_FLTR_PTYPE_NONF_IPV6_SCTP,
-               sizeof(ice_fdir_sctpv6_pkt),
-               ice_fdir_sctpv6_pkt,
+               sizeof(ice_fdir_sctpv6_pkt), ice_fdir_sctpv6_pkt,
+               sizeof(ice_fdir_sctp6_tun_pkt), ice_fdir_sctp6_tun_pkt,
        },
        {
                ICE_FLTR_PTYPE_NONF_IPV6_OTHER,
-               sizeof(ice_fdir_ipv6_pkt),
-               ice_fdir_ipv6_pkt,
+               sizeof(ice_fdir_ipv6_pkt), ice_fdir_ipv6_pkt,
+               sizeof(ice_fdir_ip6_tun_pkt), ice_fdir_ip6_tun_pkt,
        },
 };
 
@@ -377,15 +507,20 @@ static void ice_pkt_insert_u32(u8 *pkt, int offset, __be32 data)
 }
 
 /**
- * ice_fdir_get_prgm_pkt - generate a dummy packet
+ * ice_fdir_get_gen_prgm_pkt - generate a training packet
+ * @hw: pointer to the hardware structure
  * @input: flow director filter data structure
  * @pkt: pointer to return filter packet
  * @frag: generate a fragment packet
+ * @tun: true implies generate a tunnel packet
  */
 enum ice_status
-ice_fdir_get_prgm_pkt(struct ice_fdir_fltr *input, u8 *pkt, bool frag)
+ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
+                         u8 *pkt, bool frag, bool tun)
 {
        enum ice_fltr_ptype flow;
+       u16 tnl_port;
+       u8 *loc;
        u16 idx;
 
        if (input->flow_type == ICE_FLTR_PTYPE_NONF_IPV4_OTHER) {
@@ -431,83 +566,96 @@ ice_fdir_get_prgm_pkt(struct ice_fdir_fltr *input, u8 *pkt, bool frag)
                        break;
        if (idx == ICE_FDIR_NUM_PKT)
                return ICE_ERR_PARAM;
-       ice_memcpy(pkt, ice_fdir_pkt[idx].pkt, ice_fdir_pkt[idx].pkt_len,
-                  ICE_NONDMA_TO_NONDMA);
+       if (!tun) {
+               ice_memcpy(pkt, ice_fdir_pkt[idx].pkt,
+                          ice_fdir_pkt[idx].pkt_len, ICE_NONDMA_TO_NONDMA);
+               loc = pkt;
+       } else {
+               if (!ice_get_open_tunnel_port(hw, TNL_ALL, &tnl_port))
+                       return ICE_ERR_DOES_NOT_EXIST;
+               if (!ice_fdir_pkt[idx].tun_pkt)
+                       return ICE_ERR_PARAM;
+               ice_memcpy(pkt, ice_fdir_pkt[idx].tun_pkt,
+                          ice_fdir_pkt[idx].tun_pkt_len, ICE_NONDMA_TO_NONDMA);
+               ice_pkt_insert_u16(pkt, ICE_IPV4_UDP_DST_PORT_OFFSET,
+                                  HTONS(tnl_port));
+               loc = &pkt[ICE_FDIR_TUN_PKT_OFF];
+       }
 
        switch (flow) {
        case ICE_FLTR_PTYPE_NONF_IPV4_TCP:
-               ice_pkt_insert_u32(pkt, ICE_IPV4_DST_ADDR_OFFSET,
+               ice_pkt_insert_u32(loc, ICE_IPV4_DST_ADDR_OFFSET,
                                   input->ip.v4.dst_ip);
-               ice_pkt_insert_u16(pkt, ICE_IPV4_TCP_DST_PORT_OFFSET,
+               ice_pkt_insert_u16(loc, ICE_IPV4_TCP_DST_PORT_OFFSET,
                                   input->ip.v4.dst_port);
-               ice_pkt_insert_u32(pkt, ICE_IPV4_SRC_ADDR_OFFSET,
+               ice_pkt_insert_u32(loc, ICE_IPV4_SRC_ADDR_OFFSET,
                                   input->ip.v4.src_ip);
-               ice_pkt_insert_u16(pkt, ICE_IPV4_TCP_SRC_PORT_OFFSET,
+               ice_pkt_insert_u16(loc, ICE_IPV4_TCP_SRC_PORT_OFFSET,
                                   input->ip.v4.src_port);
                if (frag)
-                       pkt[20] = ICE_FDIR_IPV4_PKT_FLAG_DF;
+                       loc[20] = ICE_FDIR_IPV4_PKT_FLAG_DF;
                break;
        case ICE_FLTR_PTYPE_NONF_IPV4_UDP:
-               ice_pkt_insert_u32(pkt, ICE_IPV4_DST_ADDR_OFFSET,
+               ice_pkt_insert_u32(loc, ICE_IPV4_DST_ADDR_OFFSET,
                                   input->ip.v4.dst_ip);
-               ice_pkt_insert_u16(pkt, ICE_IPV4_UDP_DST_PORT_OFFSET,
+               ice_pkt_insert_u16(loc, ICE_IPV4_UDP_DST_PORT_OFFSET,
                                   input->ip.v4.dst_port);
-               ice_pkt_insert_u32(pkt, ICE_IPV4_SRC_ADDR_OFFSET,
+               ice_pkt_insert_u32(loc, ICE_IPV4_SRC_ADDR_OFFSET,
                                   input->ip.v4.src_ip);
-               ice_pkt_insert_u16(pkt, ICE_IPV4_UDP_SRC_PORT_OFFSET,
+               ice_pkt_insert_u16(loc, ICE_IPV4_UDP_SRC_PORT_OFFSET,
                                   input->ip.v4.src_port);
                break;
        case ICE_FLTR_PTYPE_NONF_IPV4_SCTP:
-               ice_pkt_insert_u32(pkt, ICE_IPV4_DST_ADDR_OFFSET,
+               ice_pkt_insert_u32(loc, ICE_IPV4_DST_ADDR_OFFSET,
                                   input->ip.v4.dst_ip);
-               ice_pkt_insert_u16(pkt, ICE_IPV4_SCTP_DST_PORT_OFFSET,
+               ice_pkt_insert_u16(loc, ICE_IPV4_SCTP_DST_PORT_OFFSET,
                                   input->ip.v4.dst_port);
-               ice_pkt_insert_u32(pkt, ICE_IPV4_SRC_ADDR_OFFSET,
+               ice_pkt_insert_u32(loc, ICE_IPV4_SRC_ADDR_OFFSET,
                                   input->ip.v4.src_ip);
-               ice_pkt_insert_u16(pkt, ICE_IPV4_SCTP_SRC_PORT_OFFSET,
+               ice_pkt_insert_u16(loc, ICE_IPV4_SCTP_SRC_PORT_OFFSET,
                                   input->ip.v4.src_port);
                break;
        case ICE_FLTR_PTYPE_NONF_IPV4_OTHER:
-               ice_pkt_insert_u32(pkt, ICE_IPV4_DST_ADDR_OFFSET,
+               ice_pkt_insert_u32(loc, ICE_IPV4_DST_ADDR_OFFSET,
                                   input->ip.v4.dst_ip);
-               ice_pkt_insert_u32(pkt, ICE_IPV4_SRC_ADDR_OFFSET,
+               ice_pkt_insert_u32(loc, ICE_IPV4_SRC_ADDR_OFFSET,
                                   input->ip.v4.src_ip);
-               ice_pkt_insert_u16(pkt, ICE_IPV4_PROTO_OFFSET, 0);
+               ice_pkt_insert_u16(loc, ICE_IPV4_PROTO_OFFSET, 0);
                break;
        case ICE_FLTR_PTYPE_NONF_IPV6_TCP:
-               ice_pkt_insert_ipv6_addr(pkt, ICE_IPV6_DST_ADDR_OFFSET,
+               ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_DST_ADDR_OFFSET,
                                         input->ip.v6.dst_ip);
-               ice_pkt_insert_ipv6_addr(pkt, ICE_IPV6_SRC_ADDR_OFFSET,
+               ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_SRC_ADDR_OFFSET,
                                         input->ip.v6.src_ip);
-               ice_pkt_insert_u16(pkt, ICE_IPV6_TCP_DST_PORT_OFFSET,
+               ice_pkt_insert_u16(loc, ICE_IPV6_TCP_DST_PORT_OFFSET,
                                   input->ip.v6.dst_port);
-               ice_pkt_insert_u16(pkt, ICE_IPV6_TCP_SRC_PORT_OFFSET,
+               ice_pkt_insert_u16(loc, ICE_IPV6_TCP_SRC_PORT_OFFSET,
                                   input->ip.v6.src_port);
                break;
        case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
-               ice_pkt_insert_ipv6_addr(pkt, ICE_IPV6_DST_ADDR_OFFSET,
+               ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_DST_ADDR_OFFSET,
                                         input->ip.v6.dst_ip);
-               ice_pkt_insert_ipv6_addr(pkt, ICE_IPV6_SRC_ADDR_OFFSET,
+               ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_SRC_ADDR_OFFSET,
                                         input->ip.v6.src_ip);
-               ice_pkt_insert_u16(pkt, ICE_IPV6_UDP_DST_PORT_OFFSET,
+               ice_pkt_insert_u16(loc, ICE_IPV6_UDP_DST_PORT_OFFSET,
                                   input->ip.v6.dst_port);
-               ice_pkt_insert_u16(pkt, ICE_IPV6_UDP_SRC_PORT_OFFSET,
+               ice_pkt_insert_u16(loc, ICE_IPV6_UDP_SRC_PORT_OFFSET,
                                   input->ip.v6.src_port);
                break;
        case ICE_FLTR_PTYPE_NONF_IPV6_SCTP:
-               ice_pkt_insert_ipv6_addr(pkt, ICE_IPV6_DST_ADDR_OFFSET,
+               ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_DST_ADDR_OFFSET,
                                         input->ip.v6.dst_ip);
-               ice_pkt_insert_ipv6_addr(pkt, ICE_IPV6_SRC_ADDR_OFFSET,
+               ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_SRC_ADDR_OFFSET,
                                         input->ip.v6.src_ip);
-               ice_pkt_insert_u16(pkt, ICE_IPV6_SCTP_DST_PORT_OFFSET,
+               ice_pkt_insert_u16(loc, ICE_IPV6_SCTP_DST_PORT_OFFSET,
                                   input->ip.v6.dst_port);
-               ice_pkt_insert_u16(pkt, ICE_IPV6_SCTP_SRC_PORT_OFFSET,
+               ice_pkt_insert_u16(loc, ICE_IPV6_SCTP_SRC_PORT_OFFSET,
                                   input->ip.v6.src_port);
                break;
        case ICE_FLTR_PTYPE_NONF_IPV6_OTHER:
-               ice_pkt_insert_ipv6_addr(pkt, ICE_IPV6_DST_ADDR_OFFSET,
+               ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_DST_ADDR_OFFSET,
                                         input->ip.v6.dst_ip);
-               ice_pkt_insert_ipv6_addr(pkt, ICE_IPV6_SRC_ADDR_OFFSET,
+               ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_SRC_ADDR_OFFSET,
                                         input->ip.v6.src_ip);
                break;
        default:
@@ -515,11 +663,23 @@ ice_fdir_get_prgm_pkt(struct ice_fdir_fltr *input, u8 *pkt, bool frag)
        }
 
        if (input->flex_fltr)
-               ice_pkt_insert_u16(pkt, input->flex_offset, input->flex_word);
+               ice_pkt_insert_u16(loc, input->flex_offset, input->flex_word);
 
        return ICE_SUCCESS;
 }
 
+/**
+ * ice_fdir_get_prgm_pkt - generate a training packet
+ * @input: flow director filter data structure
+ * @pkt: pointer to return filter packet
+ * @frag: generate a fragment packet
+ */
+enum ice_status
+ice_fdir_get_prgm_pkt(struct ice_fdir_fltr *input, u8 *pkt, bool frag)
+{
+       return ice_fdir_get_gen_prgm_pkt(NULL, input, pkt, frag, false);
+}
+
 /**
  * ice_fdir_has_frag - does flow type have 2 ptypes
  * @flow: flow ptype
index 8490fac..9e7e220 100644 (file)
@@ -58,7 +58,8 @@ enum ice_status ice_clear_pf_fd_table(struct ice_hw *hw);
 #define ICE_IP_PROTO_IP                        0
 #define ICE_IP_PROTO_ESP               50
 
-#define ICE_FDIR_MAX_RAW_PKT_SIZE      512
+#define ICE_FDIR_TUN_PKT_OFF           50
+#define ICE_FDIR_MAX_RAW_PKT_SIZE      (512 + ICE_FDIR_TUN_PKT_OFF)
 #define ICE_FDIR_BUF_FULL_MARGIN       10
 #define ICE_FDIR_BUF_HEAD_ROOM         32
 
@@ -175,12 +176,17 @@ struct ice_fdir_base_pkt {
        enum ice_fltr_ptype flow;
        u16 pkt_len;
        const u8 *pkt;
+       u16 tun_pkt_len;
+       const u8 *tun_pkt;
 };
 
 void
 ice_fdir_get_prgm_desc(struct ice_hw *hw, struct ice_fdir_fltr *input,
                       struct ice_fltr_desc *fdesc, bool add);
 enum ice_status
+ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
+                         u8 *pkt, bool frag, bool tun);
+enum ice_status
 ice_fdir_get_prgm_pkt(struct ice_fdir_fltr *input, u8 *pkt, bool frag);
 enum ice_status
 ice_add_del_fdir(struct ice_hw *hw, struct ice_fdir_fltr *input, bool add);
index 150b4c5..7d0a4f6 100644 (file)
@@ -296,13 +296,19 @@ enum ice_fltr_ptype {
        ICE_FLTR_PTYPE_MAX,
 };
 
+enum ice_fd_hw_seg {
+       ICE_FD_HW_SEG_NON_TUN = 0,
+       ICE_FD_HW_SEG_TUN,
+       ICE_FD_HW_SEG_MAX,
+};
+
 /* 2 VSI = 1 ICE_VSI_PF + 1 ICE_VSI_CTRL */
 #define ICE_MAX_FDIR_VSI_PER_FILTER    2
 
 struct ice_fd_hw_prof {
-       struct ice_flow_seg_info *fdir_seg;
+       struct ice_flow_seg_info *fdir_seg[ICE_FD_HW_SEG_MAX];
        int cnt;
-       u64 entry_h[ICE_MAX_FDIR_VSI_PER_FILTER];
+       u64 entry_h[ICE_MAX_FDIR_VSI_PER_FILTER][ICE_FD_HW_SEG_MAX];
        u16 vsi_h[ICE_MAX_FDIR_VSI_PER_FILTER];
 };