From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-la0-f54.google.com (mail-la0-f54.google.com [209.85.215.54]) by dpdk.org (Postfix) with ESMTP id 719BC5677 for ; Fri, 6 Mar 2015 13:03:06 +0100 (CET) Received: by labgq15 with SMTP id gq15so3149964lab.13 for ; Fri, 06 Mar 2015 04:03:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=XPuCvjW8lTSkJogl3swkFXpVXUzhW6HM1A9BtNYUM24=; b=o2kkKUOwYFtIaFT3hKsfr726E18KCJ6bSi7kWUAl7Wsfy2Df/mo2M0qdB8bLoNM1mM rgs+OfHJtxw+L6Xs6ahEHrepU9AnWY8ZGlLNv24M7bJbai0Pv+m9mT4SRJoBC62LHgyD I98XVvrcvfCY4Nw1fNqi4H7BlC5zpE/VTJ8VEeilmsrNIirykjZzXW4V2pW5znafA/sU Y1+Ejpx85gfsJUOoPybd64vwxPFpkDR5tJ1rn0PFEmzB2F3UoZHBZ72YqGzIZIC0Vf/i ITECOGvFBILzyFZHw0/yGZlCWGc83EbgGXC9JeGZFJ1Q+dgypcO4jg+SGEwPVtdv3wzp LUyA== X-Received: by 10.112.134.167 with SMTP id pl7mr12191346lbb.63.1425643386104; Fri, 06 Mar 2015 04:03:06 -0800 (PST) Received: from [192.168.77.219] ([194.218.229.29]) by mx.google.com with ESMTPSA id la1sm1780409lab.2.2015.03.06.04.03.04 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Mar 2015 04:03:04 -0800 (PST) Message-ID: <54F99770.5040201@gmail.com> Date: Fri, 06 Mar 2015 13:02:56 +0100 From: Tomas Vestelind User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Bruce Richardson References: <20150306111025.GA9352@bricha3-MOBL3> In-Reply-To: <20150306111025.GA9352@bricha3-MOBL3> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Mailman-Approved-At: Sat, 07 Mar 2015 21:29:46 +0100 Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH] hash: added rte_hash_clear that clears all keys X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Mar 2015 12:03:06 -0000 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 >> --- >> 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 >> > >