[dpdk-dev] [PATCH v2] hash: new function to retrieve a key given its position

De Lara Guarch, Pablo pablo.de.lara.guarch at intel.com
Fri Jun 24 12:29:47 CEST 2016



> -----Original Message-----
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Yari Adan
> Petralanda
> Sent: Friday, June 17, 2016 12:00 PM
> To: dev at dpdk.org
> Subject: [dpdk-dev] [PATCH v2] hash: new function to retrieve a key given its
> position
> 
> The function rte_hash_get_key_with_position is added in this patch.
> As the position returned when adding a key is frequently used as an
> offset into an array of user data, this function performs the operation
> of retrieving a key given this offset.
> 
> A possible use case would be to delete a key from the hash table when
> its entry in the array of data has certain value. For instance, the key
> could be a flow 5-tuple, and the value stored in the array a time
> stamp.
> 
> Signed-off-by: Juan Antonio Montesinos
> <juan.antonio.montesinos.delgado at ericsson.com>
> Signed-off-by: Yari Adan Petralanda <yari.adan.petralanda at ericsson.com>
> ---
>  app/test/test_hash.c                 | 42
> ++++++++++++++++++++++++++++++++++++
>  lib/librte_hash/rte_cuckoo_hash.c    | 18 ++++++++++++++++
>  lib/librte_hash/rte_hash.h           | 18 ++++++++++++++++
>  lib/librte_hash/rte_hash_version.map |  7 ++++++
>  4 files changed, 85 insertions(+)
> 
> diff --git a/app/test/test_hash.c b/app/test/test_hash.c
> index 7e41725..d50afae 100644
> --- a/app/test/test_hash.c
> +++ b/app/test/test_hash.c
> @@ -421,6 +421,46 @@ static int test_add_update_delete(void)
>  }
> 
>  /*
> + * Sequence of operations for retrieving a key with its position
> + *
> + *  - create table
> + *  - add key
> + *  - get the key with its position: hit
> + *  - delete key
> + *  - try to get the deleted key: miss
> + *
> + */
> +static int test_hash_get_key_with_position(void)
> +{
> +	struct rte_hash *handle = NULL;
> +	int pos, expectedPos, result;
> +	void *key;
> +
> +	ut_params.name = "hash_get_key_with_position";

The name is too long and causes rte_hash_create() to fail (therefore, test does not work),
as internal ring name results in more than 32 characters.
Could you rename it to something shorter? hash_get_key_with_pos?

> +	handle = rte_hash_create(&ut_params);
> +	RETURN_IF_ERROR(handle == NULL, "hash creation failed");
> +
> +	pos = rte_hash_add_key(handle, &keys[0]);
> +	print_key_info("Add", &keys[0], pos);
> +	RETURN_IF_ERROR(pos < 0, "failed to add key (pos0=%d)", pos);
> +	expectedPos = pos;

[...]

Rest of the patch looks good to me.


More information about the dev mailing list