DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev]  [PATCH 1/2] test: add unit test case for rte log2
@ 2017-07-06 14:20 Jerin Jacob
  2017-07-06 14:20 ` [dpdk-dev] [PATCH 2/2] net/thunderx: remove libm dependency Jerin Jacob
  2017-07-10 12:29 ` [dpdk-dev] [PATCH 1/2] test: add unit test case for rte log2 Olivier Matz
  0 siblings, 2 replies; 5+ messages in thread
From: Jerin Jacob @ 2017-07-06 14:20 UTC (permalink / raw)
  To: dev; +Cc: thomas, ferruh.yigit, olivier.matz, Jerin Jacob

add a unit testcase for rte_log2_u32.

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
 test/test/test_common.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/test/test/test_common.c b/test/test/test_common.c
index 6e803f5d3..ae3482da7 100644
--- a/test/test/test_common.c
+++ b/test/test/test_common.c
@@ -33,6 +33,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <math.h>
 #include <rte_common.h>
 #include <rte_hexdump.h>
 #include <rte_pause.h>
@@ -160,12 +161,32 @@ test_align(void)
 }
 
 static int
+test_log2(void)
+{
+	uint32_t i, base, compare;
+	const uint32_t max = 0x10000;
+	const uint32_t step = 1;
+
+	for (i = 0; i < max; i = i + step) {
+		base = (uint32_t)ceilf(log2((uint32_t)i));
+		compare = rte_log2_u32(i);
+		if (base != compare) {
+			printf("Wrong rte_log2_u32(%x) val %x, expected %x\n",
+				i, compare, base);
+			return TEST_FAILED;
+		}
+	}
+	return 0;
+}
+
+static int
 test_common(void)
 {
 	int ret = 0;
 	ret |= test_align();
 	ret |= test_macros(0);
 	ret |= test_misc();
+	ret |= test_log2();
 
 	return ret;
 }
-- 
2.13.2

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dpdk-dev]  [PATCH 2/2] net/thunderx: remove libm dependency
  2017-07-06 14:20 [dpdk-dev] [PATCH 1/2] test: add unit test case for rte log2 Jerin Jacob
@ 2017-07-06 14:20 ` Jerin Jacob
  2017-07-10 12:29   ` Olivier Matz
  2017-07-10 12:29 ` [dpdk-dev] [PATCH 1/2] test: add unit test case for rte log2 Olivier Matz
  1 sibling, 1 reply; 5+ messages in thread
From: Jerin Jacob @ 2017-07-06 14:20 UTC (permalink / raw)
  To: dev; +Cc: thomas, ferruh.yigit, olivier.matz, Jerin Jacob

Used rte_log2_u32() to replace integer log2() to
remove libm dependency.

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
 drivers/net/thunderx/base/nicvf_hw.c   | 8 +++++---
 drivers/net/thunderx/base/nicvf_plat.h | 1 +
 mk/rte.app.mk                          | 2 +-
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/thunderx/base/nicvf_hw.c b/drivers/net/thunderx/base/nicvf_hw.c
index 04b3b69c5..b9baf20dd 100644
--- a/drivers/net/thunderx/base/nicvf_hw.c
+++ b/drivers/net/thunderx/base/nicvf_hw.c
@@ -448,7 +448,8 @@ nicvf_qsize_regbit(uint32_t len, uint32_t len_shift)
 {
 	int val;
 
-	val = ((uint32_t)log2(len) - len_shift);
+	val = nicvf_log2_u32(len) - len_shift;
+
 	assert(val >= NICVF_QSIZE_MIN_VAL);
 	assert(val <= NICVF_QSIZE_MAX_VAL);
 	return val;
@@ -801,7 +802,7 @@ nicvf_rss_reta_update(struct nicvf *nic, uint8_t *tbl, uint32_t max_count)
 		return NICVF_ERR_RSS_GET_SZ;
 
 	assert(rss->rss_size > 0);
-	rss->hash_bits = (uint8_t)log2(rss->rss_size);
+	rss->hash_bits = (uint8_t)nicvf_log2_u32(rss->rss_size);
 	for (idx = 0; idx < rss->rss_size && idx < max_count; idx++)
 		rss->ind_tbl[idx] = tbl[idx];
 
@@ -822,7 +823,8 @@ nicvf_rss_reta_query(struct nicvf *nic, uint8_t *tbl, uint32_t max_count)
 		return NICVF_ERR_RSS_GET_SZ;
 
 	assert(rss->rss_size > 0);
-	rss->hash_bits = (uint8_t)log2(rss->rss_size);
+	rss->hash_bits = (uint8_t)nicvf_log2_u32(rss->rss_size);
+
 	for (idx = 0; idx < rss->rss_size && idx < max_count; idx++)
 		tbl[idx] = rss->ind_tbl[idx];
 
diff --git a/drivers/net/thunderx/base/nicvf_plat.h b/drivers/net/thunderx/base/nicvf_plat.h
index 3536d8374..fc7d0bcf7 100644
--- a/drivers/net/thunderx/base/nicvf_plat.h
+++ b/drivers/net/thunderx/base/nicvf_plat.h
@@ -59,6 +59,7 @@
 /* utils */
 #include <rte_common.h>
 #define nicvf_min(x, y) RTE_MIN(x, y)
+#define nicvf_log2_u32(x) rte_log2_u32(x)
 
 /* byte order */
 #include <rte_byteorder.h>
diff --git a/mk/rte.app.mk b/mk/rte.app.mk
index 7d71a4975..238966504 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -136,7 +136,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_RING)       += -lrte_pmd_ring
 _LDLIBS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD)    += -lrte_pmd_sfc_efx
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2)   += -lrte_pmd_szedata2 -lsze2
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_TAP)        += -lrte_pmd_tap
-_LDLIBS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += -lrte_pmd_thunderx_nicvf -lm
+_LDLIBS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += -lrte_pmd_thunderx_nicvf
 _LDLIBS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD)     += -lrte_pmd_virtio
 ifeq ($(CONFIG_RTE_LIBRTE_VHOST),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_VHOST)      += -lrte_pmd_vhost
-- 
2.13.2

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH 1/2] test: add unit test case for rte log2
  2017-07-06 14:20 [dpdk-dev] [PATCH 1/2] test: add unit test case for rte log2 Jerin Jacob
  2017-07-06 14:20 ` [dpdk-dev] [PATCH 2/2] net/thunderx: remove libm dependency Jerin Jacob
