From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 23794A034F; Mon, 25 Nov 2019 20:41:29 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B991528EE; Mon, 25 Nov 2019 20:41:27 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id EE798A3 for ; Mon, 25 Nov 2019 20:41:25 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Nov 2019 11:41:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,242,1571727600"; d="scan'208";a="211194480" Received: from orsmsx107.amr.corp.intel.com ([10.22.240.5]) by orsmga006.jf.intel.com with ESMTP; 25 Nov 2019 11:41:24 -0800 Received: from orsmsx104.amr.corp.intel.com ([169.254.4.122]) by ORSMSX107.amr.corp.intel.com ([169.254.1.224]) with mapi id 14.03.0439.000; Mon, 25 Nov 2019 11:41:24 -0800 From: "Wang, Yipeng1" To: "Amber, Kumar" , "dev@dpdk.org" Thread-Topic: [PATCH v3] hash: added a new API to hash to query key id Thread-Index: AQHVoWGhYx3hNvX3F0WGa8r7UR72WKecRJGAgAABb0A= Date: Mon, 25 Nov 2019 19:41:24 +0000 Message-ID: References: <20191122182100.15631-1-kumar.amber@intel.com> <20191125110805.28187-1-kumar.amber@intel.com> In-Reply-To: <20191125110805.28187-1-kumar.amber@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZjE2MzllOGUtZWFiYS00ZDY5LWE3NzQtZmYwZmNkZjg5YzA2IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiQWFEU3B6K1FlR2thc2g3QU5nOFNxZ3ZUUXVoZXVEVlB2XC93cThENlhTem80allMMUFXZ2RXUUhnU0lKdUdkSloifQ== x-originating-ip: [10.22.254.138] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v3] hash: added a new API to hash to query key id X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi, Amber, Thanks for the patch! A bit comment inlined: >-----Original Message----- >From: Amber, Kumar >Sent: Monday, November 25, 2019 3:08 AM >To: dev@dpdk.org >Cc: Wang, Yipeng1 >Subject: [PATCH v3] hash: added a new API to hash to query key id > >Adding new API function to query the maximum key ID >that could possibly returned by rte_hash_add_key and [Wang, Yipeng] That could possibly "be" returned...=20 >rte_hash_add_key_with_hash. When RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD >is set, the maximum key id is larger than the entry count specified >by the user. > >Signed-off-by: Kumar Amber >--- > lib/librte_hash/rte_cuckoo_hash.c | 15 +++++++++++++++ > lib/librte_hash/rte_hash.h | 25 +++++++++++++++++++++++-- > lib/librte_hash/rte_hash_version.map | 1 + > 3 files changed, 39 insertions(+), 2 deletions(-) > >diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cucko= o_hash.c >index 87a4c01f2..3a94f10b8 100644 >--- a/lib/librte_hash/rte_cuckoo_hash.c >+++ b/lib/librte_hash/rte_cuckoo_hash.c >@@ -506,6 +506,21 @@ rte_hash_hash(const struct rte_hash *h, const void *k= ey) > return h->hash_func(key, h->key_len, h->hash_func_init_val); > } > >+uint32_t >+rte_hash_max_key_id(const struct rte_hash *h) >+{ >+ RETURN_IF_TRUE((h =3D=3D NULL), -EINVAL); >+ if (h->use_local_cache) >+ /* >+ * Increase number of slots by total number of indices >+ * that can be stored in the lcore caches >+ */ >+ return (h->entries + ((RTE_MAX_LCORE - 1) * >+ (LCORE_CACHE_SIZE - 1))); >+ else >+ return h->entries; >+} >+ > int32_t > rte_hash_count(const struct rte_hash *h) > { >diff --git a/lib/librte_hash/rte_hash.h b/lib/librte_hash/rte_hash.h >index 0d73370dc..c87861e72 100644 >--- a/lib/librte_hash/rte_hash.h >+++ b/lib/librte_hash/rte_hash.h >@@ -164,6 +164,23 @@ rte_hash_reset(struct rte_hash *h); > int32_t > rte_hash_count(const struct rte_hash *h); > >+/** >+ * @warning >+ * @b EXPERIMENTAL: this API may change without prior notice >+ * >+ * Return the maximum key value ID that could possibly be returned by >+ * rte_hash_add_key function. [Wang, Yipeng] Seems you have two spaces between "Return" and "the", change= to one. >+ * >+ * @param h >+ * Hash table to query from >+ * @return >+ * - -EINVAL if parameters are invalid >+ * - A value indicating the max key Id key slots present in the table. [Wang, Yipeng] Two spaces between "Id" and "key". Maybe you want to say key= Id "of" key slots? >+ */ >+__rte_experimental >+uint32_t >+rte_hash_max_key_id(const struct rte_hash *h); >+ > /** > * Add a key-value pair to an existing hash table. > * This operation is not multi-thread safe >@@ -234,7 +251,9 @@ rte_hash_add_key_with_hash_data(const struct rte_hash = *h, const void *key, > * - -EINVAL if the parameters are invalid. > * - -ENOSPC if there is no space in the hash for this key. > * - A positive value that can be used by the caller as an offset into = an >- * array of user data. This value is unique for this key. >+ * array of user data. This value is unique for this key. This >+ * unique key id may be larger than the user specified entry count >+ * when RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD flag is set. > */ > int32_t > rte_hash_add_key(const struct rte_hash *h, const void *key); >@@ -256,7 +275,9 @@ rte_hash_add_key(const struct rte_hash *h, const void = *key); > * - -EINVAL if the parameters are invalid. > * - -ENOSPC if there is no space in the hash for this key. > * - A positive value that can be used by the caller as an offset into = an >- * array of user data. This value is unique for this key. >+ * array of user data. This value is unique for this key. This >+ * unique key ID may be larger than the user specified entry count >+ * when RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD flag is set. > */ > int32_t > rte_hash_add_key_with_hash(const struct rte_hash *h, const void *key, has= h_sig_t sig); >diff --git a/lib/librte_hash/rte_hash_version.map b/lib/librte_hash/rte_ha= sh_version.map >index 734ae28b0..562ceb8bc 100644 >--- a/lib/librte_hash/rte_hash_version.map >+++ b/lib/librte_hash/rte_hash_version.map >@@ -58,5 +58,6 @@ EXPERIMENTAL { > global: > > rte_hash_free_key_with_position; >+ rte_hash_max_key_id; > [Wang, Yipeng] Fix the Indentation of this line. [Wang, Yipeng]=20 I also realized that rte_add_key returns int32_t but the ID could potential= ly be uint32_t. But by default, the entry ID should never overflow the range. Let's just convert the new API's return to int32_t to be consistent for now= .