To match the GFNI RSS hash computation functions, add scalar
equivalents.

Signed-off-by: Bruce Richardson <[email protected]>
---
 lib/hash/meson.build     |  1 +
 lib/hash/thash_private.h | 12 ++++++++++
 lib/hash/thash_rss.c     | 49 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 62 insertions(+)
 create mode 100644 lib/hash/thash_rss.c

diff --git a/lib/hash/meson.build b/lib/hash/meson.build
index de21cfac50..abee43fa2a 100644
--- a/lib/hash/meson.build
+++ b/lib/hash/meson.build
@@ -24,6 +24,7 @@ sources = files(
         'rte_thash.c',
         'rte_thash_gfni.c',
         'rte_thash_gf2_poly_math.c',
+        'thash_rss.c',
 )
 
 deps += ['net']
diff --git a/lib/hash/thash_private.h b/lib/hash/thash_private.h
index 520d156d1d..f9187536aa 100644
--- a/lib/hash/thash_private.h
+++ b/lib/hash/thash_private.h
@@ -25,4 +25,16 @@ thash_gfni_avx512_32B(const uint64_t *mtrx, const uint8_t 
*tuple);
 uint32_t
 thash_gfni_avx512_36B(const uint64_t *mtrx, const uint8_t *tuple);
 
+uint32_t
+thash_scalar_8B(const uint8_t *key, const uint8_t *tuple);
+
+uint32_t
+thash_scalar_12B(const uint8_t *key, const uint8_t *tuple);
+
+uint32_t
+thash_scalar_32B(const uint8_t *key, const uint8_t *tuple);
+
+uint32_t
+thash_scalar_36B(const uint8_t *key, const uint8_t *tuple);
+
 #endif /* THASH_PRIVATE_H */
diff --git a/lib/hash/thash_rss.c b/lib/hash/thash_rss.c
new file mode 100644
index 0000000000..65c109e1b0
--- /dev/null
+++ b/lib/hash/thash_rss.c
@@ -0,0 +1,49 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2026 Intel Corporation
+ */
+
+#include <string.h>
+
+#include <rte_byteorder.h>
+#include <rte_thash.h>
+
+#include "thash_private.h"
+
+static inline uint32_t
+thash_scalar(const uint8_t *key, const uint8_t *tuple, uint32_t len)
+{
+       uint32_t input[RTE_THASH_V6_L4_LEN];
+
+       for (uint32_t i = 0; i < len / sizeof(input[0]); i++) {
+               uint32_t word;
+
+               memcpy(&word, &tuple[i * sizeof(word)], sizeof(word));
+               input[i] = rte_be_to_cpu_32(word);
+       }
+
+       return rte_softrss_be(input, len / sizeof(input[0]), key);
+}
+
+uint32_t
+thash_scalar_8B(const uint8_t *key, const uint8_t *tuple)
+{
+       return thash_scalar(key, tuple, 8);
+}
+
+uint32_t
+thash_scalar_12B(const uint8_t *key, const uint8_t *tuple)
+{
+       return thash_scalar(key, tuple, 12);
+}
+
+uint32_t
+thash_scalar_32B(const uint8_t *key, const uint8_t *tuple)
+{
+       return thash_scalar(key, tuple, 32);
+}
+
+uint32_t
+thash_scalar_36B(const uint8_t *key, const uint8_t *tuple)
+{
+       return thash_scalar(key, tuple, 36);
+}
-- 
2.55.0

Reply via email to