@ 2017-07-10 12:29 ` Olivier Matz
  2017-07-10 14:56   ` Thomas Monjalon
  1 sibling, 1 reply; 5+ messages in thread
From: Olivier Matz @ 2017-07-10 12:29 UTC (permalink / raw)
  To: Jerin Jacob; +Cc: dev, thomas, ferruh.yigit

On Thu,  6 Jul 2017 19:50:24 +0530, Jerin Jacob <jerin.jacob@caviumnetworks.com> wrote:
> add a unit testcase for rte_log2_u32.
> 
> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>

Reviewed-by: Olivier Matz <olivier.matz@6wind.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH 2/2] net/thunderx: remove libm dependency
  2017-07-06 14:20 ` [dpdk-dev] [PATCH 2/2] net/thunderx: remove libm dependency Jerin Jacob
@ 2017-07-10 12:29   ` Olivier Matz
  0 siblings, 0 replies; 5+ messages in thread
From: Olivier Matz @ 2017-07-10 12:29 UTC (permalink / raw)
  To: Jerin Jacob; +Cc: dev, thomas, ferruh.yigit

On Thu,  6 Jul 2017 19:50:25 +0530, Jerin Jacob <jerin.jacob@caviumnetworks.com> wrote:
> Used rte_log2_u32() to replace integer log2() to
> remove libm dependency.
> 
> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>

Reviewed-by: Olivier Matz <olivier.matz@6wind.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH 1/2] test: add unit test case for rte log2
  2017-07-10 12:29 ` [dpdk-dev] [PATCH 1/2] test: add unit test case for rte log2 Olivier Matz
@ 2017-07-10 14:56   ` Thomas Monjalon
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Monjalon @ 2017-07-10 14:56 UTC (permalink / raw)
  To: Jerin Jacob; +Cc: dev, Olivier Matz, ferruh.yigit

10/07/2017 14:29, Olivier Matz:
> On Thu,  6 Jul 2017 19:50:24 +0530, Jerin Jacob <jerin.jacob@caviumnetworks.com> wrote:
> > add a unit testcase for rte_log2_u32.
> > 
> > Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> 
> Reviewed-by: Olivier Matz <olivier.matz@6wind.com>

Series applied, thanks

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-07-10 14:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-06 14:20 [dpdk-dev] [PATCH 1/2] test: add unit test case for rte log2 Jerin Jacob
2017-07-06 14:20 ` [dpdk-dev] [PATCH 2/2] net/thunderx: remove libm dependency Jerin Jacob
2017-07-10 12:29   ` Olivier Matz
2017-07-10 12:29 ` [dpdk-dev] [PATCH 1/2] test: add unit test case for rte log2 Olivier Matz
2017-07-10 14:56   ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).