From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40053.outbound.protection.outlook.com [40.107.4.53]) by dpdk.org (Postfix) with ESMTP id A1F0AA48A for ; Sun, 18 Feb 2018 07:11:21 +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=WTN8FvTER1WQzWTVMFsVkGgdM1+AxMddsZyDwjSuEfM=; b=QcVVMcwIeRzAhji0nM9Do8yP4W62E7t59K2z8EE/ZC9meU9i40rHGwHAfkci2s+OP6k5l6Tlm1Vs1hot6s1yugOKWhlNppZF634QzwkOImx50LAyKbL2RuLYYN5GLaX1WLNA+BVHHAEuiyKlTL9m0ag18p+kqVXHclU6ibjrNuo= Received: from AM4PR0501MB2657.eurprd05.prod.outlook.com (10.172.215.19) by AM4PR0501MB2340.eurprd05.prod.outlook.com (10.167.123.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.485.10; Sun, 18 Feb 2018 06:11:20 +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.020; Sun, 18 Feb 2018 06:11:20 +0000 From: Matan Azrad To: Pavan Nikhilesh , "jerin.jacob@caviumnetworks.com" , "Thomas Monjalon" CC: "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH 1/2] eal: add API to align integer to previous power of 2 Thread-Index: AQHTp90bBNb9stnSKESG8ExLeCGnzqOpqFKw Date: Sun, 18 Feb 2018 06:11:20 +0000 Message-ID: References: <20180217104934.17291-1-pbhagavatula@caviumnetworks.com> In-Reply-To: <20180217104934.17291-1-pbhagavatula@caviumnetworks.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; AM4PR0501MB2340; 7:VNtoChyIgdn6D2fOFzRbrCPJJNIg3DEoRPX/78uqYW1tPtVP18rYze5J/yvAzkOWj7k7VJoGx4LXiSt1xeMtZ6zNXTf+1BSKCjwNKoim2xydXu4RN5Ms8HXnz/v2JoF8o9BDsisk0TtVWWKzM1lFSVfwaePuBT/+/2w/h2VUBANUq2KBfECbgRNoii9NjcVsDtYmlrRyRVz1KKJZe0Uj0tA0i9zavmM09bzxi/NbBWPMF1LRm/2Eit3MfhKXBiVV x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: fe8a2cec-4640-47d1-9d49-08d576966e06 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(2017052603307)(7153060)(7193020); SRVR:AM4PR0501MB2340; x-ms-traffictypediagnostic: AM4PR0501MB2340: 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:(6040501)(2401047)(5005006)(8121501046)(3231101)(944501161)(10201501046)(3002001)(93006095)(93001095)(6055026)(6041288)(20161123562045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011); SRVR:AM4PR0501MB2340; BCL:0; PCL:0; RULEID:; SRVR:AM4PR0501MB2340; x-forefront-prvs: 058707456E x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(396003)(39860400002)(376002)(366004)(39380400002)(76104003)(199004)(189003)(33656002)(2900100001)(25786009)(106356001)(97736004)(2501003)(5250100002)(5660300001)(66066001)(2906002)(14454004)(86362001)(8936002)(305945005)(7696005)(478600001)(7736002)(99286004)(81166006)(81156014)(6116002)(3846002)(3660700001)(26005)(186003)(110136005)(76176011)(102836004)(3280700002)(74316002)(105586002)(316002)(68736007)(6506007)(229853002)(53936002)(9686003)(55016002)(6436002)(6246003)(2950100002)(4326008); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR0501MB2340; 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: a8iTNRF1zA4j6AOMECyIj372W0cQwPQVHpYvZ9xmEbhd/DasVdkPs16/AKub4pIegSAhFkoWHHX5FEwwd7AY1QkpAkoYfZobfDrfnv+GerF9Fokh3Z4GF/eVC+KNqX5lGMBQ+3VcCX8kqfkH0wDr+M+LNG2HT9wqNuY8u59Og7k= 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: fe8a2cec-4640-47d1-9d49-08d576966e06 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Feb 2018 06:11:20.5267 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0501MB2340 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 06:11:21 -0000 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. >=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 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; > } >=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); > +} > + Same comments for 64b API. > /*********** Macros for calculating min and max **********/ >=20 > /** > -- > 2.16.1 If it is a new API, I think it should be added to the map file and to be ta= gged as experimental. No? Matan