DPDK patches and discussions
 help / color / mirror / Atom feed
From: Junfeng Guo <junfeng.guo@intel.com>
To: qi.z.zhang@intel.com, jingjing.wu@intel.com, beilei.xing@intel.com
Cc: dev@dpdk.org, ting.xu@intel.com, junfeng.guo@intel.com
Subject: [PATCH v4 3/4] net/iavf: enable Protocol Agnostic Flow Offloading FDIR
Date: Thu, 21 Apr 2022 11:28:50 +0800	[thread overview]
Message-ID: <20220421032851.1355350-4-junfeng.guo@intel.com> (raw)
In-Reply-To: <20220421032851.1355350-1-junfeng.guo@intel.com>

This patch enabled Protocol Agnostic Flow Offloading FDIR in AVF.

Signed-off-by: Junfeng Guo <junfeng.guo@intel.com>
---
 doc/guides/rel_notes/release_22_07.rst |  1 +
 drivers/net/iavf/iavf_fdir.c           | 67 ++++++++++++++++++++++++++
 drivers/net/iavf/iavf_generic_flow.c   |  6 +++
 drivers/net/iavf/iavf_generic_flow.h   |  3 ++
 4 files changed, 77 insertions(+)

diff --git a/doc/guides/rel_notes/release_22_07.rst b/doc/guides/rel_notes/release_22_07.rst
index f1b4057d70..5091dde171 100644
--- a/doc/guides/rel_notes/release_22_07.rst
+++ b/doc/guides/rel_notes/release_22_07.rst
@@ -59,6 +59,7 @@ New Features
 
   * Added Tx QoS queue rate limitation support.
   * Added quanta size configuration support.
+  * Added Protocol Agnostic Flow Offloading support in AVF FDIR and RSS.
 
 Removed Items
 -------------
diff --git a/drivers/net/iavf/iavf_fdir.c b/drivers/net/iavf/iavf_fdir.c
index e9a3566c0d..f236260502 100644
--- a/drivers/net/iavf/iavf_fdir.c
+++ b/drivers/net/iavf/iavf_fdir.c
@@ -194,6 +194,7 @@
 	IAVF_INSET_TUN_TCP_DST_PORT)
 
 static struct iavf_pattern_match_item iavf_fdir_pattern[] = {
+	{iavf_pattern_raw,			 IAVF_INSET_NONE,		IAVF_INSET_NONE},
 	{iavf_pattern_ethertype,		 IAVF_FDIR_INSET_ETH,		IAVF_INSET_NONE},
 	{iavf_pattern_eth_ipv4,			 IAVF_FDIR_INSET_ETH_IPV4,	IAVF_INSET_NONE},
 	{iavf_pattern_eth_ipv4_udp,		 IAVF_FDIR_INSET_ETH_IPV4_UDP,	IAVF_INSET_NONE},
@@ -720,6 +721,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 	struct virtchnl_proto_hdrs *hdrs =
 			&filter->add_fltr.rule_cfg.proto_hdrs;
 	enum rte_flow_item_type l3 = RTE_FLOW_ITEM_TYPE_END;
+	const struct rte_flow_item_raw *raw_spec, *raw_mask;
 	const struct rte_flow_item_eth *eth_spec, *eth_mask;
 	const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_last, *ipv4_mask;
 	const struct rte_flow_item_ipv6 *ipv6_spec, *ipv6_mask;
@@ -746,6 +748,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 	enum rte_flow_item_type next_type;
 	uint8_t tun_inner = 0;
 	uint16_t ether_type, flags_version;
+	uint8_t item_num = 0;
 	int layer = 0;
 
 	uint8_t  ipv6_addr_mask[16] = {
@@ -763,8 +766,72 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 					   RTE_FLOW_ERROR_TYPE_ITEM, item,
 					   "Not support range");
 		}
