From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 17D4D1BAA7 for ; Tue, 26 Jun 2018 18:11:26 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jun 2018 09:11:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,275,1526367600"; d="scan'208";a="53054264" Received: from irsmsx152.ger.corp.intel.com ([163.33.192.66]) by orsmga006.jf.intel.com with ESMTP; 26 Jun 2018 09:11:24 -0700 Received: from irsmsx111.ger.corp.intel.com (10.108.20.4) by IRSMSX152.ger.corp.intel.com (163.33.192.66) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 26 Jun 2018 17:11:24 +0100 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.139]) by irsmsx111.ger.corp.intel.com ([169.254.2.230]) with mapi id 14.03.0319.002; Tue, 26 Jun 2018 17:11:23 +0100 From: "De Lara Guarch, Pablo" To: "Wang, Yipeng1" CC: "dev@dpdk.org" , "Mcnamara, John" , "Richardson, Bruce" , "honnappa.nagarahalli@arm.com" , "vguvva@caviumnetworks.com" , "brijesh.s.singh@gmail.com" Thread-Topic: [PATCH v1 3/3] hash: add new API function to query the key count Thread-Index: AQHT/1INHDRP5PM4c0Sn1PqeuFAFiKRysIkw Date: Tue, 26 Jun 2018 16:11:22 +0000 Message-ID: References: <1528455078-328182-1-git-send-email-yipeng1.wang@intel.com> <1528455078-328182-4-git-send-email-yipeng1.wang@intel.com> In-Reply-To: <1528455078-328182-4-git-send-email-yipeng1.wang@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZGU0MWI0YmMtZTE0OC00NzZjLWE1NTUtZTE2YjJjZGNhYWYwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiTVhNS0tBYkJFekUyU0U1dzJ0MWp4T1B0anA4KzBLR0F4Q1lwXC9qUGhtZU1UQWh3VHNQN0FaRG1YUFJOR0E3bHQifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v1 3/3] hash: add new API function to query the key count 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: , X-List-Received-Date: Tue, 26 Jun 2018 16:11:28 -0000 > -----Original Message----- > From: Wang, Yipeng1 > Sent: Friday, June 8, 2018 11:51 AM > To: De Lara Guarch, Pablo > Cc: dev@dpdk.org; Wang, Yipeng1 ; Mcnamara, > John ; Richardson, Bruce > ; honnappa.nagarahalli@arm.com; > vguvva@caviumnetworks.com; brijesh.s.singh@gmail.com > Subject: [PATCH v1 3/3] hash: add new API function to query the key count >=20 > Add a new function, rte_hash_count, to return the number of keys that are > currently stored in the hash table. Corresponding test functions are adde= d into > hash_test and hash_multiwriter test. >=20 > Signed-off-by: Yipeng Wang > --- > lib/librte_hash/rte_cuckoo_hash.c | 39 > +++++++++++++++++++++++++++++++----- > lib/librte_hash/rte_hash.h | 11 ++++++++++ > lib/librte_hash/rte_hash_version.map | 8 ++++++++ > test/test/test_hash.c | 12 +++++++++++ > test/test/test_hash_multiwriter.c | 9 +++++++++ > 5 files changed, 74 insertions(+), 5 deletions(-) >=20 > diff --git a/lib/librte_hash/rte_cuckoo_hash.c > b/lib/librte_hash/rte_cuckoo_hash.c > index a5bb4d4..3dff871 100644 > --- a/lib/librte_hash/rte_cuckoo_hash.c > +++ b/lib/librte_hash/rte_cuckoo_hash.c > @@ -133,13 +133,13 @@ rte_hash_create(const struct rte_hash_parameters > *params) > * except for the first cache > */ > num_key_slots =3D params->entries + (RTE_MAX_LCORE - 1) * > - LCORE_CACHE_SIZE + 1; > + (LCORE_CACHE_SIZE - 1) + 1; This and the other changes made outside the new rte_hash_count API can be d= one in a different patch. If this was an issue on the calculation of key slots, it should be marked a= s a fix and then a patch with the new API can follow, with the tests. ... >=20 > +int32_t > +rte_hash_count(struct rte_hash *h) > +{ > + uint32_t tot_ring_cnt, cached_cnt =3D 0; > + uint32_t i, ret; > + > + if (h =3D=3D NULL || h->free_slots =3D=3D NULL) I don't think the check on free_slots is necessary, since rte_hash_create is already checking that. ... > --- a/lib/librte_hash/rte_hash.h > +++ b/lib/librte_hash/rte_hash.h > @@ -127,6 +127,17 @@ void > rte_hash_reset(struct rte_hash *h); >=20 > /** > + * Return the number of keys in the hash table > + * @param h > + * Hash table to query from > + * @return > + * - -EINVAL if parameters are invalid > + * - A value indicating how many keys inserted in the table. "how many keys were inserted"