DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v1 0/2] enable protocol agnostic flow offloading in RSS
@ 2021-10-08  7:09 Ting Xu
  2021-10-08  7:09 ` [dpdk-dev] [PATCH v1 1/2] net/ice: " Ting Xu
                   ` (5 more replies)
  0 siblings, 6 replies; 29+ messages in thread
From: Ting Xu @ 2021-10-08  7:09 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, qiming.yang, Ting Xu

Enable protocol agnostic flow offloading to support raw pattern input
for RSS hash flow rule creation. It is based on Parser Libary feature.
Current rte_flow raw API is utilized.

Ting Xu (2):
  net/ice: enable protocol agnostic flow offloading in RSS
  doc: add protocol agnostic flow offloading for RSS hash

 doc/guides/rel_notes/release_21_11.rst |   1 +
 drivers/net/ice/ice_hash.c             | 182 ++++++++++++++++++++++---
 2 files changed, 161 insertions(+), 22 deletions(-)

-- 
2.17.1


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

* [dpdk-dev] [PATCH v1 1/2] net/ice: enable protocol agnostic flow offloading in RSS
  2021-10-08  7:09 [dpdk-dev] [PATCH v1 0/2] enable protocol agnostic flow offloading in RSS Ting Xu
@ 2021-10-08  7:09 ` Ting Xu
  2021-10-08  7:09 ` [dpdk-dev] [PATCH v1 2/2] doc: add protocol agnostic flow offloading for RSS hash Ting Xu
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 29+ messages in thread
From: Ting Xu @ 2021-10-08  7:09 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, qiming.yang, Ting Xu

Enable protocol agnostic flow offloading to support raw pattern input
for RSS hash flow rule creation. It is based on Parser Libary feature.
Current rte_flow raw API is utilized.

Signed-off-by: Ting Xu <ting.xu@intel.com>
---
 drivers/net/ice/ice_hash.c | 182 ++++++++++++++++++++++++++++++++-----
 1 file changed, 160 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c
index df1bdfd284..07b98d1455 100644
--- a/drivers/net/ice/ice_hash.c
+++ b/drivers/net/ice/ice_hash.c
@@ -32,6 +32,7 @@
 #define ICE_PHINT_GTPU_EH			BIT_ULL(3)
 #define	ICE_PHINT_GTPU_EH_DWN			BIT_ULL(4)
 #define	ICE_PHINT_GTPU_EH_UP			BIT_ULL(5)
+#define ICE_PHINT_RAW				BIT_ULL(6)
 
 #define ICE_GTPU_EH_DWNLINK	0
 #define ICE_GTPU_EH_UPLINK	1
@@ -71,6 +72,7 @@
 struct ice_rss_meta {
 	uint8_t hash_function;
 	struct ice_rss_hash_cfg cfg;
+	struct ice_rss_raw_cfg raw;
 };
 
 struct ice_hash_flow_cfg {
@@ -492,6 +494,7 @@ struct ice_rss_hash_cfg eth_tmplt = {
  */
 static struct ice_pattern_match_item ice_hash_pattern_list[] = {
 	/* IPV4 */
+	{pattern_raw,				ICE_INSET_NONE,				ICE_INSET_NONE,	NULL},
 	{pattern_eth_ipv4,			ICE_RSS_TYPE_ETH_IPV4,		ICE_INSET_NONE,	&ipv4_tmplt},
 	{pattern_eth_ipv4_udp,			ICE_RSS_TYPE_ETH_IPV4_UDP,	ICE_INSET_NONE,	&ipv4_udp_tmplt},
 	{pattern_eth_ipv4_tcp,			ICE_RSS_TYPE_ETH_IPV4_TCP,	ICE_INSET_NONE,	&ipv4_tcp_tmplt},
@@ -612,6 +615,9 @@ ice_hash_parse_pattern(const struct rte_flow_item pattern[], uint64_t *phint,
 		}
 
 		switch (item->type) {
+		case RTE_FLOW_ITEM_TYPE_RAW:
+			*phint |= ICE_PHINT_RAW;
+			break;
 		case RTE_FLOW_ITEM_TYPE_VLAN:
 			*phint |= ICE_PHINT_VLAN;
 			break;
@@ -639,6 +645,91 @@ ice_hash_parse_pattern(const struct rte_flow_item pattern[], uint64_t *phint,
 	return 0;
 }
 
+static int
+ice_hash_parse_raw_pattern(struct ice_adapter *ad,
+				const struct rte_flow_item *item,
+				struct ice_rss_meta *meta)
+{
+	const struct rte_flow_item_raw *raw_spec, *raw_mask;
+	struct ice_parser_profile prof;
+	struct ice_parser_result rslt;
+	struct ice_parser *psr;
+	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';
+	}
+
+	if (ice_parser_create(&ad->hw, &psr))
+		return -rte_errno;
+	if (ice_parser_run(psr, pkt_buf, pkt_len, &rslt))
+		return -rte_errno;
+	ice_parser_destroy(psr);
+
+	if (ice_parser_profile_init(&rslt, pkt_buf, msk_buf,
+		pkt_len, ICE_BLK_RSS, true, &prof))
+		return -rte_errno;
+
+	rte_memcpy(&meta->raw.prof, &prof, sizeof(prof));
+
+	rte_free(pkt_buf);
+	rte_free(msk_buf);
+	return 0;
+}
+
 static void
 ice_refine_hash_cfg_l234(struct ice_rss_hash_cfg *hash_cfg,
 			 uint64_t rss_type)
@@ -999,7 +1090,10 @@ ice_hash_parse_action(struct ice_pattern_match_item *pattern_match_item,
 				   RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ) {
 				rss_meta->hash_function =
 				RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
-				cfg->symm = true;
+				if (pattern_hint == ICE_PHINT_RAW)
+					rss_meta->raw.symm = true;
+				else
+					cfg->symm = true;
 			}
 
 			if (rss->level)
@@ -1017,6 +1111,10 @@ ice_hash_parse_action(struct ice_pattern_match_item *pattern_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 == ICE_PHINT_RAW)
+				break;
+
 			/**
 			 * Check simultaneous use of SRC_ONLY and DST_ONLY
 			 * of the same level.
@@ -1085,6 +1183,17 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,
 	if (ret)
 		goto error;
 
+	if (phint == ICE_PHINT_RAW) {
+		rss_meta_ptr->raw.raw_ena = true;
+		ret = ice_hash_parse_raw_pattern(ad, pattern, rss_meta_ptr);
+		if (ret) {
+			rte_flow_error_set(error, EINVAL,
+					   RTE_FLOW_ERROR_TYPE_ITEM, NULL,
+					   "Parse raw pattern failed");
+			goto error;
+		}
+	}
+
 	/* Check rss action. */
 	ret = ice_hash_parse_action(pattern_match_item, actions, phint,
 				    (void **)&rss_meta_ptr, error);
@@ -1134,15 +1243,30 @@ ice_hash_create(struct ice_adapter *ad,
 
 		goto out;
 	} else {
-		memcpy(&filter_ptr->rss_cfg.hash, &rss_meta->cfg,
-		       sizeof(struct ice_rss_hash_cfg));
-		ret = ice_add_rss_cfg_wrap(pf, vsi->idx,
-					   &filter_ptr->rss_cfg.hash);
-		if (ret) {
-			rte_flow_error_set(error, EINVAL,
-					RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
-					"rss flow create fail");
-			goto error;
+		if (rss_meta->raw.raw_ena) {
+			memcpy(&filter_ptr->rss_cfg.raw, &rss_meta->raw,
+			       sizeof(struct ice_rss_raw_cfg));
+			ret = ice_add_rss_raw_cfg(hw, &rss_meta->raw,
+						  pf->main_vsi->idx);
+			if (ret) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_HANDLE,
+						   NULL,
+						   "rss flow create fail");
+				goto error;
+			}
+		} else {
+			memcpy(&filter_ptr->rss_cfg.hash, &rss_meta->cfg,
+			       sizeof(struct ice_rss_hash_cfg));
+			ret = ice_add_rss_cfg_wrap(pf, vsi->idx,
+						   &filter_ptr->rss_cfg.hash);
+			if (ret) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_HANDLE,
+						   NULL,
+						   "rss flow create fail");
+				goto error;
+			}
 		}
 	}
 
@@ -1178,18 +1302,32 @@ ice_hash_destroy(struct ice_adapter *ad,
 			(1 << VSIQF_HASH_CTL_HASH_SCHEME_S);
 		ICE_WRITE_REG(hw, VSIQF_HASH_CTL(vsi->vsi_id), reg);
 	} else {
-		ret = ice_rem_rss_cfg_wrap(pf, vsi->idx,
-					   &filter_ptr->rss_cfg.hash);
-		/* Fixme: Ignore the error if a rule does not exist.
-		 * Currently a rule for inputset change or symm turn on/off
-		 * will overwrite an exist rule, while application still
-		 * have 2 rte_flow handles.
-		 **/
-		if (ret && ret != ICE_ERR_DOES_NOT_EXIST) {
-			rte_flow_error_set(error, EINVAL,
-					RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
-					"rss flow destroy fail");
-			goto error;
+		if (filter_ptr->rss_cfg.raw.raw_ena) {
+			ret =
+			ice_rem_rss_raw_cfg(hw, &filter_ptr->rss_cfg.raw.prof,
+					    pf->main_vsi->idx);
+			if (ret) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_HANDLE,
+						   NULL,
+						   "rss flow destroy fail");
+				goto error;
+			}
+		} else {
+			ret = ice_rem_rss_cfg_wrap(pf, vsi->idx,
+						   &filter_ptr->rss_cfg.hash);
+			/* Fixme: Ignore the error if a rule does not exist.
+			 * Currently a rule for inputset change or symm turn
+			 * on/off will overwrite an exist rule, while
+			 * application still have 2 rte_flow handles.
+			 **/
+			if (ret && ret != ICE_ERR_DOES_NOT_EXIST) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_HANDLE,
+						   NULL,
+						   "rss flow destroy fail");
+				goto error;
+			}
 		}
 	}
 
-- 
2.17.1


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

* [dpdk-dev] [PATCH v1 2/2] doc: add protocol agnostic flow offloading for RSS hash
  2021-10-08  7:09 [dpdk-dev] [PATCH v1 0/2] enable protocol agnostic flow offloading in RSS Ting Xu
  2021-10-08  7:09 ` [dpdk-dev] [PATCH v1 1/2] net/ice: " Ting Xu
@ 2021-10-08  7:09 ` Ting Xu
  2021-11-01 11:02 ` [dpdk-dev] [PATCH v2 0/3] enable protocol agnostic flow offloading in RSS Ting Xu
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 29+ messages in thread
From: Ting Xu @ 2021-10-08  7:09 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, qiming.yang, Ting Xu

Protocol agnostic flow offloading for RSS hash is supported. Raw pattern
input can be used to create RSS hash flow rules, using current rte_flow
raw API.

Signed-off-by: Ting Xu <ting.xu@intel.com>
---
 doc/guides/rel_notes/release_21_11.rst | 1 +
 1 file changed, 1 insertion(+)

diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst
index b71e256835..b1bdb62417 100644
--- a/doc/guides/rel_notes/release_21_11.rst
+++ b/doc/guides/rel_notes/release_21_11.rst
@@ -86,6 +86,7 @@ New Features
 
   * Added 1PPS out support by a devargs.
   * Added IPv4 and L4(TCP/UDP/SCTP) checksum hash support in RSS flow.
+  * Added protocol agnostic flow offloading for RSS hash.
 
 * **Updated Marvell cnxk ethdev driver.**
 
-- 
2.17.1


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

* [dpdk-dev] [PATCH v2 0/3] enable protocol agnostic flow offloading in RSS
  2021-10-08  7:09 [dpdk-dev] [PATCH v1 0/2] enable protocol agnostic flow offloading in RSS Ting Xu
  2021-10-08  7:09 ` [dpdk-dev] [PATCH v1 1/2] net/ice: " Ting Xu
  2021-10-08  7:09 ` [dpdk-dev] [PATCH v1 2/2] doc: add protocol agnostic flow offloading for RSS hash Ting Xu
@ 2021-11-01 11:02 ` Ting Xu
  2021-11-01 11:02   ` [dpdk-dev] [PATCH v2 1/3] net/ice: " Ting Xu
                     ` (2 more replies)
  2021-11-01 11:05 ` [dpdk-dev] [PATCH v2 0/3] enable protocol agnostic flow offloading in RSS Ting Xu
                   ` (2 subsequent siblings)
  5 siblings, 3 replies; 29+ messages in thread
From: Ting Xu @ 2021-11-01 11:02 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, qiming.yang, Ting Xu

Enable protocol agnostic flow offloading to support raw pattern input
for RSS hash flow rule creation. It is based on Parser Libary feature.
Current rte_flow raw API is utilized.

Ting Xu (3):
  net/ice/base: support add HW profile for RSS raw flow
  net/ice: enable protocol agnostic flow offloading in RSS
  doc: add protocol agnostic flow offloading for RSS

 doc/guides/rel_notes/release_21_11.rst |   1 +
 drivers/net/ice/base/ice_flow.c        | 109 ++++++++++
 drivers/net/ice/base/ice_flow.h        |  16 ++
 drivers/net/ice/ice_ethdev.h           |   9 +
 drivers/net/ice/ice_hash.c             | 286 +++++++++++++++++++++++--
 5 files changed, 399 insertions(+), 22 deletions(-)

-- 
2.17.1


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

* [dpdk-dev] [PATCH v2 1/3] net/ice: enable protocol agnostic flow offloading in RSS
  2021-11-01 11:02 ` [dpdk-dev] [PATCH v2 0/3] enable protocol agnostic flow offloading in RSS Ting Xu
@ 2021-11-01 11:02   ` Ting Xu
  2021-11-01 11:02   ` [dpdk-dev] [PATCH v2 2/3] " Ting Xu
  2021-11-01 11:02   ` [dpdk-dev] [PATCH v2 3/3] doc: add protocol agnostic flow offloading for RSS Ting Xu
  2 siblings, 0 replies; 29+ messages in thread
From: Ting Xu @ 2021-11-01 11:02 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, qiming.yang, Ting Xu

Enable protocol agnostic flow offloading to support raw pattern input
for RSS hash flow rule creation. It is based on Parser Libary feature.
Current rte_flow raw API is utilized.

Signed-off-by: Ting Xu <ting.xu@intel.com>
---
 drivers/net/ice/ice_hash.c | 182 ++++++++++++++++++++++++++++++++-----
 1 file changed, 160 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c
index 20a3204fab..eade5f996c 100644
--- a/drivers/net/ice/ice_hash.c
+++ b/drivers/net/ice/ice_hash.c
@@ -32,6 +32,7 @@
 #define ICE_PHINT_GTPU_EH			BIT_ULL(3)
 #define	ICE_PHINT_GTPU_EH_DWN			BIT_ULL(4)
 #define	ICE_PHINT_GTPU_EH_UP			BIT_ULL(5)
+#define ICE_PHINT_RAW				BIT_ULL(6)
 
 #define ICE_GTPU_EH_DWNLINK	0
 #define ICE_GTPU_EH_UPLINK	1
@@ -71,6 +72,7 @@
 struct ice_rss_meta {
 	uint8_t hash_function;
 	struct ice_rss_hash_cfg cfg;
+	struct ice_rss_raw_cfg raw;
 };
 
 struct ice_hash_flow_cfg {
@@ -492,6 +494,7 @@ struct ice_rss_hash_cfg eth_tmplt = {
  */
 static struct ice_pattern_match_item ice_hash_pattern_list[] = {
 	/* IPV4 */
+	{pattern_raw,				ICE_INSET_NONE,				ICE_INSET_NONE,	NULL},
 	{pattern_eth_ipv4,			ICE_RSS_TYPE_ETH_IPV4,		ICE_INSET_NONE,	&ipv4_tmplt},
 	{pattern_eth_ipv4_udp,			ICE_RSS_TYPE_ETH_IPV4_UDP,	ICE_INSET_NONE,	&ipv4_udp_tmplt},
 	{pattern_eth_ipv4_tcp,			ICE_RSS_TYPE_ETH_IPV4_TCP,	ICE_INSET_NONE,	&ipv4_tcp_tmplt},
@@ -612,6 +615,9 @@ ice_hash_parse_pattern(const struct rte_flow_item pattern[], uint64_t *phint,
 		}
 
 		switch (item->type) {
+		case RTE_FLOW_ITEM_TYPE_RAW:
+			*phint |= ICE_PHINT_RAW;
+			break;
 		case RTE_FLOW_ITEM_TYPE_VLAN:
 			*phint |= ICE_PHINT_VLAN;
 			break;
@@ -639,6 +645,91 @@ ice_hash_parse_pattern(const struct rte_flow_item pattern[], uint64_t *phint,
 	return 0;
 }
 
+static int
+ice_hash_parse_raw_pattern(struct ice_adapter *ad,
+				const struct rte_flow_item *item,
+				struct ice_rss_meta *meta)
+{
+	const struct rte_flow_item_raw *raw_spec, *raw_mask;
+	struct ice_parser_profile prof;
+	struct ice_parser_result rslt;
+	struct ice_parser *psr;
+	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';
+	}
+
+	if (ice_parser_create(&ad->hw, &psr))
+		return -rte_errno;
+	if (ice_parser_run(psr, pkt_buf, pkt_len, &rslt))
+		return -rte_errno;
+	ice_parser_destroy(psr);
+
+	if (ice_parser_profile_init(&rslt, pkt_buf, msk_buf,
+		pkt_len, ICE_BLK_RSS, true, &prof))
+		return -rte_errno;
+
+	rte_memcpy(&meta->raw.prof, &prof, sizeof(prof));
+
+	rte_free(pkt_buf);
+	rte_free(msk_buf);
+	return 0;
+}
+
 static void
 ice_refine_hash_cfg_l234(struct ice_rss_hash_cfg *hash_cfg,
 			 uint64_t rss_type)
@@ -999,7 +1090,10 @@ ice_hash_parse_action(struct ice_pattern_match_item *pattern_match_item,
 				   RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ) {
 				rss_meta->hash_function =
 				RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
-				cfg->symm = true;
+				if (pattern_hint == ICE_PHINT_RAW)
+					rss_meta->raw.symm = true;
+				else
+					cfg->symm = true;
 			}
 
 			if (rss->level)
@@ -1017,6 +1111,10 @@ ice_hash_parse_action(struct ice_pattern_match_item *pattern_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 == ICE_PHINT_RAW)
+				break;
+
 			/**
 			 * Check simultaneous use of SRC_ONLY and DST_ONLY
 			 * of the same level.
@@ -1085,6 +1183,17 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,
 	if (ret)
 		goto error;
 
+	if (phint == ICE_PHINT_RAW) {
+		rss_meta_ptr->raw.raw_ena = true;
+		ret = ice_hash_parse_raw_pattern(ad, pattern, rss_meta_ptr);
+		if (ret) {
+			rte_flow_error_set(error, EINVAL,
+					   RTE_FLOW_ERROR_TYPE_ITEM, NULL,
+					   "Parse raw pattern failed");
+			goto error;
+		}
+	}
+
 	/* Check rss action. */
 	ret = ice_hash_parse_action(pattern_match_item, actions, phint,
 				    (void **)&rss_meta_ptr, error);
@@ -1134,15 +1243,30 @@ ice_hash_create(struct ice_adapter *ad,
 
 		goto out;
 	} else {
-		memcpy(&filter_ptr->rss_cfg.hash, &rss_meta->cfg,
-		       sizeof(struct ice_rss_hash_cfg));
-		ret = ice_add_rss_cfg_wrap(pf, vsi->idx,
-					   &filter_ptr->rss_cfg.hash);
-		if (ret) {
-			rte_flow_error_set(error, EINVAL,
-					RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
-					"rss flow create fail");
-			goto error;
+		if (rss_meta->raw.raw_ena) {
+			memcpy(&filter_ptr->rss_cfg.raw, &rss_meta->raw,
+			       sizeof(struct ice_rss_raw_cfg));
+			ret = ice_add_rss_raw_cfg(hw, &rss_meta->raw,
+						  pf->main_vsi->idx);
+			if (ret) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_HANDLE,
+						   NULL,
+						   "rss flow create fail");
+				goto error;
+			}
+		} else {
+			memcpy(&filter_ptr->rss_cfg.hash, &rss_meta->cfg,
+			       sizeof(struct ice_rss_hash_cfg));
+			ret = ice_add_rss_cfg_wrap(pf, vsi->idx,
+						   &filter_ptr->rss_cfg.hash);
+			if (ret) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_HANDLE,
+						   NULL,
+						   "rss flow create fail");
+				goto error;
+			}
 		}
 	}
 
