8ea4143883
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: 5a80bf0ae6
("table: add cuckoo hash")
Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
58 lines
944 B
C
58 lines
944 B
C
/* SPDX-License-Identifier: BSD-3-Clause
|
|
* Copyright(c) 2018 Intel Corporation
|
|
*/
|
|
|
|
#ifndef __INCLUDE_RTE_TABLE_HASH_CUCKOO_H__
|
|
#define __INCLUDE_RTE_TABLE_HASH_CUCKOO_H__
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/**
|
|
* @file
|
|
* RTE Table Hash Cuckoo
|
|
*
|
|
***/
|
|
#include <stdint.h>
|
|
|
|
#include <rte_hash.h>
|
|
|
|
#include "rte_table.h"
|
|
|
|
/** Hash table parameters */
|
|
struct rte_table_hash_cuckoo_params {
|
|
/** Name */
|
|
const char *name;
|
|
|
|
/** Key size (number of bytes) */
|
|
uint32_t key_size;
|
|
|
|
/** Byte offset within packet meta-data where the key is located */
|
|
uint32_t key_offset;
|
|
|
|
/** Key mask */
|
|
uint8_t *key_mask;
|
|
|
|
/** Number of keys */
|
|
uint32_t n_keys;
|
|
|
|
/** Number of buckets */
|
|
uint32_t n_buckets;
|
|
|
|
/** Hash function */
|
|
rte_hash_function f_hash;
|
|
|
|
/** Seed value for the hash function */
|
|
uint32_t seed;
|
|
};
|
|
|
|
/** Cuckoo hash table operations */
|
|
extern struct rte_table_ops rte_table_hash_cuckoo_ops;
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|