DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jeff Guo <jia.guo@intel.com>
To: qi.z.zhang@intel.com, qiming.yang@intel.com
Cc: dev@dpdk.org, ting.xu@intel.com, jia.guo@intel.com
Subject: [dpdk-dev] [PATCH v3 3/3] net/ice: support FDIR for IP fragment packet
Date: Sun, 11 Apr 2021 14:06:59 +0800
Message-ID: <20210411060659.72525-4-jia.guo@intel.com> (raw)
In-Reply-To: <20210411060659.72525-1-jia.guo@intel.com>

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


  parent reply	other threads:[~2021-04-11  6:12 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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     ` Jeff Guo [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210411060659.72525-4-jia.guo@intel.com \
    --to=jia.guo@intel.com \
    --cc=dev@dpdk.org \
    --cc=qi.z.zhang@intel.com \
    --cc=qiming.yang@intel.com \
    --cc=ting.xu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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