net/ice/base: support FDIR for L2TPV3 ESP AH and PFCP
authorQi Zhang <qi.z.zhang@intel.com>
Mon, 15 Jun 2020 02:04:39 +0000 (10:04 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 16 Jun 2020 17:21:07 +0000 (19:21 +0200)
FDIR can forward:
- L2TPV3 packets with session id.
- IPSEC ESP packets with security parameter index.
- IPSEC AH packets with security parameter index.
- NAT_T ESP packets with security parameter index.
- PFCP packets with s field value.

Signed-off-by: Yahui Cao <yahui.cao@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 0155597..38aad19 100644 (file)
@@ -102,6 +102,138 @@ static const u8 ice_fdir_ipv4_gtpu4_pkt[] = {
        0x00, 0x00,
 };
 
+static const u8 ice_fdir_ipv4_l2tpv3_pkt[] = {
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
+       0x00, 0x14, 0x00, 0x00, 0x40, 0x00, 0x40, 0x73,
+       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_ipv6_l2tpv3_pkt[] = {
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x86, 0xDD, 0x60, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x73, 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_ipv4_esp_pkt[] = {
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
+       0x00, 0x14, 0x00, 0x00, 0x40, 0x00, 0x40, 0x32,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00
+};
+
+static const u8 ice_fdir_ipv6_esp_pkt[] = {
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x86, 0xDD, 0x60, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x32, 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_ipv4_ah_pkt[] = {
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
+       0x00, 0x14, 0x00, 0x00, 0x40, 0x00, 0x40, 0x33,
+       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_ipv6_ah_pkt[] = {
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x86, 0xDD, 0x60, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x33, 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, 0x00, 0x00, 0x00, 0x00,
+};
+
+static const u8 ice_fdir_ipv4_nat_t_esp_pkt[] = {
+       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, 0x11, 0x94, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00,
+};
+
+static const u8 ice_fdir_ipv6_nat_t_esp_pkt[] = {
+       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,
+       0x11, 0x94, 0x00, 0x00, 0x00, 0x08,
+};
+
+static const u8 ice_fdir_ipv4_pfcp_node_pkt[] = {
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
+       0x00, 0x2C, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x22, 0x65, 0x22, 0x65, 0x00, 0x00,
+       0x00, 0x00, 0x20, 0x00, 0x00, 0x10, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00,
+};
+
+static const u8 ice_fdir_ipv4_pfcp_session_pkt[] = {
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
+       0x00, 0x2C, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x22, 0x65, 0x22, 0x65, 0x00, 0x00,
+       0x00, 0x00, 0x21, 0x00, 0x00, 0x10, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00,
+};
+
+static const u8 ice_fdir_ipv6_pfcp_node_pkt[] = {
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x86, 0xDD, 0x60, 0x00,
+       0x00, 0x00, 0x00, 0x18, 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, 0x22, 0x65,
+       0x22, 0x65, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00,
+       0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+static const u8 ice_fdir_ipv6_pfcp_session_pkt[] = {
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x86, 0xDD, 0x60, 0x00,
+       0x00, 0x00, 0x00, 0x18, 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, 0x22, 0x65,
+       0x22, 0x65, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00,
+       0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
 static const u8 ice_fdir_non_ip_l2_pkt[] = {
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -334,6 +466,78 @@ static const struct ice_fdir_base_pkt ice_fdir_pkt[] = {
                sizeof(ice_fdir_ipv4_gtpu4_pkt),
                ice_fdir_ipv4_gtpu4_pkt,
        },
+       {
+               ICE_FLTR_PTYPE_NONF_IPV4_L2TPV3,
+               sizeof(ice_fdir_ipv4_l2tpv3_pkt), ice_fdir_ipv4_l2tpv3_pkt,
+               sizeof(ice_fdir_ipv4_l2tpv3_pkt), ice_fdir_ipv4_l2tpv3_pkt,
+       },
+       {
+               ICE_FLTR_PTYPE_NONF_IPV6_L2TPV3,
+               sizeof(ice_fdir_ipv6_l2tpv3_pkt), ice_fdir_ipv6_l2tpv3_pkt,
+               sizeof(ice_fdir_ipv6_l2tpv3_pkt), ice_fdir_ipv6_l2tpv3_pkt,
+       },
+       {
+               ICE_FLTR_PTYPE_NONF_IPV4_ESP,
+               sizeof(ice_fdir_ipv4_esp_pkt), ice_fdir_ipv4_esp_pkt,
+               sizeof(ice_fdir_ipv4_esp_pkt), ice_fdir_ipv4_esp_pkt,
+       },
+       {
+               ICE_FLTR_PTYPE_NONF_IPV6_ESP,
+               sizeof(ice_fdir_ipv6_esp_pkt), ice_fdir_ipv6_esp_pkt,
+               sizeof(ice_fdir_ipv6_esp_pkt), ice_fdir_ipv6_esp_pkt,
+       },
+       {
+               ICE_FLTR_PTYPE_NONF_IPV4_AH,
+               sizeof(ice_fdir_ipv4_ah_pkt), ice_fdir_ipv4_ah_pkt,
+               sizeof(ice_fdir_ipv4_ah_pkt), ice_fdir_ipv4_ah_pkt,
+       },
+       {
+               ICE_FLTR_PTYPE_NONF_IPV6_AH,
+               sizeof(ice_fdir_ipv6_ah_pkt), ice_fdir_ipv6_ah_pkt,
+               sizeof(ice_fdir_ipv6_ah_pkt), ice_fdir_ipv6_ah_pkt,
+       },
+       {
+               ICE_FLTR_PTYPE_NONF_IPV4_NAT_T_ESP,
+               sizeof(ice_fdir_ipv4_nat_t_esp_pkt),
+               ice_fdir_ipv4_nat_t_esp_pkt,
+               sizeof(ice_fdir_ipv4_nat_t_esp_pkt),
+               ice_fdir_ipv4_nat_t_esp_pkt,
+       },
+       {
+               ICE_FLTR_PTYPE_NONF_IPV6_NAT_T_ESP,
+               sizeof(ice_fdir_ipv6_nat_t_esp_pkt),
+               ice_fdir_ipv6_nat_t_esp_pkt,
+               sizeof(ice_fdir_ipv6_nat_t_esp_pkt),
+               ice_fdir_ipv6_nat_t_esp_pkt,
+       },
+       {
+               ICE_FLTR_PTYPE_NONF_IPV4_PFCP_NODE,
+               sizeof(ice_fdir_ipv4_pfcp_node_pkt),
+               ice_fdir_ipv4_pfcp_node_pkt,
+               sizeof(ice_fdir_ipv4_pfcp_node_pkt),
+               ice_fdir_ipv4_pfcp_node_pkt,
+       },
+       {
+               ICE_FLTR_PTYPE_NONF_IPV4_PFCP_SESSION,
+               sizeof(ice_fdir_ipv4_pfcp_session_pkt),
+               ice_fdir_ipv4_pfcp_session_pkt,
+               sizeof(ice_fdir_ipv4_pfcp_session_pkt),
+               ice_fdir_ipv4_pfcp_session_pkt,
+       },
+       {
+               ICE_FLTR_PTYPE_NONF_IPV6_PFCP_NODE,
+               sizeof(ice_fdir_ipv6_pfcp_node_pkt),
+               ice_fdir_ipv6_pfcp_node_pkt,
+               sizeof(ice_fdir_ipv6_pfcp_node_pkt),
+               ice_fdir_ipv6_pfcp_node_pkt,
+       },
+       {
+               ICE_FLTR_PTYPE_NONF_IPV6_PFCP_SESSION,
+               sizeof(ice_fdir_ipv6_pfcp_session_pkt),
+               ice_fdir_ipv6_pfcp_session_pkt,
+               sizeof(ice_fdir_ipv6_pfcp_session_pkt),
+               ice_fdir_ipv6_pfcp_session_pkt,
+       },
        {
                ICE_FLTR_PTYPE_NON_IP_L2,
                sizeof(ice_fdir_non_ip_l2_pkt), ice_fdir_non_ip_l2_pkt,
@@ -832,6 +1036,56 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
                ice_pkt_insert_u6_qfi(loc, ICE_IPV4_GTPU_QFI_OFFSET,
                                      input->gtpu_data.qfi);
                break;
+       case ICE_FLTR_PTYPE_NONF_IPV4_L2TPV3:
+               ice_pkt_insert_u32(loc, ICE_IPV4_L2TPV3_SESS_ID_OFFSET,
+                                  input->l2tpv3_data.session_id);
+               break;
+       case ICE_FLTR_PTYPE_NONF_IPV6_L2TPV3:
+               ice_pkt_insert_u32(loc, ICE_IPV6_L2TPV3_SESS_ID_OFFSET,
+                                  input->l2tpv3_data.session_id);
+               break;
+       case ICE_FLTR_PTYPE_NONF_IPV4_ESP:
+               ice_pkt_insert_u32(loc, ICE_IPV4_ESP_SPI_OFFSET,
+                                  input->ip.v4.sec_parm_idx);
+               break;
+       case ICE_FLTR_PTYPE_NONF_IPV6_ESP:
+               ice_pkt_insert_u32(loc, ICE_IPV6_ESP_SPI_OFFSET,
+                                  input->ip.v6.sec_parm_idx);
+               break;
+       case ICE_FLTR_PTYPE_NONF_IPV4_AH:
+               ice_pkt_insert_u32(loc, ICE_IPV4_AH_SPI_OFFSET,
+                                  input->ip.v4.sec_parm_idx);
+               break;
+       case ICE_FLTR_PTYPE_NONF_IPV6_AH:
+               ice_pkt_insert_u32(loc, ICE_IPV6_AH_SPI_OFFSET,
+                                  input->ip.v6.sec_parm_idx);
+               break;
+       case ICE_FLTR_PTYPE_NONF_IPV4_NAT_T_ESP:
+               ice_pkt_insert_u32(loc, ICE_IPV4_DST_ADDR_OFFSET,
+                                  input->ip.v4.src_ip);
+               ice_pkt_insert_u32(loc, ICE_IPV4_SRC_ADDR_OFFSET,
+                                  input->ip.v4.dst_ip);
+               ice_pkt_insert_u32(loc, ICE_IPV4_NAT_T_ESP_SPI_OFFSET,
+                                  input->ip.v4.sec_parm_idx);
+               break;
+       case ICE_FLTR_PTYPE_NONF_IPV6_NAT_T_ESP:
+               ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_DST_ADDR_OFFSET,
+                                        input->ip.v6.src_ip);
+               ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_SRC_ADDR_OFFSET,
+                                        input->ip.v6.dst_ip);
+               ice_pkt_insert_u32(loc, ICE_IPV6_NAT_T_ESP_SPI_OFFSET,
+                                  input->ip.v6.sec_parm_idx);
+               break;
+       case ICE_FLTR_PTYPE_NONF_IPV4_PFCP_NODE:
+       case ICE_FLTR_PTYPE_NONF_IPV4_PFCP_SESSION:
+               ice_pkt_insert_u16(loc, ICE_IPV4_UDP_SRC_PORT_OFFSET,
+                                  input->ip.v4.dst_port);
+               break;
+       case ICE_FLTR_PTYPE_NONF_IPV6_PFCP_NODE:
+       case ICE_FLTR_PTYPE_NONF_IPV6_PFCP_SESSION:
+               ice_pkt_insert_u16(loc, ICE_IPV6_UDP_SRC_PORT_OFFSET,
+                                  input->ip.v6.dst_port);
+               break;
        case ICE_FLTR_PTYPE_NON_IP_L2:
                ice_pkt_insert_u16(loc, ICE_MAC_ETHTYPE_OFFSET,
                                   input->ext_data.ether_type);
index b39ce0b..2d41ec3 100644 (file)
 #define ICE_IPV6_PROTO_OFFSET          20
 #define ICE_IPV4_GTPU_TEID_OFFSET      46
 #define ICE_IPV4_GTPU_QFI_OFFSET       56
+#define ICE_IPV4_L2TPV3_SESS_ID_OFFSET 34
+#define ICE_IPV6_L2TPV3_SESS_ID_OFFSET 54
+#define ICE_IPV4_ESP_SPI_OFFSET                34
+#define ICE_IPV6_ESP_SPI_OFFSET                54
+#define ICE_IPV4_AH_SPI_OFFSET         38
+#define ICE_IPV6_AH_SPI_OFFSET         58
+#define ICE_IPV4_NAT_T_ESP_SPI_OFFSET  42
+#define ICE_IPV6_NAT_T_ESP_SPI_OFFSET  62
 
 #define ICE_FDIR_MAX_FLTRS             16384
 
@@ -150,6 +158,10 @@ struct ice_fdir_udp_gtp {
        u8 next_ext;
 };
 
+struct ice_fdir_l2tpv3 {
+       __be32 session_id;
+};
+
 struct ice_fdir_extra {
        u8 dst_mac[ETH_ALEN];   /* dest MAC address */
        __be16 ether_type;      /* for NON_IP_L2 */
@@ -170,6 +182,9 @@ struct ice_fdir_fltr {
        struct ice_fdir_udp_gtp gtpu_data;
        struct ice_fdir_udp_gtp gtpu_mask;
 
+       struct ice_fdir_l2tpv3 l2tpv3_data;
+       struct ice_fdir_l2tpv3 l2tpv3_mask;
+
        struct ice_fdir_extra ext_data;
        struct ice_fdir_extra ext_mask;
 
index 8f01a96..a6dece9 100644 (file)
@@ -296,6 +296,18 @@ enum ice_fltr_ptype {
        ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_TCP,
        ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_ICMP,
        ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_OTHER,
+       ICE_FLTR_PTYPE_NONF_IPV4_L2TPV3,
+       ICE_FLTR_PTYPE_NONF_IPV6_L2TPV3,
+       ICE_FLTR_PTYPE_NONF_IPV4_ESP,
+       ICE_FLTR_PTYPE_NONF_IPV6_ESP,
+       ICE_FLTR_PTYPE_NONF_IPV4_AH,
+       ICE_FLTR_PTYPE_NONF_IPV6_AH,
+       ICE_FLTR_PTYPE_NONF_IPV4_NAT_T_ESP,
+       ICE_FLTR_PTYPE_NONF_IPV6_NAT_T_ESP,
+       ICE_FLTR_PTYPE_NONF_IPV4_PFCP_NODE,
+       ICE_FLTR_PTYPE_NONF_IPV4_PFCP_SESSION,
+       ICE_FLTR_PTYPE_NONF_IPV6_PFCP_NODE,
+       ICE_FLTR_PTYPE_NONF_IPV6_PFCP_SESSION,
        ICE_FLTR_PTYPE_NON_IP_L2,
        ICE_FLTR_PTYPE_FRAG_IPV4,
        ICE_FLTR_PTYPE_NONF_IPV6_UDP,