[PATCH v4 08/10] hash: use accelerated CRC on riscv
Daniel Gregory
code at danielg0.com
Sun Feb 22 16:30:02 CET 2026
From: Daniel Gregory <daniel.gregory at bytedance.com>
When the RISC-V Zbc (carryless multiplication) extension is present, an
implementation of CRC hashing using hardware instructions is available.
Use it rather than jhash.
Signed-off-by: Daniel Gregory <daniel.gregory at bytedance.com>
Signed-off-by: Daniel Gregory <code at danielg0.com>
---
lib/hash/rte_cuckoo_hash.c | 3 +++
lib/hash/rte_fbk_hash.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index da12825c6e..ce45760b3e 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -460,6 +460,9 @@ rte_hash_create(const struct rte_hash_parameters *params)
#elif defined(RTE_ARCH_ARM64)
if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
default_hash_func = (rte_hash_function)rte_hash_crc;
+#elif defined(RTE_ARCH_RISCV)
+ if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_RISCV_EXT_ZBC))
+ default_hash_func = (rte_hash_function)rte_hash_crc;
#endif
/* Setup hash context */
strlcpy(h->name, params->name, sizeof(h->name));
diff --git a/lib/hash/rte_fbk_hash.c b/lib/hash/rte_fbk_hash.c
index 45d4a13427..4266bb5198 100644
--- a/lib/hash/rte_fbk_hash.c
+++ b/lib/hash/rte_fbk_hash.c
@@ -148,6 +148,9 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
#elif defined(RTE_ARCH_ARM64)
if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
default_hash_func = (rte_fbk_hash_fn)rte_hash_crc_4byte;
+#elif defined(RTE_ARCH_RISCV)
+ if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_RISCV_EXT_ZBC))
+ default_hash_func = (rte_fbk_hash_fn)rte_hash_crc_4byte;
#endif
/* Set up hash table context. */
--
2.53.0
More information about the dev
mailing list