net/ice/base: support flow director for non-IP packets
authorQi Zhang <qi.z.zhang@intel.com>
Mon, 15 Jun 2020 02:04:23 +0000 (10:04 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 16 Jun 2020 17:21:07 +0000 (19:21 +0200)
FDIR can forward Ethernet packets with non-IP ethertype.

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_flow.c
drivers/net/ice/base/ice_flow.h
drivers/net/ice/base/ice_type.h

index 4e9aafc..c925332 100644 (file)
@@ -102,6 +102,12 @@ static const u8 ice_fdir_ipv4_gtpu4_pkt[] = {
        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,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
 static const u8 ice_fdir_tcpv6_pkt[] = {
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x86, 0xDD, 0x60, 0x00,
@@ -328,6 +334,11 @@ static const struct ice_fdir_base_pkt ice_fdir_pkt[] = {
                sizeof(ice_fdir_ipv4_gtpu4_pkt),
                ice_fdir_ipv4_gtpu4_pkt,
        },
+       {
+               ICE_FLTR_PTYPE_NON_IP_L2,
+               sizeof(ice_fdir_non_ip_l2_pkt), ice_fdir_non_ip_l2_pkt,
+               sizeof(ice_fdir_non_ip_l2_pkt), ice_fdir_non_ip_l2_pkt,
+       },
        {
                ICE_FLTR_PTYPE_NONF_IPV6_TCP,
                sizeof(ice_fdir_tcpv6_pkt), ice_fdir_tcpv6_pkt,
@@ -819,6 +830,10 @@ 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_NON_IP_L2:
+               ice_pkt_insert_u16(loc, ICE_MAC_ETHTYPE_OFFSET,
+                                  input->ext_data.ether_type);
+               break;
        case ICE_FLTR_PTYPE_NONF_IPV6_TCP:
                ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_DST_ADDR_OFFSET,
                                         input->ip.v6.dst_ip);
index 18656c5..97553c8 100644 (file)
@@ -79,6 +79,7 @@ enum ice_status ice_clear_pf_fd_table(struct ice_hw *hw);
 #define ICE_IPV6_SCTP_SRC_PORT_OFFSET  54
 #define ICE_IPV6_SCTP_DST_PORT_OFFSET  56
 
+#define ICE_MAC_ETHTYPE_OFFSET         12
 #define ICE_IPV4_TOS_OFFSET            15
 #define ICE_IPV4_TTL_OFFSET            22
 #define ICE_IPV6_TC_OFFSET             14
@@ -165,6 +166,7 @@ struct ice_fdir_udp_gtp {
 
 struct ice_fdir_extra {
        u8 dst_mac[ETH_ALEN];   /* dest MAC address */
+       __be16 ether_type;      /* for NON_IP_L2 */
        u32 usr_def[2];         /* user data */
        __be16 vlan_type;       /* VLAN ethertype */
        __be16 vlan_tag;        /* VLAN tag info */
index e741f59..90302a6 100644 (file)
@@ -63,7 +63,7 @@ struct ice_flow_field_info ice_flds_info[ICE_FLOW_FIELD_IDX_MAX] = {
        /* ICE_FLOW_FIELD_IDX_C_VLAN */
        ICE_FLOW_FLD_INFO(ICE_FLOW_SEG_HDR_VLAN, 14, ICE_FLOW_FLD_SZ_VLAN),
        /* ICE_FLOW_FIELD_IDX_ETH_TYPE */
-       ICE_FLOW_FLD_INFO(ICE_FLOW_SEG_HDR_ETH, 12, ICE_FLOW_FLD_SZ_ETH_TYPE),
+       ICE_FLOW_FLD_INFO(ICE_FLOW_SEG_HDR_ETH, 0, ICE_FLOW_FLD_SZ_ETH_TYPE),
        /* IPv4 / IPv6 */
        /* ICE_FLOW_FIELD_IDX_IPV4_DSCP */
        ICE_FLOW_FLD_INFO_MSK(ICE_FLOW_SEG_HDR_IPV4, 0, ICE_FLOW_FLD_SZ_IP_DSCP,
@@ -532,6 +532,17 @@ static const u32 ice_ptypes_nat_t_esp[] = {
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
 };
 
+static const u32 ice_ptypes_mac_non_ip_ofos[] = {
+       0x00000846, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00400000, 0x03FFF000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+};
+
 /* Manage parameters and info. used during the creation of a flow profile */
 struct ice_flow_prof_params {
        enum ice_block blk;
@@ -683,12 +694,6 @@ ice_flow_proc_seg_hdrs(struct ice_flow_prof_params *params)
                                       ICE_FLOW_PTYPE_MAX);
                }
 
-               if (hdrs & ICE_FLOW_SEG_HDR_PPPOE) {
-                       src = (const ice_bitmap_t *)ice_ptypes_pppoe;
-                       ice_and_bitmap(params->ptypes, params->ptypes, src,
-                                      ICE_FLOW_PTYPE_MAX);
-               }
-
                if (hdrs & ICE_FLOW_SEG_HDR_IPV4) {
                        src = !i ? (const ice_bitmap_t *)ice_ptypes_ipv4_ofos :
                                (const ice_bitmap_t *)ice_ptypes_ipv4_il;
@@ -731,6 +736,16 @@ ice_flow_proc_seg_hdrs(struct ice_flow_prof_params *params)
                        }
                }
 
+               if (hdrs & ICE_FLOW_SEG_HDR_ETH_NON_IP) {
+                       src = (const ice_bitmap_t *)ice_ptypes_mac_non_ip_ofos;
+                       ice_and_bitmap(params->ptypes, params->ptypes,
+                                      src, ICE_FLOW_PTYPE_MAX);
+               } else if (hdrs & ICE_FLOW_SEG_HDR_PPPOE) {
+                       src = (const ice_bitmap_t *)ice_ptypes_pppoe;
+                       ice_and_bitmap(params->ptypes, params->ptypes, src,
+                                      ICE_FLOW_PTYPE_MAX);
+               }
+
                if (hdrs & ICE_FLOW_SEG_HDR_ICMP) {
                        src = !i ? (const ice_bitmap_t *)ice_ptypes_icmp_of :
                                (const ice_bitmap_t *)ice_ptypes_icmp_il;
index c8a0483..9fb60a6 100644 (file)
@@ -148,6 +148,7 @@ enum ice_flow_seg_hdr {
        ICE_FLOW_SEG_HDR_ESP            = 0x00100000,
        ICE_FLOW_SEG_HDR_AH             = 0x00200000,
        ICE_FLOW_SEG_HDR_NAT_T_ESP      = 0x00400000,
+       ICE_FLOW_SEG_HDR_ETH_NON_IP     = 0x00800000,
 };
 
 /* These segements all have the same PTYPES, but are otherwise distinguished by
index 94ea442..cf62217 100644 (file)
@@ -295,6 +295,7 @@ 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_NON_IP_L2,
        ICE_FLTR_PTYPE_FRAG_IPV4,
        ICE_FLTR_PTYPE_NONF_IPV6_UDP,
        ICE_FLTR_PTYPE_NONF_IPV6_TCP,