DPDK patches and discussions
 help / color / mirror / Atom feed
From: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
To: dev@dpdk.org
Cc: stephen@networkplumber.org, Yipeng Wang <yipeng1.wang@intel.com>,
	Sameh Gobriel <sameh.gobriel@intel.com>,
	Bruce Richardson <bruce.richardson@intel.com>
Subject: [PATCH v4 3/4] hash: implement RSS hash key generation API
Date: Thu, 24 Oct 2024 18:46:55 +0000	[thread overview]
Message-ID: <20241024184657.901099-4-vladimir.medvedkin@intel.com> (raw)
In-Reply-To: <20241024184657.901099-1-vladimir.medvedkin@intel.com>

This patch implements Toeplitz hash key generation function using the new
polynomial generation function.

Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
---
 doc/guides/rel_notes/release_24_11.rst |  3 +++
 lib/hash/rte_thash.c                   | 23 ++++++++++++++++++-----
 2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/doc/guides/rel_notes/release_24_11.rst b/doc/guides/rel_notes/release_24_11.rst
index fa4822d928..9d00a2e1c2 100644
--- a/doc/guides/rel_notes/release_24_11.rst
+++ b/doc/guides/rel_notes/release_24_11.rst
@@ -247,6 +247,9 @@ New Features
   Added ability for node to advertise and update multiple xstat counters,
   that can be retrieved using ``rte_graph_cluster_stats_get``.
 
+* **Added RSS hash key generating API.**
+  A new function ``rte_thash_gen_key`` is provided to modify the RSS hash key
+  to achieve better traffic distribution with RSS.
 
 Removed Items
 -------------
diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c
index da35aec860..336c228e64 100644
--- a/lib/hash/rte_thash.c
+++ b/lib/hash/rte_thash.c
@@ -827,11 +827,24 @@ int
 rte_thash_gen_key(uint8_t *key, size_t key_len, size_t reta_sz_log,
 	uint32_t entropy_start, size_t 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);
+	size_t i, end, start;
+
+	/* define lfsr sequence range*/
+	end = entropy_start + entropy_sz + TOEPLITZ_HASH_LEN - 1;
+	start = end - (entropy_sz + reta_sz_log - 1);
+
+	if ((key == NULL) || (key_len * CHAR_BIT < entropy_start + entropy_sz) ||
+			(entropy_sz < reta_sz_log) || (reta_sz_log > TOEPLITZ_HASH_LEN))
+		return -EINVAL;
+
+	struct thash_lfsr *lfsr = alloc_lfsr(reta_sz_log);
+	if (lfsr == NULL)
+		return -ENOMEM;
+
+	for (i = start; i < end; i++)
+		set_bit(key, get_bit_lfsr(lfsr), i);
+
+	free_lfsr(lfsr);
 
 	return 0;
 }
-- 
2.43.0


  parent reply	other threads:[~2024-10-24 18:47 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-10 12:33 [PATCH v2 0/4] RSS hash key generation Vladimir Medvedkin
2024-10-10 12:33 ` [PATCH v2 1/4] thash: add RSS hash key generation API Vladimir Medvedkin
2024-10-10 15:04   ` Stephen Hemminger
2024-10-10 12:33 ` [PATCH v2 2/4] hash: add dynamic polynomial calculation Vladimir Medvedkin
2024-10-10 12:33 ` [PATCH v2 3/4] hash: implement RSS hash key generation API Vladimir Medvedkin
2024-10-10 12:33 ` [PATCH v2 4/4] test/thash: add tests for RSS " Vladimir Medvedkin
2024-10-11 18:16 ` [PATCH v3 0/4] RSS hash key generation Vladimir Medvedkin
2024-10-11 18:16   ` [PATCH v3 1/4] thash: add RSS hash key generation API Vladimir Medvedkin
2024-10-11 18:17   ` [PATCH v3 2/4] hash: add dynamic polynomial calculation Vladimir Medvedkin
2024-10-15 22:29     ` Stephen Hemminger
2024-10-16 16:28       ` Medvedkin, Vladimir
2024-10-17  3:23         ` Stephen Hemminger
2024-10-18 13:42           ` Medvedkin, Vladimir
2024-10-11 18:17   ` [PATCH v3 3/4] hash: implement RSS hash key generation API Vladimir Medvedkin
2024-10-11 18:17   ` [PATCH v3 4/4] test/thash: add tests for RSS " Vladimir Medvedkin
2024-10-24 18:46   ` [PATCH v4 0/4] RSS hash key generation Vladimir Medvedkin
2024-10-24 18:46     ` [PATCH v4 1/4] thash: add RSS hash key generation API Vladimir Medvedkin
2024-10-24 19:05       ` Stephen Hemminger
2024-10-24 18:46     ` [PATCH v4 2/4] hash: add dynamic polynomial calculation Vladimir Medvedkin
2024-10-24 19:06       ` Stephen Hemminger
2024-10-24 18:46     ` Vladimir Medvedkin [this message]
2024-10-24 19:06       ` [PATCH v4 3/4] hash: implement RSS hash key generation API Stephen Hemminger
2024-10-24 18:46     ` [PATCH v4 4/4] test/thash: add tests for RSS " Vladimir Medvedkin
2024-10-24 19:06       ` Stephen Hemminger

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=20241024184657.901099-4-vladimir.medvedkin@intel.com \
    --to=vladimir.medvedkin@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=sameh.gobriel@intel.com \
    --cc=stephen@networkplumber.org \
    --cc=yipeng1.wang@intel.com \
    /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).