From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 8BE0F8E8C for ; Tue, 24 Nov 2015 15:07:52 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 24 Nov 2015 06:06:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,338,1444719600"; d="scan'208";a="606328663" Received: from irsmsx103.ger.corp.intel.com ([163.33.3.157]) by FMSMGA003.fm.intel.com with ESMTP; 24 Nov 2015 06:06:33 -0800 Received: from irsmsx112.ger.corp.intel.com (10.108.20.5) by IRSMSX103.ger.corp.intel.com (163.33.3.157) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 24 Nov 2015 14:06:32 +0000 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.23]) by irsmsx112.ger.corp.intel.com ([169.254.1.8]) with mapi id 14.03.0248.002; Tue, 24 Nov 2015 14:06:32 +0000 From: "De Lara Guarch, Pablo" To: Yu Nemo Wenbin , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] hash: add rte_hash_set_cmp_func() function. Thread-Index: AQHRImfVtJas3TimgE+kK8Snd/SY156rO8wg Date: Tue, 24 Nov 2015 14:06:32 +0000 Message-ID: References: <1447895712-12159-1-git-send-email-yuwb_bjy@ctbri.com.cn> In-Reply-To: <1447895712-12159-1-git-send-email-yuwb_bjy@ctbri.com.cn> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] hash: add rte_hash_set_cmp_func() function. 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: Tue, 24 Nov 2015 14:07:53 -0000 Hi, > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Yu Nemo Wenbin > Sent: Thursday, November 19, 2015 1:15 AM > To: dev@dpdk.org > Subject: [dpdk-dev] [PATCH] hash: add rte_hash_set_cmp_func() function. >=20 > Give user a chance to costomize the hash key compare function. > The default rte_hash_cmp_eq function is set in the rte_hash_create > function, but these builtin ones may not good enough, so the user > may call this to override the default one. Typos in "costomize" and "may not good" (may not be good) >=20 > Signed-off-by: Yu Nemo Wenbin > --- > lib/librte_hash/rte_cuckoo_hash.c | 7 +++++-- > lib/librte_hash/rte_hash.h | 15 +++++++++++++++ > lib/librte_hash/rte_hash_version.map | 1 + > 3 files changed, 21 insertions(+), 2 deletions(-) >=20 > diff --git a/lib/librte_hash/rte_cuckoo_hash.c > b/lib/librte_hash/rte_cuckoo_hash.c > index 1e970de..71e2419 100644 > --- a/lib/librte_hash/rte_cuckoo_hash.c > +++ b/lib/librte_hash/rte_cuckoo_hash.c > @@ -98,8 +98,6 @@ EAL_REGISTER_TAILQ(rte_hash_tailq) >=20 > #define LCORE_CACHE_SIZE 8 >=20 > -typedef int (*rte_hash_cmp_eq_t)(const void *key1, const void *key2, > size_t key_len); > - > struct lcore_cache { > unsigned len; /**< Cache len */ > void *objs[LCORE_CACHE_SIZE]; /**< Cache objects */ > @@ -183,6 +181,11 @@ rte_hash_find_existing(const char *name) > return h; > } >=20 > +void rte_hash_set_cmp_func(struct rte_hash *h, rte_hash_cmp_eq_t > func) > +{ > + h->rte_hash_cmp_eq =3D func; > +} > + > struct rte_hash * > rte_hash_create(const struct rte_hash_parameters *params) > { > diff --git a/lib/librte_hash/rte_hash.h b/lib/librte_hash/rte_hash.h > index b678766..8378a42 100644 > --- a/lib/librte_hash/rte_hash.h > +++ b/lib/librte_hash/rte_hash.h > @@ -66,6 +66,9 @@ typedef uint32_t hash_sig_t; > typedef uint32_t (*rte_hash_function)(const void *key, uint32_t key_len, > uint32_t init_val); >=20 > +/** Type of function used to compare the key. It works like the memcmp() > */ Remove "the". > +typedef int (*rte_hash_cmp_eq_t)(const void *key1, const void *key2, > size_t key_len); > + > /** > * Parameters used when creating the hash table. > */ > @@ -104,6 +107,18 @@ struct rte_hash * > rte_hash_create(const struct rte_hash_parameters *params); >=20 > /** > + * Set the rte_hash_set_cmp_func. > + * Set the new hash compare function if the default one is not suitable > enough. > + * > + * @note Function pointer does not work with multi-process, so don't use > it > + * in multi-process mode. > + * > + * @param h > + * Hash table to reset > + */ > +void rte_hash_set_cmp_func(struct rte_hash *h, rte_hash_cmp_eq_t > func); > + > +/** > * Find an existing hash table object and return a pointer to it. > * > * @param name > diff --git a/lib/librte_hash/rte_hash_version.map > b/lib/librte_hash/rte_hash_version.map > index 906c8ad..3bc1e2c 100644 > --- a/lib/librte_hash/rte_hash_version.map > +++ b/lib/librte_hash/rte_hash_version.map > @@ -30,5 +30,6 @@ DPDK_2.1 { > rte_hash_lookup_data; > rte_hash_lookup_with_hash_data; > rte_hash_reset; > + rte_hash_set_cmp_func; >=20 > } DPDK_2.0; > -- > 1.9.1 You have to add the new function in a different set (create a new one for 2= .2). Thanks, Pablo