From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0068.outbound.protection.outlook.com [104.47.40.68]) by dpdk.org (Postfix) with ESMTP id D443A1B015 for ; Sat, 17 Feb 2018 11:50:07 +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=uW7VOsTejl8/gyECtBYKnQfJ3ocPuTAMKoAHYC9ng2g=; b=MRx3gISlYVlS95i+l0C8EVEYqOuoT724sppCvPJYfFOSeQL0QDC3cRu1AzU4EyZGMI4T3gsSlgmyoeaFYy8gkY08LVs3sYaCiSv1PiAB0ck9NbajqONFENnvVE1CpAPX/vsVncLsGUAQ02putQI0e4/j9ZboCih6z7bZTPGA0OA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from localhost.localdomain (111.93.218.67) by BN6PR07MB3459.namprd07.prod.outlook.com (10.161.153.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.506.18; Sat, 17 Feb 2018 10:50:03 +0000 From: Pavan Nikhilesh To: jerin.jacob@caviumnetworks.com, thomas@monjalon.net Cc: dev@dpdk.org, Pavan Nikhilesh Date: Sat, 17 Feb 2018 16:19:33 +0530 Message-Id: <20180217104934.17291-1-pbhagavatula@caviumnetworks.com> X-Mailer: git-send-email 2.16.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: BM1PR0101CA0012.INDPRD01.PROD.OUTLOOK.COM (10.174.220.22) To BN6PR07MB3459.namprd07.prod.outlook.com (10.161.153.22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a79ea11b-d6d8-43f8-41ea-08d575f43423 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:BN6PR07MB3459; X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB3459; 3:37ox4WSXsfAZNgcvjlT1mXCwc9lp/kZo+D/R1emq/ov2oXlsmOUt58BBwNwhpwmRF4dFKiGCaXlgj35355crh1oHzFVvG47E2rz1Q4nMKO+y0n143BcdBmqsUxcqhIHd3SKH2ETMsHsbdPbt9qkZX5mhOSobqJmO3QJTTNlgix30dKOTlN40s7cMCObyYPzzDk7oB1lTjgAYeyvgE7JQNlTor87Zmoj9bW0bZyikGtV1T13fszPkbDvRbA2+EZN/; 25:7GCSWiM6wwuvn5ce38ronIUKLio9cwMG2BqZC63sKyO8czhxKrMY+B+zEbWHksC6Di8gxN4YCFSfMdpZvUUWBx2wBIaJODOLXvsCQpeipHR+xcNij7VR6WpfADbD3BUd201QACX+d7P8/3UpEiSXcWwgTJDEB6cXztvK4dCvLMHoj3cpiCjd6VnIBGzkoq36IPTHpMDBNZvw05zlk/HgusXgqpNimYczYNkQbfS5E49IEcjBVdgKMMp3L4XwloNVtUGLaslfXAscQKFRdvOldNIJOFdcu8zcY7ZKJDB+X4qcpWHSUWOXjyiM1J998WCl1NrPUtwvb5sa7X23A9CzXg==; 31:Ee3QxU74Moha4Ts9/FJJU48lbfcey6XTz+7L7cLM3vjzylnR7dMawmn4OHCaRoZ1opzke+XxWxPha28htt6Hcu2cwHnujAnotwS7ikjMdzrC7ZMqERiwFPzhKQs/ev1lupaeWqq3DNrxwUmYZgZmJt140ifY53Uugr32D6NmroMD8HhNZZXPQKW/FAFHDZEOAJduUNX34xnyKXl2VmKI94XhYp4+LPdbcQ4D83bQdqg= X-MS-TrafficTypeDiagnostic: BN6PR07MB3459: X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB3459; 20:5MGk1ae9BSGhAxnZfbBJb4zom9YBjJv5rRud3BLkNHNjHujSCNK/76b7ukYGmoaGsekMt8zaM7TndlD08pMbloP74606ELCGdFR9Hw29p3TVyrrZYKtKNu5BqR2LUJ8Psmj9AsKkgKq4iutEhK2MYR/DSts9h9qtHO3jsTbkGEC/BGZOgY/Kgq5K+8wkGLmaDg43SvJfGduxM4Q4owbUfnbvAZ4dbmqxaZ+DykkGi+LKTvTgtwOM3Erk7+whZJRa9UFjDFAN5KX2pC9mdPdcYz/kpfh+wYemv8zEfWJi0mVzl3v2gNxV6yrKsdTCdeqPII8EEP7GUVtT6Lr3CQo6IHdqHBuDRD9YlOL50Pyndf703yo2JmrUoV+2fE+Dwb8pM7ngz1rjOUHYFFyJ5pii/OMj+EYRRRbwxy7nQGVAr0sDIxu+TY6pWrgPzC8BrgNeGOpUYWVgQjbmCIW+uhoWk0zwSQ6qslYViZQ0HLeSQuiqyYT+a0/ccSgZDkflIhr0HnLbSF7aYjWcvrpT2LiLlgJr/x8UgZZl7McEROM2m55ZovwU4jOtvCm+CCrrSN6/EomJulkBItio8CSFEOUFrT/MMIDuZUaOac0VkjcYXtY=; 4:WWVfuUOIa2Q1F32/ZYMaKmswmAvsBkAjab78Vim8eJxsU33S4f1R4Om2lx87aPxgXehmutvOtdpFtaOOI1yerG4SCStGq1clB/3+TzIWIvsBRtdDs5cCB+e0oOtACk10bQYwQqN3AY1QRcaddHDhdvJUSsZjn3cWEtZp1Qu69XLtsvXTk4BVWndpE4aMlqbK1BuIvS8EbJpT6l3JNGQBvsX2ellr3xNVGLcLCnBO6xJprFud+xidMZQGO61/vGSlp1nSqSSlxvel7+qpXb2AoA== 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)(3231101)(944501161)(10201501046)(3002001)(93006095)(6041288)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(6072148)(201708071742011); SRVR:BN6PR07MB3459; BCL:0; PCL:0; RULEID:; SRVR:BN6PR07MB3459; X-Forefront-PRVS: 058637CA05 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(346002)(376002)(39380400002)(396003)(366004)(39860400002)(199004)(189003)(16526019)(50226002)(72206003)(6506007)(386003)(81166006)(50466002)(48376002)(1857600001)(478600001)(81156014)(8676002)(8936002)(26005)(16586007)(316002)(66066001)(51416003)(47776003)(97736004)(52116002)(7736002)(6486002)(5009440100003)(5660300001)(25786009)(4326008)(3846002)(6116002)(1076002)(107886003)(2906002)(105586002)(68736007)(305945005)(6512007)(106356001)(36756003)(53936002)(42882006)(6666003)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR07MB3459; H:localhost.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; BN6PR07MB3459; 23:tl9ELKYRv+0OCxcgtglpsDVJdzLS7WaLf3rld6TKS?= =?us-ascii?Q?2raszPdYUsJ+mPn8m5fjRihx6z3Kk7iTqLbvGMSgZJVJOtxwb/gpasaZyFDJ?= =?us-ascii?Q?McQgLh8uAvJQMH+QGz4MBnJhctVoY5hStBB3wzGo26nvspi0rD2XnpB0U20F?= =?us-ascii?Q?P2BY1pLJ7aLoHCE94OAzruNgndtY63G205hBDa4SmTzeItfxqWnRao7AzQYy?= =?us-ascii?Q?yxcOKMzABxzViurYAyniQIBLtfy63HNqXRy0qZgecjJwIqRnKFeYEcT1oJ6u?= =?us-ascii?Q?86b/OpO3RLZONwXx300Uz1IToIgJISywj8EZLPBmJn2pvEqJGSZDpt2e/UwU?= =?us-ascii?Q?Tv7sQH/jUcG9hJl3YaAJ1eAaKlClb67l36WajotheDVZjn/0IFuIH2TF9QjF?= =?us-ascii?Q?2qEEZQHInlN5m3/uj+mI3OjlrKhG0s1/c6iRtjM4Ncv9Q4c+ias6EMmbZQwU?= =?us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ZvJDUmsHTkPBMzlKCGV8Y4A/6pZrT5C0xUoR/Iy/UN8+LqBlYxux4h31XradEC6u+xYcsxFzflvgSJy+rqPvz77b8xldTTwu9sT8Und0RuwIV0KsEKdUOF8UBozIqLbyWQMSUsv/8rIYII/4ONf2N274GXBahs1Orxh8FbvhZ3CT79rTcQIQElINFrnLJ3RtPMHDa+6wFzc8EdVbatj9FEm2yvQjdvrYvnN9wLGOA8XOxrgfVU=; 5:THe/6U+yRz9aN/plnhMr9tylzh72DnRcospOFxaFXay0828wxKn/TSnwvYe3ynDVIX49nMK3AmR2UgcXLVQtLMrFV9dOsjaFLT0lZM7rp6+TKMNV/49gvF0/e1B7srzEQpQY4huzT7GMqBM3DSc5U3r/ai19+7kk6l5nJvBCquU=; 24:K28K0oEye2kRVXtUYUaLKItqjq1SpCbWA/tFg6/KSQwmHeSMY8EVZ6K4tYz9rNwHfFp2joJzHLw4IM9NfIrci+vf2aLYZLEXKrjob3u5aIE=; 7:7YtmoaQ9K1ds0AVaGlnVQso/EMLduN910W5FMhSA6Qmgob0d44ZGF69ioIwxwEy/DDlGfg7WE4AWFHq77CZ3r1yh36PpHKGHagWWqymi58+lVt++dGSGM0SV86XE3A5w5mJ31Vhy3DP0G37tKXbL+WeowCDBY5R+vuUR0Z1RTwONTt3/lr1dznXVThdMDjR3i1z9zIezXnuGGRHIYjLeUgfuSDwt/TMnp6AR38WnnO8Z+eqgg2XMIgmqjdnFBEJ1 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Feb 2018 10:50:03.3677 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a79ea11b-d6d8-43f8-41ea-08d575f43423 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR07MB3459 Subject: [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: Sat, 17 Feb 2018 10:50:08 -0000 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 + */ +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