@@ -1178,18 +1302,32 @@ ice_hash_destroy(struct ice_adapter *ad,
 			(1 << VSIQF_HASH_CTL_HASH_SCHEME_S);
 		ICE_WRITE_REG(hw, VSIQF_HASH_CTL(vsi->vsi_id), reg);
 	} else {
-		ret = ice_rem_rss_cfg_wrap(pf, vsi->idx,
-					   &filter_ptr->rss_cfg.hash);
-		/* Fixme: Ignore the error if a rule does not exist.
-		 * Currently a rule for inputset change or symm turn on/off
-		 * will overwrite an exist rule, while application still
-		 * have 2 rte_flow handles.
-		 **/
-		if (ret && ret != ICE_ERR_DOES_NOT_EXIST) {
-			rte_flow_error_set(error, EINVAL,
-					RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
-					"rss flow destroy fail");
-			goto error;
+		if (filter_ptr->rss_cfg.raw.raw_ena) {
+			ret =
+			ice_rem_rss_raw_cfg(hw, &filter_ptr->rss_cfg.raw.prof,
+					    pf->main_vsi->idx);
+			if (ret) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_HANDLE,
+						   NULL,
+						   "rss flow destroy fail");
+				goto error;
+			}
+		} else {
+			ret = ice_rem_rss_cfg_wrap(pf, vsi->idx,
+						   &filter_ptr->rss_cfg.hash);
+			/* Fixme: Ignore the error if a rule does not exist.
+			 * Currently a rule for inputset change or symm turn
+			 * on/off will overwrite an exist rule, while
+			 * application still have 2 rte_flow handles.
+			 **/
+			if (ret && ret != ICE_ERR_DOES_NOT_EXIST) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_HANDLE,
+						   NULL,
+						   "rss flow destroy fail");
+				goto error;
+			}
 		}
 	}
 
-- 
2.17.1


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

* [dpdk-dev] [PATCH v2 2/3] net/ice: enable protocol agnostic flow offloading in RSS
  2021-11-01 11:02 ` [dpdk-dev] [PATCH v2 0/3] enable protocol agnostic flow offloading in RSS Ting Xu
  2021-11-01 11:02   ` [dpdk-dev] [PATCH v2 1/3] net/ice: " Ting Xu
@ 2021-11-01 11:02   ` Ting Xu
  2021-11-01 11:02   ` [dpdk-dev] [PATCH v2 3/3] doc: add protocol agnostic flow offloading for RSS Ting Xu
  2 siblings, 0 replies; 29+ messages in thread
From: Ting Xu @ 2021-11-01 11:02 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, qiming.yang, Ting Xu

Enable protocol agnostic flow offloading to support raw pattern input
for RSS hash flow rule creation. It is based on Parser Libary feature.
Current rte_flow raw API is utilized.

Signed-off-by: Ting Xu <ting.xu@intel.com>
---
 drivers/net/ice/ice_ethdev.h |   9 ++
 drivers/net/ice/ice_hash.c   | 286 ++++++++++++++++++++++++++++++++---
 2 files changed, 273 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h
index bbfeb0cc23..76dc3c99e5 100644
--- a/drivers/net/ice/ice_ethdev.h
+++ b/drivers/net/ice/ice_ethdev.h
@@ -500,6 +500,14 @@ struct ice_fdir_prof_info {
 	u64 fdir_actived_cnt;
 };
 
+/**
+ * Structure to store rss fv entry.
+ */
+struct ice_rss_prof_info {
+	struct ice_parser_profile prof;
+	bool symm;
+};
+
 /**
  * Structure to store private data for each PF/VF instance.
  */
@@ -524,6 +532,7 @@ struct ice_adapter {
 	bool ptp_ena;
 	uint64_t time_hw;
 	struct ice_fdir_prof_info fdir_prof_info[ICE_MAX_PTGS];
+	struct ice_rss_prof_info rss_prof_info[ICE_MAX_PTGS];
 #ifdef RTE_ARCH_X86
 	bool rx_use_avx2;
 	bool rx_use_avx512;
diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c
index 35eff8b17d..dd37145e4a 100644
--- a/drivers/net/ice/ice_hash.c
+++ b/drivers/net/ice/ice_hash.c
@@ -32,6 +32,7 @@
 #define ICE_PHINT_GTPU_EH			BIT_ULL(3)
 #define	ICE_PHINT_GTPU_EH_DWN			BIT_ULL(4)
 #define	ICE_PHINT_GTPU_EH_UP			BIT_ULL(5)
+#define ICE_PHINT_RAW				BIT_ULL(6)
 
 #define ICE_GTPU_EH_DWNLINK	0
 #define ICE_GTPU_EH_UPLINK	1
@@ -71,6 +72,7 @@
 struct ice_rss_meta {
 	uint8_t hash_function;
 	struct ice_rss_hash_cfg cfg;
+	struct ice_rss_raw_cfg raw;
 };
 
 struct ice_hash_flow_cfg {
@@ -492,6 +494,7 @@ struct ice_rss_hash_cfg eth_tmplt = {
  */
 static struct ice_pattern_match_item ice_hash_pattern_list[] = {
 	/* IPV4 */
+	{pattern_raw,				ICE_INSET_NONE,				ICE_INSET_NONE,	NULL},
 	{pattern_eth_ipv4,			ICE_RSS_TYPE_ETH_IPV4,		ICE_INSET_NONE,	&ipv4_tmplt},
 	{pattern_eth_ipv4_udp,			ICE_RSS_TYPE_ETH_IPV4_UDP,	ICE_INSET_NONE,	&ipv4_udp_tmplt},
 	{pattern_eth_ipv4_tcp,			ICE_RSS_TYPE_ETH_IPV4_TCP,	ICE_INSET_NONE,	&ipv4_tcp_tmplt},
@@ -612,6 +615,9 @@ ice_hash_parse_pattern(const struct rte_flow_item pattern[], uint64_t *phint,
 		}
 
 		switch (item->type) {
+		case RTE_FLOW_ITEM_TYPE_RAW:
+			*phint |= ICE_PHINT_RAW;
+			break;
 		case RTE_FLOW_ITEM_TYPE_VLAN:
 			*phint |= ICE_PHINT_VLAN;
 			break;
@@ -639,6 +645,91 @@ ice_hash_parse_pattern(const struct rte_flow_item pattern[], uint64_t *phint,
 	return 0;
 }
 
+static int
+ice_hash_parse_raw_pattern(struct ice_adapter *ad,
+				const struct rte_flow_item *item,
+				struct ice_rss_meta *meta)
+{
+	const struct rte_flow_item_raw *raw_spec, *raw_mask;
+	struct ice_parser_profile prof;
+	struct ice_parser_result rslt;
+	struct ice_parser *psr;
+	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';
+	}
+
+	if (ice_parser_create(&ad->hw, &psr))
+		return -rte_errno;
+	if (ice_parser_run(psr, pkt_buf, pkt_len, &rslt))
+		return -rte_errno;
+	ice_parser_destroy(psr);
+
+	if (ice_parser_profile_init(&rslt, pkt_buf, msk_buf,
+		pkt_len, ICE_BLK_RSS, true, &prof))
+		return -rte_errno;
+
+	rte_memcpy(&meta->raw.prof, &prof, sizeof(prof));
+
+	rte_free(pkt_buf);
+	rte_free(msk_buf);
+	return 0;
+}
+
 static void
 ice_refine_hash_cfg_l234(struct ice_rss_hash_cfg *hash_cfg,
 			 uint64_t rss_type)
@@ -999,7 +1090,10 @@ ice_hash_parse_action(struct ice_pattern_match_item *pattern_match_item,
 				   RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ) {
 				rss_meta->hash_function =
 				RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
-				cfg->symm = true;
+				if (pattern_hint == ICE_PHINT_RAW)
+					rss_meta->raw.symm = true;
+				else
+					cfg->symm = true;
 			}
 
 			if (rss->level)
@@ -1017,6 +1111,10 @@ ice_hash_parse_action(struct ice_pattern_match_item *pattern_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 == ICE_PHINT_RAW)
+				break;
+
 			/**
 			 * Check simultaneous use of SRC_ONLY and DST_ONLY
 			 * of the same level.
@@ -1085,6 +1183,17 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,
 	if (ret)
 		goto error;
 
+	if (phint == ICE_PHINT_RAW) {
+		rss_meta_ptr->raw.raw_ena = true;
+		ret = ice_hash_parse_raw_pattern(ad, pattern, rss_meta_ptr);
+		if (ret) {
+			rte_flow_error_set(error, EINVAL,
+					   RTE_FLOW_ERROR_TYPE_ITEM, NULL,
+					   "Parse raw pattern failed");
+			goto error;
+		}
+	}
+
 	/* Check rss action. */
 	ret = ice_hash_parse_action(pattern_match_item, actions, phint,
 				    (void **)&rss_meta_ptr, error);
@@ -1099,6 +1208,71 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,
 	return ret;
 }
 
+static int
+ice_hash_add_raw_cfg(struct ice_adapter *ad,
+		struct ice_rss_raw_cfg *cfg, u16 vsi_handle)
+{
+	struct ice_parser_profile *prof = &cfg->prof;
+	struct ice_rss_prof_info *rss_prof;
+	struct ice_hw *hw = &ad->hw;
+	int i, ptg, ret;
+	u64 id;
+
+	id = (u64)ice_find_first_bit(prof->ptypes, UINT16_MAX);
+
+	ptg = hw->blk[ICE_BLK_RSS].xlt1.t[id];
+	rss_prof = &ad->rss_prof_info[ptg];
+	/* check if ptg already has profile */
+	if (rss_prof->prof.fv_num) {
+		for (i = 0; i < ICE_MAX_FV_WORDS; i++) {
+			if (rss_prof->prof.fv[i].proto_id !=
+			    prof->fv[i].proto_id ||
+			    rss_prof->prof.fv[i].offset !=
+			    prof->fv[i].offset)
+				break;
+		}
+
+		/* current profile is matched, check symmetric hash */
+		if (i == ICE_MAX_FV_WORDS) {
+			if (rss_prof->symm == cfg->symm)
+				return ICE_SUCCESS;
+			else
+				goto update_symm;
+		}
+
+		/* current profile is not matched, remove it */
+		ret = ice_rem_prof_id_flow(hw, ICE_BLK_RSS,
+					   ice_get_hw_vsi_num(hw, vsi_handle),
+					   id);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "remove RSS flow failed\n");
+			return ret;
+		}
+
+		ret = ice_rem_prof(hw, ICE_BLK_RSS, id);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "remove RSS profile failed\n");
+			return ret;
+		}
+	}
+
+	/* add new profile */
+	ret = ice_flow_set_hw_prof(hw, vsi_handle, 0, prof, ICE_BLK_RSS);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "HW profile add failed\n");
+		return ret;
+	}
+
+	rss_prof->symm = cfg->symm;
+	ice_memcpy(&rss_prof->prof, prof,
+		   sizeof(struct ice_parser_profile),
+		   ICE_NONDMA_TO_NONDMA);
+
+update_symm:
+	ice_rss_update_raw_symm(hw, cfg, id);
+	return 0;
+}
+
 static int
 ice_hash_create(struct ice_adapter *ad,
 		struct rte_flow *flow,
@@ -1134,15 +1308,30 @@ ice_hash_create(struct ice_adapter *ad,
 
 		goto out;
 	} else {
-		memcpy(&filter_ptr->rss_cfg.hash, &rss_meta->cfg,
-		       sizeof(struct ice_rss_hash_cfg));
-		ret = ice_add_rss_cfg_wrap(pf, vsi->idx,
-					   &filter_ptr->rss_cfg.hash);
-		if (ret) {
-			rte_flow_error_set(error, EINVAL,
-					RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
-					"rss flow create fail");
-			goto error;
+		if (rss_meta->raw.raw_ena) {
+			memcpy(&filter_ptr->rss_cfg.raw, &rss_meta->raw,
+			       sizeof(struct ice_rss_raw_cfg));
+			ret = ice_hash_add_raw_cfg(ad, &rss_meta->raw,
+						   pf->main_vsi->idx);
+			if (ret) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_HANDLE,
+						   NULL,
+						   "rss flow create fail");
+				goto error;
+			}
+		} else {
+			memcpy(&filter_ptr->rss_cfg.hash, &rss_meta->cfg,
+			       sizeof(struct ice_rss_hash_cfg));
+			ret = ice_add_rss_cfg_wrap(pf, vsi->idx,
+						   &filter_ptr->rss_cfg.hash);
+			if (ret) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_HANDLE,
+						   NULL,
+						   "rss flow create fail");
+				goto error;
+			}
 		}
 	}
 
@@ -1157,6 +1346,45 @@ ice_hash_create(struct ice_adapter *ad,
 	return -rte_errno;
 }
 
+static int
+ice_hash_rem_raw_cfg(struct ice_adapter *ad,
+			struct ice_parser_profile *prof,
+		    u16 vsi_handle)
+{
+	struct ice_hw *hw = &ad->hw;
+	int ptg, ret;
+	u16 vsig;
+	u64 id;
+
+	id = (u64)ice_find_first_bit(prof->ptypes, 0xFFFF);
+
+	ptg = hw->blk[ICE_BLK_RSS].xlt1.t[id];
+
+	memset(&ad->rss_prof_info[ptg], 0,
+		sizeof(struct ice_rss_prof_info));
+
+	/* check if vsig is already removed */
+	ret = ice_vsig_find_vsi(hw, ICE_BLK_RSS,
+		ice_get_hw_vsi_num(hw, vsi_handle), &vsig);
+	if (!ret && vsig) {
+		ret = ice_rem_prof_id_flow(hw, ICE_BLK_RSS,
+					   ice_get_hw_vsi_num(hw, vsi__handle),
+					   id);
+		if (ret)
+			goto err;
+
+		ret = ice_rem_prof(hw, ICE_BLK_RSS, id);
+		if (ret)
+			goto err;
+	}
+
+	return 0;
+
+err:
+	PMD_DRV_LOG(ERR, "HW profile remove failed\n");
+	return ret;
+}
+
 static int
 ice_hash_destroy(struct ice_adapter *ad,
 		struct rte_flow *flow,
@@ -1178,18 +1406,32 @@ ice_hash_destroy(struct ice_adapter *ad,
 			(1 << VSIQF_HASH_CTL_HASH_SCHEME_S);
 		ICE_WRITE_REG(hw, VSIQF_HASH_CTL(vsi->vsi_id), reg);
 	} else {
-		ret = ice_rem_rss_cfg_wrap(pf, vsi->idx,
-					   &filter_ptr->rss_cfg.hash);
-		/* Fixme: Ignore the error if a rule does not exist.
-		 * Currently a rule for inputset change or symm turn on/off
-		 * will overwrite an exist rule, while application still
-		 * have 2 rte_flow handles.
-		 **/
-		if (ret && ret != ICE_ERR_DOES_NOT_EXIST) {
-			rte_flow_error_set(error, EINVAL,
-					RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
-					"rss flow destroy fail");
-			goto error;
+		if (filter_ptr->rss_cfg.raw.raw_ena) {
+			ret =
+			ice_hash_rem_raw_cfg(ad, &filter_ptr->rss_cfg.raw.prof,
+					     pf->main_vsi->idx);
+			if (ret) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_HANDLE,
+						   NULL,
+						   "rss flow destroy fail");
+				goto error;
+			}
+		} else {
+			ret = ice_rem_rss_cfg_wrap(pf, vsi->idx,
+						   &filter_ptr->rss_cfg.hash);
+			/* Fixme: Ignore the error if a rule does not exist.
+			 * Currently a rule for inputset change or symm turn
+			 * on/off will overwrite an exist rule, while
+			 * application still have 2 rte_flow handles.
+			 **/
+			if (ret && ret != ICE_ERR_DOES_NOT_EXIST) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_HANDLE,
+						   NULL,
+						   "rss flow destroy fail");
+				goto error;
+			}
 		}
 	}
 
