From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0080.outbound.protection.outlook.com [104.47.0.80]) by dpdk.org (Postfix) with ESMTP id BD22E1B16A for ; Mon, 19 Feb 2018 07:03:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=XADhtM36Cpcg3nVqhjSpHlNxCHoqfzow6ScTyxdMhjY=; b=NDQiQbMM+5gdoDVl5V5wx3OCsEEiKDll69gE4zArF77T5gmzt5PjBS84n9Ih+EJNGXa064c8ykG6sAHIIwTYuVgDFwVJ2IF6/z83P5DKZFWV2AGOU1PWoXLXrJlulglXt2CslcM/145c6Q3k+dBGEUPCJb3u+errTEEh4j860dA= Received: from AM4PR0501MB2657.eurprd05.prod.outlook.com (10.172.215.19) by AM4PR0501MB2273.eurprd05.prod.outlook.com (10.165.82.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.506.18; Mon, 19 Feb 2018 06:03:40 +0000 Received: from AM4PR0501MB2657.eurprd05.prod.outlook.com ([fe80::80c6:df5:b1b0:ff05]) by AM4PR0501MB2657.eurprd05.prod.outlook.com ([fe80::80c6:df5:b1b0:ff05%17]) with mapi id 15.20.0506.021; Mon, 19 Feb 2018 06:03:40 +0000 From: Matan Azrad To: "Wiles, Keith" 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: AQHTqM6hjNC7dvJ+KUy8qhmt6Do6xqOrPDog Date: Mon, 19 Feb 2018 06:03:39 +0000 Message-ID: References: <20180217104934.17291-1-pbhagavatula@caviumnetworks.com> <28F3DAA5-CCAB-4D2E-A6C9-FEB685A619C8@intel.com> In-Reply-To: <28F3DAA5-CCAB-4D2E-A6C9-FEB685A619C8@intel.com> Accept-Language: en-US, he-IL Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM4PR0501MB2273; 7:EQdhFB5vQF/6CmDPRb1HCy+UdatuCRpyYJWNfsKVoWlaiytpLPsS8HPOOkYXHTaZEN41tv1jcqTyqXFNPGXIk+Nax89wudlwXfVBt5HQTLB6heZ/sMcKFHilz2VU5whVcr4bMNmVZ64pXVhfrPDU3HPwkXX5PdMa8jaeh2ZmpTCobhEIAh0QvlRt0hwaWureMZngQoZXeMqH8SpfF1PfLGAocskHtAPZbD3/x28GyzkB1zorXD3VR1xh9t1CIMbm x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: b56b393f-82b0-4776-305c-08d5775e8614 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(2017052603307)(7153060)(7193020); SRVR:AM4PR0501MB2273; x-ms-traffictypediagnostic: AM4PR0501MB2273: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001056)(6040501)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(10201501046)(3231101)(944501161)(6055026)(6041288)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:AM4PR0501MB2273; BCL:0; PCL:0; RULEID:; SRVR:AM4PR0501MB2273; x-forefront-prvs: 0588B2BD96 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(396003)(376002)(39380400002)(366004)(346002)(76104003)(199004)(189003)(2900100001)(4326008)(25786009)(8936002)(53936002)(5660300001)(55016002)(81166006)(81156014)(102836004)(9686003)(86362001)(97736004)(68736007)(6916009)(3660700001)(2950100002)(66066001)(14454004)(478600001)(105586002)(3280700002)(74316002)(76176011)(229853002)(6436002)(106356001)(6116002)(3846002)(305945005)(26005)(53546011)(99286004)(6506007)(186003)(7736002)(316002)(33656002)(6246003)(7696005)(2906002)(5250100002)(54906003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR0501MB2273; H:AM4PR0501MB2657.eurprd05.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: coZf6IEzv9Qkqdk9CAsj91f/frbG6nvZhjNQ0Id1xkzZquMCgoQeBEXZALE2BQsxpgY8AjiL0iPQWT9C/F+ec96UcnMcPaAWbGbGFgRJouGwEJoIsQmo86qLZWZLK/Kcn9jDzymHtOWM7iq3TJtzHYDFCT6jgmG7pNNW6mHBZEo= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: b56b393f-82b0-4776-305c-08d5775e8614 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Feb 2018 06:03:40.0863 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0501MB2273 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: Mon, 19 Feb 2018 06:03:42 -0000 > From: Wiles, Keith, Sunday, February 18, 2018 5:39 PM > > On Feb 18, 2018, at 12:11 AM, Matan Azrad > wrote: > > > > Hi Pavan > > > > Please see some comments below. > > > > 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= of > 2. > >> > >> Signed-off-by: Pavan Nikhilesh > >> --- > >> lib/librte_eal/common/include/rte_common.h | 36 > >> ++++++++++++++++++++++++++++++ > >> 1 file changed, 36 insertions(+) > >> > >> 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; > >> } > >> > >> +/** > >> + * 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 > > > > I think the zero case(x=3D0) result should be documented. > > > >> + */ > >> +static inline uint32_t > >> +rte_align32lowpow2(uint32_t x) > > > > What do you think about " rte_align32prevpow2"? > > > >> +{ > >> + x =3D rte_align32pow2(x); > > > > In case of x is power of 2 number(already aligned), looks like the > result here is x and the final result is (x >> 1)? > > Is it as you expect? > > > >> + x--; > >> + > >> + return x - (x >> 1); > > > > Why can't the implementation just be: > > return rte_align32pow2(x) >> 1; > > > > If the above is correct, Are you sure we need this API? > > > >> +} > >> + > >> /** > >> * Aligns 64b input parameter to the next power of 2 > >> * > >> @@ -282,6 +300,24 @@ rte_align64pow2(uint64_t v) > >> return v + 1; > >> } > >> > >> +/** > >> + * 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); > >> +} > >> + > > > > Same comments for 64b API. > > > >> /*********** Macros for calculating min and max **********/ > >> > >> /** > >> -- > >> 2.16.1 > > > > > > If it is a new API, I think it should be added to the map file and to b= e tagged > as experimental. No? > > >=20 > Is this the type of API that needs to be marked experimental, I think it is relevant to any exposed API(not only for internal libraries). > we should be able to prove these functions, correct? Don't we need to prove any function in DPDK? What is your point? > > Matan >=20 > Regards, > Keith