From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0048.outbound.protection.outlook.com [104.47.40.48]) by dpdk.org (Postfix) with ESMTP id F3B5C1BC41 for ; Wed, 4 Apr 2018 18:42:38 +0200 (CEST) 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=PbOvcl0IctbTAMDU18zSV0XsYM82gBam0p29zloMc8s=; b=PyvikHbLpgBgOPQNHiH5cm+mPAxqEnthx80KmN0WMnjepWs6gy4A6v5xuIGY7uULFmGZNGUi0G8ityD2Fb7poYuKI2lBS9zFNpH23mMPDrzKvYBRCqT2JUIrZR3VgNAXhXxZFM2Bj/9yel9+/j2W200xHlH6cy8Xfs/gMvpuWb8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from ltp-pvn (103.16.71.47) by MWHPR07MB3472.namprd07.prod.outlook.com (2603:10b6:301:63::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.631.10; Wed, 4 Apr 2018 16:42:34 +0000 Date: Wed, 4 Apr 2018 22:12:08 +0530 From: Pavan Nikhilesh To: Matan Azrad , "jerin.jacob@caviumnetworks.com" , "keith.wiles@intel.com" , Thomas Monjalon Cc: dev@dpdk.org Message-ID: <20180404164207.GA21153@ltp-pvn> References: <20180217104934.17291-1-pbhagavatula@caviumnetworks.com> <20180404101606.5156-1-pbhagavatula@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Originating-IP: [103.16.71.47] X-ClientProxiedBy: SG2PR06CA0085.apcprd06.prod.outlook.com (2603:1096:3:14::11) To MWHPR07MB3472.namprd07.prod.outlook.com (2603:10b6:301:63::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cee68ef1-4cb3-4390-cbb0-08d59a4b1250 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:MWHPR07MB3472; X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3472; 3:W32r9FnlF5ACHX43vEP5lVJX73p0neH/tvOJhKyaiu9JcCE+szBP309V3SNDrVU09wcDd2EUOMVRBYYqUbUiVh5XvI76wh1suYm6QWW8a48+1H0zUWfJm2NFOLNtRHKcU4vH8kbV4gFL8QESaqQ8SkHOYFb/VIrNu4nonyTXfCTIZ9Yl50FgcYJ9OY5WdT9umCb7NKaZMk00tZ6/WOKHbWmeqG2kS4Q5VDjtmxBaWbSU4istm1Jz88mlxfwyYOlu; 25:fti13qV2DwHb+CbpqHhK53dJLXgPcdS4DyJIFZ1DjY2Nf3aVE6TVObqb4/1hzu/6OQmYf9Z4VPXw61JNByedBw051fRjfVoWUhDpQE53HFbIBVlbYPZ5CWCDXfkXSGcg3/FhmJX5P3gNC0B8JgjYse6/i85xsH1fN12QWWTNjCNs6bbwTFApLlUW7MtbzzERgr5O0y8F7Gd9iypSUTB9fCltMrdYQZ16G+fqlscVCOUs0vbSVhQSRF/XkCyX5fde5f9obuzb8bx/PZdCGyTXDJBIzRKOCGYiwXGQ95dywNtLT2215YXCzzQLmlJTAswThnCGUkLw9Lvx2geEpiq6TQ==; 31:R2HYUixmFV8QoqJoVLakQC19OwpY4pgdvh0ZndrNpymEyaHYJ+zULmHEck8D1hTZF8ahdNvwAWBaGI4TvnttZNTQgRMGEvOY2BOk6im0gw2UUL0UXXLTs+vuacOTl0aVGyBLSzWu1WG0eEG25K/OQL5ENvi9MFHHrehRh51dcL7nSer/KTRZdfnQ+SikutHlffxPecVNXZ/GRy/9FUHqZKyGzXn+NJoK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244540007438412); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231221)(944501327)(52105095)(10201501046)(3002001)(93006095)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:MWHPR07MB3472; BCL:0; PCL:0; RULEID:; SRVR:MWHPR07MB3472; X-Forefront-PRVS: 0632519F33 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(366004)(396003)(376002)(346002)(39380400002)(199004)(189003)(186003)(305945005)(6246003)(42882007)(55016002)(105586002)(7736002)(446003)(50466002)(68736007)(47776003)(97736004)(53936002)(16586007)(110136005)(9686003)(11346002)(58126008)(81166006)(8676002)(8936002)(66066001)(25786009)(33656002)(2501003)(1076002)(6666003)(476003)(76176011)(16526019)(52116002)(6496006)(106356001)(229853002)(956004)(33896004)(81156014)(5660300001)(4326008)(316002)(72206003)(26005)(2906002)(6116002)(478600001)(23726003)(2201001)(386003)(3846002)(486006)(33716001)(18370500001)(107986001)(42262002)(357404004); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR07MB3472; H:ltp-pvn; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR07MB3472; 23:ud71AQybFGQIMi2U/4t5wgMTpulloWDY56cCouqo3?= =?us-ascii?Q?jLJHV/4yIlbniIw2czbNmWguxGiKIRSWReRZ1VQG6OSK4FR5Ct3vD9A7Weva?= =?us-ascii?Q?rQJaIMECAFVdJ+SFswRxT29/RzfuB+XfO0Qg+2v1Pb8tEs+mFUCm9D1b9Mz8?= =?us-ascii?Q?yT6xlKQVcwavsolVzrLoupT4TxSknl4F78eHDQ1+Dz35BDZ1c0GafFArVRcJ?= =?us-ascii?Q?Zj686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E9cAr3T1orCPPHszg==; 5:a5cSxoM6XIcvqMn6GFPTVIRVrjMcKPuHSfHrKEzeRXEkg1bApVNDpdx4DB+OrRTts9/x8ugI4tFQ6PHLE4YIitonpRNis8PkDWYBCWqTg7qZru1RJB7ZpaEXOXvAWe9hay0tpU6yPzgQt4JlX2kxn8VHz7r7LgAw3HtO/w6IU+o=; 24:OslMG5ZMDRjqbiQO4MUn1r7E0GTnNwKl3O1vAADlv06zY9nEbf2phdgc0EnhGlWqNlROk0+NpqO81y13LK6tZLEAhNFpVKWfR/lN8QGc3Os= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3472; 7:Xvp+kXZ94KRfd38JrbSP7uA6JNqFqg/Tco5S+otZutQY6iX7yHvJFKJZJX5xCf2ejPCZHC7hvK1+Kh3ggpt8/i7bDlRbrmtcgELmcCZpmKz7I+kXVp7sTEBrhueKJbayJHwHorZ6liS43Z2hiQhrJspJfaQRjH836bFW/v1DbxJ0QGwPPxADoxXx0DAExfypE9IzoE9UBWrmBYHVr390clRwsBj/Pgh/szdMe8Mdpm2Q7yJvW1IxRlRifqBaCNd4 X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2018 16:42:34.7367 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cee68ef1-4cb3-4390-cbb0-08d59a4b1250 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR07MB3472 Subject: Re: [dpdk-dev] [PATCH v3 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: Wed, 04 Apr 2018 16:42:39 -0000 Hi Matan, On Wed, Apr 04, 2018 at 04:10:36PM +0000, Matan Azrad wrote: > Hi Pavan > > Shouldn't the new APIs be tagged with the experimental tag as agreed? Can't tag it experimental as it causes cyclic dependency (need to include rte_compact.h). Besides it's a simple proven math API I don't think it will change anytime soon. Thanks, Pavan > > Besides that, > Acked-by: Matan Azrad > > From: Pavan Nikhilesh, Wednesday, April 4, 2018 1:16 PM > > Add 32b and 64b API's to align the given integer to the previous power of 2. > > > > Signed-off-by: Pavan Nikhilesh > > --- > > v3 Changes: > > - Move commonly used code to rte_combine(32/64)ms1b so that it can be > > reused. > > > > v2 Changes: > > - Modified api name to `rte_align(32/64)prevpow2` from > > `rte_align(32/64)lowpow2`. > > - corrected fuction to return if the integer is already aligned to power of 2. > > > > lib/librte_eal/common/include/rte_common.h | 92 > > ++++++++++++++++++++++++++---- > > 1 file changed, 81 insertions(+), 11 deletions(-) > > > > diff --git a/lib/librte_eal/common/include/rte_common.h > > b/lib/librte_eal/common/include/rte_common.h > > index c7803e41c..7e147dcf2 100644 > > --- a/lib/librte_eal/common/include/rte_common.h > > +++ b/lib/librte_eal/common/include/rte_common.h > > @@ -223,6 +223,51 @@ extern int RTE_BUILD_BUG_ON_detected_error; } > > while(0) #endif > > > > +/** > > + * Combines 32b inputs most significant set bits into the least > > + * significant bits to construct a value with the same MSBs as x > > + * but all 1's under it. > > + * > > + * @param x > > + * The integer whose MSBs need to be combined with its LSBs > > + * @return > > + * The combined value. > > + */ > > +static inline uint32_t > > +rte_combine32ms1b(register uint32_t x) > > +{ > > + x |= x >> 1; > > + x |= x >> 2; > > + x |= x >> 4; > > + x |= x >> 8; > > + x |= x >> 16; > > + > > + return x; > > +} > > + > > +/** > > + * Combines 64b inputs most significant set bits into the least > > + * significant bits to construct a value with the same MSBs as x > > + * but all 1's under it. > > + * > > + * @param v > > + * The integer whose MSBs need to be combined with its LSBs > > + * @return > > + * The combined value. > > + */ > > +static inline uint64_t > > +rte_combine64ms1b(register uint64_t v) > > +{ > > + v |= v >> 1; > > + v |= v >> 2; > > + v |= v >> 4; > > + v |= v >> 8; > > + v |= v >> 16; > > + v |= v >> 32; > > + > > + return v; > > +} > > + > > /*********** Macros to work with powers of 2 ********/ > > > > /** > > @@ -250,15 +295,28 @@ static inline uint32_t rte_align32pow2(uint32_t x) { > > x--; > > - x |= x >> 1; > > - x |= x >> 2; > > - x |= x >> 4; > > - x |= x >> 8; > > - x |= x >> 16; > > + x = rte_combine32ms1b(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_align32prevpow2(uint32_t x) > > +{ > > + x = rte_combine32ms1b(x); > > + > > + return x - (x >> 1); > > +} > > + > > /** > > * Aligns 64b input parameter to the next power of 2 > > * > > @@ -272,16 +330,28 @@ static inline uint64_t rte_align64pow2(uint64_t v) { > > v--; > > - v |= v >> 1; > > - v |= v >> 2; > > - v |= v >> 4; > > - v |= v >> 8; > > - v |= v >> 16; > > - v |= v >> 32; > > + v = rte_combine64ms1b(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_align64prevpow2(uint64_t v) > > +{ > > + v = rte_combine64ms1b(v); > > + > > + return v - (v >> 1); > > +} > > + > > /*********** Macros for calculating min and max **********/ > > > > /** > > -- > > 2.16.3 >