From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0056.outbound.protection.outlook.com [104.47.34.56]) by dpdk.org (Postfix) with ESMTP id 4B2021B222 for ; Fri, 16 Feb 2018 22:37:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=js4JNgqooxnkt920xQAyM3WBJrpmHiLDKbveUpkKOmo=; b=Qu6apa01xsxRzvUwzCFUNTpfdhmtD5IDa6leTBcZy+ESJiIB/C8pYE6gN8f08u6XgguMy9e8mTaXmnC2jjoM0oXlur48ayXu7CTSWgXvS13QJF+X+7n4b7EZdKv/AHg2cozcey0izeVVd2MHfirU4eBrlTI8ewHBWByAY3OIZCg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from localhost.localdomain (111.93.218.67) by DM5PR07MB3467.namprd07.prod.outlook.com (2603:10b6:4:67::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.506.18; Fri, 16 Feb 2018 21:37:34 +0000 From: Pavan Nikhilesh To: jerin.jacob@caviumnetworks.com, santosh.shukla@caviumnetworks.com, erik.g.carrillo@intel.com Cc: dev@dpdk.org, Pavan Nikhilesh Date: Sat, 17 Feb 2018 03:06:51 +0530 Message-Id: <20180216213700.3415-2-pbhagavatula@caviumnetworks.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180216213700.3415-1-pbhagavatula@caviumnetworks.com> References: <20180216213700.3415-1-pbhagavatula@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: SG2PR01CA0090.apcprd01.prod.exchangelabs.com (2603:1096:3:15::16) To DM5PR07MB3467.namprd07.prod.outlook.com (2603:10b6:4:67::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 392893e6-0afe-43ab-faf7-08d575857f25 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:DM5PR07MB3467; X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3467; 3:GCto5f9sGQtZT/7U6B8jN7TVRJ2UGtEFaerBmfRybCLJftoCvf+RgVPgfyAqKajmGeS/hvjvU/Qe8rl5seHy8b+6iQeHYM+wGYn+CzY61W+cQ8B5t0sgewJYLCNg9USAe5ZG7c2GPmPAbVHmg0W5qrJE+ASKzDsLpPxfNtdDUBYdLoKCRkWOhKk4D2XyzQOjnXGj2cLk88e3A3/Cl+5Fd2JF+mkhbm72f1JewNUZjKG1A24IZhEkbAciiCCOkmm2; 25:DJAy+1Je+O4DZgZDDsWb9Jj097gfA10doGv4Bwnln4VLclWqFCKMYuxhHtMqOsHtnmUp3fumyKyACM1BbC2eHgQGbaMOHWqmsQSBCRkkm08XQ9C0ZalodwvBEdsmpGk37NVNr2s0ncd4gb4PbKAZ+NGcniGPK4MaDidp9v7c4IiCQvpOJT+j2SlpzFTUABvqViTlfwJpL5bdrGNcaUJPvMzkCsNmJKFBzA8ClXUnNdkdHFaXwmU+LEKWTFYGVUHOa6nR5iUPgEt8DAGbgYDPK/LvwRzQqcXgao4GGFrKd1HxnRLEK8OmrgG9xI1fysEkfR2DMGWe8HIQwy3vlqALhQ==; 31:xj8FoXXvmzPE8pQ7EAi8zsPd75DczMeC9Mdxovc3G84+8JgjxAQYanfWOXfjcbjSkX9+o0Yb7J7+CDdQhCggRw+7MlAt03AtHIN7CrZ1TIMy9csNqclc08e+Fr/7T2Qve/vdW8I2nKORXcNSq44sWcYKDvtVJ8i8MI1e+bx9OW1QmBNmO3mIE8JRMs0Z7S1EGlQQHvTg7ozqC+ymMcMScxCvxyl+RnpJacnbgOMjlJ4= X-MS-TrafficTypeDiagnostic: DM5PR07MB3467: X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3467; 20:2gvSDC62es/GrJGgaWzn7IoYipruQKzVTwe+8RSVoEpJkaKPdKjOeppFw8CkuQ7HPh5r9qqN8BrYaDVaMr18VooAC6nFVCd/oZqTLAtwEfA/rlBQWSt7uJgrUwq0rms4EYYzjgvq2F2Bz4/vsQc/qDITH/QpTdWlNmnuqgjaLX9CFKwSkulZKBwTl93kPJc98qBaSwm4czTrm3/6QDLdQQHoCbkgRTOuOq97UTLL0mnUn5dqYn2VYP4KC3lL49V8sXZ+Wm3exLDT8vgp/lgj2iB9OQW8WZsSzLtDeUdpDXS/I50NSWs2sYhOVXHpGZ12KGNIftegZs/CgPBB1wSUDFJv4Pb9DvIMoQ74oUUnQsL0FLfadQGDCViJM8jXxbSJ2rzQA4SgSeImtCpOs1V1WcEbax1PDYyZOfU0C/VPW4MdDxjetAUjErf1veB1vyOrSPzfiAwUxhGH7e0i7UZjA6M0sRnYp2DdTN3uTznJJiC5byBntT/Lp1cpm43cQ87aNEk/0ASqWui2OUwMN17t4K1H1gAAeq3mPrdWRWmdHBvdGrM0Z4mxM+hk6af5GumjXTZ5lHJ/vVHjwcc1r4lsKCvc0x9Zv3RToh20aFklLhg=; 4:lkLH9jnfvZLPJNvzBX7ocJWWuG7d59xXlrTopsJh9tUy4ZUf9hgtzrn8/ji+kyWqwdIECZYcUBHmVAayivFD+4yS/CmSv3DtXALiMT7EAYaUQJynFcNgyEMSZ7c/7sWls/2gkIsNf7nutzpxbwQOgqOLdBuKPYvdnADwwifdREyJsSTBJT02y78YB/hUjbuOnqeM7cUBWGab9lgs9t19gmGVHdRFbUhNBteoi3F3INiRZ3DzjrKe/KR0+gmRklV8+39Bh2cp6+knxHCtCiVfLA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(8121501046)(5005006)(10201501046)(3231101)(944501161)(93006095)(3002001)(6041288)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(6072148)(201708071742011); SRVR:DM5PR07MB3467; BCL:0; PCL:0; RULEID:; SRVR:DM5PR07MB3467; X-Forefront-PRVS: 0585417D7B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(346002)(366004)(396003)(39860400002)(39380400002)(376002)(189003)(199004)(6486002)(25786009)(2950100002)(386003)(6506007)(53936002)(42882006)(5009440100003)(4326008)(107886003)(6666003)(6512007)(16586007)(106356001)(316002)(105586002)(36756003)(478600001)(2906002)(47776003)(6116002)(76176011)(3846002)(1076002)(97736004)(66066001)(8676002)(51416003)(50466002)(48376002)(81156014)(5660300001)(68736007)(8936002)(52116002)(16526019)(26005)(305945005)(1857600001)(72206003)(81166006)(50226002)(7736002)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR07MB3467; H:localhost.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR07MB3467; 23:nLUXKQUMUYQBnWBQSGAU7+/JnCfBUFIKdHrKvvL91?= =?us-ascii?Q?Um2kJgLMVULQ2oQAsaAvdYROnTGt7PQafK2CwoDcxF3rjf6jXvgFqxzSrATp?= =?us-ascii?Q?O+dyhLJ1HTB5TOinqQvT+E+GMm3OelcLb5sveM/zWWh33GHtsOUjYlS0M4Me?= =?us-ascii?Q?doY/kPUlVD/qv9ByFGC3UM5NIXR/B7Ds1UdHfiSSFIPUMnAc3PiL+BoKYtFG?= =?us-ascii?Q?AJ3ppdTvL9R7l63BFrs++xRCIrosytNPwgcU4UGYEDALCaEuRW43AEdsecgA?= =?us-ascii?Q?eKyM69VCZ04mClvRdWHo4dms98sUtv9VrgpbPaMKltCZ7YqeWLCyA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kDbDURFXSndXVVhoNSMdBmoHzuA=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3467; 6:vNtYwwsVPwTnqpPntJwO8BTPt2WnN6KhBbaGXzVXC77pjVuknAJBGMhCystO7AV+NMeTprHdabjOJa8WV8aOTwHrPL+wk3aMef2BTSan9sCHakT0qw1hoD3zp3hqE69CS7ftnEkNxSdpDwfLguoFRtyFYAoIV9FZUVObdyPxTOTScC6ArzqQQ072MCl8hds/aj5TLmTpY57yFx4ZDYJ3ATQdIebri2PAUr3oUeQDNp7+k0yjdU52wYhNlFMYbFUI7SQAciGmgnoZhYnZcesuFwRRwxE+Z1xT1d7V3Yqea60uzRq/dtBLVmEYxSxwEMkCWsWXMQNYIzA1C/75ryQN/y/kuuqjs7kiC5SUk/R1iMY=; 5:zV0ltawQeh4s2N1kNNMTnCMacl+IIvrlF0/LkGusGqvwEqG/e1EfhDQdRneTgbpiMH5CNnfZXNS3BGHa3a+hNh54g37sI6QWNORilbmu3jOT1HFT/TfUPFpQTTnYMLqrVp6wIF+Oj/JQWUPNPxfUEmQLEaX8/nx0qZnbuKtkUAU=; 24:QctCAIf0r9ek/+NZT+MzgEiNvA8ELu+ogN+dM9K42An3ccDi/aC4uXDNJqLWwZWdsD36TVrweS2DcAnVMGRo0byPVj4gxKaDNwKp0fWiFA8=; 7:ALxqfgTlBmEprHYUh0Mx4IPIBo2s/lMOhMPtv0ckvHXlVukt7qH+2ReahHhvR8cwyER8zroZHzt7KWIZ0H+rhWx9TGh3H56kS721NVipu4b5ruBOd9wXAT3bdR2omI7mmbIdyIIPBaJlSVusAbYwjcTsi0aat9+EIluGSS5xc+5TeTQEjynD2gAIRSyvD0DcBaPTNqMgXozmoPF9BmiaoVcwIpZoiPhRCIUeHAKgNxu9z9Uzqd+P0664mbSxfdSU SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2018 21:37:34.8495 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 392893e6-0afe-43ab-faf7-08d575857f25 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR07MB3467 Subject: [dpdk-dev] [PATCH 01/10] eal: add API to align variable 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: Fri, 16 Feb 2018 21:37:38 -0000 Add 32b and 64b API's to align the given variable 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 + */ +static inline uint32_t +rte_align32lowpow2(uint32_t x) +{ + x = rte_align32pow2(x); + x--; + + return x - (x >> 1); +} + /** * 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 = rte_align64pow2(v); + v--; + + return v - (v >> 1); +} + /*********** Macros for calculating min and max **********/ /** -- 2.16.1