[RFC,1/4] thash: add RSS hash key generation API

Message ID 20240906165318.1322550-2-vladimir.medvedkin@intel.com (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers
Series RSS hash key generation |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Medvedkin, Vladimir Sept. 6, 2024, 4:53 p.m. UTC
Currently the only way to have non static Toeplitz hash key is to
generate it randomly. Such a key may not guarantee good packets
distribution, especially if there are small number of flows.

This patch adds stub implementation of the Toeplitz hash key generation
function, which may improve Toeplitz hash key with respect to hash values
distribution.

Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
---
 lib/hash/rte_thash.c | 13 +++++++++++++
 lib/hash/rte_thash.h | 24 ++++++++++++++++++++++++
 lib/hash/version.map |  4 +++-
 3 files changed, 40 insertions(+), 1 deletion(-)
  

Comments

Stephen Hemminger Sept. 9, 2024, 12:09 a.m. UTC | #1
On Fri,  6 Sep 2024 16:53:15 +0000
Vladimir Medvedkin <vladimir.medvedkin@intel.com> wrote:

> diff --git a/lib/hash/version.map b/lib/hash/version.map
> index 11a5394a45..7d31fc1ba5 100644
> --- a/lib/hash/version.map
> +++ b/lib/hash/version.map
> @@ -52,6 +52,8 @@ EXPERIMENTAL {
>  
>  	# added in 24.07
>  	rte_hash_rcu_qsbr_dq_reclaim;
> +	# added in 24.11
> +	rte_thash_gen_key;
>  };
>  
>  INTERNAL {
> @@ -59,4 +61,4 @@ INTERNAL {
>  
>  	rte_thash_gfni_stub;
>  	rte_thash_gfni_bulk_stub;
> -};
> +};
> \ No newline at end of file

Fix your editor settings to always end file with newline
  

Patch

diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c
index 10721effe6..df9b4960ce 100644
--- a/lib/hash/rte_thash.c
+++ b/lib/hash/rte_thash.c
@@ -832,3 +832,16 @@  rte_thash_adjust_tuple(struct rte_thash_ctx *ctx,
 
 	return ret;
 }
+
+int
+rte_thash_gen_key(uint8_t *key, int key_len, int reta_sz_log,
+	int entropy_start, int entropy_sz)
+{
+	RTE_SET_USED(key);
+	RTE_SET_USED(key_len);
+	RTE_SET_USED(reta_sz_log);
+	RTE_SET_USED(entropy_start);
+	RTE_SET_USED(entropy_sz);
+
+	return 0;
+}
diff --git a/lib/hash/rte_thash.h b/lib/hash/rte_thash.h
index 30b657e67a..560fc1de73 100644
--- a/lib/hash/rte_thash.h
+++ b/lib/hash/rte_thash.h
@@ -447,6 +447,30 @@  rte_thash_adjust_tuple(struct rte_thash_ctx *ctx,
 	uint32_t desired_value, unsigned int attempts,
 	rte_thash_check_tuple_t fn, void *userdata);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Modify RSS hash key such that subtuple bits corresponding to `entropy_sz`
+ * bits starting from `entropy_start` will have the most even distribution with
+ * this key with a given ReTa size.
+ *
+ * @param key pointer to the RSS hash key
+ * @param key_len length of the key
+ * @param reta_sz_log log2 of the size of RSS redirection table. i.e. number of
+ *   bits of the rss hash value used to identify RSS ReTa entry
+ * @param entropy_start bit offset from the beginning of the tuple where user
+ *   expects best distribution of the subtuple values.
+ * @param entropy_sz size in bits of the part of subtuple
+ *
+ * @return
+ *  0 on success negative otherwise
+ */
+__rte_experimental
+int
+rte_thash_gen_key(uint8_t *key, int key_len, int reta_sz_log,
+	int entropy_start, int entropy_sz);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/hash/version.map b/lib/hash/version.map
index 11a5394a45..7d31fc1ba5 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -52,6 +52,8 @@  EXPERIMENTAL {
 
 	# added in 24.07
 	rte_hash_rcu_qsbr_dq_reclaim;
+	# added in 24.11
+	rte_thash_gen_key;
 };
 
 INTERNAL {
@@ -59,4 +61,4 @@  INTERNAL {
 
 	rte_thash_gfni_stub;
 	rte_thash_gfni_bulk_stub;
-};
+};
\ No newline at end of file