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 4/4] net/iavf: support Protocol Agnostic Flow Offloading VF RSS
Date: Thu, 21 Apr 2022 11:28:51 +0800	[thread overview]
Message-ID: <20220421032851.1355350-5-junfeng.guo@intel.com> (raw)
In-Reply-To: <20220421032851.1355350-1-junfeng.guo@intel.com>

From: Ting Xu <ting.xu@intel.com>

Enable Protocol Agnostic Flow Offloading RSS hash for VF.

Signed-off-by: Ting Xu <ting.xu@intel.com>
---
 drivers/net/iavf/iavf_hash.c | 96 ++++++++++++++++++++++++++++++++++++
 1 file changed, 96 insertions(+)

diff --git a/drivers/net/iavf/iavf_hash.c b/drivers/net/iavf/iavf_hash.c
index 278e75117d..42df7c4e48 100644
--- a/drivers/net/iavf/iavf_hash.c
+++ b/drivers/net/iavf/iavf_hash.c
@@ -37,6 +37,8 @@
 /* L2TPv2 */
 #define IAVF_PHINT_L2TPV2			BIT_ULL(9)
 #define IAVF_PHINT_L2TPV2_LEN			BIT_ULL(10)
+/* Raw */
+#define IAVF_PHINT_RAW				BIT_ULL(11)
 
 #define IAVF_PHINT_GTPU_MSK	(IAVF_PHINT_GTPU	| \
 				 IAVF_PHINT_GTPU_EH	| \