-- 
2.17.1


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

* [dpdk-dev] [PATCH v2 3/3] doc: add protocol agnostic flow offloading for RSS
  2021-11-01 11:02 ` [dpdk-dev] [PATCH v2 0/3] enable protocol agnostic flow offloading in RSS Ting Xu
  2021-11-01 11:02   ` [dpdk-dev] [PATCH v2 1/3] net/ice: " Ting Xu
  2021-11-01 11:02   ` [dpdk-dev] [PATCH v2 2/3] " Ting Xu
@ 2021-11-01 11:02   ` Ting Xu
  2 siblings, 0 replies; 29+ messages in thread
From: Ting Xu @ 2021-11-01 11:02 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, qiming.yang, Ting Xu

Protocol agnostic flow offloading for RSS hash is supported. Raw pattern
input can be used to create RSS hash flow rules, using current rte_flow
raw API.

Signed-off-by: Ting Xu <ting.xu@intel.com>
---
 doc/guides/rel_notes/release_21_11.rst | 1 +
 1 file changed, 1 insertion(+)

diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst
index 36fdee0a98..0582717628 100644
--- a/doc/guides/rel_notes/release_21_11.rst
+++ b/doc/guides/rel_notes/release_21_11.rst
@@ -168,6 +168,7 @@ New Features
 * **Updated Intel ice driver.**
 
   * Added protocol agnostic flow offloading support in Flow Director.
+  * Added protocol agnostic flow offloading support in RSS hash.
   * Added 1PPS out support by a devargs.
   * Added IPv4 and L4 (TCP/UDP/SCTP) checksum hash support in RSS flow.
   * Added DEV_RX_OFFLOAD_TIMESTAMP support.
-- 
2.17.1


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

* [dpdk-dev] [PATCH v2 0/3] enable protocol agnostic flow offloading in RSS
  2021-10-08  7:09 [dpdk-dev] [PATCH v1 0/2] enable protocol agnostic flow offloading in RSS Ting Xu
                   ` (2 preceding siblings ...)
  2021-11-01 11:02 ` [dpdk-dev] [PATCH v2 0/3] enable protocol agnostic flow offloading in RSS Ting Xu
@ 2021-11-01 11:05 ` Ting Xu
  2021-11-01 11:05   ` [dpdk-dev] [PATCH v2 1/3] net/ice/base: support add HW profile for RSS raw flow Ting Xu
                     ` (2 more replies)
  2021-11-02  1:49 ` [dpdk-dev] [PATCH v3 0/3] enable protocol agnostic flow offloading in RSS Ting Xu
  2021-11-04  2:22 ` [dpdk-dev] [PATCH v4 0/2] " Ting Xu
  5 siblings, 3 replies; 29+ messages in thread
From: Ting Xu @ 2021-11-01 11:05 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, qiming.yang, Ting Xu

Enable protocol agnostic flow offloading to support raw pattern input
for RSS hash flow rule creation. It is based on Parser Libary feature.
Current rte_flow raw API is utilized.

Ting Xu (3):
  net/ice/base: support add HW profile for RSS raw flow
  net/ice: enable protocol agnostic flow offloading in RSS
  doc: add protocol agnostic flow offloading for RSS

 doc/guides/rel_notes/release_21_11.rst |   1 +
 drivers/net/ice/base/ice_flow.c        | 109 ++++++++++
 drivers/net/ice/base/ice_flow.h        |  16 ++
 drivers/net/ice/ice_ethdev.h           |   9 +
 drivers/net/ice/ice_hash.c             | 286 +++++++++++++++++++++++--
 5 files changed, 399 insertions(+), 22 deletions(-)

-- 
2.17.1


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

* [dpdk-dev] [PATCH v2 1/3] net/ice/base: support add HW profile for RSS raw flow
  2021-11-01 11:05 ` [dpdk-dev] [PATCH v2 0/3] enable protocol agnostic flow offloading in RSS Ting Xu
@ 2021-11-01 11:05   ` Ting Xu
  2021-11-01 11:05   ` [dpdk-dev] [PATCH v2 2/3] net/ice: enable protocol agnostic flow offloading in RSS Ting Xu
  2021-11-01 11:05   ` [dpdk-dev] [PATCH v2 3/3] doc: add protocol agnostic flow offloading for RSS Ting Xu
  2 siblings, 0 replies; 29+ messages in thread
From: Ting Xu @ 2021-11-01 11:05 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, qiming.yang, Ting Xu

Based on the parser library, we can directly set HW profile and
associate VSI for RSS raw flows. Add symmetric hash configuration
for raw flow.

Signed-off-by: Ting Xu <ting.xu@intel.com>
---
 drivers/net/ice/base/ice_flow.c | 109 ++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_flow.h |  16 +++++
 2 files changed, 125 insertions(+)

diff --git a/drivers/net/ice/base/ice_flow.c b/drivers/net/ice/base/ice_flow.c
index f699dbbc74..da27d157c0 100644
--- a/drivers/net/ice/base/ice_flow.c
+++ b/drivers/net/ice/base/ice_flow.c
@@ -4071,6 +4071,115 @@ ice_rss_update_symm(struct ice_hw *hw,
 	}
 }
 
+/**
+ * ice_rss_cfg_raw_symm - configure symmetric hash parameters
+ * for raw pattern
+ * @hw: pointer to the hardware structure
+ * @prof: pointer to parser profile
+ * @prof_id: profile ID
+ *
+ * Calculate symmetric hash parameters based on input protocol type.
+ */
+static void
+ice_rss_cfg_raw_symm(struct ice_hw *hw,
+		     struct ice_parser_profile *prof, u64 prof_id)
+{
+	u8 src_idx, dst_idx, proto_id;
+	int len, i = 0;
+
+	while (i < prof->fv_num) {
+		proto_id = prof->fv[i].proto_id;
+
+		switch (proto_id) {
+		case ICE_PROT_IPV4_OF_OR_S:
+			len = ICE_FLOW_FLD_SZ_IPV4_ADDR /
+			      ICE_FLOW_FV_EXTRACT_SZ;
+			if (prof->fv[i].offset ==
+			    ICE_FLOW_FIELD_IPV4_SRC_OFFSET &&
+			    prof->fv[i + len].proto_id == proto_id &&
+			    prof->fv[i + len].offset ==
+			    ICE_FLOW_FIELD_IPV4_DST_OFFSET) {
+				src_idx = i;
+				dst_idx = i + len;
+				i += 2 * len;
+				break;
+			}
+			i++;
+			continue;
+		case ICE_PROT_IPV6_OF_OR_S:
+			len = ICE_FLOW_FLD_SZ_IPV6_ADDR /
+			      ICE_FLOW_FV_EXTRACT_SZ;
+			if (prof->fv[i].offset ==
+			    ICE_FLOW_FIELD_IPV6_SRC_OFFSET &&
+			    prof->fv[i + len].proto_id == proto_id &&
+			    prof->fv[i + len].offset ==
+			    ICE_FLOW_FIELD_IPV6_DST_OFFSET) {
+				src_idx = i;
+				dst_idx = i + len;
+				i += 2 * len;
+				break;
+			}
+			i++;
+			continue;
+		case ICE_PROT_TCP_IL:
+		case ICE_PROT_UDP_IL_OR_S:
+		case ICE_PROT_SCTP_IL:
+			len = ICE_FLOW_FLD_SZ_PORT /
+			      ICE_FLOW_FV_EXTRACT_SZ;
+			if (prof->fv[i].offset ==
+			    ICE_FLOW_FIELD_SRC_PORT_OFFSET &&
+			    prof->fv[i + len].proto_id == proto_id &&
+			    prof->fv[i + len].offset ==
+			    ICE_FLOW_FIELD_DST_PORT_OFFSET) {
+				src_idx = i;
+				dst_idx = i + len;
+				i += 2 * len;
+				break;
+			}
+			i++;
+			continue;
+		default:
+			i++;
+			continue;
+		}
+		ice_rss_config_xor(hw, prof_id, src_idx, dst_idx, len);
+	}
+}
+
+/* Max registers index per packet profile */
+#define ICE_SYMM_REG_INDEX_MAX 6
+
+/**
+ * ice_rss_update_raw_symm - update symmetric hash configuration
+ * for raw pattern
+ * @hw: pointer to the hardware structure
+ * @cfg: configure parameters for raw pattern
+ * @id: profile tracking ID
+ *
+ * Update symmetric hash configuration for raw pattern if required.
+ * Otherwise only clear to default.
+ */
+void
+ice_rss_update_raw_symm(struct ice_hw *hw,
+			struct ice_rss_raw_cfg *cfg, u64 id)
+{
+	struct ice_prof_map *map;
+	u8 prof_id, m;
+
+	ice_acquire_lock(&hw->blk[ICE_BLK_RSS].es.prof_map_lock);
+	map = ice_search_prof_id(hw, ICE_BLK_RSS, id);
+	if (map)
+		prof_id = map->prof_id;
+	ice_release_lock(&hw->blk[ICE_BLK_RSS].es.prof_map_lock);
+	if (!map)
+		return;
+	/* clear to default */
+	for (m = 0; m < ICE_SYMM_REG_INDEX_MAX; m++)
+		wr32(hw, GLQF_HSYMM(prof_id, m), 0);
+	if (cfg->symm)
+		ice_rss_cfg_raw_symm(hw, &cfg->prof, prof_id);
+}
+
 /**
  * ice_add_rss_cfg_sync - add an RSS configuration
  * @hw: pointer to the hardware structure
diff --git a/drivers/net/ice/base/ice_flow.h b/drivers/net/ice/base/ice_flow.h
index dea7b3c0e8..aac7ead891 100644
--- a/drivers/net/ice/base/ice_flow.h
+++ b/drivers/net/ice/base/ice_flow.h
@@ -149,6 +149,13 @@
 #define ICE_FLOW_HASH_NAT_T_ESP_IPV6_SPI \
 	(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_NAT_T_ESP_SPI)
 
+#define ICE_FLOW_FIELD_IPV4_SRC_OFFSET 12
+#define ICE_FLOW_FIELD_IPV4_DST_OFFSET 16
+#define ICE_FLOW_FIELD_IPV6_SRC_OFFSET 8
+#define ICE_FLOW_FIELD_IPV6_DST_OFFSET 24
+#define ICE_FLOW_FIELD_SRC_PORT_OFFSET 0
+#define ICE_FLOW_FIELD_DST_PORT_OFFSET 2
+
 /* Protocol header fields within a packet segment. A segment consists of one or
  * more protocol headers that make up a logical group of protocol headers. Each
  * logical group of protocol headers encapsulates or is encapsulated using/by
@@ -493,11 +500,18 @@ struct ice_flow_prof {
 	struct ice_flow_action *acts;
 };
 
+struct ice_rss_raw_cfg {
+	struct ice_parser_profile prof;
+	bool raw_ena;
+	bool symm;
+};
+
 struct ice_rss_cfg {
 	struct LIST_ENTRY_TYPE l_entry;
 	/* bitmap of VSIs added to the RSS entry */
 	ice_declare_bitmap(vsis, ICE_MAX_VSI);
 	struct ice_rss_hash_cfg hash;
+	struct ice_rss_raw_cfg raw;
 };
 
 enum ice_flow_action_type {
@@ -585,5 +599,7 @@ ice_add_rss_cfg(struct ice_hw *hw, u16 vsi_handle,
 enum ice_status
 ice_rem_rss_cfg(struct ice_hw *hw, u16 vsi_handle,
 		const struct ice_rss_hash_cfg *cfg);
+void ice_rss_update_raw_symm(struct ice_hw *hw,
+			struct ice_rss_raw_cfg *cfg, u64 id);
 u64 ice_get_rss_cfg(struct ice_hw *hw, u16 vsi_handle, u32 hdrs);
 #endif /* _ICE_FLOW_H_ */
-- 
2.17.1


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

* [dpdk-dev] [PATCH v2 2/3] net/ice: enable protocol agnostic flow offloading in RSS
  2021-11-01 11:05 ` [dpdk-dev] [PATCH v2 0/3] enable protocol agnostic flow offloading in RSS Ting Xu
  2021-11-01 11:05   ` [dpdk-dev] [PATCH v2 1/3] net/ice/base: support add HW profile for RSS raw flow Ting Xu
@ 2021-11-01 11:05   ` Ting Xu
  2021-11-01 11:05   ` [dpdk-dev] [PATCH v2 3/3] doc: add protocol agnostic flow offloading for RSS Ting Xu
  2 siblings, 0 replies; 29+ messages in thread
From: Ting Xu @ 2021-11-01 11:05 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, qiming.yang, Ting Xu

Enable protocol agnostic flow offloading to support raw pattern input
for RSS hash flow rule creation. It is based on Parser Libary feature.
Current rte_flow raw API is utilized.

Signed-off-by: Ting Xu <ting.xu@intel.com>
---
 drivers/net/ice/ice_ethdev.h |   9 ++
 drivers/net/ice/ice_hash.c   | 286 ++++++++++++++++++++++++++++++++---
 2 files changed, 273 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h
index bbfeb0cc23..76dc3c99e5 100644
--- a/drivers/net/ice/ice_ethdev.h
+++ b/drivers/net/ice/ice_ethdev.h
@@ -500,6 +500,14 @@ struct ice_fdir_prof_info {
 	u64 fdir_actived_cnt;
 };
 
+/**
+ * Structure to store rss fv entry.
+ */
+struct ice_rss_prof_info {
+	struct ice_parser_profile prof;
+	bool symm;
+};
+
 /**
  * Structure to store private data for each PF/VF instance.
  */
@@ -524,6 +532,7 @@ struct ice_adapter {
 	bool ptp_ena;
 	uint64_t time_hw;
 	struct ice_fdir_prof_info fdir_prof_info[ICE_MAX_PTGS];
+	struct ice_rss_prof_info rss_prof_info[ICE_MAX_PTGS];
 #ifdef RTE_ARCH_X86
 	bool rx_use_avx2;
 	bool rx_use_avx512;
diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c
index 35eff8b17d..dd37145e4a 100644
--- a/drivers/net/ice/ice_hash.c
+++ b/drivers/net/ice/ice_hash.c
@@ -32,6 +32,7 @@
 #define ICE_PHINT_GTPU_EH			BIT_ULL(3)
 #define	ICE_PHINT_GTPU_EH_DWN			BIT_ULL(4)
 #define	ICE_PHINT_GTPU_EH_UP			BIT_ULL(5)
+#define ICE_PHINT_RAW				BIT_ULL(6)
 
 #define ICE_GTPU_EH_DWNLINK	0
 #define ICE_GTPU_EH_UPLINK	1
@@ -71,6 +72,7 @@
 struct ice_rss_meta {
 	uint8_t hash_function;
 	struct ice_rss_hash_cfg cfg;
+	struct ice_rss_raw_cfg raw;
 };
 
 struct ice_hash_flow_cfg {
@@ -492,6 +494,7 @@ struct ice_rss_hash_cfg eth_tmplt = {
  */
 static struct ice_pattern_match_item ice_hash_pattern_list[] = {
 	/* IPV4 */
+	{pattern_raw,				ICE_INSET_NONE,				ICE_INSET_NONE,	NULL},
 	{pattern_eth_ipv4,			ICE_RSS_TYPE_ETH_IPV4,		ICE_INSET_NONE,	&ipv4_tmplt},
 	{pattern_eth_ipv4_udp,			ICE_RSS_TYPE_ETH_IPV4_UDP,	ICE_INSET_NONE,	&ipv4_udp_tmplt},
 	{pattern_eth_ipv4_tcp,			ICE_RSS_TYPE_ETH_IPV4_TCP,	ICE_INSET_NONE,	&ipv4_tcp_tmplt},
@@ -612,6 +615,9 @@ ice_hash_parse_pattern(const struct rte_flow_item pattern[], uint64_t *phint,
 		}
 
 		switch (item->type) {
+		case RTE_FLOW_ITEM_TYPE_RAW:
+			*phint |= ICE_PHINT_RAW;
+			break;
 		case RTE_FLOW_ITEM_TYPE_VLAN:
 			*phint |= ICE_PHINT_VLAN;
 			break;
@@ -639,6 +645,91 @@ ice_hash_parse_pattern(const struct rte_flow_item pattern[], uint64_t *phint,
 	return 0;
 }
 
+static int
+ice_hash_parse_raw_pattern(struct ice_adapter *ad,
+				const struct rte_flow_item *item,
+				struct ice_rss_meta *meta)
+{
+	const struct rte_flow_item_raw *raw_spec, *raw_mask;
+	struct ice_parser_profile prof;
+	struct ice_parser_result rslt;
+	struct ice_parser *psr;
+	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';
+	}
+
+	if (ice_parser_create(&ad->hw, &psr))
+		return -rte_errno;
+	if (ice_parser_run(psr, pkt_buf, pkt_len, &rslt))
+		return -rte_errno;
+	ice_parser_destroy(psr);
+
+	if (ice_parser_profile_init(&rslt, pkt_buf, msk_buf,
+		pkt_len, ICE_BLK_RSS, true, &prof))
+		return -rte_errno;
+
+	rte_memcpy(&meta->raw.prof, &prof, sizeof(prof));
+
+	rte_free(pkt_buf);
+	rte_free(msk_buf);
+	return 0;
+}
+
 static void
 ice_refine_hash_cfg_l234(struct ice_rss_hash_cfg *hash_cfg,
 			 uint64_t rss_type)
@@ -999,7 +1090,10 @@ ice_hash_parse_action(struct ice_pattern_match_item *pattern_match_item,
 				   RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ) {
 				rss_meta->hash_function =
 				RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
-				cfg->symm = true;
+				if (pattern_hint == ICE_PHINT_RAW)
+					rss_meta->raw.symm = true;
+				else
+					cfg->symm = true;
 			}
 
 			if (rss->level)
@@ -1017,6 +1111,10 @@ ice_hash_parse_action(struct ice_pattern_match_item *pattern_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 == ICE_PHINT_RAW)
+				break;
+
 			/**
 			 * Check simultaneous use of SRC_ONLY and DST_ONLY
 			 * of the same level.
@@ -1085,6 +1183,17 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,
 	if (ret)
 		goto error;
 
+	if (phint == ICE_PHINT_RAW) {
+		rss_meta_ptr->raw.raw_ena = true;
+		ret = ice_hash_parse_raw_pattern(ad, pattern, rss_meta_ptr);
+		if (ret) {
+			rte_flow_error_set(error, EINVAL,
+					   RTE_FLOW_ERROR_TYPE_ITEM, NULL,
+					   "Parse raw pattern failed");
+			goto error;
+		}
+	}
+
 	/* Check rss action. */
 	ret = ice_hash_parse_action(pattern_match_item, actions, phint,
 				    (void **)&rss_meta_ptr, error);
@@ -1099,6 +1208,71 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,
 	return ret;
 }
 
+static int
+ice_hash_add_raw_cfg(struct ice_adapter *ad,
+		struct ice_rss_raw_cfg *cfg, u16 vsi_handle)
+{
+	struct ice_parser_profile *prof = &cfg->prof;
+	struct ice_rss_prof_info *rss_prof;
+	struct ice_hw *hw = &ad->hw;
+	int i, ptg, ret;
+	u64 id;
+
+	id = (u64)ice_find_first_bit(prof->ptypes, UINT16_MAX);
+
+	ptg = hw->blk[ICE_BLK_RSS].xlt1.t[id];
+	rss_prof = &ad->rss_prof_info[ptg];
+	/* check if ptg already has profile */
+	if (rss_prof->prof.fv_num) {
+		for (i = 0; i < ICE_MAX_FV_WORDS; i++) {
+			if (rss_prof->prof.fv[i].proto_id !=
+			    prof->fv[i].proto_id ||
+			    rss_prof->prof.fv[i].offset !=
+			    prof->fv[i].offset)
+				break;
+		}
+
+		/* current profile is matched, check symmetric hash */
+		if (i == ICE_MAX_FV_WORDS) {
+			if (rss_prof->symm == cfg->symm)
+				return ICE_SUCCESS;
+			else
+				goto update_symm;
+		}
+
+		/* current profile is not matched, remove it */
+		ret = ice_rem_prof_id_flow(hw, ICE_BLK_RSS,
+					   ice_get_hw_vsi_num(hw, vsi_handle),
+					   id);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "remove RSS flow failed\n");
+			return ret;
+		}
+
+		ret = ice_rem_prof(hw, ICE_BLK_RSS, id);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "remove RSS profile failed\n");
+			return ret;
+		}
+	}
+
+	/* add new profile */
+	ret = ice_flow_set_hw_prof(hw, vsi_handle, 0, prof, ICE_BLK_RSS);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "HW profile add failed\n");
+		return ret;
+	}
+
+	rss_prof->symm = cfg->symm;
+	ice_memcpy(&rss_prof->prof, prof,
+		   sizeof(struct ice_parser_profile),
+		   ICE_NONDMA_TO_NONDMA);
+
+update_symm:
+	ice_rss_update_raw_symm(hw, cfg, id);
+	return 0;
+}
+
 static int
 ice_hash_create(struct ice_adapter *ad,
 		struct rte_flow *flow,
@@ -1134,15 +1308,30 @@ ice_hash_create(struct ice_adapter *ad,
 
 		goto out;
 	} else {
-		memcpy(&filter_ptr->rss_cfg.hash, &rss_meta->cfg,
-		       sizeof(struct ice_rss_hash_cfg));
-		ret = ice_add_rss_cfg_wrap(pf, vsi->idx,
-					   &filter_ptr->rss_cfg.hash);
-		if (ret) {
-			rte_flow_error_set(error, EINVAL,
-					RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
-					"rss flow create fail");
-			goto error;
+		if (rss_meta->raw.raw_ena) {
+			memcpy(&filter_ptr->rss_cfg.raw, &rss_meta->raw,
+			       sizeof(struct ice_rss_raw_cfg));
+			ret = ice_hash_add_raw_cfg(ad, &rss_meta->raw,
+						   pf->main_vsi->idx);
+			if (ret) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_HANDLE,
+						   NULL,
+						   "rss flow create fail");
+				goto error;
+			}
+		} else {
+			memcpy(&filter_ptr->rss_cfg.hash, &rss_meta->cfg,
+			       sizeof(struct ice_rss_hash_cfg));
+			ret = ice_add_rss_cfg_wrap(pf, vsi->idx,
+						   &filter_ptr->rss_cfg.hash);
+			if (ret) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_HANDLE,
+						   NULL,
+						   "rss flow create fail");
+				goto error;
+			}
 		}
 	}
 
@@ -1157,6 +1346,45 @@ ice_hash_create(struct ice_adapter *ad,
 	return -rte_errno;
 }
 
+static int
+ice_hash_rem_raw_cfg(struct ice_adapter *ad,
+			struct ice_parser_profile *prof,
+		    u16 vsi_handle)
+{
+	struct ice_hw *hw = &ad->hw;
+	int ptg, ret;
+	u16 vsig;
+	u64 id;
+
+	id = (u64)ice_find_first_bit(prof->ptypes, 0xFFFF);
+
+	ptg = hw->blk[ICE_BLK_RSS].xlt1.t[id];
+
+	memset(&ad->rss_prof_info[ptg], 0,
+		sizeof(struct ice_rss_prof_info));
+
+	/* check if vsig is already removed */
+	ret = ice_vsig_find_vsi(hw, ICE_BLK_RSS,
+		ice_get_hw_vsi_num(hw, vsi_handle), &vsig);
+	if (!ret && vsig) {
+		ret = ice_rem_prof_id_flow(hw, ICE_BLK_RSS,
+					   ice_get_hw_vsi_num(hw, vsi__handle),
+					   id);
+		if (ret)
+			goto err;
+
+		ret = ice_rem_prof(hw, ICE_BLK_RSS, id);
+		if (ret)
+			goto err;
+	}
+
+	return 0;
+
+err:
+	PMD_DRV_LOG(ERR, "HW profile remove failed\n");
+	return ret;
+}
+
 static int
 ice_hash_destroy(struct ice_adapter *ad,
 		struct rte_flow *flow,
@@ -1178,18 +1406,32 @@ ice_hash_destroy(struct ice_adapter *ad,
 			(1 << VSIQF_HASH_CTL_HASH_SCHEME_S);
 		ICE_WRITE_REG(hw, VSIQF_HASH_CTL(vsi->vsi_id), reg);
 	} else {
-		ret = ice_rem_rss_cfg_wrap(pf, vsi->idx,
-					   &filter_ptr->rss_cfg.hash);
-		/* Fixme: Ignore the error if a rule does not exist.
-		 * Currently a rule for inputset change or symm turn on/off
-		 * will overwrite an exist rule, while application still
-		 * have 2 rte_flow handles.
-		 **/
-		if (ret && ret != ICE_ERR_DOES_NOT_EXIST) {
-			rte_flow_error_set(error, EINVAL,
-					RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
-					"rss flow destroy fail");
-			goto error;
+		if (filter_ptr->rss_cfg.raw.raw_ena) {
+			ret =
+			ice_hash_rem_raw_cfg(ad, &filter_ptr->rss_cfg.raw.prof,
+					     pf->main_vsi->idx);
+			if (ret) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_HANDLE,
+						   NULL,
+						   "rss flow destroy fail");
+				goto error;
+			}
+		} else {
+			ret = ice_rem_rss_cfg_wrap(pf, vsi->idx,
+						   &filter_ptr->rss_cfg.hash);
+			/* Fixme: Ignore the error if a rule does not exist.
+			 * Currently a rule for inputset change or symm turn
+			 * on/off will overwrite an exist rule, while
+			 * application still have 2 rte_flow handles.
+			 **/
+			if (ret && ret != ICE_ERR_DOES_NOT_EXIST) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_HANDLE,
+						   NULL,
+						   "rss flow destroy fail");
+				goto error;
+			}
 		}
 	}
 
-- 
2.17.1


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

* [dpdk-dev] [PATCH v2 3/3] doc: add protocol agnostic flow offloading for RSS
  2021-11-01 11:05 ` [dpdk-dev] [PATCH v2 0/3] enable protocol agnostic flow offloading in RSS Ting Xu
  2021-11-01 11:05   ` [dpdk-dev] [PATCH v2 1/3] net/ice/base: support add HW profile for RSS raw flow Ting Xu
  2021-11-01 11:05   ` [dpdk-dev] [PATCH v2 2/3] net/ice: enable protocol agnostic flow offloading in RSS Ting Xu
