* Re: [PATCH] hash: added rte_hash_clear that clears all keys
@ 2015-03-06 11:10 Bruce Richardson
2015-03-06 12:02 ` Tomas Vestelind
0 siblings, 1 reply; 4+ messages in thread
From: Bruce Richardson @ 2015-03-06 11:10 UTC (permalink / raw)
To: Tomas Vestelind; +Cc: dev-VfR2kkLFssw
On Tue, Aug 12, 2014 at 11:47:57PM +0200, Tomas Vestelind wrote:
> I added rte_hash_clear which clear the map from all previously added
> keys.
>
This patch is now quite old and needs an update to add the new API to the
rte_hash_version.map. A unit test for the new function would also be good to
have. Otherwise patch content looks ok. Is an updated V2 planned?
Regards,
/Bruce
> Signed-off-by: Tomas Vestelind <tomas.vestelind at gmail.com>
> ---
> lib/librte_hash/rte_hash.c | 14 ++++++++++++++
> lib/librte_hash/rte_hash.h | 10 ++++++++++
> 2 files changed, 24 insertions(+)
>
> diff --git a/lib/librte_hash/rte_hash.c b/lib/librte_hash/rte_hash.c
> index 2108c4f..917a6c1 100644
> --- a/lib/librte_hash/rte_hash.c
> +++ b/lib/librte_hash/rte_hash.c
> @@ -507,3 +507,17 @@ rte_hash_keys(const struct rte_hash *h, void *keys)
>
> return found_keys;
> }
> +
> +void
> +rte_hash_clear(const struct rte_hash *h)
> +{
> + unsigned int bucket, entry;
> +
> + /* Clear all entries by invalidating each signature */
> + for (bucket = 0; bucket < h->num_buckets; bucket++) {
> + hash_sig_t *sig = get_sig_tbl_bucket(h, bucket);
> + for (entry = 0; entry < h->bucket_entries; entry++) {
> + sig[entry] = NULL_SIGNATURE;
> + }
> + }
> +}
> diff --git a/lib/librte_hash/rte_hash.h b/lib/librte_hash/rte_hash.h
> index e0fb28f..b84137e 100644
> --- a/lib/librte_hash/rte_hash.h
> +++ b/lib/librte_hash/rte_hash.h
> @@ -318,6 +318,16 @@ rte_hash_lookup_bulk(const struct rte_hash *h, const void **keys,
> */
> unsigned int
> rte_hash_keys(const struct rte_hash *h, void *keys);
> +
> +/**
> + * Clear all keys. This operation is not multi-thread safe and should only be
> + * called from one thread.
> + *
> + * @param h
> + * Hash table to clear.
> + */
> +void
> +rte_hash_clear(const struct rte_hash *h);
> #ifdef __cplusplus
> }
> #endif
> --
> 1.7.10.4
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] hash: added rte_hash_clear that clears all keys
2015-03-06 11:10 [PATCH] hash: added rte_hash_clear that clears all keys Bruce Richardson
@ 2015-03-06 12:02 ` Tomas Vestelind
[not found] ` <54F99770.5040201-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Tomas Vestelind @ 2015-03-06 12:02 UTC (permalink / raw)
To: Bruce Richardson; +Cc: dev-VfR2kkLFssw
Hi Bruce!
Oh yea, this patch is quite old :)
I'm currently not working actively with DPDK. If no one else wants to do
it, I could do the update and add a unit test
/Tomas
On 2015-03-06 12:10, Bruce Richardson wrote:
> On Tue, Aug 12, 2014 at 11:47:57PM +0200, Tomas Vestelind wrote:
>> I added rte_hash_clear which clear the map from all previously added
>> keys.
>>
> This patch is now quite old and needs an update to add the new API to the
> rte_hash_version.map. A unit test for the new function would also be good to
> have. Otherwise patch content looks ok. Is an updated V2 planned?
>
> Regards,
> /Bruce
>
>> Signed-off-by: Tomas Vestelind <tomas.vestelind at gmail.com>
>> ---
>> lib/librte_hash/rte_hash.c | 14 ++++++++++++++
>> lib/librte_hash/rte_hash.h | 10 ++++++++++
>> 2 files changed, 24 insertions(+)
>>
>> diff --git a/lib/librte_hash/rte_hash.c b/lib/librte_hash/rte_hash.c
>> index 2108c4f..917a6c1 100644
>> --- a/lib/librte_hash/rte_hash.c
>> +++ b/lib/librte_hash/rte_hash.c
>> @@ -507,3 +507,17 @@ rte_hash_keys(const struct rte_hash *h, void *keys)
>>
>> return found_keys;
>> }
>> +
>> +void
>> +rte_hash_clear(const struct rte_hash *h)
>> +{
>> + unsigned int bucket, entry;
>> +
>> + /* Clear all entries by invalidating each signature */
>> + for (bucket = 0; bucket < h->num_buckets; bucket++) {
>> + hash_sig_t *sig = get_sig_tbl_bucket(h, bucket);
>> + for (entry = 0; entry < h->bucket_entries; entry++) {
>> + sig[entry] = NULL_SIGNATURE;
>> + }
>> + }
>> +}
>> diff --git a/lib/librte_hash/rte_hash.h b/lib/librte_hash/rte_hash.h
>> index e0fb28f..b84137e 100644
>> --- a/lib/librte_hash/rte_hash.h
>> +++ b/lib/librte_hash/rte_hash.h
>> @@ -318,6 +318,16 @@ rte_hash_lookup_bulk(const struct rte_hash *h, const void **keys,
>> */
>> unsigned int
>> rte_hash_keys(const struct rte_hash *h, void *keys);
>> +
>> +/**
>> + * Clear all keys. This operation is not multi-thread safe and should only be
>> + * called from one thread.
>> + *
>> + * @param h
>> + * Hash table to clear.
>> + */
>> +void
>> +rte_hash_clear(const struct rte_hash *h);
>> #ifdef __cplusplus
>> }
>> #endif
>> --
>> 1.7.10.4
>>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] hash: added rte_hash_clear that clears all keys
@ 2014-08-12 21:47 Tomas Vestelind
0 siblings, 0 replies; 4+ messages in thread
From: Tomas Vestelind @ 2014-08-12 21:47 UTC (permalink / raw)
To: dev-VfR2kkLFssw
I added rte_hash_clear which clear the map from all previously added
keys.
Signed-off-by: Tomas Vestelind <tomas.vestelind-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
lib/librte_hash/rte_hash.c | 14 ++++++++++++++
lib/librte_hash/rte_hash.h | 10 ++++++++++
2 files changed, 24 insertions(+)
diff --git a/lib/librte_hash/rte_hash.c b/lib/librte_hash/rte_hash.c
index 2108c4f..917a6c1 100644
--- a/lib/librte_hash/rte_hash.c
+++ b/lib/librte_hash/rte_hash.c
@@ -507,3 +507,17 @@ rte_hash_keys(const struct rte_hash *h, void *keys)
return found_keys;
}
+
+void
+rte_hash_clear(const struct rte_hash *h)
+{
+ unsigned int bucket, entry;
+
+ /* Clear all entries by invalidating each signature */
+ for (bucket = 0; bucket < h->num_buckets; bucket++) {
+ hash_sig_t *sig = get_sig_tbl_bucket(h, bucket);
+ for (entry = 0; entry < h->bucket_entries; entry++) {
+ sig[entry] = NULL_SIGNATURE;
+ }
+ }
+}
diff --git a/lib/librte_hash/rte_hash.h b/lib/librte_hash/rte_hash.h
index e0fb28f..b84137e 100644
--- a/lib/librte_hash/rte_hash.h
+++ b/lib/librte_hash/rte_hash.h
@@ -318,6 +318,16 @@ rte_hash_lookup_bulk(const struct rte_hash *h, const void **keys,
*/
unsigned int
rte_hash_keys(const struct rte_hash *h, void *keys);
+
+/**
+ * Clear all keys. This operation is not multi-thread safe and should only be
+ * called from one thread.
+ *
+ * @param h
+ * Hash table to clear.
+ */
+void
+rte_hash_clear(const struct rte_hash *h);
#ifdef __cplusplus
}
#endif
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-03-06 12:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-06 11:10 [PATCH] hash: added rte_hash_clear that clears all keys Bruce Richardson
2015-03-06 12:02 ` Tomas Vestelind
[not found] ` <54F99770.5040201-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-03-06 12:53 ` Bruce Richardson
-- strict thread matches above, loose matches on Subject: below --
2014-08-12 21:47 Tomas Vestelind
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).