From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 1BD5A1BDD5 for ; Fri, 6 Jul 2018 12:04:14 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jul 2018 03:04:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,315,1526367600"; d="scan'208";a="69147804" Received: from irsmsx154.ger.corp.intel.com ([163.33.192.96]) by fmsmga004.fm.intel.com with ESMTP; 06 Jul 2018 03:04:12 -0700 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.139]) by IRSMSX154.ger.corp.intel.com ([169.254.12.32]) with mapi id 14.03.0319.002; Fri, 6 Jul 2018 11:04:12 +0100 From: "De Lara Guarch, Pablo" To: "Wang, Yipeng1" CC: "dev@dpdk.org" , "Richardson, Bruce" , "honnappa.nagarahalli@arm.com" , "vguvva@caviumnetworks.com" , "brijesh.s.singh@gmail.com" Thread-Topic: [PATCH v2 1/6] hash: make duplicated code into functions Thread-Index: AQHUD9/NSmFYLC+pVEqv77NRNak7QqSA8Inw Date: Fri, 6 Jul 2018 10:04:11 +0000 Message-ID: References: <1528455078-328182-1-git-send-email-yipeng1.wang@intel.com> <1530275097-123488-1-git-send-email-yipeng1.wang@intel.com> <1530275097-123488-2-git-send-email-yipeng1.wang@intel.com> In-Reply-To: <1530275097-123488-2-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: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNDk2MDViYTMtOTRjYS00M2NiLWFiMmQtZjE0YjkxODAwM2RhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiNHlQSG1QMzgreFdHQ1A5akhlNXN0R0Y0Rm0wa2I5a1R4KzlHd1lMaXNUUEdaVDBCZW5aNzZWejF2UWxMT2pwQiJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action 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 v2 1/6] hash: make duplicated code into functions 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: Fri, 06 Jul 2018 10:04:15 -0000 Hi Yipeng, > -----Original Message----- > From: Wang, Yipeng1 > Sent: Friday, June 29, 2018 1:25 PM > To: De Lara Guarch, Pablo > Cc: dev@dpdk.org; Wang, Yipeng1 ; Richardson, > Bruce ; honnappa.nagarahalli@arm.com; > vguvva@caviumnetworks.com; brijesh.s.singh@gmail.com > Subject: [PATCH v2 1/6] hash: make duplicated code into functions >=20 > This commit refactors the hash table lookup/add/del code to remove some c= ode > duplication. Processing on primary bucket can also apply to secondary buc= ket > with same code. >=20 > Signed-off-by: Yipeng Wang > --- > lib/librte_hash/rte_cuckoo_hash.c | 186 ++++++++++++++++++--------------= ------ ... > +/* Search one bucket to find the match key */ > static inline int32_t > -__rte_hash_lookup_with_hash(const struct rte_hash *h, const void *key, > - hash_sig_t sig, void **data) > +search_one_bucket(const struct rte_hash *h, const void *key, hash_sig_t = sig, > + void **data, struct rte_hash_bucket *bkt) Use "const" in "struct rte_hash_bucket". ... > +search_and_remove(const struct rte_hash *h, const void *key, > + struct rte_hash_bucket *bkt, hash_sig_t sig, > + int32_t *ret_val) > { > - uint32_t bucket_idx; > - hash_sig_t alt_hash; > - unsigned i; > - struct rte_hash_bucket *bkt; > struct rte_hash_key *k, *keys =3D h->key_store; > - int32_t ret; > - > - bucket_idx =3D sig & h->bucket_bitmask; > - bkt =3D &h->buckets[bucket_idx]; > + unsigned int i; >=20 > /* Check if key is in primary location */ > for (i =3D 0; i < RTE_HASH_BUCKET_ENTRIES; i++) { @@ -833,37 +825,39 > @@ __rte_hash_del_key_with_hash(const struct rte_hash *h, const void *key= , > * Return index where key is stored, > * subtracting the first dummy index > */ > - ret =3D bkt->key_idx[i] - 1; > + *ret_val =3D bkt->key_idx[i] - 1; > bkt->key_idx[i] =3D EMPTY_SLOT; > - return ret; > + return 0; You can store ret_val and return it, instead of returning 0, so the function is similar to the other search functions. > } > } > } > + return -1;