patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Huisong Li <lihuisong@huawei.com>
To: <stable@dpdk.org>, <ktraynor@redhat.com>
Cc: <liudongdong3@huawei.com>, <huangdaode@huawei.com>,
	<liuyonglong@huawei.com>, <lihuisong@huawei.com>
Subject: [PATCH 21.11 07/17] net/hns3: use hardware config to report hash types
Date: Tue, 21 Mar 2023 17:22:56 +0800	[thread overview]
Message-ID: <20230321092306.16918-8-lihuisong@huawei.com> (raw)
In-Reply-To: <20230321092306.16918-1-lihuisong@huawei.com>

[ upstream commit 406b25c7ffd2d84b1e09665872f69755c75e7d89 ]

Use the configuration in hardware to report hash types instead
of data maintained in software.

Fixes: c37ca66f2b27 ("net/hns3: support RSS")

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
 drivers/net/hns3/hns3_rss.c | 260 ++++++++++++++++++++++++++++--------
 drivers/net/hns3/hns3_rss.h |   1 +
 2 files changed, 208 insertions(+), 53 deletions(-)

diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c
index 7c0ca04400..f535161e77 100644
--- a/drivers/net/hns3/hns3_rss.c
+++ b/drivers/net/hns3/hns3_rss.c
@@ -70,6 +70,17 @@ enum hns3_tuple_field {
 	HNS3_RSS_FIELD_IPV6_FRAG_IP_S
 };
 
+#define HNS3_RSS_TUPLE_IPV4_TCP_M	GENMASK(3, 0)
+#define HNS3_RSS_TUPLE_IPV4_UDP_M	GENMASK(11, 8)
+#define HNS3_RSS_TUPLE_IPV4_SCTP_M	GENMASK(20, 16)
+#define HNS3_RSS_TUPLE_IPV4_NONF_M	GENMASK(25, 24)
+#define HNS3_RSS_TUPLE_IPV4_FLAG_M	GENMASK(27, 26)
+#define HNS3_RSS_TUPLE_IPV6_TCP_M	GENMASK(35, 32)
+#define HNS3_RSS_TUPLE_IPV6_UDP_M	GENMASK(43, 40)
+#define HNS3_RSS_TUPLE_IPV6_SCTP_M	GENMASK(52, 48)
+#define HNS3_RSS_TUPLE_IPV6_NONF_M	GENMASK(57, 56)
+#define HNS3_RSS_TUPLE_IPV6_FLAG_M	GENMASK(59, 58)
+
 enum hns3_rss_tuple_type {
 	HNS3_RSS_IP_TUPLE,
 	HNS3_RSS_IP_L4_TUPLE,
@@ -79,200 +90,249 @@ static const struct {
 	uint64_t rss_types;
 	uint16_t tuple_type;
 	uint64_t rss_field;
+	uint64_t tuple_mask;
 } hns3_set_tuple_table[] = {
 	/* IPV4-FRAG */
 	{ RTE_ETH_RSS_FRAG_IPV4 | RTE_ETH_RSS_L3_SRC_ONLY,
 	  HNS3_RSS_IP_TUPLE,
-	  BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_S) },
+	  BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_S),
+	  HNS3_RSS_TUPLE_IPV4_FLAG_M },
 	{ RTE_ETH_RSS_FRAG_IPV4 | RTE_ETH_RSS_L3_DST_ONLY,
 	  HNS3_RSS_IP_TUPLE,
-	  BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_D) },
+	  BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_D),
+	  HNS3_RSS_TUPLE_IPV4_FLAG_M },
 	{ RTE_ETH_RSS_FRAG_IPV4,
 	  HNS3_RSS_IP_TUPLE,
 	  BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_S) |
-	  BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_D) },
+	  BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_D),
+	  HNS3_RSS_TUPLE_IPV4_FLAG_M },
 
 	/* IPV4 */
 	{ RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_L3_SRC_ONLY,
 	  HNS3_RSS_IP_TUPLE,
-	  BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) },
+	  BIT_ULL(HNS3_RSS_FIELD_IPV4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S3_RSS_TUPLE_IPV6_SCTP_M },
 	{ RTE_ETH_RSS_NONFRAG_IPV6_SCTP | RTE_ETH_RSS_L4_DST_ONLY,
 	  HNS3_RSS_IP_L4_TUPLE,
-	  BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_D) },
+	  BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_D),
+	  HNS3_RSS_TUPLE_IPV6_SCTP_M },
 	{ RTE_ETH_RSS_NONFRAG_IPV6_SCTP,
 	  HNS3_RSS_IP_L4_TUPLE,
 	  BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_S) |
 	  BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_D) |
 	  BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_D) |
 	  BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_S) |