@ 2021-11-01 11:05   ` Ting Xu
  2 siblings, 0 replies; 29+ messages in thread
From: Ting Xu @ 2021-11-01 11:05 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, qiming.yang, Ting Xu

Protocol agnostic flow offloading for RSS hash is supported. Raw pattern
input can be used to create RSS hash flow rules, using current rte_flow
raw API.

Signed-off-by: Ting Xu <ting.xu@intel.com>
---
 doc/guides/rel_notes/release_21_11.rst | 1 +
 1 file changed, 1 insertion(+)

diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst
index 36fdee0a98..0582717628 100644
--- a/doc/guides/rel_notes/release_21_11.rst
+++ b/doc/guides/rel_notes/release_21_11.rst
@@ -168,6 +168,7 @@ New Features
 * **Updated Intel ice driver.**
 
   * Added protocol agnostic flow offloading support in Flow Director.
+  * Added protocol agnostic flow offloading support in RSS hash.
   * Added 1PPS out support by a devargs.
   * Added IPv4 and L4 (TCP/UDP/SCTP) checksum hash support in RSS flow.
   * Added DEV_RX_OFFLOAD_TIMESTAMP support.
-- 
2.17.1


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

* [dpdk-dev] [PATCH v3 0/3] enable protocol agnostic flow offloading in RSS
  2021-10-08  7:09 [dpdk-dev] [PATCH v1 0/2] enable protocol agnostic flow offloading in RSS Ting Xu
                   ` (3 preceding siblings ...)
  2021-11-01 11:05 ` [dpdk-dev] [PATCH v2 0/3] enable protocol agnostic flow offloading in RSS Ting Xu
@ 2021-11-02  1:49 ` Ting Xu
  2021-11-02  1:49   ` [dpdk-dev] [PATCH v3 1/3] net/ice/base: support add HW profile for RSS raw flow Ting Xu
                     ` (3 more replies)
  2021-11-04  2:22 ` [dpdk-dev] [PATCH v4 0/2] " Ting Xu
  5 siblings, 4 replies; 29+ messages in thread
From: Ting Xu @ 2021-11-02  1:49 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, qiming.yang, junfeng.guo, Ting Xu

Enable protocol agnostic flow offloading to support raw pattern input
for RSS hash flow rule creation. It is based on Parser Library feature.
Current rte_flow raw API is utilized.

Ting Xu (3):
  net/ice/base: support add HW profile for RSS raw flow
  net/ice: enable protocol agnostic flow offloading in RSS
  doc: add protocol agnostic flow offloading for RSS

 doc/guides/rel_notes/release_21_11.rst |   1 +
 drivers/net/ice/base/ice_flow.c        | 109 ++++++++++
 drivers/net/ice/base/ice_flow.h        |  16 ++
 drivers/net/ice/ice_ethdev.h           |   9 +
 drivers/net/ice/ice_hash.c             | 286 +++++++++++++++++++++++--
 5 files changed, 399 insertions(+), 22 deletions(-)

-- 
2.17.1


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

* [dpdk-dev] [PATCH v3 1/3] net/ice/base: support add HW profile for RSS raw flow
  2021-11-02  1:49 ` [dpdk-dev] [PATCH v3 0/3] enable protocol agnostic flow offloading in RSS Ting Xu
@ 2021-11-02  1:49   ` Ting Xu
  2021-11-02  1:49   ` [dpdk-dev] [PATCH v3 2/3] net/ice: enable protocol agnostic flow offloading in RSS Ting Xu
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 29+ messages in thread
From: Ting Xu @ 2021-11-02  1:49 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, qiming.yang, junfeng.guo, Ting Xu

Based on the parser library, we can directly set HW profile and
associate VSI for RSS raw flows. Add symmetric hash configuration
for raw flow.

Signed-off-by: Ting Xu <ting.xu@intel.com>
---
 drivers/net/ice/base/ice_flow.c | 109 ++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_flow.h |  16 +++++
 2 files changed, 125 insertions(+)

diff --git a/drivers/net/ice/base/ice_flow.c b/drivers/net/ice/base/ice_flow.c
index f699dbbc74..da27d157c0 100644
--- a/drivers/net/ice/base/ice_flow.c
+++ b/drivers/net/ice/base/ice_flow.c
@@ -4071,6 +4071,115 @@ ice_rss_update_symm(struct ice_hw *hw,
 	}
 }
 
+/**
+ * ice_rss_cfg_raw_symm - configure symmetric hash parameters
+ * for raw pattern
+ * @hw: pointer to the hardware structure
+ * @prof: pointer to parser profile
+ * @prof_id: profile ID
+ *
+ * Calculate symmetric hash parameters based on input protocol type.
+ */
+static void
+ice_rss_cfg_raw_symm(struct ice_hw *hw,
+		     struct ice_parser_profile *prof, u64 prof_id)
+{
+	u8 src_idx, dst_idx, proto_id;
+	int len, i = 0;
+
+	while (i < prof->fv_num) {
+		proto_id = prof->fv[i].proto_id;
+
+		switch (proto_id) {
+		case ICE_PROT_IPV4_OF_OR_S:
+			len = ICE_FLOW_FLD_SZ_IPV4_ADDR /
+			      ICE_FLOW_FV_EXTRACT_SZ;
+			if (prof->fv[i].offset ==
+			    ICE_FLOW_FIELD_IPV4_SRC_OFFSET &&
+			    prof->fv[i + len].proto_id == proto_id &&
+			    prof->fv[i + len].offset ==
+			    ICE_FLOW_FIELD_IPV4_DST_OFFSET) {
+				src_idx = i;
+				dst_idx = i + len;
+				i += 2 * len;
+				break;
+			}
+			i++;
+			continue;
+		case ICE_PROT_IPV6_OF_OR_S:
+			len = ICE_FLOW_FLD_SZ_IPV6_ADDR /
+			      ICE_FLOW_FV_EXTRACT_SZ;
+			if (prof->fv[i].offset ==
+			    ICE_FLOW_FIELD_IPV6_SRC_OFFSET &&
+			    prof->fv[i + len].proto_id == proto_id &&
+			    prof->fv[i + len].offset ==
+			    ICE_FLOW_FIELD_IPV6_DST_OFFSET) {
+				src_idx = i;
+				dst_idx = i + len;
+				i += 2 * len;
+				break;
+			}
+			i++;
+			continue;
+		case ICE_PROT_TCP_IL:
+		case ICE_PROT_UDP_IL_OR_S:
+		case ICE_PROT_SCTP_IL:
+			len = ICE_FLOW_FLD_SZ_PORT /
+			      ICE_FLOW_FV_EXTRACT_SZ;
+			if (prof->fv[i].offset ==
+			    ICE_FLOW_FIELD_SRC_PORT_OFFSET &&
+			    prof->fv[i + len].proto_id == proto_id &&
+			    prof->fv[i + len].offset ==
+			    ICE_FLOW_FIELD_DST_PORT_OFFSET) {
+				src_idx = i;
+				dst_idx = i + len;
+				i += 2 * len;
+				break;
+			}
+			i++;
+			continue;
+		default:
+			i++;
+			continue;
+		}
+		ice_rss_config_xor(hw, prof_id, src_idx, dst_idx, len);
+	}
+}
+
+/* Max registers index per packet profile */
+#define ICE_SYMM_REG_INDEX_MAX 6
+
+/**
+ * ice_rss_update_raw_symm - update symmetric hash configuration
+ * for raw pattern
+ * @hw: pointer to the hardware structure
+ * @cfg: configure parameters for raw pattern
+ * @id: profile tracking ID
+ *
+ * Update symmetric hash configuration for raw pattern if required.
+ * Otherwise only clear to default.
+ */
+void
+ice_rss_update_raw_symm(struct ice_hw *hw,
+			struct ice_rss_raw_cfg *cfg, u64 id)
+{
+	struct ice_prof_map *map;
+	u8 prof_id, m;
+
+	ice_acquire_lock(&hw->blk[ICE_BLK_RSS].es.prof_map_lock);
+	map = ice_search_prof_id(hw, ICE_BLK_RSS, id);
+	if (map)
+		prof_id = map->prof_id;
+	ice_release_lock(&hw->blk[ICE_BLK_RSS].es.prof_map_lock);
+	if (!map)
+		return;
+	/* clear to default */
+	for (m = 0; m < ICE_SYMM_REG_INDEX_MAX; m++)
+		wr32(hw, GLQF_HSYMM(prof_id, m), 0);
+	if (cfg->symm)
+		ice_rss_cfg_raw_symm(hw, &cfg->prof, prof_id);
+}
+
 /**
  * ice_add_rss_cfg_sync - add an RSS configuration
  * @hw: pointer to the hardware structure
diff --git a/drivers/net/ice/base/ice_flow.h b/drivers/net/ice/base/ice_flow.h
index dea7b3c0e8..f941ce4333 100644
--- a/drivers/net/ice/base/ice_flow.h
+++ b/drivers/net/ice/base/ice_flow.h
@@ -149,6 +149,13 @@
 #define ICE_FLOW_HASH_NAT_T_ESP_IPV6_SPI \
 	(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_NAT_T_ESP_SPI)
 
+#define ICE_FLOW_FIELD_IPV4_SRC_OFFSET 12
+#define ICE_FLOW_FIELD_IPV4_DST_OFFSET 16
+#define ICE_FLOW_FIELD_IPV6_SRC_OFFSET 8
+#define ICE_FLOW_FIELD_IPV6_DST_OFFSET 24
+#define ICE_FLOW_FIELD_SRC_PORT_OFFSET 0
+#define ICE_FLOW_FIELD_DST_PORT_OFFSET 2
+
 /* Protocol header fields within a packet segment. A segment consists of one or
  * more protocol headers that make up a logical group of protocol headers. Each
  * logical group of protocol headers encapsulates or is encapsulated using/by
@@ -493,11 +500,18 @@ struct ice_flow_prof {
 	struct ice_flow_action *acts;
 };
 
+struct ice_rss_raw_cfg {
+	struct ice_parser_profile prof;
+	bool raw_ena;
+	bool symm;
+};
+
 struct ice_rss_cfg {
 	struct LIST_ENTRY_TYPE l_entry;
 	/* bitmap of VSIs added to the RSS entry */
 	ice_declare_bitmap(vsis, ICE_MAX_VSI);
 	struct ice_rss_hash_cfg hash;
