[dpdk-dev] [PATCH v1 3/3] hash: add new API function to query the key count
De Lara Guarch, Pablo
pablo.de.lara.guarch at intel.com
Tue Jun 26 18:11:22 CEST 2018
> -----Original Message-----
> From: Wang, Yipeng1
> Sent: Friday, June 8, 2018 11:51 AM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch at intel.com>
> Cc: dev at dpdk.org; Wang, Yipeng1 <yipeng1.wang at intel.com>; Mcnamara,
> John <john.mcnamara at intel.com>; Richardson, Bruce
> <bruce.richardson at intel.com>; honnappa.nagarahalli at arm.com;
> vguvva at caviumnetworks.com; brijesh.s.singh at gmail.com
> Subject: [PATCH v1 3/3] hash: add new API function to query the key count
>
> Add a new function, rte_hash_count, to return the number of keys that are
> currently stored in the hash table. Corresponding test functions are added into
> hash_test and hash_multiwriter test.
>
> Signed-off-by: Yipeng Wang <yipeng1.wang at intel.com>
> ---
> lib/librte_hash/rte_cuckoo_hash.c | 39
> +++++++++++++++++++++++++++++++-----
> lib/librte_hash/rte_hash.h | 11 ++++++++++
> lib/librte_hash/rte_hash_version.map | 8 ++++++++
> test/test/test_hash.c | 12 +++++++++++
> test/test/test_hash_multiwriter.c | 9 +++++++++
> 5 files changed, 74 insertions(+), 5 deletions(-)
>
> diff --git a/lib/librte_hash/rte_cuckoo_hash.c
> b/lib/librte_hash/rte_cuckoo_hash.c
> index a5bb4d4..3dff871 100644
> --- a/lib/librte_hash/rte_cuckoo_hash.c
> +++ b/lib/librte_hash/rte_cuckoo_hash.c
> @@ -133,13 +133,13 @@ rte_hash_create(const struct rte_hash_parameters
> *params)
> * except for the first cache
> */
> num_key_slots = params->entries + (RTE_MAX_LCORE - 1) *
> - LCORE_CACHE_SIZE + 1;
> + (LCORE_CACHE_SIZE - 1) + 1;
This and the other changes made outside the new rte_hash_count API can be done in a different patch.
If this was an issue on the calculation of key slots, it should be marked as a fix and then
a patch with the new API can follow, with the tests.
...
>
> +int32_t
> +rte_hash_count(struct rte_hash *h)
> +{
> + uint32_t tot_ring_cnt, cached_cnt = 0;
> + uint32_t i, ret;
> +
> + if (h == NULL || h->free_slots == NULL)
I don't think the check on free_slots is necessary,
since rte_hash_create is already checking that.
...
> --- a/lib/librte_hash/rte_hash.h
> +++ b/lib/librte_hash/rte_hash.h
> @@ -127,6 +127,17 @@ void
> rte_hash_reset(struct rte_hash *h);
>
> /**
> + * Return the number of keys in the hash table
> + * @param h
> + * Hash table to query from
> + * @return
> + * - -EINVAL if parameters are invalid
> + * - A value indicating how many keys inserted in the table.
"how many keys were inserted"
More information about the dev
mailing list