[04/16] net/hns3: use hardware config to report hash types

Message ID 20230310093518.5198-5-liudongdong3@huawei.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/hns3: some code refactor for hns3 RSS |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Dongdong Liu March 10, 2023, 9:35 a.m. UTC
From: Huisong Li <lihuisong@huawei.com>

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

Fixes: c37ca66f2b27 ("net/hns3: support RSS")
Cc: stable@dpdk.org

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

Patch

diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c
index a046cc31d1..21266d64b7 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_EN_NONFRAG_IP_S),
+	  HNS3_RSS_TUPLE_IPV4_NONF_M },
 	{ RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_L3_DST_ONLY,
 	  HNS3_R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UPLE,
-	  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 },
 };
 
 /*
@@ -575,6 +635,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
@@ -590,28 +740,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 be0141f602..17473e70e2 100644
--- a/drivers/net/hns3/hns3_rss.h
+++ b/drivers/net/hns3/hns3_rss.h
@@ -110,6 +110,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,