hash: rename a jhash function
Changed name to something more meaningful, and mark rte_jhash2 as deprecated. Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
This commit is contained in:
parent
49361c3f3c
commit
7530c9eea7
@ -228,7 +228,7 @@ hash_create_free(__attribute__((unused)) void *arg)
|
||||
.entries = 16,
|
||||
.bucket_entries = 4,
|
||||
.key_len = 4,
|
||||
.hash_func = (rte_hash_function)rte_jhash2,
|
||||
.hash_func = (rte_hash_function)rte_jhash_32b,
|
||||
.hash_func_init_val = 0,
|
||||
.socket_id = 0,
|
||||
};
|
||||
|
@ -1177,7 +1177,7 @@ test_hash_add_delete_jhash2(void)
|
||||
|
||||
hash_params_ex.name = "hash_test_jhash2";
|
||||
hash_params_ex.key_len = 4;
|
||||
hash_params_ex.hash_func = (rte_hash_function)rte_jhash2;
|
||||
hash_params_ex.hash_func = (rte_hash_function)rte_jhash_32b;
|
||||
|
||||
handle = rte_hash_create(&hash_params_ex);
|
||||
if (handle == NULL) {
|
||||
@ -1216,7 +1216,7 @@ test_hash_add_delete_2_jhash2(void)
|
||||
|
||||
hash_params_ex.name = "hash_test_2_jhash2";
|
||||
hash_params_ex.key_len = 8;
|
||||
hash_params_ex.hash_func = (rte_hash_function)rte_jhash2;
|
||||
hash_params_ex.hash_func = (rte_hash_function)rte_jhash_32b;
|
||||
|
||||
handle = rte_hash_create(&hash_params_ex);
|
||||
if (handle == NULL)
|
||||
|
@ -204,7 +204,7 @@ verify_precalculated_hash_func_tests(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify that rte_jhash and rte_jhash2 return the same
|
||||
* Verify that rte_jhash and rte_jhash_32b return the same
|
||||
*/
|
||||
static int
|
||||
verify_jhash_32bits(void)
|
||||
@ -223,12 +223,12 @@ verify_jhash_32bits(void)
|
||||
hash = rte_jhash(key, hashtest_key_lens[i],
|
||||
hashtest_initvals[j]);
|
||||
/* Divide key length by 4 in rte_jhash for 32 bits */
|
||||
hash32 = rte_jhash2((const uint32_t *)key,
|
||||
hash32 = rte_jhash_32b((const uint32_t *)key,
|
||||
hashtest_key_lens[i] >> 2,
|
||||
hashtest_initvals[j]);
|
||||
if (hash != hash32) {
|
||||
printf("rte_jhash returns different value (0x%x)"
|
||||
"than rte_jhash2 (0x%x)\n",
|
||||
"than rte_jhash_32b (0x%x)\n",
|
||||
hash, hash32);
|
||||
return -1;
|
||||
}
|
||||
|
@ -46,6 +46,8 @@ extern "C" {
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <rte_log.h>
|
||||
#include <rte_byteorder.h>
|
||||
|
||||
/* jhash.h: Jenkins hash support.
|
||||
@ -279,7 +281,7 @@ rte_jhash_2hashes(const void *key, uint32_t length, uint32_t *pc, uint32_t *pb)
|
||||
* IN: second seed OUT: secondary hash value.
|
||||
*/
|
||||
static inline void
|
||||
rte_jhash2_2hashes(const uint32_t *k, uint32_t length, uint32_t *pc, uint32_t *pb)
|
||||
rte_jhash_32b_2hashes(const uint32_t *k, uint32_t length, uint32_t *pc, uint32_t *pb)
|
||||
{
|
||||
__rte_jhash_2hashes((const void *) k, (length << 2), pc, pb, 0);
|
||||
}
|
||||
@ -322,11 +324,22 @@ rte_jhash(const void *key, uint32_t length, uint32_t initval)
|
||||
* Calculated hash value.
|
||||
*/
|
||||
static inline uint32_t
|
||||
rte_jhash_32b(const uint32_t *k, uint32_t length, uint32_t initval)
|
||||
{
|
||||
uint32_t initval2 = 0;
|
||||
|
||||
rte_jhash_32b_2hashes(k, length, &initval, &initval2);
|
||||
|
||||
return initval;
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
__attribute__ ((deprecated))
|
||||
rte_jhash2(const uint32_t *k, uint32_t length, uint32_t initval)
|
||||
{
|
||||
uint32_t initval2 = 0;
|
||||
|
||||
rte_jhash2_2hashes(k, length, &initval, &initval2);
|
||||
rte_jhash_32b_2hashes(k, length, &initval, &initval2);
|
||||
|
||||
return initval;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user