+	struct ice_rss_raw_cfg raw;
 };
 
 enum ice_flow_action_type {
@@ -585,5 +599,7 @@ ice_add_rss_cfg(struct ice_hw *hw, u16 vsi_handle,
 enum ice_status
 ice_rem_rss_cfg(struct ice_hw *hw, u16 vsi_handle,
 		const struct ice_rss_hash_cfg *cfg);
+void ice_rss_update_raw_symm(struct ice_hw *hw,
+			     struct ice_rss_raw_cfg *cfg, u64 id);
 u64 ice_get_rss_cfg(struct ice_hw *hw, u16 vsi_handle, u32 hdrs);
 #endif /* _ICE_FLOW_H_ */
-- 
2.17.1


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

* [dpdk-dev] [PATCH v3 2/3] net/ice: enable protocol agnostic flow offloading in RSS
  2021-11-02  1:49 ` [dpdk-dev] [PATCH v3 0/3] enable protocol agnostic flow offloading in RSS Ting Xu
  2021-11-02  1:49   ` [dpdk-dev] [PATCH v3 1/3] net/ice/base: support add HW profile for RSS raw flow Ting Xu
@ 2021-11-02  1:49   ` Ting Xu
  2021-11-03 14:13     ` Ferruh Yigit
  2021-11-02  1:49   ` [dpdk-dev] [PATCH v3 3/3] doc: add protocol agnostic flow offloading for RSS Ting Xu
  2021-11-03 12:45   ` [dpdk-dev] [PATCH v3 0/3] enable protocol agnostic flow offloading in RSS Zhang, Qi Z
  3 siblings, 1 reply; 29+ messages in thread
From: Ting Xu @ 2021-11-02  1:49 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, qiming.yang, junfeng.guo, Ting Xu

Enable protocol agnostic flow offloading to support raw pattern input
for RSS hash flow rule creation. It is based on Parser Library feature.
Current rte_flow raw API is utilized.

Signed-off-by: Ting Xu <ting.xu@intel.com>
---
 drivers/net/ice/ice_ethdev.h |   9 ++
 drivers/net/ice/ice_hash.c   | 286 ++++++++++++++++++++++++++++++++---
 2 files changed, 273 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h
index bbfeb0cc23..76dc3c99e5 100644
--- a/drivers/net/ice/ice_ethdev.h
+++ b/drivers/net/ice/ice_ethdev.h
@@ -500,6 +500,14 @@ struct ice_fdir_prof_info {
 	u64 fdir_actived_cnt;
 };
 
+/**
+ * Structure to store rss fv entry.
+ */
+struct ice_rss_prof_info {
+	struct ice_parser_profile prof;
+	bool symm;
+};
+
 /**
  * Structure to store private data for each PF/VF instance.
  */
@@ -524,6 +532,7 @@ struct ice_adapter {
 	bool ptp_ena;
 	uint64_t time_hw;
 	struct ice_fdir_prof_info fdir_prof_info[ICE_MAX_PTGS];
+	struct ice_rss_prof_info rss_prof_info[ICE_MAX_PTGS];
 #ifdef RTE_ARCH_X86
 	bool rx_use_avx2;
 	bool rx_use_avx512;
diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c
index 35eff8b17d..14e25a0383 100644
--- a/drivers/net/ice/ice_hash.c
+++ b/drivers/net/ice/ice_hash.c
@@ -32,6 +32,7 @@
 #define ICE_PHINT_GTPU_EH			BIT_ULL(3)
 #define	ICE_PHINT_GTPU_EH_DWN			BIT_ULL(4)
 #define	ICE_PHINT_GTPU_EH_UP			BIT_ULL(5)
+#define ICE_PHINT_RAW				BIT_ULL(6)
 
 #define ICE_GTPU_EH_DWNLINK	0
 #define ICE_GTPU_EH_UPLINK	1
@@ -71,6 +72,7 @@
 struct ice_rss_meta {
 	uint8_t hash_function;
 	struct ice_rss_hash_cfg cfg;
+	struct ice_rss_raw_cfg raw;
 };
 
 struct ice_hash_flow_cfg {
@@ -492,6 +494,7 @@ struct ice_rss_hash_cfg eth_tmplt = {
  */
 static struct ice_pattern_match_item ice_hash_pattern_list[] = {
 	/* IPV4 */
+	{pattern_raw,				ICE_INSET_NONE,				ICE_INSET_NONE,	NULL},
 	{pattern_eth_ipv4,			ICE_RSS_TYPE_ETH_IPV4,		ICE_INSET_NONE,	&ipv4_tmplt},
 	{pattern_eth_ipv4_udp,			ICE_RSS_TYPE_ETH_IPV4_UDP,	ICE_INSET_NONE,	&ipv4_udp_tmplt},
 	{pattern_eth_ipv4_tcp,			ICE_RSS_TYPE_ETH_IPV4_TCP,	ICE_INSET_NONE,	&ipv4_tcp_tmplt},
@@ -612,6 +615,9 @@ ice_hash_parse_pattern(const struct rte_flow_item pattern[], uint64_t *phint,
 		}
 
 		switch (item->type) {
+		case RTE_FLOW_ITEM_TYPE_RAW:
+			*phint |= ICE_PHINT_RAW;
+			break;
 		case RTE_FLOW_ITEM_TYPE_VLAN:
 			*phint |= ICE_PHINT_VLAN;
 			break;
@@ -639,6 +645,91 @@ ice_hash_parse_pattern(const struct rte_flow_item pattern[], uint64_t *phint,
 	return 0;
 }
 
+static int
+ice_hash_parse_raw_pattern(struct ice_adapter *ad,
+				const struct rte_flow_item *item,
+				struct ice_rss_meta *meta)
+{
+	const struct rte_flow_item_raw *raw_spec, *raw_mask;
+	struct ice_parser_profile prof;
+	struct ice_parser_result rslt;
+	struct ice_parser *psr;
+	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';
+	}
+
+	if (ice_parser_create(&ad->hw, &psr))
+		return -rte_errno;
+	if (ice_parser_run(psr, pkt_buf, pkt_len, &rslt))
+		return -rte_errno;
+	ice_parser_destroy(psr);
+
+	if (ice_parser_profile_init(&rslt, pkt_buf, msk_buf,
+		pkt_len, ICE_BLK_RSS, true, &prof))
+		return -rte_errno;
+
+	rte_memcpy(&meta->raw.prof, &prof, sizeof(prof));
+
+	rte_free(pkt_buf);
+	rte_free(msk_buf);
+	return 0;
+}
+
 static void
 ice_refine_hash_cfg_l234(struct ice_rss_hash_cfg *hash_cfg,
 			 uint64_t rss_type)
@@ -999,7 +1090,10 @@ ice_hash_parse_action(struct ice_pattern_match_item *pattern_match_item,
 				   RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ) {
 				rss_meta->hash_function =
 				RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
-				cfg->symm = true;
+				if (pattern_hint == ICE_PHINT_RAW)
+					rss_meta->raw.symm = true;
+				else
+					cfg->symm = true;
 			}
 
 			if (rss->level)
@@ -1017,6 +1111,10 @@ ice_hash_parse_action(struct ice_pattern_match_item *pattern_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 == ICE_PHINT_RAW)
+				break;
+
 			/**
 			 * Check simultaneous use of SRC_ONLY and DST_ONLY
 			 * of the same level.
@@ -1085,6 +1183,17 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,
 	if (ret)
 		goto error;
 
+	if (phint == ICE_PHINT_RAW) {
+		rss_meta_ptr->raw.raw_ena = true;
+		ret = ice_hash_parse_raw_pattern(ad, pattern, rss_meta_ptr);
+		if (ret) {
+			rte_flow_error_set(error, EINVAL,
+					   RTE_FLOW_ERROR_TYPE_ITEM, NULL,
+					   "Parse raw pattern failed");
+			goto error;
+		}
+	}
+
 	/* Check rss action. */
 	ret = ice_hash_parse_action(pattern_match_item, actions, phint,
 				    (void **)&rss_meta_ptr, error);
@@ -1099,6 +1208,71 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,
 	return ret;
 }
 
+static int
+ice_hash_add_raw_cfg(struct ice_adapter *ad,
+		struct ice_rss_raw_cfg *cfg, u16 vsi_handle)
+{
+	struct ice_parser_profile *prof = &cfg->prof;
+	struct ice_rss_prof_info *rss_prof;
+	struct ice_hw *hw = &ad->hw;
+	int i, ptg, ret;
+	u64 id;
+
+	id = (u64)ice_find_first_bit(prof->ptypes, UINT16_MAX);
+
+	ptg = hw->blk[ICE_BLK_RSS].xlt1.t[id];
+	rss_prof = &ad->rss_prof_info[ptg];
+	/* check if ptg already has profile */
+	if (rss_prof->prof.fv_num) {
+		for (i = 0; i < ICE_MAX_FV_WORDS; i++) {
+			if (rss_prof->prof.fv[i].proto_id !=
+			    prof->fv[i].proto_id ||
+			    rss_prof->prof.fv[i].offset !=
+			    prof->fv[i].offset)
+				break;
+		}
+
+		/* current profile is matched, check symmetric hash */
+		if (i == ICE_MAX_FV_WORDS) {
+			if (rss_prof->symm != cfg->symm)
+				goto update_symm;
+
+			return 0;
+		}
+
+		/* current profile is not matched, remove it */
+		ret = ice_rem_prof_id_flow(hw, ICE_BLK_RSS,
+					   ice_get_hw_vsi_num(hw, vsi_handle),
+					   id);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "remove RSS flow failed\n");
+			return ret;
+		}
+
+		ret = ice_rem_prof(hw, ICE_BLK_RSS, id);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "remove RSS profile failed\n");
+			return ret;
+		}
+	}
+
+	/* add new profile */
+	ret = ice_flow_set_hw_prof(hw, vsi_handle, 0, prof, ICE_BLK_RSS);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "HW profile add failed\n");
+		return ret;
+	}
+
+	rss_prof->symm = cfg->symm;
+	ice_memcpy(&rss_prof->prof, prof,
+		   sizeof(struct ice_parser_profile),
+		   ICE_NONDMA_TO_NONDMA);
+
+update_symm:
+	ice_rss_update_raw_symm(hw, cfg, id);
+	return 0;
+}
+
 static int
 ice_hash_create(struct ice_adapter *ad,
 		struct rte_flow *flow,
@@ -1134,15 +1308,30 @@ ice_hash_create(struct ice_adapter *ad,
 
 		goto out;
 	} else {
-		memcpy(&filter_ptr->rss_cfg.hash, &rss_meta->cfg,
-		       sizeof(struct ice_rss_hash_cfg));
-		ret = ice_add_rss_cfg_wrap(pf, vsi->idx,
-					   &filter_ptr->rss_cfg.hash);
-		if (ret) {
-			rte_flow_error_set(error, EINVAL,
-					RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
-					"rss flow create fail");
-			goto error;
+		if (rss_meta->raw.raw_ena) {
+			memcpy(&filter_ptr->rss_cfg.raw, &rss_meta->raw,
+			       sizeof(struct ice_rss_raw_cfg));
+			ret = ice_hash_add_raw_cfg(ad, &rss_meta->raw,
+						   pf->main_vsi->idx);
+			if (ret) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_HANDLE,
+						   NULL,
+						   "rss flow create fail");
+				goto error;
+			}
+		} else {
+			memcpy(&filter_ptr->rss_cfg.hash, &rss_meta->cfg,
+			       sizeof(struct ice_rss_hash_cfg));
+			ret = ice_add_rss_cfg_wrap(pf, vsi->idx,
+						   &filter_ptr->rss_cfg.hash);
+			if (ret) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_HANDLE,
+						   NULL,
+						   "rss flow create fail");
+				goto error;
+			}
 		}
 	}
 
@@ -1157,6 +1346,45 @@ ice_hash_create(struct ice_adapter *ad,
 	return -rte_errno;
 }
 
+static int
+ice_hash_rem_raw_cfg(struct ice_adapter *ad,
+			struct ice_parser_profile *prof,
+		    u16 vsi_handle)
+{
+	struct ice_hw *hw = &ad->hw;
+	int ptg, ret;
+	u16 vsig;
+	u64 id;
+
+	id = (u64)ice_find_first_bit(prof->ptypes, 0xFFFF);
+
+	ptg = hw->blk[ICE_BLK_RSS].xlt1.t[id];
+
+	memset(&ad->rss_prof_info[ptg], 0,
+		sizeof(struct ice_rss_prof_info));
+
+	/* check if vsig is already removed */
+	ret = ice_vsig_find_vsi(hw, ICE_BLK_RSS,
+		ice_get_hw_vsi_num(hw, vsi_handle), &vsig);
+	if (!ret && vsig) {
+		ret = ice_rem_prof_id_flow(hw, ICE_BLK_RSS,
+					   ice_get_hw_vsi_num(hw, vsi__handle),
+					   id);
+		if (ret)
+			goto err;
+
+		ret = ice_rem_prof(hw, ICE_BLK_RSS, id);
+		if (ret)
+			goto err;
+	}
+
+	return 0;
+
+err:
+	PMD_DRV_LOG(ERR, "HW profile remove failed\n");
+	return ret;
+}
+
 static int
 ice_hash_destroy(struct ice_adapter *ad,
 		struct rte_flow *flow,
@@ -1178,18 +1406,32 @@ ice_hash_destroy(struct ice_adapter *ad,
 			(1 << VSIQF_HASH_CTL_HASH_SCHEME_S);
 		ICE_WRITE_REG(hw, VSIQF_HASH_CTL(vsi->vsi_id), reg);
 	} else {
-		ret = ice_rem_rss_cfg_wrap(pf, vsi->idx,
-					   &filter_ptr->rss_cfg.hash);
-		/* Fixme: Ignore the error if a rule does not exist.
-		 * Currently a rule for inputset change or symm turn on/off
-		 * will overwrite an exist rule, while application still
-		 * have 2 rte_flow handles.
-		 **/
-		if (ret && ret != ICE_ERR_DOES_NOT_EXIST) {
-			rte_flow_error_set(error, EINVAL,
-					RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
-					"rss flow destroy fail");
-			goto error;
+		if (filter_ptr->rss_cfg.raw.raw_ena) {
+			ret =
+			ice_hash_rem_raw_cfg(ad, &filter_ptr->rss_cfg.raw.prof,
+					     pf->main_vsi->idx);
+			if (ret) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_HANDLE,
+						   NULL,
+						   "rss flow destroy fail");
+				goto error;
+			}
+		} else {
+			ret = ice_rem_rss_cfg_wrap(pf, vsi->idx,
+						   &filter_ptr->rss_cfg.hash);
+			/* Fixme: Ignore the error if a rule does not exist.
+			 * Currently a rule for inputset change or symm turn
+			 * on/off will overwrite an exist rule, while
+			 * application still have 2 rte_flow handles.
+			 **/
+			if (ret && ret != ICE_ERR_DOES_NOT_EXIST) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_HANDLE,
+						   NULL,
+						   "rss flow destroy fail");
+				goto error;
+			}
 		}
 	}
 
-- 
2.17.1


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

* [dpdk-dev] [PATCH v3 3/3] doc: add protocol agnostic flow offloading for RSS
  2021-11-02  1:49 ` [dpdk-dev] [PATCH v3 0/3] enable protocol agnostic flow offloading in RSS Ting Xu
  2021-11-02  1:49   ` [dpdk-dev] [PATCH v3 1/3] net/ice/base: support add HW profile for RSS raw flow Ting Xu
  2021-11-02  1:49   ` [dpdk-dev] [PATCH v3 2/3] net/ice: enable protocol agnostic flow offloading in RSS Ting Xu
@ 2021-11-02  1:49   ` Ting Xu
  2021-11-03 12:45   ` [dpdk-dev] [PATCH v3 0/3] enable protocol agnostic flow offloading in RSS Zhang, Qi Z
  3 siblings, 0 replies; 29+ messages in thread
From: Ting Xu @ 2021-11-02  1:49 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, qiming.yang, junfeng.guo, Ting Xu

Protocol agnostic flow offloading for RSS hash is supported. Raw pattern
input can be used to create RSS hash flow rules, using current rte_flow
raw API.

Signed-off-by: Ting Xu <ting.xu@intel.com>
---
 doc/guides/rel_notes/release_21_11.rst | 1 +
 1 file changed, 1 insertion(+)

diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst
index 36fdee0a98..0582717628 100644
--- a/doc/guides/rel_notes/release_21_11.rst
+++ b/doc/guides/rel_notes/release_21_11.rst
@@ -168,6 +168,7 @@ New Features
 * **Updated Intel ice driver.**
 
   * Added protocol agnostic flow offloading support in Flow Director.
+  * Added protocol agnostic flow offloading support in RSS hash.
   * Added 1PPS out support by a devargs.
   * Added IPv4 and L4 (TCP/UDP/SCTP) checksum hash support in RSS flow.
   * Added DEV_RX_OFFLOAD_TIMESTAMP support.
-- 
2.17.1


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

* Re: [dpdk-dev] [PATCH v3 0/3] enable protocol agnostic flow offloading in RSS
  2021-11-02  1:49 ` [dpdk-dev] [PATCH v3 0/3] enable protocol agnostic flow offloading in RSS Ting Xu
                     ` (2 preceding siblings ...)
  2021-11-02  1:49   ` [dpdk-dev] [PATCH v3 3/3] doc: add protocol agnostic flow offloading for RSS Ting Xu
