The RSS is computed over IPv4 or IPv6 headers using 8 or 32-byte keys respectively, or over IP + TCP/UDP headers using 12 or 36 byte keys. Therefore create explicit non-inline functions for those key lengths. By making these non-inline functions we can compile them using GFNI instructions for later runtime selection, even when the current target instruction set does not include all necessary instructions, e.g. building for a "default" target.
Signed-off-by: Bruce Richardson <[email protected]> --- lib/hash/meson.build | 8 ++++++++ lib/hash/thash_gfni_avx512.c | 35 +++++++++++++++++++++++++++++++++++ lib/hash/thash_private.h | 12 ++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 lib/hash/thash_gfni_avx512.c diff --git a/lib/hash/meson.build b/lib/hash/meson.build index 7ce504ee8b..de21cfac50 100644 --- a/lib/hash/meson.build +++ b/lib/hash/meson.build @@ -29,3 +29,11 @@ sources = files( deps += ['net'] deps += ['ring'] deps += ['rcu'] + +if dpdk_conf.has('RTE_ARCH_X86') and cc_has_avx512 + thash_gfni_cflags = ['-mgfni', '-mavx512vbmi'] + if cc.has_multi_arguments(thash_gfni_cflags) + sources_avx512 += files('thash_gfni_avx512.c') + cflags_avx512 += thash_gfni_cflags + endif +endif diff --git a/lib/hash/thash_gfni_avx512.c b/lib/hash/thash_gfni_avx512.c new file mode 100644 index 0000000000..d62b5acc1f --- /dev/null +++ b/lib/hash/thash_gfni_avx512.c @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2026 Intel Corporation + */ + +#include <rte_thash_x86_gfni.h> + +#include "thash_private.h" + +#ifndef RTE_THASH_GFNI_DEFINED +#error "GFNI and required AVX512 extensions must be enabled to build this file" +#endif + +uint32_t +thash_gfni_avx512_8B(const uint64_t *mtrx, const uint8_t *tuple) +{ + return rte_thash_gfni(mtrx, tuple, 8); +} + +uint32_t +thash_gfni_avx512_12B(const uint64_t *mtrx, const uint8_t *tuple) +{ + return rte_thash_gfni(mtrx, tuple, 12); +} + +uint32_t +thash_gfni_avx512_32B(const uint64_t *mtrx, const uint8_t *tuple) +{ + return rte_thash_gfni(mtrx, tuple, 32); +} + +uint32_t +thash_gfni_avx512_36B(const uint64_t *mtrx, const uint8_t *tuple) +{ + return rte_thash_gfni(mtrx, tuple, 36); +} diff --git a/lib/hash/thash_private.h b/lib/hash/thash_private.h index ed13b605a3..520d156d1d 100644 --- a/lib/hash/thash_private.h +++ b/lib/hash/thash_private.h @@ -13,4 +13,16 @@ uint32_t thash_get_rand_poly(uint32_t poly_degree); +uint32_t +thash_gfni_avx512_8B(const uint64_t *mtrx, const uint8_t *tuple); + +uint32_t +thash_gfni_avx512_12B(const uint64_t *mtrx, const uint8_t *tuple); + +uint32_t +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); + #endif /* THASH_PRIVATE_H */ -- 2.55.0