-	  BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_VER) },
+	  BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_VER),
+	  HNS3_RSS_TUPLE_IPV6_SCTP_M },
 };
 
 /*
@@ -623,6 +683,96 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
 	return ret;
 }
 
+int
+hns3_get_rss_tuple_field(struct hns3_hw *hw, uint64_t *tuple_fields)
+{
+	struct hns3_rss_input_tuple_cmd *req;
+	struct hns3_cmd_desc desc;
+	int ret;
+
+	hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RSS_INPUT_TUPLE, true);
+	req = (struct hns3_rss_input_tuple_cmd *)desc.data;
+	ret = hns3_cmd_send(hw, &desc, 1);
+	if (ret != 0) {
+		hns3_err(hw, "fail to get RSS hash tuple fields from firmware, ret = %d",
+			 ret);
+		return ret;
+	}
+
+	*tuple_fields = rte_le_to_cpu_64(req->tuple_field);
+
+	return 0;
+}
+
+static uint64_t
+hns3_rss_tuple_fields_to_rss_hf(struct hns3_hw *hw, uint64_t tuple_fields)
+{
+	uint64_t ipv6_sctp_l4_mask =
+				BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_D) |
+				BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_S);
+	uint64_t rss_hf = 0;
+	uint64_t tuple_mask;
+	uint32_t i;
+
+	for (i = 0; i < RTE_DIM(hns3_set_tuple_table); i++) {
+		tuple_mask = hns3_set_tuple_table[i].tuple_mask;
+		/*
+		 * The RSS hash of the packet type is disabled if its tuples is
+		 * zero.
+		 */
+		if ((tuple_fields & tuple_mask) == 0)
+			continue;
+
+		/*
+		 * Some hardware don't support to use src/dst port fields to
+		 * hash for IPV6-SCTP packet.
+		 */
+		if ((hns3_set_tuple_table[i].rss_types &
+					RTE_ETH_RSS_NONFRAG_IPV6_SCTP) &&
+		    !hw->rss_info.ipv6_sctp_offload_supported)
+			tuple_mask &= ~ipv6_sctp_l4_mask;
+
+		/*
+		 * The framework (ethdev ops) or driver (rte flow API) ensure
+		 * that both L3_SRC/DST_ONLY and L4_SRC/DST_ONLY cannot be set
+		 * to driver at the same time. But if user doesn't specify
+		 * anything L3/L4_SRC/DST_ONLY, driver enables all tuple fields.
+		 * In this case, driver should not report L3/L4_SRC/DST_ONLY.
+		 */
+		if ((tuple_fields & tuple_mask) == tuple_mask) {
+			/* Skip the item enabled part tuples. */
+			if ((tuple_fields & hns3_set_tuple_table[i].rss_field) !=
+					tuple_mask)
+				continue;
+
+			rss_hf |= hns3_set_tuple_table[i].rss_types;
+			continue;
+		}
+
+		/* Match the item enabled part tuples.*/
+		if ((tuple_fields & hns3_set_tuple_table[i].rss_field) ==
+					hns3_set_tuple_table[i].rss_field)
+			rss_hf |= hns3_set_tuple_table[i].rss_types;
+	}
+
+	return rss_hf;
+}
+
+static int
+hns3_rss_hash_get_rss_hf(struct hns3_hw *hw, uint64_t *rss_hf)
+{
+	uint64_t tuple_fields;
+	int ret;
+
+	ret = hns3_get_rss_tuple_field(hw, &tuple_fields);
+	if (ret != 0)
+		return ret;
+
+	*rss_hf = hns3_rss_tuple_fields_to_rss_hf(hw, tuple_fields);
+
+	return 0;
+}
+
 /*
  * Get rss key and rss_hf types set of RSS hash configuration.
  * @param dev
@@ -638,28 +788,32 @@ hns3_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
 {
 	struct hns3_adapter *hns = dev->data->dev_private;
 	struct hns3_hw *hw = &hns->hw;
-	struct hns3_rss_conf *rss_cfg = &hw->rss_info;
 	uint8_t hash_algo;
 	int ret;
 
 	rte_spinlock_lock(&hw->lock);
-	rss_conf->rss_hf = rss_cfg->conf.types;
+	ret = hns3_rss_hash_get_rss_hf(hw, &rss_conf->rss_hf);
+	if (ret != 0) {
+		hns3_err(hw, "obtain hash tuples failed, ret = %d", ret);
+		goto out;
+	}
 
 	/* Get the RSS Key required by the user */
 	if (rss_conf->rss_key && rss_conf->rss_key_len >= hw->rss_key_size) {
 		ret = hns3_rss_get_algo_key(hw, &hash_algo, rss_conf->rss_key,
 					    hw->rss_key_size);
 		if (ret != 0) {
-			rte_spinlock_unlock(&hw->lock);
 			hns3_err(hw, "obtain hash algo and key failed, ret = %d",
 				 ret);
-			return ret;
+			goto out;
 		}
 		rss_conf->rss_key_len = hw->rss_key_size;
 	}
