DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v1 0/3] support flow for IP fragment in ICE
@ 2021-03-17  3:43 Jeff Guo
  2021-03-17  3:43 ` [dpdk-dev] [PATCH v1 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
                   ` (3 more replies)
  0 siblings, 4 replies; 42+ messages in thread
From: Jeff Guo @ 2021-03-17  3:43 UTC (permalink / raw)
  To: qiming.yang, qi.z.zhang; +Cc: ting.xu, dev, jia.guo

Support RSS hash and FDIR for IP fragment packets in ICE PMD.

Jeff Guo (3):
  net/ice/base: support IP fragment RSS and FDIR
  net/ice: support RSS hash for IP fragment
  net/ice: support FDIR for IP fragment packet

 drivers/net/ice/base/ice_fdir.c    | 50 ++++++++++++++++-
 drivers/net/ice/base/ice_fdir.h    | 22 ++++++--
 drivers/net/ice/base/ice_flow.c    | 50 ++++++++++++++++-
 drivers/net/ice/base/ice_flow.h    |  5 +-
 drivers/net/ice/base/ice_type.h    |  1 +
 drivers/net/ice/ice_fdir_filter.c  | 87 +++++++++++++++++++++++++-----
 drivers/net/ice/ice_generic_flow.c | 21 ++++++++
 drivers/net/ice/ice_generic_flow.h |  6 +++
 drivers/net/ice/ice_hash.c         | 48 ++++++++++++++---
 9 files changed, 260 insertions(+), 30 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v1 1/3] net/ice/base: support IP fragment RSS and FDIR
  2021-03-17  3:43 [dpdk-dev] [PATCH v1 0/3] support flow for IP fragment in ICE Jeff Guo
@ 2021-03-17  3:43 ` Jeff Guo
  2021-03-17  3:43 ` [dpdk-dev] [PATCH v1 2/3] net/ice: support RSS hash for IP fragment Jeff Guo
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 42+ messages in thread
From: Jeff Guo @ 2021-03-17  3:43 UTC (permalink / raw)
  To: qiming.yang, qi.z.zhang; +Cc: ting.xu, dev, jia.guo

Add support for IP fragment RSS hash and FDIR according to packet ID.
Separate IP fragment and IP other packet types.

Signed-off-by: Ting Xu <ting.xu@intel.com>
Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
 drivers/net/ice/base/ice_fdir.c | 50 +++++++++++++++++++++++++++++++--
 drivers/net/ice/base/ice_fdir.h | 22 ++++++++++++---
 drivers/net/ice/base/ice_flow.c | 50 ++++++++++++++++++++++++++++++++-
 drivers/net/ice/base/ice_flow.h |  5 +++-
 drivers/net/ice/base/ice_type.h |  1 +
 5 files changed, 120 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ice/base/ice_fdir.c b/drivers/net/ice/base/ice_fdir.c
index 2b39c13127..0eb7cdd729 100644
--- a/drivers/net/ice/base/ice_fdir.c
+++ b/drivers/net/ice/base/ice_fdir.c
@@ -518,6 +518,24 @@ 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 +734,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_pkt), ice_fdir_ipv4_frag_pkt,
+		sizeof(ice_fdir_ipv4_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),
@@ -1505,7 +1533,7 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
 		ice_pkt_insert_u8(loc, ICE_IPV4_TTL_OFFSET, input->ip.v4.ttl);
 		ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
 		if (frag)
-			loc[20] = ICE_FDIR_IPV4_PKT_FLAG_DF;
+			loc[20] = ICE_FDIR_IPV4_PKT_FLAG_MF;
 		break;
 	case ICE_FLTR_PTYPE_NONF_IPV4_UDP:
 		ice_pkt_insert_mac_addr(pkt, input->ext_data_outer.dst_mac);
@@ -1808,6 +1836,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 +1883,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;
diff --git a/drivers/net/ice/base/ice_fdir.h b/drivers/net/ice/base/ice_fdir.h
index 6573f96bc1..2acc1d6f1b 100644
--- a/drivers/net/ice/base/ice_fdir.h
+++ b/drivers/net/ice/base/ice_fdir.h
@@ -43,9 +43,11 @@
 #define ICE_MAC_ETHTYPE_OFFSET		12
 #define ICE_IPV4_TOS_OFFSET		15
 #define ICE_IPV4_TTL_OFFSET		22
+#define ICE_IPV4_ID_OFFSET		18
 #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
@@ -83,12 +85,22 @@
 
 #define ICE_FDIR_MAX_FLTRS		16384
 
-/* IP v4 has 2 flag bits that enable fragment processing: DF and MF. DF
+/* IPv4 has 2 flag bits that enable fragment processing: DF and MF. DF
  * requests that the packet not be fragmented. MF indicates that a packet has
- * been fragmented.
+ * been fragmented, except that for the last fragment has a non-zero
+ * Fragment Offset field with zero MF.
  */
-#define ICE_FDIR_IPV4_PKT_FLAG_DF		0x20
-#define ICE_FDIR_IPV4_PKT_FLAG_MF		0x40
+#define ICE_FDIR_IPV4_PKT_FLAG_MF		0x20
+#define ICE_FDIR_IPV4_PKT_FLAG_MF_SHIFT	8
+#ifndef NO_UNUSED_PACKAGE_CODE
+#define ICE_FDIR_IPV4_PKT_FLAG_DF		0x40
+#endif /* NO_UNUSED_PACKAGE_CODE */
+
+/* For IPv6 fragmented packets, all fragments except the last have
+ * the MF flag set.
+ */
+#define ICE_FDIR_IPV6_PKT_FLAG_MF		0x100
+#define ICE_FDIR_IPV6_PKT_FLAG_MF_SHIFT	8
 
 enum ice_fltr_prgm_desc_dest {
 	ICE_FLTR_PRGM_DESC_DEST_DROP_PKT,
@@ -150,6 +162,7 @@ struct ice_fdir_v4 {
 	u8 ip_ver;
 	u8 proto;
 	u8 ttl;
+	__be16 packet_id;
 };
 
 #define ICE_IPV6_ADDR_LEN_AS_U32		4
@@ -164,6 +177,7 @@ struct ice_fdir_v6 {
 	u8 tc;
 	u8 proto;
 	u8 hlim;
+	__be32 packet_id;
 };
 
 struct ice_fdir_udp_gtp {
diff --git a/drivers/net/ice/base/ice_flow.c b/drivers/net/ice/base/ice_flow.c
index d123206fc6..019feec116 100644
--- a/drivers/net/ice/base/ice_flow.c
+++ b/drivers/net/ice/base/ice_flow.c
@@ -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),
@@ -725,6 +733,27 @@ static const u32 ice_ptypes_udp_ecpri_tp0[] = {
 	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;
@@ -899,6 +928,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 :
@@ -1177,6 +1216,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:
@@ -1187,6 +1229,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:
@@ -3341,13 +3386,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);
diff --git a/drivers/net/ice/base/ice_flow.h b/drivers/net/ice/base/ice_flow.h
index c3bce13194..761e14e1d4 100644
--- a/drivers/net/ice/base/ice_flow.h
+++ b/drivers/net/ice/base/ice_flow.h
@@ -186,8 +186,9 @@ enum ice_flow_seg_hdr {
 	ICE_FLOW_SEG_HDR_ECPRI_TP0	= 0x04000000,
 	ICE_FLOW_SEG_HDR_UDP_ECPRI_TP0	= 0x08000000,
 	/* 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_FRAG	= 0x10000000,
 	ICE_FLOW_SEG_HDR_IPV_OTHER	= 0x20000000,
 };
 
@@ -225,6 +226,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,
diff --git a/drivers/net/ice/base/ice_type.h b/drivers/net/ice/base/ice_type.h
index a6599363f9..5abe9dc9ea 100644
--- a/drivers/net/ice/base/ice_type.h
+++ b/drivers/net/ice/base/ice_type.h
@@ -349,6 +349,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,
-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v1 2/3] net/ice: support RSS hash for IP fragment
  2021-03-17  3:43 [dpdk-dev] [PATCH v1 0/3] support flow for IP fragment in ICE Jeff Guo
  2021-03-17  3:43 ` [dpdk-dev] [PATCH v1 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
@ 2021-03-17  3:43 ` Jeff Guo
  2021-03-17  3:43 ` [dpdk-dev] [PATCH v1 3/3] net/ice: support FDIR for IP fragment packet Jeff Guo
  2021-03-24 13:54 ` [dpdk-dev] [PATCH v2 0/3] support flow for IP fragment in ICE Jeff Guo
  3 siblings, 0 replies; 42+ messages in thread
From: Jeff Guo @ 2021-03-17  3:43 UTC (permalink / raw)
  To: qiming.yang, qi.z.zhang; +Cc: ting.xu, dev, jia.guo

New pattern and RSS hash flow parsing are added to handle fragmented
IPv4/IPv6  packet.

Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
 drivers/net/ice/ice_generic_flow.c | 21 +++++++++++++
 drivers/net/ice/ice_generic_flow.h |  6 ++++
 drivers/net/ice/ice_hash.c         | 48 +++++++++++++++++++++++++-----
 3 files changed, 67 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ice/ice_generic_flow.c b/drivers/net/ice/ice_generic_flow.c
index 8704812622..2389bc6637 100644
--- a/drivers/net/ice/ice_generic_flow.c
+++ b/drivers/net/ice/ice_generic_flow.c
@@ -212,6 +212,27 @@ enum rte_flow_item_type pattern_eth_qinq_ipv6[] = {
 	RTE_FLOW_ITEM_TYPE_IPV6,
 	RTE_FLOW_ITEM_TYPE_END,
 };
+enum rte_flow_item_type pattern_eth_ipv6_frag_ext[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+enum rte_flow_item_type pattern_eth_vlan_ipv6_frag_ext[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_VLAN,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+enum rte_flow_item_type pattern_eth_qinq_ipv6_frag_ext[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_VLAN,
+	RTE_FLOW_ITEM_TYPE_VLAN,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+	RTE_FLOW_ITEM_TYPE_END,
+};
 enum rte_flow_item_type pattern_eth_ipv6_udp[] = {
 	RTE_FLOW_ITEM_TYPE_ETH,
 	RTE_FLOW_ITEM_TYPE_IPV6,
diff --git a/drivers/net/ice/ice_generic_flow.h b/drivers/net/ice/ice_generic_flow.h
index 9f422e5925..2afe719264 100644
--- a/drivers/net/ice/ice_generic_flow.h
+++ b/drivers/net/ice/ice_generic_flow.h
@@ -52,6 +52,7 @@
 #define ICE_L2TPV3OIP_SESSION_ID	BIT_ULL(43)
 #define ICE_PFCP_SEID			BIT_ULL(42)
 #define ICE_PFCP_S_FIELD		BIT_ULL(41)
+#define ICE_IP_PK_ID		    BIT_ULL(40)
 
 /* input set */
 
@@ -69,11 +70,13 @@
 #define ICE_INSET_IPV4_TOS		(ICE_PROT_IPV4 | ICE_IP_TOS)
 #define ICE_INSET_IPV4_PROTO		(ICE_PROT_IPV4 | ICE_IP_PROTO)
 #define ICE_INSET_IPV4_TTL		(ICE_PROT_IPV4 | ICE_IP_TTL)
+#define ICE_INSET_IPV4_PKID		(ICE_PROT_IPV4 | ICE_IP_PK_ID)
 #define ICE_INSET_IPV6_SRC		(ICE_PROT_IPV6 | ICE_IP_SRC)
 #define ICE_INSET_IPV6_DST		(ICE_PROT_IPV6 | ICE_IP_DST)
 #define ICE_INSET_IPV6_NEXT_HDR		(ICE_PROT_IPV6 | ICE_IP_PROTO)
 #define ICE_INSET_IPV6_HOP_LIMIT	(ICE_PROT_IPV6 | ICE_IP_TTL)
 #define ICE_INSET_IPV6_TC		(ICE_PROT_IPV6 | ICE_IP_TOS)
+#define ICE_INSET_IPV6_PKID		(ICE_PROT_IPV6 | ICE_IP_PK_ID)
 
 #define ICE_INSET_TCP_SRC_PORT		(ICE_PROT_TCP | ICE_SPORT)
 #define ICE_INSET_TCP_DST_PORT		(ICE_PROT_TCP | ICE_DPORT)
@@ -202,6 +205,9 @@ extern enum rte_flow_item_type pattern_eth_qinq_ipv4_icmp[];
 extern enum rte_flow_item_type pattern_eth_ipv6[];
 extern enum rte_flow_item_type pattern_eth_vlan_ipv6[];
 extern enum rte_flow_item_type pattern_eth_qinq_ipv6[];
+extern enum rte_flow_item_type pattern_eth_ipv6_frag_ext[];
+extern enum rte_flow_item_type pattern_eth_vlan_ipv6_frag_ext[];
+extern enum rte_flow_item_type pattern_eth_qinq_ipv6_frag_ext[];
 extern enum rte_flow_item_type pattern_eth_ipv6_udp[];
 extern enum rte_flow_item_type pattern_eth_vlan_ipv6_udp[];
 extern enum rte_flow_item_type pattern_eth_qinq_ipv6_udp[];
diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c
index 58a0c18d09..b3ed9b219c 100644
--- a/drivers/net/ice/ice_hash.c
+++ b/drivers/net/ice/ice_hash.c
@@ -47,8 +47,10 @@
 				 ETH_RSS_NONFRAG_IPV6_TCP	| \
 				 ETH_RSS_NONFRAG_IPV6_SCTP)
 
-#define VALID_RSS_IPV4		(ETH_RSS_IPV4 | VALID_RSS_IPV4_L4)
-#define VALID_RSS_IPV6		(ETH_RSS_IPV6 | VALID_RSS_IPV6_L4)
+#define VALID_RSS_IPV4		(ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 | \
+				 VALID_RSS_IPV4_L4)
+#define VALID_RSS_IPV6		(ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 | \
+				 VALID_RSS_IPV6_L4)
 #define VALID_RSS_L3		(VALID_RSS_IPV4 | VALID_RSS_IPV6)
 #define VALID_RSS_L4		(VALID_RSS_IPV4_L4 | VALID_RSS_IPV6_L4)
 
@@ -108,6 +110,7 @@ ice_hash_parse_pattern_action(struct ice_adapter *ad,
 /* Rss configuration template */
 struct ice_rss_hash_cfg ipv4_tmplt = {
 	ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV4 |
+	ICE_FLOW_SEG_HDR_IPV_FRAG |
 	ICE_FLOW_SEG_HDR_IPV_OTHER,
 	ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_IPV4,
 	ICE_RSS_ANY_HEADERS,
@@ -146,6 +149,15 @@ struct ice_rss_hash_cfg ipv6_tmplt = {
 	0
 };
 
+struct ice_rss_hash_cfg ipv6_frag_tmplt = {
+	ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV6 |
+	ICE_FLOW_SEG_HDR_IPV_FRAG |
+	ICE_FLOW_SEG_HDR_IPV_OTHER,
+	ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_IPV6,
+	ICE_RSS_ANY_HEADERS,
+	0
+};
+
 struct ice_rss_hash_cfg ipv6_udp_tmplt = {
 	ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV6 |
 	ICE_FLOW_SEG_HDR_IPV_OTHER | ICE_FLOW_SEG_HDR_UDP,
@@ -198,6 +210,7 @@ struct ice_rss_hash_cfg outer_ipv6_inner_ipv4_tmplt = {
 	ICE_RSS_INNER_HEADERS_W_OUTER_IPV6,
 	0
 };
+
 struct ice_rss_hash_cfg outer_ipv6_inner_ipv4_udp_tmplt = {
 	ICE_FLOW_SEG_HDR_IPV4 | ICE_FLOW_SEG_HDR_IPV_OTHER |
 	ICE_FLOW_SEG_HDR_UDP,
@@ -220,6 +233,7 @@ struct ice_rss_hash_cfg outer_ipv4_inner_ipv6_tmplt = {
 	ICE_RSS_INNER_HEADERS_W_OUTER_IPV4,
 	0
 };
+
 struct ice_rss_hash_cfg outer_ipv4_inner_ipv6_udp_tmplt = {
 	ICE_FLOW_SEG_HDR_IPV6 | ICE_FLOW_SEG_HDR_IPV_OTHER |
 	ICE_FLOW_SEG_HDR_UDP,
@@ -353,7 +367,8 @@ struct ice_rss_hash_cfg empty_tmplt = {
 };
 
 /* IPv4 */
-#define ICE_RSS_TYPE_ETH_IPV4		(ETH_RSS_ETH | ETH_RSS_IPV4)
+#define ICE_RSS_TYPE_ETH_IPV4		(ETH_RSS_ETH | ETH_RSS_IPV4 | \
+					 ETH_RSS_FRAG_IPV4)
 #define ICE_RSS_TYPE_ETH_IPV4_UDP	(ICE_RSS_TYPE_ETH_IPV4 | \
 					 ETH_RSS_NONFRAG_IPV4_UDP)
 #define ICE_RSS_TYPE_ETH_IPV4_TCP	(ICE_RSS_TYPE_ETH_IPV4 | \
@@ -370,6 +385,8 @@ struct ice_rss_hash_cfg empty_tmplt = {
 
 /* IPv6 */
 #define ICE_RSS_TYPE_ETH_IPV6		(ETH_RSS_ETH | ETH_RSS_IPV6)
+#define ICE_RSS_TYPE_ETH_IPV6_FRAG	(ETH_RSS_ETH | ETH_RSS_IPV6 | \
+					 ETH_RSS_FRAG_IPV6)
 #define ICE_RSS_TYPE_ETH_IPV6_UDP	(ICE_RSS_TYPE_ETH_IPV6 | \
 					 ETH_RSS_NONFRAG_IPV6_UDP)
 #define ICE_RSS_TYPE_ETH_IPV6_TCP	(ICE_RSS_TYPE_ETH_IPV6 | \
@@ -386,7 +403,8 @@ struct ice_rss_hash_cfg empty_tmplt = {
 
 /* VLAN IPV4 */
 #define ICE_RSS_TYPE_VLAN_IPV4		(ICE_RSS_TYPE_IPV4 | \
-					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
+					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN | \
+					 ETH_RSS_FRAG_IPV4)
 #define ICE_RSS_TYPE_VLAN_IPV4_UDP	(ICE_RSS_TYPE_IPV4_UDP | \
 					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
 #define ICE_RSS_TYPE_VLAN_IPV4_TCP	(ICE_RSS_TYPE_IPV4_TCP | \
@@ -396,6 +414,9 @@ struct ice_rss_hash_cfg empty_tmplt = {
 /* VLAN IPv6 */
 #define ICE_RSS_TYPE_VLAN_IPV6		(ICE_RSS_TYPE_IPV6 | \
 					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
+#define ICE_RSS_TYPE_VLAN_IPV6_FRAG	(ICE_RSS_TYPE_IPV6 | \
+					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN | \
+					 ETH_RSS_FRAG_IPV6)
 #define ICE_RSS_TYPE_VLAN_IPV6_UDP	(ICE_RSS_TYPE_IPV6_UDP | \
 					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
 #define ICE_RSS_TYPE_VLAN_IPV6_TCP	(ICE_RSS_TYPE_IPV6_TCP | \
@@ -485,10 +506,12 @@ static struct ice_pattern_match_item ice_hash_pattern_list[] = {
 	{pattern_eth_ipv4_pfcp,			ICE_RSS_TYPE_IPV4_PFCP,		ICE_INSET_NONE,	&eth_ipv4_pfcp_tmplt},
 	/* IPV6 */
 	{pattern_eth_ipv6,			ICE_RSS_TYPE_ETH_IPV6,		ICE_INSET_NONE,	&ipv6_tmplt},
+	{pattern_eth_ipv6_frag_ext,		ICE_RSS_TYPE_ETH_IPV6_FRAG,	ICE_INSET_NONE,	&ipv6_frag_tmplt},
 	{pattern_eth_ipv6_udp,			ICE_RSS_TYPE_ETH_IPV6_UDP,	ICE_INSET_NONE,	&ipv6_udp_tmplt},
 	{pattern_eth_ipv6_tcp,			ICE_RSS_TYPE_ETH_IPV6_TCP,	ICE_INSET_NONE,	&ipv6_tcp_tmplt},
 	{pattern_eth_ipv6_sctp,			ICE_RSS_TYPE_ETH_IPV6_SCTP,	ICE_INSET_NONE,	&ipv6_sctp_tmplt},
 	{pattern_eth_vlan_ipv6,			ICE_RSS_TYPE_VLAN_IPV6,		ICE_INSET_NONE,	&ipv6_tmplt},
+	{pattern_eth_vlan_ipv6_frag_ext,	ICE_RSS_TYPE_VLAN_IPV6_FRAG,	ICE_INSET_NONE, &ipv6_frag_tmplt},
 	{pattern_eth_vlan_ipv6_udp,		ICE_RSS_TYPE_VLAN_IPV6_UDP,	ICE_INSET_NONE,	&ipv6_udp_tmplt},
 	{pattern_eth_vlan_ipv6_tcp,		ICE_RSS_TYPE_VLAN_IPV6_TCP,	ICE_INSET_NONE,	&ipv6_tcp_tmplt},
 	{pattern_eth_vlan_ipv6_sctp,		ICE_RSS_TYPE_VLAN_IPV6_SCTP,	ICE_INSET_NONE,	&ipv6_sctp_tmplt},
@@ -629,11 +652,14 @@ ice_refine_hash_cfg_l234(struct ice_rss_hash_cfg *hash_cfg,
 
 	if (*addl_hdrs & ICE_FLOW_SEG_HDR_IPV4) {
 		if (rss_type &
-		   (ETH_RSS_IPV4 |
+		   (ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 |
 		    ETH_RSS_NONFRAG_IPV4_UDP |
 		    ETH_RSS_NONFRAG_IPV4_TCP |
 		    ETH_RSS_NONFRAG_IPV4_SCTP)) {
-			if (rss_type & ETH_RSS_L3_SRC_ONLY)
+			if (rss_type & ETH_RSS_FRAG_IPV4)
+				*hash_flds &=
+					~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_ID));
+			else if (rss_type & ETH_RSS_L3_SRC_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA));
 			else if (rss_type & ETH_RSS_L3_DST_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA));
@@ -648,11 +674,14 @@ ice_refine_hash_cfg_l234(struct ice_rss_hash_cfg *hash_cfg,
 
 	if (*addl_hdrs & ICE_FLOW_SEG_HDR_IPV6) {
 		if (rss_type &
-		   (ETH_RSS_IPV6 |
+		   (ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 |
 		    ETH_RSS_NONFRAG_IPV6_UDP |
 		    ETH_RSS_NONFRAG_IPV6_TCP |
 		    ETH_RSS_NONFRAG_IPV6_SCTP)) {
-			if (rss_type & ETH_RSS_L3_SRC_ONLY)
+			if (rss_type & ETH_RSS_FRAG_IPV6)
+				*hash_flds &=
+					~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_ID));
+			else if (rss_type & ETH_RSS_L3_SRC_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA));
 			else if (rss_type & ETH_RSS_L3_DST_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA));
@@ -827,6 +856,8 @@ static void ice_refine_hash_cfg(struct ice_rss_hash_cfg *hash_cfg,
 static uint64_t invalid_rss_comb[] = {
 	ETH_RSS_IPV4 | ETH_RSS_NONFRAG_IPV4_UDP,
 	ETH_RSS_IPV6 | ETH_RSS_NONFRAG_IPV6_UDP,
+	ETH_RSS_FRAG_IPV4 | ETH_RSS_NONFRAG_IPV4_UDP,
+	ETH_RSS_FRAG_IPV6 | ETH_RSS_NONFRAG_IPV6_UDP,
 	RTE_ETH_RSS_L3_PRE40 |
 	RTE_ETH_RSS_L3_PRE56 |
 	RTE_ETH_RSS_L3_PRE96
@@ -865,6 +896,7 @@ ice_any_invalid_rss_type(enum rte_eth_hash_function rss_func,
 
 		if (!(rss_type &
 		   (ETH_RSS_IPV4 | ETH_RSS_IPV6 |
+		    ETH_RSS_FRAG_IPV4 | ETH_RSS_FRAG_IPV6 |
 		    ETH_RSS_NONFRAG_IPV4_UDP | ETH_RSS_NONFRAG_IPV6_UDP |
 		    ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_NONFRAG_IPV6_TCP |
 		    ETH_RSS_NONFRAG_IPV4_SCTP | ETH_RSS_NONFRAG_IPV6_SCTP)))
-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v1 3/3] net/ice: support FDIR for IP fragment packet
  2021-03-17  3:43 [dpdk-dev] [PATCH v1 0/3] support flow for IP fragment in ICE Jeff Guo
  2021-03-17  3:43 ` [dpdk-dev] [PATCH v1 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
  2021-03-17  3:43 ` [dpdk-dev] [PATCH v1 2/3] net/ice: support RSS hash for IP fragment Jeff Guo
@ 2021-03-17  3:43 ` Jeff Guo
  2021-03-24 13:54 ` [dpdk-dev] [PATCH v2 0/3] support flow for IP fragment in ICE Jeff Guo
  3 siblings, 0 replies; 42+ messages in thread
From: Jeff Guo @ 2021-03-17  3:43 UTC (permalink / raw)
  To: qiming.yang, qi.z.zhang; +Cc: ting.xu, dev, jia.guo

New FDIR parsing are added to handle the fragmented IPv4/IPv6 packet.

Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
 drivers/net/ice/ice_fdir_filter.c | 87 ++++++++++++++++++++++++++-----
 1 file changed, 73 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
index 3af5812660..3473c05244 100644
--- a/drivers/net/ice/ice_fdir_filter.c
+++ b/drivers/net/ice/ice_fdir_filter.c
@@ -24,7 +24,7 @@
 #define ICE_FDIR_INSET_ETH_IPV4 (\
 	ICE_FDIR_INSET_ETH | \
 	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | ICE_INSET_IPV4_TOS | \
-	ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO)
+	ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO | ICE_INSET_IPV4_PKID)
 
 #define ICE_FDIR_INSET_ETH_IPV4_UDP (\
 	ICE_FDIR_INSET_ETH_IPV4 | \
@@ -41,7 +41,8 @@
 #define ICE_FDIR_INSET_ETH_IPV6 (\
 	ICE_INSET_DMAC | \
 	ICE_INSET_IPV6_SRC | ICE_INSET_IPV6_DST | ICE_INSET_IPV6_TC | \
-	ICE_INSET_IPV6_HOP_LIMIT | ICE_INSET_IPV6_NEXT_HDR)
+	ICE_INSET_IPV6_HOP_LIMIT | ICE_INSET_IPV6_NEXT_HDR | \
+	ICE_INSET_IPV6_PKID)
 
 #define ICE_FDIR_INSET_ETH_IPV6_UDP (\
 	ICE_FDIR_INSET_ETH_IPV6 | \
@@ -56,7 +57,8 @@
 	ICE_INSET_SCTP_SRC_PORT | ICE_INSET_SCTP_DST_PORT)
 
 #define ICE_FDIR_INSET_IPV4 (\
-	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST)
+	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | \
+	ICE_INSET_IPV4_PKID)
 
 #define ICE_FDIR_INSET_IPV4_TCP (\
 	ICE_FDIR_INSET_IPV4 | \
@@ -72,7 +74,8 @@
 
 #define ICE_FDIR_INSET_ETH_IPV4_VXLAN (\
 	ICE_FDIR_INSET_ETH | \
-	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST)
+	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | \
+	ICE_INSET_IPV4_PKID)
 
 #define ICE_FDIR_INSET_IPV4_GTPU (\
 	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | ICE_INSET_GTPU_TEID)
@@ -95,6 +98,7 @@ static struct ice_pattern_match_item ice_fdir_pattern_list[] = {
 	{pattern_eth_ipv4_tcp,				ICE_FDIR_INSET_ETH_IPV4_TCP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv4_sctp,				ICE_FDIR_INSET_ETH_IPV4_SCTP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6,				ICE_FDIR_INSET_ETH_IPV6,	ICE_INSET_NONE,			ICE_INSET_NONE},
+	{pattern_eth_ipv6_frag_ext,			ICE_FDIR_INSET_ETH_IPV6,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6_udp,				ICE_FDIR_INSET_ETH_IPV6_UDP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6_tcp,				ICE_FDIR_INSET_ETH_IPV6_TCP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6_sctp,				ICE_FDIR_INSET_ETH_IPV6_SCTP,	ICE_INSET_NONE,			ICE_INSET_NONE},
@@ -882,11 +886,13 @@ ice_fdir_input_set_parse(uint64_t inset, enum ice_flow_field *field)
 		{ICE_INSET_IPV4_TOS, ICE_FLOW_FIELD_IDX_IPV4_DSCP},
 		{ICE_INSET_IPV4_TTL, ICE_FLOW_FIELD_IDX_IPV4_TTL},
 		{ICE_INSET_IPV4_PROTO, ICE_FLOW_FIELD_IDX_IPV4_PROT},
+		{ICE_INSET_IPV4_PKID, ICE_FLOW_FIELD_IDX_IPV4_ID},
 		{ICE_INSET_IPV6_SRC, ICE_FLOW_FIELD_IDX_IPV6_SA},
 		{ICE_INSET_IPV6_DST, ICE_FLOW_FIELD_IDX_IPV6_DA},
 		{ICE_INSET_IPV6_TC, ICE_FLOW_FIELD_IDX_IPV6_DSCP},
 		{ICE_INSET_IPV6_NEXT_HDR, ICE_FLOW_FIELD_IDX_IPV6_PROT},
 		{ICE_INSET_IPV6_HOP_LIMIT, ICE_FLOW_FIELD_IDX_IPV6_TTL},
+		{ICE_INSET_IPV6_PKID, ICE_FLOW_FIELD_IDX_IPV6_ID},
 		{ICE_INSET_TCP_SRC_PORT, ICE_FLOW_FIELD_IDX_TCP_SRC_PORT},
 		{ICE_INSET_TCP_DST_PORT, ICE_FLOW_FIELD_IDX_TCP_DST_PORT},
 		{ICE_INSET_UDP_SRC_PORT, ICE_FLOW_FIELD_IDX_UDP_SRC_PORT},
@@ -935,6 +941,10 @@ ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct ice_flow_seg_info *seg)
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4 |
 				  ICE_FLOW_SEG_HDR_IPV_OTHER);
 		break;
+	case ICE_FLTR_PTYPE_FRAG_IPV4:
+		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4 |
+				  ICE_FLOW_SEG_HDR_IPV_FRAG);
+		break;
 	case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP |
 				  ICE_FLOW_SEG_HDR_IPV6 |
@@ -951,6 +961,10 @@ ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct ice_flow_seg_info *seg)
 				  ICE_FLOW_SEG_HDR_IPV_OTHER);
 		break;
 	case ICE_FLTR_PTYPE_NONF_IPV6_OTHER:
+		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6 |
+				  ICE_FLOW_SEG_HDR_IPV_FRAG);
+		break;
+	case ICE_FLTR_PTYPE_FRAG_IPV6:
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6 |
 				  ICE_FLOW_SEG_HDR_IPV_OTHER);
 		break;
@@ -1592,8 +1606,10 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 	enum rte_flow_item_type l3 = RTE_FLOW_ITEM_TYPE_END;
 	enum ice_fdir_tunnel_type tunnel_type = ICE_FDIR_TUNNEL_TYPE_NONE;
 	const struct rte_flow_item_eth *eth_spec, *eth_mask;
-	const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_mask;
+	const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_last, *ipv4_mask;
 	const struct rte_flow_item_ipv6 *ipv6_spec, *ipv6_mask;
+	const struct rte_flow_item_ipv6_frag_ext *ipv6_frag_spec,
+					*ipv6_frag_last, *ipv6_frag_mask;
 	const struct rte_flow_item_tcp *tcp_spec, *tcp_mask;
 	const struct rte_flow_item_udp *udp_spec, *udp_mask;
 	const struct rte_flow_item_sctp *sctp_spec, *sctp_mask;
@@ -1615,6 +1631,7 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 	struct ice_fdir_extra *p_ext_data;
 	struct ice_fdir_v4 *p_v4 = NULL;
 	struct ice_fdir_v6 *p_v6 = NULL;
+	bool spec_all_pid = false;
 
 	for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
 		if (item->type == RTE_FLOW_ITEM_TYPE_VXLAN)
@@ -1632,13 +1649,6 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 	 * flow. input_set_i is used for inner part.
 	 */
 	for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
-		if (item->last) {
-			rte_flow_error_set(error, EINVAL,
-					   RTE_FLOW_ERROR_TYPE_ITEM,
-					   item,
-					   "Not support range");
-			return -rte_errno;
-		}
 		item_type = item->type;
 
 		input_set = (tunnel_type && !is_outer) ?
@@ -1689,6 +1699,7 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			flow_type = ICE_FLTR_PTYPE_NONF_IPV4_OTHER;
 			l3 = RTE_FLOW_ITEM_TYPE_IPV4;
 			ipv4_spec = item->spec;
+			ipv4_last = item->last;
 			ipv4_mask = item->mask;
 			p_v4 = (tunnel_type && is_outer) ?
 			       &filter->input.ip_outer.v4 :
@@ -1700,8 +1711,6 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			/* Check IPv4 mask and update input set */
 			if (ipv4_mask->hdr.version_ihl ||
 			    ipv4_mask->hdr.total_length ||
-			    ipv4_mask->hdr.packet_id ||
-			    ipv4_mask->hdr.fragment_offset ||
 			    ipv4_mask->hdr.hdr_checksum) {
 				rte_flow_error_set(error, EINVAL,
 						   RTE_FLOW_ERROR_TYPE_ITEM,
@@ -1726,6 +1735,25 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			p_v4->ttl = ipv4_spec->hdr.time_to_live;
 			p_v4->proto = ipv4_spec->hdr.next_proto_id;
 			p_v4->tos = ipv4_spec->hdr.type_of_service;
+
+			if (ipv4_mask->hdr.packet_id == UINT16_MAX ||
+			    ipv4_mask->hdr.fragment_offset == UINT16_MAX) {
+				if (ipv4_last &&
+				    ipv4_spec->hdr.packet_id == 0 &&
+				    ipv4_last->hdr.packet_id == 0xffff)
+					spec_all_pid = true;
+
+				/* All IPv4 fragment packet has the
+				 * same ethertype, if the spec is for
+				 * all invalid packet id, set the
+				 * ethertype into input set.
+				 */
+				*input_set |= spec_all_pid ?
+						ICE_INSET_ETHERTYPE :
+						ICE_INSET_IPV4_PKID;
+				flow_type = ICE_FLTR_PTYPE_FRAG_IPV4;
+				break;
+			}
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV6:
 			flow_type = ICE_FLTR_PTYPE_NONF_IPV6_OTHER;
@@ -1771,6 +1799,37 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			p_v6->proto = ipv6_spec->hdr.proto;
 			p_v6->hlim = ipv6_spec->hdr.hop_limits;
 			break;
+		case RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT:
+			l3 = RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT;
+			ipv6_frag_spec = item->spec;
+			ipv6_frag_last = item->last;
+			ipv6_frag_mask = item->mask;
+
+			if (ipv6_frag_spec && ipv6_frag_mask) {
+				if (ipv6_frag_mask->hdr.id == UINT32_MAX ||
+				    ipv6_frag_mask->hdr.frag_data ==
+				    UINT16_MAX) {
+					if (ipv6_frag_last &&
+					    ipv6_frag_spec->hdr.id == 0 &&
+					    ipv6_frag_last->hdr.id ==
+					    0xffffffff)
+						spec_all_pid = true;
+
+					/* All IPv6 fragment packet has the
+					 * same ethertype, if the spec is for
+					 * all invalid packet id, set the
+					 * ethertype into input set.
+					 */
+					*input_set |= spec_all_pid ?
+							ICE_INSET_ETHERTYPE :
+							ICE_INSET_IPV6_PKID;
+				}
+				flow_type = ICE_FLTR_PTYPE_FRAG_IPV6;
+			} else {
+				flow_type = ICE_FLTR_PTYPE_NONF_IPV6_OTHER;
+			}
+			break;
+
 		case RTE_FLOW_ITEM_TYPE_TCP:
 			if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
 				flow_type = ICE_FLTR_PTYPE_NONF_IPV4_TCP;
-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v2 0/3] support flow for IP fragment in ICE
  2021-03-17  3:43 [dpdk-dev] [PATCH v1 0/3] support flow for IP fragment in ICE Jeff Guo
                   ` (2 preceding siblings ...)
  2021-03-17  3:43 ` [dpdk-dev] [PATCH v1 3/3] net/ice: support FDIR for IP fragment packet Jeff Guo
@ 2021-03-24 13:54 ` Jeff Guo
  2021-03-24 13:54   ` [dpdk-dev] [PATCH v2 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
                     ` (8 more replies)
  3 siblings, 9 replies; 42+ messages in thread
From: Jeff Guo @ 2021-03-24 13:54 UTC (permalink / raw)
  To: qiming.yang, qi.z.zhang; +Cc: ting.xu, dev, jia.guo

Support RSS hash and FDIR for IP fragment packets in ICE PMD.

v2:
add some input check

Jeff Guo (3):
  net/ice/base: support IP fragment RSS and FDIR
  net/ice: support RSS hash for IP fragment
  net/ice: support FDIR for IP fragment packet

 drivers/net/ice/base/ice_fdir.c    | 50 +++++++++++++++-
 drivers/net/ice/base/ice_fdir.h    | 22 +++++--
 drivers/net/ice/base/ice_flow.c    | 50 +++++++++++++++-
 drivers/net/ice/base/ice_flow.h    |  5 +-
 drivers/net/ice/base/ice_type.h    |  1 +
 drivers/net/ice/ice_fdir_filter.c  | 96 ++++++++++++++++++++++++++----
 drivers/net/ice/ice_generic_flow.c | 21 +++++++
 drivers/net/ice/ice_generic_flow.h |  6 ++
 drivers/net/ice/ice_hash.c         | 48 ++++++++++++---
 9 files changed, 272 insertions(+), 27 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v2 1/3] net/ice/base: support IP fragment RSS and FDIR
  2021-03-24 13:54 ` [dpdk-dev] [PATCH v2 0/3] support flow for IP fragment in ICE Jeff Guo
@ 2021-03-24 13:54   ` Jeff Guo
  2021-03-24 13:54   ` [dpdk-dev] [PATCH v2 2/3] net/ice: support RSS hash for IP fragment Jeff Guo
                     ` (7 subsequent siblings)
  8 siblings, 0 replies; 42+ messages in thread
From: Jeff Guo @ 2021-03-24 13:54 UTC (permalink / raw)
  To: qiming.yang, qi.z.zhang; +Cc: ting.xu, dev, jia.guo

Add support for IP fragment RSS hash and FDIR according to packet ID.
Separate IP fragment and IP other packet types.

Signed-off-by: Ting Xu <ting.xu@intel.com>
Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
 drivers/net/ice/base/ice_fdir.c | 50 +++++++++++++++++++++++++++++++--
 drivers/net/ice/base/ice_fdir.h | 22 ++++++++++++---
 drivers/net/ice/base/ice_flow.c | 50 ++++++++++++++++++++++++++++++++-
 drivers/net/ice/base/ice_flow.h |  5 +++-
 drivers/net/ice/base/ice_type.h |  1 +
 5 files changed, 120 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ice/base/ice_fdir.c b/drivers/net/ice/base/ice_fdir.c
index 2b39c13127..0eb7cdd729 100644
--- a/drivers/net/ice/base/ice_fdir.c
+++ b/drivers/net/ice/base/ice_fdir.c
@@ -518,6 +518,24 @@ 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 +734,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_pkt), ice_fdir_ipv4_frag_pkt,
+		sizeof(ice_fdir_ipv4_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),
@@ -1505,7 +1533,7 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
 		ice_pkt_insert_u8(loc, ICE_IPV4_TTL_OFFSET, input->ip.v4.ttl);
 		ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
 		if (frag)
-			loc[20] = ICE_FDIR_IPV4_PKT_FLAG_DF;
+			loc[20] = ICE_FDIR_IPV4_PKT_FLAG_MF;
 		break;
 	case ICE_FLTR_PTYPE_NONF_IPV4_UDP:
 		ice_pkt_insert_mac_addr(pkt, input->ext_data_outer.dst_mac);
@@ -1808,6 +1836,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 +1883,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;
diff --git a/drivers/net/ice/base/ice_fdir.h b/drivers/net/ice/base/ice_fdir.h
index 6573f96bc1..2acc1d6f1b 100644
--- a/drivers/net/ice/base/ice_fdir.h
+++ b/drivers/net/ice/base/ice_fdir.h
@@ -43,9 +43,11 @@
 #define ICE_MAC_ETHTYPE_OFFSET		12
 #define ICE_IPV4_TOS_OFFSET		15
 #define ICE_IPV4_TTL_OFFSET		22
+#define ICE_IPV4_ID_OFFSET		18
 #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
@@ -83,12 +85,22 @@
 
 #define ICE_FDIR_MAX_FLTRS		16384
 
-/* IP v4 has 2 flag bits that enable fragment processing: DF and MF. DF
+/* IPv4 has 2 flag bits that enable fragment processing: DF and MF. DF
  * requests that the packet not be fragmented. MF indicates that a packet has
- * been fragmented.
+ * been fragmented, except that for the last fragment has a non-zero
+ * Fragment Offset field with zero MF.
  */
-#define ICE_FDIR_IPV4_PKT_FLAG_DF		0x20
-#define ICE_FDIR_IPV4_PKT_FLAG_MF		0x40
+#define ICE_FDIR_IPV4_PKT_FLAG_MF		0x20
+#define ICE_FDIR_IPV4_PKT_FLAG_MF_SHIFT	8
+#ifndef NO_UNUSED_PACKAGE_CODE
+#define ICE_FDIR_IPV4_PKT_FLAG_DF		0x40
+#endif /* NO_UNUSED_PACKAGE_CODE */
+
+/* For IPv6 fragmented packets, all fragments except the last have
+ * the MF flag set.
+ */
+#define ICE_FDIR_IPV6_PKT_FLAG_MF		0x100
+#define ICE_FDIR_IPV6_PKT_FLAG_MF_SHIFT	8
 
 enum ice_fltr_prgm_desc_dest {
 	ICE_FLTR_PRGM_DESC_DEST_DROP_PKT,
@@ -150,6 +162,7 @@ struct ice_fdir_v4 {
 	u8 ip_ver;
 	u8 proto;
 	u8 ttl;
+	__be16 packet_id;
 };
 
 #define ICE_IPV6_ADDR_LEN_AS_U32		4
@@ -164,6 +177,7 @@ struct ice_fdir_v6 {
 	u8 tc;
 	u8 proto;
 	u8 hlim;
+	__be32 packet_id;
 };
 
 struct ice_fdir_udp_gtp {
diff --git a/drivers/net/ice/base/ice_flow.c b/drivers/net/ice/base/ice_flow.c
index d123206fc6..019feec116 100644
--- a/drivers/net/ice/base/ice_flow.c
+++ b/drivers/net/ice/base/ice_flow.c
@@ -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),
@@ -725,6 +733,27 @@ static const u32 ice_ptypes_udp_ecpri_tp0[] = {
 	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;
@@ -899,6 +928,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 :
@@ -1177,6 +1216,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:
@@ -1187,6 +1229,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:
@@ -3341,13 +3386,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);
diff --git a/drivers/net/ice/base/ice_flow.h b/drivers/net/ice/base/ice_flow.h
index c3bce13194..761e14e1d4 100644
--- a/drivers/net/ice/base/ice_flow.h
+++ b/drivers/net/ice/base/ice_flow.h
@@ -186,8 +186,9 @@ enum ice_flow_seg_hdr {
 	ICE_FLOW_SEG_HDR_ECPRI_TP0	= 0x04000000,
 	ICE_FLOW_SEG_HDR_UDP_ECPRI_TP0	= 0x08000000,
 	/* 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_FRAG	= 0x10000000,
 	ICE_FLOW_SEG_HDR_IPV_OTHER	= 0x20000000,
 };
 
@@ -225,6 +226,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,
diff --git a/drivers/net/ice/base/ice_type.h b/drivers/net/ice/base/ice_type.h
index a6599363f9..5abe9dc9ea 100644
--- a/drivers/net/ice/base/ice_type.h
+++ b/drivers/net/ice/base/ice_type.h
@@ -349,6 +349,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,
-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v2 2/3] net/ice: support RSS hash for IP fragment
  2021-03-24 13:54 ` [dpdk-dev] [PATCH v2 0/3] support flow for IP fragment in ICE Jeff Guo
  2021-03-24 13:54   ` [dpdk-dev] [PATCH v2 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
@ 2021-03-24 13:54   ` Jeff Guo
  2021-03-24 13:54   ` [dpdk-dev] [PATCH v2 3/3] net/ice: support FDIR for IP fragment packet Jeff Guo
                     ` (6 subsequent siblings)
  8 siblings, 0 replies; 42+ messages in thread
From: Jeff Guo @ 2021-03-24 13:54 UTC (permalink / raw)
  To: qiming.yang, qi.z.zhang; +Cc: ting.xu, dev, jia.guo

New pattern and RSS hash flow parsing are added to handle fragmented
IPv4/IPv6  packet.

Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
 drivers/net/ice/ice_generic_flow.c | 21 +++++++++++++
 drivers/net/ice/ice_generic_flow.h |  6 ++++
 drivers/net/ice/ice_hash.c         | 48 +++++++++++++++++++++++++-----
 3 files changed, 67 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ice/ice_generic_flow.c b/drivers/net/ice/ice_generic_flow.c
index 8704812622..2389bc6637 100644
--- a/drivers/net/ice/ice_generic_flow.c
+++ b/drivers/net/ice/ice_generic_flow.c
@@ -212,6 +212,27 @@ enum rte_flow_item_type pattern_eth_qinq_ipv6[] = {
 	RTE_FLOW_ITEM_TYPE_IPV6,
 	RTE_FLOW_ITEM_TYPE_END,
 };
+enum rte_flow_item_type pattern_eth_ipv6_frag_ext[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+enum rte_flow_item_type pattern_eth_vlan_ipv6_frag_ext[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_VLAN,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+enum rte_flow_item_type pattern_eth_qinq_ipv6_frag_ext[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_VLAN,
+	RTE_FLOW_ITEM_TYPE_VLAN,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+	RTE_FLOW_ITEM_TYPE_END,
+};
 enum rte_flow_item_type pattern_eth_ipv6_udp[] = {
 	RTE_FLOW_ITEM_TYPE_ETH,
 	RTE_FLOW_ITEM_TYPE_IPV6,
diff --git a/drivers/net/ice/ice_generic_flow.h b/drivers/net/ice/ice_generic_flow.h
index 9f422e5925..2afe719264 100644
--- a/drivers/net/ice/ice_generic_flow.h
+++ b/drivers/net/ice/ice_generic_flow.h
@@ -52,6 +52,7 @@
 #define ICE_L2TPV3OIP_SESSION_ID	BIT_ULL(43)
 #define ICE_PFCP_SEID			BIT_ULL(42)
 #define ICE_PFCP_S_FIELD		BIT_ULL(41)
+#define ICE_IP_PK_ID		    BIT_ULL(40)
 
 /* input set */
 
@@ -69,11 +70,13 @@
 #define ICE_INSET_IPV4_TOS		(ICE_PROT_IPV4 | ICE_IP_TOS)
 #define ICE_INSET_IPV4_PROTO		(ICE_PROT_IPV4 | ICE_IP_PROTO)
 #define ICE_INSET_IPV4_TTL		(ICE_PROT_IPV4 | ICE_IP_TTL)
+#define ICE_INSET_IPV4_PKID		(ICE_PROT_IPV4 | ICE_IP_PK_ID)
 #define ICE_INSET_IPV6_SRC		(ICE_PROT_IPV6 | ICE_IP_SRC)
 #define ICE_INSET_IPV6_DST		(ICE_PROT_IPV6 | ICE_IP_DST)
 #define ICE_INSET_IPV6_NEXT_HDR		(ICE_PROT_IPV6 | ICE_IP_PROTO)
 #define ICE_INSET_IPV6_HOP_LIMIT	(ICE_PROT_IPV6 | ICE_IP_TTL)
 #define ICE_INSET_IPV6_TC		(ICE_PROT_IPV6 | ICE_IP_TOS)
+#define ICE_INSET_IPV6_PKID		(ICE_PROT_IPV6 | ICE_IP_PK_ID)
 
 #define ICE_INSET_TCP_SRC_PORT		(ICE_PROT_TCP | ICE_SPORT)
 #define ICE_INSET_TCP_DST_PORT		(ICE_PROT_TCP | ICE_DPORT)
@@ -202,6 +205,9 @@ extern enum rte_flow_item_type pattern_eth_qinq_ipv4_icmp[];
 extern enum rte_flow_item_type pattern_eth_ipv6[];
 extern enum rte_flow_item_type pattern_eth_vlan_ipv6[];
 extern enum rte_flow_item_type pattern_eth_qinq_ipv6[];
+extern enum rte_flow_item_type pattern_eth_ipv6_frag_ext[];
+extern enum rte_flow_item_type pattern_eth_vlan_ipv6_frag_ext[];
+extern enum rte_flow_item_type pattern_eth_qinq_ipv6_frag_ext[];
 extern enum rte_flow_item_type pattern_eth_ipv6_udp[];
 extern enum rte_flow_item_type pattern_eth_vlan_ipv6_udp[];
 extern enum rte_flow_item_type pattern_eth_qinq_ipv6_udp[];
diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c
index 58a0c18d09..b3ed9b219c 100644
--- a/drivers/net/ice/ice_hash.c
+++ b/drivers/net/ice/ice_hash.c
@@ -47,8 +47,10 @@
 				 ETH_RSS_NONFRAG_IPV6_TCP	| \
 				 ETH_RSS_NONFRAG_IPV6_SCTP)
 
-#define VALID_RSS_IPV4		(ETH_RSS_IPV4 | VALID_RSS_IPV4_L4)
-#define VALID_RSS_IPV6		(ETH_RSS_IPV6 | VALID_RSS_IPV6_L4)
+#define VALID_RSS_IPV4		(ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 | \
+				 VALID_RSS_IPV4_L4)
+#define VALID_RSS_IPV6		(ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 | \
+				 VALID_RSS_IPV6_L4)
 #define VALID_RSS_L3		(VALID_RSS_IPV4 | VALID_RSS_IPV6)
 #define VALID_RSS_L4		(VALID_RSS_IPV4_L4 | VALID_RSS_IPV6_L4)
 
@@ -108,6 +110,7 @@ ice_hash_parse_pattern_action(struct ice_adapter *ad,
 /* Rss configuration template */
 struct ice_rss_hash_cfg ipv4_tmplt = {
 	ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV4 |
+	ICE_FLOW_SEG_HDR_IPV_FRAG |
 	ICE_FLOW_SEG_HDR_IPV_OTHER,
 	ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_IPV4,
 	ICE_RSS_ANY_HEADERS,
@@ -146,6 +149,15 @@ struct ice_rss_hash_cfg ipv6_tmplt = {
 	0
 };
 
+struct ice_rss_hash_cfg ipv6_frag_tmplt = {
+	ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV6 |
+	ICE_FLOW_SEG_HDR_IPV_FRAG |
+	ICE_FLOW_SEG_HDR_IPV_OTHER,
+	ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_IPV6,
+	ICE_RSS_ANY_HEADERS,
+	0
+};
+
 struct ice_rss_hash_cfg ipv6_udp_tmplt = {
 	ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV6 |
 	ICE_FLOW_SEG_HDR_IPV_OTHER | ICE_FLOW_SEG_HDR_UDP,
@@ -198,6 +210,7 @@ struct ice_rss_hash_cfg outer_ipv6_inner_ipv4_tmplt = {
 	ICE_RSS_INNER_HEADERS_W_OUTER_IPV6,
 	0
 };
+
 struct ice_rss_hash_cfg outer_ipv6_inner_ipv4_udp_tmplt = {
 	ICE_FLOW_SEG_HDR_IPV4 | ICE_FLOW_SEG_HDR_IPV_OTHER |
 	ICE_FLOW_SEG_HDR_UDP,
@@ -220,6 +233,7 @@ struct ice_rss_hash_cfg outer_ipv4_inner_ipv6_tmplt = {
 	ICE_RSS_INNER_HEADERS_W_OUTER_IPV4,
 	0
 };
+
 struct ice_rss_hash_cfg outer_ipv4_inner_ipv6_udp_tmplt = {
 	ICE_FLOW_SEG_HDR_IPV6 | ICE_FLOW_SEG_HDR_IPV_OTHER |
 	ICE_FLOW_SEG_HDR_UDP,
@@ -353,7 +367,8 @@ struct ice_rss_hash_cfg empty_tmplt = {
 };
 
 /* IPv4 */
-#define ICE_RSS_TYPE_ETH_IPV4		(ETH_RSS_ETH | ETH_RSS_IPV4)
+#define ICE_RSS_TYPE_ETH_IPV4		(ETH_RSS_ETH | ETH_RSS_IPV4 | \
+					 ETH_RSS_FRAG_IPV4)
 #define ICE_RSS_TYPE_ETH_IPV4_UDP	(ICE_RSS_TYPE_ETH_IPV4 | \
 					 ETH_RSS_NONFRAG_IPV4_UDP)
 #define ICE_RSS_TYPE_ETH_IPV4_TCP	(ICE_RSS_TYPE_ETH_IPV4 | \
@@ -370,6 +385,8 @@ struct ice_rss_hash_cfg empty_tmplt = {
 
 /* IPv6 */
 #define ICE_RSS_TYPE_ETH_IPV6		(ETH_RSS_ETH | ETH_RSS_IPV6)
+#define ICE_RSS_TYPE_ETH_IPV6_FRAG	(ETH_RSS_ETH | ETH_RSS_IPV6 | \
+					 ETH_RSS_FRAG_IPV6)
 #define ICE_RSS_TYPE_ETH_IPV6_UDP	(ICE_RSS_TYPE_ETH_IPV6 | \
 					 ETH_RSS_NONFRAG_IPV6_UDP)
 #define ICE_RSS_TYPE_ETH_IPV6_TCP	(ICE_RSS_TYPE_ETH_IPV6 | \
@@ -386,7 +403,8 @@ struct ice_rss_hash_cfg empty_tmplt = {
 
 /* VLAN IPV4 */
 #define ICE_RSS_TYPE_VLAN_IPV4		(ICE_RSS_TYPE_IPV4 | \
-					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
+					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN | \
+					 ETH_RSS_FRAG_IPV4)
 #define ICE_RSS_TYPE_VLAN_IPV4_UDP	(ICE_RSS_TYPE_IPV4_UDP | \
 					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
 #define ICE_RSS_TYPE_VLAN_IPV4_TCP	(ICE_RSS_TYPE_IPV4_TCP | \
@@ -396,6 +414,9 @@ struct ice_rss_hash_cfg empty_tmplt = {
 /* VLAN IPv6 */
 #define ICE_RSS_TYPE_VLAN_IPV6		(ICE_RSS_TYPE_IPV6 | \
 					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
+#define ICE_RSS_TYPE_VLAN_IPV6_FRAG	(ICE_RSS_TYPE_IPV6 | \
+					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN | \
+					 ETH_RSS_FRAG_IPV6)
 #define ICE_RSS_TYPE_VLAN_IPV6_UDP	(ICE_RSS_TYPE_IPV6_UDP | \
 					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
 #define ICE_RSS_TYPE_VLAN_IPV6_TCP	(ICE_RSS_TYPE_IPV6_TCP | \
@@ -485,10 +506,12 @@ static struct ice_pattern_match_item ice_hash_pattern_list[] = {
 	{pattern_eth_ipv4_pfcp,			ICE_RSS_TYPE_IPV4_PFCP,		ICE_INSET_NONE,	&eth_ipv4_pfcp_tmplt},
 	/* IPV6 */
 	{pattern_eth_ipv6,			ICE_RSS_TYPE_ETH_IPV6,		ICE_INSET_NONE,	&ipv6_tmplt},
+	{pattern_eth_ipv6_frag_ext,		ICE_RSS_TYPE_ETH_IPV6_FRAG,	ICE_INSET_NONE,	&ipv6_frag_tmplt},
 	{pattern_eth_ipv6_udp,			ICE_RSS_TYPE_ETH_IPV6_UDP,	ICE_INSET_NONE,	&ipv6_udp_tmplt},
 	{pattern_eth_ipv6_tcp,			ICE_RSS_TYPE_ETH_IPV6_TCP,	ICE_INSET_NONE,	&ipv6_tcp_tmplt},
 	{pattern_eth_ipv6_sctp,			ICE_RSS_TYPE_ETH_IPV6_SCTP,	ICE_INSET_NONE,	&ipv6_sctp_tmplt},
 	{pattern_eth_vlan_ipv6,			ICE_RSS_TYPE_VLAN_IPV6,		ICE_INSET_NONE,	&ipv6_tmplt},
+	{pattern_eth_vlan_ipv6_frag_ext,	ICE_RSS_TYPE_VLAN_IPV6_FRAG,	ICE_INSET_NONE, &ipv6_frag_tmplt},
 	{pattern_eth_vlan_ipv6_udp,		ICE_RSS_TYPE_VLAN_IPV6_UDP,	ICE_INSET_NONE,	&ipv6_udp_tmplt},
 	{pattern_eth_vlan_ipv6_tcp,		ICE_RSS_TYPE_VLAN_IPV6_TCP,	ICE_INSET_NONE,	&ipv6_tcp_tmplt},
 	{pattern_eth_vlan_ipv6_sctp,		ICE_RSS_TYPE_VLAN_IPV6_SCTP,	ICE_INSET_NONE,	&ipv6_sctp_tmplt},
@@ -629,11 +652,14 @@ ice_refine_hash_cfg_l234(struct ice_rss_hash_cfg *hash_cfg,
 
 	if (*addl_hdrs & ICE_FLOW_SEG_HDR_IPV4) {
 		if (rss_type &
-		   (ETH_RSS_IPV4 |
+		   (ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 |
 		    ETH_RSS_NONFRAG_IPV4_UDP |
 		    ETH_RSS_NONFRAG_IPV4_TCP |
 		    ETH_RSS_NONFRAG_IPV4_SCTP)) {
-			if (rss_type & ETH_RSS_L3_SRC_ONLY)
+			if (rss_type & ETH_RSS_FRAG_IPV4)
+				*hash_flds &=
+					~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_ID));
+			else if (rss_type & ETH_RSS_L3_SRC_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA));
 			else if (rss_type & ETH_RSS_L3_DST_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA));
@@ -648,11 +674,14 @@ ice_refine_hash_cfg_l234(struct ice_rss_hash_cfg *hash_cfg,
 
 	if (*addl_hdrs & ICE_FLOW_SEG_HDR_IPV6) {
 		if (rss_type &
-		   (ETH_RSS_IPV6 |
+		   (ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 |
 		    ETH_RSS_NONFRAG_IPV6_UDP |
 		    ETH_RSS_NONFRAG_IPV6_TCP |
 		    ETH_RSS_NONFRAG_IPV6_SCTP)) {
-			if (rss_type & ETH_RSS_L3_SRC_ONLY)
+			if (rss_type & ETH_RSS_FRAG_IPV6)
+				*hash_flds &=
+					~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_ID));
+			else if (rss_type & ETH_RSS_L3_SRC_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA));
 			else if (rss_type & ETH_RSS_L3_DST_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA));
@@ -827,6 +856,8 @@ static void ice_refine_hash_cfg(struct ice_rss_hash_cfg *hash_cfg,
 static uint64_t invalid_rss_comb[] = {
 	ETH_RSS_IPV4 | ETH_RSS_NONFRAG_IPV4_UDP,
 	ETH_RSS_IPV6 | ETH_RSS_NONFRAG_IPV6_UDP,
+	ETH_RSS_FRAG_IPV4 | ETH_RSS_NONFRAG_IPV4_UDP,
+	ETH_RSS_FRAG_IPV6 | ETH_RSS_NONFRAG_IPV6_UDP,
 	RTE_ETH_RSS_L3_PRE40 |
 	RTE_ETH_RSS_L3_PRE56 |
 	RTE_ETH_RSS_L3_PRE96
@@ -865,6 +896,7 @@ ice_any_invalid_rss_type(enum rte_eth_hash_function rss_func,
 
 		if (!(rss_type &
 		   (ETH_RSS_IPV4 | ETH_RSS_IPV6 |
+		    ETH_RSS_FRAG_IPV4 | ETH_RSS_FRAG_IPV6 |
 		    ETH_RSS_NONFRAG_IPV4_UDP | ETH_RSS_NONFRAG_IPV6_UDP |
 		    ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_NONFRAG_IPV6_TCP |
 		    ETH_RSS_NONFRAG_IPV4_SCTP | ETH_RSS_NONFRAG_IPV6_SCTP)))
-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v2 3/3] net/ice: support FDIR for IP fragment packet
  2021-03-24 13:54 ` [dpdk-dev] [PATCH v2 0/3] support flow for IP fragment in ICE Jeff Guo
  2021-03-24 13:54   ` [dpdk-dev] [PATCH v2 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
  2021-03-24 13:54   ` [dpdk-dev] [PATCH v2 2/3] net/ice: support RSS hash for IP fragment Jeff Guo
@ 2021-03-24 13:54   ` Jeff Guo
  2021-03-30  3:25     ` Xu, Ting
  2021-04-01  2:08     ` Xu, Ting
  2021-04-11  6:06   ` [dpdk-dev] [PATCH v3 0/3] support flow for IP fragment in ICE Jeff Guo
                     ` (5 subsequent siblings)
  8 siblings, 2 replies; 42+ messages in thread
From: Jeff Guo @ 2021-03-24 13:54 UTC (permalink / raw)
  To: qiming.yang, qi.z.zhang; +Cc: ting.xu, dev, jia.guo

New FDIR parsing are added to handle the fragmented IPv4/IPv6 packet.

Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
 drivers/net/ice/ice_fdir_filter.c | 96 +++++++++++++++++++++++++++----
 1 file changed, 85 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
index 3af5812660..3504d3c6c2 100644
--- a/drivers/net/ice/ice_fdir_filter.c
+++ b/drivers/net/ice/ice_fdir_filter.c
@@ -24,7 +24,7 @@
 #define ICE_FDIR_INSET_ETH_IPV4 (\
 	ICE_FDIR_INSET_ETH | \
 	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | ICE_INSET_IPV4_TOS | \
-	ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO)
+	ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO | ICE_INSET_IPV4_PKID)
 
 #define ICE_FDIR_INSET_ETH_IPV4_UDP (\
 	ICE_FDIR_INSET_ETH_IPV4 | \
@@ -41,7 +41,8 @@
 #define ICE_FDIR_INSET_ETH_IPV6 (\
 	ICE_INSET_DMAC | \
 	ICE_INSET_IPV6_SRC | ICE_INSET_IPV6_DST | ICE_INSET_IPV6_TC | \
-	ICE_INSET_IPV6_HOP_LIMIT | ICE_INSET_IPV6_NEXT_HDR)
+	ICE_INSET_IPV6_HOP_LIMIT | ICE_INSET_IPV6_NEXT_HDR | \
+	ICE_INSET_IPV6_PKID)
 
 #define ICE_FDIR_INSET_ETH_IPV6_UDP (\
 	ICE_FDIR_INSET_ETH_IPV6 | \
@@ -56,7 +57,8 @@
 	ICE_INSET_SCTP_SRC_PORT | ICE_INSET_SCTP_DST_PORT)
 
 #define ICE_FDIR_INSET_IPV4 (\
-	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST)
+	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | \
+	ICE_INSET_IPV4_PKID)
 
 #define ICE_FDIR_INSET_IPV4_TCP (\
 	ICE_FDIR_INSET_IPV4 | \
@@ -72,7 +74,8 @@
 
 #define ICE_FDIR_INSET_ETH_IPV4_VXLAN (\
 	ICE_FDIR_INSET_ETH | \
-	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST)
+	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | \
+	ICE_INSET_IPV4_PKID)
 
 #define ICE_FDIR_INSET_IPV4_GTPU (\
 	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | ICE_INSET_GTPU_TEID)
@@ -95,6 +98,7 @@ static struct ice_pattern_match_item ice_fdir_pattern_list[] = {
 	{pattern_eth_ipv4_tcp,				ICE_FDIR_INSET_ETH_IPV4_TCP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv4_sctp,				ICE_FDIR_INSET_ETH_IPV4_SCTP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6,				ICE_FDIR_INSET_ETH_IPV6,	ICE_INSET_NONE,			ICE_INSET_NONE},
+	{pattern_eth_ipv6_frag_ext,			ICE_FDIR_INSET_ETH_IPV6,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6_udp,				ICE_FDIR_INSET_ETH_IPV6_UDP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6_tcp,				ICE_FDIR_INSET_ETH_IPV6_TCP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6_sctp,				ICE_FDIR_INSET_ETH_IPV6_SCTP,	ICE_INSET_NONE,			ICE_INSET_NONE},
@@ -882,11 +886,13 @@ ice_fdir_input_set_parse(uint64_t inset, enum ice_flow_field *field)
 		{ICE_INSET_IPV4_TOS, ICE_FLOW_FIELD_IDX_IPV4_DSCP},
 		{ICE_INSET_IPV4_TTL, ICE_FLOW_FIELD_IDX_IPV4_TTL},
 		{ICE_INSET_IPV4_PROTO, ICE_FLOW_FIELD_IDX_IPV4_PROT},
+		{ICE_INSET_IPV4_PKID, ICE_FLOW_FIELD_IDX_IPV4_ID},
 		{ICE_INSET_IPV6_SRC, ICE_FLOW_FIELD_IDX_IPV6_SA},
 		{ICE_INSET_IPV6_DST, ICE_FLOW_FIELD_IDX_IPV6_DA},
 		{ICE_INSET_IPV6_TC, ICE_FLOW_FIELD_IDX_IPV6_DSCP},
 		{ICE_INSET_IPV6_NEXT_HDR, ICE_FLOW_FIELD_IDX_IPV6_PROT},
 		{ICE_INSET_IPV6_HOP_LIMIT, ICE_FLOW_FIELD_IDX_IPV6_TTL},
+		{ICE_INSET_IPV6_PKID, ICE_FLOW_FIELD_IDX_IPV6_ID},
 		{ICE_INSET_TCP_SRC_PORT, ICE_FLOW_FIELD_IDX_TCP_SRC_PORT},
 		{ICE_INSET_TCP_DST_PORT, ICE_FLOW_FIELD_IDX_TCP_DST_PORT},
 		{ICE_INSET_UDP_SRC_PORT, ICE_FLOW_FIELD_IDX_UDP_SRC_PORT},
@@ -935,6 +941,10 @@ ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct ice_flow_seg_info *seg)
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4 |
 				  ICE_FLOW_SEG_HDR_IPV_OTHER);
 		break;
+	case ICE_FLTR_PTYPE_FRAG_IPV4:
+		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4 |
+				  ICE_FLOW_SEG_HDR_IPV_FRAG);
+		break;
 	case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP |
 				  ICE_FLOW_SEG_HDR_IPV6 |
@@ -951,6 +961,10 @@ ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct ice_flow_seg_info *seg)
 				  ICE_FLOW_SEG_HDR_IPV_OTHER);
 		break;
 	case ICE_FLTR_PTYPE_NONF_IPV6_OTHER:
+		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6 |
+				  ICE_FLOW_SEG_HDR_IPV_FRAG);
+		break;
+	case ICE_FLTR_PTYPE_FRAG_IPV6:
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6 |
 				  ICE_FLOW_SEG_HDR_IPV_OTHER);
 		break;
@@ -1592,8 +1606,10 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 	enum rte_flow_item_type l3 = RTE_FLOW_ITEM_TYPE_END;
 	enum ice_fdir_tunnel_type tunnel_type = ICE_FDIR_TUNNEL_TYPE_NONE;
 	const struct rte_flow_item_eth *eth_spec, *eth_mask;
-	const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_mask;
+	const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_last, *ipv4_mask;
 	const struct rte_flow_item_ipv6 *ipv6_spec, *ipv6_mask;
+	const struct rte_flow_item_ipv6_frag_ext *ipv6_frag_spec,
+					*ipv6_frag_last, *ipv6_frag_mask;
 	const struct rte_flow_item_tcp *tcp_spec, *tcp_mask;
 	const struct rte_flow_item_udp *udp_spec, *udp_mask;
 	const struct rte_flow_item_sctp *sctp_spec, *sctp_mask;
@@ -1615,6 +1631,7 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 	struct ice_fdir_extra *p_ext_data;
 	struct ice_fdir_v4 *p_v4 = NULL;
 	struct ice_fdir_v6 *p_v6 = NULL;
+	bool spec_all_pid = false;
 
 	for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
 		if (item->type == RTE_FLOW_ITEM_TYPE_VXLAN)
@@ -1632,13 +1649,14 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 	 * flow. input_set_i is used for inner part.
 	 */
 	for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
-		if (item->last) {
+		if (item->last && (item_type != RTE_FLOW_ITEM_TYPE_IPV4 ||
+				   item_type !=
+				   RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT)) {
 			rte_flow_error_set(error, EINVAL,
-					   RTE_FLOW_ERROR_TYPE_ITEM,
-					   item,
+					   RTE_FLOW_ERROR_TYPE_ITEM, item,
 					   "Not support range");
-			return -rte_errno;
 		}
+
 		item_type = item->type;
 
 		input_set = (tunnel_type && !is_outer) ?
@@ -1689,6 +1707,7 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			flow_type = ICE_FLTR_PTYPE_NONF_IPV4_OTHER;
 			l3 = RTE_FLOW_ITEM_TYPE_IPV4;
 			ipv4_spec = item->spec;
+			ipv4_last = item->last;
 			ipv4_mask = item->mask;
 			p_v4 = (tunnel_type && is_outer) ?
 			       &filter->input.ip_outer.v4 :
@@ -1700,8 +1719,6 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			/* Check IPv4 mask and update input set */
 			if (ipv4_mask->hdr.version_ihl ||
 			    ipv4_mask->hdr.total_length ||
-			    ipv4_mask->hdr.packet_id ||
-			    ipv4_mask->hdr.fragment_offset ||
 			    ipv4_mask->hdr.hdr_checksum) {
 				rte_flow_error_set(error, EINVAL,
 						   RTE_FLOW_ERROR_TYPE_ITEM,
@@ -1710,6 +1727,20 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 				return -rte_errno;
 			}
 
+			if (ipv4_last->hdr.version_ihl ||
+			    ipv4_last->hdr.type_of_service ||
+			    ipv4_last->hdr.time_to_live ||
+			    ipv4_last->hdr.total_length |
+			    ipv4_last->hdr.next_proto_id ||
+			    ipv4_last->hdr.hdr_checksum ||
+			    ipv4_last->hdr.src_addr ||
+			    ipv4_last->hdr.dst_addr) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ITEM,
+						   item, "Invalid IPv4 last.");
+				return -rte_errno;
+			}
+
 			if (ipv4_mask->hdr.dst_addr == UINT32_MAX)
 				*input_set |= ICE_INSET_IPV4_DST;
 			if (ipv4_mask->hdr.src_addr == UINT32_MAX)
@@ -1726,6 +1757,24 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			p_v4->ttl = ipv4_spec->hdr.time_to_live;
 			p_v4->proto = ipv4_spec->hdr.next_proto_id;
 			p_v4->tos = ipv4_spec->hdr.type_of_service;
+
+			if (ipv4_mask->hdr.packet_id == UINT16_MAX) {
+				if (ipv4_last &&
+				    ipv4_spec->hdr.packet_id == 0 &&
+				    ipv4_last->hdr.packet_id == 0xffff)
+					spec_all_pid = true;
+
+				/* All IPv4 fragment packet has the same
+				 * ethertype, if the spec is for all invalid
+				 * packet id, set ethertype into input set.
+				 */
+				*input_set |= spec_all_pid ?
+						ICE_INSET_ETHERTYPE :
+						ICE_INSET_IPV4_PKID;
+			}
+
+			if (ipv4_mask->hdr.fragment_offset == UINT16_MAX)
+				flow_type = ICE_FLTR_PTYPE_FRAG_IPV4;
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV6:
 			flow_type = ICE_FLTR_PTYPE_NONF_IPV6_OTHER;
@@ -1771,6 +1820,31 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			p_v6->proto = ipv6_spec->hdr.proto;
 			p_v6->hlim = ipv6_spec->hdr.hop_limits;
 			break;
+		case RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT:
+			l3 = RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT;
+			flow_type = ICE_FLTR_PTYPE_FRAG_IPV6;
+			ipv6_frag_spec = item->spec;
+			ipv6_frag_last = item->last;
+			ipv6_frag_mask = item->mask;
+
+			if (!(ipv6_frag_spec && ipv6_frag_mask))
+				break;
+
+			if (ipv6_frag_last &&
+			    ipv6_frag_spec->hdr.id == 0 &&
+			    ipv6_frag_last->hdr.id ==
+			    0xffffffff)
+				spec_all_pid = true;
+
+			/* All IPv6 fragment packet has the same ethertype, if
+			 * the spec is for all invalid packet id, set ethertype
+			 * into input set.
+			 */
+			*input_set |= spec_all_pid ?
+					ICE_INSET_ETHERTYPE :
+					ICE_INSET_IPV6_PKID;
+			break;
+
 		case RTE_FLOW_ITEM_TYPE_TCP:
 			if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
 				flow_type = ICE_FLTR_PTYPE_NONF_IPV4_TCP;
-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [dpdk-dev] [PATCH v2 3/3] net/ice: support FDIR for IP fragment packet
  2021-03-24 13:54   ` [dpdk-dev] [PATCH v2 3/3] net/ice: support FDIR for IP fragment packet Jeff Guo
@ 2021-03-30  3:25     ` Xu, Ting
  2021-04-02  2:06       ` Guo, Jia
  2021-04-01  2:08     ` Xu, Ting
  1 sibling, 1 reply; 42+ messages in thread
From: Xu, Ting @ 2021-03-30  3:25 UTC (permalink / raw)
  To: Guo, Jia, Yang, Qiming, Zhang, Qi Z; +Cc: dev

Hi, Jeff

> -----Original Message-----
> From: Guo, Jia <jia.guo@intel.com>
> Sent: Wednesday, March 24, 2021 9:54 PM
> To: Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>
> Cc: Xu, Ting <ting.xu@intel.com>; dev@dpdk.org; Guo, Jia <jia.guo@intel.com>
> Subject: [PATCH v2 3/3] net/ice: support FDIR for IP fragment packet
> 
> New FDIR parsing are added to handle the fragmented IPv4/IPv6 packet.
> 
> Signed-off-by: Jeff Guo <jia.guo@intel.com>
> ---
>  drivers/net/ice/ice_fdir_filter.c | 96 +++++++++++++++++++++++++++----
>  1 file changed, 85 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
> index 3af5812660..3504d3c6c2 100644
> --- a/drivers/net/ice/ice_fdir_filter.c
> +++ b/drivers/net/ice/ice_fdir_filter.c
> @@ -24,7 +24,7 @@
>  #define ICE_FDIR_INSET_ETH_IPV4 (\
>  	ICE_FDIR_INSET_ETH | \
>  	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | ICE_INSET_IPV4_TOS | \
> -	ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO)
> +	ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO | ICE_INSET_IPV4_PKID)
> 
>  #define ICE_FDIR_INSET_ETH_IPV4_UDP (\
>  	ICE_FDIR_INSET_ETH_IPV4 | \
> @@ -41,7 +41,8 @@
>  #define ICE_FDIR_INSET_ETH_IPV6 (\
>  	ICE_INSET_DMAC | \
>  	ICE_INSET_IPV6_SRC | ICE_INSET_IPV6_DST | ICE_INSET_IPV6_TC | \
> -	ICE_INSET_IPV6_HOP_LIMIT | ICE_INSET_IPV6_NEXT_HDR)
> +	ICE_INSET_IPV6_HOP_LIMIT | ICE_INSET_IPV6_NEXT_HDR | \
> +	ICE_INSET_IPV6_PKID)
> 
>  #define ICE_FDIR_INSET_ETH_IPV6_UDP (\
>  	ICE_FDIR_INSET_ETH_IPV6 | \
> @@ -56,7 +57,8 @@
>  	ICE_INSET_SCTP_SRC_PORT | ICE_INSET_SCTP_DST_PORT)
> 
>  #define ICE_FDIR_INSET_IPV4 (\
> -	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST)
> +	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | \
> +	ICE_INSET_IPV4_PKID)
> 
>  #define ICE_FDIR_INSET_IPV4_TCP (\
>  	ICE_FDIR_INSET_IPV4 | \
> @@ -72,7 +74,8 @@
> 
>  #define ICE_FDIR_INSET_ETH_IPV4_VXLAN (\
>  	ICE_FDIR_INSET_ETH | \
> -	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST)
> +	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | \
> +	ICE_INSET_IPV4_PKID)
> 
>  #define ICE_FDIR_INSET_IPV4_GTPU (\
>  	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | ICE_INSET_GTPU_TEID)
> @@ -95,6 +98,7 @@ static struct ice_pattern_match_item
> ice_fdir_pattern_list[] = {
>  	{pattern_eth_ipv4_tcp,
> 	ICE_FDIR_INSET_ETH_IPV4_TCP,	ICE_INSET_NONE,
> 	ICE_INSET_NONE},
>  	{pattern_eth_ipv4_sctp,
> 	ICE_FDIR_INSET_ETH_IPV4_SCTP,	ICE_INSET_NONE,
> 		ICE_INSET_NONE},
>  	{pattern_eth_ipv6,
> 	ICE_FDIR_INSET_ETH_IPV6,	ICE_INSET_NONE,
> 	ICE_INSET_NONE},
> +	{pattern_eth_ipv6_frag_ext,
> 	ICE_FDIR_INSET_ETH_IPV6,	ICE_INSET_NONE,
> 	ICE_INSET_NONE},
>  	{pattern_eth_ipv6_udp,
> 	ICE_FDIR_INSET_ETH_IPV6_UDP,	ICE_INSET_NONE,
> 		ICE_INSET_NONE},
>  	{pattern_eth_ipv6_tcp,
> 	ICE_FDIR_INSET_ETH_IPV6_TCP,	ICE_INSET_NONE,
> 	ICE_INSET_NONE},
>  	{pattern_eth_ipv6_sctp,
> 	ICE_FDIR_INSET_ETH_IPV6_SCTP,	ICE_INSET_NONE,
> 		ICE_INSET_NONE},
> @@ -882,11 +886,13 @@ ice_fdir_input_set_parse(uint64_t inset, enum
> ice_flow_field *field)
>  		{ICE_INSET_IPV4_TOS, ICE_FLOW_FIELD_IDX_IPV4_DSCP},
>  		{ICE_INSET_IPV4_TTL, ICE_FLOW_FIELD_IDX_IPV4_TTL},
>  		{ICE_INSET_IPV4_PROTO, ICE_FLOW_FIELD_IDX_IPV4_PROT},
> +		{ICE_INSET_IPV4_PKID, ICE_FLOW_FIELD_IDX_IPV4_ID},
>  		{ICE_INSET_IPV6_SRC, ICE_FLOW_FIELD_IDX_IPV6_SA},
>  		{ICE_INSET_IPV6_DST, ICE_FLOW_FIELD_IDX_IPV6_DA},
>  		{ICE_INSET_IPV6_TC, ICE_FLOW_FIELD_IDX_IPV6_DSCP},
>  		{ICE_INSET_IPV6_NEXT_HDR,
> ICE_FLOW_FIELD_IDX_IPV6_PROT},
>  		{ICE_INSET_IPV6_HOP_LIMIT, ICE_FLOW_FIELD_IDX_IPV6_TTL},
> +		{ICE_INSET_IPV6_PKID, ICE_FLOW_FIELD_IDX_IPV6_ID},
>  		{ICE_INSET_TCP_SRC_PORT,
> ICE_FLOW_FIELD_IDX_TCP_SRC_PORT},
>  		{ICE_INSET_TCP_DST_PORT,
> ICE_FLOW_FIELD_IDX_TCP_DST_PORT},
>  		{ICE_INSET_UDP_SRC_PORT,
> ICE_FLOW_FIELD_IDX_UDP_SRC_PORT}, @@ -935,6 +941,10 @@
> ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct ice_flow_seg_info
> *seg)
>  		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4 |
>  				  ICE_FLOW_SEG_HDR_IPV_OTHER);
>  		break;
> +	case ICE_FLTR_PTYPE_FRAG_IPV4:
> +		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4 |
> +				  ICE_FLOW_SEG_HDR_IPV_FRAG);
> +		break;
>  	case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
>  		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP |
>  				  ICE_FLOW_SEG_HDR_IPV6 |
> @@ -951,6 +961,10 @@ ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow,
> struct ice_flow_seg_info *seg)
>  				  ICE_FLOW_SEG_HDR_IPV_OTHER);
>  		break;
>  	case ICE_FLTR_PTYPE_NONF_IPV6_OTHER:
> +		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6 |
> +				  ICE_FLOW_SEG_HDR_IPV_FRAG);
> +		break;
> +	case ICE_FLTR_PTYPE_FRAG_IPV6:

Are the frag and non-frag cases inverted?

>  		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6 |
>  				  ICE_FLOW_SEG_HDR_IPV_OTHER);
>  		break;
> @@ -1592,8 +1606,10 @@ ice_fdir_parse_pattern(__rte_unused struct
> ice_adapter *ad,
>  	enum rte_flow_item_type l3 = RTE_FLOW_ITEM_TYPE_END;
>  	enum ice_fdir_tunnel_type tunnel_type =
> ICE_FDIR_TUNNEL_TYPE_NONE;
>  	const struct rte_flow_item_eth *eth_spec, *eth_mask;
> -	const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_mask;
> +	const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_last, *ipv4_mask;
>  	const struct rte_flow_item_ipv6 *ipv6_spec, *ipv6_mask;
> +	const struct rte_flow_item_ipv6_frag_ext *ipv6_frag_spec,
> +					*ipv6_frag_last, *ipv6_frag_mask;
>  	const struct rte_flow_item_tcp *tcp_spec, *tcp_mask;
>  	const struct rte_flow_item_udp *udp_spec, *udp_mask;
>  	const struct rte_flow_item_sctp *sctp_spec, *sctp_mask; @@ -1615,6
> +1631,7 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
>  	struct ice_fdir_extra *p_ext_data;
>  	struct ice_fdir_v4 *p_v4 = NULL;
>  	struct ice_fdir_v6 *p_v6 = NULL;
> +	bool spec_all_pid = false;
> 
>  	for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++)
> {
>  		if (item->type == RTE_FLOW_ITEM_TYPE_VXLAN) @@ -1632,13
> +1649,14 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
>  	 * flow. input_set_i is used for inner part.
>  	 */
>  	for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++)
> {
> -		if (item->last) {
> +		if (item->last && (item_type != RTE_FLOW_ITEM_TYPE_IPV4 ||
> +				   item_type !=
> +				   RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT)) {
>  			rte_flow_error_set(error, EINVAL,
> -					   RTE_FLOW_ERROR_TYPE_ITEM,
> -					   item,
> +					   RTE_FLOW_ERROR_TYPE_ITEM, item,
>  					   "Not support range");
> -			return -rte_errno;
>  		}
> +
>  		item_type = item->type;
> 
>  		input_set = (tunnel_type && !is_outer) ?
> @@ -1689,6 +1707,7 @@ ice_fdir_parse_pattern(__rte_unused struct
> ice_adapter *ad,
>  			flow_type = ICE_FLTR_PTYPE_NONF_IPV4_OTHER;
>  			l3 = RTE_FLOW_ITEM_TYPE_IPV4;
>  			ipv4_spec = item->spec;
> +			ipv4_last = item->last;
>  			ipv4_mask = item->mask;
>  			p_v4 = (tunnel_type && is_outer) ?
>  			       &filter->input.ip_outer.v4 :
> @@ -1700,8 +1719,6 @@ ice_fdir_parse_pattern(__rte_unused struct
> ice_adapter *ad,
>  			/* Check IPv4 mask and update input set */
>  			if (ipv4_mask->hdr.version_ihl ||
>  			    ipv4_mask->hdr.total_length ||
> -			    ipv4_mask->hdr.packet_id ||
> -			    ipv4_mask->hdr.fragment_offset ||
>  			    ipv4_mask->hdr.hdr_checksum) {
>  				rte_flow_error_set(error, EINVAL,
> 
> RTE_FLOW_ERROR_TYPE_ITEM,
> @@ -1710,6 +1727,20 @@ ice_fdir_parse_pattern(__rte_unused struct
> ice_adapter *ad,
>  				return -rte_errno;
>  			}
> 
> +			if (ipv4_last->hdr.version_ihl ||
> +			    ipv4_last->hdr.type_of_service ||
> +			    ipv4_last->hdr.time_to_live ||
> +			    ipv4_last->hdr.total_length |
> +			    ipv4_last->hdr.next_proto_id ||
> +			    ipv4_last->hdr.hdr_checksum ||
> +			    ipv4_last->hdr.src_addr ||
> +			    ipv4_last->hdr.dst_addr) {
> +				rte_flow_error_set(error, EINVAL,
> +
> RTE_FLOW_ERROR_TYPE_ITEM,
> +						   item, "Invalid IPv4 last.");
> +				return -rte_errno;
> +			}
> +
>  			if (ipv4_mask->hdr.dst_addr == UINT32_MAX)
>  				*input_set |= ICE_INSET_IPV4_DST;
>  			if (ipv4_mask->hdr.src_addr == UINT32_MAX) @@ -
> 1726,6 +1757,24 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter
> *ad,
>  			p_v4->ttl = ipv4_spec->hdr.time_to_live;
>  			p_v4->proto = ipv4_spec->hdr.next_proto_id;
>  			p_v4->tos = ipv4_spec->hdr.type_of_service;
> +
> +			if (ipv4_mask->hdr.packet_id == UINT16_MAX) {
> +				if (ipv4_last &&
> +				    ipv4_spec->hdr.packet_id == 0 &&
> +				    ipv4_last->hdr.packet_id == 0xffff)
> +					spec_all_pid = true;
> +
> +				/* All IPv4 fragment packet has the same
> +				 * ethertype, if the spec is for all invalid
> +				 * packet id, set ethertype into input set.
> +				 */
> +				*input_set |= spec_all_pid ?
> +						ICE_INSET_ETHERTYPE :
> +						ICE_INSET_IPV4_PKID;
> +			}
> +
> +			if (ipv4_mask->hdr.fragment_offset == UINT16_MAX)
> +				flow_type = ICE_FLTR_PTYPE_FRAG_IPV4;
>  			break;
>  		case RTE_FLOW_ITEM_TYPE_IPV6:
>  			flow_type = ICE_FLTR_PTYPE_NONF_IPV6_OTHER; @@
> -1771,6 +1820,31 @@ ice_fdir_parse_pattern(__rte_unused struct
> ice_adapter *ad,
>  			p_v6->proto = ipv6_spec->hdr.proto;
>  			p_v6->hlim = ipv6_spec->hdr.hop_limits;
>  			break;
> +		case RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT:
> +			l3 = RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT;
> +			flow_type = ICE_FLTR_PTYPE_FRAG_IPV6;
> +			ipv6_frag_spec = item->spec;
> +			ipv6_frag_last = item->last;
> +			ipv6_frag_mask = item->mask;
> +
> +			if (!(ipv6_frag_spec && ipv6_frag_mask))
> +				break;
> +
> +			if (ipv6_frag_last &&
> +			    ipv6_frag_spec->hdr.id == 0 &&
> +			    ipv6_frag_last->hdr.id ==
> +			    0xffffffff)
> +				spec_all_pid = true;
> +
> +			/* All IPv6 fragment packet has the same ethertype, if
> +			 * the spec is for all invalid packet id, set ethertype
> +			 * into input set.
> +			 */
> +			*input_set |= spec_all_pid ?
> +					ICE_INSET_ETHERTYPE :
> +					ICE_INSET_IPV6_PKID;
> +			break;
> +
>  		case RTE_FLOW_ITEM_TYPE_TCP:
>  			if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
>  				flow_type = ICE_FLTR_PTYPE_NONF_IPV4_TCP;
> --
> 2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [dpdk-dev] [PATCH v2 3/3] net/ice: support FDIR for IP fragment packet
  2021-03-24 13:54   ` [dpdk-dev] [PATCH v2 3/3] net/ice: support FDIR for IP fragment packet Jeff Guo
  2021-03-30  3:25     ` Xu, Ting
@ 2021-04-01  2:08     ` Xu, Ting
  2021-04-02  1:53       ` Guo, Jia
  1 sibling, 1 reply; 42+ messages in thread
From: Xu, Ting @ 2021-04-01  2:08 UTC (permalink / raw)
  To: Guo, Jia, Yang, Qiming, Zhang, Qi Z; +Cc: dev

Hi, Jeff

See inline

Best Regards,
Xu Ting

> -----Original Message-----
> From: Guo, Jia <jia.guo@intel.com>
> Sent: Wednesday, March 24, 2021 9:54 PM
> To: Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>
> Cc: Xu, Ting <ting.xu@intel.com>; dev@dpdk.org; Guo, Jia <jia.guo@intel.com>
> Subject: [PATCH v2 3/3] net/ice: support FDIR for IP fragment packet
> 
> New FDIR parsing are added to handle the fragmented IPv4/IPv6 packet.
> 
> Signed-off-by: Jeff Guo <jia.guo@intel.com>
> ---
>  drivers/net/ice/ice_fdir_filter.c | 96 +++++++++++++++++++++++++++----
>  1 file changed, 85 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
> index 3af5812660..3504d3c6c2 100644
> --- a/drivers/net/ice/ice_fdir_filter.c
> +++ b/drivers/net/ice/ice_fdir_filter.c
> @@ -24,7 +24,7 @@
>  #define ICE_FDIR_INSET_ETH_IPV4 (\
>  	ICE_FDIR_INSET_ETH | \
>  	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | ICE_INSET_IPV4_TOS | \
> -	ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO)
> +	ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO | ICE_INSET_IPV4_PKID)
> 

Skip...

> @@ -1700,8 +1719,6 @@ ice_fdir_parse_pattern(__rte_unused struct
> ice_adapter *ad,
>  			/* Check IPv4 mask and update input set */
>  			if (ipv4_mask->hdr.version_ihl ||
>  			    ipv4_mask->hdr.total_length ||
> -			    ipv4_mask->hdr.packet_id ||
> -			    ipv4_mask->hdr.fragment_offset ||
>  			    ipv4_mask->hdr.hdr_checksum) {
>  				rte_flow_error_set(error, EINVAL,
> 
> RTE_FLOW_ERROR_TYPE_ITEM,
> @@ -1710,6 +1727,20 @@ ice_fdir_parse_pattern(__rte_unused struct
> ice_adapter *ad,
>  				return -rte_errno;
>  			}
> 

May need to check if ipv4_last exists before using it.

> +			if (ipv4_last->hdr.version_ihl ||
> +			    ipv4_last->hdr.type_of_service ||
> +			    ipv4_last->hdr.time_to_live ||
> +			    ipv4_last->hdr.total_length |
> +			    ipv4_last->hdr.next_proto_id ||
> +			    ipv4_last->hdr.hdr_checksum ||
> +			    ipv4_last->hdr.src_addr ||
> +			    ipv4_last->hdr.dst_addr) {
> +				rte_flow_error_set(error, EINVAL,
> +
> RTE_FLOW_ERROR_TYPE_ITEM,
> +						   item, "Invalid IPv4 last.");
> +				return -rte_errno;
> +			}
> +
>  			if (ipv4_mask->hdr.dst_addr == UINT32_MAX)
>  				*input_set |= ICE_INSET_IPV4_DST;
>  			if (ipv4_mask->hdr.src_addr == UINT32_MAX) @@ -

Skip...

> 2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [dpdk-dev] [PATCH v2 3/3] net/ice: support FDIR for IP fragment packet
  2021-04-01  2:08     ` Xu, Ting
@ 2021-04-02  1:53       ` Guo, Jia
  0 siblings, 0 replies; 42+ messages in thread
From: Guo, Jia @ 2021-04-02  1:53 UTC (permalink / raw)
  To: Xu, Ting, Yang, Qiming, Zhang, Qi Z; +Cc: dev

Hi, ting

> -----Original Message-----
> From: Xu, Ting <ting.xu@intel.com>
> Sent: Thursday, April 1, 2021 10:08 AM
> To: Guo, Jia <jia.guo@intel.com>; Yang, Qiming <qiming.yang@intel.com>;
> Zhang, Qi Z <qi.z.zhang@intel.com>
> Cc: dev@dpdk.org
> Subject: RE: [PATCH v2 3/3] net/ice: support FDIR for IP fragment packet
> 
> Hi, Jeff
> 
> See inline
> 
> Best Regards,
> Xu Ting
> 
> > -----Original Message-----
> > From: Guo, Jia <jia.guo@intel.com>
> > Sent: Wednesday, March 24, 2021 9:54 PM
> > To: Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
> > <qi.z.zhang@intel.com>
> > Cc: Xu, Ting <ting.xu@intel.com>; dev@dpdk.org; Guo, Jia
> > <jia.guo@intel.com>
> > Subject: [PATCH v2 3/3] net/ice: support FDIR for IP fragment packet
> >
> > New FDIR parsing are added to handle the fragmented IPv4/IPv6 packet.
> >
> > Signed-off-by: Jeff Guo <jia.guo@intel.com>
> > ---
> >  drivers/net/ice/ice_fdir_filter.c | 96
> > +++++++++++++++++++++++++++----
> >  1 file changed, 85 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/net/ice/ice_fdir_filter.c
> > b/drivers/net/ice/ice_fdir_filter.c
> > index 3af5812660..3504d3c6c2 100644
> > --- a/drivers/net/ice/ice_fdir_filter.c
> > +++ b/drivers/net/ice/ice_fdir_filter.c
> > @@ -24,7 +24,7 @@
> >  #define ICE_FDIR_INSET_ETH_IPV4 (\
> >  ICE_FDIR_INSET_ETH | \
> >  ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | ICE_INSET_IPV4_TOS | \
> > -ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO)
> > +ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO | ICE_INSET_IPV4_PKID)
> >
> 
> Skip...
> 
> > @@ -1700,8 +1719,6 @@ ice_fdir_parse_pattern(__rte_unused struct
> > ice_adapter *ad,
> >  /* Check IPv4 mask and update input set */  if
> > (ipv4_mask->hdr.version_ihl ||
> >      ipv4_mask->hdr.total_length ||
> > -    ipv4_mask->hdr.packet_id ||
> > -    ipv4_mask->hdr.fragment_offset ||
> >      ipv4_mask->hdr.hdr_checksum) {
> >  rte_flow_error_set(error, EINVAL,
> >
> > RTE_FLOW_ERROR_TYPE_ITEM,
> > @@ -1710,6 +1727,20 @@ ice_fdir_parse_pattern(__rte_unused struct
> > ice_adapter *ad,  return -rte_errno;  }
> >
> 
> May need to check if ipv4_last exists before using it.
> 

Sure, will add the check in next version.

> > +if (ipv4_last->hdr.version_ihl ||
> > +    ipv4_last->hdr.type_of_service ||
> > +    ipv4_last->hdr.time_to_live ||
> > +    ipv4_last->hdr.total_length |
> > +    ipv4_last->hdr.next_proto_id ||
> > +    ipv4_last->hdr.hdr_checksum ||
> > +    ipv4_last->hdr.src_addr ||
> > +    ipv4_last->hdr.dst_addr) {
> > +rte_flow_error_set(error, EINVAL,
> > +
> > RTE_FLOW_ERROR_TYPE_ITEM,
> > +   item, "Invalid IPv4 last.");
> > +return -rte_errno;
> > +}
> > +
> >  if (ipv4_mask->hdr.dst_addr == UINT32_MAX)  *input_set |=
> > ICE_INSET_IPV4_DST;  if (ipv4_mask->hdr.src_addr == UINT32_MAX) @@ -
> 
> Skip...
> 
> > 2.20.1
> 


^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [dpdk-dev] [PATCH v2 3/3] net/ice: support FDIR for IP fragment packet
  2021-03-30  3:25     ` Xu, Ting
@ 2021-04-02  2:06       ` Guo, Jia
  0 siblings, 0 replies; 42+ messages in thread
From: Guo, Jia @ 2021-04-02  2:06 UTC (permalink / raw)
  To: Xu, Ting, Yang, Qiming, Zhang, Qi Z; +Cc: dev

Hi, ting

> -----Original Message-----
> From: Xu, Ting <ting.xu@intel.com>
> Sent: Tuesday, March 30, 2021 11:25 AM
> To: Guo, Jia <jia.guo@intel.com>; Yang, Qiming <qiming.yang@intel.com>;
> Zhang, Qi Z <qi.z.zhang@intel.com>
> Cc: dev@dpdk.org
> Subject: RE: [PATCH v2 3/3] net/ice: support FDIR for IP fragment packet
> 
> Hi, Jeff
> 
> > -----Original Message-----
> > From: Guo, Jia <jia.guo@intel.com>
> > Sent: Wednesday, March 24, 2021 9:54 PM
> > To: Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
> > <qi.z.zhang@intel.com>
> > Cc: Xu, Ting <ting.xu@intel.com>; dev@dpdk.org; Guo, Jia
> > <jia.guo@intel.com>
> > Subject: [PATCH v2 3/3] net/ice: support FDIR for IP fragment packet
> >
> > New FDIR parsing are added to handle the fragmented IPv4/IPv6 packet.
> >
> > Signed-off-by: Jeff Guo <jia.guo@intel.com>
> > ---
> >  drivers/net/ice/ice_fdir_filter.c | 96
> > +++++++++++++++++++++++++++----
> >  1 file changed, 85 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/net/ice/ice_fdir_filter.c
> > b/drivers/net/ice/ice_fdir_filter.c
> > index 3af5812660..3504d3c6c2 100644
> > --- a/drivers/net/ice/ice_fdir_filter.c
> > +++ b/drivers/net/ice/ice_fdir_filter.c
> > @@ -24,7 +24,7 @@
> >  #define ICE_FDIR_INSET_ETH_IPV4 (\
> >  ICE_FDIR_INSET_ETH | \
> >  ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | ICE_INSET_IPV4_TOS | \
> > -ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO)
> > +ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO | ICE_INSET_IPV4_PKID)
> >
> >  #define ICE_FDIR_INSET_ETH_IPV4_UDP (\
> >  ICE_FDIR_INSET_ETH_IPV4 | \
> > @@ -41,7 +41,8 @@
> >  #define ICE_FDIR_INSET_ETH_IPV6 (\
> >  ICE_INSET_DMAC | \
> >  ICE_INSET_IPV6_SRC | ICE_INSET_IPV6_DST | ICE_INSET_IPV6_TC | \
> > -ICE_INSET_IPV6_HOP_LIMIT | ICE_INSET_IPV6_NEXT_HDR)
> > +ICE_INSET_IPV6_HOP_LIMIT | ICE_INSET_IPV6_NEXT_HDR | \
> > +ICE_INSET_IPV6_PKID)
> >
> >  #define ICE_FDIR_INSET_ETH_IPV6_UDP (\
> >  ICE_FDIR_INSET_ETH_IPV6 | \
> > @@ -56,7 +57,8 @@
> >  ICE_INSET_SCTP_SRC_PORT | ICE_INSET_SCTP_DST_PORT)
> >
> >  #define ICE_FDIR_INSET_IPV4 (\
> > -ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST)
> > +ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | \
> > +ICE_INSET_IPV4_PKID)
> >
> >  #define ICE_FDIR_INSET_IPV4_TCP (\
> >  ICE_FDIR_INSET_IPV4 | \
> > @@ -72,7 +74,8 @@
> >
> >  #define ICE_FDIR_INSET_ETH_IPV4_VXLAN (\  ICE_FDIR_INSET_ETH | \
> > -ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST)
> > +ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | \
> > +ICE_INSET_IPV4_PKID)
> >
> >  #define ICE_FDIR_INSET_IPV4_GTPU (\
> >  ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | ICE_INSET_GTPU_TEID)
> @@
> > -95,6 +98,7 @@ static struct ice_pattern_match_item
> > ice_fdir_pattern_list[] = {  {pattern_eth_ipv4_tcp,
> > ICE_FDIR_INSET_ETH_IPV4_TCP,ICE_INSET_NONE,
> > ICE_INSET_NONE},
> >  {pattern_eth_ipv4_sctp,
> > ICE_FDIR_INSET_ETH_IPV4_SCTP,ICE_INSET_NONE,
> > ICE_INSET_NONE},
> >  {pattern_eth_ipv6,
> > ICE_FDIR_INSET_ETH_IPV6,ICE_INSET_NONE,
> > ICE_INSET_NONE},
> > +{pattern_eth_ipv6_frag_ext,
> > ICE_FDIR_INSET_ETH_IPV6,ICE_INSET_NONE,
> > ICE_INSET_NONE},
> >  {pattern_eth_ipv6_udp,
> > ICE_FDIR_INSET_ETH_IPV6_UDP,ICE_INSET_NONE,
> > ICE_INSET_NONE},
> >  {pattern_eth_ipv6_tcp,
> > ICE_FDIR_INSET_ETH_IPV6_TCP,ICE_INSET_NONE,
> > ICE_INSET_NONE},
> >  {pattern_eth_ipv6_sctp,
> > ICE_FDIR_INSET_ETH_IPV6_SCTP,ICE_INSET_NONE,
> > ICE_INSET_NONE},
> > @@ -882,11 +886,13 @@ ice_fdir_input_set_parse(uint64_t inset, enum
> > ice_flow_field *field)  {ICE_INSET_IPV4_TOS,
> > ICE_FLOW_FIELD_IDX_IPV4_DSCP},  {ICE_INSET_IPV4_TTL,
> > ICE_FLOW_FIELD_IDX_IPV4_TTL},  {ICE_INSET_IPV4_PROTO,
> > ICE_FLOW_FIELD_IDX_IPV4_PROT},
> > +{ICE_INSET_IPV4_PKID, ICE_FLOW_FIELD_IDX_IPV4_ID},
> >  {ICE_INSET_IPV6_SRC, ICE_FLOW_FIELD_IDX_IPV6_SA},
> > {ICE_INSET_IPV6_DST, ICE_FLOW_FIELD_IDX_IPV6_DA},
> {ICE_INSET_IPV6_TC,
> > ICE_FLOW_FIELD_IDX_IPV6_DSCP},  {ICE_INSET_IPV6_NEXT_HDR,
> > ICE_FLOW_FIELD_IDX_IPV6_PROT},  {ICE_INSET_IPV6_HOP_LIMIT,
> > ICE_FLOW_FIELD_IDX_IPV6_TTL},
> > +{ICE_INSET_IPV6_PKID, ICE_FLOW_FIELD_IDX_IPV6_ID},
> >  {ICE_INSET_TCP_SRC_PORT,
> > ICE_FLOW_FIELD_IDX_TCP_SRC_PORT},
> >  {ICE_INSET_TCP_DST_PORT,
> > ICE_FLOW_FIELD_IDX_TCP_DST_PORT},
> >  {ICE_INSET_UDP_SRC_PORT,
> > ICE_FLOW_FIELD_IDX_UDP_SRC_PORT}, @@ -935,6 +941,10 @@
> > ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct
> > ice_flow_seg_info
> > *seg)
> >  ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4 |
> >    ICE_FLOW_SEG_HDR_IPV_OTHER);
> >  break;
> > +case ICE_FLTR_PTYPE_FRAG_IPV4:
> > +ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4 |
> > +  ICE_FLOW_SEG_HDR_IPV_FRAG);
> > +break;
> >  case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
> >  ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP |
> >    ICE_FLOW_SEG_HDR_IPV6 |
> > @@ -951,6 +961,10 @@ ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow,
> > struct ice_flow_seg_info *seg)
> >    ICE_FLOW_SEG_HDR_IPV_OTHER);
> >  break;
> >  case ICE_FLTR_PTYPE_NONF_IPV6_OTHER:
> > +ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6 |
> > +  ICE_FLOW_SEG_HDR_IPV_FRAG);
> > +break;
> > +case ICE_FLTR_PTYPE_FRAG_IPV6:
> 
> Are the frag and non-frag cases inverted?
> 

That is right as you said, will correct it in coming version. Thanks.

> >  ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6 |
> >    ICE_FLOW_SEG_HDR_IPV_OTHER);
> >  break;
> > @@ -1592,8 +1606,10 @@ ice_fdir_parse_pattern(__rte_unused struct
> > ice_adapter *ad,  enum rte_flow_item_type l3 =
> RTE_FLOW_ITEM_TYPE_END;
> > enum ice_fdir_tunnel_type tunnel_type = ICE_FDIR_TUNNEL_TYPE_NONE;
> > const struct rte_flow_item_eth *eth_spec, *eth_mask; -const struct
> > rte_flow_item_ipv4 *ipv4_spec, *ipv4_mask;
> > +const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_last, *ipv4_mask;
> >  const struct rte_flow_item_ipv6 *ipv6_spec, *ipv6_mask;
> > +const struct rte_flow_item_ipv6_frag_ext *ipv6_frag_spec,
> > +*ipv6_frag_last, *ipv6_frag_mask;
> >  const struct rte_flow_item_tcp *tcp_spec, *tcp_mask;  const struct
> > rte_flow_item_udp *udp_spec, *udp_mask;  const struct
> > rte_flow_item_sctp *sctp_spec, *sctp_mask; @@ -1615,6
> > +1631,7 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
> >  struct ice_fdir_extra *p_ext_data;
> >  struct ice_fdir_v4 *p_v4 = NULL;
> >  struct ice_fdir_v6 *p_v6 = NULL;
> > +bool spec_all_pid = false;
> >
> >  for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
> > if (item->type == RTE_FLOW_ITEM_TYPE_VXLAN) @@ -1632,13
> > +1649,14 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter
> > +*ad,
> >   * flow. input_set_i is used for inner part.
> >   */
> >  for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
> > -if (item->last) {
> > +if (item->last && (item_type != RTE_FLOW_ITEM_TYPE_IPV4 ||
> > +   item_type !=
> > +   RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT)) {
> >  rte_flow_error_set(error, EINVAL,
> > -   RTE_FLOW_ERROR_TYPE_ITEM,
> > -   item,
> > +   RTE_FLOW_ERROR_TYPE_ITEM, item,
> >     "Not support range");
> > -return -rte_errno;
> >  }
> > +
> >  item_type = item->type;
> >
> >  input_set = (tunnel_type && !is_outer) ?
> > @@ -1689,6 +1707,7 @@ ice_fdir_parse_pattern(__rte_unused struct
> > ice_adapter *ad,  flow_type = ICE_FLTR_PTYPE_NONF_IPV4_OTHER;
> >  l3 = RTE_FLOW_ITEM_TYPE_IPV4;
> >  ipv4_spec = item->spec;
> > +ipv4_last = item->last;
> >  ipv4_mask = item->mask;
> >  p_v4 = (tunnel_type && is_outer) ?
> >         &filter->input.ip_outer.v4 :
> > @@ -1700,8 +1719,6 @@ ice_fdir_parse_pattern(__rte_unused struct
> > ice_adapter *ad,
> >  /* Check IPv4 mask and update input set */  if
> > (ipv4_mask->hdr.version_ihl ||
> >      ipv4_mask->hdr.total_length ||
> > -    ipv4_mask->hdr.packet_id ||
> > -    ipv4_mask->hdr.fragment_offset ||
> >      ipv4_mask->hdr.hdr_checksum) {
> >  rte_flow_error_set(error, EINVAL,
> >
> > RTE_FLOW_ERROR_TYPE_ITEM,
> > @@ -1710,6 +1727,20 @@ ice_fdir_parse_pattern(__rte_unused struct
> > ice_adapter *ad,  return -rte_errno;  }
> >
> > +if (ipv4_last->hdr.version_ihl ||
> > +    ipv4_last->hdr.type_of_service ||
> > +    ipv4_last->hdr.time_to_live ||
> > +    ipv4_last->hdr.total_length |
> > +    ipv4_last->hdr.next_proto_id ||
> > +    ipv4_last->hdr.hdr_checksum ||
> > +    ipv4_last->hdr.src_addr ||
> > +    ipv4_last->hdr.dst_addr) {
> > +rte_flow_error_set(error, EINVAL,
> > +
> > RTE_FLOW_ERROR_TYPE_ITEM,
> > +   item, "Invalid IPv4 last.");
> > +return -rte_errno;
> > +}
> > +
> >  if (ipv4_mask->hdr.dst_addr == UINT32_MAX)  *input_set |=
> > ICE_INSET_IPV4_DST;  if (ipv4_mask->hdr.src_addr == UINT32_MAX) @@ -
> > 1726,6 +1757,24 @@ ice_fdir_parse_pattern(__rte_unused struct
> > ice_adapter *ad,  p_v4->ttl = ipv4_spec->hdr.time_to_live;
> > p_v4->proto = ipv4_spec->hdr.next_proto_id;  p_v4->tos =
> > ipv4_spec->hdr.type_of_service;
> > +
> > +if (ipv4_mask->hdr.packet_id == UINT16_MAX) { if (ipv4_last &&
> > +    ipv4_spec->hdr.packet_id == 0 &&
> > +    ipv4_last->hdr.packet_id == 0xffff) spec_all_pid = true;
> > +
> > +/* All IPv4 fragment packet has the same
> > + * ethertype, if the spec is for all invalid
> > + * packet id, set ethertype into input set.
> > + */
> > +*input_set |= spec_all_pid ?
> > +ICE_INSET_ETHERTYPE :
> > +ICE_INSET_IPV4_PKID;
> > +}
> > +
> > +if (ipv4_mask->hdr.fragment_offset == UINT16_MAX) flow_type =
> > +ICE_FLTR_PTYPE_FRAG_IPV4;
> >  break;
> >  case RTE_FLOW_ITEM_TYPE_IPV6:
> >  flow_type = ICE_FLTR_PTYPE_NONF_IPV6_OTHER; @@
> > -1771,6 +1820,31 @@ ice_fdir_parse_pattern(__rte_unused struct
> > ice_adapter *ad,  p_v6->proto = ipv6_spec->hdr.proto;  p_v6->hlim =
> > ipv6_spec->hdr.hop_limits;  break;
> > +case RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT:
> > +l3 = RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT; flow_type =
> > +ICE_FLTR_PTYPE_FRAG_IPV6; ipv6_frag_spec = item->spec;
> ipv6_frag_last
> > += item->last; ipv6_frag_mask = item->mask;
> > +
> > +if (!(ipv6_frag_spec && ipv6_frag_mask)) break;
> > +
> > +if (ipv6_frag_last &&
> > +    ipv6_frag_spec->hdr.id == 0 &&
> > +    ipv6_frag_last->hdr.id ==
> > +    0xffffffff)
> > +spec_all_pid = true;
> > +
> > +/* All IPv6 fragment packet has the same ethertype, if
> > + * the spec is for all invalid packet id, set ethertype
> > + * into input set.
> > + */
> > +*input_set |= spec_all_pid ?
> > +ICE_INSET_ETHERTYPE :
> > +ICE_INSET_IPV6_PKID;
> > +break;
> > +
> >  case RTE_FLOW_ITEM_TYPE_TCP:
> >  if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
> >  flow_type = ICE_FLTR_PTYPE_NONF_IPV4_TCP;
> > --
> > 2.20.1
> 


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v3 0/3] support flow for IP fragment in ICE
  2021-03-24 13:54 ` [dpdk-dev] [PATCH v2 0/3] support flow for IP fragment in ICE Jeff Guo
                     ` (2 preceding siblings ...)
  2021-03-24 13:54   ` [dpdk-dev] [PATCH v2 3/3] net/ice: support FDIR for IP fragment packet Jeff Guo
@ 2021-04-11  6:06   ` Jeff Guo
  2021-04-11  6:06     ` [dpdk-dev] [PATCH v3 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
                       ` (2 more replies)
  2021-04-11  6:57   ` [dpdk-dev] [PATCH v3 0/3] support flow for IP fragment in ICE Jeff Guo
                     ` (4 subsequent siblings)
  8 siblings, 3 replies; 42+ messages in thread
From: Jeff Guo @ 2021-04-11  6:06 UTC (permalink / raw)
  To: qi.z.zhang, qiming.yang; +Cc: dev, ting.xu, jia.guo

Support RSS hash and FDIR for IP fragment packets in ICE PMD.

v3:
rebase code and fix some parsing issues.
v2:
add some input check

Jeff Guo (3):
  net/ice/base: support IP fragment RSS and FDIR
  net/ice: support RSS hash for IP fragment
  net/ice: support FDIR for IP fragment packet

 drivers/net/ice/base/ice_fdir.c    |  50 ++++++++++++-
 drivers/net/ice/base/ice_fdir.h    |  22 +++++-
 drivers/net/ice/base/ice_flow.c    |  50 ++++++++++++-
 drivers/net/ice/base/ice_flow.h    |   5 +-
 drivers/net/ice/base/ice_type.h    |   1 +
 drivers/net/ice/ice_fdir_filter.c  | 116 ++++++++++++++++++++++++++---
 drivers/net/ice/ice_generic_flow.c |  22 ++++++
 drivers/net/ice/ice_generic_flow.h |   6 ++
 drivers/net/ice/ice_hash.c         |  48 ++++++++++--
 9 files changed, 293 insertions(+), 27 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v3 1/3] net/ice/base: support IP fragment RSS and FDIR
  2021-04-11  6:06   ` [dpdk-dev] [PATCH v3 0/3] support flow for IP fragment in ICE Jeff Guo
@ 2021-04-11  6:06     ` Jeff Guo
  2021-04-12  8:31       ` Xu, Ting
  2021-04-11  6:06     ` [dpdk-dev] [PATCH v3 2/3] net/ice: support RSS hash for IP fragment Jeff Guo
  2021-04-11  6:06     ` [dpdk-dev] [PATCH v3 3/3] net/ice: support FDIR for IP fragment packet Jeff Guo
  2 siblings, 1 reply; 42+ messages in thread
From: Jeff Guo @ 2021-04-11  6:06 UTC (permalink / raw)
  To: qi.z.zhang, qiming.yang; +Cc: dev, ting.xu, jia.guo

Add support for IP fragment RSS hash and FDIR according to packet ID.
Separate IP fragment and IP other packet types.

Signed-off-by: Ting Xu <ting.xu@intel.com>
Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
 drivers/net/ice/base/ice_fdir.c | 50 +++++++++++++++++++++++++++++++--
 drivers/net/ice/base/ice_fdir.h | 22 ++++++++++++---
 drivers/net/ice/base/ice_flow.c | 50 ++++++++++++++++++++++++++++++++-
 drivers/net/ice/base/ice_flow.h |  5 +++-
 drivers/net/ice/base/ice_type.h |  1 +
 5 files changed, 120 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ice/base/ice_fdir.c b/drivers/net/ice/base/ice_fdir.c
index 2b39c13127..0eb7cdd729 100644
--- a/drivers/net/ice/base/ice_fdir.c
+++ b/drivers/net/ice/base/ice_fdir.c
@@ -518,6 +518,24 @@ 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 +734,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_pkt), ice_fdir_ipv4_frag_pkt,
+		sizeof(ice_fdir_ipv4_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),
@@ -1505,7 +1533,7 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
 		ice_pkt_insert_u8(loc, ICE_IPV4_TTL_OFFSET, input->ip.v4.ttl);
 		ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
 		if (frag)
-			loc[20] = ICE_FDIR_IPV4_PKT_FLAG_DF;
+			loc[20] = ICE_FDIR_IPV4_PKT_FLAG_MF;
 		break;
 	case ICE_FLTR_PTYPE_NONF_IPV4_UDP:
 		ice_pkt_insert_mac_addr(pkt, input->ext_data_outer.dst_mac);
@@ -1808,6 +1836,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 +1883,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;
diff --git a/drivers/net/ice/base/ice_fdir.h b/drivers/net/ice/base/ice_fdir.h
index 6573f96bc1..2acc1d6f1b 100644
--- a/drivers/net/ice/base/ice_fdir.h
+++ b/drivers/net/ice/base/ice_fdir.h
@@ -43,9 +43,11 @@
 #define ICE_MAC_ETHTYPE_OFFSET		12
 #define ICE_IPV4_TOS_OFFSET		15
 #define ICE_IPV4_TTL_OFFSET		22
+#define ICE_IPV4_ID_OFFSET		18
 #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
@@ -83,12 +85,22 @@
 
 #define ICE_FDIR_MAX_FLTRS		16384
 
-/* IP v4 has 2 flag bits that enable fragment processing: DF and MF. DF
+/* IPv4 has 2 flag bits that enable fragment processing: DF and MF. DF
  * requests that the packet not be fragmented. MF indicates that a packet has
- * been fragmented.
+ * been fragmented, except that for the last fragment has a non-zero
+ * Fragment Offset field with zero MF.
  */
-#define ICE_FDIR_IPV4_PKT_FLAG_DF		0x20
-#define ICE_FDIR_IPV4_PKT_FLAG_MF		0x40
+#define ICE_FDIR_IPV4_PKT_FLAG_MF		0x20
+#define ICE_FDIR_IPV4_PKT_FLAG_MF_SHIFT	8
+#ifndef NO_UNUSED_PACKAGE_CODE
+#define ICE_FDIR_IPV4_PKT_FLAG_DF		0x40
+#endif /* NO_UNUSED_PACKAGE_CODE */
+
+/* For IPv6 fragmented packets, all fragments except the last have
+ * the MF flag set.
+ */
+#define ICE_FDIR_IPV6_PKT_FLAG_MF		0x100
+#define ICE_FDIR_IPV6_PKT_FLAG_MF_SHIFT	8
 
 enum ice_fltr_prgm_desc_dest {
 	ICE_FLTR_PRGM_DESC_DEST_DROP_PKT,
@@ -150,6 +162,7 @@ struct ice_fdir_v4 {
 	u8 ip_ver;
 	u8 proto;
 	u8 ttl;
+	__be16 packet_id;
 };
 
 #define ICE_IPV6_ADDR_LEN_AS_U32		4
@@ -164,6 +177,7 @@ struct ice_fdir_v6 {
 	u8 tc;
 	u8 proto;
 	u8 hlim;
+	__be32 packet_id;
 };
 
 struct ice_fdir_udp_gtp {
diff --git a/drivers/net/ice/base/ice_flow.c b/drivers/net/ice/base/ice_flow.c
index c12ddfa247..9dea881914 100644
--- a/drivers/net/ice/base/ice_flow.c
+++ b/drivers/net/ice/base/ice_flow.c
@@ -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),
@@ -725,6 +733,27 @@ static const u32 ice_ptypes_udp_ecpri_tp0[] = {
 	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;
@@ -899,6 +928,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 :
@@ -1177,6 +1216,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:
@@ -1187,6 +1229,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:
@@ -3341,13 +3386,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);
diff --git a/drivers/net/ice/base/ice_flow.h b/drivers/net/ice/base/ice_flow.h
index af15ecb0ff..d905b95b1c 100644
--- a/drivers/net/ice/base/ice_flow.h
+++ b/drivers/net/ice/base/ice_flow.h
@@ -186,8 +186,9 @@ enum ice_flow_seg_hdr {
 	ICE_FLOW_SEG_HDR_ECPRI_TP0	= 0x04000000,
 	ICE_FLOW_SEG_HDR_UDP_ECPRI_TP0	= 0x08000000,
 	/* 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_FRAG	= 0x10000000,
 	ICE_FLOW_SEG_HDR_IPV_OTHER	= 0x20000000,
 };
 
@@ -225,6 +226,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,
diff --git a/drivers/net/ice/base/ice_type.h b/drivers/net/ice/base/ice_type.h
index a6599363f9..5abe9dc9ea 100644
--- a/drivers/net/ice/base/ice_type.h
+++ b/drivers/net/ice/base/ice_type.h
@@ -349,6 +349,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,
-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v3 2/3] net/ice: support RSS hash for IP fragment
  2021-04-11  6:06   ` [dpdk-dev] [PATCH v3 0/3] support flow for IP fragment in ICE Jeff Guo
  2021-04-11  6:06     ` [dpdk-dev] [PATCH v3 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
@ 2021-04-11  6:06     ` Jeff Guo
  2021-04-11  6:06     ` [dpdk-dev] [PATCH v3 3/3] net/ice: support FDIR for IP fragment packet Jeff Guo
  2 siblings, 0 replies; 42+ messages in thread
From: Jeff Guo @ 2021-04-11  6:06 UTC (permalink / raw)
  To: qi.z.zhang, qiming.yang; +Cc: dev, ting.xu, jia.guo

New pattern and RSS hash flow parsing are added to handle fragmented
IPv4/IPv6  packet.

Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
 drivers/net/ice/ice_generic_flow.c | 21 +++++++++++++
 drivers/net/ice/ice_generic_flow.h |  6 ++++
 drivers/net/ice/ice_hash.c         | 48 +++++++++++++++++++++++++-----
 3 files changed, 67 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ice/ice_generic_flow.c b/drivers/net/ice/ice_generic_flow.c
index 8704812622..2389bc6637 100644
--- a/drivers/net/ice/ice_generic_flow.c
+++ b/drivers/net/ice/ice_generic_flow.c
@@ -212,6 +212,27 @@ enum rte_flow_item_type pattern_eth_qinq_ipv6[] = {
 	RTE_FLOW_ITEM_TYPE_IPV6,
 	RTE_FLOW_ITEM_TYPE_END,
 };
+enum rte_flow_item_type pattern_eth_ipv6_frag_ext[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+enum rte_flow_item_type pattern_eth_vlan_ipv6_frag_ext[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_VLAN,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+enum rte_flow_item_type pattern_eth_qinq_ipv6_frag_ext[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_VLAN,
+	RTE_FLOW_ITEM_TYPE_VLAN,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+	RTE_FLOW_ITEM_TYPE_END,
+};
 enum rte_flow_item_type pattern_eth_ipv6_udp[] = {
 	RTE_FLOW_ITEM_TYPE_ETH,
 	RTE_FLOW_ITEM_TYPE_IPV6,
diff --git a/drivers/net/ice/ice_generic_flow.h b/drivers/net/ice/ice_generic_flow.h
index 9f422e5925..2afe719264 100644
--- a/drivers/net/ice/ice_generic_flow.h
+++ b/drivers/net/ice/ice_generic_flow.h
@@ -52,6 +52,7 @@
 #define ICE_L2TPV3OIP_SESSION_ID	BIT_ULL(43)
 #define ICE_PFCP_SEID			BIT_ULL(42)
 #define ICE_PFCP_S_FIELD		BIT_ULL(41)
+#define ICE_IP_PK_ID		    BIT_ULL(40)
 
 /* input set */
 
@@ -69,11 +70,13 @@
 #define ICE_INSET_IPV4_TOS		(ICE_PROT_IPV4 | ICE_IP_TOS)
 #define ICE_INSET_IPV4_PROTO		(ICE_PROT_IPV4 | ICE_IP_PROTO)
 #define ICE_INSET_IPV4_TTL		(ICE_PROT_IPV4 | ICE_IP_TTL)
+#define ICE_INSET_IPV4_PKID		(ICE_PROT_IPV4 | ICE_IP_PK_ID)
 #define ICE_INSET_IPV6_SRC		(ICE_PROT_IPV6 | ICE_IP_SRC)
 #define ICE_INSET_IPV6_DST		(ICE_PROT_IPV6 | ICE_IP_DST)
 #define ICE_INSET_IPV6_NEXT_HDR		(ICE_PROT_IPV6 | ICE_IP_PROTO)
 #define ICE_INSET_IPV6_HOP_LIMIT	(ICE_PROT_IPV6 | ICE_IP_TTL)
 #define ICE_INSET_IPV6_TC		(ICE_PROT_IPV6 | ICE_IP_TOS)
+#define ICE_INSET_IPV6_PKID		(ICE_PROT_IPV6 | ICE_IP_PK_ID)
 
 #define ICE_INSET_TCP_SRC_PORT		(ICE_PROT_TCP | ICE_SPORT)
 #define ICE_INSET_TCP_DST_PORT		(ICE_PROT_TCP | ICE_DPORT)
@@ -202,6 +205,9 @@ extern enum rte_flow_item_type pattern_eth_qinq_ipv4_icmp[];
 extern enum rte_flow_item_type pattern_eth_ipv6[];
 extern enum rte_flow_item_type pattern_eth_vlan_ipv6[];
 extern enum rte_flow_item_type pattern_eth_qinq_ipv6[];
+extern enum rte_flow_item_type pattern_eth_ipv6_frag_ext[];
+extern enum rte_flow_item_type pattern_eth_vlan_ipv6_frag_ext[];
+extern enum rte_flow_item_type pattern_eth_qinq_ipv6_frag_ext[];
 extern enum rte_flow_item_type pattern_eth_ipv6_udp[];
 extern enum rte_flow_item_type pattern_eth_vlan_ipv6_udp[];
 extern enum rte_flow_item_type pattern_eth_qinq_ipv6_udp[];
diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c
index 7d7e7052da..9df20df550 100644
--- a/drivers/net/ice/ice_hash.c
+++ b/drivers/net/ice/ice_hash.c
@@ -47,8 +47,10 @@
 				 ETH_RSS_NONFRAG_IPV6_TCP	| \
 				 ETH_RSS_NONFRAG_IPV6_SCTP)
 
-#define VALID_RSS_IPV4		(ETH_RSS_IPV4 | VALID_RSS_IPV4_L4)
-#define VALID_RSS_IPV6		(ETH_RSS_IPV6 | VALID_RSS_IPV6_L4)
+#define VALID_RSS_IPV4		(ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 | \
+				 VALID_RSS_IPV4_L4)
+#define VALID_RSS_IPV6		(ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 | \
+				 VALID_RSS_IPV6_L4)
 #define VALID_RSS_L3		(VALID_RSS_IPV4 | VALID_RSS_IPV6)
 #define VALID_RSS_L4		(VALID_RSS_IPV4_L4 | VALID_RSS_IPV6_L4)
 
@@ -108,6 +110,7 @@ ice_hash_parse_pattern_action(struct ice_adapter *ad,
 /* Rss configuration template */
 struct ice_rss_hash_cfg ipv4_tmplt = {
 	ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV4 |
+	ICE_FLOW_SEG_HDR_IPV_FRAG |
 	ICE_FLOW_SEG_HDR_IPV_OTHER,
 	ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_IPV4,
 	ICE_RSS_OUTER_HEADERS,
@@ -146,6 +149,15 @@ struct ice_rss_hash_cfg ipv6_tmplt = {
 	0
 };
 
+struct ice_rss_hash_cfg ipv6_frag_tmplt = {
+	ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV6 |
+	ICE_FLOW_SEG_HDR_IPV_FRAG |
+	ICE_FLOW_SEG_HDR_IPV_OTHER,
+	ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_IPV6,
+	ICE_RSS_ANY_HEADERS,
+	0
+};
+
 struct ice_rss_hash_cfg ipv6_udp_tmplt = {
 	ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV6 |
 	ICE_FLOW_SEG_HDR_IPV_OTHER | ICE_FLOW_SEG_HDR_UDP,
@@ -198,6 +210,7 @@ struct ice_rss_hash_cfg outer_ipv6_inner_ipv4_tmplt = {
 	ICE_RSS_INNER_HEADERS_W_OUTER_IPV6,
 	0
 };
+
 struct ice_rss_hash_cfg outer_ipv6_inner_ipv4_udp_tmplt = {
 	ICE_FLOW_SEG_HDR_IPV4 | ICE_FLOW_SEG_HDR_IPV_OTHER |
 	ICE_FLOW_SEG_HDR_UDP,
@@ -220,6 +233,7 @@ struct ice_rss_hash_cfg outer_ipv4_inner_ipv6_tmplt = {
 	ICE_RSS_INNER_HEADERS_W_OUTER_IPV4,
 	0
 };
+
 struct ice_rss_hash_cfg outer_ipv4_inner_ipv6_udp_tmplt = {
 	ICE_FLOW_SEG_HDR_IPV6 | ICE_FLOW_SEG_HDR_IPV_OTHER |
 	ICE_FLOW_SEG_HDR_UDP,
@@ -353,7 +367,8 @@ struct ice_rss_hash_cfg empty_tmplt = {
 };
 
 /* IPv4 */
-#define ICE_RSS_TYPE_ETH_IPV4		(ETH_RSS_ETH | ETH_RSS_IPV4)
+#define ICE_RSS_TYPE_ETH_IPV4		(ETH_RSS_ETH | ETH_RSS_IPV4 | \
+					 ETH_RSS_FRAG_IPV4)
 #define ICE_RSS_TYPE_ETH_IPV4_UDP	(ICE_RSS_TYPE_ETH_IPV4 | \
 					 ETH_RSS_NONFRAG_IPV4_UDP)
 #define ICE_RSS_TYPE_ETH_IPV4_TCP	(ICE_RSS_TYPE_ETH_IPV4 | \
@@ -370,6 +385,8 @@ struct ice_rss_hash_cfg empty_tmplt = {
 
 /* IPv6 */
 #define ICE_RSS_TYPE_ETH_IPV6		(ETH_RSS_ETH | ETH_RSS_IPV6)
+#define ICE_RSS_TYPE_ETH_IPV6_FRAG	(ETH_RSS_ETH | ETH_RSS_IPV6 | \
+					 ETH_RSS_FRAG_IPV6)
 #define ICE_RSS_TYPE_ETH_IPV6_UDP	(ICE_RSS_TYPE_ETH_IPV6 | \
 					 ETH_RSS_NONFRAG_IPV6_UDP)
 #define ICE_RSS_TYPE_ETH_IPV6_TCP	(ICE_RSS_TYPE_ETH_IPV6 | \
@@ -386,7 +403,8 @@ struct ice_rss_hash_cfg empty_tmplt = {
 
 /* VLAN IPV4 */
 #define ICE_RSS_TYPE_VLAN_IPV4		(ICE_RSS_TYPE_IPV4 | \
-					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
+					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN | \
+					 ETH_RSS_FRAG_IPV4)
 #define ICE_RSS_TYPE_VLAN_IPV4_UDP	(ICE_RSS_TYPE_IPV4_UDP | \
 					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
 #define ICE_RSS_TYPE_VLAN_IPV4_TCP	(ICE_RSS_TYPE_IPV4_TCP | \
@@ -396,6 +414,9 @@ struct ice_rss_hash_cfg empty_tmplt = {
 /* VLAN IPv6 */
 #define ICE_RSS_TYPE_VLAN_IPV6		(ICE_RSS_TYPE_IPV6 | \
 					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
+#define ICE_RSS_TYPE_VLAN_IPV6_FRAG	(ICE_RSS_TYPE_IPV6 | \
+					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN | \
+					 ETH_RSS_FRAG_IPV6)
 #define ICE_RSS_TYPE_VLAN_IPV6_UDP	(ICE_RSS_TYPE_IPV6_UDP | \
 					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
 #define ICE_RSS_TYPE_VLAN_IPV6_TCP	(ICE_RSS_TYPE_IPV6_TCP | \
@@ -485,10 +506,12 @@ static struct ice_pattern_match_item ice_hash_pattern_list[] = {
 	{pattern_eth_ipv4_pfcp,			ICE_RSS_TYPE_IPV4_PFCP,		ICE_INSET_NONE,	&eth_ipv4_pfcp_tmplt},
 	/* IPV6 */
 	{pattern_eth_ipv6,			ICE_RSS_TYPE_ETH_IPV6,		ICE_INSET_NONE,	&ipv6_tmplt},
+	{pattern_eth_ipv6_frag_ext,		ICE_RSS_TYPE_ETH_IPV6_FRAG,	ICE_INSET_NONE,	&ipv6_frag_tmplt},
 	{pattern_eth_ipv6_udp,			ICE_RSS_TYPE_ETH_IPV6_UDP,	ICE_INSET_NONE,	&ipv6_udp_tmplt},
 	{pattern_eth_ipv6_tcp,			ICE_RSS_TYPE_ETH_IPV6_TCP,	ICE_INSET_NONE,	&ipv6_tcp_tmplt},
 	{pattern_eth_ipv6_sctp,			ICE_RSS_TYPE_ETH_IPV6_SCTP,	ICE_INSET_NONE,	&ipv6_sctp_tmplt},
 	{pattern_eth_vlan_ipv6,			ICE_RSS_TYPE_VLAN_IPV6,		ICE_INSET_NONE,	&ipv6_tmplt},
+	{pattern_eth_vlan_ipv6_frag_ext,	ICE_RSS_TYPE_VLAN_IPV6_FRAG,	ICE_INSET_NONE, &ipv6_frag_tmplt},
 	{pattern_eth_vlan_ipv6_udp,		ICE_RSS_TYPE_VLAN_IPV6_UDP,	ICE_INSET_NONE,	&ipv6_udp_tmplt},
 	{pattern_eth_vlan_ipv6_tcp,		ICE_RSS_TYPE_VLAN_IPV6_TCP,	ICE_INSET_NONE,	&ipv6_tcp_tmplt},
 	{pattern_eth_vlan_ipv6_sctp,		ICE_RSS_TYPE_VLAN_IPV6_SCTP,	ICE_INSET_NONE,	&ipv6_sctp_tmplt},
@@ -629,11 +652,14 @@ ice_refine_hash_cfg_l234(struct ice_rss_hash_cfg *hash_cfg,
 
 	if (*addl_hdrs & ICE_FLOW_SEG_HDR_IPV4) {
 		if (rss_type &
-		   (ETH_RSS_IPV4 |
+		   (ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 |
 		    ETH_RSS_NONFRAG_IPV4_UDP |
 		    ETH_RSS_NONFRAG_IPV4_TCP |
 		    ETH_RSS_NONFRAG_IPV4_SCTP)) {
-			if (rss_type & ETH_RSS_L3_SRC_ONLY)
+			if (rss_type & ETH_RSS_FRAG_IPV4)
+				*hash_flds &=
+					~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_ID));
+			else if (rss_type & ETH_RSS_L3_SRC_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA));
 			else if (rss_type & ETH_RSS_L3_DST_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA));
@@ -648,11 +674,14 @@ ice_refine_hash_cfg_l234(struct ice_rss_hash_cfg *hash_cfg,
 
 	if (*addl_hdrs & ICE_FLOW_SEG_HDR_IPV6) {
 		if (rss_type &
-		   (ETH_RSS_IPV6 |
+		   (ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 |
 		    ETH_RSS_NONFRAG_IPV6_UDP |
 		    ETH_RSS_NONFRAG_IPV6_TCP |
 		    ETH_RSS_NONFRAG_IPV6_SCTP)) {
-			if (rss_type & ETH_RSS_L3_SRC_ONLY)
+			if (rss_type & ETH_RSS_FRAG_IPV6)
+				*hash_flds &=
+					~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_ID));
+			else if (rss_type & ETH_RSS_L3_SRC_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA));
 			else if (rss_type & ETH_RSS_L3_DST_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA));
@@ -827,6 +856,8 @@ static void ice_refine_hash_cfg(struct ice_rss_hash_cfg *hash_cfg,
 static uint64_t invalid_rss_comb[] = {
 	ETH_RSS_IPV4 | ETH_RSS_NONFRAG_IPV4_UDP,
 	ETH_RSS_IPV6 | ETH_RSS_NONFRAG_IPV6_UDP,
+	ETH_RSS_FRAG_IPV4 | ETH_RSS_NONFRAG_IPV4_UDP,
+	ETH_RSS_FRAG_IPV6 | ETH_RSS_NONFRAG_IPV6_UDP,
 	RTE_ETH_RSS_L3_PRE40 |
 	RTE_ETH_RSS_L3_PRE56 |
 	RTE_ETH_RSS_L3_PRE96
@@ -865,6 +896,7 @@ ice_any_invalid_rss_type(enum rte_eth_hash_function rss_func,
 
 		if (!(rss_type &
 		   (ETH_RSS_IPV4 | ETH_RSS_IPV6 |
+		    ETH_RSS_FRAG_IPV4 | ETH_RSS_FRAG_IPV6 |
 		    ETH_RSS_NONFRAG_IPV4_UDP | ETH_RSS_NONFRAG_IPV6_UDP |
 		    ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_NONFRAG_IPV6_TCP |
 		    ETH_RSS_NONFRAG_IPV4_SCTP | ETH_RSS_NONFRAG_IPV6_SCTP)))
-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v3 3/3] net/ice: support FDIR for IP fragment packet
  2021-04-11  6:06   ` [dpdk-dev] [PATCH v3 0/3] support flow for IP fragment in ICE Jeff Guo
  2021-04-11  6:06     ` [dpdk-dev] [PATCH v3 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
  2021-04-11  6:06     ` [dpdk-dev] [PATCH v3 2/3] net/ice: support RSS hash for IP fragment Jeff Guo
@ 2021-04-11  6:06     ` Jeff Guo
  2 siblings, 0 replies; 42+ messages in thread
From: Jeff Guo @ 2021-04-11  6:06 UTC (permalink / raw)
  To: qi.z.zhang, qiming.yang; +Cc: dev, ting.xu, jia.guo

New FDIR parsing are added to handle the fragmented IPv4/IPv6 packet.

Signed-off-by: Jeff Guo <jia.guo@intel.com>
Signed-off-by: Ting Xu <ting.xu@intel.com>
---
 drivers/net/ice/ice_fdir_filter.c  | 116 ++++++++++++++++++++++++++---
 drivers/net/ice/ice_generic_flow.c |   1 +
 2 files changed, 106 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
index 92e18d59cc..093c83ed0c 100644
--- a/drivers/net/ice/ice_fdir_filter.c
+++ b/drivers/net/ice/ice_fdir_filter.c
@@ -24,7 +24,7 @@
 #define ICE_FDIR_INSET_ETH_IPV4 (\
 	ICE_FDIR_INSET_ETH | \
 	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | ICE_INSET_IPV4_TOS | \
-	ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO)
+	ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO | ICE_INSET_IPV4_PKID)
 
 #define ICE_FDIR_INSET_ETH_IPV4_UDP (\
 	ICE_FDIR_INSET_ETH_IPV4 | \
@@ -41,7 +41,8 @@
 #define ICE_FDIR_INSET_ETH_IPV6 (\
 	ICE_INSET_DMAC | \
 	ICE_INSET_IPV6_SRC | ICE_INSET_IPV6_DST | ICE_INSET_IPV6_TC | \
-	ICE_INSET_IPV6_HOP_LIMIT | ICE_INSET_IPV6_NEXT_HDR)
+	ICE_INSET_IPV6_HOP_LIMIT | ICE_INSET_IPV6_NEXT_HDR | \
+	ICE_INSET_IPV6_PKID)
 
 #define ICE_FDIR_INSET_ETH_IPV6_UDP (\
 	ICE_FDIR_INSET_ETH_IPV6 | \
@@ -56,7 +57,8 @@
 	ICE_INSET_SCTP_SRC_PORT | ICE_INSET_SCTP_DST_PORT)
 
 #define ICE_FDIR_INSET_IPV4 (\
-	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST)
+	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | \
+	ICE_INSET_IPV4_PKID)
 
 #define ICE_FDIR_INSET_IPV4_TCP (\
 	ICE_FDIR_INSET_IPV4 | \
@@ -95,6 +97,7 @@ static struct ice_pattern_match_item ice_fdir_pattern_list[] = {
 	{pattern_eth_ipv4_tcp,				ICE_FDIR_INSET_ETH_IPV4_TCP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv4_sctp,				ICE_FDIR_INSET_ETH_IPV4_SCTP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6,				ICE_FDIR_INSET_ETH_IPV6,	ICE_INSET_NONE,			ICE_INSET_NONE},
+	{pattern_eth_ipv6_frag_ext,			ICE_FDIR_INSET_ETH_IPV6,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6_udp,				ICE_FDIR_INSET_ETH_IPV6_UDP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6_tcp,				ICE_FDIR_INSET_ETH_IPV6_TCP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6_sctp,				ICE_FDIR_INSET_ETH_IPV6_SCTP,	ICE_INSET_NONE,			ICE_INSET_NONE},
@@ -882,11 +885,13 @@ ice_fdir_input_set_parse(uint64_t inset, enum ice_flow_field *field)
 		{ICE_INSET_IPV4_TOS, ICE_FLOW_FIELD_IDX_IPV4_DSCP},
 		{ICE_INSET_IPV4_TTL, ICE_FLOW_FIELD_IDX_IPV4_TTL},
 		{ICE_INSET_IPV4_PROTO, ICE_FLOW_FIELD_IDX_IPV4_PROT},
+		{ICE_INSET_IPV4_PKID, ICE_FLOW_FIELD_IDX_IPV4_ID},
 		{ICE_INSET_IPV6_SRC, ICE_FLOW_FIELD_IDX_IPV6_SA},
 		{ICE_INSET_IPV6_DST, ICE_FLOW_FIELD_IDX_IPV6_DA},
 		{ICE_INSET_IPV6_TC, ICE_FLOW_FIELD_IDX_IPV6_DSCP},
 		{ICE_INSET_IPV6_NEXT_HDR, ICE_FLOW_FIELD_IDX_IPV6_PROT},
 		{ICE_INSET_IPV6_HOP_LIMIT, ICE_FLOW_FIELD_IDX_IPV6_TTL},
+		{ICE_INSET_IPV6_PKID, ICE_FLOW_FIELD_IDX_IPV6_ID},
 		{ICE_INSET_TCP_SRC_PORT, ICE_FLOW_FIELD_IDX_TCP_SRC_PORT},
 		{ICE_INSET_TCP_DST_PORT, ICE_FLOW_FIELD_IDX_TCP_DST_PORT},
 		{ICE_INSET_UDP_SRC_PORT, ICE_FLOW_FIELD_IDX_UDP_SRC_PORT},
@@ -936,6 +941,10 @@ ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct ice_flow_seg_info *seg)
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4 |
 				  ICE_FLOW_SEG_HDR_IPV_OTHER);
 		break;
+	case ICE_FLTR_PTYPE_FRAG_IPV4:
+		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4 |
+				  ICE_FLOW_SEG_HDR_IPV_FRAG);
+		break;
 	case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP |
 				  ICE_FLOW_SEG_HDR_IPV6 |
@@ -955,6 +964,10 @@ ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct ice_flow_seg_info *seg)
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6 |
 				  ICE_FLOW_SEG_HDR_IPV_OTHER);
 		break;
+	case ICE_FLTR_PTYPE_FRAG_IPV6:
+		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6 |
+				  ICE_FLOW_SEG_HDR_IPV_FRAG);
+		break;
 	case ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN:
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP |
 				ICE_FLOW_SEG_HDR_IPV4 |
@@ -1599,8 +1612,10 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 	enum rte_flow_item_type l3 = RTE_FLOW_ITEM_TYPE_END;
 	enum ice_fdir_tunnel_type tunnel_type = ICE_FDIR_TUNNEL_TYPE_NONE;
 	const struct rte_flow_item_eth *eth_spec, *eth_mask;
-	const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_mask;
+	const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_last, *ipv4_mask;
 	const struct rte_flow_item_ipv6 *ipv6_spec, *ipv6_mask;
+	const struct rte_flow_item_ipv6_frag_ext *ipv6_frag_spec,
+					*ipv6_frag_last, *ipv6_frag_mask;
 	const struct rte_flow_item_tcp *tcp_spec, *tcp_mask;
 	const struct rte_flow_item_udp *udp_spec, *udp_mask;
 	const struct rte_flow_item_sctp *sctp_spec, *sctp_mask;
@@ -1639,13 +1654,14 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 	 * flow. input_set_i is used for inner part.
 	 */
 	for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
-		if (item->last) {
+		if (item->last && (item_type != RTE_FLOW_ITEM_TYPE_IPV4 ||
+				   item_type !=
+				   RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT)) {
 			rte_flow_error_set(error, EINVAL,
-					   RTE_FLOW_ERROR_TYPE_ITEM,
-					   item,
+					   RTE_FLOW_ERROR_TYPE_ITEM, item,
 					   "Not support range");
-			return -rte_errno;
 		}
+
 		item_type = item->type;
 
 		input_set = (tunnel_type && !is_outer) ?
@@ -1696,6 +1712,7 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			flow_type = ICE_FLTR_PTYPE_NONF_IPV4_OTHER;
 			l3 = RTE_FLOW_ITEM_TYPE_IPV4;
 			ipv4_spec = item->spec;
+			ipv4_last = item->last;
 			ipv4_mask = item->mask;
 			p_v4 = (tunnel_type && is_outer) ?
 			       &filter->input.ip_outer.v4 :
@@ -1707,8 +1724,6 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			/* Check IPv4 mask and update input set */
 			if (ipv4_mask->hdr.version_ihl ||
 			    ipv4_mask->hdr.total_length ||
-			    ipv4_mask->hdr.packet_id ||
-			    ipv4_mask->hdr.fragment_offset ||
 			    ipv4_mask->hdr.hdr_checksum) {
 				rte_flow_error_set(error, EINVAL,
 						   RTE_FLOW_ERROR_TYPE_ITEM,
@@ -1717,6 +1732,21 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 				return -rte_errno;
 			}
 
+			if (ipv4_last &&
+			    (ipv4_last->hdr.version_ihl ||
+			     ipv4_last->hdr.type_of_service ||
+			     ipv4_last->hdr.time_to_live ||
+			     ipv4_last->hdr.total_length |
+			     ipv4_last->hdr.next_proto_id ||
+			     ipv4_last->hdr.hdr_checksum ||
+			     ipv4_last->hdr.src_addr ||
+			     ipv4_last->hdr.dst_addr)) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ITEM,
+						   item, "Invalid IPv4 last.");
+				return -rte_errno;
+			}
+
 			if (ipv4_mask->hdr.dst_addr == UINT32_MAX)
 				*input_set |= ICE_INSET_IPV4_DST;
 			if (ipv4_mask->hdr.src_addr == UINT32_MAX)
@@ -1733,6 +1763,32 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			p_v4->ttl = ipv4_spec->hdr.time_to_live;
 			p_v4->proto = ipv4_spec->hdr.next_proto_id;
 			p_v4->tos = ipv4_spec->hdr.type_of_service;
+
+			/* only support any packet id for fragment IPv4
+			 * any packet_id:
+			 * spec is 0, last is 0xffff, mask is 0xffff
+			 * fragment Ipv4:
+			 * spec is 0x2000, mask is 0xffff
+			 */
+			if (ipv4_last && ipv4_spec->hdr.packet_id == 0 &&
+			    ipv4_last->hdr.packet_id == UINT16_MAX &&
+			    ipv4_mask->hdr.packet_id == UINT16_MAX &&
+			    ipv4_spec->hdr.fragment_offset ==
+			    rte_cpu_to_be_16(RTE_IPV4_HDR_MF_FLAG) &&
+			    ipv4_mask->hdr.fragment_offset == UINT16_MAX) {
+				/* all IPv4 fragment packet has the same
+				 * ethertype, if the spec is for all valid
+				 * packet id, set ethertype into input set.
+				 */
+				*input_set |= ICE_INSET_ETHERTYPE;
+				input_set_o |= ICE_INSET_ETHERTYPE;
+			} else if (ipv4_mask->hdr.packet_id == UINT16_MAX) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ITEM,
+						   item, "Invalid IPv4 mask.");
+				return -rte_errno;
+			}
+
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV6:
 			flow_type = ICE_FLTR_PTYPE_NONF_IPV6_OTHER;
@@ -1778,6 +1834,43 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			p_v6->proto = ipv6_spec->hdr.proto;
 			p_v6->hlim = ipv6_spec->hdr.hop_limits;
 			break;
+		case RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT:
+			l3 = RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT;
+			flow_type = ICE_FLTR_PTYPE_FRAG_IPV6;
+			ipv6_frag_spec = item->spec;
+			ipv6_frag_last = item->last;
+			ipv6_frag_mask = item->mask;
+
+			if (!(ipv6_frag_spec && ipv6_frag_mask))
+				break;
+
+			/* only support any packet id for fragment IPv6
+			 * any packet_id:
+			 * spec is 0, last is 0xffffffff, mask is 0xffffffff
+			 * fragment Ipv6:
+			 * spec is 0x1, mask is 0xffff
+			 */
+			if (ipv6_frag_last && ipv6_frag_spec->hdr.id == 0 &&
+			    ipv6_frag_last->hdr.id == UINT32_MAX &&
+			    ipv6_frag_mask->hdr.id == UINT32_MAX &&
+			    ipv6_frag_spec->hdr.frag_data ==
+			    rte_cpu_to_be_16(1) &&
+			    ipv6_frag_mask->hdr.frag_data == UINT16_MAX) {
+				/* all IPv6 fragment packet has the same
+				 * ethertype, if the spec is for all valid
+				 * packet id, set ethertype into input set.
+				 */
+				*input_set |= ICE_INSET_ETHERTYPE;
+				input_set_o |= ICE_INSET_ETHERTYPE;
+			} else if (ipv6_frag_mask->hdr.id == UINT32_MAX) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ITEM,
+						   item, "Invalid IPv6 mask.");
+				return -rte_errno;
+			}
+
+			break;
+
 		case RTE_FLOW_ITEM_TYPE_TCP:
 			if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
 				flow_type = ICE_FLTR_PTYPE_NONF_IPV4_TCP;
@@ -2016,7 +2109,8 @@ ice_fdir_parse(struct ice_adapter *ad,
 	if (ret)
 		goto error;
 	input_set = filter->input_set_o | filter->input_set_i;
-	if (!input_set || filter->input_set_o & ~item->input_set_mask_o ||
+	if (!input_set || filter->input_set_o &
+	    ~(item->input_set_mask_o | ICE_INSET_ETHERTYPE) ||
 	    filter->input_set_i & ~item->input_set_mask_i) {
 		rte_flow_error_set(error, EINVAL,
 				   RTE_FLOW_ERROR_TYPE_ITEM_SPEC,
diff --git a/drivers/net/ice/ice_generic_flow.c b/drivers/net/ice/ice_generic_flow.c
index 2389bc6637..7a34a51600 100644
--- a/drivers/net/ice/ice_generic_flow.c
+++ b/drivers/net/ice/ice_generic_flow.c
@@ -2108,6 +2108,7 @@ static struct ice_ptype_match ice_ptype_map[] = {
 	{pattern_eth_ipv6_udp,				ICE_PTYPE_IPV6_UDP_PAY},
 	{pattern_eth_ipv6_tcp,				ICE_PTYPE_IPV6_TCP_PAY},
 	{pattern_eth_ipv6_sctp,				ICE_PTYPE_IPV6_SCTP_PAY},
+	{pattern_eth_ipv6_frag_ext,			ICE_PTYPE_IPV6FRAG_PAY},
 	{pattern_eth_ipv6_gtpu,				ICE_MAC_IPV6_GTPU},
 	{pattern_eth_ipv6_gtpu_eh,			ICE_MAC_IPV6_GTPU},
 	{pattern_eth_ipv6_gtpu_ipv4,			ICE_MAC_IPV6_GTPU_IPV4_PAY},
-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v3 0/3] support flow for IP fragment in ICE
  2021-03-24 13:54 ` [dpdk-dev] [PATCH v2 0/3] support flow for IP fragment in ICE Jeff Guo
                     ` (3 preceding siblings ...)
  2021-04-11  6:06   ` [dpdk-dev] [PATCH v3 0/3] support flow for IP fragment in ICE Jeff Guo
@ 2021-04-11  6:57   ` Jeff Guo
  2021-04-11  6:57     ` [dpdk-dev] [PATCH v3 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
                       ` (2 more replies)
  2021-04-13  7:58   ` [dpdk-dev] [PATCH v4 0/3] support flow for IP fragment in ICE Jeff Guo
                     ` (3 subsequent siblings)
  8 siblings, 3 replies; 42+ messages in thread
From: Jeff Guo @ 2021-04-11  6:57 UTC (permalink / raw)
  To: qi.z.zhang, qiming.yang; +Cc: dev, ting.xu, jia.guo

Support RSS hash and FDIR for IP fragment packets in ICE PMD.

v3:
rebase code and fix some parsing issues.
v2:
add some input check

Jeff Guo (3):
  net/ice/base: support IP fragment RSS and FDIR
  net/ice: support RSS hash for IP fragment
  net/ice: support FDIR for IP fragment packet

 drivers/net/ice/base/ice_fdir.c    |  50 ++++++++++++-
 drivers/net/ice/base/ice_fdir.h    |  22 +++++-
 drivers/net/ice/base/ice_flow.c    |  50 ++++++++++++-
 drivers/net/ice/base/ice_flow.h    |   5 +-
 drivers/net/ice/base/ice_type.h    |   1 +
 drivers/net/ice/ice_fdir_filter.c  | 116 ++++++++++++++++++++++++++---
 drivers/net/ice/ice_generic_flow.c |  22 ++++++
 drivers/net/ice/ice_generic_flow.h |   6 ++
 drivers/net/ice/ice_hash.c         |  48 ++++++++++--
 9 files changed, 293 insertions(+), 27 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v3 1/3] net/ice/base: support IP fragment RSS and FDIR
  2021-04-11  6:57   ` [dpdk-dev] [PATCH v3 0/3] support flow for IP fragment in ICE Jeff Guo
@ 2021-04-11  6:57     ` Jeff Guo
  2021-04-11  6:57     ` [dpdk-dev] [PATCH v3 2/3] net/ice: support RSS hash for IP fragment Jeff Guo
  2021-04-11  6:57     ` [dpdk-dev] [PATCH v3 3/3] net/ice: support FDIR for IP fragment packet Jeff Guo
  2 siblings, 0 replies; 42+ messages in thread
From: Jeff Guo @ 2021-04-11  6:57 UTC (permalink / raw)
  To: qi.z.zhang, qiming.yang; +Cc: dev, ting.xu, jia.guo

Add support for IP fragment RSS hash and FDIR according to packet ID.
Separate IP fragment and IP other packet types.

Signed-off-by: Ting Xu <ting.xu@intel.com>
Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
 drivers/net/ice/base/ice_fdir.c | 50 +++++++++++++++++++++++++++++++--
 drivers/net/ice/base/ice_fdir.h | 22 ++++++++++++---
 drivers/net/ice/base/ice_flow.c | 50 ++++++++++++++++++++++++++++++++-
 drivers/net/ice/base/ice_flow.h |  5 +++-
 drivers/net/ice/base/ice_type.h |  1 +
 5 files changed, 120 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ice/base/ice_fdir.c b/drivers/net/ice/base/ice_fdir.c
index 2b39c13127..0eb7cdd729 100644
--- a/drivers/net/ice/base/ice_fdir.c
+++ b/drivers/net/ice/base/ice_fdir.c
@@ -518,6 +518,24 @@ 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 +734,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_pkt), ice_fdir_ipv4_frag_pkt,
+		sizeof(ice_fdir_ipv4_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),
@@ -1505,7 +1533,7 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
 		ice_pkt_insert_u8(loc, ICE_IPV4_TTL_OFFSET, input->ip.v4.ttl);
 		ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
 		if (frag)
-			loc[20] = ICE_FDIR_IPV4_PKT_FLAG_DF;
+			loc[20] = ICE_FDIR_IPV4_PKT_FLAG_MF;
 		break;
 	case ICE_FLTR_PTYPE_NONF_IPV4_UDP:
 		ice_pkt_insert_mac_addr(pkt, input->ext_data_outer.dst_mac);
@@ -1808,6 +1836,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 +1883,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;
diff --git a/drivers/net/ice/base/ice_fdir.h b/drivers/net/ice/base/ice_fdir.h
index 6573f96bc1..2acc1d6f1b 100644
--- a/drivers/net/ice/base/ice_fdir.h
+++ b/drivers/net/ice/base/ice_fdir.h
@@ -43,9 +43,11 @@
 #define ICE_MAC_ETHTYPE_OFFSET		12
 #define ICE_IPV4_TOS_OFFSET		15
 #define ICE_IPV4_TTL_OFFSET		22
+#define ICE_IPV4_ID_OFFSET		18
 #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
@@ -83,12 +85,22 @@
 
 #define ICE_FDIR_MAX_FLTRS		16384
 
-/* IP v4 has 2 flag bits that enable fragment processing: DF and MF. DF
+/* IPv4 has 2 flag bits that enable fragment processing: DF and MF. DF
  * requests that the packet not be fragmented. MF indicates that a packet has
- * been fragmented.
+ * been fragmented, except that for the last fragment has a non-zero
+ * Fragment Offset field with zero MF.
  */
-#define ICE_FDIR_IPV4_PKT_FLAG_DF		0x20
-#define ICE_FDIR_IPV4_PKT_FLAG_MF		0x40
+#define ICE_FDIR_IPV4_PKT_FLAG_MF		0x20
+#define ICE_FDIR_IPV4_PKT_FLAG_MF_SHIFT	8
+#ifndef NO_UNUSED_PACKAGE_CODE
+#define ICE_FDIR_IPV4_PKT_FLAG_DF		0x40
+#endif /* NO_UNUSED_PACKAGE_CODE */
+
+/* For IPv6 fragmented packets, all fragments except the last have
+ * the MF flag set.
+ */
+#define ICE_FDIR_IPV6_PKT_FLAG_MF		0x100
+#define ICE_FDIR_IPV6_PKT_FLAG_MF_SHIFT	8
 
 enum ice_fltr_prgm_desc_dest {
 	ICE_FLTR_PRGM_DESC_DEST_DROP_PKT,
@@ -150,6 +162,7 @@ struct ice_fdir_v4 {
 	u8 ip_ver;
 	u8 proto;
 	u8 ttl;
+	__be16 packet_id;
 };
 
 #define ICE_IPV6_ADDR_LEN_AS_U32		4
@@ -164,6 +177,7 @@ struct ice_fdir_v6 {
 	u8 tc;
 	u8 proto;
 	u8 hlim;
+	__be32 packet_id;
 };
 
 struct ice_fdir_udp_gtp {
diff --git a/drivers/net/ice/base/ice_flow.c b/drivers/net/ice/base/ice_flow.c
index c12ddfa247..9dea881914 100644
--- a/drivers/net/ice/base/ice_flow.c
+++ b/drivers/net/ice/base/ice_flow.c
@@ -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),
@@ -725,6 +733,27 @@ static const u32 ice_ptypes_udp_ecpri_tp0[] = {
 	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;
@@ -899,6 +928,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 :
@@ -1177,6 +1216,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:
@@ -1187,6 +1229,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:
@@ -3341,13 +3386,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);
diff --git a/drivers/net/ice/base/ice_flow.h b/drivers/net/ice/base/ice_flow.h
index af15ecb0ff..d905b95b1c 100644
--- a/drivers/net/ice/base/ice_flow.h
+++ b/drivers/net/ice/base/ice_flow.h
@@ -186,8 +186,9 @@ enum ice_flow_seg_hdr {
 	ICE_FLOW_SEG_HDR_ECPRI_TP0	= 0x04000000,
 	ICE_FLOW_SEG_HDR_UDP_ECPRI_TP0	= 0x08000000,
 	/* 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_FRAG	= 0x10000000,
 	ICE_FLOW_SEG_HDR_IPV_OTHER	= 0x20000000,
 };
 
@@ -225,6 +226,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,
diff --git a/drivers/net/ice/base/ice_type.h b/drivers/net/ice/base/ice_type.h
index a6599363f9..5abe9dc9ea 100644
--- a/drivers/net/ice/base/ice_type.h
+++ b/drivers/net/ice/base/ice_type.h
@@ -349,6 +349,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,
-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v3 2/3] net/ice: support RSS hash for IP fragment
  2021-04-11  6:57   ` [dpdk-dev] [PATCH v3 0/3] support flow for IP fragment in ICE Jeff Guo
  2021-04-11  6:57     ` [dpdk-dev] [PATCH v3 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
@ 2021-04-11  6:57     ` Jeff Guo
  2021-04-11  6:57     ` [dpdk-dev] [PATCH v3 3/3] net/ice: support FDIR for IP fragment packet Jeff Guo
  2 siblings, 0 replies; 42+ messages in thread
From: Jeff Guo @ 2021-04-11  6:57 UTC (permalink / raw)
  To: qi.z.zhang, qiming.yang; +Cc: dev, ting.xu, jia.guo

New pattern and RSS hash flow parsing are added to handle fragmented
IPv4/IPv6  packet.

Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
 drivers/net/ice/ice_generic_flow.c | 21 +++++++++++++
 drivers/net/ice/ice_generic_flow.h |  6 ++++
 drivers/net/ice/ice_hash.c         | 48 +++++++++++++++++++++++++-----
 3 files changed, 67 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ice/ice_generic_flow.c b/drivers/net/ice/ice_generic_flow.c
index 8704812622..2389bc6637 100644
--- a/drivers/net/ice/ice_generic_flow.c
+++ b/drivers/net/ice/ice_generic_flow.c
@@ -212,6 +212,27 @@ enum rte_flow_item_type pattern_eth_qinq_ipv6[] = {
 	RTE_FLOW_ITEM_TYPE_IPV6,
 	RTE_FLOW_ITEM_TYPE_END,
 };
+enum rte_flow_item_type pattern_eth_ipv6_frag_ext[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+enum rte_flow_item_type pattern_eth_vlan_ipv6_frag_ext[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_VLAN,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+enum rte_flow_item_type pattern_eth_qinq_ipv6_frag_ext[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_VLAN,
+	RTE_FLOW_ITEM_TYPE_VLAN,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+	RTE_FLOW_ITEM_TYPE_END,
+};
 enum rte_flow_item_type pattern_eth_ipv6_udp[] = {
 	RTE_FLOW_ITEM_TYPE_ETH,
 	RTE_FLOW_ITEM_TYPE_IPV6,
diff --git a/drivers/net/ice/ice_generic_flow.h b/drivers/net/ice/ice_generic_flow.h
index 9f422e5925..2afe719264 100644
--- a/drivers/net/ice/ice_generic_flow.h
+++ b/drivers/net/ice/ice_generic_flow.h
@@ -52,6 +52,7 @@
 #define ICE_L2TPV3OIP_SESSION_ID	BIT_ULL(43)
 #define ICE_PFCP_SEID			BIT_ULL(42)
 #define ICE_PFCP_S_FIELD		BIT_ULL(41)
+#define ICE_IP_PK_ID		    BIT_ULL(40)
 
 /* input set */
 
@@ -69,11 +70,13 @@
 #define ICE_INSET_IPV4_TOS		(ICE_PROT_IPV4 | ICE_IP_TOS)
 #define ICE_INSET_IPV4_PROTO		(ICE_PROT_IPV4 | ICE_IP_PROTO)
 #define ICE_INSET_IPV4_TTL		(ICE_PROT_IPV4 | ICE_IP_TTL)
+#define ICE_INSET_IPV4_PKID		(ICE_PROT_IPV4 | ICE_IP_PK_ID)
 #define ICE_INSET_IPV6_SRC		(ICE_PROT_IPV6 | ICE_IP_SRC)
 #define ICE_INSET_IPV6_DST		(ICE_PROT_IPV6 | ICE_IP_DST)
 #define ICE_INSET_IPV6_NEXT_HDR		(ICE_PROT_IPV6 | ICE_IP_PROTO)
 #define ICE_INSET_IPV6_HOP_LIMIT	(ICE_PROT_IPV6 | ICE_IP_TTL)
 #define ICE_INSET_IPV6_TC		(ICE_PROT_IPV6 | ICE_IP_TOS)
+#define ICE_INSET_IPV6_PKID		(ICE_PROT_IPV6 | ICE_IP_PK_ID)
 
 #define ICE_INSET_TCP_SRC_PORT		(ICE_PROT_TCP | ICE_SPORT)
 #define ICE_INSET_TCP_DST_PORT		(ICE_PROT_TCP | ICE_DPORT)
@@ -202,6 +205,9 @@ extern enum rte_flow_item_type pattern_eth_qinq_ipv4_icmp[];
 extern enum rte_flow_item_type pattern_eth_ipv6[];
 extern enum rte_flow_item_type pattern_eth_vlan_ipv6[];
 extern enum rte_flow_item_type pattern_eth_qinq_ipv6[];
+extern enum rte_flow_item_type pattern_eth_ipv6_frag_ext[];
+extern enum rte_flow_item_type pattern_eth_vlan_ipv6_frag_ext[];
+extern enum rte_flow_item_type pattern_eth_qinq_ipv6_frag_ext[];
 extern enum rte_flow_item_type pattern_eth_ipv6_udp[];
 extern enum rte_flow_item_type pattern_eth_vlan_ipv6_udp[];
 extern enum rte_flow_item_type pattern_eth_qinq_ipv6_udp[];
diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c
index 7d7e7052da..9df20df550 100644
--- a/drivers/net/ice/ice_hash.c
+++ b/drivers/net/ice/ice_hash.c
@@ -47,8 +47,10 @@
 				 ETH_RSS_NONFRAG_IPV6_TCP	| \
 				 ETH_RSS_NONFRAG_IPV6_SCTP)
 
-#define VALID_RSS_IPV4		(ETH_RSS_IPV4 | VALID_RSS_IPV4_L4)
-#define VALID_RSS_IPV6		(ETH_RSS_IPV6 | VALID_RSS_IPV6_L4)
+#define VALID_RSS_IPV4		(ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 | \
+				 VALID_RSS_IPV4_L4)
+#define VALID_RSS_IPV6		(ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 | \
+				 VALID_RSS_IPV6_L4)
 #define VALID_RSS_L3		(VALID_RSS_IPV4 | VALID_RSS_IPV6)
 #define VALID_RSS_L4		(VALID_RSS_IPV4_L4 | VALID_RSS_IPV6_L4)
 
@@ -108,6 +110,7 @@ ice_hash_parse_pattern_action(struct ice_adapter *ad,
 /* Rss configuration template */
 struct ice_rss_hash_cfg ipv4_tmplt = {
 	ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV4 |
+	ICE_FLOW_SEG_HDR_IPV_FRAG |
 	ICE_FLOW_SEG_HDR_IPV_OTHER,
 	ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_IPV4,
 	ICE_RSS_OUTER_HEADERS,
@@ -146,6 +149,15 @@ struct ice_rss_hash_cfg ipv6_tmplt = {
 	0
 };
 
+struct ice_rss_hash_cfg ipv6_frag_tmplt = {
+	ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV6 |
+	ICE_FLOW_SEG_HDR_IPV_FRAG |
+	ICE_FLOW_SEG_HDR_IPV_OTHER,
+	ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_IPV6,
+	ICE_RSS_ANY_HEADERS,
+	0
+};
+
 struct ice_rss_hash_cfg ipv6_udp_tmplt = {
 	ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV6 |
 	ICE_FLOW_SEG_HDR_IPV_OTHER | ICE_FLOW_SEG_HDR_UDP,
@@ -198,6 +210,7 @@ struct ice_rss_hash_cfg outer_ipv6_inner_ipv4_tmplt = {
 	ICE_RSS_INNER_HEADERS_W_OUTER_IPV6,
 	0
 };
+
 struct ice_rss_hash_cfg outer_ipv6_inner_ipv4_udp_tmplt = {
 	ICE_FLOW_SEG_HDR_IPV4 | ICE_FLOW_SEG_HDR_IPV_OTHER |
 	ICE_FLOW_SEG_HDR_UDP,
@@ -220,6 +233,7 @@ struct ice_rss_hash_cfg outer_ipv4_inner_ipv6_tmplt = {
 	ICE_RSS_INNER_HEADERS_W_OUTER_IPV4,
 	0
 };
+
 struct ice_rss_hash_cfg outer_ipv4_inner_ipv6_udp_tmplt = {
 	ICE_FLOW_SEG_HDR_IPV6 | ICE_FLOW_SEG_HDR_IPV_OTHER |
 	ICE_FLOW_SEG_HDR_UDP,
@@ -353,7 +367,8 @@ struct ice_rss_hash_cfg empty_tmplt = {
 };
 
 /* IPv4 */
-#define ICE_RSS_TYPE_ETH_IPV4		(ETH_RSS_ETH | ETH_RSS_IPV4)
+#define ICE_RSS_TYPE_ETH_IPV4		(ETH_RSS_ETH | ETH_RSS_IPV4 | \
+					 ETH_RSS_FRAG_IPV4)
 #define ICE_RSS_TYPE_ETH_IPV4_UDP	(ICE_RSS_TYPE_ETH_IPV4 | \
 					 ETH_RSS_NONFRAG_IPV4_UDP)
 #define ICE_RSS_TYPE_ETH_IPV4_TCP	(ICE_RSS_TYPE_ETH_IPV4 | \
@@ -370,6 +385,8 @@ struct ice_rss_hash_cfg empty_tmplt = {
 
 /* IPv6 */
 #define ICE_RSS_TYPE_ETH_IPV6		(ETH_RSS_ETH | ETH_RSS_IPV6)
+#define ICE_RSS_TYPE_ETH_IPV6_FRAG	(ETH_RSS_ETH | ETH_RSS_IPV6 | \
+					 ETH_RSS_FRAG_IPV6)
 #define ICE_RSS_TYPE_ETH_IPV6_UDP	(ICE_RSS_TYPE_ETH_IPV6 | \
 					 ETH_RSS_NONFRAG_IPV6_UDP)
 #define ICE_RSS_TYPE_ETH_IPV6_TCP	(ICE_RSS_TYPE_ETH_IPV6 | \
@@ -386,7 +403,8 @@ struct ice_rss_hash_cfg empty_tmplt = {
 
 /* VLAN IPV4 */
 #define ICE_RSS_TYPE_VLAN_IPV4		(ICE_RSS_TYPE_IPV4 | \
-					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
+					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN | \
+					 ETH_RSS_FRAG_IPV4)
 #define ICE_RSS_TYPE_VLAN_IPV4_UDP	(ICE_RSS_TYPE_IPV4_UDP | \
 					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
 #define ICE_RSS_TYPE_VLAN_IPV4_TCP	(ICE_RSS_TYPE_IPV4_TCP | \
@@ -396,6 +414,9 @@ struct ice_rss_hash_cfg empty_tmplt = {
 /* VLAN IPv6 */
 #define ICE_RSS_TYPE_VLAN_IPV6		(ICE_RSS_TYPE_IPV6 | \
 					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
+#define ICE_RSS_TYPE_VLAN_IPV6_FRAG	(ICE_RSS_TYPE_IPV6 | \
+					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN | \
+					 ETH_RSS_FRAG_IPV6)
 #define ICE_RSS_TYPE_VLAN_IPV6_UDP	(ICE_RSS_TYPE_IPV6_UDP | \
 					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
 #define ICE_RSS_TYPE_VLAN_IPV6_TCP	(ICE_RSS_TYPE_IPV6_TCP | \
@@ -485,10 +506,12 @@ static struct ice_pattern_match_item ice_hash_pattern_list[] = {
 	{pattern_eth_ipv4_pfcp,			ICE_RSS_TYPE_IPV4_PFCP,		ICE_INSET_NONE,	&eth_ipv4_pfcp_tmplt},
 	/* IPV6 */
 	{pattern_eth_ipv6,			ICE_RSS_TYPE_ETH_IPV6,		ICE_INSET_NONE,	&ipv6_tmplt},
+	{pattern_eth_ipv6_frag_ext,		ICE_RSS_TYPE_ETH_IPV6_FRAG,	ICE_INSET_NONE,	&ipv6_frag_tmplt},
 	{pattern_eth_ipv6_udp,			ICE_RSS_TYPE_ETH_IPV6_UDP,	ICE_INSET_NONE,	&ipv6_udp_tmplt},
 	{pattern_eth_ipv6_tcp,			ICE_RSS_TYPE_ETH_IPV6_TCP,	ICE_INSET_NONE,	&ipv6_tcp_tmplt},
 	{pattern_eth_ipv6_sctp,			ICE_RSS_TYPE_ETH_IPV6_SCTP,	ICE_INSET_NONE,	&ipv6_sctp_tmplt},
 	{pattern_eth_vlan_ipv6,			ICE_RSS_TYPE_VLAN_IPV6,		ICE_INSET_NONE,	&ipv6_tmplt},
+	{pattern_eth_vlan_ipv6_frag_ext,	ICE_RSS_TYPE_VLAN_IPV6_FRAG,	ICE_INSET_NONE, &ipv6_frag_tmplt},
 	{pattern_eth_vlan_ipv6_udp,		ICE_RSS_TYPE_VLAN_IPV6_UDP,	ICE_INSET_NONE,	&ipv6_udp_tmplt},
 	{pattern_eth_vlan_ipv6_tcp,		ICE_RSS_TYPE_VLAN_IPV6_TCP,	ICE_INSET_NONE,	&ipv6_tcp_tmplt},
 	{pattern_eth_vlan_ipv6_sctp,		ICE_RSS_TYPE_VLAN_IPV6_SCTP,	ICE_INSET_NONE,	&ipv6_sctp_tmplt},
@@ -629,11 +652,14 @@ ice_refine_hash_cfg_l234(struct ice_rss_hash_cfg *hash_cfg,
 
 	if (*addl_hdrs & ICE_FLOW_SEG_HDR_IPV4) {
 		if (rss_type &
-		   (ETH_RSS_IPV4 |
+		   (ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 |
 		    ETH_RSS_NONFRAG_IPV4_UDP |
 		    ETH_RSS_NONFRAG_IPV4_TCP |
 		    ETH_RSS_NONFRAG_IPV4_SCTP)) {
-			if (rss_type & ETH_RSS_L3_SRC_ONLY)
+			if (rss_type & ETH_RSS_FRAG_IPV4)
+				*hash_flds &=
+					~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_ID));
+			else if (rss_type & ETH_RSS_L3_SRC_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA));
 			else if (rss_type & ETH_RSS_L3_DST_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA));
@@ -648,11 +674,14 @@ ice_refine_hash_cfg_l234(struct ice_rss_hash_cfg *hash_cfg,
 
 	if (*addl_hdrs & ICE_FLOW_SEG_HDR_IPV6) {
 		if (rss_type &
-		   (ETH_RSS_IPV6 |
+		   (ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 |
 		    ETH_RSS_NONFRAG_IPV6_UDP |
 		    ETH_RSS_NONFRAG_IPV6_TCP |
 		    ETH_RSS_NONFRAG_IPV6_SCTP)) {
-			if (rss_type & ETH_RSS_L3_SRC_ONLY)
+			if (rss_type & ETH_RSS_FRAG_IPV6)
+				*hash_flds &=
+					~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_ID));
+			else if (rss_type & ETH_RSS_L3_SRC_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA));
 			else if (rss_type & ETH_RSS_L3_DST_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA));
@@ -827,6 +856,8 @@ static void ice_refine_hash_cfg(struct ice_rss_hash_cfg *hash_cfg,
 static uint64_t invalid_rss_comb[] = {
 	ETH_RSS_IPV4 | ETH_RSS_NONFRAG_IPV4_UDP,
 	ETH_RSS_IPV6 | ETH_RSS_NONFRAG_IPV6_UDP,
+	ETH_RSS_FRAG_IPV4 | ETH_RSS_NONFRAG_IPV4_UDP,
+	ETH_RSS_FRAG_IPV6 | ETH_RSS_NONFRAG_IPV6_UDP,
 	RTE_ETH_RSS_L3_PRE40 |
 	RTE_ETH_RSS_L3_PRE56 |
 	RTE_ETH_RSS_L3_PRE96
@@ -865,6 +896,7 @@ ice_any_invalid_rss_type(enum rte_eth_hash_function rss_func,
 
 		if (!(rss_type &
 		   (ETH_RSS_IPV4 | ETH_RSS_IPV6 |
+		    ETH_RSS_FRAG_IPV4 | ETH_RSS_FRAG_IPV6 |
 		    ETH_RSS_NONFRAG_IPV4_UDP | ETH_RSS_NONFRAG_IPV6_UDP |
 		    ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_NONFRAG_IPV6_TCP |
 		    ETH_RSS_NONFRAG_IPV4_SCTP | ETH_RSS_NONFRAG_IPV6_SCTP)))
-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v3 3/3] net/ice: support FDIR for IP fragment packet
  2021-04-11  6:57   ` [dpdk-dev] [PATCH v3 0/3] support flow for IP fragment in ICE Jeff Guo
  2021-04-11  6:57     ` [dpdk-dev] [PATCH v3 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
  2021-04-11  6:57     ` [dpdk-dev] [PATCH v3 2/3] net/ice: support RSS hash for IP fragment Jeff Guo
@ 2021-04-11  6:57     ` Jeff Guo
  2 siblings, 0 replies; 42+ messages in thread
From: Jeff Guo @ 2021-04-11  6:57 UTC (permalink / raw)
  To: qi.z.zhang, qiming.yang; +Cc: dev, ting.xu, jia.guo

New FDIR parsing are added to handle the fragmented IPv4/IPv6 packet.

Signed-off-by: Jeff Guo <jia.guo@intel.com>
Signed-off-by: Ting Xu <ting.xu@intel.com>
---
 drivers/net/ice/ice_fdir_filter.c  | 116 ++++++++++++++++++++++++++---
 drivers/net/ice/ice_generic_flow.c |   1 +
 2 files changed, 106 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
index 92e18d59cc..8158f75f05 100644
--- a/drivers/net/ice/ice_fdir_filter.c
+++ b/drivers/net/ice/ice_fdir_filter.c
@@ -24,7 +24,7 @@
 #define ICE_FDIR_INSET_ETH_IPV4 (\
 	ICE_FDIR_INSET_ETH | \
 	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | ICE_INSET_IPV4_TOS | \
-	ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO)
+	ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO | ICE_INSET_IPV4_PKID)
 
 #define ICE_FDIR_INSET_ETH_IPV4_UDP (\
 	ICE_FDIR_INSET_ETH_IPV4 | \
@@ -41,7 +41,8 @@
 #define ICE_FDIR_INSET_ETH_IPV6 (\
 	ICE_INSET_DMAC | \
 	ICE_INSET_IPV6_SRC | ICE_INSET_IPV6_DST | ICE_INSET_IPV6_TC | \
-	ICE_INSET_IPV6_HOP_LIMIT | ICE_INSET_IPV6_NEXT_HDR)
+	ICE_INSET_IPV6_HOP_LIMIT | ICE_INSET_IPV6_NEXT_HDR | \
+	ICE_INSET_IPV6_PKID)
 
 #define ICE_FDIR_INSET_ETH_IPV6_UDP (\
 	ICE_FDIR_INSET_ETH_IPV6 | \
@@ -56,7 +57,8 @@
 	ICE_INSET_SCTP_SRC_PORT | ICE_INSET_SCTP_DST_PORT)
 
 #define ICE_FDIR_INSET_IPV4 (\
-	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST)
+	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | \
+	ICE_INSET_IPV4_PKID)
 
 #define ICE_FDIR_INSET_IPV4_TCP (\
 	ICE_FDIR_INSET_IPV4 | \
@@ -95,6 +97,7 @@ static struct ice_pattern_match_item ice_fdir_pattern_list[] = {
 	{pattern_eth_ipv4_tcp,				ICE_FDIR_INSET_ETH_IPV4_TCP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv4_sctp,				ICE_FDIR_INSET_ETH_IPV4_SCTP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6,				ICE_FDIR_INSET_ETH_IPV6,	ICE_INSET_NONE,			ICE_INSET_NONE},
+	{pattern_eth_ipv6_frag_ext,			ICE_FDIR_INSET_ETH_IPV6,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6_udp,				ICE_FDIR_INSET_ETH_IPV6_UDP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6_tcp,				ICE_FDIR_INSET_ETH_IPV6_TCP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6_sctp,				ICE_FDIR_INSET_ETH_IPV6_SCTP,	ICE_INSET_NONE,			ICE_INSET_NONE},
@@ -882,11 +885,13 @@ ice_fdir_input_set_parse(uint64_t inset, enum ice_flow_field *field)
 		{ICE_INSET_IPV4_TOS, ICE_FLOW_FIELD_IDX_IPV4_DSCP},
 		{ICE_INSET_IPV4_TTL, ICE_FLOW_FIELD_IDX_IPV4_TTL},
 		{ICE_INSET_IPV4_PROTO, ICE_FLOW_FIELD_IDX_IPV4_PROT},
+		{ICE_INSET_IPV4_PKID, ICE_FLOW_FIELD_IDX_IPV4_ID},
 		{ICE_INSET_IPV6_SRC, ICE_FLOW_FIELD_IDX_IPV6_SA},
 		{ICE_INSET_IPV6_DST, ICE_FLOW_FIELD_IDX_IPV6_DA},
 		{ICE_INSET_IPV6_TC, ICE_FLOW_FIELD_IDX_IPV6_DSCP},
 		{ICE_INSET_IPV6_NEXT_HDR, ICE_FLOW_FIELD_IDX_IPV6_PROT},
 		{ICE_INSET_IPV6_HOP_LIMIT, ICE_FLOW_FIELD_IDX_IPV6_TTL},
+		{ICE_INSET_IPV6_PKID, ICE_FLOW_FIELD_IDX_IPV6_ID},
 		{ICE_INSET_TCP_SRC_PORT, ICE_FLOW_FIELD_IDX_TCP_SRC_PORT},
 		{ICE_INSET_TCP_DST_PORT, ICE_FLOW_FIELD_IDX_TCP_DST_PORT},
 		{ICE_INSET_UDP_SRC_PORT, ICE_FLOW_FIELD_IDX_UDP_SRC_PORT},
@@ -936,6 +941,10 @@ ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct ice_flow_seg_info *seg)
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4 |
 				  ICE_FLOW_SEG_HDR_IPV_OTHER);
 		break;
+	case ICE_FLTR_PTYPE_FRAG_IPV4:
+		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4 |
+				  ICE_FLOW_SEG_HDR_IPV_FRAG);
+		break;
 	case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP |
 				  ICE_FLOW_SEG_HDR_IPV6 |
@@ -955,6 +964,10 @@ ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct ice_flow_seg_info *seg)
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6 |
 				  ICE_FLOW_SEG_HDR_IPV_OTHER);
 		break;
+	case ICE_FLTR_PTYPE_FRAG_IPV6:
+		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6 |
+				  ICE_FLOW_SEG_HDR_IPV_FRAG);
+		break;
 	case ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN:
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP |
 				ICE_FLOW_SEG_HDR_IPV4 |
@@ -1599,8 +1612,10 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 	enum rte_flow_item_type l3 = RTE_FLOW_ITEM_TYPE_END;
 	enum ice_fdir_tunnel_type tunnel_type = ICE_FDIR_TUNNEL_TYPE_NONE;
 	const struct rte_flow_item_eth *eth_spec, *eth_mask;
-	const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_mask;
+	const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_last, *ipv4_mask;
 	const struct rte_flow_item_ipv6 *ipv6_spec, *ipv6_mask;
+	const struct rte_flow_item_ipv6_frag_ext *ipv6_frag_spec,
+					*ipv6_frag_last, *ipv6_frag_mask;
 	const struct rte_flow_item_tcp *tcp_spec, *tcp_mask;
 	const struct rte_flow_item_udp *udp_spec, *udp_mask;
 	const struct rte_flow_item_sctp *sctp_spec, *sctp_mask;
@@ -1639,13 +1654,14 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 	 * flow. input_set_i is used for inner part.
 	 */
 	for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
-		if (item->last) {
+		if (item->last && !(item_type == RTE_FLOW_ITEM_TYPE_IPV4 ||
+				    item_type ==
+				    RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT)) {
 			rte_flow_error_set(error, EINVAL,
-					   RTE_FLOW_ERROR_TYPE_ITEM,
-					   item,
+					   RTE_FLOW_ERROR_TYPE_ITEM, item,
 					   "Not support range");
-			return -rte_errno;
 		}
+
 		item_type = item->type;
 
 		input_set = (tunnel_type && !is_outer) ?
@@ -1696,6 +1712,7 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			flow_type = ICE_FLTR_PTYPE_NONF_IPV4_OTHER;
 			l3 = RTE_FLOW_ITEM_TYPE_IPV4;
 			ipv4_spec = item->spec;
+			ipv4_last = item->last;
 			ipv4_mask = item->mask;
 			p_v4 = (tunnel_type && is_outer) ?
 			       &filter->input.ip_outer.v4 :
@@ -1707,8 +1724,6 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			/* Check IPv4 mask and update input set */
 			if (ipv4_mask->hdr.version_ihl ||
 			    ipv4_mask->hdr.total_length ||
-			    ipv4_mask->hdr.packet_id ||
-			    ipv4_mask->hdr.fragment_offset ||
 			    ipv4_mask->hdr.hdr_checksum) {
 				rte_flow_error_set(error, EINVAL,
 						   RTE_FLOW_ERROR_TYPE_ITEM,
@@ -1717,6 +1732,21 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 				return -rte_errno;
 			}
 
+			if (ipv4_last &&
+			    (ipv4_last->hdr.version_ihl ||
+			     ipv4_last->hdr.type_of_service ||
+			     ipv4_last->hdr.time_to_live ||
+			     ipv4_last->hdr.total_length |
+			     ipv4_last->hdr.next_proto_id ||
+			     ipv4_last->hdr.hdr_checksum ||
+			     ipv4_last->hdr.src_addr ||
+			     ipv4_last->hdr.dst_addr)) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ITEM,
+						   item, "Invalid IPv4 last.");
+				return -rte_errno;
+			}
+
 			if (ipv4_mask->hdr.dst_addr == UINT32_MAX)
 				*input_set |= ICE_INSET_IPV4_DST;
 			if (ipv4_mask->hdr.src_addr == UINT32_MAX)
@@ -1733,6 +1763,32 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			p_v4->ttl = ipv4_spec->hdr.time_to_live;
 			p_v4->proto = ipv4_spec->hdr.next_proto_id;
 			p_v4->tos = ipv4_spec->hdr.type_of_service;
+
+			/* only support any packet id for fragment IPv4
+			 * any packet_id:
+			 * spec is 0, last is 0xffff, mask is 0xffff
+			 * fragment Ipv4:
+			 * spec is 0x2000, mask is 0xffff
+			 */
+			if (ipv4_last && ipv4_spec->hdr.packet_id == 0 &&
+			    ipv4_last->hdr.packet_id == UINT16_MAX &&
+			    ipv4_mask->hdr.packet_id == UINT16_MAX &&
+			    ipv4_spec->hdr.fragment_offset ==
+			    rte_cpu_to_be_16(RTE_IPV4_HDR_MF_FLAG) &&
+			    ipv4_mask->hdr.fragment_offset == UINT16_MAX) {
+				/* all IPv4 fragment packet has the same
+				 * ethertype, if the spec is for all valid
+				 * packet id, set ethertype into input set.
+				 */
+				*input_set |= ICE_INSET_ETHERTYPE;
+				input_set_o |= ICE_INSET_ETHERTYPE;
+			} else if (ipv4_mask->hdr.packet_id == UINT16_MAX) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ITEM,
+						   item, "Invalid IPv4 mask.");
+				return -rte_errno;
+			}
+
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV6:
 			flow_type = ICE_FLTR_PTYPE_NONF_IPV6_OTHER;
@@ -1778,6 +1834,43 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			p_v6->proto = ipv6_spec->hdr.proto;
 			p_v6->hlim = ipv6_spec->hdr.hop_limits;
 			break;
+		case RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT:
+			l3 = RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT;
+			flow_type = ICE_FLTR_PTYPE_FRAG_IPV6;
+			ipv6_frag_spec = item->spec;
+			ipv6_frag_last = item->last;
+			ipv6_frag_mask = item->mask;
+
+			if (!(ipv6_frag_spec && ipv6_frag_mask))
+				break;
+
+			/* only support any packet id for fragment IPv6
+			 * any packet_id:
+			 * spec is 0, last is 0xffffffff, mask is 0xffffffff
+			 * fragment Ipv6:
+			 * spec is 0x1, mask is 0xffff
+			 */
+			if (ipv6_frag_last && ipv6_frag_spec->hdr.id == 0 &&
+			    ipv6_frag_last->hdr.id == UINT32_MAX &&
+			    ipv6_frag_mask->hdr.id == UINT32_MAX &&
+			    ipv6_frag_spec->hdr.frag_data ==
+			    rte_cpu_to_be_16(1) &&
+			    ipv6_frag_mask->hdr.frag_data == UINT16_MAX) {
+				/* all IPv6 fragment packet has the same
+				 * ethertype, if the spec is for all valid
+				 * packet id, set ethertype into input set.
+				 */
+				*input_set |= ICE_INSET_ETHERTYPE;
+				input_set_o |= ICE_INSET_ETHERTYPE;
+			} else if (ipv6_frag_mask->hdr.id == UINT32_MAX) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ITEM,
+						   item, "Invalid IPv6 mask.");
+				return -rte_errno;
+			}
+
+			break;
+
 		case RTE_FLOW_ITEM_TYPE_TCP:
 			if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
 				flow_type = ICE_FLTR_PTYPE_NONF_IPV4_TCP;
@@ -2016,7 +2109,8 @@ ice_fdir_parse(struct ice_adapter *ad,
 	if (ret)
 		goto error;
 	input_set = filter->input_set_o | filter->input_set_i;
-	if (!input_set || filter->input_set_o & ~item->input_set_mask_o ||
+	if (!input_set || filter->input_set_o &
+	    ~(item->input_set_mask_o | ICE_INSET_ETHERTYPE) ||
 	    filter->input_set_i & ~item->input_set_mask_i) {
 		rte_flow_error_set(error, EINVAL,
 				   RTE_FLOW_ERROR_TYPE_ITEM_SPEC,
diff --git a/drivers/net/ice/ice_generic_flow.c b/drivers/net/ice/ice_generic_flow.c
index 2389bc6637..7a34a51600 100644
--- a/drivers/net/ice/ice_generic_flow.c
+++ b/drivers/net/ice/ice_generic_flow.c
@@ -2108,6 +2108,7 @@ static struct ice_ptype_match ice_ptype_map[] = {
 	{pattern_eth_ipv6_udp,				ICE_PTYPE_IPV6_UDP_PAY},
 	{pattern_eth_ipv6_tcp,				ICE_PTYPE_IPV6_TCP_PAY},
 	{pattern_eth_ipv6_sctp,				ICE_PTYPE_IPV6_SCTP_PAY},
+	{pattern_eth_ipv6_frag_ext,			ICE_PTYPE_IPV6FRAG_PAY},
 	{pattern_eth_ipv6_gtpu,				ICE_MAC_IPV6_GTPU},
 	{pattern_eth_ipv6_gtpu_eh,			ICE_MAC_IPV6_GTPU},
 	{pattern_eth_ipv6_gtpu_ipv4,			ICE_MAC_IPV6_GTPU_IPV4_PAY},
-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/3] net/ice/base: support IP fragment RSS and FDIR
  2021-04-11  6:06     ` [dpdk-dev] [PATCH v3 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
@ 2021-04-12  8:31       ` Xu, Ting
  2021-04-13  1:55         ` Guo, Jia
  0 siblings, 1 reply; 42+ messages in thread
From: Xu, Ting @ 2021-04-12  8:31 UTC (permalink / raw)
  To: Guo, Jia, Zhang, Qi Z, Yang, Qiming; +Cc: dev

Hi, Jeff,

Best Regards,
Xu Ting

> -----Original Message-----
> From: Guo, Jia <jia.guo@intel.com>
> Sent: Sunday, April 11, 2021 2:07 PM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>
> Cc: dev@dpdk.org; Xu, Ting <ting.xu@intel.com>; Guo, Jia <jia.guo@intel.com>
> Subject: [PATCH v3 1/3] net/ice/base: support IP fragment RSS and FDIR
> 
> Add support for IP fragment RSS hash and FDIR according to packet ID.
> Separate IP fragment and IP other packet types.
> 
> Signed-off-by: Ting Xu <ting.xu@intel.com>
> Signed-off-by: Jeff Guo <jia.guo@intel.com>
> ---
>  drivers/net/ice/base/ice_fdir.c | 50 +++++++++++++++++++++++++++++++--
> drivers/net/ice/base/ice_fdir.h | 22 ++++++++++++---
> drivers/net/ice/base/ice_flow.c | 50 ++++++++++++++++++++++++++++++++-
> drivers/net/ice/base/ice_flow.h |  5 +++-  drivers/net/ice/base/ice_type.h |  1
> +
>  5 files changed, 120 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/ice/base/ice_fdir.c b/drivers/net/ice/base/ice_fdir.c
> index 2b39c13127..0eb7cdd729 100644
> --- a/drivers/net/ice/base/ice_fdir.c
> +++ b/drivers/net/ice/base/ice_fdir.c
> @@ -518,6 +518,24 @@ 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 +734,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_pkt), ice_fdir_ipv4_frag_pkt,
> +		sizeof(ice_fdir_ipv4_pkt), ice_fdir_ipv4_frag_pkt,
> +	},

Should be the same, "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),

Skip...

> diff --git a/drivers/net/ice/base/ice_type.h b/drivers/net/ice/base/ice_type.h
> index a6599363f9..5abe9dc9ea 100644
> --- a/drivers/net/ice/base/ice_type.h
> +++ b/drivers/net/ice/base/ice_type.h
> @@ -349,6 +349,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,
> --
> 2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/3] net/ice/base: support IP fragment RSS and FDIR
  2021-04-12  8:31       ` Xu, Ting
@ 2021-04-13  1:55         ` Guo, Jia
  0 siblings, 0 replies; 42+ messages in thread
From: Guo, Jia @ 2021-04-13  1:55 UTC (permalink / raw)
  To: Xu, Ting, Zhang, Qi Z, Yang, Qiming; +Cc: dev

Hi, Ting

> -----Original Message-----
> From: Xu, Ting <ting.xu@intel.com>
> Sent: Monday, April 12, 2021 4:31 PM
> To: Guo, Jia <jia.guo@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>; Yang,
> Qiming <qiming.yang@intel.com>
> Cc: dev@dpdk.org
> Subject: RE: [PATCH v3 1/3] net/ice/base: support IP fragment RSS and FDIR
> 
> Hi, Jeff,
> 
> Best Regards,
> Xu Ting
> 
> > -----Original Message-----
> > From: Guo, Jia <jia.guo@intel.com>
> > Sent: Sunday, April 11, 2021 2:07 PM
> > To: Zhang, Qi Z <qi.z.zhang@intel.com>; Yang, Qiming
> > <qiming.yang@intel.com>
> > Cc: dev@dpdk.org; Xu, Ting <ting.xu@intel.com>; Guo, Jia
> > <jia.guo@intel.com>
> > Subject: [PATCH v3 1/3] net/ice/base: support IP fragment RSS and FDIR
> >
> > Add support for IP fragment RSS hash and FDIR according to packet ID.
> > Separate IP fragment and IP other packet types.
> >
> > Signed-off-by: Ting Xu <ting.xu@intel.com>
> > Signed-off-by: Jeff Guo <jia.guo@intel.com>
> > ---
> >  drivers/net/ice/base/ice_fdir.c | 50
> > +++++++++++++++++++++++++++++++-- drivers/net/ice/base/ice_fdir.h
> | 22
> > ++++++++++++--- drivers/net/ice/base/ice_flow.c | 50
> > ++++++++++++++++++++++++++++++++-
> drivers/net/ice/base/ice_flow.h |  5
> > +++-  drivers/net/ice/base/ice_type.h |  1
> > +
> >  5 files changed, 120 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/net/ice/base/ice_fdir.c
> > b/drivers/net/ice/base/ice_fdir.c index 2b39c13127..0eb7cdd729 100644
> > --- a/drivers/net/ice/base/ice_fdir.c
> > +++ b/drivers/net/ice/base/ice_fdir.c
> > @@ -518,6 +518,24 @@ 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 +734,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_pkt), ice_fdir_ipv4_frag_pkt,
> > +sizeof(ice_fdir_ipv4_pkt), ice_fdir_ipv4_frag_pkt, },
> 
> Should be the same, "ice_fdir_ipv4_frag_pkt"
> 

As you said that is, will correct it.

> > +{
> > +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),
> 
> Skip...
> 
> > diff --git a/drivers/net/ice/base/ice_type.h
> > b/drivers/net/ice/base/ice_type.h index a6599363f9..5abe9dc9ea 100644
> > --- a/drivers/net/ice/base/ice_type.h
> > +++ b/drivers/net/ice/base/ice_type.h
> > @@ -349,6 +349,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,
> > --
> > 2.20.1
> 


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v4 0/3] support flow for IP fragment in ICE
  2021-03-24 13:54 ` [dpdk-dev] [PATCH v2 0/3] support flow for IP fragment in ICE Jeff Guo
                     ` (4 preceding siblings ...)
  2021-04-11  6:57   ` [dpdk-dev] [PATCH v3 0/3] support flow for IP fragment in ICE Jeff Guo
@ 2021-04-13  7:58   ` Jeff Guo
  2021-04-13  7:58     ` [dpdk-dev] [PATCH v4 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
                       ` (2 more replies)
  2021-04-13  8:48   ` [dpdk-dev] [PATCH v4 0/3] support flow for IP fragment in ICE Jeff Guo
                     ` (2 subsequent siblings)
  8 siblings, 3 replies; 42+ messages in thread
From: Jeff Guo @ 2021-04-13  7:58 UTC (permalink / raw)
  To: qi.z.zhang, qiming.yang; +Cc: dev, ting.xu, jia.guo

Support RSS hash and FDIR for IP fragment packets in ICE PMD.

v4:
correct typo when define fragment
v3:
rebase code and fix some parsing issues.
v2:
add some input check

Jeff Guo (3):
  net/ice/base: support IP fragment RSS and FDIR
  net/ice: support RSS hash for IP fragment
  net/ice: support FDIR for IP fragment packet

 drivers/net/ice/base/ice_fdir.c    |  50 ++++++++++++-
 drivers/net/ice/base/ice_fdir.h    |  22 +++++-
 drivers/net/ice/base/ice_flow.c    |  50 ++++++++++++-
 drivers/net/ice/base/ice_flow.h    |   5 +-
 drivers/net/ice/base/ice_type.h    |   1 +
 drivers/net/ice/ice_fdir_filter.c  | 116 ++++++++++++++++++++++++++---
 drivers/net/ice/ice_generic_flow.c |  22 ++++++
 drivers/net/ice/ice_generic_flow.h |   6 ++
 drivers/net/ice/ice_hash.c         |  48 ++++++++++--
 9 files changed, 293 insertions(+), 27 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v4 1/3] net/ice/base: support IP fragment RSS and FDIR
  2021-04-13  7:58   ` [dpdk-dev] [PATCH v4 0/3] support flow for IP fragment in ICE Jeff Guo
@ 2021-04-13  7:58     ` Jeff Guo
  2021-04-13  7:58     ` [dpdk-dev] [PATCH v4 2/3] net/ice: support RSS hash for IP fragment Jeff Guo
  2021-04-13  7:58     ` [dpdk-dev] [PATCH v4 3/3] net/ice: support FDIR for IP fragment packet Jeff Guo
  2 siblings, 0 replies; 42+ messages in thread
From: Jeff Guo @ 2021-04-13  7:58 UTC (permalink / raw)
  To: qi.z.zhang, qiming.yang; +Cc: dev, ting.xu, jia.guo

Add support for IP fragment RSS hash and FDIR according to packet ID.
Separate IP fragment and IP other packet types.

Signed-off-by: Ting Xu <ting.xu@intel.com>
Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
 drivers/net/ice/base/ice_fdir.c | 50 +++++++++++++++++++++++++++++++--
 drivers/net/ice/base/ice_fdir.h | 22 ++++++++++++---
 drivers/net/ice/base/ice_flow.c | 50 ++++++++++++++++++++++++++++++++-
 drivers/net/ice/base/ice_flow.h |  5 +++-
 drivers/net/ice/base/ice_type.h |  1 +
 5 files changed, 120 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ice/base/ice_fdir.c b/drivers/net/ice/base/ice_fdir.c
index 2b39c13127..0eb7cdd729 100644
--- a/drivers/net/ice/base/ice_fdir.c
+++ b/drivers/net/ice/base/ice_fdir.c
@@ -518,6 +518,24 @@ 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 +734,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_pkt), ice_fdir_ipv4_frag_pkt,
+		sizeof(ice_fdir_ipv4_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),
@@ -1505,7 +1533,7 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
 		ice_pkt_insert_u8(loc, ICE_IPV4_TTL_OFFSET, input->ip.v4.ttl);
 		ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
 		if (frag)
-			loc[20] = ICE_FDIR_IPV4_PKT_FLAG_DF;
+			loc[20] = ICE_FDIR_IPV4_PKT_FLAG_MF;
 		break;
 	case ICE_FLTR_PTYPE_NONF_IPV4_UDP:
 		ice_pkt_insert_mac_addr(pkt, input->ext_data_outer.dst_mac);
@@ -1808,6 +1836,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 +1883,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;
diff --git a/drivers/net/ice/base/ice_fdir.h b/drivers/net/ice/base/ice_fdir.h
index 6573f96bc1..2acc1d6f1b 100644
--- a/drivers/net/ice/base/ice_fdir.h
+++ b/drivers/net/ice/base/ice_fdir.h
@@ -43,9 +43,11 @@
 #define ICE_MAC_ETHTYPE_OFFSET		12
 #define ICE_IPV4_TOS_OFFSET		15
 #define ICE_IPV4_TTL_OFFSET		22
+#define ICE_IPV4_ID_OFFSET		18
 #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
@@ -83,12 +85,22 @@
 
 #define ICE_FDIR_MAX_FLTRS		16384
 
-/* IP v4 has 2 flag bits that enable fragment processing: DF and MF. DF
+/* IPv4 has 2 flag bits that enable fragment processing: DF and MF. DF
  * requests that the packet not be fragmented. MF indicates that a packet has
- * been fragmented.
+ * been fragmented, except that for the last fragment has a non-zero
+ * Fragment Offset field with zero MF.
  */
-#define ICE_FDIR_IPV4_PKT_FLAG_DF		0x20
-#define ICE_FDIR_IPV4_PKT_FLAG_MF		0x40
+#define ICE_FDIR_IPV4_PKT_FLAG_MF		0x20
+#define ICE_FDIR_IPV4_PKT_FLAG_MF_SHIFT	8
+#ifndef NO_UNUSED_PACKAGE_CODE
+#define ICE_FDIR_IPV4_PKT_FLAG_DF		0x40
+#endif /* NO_UNUSED_PACKAGE_CODE */
+
+/* For IPv6 fragmented packets, all fragments except the last have
+ * the MF flag set.
+ */
+#define ICE_FDIR_IPV6_PKT_FLAG_MF		0x100
+#define ICE_FDIR_IPV6_PKT_FLAG_MF_SHIFT	8
 
 enum ice_fltr_prgm_desc_dest {
 	ICE_FLTR_PRGM_DESC_DEST_DROP_PKT,
@@ -150,6 +162,7 @@ struct ice_fdir_v4 {
 	u8 ip_ver;
 	u8 proto;
 	u8 ttl;
+	__be16 packet_id;
 };
 
 #define ICE_IPV6_ADDR_LEN_AS_U32		4
@@ -164,6 +177,7 @@ struct ice_fdir_v6 {
 	u8 tc;
 	u8 proto;
 	u8 hlim;
+	__be32 packet_id;
 };
 
 struct ice_fdir_udp_gtp {
diff --git a/drivers/net/ice/base/ice_flow.c b/drivers/net/ice/base/ice_flow.c
index c12ddfa247..9dea881914 100644
--- a/drivers/net/ice/base/ice_flow.c
+++ b/drivers/net/ice/base/ice_flow.c
@@ -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),
@@ -725,6 +733,27 @@ static const u32 ice_ptypes_udp_ecpri_tp0[] = {
 	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;
@@ -899,6 +928,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 :
@@ -1177,6 +1216,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:
@@ -1187,6 +1229,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:
@@ -3341,13 +3386,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);
diff --git a/drivers/net/ice/base/ice_flow.h b/drivers/net/ice/base/ice_flow.h
index af15ecb0ff..d905b95b1c 100644
--- a/drivers/net/ice/base/ice_flow.h
+++ b/drivers/net/ice/base/ice_flow.h
@@ -186,8 +186,9 @@ enum ice_flow_seg_hdr {
 	ICE_FLOW_SEG_HDR_ECPRI_TP0	= 0x04000000,
 	ICE_FLOW_SEG_HDR_UDP_ECPRI_TP0	= 0x08000000,
 	/* 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_FRAG	= 0x10000000,
 	ICE_FLOW_SEG_HDR_IPV_OTHER	= 0x20000000,
 };
 
@@ -225,6 +226,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,
diff --git a/drivers/net/ice/base/ice_type.h b/drivers/net/ice/base/ice_type.h
index a6599363f9..5abe9dc9ea 100644
--- a/drivers/net/ice/base/ice_type.h
+++ b/drivers/net/ice/base/ice_type.h
@@ -349,6 +349,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,
-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v4 2/3] net/ice: support RSS hash for IP fragment
  2021-04-13  7:58   ` [dpdk-dev] [PATCH v4 0/3] support flow for IP fragment in ICE Jeff Guo
  2021-04-13  7:58     ` [dpdk-dev] [PATCH v4 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
@ 2021-04-13  7:58     ` Jeff Guo
  2021-04-13  7:58     ` [dpdk-dev] [PATCH v4 3/3] net/ice: support FDIR for IP fragment packet Jeff Guo
  2 siblings, 0 replies; 42+ messages in thread
From: Jeff Guo @ 2021-04-13  7:58 UTC (permalink / raw)
  To: qi.z.zhang, qiming.yang; +Cc: dev, ting.xu, jia.guo

New pattern and RSS hash flow parsing are added to handle fragmented
IPv4/IPv6  packet.

Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
 drivers/net/ice/ice_generic_flow.c | 21 +++++++++++++
 drivers/net/ice/ice_generic_flow.h |  6 ++++
 drivers/net/ice/ice_hash.c         | 48 +++++++++++++++++++++++++-----
 3 files changed, 67 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ice/ice_generic_flow.c b/drivers/net/ice/ice_generic_flow.c
index 8704812622..2389bc6637 100644
--- a/drivers/net/ice/ice_generic_flow.c
+++ b/drivers/net/ice/ice_generic_flow.c
@@ -212,6 +212,27 @@ enum rte_flow_item_type pattern_eth_qinq_ipv6[] = {
 	RTE_FLOW_ITEM_TYPE_IPV6,
 	RTE_FLOW_ITEM_TYPE_END,
 };
+enum rte_flow_item_type pattern_eth_ipv6_frag_ext[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+enum rte_flow_item_type pattern_eth_vlan_ipv6_frag_ext[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_VLAN,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+enum rte_flow_item_type pattern_eth_qinq_ipv6_frag_ext[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_VLAN,
+	RTE_FLOW_ITEM_TYPE_VLAN,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+	RTE_FLOW_ITEM_TYPE_END,
+};
 enum rte_flow_item_type pattern_eth_ipv6_udp[] = {
 	RTE_FLOW_ITEM_TYPE_ETH,
 	RTE_FLOW_ITEM_TYPE_IPV6,
diff --git a/drivers/net/ice/ice_generic_flow.h b/drivers/net/ice/ice_generic_flow.h
index 9f422e5925..2afe719264 100644
--- a/drivers/net/ice/ice_generic_flow.h
+++ b/drivers/net/ice/ice_generic_flow.h
@@ -52,6 +52,7 @@
 #define ICE_L2TPV3OIP_SESSION_ID	BIT_ULL(43)
 #define ICE_PFCP_SEID			BIT_ULL(42)
 #define ICE_PFCP_S_FIELD		BIT_ULL(41)
+#define ICE_IP_PK_ID		    BIT_ULL(40)
 
 /* input set */
 
@@ -69,11 +70,13 @@
 #define ICE_INSET_IPV4_TOS		(ICE_PROT_IPV4 | ICE_IP_TOS)
 #define ICE_INSET_IPV4_PROTO		(ICE_PROT_IPV4 | ICE_IP_PROTO)
 #define ICE_INSET_IPV4_TTL		(ICE_PROT_IPV4 | ICE_IP_TTL)
+#define ICE_INSET_IPV4_PKID		(ICE_PROT_IPV4 | ICE_IP_PK_ID)
 #define ICE_INSET_IPV6_SRC		(ICE_PROT_IPV6 | ICE_IP_SRC)
 #define ICE_INSET_IPV6_DST		(ICE_PROT_IPV6 | ICE_IP_DST)
 #define ICE_INSET_IPV6_NEXT_HDR		(ICE_PROT_IPV6 | ICE_IP_PROTO)
 #define ICE_INSET_IPV6_HOP_LIMIT	(ICE_PROT_IPV6 | ICE_IP_TTL)
 #define ICE_INSET_IPV6_TC		(ICE_PROT_IPV6 | ICE_IP_TOS)
+#define ICE_INSET_IPV6_PKID		(ICE_PROT_IPV6 | ICE_IP_PK_ID)
 
 #define ICE_INSET_TCP_SRC_PORT		(ICE_PROT_TCP | ICE_SPORT)
 #define ICE_INSET_TCP_DST_PORT		(ICE_PROT_TCP | ICE_DPORT)
@@ -202,6 +205,9 @@ extern enum rte_flow_item_type pattern_eth_qinq_ipv4_icmp[];
 extern enum rte_flow_item_type pattern_eth_ipv6[];
 extern enum rte_flow_item_type pattern_eth_vlan_ipv6[];
 extern enum rte_flow_item_type pattern_eth_qinq_ipv6[];
+extern enum rte_flow_item_type pattern_eth_ipv6_frag_ext[];
+extern enum rte_flow_item_type pattern_eth_vlan_ipv6_frag_ext[];
+extern enum rte_flow_item_type pattern_eth_qinq_ipv6_frag_ext[];
 extern enum rte_flow_item_type pattern_eth_ipv6_udp[];
 extern enum rte_flow_item_type pattern_eth_vlan_ipv6_udp[];
 extern enum rte_flow_item_type pattern_eth_qinq_ipv6_udp[];
diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c
index 7d7e7052da..9df20df550 100644
--- a/drivers/net/ice/ice_hash.c
+++ b/drivers/net/ice/ice_hash.c
@@ -47,8 +47,10 @@
 				 ETH_RSS_NONFRAG_IPV6_TCP	| \
 				 ETH_RSS_NONFRAG_IPV6_SCTP)
 
-#define VALID_RSS_IPV4		(ETH_RSS_IPV4 | VALID_RSS_IPV4_L4)
-#define VALID_RSS_IPV6		(ETH_RSS_IPV6 | VALID_RSS_IPV6_L4)
+#define VALID_RSS_IPV4		(ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 | \
+				 VALID_RSS_IPV4_L4)
+#define VALID_RSS_IPV6		(ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 | \
+				 VALID_RSS_IPV6_L4)
 #define VALID_RSS_L3		(VALID_RSS_IPV4 | VALID_RSS_IPV6)
 #define VALID_RSS_L4		(VALID_RSS_IPV4_L4 | VALID_RSS_IPV6_L4)
 
@@ -108,6 +110,7 @@ ice_hash_parse_pattern_action(struct ice_adapter *ad,
 /* Rss configuration template */
 struct ice_rss_hash_cfg ipv4_tmplt = {
 	ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV4 |
+	ICE_FLOW_SEG_HDR_IPV_FRAG |
 	ICE_FLOW_SEG_HDR_IPV_OTHER,
 	ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_IPV4,
 	ICE_RSS_OUTER_HEADERS,
@@ -146,6 +149,15 @@ struct ice_rss_hash_cfg ipv6_tmplt = {
 	0
 };
 
+struct ice_rss_hash_cfg ipv6_frag_tmplt = {
+	ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV6 |
+	ICE_FLOW_SEG_HDR_IPV_FRAG |
+	ICE_FLOW_SEG_HDR_IPV_OTHER,
+	ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_IPV6,
+	ICE_RSS_ANY_HEADERS,
+	0
+};
+
 struct ice_rss_hash_cfg ipv6_udp_tmplt = {
 	ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV6 |
 	ICE_FLOW_SEG_HDR_IPV_OTHER | ICE_FLOW_SEG_HDR_UDP,
@@ -198,6 +210,7 @@ struct ice_rss_hash_cfg outer_ipv6_inner_ipv4_tmplt = {
 	ICE_RSS_INNER_HEADERS_W_OUTER_IPV6,
 	0
 };
+
 struct ice_rss_hash_cfg outer_ipv6_inner_ipv4_udp_tmplt = {
 	ICE_FLOW_SEG_HDR_IPV4 | ICE_FLOW_SEG_HDR_IPV_OTHER |
 	ICE_FLOW_SEG_HDR_UDP,
@@ -220,6 +233,7 @@ struct ice_rss_hash_cfg outer_ipv4_inner_ipv6_tmplt = {
 	ICE_RSS_INNER_HEADERS_W_OUTER_IPV4,
 	0
 };
+
 struct ice_rss_hash_cfg outer_ipv4_inner_ipv6_udp_tmplt = {
 	ICE_FLOW_SEG_HDR_IPV6 | ICE_FLOW_SEG_HDR_IPV_OTHER |
 	ICE_FLOW_SEG_HDR_UDP,
@@ -353,7 +367,8 @@ struct ice_rss_hash_cfg empty_tmplt = {
 };
 
 /* IPv4 */
-#define ICE_RSS_TYPE_ETH_IPV4		(ETH_RSS_ETH | ETH_RSS_IPV4)
+#define ICE_RSS_TYPE_ETH_IPV4		(ETH_RSS_ETH | ETH_RSS_IPV4 | \
+					 ETH_RSS_FRAG_IPV4)
 #define ICE_RSS_TYPE_ETH_IPV4_UDP	(ICE_RSS_TYPE_ETH_IPV4 | \
 					 ETH_RSS_NONFRAG_IPV4_UDP)
 #define ICE_RSS_TYPE_ETH_IPV4_TCP	(ICE_RSS_TYPE_ETH_IPV4 | \
@@ -370,6 +385,8 @@ struct ice_rss_hash_cfg empty_tmplt = {
 
 /* IPv6 */
 #define ICE_RSS_TYPE_ETH_IPV6		(ETH_RSS_ETH | ETH_RSS_IPV6)
+#define ICE_RSS_TYPE_ETH_IPV6_FRAG	(ETH_RSS_ETH | ETH_RSS_IPV6 | \
+					 ETH_RSS_FRAG_IPV6)
 #define ICE_RSS_TYPE_ETH_IPV6_UDP	(ICE_RSS_TYPE_ETH_IPV6 | \
 					 ETH_RSS_NONFRAG_IPV6_UDP)
 #define ICE_RSS_TYPE_ETH_IPV6_TCP	(ICE_RSS_TYPE_ETH_IPV6 | \
@@ -386,7 +403,8 @@ struct ice_rss_hash_cfg empty_tmplt = {
 
 /* VLAN IPV4 */
 #define ICE_RSS_TYPE_VLAN_IPV4		(ICE_RSS_TYPE_IPV4 | \
-					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
+					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN | \
+					 ETH_RSS_FRAG_IPV4)
 #define ICE_RSS_TYPE_VLAN_IPV4_UDP	(ICE_RSS_TYPE_IPV4_UDP | \
 					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
 #define ICE_RSS_TYPE_VLAN_IPV4_TCP	(ICE_RSS_TYPE_IPV4_TCP | \
@@ -396,6 +414,9 @@ struct ice_rss_hash_cfg empty_tmplt = {
 /* VLAN IPv6 */
 #define ICE_RSS_TYPE_VLAN_IPV6		(ICE_RSS_TYPE_IPV6 | \
 					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
+#define ICE_RSS_TYPE_VLAN_IPV6_FRAG	(ICE_RSS_TYPE_IPV6 | \
+					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN | \
+					 ETH_RSS_FRAG_IPV6)
 #define ICE_RSS_TYPE_VLAN_IPV6_UDP	(ICE_RSS_TYPE_IPV6_UDP | \
 					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
 #define ICE_RSS_TYPE_VLAN_IPV6_TCP	(ICE_RSS_TYPE_IPV6_TCP | \
@@ -485,10 +506,12 @@ static struct ice_pattern_match_item ice_hash_pattern_list[] = {
 	{pattern_eth_ipv4_pfcp,			ICE_RSS_TYPE_IPV4_PFCP,		ICE_INSET_NONE,	&eth_ipv4_pfcp_tmplt},
 	/* IPV6 */
 	{pattern_eth_ipv6,			ICE_RSS_TYPE_ETH_IPV6,		ICE_INSET_NONE,	&ipv6_tmplt},
+	{pattern_eth_ipv6_frag_ext,		ICE_RSS_TYPE_ETH_IPV6_FRAG,	ICE_INSET_NONE,	&ipv6_frag_tmplt},
 	{pattern_eth_ipv6_udp,			ICE_RSS_TYPE_ETH_IPV6_UDP,	ICE_INSET_NONE,	&ipv6_udp_tmplt},
 	{pattern_eth_ipv6_tcp,			ICE_RSS_TYPE_ETH_IPV6_TCP,	ICE_INSET_NONE,	&ipv6_tcp_tmplt},
 	{pattern_eth_ipv6_sctp,			ICE_RSS_TYPE_ETH_IPV6_SCTP,	ICE_INSET_NONE,	&ipv6_sctp_tmplt},
 	{pattern_eth_vlan_ipv6,			ICE_RSS_TYPE_VLAN_IPV6,		ICE_INSET_NONE,	&ipv6_tmplt},
+	{pattern_eth_vlan_ipv6_frag_ext,	ICE_RSS_TYPE_VLAN_IPV6_FRAG,	ICE_INSET_NONE, &ipv6_frag_tmplt},
 	{pattern_eth_vlan_ipv6_udp,		ICE_RSS_TYPE_VLAN_IPV6_UDP,	ICE_INSET_NONE,	&ipv6_udp_tmplt},
 	{pattern_eth_vlan_ipv6_tcp,		ICE_RSS_TYPE_VLAN_IPV6_TCP,	ICE_INSET_NONE,	&ipv6_tcp_tmplt},
 	{pattern_eth_vlan_ipv6_sctp,		ICE_RSS_TYPE_VLAN_IPV6_SCTP,	ICE_INSET_NONE,	&ipv6_sctp_tmplt},
@@ -629,11 +652,14 @@ ice_refine_hash_cfg_l234(struct ice_rss_hash_cfg *hash_cfg,
 
 	if (*addl_hdrs & ICE_FLOW_SEG_HDR_IPV4) {
 		if (rss_type &
-		   (ETH_RSS_IPV4 |
+		   (ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 |
 		    ETH_RSS_NONFRAG_IPV4_UDP |
 		    ETH_RSS_NONFRAG_IPV4_TCP |
 		    ETH_RSS_NONFRAG_IPV4_SCTP)) {
-			if (rss_type & ETH_RSS_L3_SRC_ONLY)
+			if (rss_type & ETH_RSS_FRAG_IPV4)
+				*hash_flds &=
+					~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_ID));
+			else if (rss_type & ETH_RSS_L3_SRC_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA));
 			else if (rss_type & ETH_RSS_L3_DST_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA));
@@ -648,11 +674,14 @@ ice_refine_hash_cfg_l234(struct ice_rss_hash_cfg *hash_cfg,
 
 	if (*addl_hdrs & ICE_FLOW_SEG_HDR_IPV6) {
 		if (rss_type &
-		   (ETH_RSS_IPV6 |
+		   (ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 |
 		    ETH_RSS_NONFRAG_IPV6_UDP |
 		    ETH_RSS_NONFRAG_IPV6_TCP |
 		    ETH_RSS_NONFRAG_IPV6_SCTP)) {
-			if (rss_type & ETH_RSS_L3_SRC_ONLY)
+			if (rss_type & ETH_RSS_FRAG_IPV6)
+				*hash_flds &=
+					~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_ID));
+			else if (rss_type & ETH_RSS_L3_SRC_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA));
 			else if (rss_type & ETH_RSS_L3_DST_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA));
@@ -827,6 +856,8 @@ static void ice_refine_hash_cfg(struct ice_rss_hash_cfg *hash_cfg,
 static uint64_t invalid_rss_comb[] = {
 	ETH_RSS_IPV4 | ETH_RSS_NONFRAG_IPV4_UDP,
 	ETH_RSS_IPV6 | ETH_RSS_NONFRAG_IPV6_UDP,
+	ETH_RSS_FRAG_IPV4 | ETH_RSS_NONFRAG_IPV4_UDP,
+	ETH_RSS_FRAG_IPV6 | ETH_RSS_NONFRAG_IPV6_UDP,
 	RTE_ETH_RSS_L3_PRE40 |
 	RTE_ETH_RSS_L3_PRE56 |
 	RTE_ETH_RSS_L3_PRE96
@@ -865,6 +896,7 @@ ice_any_invalid_rss_type(enum rte_eth_hash_function rss_func,
 
 		if (!(rss_type &
 		   (ETH_RSS_IPV4 | ETH_RSS_IPV6 |
+		    ETH_RSS_FRAG_IPV4 | ETH_RSS_FRAG_IPV6 |
 		    ETH_RSS_NONFRAG_IPV4_UDP | ETH_RSS_NONFRAG_IPV6_UDP |
 		    ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_NONFRAG_IPV6_TCP |
 		    ETH_RSS_NONFRAG_IPV4_SCTP | ETH_RSS_NONFRAG_IPV6_SCTP)))
-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v4 3/3] net/ice: support FDIR for IP fragment packet
  2021-04-13  7:58   ` [dpdk-dev] [PATCH v4 0/3] support flow for IP fragment in ICE Jeff Guo
  2021-04-13  7:58     ` [dpdk-dev] [PATCH v4 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
  2021-04-13  7:58     ` [dpdk-dev] [PATCH v4 2/3] net/ice: support RSS hash for IP fragment Jeff Guo
@ 2021-04-13  7:58     ` Jeff Guo
  2 siblings, 0 replies; 42+ messages in thread
From: Jeff Guo @ 2021-04-13  7:58 UTC (permalink / raw)
  To: qi.z.zhang, qiming.yang; +Cc: dev, ting.xu, jia.guo

New FDIR parsing are added to handle the fragmented IPv4/IPv6 packet.

Signed-off-by: Jeff Guo <jia.guo@intel.com>
Signed-off-by: Ting Xu <ting.xu@intel.com>
---
 drivers/net/ice/base/ice_fdir.c    |   4 +-
 drivers/net/ice/ice_fdir_filter.c  | 116 ++++++++++++++++++++++++++---
 drivers/net/ice/ice_generic_flow.c |   1 +
 3 files changed, 108 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ice/base/ice_fdir.c b/drivers/net/ice/base/ice_fdir.c
index 0eb7cdd729..a9a14b7445 100644
--- a/drivers/net/ice/base/ice_fdir.c
+++ b/drivers/net/ice/base/ice_fdir.c
@@ -736,8 +736,8 @@ static const struct ice_fdir_base_pkt ice_fdir_pkt[] = {
 	},
 	{
 		ICE_FLTR_PTYPE_FRAG_IPV4,
-		sizeof(ice_fdir_ipv4_pkt), ice_fdir_ipv4_frag_pkt,
-		sizeof(ice_fdir_ipv4_pkt), ice_fdir_ipv4_frag_pkt,
+		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,
diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
index 92e18d59cc..8158f75f05 100644
--- a/drivers/net/ice/ice_fdir_filter.c
+++ b/drivers/net/ice/ice_fdir_filter.c
@@ -24,7 +24,7 @@
 #define ICE_FDIR_INSET_ETH_IPV4 (\
 	ICE_FDIR_INSET_ETH | \
 	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | ICE_INSET_IPV4_TOS | \
-	ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO)
+	ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO | ICE_INSET_IPV4_PKID)
 
 #define ICE_FDIR_INSET_ETH_IPV4_UDP (\
 	ICE_FDIR_INSET_ETH_IPV4 | \
@@ -41,7 +41,8 @@
 #define ICE_FDIR_INSET_ETH_IPV6 (\
 	ICE_INSET_DMAC | \
 	ICE_INSET_IPV6_SRC | ICE_INSET_IPV6_DST | ICE_INSET_IPV6_TC | \
-	ICE_INSET_IPV6_HOP_LIMIT | ICE_INSET_IPV6_NEXT_HDR)
+	ICE_INSET_IPV6_HOP_LIMIT | ICE_INSET_IPV6_NEXT_HDR | \
+	ICE_INSET_IPV6_PKID)
 
 #define ICE_FDIR_INSET_ETH_IPV6_UDP (\
 	ICE_FDIR_INSET_ETH_IPV6 | \
@@ -56,7 +57,8 @@
 	ICE_INSET_SCTP_SRC_PORT | ICE_INSET_SCTP_DST_PORT)
 
 #define ICE_FDIR_INSET_IPV4 (\
-	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST)
+	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | \
+	ICE_INSET_IPV4_PKID)
 
 #define ICE_FDIR_INSET_IPV4_TCP (\
 	ICE_FDIR_INSET_IPV4 | \
@@ -95,6 +97,7 @@ static struct ice_pattern_match_item ice_fdir_pattern_list[] = {
 	{pattern_eth_ipv4_tcp,				ICE_FDIR_INSET_ETH_IPV4_TCP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv4_sctp,				ICE_FDIR_INSET_ETH_IPV4_SCTP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6,				ICE_FDIR_INSET_ETH_IPV6,	ICE_INSET_NONE,			ICE_INSET_NONE},
+	{pattern_eth_ipv6_frag_ext,			ICE_FDIR_INSET_ETH_IPV6,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6_udp,				ICE_FDIR_INSET_ETH_IPV6_UDP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6_tcp,				ICE_FDIR_INSET_ETH_IPV6_TCP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6_sctp,				ICE_FDIR_INSET_ETH_IPV6_SCTP,	ICE_INSET_NONE,			ICE_INSET_NONE},
@@ -882,11 +885,13 @@ ice_fdir_input_set_parse(uint64_t inset, enum ice_flow_field *field)
 		{ICE_INSET_IPV4_TOS, ICE_FLOW_FIELD_IDX_IPV4_DSCP},
 		{ICE_INSET_IPV4_TTL, ICE_FLOW_FIELD_IDX_IPV4_TTL},
 		{ICE_INSET_IPV4_PROTO, ICE_FLOW_FIELD_IDX_IPV4_PROT},
+		{ICE_INSET_IPV4_PKID, ICE_FLOW_FIELD_IDX_IPV4_ID},
 		{ICE_INSET_IPV6_SRC, ICE_FLOW_FIELD_IDX_IPV6_SA},
 		{ICE_INSET_IPV6_DST, ICE_FLOW_FIELD_IDX_IPV6_DA},
 		{ICE_INSET_IPV6_TC, ICE_FLOW_FIELD_IDX_IPV6_DSCP},
 		{ICE_INSET_IPV6_NEXT_HDR, ICE_FLOW_FIELD_IDX_IPV6_PROT},
 		{ICE_INSET_IPV6_HOP_LIMIT, ICE_FLOW_FIELD_IDX_IPV6_TTL},
+		{ICE_INSET_IPV6_PKID, ICE_FLOW_FIELD_IDX_IPV6_ID},
 		{ICE_INSET_TCP_SRC_PORT, ICE_FLOW_FIELD_IDX_TCP_SRC_PORT},
 		{ICE_INSET_TCP_DST_PORT, ICE_FLOW_FIELD_IDX_TCP_DST_PORT},
 		{ICE_INSET_UDP_SRC_PORT, ICE_FLOW_FIELD_IDX_UDP_SRC_PORT},
@@ -936,6 +941,10 @@ ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct ice_flow_seg_info *seg)
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4 |
 				  ICE_FLOW_SEG_HDR_IPV_OTHER);
 		break;
+	case ICE_FLTR_PTYPE_FRAG_IPV4:
+		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4 |
+				  ICE_FLOW_SEG_HDR_IPV_FRAG);
+		break;
 	case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP |
 				  ICE_FLOW_SEG_HDR_IPV6 |
@@ -955,6 +964,10 @@ ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct ice_flow_seg_info *seg)
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6 |
 				  ICE_FLOW_SEG_HDR_IPV_OTHER);
 		break;
+	case ICE_FLTR_PTYPE_FRAG_IPV6:
+		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6 |
+				  ICE_FLOW_SEG_HDR_IPV_FRAG);
+		break;
 	case ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN:
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP |
 				ICE_FLOW_SEG_HDR_IPV4 |
@@ -1599,8 +1612,10 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 	enum rte_flow_item_type l3 = RTE_FLOW_ITEM_TYPE_END;
 	enum ice_fdir_tunnel_type tunnel_type = ICE_FDIR_TUNNEL_TYPE_NONE;
 	const struct rte_flow_item_eth *eth_spec, *eth_mask;
-	const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_mask;
+	const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_last, *ipv4_mask;
 	const struct rte_flow_item_ipv6 *ipv6_spec, *ipv6_mask;
+	const struct rte_flow_item_ipv6_frag_ext *ipv6_frag_spec,
+					*ipv6_frag_last, *ipv6_frag_mask;
 	const struct rte_flow_item_tcp *tcp_spec, *tcp_mask;
 	const struct rte_flow_item_udp *udp_spec, *udp_mask;
 	const struct rte_flow_item_sctp *sctp_spec, *sctp_mask;
@@ -1639,13 +1654,14 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 	 * flow. input_set_i is used for inner part.
 	 */
 	for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
-		if (item->last) {
+		if (item->last && !(item_type == RTE_FLOW_ITEM_TYPE_IPV4 ||
+				    item_type ==
+				    RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT)) {
 			rte_flow_error_set(error, EINVAL,
-					   RTE_FLOW_ERROR_TYPE_ITEM,
-					   item,
+					   RTE_FLOW_ERROR_TYPE_ITEM, item,
 					   "Not support range");
-			return -rte_errno;
 		}
+
 		item_type = item->type;
 
 		input_set = (tunnel_type && !is_outer) ?
@@ -1696,6 +1712,7 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			flow_type = ICE_FLTR_PTYPE_NONF_IPV4_OTHER;
 			l3 = RTE_FLOW_ITEM_TYPE_IPV4;
 			ipv4_spec = item->spec;
+			ipv4_last = item->last;
 			ipv4_mask = item->mask;
 			p_v4 = (tunnel_type && is_outer) ?
 			       &filter->input.ip_outer.v4 :
@@ -1707,8 +1724,6 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			/* Check IPv4 mask and update input set */
 			if (ipv4_mask->hdr.version_ihl ||
 			    ipv4_mask->hdr.total_length ||
-			    ipv4_mask->hdr.packet_id ||
-			    ipv4_mask->hdr.fragment_offset ||
 			    ipv4_mask->hdr.hdr_checksum) {
 				rte_flow_error_set(error, EINVAL,
 						   RTE_FLOW_ERROR_TYPE_ITEM,
@@ -1717,6 +1732,21 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 				return -rte_errno;
 			}
 
+			if (ipv4_last &&
+			    (ipv4_last->hdr.version_ihl ||
+			     ipv4_last->hdr.type_of_service ||
+			     ipv4_last->hdr.time_to_live ||
+			     ipv4_last->hdr.total_length |
+			     ipv4_last->hdr.next_proto_id ||
+			     ipv4_last->hdr.hdr_checksum ||
+			     ipv4_last->hdr.src_addr ||
+			     ipv4_last->hdr.dst_addr)) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ITEM,
+						   item, "Invalid IPv4 last.");
+				return -rte_errno;
+			}
+
 			if (ipv4_mask->hdr.dst_addr == UINT32_MAX)
 				*input_set |= ICE_INSET_IPV4_DST;
 			if (ipv4_mask->hdr.src_addr == UINT32_MAX)
@@ -1733,6 +1763,32 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			p_v4->ttl = ipv4_spec->hdr.time_to_live;
 			p_v4->proto = ipv4_spec->hdr.next_proto_id;
 			p_v4->tos = ipv4_spec->hdr.type_of_service;
+
+			/* only support any packet id for fragment IPv4
+			 * any packet_id:
+			 * spec is 0, last is 0xffff, mask is 0xffff
+			 * fragment Ipv4:
+			 * spec is 0x2000, mask is 0xffff
+			 */
+			if (ipv4_last && ipv4_spec->hdr.packet_id == 0 &&
+			    ipv4_last->hdr.packet_id == UINT16_MAX &&
+			    ipv4_mask->hdr.packet_id == UINT16_MAX &&
+			    ipv4_spec->hdr.fragment_offset ==
+			    rte_cpu_to_be_16(RTE_IPV4_HDR_MF_FLAG) &&
+			    ipv4_mask->hdr.fragment_offset == UINT16_MAX) {
+				/* all IPv4 fragment packet has the same
+				 * ethertype, if the spec is for all valid
+				 * packet id, set ethertype into input set.
+				 */
+				*input_set |= ICE_INSET_ETHERTYPE;
+				input_set_o |= ICE_INSET_ETHERTYPE;
+			} else if (ipv4_mask->hdr.packet_id == UINT16_MAX) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ITEM,
+						   item, "Invalid IPv4 mask.");
+				return -rte_errno;
+			}
+
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV6:
 			flow_type = ICE_FLTR_PTYPE_NONF_IPV6_OTHER;
@@ -1778,6 +1834,43 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			p_v6->proto = ipv6_spec->hdr.proto;
 			p_v6->hlim = ipv6_spec->hdr.hop_limits;
 			break;
+		case RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT:
+			l3 = RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT;
+			flow_type = ICE_FLTR_PTYPE_FRAG_IPV6;
+			ipv6_frag_spec = item->spec;
+			ipv6_frag_last = item->last;
+			ipv6_frag_mask = item->mask;
+
+			if (!(ipv6_frag_spec && ipv6_frag_mask))
+				break;
+
+			/* only support any packet id for fragment IPv6
+			 * any packet_id:
+			 * spec is 0, last is 0xffffffff, mask is 0xffffffff
+			 * fragment Ipv6:
+			 * spec is 0x1, mask is 0xffff
+			 */
+			if (ipv6_frag_last && ipv6_frag_spec->hdr.id == 0 &&
+			    ipv6_frag_last->hdr.id == UINT32_MAX &&
+			    ipv6_frag_mask->hdr.id == UINT32_MAX &&
+			    ipv6_frag_spec->hdr.frag_data ==
+			    rte_cpu_to_be_16(1) &&
+			    ipv6_frag_mask->hdr.frag_data == UINT16_MAX) {
+				/* all IPv6 fragment packet has the same
+				 * ethertype, if the spec is for all valid
+				 * packet id, set ethertype into input set.
+				 */
+				*input_set |= ICE_INSET_ETHERTYPE;
+				input_set_o |= ICE_INSET_ETHERTYPE;
+			} else if (ipv6_frag_mask->hdr.id == UINT32_MAX) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ITEM,
+						   item, "Invalid IPv6 mask.");
+				return -rte_errno;
+			}
+
+			break;
+
 		case RTE_FLOW_ITEM_TYPE_TCP:
 			if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
 				flow_type = ICE_FLTR_PTYPE_NONF_IPV4_TCP;
@@ -2016,7 +2109,8 @@ ice_fdir_parse(struct ice_adapter *ad,
 	if (ret)
 		goto error;
 	input_set = filter->input_set_o | filter->input_set_i;
-	if (!input_set || filter->input_set_o & ~item->input_set_mask_o ||
+	if (!input_set || filter->input_set_o &
+	    ~(item->input_set_mask_o | ICE_INSET_ETHERTYPE) ||
 	    filter->input_set_i & ~item->input_set_mask_i) {
 		rte_flow_error_set(error, EINVAL,
 				   RTE_FLOW_ERROR_TYPE_ITEM_SPEC,
diff --git a/drivers/net/ice/ice_generic_flow.c b/drivers/net/ice/ice_generic_flow.c
index 2389bc6637..7a34a51600 100644
--- a/drivers/net/ice/ice_generic_flow.c
+++ b/drivers/net/ice/ice_generic_flow.c
@@ -2108,6 +2108,7 @@ static struct ice_ptype_match ice_ptype_map[] = {
 	{pattern_eth_ipv6_udp,				ICE_PTYPE_IPV6_UDP_PAY},
 	{pattern_eth_ipv6_tcp,				ICE_PTYPE_IPV6_TCP_PAY},
 	{pattern_eth_ipv6_sctp,				ICE_PTYPE_IPV6_SCTP_PAY},
+	{pattern_eth_ipv6_frag_ext,			ICE_PTYPE_IPV6FRAG_PAY},
 	{pattern_eth_ipv6_gtpu,				ICE_MAC_IPV6_GTPU},
 	{pattern_eth_ipv6_gtpu_eh,			ICE_MAC_IPV6_GTPU},
 	{pattern_eth_ipv6_gtpu_ipv4,			ICE_MAC_IPV6_GTPU_IPV4_PAY},
-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v4 0/3] support flow for IP fragment in ICE
  2021-03-24 13:54 ` [dpdk-dev] [PATCH v2 0/3] support flow for IP fragment in ICE Jeff Guo
                     ` (5 preceding siblings ...)
  2021-04-13  7:58   ` [dpdk-dev] [PATCH v4 0/3] support flow for IP fragment in ICE Jeff Guo
@ 2021-04-13  8:48   ` Jeff Guo
  2021-04-13  8:48     ` [dpdk-dev] [PATCH v4 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
                       ` (3 more replies)
  2021-04-13  9:38   ` [dpdk-dev] [PATCH v5 " Jeff Guo
  2021-04-13 10:06   ` [dpdk-dev] [PATCH v6 " Jeff Guo
  8 siblings, 4 replies; 42+ messages in thread
From: Jeff Guo @ 2021-04-13  8:48 UTC (permalink / raw)
  To: qi.z.zhang, qiming.yang; +Cc: dev, ting.xu, jia.guo

Support RSS hash and FDIR for IP fragment packets in ICE PMD.

v4:
correct typo when define fragment
v3:
rebase code and fix some parsing issues.
v2:
add some input check

Jeff Guo (3):
  net/ice/base: support IP fragment RSS and FDIR
  net/ice: support RSS hash for IP fragment
  net/ice: support FDIR for IP fragment packet

 drivers/net/ice/base/ice_fdir.c    |  50 ++++++++++++-
 drivers/net/ice/base/ice_fdir.h    |  22 +++++-
 drivers/net/ice/base/ice_flow.c    |  50 ++++++++++++-
 drivers/net/ice/base/ice_flow.h    |   5 +-
 drivers/net/ice/base/ice_type.h    |   1 +
 drivers/net/ice/ice_fdir_filter.c  | 116 ++++++++++++++++++++++++++---
 drivers/net/ice/ice_generic_flow.c |  22 ++++++
 drivers/net/ice/ice_generic_flow.h |   6 ++
 drivers/net/ice/ice_hash.c         |  48 ++++++++++--
 9 files changed, 293 insertions(+), 27 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v4 1/3] net/ice/base: support IP fragment RSS and FDIR
  2021-04-13  8:48   ` [dpdk-dev] [PATCH v4 0/3] support flow for IP fragment in ICE Jeff Guo
@ 2021-04-13  8:48     ` Jeff Guo
  2021-04-13  8:48     ` [dpdk-dev] [PATCH v4 2/3] net/ice: support RSS hash for IP fragment Jeff Guo
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 42+ messages in thread
From: Jeff Guo @ 2021-04-13  8:48 UTC (permalink / raw)
  To: qi.z.zhang, qiming.yang; +Cc: dev, ting.xu, jia.guo

Add support for IP fragment RSS hash and FDIR according to packet ID.
Separate IP fragment and IP other packet types.

Signed-off-by: Ting Xu <ting.xu@intel.com>
Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
 drivers/net/ice/base/ice_fdir.c | 50 +++++++++++++++++++++++++++++++--
 drivers/net/ice/base/ice_fdir.h | 22 ++++++++++++---
 drivers/net/ice/base/ice_flow.c | 50 ++++++++++++++++++++++++++++++++-
 drivers/net/ice/base/ice_flow.h |  5 +++-
 drivers/net/ice/base/ice_type.h |  1 +
 5 files changed, 120 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ice/base/ice_fdir.c b/drivers/net/ice/base/ice_fdir.c
index 2b39c13127..a9a14b7445 100644
--- a/drivers/net/ice/base/ice_fdir.c
+++ b/drivers/net/ice/base/ice_fdir.c
@@ -518,6 +518,24 @@ 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 +734,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),
@@ -1505,7 +1533,7 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
 		ice_pkt_insert_u8(loc, ICE_IPV4_TTL_OFFSET, input->ip.v4.ttl);
 		ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
 		if (frag)
-			loc[20] = ICE_FDIR_IPV4_PKT_FLAG_DF;
+			loc[20] = ICE_FDIR_IPV4_PKT_FLAG_MF;
 		break;
 	case ICE_FLTR_PTYPE_NONF_IPV4_UDP:
 		ice_pkt_insert_mac_addr(pkt, input->ext_data_outer.dst_mac);
@@ -1808,6 +1836,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 +1883,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;
diff --git a/drivers/net/ice/base/ice_fdir.h b/drivers/net/ice/base/ice_fdir.h
index 6573f96bc1..2acc1d6f1b 100644
--- a/drivers/net/ice/base/ice_fdir.h
+++ b/drivers/net/ice/base/ice_fdir.h
@@ -43,9 +43,11 @@
 #define ICE_MAC_ETHTYPE_OFFSET		12
 #define ICE_IPV4_TOS_OFFSET		15
 #define ICE_IPV4_TTL_OFFSET		22
+#define ICE_IPV4_ID_OFFSET		18
 #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
@@ -83,12 +85,22 @@
 
 #define ICE_FDIR_MAX_FLTRS		16384
 
-/* IP v4 has 2 flag bits that enable fragment processing: DF and MF. DF
+/* IPv4 has 2 flag bits that enable fragment processing: DF and MF. DF
  * requests that the packet not be fragmented. MF indicates that a packet has
- * been fragmented.
+ * been fragmented, except that for the last fragment has a non-zero
+ * Fragment Offset field with zero MF.
  */
-#define ICE_FDIR_IPV4_PKT_FLAG_DF		0x20
-#define ICE_FDIR_IPV4_PKT_FLAG_MF		0x40
+#define ICE_FDIR_IPV4_PKT_FLAG_MF		0x20
+#define ICE_FDIR_IPV4_PKT_FLAG_MF_SHIFT	8
+#ifndef NO_UNUSED_PACKAGE_CODE
+#define ICE_FDIR_IPV4_PKT_FLAG_DF		0x40
+#endif /* NO_UNUSED_PACKAGE_CODE */
+
+/* For IPv6 fragmented packets, all fragments except the last have
+ * the MF flag set.
+ */
+#define ICE_FDIR_IPV6_PKT_FLAG_MF		0x100
+#define ICE_FDIR_IPV6_PKT_FLAG_MF_SHIFT	8
 
 enum ice_fltr_prgm_desc_dest {
 	ICE_FLTR_PRGM_DESC_DEST_DROP_PKT,
@@ -150,6 +162,7 @@ struct ice_fdir_v4 {
 	u8 ip_ver;
 	u8 proto;
 	u8 ttl;
+	__be16 packet_id;
 };
 
 #define ICE_IPV6_ADDR_LEN_AS_U32		4
@@ -164,6 +177,7 @@ struct ice_fdir_v6 {
 	u8 tc;
 	u8 proto;
 	u8 hlim;
+	__be32 packet_id;
 };
 
 struct ice_fdir_udp_gtp {
diff --git a/drivers/net/ice/base/ice_flow.c b/drivers/net/ice/base/ice_flow.c
index c12ddfa247..9dea881914 100644
--- a/drivers/net/ice/base/ice_flow.c
+++ b/drivers/net/ice/base/ice_flow.c
@@ -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),
@@ -725,6 +733,27 @@ static const u32 ice_ptypes_udp_ecpri_tp0[] = {
 	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;
@@ -899,6 +928,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 :
@@ -1177,6 +1216,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:
@@ -1187,6 +1229,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:
@@ -3341,13 +3386,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);
diff --git a/drivers/net/ice/base/ice_flow.h b/drivers/net/ice/base/ice_flow.h
index af15ecb0ff..d905b95b1c 100644
--- a/drivers/net/ice/base/ice_flow.h
+++ b/drivers/net/ice/base/ice_flow.h
@@ -186,8 +186,9 @@ enum ice_flow_seg_hdr {
 	ICE_FLOW_SEG_HDR_ECPRI_TP0	= 0x04000000,
 	ICE_FLOW_SEG_HDR_UDP_ECPRI_TP0	= 0x08000000,
 	/* 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_FRAG	= 0x10000000,
 	ICE_FLOW_SEG_HDR_IPV_OTHER	= 0x20000000,
 };
 
@@ -225,6 +226,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,
diff --git a/drivers/net/ice/base/ice_type.h b/drivers/net/ice/base/ice_type.h
index a6599363f9..5abe9dc9ea 100644
--- a/drivers/net/ice/base/ice_type.h
+++ b/drivers/net/ice/base/ice_type.h
@@ -349,6 +349,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,
-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v4 2/3] net/ice: support RSS hash for IP fragment
  2021-04-13  8:48   ` [dpdk-dev] [PATCH v4 0/3] support flow for IP fragment in ICE Jeff Guo
  2021-04-13  8:48     ` [dpdk-dev] [PATCH v4 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
@ 2021-04-13  8:48     ` Jeff Guo
  2021-04-13  8:48     ` [dpdk-dev] [PATCH v4 3/3] net/ice: support FDIR for IP fragment packet Jeff Guo
  2021-04-13  9:02     ` [dpdk-dev] [PATCH v4 0/3] support flow for IP fragment in ICE Xu, Ting
  3 siblings, 0 replies; 42+ messages in thread
From: Jeff Guo @ 2021-04-13  8:48 UTC (permalink / raw)
  To: qi.z.zhang, qiming.yang; +Cc: dev, ting.xu, jia.guo

New pattern and RSS hash flow parsing are added to handle fragmented
IPv4/IPv6  packet.

Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
 drivers/net/ice/ice_generic_flow.c | 21 +++++++++++++
 drivers/net/ice/ice_generic_flow.h |  6 ++++
 drivers/net/ice/ice_hash.c         | 48 +++++++++++++++++++++++++-----
 3 files changed, 67 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ice/ice_generic_flow.c b/drivers/net/ice/ice_generic_flow.c
index 8704812622..2389bc6637 100644
--- a/drivers/net/ice/ice_generic_flow.c
+++ b/drivers/net/ice/ice_generic_flow.c
@@ -212,6 +212,27 @@ enum rte_flow_item_type pattern_eth_qinq_ipv6[] = {
 	RTE_FLOW_ITEM_TYPE_IPV6,
 	RTE_FLOW_ITEM_TYPE_END,
 };
+enum rte_flow_item_type pattern_eth_ipv6_frag_ext[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+enum rte_flow_item_type pattern_eth_vlan_ipv6_frag_ext[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_VLAN,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+enum rte_flow_item_type pattern_eth_qinq_ipv6_frag_ext[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_VLAN,
+	RTE_FLOW_ITEM_TYPE_VLAN,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+	RTE_FLOW_ITEM_TYPE_END,
+};
 enum rte_flow_item_type pattern_eth_ipv6_udp[] = {
 	RTE_FLOW_ITEM_TYPE_ETH,
 	RTE_FLOW_ITEM_TYPE_IPV6,
diff --git a/drivers/net/ice/ice_generic_flow.h b/drivers/net/ice/ice_generic_flow.h
index 9f422e5925..2afe719264 100644
--- a/drivers/net/ice/ice_generic_flow.h
+++ b/drivers/net/ice/ice_generic_flow.h
@@ -52,6 +52,7 @@
 #define ICE_L2TPV3OIP_SESSION_ID	BIT_ULL(43)
 #define ICE_PFCP_SEID			BIT_ULL(42)
 #define ICE_PFCP_S_FIELD		BIT_ULL(41)
+#define ICE_IP_PK_ID		    BIT_ULL(40)
 
 /* input set */
 
@@ -69,11 +70,13 @@
 #define ICE_INSET_IPV4_TOS		(ICE_PROT_IPV4 | ICE_IP_TOS)
 #define ICE_INSET_IPV4_PROTO		(ICE_PROT_IPV4 | ICE_IP_PROTO)
 #define ICE_INSET_IPV4_TTL		(ICE_PROT_IPV4 | ICE_IP_TTL)
+#define ICE_INSET_IPV4_PKID		(ICE_PROT_IPV4 | ICE_IP_PK_ID)
 #define ICE_INSET_IPV6_SRC		(ICE_PROT_IPV6 | ICE_IP_SRC)
 #define ICE_INSET_IPV6_DST		(ICE_PROT_IPV6 | ICE_IP_DST)
 #define ICE_INSET_IPV6_NEXT_HDR		(ICE_PROT_IPV6 | ICE_IP_PROTO)
 #define ICE_INSET_IPV6_HOP_LIMIT	(ICE_PROT_IPV6 | ICE_IP_TTL)
 #define ICE_INSET_IPV6_TC		(ICE_PROT_IPV6 | ICE_IP_TOS)
+#define ICE_INSET_IPV6_PKID		(ICE_PROT_IPV6 | ICE_IP_PK_ID)
 
 #define ICE_INSET_TCP_SRC_PORT		(ICE_PROT_TCP | ICE_SPORT)
 #define ICE_INSET_TCP_DST_PORT		(ICE_PROT_TCP | ICE_DPORT)
@@ -202,6 +205,9 @@ extern enum rte_flow_item_type pattern_eth_qinq_ipv4_icmp[];
 extern enum rte_flow_item_type pattern_eth_ipv6[];
 extern enum rte_flow_item_type pattern_eth_vlan_ipv6[];
 extern enum rte_flow_item_type pattern_eth_qinq_ipv6[];
+extern enum rte_flow_item_type pattern_eth_ipv6_frag_ext[];
+extern enum rte_flow_item_type pattern_eth_vlan_ipv6_frag_ext[];
+extern enum rte_flow_item_type pattern_eth_qinq_ipv6_frag_ext[];
 extern enum rte_flow_item_type pattern_eth_ipv6_udp[];
 extern enum rte_flow_item_type pattern_eth_vlan_ipv6_udp[];
 extern enum rte_flow_item_type pattern_eth_qinq_ipv6_udp[];
diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c
index 7d7e7052da..9df20df550 100644
--- a/drivers/net/ice/ice_hash.c
+++ b/drivers/net/ice/ice_hash.c
@@ -47,8 +47,10 @@
 				 ETH_RSS_NONFRAG_IPV6_TCP	| \
 				 ETH_RSS_NONFRAG_IPV6_SCTP)
 
-#define VALID_RSS_IPV4		(ETH_RSS_IPV4 | VALID_RSS_IPV4_L4)
-#define VALID_RSS_IPV6		(ETH_RSS_IPV6 | VALID_RSS_IPV6_L4)
+#define VALID_RSS_IPV4		(ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 | \
+				 VALID_RSS_IPV4_L4)
+#define VALID_RSS_IPV6		(ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 | \
+				 VALID_RSS_IPV6_L4)
 #define VALID_RSS_L3		(VALID_RSS_IPV4 | VALID_RSS_IPV6)
 #define VALID_RSS_L4		(VALID_RSS_IPV4_L4 | VALID_RSS_IPV6_L4)
 
@@ -108,6 +110,7 @@ ice_hash_parse_pattern_action(struct ice_adapter *ad,
 /* Rss configuration template */
 struct ice_rss_hash_cfg ipv4_tmplt = {
 	ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV4 |
+	ICE_FLOW_SEG_HDR_IPV_FRAG |
 	ICE_FLOW_SEG_HDR_IPV_OTHER,
 	ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_IPV4,
 	ICE_RSS_OUTER_HEADERS,
@@ -146,6 +149,15 @@ struct ice_rss_hash_cfg ipv6_tmplt = {
 	0
 };
 
+struct ice_rss_hash_cfg ipv6_frag_tmplt = {
+	ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV6 |
+	ICE_FLOW_SEG_HDR_IPV_FRAG |
+	ICE_FLOW_SEG_HDR_IPV_OTHER,
+	ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_IPV6,
+	ICE_RSS_ANY_HEADERS,
+	0
+};
+
 struct ice_rss_hash_cfg ipv6_udp_tmplt = {
 	ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV6 |
 	ICE_FLOW_SEG_HDR_IPV_OTHER | ICE_FLOW_SEG_HDR_UDP,
@@ -198,6 +210,7 @@ struct ice_rss_hash_cfg outer_ipv6_inner_ipv4_tmplt = {
 	ICE_RSS_INNER_HEADERS_W_OUTER_IPV6,
 	0
 };
+
 struct ice_rss_hash_cfg outer_ipv6_inner_ipv4_udp_tmplt = {
 	ICE_FLOW_SEG_HDR_IPV4 | ICE_FLOW_SEG_HDR_IPV_OTHER |
 	ICE_FLOW_SEG_HDR_UDP,
@@ -220,6 +233,7 @@ struct ice_rss_hash_cfg outer_ipv4_inner_ipv6_tmplt = {
 	ICE_RSS_INNER_HEADERS_W_OUTER_IPV4,
 	0
 };
+
 struct ice_rss_hash_cfg outer_ipv4_inner_ipv6_udp_tmplt = {
 	ICE_FLOW_SEG_HDR_IPV6 | ICE_FLOW_SEG_HDR_IPV_OTHER |
 	ICE_FLOW_SEG_HDR_UDP,
@@ -353,7 +367,8 @@ struct ice_rss_hash_cfg empty_tmplt = {
 };
 
 /* IPv4 */
-#define ICE_RSS_TYPE_ETH_IPV4		(ETH_RSS_ETH | ETH_RSS_IPV4)
+#define ICE_RSS_TYPE_ETH_IPV4		(ETH_RSS_ETH | ETH_RSS_IPV4 | \
+					 ETH_RSS_FRAG_IPV4)
 #define ICE_RSS_TYPE_ETH_IPV4_UDP	(ICE_RSS_TYPE_ETH_IPV4 | \
 					 ETH_RSS_NONFRAG_IPV4_UDP)
 #define ICE_RSS_TYPE_ETH_IPV4_TCP	(ICE_RSS_TYPE_ETH_IPV4 | \
@@ -370,6 +385,8 @@ struct ice_rss_hash_cfg empty_tmplt = {
 
 /* IPv6 */
 #define ICE_RSS_TYPE_ETH_IPV6		(ETH_RSS_ETH | ETH_RSS_IPV6)
+#define ICE_RSS_TYPE_ETH_IPV6_FRAG	(ETH_RSS_ETH | ETH_RSS_IPV6 | \
+					 ETH_RSS_FRAG_IPV6)
 #define ICE_RSS_TYPE_ETH_IPV6_UDP	(ICE_RSS_TYPE_ETH_IPV6 | \
 					 ETH_RSS_NONFRAG_IPV6_UDP)
 #define ICE_RSS_TYPE_ETH_IPV6_TCP	(ICE_RSS_TYPE_ETH_IPV6 | \
@@ -386,7 +403,8 @@ struct ice_rss_hash_cfg empty_tmplt = {
 
 /* VLAN IPV4 */
 #define ICE_RSS_TYPE_VLAN_IPV4		(ICE_RSS_TYPE_IPV4 | \
-					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
+					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN | \
+					 ETH_RSS_FRAG_IPV4)
 #define ICE_RSS_TYPE_VLAN_IPV4_UDP	(ICE_RSS_TYPE_IPV4_UDP | \
 					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
 #define ICE_RSS_TYPE_VLAN_IPV4_TCP	(ICE_RSS_TYPE_IPV4_TCP | \
@@ -396,6 +414,9 @@ struct ice_rss_hash_cfg empty_tmplt = {
 /* VLAN IPv6 */
 #define ICE_RSS_TYPE_VLAN_IPV6		(ICE_RSS_TYPE_IPV6 | \
 					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
+#define ICE_RSS_TYPE_VLAN_IPV6_FRAG	(ICE_RSS_TYPE_IPV6 | \
+					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN | \
+					 ETH_RSS_FRAG_IPV6)
 #define ICE_RSS_TYPE_VLAN_IPV6_UDP	(ICE_RSS_TYPE_IPV6_UDP | \
 					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
 #define ICE_RSS_TYPE_VLAN_IPV6_TCP	(ICE_RSS_TYPE_IPV6_TCP | \
@@ -485,10 +506,12 @@ static struct ice_pattern_match_item ice_hash_pattern_list[] = {
 	{pattern_eth_ipv4_pfcp,			ICE_RSS_TYPE_IPV4_PFCP,		ICE_INSET_NONE,	&eth_ipv4_pfcp_tmplt},
 	/* IPV6 */
 	{pattern_eth_ipv6,			ICE_RSS_TYPE_ETH_IPV6,		ICE_INSET_NONE,	&ipv6_tmplt},
+	{pattern_eth_ipv6_frag_ext,		ICE_RSS_TYPE_ETH_IPV6_FRAG,	ICE_INSET_NONE,	&ipv6_frag_tmplt},
 	{pattern_eth_ipv6_udp,			ICE_RSS_TYPE_ETH_IPV6_UDP,	ICE_INSET_NONE,	&ipv6_udp_tmplt},
 	{pattern_eth_ipv6_tcp,			ICE_RSS_TYPE_ETH_IPV6_TCP,	ICE_INSET_NONE,	&ipv6_tcp_tmplt},
 	{pattern_eth_ipv6_sctp,			ICE_RSS_TYPE_ETH_IPV6_SCTP,	ICE_INSET_NONE,	&ipv6_sctp_tmplt},
 	{pattern_eth_vlan_ipv6,			ICE_RSS_TYPE_VLAN_IPV6,		ICE_INSET_NONE,	&ipv6_tmplt},
+	{pattern_eth_vlan_ipv6_frag_ext,	ICE_RSS_TYPE_VLAN_IPV6_FRAG,	ICE_INSET_NONE, &ipv6_frag_tmplt},
 	{pattern_eth_vlan_ipv6_udp,		ICE_RSS_TYPE_VLAN_IPV6_UDP,	ICE_INSET_NONE,	&ipv6_udp_tmplt},
 	{pattern_eth_vlan_ipv6_tcp,		ICE_RSS_TYPE_VLAN_IPV6_TCP,	ICE_INSET_NONE,	&ipv6_tcp_tmplt},
 	{pattern_eth_vlan_ipv6_sctp,		ICE_RSS_TYPE_VLAN_IPV6_SCTP,	ICE_INSET_NONE,	&ipv6_sctp_tmplt},
@@ -629,11 +652,14 @@ ice_refine_hash_cfg_l234(struct ice_rss_hash_cfg *hash_cfg,
 
 	if (*addl_hdrs & ICE_FLOW_SEG_HDR_IPV4) {
 		if (rss_type &
-		   (ETH_RSS_IPV4 |
+		   (ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 |
 		    ETH_RSS_NONFRAG_IPV4_UDP |
 		    ETH_RSS_NONFRAG_IPV4_TCP |
 		    ETH_RSS_NONFRAG_IPV4_SCTP)) {
-			if (rss_type & ETH_RSS_L3_SRC_ONLY)
+			if (rss_type & ETH_RSS_FRAG_IPV4)
+				*hash_flds &=
+					~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_ID));
+			else if (rss_type & ETH_RSS_L3_SRC_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA));
 			else if (rss_type & ETH_RSS_L3_DST_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA));
@@ -648,11 +674,14 @@ ice_refine_hash_cfg_l234(struct ice_rss_hash_cfg *hash_cfg,
 
 	if (*addl_hdrs & ICE_FLOW_SEG_HDR_IPV6) {
 		if (rss_type &
-		   (ETH_RSS_IPV6 |
+		   (ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 |
 		    ETH_RSS_NONFRAG_IPV6_UDP |
 		    ETH_RSS_NONFRAG_IPV6_TCP |
 		    ETH_RSS_NONFRAG_IPV6_SCTP)) {
-			if (rss_type & ETH_RSS_L3_SRC_ONLY)
+			if (rss_type & ETH_RSS_FRAG_IPV6)
+				*hash_flds &=
+					~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_ID));
+			else if (rss_type & ETH_RSS_L3_SRC_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA));
 			else if (rss_type & ETH_RSS_L3_DST_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA));
@@ -827,6 +856,8 @@ static void ice_refine_hash_cfg(struct ice_rss_hash_cfg *hash_cfg,
 static uint64_t invalid_rss_comb[] = {
 	ETH_RSS_IPV4 | ETH_RSS_NONFRAG_IPV4_UDP,
 	ETH_RSS_IPV6 | ETH_RSS_NONFRAG_IPV6_UDP,
+	ETH_RSS_FRAG_IPV4 | ETH_RSS_NONFRAG_IPV4_UDP,
+	ETH_RSS_FRAG_IPV6 | ETH_RSS_NONFRAG_IPV6_UDP,
 	RTE_ETH_RSS_L3_PRE40 |
 	RTE_ETH_RSS_L3_PRE56 |
 	RTE_ETH_RSS_L3_PRE96
@@ -865,6 +896,7 @@ ice_any_invalid_rss_type(enum rte_eth_hash_function rss_func,
 
 		if (!(rss_type &
 		   (ETH_RSS_IPV4 | ETH_RSS_IPV6 |
+		    ETH_RSS_FRAG_IPV4 | ETH_RSS_FRAG_IPV6 |
 		    ETH_RSS_NONFRAG_IPV4_UDP | ETH_RSS_NONFRAG_IPV6_UDP |
 		    ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_NONFRAG_IPV6_TCP |
 		    ETH_RSS_NONFRAG_IPV4_SCTP | ETH_RSS_NONFRAG_IPV6_SCTP)))
-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v4 3/3] net/ice: support FDIR for IP fragment packet
  2021-04-13  8:48   ` [dpdk-dev] [PATCH v4 0/3] support flow for IP fragment in ICE Jeff Guo
  2021-04-13  8:48     ` [dpdk-dev] [PATCH v4 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
  2021-04-13  8:48     ` [dpdk-dev] [PATCH v4 2/3] net/ice: support RSS hash for IP fragment Jeff Guo
@ 2021-04-13  8:48     ` Jeff Guo
  2021-04-13  9:02     ` [dpdk-dev] [PATCH v4 0/3] support flow for IP fragment in ICE Xu, Ting
  3 siblings, 0 replies; 42+ messages in thread
From: Jeff Guo @ 2021-04-13  8:48 UTC (permalink / raw)
  To: qi.z.zhang, qiming.yang; +Cc: dev, ting.xu, jia.guo

New FDIR parsing are added to handle the fragmented IPv4/IPv6 packet.

Signed-off-by: Jeff Guo <jia.guo@intel.com>
Signed-off-by: Ting Xu <ting.xu@intel.com>
---
 drivers/net/ice/ice_fdir_filter.c  | 116 ++++++++++++++++++++++++++---
 drivers/net/ice/ice_generic_flow.c |   1 +
 2 files changed, 106 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
index 92e18d59cc..8158f75f05 100644
--- a/drivers/net/ice/ice_fdir_filter.c
+++ b/drivers/net/ice/ice_fdir_filter.c
@@ -24,7 +24,7 @@
 #define ICE_FDIR_INSET_ETH_IPV4 (\
 	ICE_FDIR_INSET_ETH | \
 	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | ICE_INSET_IPV4_TOS | \
-	ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO)
+	ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO | ICE_INSET_IPV4_PKID)
 
 #define ICE_FDIR_INSET_ETH_IPV4_UDP (\
 	ICE_FDIR_INSET_ETH_IPV4 | \
@@ -41,7 +41,8 @@
 #define ICE_FDIR_INSET_ETH_IPV6 (\
 	ICE_INSET_DMAC | \
 	ICE_INSET_IPV6_SRC | ICE_INSET_IPV6_DST | ICE_INSET_IPV6_TC | \
-	ICE_INSET_IPV6_HOP_LIMIT | ICE_INSET_IPV6_NEXT_HDR)
+	ICE_INSET_IPV6_HOP_LIMIT | ICE_INSET_IPV6_NEXT_HDR | \
+	ICE_INSET_IPV6_PKID)
 
 #define ICE_FDIR_INSET_ETH_IPV6_UDP (\
 	ICE_FDIR_INSET_ETH_IPV6 | \
@@ -56,7 +57,8 @@
 	ICE_INSET_SCTP_SRC_PORT | ICE_INSET_SCTP_DST_PORT)
 
 #define ICE_FDIR_INSET_IPV4 (\
-	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST)
+	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | \
+	ICE_INSET_IPV4_PKID)
 
 #define ICE_FDIR_INSET_IPV4_TCP (\
 	ICE_FDIR_INSET_IPV4 | \
@@ -95,6 +97,7 @@ static struct ice_pattern_match_item ice_fdir_pattern_list[] = {
 	{pattern_eth_ipv4_tcp,				ICE_FDIR_INSET_ETH_IPV4_TCP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv4_sctp,				ICE_FDIR_INSET_ETH_IPV4_SCTP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6,				ICE_FDIR_INSET_ETH_IPV6,	ICE_INSET_NONE,			ICE_INSET_NONE},
+	{pattern_eth_ipv6_frag_ext,			ICE_FDIR_INSET_ETH_IPV6,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6_udp,				ICE_FDIR_INSET_ETH_IPV6_UDP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6_tcp,				ICE_FDIR_INSET_ETH_IPV6_TCP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6_sctp,				ICE_FDIR_INSET_ETH_IPV6_SCTP,	ICE_INSET_NONE,			ICE_INSET_NONE},
@@ -882,11 +885,13 @@ ice_fdir_input_set_parse(uint64_t inset, enum ice_flow_field *field)
 		{ICE_INSET_IPV4_TOS, ICE_FLOW_FIELD_IDX_IPV4_DSCP},
 		{ICE_INSET_IPV4_TTL, ICE_FLOW_FIELD_IDX_IPV4_TTL},
 		{ICE_INSET_IPV4_PROTO, ICE_FLOW_FIELD_IDX_IPV4_PROT},
+		{ICE_INSET_IPV4_PKID, ICE_FLOW_FIELD_IDX_IPV4_ID},
 		{ICE_INSET_IPV6_SRC, ICE_FLOW_FIELD_IDX_IPV6_SA},
 		{ICE_INSET_IPV6_DST, ICE_FLOW_FIELD_IDX_IPV6_DA},
 		{ICE_INSET_IPV6_TC, ICE_FLOW_FIELD_IDX_IPV6_DSCP},
 		{ICE_INSET_IPV6_NEXT_HDR, ICE_FLOW_FIELD_IDX_IPV6_PROT},
 		{ICE_INSET_IPV6_HOP_LIMIT, ICE_FLOW_FIELD_IDX_IPV6_TTL},
+		{ICE_INSET_IPV6_PKID, ICE_FLOW_FIELD_IDX_IPV6_ID},
 		{ICE_INSET_TCP_SRC_PORT, ICE_FLOW_FIELD_IDX_TCP_SRC_PORT},
 		{ICE_INSET_TCP_DST_PORT, ICE_FLOW_FIELD_IDX_TCP_DST_PORT},
 		{ICE_INSET_UDP_SRC_PORT, ICE_FLOW_FIELD_IDX_UDP_SRC_PORT},
@@ -936,6 +941,10 @@ ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct ice_flow_seg_info *seg)
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4 |
 				  ICE_FLOW_SEG_HDR_IPV_OTHER);
 		break;
+	case ICE_FLTR_PTYPE_FRAG_IPV4:
+		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4 |
+				  ICE_FLOW_SEG_HDR_IPV_FRAG);
+		break;
 	case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP |
 				  ICE_FLOW_SEG_HDR_IPV6 |
@@ -955,6 +964,10 @@ ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct ice_flow_seg_info *seg)
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6 |
 				  ICE_FLOW_SEG_HDR_IPV_OTHER);
 		break;
+	case ICE_FLTR_PTYPE_FRAG_IPV6:
+		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6 |
+				  ICE_FLOW_SEG_HDR_IPV_FRAG);
+		break;
 	case ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN:
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP |
 				ICE_FLOW_SEG_HDR_IPV4 |
@@ -1599,8 +1612,10 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 	enum rte_flow_item_type l3 = RTE_FLOW_ITEM_TYPE_END;
 	enum ice_fdir_tunnel_type tunnel_type = ICE_FDIR_TUNNEL_TYPE_NONE;
 	const struct rte_flow_item_eth *eth_spec, *eth_mask;
-	const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_mask;
+	const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_last, *ipv4_mask;
 	const struct rte_flow_item_ipv6 *ipv6_spec, *ipv6_mask;
+	const struct rte_flow_item_ipv6_frag_ext *ipv6_frag_spec,
+					*ipv6_frag_last, *ipv6_frag_mask;
 	const struct rte_flow_item_tcp *tcp_spec, *tcp_mask;
 	const struct rte_flow_item_udp *udp_spec, *udp_mask;
 	const struct rte_flow_item_sctp *sctp_spec, *sctp_mask;
@@ -1639,13 +1654,14 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 	 * flow. input_set_i is used for inner part.
 	 */
 	for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
-		if (item->last) {
+		if (item->last && !(item_type == RTE_FLOW_ITEM_TYPE_IPV4 ||
+				    item_type ==
+				    RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT)) {
 			rte_flow_error_set(error, EINVAL,
-					   RTE_FLOW_ERROR_TYPE_ITEM,
-					   item,
+					   RTE_FLOW_ERROR_TYPE_ITEM, item,
 					   "Not support range");
-			return -rte_errno;
 		}
+
 		item_type = item->type;
 
 		input_set = (tunnel_type && !is_outer) ?
@@ -1696,6 +1712,7 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			flow_type = ICE_FLTR_PTYPE_NONF_IPV4_OTHER;
 			l3 = RTE_FLOW_ITEM_TYPE_IPV4;
 			ipv4_spec = item->spec;
+			ipv4_last = item->last;
 			ipv4_mask = item->mask;
 			p_v4 = (tunnel_type && is_outer) ?
 			       &filter->input.ip_outer.v4 :
@@ -1707,8 +1724,6 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			/* Check IPv4 mask and update input set */
 			if (ipv4_mask->hdr.version_ihl ||
 			    ipv4_mask->hdr.total_length ||
-			    ipv4_mask->hdr.packet_id ||
-			    ipv4_mask->hdr.fragment_offset ||
 			    ipv4_mask->hdr.hdr_checksum) {
 				rte_flow_error_set(error, EINVAL,
 						   RTE_FLOW_ERROR_TYPE_ITEM,
@@ -1717,6 +1732,21 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 				return -rte_errno;
 			}
 
+			if (ipv4_last &&
+			    (ipv4_last->hdr.version_ihl ||
+			     ipv4_last->hdr.type_of_service ||
+			     ipv4_last->hdr.time_to_live ||
+			     ipv4_last->hdr.total_length |
+			     ipv4_last->hdr.next_proto_id ||
+			     ipv4_last->hdr.hdr_checksum ||
+			     ipv4_last->hdr.src_addr ||
+			     ipv4_last->hdr.dst_addr)) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ITEM,
+						   item, "Invalid IPv4 last.");
+				return -rte_errno;
+			}
+
 			if (ipv4_mask->hdr.dst_addr == UINT32_MAX)
 				*input_set |= ICE_INSET_IPV4_DST;
 			if (ipv4_mask->hdr.src_addr == UINT32_MAX)
@@ -1733,6 +1763,32 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			p_v4->ttl = ipv4_spec->hdr.time_to_live;
 			p_v4->proto = ipv4_spec->hdr.next_proto_id;
 			p_v4->tos = ipv4_spec->hdr.type_of_service;
+
+			/* only support any packet id for fragment IPv4
+			 * any packet_id:
+			 * spec is 0, last is 0xffff, mask is 0xffff
+			 * fragment Ipv4:
+			 * spec is 0x2000, mask is 0xffff
+			 */
+			if (ipv4_last && ipv4_spec->hdr.packet_id == 0 &&
+			    ipv4_last->hdr.packet_id == UINT16_MAX &&
+			    ipv4_mask->hdr.packet_id == UINT16_MAX &&
+			    ipv4_spec->hdr.fragment_offset ==
+			    rte_cpu_to_be_16(RTE_IPV4_HDR_MF_FLAG) &&
+			    ipv4_mask->hdr.fragment_offset == UINT16_MAX) {
+				/* all IPv4 fragment packet has the same
+				 * ethertype, if the spec is for all valid
+				 * packet id, set ethertype into input set.
+				 */
+				*input_set |= ICE_INSET_ETHERTYPE;
+				input_set_o |= ICE_INSET_ETHERTYPE;
+			} else if (ipv4_mask->hdr.packet_id == UINT16_MAX) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ITEM,
+						   item, "Invalid IPv4 mask.");
+				return -rte_errno;
+			}
+
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV6:
 			flow_type = ICE_FLTR_PTYPE_NONF_IPV6_OTHER;
@@ -1778,6 +1834,43 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			p_v6->proto = ipv6_spec->hdr.proto;
 			p_v6->hlim = ipv6_spec->hdr.hop_limits;
 			break;
+		case RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT:
+			l3 = RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT;
+			flow_type = ICE_FLTR_PTYPE_FRAG_IPV6;
+			ipv6_frag_spec = item->spec;
+			ipv6_frag_last = item->last;
+			ipv6_frag_mask = item->mask;
+
+			if (!(ipv6_frag_spec && ipv6_frag_mask))
+				break;
+
+			/* only support any packet id for fragment IPv6
+			 * any packet_id:
+			 * spec is 0, last is 0xffffffff, mask is 0xffffffff
+			 * fragment Ipv6:
+			 * spec is 0x1, mask is 0xffff
+			 */
+			if (ipv6_frag_last && ipv6_frag_spec->hdr.id == 0 &&
+			    ipv6_frag_last->hdr.id == UINT32_MAX &&
+			    ipv6_frag_mask->hdr.id == UINT32_MAX &&
+			    ipv6_frag_spec->hdr.frag_data ==
+			    rte_cpu_to_be_16(1) &&
+			    ipv6_frag_mask->hdr.frag_data == UINT16_MAX) {
+				/* all IPv6 fragment packet has the same
+				 * ethertype, if the spec is for all valid
+				 * packet id, set ethertype into input set.
+				 */
+				*input_set |= ICE_INSET_ETHERTYPE;
+				input_set_o |= ICE_INSET_ETHERTYPE;
+			} else if (ipv6_frag_mask->hdr.id == UINT32_MAX) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ITEM,
+						   item, "Invalid IPv6 mask.");
+				return -rte_errno;
+			}
+
+			break;
+
 		case RTE_FLOW_ITEM_TYPE_TCP:
 			if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
 				flow_type = ICE_FLTR_PTYPE_NONF_IPV4_TCP;
@@ -2016,7 +2109,8 @@ ice_fdir_parse(struct ice_adapter *ad,
 	if (ret)
 		goto error;
 	input_set = filter->input_set_o | filter->input_set_i;
-	if (!input_set || filter->input_set_o & ~item->input_set_mask_o ||
+	if (!input_set || filter->input_set_o &
+	    ~(item->input_set_mask_o | ICE_INSET_ETHERTYPE) ||
 	    filter->input_set_i & ~item->input_set_mask_i) {
 		rte_flow_error_set(error, EINVAL,
 				   RTE_FLOW_ERROR_TYPE_ITEM_SPEC,
diff --git a/drivers/net/ice/ice_generic_flow.c b/drivers/net/ice/ice_generic_flow.c
index 2389bc6637..7a34a51600 100644
--- a/drivers/net/ice/ice_generic_flow.c
+++ b/drivers/net/ice/ice_generic_flow.c
@@ -2108,6 +2108,7 @@ static struct ice_ptype_match ice_ptype_map[] = {
 	{pattern_eth_ipv6_udp,				ICE_PTYPE_IPV6_UDP_PAY},
 	{pattern_eth_ipv6_tcp,				ICE_PTYPE_IPV6_TCP_PAY},
 	{pattern_eth_ipv6_sctp,				ICE_PTYPE_IPV6_SCTP_PAY},
+	{pattern_eth_ipv6_frag_ext,			ICE_PTYPE_IPV6FRAG_PAY},
 	{pattern_eth_ipv6_gtpu,				ICE_MAC_IPV6_GTPU},
 	{pattern_eth_ipv6_gtpu_eh,			ICE_MAC_IPV6_GTPU},
 	{pattern_eth_ipv6_gtpu_ipv4,			ICE_MAC_IPV6_GTPU_IPV4_PAY},
-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [dpdk-dev] [PATCH v4 0/3] support flow for IP fragment in ICE
  2021-04-13  8:48   ` [dpdk-dev] [PATCH v4 0/3] support flow for IP fragment in ICE Jeff Guo
                       ` (2 preceding siblings ...)
  2021-04-13  8:48     ` [dpdk-dev] [PATCH v4 3/3] net/ice: support FDIR for IP fragment packet Jeff Guo
@ 2021-04-13  9:02     ` Xu, Ting
  3 siblings, 0 replies; 42+ messages in thread
From: Xu, Ting @ 2021-04-13  9:02 UTC (permalink / raw)
  To: Guo, Jia, Zhang, Qi Z, Yang, Qiming; +Cc: dev



Best Regards,
Xu Ting

> -----Original Message-----
> From: Guo, Jia <jia.guo@intel.com>
> Sent: Tuesday, April 13, 2021 4:48 PM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>
> Cc: dev@dpdk.org; Xu, Ting <ting.xu@intel.com>; Guo, Jia <jia.guo@intel.com>
> Subject: [PATCH v4 0/3] support flow for IP fragment in ICE
> 
> Support RSS hash and FDIR for IP fragment packets in ICE PMD.
> 
> v4:
> correct typo when define fragment
> v3:
> rebase code and fix some parsing issues.
> v2:
> add some input check
> 
> Jeff Guo (3):
>   net/ice/base: support IP fragment RSS and FDIR
>   net/ice: support RSS hash for IP fragment
>   net/ice: support FDIR for IP fragment packet
> 
>  drivers/net/ice/base/ice_fdir.c    |  50 ++++++++++++-
>  drivers/net/ice/base/ice_fdir.h    |  22 +++++-
>  drivers/net/ice/base/ice_flow.c    |  50 ++++++++++++-
>  drivers/net/ice/base/ice_flow.h    |   5 +-
>  drivers/net/ice/base/ice_type.h    |   1 +
>  drivers/net/ice/ice_fdir_filter.c  | 116 ++++++++++++++++++++++++++---
> drivers/net/ice/ice_generic_flow.c |  22 ++++++
>  drivers/net/ice/ice_generic_flow.h |   6 ++
>  drivers/net/ice/ice_hash.c         |  48 ++++++++++--
>  9 files changed, 293 insertions(+), 27 deletions(-)
> 
> --
> 2.20.1

Reviewed-by: Ting Xu <ting.xu@intel.com>

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v5 0/3] support flow for IP fragment in ICE
  2021-03-24 13:54 ` [dpdk-dev] [PATCH v2 0/3] support flow for IP fragment in ICE Jeff Guo
                     ` (6 preceding siblings ...)
  2021-04-13  8:48   ` [dpdk-dev] [PATCH v4 0/3] support flow for IP fragment in ICE Jeff Guo
@ 2021-04-13  9:38   ` Jeff Guo
  2021-04-13  9:38     ` [dpdk-dev] [PATCH v5 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
                       ` (3 more replies)
  2021-04-13 10:06   ` [dpdk-dev] [PATCH v6 " Jeff Guo
  8 siblings, 4 replies; 42+ messages in thread
From: Jeff Guo @ 2021-04-13  9:38 UTC (permalink / raw)
  To: qi.z.zhang, qiming.yang; +Cc: dev, ting.xu, jia.guo

Support RSS hash and FDIR for IP fragment packets in ICE PMD.

v5:
rebase code.
v4:
correct typo when define fragment
v3:
rebase code and fix some parsing issues.
v2:
add some input check

Jeff Guo (3):
  net/ice/base: support IP fragment RSS and FDIR
  net/ice: support RSS hash for IP fragment
  net/ice: support FDIR for IP fragment packet

 drivers/net/ice/base/ice_fdir.c    |  50 ++++++++++++-
 drivers/net/ice/base/ice_fdir.h    |  22 +++++-
 drivers/net/ice/base/ice_flow.c    |  50 ++++++++++++-
 drivers/net/ice/base/ice_flow.h    |   9 ++-
 drivers/net/ice/base/ice_type.h    |   1 +
 drivers/net/ice/ice_fdir_filter.c  | 116 ++++++++++++++++++++++++++---
 drivers/net/ice/ice_generic_flow.c |  22 ++++++
 drivers/net/ice/ice_generic_flow.h |   6 ++
 drivers/net/ice/ice_hash.c         |  46 ++++++++++--
 9 files changed, 293 insertions(+), 29 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v5 1/3] net/ice/base: support IP fragment RSS and FDIR
  2021-04-13  9:38   ` [dpdk-dev] [PATCH v5 " Jeff Guo
@ 2021-04-13  9:38     ` Jeff Guo
  2021-04-13  9:38     ` [dpdk-dev] [PATCH v5 2/3] net/ice: support RSS hash for IP fragment Jeff Guo
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 42+ messages in thread
From: Jeff Guo @ 2021-04-13  9:38 UTC (permalink / raw)
  To: qi.z.zhang, qiming.yang; +Cc: dev, ting.xu, jia.guo

Add support for IP fragment RSS hash and FDIR according to packet ID.
Separate IP fragment and IP other packet types.

Signed-off-by: Ting Xu <ting.xu@intel.com>
Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
 drivers/net/ice/base/ice_fdir.c | 50 +++++++++++++++++++++++++++++++--
 drivers/net/ice/base/ice_fdir.h | 22 ++++++++++++---
 drivers/net/ice/base/ice_flow.c | 50 ++++++++++++++++++++++++++++++++-
 drivers/net/ice/base/ice_flow.h |  9 ++++--
 drivers/net/ice/base/ice_type.h |  1 +
 5 files changed, 122 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ice/base/ice_fdir.c b/drivers/net/ice/base/ice_fdir.c
index 8f9c0d346b..c1b14783ac 100644
--- a/drivers/net/ice/base/ice_fdir.c
+++ b/drivers/net/ice/base/ice_fdir.c
@@ -518,6 +518,24 @@ 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 +734,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),
@@ -1505,7 +1533,7 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
 		ice_pkt_insert_u8(loc, ICE_IPV4_TTL_OFFSET, input->ip.v4.ttl);
 		ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
 		if (frag)
-			loc[20] = ICE_FDIR_IPV4_PKT_FLAG_DF;
+			loc[20] = ICE_FDIR_IPV4_PKT_FLAG_MF;
 		break;
 	case ICE_FLTR_PTYPE_NONF_IPV4_UDP:
 		ice_pkt_insert_mac_addr(pkt, input->ext_data_outer.dst_mac);
@@ -1808,6 +1836,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 +1883,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;
diff --git a/drivers/net/ice/base/ice_fdir.h b/drivers/net/ice/base/ice_fdir.h
index 6573f96bc1..2acc1d6f1b 100644
--- a/drivers/net/ice/base/ice_fdir.h
+++ b/drivers/net/ice/base/ice_fdir.h
@@ -43,9 +43,11 @@
 #define ICE_MAC_ETHTYPE_OFFSET		12
 #define ICE_IPV4_TOS_OFFSET		15
 #define ICE_IPV4_TTL_OFFSET		22
+#define ICE_IPV4_ID_OFFSET		18
 #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
@@ -83,12 +85,22 @@
 
 #define ICE_FDIR_MAX_FLTRS		16384
 
-/* IP v4 has 2 flag bits that enable fragment processing: DF and MF. DF
+/* IPv4 has 2 flag bits that enable fragment processing: DF and MF. DF
  * requests that the packet not be fragmented. MF indicates that a packet has
- * been fragmented.
+ * been fragmented, except that for the last fragment has a non-zero
+ * Fragment Offset field with zero MF.
  */
-#define ICE_FDIR_IPV4_PKT_FLAG_DF		0x20
-#define ICE_FDIR_IPV4_PKT_FLAG_MF		0x40
+#define ICE_FDIR_IPV4_PKT_FLAG_MF		0x20
+#define ICE_FDIR_IPV4_PKT_FLAG_MF_SHIFT	8
+#ifndef NO_UNUSED_PACKAGE_CODE
+#define ICE_FDIR_IPV4_PKT_FLAG_DF		0x40
+#endif /* NO_UNUSED_PACKAGE_CODE */
+
+/* For IPv6 fragmented packets, all fragments except the last have
+ * the MF flag set.
+ */
+#define ICE_FDIR_IPV6_PKT_FLAG_MF		0x100
+#define ICE_FDIR_IPV6_PKT_FLAG_MF_SHIFT	8
 
 enum ice_fltr_prgm_desc_dest {
 	ICE_FLTR_PRGM_DESC_DEST_DROP_PKT,
@@ -150,6 +162,7 @@ struct ice_fdir_v4 {
 	u8 ip_ver;
 	u8 proto;
 	u8 ttl;
+	__be16 packet_id;
 };
 
 #define ICE_IPV6_ADDR_LEN_AS_U32		4
@@ -164,6 +177,7 @@ struct ice_fdir_v6 {
 	u8 tc;
 	u8 proto;
 	u8 hlim;
+	__be32 packet_id;
 };
 
 struct ice_fdir_udp_gtp {
diff --git a/drivers/net/ice/base/ice_flow.c b/drivers/net/ice/base/ice_flow.c
index e37f7ae524..2c60270140 100644
--- a/drivers/net/ice/base/ice_flow.c
+++ b/drivers/net/ice/base/ice_flow.c
@@ -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,27 @@ 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 +951,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 +1249,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 +1262,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 +3474,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);
diff --git a/drivers/net/ice/base/ice_flow.h b/drivers/net/ice/base/ice_flow.h
index 448e06028a..878c79d19e 100644
--- a/drivers/net/ice/base/ice_flow.h
+++ b/drivers/net/ice/base/ice_flow.h
@@ -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,
diff --git a/drivers/net/ice/base/ice_type.h b/drivers/net/ice/base/ice_type.h
index 3c534a7711..a6988d962c 100644
--- a/drivers/net/ice/base/ice_type.h
+++ b/drivers/net/ice/base/ice_type.h
@@ -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,
-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v5 2/3] net/ice: support RSS hash for IP fragment
  2021-04-13  9:38   ` [dpdk-dev] [PATCH v5 " Jeff Guo
  2021-04-13  9:38     ` [dpdk-dev] [PATCH v5 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
@ 2021-04-13  9:38     ` Jeff Guo
  2021-04-13  9:38     ` [dpdk-dev] [PATCH v5 3/3] net/ice: support FDIR for IP fragment packet Jeff Guo
  2021-04-13  9:46     ` [dpdk-dev] [PATCH v5 0/3] support flow for IP fragment in ICE Xu, Ting
  3 siblings, 0 replies; 42+ messages in thread
From: Jeff Guo @ 2021-04-13  9:38 UTC (permalink / raw)
  To: qi.z.zhang, qiming.yang; +Cc: dev, ting.xu, jia.guo

New pattern and RSS hash flow parsing are added to handle fragmented
IPv4/IPv6  packet.

Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
 drivers/net/ice/ice_generic_flow.c | 21 ++++++++++++++
 drivers/net/ice/ice_generic_flow.h |  6 ++++
 drivers/net/ice/ice_hash.c         | 46 ++++++++++++++++++++++++------
 3 files changed, 65 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ice/ice_generic_flow.c b/drivers/net/ice/ice_generic_flow.c
index 8704812622..2389bc6637 100644
--- a/drivers/net/ice/ice_generic_flow.c
+++ b/drivers/net/ice/ice_generic_flow.c
@@ -212,6 +212,27 @@ enum rte_flow_item_type pattern_eth_qinq_ipv6[] = {
 	RTE_FLOW_ITEM_TYPE_IPV6,
 	RTE_FLOW_ITEM_TYPE_END,
 };
+enum rte_flow_item_type pattern_eth_ipv6_frag_ext[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+enum rte_flow_item_type pattern_eth_vlan_ipv6_frag_ext[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_VLAN,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+enum rte_flow_item_type pattern_eth_qinq_ipv6_frag_ext[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_VLAN,
+	RTE_FLOW_ITEM_TYPE_VLAN,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+	RTE_FLOW_ITEM_TYPE_END,
+};
 enum rte_flow_item_type pattern_eth_ipv6_udp[] = {
 	RTE_FLOW_ITEM_TYPE_ETH,
 	RTE_FLOW_ITEM_TYPE_IPV6,
diff --git a/drivers/net/ice/ice_generic_flow.h b/drivers/net/ice/ice_generic_flow.h
index 9f422e5925..2afe719264 100644
--- a/drivers/net/ice/ice_generic_flow.h
+++ b/drivers/net/ice/ice_generic_flow.h
@@ -52,6 +52,7 @@
 #define ICE_L2TPV3OIP_SESSION_ID	BIT_ULL(43)
 #define ICE_PFCP_SEID			BIT_ULL(42)
 #define ICE_PFCP_S_FIELD		BIT_ULL(41)
+#define ICE_IP_PK_ID		    BIT_ULL(40)
 
 /* input set */
 
@@ -69,11 +70,13 @@
 #define ICE_INSET_IPV4_TOS		(ICE_PROT_IPV4 | ICE_IP_TOS)
 #define ICE_INSET_IPV4_PROTO		(ICE_PROT_IPV4 | ICE_IP_PROTO)
 #define ICE_INSET_IPV4_TTL		(ICE_PROT_IPV4 | ICE_IP_TTL)
+#define ICE_INSET_IPV4_PKID		(ICE_PROT_IPV4 | ICE_IP_PK_ID)
 #define ICE_INSET_IPV6_SRC		(ICE_PROT_IPV6 | ICE_IP_SRC)
 #define ICE_INSET_IPV6_DST		(ICE_PROT_IPV6 | ICE_IP_DST)
 #define ICE_INSET_IPV6_NEXT_HDR		(ICE_PROT_IPV6 | ICE_IP_PROTO)
 #define ICE_INSET_IPV6_HOP_LIMIT	(ICE_PROT_IPV6 | ICE_IP_TTL)
 #define ICE_INSET_IPV6_TC		(ICE_PROT_IPV6 | ICE_IP_TOS)
+#define ICE_INSET_IPV6_PKID		(ICE_PROT_IPV6 | ICE_IP_PK_ID)
 
 #define ICE_INSET_TCP_SRC_PORT		(ICE_PROT_TCP | ICE_SPORT)
 #define ICE_INSET_TCP_DST_PORT		(ICE_PROT_TCP | ICE_DPORT)
@@ -202,6 +205,9 @@ extern enum rte_flow_item_type pattern_eth_qinq_ipv4_icmp[];
 extern enum rte_flow_item_type pattern_eth_ipv6[];
 extern enum rte_flow_item_type pattern_eth_vlan_ipv6[];
 extern enum rte_flow_item_type pattern_eth_qinq_ipv6[];
+extern enum rte_flow_item_type pattern_eth_ipv6_frag_ext[];
+extern enum rte_flow_item_type pattern_eth_vlan_ipv6_frag_ext[];
+extern enum rte_flow_item_type pattern_eth_qinq_ipv6_frag_ext[];
 extern enum rte_flow_item_type pattern_eth_ipv6_udp[];
 extern enum rte_flow_item_type pattern_eth_vlan_ipv6_udp[];
 extern enum rte_flow_item_type pattern_eth_qinq_ipv6_udp[];
diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c
index e56cdf9941..75b6947625 100644
--- a/drivers/net/ice/ice_hash.c
+++ b/drivers/net/ice/ice_hash.c
@@ -47,8 +47,10 @@
 				 ETH_RSS_NONFRAG_IPV6_TCP	| \
 				 ETH_RSS_NONFRAG_IPV6_SCTP)
 
-#define VALID_RSS_IPV4		(ETH_RSS_IPV4 | VALID_RSS_IPV4_L4)
-#define VALID_RSS_IPV6		(ETH_RSS_IPV6 | VALID_RSS_IPV6_L4)
+#define VALID_RSS_IPV4		(ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 | \
+				 VALID_RSS_IPV4_L4)
+#define VALID_RSS_IPV6		(ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 | \
+				 VALID_RSS_IPV6_L4)
 #define VALID_RSS_L3		(VALID_RSS_IPV4 | VALID_RSS_IPV6)
 #define VALID_RSS_L4		(VALID_RSS_IPV4_L4 | VALID_RSS_IPV6_L4)
 
@@ -108,6 +110,7 @@ ice_hash_parse_pattern_action(struct ice_adapter *ad,
 /* Rss configuration template */
 struct ice_rss_hash_cfg ipv4_tmplt = {
 	ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV4 |
+	ICE_FLOW_SEG_HDR_IPV_FRAG |
 	ICE_FLOW_SEG_HDR_IPV_OTHER,
 	ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_IPV4,
 	ICE_RSS_OUTER_HEADERS,
@@ -146,6 +149,15 @@ struct ice_rss_hash_cfg ipv6_tmplt = {
 	0
 };
 
+struct ice_rss_hash_cfg ipv6_frag_tmplt = {
+	ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV6 |
+	ICE_FLOW_SEG_HDR_IPV_FRAG |
+	ICE_FLOW_SEG_HDR_IPV_OTHER,
+	ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_IPV6,
+	ICE_RSS_ANY_HEADERS,
+	0
+};
+
 struct ice_rss_hash_cfg ipv6_udp_tmplt = {
 	ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV6 |
 	ICE_FLOW_SEG_HDR_IPV_OTHER | ICE_FLOW_SEG_HDR_UDP,
@@ -198,6 +210,7 @@ struct ice_rss_hash_cfg outer_ipv6_inner_ipv4_tmplt = {
 	ICE_RSS_INNER_HEADERS_W_OUTER_IPV6,
 	0
 };
+
 struct ice_rss_hash_cfg outer_ipv6_inner_ipv4_udp_tmplt = {
 	ICE_FLOW_SEG_HDR_IPV4 | ICE_FLOW_SEG_HDR_IPV_OTHER |
 	ICE_FLOW_SEG_HDR_UDP,
@@ -220,6 +233,7 @@ struct ice_rss_hash_cfg outer_ipv4_inner_ipv6_tmplt = {
 	ICE_RSS_INNER_HEADERS_W_OUTER_IPV4,
 	0
 };
+
 struct ice_rss_hash_cfg outer_ipv4_inner_ipv6_udp_tmplt = {
 	ICE_FLOW_SEG_HDR_IPV6 | ICE_FLOW_SEG_HDR_IPV_OTHER |
 	ICE_FLOW_SEG_HDR_UDP,
@@ -353,7 +367,8 @@ struct ice_rss_hash_cfg empty_tmplt = {
 };
 
 /* IPv4 */
-#define ICE_RSS_TYPE_ETH_IPV4		(ETH_RSS_ETH | ETH_RSS_IPV4)
+#define ICE_RSS_TYPE_ETH_IPV4		(ETH_RSS_ETH | ETH_RSS_IPV4 | \
+					 ETH_RSS_FRAG_IPV4)
 #define ICE_RSS_TYPE_ETH_IPV4_UDP	(ICE_RSS_TYPE_ETH_IPV4 | \
 					 ETH_RSS_NONFRAG_IPV4_UDP)
 #define ICE_RSS_TYPE_ETH_IPV4_TCP	(ICE_RSS_TYPE_ETH_IPV4 | \
@@ -370,6 +385,8 @@ struct ice_rss_hash_cfg empty_tmplt = {
 
 /* IPv6 */
 #define ICE_RSS_TYPE_ETH_IPV6		(ETH_RSS_ETH | ETH_RSS_IPV6)
+#define ICE_RSS_TYPE_ETH_IPV6_FRAG	(ETH_RSS_ETH | ETH_RSS_IPV6 | \
+					 ETH_RSS_FRAG_IPV6)
 #define ICE_RSS_TYPE_ETH_IPV6_UDP	(ICE_RSS_TYPE_ETH_IPV6 | \
 					 ETH_RSS_NONFRAG_IPV6_UDP)
 #define ICE_RSS_TYPE_ETH_IPV6_TCP	(ICE_RSS_TYPE_ETH_IPV6 | \
@@ -386,7 +403,8 @@ struct ice_rss_hash_cfg empty_tmplt = {
 
 /* VLAN IPV4 */
 #define ICE_RSS_TYPE_VLAN_IPV4		(ICE_RSS_TYPE_IPV4 | \
-					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
+					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN | \
+					 ETH_RSS_FRAG_IPV4)
 #define ICE_RSS_TYPE_VLAN_IPV4_UDP	(ICE_RSS_TYPE_IPV4_UDP | \
 					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
 #define ICE_RSS_TYPE_VLAN_IPV4_TCP	(ICE_RSS_TYPE_IPV4_TCP | \
@@ -396,6 +414,9 @@ struct ice_rss_hash_cfg empty_tmplt = {
 /* VLAN IPv6 */
 #define ICE_RSS_TYPE_VLAN_IPV6		(ICE_RSS_TYPE_IPV6 | \
 					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
+#define ICE_RSS_TYPE_VLAN_IPV6_FRAG	(ICE_RSS_TYPE_IPV6 | \
+					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN | \
+					 ETH_RSS_FRAG_IPV6)
 #define ICE_RSS_TYPE_VLAN_IPV6_UDP	(ICE_RSS_TYPE_IPV6_UDP | \
 					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
 #define ICE_RSS_TYPE_VLAN_IPV6_TCP	(ICE_RSS_TYPE_IPV6_TCP | \
@@ -485,10 +506,12 @@ static struct ice_pattern_match_item ice_hash_pattern_list[] = {
 	{pattern_eth_ipv4_pfcp,			ICE_RSS_TYPE_IPV4_PFCP,		ICE_INSET_NONE,	&eth_ipv4_pfcp_tmplt},
 	/* IPV6 */
 	{pattern_eth_ipv6,			ICE_RSS_TYPE_ETH_IPV6,		ICE_INSET_NONE,	&ipv6_tmplt},
+	{pattern_eth_ipv6_frag_ext,		ICE_RSS_TYPE_ETH_IPV6_FRAG,	ICE_INSET_NONE,	&ipv6_frag_tmplt},
 	{pattern_eth_ipv6_udp,			ICE_RSS_TYPE_ETH_IPV6_UDP,	ICE_INSET_NONE,	&ipv6_udp_tmplt},
 	{pattern_eth_ipv6_tcp,			ICE_RSS_TYPE_ETH_IPV6_TCP,	ICE_INSET_NONE,	&ipv6_tcp_tmplt},
 	{pattern_eth_ipv6_sctp,			ICE_RSS_TYPE_ETH_IPV6_SCTP,	ICE_INSET_NONE,	&ipv6_sctp_tmplt},
 	{pattern_eth_vlan_ipv6,			ICE_RSS_TYPE_VLAN_IPV6,		ICE_INSET_NONE,	&ipv6_tmplt},
+	{pattern_eth_vlan_ipv6_frag_ext,	ICE_RSS_TYPE_VLAN_IPV6_FRAG,	ICE_INSET_NONE, &ipv6_frag_tmplt},
 	{pattern_eth_vlan_ipv6_udp,		ICE_RSS_TYPE_VLAN_IPV6_UDP,	ICE_INSET_NONE,	&ipv6_udp_tmplt},
 	{pattern_eth_vlan_ipv6_tcp,		ICE_RSS_TYPE_VLAN_IPV6_TCP,	ICE_INSET_NONE,	&ipv6_tcp_tmplt},
 	{pattern_eth_vlan_ipv6_sctp,		ICE_RSS_TYPE_VLAN_IPV6_SCTP,	ICE_INSET_NONE,	&ipv6_sctp_tmplt},
@@ -629,11 +652,14 @@ ice_refine_hash_cfg_l234(struct ice_rss_hash_cfg *hash_cfg,
 
 	if (*addl_hdrs & ICE_FLOW_SEG_HDR_IPV4) {
 		if (rss_type &
-		   (ETH_RSS_IPV4 |
+		   (ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 |
 		    ETH_RSS_NONFRAG_IPV4_UDP |
 		    ETH_RSS_NONFRAG_IPV4_TCP |
 		    ETH_RSS_NONFRAG_IPV4_SCTP)) {
-			if (rss_type & ETH_RSS_L3_SRC_ONLY)
+			if (rss_type & ETH_RSS_FRAG_IPV4)
+				*hash_flds &=
+					~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_ID));
+			else if (rss_type & ETH_RSS_L3_SRC_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA));
 			else if (rss_type & ETH_RSS_L3_DST_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA));
@@ -648,11 +674,14 @@ ice_refine_hash_cfg_l234(struct ice_rss_hash_cfg *hash_cfg,
 
 	if (*addl_hdrs & ICE_FLOW_SEG_HDR_IPV6) {
 		if (rss_type &
-		   (ETH_RSS_IPV6 |
+		   (ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 |
 		    ETH_RSS_NONFRAG_IPV6_UDP |
 		    ETH_RSS_NONFRAG_IPV6_TCP |
 		    ETH_RSS_NONFRAG_IPV6_SCTP)) {
-			if (rss_type & ETH_RSS_L3_SRC_ONLY)
+			if (rss_type & ETH_RSS_FRAG_IPV6)
+				*hash_flds &=
+					~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_ID));
+			else if (rss_type & ETH_RSS_L3_SRC_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA));
 			else if (rss_type & ETH_RSS_L3_DST_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA));
@@ -867,6 +896,7 @@ ice_any_invalid_rss_type(enum rte_eth_hash_function rss_func,
 
 		if (!(rss_type &
 		   (ETH_RSS_IPV4 | ETH_RSS_IPV6 |
+		    ETH_RSS_FRAG_IPV4 | ETH_RSS_FRAG_IPV6 |
 		    ETH_RSS_NONFRAG_IPV4_UDP | ETH_RSS_NONFRAG_IPV6_UDP |
 		    ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_NONFRAG_IPV6_TCP |
 		    ETH_RSS_NONFRAG_IPV4_SCTP | ETH_RSS_NONFRAG_IPV6_SCTP)))
-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v5 3/3] net/ice: support FDIR for IP fragment packet
  2021-04-13  9:38   ` [dpdk-dev] [PATCH v5 " Jeff Guo
  2021-04-13  9:38     ` [dpdk-dev] [PATCH v5 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
  2021-04-13  9:38     ` [dpdk-dev] [PATCH v5 2/3] net/ice: support RSS hash for IP fragment Jeff Guo
@ 2021-04-13  9:38     ` Jeff Guo
  2021-04-13  9:46     ` [dpdk-dev] [PATCH v5 0/3] support flow for IP fragment in ICE Xu, Ting
  3 siblings, 0 replies; 42+ messages in thread
From: Jeff Guo @ 2021-04-13  9:38 UTC (permalink / raw)
  To: qi.z.zhang, qiming.yang; +Cc: dev, ting.xu, jia.guo

New FDIR parsing are added to handle the fragmented IPv4/IPv6 packet.

Signed-off-by: Jeff Guo <jia.guo@intel.com>
Signed-off-by: Ting Xu <ting.xu@intel.com>
---
 drivers/net/ice/ice_fdir_filter.c  | 116 ++++++++++++++++++++++++++---
 drivers/net/ice/ice_generic_flow.c |   1 +
 2 files changed, 106 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
index 92e18d59cc..8158f75f05 100644
--- a/drivers/net/ice/ice_fdir_filter.c
+++ b/drivers/net/ice/ice_fdir_filter.c
@@ -24,7 +24,7 @@
 #define ICE_FDIR_INSET_ETH_IPV4 (\
 	ICE_FDIR_INSET_ETH | \
 	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | ICE_INSET_IPV4_TOS | \
-	ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO)
+	ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO | ICE_INSET_IPV4_PKID)
 
 #define ICE_FDIR_INSET_ETH_IPV4_UDP (\
 	ICE_FDIR_INSET_ETH_IPV4 | \
@@ -41,7 +41,8 @@
 #define ICE_FDIR_INSET_ETH_IPV6 (\
 	ICE_INSET_DMAC | \
 	ICE_INSET_IPV6_SRC | ICE_INSET_IPV6_DST | ICE_INSET_IPV6_TC | \
-	ICE_INSET_IPV6_HOP_LIMIT | ICE_INSET_IPV6_NEXT_HDR)
+	ICE_INSET_IPV6_HOP_LIMIT | ICE_INSET_IPV6_NEXT_HDR | \
+	ICE_INSET_IPV6_PKID)
 
 #define ICE_FDIR_INSET_ETH_IPV6_UDP (\
 	ICE_FDIR_INSET_ETH_IPV6 | \
@@ -56,7 +57,8 @@
 	ICE_INSET_SCTP_SRC_PORT | ICE_INSET_SCTP_DST_PORT)
 
 #define ICE_FDIR_INSET_IPV4 (\
-	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST)
+	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | \
+	ICE_INSET_IPV4_PKID)
 
 #define ICE_FDIR_INSET_IPV4_TCP (\
 	ICE_FDIR_INSET_IPV4 | \
@@ -95,6 +97,7 @@ static struct ice_pattern_match_item ice_fdir_pattern_list[] = {
 	{pattern_eth_ipv4_tcp,				ICE_FDIR_INSET_ETH_IPV4_TCP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv4_sctp,				ICE_FDIR_INSET_ETH_IPV4_SCTP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6,				ICE_FDIR_INSET_ETH_IPV6,	ICE_INSET_NONE,			ICE_INSET_NONE},
+	{pattern_eth_ipv6_frag_ext,			ICE_FDIR_INSET_ETH_IPV6,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6_udp,				ICE_FDIR_INSET_ETH_IPV6_UDP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6_tcp,				ICE_FDIR_INSET_ETH_IPV6_TCP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6_sctp,				ICE_FDIR_INSET_ETH_IPV6_SCTP,	ICE_INSET_NONE,			ICE_INSET_NONE},
@@ -882,11 +885,13 @@ ice_fdir_input_set_parse(uint64_t inset, enum ice_flow_field *field)
 		{ICE_INSET_IPV4_TOS, ICE_FLOW_FIELD_IDX_IPV4_DSCP},
 		{ICE_INSET_IPV4_TTL, ICE_FLOW_FIELD_IDX_IPV4_TTL},
 		{ICE_INSET_IPV4_PROTO, ICE_FLOW_FIELD_IDX_IPV4_PROT},
+		{ICE_INSET_IPV4_PKID, ICE_FLOW_FIELD_IDX_IPV4_ID},
 		{ICE_INSET_IPV6_SRC, ICE_FLOW_FIELD_IDX_IPV6_SA},
 		{ICE_INSET_IPV6_DST, ICE_FLOW_FIELD_IDX_IPV6_DA},
 		{ICE_INSET_IPV6_TC, ICE_FLOW_FIELD_IDX_IPV6_DSCP},
 		{ICE_INSET_IPV6_NEXT_HDR, ICE_FLOW_FIELD_IDX_IPV6_PROT},
 		{ICE_INSET_IPV6_HOP_LIMIT, ICE_FLOW_FIELD_IDX_IPV6_TTL},
+		{ICE_INSET_IPV6_PKID, ICE_FLOW_FIELD_IDX_IPV6_ID},
 		{ICE_INSET_TCP_SRC_PORT, ICE_FLOW_FIELD_IDX_TCP_SRC_PORT},
 		{ICE_INSET_TCP_DST_PORT, ICE_FLOW_FIELD_IDX_TCP_DST_PORT},
 		{ICE_INSET_UDP_SRC_PORT, ICE_FLOW_FIELD_IDX_UDP_SRC_PORT},
@@ -936,6 +941,10 @@ ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct ice_flow_seg_info *seg)
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4 |
 				  ICE_FLOW_SEG_HDR_IPV_OTHER);
 		break;
+	case ICE_FLTR_PTYPE_FRAG_IPV4:
+		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4 |
+				  ICE_FLOW_SEG_HDR_IPV_FRAG);
+		break;
 	case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP |
 				  ICE_FLOW_SEG_HDR_IPV6 |
@@ -955,6 +964,10 @@ ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct ice_flow_seg_info *seg)
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6 |
 				  ICE_FLOW_SEG_HDR_IPV_OTHER);
 		break;
+	case ICE_FLTR_PTYPE_FRAG_IPV6:
+		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6 |
+				  ICE_FLOW_SEG_HDR_IPV_FRAG);
+		break;
 	case ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN:
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP |
 				ICE_FLOW_SEG_HDR_IPV4 |
@@ -1599,8 +1612,10 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 	enum rte_flow_item_type l3 = RTE_FLOW_ITEM_TYPE_END;
 	enum ice_fdir_tunnel_type tunnel_type = ICE_FDIR_TUNNEL_TYPE_NONE;
 	const struct rte_flow_item_eth *eth_spec, *eth_mask;
-	const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_mask;
+	const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_last, *ipv4_mask;
 	const struct rte_flow_item_ipv6 *ipv6_spec, *ipv6_mask;
+	const struct rte_flow_item_ipv6_frag_ext *ipv6_frag_spec,
+					*ipv6_frag_last, *ipv6_frag_mask;
 	const struct rte_flow_item_tcp *tcp_spec, *tcp_mask;
 	const struct rte_flow_item_udp *udp_spec, *udp_mask;
 	const struct rte_flow_item_sctp *sctp_spec, *sctp_mask;
@@ -1639,13 +1654,14 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 	 * flow. input_set_i is used for inner part.
 	 */
 	for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
-		if (item->last) {
+		if (item->last && !(item_type == RTE_FLOW_ITEM_TYPE_IPV4 ||
+				    item_type ==
+				    RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT)) {
 			rte_flow_error_set(error, EINVAL,
-					   RTE_FLOW_ERROR_TYPE_ITEM,
-					   item,
+					   RTE_FLOW_ERROR_TYPE_ITEM, item,
 					   "Not support range");
-			return -rte_errno;
 		}
+
 		item_type = item->type;
 
 		input_set = (tunnel_type && !is_outer) ?
@@ -1696,6 +1712,7 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			flow_type = ICE_FLTR_PTYPE_NONF_IPV4_OTHER;
 			l3 = RTE_FLOW_ITEM_TYPE_IPV4;
 			ipv4_spec = item->spec;
+			ipv4_last = item->last;
 			ipv4_mask = item->mask;
 			p_v4 = (tunnel_type && is_outer) ?
 			       &filter->input.ip_outer.v4 :
@@ -1707,8 +1724,6 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			/* Check IPv4 mask and update input set */
 			if (ipv4_mask->hdr.version_ihl ||
 			    ipv4_mask->hdr.total_length ||
-			    ipv4_mask->hdr.packet_id ||
-			    ipv4_mask->hdr.fragment_offset ||
 			    ipv4_mask->hdr.hdr_checksum) {
 				rte_flow_error_set(error, EINVAL,
 						   RTE_FLOW_ERROR_TYPE_ITEM,
@@ -1717,6 +1732,21 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 				return -rte_errno;
 			}
 
+			if (ipv4_last &&
+			    (ipv4_last->hdr.version_ihl ||
+			     ipv4_last->hdr.type_of_service ||
+			     ipv4_last->hdr.time_to_live ||
+			     ipv4_last->hdr.total_length |
+			     ipv4_last->hdr.next_proto_id ||
+			     ipv4_last->hdr.hdr_checksum ||
+			     ipv4_last->hdr.src_addr ||
+			     ipv4_last->hdr.dst_addr)) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ITEM,
+						   item, "Invalid IPv4 last.");
+				return -rte_errno;
+			}
+
 			if (ipv4_mask->hdr.dst_addr == UINT32_MAX)
 				*input_set |= ICE_INSET_IPV4_DST;
 			if (ipv4_mask->hdr.src_addr == UINT32_MAX)
@@ -1733,6 +1763,32 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			p_v4->ttl = ipv4_spec->hdr.time_to_live;
 			p_v4->proto = ipv4_spec->hdr.next_proto_id;
 			p_v4->tos = ipv4_spec->hdr.type_of_service;
+
+			/* only support any packet id for fragment IPv4
+			 * any packet_id:
+			 * spec is 0, last is 0xffff, mask is 0xffff
+			 * fragment Ipv4:
+			 * spec is 0x2000, mask is 0xffff
+			 */
+			if (ipv4_last && ipv4_spec->hdr.packet_id == 0 &&
+			    ipv4_last->hdr.packet_id == UINT16_MAX &&
+			    ipv4_mask->hdr.packet_id == UINT16_MAX &&
+			    ipv4_spec->hdr.fragment_offset ==
+			    rte_cpu_to_be_16(RTE_IPV4_HDR_MF_FLAG) &&
+			    ipv4_mask->hdr.fragment_offset == UINT16_MAX) {
+				/* all IPv4 fragment packet has the same
+				 * ethertype, if the spec is for all valid
+				 * packet id, set ethertype into input set.
+				 */
+				*input_set |= ICE_INSET_ETHERTYPE;
+				input_set_o |= ICE_INSET_ETHERTYPE;
+			} else if (ipv4_mask->hdr.packet_id == UINT16_MAX) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ITEM,
+						   item, "Invalid IPv4 mask.");
+				return -rte_errno;
+			}
+
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV6:
 			flow_type = ICE_FLTR_PTYPE_NONF_IPV6_OTHER;
@@ -1778,6 +1834,43 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			p_v6->proto = ipv6_spec->hdr.proto;
 			p_v6->hlim = ipv6_spec->hdr.hop_limits;
 			break;
+		case RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT:
+			l3 = RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT;
+			flow_type = ICE_FLTR_PTYPE_FRAG_IPV6;
+			ipv6_frag_spec = item->spec;
+			ipv6_frag_last = item->last;
+			ipv6_frag_mask = item->mask;
+
+			if (!(ipv6_frag_spec && ipv6_frag_mask))
+				break;
+
+			/* only support any packet id for fragment IPv6
+			 * any packet_id:
+			 * spec is 0, last is 0xffffffff, mask is 0xffffffff
+			 * fragment Ipv6:
+			 * spec is 0x1, mask is 0xffff
+			 */
+			if (ipv6_frag_last && ipv6_frag_spec->hdr.id == 0 &&
+			    ipv6_frag_last->hdr.id == UINT32_MAX &&
+			    ipv6_frag_mask->hdr.id == UINT32_MAX &&
+			    ipv6_frag_spec->hdr.frag_data ==
+			    rte_cpu_to_be_16(1) &&
+			    ipv6_frag_mask->hdr.frag_data == UINT16_MAX) {
+				/* all IPv6 fragment packet has the same
+				 * ethertype, if the spec is for all valid
+				 * packet id, set ethertype into input set.
+				 */
+				*input_set |= ICE_INSET_ETHERTYPE;
+				input_set_o |= ICE_INSET_ETHERTYPE;
+			} else if (ipv6_frag_mask->hdr.id == UINT32_MAX) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ITEM,
+						   item, "Invalid IPv6 mask.");
+				return -rte_errno;
+			}
+
+			break;
+
 		case RTE_FLOW_ITEM_TYPE_TCP:
 			if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
 				flow_type = ICE_FLTR_PTYPE_NONF_IPV4_TCP;
@@ -2016,7 +2109,8 @@ ice_fdir_parse(struct ice_adapter *ad,
 	if (ret)
 		goto error;
 	input_set = filter->input_set_o | filter->input_set_i;
-	if (!input_set || filter->input_set_o & ~item->input_set_mask_o ||
+	if (!input_set || filter->input_set_o &
+	    ~(item->input_set_mask_o | ICE_INSET_ETHERTYPE) ||
 	    filter->input_set_i & ~item->input_set_mask_i) {
 		rte_flow_error_set(error, EINVAL,
 				   RTE_FLOW_ERROR_TYPE_ITEM_SPEC,
diff --git a/drivers/net/ice/ice_generic_flow.c b/drivers/net/ice/ice_generic_flow.c
index 2389bc6637..7a34a51600 100644
--- a/drivers/net/ice/ice_generic_flow.c
+++ b/drivers/net/ice/ice_generic_flow.c
@@ -2108,6 +2108,7 @@ static struct ice_ptype_match ice_ptype_map[] = {
 	{pattern_eth_ipv6_udp,				ICE_PTYPE_IPV6_UDP_PAY},
 	{pattern_eth_ipv6_tcp,				ICE_PTYPE_IPV6_TCP_PAY},
 	{pattern_eth_ipv6_sctp,				ICE_PTYPE_IPV6_SCTP_PAY},
+	{pattern_eth_ipv6_frag_ext,			ICE_PTYPE_IPV6FRAG_PAY},
 	{pattern_eth_ipv6_gtpu,				ICE_MAC_IPV6_GTPU},
 	{pattern_eth_ipv6_gtpu_eh,			ICE_MAC_IPV6_GTPU},
 	{pattern_eth_ipv6_gtpu_ipv4,			ICE_MAC_IPV6_GTPU_IPV4_PAY},
-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [dpdk-dev] [PATCH v5 0/3] support flow for IP fragment in ICE
  2021-04-13  9:38   ` [dpdk-dev] [PATCH v5 " Jeff Guo
                       ` (2 preceding siblings ...)
  2021-04-13  9:38     ` [dpdk-dev] [PATCH v5 3/3] net/ice: support FDIR for IP fragment packet Jeff Guo
@ 2021-04-13  9:46     ` Xu, Ting
  3 siblings, 0 replies; 42+ messages in thread
From: Xu, Ting @ 2021-04-13  9:46 UTC (permalink / raw)
  To: Guo, Jia, Zhang, Qi Z, Yang, Qiming; +Cc: dev

> -----Original Message-----
> From: Guo, Jia <jia.guo@intel.com>
> Sent: Tuesday, April 13, 2021 5:39 PM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>
> Cc: dev@dpdk.org; Xu, Ting <ting.xu@intel.com>; Guo, Jia <jia.guo@intel.com>
> Subject: [PATCH v5 0/3] support flow for IP fragment in ICE
> 
> Support RSS hash and FDIR for IP fragment packets in ICE PMD.
> 
> v5:
> rebase code.
> v4:
> correct typo when define fragment
> v3:
> rebase code and fix some parsing issues.
> v2:
> add some input check
> 
> Jeff Guo (3):
>   net/ice/base: support IP fragment RSS and FDIR
>   net/ice: support RSS hash for IP fragment
>   net/ice: support FDIR for IP fragment packet
> 
>  drivers/net/ice/base/ice_fdir.c    |  50 ++++++++++++-
>  drivers/net/ice/base/ice_fdir.h    |  22 +++++-
>  drivers/net/ice/base/ice_flow.c    |  50 ++++++++++++-
>  drivers/net/ice/base/ice_flow.h    |   9 ++-
>  drivers/net/ice/base/ice_type.h    |   1 +
>  drivers/net/ice/ice_fdir_filter.c  | 116 ++++++++++++++++++++++++++---
> drivers/net/ice/ice_generic_flow.c |  22 ++++++
>  drivers/net/ice/ice_generic_flow.h |   6 ++
>  drivers/net/ice/ice_hash.c         |  46 ++++++++++--
>  9 files changed, 293 insertions(+), 29 deletions(-)
> 
> --
> 2.20.1

Reviewed-by: Ting Xu <ting.xu@intel.com>

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v6 0/3] support flow for IP fragment in ICE
  2021-03-24 13:54 ` [dpdk-dev] [PATCH v2 0/3] support flow for IP fragment in ICE Jeff Guo
                     ` (7 preceding siblings ...)
  2021-04-13  9:38   ` [dpdk-dev] [PATCH v5 " Jeff Guo
@ 2021-04-13 10:06   ` Jeff Guo
  2021-04-13 10:06     ` [dpdk-dev] [PATCH v6 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
                       ` (3 more replies)
  8 siblings, 4 replies; 42+ messages in thread
From: Jeff Guo @ 2021-04-13 10:06 UTC (permalink / raw)
  To: qi.z.zhang, qiming.yang; +Cc: dev, ting.xu, jia.guo

Support RSS hash and FDIR for IP fragment packets in ICE PMD.

v6:
fix uninitialize issue
v5:
rebase code.
v4:
correct typo when define fragment
v3:
rebase code and fix some parsing issues.
v2:
add some input check

Jeff Guo (3):
  net/ice/base: support IP fragment RSS and FDIR
  net/ice: support RSS hash for IP fragment
  net/ice: support FDIR for IP fragment packet

 drivers/net/ice/base/ice_fdir.c    |  50 +++++++++++-
 drivers/net/ice/base/ice_fdir.h    |  22 +++++-
 drivers/net/ice/base/ice_flow.c    |  50 +++++++++++-
 drivers/net/ice/base/ice_flow.h    |   9 ++-
 drivers/net/ice/base/ice_type.h    |   1 +
 drivers/net/ice/ice_fdir_filter.c  | 118 ++++++++++++++++++++++++++---
 drivers/net/ice/ice_generic_flow.c |  22 ++++++
 drivers/net/ice/ice_generic_flow.h |   6 ++
 drivers/net/ice/ice_hash.c         |  46 +++++++++--
 9 files changed, 294 insertions(+), 30 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v6 1/3] net/ice/base: support IP fragment RSS and FDIR
  2021-04-13 10:06   ` [dpdk-dev] [PATCH v6 " Jeff Guo
@ 2021-04-13 10:06     ` Jeff Guo
  2021-04-13 10:06     ` [dpdk-dev] [PATCH v6 2/3] net/ice: support RSS hash for IP fragment Jeff Guo
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 42+ messages in thread
From: Jeff Guo @ 2021-04-13 10:06 UTC (permalink / raw)
  To: qi.z.zhang, qiming.yang; +Cc: dev, ting.xu, jia.guo

Add support for IP fragment RSS hash and FDIR according to packet ID.
Separate IP fragment and IP other packet types.

Signed-off-by: Ting Xu <ting.xu@intel.com>
Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
 drivers/net/ice/base/ice_fdir.c | 50 +++++++++++++++++++++++++++++++--
 drivers/net/ice/base/ice_fdir.h | 22 ++++++++++++---
 drivers/net/ice/base/ice_flow.c | 50 ++++++++++++++++++++++++++++++++-
 drivers/net/ice/base/ice_flow.h |  9 ++++--
 drivers/net/ice/base/ice_type.h |  1 +
 5 files changed, 122 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ice/base/ice_fdir.c b/drivers/net/ice/base/ice_fdir.c
index 8f9c0d346b..c1b14783ac 100644
--- a/drivers/net/ice/base/ice_fdir.c
+++ b/drivers/net/ice/base/ice_fdir.c
@@ -518,6 +518,24 @@ 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 +734,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),
@@ -1505,7 +1533,7 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
 		ice_pkt_insert_u8(loc, ICE_IPV4_TTL_OFFSET, input->ip.v4.ttl);
 		ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
 		if (frag)
-			loc[20] = ICE_FDIR_IPV4_PKT_FLAG_DF;
+			loc[20] = ICE_FDIR_IPV4_PKT_FLAG_MF;
 		break;
 	case ICE_FLTR_PTYPE_NONF_IPV4_UDP:
 		ice_pkt_insert_mac_addr(pkt, input->ext_data_outer.dst_mac);
@@ -1808,6 +1836,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 +1883,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;
diff --git a/drivers/net/ice/base/ice_fdir.h b/drivers/net/ice/base/ice_fdir.h
index 6573f96bc1..2acc1d6f1b 100644
--- a/drivers/net/ice/base/ice_fdir.h
+++ b/drivers/net/ice/base/ice_fdir.h
@@ -43,9 +43,11 @@
 #define ICE_MAC_ETHTYPE_OFFSET		12
 #define ICE_IPV4_TOS_OFFSET		15
 #define ICE_IPV4_TTL_OFFSET		22
+#define ICE_IPV4_ID_OFFSET		18
 #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
@@ -83,12 +85,22 @@
 
 #define ICE_FDIR_MAX_FLTRS		16384
 
-/* IP v4 has 2 flag bits that enable fragment processing: DF and MF. DF
+/* IPv4 has 2 flag bits that enable fragment processing: DF and MF. DF
  * requests that the packet not be fragmented. MF indicates that a packet has
- * been fragmented.
+ * been fragmented, except that for the last fragment has a non-zero
+ * Fragment Offset field with zero MF.
  */
-#define ICE_FDIR_IPV4_PKT_FLAG_DF		0x20
-#define ICE_FDIR_IPV4_PKT_FLAG_MF		0x40
+#define ICE_FDIR_IPV4_PKT_FLAG_MF		0x20
+#define ICE_FDIR_IPV4_PKT_FLAG_MF_SHIFT	8
+#ifndef NO_UNUSED_PACKAGE_CODE
+#define ICE_FDIR_IPV4_PKT_FLAG_DF		0x40
+#endif /* NO_UNUSED_PACKAGE_CODE */
+
+/* For IPv6 fragmented packets, all fragments except the last have
+ * the MF flag set.
+ */
+#define ICE_FDIR_IPV6_PKT_FLAG_MF		0x100
+#define ICE_FDIR_IPV6_PKT_FLAG_MF_SHIFT	8
 
 enum ice_fltr_prgm_desc_dest {
 	ICE_FLTR_PRGM_DESC_DEST_DROP_PKT,
@@ -150,6 +162,7 @@ struct ice_fdir_v4 {
 	u8 ip_ver;
 	u8 proto;
 	u8 ttl;
+	__be16 packet_id;
 };
 
 #define ICE_IPV6_ADDR_LEN_AS_U32		4
@@ -164,6 +177,7 @@ struct ice_fdir_v6 {
 	u8 tc;
 	u8 proto;
 	u8 hlim;
+	__be32 packet_id;
 };
 
 struct ice_fdir_udp_gtp {
diff --git a/drivers/net/ice/base/ice_flow.c b/drivers/net/ice/base/ice_flow.c
index e37f7ae524..2c60270140 100644
--- a/drivers/net/ice/base/ice_flow.c
+++ b/drivers/net/ice/base/ice_flow.c
@@ -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,27 @@ 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 +951,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 +1249,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 +1262,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 +3474,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);
diff --git a/drivers/net/ice/base/ice_flow.h b/drivers/net/ice/base/ice_flow.h
index 448e06028a..878c79d19e 100644
--- a/drivers/net/ice/base/ice_flow.h
+++ b/drivers/net/ice/base/ice_flow.h
@@ -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,
diff --git a/drivers/net/ice/base/ice_type.h b/drivers/net/ice/base/ice_type.h
index 3c534a7711..a6988d962c 100644
--- a/drivers/net/ice/base/ice_type.h
+++ b/drivers/net/ice/base/ice_type.h
@@ -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,
-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v6 2/3] net/ice: support RSS hash for IP fragment
  2021-04-13 10:06   ` [dpdk-dev] [PATCH v6 " Jeff Guo
  2021-04-13 10:06     ` [dpdk-dev] [PATCH v6 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
@ 2021-04-13 10:06     ` Jeff Guo
  2021-04-13 10:06     ` [dpdk-dev] [PATCH v6 3/3] net/ice: support FDIR for IP fragment packet Jeff Guo
  2021-04-29  3:12     ` [dpdk-dev] [PATCH v6 0/3] support flow for IP fragment in ICE Zhang, Qi Z
  3 siblings, 0 replies; 42+ messages in thread
From: Jeff Guo @ 2021-04-13 10:06 UTC (permalink / raw)
  To: qi.z.zhang, qiming.yang; +Cc: dev, ting.xu, jia.guo

New pattern and RSS hash flow parsing are added to handle fragmented
IPv4/IPv6  packet.

Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
 drivers/net/ice/ice_generic_flow.c | 21 ++++++++++++++
 drivers/net/ice/ice_generic_flow.h |  6 ++++
 drivers/net/ice/ice_hash.c         | 46 ++++++++++++++++++++++++------
 3 files changed, 65 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ice/ice_generic_flow.c b/drivers/net/ice/ice_generic_flow.c
index 8704812622..2389bc6637 100644
--- a/drivers/net/ice/ice_generic_flow.c
+++ b/drivers/net/ice/ice_generic_flow.c
@@ -212,6 +212,27 @@ enum rte_flow_item_type pattern_eth_qinq_ipv6[] = {
 	RTE_FLOW_ITEM_TYPE_IPV6,
 	RTE_FLOW_ITEM_TYPE_END,
 };
+enum rte_flow_item_type pattern_eth_ipv6_frag_ext[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+enum rte_flow_item_type pattern_eth_vlan_ipv6_frag_ext[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_VLAN,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+enum rte_flow_item_type pattern_eth_qinq_ipv6_frag_ext[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_VLAN,
+	RTE_FLOW_ITEM_TYPE_VLAN,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+	RTE_FLOW_ITEM_TYPE_END,
+};
 enum rte_flow_item_type pattern_eth_ipv6_udp[] = {
 	RTE_FLOW_ITEM_TYPE_ETH,
 	RTE_FLOW_ITEM_TYPE_IPV6,
diff --git a/drivers/net/ice/ice_generic_flow.h b/drivers/net/ice/ice_generic_flow.h
index 9f422e5925..2afe719264 100644
--- a/drivers/net/ice/ice_generic_flow.h
+++ b/drivers/net/ice/ice_generic_flow.h
@@ -52,6 +52,7 @@
 #define ICE_L2TPV3OIP_SESSION_ID	BIT_ULL(43)
 #define ICE_PFCP_SEID			BIT_ULL(42)
 #define ICE_PFCP_S_FIELD		BIT_ULL(41)
+#define ICE_IP_PK_ID		    BIT_ULL(40)
 
 /* input set */
 
@@ -69,11 +70,13 @@
 #define ICE_INSET_IPV4_TOS		(ICE_PROT_IPV4 | ICE_IP_TOS)
 #define ICE_INSET_IPV4_PROTO		(ICE_PROT_IPV4 | ICE_IP_PROTO)
 #define ICE_INSET_IPV4_TTL		(ICE_PROT_IPV4 | ICE_IP_TTL)
+#define ICE_INSET_IPV4_PKID		(ICE_PROT_IPV4 | ICE_IP_PK_ID)
 #define ICE_INSET_IPV6_SRC		(ICE_PROT_IPV6 | ICE_IP_SRC)
 #define ICE_INSET_IPV6_DST		(ICE_PROT_IPV6 | ICE_IP_DST)
 #define ICE_INSET_IPV6_NEXT_HDR		(ICE_PROT_IPV6 | ICE_IP_PROTO)
 #define ICE_INSET_IPV6_HOP_LIMIT	(ICE_PROT_IPV6 | ICE_IP_TTL)
 #define ICE_INSET_IPV6_TC		(ICE_PROT_IPV6 | ICE_IP_TOS)
+#define ICE_INSET_IPV6_PKID		(ICE_PROT_IPV6 | ICE_IP_PK_ID)
 
 #define ICE_INSET_TCP_SRC_PORT		(ICE_PROT_TCP | ICE_SPORT)
 #define ICE_INSET_TCP_DST_PORT		(ICE_PROT_TCP | ICE_DPORT)
@@ -202,6 +205,9 @@ extern enum rte_flow_item_type pattern_eth_qinq_ipv4_icmp[];
 extern enum rte_flow_item_type pattern_eth_ipv6[];
 extern enum rte_flow_item_type pattern_eth_vlan_ipv6[];
 extern enum rte_flow_item_type pattern_eth_qinq_ipv6[];
+extern enum rte_flow_item_type pattern_eth_ipv6_frag_ext[];
+extern enum rte_flow_item_type pattern_eth_vlan_ipv6_frag_ext[];
+extern enum rte_flow_item_type pattern_eth_qinq_ipv6_frag_ext[];
 extern enum rte_flow_item_type pattern_eth_ipv6_udp[];
 extern enum rte_flow_item_type pattern_eth_vlan_ipv6_udp[];
 extern enum rte_flow_item_type pattern_eth_qinq_ipv6_udp[];
diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c
index e56cdf9941..75b6947625 100644
--- a/drivers/net/ice/ice_hash.c
+++ b/drivers/net/ice/ice_hash.c
@@ -47,8 +47,10 @@
 				 ETH_RSS_NONFRAG_IPV6_TCP	| \
 				 ETH_RSS_NONFRAG_IPV6_SCTP)
 
-#define VALID_RSS_IPV4		(ETH_RSS_IPV4 | VALID_RSS_IPV4_L4)
-#define VALID_RSS_IPV6		(ETH_RSS_IPV6 | VALID_RSS_IPV6_L4)
+#define VALID_RSS_IPV4		(ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 | \
+				 VALID_RSS_IPV4_L4)
+#define VALID_RSS_IPV6		(ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 | \
+				 VALID_RSS_IPV6_L4)
 #define VALID_RSS_L3		(VALID_RSS_IPV4 | VALID_RSS_IPV6)
 #define VALID_RSS_L4		(VALID_RSS_IPV4_L4 | VALID_RSS_IPV6_L4)
 
@@ -108,6 +110,7 @@ ice_hash_parse_pattern_action(struct ice_adapter *ad,
 /* Rss configuration template */
 struct ice_rss_hash_cfg ipv4_tmplt = {
 	ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV4 |
+	ICE_FLOW_SEG_HDR_IPV_FRAG |
 	ICE_FLOW_SEG_HDR_IPV_OTHER,
 	ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_IPV4,
 	ICE_RSS_OUTER_HEADERS,
@@ -146,6 +149,15 @@ struct ice_rss_hash_cfg ipv6_tmplt = {
 	0
 };
 
+struct ice_rss_hash_cfg ipv6_frag_tmplt = {
+	ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV6 |
+	ICE_FLOW_SEG_HDR_IPV_FRAG |
+	ICE_FLOW_SEG_HDR_IPV_OTHER,
+	ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_IPV6,
+	ICE_RSS_ANY_HEADERS,
+	0
+};
+
 struct ice_rss_hash_cfg ipv6_udp_tmplt = {
 	ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV6 |
 	ICE_FLOW_SEG_HDR_IPV_OTHER | ICE_FLOW_SEG_HDR_UDP,
@@ -198,6 +210,7 @@ struct ice_rss_hash_cfg outer_ipv6_inner_ipv4_tmplt = {
 	ICE_RSS_INNER_HEADERS_W_OUTER_IPV6,
 	0
 };
+
 struct ice_rss_hash_cfg outer_ipv6_inner_ipv4_udp_tmplt = {
 	ICE_FLOW_SEG_HDR_IPV4 | ICE_FLOW_SEG_HDR_IPV_OTHER |
 	ICE_FLOW_SEG_HDR_UDP,
@@ -220,6 +233,7 @@ struct ice_rss_hash_cfg outer_ipv4_inner_ipv6_tmplt = {
 	ICE_RSS_INNER_HEADERS_W_OUTER_IPV4,
 	0
 };
+
 struct ice_rss_hash_cfg outer_ipv4_inner_ipv6_udp_tmplt = {
 	ICE_FLOW_SEG_HDR_IPV6 | ICE_FLOW_SEG_HDR_IPV_OTHER |
 	ICE_FLOW_SEG_HDR_UDP,
@@ -353,7 +367,8 @@ struct ice_rss_hash_cfg empty_tmplt = {
 };
 
 /* IPv4 */
-#define ICE_RSS_TYPE_ETH_IPV4		(ETH_RSS_ETH | ETH_RSS_IPV4)
+#define ICE_RSS_TYPE_ETH_IPV4		(ETH_RSS_ETH | ETH_RSS_IPV4 | \
+					 ETH_RSS_FRAG_IPV4)
 #define ICE_RSS_TYPE_ETH_IPV4_UDP	(ICE_RSS_TYPE_ETH_IPV4 | \
 					 ETH_RSS_NONFRAG_IPV4_UDP)
 #define ICE_RSS_TYPE_ETH_IPV4_TCP	(ICE_RSS_TYPE_ETH_IPV4 | \
@@ -370,6 +385,8 @@ struct ice_rss_hash_cfg empty_tmplt = {
 
 /* IPv6 */
 #define ICE_RSS_TYPE_ETH_IPV6		(ETH_RSS_ETH | ETH_RSS_IPV6)
+#define ICE_RSS_TYPE_ETH_IPV6_FRAG	(ETH_RSS_ETH | ETH_RSS_IPV6 | \
+					 ETH_RSS_FRAG_IPV6)
 #define ICE_RSS_TYPE_ETH_IPV6_UDP	(ICE_RSS_TYPE_ETH_IPV6 | \
 					 ETH_RSS_NONFRAG_IPV6_UDP)
 #define ICE_RSS_TYPE_ETH_IPV6_TCP	(ICE_RSS_TYPE_ETH_IPV6 | \
@@ -386,7 +403,8 @@ struct ice_rss_hash_cfg empty_tmplt = {
 
 /* VLAN IPV4 */
 #define ICE_RSS_TYPE_VLAN_IPV4		(ICE_RSS_TYPE_IPV4 | \
-					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
+					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN | \
+					 ETH_RSS_FRAG_IPV4)
 #define ICE_RSS_TYPE_VLAN_IPV4_UDP	(ICE_RSS_TYPE_IPV4_UDP | \
 					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
 #define ICE_RSS_TYPE_VLAN_IPV4_TCP	(ICE_RSS_TYPE_IPV4_TCP | \
@@ -396,6 +414,9 @@ struct ice_rss_hash_cfg empty_tmplt = {
 /* VLAN IPv6 */
 #define ICE_RSS_TYPE_VLAN_IPV6		(ICE_RSS_TYPE_IPV6 | \
 					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
+#define ICE_RSS_TYPE_VLAN_IPV6_FRAG	(ICE_RSS_TYPE_IPV6 | \
+					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN | \
+					 ETH_RSS_FRAG_IPV6)
 #define ICE_RSS_TYPE_VLAN_IPV6_UDP	(ICE_RSS_TYPE_IPV6_UDP | \
 					 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
 #define ICE_RSS_TYPE_VLAN_IPV6_TCP	(ICE_RSS_TYPE_IPV6_TCP | \
@@ -485,10 +506,12 @@ static struct ice_pattern_match_item ice_hash_pattern_list[] = {
 	{pattern_eth_ipv4_pfcp,			ICE_RSS_TYPE_IPV4_PFCP,		ICE_INSET_NONE,	&eth_ipv4_pfcp_tmplt},
 	/* IPV6 */
 	{pattern_eth_ipv6,			ICE_RSS_TYPE_ETH_IPV6,		ICE_INSET_NONE,	&ipv6_tmplt},
+	{pattern_eth_ipv6_frag_ext,		ICE_RSS_TYPE_ETH_IPV6_FRAG,	ICE_INSET_NONE,	&ipv6_frag_tmplt},
 	{pattern_eth_ipv6_udp,			ICE_RSS_TYPE_ETH_IPV6_UDP,	ICE_INSET_NONE,	&ipv6_udp_tmplt},
 	{pattern_eth_ipv6_tcp,			ICE_RSS_TYPE_ETH_IPV6_TCP,	ICE_INSET_NONE,	&ipv6_tcp_tmplt},
 	{pattern_eth_ipv6_sctp,			ICE_RSS_TYPE_ETH_IPV6_SCTP,	ICE_INSET_NONE,	&ipv6_sctp_tmplt},
 	{pattern_eth_vlan_ipv6,			ICE_RSS_TYPE_VLAN_IPV6,		ICE_INSET_NONE,	&ipv6_tmplt},
+	{pattern_eth_vlan_ipv6_frag_ext,	ICE_RSS_TYPE_VLAN_IPV6_FRAG,	ICE_INSET_NONE, &ipv6_frag_tmplt},
 	{pattern_eth_vlan_ipv6_udp,		ICE_RSS_TYPE_VLAN_IPV6_UDP,	ICE_INSET_NONE,	&ipv6_udp_tmplt},
 	{pattern_eth_vlan_ipv6_tcp,		ICE_RSS_TYPE_VLAN_IPV6_TCP,	ICE_INSET_NONE,	&ipv6_tcp_tmplt},
 	{pattern_eth_vlan_ipv6_sctp,		ICE_RSS_TYPE_VLAN_IPV6_SCTP,	ICE_INSET_NONE,	&ipv6_sctp_tmplt},
@@ -629,11 +652,14 @@ ice_refine_hash_cfg_l234(struct ice_rss_hash_cfg *hash_cfg,
 
 	if (*addl_hdrs & ICE_FLOW_SEG_HDR_IPV4) {
 		if (rss_type &
-		   (ETH_RSS_IPV4 |
+		   (ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 |
 		    ETH_RSS_NONFRAG_IPV4_UDP |
 		    ETH_RSS_NONFRAG_IPV4_TCP |
 		    ETH_RSS_NONFRAG_IPV4_SCTP)) {
-			if (rss_type & ETH_RSS_L3_SRC_ONLY)
+			if (rss_type & ETH_RSS_FRAG_IPV4)
+				*hash_flds &=
+					~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_ID));
+			else if (rss_type & ETH_RSS_L3_SRC_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA));
 			else if (rss_type & ETH_RSS_L3_DST_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA));
@@ -648,11 +674,14 @@ ice_refine_hash_cfg_l234(struct ice_rss_hash_cfg *hash_cfg,
 
 	if (*addl_hdrs & ICE_FLOW_SEG_HDR_IPV6) {
 		if (rss_type &
-		   (ETH_RSS_IPV6 |
+		   (ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 |
 		    ETH_RSS_NONFRAG_IPV6_UDP |
 		    ETH_RSS_NONFRAG_IPV6_TCP |
 		    ETH_RSS_NONFRAG_IPV6_SCTP)) {
-			if (rss_type & ETH_RSS_L3_SRC_ONLY)
+			if (rss_type & ETH_RSS_FRAG_IPV6)
+				*hash_flds &=
+					~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_ID));
+			else if (rss_type & ETH_RSS_L3_SRC_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA));
 			else if (rss_type & ETH_RSS_L3_DST_ONLY)
 				*hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA));
@@ -867,6 +896,7 @@ ice_any_invalid_rss_type(enum rte_eth_hash_function rss_func,
 
 		if (!(rss_type &
 		   (ETH_RSS_IPV4 | ETH_RSS_IPV6 |
+		    ETH_RSS_FRAG_IPV4 | ETH_RSS_FRAG_IPV6 |
 		    ETH_RSS_NONFRAG_IPV4_UDP | ETH_RSS_NONFRAG_IPV6_UDP |
 		    ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_NONFRAG_IPV6_TCP |
 		    ETH_RSS_NONFRAG_IPV4_SCTP | ETH_RSS_NONFRAG_IPV6_SCTP)))
-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v6 3/3] net/ice: support FDIR for IP fragment packet
  2021-04-13 10:06   ` [dpdk-dev] [PATCH v6 " Jeff Guo
  2021-04-13 10:06     ` [dpdk-dev] [PATCH v6 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
  2021-04-13 10:06     ` [dpdk-dev] [PATCH v6 2/3] net/ice: support RSS hash for IP fragment Jeff Guo
@ 2021-04-13 10:06     ` Jeff Guo
  2021-04-29  3:12     ` [dpdk-dev] [PATCH v6 0/3] support flow for IP fragment in ICE Zhang, Qi Z
  3 siblings, 0 replies; 42+ messages in thread
From: Jeff Guo @ 2021-04-13 10:06 UTC (permalink / raw)
  To: qi.z.zhang, qiming.yang; +Cc: dev, ting.xu, jia.guo

New FDIR parsing are added to handle the fragmented IPv4/IPv6 packet.

Signed-off-by: Jeff Guo <jia.guo@intel.com>
Signed-off-by: Ting Xu <ting.xu@intel.com>
Reviewed-by: Ting Xu <ting.xu@intel.com>
---
 drivers/net/ice/ice_fdir_filter.c  | 118 ++++++++++++++++++++++++++---
 drivers/net/ice/ice_generic_flow.c |   1 +
 2 files changed, 107 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
index 92e18d59cc..8a01c8c997 100644
--- a/drivers/net/ice/ice_fdir_filter.c
+++ b/drivers/net/ice/ice_fdir_filter.c
@@ -24,7 +24,7 @@
 #define ICE_FDIR_INSET_ETH_IPV4 (\
 	ICE_FDIR_INSET_ETH | \
 	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | ICE_INSET_IPV4_TOS | \
-	ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO)
+	ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO | ICE_INSET_IPV4_PKID)
 
 #define ICE_FDIR_INSET_ETH_IPV4_UDP (\
 	ICE_FDIR_INSET_ETH_IPV4 | \
@@ -41,7 +41,8 @@
 #define ICE_FDIR_INSET_ETH_IPV6 (\
 	ICE_INSET_DMAC | \
 	ICE_INSET_IPV6_SRC | ICE_INSET_IPV6_DST | ICE_INSET_IPV6_TC | \
-	ICE_INSET_IPV6_HOP_LIMIT | ICE_INSET_IPV6_NEXT_HDR)
+	ICE_INSET_IPV6_HOP_LIMIT | ICE_INSET_IPV6_NEXT_HDR | \
+	ICE_INSET_IPV6_PKID)
 
 #define ICE_FDIR_INSET_ETH_IPV6_UDP (\
 	ICE_FDIR_INSET_ETH_IPV6 | \
@@ -56,7 +57,8 @@
 	ICE_INSET_SCTP_SRC_PORT | ICE_INSET_SCTP_DST_PORT)
 
 #define ICE_FDIR_INSET_IPV4 (\
-	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST)
+	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | \
+	ICE_INSET_IPV4_PKID)
 
 #define ICE_FDIR_INSET_IPV4_TCP (\
 	ICE_FDIR_INSET_IPV4 | \
@@ -95,6 +97,7 @@ static struct ice_pattern_match_item ice_fdir_pattern_list[] = {
 	{pattern_eth_ipv4_tcp,				ICE_FDIR_INSET_ETH_IPV4_TCP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv4_sctp,				ICE_FDIR_INSET_ETH_IPV4_SCTP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6,				ICE_FDIR_INSET_ETH_IPV6,	ICE_INSET_NONE,			ICE_INSET_NONE},
+	{pattern_eth_ipv6_frag_ext,			ICE_FDIR_INSET_ETH_IPV6,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6_udp,				ICE_FDIR_INSET_ETH_IPV6_UDP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6_tcp,				ICE_FDIR_INSET_ETH_IPV6_TCP,	ICE_INSET_NONE,			ICE_INSET_NONE},
 	{pattern_eth_ipv6_sctp,				ICE_FDIR_INSET_ETH_IPV6_SCTP,	ICE_INSET_NONE,			ICE_INSET_NONE},
@@ -882,11 +885,13 @@ ice_fdir_input_set_parse(uint64_t inset, enum ice_flow_field *field)
 		{ICE_INSET_IPV4_TOS, ICE_FLOW_FIELD_IDX_IPV4_DSCP},
 		{ICE_INSET_IPV4_TTL, ICE_FLOW_FIELD_IDX_IPV4_TTL},
 		{ICE_INSET_IPV4_PROTO, ICE_FLOW_FIELD_IDX_IPV4_PROT},
+		{ICE_INSET_IPV4_PKID, ICE_FLOW_FIELD_IDX_IPV4_ID},
 		{ICE_INSET_IPV6_SRC, ICE_FLOW_FIELD_IDX_IPV6_SA},
 		{ICE_INSET_IPV6_DST, ICE_FLOW_FIELD_IDX_IPV6_DA},
 		{ICE_INSET_IPV6_TC, ICE_FLOW_FIELD_IDX_IPV6_DSCP},
 		{ICE_INSET_IPV6_NEXT_HDR, ICE_FLOW_FIELD_IDX_IPV6_PROT},
 		{ICE_INSET_IPV6_HOP_LIMIT, ICE_FLOW_FIELD_IDX_IPV6_TTL},
+		{ICE_INSET_IPV6_PKID, ICE_FLOW_FIELD_IDX_IPV6_ID},
 		{ICE_INSET_TCP_SRC_PORT, ICE_FLOW_FIELD_IDX_TCP_SRC_PORT},
 		{ICE_INSET_TCP_DST_PORT, ICE_FLOW_FIELD_IDX_TCP_DST_PORT},
 		{ICE_INSET_UDP_SRC_PORT, ICE_FLOW_FIELD_IDX_UDP_SRC_PORT},
@@ -936,6 +941,10 @@ ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct ice_flow_seg_info *seg)
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4 |
 				  ICE_FLOW_SEG_HDR_IPV_OTHER);
 		break;
+	case ICE_FLTR_PTYPE_FRAG_IPV4:
+		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4 |
+				  ICE_FLOW_SEG_HDR_IPV_FRAG);
+		break;
 	case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP |
 				  ICE_FLOW_SEG_HDR_IPV6 |
@@ -955,6 +964,10 @@ ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct ice_flow_seg_info *seg)
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6 |
 				  ICE_FLOW_SEG_HDR_IPV_OTHER);
 		break;
+	case ICE_FLTR_PTYPE_FRAG_IPV6:
+		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6 |
+				  ICE_FLOW_SEG_HDR_IPV_FRAG);
+		break;
 	case ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN:
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP |
 				ICE_FLOW_SEG_HDR_IPV4 |
@@ -1599,8 +1612,10 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 	enum rte_flow_item_type l3 = RTE_FLOW_ITEM_TYPE_END;
 	enum ice_fdir_tunnel_type tunnel_type = ICE_FDIR_TUNNEL_TYPE_NONE;
 	const struct rte_flow_item_eth *eth_spec, *eth_mask;
-	const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_mask;
+	const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_last, *ipv4_mask;
 	const struct rte_flow_item_ipv6 *ipv6_spec, *ipv6_mask;
+	const struct rte_flow_item_ipv6_frag_ext *ipv6_frag_spec,
+					*ipv6_frag_last, *ipv6_frag_mask;
 	const struct rte_flow_item_tcp *tcp_spec, *tcp_mask;
 	const struct rte_flow_item_udp *udp_spec, *udp_mask;
 	const struct rte_flow_item_sctp *sctp_spec, *sctp_mask;
@@ -1639,14 +1654,15 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 	 * flow. input_set_i is used for inner part.
 	 */
 	for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
-		if (item->last) {
+		item_type = item->type;
+
+		if (item->last && !(item_type == RTE_FLOW_ITEM_TYPE_IPV4 ||
+				    item_type ==
+				    RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT)) {
 			rte_flow_error_set(error, EINVAL,
-					   RTE_FLOW_ERROR_TYPE_ITEM,
-					   item,
+					   RTE_FLOW_ERROR_TYPE_ITEM, item,
 					   "Not support range");
-			return -rte_errno;
 		}
-		item_type = item->type;
 
 		input_set = (tunnel_type && !is_outer) ?
 			    &input_set_i : &input_set_o;
@@ -1696,6 +1712,7 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			flow_type = ICE_FLTR_PTYPE_NONF_IPV4_OTHER;
 			l3 = RTE_FLOW_ITEM_TYPE_IPV4;
 			ipv4_spec = item->spec;
+			ipv4_last = item->last;
 			ipv4_mask = item->mask;
 			p_v4 = (tunnel_type && is_outer) ?
 			       &filter->input.ip_outer.v4 :
@@ -1707,8 +1724,6 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			/* Check IPv4 mask and update input set */
 			if (ipv4_mask->hdr.version_ihl ||
 			    ipv4_mask->hdr.total_length ||
-			    ipv4_mask->hdr.packet_id ||
-			    ipv4_mask->hdr.fragment_offset ||
 			    ipv4_mask->hdr.hdr_checksum) {
 				rte_flow_error_set(error, EINVAL,
 						   RTE_FLOW_ERROR_TYPE_ITEM,
@@ -1717,6 +1732,21 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 				return -rte_errno;
 			}
 
+			if (ipv4_last &&
+			    (ipv4_last->hdr.version_ihl ||
+			     ipv4_last->hdr.type_of_service ||
+			     ipv4_last->hdr.time_to_live ||
+			     ipv4_last->hdr.total_length |
+			     ipv4_last->hdr.next_proto_id ||
+			     ipv4_last->hdr.hdr_checksum ||
+			     ipv4_last->hdr.src_addr ||
+			     ipv4_last->hdr.dst_addr)) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ITEM,
+						   item, "Invalid IPv4 last.");
+				return -rte_errno;
+			}
+
 			if (ipv4_mask->hdr.dst_addr == UINT32_MAX)
 				*input_set |= ICE_INSET_IPV4_DST;
 			if (ipv4_mask->hdr.src_addr == UINT32_MAX)
@@ -1733,6 +1763,32 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			p_v4->ttl = ipv4_spec->hdr.time_to_live;
 			p_v4->proto = ipv4_spec->hdr.next_proto_id;
 			p_v4->tos = ipv4_spec->hdr.type_of_service;
+
+			/* only support any packet id for fragment IPv4
+			 * any packet_id:
+			 * spec is 0, last is 0xffff, mask is 0xffff
+			 * fragment Ipv4:
+			 * spec is 0x2000, mask is 0xffff
+			 */
+			if (ipv4_last && ipv4_spec->hdr.packet_id == 0 &&
+			    ipv4_last->hdr.packet_id == UINT16_MAX &&
+			    ipv4_mask->hdr.packet_id == UINT16_MAX &&
+			    ipv4_spec->hdr.fragment_offset ==
+			    rte_cpu_to_be_16(RTE_IPV4_HDR_MF_FLAG) &&
+			    ipv4_mask->hdr.fragment_offset == UINT16_MAX) {
+				/* all IPv4 fragment packet has the same
+				 * ethertype, if the spec is for all valid
+				 * packet id, set ethertype into input set.
+				 */
+				*input_set |= ICE_INSET_ETHERTYPE;
+				input_set_o |= ICE_INSET_ETHERTYPE;
+			} else if (ipv4_mask->hdr.packet_id == UINT16_MAX) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ITEM,
+						   item, "Invalid IPv4 mask.");
+				return -rte_errno;
+			}
+
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV6:
 			flow_type = ICE_FLTR_PTYPE_NONF_IPV6_OTHER;
@@ -1778,6 +1834,43 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			p_v6->proto = ipv6_spec->hdr.proto;
 			p_v6->hlim = ipv6_spec->hdr.hop_limits;
 			break;
+		case RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT:
+			l3 = RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT;
+			flow_type = ICE_FLTR_PTYPE_FRAG_IPV6;
+			ipv6_frag_spec = item->spec;
+			ipv6_frag_last = item->last;
+			ipv6_frag_mask = item->mask;
+
+			if (!(ipv6_frag_spec && ipv6_frag_mask))
+				break;
+
+			/* only support any packet id for fragment IPv6
+			 * any packet_id:
+			 * spec is 0, last is 0xffffffff, mask is 0xffffffff
+			 * fragment Ipv6:
+			 * spec is 0x1, mask is 0xffff
+			 */
+			if (ipv6_frag_last && ipv6_frag_spec->hdr.id == 0 &&
+			    ipv6_frag_last->hdr.id == UINT32_MAX &&
+			    ipv6_frag_mask->hdr.id == UINT32_MAX &&
+			    ipv6_frag_spec->hdr.frag_data ==
+			    rte_cpu_to_be_16(1) &&
+			    ipv6_frag_mask->hdr.frag_data == UINT16_MAX) {
+				/* all IPv6 fragment packet has the same
+				 * ethertype, if the spec is for all valid
+				 * packet id, set ethertype into input set.
+				 */
+				*input_set |= ICE_INSET_ETHERTYPE;
+				input_set_o |= ICE_INSET_ETHERTYPE;
+			} else if (ipv6_frag_mask->hdr.id == UINT32_MAX) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ITEM,
+						   item, "Invalid IPv6 mask.");
+				return -rte_errno;
+			}
+
+			break;
+
 		case RTE_FLOW_ITEM_TYPE_TCP:
 			if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
 				flow_type = ICE_FLTR_PTYPE_NONF_IPV4_TCP;
@@ -2016,7 +2109,8 @@ ice_fdir_parse(struct ice_adapter *ad,
 	if (ret)
 		goto error;
 	input_set = filter->input_set_o | filter->input_set_i;
-	if (!input_set || filter->input_set_o & ~item->input_set_mask_o ||
+	if (!input_set || filter->input_set_o &
+	    ~(item->input_set_mask_o | ICE_INSET_ETHERTYPE) ||
 	    filter->input_set_i & ~item->input_set_mask_i) {
 		rte_flow_error_set(error, EINVAL,
 				   RTE_FLOW_ERROR_TYPE_ITEM_SPEC,
diff --git a/drivers/net/ice/ice_generic_flow.c b/drivers/net/ice/ice_generic_flow.c
index 2389bc6637..7a34a51600 100644
--- a/drivers/net/ice/ice_generic_flow.c
+++ b/drivers/net/ice/ice_generic_flow.c
@@ -2108,6 +2108,7 @@ static struct ice_ptype_match ice_ptype_map[] = {
 	{pattern_eth_ipv6_udp,				ICE_PTYPE_IPV6_UDP_PAY},
 	{pattern_eth_ipv6_tcp,				ICE_PTYPE_IPV6_TCP_PAY},
 	{pattern_eth_ipv6_sctp,				ICE_PTYPE_IPV6_SCTP_PAY},
+	{pattern_eth_ipv6_frag_ext,			ICE_PTYPE_IPV6FRAG_PAY},
 	{pattern_eth_ipv6_gtpu,				ICE_MAC_IPV6_GTPU},
 	{pattern_eth_ipv6_gtpu_eh,			ICE_MAC_IPV6_GTPU},
 	{pattern_eth_ipv6_gtpu_ipv4,			ICE_MAC_IPV6_GTPU_IPV4_PAY},
-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [dpdk-dev] [PATCH v6 0/3] support flow for IP fragment in ICE
  2021-04-13 10:06   ` [dpdk-dev] [PATCH v6 " Jeff Guo
                       ` (2 preceding siblings ...)
  2021-04-13 10:06     ` [dpdk-dev] [PATCH v6 3/3] net/ice: support FDIR for IP fragment packet Jeff Guo
@ 2021-04-29  3:12     ` Zhang, Qi Z
  3 siblings, 0 replies; 42+ messages in thread
From: Zhang, Qi Z @ 2021-04-29  3:12 UTC (permalink / raw)
  To: Guo, Jia, Yang, Qiming; +Cc: dev, Xu, Ting



> -----Original Message-----
> From: Guo, Jia <jia.guo@intel.com>
> Sent: Tuesday, April 13, 2021 6:06 PM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>
> Cc: dev@dpdk.org; Xu, Ting <ting.xu@intel.com>; Guo, Jia <jia.guo@intel.com>
> Subject: [PATCH v6 0/3] support flow for IP fragment in ICE
> 
> Support RSS hash and FDIR for IP fragment packets in ICE PMD.
> 
> v6:
> fix uninitialize issue
> v5:
> rebase code.
> v4:
> correct typo when define fragment
> v3:
> rebase code and fix some parsing issues.
> v2:
> add some input check
> 
> Jeff Guo (3):
>   net/ice/base: support IP fragment RSS and FDIR
>   net/ice: support RSS hash for IP fragment
>   net/ice: support FDIR for IP fragment packet
> 
>  drivers/net/ice/base/ice_fdir.c    |  50 +++++++++++-
>  drivers/net/ice/base/ice_fdir.h    |  22 +++++-
>  drivers/net/ice/base/ice_flow.c    |  50 +++++++++++-
>  drivers/net/ice/base/ice_flow.h    |   9 ++-
>  drivers/net/ice/base/ice_type.h    |   1 +
>  drivers/net/ice/ice_fdir_filter.c  | 118 ++++++++++++++++++++++++++---
> drivers/net/ice/ice_generic_flow.c |  22 ++++++
>  drivers/net/ice/ice_generic_flow.h |   6 ++
>  drivers/net/ice/ice_hash.c         |  46 +++++++++--
>  9 files changed, 294 insertions(+), 30 deletions(-)
> 
> --
> 2.20.1

Acked-by: Qi Zhang <qi.z.zhang@intel.com>

Patch 1/3 set to supersede as duplicate with 
http://patchwork.dpdk.org/project/dpdk/patch/20210429004143.2921260-7-qi.z.zhang@intel.com/

Patch 2/3, 3/3:
Applied to dpdk-next-net-intel.

Thanks
Qi


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [dpdk-dev] [PATCH v3 0/3] support flow for IP fragment in ICE
  2021-03-24 13:48 [dpdk-dev] [PATCH v2 0/4] support flow for IP fragment in IAVF Jeff Guo
@ 2021-04-11  6:07 ` Jeff Guo
  0 siblings, 0 replies; 42+ messages in thread
From: Jeff Guo @ 2021-04-11  6:07 UTC (permalink / raw)
  To: orika, qi.z.zhang, beilei.xing, xiaoyun.li, jingjing.wu
  Cc: dev, ting.xu, jia.guo

Support RSS hash and FDIR for IP fragment packets in ICE PMD.

v3:
rebase code and fix some parsing issues.
v2:
add some input check

Jeff Guo (3):
  net/ice/base: support IP fragment RSS and FDIR
  net/ice: support RSS hash for IP fragment
  net/ice: support FDIR for IP fragment packet

 drivers/net/ice/base/ice_fdir.c    |  50 ++++++++++++-
 drivers/net/ice/base/ice_fdir.h    |  22 +++++-
 drivers/net/ice/base/ice_flow.c    |  50 ++++++++++++-
 drivers/net/ice/base/ice_flow.h    |   5 +-
 drivers/net/ice/base/ice_type.h    |   1 +
 drivers/net/ice/ice_fdir_filter.c  | 116 ++++++++++++++++++++++++++---
 drivers/net/ice/ice_generic_flow.c |  22 ++++++
 drivers/net/ice/ice_generic_flow.h |   6 ++
 drivers/net/ice/ice_hash.c         |  48 ++++++++++--
 9 files changed, 293 insertions(+), 27 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

end of thread, other threads:[~2021-04-29  3:12 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-17  3:43 [dpdk-dev] [PATCH v1 0/3] support flow for IP fragment in ICE Jeff Guo
2021-03-17  3:43 ` [dpdk-dev] [PATCH v1 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
2021-03-17  3:43 ` [dpdk-dev] [PATCH v1 2/3] net/ice: support RSS hash for IP fragment Jeff Guo
2021-03-17  3:43 ` [dpdk-dev] [PATCH v1 3/3] net/ice: support FDIR for IP fragment packet Jeff Guo
2021-03-24 13:54 ` [dpdk-dev] [PATCH v2 0/3] support flow for IP fragment in ICE Jeff Guo
2021-03-24 13:54   ` [dpdk-dev] [PATCH v2 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
2021-03-24 13:54   ` [dpdk-dev] [PATCH v2 2/3] net/ice: support RSS hash for IP fragment Jeff Guo
2021-03-24 13:54   ` [dpdk-dev] [PATCH v2 3/3] net/ice: support FDIR for IP fragment packet Jeff Guo
2021-03-30  3:25     ` Xu, Ting
2021-04-02  2:06       ` Guo, Jia
2021-04-01  2:08     ` Xu, Ting
2021-04-02  1:53       ` Guo, Jia
2021-04-11  6:06   ` [dpdk-dev] [PATCH v3 0/3] support flow for IP fragment in ICE Jeff Guo
2021-04-11  6:06     ` [dpdk-dev] [PATCH v3 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
2021-04-12  8:31       ` Xu, Ting
2021-04-13  1:55         ` Guo, Jia
2021-04-11  6:06     ` [dpdk-dev] [PATCH v3 2/3] net/ice: support RSS hash for IP fragment Jeff Guo
2021-04-11  6:06     ` [dpdk-dev] [PATCH v3 3/3] net/ice: support FDIR for IP fragment packet Jeff Guo
2021-04-11  6:57   ` [dpdk-dev] [PATCH v3 0/3] support flow for IP fragment in ICE Jeff Guo
2021-04-11  6:57     ` [dpdk-dev] [PATCH v3 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
2021-04-11  6:57     ` [dpdk-dev] [PATCH v3 2/3] net/ice: support RSS hash for IP fragment Jeff Guo
2021-04-11  6:57     ` [dpdk-dev] [PATCH v3 3/3] net/ice: support FDIR for IP fragment packet Jeff Guo
2021-04-13  7:58   ` [dpdk-dev] [PATCH v4 0/3] support flow for IP fragment in ICE Jeff Guo
2021-04-13  7:58     ` [dpdk-dev] [PATCH v4 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
2021-04-13  7:58     ` [dpdk-dev] [PATCH v4 2/3] net/ice: support RSS hash for IP fragment Jeff Guo
2021-04-13  7:58     ` [dpdk-dev] [PATCH v4 3/3] net/ice: support FDIR for IP fragment packet Jeff Guo
2021-04-13  8:48   ` [dpdk-dev] [PATCH v4 0/3] support flow for IP fragment in ICE Jeff Guo
2021-04-13  8:48     ` [dpdk-dev] [PATCH v4 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
2021-04-13  8:48     ` [dpdk-dev] [PATCH v4 2/3] net/ice: support RSS hash for IP fragment Jeff Guo
2021-04-13  8:48     ` [dpdk-dev] [PATCH v4 3/3] net/ice: support FDIR for IP fragment packet Jeff Guo
2021-04-13  9:02     ` [dpdk-dev] [PATCH v4 0/3] support flow for IP fragment in ICE Xu, Ting
2021-04-13  9:38   ` [dpdk-dev] [PATCH v5 " Jeff Guo
2021-04-13  9:38     ` [dpdk-dev] [PATCH v5 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
2021-04-13  9:38     ` [dpdk-dev] [PATCH v5 2/3] net/ice: support RSS hash for IP fragment Jeff Guo
2021-04-13  9:38     ` [dpdk-dev] [PATCH v5 3/3] net/ice: support FDIR for IP fragment packet Jeff Guo
2021-04-13  9:46     ` [dpdk-dev] [PATCH v5 0/3] support flow for IP fragment in ICE Xu, Ting
2021-04-13 10:06   ` [dpdk-dev] [PATCH v6 " Jeff Guo
2021-04-13 10:06     ` [dpdk-dev] [PATCH v6 1/3] net/ice/base: support IP fragment RSS and FDIR Jeff Guo
2021-04-13 10:06     ` [dpdk-dev] [PATCH v6 2/3] net/ice: support RSS hash for IP fragment Jeff Guo
2021-04-13 10:06     ` [dpdk-dev] [PATCH v6 3/3] net/ice: support FDIR for IP fragment packet Jeff Guo
2021-04-29  3:12     ` [dpdk-dev] [PATCH v6 0/3] support flow for IP fragment in ICE Zhang, Qi Z
2021-03-24 13:48 [dpdk-dev] [PATCH v2 0/4] support flow for IP fragment in IAVF Jeff Guo
2021-04-11  6:07 ` [dpdk-dev] [PATCH v3 0/3] support flow for IP fragment in ICE Jeff Guo

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git