summaryrefslogtreecommitdiff
path: root/lib/librte_table/rte_table_hash_cuckoo.c
diff options
context:
space:
mode:
authorJasvinder Singh <jasvinder.singh@intel.com>2018-05-08 15:17:18 +0100
committerCristian Dumitrescu <cristian.dumitrescu@intel.com>2018-05-08 16:19:58 +0200
commit8ea41438832a360aed2b7ba49fb75e310a2ff1dc (patch)
tree481e8e2e8eb9b65725fc722908d75dc1cec047e2 /lib/librte_table/rte_table_hash_cuckoo.c
parent7959831b4d1b52f6525acb63ce0d94eeeb396855 (diff)
downloaddpdk-8ea41438832a360aed2b7ba49fb75e310a2ff1dc.zip
dpdk-8ea41438832a360aed2b7ba49fb75e310a2ff1dc.tar.gz
dpdk-8ea41438832a360aed2b7ba49fb75e310a2ff1dc.tar.xz
table: add dedicated params struct for cuckoo hash
Add dedicated parameter structure for cuckoo hash. The cuckoo hash from librte_hash uses slightly different prototype for the hash function (no key_mask parameter, 32-bit seed and return value) that require either of the following approaches: 1/ Function pointer conversion: gcc 8.1 warning [1], misleading [2] 2/ Union within the parameter structure: pollutes a very generic API parameter structure with some implementation dependent detail (i.e. key mask not available for one of the available implementations) 3/ Using opaque pointer for hash function: same issue from 2/ 4/ Different parameter structure: avoid issue from 2/; hopefully, it won't be long before librte_hash implements the key mask feature, so the generic API structure could be used. [1] http://www.dpdk.org/ml/archives/dev/2018-April/094950.html [2] http://www.dpdk.org/ml/archives/dev/2018-April/096250.html Fixes: 5a80bf0ae613 ("table: add cuckoo hash") Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Diffstat (limited to 'lib/librte_table/rte_table_hash_cuckoo.c')
-rw-r--r--lib/librte_table/rte_table_hash_cuckoo.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/librte_table/rte_table_hash_cuckoo.c b/lib/librte_table/rte_table_hash_cuckoo.c
index dcb4fe9..f024303 100644
--- a/lib/librte_table/rte_table_hash_cuckoo.c
+++ b/lib/librte_table/rte_table_hash_cuckoo.c
@@ -10,8 +10,7 @@
#include <rte_malloc.h>
#include <rte_log.h>
-#include <rte_hash.h>
-#include "rte_table_hash.h"
+#include "rte_table_hash_cuckoo.h"
#ifdef RTE_TABLE_STATS_COLLECT
@@ -35,7 +34,7 @@ struct rte_table_hash {
uint32_t key_size;
uint32_t entry_size;
uint32_t n_keys;
- rte_table_hash_op_hash f_hash;
+ rte_hash_function f_hash;
uint32_t seed;
uint32_t key_offset;
@@ -47,7 +46,7 @@ struct rte_table_hash {
};
static int
-check_params_create_hash_cuckoo(struct rte_table_hash_params *params)
+check_params_create_hash_cuckoo(struct rte_table_hash_cuckoo_params *params)
{
if (params == NULL) {
RTE_LOG(ERR, TABLE, "NULL Input Parameters.\n");
@@ -82,7 +81,7 @@ rte_table_hash_cuckoo_create(void *params,
int socket_id,
uint32_t entry_size)
{
- struct rte_table_hash_params *p = params;
+ struct rte_table_hash_cuckoo_params *p = params;
struct rte_hash *h_table;
struct rte_table_hash *t;
uint32_t total_size;
@@ -107,7 +106,7 @@ rte_table_hash_cuckoo_create(void *params,
struct rte_hash_parameters hash_cuckoo_params = {
.entries = p->n_keys,
.key_len = p->key_size,
- .hash_func = (rte_hash_function)(p->f_hash),
+ .hash_func = p->f_hash,
.hash_func_init_val = p->seed,
.socket_id = socket_id,
.name = p->name