@ 2021-11-03 12:45   ` Zhang, Qi Z
  2021-11-03 14:15     ` Ferruh Yigit
  3 siblings, 1 reply; 29+ messages in thread
From: Zhang, Qi Z @ 2021-11-03 12:45 UTC (permalink / raw)
  To: Xu, Ting, dev; +Cc: Yang, Qiming, Guo, Junfeng



> -----Original Message-----
> From: Xu, Ting <ting.xu@intel.com>
> Sent: Tuesday, November 2, 2021 9:50 AM
> To: dev@dpdk.org
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; Guo, Junfeng <junfeng.guo@intel.com>; Xu, Ting
> <ting.xu@intel.com>
> Subject: [PATCH v3 0/3] enable protocol agnostic flow offloading in RSS
> 
> Enable protocol agnostic flow offloading to support raw pattern input for RSS
> hash flow rule creation. It is based on Parser Library feature.
> Current rte_flow raw API is utilized.
> 
> Ting Xu (3):
>   net/ice/base: support add HW profile for RSS raw flow
>   net/ice: enable protocol agnostic flow offloading in RSS
>   doc: add protocol agnostic flow offloading for RSS

Release note update should be squash to the patch that implemented the feature.

> 
>  doc/guides/rel_notes/release_21_11.rst |   1 +
>  drivers/net/ice/base/ice_flow.c        | 109 ++++++++++
>  drivers/net/ice/base/ice_flow.h        |  16 ++
>  drivers/net/ice/ice_ethdev.h           |   9 +
>  drivers/net/ice/ice_hash.c             | 286 +++++++++++++++++++++++--
>  5 files changed, 399 insertions(+), 22 deletions(-)
> 
> --
> 2.17.1

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

Applied to dpdk-next-net-intel.

Thanks
Qi


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

* Re: [dpdk-dev] [PATCH v3 2/3] net/ice: enable protocol agnostic flow offloading in RSS
  2021-11-02  1:49   ` [dpdk-dev] [PATCH v3 2/3] net/ice: enable protocol agnostic flow offloading in RSS Ting Xu
@ 2021-11-03 14:13     ` Ferruh Yigit
  2021-11-04  3:29       ` Xu, Ting
  0 siblings, 1 reply; 29+ messages in thread
From: Ferruh Yigit @ 2021-11-03 14:13 UTC (permalink / raw)
  To: Ting Xu, dev; +Cc: qi.z.zhang, qiming.yang, junfeng.guo

On 11/2/2021 1:49 AM, Ting Xu wrote:
> +static int
> +ice_hash_rem_raw_cfg(struct ice_adapter *ad,
> +			struct ice_parser_profile *prof,
> +		    u16 vsi_handle)
> +{
> +	struct ice_hw *hw = &ad->hw;
> +	int ptg, ret;
> +	u16 vsig;
> +	u64 id;
> +
> +	id = (u64)ice_find_first_bit(prof->ptypes, 0xFFFF);
> +
> +	ptg = hw->blk[ICE_BLK_RSS].xlt1.t[id];
> +
> +	memset(&ad->rss_prof_info[ptg], 0,
> +		sizeof(struct ice_rss_prof_info));
> +
> +	/* check if vsig is already removed */
> +	ret = ice_vsig_find_vsi(hw, ICE_BLK_RSS,
> +		ice_get_hw_vsi_num(hw, vsi_handle), &vsig);
> +	if (!ret && vsig) {
> +		ret = ice_rem_prof_id_flow(hw, ICE_BLK_RSS,
> +					   ice_get_hw_vsi_num(hw, vsi__handle),

The set doesn't compile, 'vsi__handle' is not defined.

Most probably it is a typo for 'vsi_handle', but I was reluctant
to fix it in next-net. If the code sent without compiling, there
may be other issues missed, can you please check the set again,
build it, test it and send a new version?

Thanks,
ferruh

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

* Re: [dpdk-dev] [PATCH v3 0/3] enable protocol agnostic flow offloading in RSS
  2021-11-03 12:45   ` [dpdk-dev] [PATCH v3 0/3] enable protocol agnostic flow offloading in RSS Zhang, Qi Z
@ 2021-11-03 14:15     ` Ferruh Yigit
  0 siblings, 0 replies; 29+ messages in thread
From: Ferruh Yigit @ 2021-11-03 14:15 UTC (permalink / raw)
  To: Zhang, Qi Z, Xu, Ting, dev; +Cc: Yang, Qiming, Guo, Junfeng

On 11/3/2021 12:45 PM, Zhang, Qi Z wrote:
> 
> 
>> -----Original Message-----
>> From: Xu, Ting <ting.xu@intel.com>
>> Sent: Tuesday, November 2, 2021 9:50 AM
>> To: dev@dpdk.org
>> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; Yang, Qiming
>> <qiming.yang@intel.com>; Guo, Junfeng <junfeng.guo@intel.com>; Xu, Ting
>> <ting.xu@intel.com>
>> Subject: [PATCH v3 0/3] enable protocol agnostic flow offloading in RSS
>>
>> Enable protocol agnostic flow offloading to support raw pattern input for RSS
>> hash flow rule creation. It is based on Parser Library feature.
>> Current rte_flow raw API is utilized.
>>
>> Ting Xu (3):
>>    net/ice/base: support add HW profile for RSS raw flow
>>    net/ice: enable protocol agnostic flow offloading in RSS
>>    doc: add protocol agnostic flow offloading for RSS
> 
> Release note update should be squash to the patch that implemented the feature.
> 

+1

Ting, can you send new version including this change please.

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

* [dpdk-dev] [PATCH v4 0/2] enable protocol agnostic flow offloading in RSS
  2021-10-08  7:09 [dpdk-dev] [PATCH v1 0/2] enable protocol agnostic flow offloading in RSS Ting Xu
                   ` (4 preceding siblings ...)
  2021-11-02  1:49 ` [dpdk-dev] [PATCH v3 0/3] enable protocol agnostic flow offloading in RSS Ting Xu
@ 2021-11-04  2:22 ` Ting Xu
  2021-11-04  2:22   ` [dpdk-dev] [PATCH v4 1/2] net/ice/base: support add HW profile for RSS raw flow Ting Xu
                     ` (3 more replies)
  5 siblings, 4 replies; 29+ messages in thread
From: Ting Xu @ 2021-11-04  2:22 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, qiming.yang, junfeng.guo, Ting Xu

Enable protocol agnostic flow offloading to support raw pattern input
for RSS hash flow rule creation. It is based on Parser Library feature.
Current rte_flow raw API is utilized.

Ting Xu (2):
  net/ice/base: support add HW profile for RSS raw flow
  net/ice: enable protocol agnostic flow offloading in RSS

 doc/guides/rel_notes/release_21_11.rst |   1 +
 drivers/net/ice/base/ice_flow.c        | 109 ++++++++++
 drivers/net/ice/base/ice_flow.h        |  16 ++
 drivers/net/ice/ice_ethdev.h           |   9 +
 drivers/net/ice/ice_hash.c             | 286 +++++++++++++++++++++++--
 5 files changed, 399 insertions(+), 22 deletions(-)

-- 
2.17.1


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

* [dpdk-dev] [PATCH v4 1/2] net/ice/base: support add HW profile for RSS raw flow
  2021-11-04  2:22 ` [dpdk-dev] [PATCH v4 0/2] " Ting Xu
@ 2021-11-04  2:22   ` Ting Xu
  2021-11-04  2:22   ` [dpdk-dev] [PATCH v4 2/2] net/ice: enable protocol agnostic flow offloading in RSS Ting Xu
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 29+ messages in thread
From: Ting Xu @ 2021-11-04  2:22 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, qiming.yang, junfeng.guo, Ting Xu

Based on the parser library, we can directly set HW profile and
associate VSI for RSS raw flows. Add symmetric hash configuration
for raw flow.

Signed-off-by: Ting Xu <ting.xu@intel.com>
---
 drivers/net/ice/base/ice_flow.c | 109 ++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_flow.h |  16 +++++
 2 files changed, 125 insertions(+)

diff --git a/drivers/net/ice/base/ice_flow.c b/drivers/net/ice/base/ice_flow.c
index f699dbbc74..da27d157c0 100644
--- a/drivers/net/ice/base/ice_flow.c
+++ b/drivers/net/ice/base/ice_flow.c
@@ -4071,6 +4071,115 @@ ice_rss_update_symm(struct ice_hw *hw,
 	}
 }
 
+/**
+ * ice_rss_cfg_raw_symm - configure symmetric hash parameters
+ * for raw pattern
+ * @hw: pointer to the hardware structure
+ * @prof: pointer to parser profile
+ * @prof_id: profile ID
+ *
+ * Calculate symmetric hash parameters based on input protocol type.
+ */
+static void
+ice_rss_cfg_raw_symm(struct ice_hw *hw,
+		     struct ice_parser_profile *prof, u64 prof_id)
+{
+	u8 src_idx, dst_idx, proto_id;
+	int len, i = 0;
+
+	while (i < prof->fv_num) {
+		proto_id = prof->fv[i].proto_id;
+
+		switch (proto_id) {
+		case ICE_PROT_IPV4_OF_OR_S:
+			len = ICE_FLOW_FLD_SZ_IPV4_ADDR /
+			      ICE_FLOW_FV_EXTRACT_SZ;
+			if (prof->fv[i].offset ==
+			    ICE_FLOW_FIELD_IPV4_SRC_OFFSET &&
+			    prof->fv[i + len].proto_id == proto_id &&
+			    prof->fv[i + len].offset ==
+			    ICE_FLOW_FIELD_IPV4_DST_OFFSET) {
+				src_idx = i;
+				dst_idx = i + len;
+				i += 2 * len;
+				break;
+			}
+			i++;
+			continue;
+		case ICE_PROT_IPV6_OF_OR_S:
+			len = ICE_FLOW_FLD_SZ_IPV6_ADDR /
+			      ICE_FLOW_FV_EXTRACT_SZ;
+			if (prof->fv[i].offset ==
+			    ICE_FLOW_FIELD_IPV6_SRC_OFFSET &&
+			    prof->fv[i + len].proto_id == proto_id &&
+			    prof->fv[i + len].offset ==
+			    ICE_FLOW_FIELD_IPV6_DST_OFFSET) {
+				src_idx = i;
+				dst_idx = i + len;
+				i += 2 * len;
+				break;
+			}
+			i++;
+			continue;
+		case ICE_PROT_TCP_IL:
+		case ICE_PROT_UDP_IL_OR_S:
+		case ICE_PROT_SCTP_IL:
+			len = ICE_FLOW_FLD_SZ_PORT /
+			      ICE_FLOW_FV_EXTRACT_SZ;
+			if (prof->fv[i].offset ==
+			    ICE_FLOW_FIELD_SRC_PORT_OFFSET &&
+			    prof->fv[i + len].proto_id == proto_id &&
+			    prof->fv[i + len].offset ==
+			    ICE_FLOW_FIELD_DST_PORT_OFFSET) {
+				src_idx = i;
+				dst_idx = i + len;
+				i += 2 * len;
+				break;
+			}
+			i++;
+			continue;
+		default:
+			i++;
+			continue;
+		}
+		ice_rss_config_xor(hw, prof_id, src_idx, dst_idx, len);
+	}
+}
+
+/* Max registers index per packet profile */
+#define ICE_SYMM_REG_INDEX_MAX 6
+
+/**
+ * ice_rss_update_raw_symm - update symmetric hash configuration
+ * for raw pattern
+ * @hw: pointer to the hardware structure
+ * @cfg: configure parameters for raw pattern
+ * @id: profile tracking ID
+ *
+ * Update symmetric hash configuration for raw pattern if required.
+ * Otherwise only clear to default.
+ */
+void
+ice_rss_update_raw_symm(struct ice_hw *hw,
+			struct ice_rss_raw_cfg *cfg, u64 id)
+{
+	struct ice_prof_map *map;
+	u8 prof_id, m;
+
+	ice_acquire_lock(&hw->blk[ICE_BLK_RSS].es.prof_map_lock);
+	map = ice_search_prof_id(hw, ICE_BLK_RSS, id);
+	if (map)
+		prof_id = map->prof_id;
+	ice_release_lock(&hw->blk[ICE_BLK_RSS].es.prof_map_lock);
+	if (!map)
+		return;
+	/* clear to default */
+	for (m = 0; m < ICE_SYMM_REG_INDEX_MAX; m++)
+		wr32(hw, GLQF_HSYMM(prof_id, m), 0);
+	if (cfg->symm)
+		ice_rss_cfg_raw_symm(hw, &cfg->prof, prof_id);
+}
+
 /**
  * ice_add_rss_cfg_sync - add an RSS configuration
  * @hw: pointer to the hardware structure
diff --git a/drivers/net/ice/base/ice_flow.h b/drivers/net/ice/base/ice_flow.h
index dea7b3c0e8..f941ce4333 100644
--- a/drivers/net/ice/base/ice_flow.h
+++ b/drivers/net/ice/base/ice_flow.h
@@ -149,6 +149,13 @@
 #define ICE_FLOW_HASH_NAT_T_ESP_IPV6_SPI \
 	(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_NAT_T_ESP_SPI)
 
+#define ICE_FLOW_FIELD_IPV4_SRC_OFFSET 12
+#define ICE_FLOW_FIELD_IPV4_DST_OFFSET 16
+#define ICE_FLOW_FIELD_IPV6_SRC_OFFSET 8
+#define ICE_FLOW_FIELD_IPV6_DST_OFFSET 24
+#define ICE_FLOW_FIELD_SRC_PORT_OFFSET 0
+#define ICE_FLOW_FIELD_DST_PORT_OFFSET 2
+
 /* Protocol header fields within a packet segment. A segment consists of one or
  * more protocol headers that make up a logical group of protocol headers. Each
  * logical group of protocol headers encapsulates or is encapsulated using/by
@@ -493,11 +500,18 @@ struct ice_flow_prof {
 	struct ice_flow_action *acts;
 };
 
+struct ice_rss_raw_cfg {
+	struct ice_parser_profile prof;
+	bool raw_ena;
+	bool symm;
+};
+
 struct ice_rss_cfg {
 	struct LIST_ENTRY_TYPE l_entry;
 	/* bitmap of VSIs added to the RSS entry */
 	ice_declare_bitmap(vsis, ICE_MAX_VSI);
 	struct ice_rss_hash_cfg hash;
+	struct ice_rss_raw_cfg raw;
 };
 
 enum ice_flow_action_type {
@@ -585,5 +599,7 @@ ice_add_rss_cfg(struct ice_hw *hw, u16 vsi_handle,
 enum ice_status
 ice_rem_rss_cfg(struct ice_hw *hw, u16 vsi_handle,
 		const struct ice_rss_hash_cfg *cfg);
+void ice_rss_update_raw_symm(struct ice_hw *hw,
+			     struct ice_rss_raw_cfg *cfg, u64 id);
 u64 ice_get_rss_cfg(struct ice_hw *hw, u16 vsi_handle, u32 hdrs);
 #endif /* _ICE_FLOW_H_ */
-- 
2.17.1


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

* [dpdk-dev] [PATCH v4 2/2] net/ice: enable protocol agnostic flow offloading in RSS
  2021-11-04  2:22 ` [dpdk-dev] [PATCH v4 0/2] " Ting Xu
  2021-11-04  2:22   ` [dpdk-dev] [PATCH v4 1/2] net/ice/base: support add HW profile for RSS raw flow Ting Xu
@ 2021-11-04  2:22   ` Ting Xu
  2021-11-04  3:31   ` [dpdk-dev] [PATCH v4 0/2] " Zhang, Qi Z
  2021-11-05 13:09   ` Thomas Monjalon
  3 siblings, 0 replies; 29+ messages in thread
From: Ting Xu @ 2021-11-04  2:22 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, qiming.yang, junfeng.guo, Ting Xu

Enable protocol agnostic flow offloading to support raw pattern input
for RSS hash flow rule creation. It is based on Parser Library feature.
Current rte_flow raw API is utilized.

Signed-off-by: Ting Xu <ting.xu@intel.com>
---
 doc/guides/rel_notes/release_21_11.rst |   1 +
 drivers/net/ice/ice_ethdev.h           |   9 +
 drivers/net/ice/ice_hash.c             | 286 +++++++++++++++++++++++--
 3 files changed, 274 insertions(+), 22 deletions(-)

diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst
index 36fdee0a98..0582717628 100644
--- a/doc/guides/rel_notes/release_21_11.rst
+++ b/doc/guides/rel_notes/release_21_11.rst
@@ -168,6 +168,7 @@ New Features
 * **Updated Intel ice driver.**
 
   * Added protocol agnostic flow offloading support in Flow Director.
+  * Added protocol agnostic flow offloading support in RSS hash.
   * Added 1PPS out support by a devargs.
   * Added IPv4 and L4 (TCP/UDP/SCTP) checksum hash support in RSS flow.
   * Added DEV_RX_OFFLOAD_TIMESTAMP support.
diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h
index d021e7fd0b..3a5bb9bbc6 100644
--- a/drivers/net/ice/ice_ethdev.h
+++ b/drivers/net/ice/ice_ethdev.h
@@ -500,6 +500,14 @@ struct ice_fdir_prof_info {
 	u64 fdir_actived_cnt;
 };
 
+/**
+ * Structure to store rss fv entry.
+ */
+struct ice_rss_prof_info {
+	struct ice_parser_profile prof;
+	bool symm;
+};
+
 /**
  * Structure to store private data for each PF/VF instance.
  */
@@ -524,6 +532,7 @@ struct ice_adapter {
 	bool ptp_ena;
 	uint64_t time_hw;
 	struct ice_fdir_prof_info fdir_prof_info[ICE_MAX_PTGS];
+	struct ice_rss_prof_info rss_prof_info[ICE_MAX_PTGS];
 #ifdef RTE_ARCH_X86
 	bool rx_use_avx2;
 	bool rx_use_avx512;
diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c
index 35eff8b17d..4b682a4f35 100644
--- a/drivers/net/ice/ice_hash.c
+++ b/drivers/net/ice/ice_hash.c
@@ -32,6 +32,7 @@
 #define ICE_PHINT_GTPU_EH			BIT_ULL(3)
 #define	ICE_PHINT_GTPU_EH_DWN			BIT_ULL(4)
 #define	ICE_PHINT_GTPU_EH_UP			BIT_ULL(5)
+#define ICE_PHINT_RAW				BIT_ULL(6)
 
 #define ICE_GTPU_EH_DWNLINK	0
 #define ICE_GTPU_EH_UPLINK	1
@@ -71,6 +72,7 @@
 struct ice_rss_meta {
 	uint8_t hash_function;
 	struct ice_rss_hash_cfg cfg;
+	struct ice_rss_raw_cfg raw;
 };
 
 struct ice_hash_flow_cfg {
@@ -492,6 +494,7 @@ struct ice_rss_hash_cfg eth_tmplt = {
  */
 static struct ice_pattern_match_item ice_hash_pattern_list[] = {
 	/* IPV4 */
+	{pattern_raw,				ICE_INSET_NONE,				ICE_INSET_NONE,	NULL},
 	{pattern_eth_ipv4,			ICE_RSS_TYPE_ETH_IPV4,		ICE_INSET_NONE,	&ipv4_tmplt},
 	{pattern_eth_ipv4_udp,			ICE_RSS_TYPE_ETH_IPV4_UDP,	ICE_INSET_NONE,	&ipv4_udp_tmplt},
 	{pattern_eth_ipv4_tcp,			ICE_RSS_TYPE_ETH_IPV4_TCP,	ICE_INSET_NONE,	&ipv4_tcp_tmplt},
@@ -612,6 +615,9 @@ ice_hash_parse_pattern(const struct rte_flow_item pattern[], uint64_t *phint,
 		}
 
 		switch (item->type) {
+		case RTE_FLOW_ITEM_TYPE_RAW:
+			*phint |= ICE_PHINT_RAW;
+			break;
 		case RTE_FLOW_ITEM_TYPE_VLAN:
 			*phint |= ICE_PHINT_VLAN;
 			break;
@@ -639,6 +645,91 @@ ice_hash_parse_pattern(const struct rte_flow_item pattern[], uint64_t *phint,
 	return 0;
 }
 
+static int
+ice_hash_parse_raw_pattern(struct ice_adapter *ad,
+				const struct rte_flow_item *item,
+				struct ice_rss_meta *meta)
+{
+	const struct rte_flow_item_raw *raw_spec, *raw_mask;
+	struct ice_parser_profile prof;
+	struct ice_parser_result rslt;
+	struct ice_parser *psr;
+	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';
+	}
+
+	if (ice_parser_create(&ad->hw, &psr))
+		return -rte_errno;
+	if (ice_parser_run(psr, pkt_buf, pkt_len, &rslt))
+		return -rte_errno;
+	ice_parser_destroy(psr);
+
+	if (ice_parser_profile_init(&rslt, pkt_buf, msk_buf,
+		pkt_len, ICE_BLK_RSS, true, &prof))
+		return -rte_errno;
+
+	rte_memcpy(&meta->raw.prof, &prof, sizeof(prof));
+
+	rte_free(pkt_buf);
+	rte_free(msk_buf);
+	return 0;
+}
+
 static void
 ice_refine_hash_cfg_l234(struct ice_rss_hash_cfg *hash_cfg,
 			 uint64_t rss_type)
@@ -999,7 +1090,10 @@ ice_hash_parse_action(struct ice_pattern_match_item *pattern_match_item,
 				   RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ) {
 				rss_meta->hash_function =
 				RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
-				cfg->symm = true;
+				if (pattern_hint == ICE_PHINT_RAW)
+					rss_meta->raw.symm = true;
+				else
+					cfg->symm = true;
 			}
 
 			if (rss->level)
@@ -1017,6 +1111,10 @@ ice_hash_parse_action(struct ice_pattern_match_item *pattern_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 == ICE_PHINT_RAW)
+				break;
+
 			/**
 			 * Check simultaneous use of SRC_ONLY and DST_ONLY
 			 * of the same level.
@@ -1085,6 +1183,17 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,
 	if (ret)
 		goto error;
 
+	if (phint == ICE_PHINT_RAW) {
+		rss_meta_ptr->raw.raw_ena = true;
+		ret = ice_hash_parse_raw_pattern(ad, pattern, rss_meta_ptr);
+		if (ret) {
+			rte_flow_error_set(error, EINVAL,
+					   RTE_FLOW_ERROR_TYPE_ITEM, NULL,
+					   "Parse raw pattern failed");
+			goto error;
+		}
+	}
+
 	/* Check rss action. */
 	ret = ice_hash_parse_action(pattern_match_item, actions, phint,
 				    (void **)&rss_meta_ptr, error);
@@ -1099,6 +1208,71 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,
 	return ret;
 }
 
+static int
+ice_hash_add_raw_cfg(struct ice_adapter *ad,
+		struct ice_rss_raw_cfg *cfg, u16 vsi_handle)
+{
+	struct ice_parser_profile *prof = &cfg->prof;
+	struct ice_rss_prof_info *rss_prof;
+	struct ice_hw *hw = &ad->hw;
+	int i, ptg, ret;
+	u64 id;
+
+	id = (u64)ice_find_first_bit(prof->ptypes, UINT16_MAX);
+
+	ptg = hw->blk[ICE_BLK_RSS].xlt1.t[id];
+	rss_prof = &ad->rss_prof_info[ptg];
+	/* check if ptg already has profile */
+	if (rss_prof->prof.fv_num) {
+		for (i = 0; i < ICE_MAX_FV_WORDS; i++) {
+			if (rss_prof->prof.fv[i].proto_id !=
+			    prof->fv[i].proto_id ||
+			    rss_prof->prof.fv[i].offset !=
+			    prof->fv[i].offset)
+				break;
+		}
+
+		/* current profile is matched, check symmetric hash */
+		if (i == ICE_MAX_FV_WORDS) {
+			if (rss_prof->symm != cfg->symm)
+				goto update_symm;
+
+			return 0;
+		}
+
+		/* current profile is not matched, remove it */
+		ret = ice_rem_prof_id_flow(hw, ICE_BLK_RSS,
+					   ice_get_hw_vsi_num(hw, vsi_handle),
+					   id);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "remove RSS flow failed\n");
+			return ret;
+		}
+
+		ret = ice_rem_prof(hw, ICE_BLK_RSS, id);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "remove RSS profile failed\n");
+			return ret;
+		}
+	}
+
+	/* add new profile */
+	ret = ice_flow_set_hw_prof(hw, vsi_handle, 0, prof, ICE_BLK_RSS);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "HW profile add failed\n");
+		return ret;
+	}
+
+	rss_prof->symm = cfg->symm;
+	ice_memcpy(&rss_prof->prof, prof,
+		   sizeof(struct ice_parser_profile),
+		   ICE_NONDMA_TO_NONDMA);
+
+update_symm:
+	ice_rss_update_raw_symm(hw, cfg, id);
+	return 0;
+}
+
 static int
 ice_hash_create(struct ice_adapter *ad,
 		struct rte_flow *flow,
@@ -1134,15 +1308,30 @@ ice_hash_create(struct ice_adapter *ad,
 
 		goto out;
 	} else {
-		memcpy(&filter_ptr->rss_cfg.hash, &rss_meta->cfg,
-		       sizeof(struct ice_rss_hash_cfg));
-		ret = ice_add_rss_cfg_wrap(pf, vsi->idx,
-					   &filter_ptr->rss_cfg.hash);
-		if (ret) {
-			rte_flow_error_set(error, EINVAL,
-					RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
-					"rss flow create fail");
-			goto error;
+		if (rss_meta->raw.raw_ena) {
+			memcpy(&filter_ptr->rss_cfg.raw, &rss_meta->raw,
+			       sizeof(struct ice_rss_raw_cfg));
+			ret = ice_hash_add_raw_cfg(ad, &rss_meta->raw,
+						   pf->main_vsi->idx);
+			if (ret) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_HANDLE,
+						   NULL,
+						   "rss flow create fail");
+				goto error;
+			}
+		} else {
+			memcpy(&filter_ptr->rss_cfg.hash, &rss_meta->cfg,
+			       sizeof(struct ice_rss_hash_cfg));
+			ret = ice_add_rss_cfg_wrap(pf, vsi->idx,
+						   &filter_ptr->rss_cfg.hash);
+			if (ret) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_HANDLE,
+						   NULL,
+						   "rss flow create fail");
+				goto error;
+			}
 		}
 	}
 
@@ -1157,6 +1346,45 @@ ice_hash_create(struct ice_adapter *ad,
 	return -rte_errno;
 }
 
+static int
+ice_hash_rem_raw_cfg(struct ice_adapter *ad,
+			struct ice_parser_profile *prof,
+		    u16 vsi_handle)
+{
+	struct ice_hw *hw = &ad->hw;
+	int ptg, ret;
+	u16 vsig;
+	u64 id;
+
+	id = (u64)ice_find_first_bit(prof->ptypes, 0xFFFF);
+
+	ptg = hw->blk[ICE_BLK_RSS].xlt1.t[id];
+
+	memset(&ad->rss_prof_info[ptg], 0,
+		sizeof(struct ice_rss_prof_info));
+
+	/* check if vsig is already removed */
+	ret = ice_vsig_find_vsi(hw, ICE_BLK_RSS,
+		ice_get_hw_vsi_num(hw, vsi_handle), &vsig);
+	if (!ret && vsig) {
+		ret = ice_rem_prof_id_flow(hw, ICE_BLK_RSS,
+					   ice_get_hw_vsi_num(hw, vsi_handle),
+					   id);
+		if (ret)
+			goto err;
+
+		ret = ice_rem_prof(hw, ICE_BLK_RSS, id);
+		if (ret)
+			goto err;
+	}
+
+	return 0;
+
+err:
+	PMD_DRV_LOG(ERR, "HW profile remove failed\n");
+	return ret;
+}
+
 static int
 ice_hash_destroy(struct ice_adapter *ad,
 		struct rte_flow *flow,
@@ -1178,18 +1406,32 @@ ice_hash_destroy(struct ice_adapter *ad,
 			(1 << VSIQF_HASH_CTL_HASH_SCHEME_S);
 		ICE_WRITE_REG(hw, VSIQF_HASH_CTL(vsi->vsi_id), reg);
 	} else {
-		ret = ice_rem_rss_cfg_wrap(pf, vsi->idx,
-					   &filter_ptr->rss_cfg.hash);
-		/* Fixme: Ignore the error if a rule does not exist.
-		 * Currently a rule for inputset change or symm turn on/off
-		 * will overwrite an exist rule, while application still
-		 * have 2 rte_flow handles.
-		 **/
-		if (ret && ret != ICE_ERR_DOES_NOT_EXIST) {
-			rte_flow_error_set(error, EINVAL,
-					RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
-					"rss flow destroy fail");
-			goto error;
+		if (filter_ptr->rss_cfg.raw.raw_ena) {
+			ret =
+			ice_hash_rem_raw_cfg(ad, &filter_ptr->rss_cfg.raw.prof,
+					     pf->main_vsi->idx);
+			if (ret) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_HANDLE,
+						   NULL,
+						   "rss flow destroy fail");
+				goto error;
+			}
+		} else {
+			ret = ice_rem_rss_cfg_wrap(pf, vsi->idx,
+						   &filter_ptr->rss_cfg.hash);
+			/* Fixme: Ignore the error if a rule does not exist.
+			 * Currently a rule for inputset change or symm turn
+			 * on/off will overwrite an exist rule, while
+			 * application still have 2 rte_flow handles.
+			 **/
+			if (ret && ret != ICE_ERR_DOES_NOT_EXIST) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_HANDLE,
+						   NULL,
+						   "rss flow destroy fail");
+				goto error;
+			}
 		}
 	}
 
-- 
2.17.1


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

* Re: [dpdk-dev] [PATCH v3 2/3] net/ice: enable protocol agnostic flow offloading in RSS
  2021-11-03 14:13     ` Ferruh Yigit
@ 2021-11-04  3:29       ` Xu, Ting
  0 siblings, 0 replies; 29+ messages in thread
From: Xu, Ting @ 2021-11-04  3:29 UTC (permalink / raw)
  To: Yigit, Ferruh, dev; +Cc: Zhang, Qi Z, Yang, Qiming, Guo, Junfeng