@@ -58,6 +60,7 @@ struct iavf_hash_match_type {
 struct iavf_rss_meta {
 	struct virtchnl_proto_hdrs proto_hdrs;
 	enum virtchnl_rss_algorithm rss_algorithm;
+	bool raw_ena;
 };
 
 struct iavf_hash_flow_cfg {
@@ -532,6 +535,7 @@ struct virtchnl_proto_hdrs ipv6_l2tpv2_ppp_tmplt = {
  */
 static struct iavf_pattern_match_item iavf_hash_pattern_list[] = {
 	/* IPv4 */
+	{iavf_pattern_raw,				IAVF_INSET_NONE,		NULL},
 	{iavf_pattern_eth_ipv4,				IAVF_RSS_TYPE_OUTER_IPV4,	&outer_ipv4_tmplt},
 	{iavf_pattern_eth_ipv4_udp,			IAVF_RSS_TYPE_OUTER_IPV4_UDP,	&outer_ipv4_udp_tmplt},
 	{iavf_pattern_eth_ipv4_tcp,			IAVF_RSS_TYPE_OUTER_IPV4_TCP,	&outer_ipv4_tcp_tmplt},
@@ -804,6 +808,9 @@ iavf_hash_parse_pattern(const struct rte_flow_item pattern[], uint64_t *phint,
 		}
 
 		switch (item->type) {
+		case RTE_FLOW_ITEM_TYPE_RAW:
+			*phint |= IAVF_PHINT_RAW;
+			break;
 		case RTE_FLOW_ITEM_TYPE_IPV4:
 			if (!(*phint & IAVF_PHINT_GTPU_MSK) &&
 			    !(*phint & IAVF_PHINT_GRE) &&
@@ -873,6 +880,80 @@ iavf_hash_parse_pattern(const struct rte_flow_item pattern[], uint64_t *phint,
 	return 0;
 }
 
+static int
+iavf_hash_parse_raw_pattern(const struct rte_flow_item *item,
+			struct iavf_rss_meta *meta)
+{
+	const struct rte_flow_item_raw *raw_spec, *raw_mask;
+	uint8_t *pkt_buf, *msk_buf;
+	uint8_t spec_len, pkt_len;
+	uint8_t tmp_val = 0;
+	uint8_t tmp_c = 0;
+	int i, j;
+
+	raw_spec = item->spec;
+	raw_mask = item->mask;
+
+	spec_len = strlen((char *)(uintptr_t)raw_spec->pattern);
+	if (strlen((char *)(uintptr_t)raw_mask->pattern) !=
+		spec_len)
+		return -rte_errno;
+
+	pkt_len = spec_len / 2;
+
+	pkt_buf = rte_zmalloc(NULL, pkt_len, 0);
+	if (!pkt_buf)
+		return -ENOMEM;
+
+	msk_buf = rte_zmalloc(NULL, pkt_len, 0);
+	if (!msk_buf)
+		return -ENOMEM;
+
+	/* convert string to int array */
+	for (i = 0, j = 0; i < spec_len; i += 2, j++) {
+		tmp_c = raw_spec->pattern[i];
+		if (tmp_c >= 'a' && tmp_c <= 'f')
+			tmp_val = tmp_c - 'a' + 10;
+		if (tmp_c >= 'A' && tmp_c <= 'F')
+			tmp_val = tmp_c - 'A' + 10;
+		if (tmp_c >= '0' && tmp_c <= '9')
+			tmp_val = tmp_c - '0';
+
+		tmp_c = raw_spec->pattern[i + 1];
+		if (tmp_c >= 'a' && tmp_c <= 'f')
+			pkt_buf[j] = tmp_val * 16 + tmp_c - 'a' + 10;
+		if (tmp_c >= 'A' && tmp_c <= 'F')
+			pkt_buf[j] = tmp_val * 16 + tmp_c - 'A' + 10;
+		if (tmp_c >= '0' && tmp_c <= '9')
+			pkt_buf[j] = tmp_val * 16 + tmp_c - '0';
+
+		tmp_c = raw_mask->pattern[i];
+		if (tmp_c >= 'a' && tmp_c <= 'f')
+			tmp_val = tmp_c - 0x57;
+		if (tmp_c >= 'A' && tmp_c <= 'F')
+			tmp_val = tmp_c - 0x37;
+		if (tmp_c >= '0' && tmp_c <= '9')
+			tmp_val = tmp_c - '0';
+
+		tmp_c = raw_mask->pattern[i + 1];
+		if (tmp_c >= 'a' && tmp_c <= 'f')
+			msk_buf[j] = tmp_val * 16 + tmp_c - 'a' + 10;
+		if (tmp_c >= 'A' && tmp_c <= 'F')
+			msk_buf[j] = tmp_val * 16 + tmp_c - 'A' + 10;
+		if (tmp_c >= '0' && tmp_c <= '9')
+			msk_buf[j] = tmp_val * 16 + tmp_c - '0';
+	}
+
+	rte_memcpy(meta->proto_hdrs.raw.spec, pkt_buf, pkt_len);
+	rte_memcpy(meta->proto_hdrs.raw.mask, msk_buf, pkt_len);
+	meta->proto_hdrs.raw.pkt_len = pkt_len;
+
+	rte_free(pkt_buf);
+	rte_free(msk_buf);
+
+	return 0;
+}
+
 #define REFINE_PROTO_FLD(op, fld) \
 	VIRTCHNL_##op##_PROTO_HDR_FIELD(hdr, VIRTCHNL_PROTO_HDR_##fld)
 #define REPALCE_PROTO_FLD(fld_1, fld_2) \
@@ -1387,6 +1468,10 @@ iavf_hash_parse_action(struct iavf_pattern_match_item *match_item,
 					RTE_FLOW_ERROR_TYPE_ACTION, action,
 					"a non-NULL RSS queue is not supported");
 
+			/* If pattern type is raw, no need to refine rss type */
+			if (pattern_hint == IAVF_PHINT_RAW)
+				break;
+
 			/**
 			 * Check simultaneous use of SRC_ONLY and DST_ONLY
 			 * of the same level.
@@ -1453,6 +1538,17 @@ iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad,
 	if (ret)
 		goto error;
 
+	if (phint == IAVF_PHINT_RAW) {
+		rss_meta_ptr->raw_ena = true;
+		ret = iavf_hash_parse_raw_pattern(pattern, rss_meta_ptr);
+		if (ret) {
+			rte_flow_error_set(error, EINVAL,
+					   RTE_FLOW_ERROR_TYPE_ITEM, NULL,
+					   "Parse raw pattern failed");
+			goto error;
+		}
+	}
+
 	ret = iavf_hash_parse_action(pattern_match_item, actions, phint,
 				     rss_meta_ptr, error);
 
-- 
2.25.1


  parent reply	other threads:[~2022-04-21  3:29 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             ` [PATCH v4 3/4] net/iavf: enable Protocol Agnostic Flow Offloading FDIR Junfeng Guo
2022-04-21  3:28             ` Junfeng Guo [this message]
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-5-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).