From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0077.outbound.protection.outlook.com [104.47.34.77]) by dpdk.org (Postfix) with ESMTP id D17162B84 for ; Thu, 6 Apr 2017 17:11:36 +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=d257h50jG/Y6y8kVT8PwS926ZwOKeK+aosZ0vkbsr/k=; b=I9oQo+WwmH468gbAEo2t2fT2IoM5rkV8GbObJqCk3JKrBWzHseVhXmT8QrWJdrbzKivIz7VWh3C+hfwkfyHDOi26X2mY9C7AKEzRisiYCRrJGiNi7CWoVfvqC+LJj7ZvhsEnuXjqJjRuLYyUOKSQZs2CwpT9MMxg9j2KUhZtZ/4= Authentication-Results: 6wind.com; dkim=none (message not signed) header.d=none;6wind.com; dmarc=none action=none header.from=caviumnetworks.com; Received: from jerin (111.93.218.67) by BY1PR0701MB1723.namprd07.prod.outlook.com (10.162.111.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1005.10; Thu, 6 Apr 2017 15:11:32 +0000 Date: Thu, 6 Apr 2017 20:41:15 +0530 From: Jerin Jacob To: Olivier MATZ Cc: dev@dpdk.org, alejandro.lucero@netronome.com Message-ID: <20170406151114.GB21546@jerin> References: <20170406141536.14980-1-olivier.matz@6wind.com> <20170406162355.222dfbf3@glumotte.dev.6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170406162355.222dfbf3@glumotte.dev.6wind.com> User-Agent: Mutt/1.8.0 (2017-02-23) X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: BM1PR01CA0097.INDPRD01.PROD.OUTLOOK.COM (10.174.208.13) To BY1PR0701MB1723.namprd07.prod.outlook.com (10.162.111.142) X-MS-Office365-Filtering-Correlation-Id: 8a12912f-deb9-4846-2f46-08d47cff36cf X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:BY1PR0701MB1723; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1723; 3:WPcoQouur5SiHaeBPpja8CdtoetdUepmRJMDmNEt1oGQXdmnvWhSv2lXgZN5ifdT8Nng8Tr7789MmjVyLM1HZOj97IQc/II7eIiBIYAXKG2tfHYe7JrXWK4hB3Zkq8DikEJkugAo0sgEW/xM5ek6i5ph/so8/HKdbfuUqEYqzh8+fJnCd3WR52LcTsT3rPDB57HMMA1AoGyK//BLJv4I7BKcrPWWu8nKZS8jUBN3amVe4J81d4Ki8K7177tupHTxfjuGZ/XaxCfhFmiiMMFjkaanc9guWmEbqs/GwsskOSWkV5/aXVbDI+mmUm/65a0m/VWWvU/eE71YVvIrpXrZRw==; 25:3Z8wm1tDqw+RRTaMqmXoz1gOUXYCaGHSnF/WS/QzR8MGqGP8KIsS/I2RZZcKDcf6JATOaGZ3Dk2a2/hyQX35PjW7kmXhCiIITe8CRqfVqv+rqFvoZkOCXlogWhRAqboQNrKJMbHWH38rzJzNDus6ocOAIpw2n5TJLomGkhB/0jXQ8SApPZ1SmV/cYGFr9jw/lpUykM4sJFb1qrSpfC3Dir+1KEmYptQQ/EErgb7SdkiAXwoZevbG+uGxyA068BINfe8WrH5bP1YKXNDgf8etHrIyBpjpyEUKwPdS4RIjD0XjWSOXn82TtlstMn9hm9GmqCfOoGUoDJbsK+51vmiFRdzZ4HdXpLULee17iZEHRydUl4pu3h6U9eFlDk8reWc05xJzdBKMhG8DpARKmjkq+Xus6ZizEzuEpsLlYg5EfVi9bu5ysnA8K7A49hyT4CbklUS4YuSzMUSaP5tCO1sXwQ== X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1723; 31:D1IphlkbmMQ4tppW5qDv3xG14PSl2CMkTm0xza+28/I9lI2rdSeg3HBQiYXhfE2FwIqNxwIApJ68B9zPVV2U+cNuUo4mpRNzTH+le80VHls4MvZ4jvO3tg104RNjMlWci3ap0EgWyFDaq4V4DsAUJTY7upVYhb5xI7oN7DVfdN8FHW/NUrv6sNnxq1mw8MNr7JxCcMB14XE6DRJ3qAxGPkEeu7YalhIYHaT/sTXhMpM9LWxDgZpKMblR3M4vxNZZvOamRF67/Do5pVZJ/yTG/gNd8rUvNQ9LSgOeU1ZZPWg=; 20:s/AJo2hyFItiqcHu77F8PIEqAoto4QtGbaNtRQblZeWLvitJ4/pV8ISsuy1LTpRzPrGCskBRk0mI/Zim6PDOYvdX6KMio5sL4UoROuzy2+/u8NlxzfcHhxec5VN+/gNQbqU4jfp6iZ84YzXL1yXOSLH+Rwd7SfDy3jiVyz9aI7sla/tguIMuFBMTfOUXyNzbtBF12V7cMRV0lqw2B6ooU4rBmgHCZ/5kls5BpH3U9dF3K3HAeJmks1/ZfbzNKTrER+v0BLUwALZGeaYbS0s0JntMxJe/9ES108wG0Ftc2Xqa83+Jmq0j7WKZBZd2Y9zh9kkVYsnNw2xsI5TVoP7xMVS+Et6QwPbB0d/SDcutqRpUBGPx91wYRk5g8ptKmczCobfNDrhy4ixxXOKa39vozLHu2eUVz2mZaO7tgTsUPexu+v2R+txXbtG+zTnNu1eBrhVDy86K+ArCqC+2uG5h3aQ+gm/1lm54psqSABsjK3vTnfg3eNytHnBtqUkUbPuYGoaVh3AwzxqofbI8B6brdxsxj1+EcwA4EajbJmu8Nf6X12uqi2QU0+j9uxKpOu0in2fahinzUa+/xsD712V099X/Pn4j8fG9ngvPjD35ul8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(93006095)(10201501046)(6041248)(201703131423075)(201702281528075)(201703061421075)(20161123562025)(20161123564025)(20161123555025)(20161123560025)(6072148); SRVR:BY1PR0701MB1723; BCL:0; PCL:0; RULEID:; SRVR:BY1PR0701MB1723; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1723; 4:jqSEuK1GJiufS3UqWdQlNNu9qIG/Ciu/EjFRdjCVFmXEyDc+wlxVuYOjwxuYe/ndheIssqUWWywIpaeEMBfDrXfhhUAL9dA61GwJDrFN0sfxf7wwfkX//4mrBdcKJfZmVS1/hzvP7STa1JjYpfZk3MvqmlpYNSBiKjOA9Xt8SLIRvjJx2hbKRYFZZCs0ytgsSbjyQRB+M3WU//rmTBoMVxtkaHeZyIr1ZNhhLip16kQW4/g1KmuTEKHm7FFQ2k1HrZXvom9mWpz61kjX1Qsnetv2NmWo3vFswBDGW5wUvRwW8XdoDc3srdRc+TDhasPdcA2fJT/vLjO8B5nFDMRxvFXJXDTmWxqvIsq7HKScb/Wn0rin/qhaG7hhYSrhDPi3qXkFdlcv41RXPlj/eIBEjzVaS7joHL0BOQDuCP5vG2iXD6UeW8C98YJjN9g2KcLHNT8aqCCBku7iEvLeSaonaiN7uXFsKp7CWkhS/kk87zkhY1f5/2BUaaxKaEPh/CvzAnpZPB50moIp1go5yyfXV4EP03Fb1C3d0kt9/KSierVImM1WGA+SX88Q6dRpsD+4pZSIsLq9ZE7Tc/id7JLt7nM51TRcGHWFB9qMkEcx83nlzscp1GjK3zUVJ/Cc2TfKemlBqpMHtojm8aliVDTKzff/rkWQo18eYreg96Pq1WtUoAjCTBaOctVE0yFW/kmF X-Forefront-PRVS: 02698DF457 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39840400002)(39400400002)(39450400003)(39410400002)(39850400002)(24454002)(53936002)(2950100002)(42882006)(6496005)(6916009)(5660300001)(23726003)(6666003)(110136004)(3846002)(6246003)(305945005)(229853002)(1076002)(50466002)(6116002)(7736002)(189998001)(2906002)(83506001)(4001350100001)(9686003)(50986999)(81166006)(76176999)(54356999)(47776003)(55016002)(8676002)(66066001)(33716001)(25786009)(5009440100003)(33656002)(4326008)(42186005)(38730400002)(18370500001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR0701MB1723; H:jerin; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY1PR0701MB1723; 23:McU/8Qb1+42v4G91EnQn7EtSWuFimxhFVILdXpp?= =?us-ascii?Q?tBSmmd/pi4q/5qNw+DaEiPMsJGLRclDLHL5kKlLPbj9brvCZv47ijvbuyp1Y?= =?us-ascii?Q?bCA8RK9stLECl5PJENOpFxBUJa4rMDAXZevLangZ9sFFHAd/87ruZtDevvVl?= =?us-ascii?Q?t0hj6m6DjJQAN+kPhBxq2ZcIcNNSJkZsUp2lnqauVdE6Bfbu6ZinnsJO2fUJ?= =?us-ascii?Q?uTF9yR+RuiQ1o+sEwGoMgXUr4LWKjnt37HL2rxoOhJfppVdpRw8ghefjcfwd?= =?us-ascii?Q?vDocpX0MgeBP0pWcSNvDm/UWbdyl8vXba7HMgZZuoS1gHEt0M6Cw9ECgBk84?= =?us-ascii?Q?8eCX4/btIpfdMMFOqL+pqLX67PMRak1TnMe3raN6buM0LPJdFMFd63Ga3iZa?= =?us-ascii?Q?qR7Nv8GazofPBKugwMt2FodcSOaaMIavj0rVeTL2hTR7wFChrrbNkcEfhZYX?= =?us-ascii?Q?KKAP5bmPRmupGqUG9WYibNtW0pxYAKFviublcgfGKsJnxI7VndiWeg9QSK15?= =?us-ascii?Q?FRSimtM+yAGy1yIlLB5toyKZroAjBepwvivE1vWD5RiPxxo1cs+rq1H8F1oa?= =?us-ascii?Q?nUY0npkRlTb7Quc02d7LTP245ONar6mh8iolHv+OsvmjDgxKMy3/qoVo28yX?= =?us-ascii?Q?uw+SX6Zg0nf/cxl9QyC5wrlJ4Ia5WZ05tUwAUfmZZIwaUPaP40gIH5hmxmKT?= =?us-ascii?Q?Y+47CTvoi1dsK76ROriPVEUTTa3sImUfIestBhA+3xGCMxqCetJuJJTev8ky?= =?us-ascii?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aA+Izcpts46xOAnuOUUC8TvwRpQSrqHi25AGuKaTkBEIZiA==; 24:f+M6suvtjgQV7yQO7aeyeyvxf1Ba0W0jvTAUDKTWSkytlHbQ1pqnamO2qSuFex9/hnYg3OLoDgFMNPEykN3WN9D1SdhWZbqYefVkGz/19s0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1723; 7:2pcavUQvaw1dzqCLdfDGYzR26iTEX2dDk3i2sal5AfN9uvfBZ6Xd0TDBccijvEDjawTBDaF2uKUejuMf6SIT1DA3LyGQeeS9T1wqU1RjLpACTIsKJZ+fPIUMnmS1bKzap6469/6eYtGcN/NyVbIIW6A2xUd0w7UHh7GrB+l2isF7w+1s3D8+88U8f/EDRPKXLH92h8m1ZFW0w8AyrNbCmtpGlk+Imf0lrXDTd4el+C2HA93KlB1j3iQ3bxWOP8moPYZHoJ8pdz/MwclqGrQLoYJrPkbDX8sLCBpmBlk1qd5C+g/whkKp4yHZ3e25DZl62blr8RAG6vTRxUB/tio4vA== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2017 15:11:32.2435 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1723 Subject: Re: [dpdk-dev] [PATCH] common: introduce an integer log2 function 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: Thu, 06 Apr 2017 15:11:37 -0000 -----Original Message----- > Date: Thu, 6 Apr 2017 16:23:55 +0200 > From: Olivier MATZ > To: dev@dpdk.org, Jerin Jacob > Cc: alejandro.lucero@netronome.com > Subject: Re: [dpdk-dev] [PATCH] common: introduce an integer log2 function > X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) > > I forgot to CC Alejandro for nfp. > > Also CC Jerin: I think the same could be done in thunderx, but > I did not want to do the patch since it changes the base/ driver. > > > On Thu, 6 Apr 2017 16:15:36 +0200, Olivier Matz wrote: > > At some places, the log2() function is used despite this function > > works on float. This introduces a dependency to the math lib but > > most of the time it is not required because we want an integer log2. > > > > Add a new helper to do this job and fix 2 drivers. > > > > Signed-off-by: Olivier Matz > > --- > > drivers/net/nfp/nfp_net.c | 6 ++---- > > lib/librte_eal/common/include/rte_common.h | 17 +++++++++++++++++ > > mk/rte.app.mk | 2 +- > > 3 files changed, 20 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c > > index a1ad97ad5..0e6a729ef 100644 > > --- a/drivers/net/nfp/nfp_net.c > > +++ b/drivers/net/nfp/nfp_net.c > > @@ -39,8 +39,6 @@ > > * Netronome vNIC DPDK Poll-Mode Driver: Main entry point > > */ > > > > -#include > > - > > #include > > #include > > #include > > @@ -1493,7 +1491,7 @@ nfp_net_rx_queue_setup(struct rte_eth_dev *dev, > > * of descriptors in log2 format > > */ > > nn_cfg_writeq(hw, NFP_NET_CFG_RXR_ADDR(queue_idx), rxq->dma); > > - nn_cfg_writeb(hw, NFP_NET_CFG_RXR_SZ(queue_idx), log2(nb_desc)); > > + nn_cfg_writeb(hw, NFP_NET_CFG_RXR_SZ(queue_idx), rte_log2_u32(nb_desc)); > > > > return 0; > > } > > @@ -1647,7 +1645,7 @@ nfp_net_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, > > * of descriptors in log2 format > > */ > > nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma); > > - nn_cfg_writeb(hw, NFP_NET_CFG_TXR_SZ(queue_idx), log2(nb_desc)); > > + nn_cfg_writeb(hw, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(nb_desc)); > > > > return 0; > > } > > diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h > > index e057f6e21..eea0054c1 100644 > > --- a/lib/librte_eal/common/include/rte_common.h > > +++ b/lib/librte_eal/common/include/rte_common.h > > @@ -326,6 +326,23 @@ rte_bsf32(uint32_t v) > > return __builtin_ctz(v); > > } > > > > +/** > > + * Return the rounded-up log2 of a integer. > > + * > > + * @param v > > + * The input parameter. > > + * @return > > + * The rounded-up log2 of the input, or 0 if the input is 0. > > + */ > > +static inline uint32_t > > +rte_log2_u32(uint32_t v) > > +{ > > + if (v == 0) > > + return 0; > > + v = rte_align32pow2(v); > > + return rte_bsf32(v); > > +} I think, It will good be if we add unit test case for the same. > > + > > #ifndef offsetof > > /** Return the offset of a field in a structure. */ > > #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER) > > diff --git a/mk/rte.app.mk b/mk/rte.app.mk > > index 4c659e971..2fcd388e6 100644 > > --- a/mk/rte.app.mk > > +++ b/mk/rte.app.mk > > @@ -125,7 +125,7 @@ endif > > _LDLIBS-$(CONFIG_RTE_LIBRTE_LIO_PMD) += -lrte_pmd_lio > > _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += -lrte_pmd_mlx4 -libverbs > > _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += -lrte_pmd_mlx5 -libverbs > > -_LDLIBS-$(CONFIG_RTE_LIBRTE_NFP_PMD) += -lrte_pmd_nfp -lm > > +_LDLIBS-$(CONFIG_RTE_LIBRTE_NFP_PMD) += -lrte_pmd_nfp > > _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NULL) += -lrte_pmd_null > > _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_PCAP) += -lrte_pmd_pcap -lpcap > > _LDLIBS-$(CONFIG_RTE_LIBRTE_QEDE_PMD) += -lrte_pmd_qede >