> -----Original Message-----
> From: Yigit, Ferruh <ferruh.yigit@intel.com>
> Sent: Wednesday, November 3, 2021 10:13 PM
> To: Xu, Ting <ting.xu@intel.com>; dev@dpdk.org
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; Guo, Junfeng <junfeng.guo@intel.com>
> Subject: Re: [dpdk-dev] [PATCH v3 2/3] net/ice: enable protocol agnostic flow
> offloading in RSS
> 
> On 11/2/2021 1:49 AM, Ting Xu wrote:
> > +static int
> > +ice_hash_rem_raw_cfg(struct ice_adapter *ad,
> > +			struct ice_parser_profile *prof,
> > +		    u16 vsi_handle)
> > +{
> > +	struct ice_hw *hw = &ad->hw;
> > +	int ptg, ret;
> > +	u16 vsig;
> > +	u64 id;
> > +
> > +	id = (u64)ice_find_first_bit(prof->ptypes, 0xFFFF);
> > +
> > +	ptg = hw->blk[ICE_BLK_RSS].xlt1.t[id];
> > +
> > +	memset(&ad->rss_prof_info[ptg], 0,
> > +		sizeof(struct ice_rss_prof_info));
> > +
> > +	/* check if vsig is already removed */
> > +	ret = ice_vsig_find_vsi(hw, ICE_BLK_RSS,
> > +		ice_get_hw_vsi_num(hw, vsi_handle), &vsig);
> > +	if (!ret && vsig) {
> > +		ret = ice_rem_prof_id_flow(hw, ICE_BLK_RSS,
> > +					   ice_get_hw_vsi_num(hw,
> vsi__handle),
> 
> The set doesn't compile, 'vsi__handle' is not defined.
> 
> Most probably it is a typo for 'vsi_handle', but I was reluctant to fix it in next-
> net. If the code sent without compiling, there may be other issues missed, can
> you please check the set again, build it, test it and send a new version?
> 
> Thanks,
> Ferruh

Hi, Ferruh, Sorry for the missing check since I was hurried when submitted this patchset after update.
A new version is sent now with build and test passed. Thanks!

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

* Re: [dpdk-dev] [PATCH v4 0/2] enable protocol agnostic flow offloading in RSS
  2021-11-04  2:22 ` [dpdk-dev] [PATCH v4 0/2] " Ting Xu
  2021-11-04  2:22   ` [dpdk-dev] [PATCH v4 1/2] net/ice/base: support add HW profile for RSS raw flow Ting Xu
  2021-11-04  2:22   ` [dpdk-dev] [PATCH v4 2/2] net/ice: enable protocol agnostic flow offloading in RSS Ting Xu
@ 2021-11-04  3:31   ` Zhang, Qi Z
  2021-11-05 13:09   ` Thomas Monjalon
  3 siblings, 0 replies; 29+ messages in thread
From: Zhang, Qi Z @ 2021-11-04  3:31 UTC (permalink / raw)
  To: Xu, Ting, dev; +Cc: Yang, Qiming, Guo, Junfeng



> -----Original Message-----
> From: Xu, Ting <ting.xu@intel.com>
> Sent: Thursday, November 4, 2021 10:22 AM
> To: dev@dpdk.org
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; Guo, Junfeng <junfeng.guo@intel.com>; Xu, Ting
> <ting.xu@intel.com>
> Subject: [PATCH v4 0/2] enable protocol agnostic flow offloading in RSS
> 
> Enable protocol agnostic flow offloading to support raw pattern input for RSS
> hash flow rule creation. It is based on Parser Library feature.
> Current rte_flow raw API is utilized.
> 
> Ting Xu (2):
>   net/ice/base: support add HW profile for RSS raw flow
>   net/ice: enable protocol agnostic flow offloading in RSS
> 
>  doc/guides/rel_notes/release_21_11.rst |   1 +
>  drivers/net/ice/base/ice_flow.c        | 109 ++++++++++
>  drivers/net/ice/base/ice_flow.h        |  16 ++
>  drivers/net/ice/ice_ethdev.h           |   9 +
>  drivers/net/ice/ice_hash.c             | 286 +++++++++++++++++++++++--
>  5 files changed, 399 insertions(+), 22 deletions(-)
> 
> --
> 2.17.1

Applied to dpdk-next-net-intel.

Thanks
Qi


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

* Re: [dpdk-dev] [PATCH v4 0/2] enable protocol agnostic flow offloading in RSS
  2021-11-04  2:22 ` [dpdk-dev] [PATCH v4 0/2] " Ting Xu
                     ` (2 preceding siblings ...)
  2021-11-04  3:31   ` [dpdk-dev] [PATCH v4 0/2] " Zhang, Qi Z
@ 2021-11-05 13:09   ` Thomas Monjalon
  2021-11-05 13:18     ` Xu, Ting
  3 siblings, 1 reply; 29+ messages in thread
From: Thomas Monjalon @ 2021-11-05 13:09 UTC (permalink / raw)
  To: qi.z.zhang, Ting Xu
  Cc: dev, qiming.yang, junfeng.guo, orika, viacheslavo, ferruh.yigit,
	andrew.rybchenko

04/11/2021 03:22, Ting Xu:
> Enable protocol agnostic flow offloading to support raw pattern input
> for RSS hash flow rule creation. It is based on Parser Library feature.
> Current rte_flow raw API is utilized.

I remember raw item was especially targetting encapsulation action.
Which action do you achieve in ice PMD? Only RSS with raw item?

For matching, raw item is quite limited. I think the new flex item
is more appropriate for general custom protocol parsing.
Did you look into flex item feature?




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

* Re: [dpdk-dev] [PATCH v4 0/2] enable protocol agnostic flow offloading in RSS
  2021-11-05 13:09   ` Thomas Monjalon
@ 2021-11-05 13:18     ` Xu, Ting
  2021-11-05 13:23       ` Thomas Monjalon
  0 siblings, 1 reply; 29+ messages in thread
From: Xu, Ting @ 2021-11-05 13:18 UTC (permalink / raw)
  To: Thomas Monjalon, Zhang, Qi Z
  Cc: dev, Yang, Qiming, Guo, Junfeng, orika, viacheslavo, Yigit,
	Ferruh, andrew.rybchenko

> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Friday, November 5, 2021 9:10 PM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>; Xu, Ting <ting.xu@intel.com>
> Cc: dev@dpdk.org; Yang, Qiming <qiming.yang@intel.com>; Guo, Junfeng
> <junfeng.guo@intel.com>; orika@nvidia.com; viacheslavo@nvidia.com; Yigit,
> Ferruh <ferruh.yigit@intel.com>; andrew.rybchenko@oktetlabs.ru
> Subject: Re: [dpdk-dev] [PATCH v4 0/2] enable protocol agnostic flow
> offloading in RSS
> 
> 04/11/2021 03:22, Ting Xu:
> > Enable protocol agnostic flow offloading to support raw pattern input
> > for RSS hash flow rule creation. It is based on Parser Library feature.
> > Current rte_flow raw API is utilized.
> 
> I remember raw item was especially targetting encapsulation action.
> Which action do you achieve in ice PMD? Only RSS with raw item?
> 
> For matching, raw item is quite limited. I think the new flex item is more
> appropriate for general custom protocol parsing.
> Did you look into flex item feature?
> 
Hi, Thomas, we make use of the API for rte_raw to achieve our protocol agnostic flow offloading method, including RSS and FDIR. Behind it is the new Parser Library feature based on DDP, rather than the original logic I think. Binary-format pattern spec and mask are passed to Parser Library and the corresponding protocol ID and offset will be provided.


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

* Re: [dpdk-dev] [PATCH v4 0/2] enable protocol agnostic flow offloading in RSS
  2021-11-05 13:18     ` Xu, Ting
@ 2021-11-05 13:23       ` Thomas Monjalon
  2021-11-05 14:53         ` Xu, Ting
  0 siblings, 1 reply; 29+ messages in thread
From: Thomas Monjalon @ 2021-11-05 13:23 UTC (permalink / raw)
  To: Zhang, Qi Z, Xu, Ting
  Cc: dev, Yang, Qiming, Guo, Junfeng, orika, viacheslavo, Yigit,
	Ferruh, andrew.rybchenko

05/11/2021 14:18, Xu, Ting:
> From: Thomas Monjalon <thomas@monjalon.net>
> > 04/11/2021 03:22, Ting Xu:
> > > Enable protocol agnostic flow offloading to support raw pattern input
> > > for RSS hash flow rule creation. It is based on Parser Library feature.
> > > Current rte_flow raw API is utilized.
> > 
> > I remember raw item was especially targetting encapsulation action.
> > Which action do you achieve in ice PMD? Only RSS with raw item?
> > 
> > For matching, raw item is quite limited. I think the new flex item is more
> > appropriate for general custom protocol parsing.
> > Did you look into flex item feature?
> > 
> Hi, Thomas, we make use of the API for rte_raw to achieve
> our protocol agnostic flow offloading method, including RSS and FDIR.
> Behind it is the new Parser Library feature based on DDP,

Where is this parser library code?

> rather than the original logic I think.

> Binary-format pattern spec and mask are passed to Parser Library
> and the corresponding protocol ID and offset will be provided.

Sorry you didn't reply about the new flex item added in this release.
Do you know it was added?
	https://git.dpdk.org/dpdk/commit/?id=dc4d860e8a89



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

* Re: [dpdk-dev] [PATCH v4 0/2] enable protocol agnostic flow offloading in RSS
  2021-11-05 13:23       ` Thomas Monjalon
@ 2021-11-05 14:53         ` Xu, Ting
  2021-11-08  2:44           ` Zhang, Qi Z
  0 siblings, 1 reply; 29+ messages in thread
From: Xu, Ting @ 2021-11-05 14:53 UTC (permalink / raw)
  To: Thomas Monjalon, Zhang, Qi Z
  Cc: dev, Yang, Qiming, Guo, Junfeng, orika, viacheslavo, Yigit,
	Ferruh, andrew.rybchenko

> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Friday, November 5, 2021 9:23 PM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>; Xu, Ting <ting.xu@intel.com>
> Cc: dev@dpdk.org; Yang, Qiming <qiming.yang@intel.com>; Guo, Junfeng
> <junfeng.guo@intel.com>; orika@nvidia.com; viacheslavo@nvidia.com; Yigit,
> Ferruh <ferruh.yigit@intel.com>; andrew.rybchenko@oktetlabs.ru
> Subject: Re: [dpdk-dev] [PATCH v4 0/2] enable protocol agnostic flow
> offloading in RSS
> 
> 05/11/2021 14:18, Xu, Ting:
> > From: Thomas Monjalon <thomas@monjalon.net>
> > > 04/11/2021 03:22, Ting Xu:
> > > > Enable protocol agnostic flow offloading to support raw pattern
> > > > input for RSS hash flow rule creation. It is based on Parser Library
> feature.
> > > > Current rte_flow raw API is utilized.
> > >
> > > I remember raw item was especially targetting encapsulation action.
> > > Which action do you achieve in ice PMD? Only RSS with raw item?
> > >
> > > For matching, raw item is quite limited. I think the new flex item
> > > is more appropriate for general custom protocol parsing.
> > > Did you look into flex item feature?
> > >
> > Hi, Thomas, we make use of the API for rte_raw to achieve our protocol
> > agnostic flow offloading method, including RSS and FDIR.
> > Behind it is the new Parser Library feature based on DDP,
> 
> Where is this parser library code?

Parser Library is committed before as ice base code.

> 
> > rather than the original logic I think.
> 
> > Binary-format pattern spec and mask are passed to Parser Library and
> > the corresponding protocol ID and offset will be provided.
> 
> Sorry you didn't reply about the new flex item added in this release.
> Do you know it was added?
> 	https://git.dpdk.org/dpdk/commit/?id=dc4d860e8a89
> 

Protocol agnostic flow offloading is based on ice DDP feature, although they all want to make flow creation more flexible, I think it is different with flex item.
@Zhang, Qi Z Hi, Qi, are you familiar with flex item?


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

* Re: [dpdk-dev] [PATCH v4 0/2] enable protocol agnostic flow offloading in RSS
  2021-11-05 14:53         ` Xu, Ting
@ 2021-11-08  2:44           ` Zhang, Qi Z
  2021-11-08 19:47             ` Thomas Monjalon
  0 siblings, 1 reply; 29+ messages in thread
From: Zhang, Qi Z @ 2021-11-08  2:44 UTC (permalink / raw)
  To: Xu, Ting, Thomas Monjalon
  Cc: dev, Yang, Qiming, Guo, Junfeng, orika, viacheslavo, Yigit,
	Ferruh, andrew.rybchenko



> -----Original Message-----
> From: Xu, Ting <ting.xu@intel.com>
> Sent: Friday, November 5, 2021 10:54 PM
> To: Thomas Monjalon <thomas@monjalon.net>; Zhang, Qi Z
> <qi.z.zhang@intel.com>
> Cc: dev@dpdk.org; Yang, Qiming <qiming.yang@intel.com>; Guo, Junfeng
> <junfeng.guo@intel.com>; orika@nvidia.com; viacheslavo@nvidia.com;
> Yigit, Ferruh <ferruh.yigit@intel.com>; andrew.rybchenko@oktetlabs.ru
> Subject: RE: [dpdk-dev] [PATCH v4 0/2] enable protocol agnostic flow
> offloading in RSS
> 
> > -----Original Message-----
> > From: Thomas Monjalon <thomas@monjalon.net>
> > Sent: Friday, November 5, 2021 9:23 PM
> > To: Zhang, Qi Z <qi.z.zhang@intel.com>; Xu, Ting <ting.xu@intel.com>
> > Cc: dev@dpdk.org; Yang, Qiming <qiming.yang@intel.com>; Guo, Junfeng
> > <junfeng.guo@intel.com>; orika@nvidia.com; viacheslavo@nvidia.com;
> > Yigit, Ferruh <ferruh.yigit@intel.com>; andrew.rybchenko@oktetlabs.ru
> > Subject: Re: [dpdk-dev] [PATCH v4 0/2] enable protocol agnostic flow
> > offloading in RSS
> >
> > 05/11/2021 14:18, Xu, Ting:
> > > From: Thomas Monjalon <thomas@monjalon.net>
> > > > 04/11/2021 03:22, Ting Xu:
> > > > > Enable protocol agnostic flow offloading to support raw pattern
> > > > > input for RSS hash flow rule creation. It is based on Parser
> > > > > Library
> > feature.
> > > > > Current rte_flow raw API is utilized.
> > > >
> > > > I remember raw item was especially targetting encapsulation action.
> > > > Which action do you achieve in ice PMD? Only RSS with raw item?
> > > >
> > > > For matching, raw item is quite limited. I think the new flex item
> > > > is more appropriate for general custom protocol parsing.
> > > > Did you look into flex item feature?
> > > >
> > > Hi, Thomas, we make use of the API for rte_raw to achieve our
> > > protocol agnostic flow offloading method, including RSS and FDIR.
> > > Behind it is the new Parser Library feature based on DDP,
> >
> > Where is this parser library code?
> 
> Parser Library is committed before as ice base code.
> 
> >
> > > rather than the original logic I think.
> >
> > > Binary-format pattern spec and mask are passed to Parser Library and
> > > the corresponding protocol ID and offset will be provided.
> >
> > Sorry you didn't reply about the new flex item added in this release.
> > Do you know it was added?
> > 	https://git.dpdk.org/dpdk/commit/?id=dc4d860e8a89
> >
> 
> Protocol agnostic flow offloading is based on ice DDP feature, although
> they all want to make flow creation more flexible, I think it is different
> with flex item.
> @Zhang, Qi Z Hi, Qi, are you familiar with flex item?
> 

Yes, this is a very Intel DDP specific feature, the goal is to make our driver to support any customized parser (DDP) without change code.

Below steps are planned:

1. raw packet interface, this help on quick POC, as its simply the rte_flow parser, but of cause it's not scale for an DPDK application to support different vendor.
2. enable a build-in util to forge a packet from a sequence of rte_flow headers, then the application will be scale, but the missing part is how to describe a customized header, we have similar idea like json, but seems "Flex Item" already help to fix this gap, and we will improve the solution base on it.

Thanks
Qi


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

* Re: [dpdk-dev] [PATCH v4 0/2] enable protocol agnostic flow offloading in RSS
  2021-11-08  2:44           ` Zhang, Qi Z
@ 2021-11-08 19:47             ` Thomas Monjalon
  0 siblings, 0 replies; 29+ messages in thread
From: Thomas Monjalon @ 2021-11-08 19:47 UTC (permalink / raw)
  To: Xu, Ting, Zhang, Qi Z
  Cc: dev, Yang, Qiming, Guo, Junfeng, orika, viacheslavo, Yigit,
	Ferruh, andrew.rybchenko

08/11/2021 03:44, Zhang, Qi Z:
> From: Xu, Ting <ting.xu@intel.com>
> > From: Thomas Monjalon <thomas@monjalon.net>
> > > 05/11/2021 14:18, Xu, Ting:
> > > > From: Thomas Monjalon <thomas@monjalon.net>
> > > > > 04/11/2021 03:22, Ting Xu:
> > > > > > Enable protocol agnostic flow offloading to support raw pattern
> > > > > > input for RSS hash flow rule creation. It is based on Parser
> > > > > > Library
> > > feature.
> > > > > > Current rte_flow raw API is utilized.
> > > > >
> > > > > I remember raw item was especially targetting encapsulation action.
> > > > > Which action do you achieve in ice PMD? Only RSS with raw item?
> > > > >
> > > > > For matching, raw item is quite limited. I think the new flex item
> > > > > is more appropriate for general custom protocol parsing.
> > > > > Did you look into flex item feature?
> > > > >
> > > > Hi, Thomas, we make use of the API for rte_raw to achieve our
> > > > protocol agnostic flow offloading method, including RSS and FDIR.
> > > > Behind it is the new Parser Library feature based on DDP,
> > >
> > > Where is this parser library code?
> > 
> > Parser Library is committed before as ice base code.
> > 
> > >
> > > > rather than the original logic I think.
> > >
> > > > Binary-format pattern spec and mask are passed to Parser Library and
> > > > the corresponding protocol ID and offset will be provided.
> > >
> > > Sorry you didn't reply about the new flex item added in this release.
> > > Do you know it was added?
> > > 	https://git.dpdk.org/dpdk/commit/?id=dc4d860e8a89
> > >
> > 
> > Protocol agnostic flow offloading is based on ice DDP feature, although
> > they all want to make flow creation more flexible, I think it is different
> > with flex item.
> > @Zhang, Qi Z Hi, Qi, are you familiar with flex item?
> > 
> 
> Yes, this is a very Intel DDP specific feature, the goal is to make our driver to support any customized parser (DDP) without change code.
> 
> Below steps are planned:
> 
> 1. raw packet interface, this help on quick POC, as its simply the rte_flow parser, but of cause it's not scale for an DPDK application to support different vendor.
> 2. enable a build-in util to forge a packet from a sequence of rte_flow headers, then the application will be scale, but the missing part is how to describe a customized header, we have similar idea like json, but seems "Flex Item" already help to fix this gap, and we will improve the solution base on it.

Yes please, I hope flex item will fit with your need.



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

end of thread, other threads:[~2021-11-08 19:47 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-08  7:09 [dpdk-dev] [PATCH v1 0/2] enable protocol agnostic flow offloading in RSS Ting Xu
2021-10-08  7:09 ` [dpdk-dev] [PATCH v1 1/2] net/ice: " Ting Xu
2021-10-08  7:09 ` [dpdk-dev] [PATCH v1 2/2] doc: add protocol agnostic flow offloading for RSS hash Ting Xu
2021-11-01 11:02 ` [dpdk-dev] [PATCH v2 0/3] enable protocol agnostic flow offloading in RSS Ting Xu
2021-11-01 11:02   ` [dpdk-dev] [PATCH v2 1/3] net/ice: " Ting Xu
2021-11-01 11:02   ` [dpdk-dev] [PATCH v2 2/3] " Ting Xu
2021-11-01 11:02   ` [dpdk-dev] [PATCH v2 3/3] doc: add protocol agnostic flow offloading for RSS Ting Xu
2021-11-01 11:05 ` [dpdk-dev] [PATCH v2 0/3] enable protocol agnostic flow offloading in RSS Ting Xu
2021-11-01 11:05   ` [dpdk-dev] [PATCH v2 1/3] net/ice/base: support add HW profile for RSS raw flow Ting Xu
2021-11-01 11:05   ` [dpdk-dev] [PATCH v2 2/3] net/ice: enable protocol agnostic flow offloading in RSS Ting Xu
2021-11-01 11:05   ` [dpdk-dev] [PATCH v2 3/3] doc: add protocol agnostic flow offloading for RSS Ting Xu
2021-11-02  1:49 ` [dpdk-dev] [PATCH v3 0/3] enable protocol agnostic flow offloading in RSS Ting Xu
2021-11-02  1:49   ` [dpdk-dev] [PATCH v3 1/3] net/ice/base: support add HW profile for RSS raw flow Ting Xu
2021-11-02  1:49   ` [dpdk-dev] [PATCH v3 2/3] net/ice: enable protocol agnostic flow offloading in RSS Ting Xu
2021-11-03 14:13     ` Ferruh Yigit
2021-11-04  3:29       ` Xu, Ting
2021-11-02  1:49   ` [dpdk-dev] [PATCH v3 3/3] doc: add protocol agnostic flow offloading for RSS Ting Xu
2021-11-03 12:45   ` [dpdk-dev] [PATCH v3 0/3] enable protocol agnostic flow offloading in RSS Zhang, Qi Z
2021-11-03 14:15     ` Ferruh Yigit
2021-11-04  2:22 ` [dpdk-dev] [PATCH v4 0/2] " Ting Xu
2021-11-04  2:22   ` [dpdk-dev] [PATCH v4 1/2] net/ice/base: support add HW profile for RSS raw flow Ting Xu
2021-11-04  2:22   ` [dpdk-dev] [PATCH v4 2/2] net/ice: enable protocol agnostic flow offloading in RSS Ting Xu
2021-11-04  3:31   ` [dpdk-dev] [PATCH v4 0/2] " Zhang, Qi Z
2021-11-05 13:09   ` Thomas Monjalon
2021-11-05 13:18     ` Xu, Ting
2021-11-05 13:23       ` Thomas Monjalon
2021-11-05 14:53         ` Xu, Ting
2021-11-08  2:44           ` Zhang, Qi Z
2021-11-08 19:47             ` Thomas Monjalon

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).