From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f179.google.com (mail-wr0-f179.google.com [209.85.128.179]) by dpdk.org (Postfix) with ESMTP id 3D8322BF5 for ; Thu, 6 Apr 2017 16:23:44 +0200 (CEST) Received: by mail-wr0-f179.google.com with SMTP id t20so64814319wra.1 for ; Thu, 06 Apr 2017 07:23:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=57pMKNhACUfoXRYM3spDVmG3gL6rpsLIo92rCvQg4H8=; b=ShgOHi0oGsLg7Lw6p7sagYTVxD95RhujZbwBzBtUvUyJgtUmbX1AECKKRr3O90+1FQ T94Jfg+Ji3ajSAYrFdKE5+oPv7jL69D/Cz7FO/Jv684gop5w8Lkjyc5lUKFVWyh8fJ63 17fEyXvWTmBwa7Qqu3+STW13ctYDz/yeYsSelqVlT4exfXc0nbFGVuaFbb0ka2N9d6wJ oFKPMzaP8HpfATJOBQnGZWXhSDdFJ+Bp4eMNopohw3hMTf2Sbi2fpIsHFFdqDrisNeRF cMZtP1dzUYHedklrTOlDNJn/vbY+5Ea3EMuer1m+GKp3t4cS5GJOzGq31BTzkTAguM3K nmOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=57pMKNhACUfoXRYM3spDVmG3gL6rpsLIo92rCvQg4H8=; b=i7GWVAtHaNfkQPHn/TzobQnCLr0E0v2bCwiQ4gR41glEruhvYeRT6YZpdHLzWbFoER 3zPrWbFvpHfsb1zOxumu2244NaMDBYOAYkQxV09pJ0Aw9AH3p1hSnAVpFSiVswYyzQzd rLMhY5rCKq5r1TC956hdbvxC49jA6enaU4AffaDIqT63jEjuyfckkDZN+Lfsd1rZ9J9r bu77nrfSeOPek/sOJUdHWIn1X8u6dwf6Ys/N5L0my9mGZMDdq2x4wqWBCIMJBD1BD2I/ jiS5jt04roygx6yG7i8PB/Tp6zYAtnZhkLMuEZTekrrAQnAQ0rqmgmzQ1gEF31UzM6AE wHxg== X-Gm-Message-State: AFeK/H3sE+YVWwvPKy/MrLfQ77/Tah8Xg9pj9f3nr/c5jyf82hvSYCdeeYZglNO4X5VdllTo X-Received: by 10.28.195.214 with SMTP id t205mr23178605wmf.104.1491488620754; Thu, 06 Apr 2017 07:23:40 -0700 (PDT) Received: from glumotte.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id e129sm26636619wma.13.2017.04.06.07.23.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Apr 2017 07:23:40 -0700 (PDT) Date: Thu, 6 Apr 2017 16:23:55 +0200 From: Olivier MATZ To: dev@dpdk.org, Jerin Jacob Cc: alejandro.lucero@netronome.com Message-ID: <20170406162355.222dfbf3@glumotte.dev.6wind.com> In-Reply-To: <20170406141536.14980-1-olivier.matz@6wind.com> References: <20170406141536.14980-1-olivier.matz@6wind.com> X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 14:23:44 -0000 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); > +} > + > #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