[dpdk-dev] Q on rte hash table

Ravi Kerur rkerur at gmail.com
Thu Aug 12 18:24:19 CEST 2021


Hello,

Using dpdk 19.11 and trying to understand the index returned by
'rte_hash_add_key', API says
...
*   - A positive value that can be used by the caller as an offset into an
 *     array of user data. This value is unique for this key.
 */
int32_t
rte_hash_add_key(const struct rte_hash *h, const void *key);

I create hash with 64 entries and other params as follows
struct rte_hash_parameters user_params = {
                .name = "test_hash",
                .entries = 64,
                .key_len = sizeof(uint32_t),
                .hash_func = rte_hash_crc,
                .hash_func_init_val = 0,
        };

Extra flags has
extra_flag =
                RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY |
                RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD;

user_hash_tbl = rte_hash_create(&user_params);

When I add a key to the table I was expecting returned index to be in the
range '0 - 63'

user_idx = rte_hash_add_key(user_hash_tbl, (void *)&user_id);

However, I am seeing user_idx values 127, 128, ...

Due to MULTI_WRITE_ADD num_of_slots is calculated is as follows when
creating a table.
num_key_slots = params->entries + (RTE_MAX_LCORE - 1) *
                                        (LCORE_CACHE_SIZE - 1) + 1;

with RTE_MAX_LCORE = 255, LCORE_CACHE_SIZE = 64

num_key_slots come to 16067

In my case the user_idx range can be '0 - 16067' . Is this correct?

Thanks,
Ravi


More information about the dev mailing list