net/ice/base: update IPv4 and IPv6 flow packet type masks
[dpdk.git] / drivers / net / ice / base / ice_flow.c
index 744b280..667c077 100644 (file)
@@ -218,8 +218,24 @@ static const u32 ice_ptypes_macvlan_il[] = {
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
 };
 
-/* Packet types for packets with an Outer/First/Single IPv4 header */
+/* Packet types for packets with an Outer/First/Single IPv4 header, does NOT
+ * include IPV4 other PTYPEs
+ */
 static const u32 ice_ptypes_ipv4_ofos[] = {
+       0x1DC00000, 0x04000800, 0x00000000, 0x00000000,
+       0x00000000, 0x00000155, 0x00000000, 0x00000000,
+       0x00000000, 0x000FC000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+};
+
+/* Packet types for packets with an Outer/First/Single IPv4 header, includes
+ * IPV4 other PTYPEs
+ */
+static const u32 ice_ptypes_ipv4_ofos_all[] = {
        0x1DC00000, 0x04000800, 0x00000000, 0x00000000,
        0x00000000, 0x00000155, 0x00000000, 0x00000000,
        0x00000000, 0x000FC000, 0x83E0F800, 0x00000101,
@@ -242,8 +258,24 @@ static const u32 ice_ptypes_ipv4_il[] = {
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
 };
 
-/* Packet types for packets with an Outer/First/Single IPv6 header */
+/* Packet types for packets with an Outer/First/Single IPv6 header, does NOT
+ * include IVP6 other PTYPEs
+ */
 static const u32 ice_ptypes_ipv6_ofos[] = {
+       0x00000000, 0x00000000, 0x77000000, 0x10002000,
+       0x00000000, 0x000002AA, 0x00000000, 0x00000000,
+       0x00000000, 0x03F00000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+};
+
+/* Packet types for packets with an Outer/First/Single IPv6 header, includes
+ * IPV6 other PTYPEs
+ */
+static const u32 ice_ptypes_ipv6_ofos_all[] = {
        0x00000000, 0x00000000, 0x77000000, 0x10002000,
        0x00000000, 0x000002AA, 0x00000000, 0x00000000,
        0x00080F00, 0x03F00000, 0x7C1F0000, 0x00000206,
@@ -266,6 +298,54 @@ static const u32 ice_ptypes_ipv6_il[] = {
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
 };
 
+/* Packet types for packets with an Outer/First/Single IPv4 header - no L4 */
+static const u32 ice_ipv4_ofos_no_l4[] = {
+       0x10C00000, 0x04000800, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x000cc000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+};
+
+/* Packet types for packets with an Innermost/Last IPv4 header - no L4 */
+static const u32 ice_ipv4_il_no_l4[] = {
+       0x60000000, 0x18043008, 0x80000002, 0x6010c021,
+       0x00000008, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00139800, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+};
+
+/* Packet types for packets with an Outer/First/Single IPv6 header - no L4 */
+static const u32 ice_ipv6_ofos_no_l4[] = {
+       0x00000000, 0x00000000, 0x43000000, 0x10002000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x02300000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+};
+
+/* Packet types for packets with an Innermost/Last IPv6 header - no L4 */
+static const u32 ice_ipv6_il_no_l4[] = {
+       0x00000000, 0x02180430, 0x0000010c, 0x086010c0,
+       0x00000430, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x4e600000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+};
+
 /* Packet types for packets with an Outermost/First ARP header */
 static const u32 ice_ptypes_arp_of[] = {
        0x00000800, 0x00000000, 0x00000000, 0x00000000,
@@ -473,7 +553,7 @@ static const u32 ice_ptypes_gtpu[] = {
 static const u32 ice_ptypes_pppoe[] = {
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
-       0x00000000, 0x03FFF000, 0x00000000, 0x00000000,
+       0x00000000, 0x03fff000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
@@ -598,6 +678,9 @@ struct ice_flow_prof_params {
 #define ICE_FLOW_SEG_HDRS_L4_MASK      \
        (ICE_FLOW_SEG_HDR_ICMP | ICE_FLOW_SEG_HDR_TCP | ICE_FLOW_SEG_HDR_UDP | \
         ICE_FLOW_SEG_HDR_SCTP)
+/* mask for L4 protocols that are NOT part of IPV4/6 OTHER PTYPE groups */
+#define ICE_FLOW_SEG_HDRS_L4_MASK_NO_OTHER     \
+       (ICE_FLOW_SEG_HDR_TCP | ICE_FLOW_SEG_HDR_UDP | ICE_FLOW_SEG_HDR_SCTP)
 
 /**
  * ice_flow_val_hdrs - validates packet segments for valid protocol headers
@@ -715,46 +798,47 @@ ice_flow_proc_seg_hdrs(struct ice_flow_prof_params *params)
                                       ICE_FLOW_PTYPE_MAX);
                }
 
-               if (hdrs & ICE_FLOW_SEG_HDR_IPV4) {
+               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) &&
+                   (hdrs & ICE_FLOW_SEG_HDR_IPV_OTHER)) {
+                       src = !i ?
+                               (const ice_bitmap_t *)ice_ptypes_ipv4_ofos_all :
+                               (const ice_bitmap_t *)ice_ptypes_ipv4_il;
+                       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_OTHER)) {
+                       src = !i ?
+                               (const ice_bitmap_t *)ice_ptypes_ipv6_ofos_all :
+                               (const ice_bitmap_t *)ice_ptypes_ipv6_il;
+                       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_ipv4_ofos_no_l4 :
+                               (const ice_bitmap_t *)ice_ipv4_il_no_l4;
+                       ice_and_bitmap(params->ptypes, params->ptypes, src,
+                                      ICE_FLOW_PTYPE_MAX);
+               } else 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;
                        ice_and_bitmap(params->ptypes, params->ptypes, src,
                                       ICE_FLOW_PTYPE_MAX);
-                       if (hdrs & ICE_FLOW_SEG_HDR_UDP) {
-                               src = (const ice_bitmap_t *)ice_ptypes_udp_il;
-                               ice_and_bitmap(params->ptypes,
-                                               params->ptypes, src,
-                                              ICE_FLOW_PTYPE_MAX);
-                       } else if (hdrs & ICE_FLOW_SEG_HDR_TCP) {
-                               ice_and_bitmap(params->ptypes, params->ptypes,
-                                              (const ice_bitmap_t *)
-                                              ice_ptypes_tcp_il,
-                                              ICE_FLOW_PTYPE_MAX);
-                       } else if (hdrs & ICE_FLOW_SEG_HDR_SCTP) {
-                               src = (const ice_bitmap_t *)ice_ptypes_sctp_il;
-                               ice_and_bitmap(params->ptypes, params->ptypes,
-                                              src, ICE_FLOW_PTYPE_MAX);
-                       }
+               } else if ((hdrs & ICE_FLOW_SEG_HDR_IPV6) &&
+                          !(hdrs & ICE_FLOW_SEG_HDRS_L4_MASK_NO_OTHER)) {
+                       src = !i ? (const ice_bitmap_t *)ice_ipv6_ofos_no_l4 :
+                               (const ice_bitmap_t *)ice_ipv6_il_no_l4;
+                       ice_and_bitmap(params->ptypes, params->ptypes, src,
+                                      ICE_FLOW_PTYPE_MAX);
                } else if (hdrs & ICE_FLOW_SEG_HDR_IPV6) {
                        src = !i ? (const ice_bitmap_t *)ice_ptypes_ipv6_ofos :
                                (const ice_bitmap_t *)ice_ptypes_ipv6_il;
                        ice_and_bitmap(params->ptypes, params->ptypes, src,
                                       ICE_FLOW_PTYPE_MAX);
-                       if (hdrs & ICE_FLOW_SEG_HDR_UDP) {
-                               src = (const ice_bitmap_t *)ice_ptypes_udp_il;
-                               ice_and_bitmap(params->ptypes,
-                                               params->ptypes, src,
-                                              ICE_FLOW_PTYPE_MAX);
-                       } else if (hdrs & ICE_FLOW_SEG_HDR_TCP) {
-                               ice_and_bitmap(params->ptypes, params->ptypes,
-                                              (const ice_bitmap_t *)
-                                              ice_ptypes_tcp_il,
-                                              ICE_FLOW_PTYPE_MAX);
-                       } else if (hdrs & ICE_FLOW_SEG_HDR_SCTP) {
-                               src = (const ice_bitmap_t *)ice_ptypes_sctp_il;
-                               ice_and_bitmap(params->ptypes, params->ptypes,
-                                              src, ICE_FLOW_PTYPE_MAX);
-                       }
                }
 
                if (hdrs & ICE_FLOW_SEG_HDR_ETH_NON_IP) {
@@ -771,6 +855,20 @@ ice_flow_proc_seg_hdrs(struct ice_flow_prof_params *params)
                                          ICE_FLOW_PTYPE_MAX);
                }
 
+               if (hdrs & ICE_FLOW_SEG_HDR_UDP) {
+                       src = (const ice_bitmap_t *)ice_ptypes_udp_il;
+                       ice_and_bitmap(params->ptypes, params->ptypes, src,
+                                      ICE_FLOW_PTYPE_MAX);
+               } else if (hdrs & ICE_FLOW_SEG_HDR_TCP) {
+                       ice_and_bitmap(params->ptypes, params->ptypes,
+                                      (const ice_bitmap_t *)ice_ptypes_tcp_il,
+                                      ICE_FLOW_PTYPE_MAX);
+               } else if (hdrs & ICE_FLOW_SEG_HDR_SCTP) {
+                       src = (const ice_bitmap_t *)ice_ptypes_sctp_il;
+                       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;
@@ -3154,7 +3252,7 @@ ice_flow_set_rss_seg_info(struct ice_flow_seg_info *segs, u64 hash_fields,
        ICE_FLOW_SET_HDRS(segs, flow_hdr);
 
        if (segs->hdrs & ~ICE_FLOW_RSS_SEG_HDR_VAL_MASKS &
-           ~ICE_FLOW_RSS_HDRS_INNER_MASK)
+           ~ICE_FLOW_RSS_HDRS_INNER_MASK & ~ICE_FLOW_SEG_HDR_IPV_OTHER)
                return ICE_ERR_PARAM;
 
        val = (u64)(segs->hdrs & ICE_FLOW_RSS_SEG_HDR_L3_MASKS);