From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 435492C72 for ; Sun, 18 Feb 2018 16:39:11 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Feb 2018 07:39:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,530,1511856000"; d="scan'208";a="18594862" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga007.fm.intel.com with ESMTP; 18 Feb 2018 07:39:10 -0800 Received: from fmsmsx117.amr.corp.intel.com ([169.254.3.243]) by FMSMSX105.amr.corp.intel.com ([169.254.4.164]) with mapi id 14.03.0319.002; Sun, 18 Feb 2018 07:39:10 -0800 From: "Wiles, Keith" To: Matan Azrad CC: Pavan Nikhilesh , "jerin.jacob@caviumnetworks.com" , "Thomas Monjalon" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH 1/2] eal: add API to align integer to previous power of 2 Thread-Index: AQHTqH9YhrarJeV/c02BHfwy89nKE6Oq0lgA Date: Sun, 18 Feb 2018 15:39:09 +0000 Message-ID: <28F3DAA5-CCAB-4D2E-A6C9-FEB685A619C8@intel.com> References: <20180217104934.17291-1-pbhagavatula@caviumnetworks.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.254.32.238] Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH 1/2] eal: add API to align integer to previous power of 2 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: Sun, 18 Feb 2018 15:39:13 -0000 > On Feb 18, 2018, at 12:11 AM, Matan Azrad wrote: >=20 > Hi Pavan >=20 > Please see some comments below. >=20 > From: Pavan Nikhilesh, Saturday, February 17, 2018 12:50 PM >> Add 32b and 64b API's to align the given integer to the previous power o= f 2. >>=20 >> Signed-off-by: Pavan Nikhilesh >> --- >> lib/librte_eal/common/include/rte_common.h | 36 >> ++++++++++++++++++++++++++++++ >> 1 file changed, 36 insertions(+) >>=20 >> diff --git a/lib/librte_eal/common/include/rte_common.h >> b/lib/librte_eal/common/include/rte_common.h >> index c7803e41c..126914f07 100644 >> --- a/lib/librte_eal/common/include/rte_common.h >> +++ b/lib/librte_eal/common/include/rte_common.h >> @@ -259,6 +259,24 @@ rte_align32pow2(uint32_t x) >> return x + 1; >> } >>=20 >> +/** >> + * Aligns input parameter to the previous power of 2 >> + * >> + * @param x >> + * The integer value to algin >> + * >> + * @return >> + * Input parameter aligned to the previous power of 2 >=20 > I think the zero case(x=3D0) result should be documented. >=20 >> + */ >> +static inline uint32_t >> +rte_align32lowpow2(uint32_t x) >=20 > What do you think about " rte_align32prevpow2"? >=20 >> +{ >> + x =3D rte_align32pow2(x); >=20 > In case of x is power of 2 number(already aligned), looks like the resu= lt here is x and the final result is (x >> 1)? > Is it as you expect? >=20 >> + x--; >> + >> + return x - (x >> 1); >=20 > Why can't the implementation just be: > return rte_align32pow2(x) >> 1; >=20 > If the above is correct, Are you sure we need this API? >=20 >> +} >> + >> /** >> * Aligns 64b input parameter to the next power of 2 >> * >> @@ -282,6 +300,24 @@ rte_align64pow2(uint64_t v) >> return v + 1; >> } >>=20 >> +/** >> + * Aligns 64b input parameter to the previous power of 2 >> + * >> + * @param v >> + * The 64b value to align >> + * >> + * @return >> + * Input parameter aligned to the previous power of 2 >> + */ >> +static inline uint64_t >> +rte_align64lowpow2(uint64_t v) >> +{ >> + v =3D rte_align64pow2(v); >> + v--; >> + >> + return v - (v >> 1); >> +} >> + >=20 > Same comments for 64b API. >=20 >> /*********** Macros for calculating min and max **********/ >>=20 >> /** >> -- >> 2.16.1 >=20 >=20 > If it is a new API, I think it should be added to the map file and to be = tagged as experimental. No? >=20 Is this the type of API that needs to be marked experimental, we should be = able to prove these functions, correct? > Matan Regards, Keith