DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 3/3] net: run-time function selection
@ 2017-11-06 18:05 Elza Mathew
  2017-12-11 15:31 ` Bruce Richardson
  0 siblings, 1 reply; 5+ messages in thread
From: Elza Mathew @ 2017-11-06 18:05 UTC (permalink / raw)
  To: jasvinder.singh; +Cc: dev

Compile-time function selection can potentially lead to
lower performance on generic builds done by distros.
Replaced compile time flag checks with run-time
function selection.

Signed-off-by: Elza Mathew <elza.mathew@intel.com>
---
 lib/librte_net/rte_net_crc.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/lib/librte_net/rte_net_crc.c b/lib/librte_net/rte_net_crc.c
index 661fe32..8f6a0e7 100644
--- a/lib/librte_net/rte_net_crc.c
+++ b/lib/librte_net/rte_net_crc.c
@@ -39,8 +39,8 @@
 #include <rte_common.h>
 #include <rte_net_crc.h>
 
-#if defined(RTE_ARCH_X86_64) && defined(RTE_MACHINE_CPUFLAG_PCLMULQDQ)
-#define X86_64_SSE42_PCLMULQDQ     1
+#ifdef RTE_ARCH_X86_64
+#include <net_crc_sse.h>
 #elif defined(RTE_ARCH_ARM64) && defined(RTE_MACHINE_CPUFLAG_PMULL)
 #define ARM64_NEON_PMULL           1
 #endif
@@ -71,7 +71,7 @@
 	[RTE_NET_CRC32_ETH] = rte_crc32_eth_handler,
 };
 
-#ifdef X86_64_SSE42_PCLMULQDQ
+#ifdef RTE_ARCH_X86_64
 static rte_net_crc_handler handlers_sse42[] = {
 	[RTE_NET_CRC16_CCITT] = rte_crc16_ccitt_sse42_handler,
 	[RTE_NET_CRC32_ETH] = rte_crc32_eth_sse42_handler,
@@ -169,10 +169,12 @@
 rte_net_crc_set_alg(enum rte_net_crc_alg alg)
 {
 	switch (alg) {
-#ifdef X86_64_SSE42_PCLMULQDQ
+#ifdef RTE_ARCH_X86_64
 	case RTE_NET_CRC_SSE42:
-		handlers = handlers_sse42;
-		break;
+		if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_PCLMULQDQ)) {
+			handlers = handlers_sse42;
+			break;
+		}
 #elif defined ARM64_NEON_PMULL
 		/* fall-through */
 	case RTE_NET_CRC_NEON:
@@ -212,9 +214,11 @@ static inline void __attribute__((constructor))
 
 	rte_net_crc_scalar_init();
 
-#ifdef X86_64_SSE42_PCLMULQDQ
-	alg = RTE_NET_CRC_SSE42;
-	rte_net_crc_sse42_init();
+#ifdef RTE_ARCH_X86_64
+	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_PCLMULQDQ)) {
+		alg = RTE_NET_CRC_SSE42;
+		rte_net_crc_sse42_init();
+	}
 #elif defined ARM64_NEON_PMULL
 	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_PMULL)) {
 		alg = RTE_NET_CRC_NEON;
-- 
1.9.1

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

end of thread, other threads:[~2018-01-22 17:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-06 18:05 [dpdk-dev] [PATCH 3/3] net: run-time function selection Elza Mathew
2017-12-11 15:31 ` Bruce Richardson
2018-01-18 23:43   ` Thomas Monjalon
2018-01-19  9:20     ` Bruce Richardson
2018-01-22 17:36   ` Bruce Richardson

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).