DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jie Hai <haijie1@huawei.com>
To: <thomas@monjalon.net>, <ferruh.yigit@amd.com>, <dev@dpdk.org>,
	<andrew.rybchenko@oktetlabs.ru>
Cc: <fengchengwen@huawei.com>, <lihuisong@huawei.com>
Subject: [RESEND 1/2] ethdev: add new API to get RSS hash algorithm by name
Date: Thu, 30 Nov 2023 18:44:14 +0800	[thread overview]
Message-ID: <20231130104415.1064644-2-haijie1@huawei.com> (raw)
In-Reply-To: <20231130104415.1064644-1-haijie1@huawei.com>

This patch supports conversion from names to hash algorithm
(see RTE_ETH_HASH_FUNCTION_XXX).

Signed-off-by: Jie Hai <haijie1@huawei.com>
Reviewed-by: Huisong Li <lihuisong@huawei.com>
---
 doc/guides/rel_notes/release_24_03.rst |  5 +++++
 lib/ethdev/rte_ethdev.c                | 15 +++++++++++++++
 lib/ethdev/rte_ethdev.h                | 20 ++++++++++++++++++++
 lib/ethdev/version.map                 |  3 +++
 4 files changed, 43 insertions(+)

diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst
index e9c9717706a0..bd84875d4f17 100644
--- a/doc/guides/rel_notes/release_24_03.rst
+++ b/doc/guides/rel_notes/release_24_03.rst
@@ -55,6 +55,11 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Improved support of RSS hash algorithm.**
+
+  * Added new function ``rte_eth_find_rss_algo`` to get RSS hash
+    algorithm by its name.
+
 
 Removed Items
 -------------
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index 3858983fcc80..c0398d945502 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -4826,6 +4826,21 @@ rte_eth_dev_rss_algo_name(enum rte_eth_hash_function rss_algo)
 	return name;
 }
 
+int
+rte_eth_find_rss_algo(const char *name, uint32_t *algo)
+{
+	unsigned int i;
+
+	for (i = 0; i < RTE_DIM(rte_eth_dev_rss_algo_names); i++) {
+		if (strcmp(name, rte_eth_dev_rss_algo_names[i].name) == 0) {
+			*algo = rte_eth_dev_rss_algo_names[i].algo;
+			return 0;
+		}
+	}
+
+	return -EINVAL;
+}
+
 int
 rte_eth_dev_udp_tunnel_port_add(uint16_t port_id,
 				struct rte_eth_udp_tunnel *udp_tunnel)
diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index 77331ce6525e..3bde5c4c17a6 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -4667,6 +4667,26 @@ __rte_experimental
 const char *
 rte_eth_dev_rss_algo_name(enum rte_eth_hash_function rss_algo);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice.
+ *
+ *  Get RSS hash algorithm by its name.
+ *
+ * @param name
+ *   RSS hash algorithm.
+ *
+ * @param algo
+ *   return the RSS hash algorithm found, @see rte_eth_hash_function.
+ *
+ * @return
+ *   - (0) if successful.
+ *   - (-EINVAL) if not found.
+ */
+__rte_experimental
+int
+rte_eth_find_rss_algo(const char *name, uint32_t *algo);
+
 /**
  * Add UDP tunneling port for a type of tunnel.
  *
diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map
index 5c4917c020dc..a050baab0fe7 100644
--- a/lib/ethdev/version.map
+++ b/lib/ethdev/version.map
@@ -316,6 +316,9 @@ EXPERIMENTAL {
 	rte_eth_recycle_rx_queue_info_get;
 	rte_flow_group_set_miss_actions;
 	rte_flow_calc_table_hash;
+
+	# added in 24.03
+	rte_eth_find_rss_algo;
 };
 
 INTERNAL {
-- 
2.30.0


  reply	other threads:[~2023-11-30 10:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-22  9:48 [PATCH 0/2] app/testpmd: support set RSS hash algorithm Jie Hai
2023-11-22  9:48 ` [PATCH 1/2] ethdev: add new API to get RSS hash algorithm by name Jie Hai
2023-11-22  9:48 ` [PATCH 2/2] app/testpmd: support set RSS hash algorithm Jie Hai
2023-11-22 10:46 ` [PATCH 0/2] " Ferruh Yigit
2023-11-23  6:32   ` Jie Hai
2023-11-30  9:02 ` Ferruh Yigit
2023-11-30 10:01   ` Jie Hai
2023-11-30 10:44 ` [RESEND " Jie Hai
2023-11-30 10:44   ` Jie Hai [this message]
2023-11-30 11:23     ` [RESEND 1/2] ethdev: add new API to get RSS hash algorithm by name Ferruh Yigit
2023-11-30 10:44   ` [RESEND 2/2] app/testpmd: support set RSS hash algorithm Jie Hai
2023-11-30 11:37     ` Ferruh Yigit
2023-11-30 11:38     ` Ferruh Yigit
2023-12-01  8:52 ` [PATCH v2 0/2] " Jie Hai
2023-12-01  8:52   ` [PATCH v2 1/2] ethdev: add new API to get RSS hash algorithm by name Jie Hai
2023-12-01  8:52   ` [PATCH v2 2/2] app/testpmd: support set RSS hash algorithm Jie Hai
2023-12-01 11:26     ` Ferruh Yigit
2023-12-04 13:57   ` [PATCH v2 0/2] " Ferruh Yigit

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=20231130104415.1064644-2-haijie1@huawei.com \
    --to=haijie1@huawei.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=fengchengwen@huawei.com \
    --cc=ferruh.yigit@amd.com \
    --cc=lihuisong@huawei.com \
    --cc=thomas@monjalon.net \
    /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).