net/ice/base: support IP fragment RSS and FDIR
authorQi Zhang <qi.z.zhang@intel.com>
Thu, 29 Apr 2021 00:41:43 +0000 (08:41 +0800)
committerQi Zhang <qi.z.zhang@intel.com>
Fri, 30 Apr 2021 13:50:05 +0000 (15:50 +0200)
Add support for IP fragment RSS hash and FDIR function. Separate IP
fragment and IP other packet types.

The patch also update the release date in README.

Signed-off-by: Ting Xu <ting.xu@intel.com>
Signed-off-by: Jeff Guo <jia.guo@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
drivers/net/ice/base/README
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 7d32e58..87a1ceb 100644 (file)
@@ -6,7 +6,7 @@ IntelĀ® ICE driver
 ==================
 
 This directory contains source code of FreeBSD ice driver of version
-2021.01.20 released by the team which develops
+2021.04.29 released by the team which develops
 basic drivers for any ice NIC. The directory of base/ contains the
 original source package.
 This driver is valid for the product(s) listed below
index f6a6ff3..1805082 100644 (file)
@@ -518,6 +518,25 @@ static const u8 ice_fdir_ipv4_udp_ecpri_tp0_pkt[] = {
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 };
 
+static const u8 ice_fdir_ipv6_frag_pkt[] = {
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x86, 0xDD, 0x60, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x2C, 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, 0x3B, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+static const u8 ice_fdir_ipv4_frag_pkt[] = {
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
+       0x00, 0x14, 0x00, 0x00, 0x20, 0x00, 0x40, 0x10,
+       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,
@@ -716,6 +735,16 @@ static const struct ice_fdir_base_pkt ice_fdir_pkt[] = {
                sizeof(ice_fdir_ipv4_pkt), ice_fdir_ipv4_pkt,
                sizeof(ice_fdir_ip4_tun_pkt), ice_fdir_ip4_tun_pkt,
        },
+       {
+               ICE_FLTR_PTYPE_FRAG_IPV4,
+               sizeof(ice_fdir_ipv4_frag_pkt), ice_fdir_ipv4_frag_pkt,
+               sizeof(ice_fdir_ipv4_frag_pkt), ice_fdir_ipv4_frag_pkt,
+       },
+       {
+               ICE_FLTR_PTYPE_FRAG_IPV6,
+               sizeof(ice_fdir_ipv6_frag_pkt), ice_fdir_ipv6_frag_pkt,
+               sizeof(ice_fdir_ipv6_frag_pkt), ice_fdir_ipv6_frag_pkt,
+       },
        {
                ICE_FLTR_PTYPE_NONF_IPV4_GTPU,
                sizeof(ice_fdir_ipv4_gtpu4_pkt),
@@ -1808,6 +1837,23 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
                                  input->ip.v6.proto);
                ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
                break;
+       case ICE_FLTR_PTYPE_FRAG_IPV4:
+               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_u8(loc, ICE_IPV4_TOS_OFFSET, input->ip.v4.tos);
+               ice_pkt_insert_u16(loc, ICE_IPV4_ID_OFFSET,
+                                  input->ip.v4.packet_id);
+               ice_pkt_insert_u8(loc, ICE_IPV4_TTL_OFFSET, input->ip.v4.ttl);
+               ice_pkt_insert_u8(loc, ICE_IPV4_PROTO_OFFSET,
+                                 input->ip.v4.proto);
+               ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
+               break;
+       case ICE_FLTR_PTYPE_FRAG_IPV6:
+               ice_pkt_insert_u32(loc, ICE_IPV6_ID_OFFSET,
+                                  input->ip.v6.packet_id);
+               break;
        default:
                return ICE_ERR_PARAM;
        }
@@ -1838,7 +1884,8 @@ ice_fdir_get_prgm_pkt(struct ice_fdir_fltr *input, u8 *pkt, bool frag)
  */
 bool ice_fdir_has_frag(enum ice_fltr_ptype flow)
 {
-       if (flow == ICE_FLTR_PTYPE_NONF_IPV4_OTHER)
+       if (flow == ICE_FLTR_PTYPE_FRAG_IPV4 ||
+           flow == ICE_FLTR_PTYPE_FRAG_IPV6)
                return true;
        else
                return false;
index b679a8a..0ebf7f3 100644 (file)
 
 #define ICE_MAC_ETHTYPE_OFFSET         12
 #define ICE_IPV4_TOS_OFFSET            15
+#define ICE_IPV4_ID_OFFSET             18
 #define ICE_IPV4_TTL_OFFSET            22
 #define ICE_IPV6_TC_OFFSET             14
 #define ICE_IPV6_HLIM_OFFSET           21
 #define ICE_IPV6_PROTO_OFFSET          20
+#define ICE_IPV6_ID_OFFSET             58
 /* For TUN inner (without inner MAC) */
 #define ICE_IPV4_NO_MAC_TOS_OFFSET     1
 #define ICE_IPV4_NO_MAC_TTL_OFFSET     8
@@ -158,6 +160,7 @@ struct ice_fdir_v4 {
        u8 ip_ver;
        u8 proto;
        u8 ttl;
+       __be16 packet_id;
 };
 
 #define ICE_IPV6_ADDR_LEN_AS_U32               4
@@ -172,6 +175,7 @@ struct ice_fdir_v6 {
        u8 tc;
        u8 proto;
        u8 hlim;
+       __be32 packet_id;
 };
 
 struct ice_fdir_udp_gtp {
index 6dba9e7..d624274 100644 (file)
@@ -13,6 +13,8 @@
 #define ICE_FLOW_FLD_SZ_IPV6_PRE32_ADDR        4
 #define ICE_FLOW_FLD_SZ_IPV6_PRE48_ADDR        6
 #define ICE_FLOW_FLD_SZ_IPV6_PRE64_ADDR        8
+#define ICE_FLOW_FLD_SZ_IPV4_ID                2
+#define ICE_FLOW_FLD_SZ_IPV6_ID                4
 #define ICE_FLOW_FLD_SZ_IP_DSCP                1
 #define ICE_FLOW_FLD_SZ_IP_TTL         1
 #define ICE_FLOW_FLD_SZ_IP_PROT                1
@@ -96,6 +98,12 @@ struct ice_flow_field_info ice_flds_info[ICE_FLOW_FIELD_IDX_MAX] = {
        ICE_FLOW_FLD_INFO(ICE_FLOW_SEG_HDR_IPV6, 8, ICE_FLOW_FLD_SZ_IPV6_ADDR),
        /* ICE_FLOW_FIELD_IDX_IPV6_DA */
        ICE_FLOW_FLD_INFO(ICE_FLOW_SEG_HDR_IPV6, 24, ICE_FLOW_FLD_SZ_IPV6_ADDR),
+       /* ICE_FLOW_FIELD_IDX_IPV4_FRAG */
+       ICE_FLOW_FLD_INFO(ICE_FLOW_SEG_HDR_IPV_FRAG, 4,
+                         ICE_FLOW_FLD_SZ_IPV4_ID),
+       /* ICE_FLOW_FIELD_IDX_IPV6_FRAG */
+       ICE_FLOW_FLD_INFO(ICE_FLOW_SEG_HDR_IPV_FRAG, 4,
+                         ICE_FLOW_FLD_SZ_IPV6_ID),
        /* ICE_FLOW_FIELD_IDX_IPV6_PRE32_SA */
        ICE_FLOW_FLD_INFO(ICE_FLOW_SEG_HDR_IPV6, 8,
                          ICE_FLOW_FLD_SZ_IPV6_PRE32_ADDR),
@@ -747,6 +755,28 @@ static const u32 ice_ptypes_ppp[] = {
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
 };
 
+static const u32 ice_ptypes_ipv4_frag[] = {
+       0x00400000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       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_ipv6_frag[] = {
+       0x00000000, 0x00000000, 0x01000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 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;
@@ -922,6 +952,16 @@ ice_flow_proc_seg_hdrs(struct ice_flow_prof_params *params)
                                (const ice_bitmap_t *)ice_ptypes_ipv6_ofos_all;
                        ice_and_bitmap(params->ptypes, params->ptypes, src,
                                       ICE_FLOW_PTYPE_MAX);
+               } else if ((hdrs & ICE_FLOW_SEG_HDR_IPV4) &&
+                               (hdrs & ICE_FLOW_SEG_HDR_IPV_FRAG)) {
+                       src = (const ice_bitmap_t *)ice_ptypes_ipv4_frag;
+                       ice_and_bitmap(params->ptypes, params->ptypes, src,
+                                      ICE_FLOW_PTYPE_MAX);
+               } else if ((hdrs & ICE_FLOW_SEG_HDR_IPV6) &&
+                               (hdrs & ICE_FLOW_SEG_HDR_IPV_FRAG)) {
+                       src = (const ice_bitmap_t *)ice_ptypes_ipv6_frag;
+                       ice_and_bitmap(params->ptypes, params->ptypes, src,
+                                      ICE_FLOW_PTYPE_MAX);
                } else if ((hdrs & ICE_FLOW_SEG_HDR_IPV4) &&
                           !(hdrs & ICE_FLOW_SEG_HDRS_L4_MASK_NO_OTHER)) {
                        src = !i ? (const ice_bitmap_t *)ice_ptypes_ipv4_ofos_no_l4 :
@@ -1210,6 +1250,9 @@ ice_flow_xtract_fld(struct ice_hw *hw, struct ice_flow_prof_params *params,
        case ICE_FLOW_FIELD_IDX_IPV4_DA:
                prot_id = seg == 0 ? ICE_PROT_IPV4_OF_OR_S : ICE_PROT_IPV4_IL;
                break;
+       case ICE_FLOW_FIELD_IDX_IPV4_ID:
+               prot_id = ICE_PROT_IPV4_OF_OR_S;
+               break;
        case ICE_FLOW_FIELD_IDX_IPV6_SA:
        case ICE_FLOW_FIELD_IDX_IPV6_DA:
        case ICE_FLOW_FIELD_IDX_IPV6_PRE32_SA:
@@ -1220,6 +1263,9 @@ ice_flow_xtract_fld(struct ice_hw *hw, struct ice_flow_prof_params *params,
        case ICE_FLOW_FIELD_IDX_IPV6_PRE64_DA:
                prot_id = seg == 0 ? ICE_PROT_IPV6_OF_OR_S : ICE_PROT_IPV6_IL;
                break;
+       case ICE_FLOW_FIELD_IDX_IPV6_ID:
+               prot_id = ICE_PROT_IPV6_FRAG;
+               break;
        case ICE_FLOW_FIELD_IDX_TCP_SRC_PORT:
        case ICE_FLOW_FIELD_IDX_TCP_DST_PORT:
        case ICE_FLOW_FIELD_IDX_TCP_FLAGS:
@@ -3429,13 +3475,16 @@ ice_flow_set_rss_seg_info(struct ice_flow_seg_info *segs, u8 seg_cnt,
        /* set outer most header */
        if (cfg->hdr_type == ICE_RSS_INNER_HEADERS_W_OUTER_IPV4)
                segs[ICE_RSS_OUTER_HEADERS].hdrs |= ICE_FLOW_SEG_HDR_IPV4 |
+                                                  ICE_FLOW_SEG_HDR_IPV_FRAG |
                                                   ICE_FLOW_SEG_HDR_IPV_OTHER;
        else if (cfg->hdr_type == ICE_RSS_INNER_HEADERS_W_OUTER_IPV6)
                segs[ICE_RSS_OUTER_HEADERS].hdrs |= ICE_FLOW_SEG_HDR_IPV6 |
+                                                  ICE_FLOW_SEG_HDR_IPV_FRAG |
                                                   ICE_FLOW_SEG_HDR_IPV_OTHER;
 
        if (seg->hdrs & ~ICE_FLOW_RSS_SEG_HDR_VAL_MASKS &
-           ~ICE_FLOW_RSS_HDRS_INNER_MASK & ~ICE_FLOW_SEG_HDR_IPV_OTHER)
+           ~ICE_FLOW_RSS_HDRS_INNER_MASK & ~ICE_FLOW_SEG_HDR_IPV_OTHER &
+           ~ICE_FLOW_SEG_HDR_IPV_FRAG)
                return ICE_ERR_PARAM;
 
        val = (u64)(seg->hdrs & ICE_FLOW_RSS_SEG_HDR_L3_MASKS);
index 448e060..878c79d 100644 (file)
@@ -186,11 +186,12 @@ enum ice_flow_seg_hdr {
        ICE_FLOW_SEG_HDR_ECPRI_TP0      = 0x04000000,
        ICE_FLOW_SEG_HDR_UDP_ECPRI_TP0  = 0x08000000,
        ICE_FLOW_SEG_HDR_L2TPV2         = 0x10000000,
-       ICE_FLOW_SEG_HDR_PPP            = 0x40000000,
+       ICE_FLOW_SEG_HDR_PPP            = 0x20000000,
        /* The following is an additive bit for ICE_FLOW_SEG_HDR_IPV4 and
-        * ICE_FLOW_SEG_HDR_IPV6 which include the IPV4 other PTYPEs
+        * ICE_FLOW_SEG_HDR_IPV6.
         */
-       ICE_FLOW_SEG_HDR_IPV_OTHER      = 0x20000000,
+       ICE_FLOW_SEG_HDR_IPV_FRAG       = 0x40000000,
+       ICE_FLOW_SEG_HDR_IPV_OTHER      = 0x80000000,
 };
 
 /* These segements all have the same PTYPES, but are otherwise distinguished by
@@ -227,6 +228,8 @@ enum ice_flow_field {
        ICE_FLOW_FIELD_IDX_IPV4_DA,
        ICE_FLOW_FIELD_IDX_IPV6_SA,
        ICE_FLOW_FIELD_IDX_IPV6_DA,
+       ICE_FLOW_FIELD_IDX_IPV4_ID,
+       ICE_FLOW_FIELD_IDX_IPV6_ID,
        ICE_FLOW_FIELD_IDX_IPV6_PRE32_SA,
        ICE_FLOW_FIELD_IDX_IPV6_PRE32_DA,
        ICE_FLOW_FIELD_IDX_IPV6_PRE48_SA,
index f64f215..ce508a0 100644 (file)
@@ -347,6 +347,7 @@ enum ice_fltr_ptype {
        ICE_FLTR_PTYPE_NONF_ECPRI_TP0,
        ICE_FLTR_PTYPE_NONF_IPV4_UDP_ECPRI_TP0,
        ICE_FLTR_PTYPE_FRAG_IPV4,
+       ICE_FLTR_PTYPE_FRAG_IPV6,
        ICE_FLTR_PTYPE_NONF_IPV6_UDP,
        ICE_FLTR_PTYPE_NONF_IPV6_TCP,
        ICE_FLTR_PTYPE_NONF_IPV6_SCTP,