+		item_num++;
 
 		switch (item_type) {
+		case RTE_FLOW_ITEM_TYPE_RAW: {
+			raw_spec = item->spec;
+			raw_mask = item->mask;
+
+			if (item_num != 1)
+				return -rte_errno;
+
+			if (raw_spec->length != raw_mask->length)
+				return -rte_errno;
+
+			uint16_t pkt_len = 0;
+			uint16_t tmp_val = 0;
+			uint8_t tmp = 0;
+			int i, j;
+
+			pkt_len = raw_spec->length;
+
+			for (i = 0, j = 0; i < pkt_len; i += 2, j++) {
+				tmp = raw_spec->pattern[i];
+				if (tmp >= 'a' && tmp <= 'f')
+					tmp_val = tmp - 'a' + 10;
+				if (tmp >= 'A' && tmp <= 'F')
+					tmp_val = tmp - 'A' + 10;
+				if (tmp >= '0' && tmp <= '9')
+					tmp_val = tmp - '0';
+
+				tmp_val *= 16;
+				tmp = raw_spec->pattern[i + 1];
+				if (tmp >= 'a' && tmp <= 'f')
+					tmp_val += (tmp - 'a' + 10);
+				if (tmp >= 'A' && tmp <= 'F')
+					tmp_val += (tmp - 'A' + 10);
+				if (tmp >= '0' && tmp <= '9')
+					tmp_val += (tmp - '0');
+
+				hdrs->raw.spec[j] = tmp_val;
+
+				tmp = raw_mask->pattern[i];
+				if (tmp >= 'a' && tmp <= 'f')
+					tmp_val = tmp - 'a' + 10;
+				if (tmp >= 'A' && tmp <= 'F')
+					tmp_val = tmp - 'A' + 10;
+				if (tmp >= '0' && tmp <= '9')
+					tmp_val = tmp - '0';
+
+				tmp_val *= 16;
+				tmp = raw_mask->pattern[i + 1];
+				if (tmp >= 'a' && tmp <= 'f')
+					tmp_val += (tmp - 'a' + 10);
+				if (tmp >= 'A' && tmp <= 'F')
+					tmp_val += (tmp - 'A' + 10);
+				if (tmp >= '0' && tmp <= '9')
+					tmp_val += (tmp - '0');
+
+				hdrs->raw.mask[j] = tmp_val;
+			}
+
+			hdrs->raw.pkt_len = pkt_len / 2;
+			hdrs->tunnel_level = 0;
+			hdrs->count = 0;
+			return 0;
+		}
+
 		case RTE_FLOW_ITEM_TYPE_ETH:
 			eth_spec = item->spec;
 			eth_mask = item->mask;
diff --git a/drivers/net/iavf/iavf_generic_flow.c b/drivers/net/iavf/iavf_generic_flow.c
index ddc1fdd22b..e1a611e319 100644
--- a/drivers/net/iavf/iavf_generic_flow.c
+++ b/drivers/net/iavf/iavf_generic_flow.c
@@ -48,6 +48,12 @@ const struct rte_flow_ops iavf_flow_ops = {
 	.query = iavf_flow_query,
 };
 
+/* raw */
+enum rte_flow_item_type iavf_pattern_raw[] = {
+	RTE_FLOW_ITEM_TYPE_RAW,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+
 /* empty */
 enum rte_flow_item_type iavf_pattern_empty[] = {
 	RTE_FLOW_ITEM_TYPE_END,
diff --git a/drivers/net/iavf/iavf_generic_flow.h b/drivers/net/iavf/iavf_generic_flow.h
index f6af176073..52eb1caf29 100644
--- a/drivers/net/iavf/iavf_generic_flow.h
+++ b/drivers/net/iavf/iavf_generic_flow.h
@@ -180,6 +180,9 @@
 #define IAVF_INSET_L2TPV2 \
 	(IAVF_PROT_L2TPV2 | IAVF_L2TPV2_SESSION_ID)
 
+/* raw pattern */
+extern enum rte_flow_item_type iavf_pattern_raw[];
+
 /* empty pattern */
 extern enum rte_flow_item_type iavf_pattern_empty[];
 
-- 
2.25.1


  parent reply	other threads:[~2022-04-21  3:28 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-07  6:27 [PATCH 0/3] Enable Protocol Agnostic Flow Offloading FDIR in AVF Junfeng Guo
2022-04-07  6:27 ` [PATCH 1/3] common/iavf: support raw packet in protocol header Junfeng Guo
2022-04-07  6:27 ` [PATCH 2/3] net/iavf: align with proto hdr struct change Junfeng Guo
2022-04-07  6:27 ` [PATCH 3/3] net/iavf: enable Protocol Agnostic Flow Offloading FDIR Junfeng Guo
2022-04-08  8:02   ` [PATCH v2 0/3] Enable Protocol Agnostic Flow Offloading FDIR in AVF Junfeng Guo
2022-04-08  8:02     ` [PATCH v2 1/3] common/iavf: support raw packet in protocol header Junfeng Guo
2022-04-08  8:02     ` [PATCH v2 2/3] net/iavf: align with proto hdr struct change Junfeng Guo
2022-04-08  8:02     ` [PATCH v2 3/3] net/iavf: enable Protocol Agnostic Flow Offloading FDIR Junfeng Guo
2022-04-08  9:12       ` [PATCH v3 0/3] Enable Protocol Agnostic Flow Offloading FDIR in AVF Junfeng Guo
2022-04-08  9:12         ` [PATCH v3 1/3] common/iavf: support raw packet in protocol header Junfeng Guo
2022-04-08  9:12         ` [PATCH v3 2/3] net/iavf: align with proto hdr struct change Junfeng Guo
2022-04-08  9:12         ` [PATCH v3 3/3] net/iavf: enable Protocol Agnostic Flow Offloading FDIR Junfeng Guo
2022-04-21  3:28           ` [PATCH v4 0/4] Enable Protocol Agnostic Flow Offloading in AVF Junfeng Guo
2022-04-21  3:28             ` [PATCH v4 1/4] common/iavf: support raw packet in protocol header Junfeng Guo
2022-05-21  1:34               ` Zhang, Qi Z
2022-04-21  3:28             ` [PATCH v4 2/4] net/iavf: align with proto hdr struct change Junfeng Guo
2022-04-21  3:28             ` Junfeng Guo [this message]
2022-04-21  3:28             ` [PATCH v4 4/4] net/iavf: support Protocol Agnostic Flow Offloading VF RSS Junfeng Guo
2022-05-20  9:16               ` [PATCH v5 0/4] Enable Protocol Agnostic Flow Offloading in AVF Junfeng Guo
2022-05-20  9:16                 ` [PATCH v5 1/4] common/iavf: support raw packet in protocol header Junfeng Guo
2022-05-23  2:31                   ` [PATCH v6 0/3] Enable Protocol Agnostic Flow Offloading in AVF Junfeng Guo
2022-05-23  2:31                     ` [PATCH v6 1/3] common/iavf: support raw packet in protocol header Junfeng Guo
2022-05-23  2:31                     ` [PATCH 1/2] net/iavf: enable Protocol Agnostic Flow Offloading FDIR Junfeng Guo
2022-05-23  2:44                       ` Guo, Junfeng
2022-05-23  2:31                     ` [PATCH v6 2/3] " Junfeng Guo
2022-05-23  5:10                       ` Zhang, Qi Z
2022-05-23  2:31                     ` [PATCH 2/2] net/iavf: support Protocol Agnostic Flow Offloading VF RSS Junfeng Guo
2022-05-23  2:45                       ` Guo, Junfeng
2022-05-23  2:31                     ` [PATCH v6 3/3] " Junfeng Guo
2022-05-23  5:09                     ` [PATCH v6 0/3] Enable Protocol Agnostic Flow Offloading in AVF Zhang, Qi Z
2022-06-05 17:43                       ` Thomas Monjalon
2022-06-05 23:10                         ` Zhang, Qi Z
2022-05-20  9:16                 ` [PATCH v5 2/4] net/iavf: align with proto hdr struct change Junfeng Guo
2022-05-20  9:16                 ` [PATCH v5 3/4] net/iavf: enable Protocol Agnostic Flow Offloading FDIR Junfeng Guo
2022-05-20  9:16                 ` [PATCH v5 4/4] net/iavf: support Protocol Agnostic Flow Offloading VF RSS Junfeng Guo

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=20220421032851.1355350-4-junfeng.guo@intel.com \
    --to=junfeng.guo@intel.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.com \
    --cc=qi.z.zhang@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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).