+
+out:
 	rte_spinlock_unlock(&hw->lock);
 
-	return 0;
+	return ret;
 }
 
 /*
diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h
index 598381df84..cc53f363ae 100644
--- a/drivers/net/hns3/hns3_rss.h
+++ b/drivers/net/hns3/hns3_rss.h
@@ -112,6 +112,7 @@ int hns3_rss_reset_indir_table(struct hns3_hw *hw);
 int hns3_config_rss(struct hns3_adapter *hns);
 void hns3_rss_uninit(struct hns3_adapter *hns);
 int hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf);
+int hns3_get_rss_tuple_field(struct hns3_hw *hw, uint64_t *tuple_fields);
 int hns3_rss_set_algo_key(struct hns3_hw *hw, uint8_t hash_algo,
 			  const uint8_t *key, uint8_t key_len);
 int hns3_rss_get_algo_key(struct hns3_hw *hw,  uint8_t *hash_algo,
-- 
2.22.0


  parent reply	other threads:[~2023-03-21  9:24 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-21  9:22 [PATCH 21.11 00/17] backport some patches for hns3 Huisong Li
2023-03-21  9:22 ` [PATCH 21.11 01/17] net/hns3: separate Tx prepare from getting Tx function Huisong Li
2023-03-21  9:22 ` [PATCH 21.11 02/17] net/hns3: make getting Tx function static Huisong Li
2023-03-21  9:22 ` [PATCH 21.11 03/17] net/hns3: fix RSS key size compatibility Huisong Li
2023-03-21  9:22 ` [PATCH 21.11 04/17] net/hns3: fix burst mode query with dummy function Huisong Li
2023-03-21  9:22 ` [PATCH 21.11 05/17] net/hns3: extract common functions to set Rx/Tx Huisong Li
2023-03-21  9:22 ` [PATCH 21.11 06/17] net/hns3: use hardware config to report hash key Huisong Li
2023-03-21  9:22 ` Huisong Li [this message]
2023-03-21  9:22 ` [PATCH 21.11 08/17] net/hns3: separate setting hash algorithm Huisong Li
2023-03-21  9:22 ` [PATCH 21.11 09/17] net/hns3: separate setting hash key Huisong Li
2023-03-21  9:22 ` [PATCH 21.11 10/17] net/hns3: separate setting RSS types Huisong Li
2023-03-21  9:23 ` [PATCH 21.11 11/17] net/hns3: use new RSS rule to configure hardware Huisong Li
2023-03-21  9:23 ` [PATCH 21.11 12/17] net/hns3: save hash algo to RSS filter list node Huisong Li
2023-03-21  9:23 ` [PATCH 21.11 13/17] net/hns3: remove unused structures Huisong Li
2023-03-21  9:23 ` [PATCH 21.11 14/17] net/hns3: allow adding queue buffer size hash rule Huisong Li
2023-03-21  9:23 ` [PATCH 21.11 15/17] net/hns3: separate flow RSS config from RSS conf Huisong Li
2023-03-21  9:23 ` [PATCH 21.11 16/17] net/hns3: reimplement hash flow function Huisong Li
2023-03-21  9:23 ` [PATCH 21.11 17/17] net/hns3: add verification of RSS types Huisong Li
2023-03-21 16:21 ` [PATCH 21.11 00/17] backport some patches for hns3 Kevin Traynor

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=20230321092306.16918-8-lihuisong@huawei.com \
    --to=lihuisong@huawei.com \
    --cc=huangdaode@huawei.com \
    --cc=ktraynor@redhat.com \
    --cc=liudongdong3@huawei.com \
    --cc=liuyonglong@huawei.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

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

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).