> -----Original Message----- > From: Medvedkin, Vladimir <vladimir.medved...@intel.com> > Sent: Tuesday, April 13, 2021 6:20 AM > To: dev@dpdk.org > Cc: Ananyev, Konstantin <konstantin.anan...@intel.com>; Chilikin, Andrey > <andrey.chili...@intel.com>; Kinsella, Ray <ray.kinse...@intel.com>; Wang, > Yipeng1 <yipeng1.w...@intel.com>; Gobriel, Sameh > <sameh.gobr...@intel.com>; Richardson, Bruce > <bruce.richard...@intel.com> > Subject: [PATCH v4 1/3] hash: add predictable RSS API > > This patch adds predictable RSS API. > It is based on the idea of searching partial Toeplitz hash collisions. > > Signed-off-by: Vladimir Medvedkin <vladimir.medved...@intel.com> > --- > lib/librte_hash/meson.build | 3 +- > lib/librte_hash/rte_thash.c | 109 ++++++++++++++++++++++++ > lib/librte_hash/rte_thash.h | 198 > ++++++++++++++++++++++++++++++++++++++++++++ > lib/librte_hash/version.map | 8 ++ > 4 files changed, 317 insertions(+), 1 deletion(-) create mode 100644 > lib/librte_hash/rte_thash.c > > diff --git a/lib/librte_hash/meson.build b/lib/librte_hash/meson.build index > 242859f..3546014 100644 > --- a/lib/librte_hash/meson.build > +++ b/lib/librte_hash/meson.build > @@ -8,6 +8,7 @@ headers = files('rte_fbk_hash.h', > 'rte_thash.h') > indirect_headers += files('rte_crc_arm64.h') > > -sources = files('rte_cuckoo_hash.c', 'rte_fbk_hash.c') > +sources = files('rte_cuckoo_hash.c', 'rte_fbk_hash.c', 'rte_thash.c') > +deps += ['net'] > deps += ['ring'] > deps += ['rcu'] > diff --git a/lib/librte_hash/rte_thash.c b/lib/librte_hash/rte_thash.c new > file > mode 100644 index 0000000..1325678 > --- /dev/null > +++ b/lib/librte_hash/rte_thash.c > @@ -0,0 +1,109 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2021 Intel Corporation > + */ > + > +#include <rte_thash.h> > +#include <rte_tailq.h> > +#include <rte_random.h> > +#include <rte_memcpy.h> > +#include <rte_errno.h> > +#include <rte_eal.h> > +#include <rte_eal_memconfig.h> > +#include <rte_malloc.h> > + > +#define THASH_NAME_LEN 64 > + > +struct thash_lfsr { > + uint32_t ref_cnt; > + uint32_t poly; > + /**< polynomial associated with the lfsr */ > + uint32_t rev_poly; > + /**< polynomial to generate the sequence in reverse direction */ > + uint32_t state; > + /**< current state of the lfsr */ > + uint32_t rev_state; > + /**< current state of the lfsr for reverse direction */ > + uint32_t deg; /**< polynomial degree*/ > + uint32_t bits_cnt; /**< number of bits generated by lfsr*/ > +}; > + > +struct rte_thash_subtuple_helper { > + char name[THASH_NAME_LEN]; /** < Name of subtuple > configuration */ > + LIST_ENTRY(rte_thash_subtuple_helper) next; > + struct thash_lfsr *lfsr; > + uint32_t offset; /** < Offset of the m-sequence */ > + uint32_t len; /** < Length of the m-sequence */ > + uint32_t tuple_offset; /** < Offset in bits of the subtuple */ > + uint32_t tuple_len; /** < Length in bits of the subtuple > */ > + uint32_t lsb_msk; /** < (1 << reta_sz_log) - 1 */ > + __extension__ uint32_t compl_table[0] __rte_cache_aligned; > + /** < Complementary table */ > +}; > + > +struct rte_thash_ctx { > + char name[THASH_NAME_LEN]; > + LIST_HEAD(, rte_thash_subtuple_helper) head; > + uint32_t key_len; /** < Length of the NIC RSS hash key > */ > + uint32_t reta_sz_log; /** < size of the RSS ReTa in bits */ > + uint32_t subtuples_nb; /** < number of subtuples */ > + uint32_t flags; > + uint8_t hash_key[0]; > +}; > + > +struct rte_thash_ctx * > +rte_thash_init_ctx(const char *name __rte_unused, > + uint32_t key_len __rte_unused, uint32_t reta_sz __rte_unused, > + uint8_t *key __rte_unused, uint32_t flags __rte_unused) { > + return NULL; > +} > + > +struct rte_thash_ctx * > +rte_thash_find_existing(const char *name __rte_unused) { > + return NULL; > +} > + > +void > +rte_thash_free_ctx(struct rte_thash_ctx *ctx __rte_unused) { } > + > +int > +rte_thash_add_helper(struct rte_thash_ctx *ctx __rte_unused, > + const char *name __rte_unused, uint32_t len __rte_unused, > + uint32_t offset __rte_unused) > +{ > + return 0; > +} > + > +struct rte_thash_subtuple_helper * > +rte_thash_get_helper(struct rte_thash_ctx *ctx __rte_unused, > + const char *name __rte_unused) > +{ > + return NULL; > +} > + > +uint32_t > +rte_thash_get_complement(struct rte_thash_subtuple_helper *h > __rte_unused, > + uint32_t hash __rte_unused, uint32_t desired_hash __rte_unused) { > + return 0; > +} > + > +const uint8_t * > +rte_thash_get_key(struct rte_thash_ctx *ctx __rte_unused) { > + return NULL; > +} > + > +int > +rte_thash_adjust_tuple(struct rte_thash_ctx *ctx __rte_unused, > + struct rte_thash_subtuple_helper *h __rte_unused, > + uint8_t *tuple __rte_unused, unsigned int tuple_len __rte_unused, > + uint32_t desired_value __rte_unused, > + unsigned int attempts __rte_unused, > + rte_thash_check_tuple_t fn __rte_unused, void *userdata > __rte_unused) > +{ > + return 0; > +} > diff --git a/lib/librte_hash/rte_thash.h b/lib/librte_hash/rte_thash.h index > 061efa2..f3e05fc 100644 > --- a/lib/librte_hash/rte_thash.h > +++ b/lib/librte_hash/rte_thash.h > @@ -1,5 +1,6 @@ > /* SPDX-License-Identifier: BSD-3-Clause > * Copyright(c) 2015-2019 Vladimir Medvedkin <medvedk...@gmail.com> > + * Copyright(c) 2021 Intel Corporation > */ > > #ifndef _RTE_THASH_H > @@ -222,6 +223,203 @@ rte_softrss_be(uint32_t *input_tuple, uint32_t > input_len, > return ret; > } > > +/** @internal Minimum size of the RSS ReTa */ [Wang, Yipeng] Logarithm of minimum size. > +#define RTE_THASH_RETA_SZ_MIN 2U > +/** @internal Maximum size of the RSS ReTa */ > +#define RTE_THASH_RETA_SZ_MAX 16U > + > +/** > + * LFSR will ignore if generated m-sequence has more than 2^n -1 bits [Wang, Yipeng] Have you mentioned what is n here in the comment? > +*/ <snip> > }; > -- > 2.7.4
[Wang, Yipeng] Acked-by: Yipeng Wang <yipeng1.w...@intel.com>