net/ice/base: support switch filter (GTP tunnel+IP flow)
[dpdk.git] / drivers / net / ice / base / ice_flow.c
index bce90d9..a081fbe 100644 (file)
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2020 Intel Corporation
+ * Copyright(c) 2001-2021 Intel Corporation
  */
 
 #include "ice_common.h"
@@ -31,6 +31,7 @@
 #define ICE_FLOW_FLD_SZ_AH_SPI 4
 #define ICE_FLOW_FLD_SZ_NAT_T_ESP_SPI  4
 #define ICE_FLOW_FLD_SZ_VXLAN_VNI      4
+#define ICE_FLOW_FLD_SZ_ECPRI_TP0_PC_ID        2
 
 /* Describe properties of a protocol header field */
 struct ice_flow_field_info {
@@ -193,6 +194,14 @@ struct ice_flow_field_info ice_flds_info[ICE_FLOW_FIELD_IDX_MAX] = {
        /* ICE_FLOW_FIELD_IDX_VXLAN_VNI */
        ICE_FLOW_FLD_INFO(ICE_FLOW_SEG_HDR_VXLAN, 12,
                          ICE_FLOW_FLD_SZ_VXLAN_VNI),
+       /* ECPRI_TP0 */
+       /* ICE_FLOW_FIELD_IDX_ECPRI_TP0_PC_ID */
+       ICE_FLOW_FLD_INFO(ICE_FLOW_SEG_HDR_ECPRI_TP0, 4,
+                         ICE_FLOW_FLD_SZ_ECPRI_TP0_PC_ID),
+       /* UDP_ECPRI_TP0 */
+       /* ICE_FLOW_FIELD_IDX_UDP_ECPRI_TP0_PC_ID */
+       ICE_FLOW_FLD_INFO(ICE_FLOW_SEG_HDR_UDP_ECPRI_TP0, 12,
+                         ICE_FLOW_FLD_SZ_ECPRI_TP0_PC_ID),
 };
 
 /* Bitmaps indicating relevant packet types for a particular protocol header
@@ -202,7 +211,7 @@ struct ice_flow_field_info ice_flds_info[ICE_FLOW_FIELD_IDX_MAX] = {
 static const u32 ice_ptypes_mac_ofos[] = {
        0xFDC00846, 0xBFBF7F7E, 0xF70001DF, 0xFEFDFDFB,
        0x0000077E, 0x000003FF, 0x00000000, 0x00000000,
-       0x00400000, 0x03FFF000, 0xFFFFFFE0, 0x00000307,
+       0x00400000, 0x03FFF000, 0xFFFFFFE0, 0x00100707,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
@@ -228,7 +237,7 @@ static const u32 ice_ptypes_macvlan_il[] = {
 static const u32 ice_ptypes_ipv4_ofos[] = {
        0x1DC00000, 0x24000800, 0x00000000, 0x00000000,
        0x00000000, 0x00000155, 0x00000000, 0x00000000,
-       0x00000000, 0x000FC000, 0x000002A0, 0x00000000,
+       0x00000000, 0x000FC000, 0x000002A0, 0x00100000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
@@ -254,7 +263,7 @@ static const u32 ice_ptypes_ipv4_ofos_all[] = {
 static const u32 ice_ptypes_ipv4_il[] = {
        0xE0000000, 0xB807700E, 0x80000003, 0xE01DC03B,
        0x0000000E, 0x00000000, 0x00000000, 0x00000000,
-       0x00000000, 0x00000000, 0x001FF800, 0x00000000,
+       0x00000000, 0x00000000, 0x001FF800, 0x00100000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
@@ -368,7 +377,7 @@ static const u32 ice_ptypes_arp_of[] = {
 static const u32 ice_ptypes_udp_il[] = {
        0x81000000, 0x20204040, 0x04000010, 0x80810102,
        0x00000040, 0x00000000, 0x00000000, 0x00000000,
-       0x00000000, 0x00410000, 0x908427E0, 0x00000007,
+       0x00000000, 0x00410000, 0x908427E0, 0x00100007,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
@@ -694,6 +703,28 @@ static const u32 ice_ptypes_gtpu_no_ip[] = {
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
 };
 
+static const u32 ice_ptypes_ecpri_tp0[] = {
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000400,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+};
+
+static const u32 ice_ptypes_udp_ecpri_tp0[] = {
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00100000,
+       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;
@@ -718,7 +749,8 @@ struct ice_flow_prof_params {
        ICE_FLOW_SEG_HDR_GTPC_TEID | ICE_FLOW_SEG_HDR_GTPU | \
        ICE_FLOW_SEG_HDR_PFCP_SESSION | ICE_FLOW_SEG_HDR_L2TPV3 | \
        ICE_FLOW_SEG_HDR_ESP | ICE_FLOW_SEG_HDR_AH | \
-       ICE_FLOW_SEG_HDR_NAT_T_ESP | ICE_FLOW_SEG_HDR_GTPU_NON_IP)
+       ICE_FLOW_SEG_HDR_NAT_T_ESP | ICE_FLOW_SEG_HDR_GTPU_NON_IP | \
+       ICE_FLOW_SEG_HDR_ECPRI_TP0 | ICE_FLOW_SEG_HDR_UDP_ECPRI_TP0)
 
 #define ICE_FLOW_SEG_HDRS_L2_MASK      \
        (ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_VLAN)
@@ -848,8 +880,8 @@ 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;
+               if (hdrs & ICE_FLOW_SEG_HDR_ECPRI_TP0) {
+                       src = (const ice_bitmap_t *)ice_ptypes_ecpri_tp0;
                        ice_and_bitmap(params->ptypes, params->ptypes, src,
                                       ICE_FLOW_PTYPE_MAX);
                }
@@ -994,6 +1026,10 @@ ice_flow_proc_seg_hdrs(struct ice_flow_prof_params *params)
                        src = (const ice_bitmap_t *)ice_ptypes_vxlan_vni;
                        ice_and_bitmap(params->ptypes, params->ptypes,
                                       src, ICE_FLOW_PTYPE_MAX);
+               } else if (hdrs & ICE_FLOW_SEG_HDR_UDP_ECPRI_TP0) {
+                       src = (const ice_bitmap_t *)ice_ptypes_udp_ecpri_tp0;
+                       ice_and_bitmap(params->ptypes, params->ptypes,
+                                      src, ICE_FLOW_PTYPE_MAX);
                }
 
                if (hdrs & ICE_FLOW_SEG_HDR_PFCP) {
@@ -1192,6 +1228,12 @@ ice_flow_xtract_fld(struct ice_hw *hw, struct ice_flow_prof_params *params,
        case ICE_FLOW_FIELD_IDX_NAT_T_ESP_SPI:
                prot_id = ICE_PROT_UDP_IL_OR_S;
                break;
+       case ICE_FLOW_FIELD_IDX_ECPRI_TP0_PC_ID:
+               prot_id = ICE_PROT_ECPRI;
+               break;
+       case ICE_FLOW_FIELD_IDX_UDP_ECPRI_TP0_PC_ID:
+               prot_id = ICE_PROT_UDP_IL_OR_S;
+               break;
        case ICE_FLOW_FIELD_IDX_ARP_SIP:
        case ICE_FLOW_FIELD_IDX_ARP_DIP:
        case ICE_FLOW_FIELD_IDX_ARP_SHA:
@@ -3491,9 +3533,9 @@ ice_add_rss_list(struct ice_hw *hw, u16 vsi_handle, struct ice_flow_prof *prof)
  *          3 for tunneled with outer ipv6
  */
 #define ICE_FLOW_GEN_PROFID(hash, hdr, encap) \
-       (u64)(((u64)(hash) & ICE_FLOW_PROF_HASH_M) | \
-             (((u64)(hdr) << ICE_FLOW_PROF_HDR_S) & ICE_FLOW_PROF_HDR_M) | \
-             (((u64)(encap) << ICE_FLOW_PROF_ENCAP_S) & ICE_FLOW_PROF_ENCAP_M))
+       ((u64)(((u64)(hash) & ICE_FLOW_PROF_HASH_M) | \
+              (((u64)(hdr) << ICE_FLOW_PROF_HDR_S) & ICE_FLOW_PROF_HDR_M) | \
+              (((u64)(encap) << ICE_FLOW_PROF_ENCAP_S) & ICE_FLOW_PROF_ENCAP_M)))
 
 static void
 ice_rss_config_xor_word(struct ice_hw *hw, u8 prof_id, u8 src, u8 dst)