[dpdk-dev] [PATCH 2/2] acl: Preform dynamic sse4.2 support check

Neil Horman nhorman at tuxdriver.com
Tue Jul 29 22:24:26 CEST 2014


The ACL library relies on sse4.2 intrinsics to operate, but we don't have to
enable sse4.2 in the entire build.  Instead enable it for the ACL library alone,
and use rte_acl_create as a choke point, at which we can test for sse4.2
support, and return NULL.

Signed-off-by: Neil Horman <nhorman at tuxdriver.com>
CC: Thomas Monjalon <thomas.monjalon at 6wind.com>
---
 lib/librte_acl/Makefile  | 2 +-
 lib/librte_acl/rte_acl.c | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/librte_acl/Makefile b/lib/librte_acl/Makefile
index 4fe4593..3646439 100644
--- a/lib/librte_acl/Makefile
+++ b/lib/librte_acl/Makefile
@@ -35,7 +35,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 LIB = librte_acl.a
 
 CFLAGS += -O3
-CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR)
+CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -msse4.2
 
 # all source are stored in SRCS-y
 SRCS-$(CONFIG_RTE_LIBRTE_ACL) += tb_mem.c
diff --git a/lib/librte_acl/rte_acl.c b/lib/librte_acl/rte_acl.c
index 7c288bd..14ea7e0 100644
--- a/lib/librte_acl/rte_acl.c
+++ b/lib/librte_acl/rte_acl.c
@@ -112,6 +112,15 @@ rte_acl_create(const struct rte_acl_param *param)
 	struct rte_acl_list *acl_list;
 	struct rte_tailq_entry *te;
 	char name[sizeof(ctx->name)];
+	static int acl_supported = -1;
+
+	if (acl_supported == -1)
+		acl_supported = rte_cpu_get_flag_enabled(RTE_CPUFLAG_SSE4_2);
+
+	if (!acl_supported) {
+		rte_errno = EOPNOTSUPP;
+		return NULL;
+	}
 
 	/* check that we have an initialised tail queue */
 	acl_list = RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_ACL, rte_acl_list);
-- 
1.8.3.1



More information about the dev mailing list