From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 8CE9AA0096 for ; Mon, 8 Apr 2019 20:24:46 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2B9815323; Mon, 8 Apr 2019 20:24:34 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 1A93E2BCE for ; Mon, 8 Apr 2019 20:24:25 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7C3584DB00; Mon, 8 Apr 2019 18:24:24 +0000 (UTC) Received: from dhcp-25.97.bos.redhat.com (unknown [10.18.25.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id F387364051; Mon, 8 Apr 2019 18:24:23 +0000 (UTC) From: Aaron Conole To: dev@dpdk.org Cc: Konstantin Ananyev , Jerin Jacob , Gavin Hu Date: Mon, 8 Apr 2019 14:24:20 -0400 Message-Id: <20190408182420.4398-4-aconole@redhat.com> In-Reply-To: <20190408182420.4398-1-aconole@redhat.com> References: <20190408182420.4398-1-aconole@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 08 Apr 2019 18:24:24 +0000 (UTC) Subject: [dpdk-dev] [PATCH 3/3] acl: adjust the tests 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190408182420.Dif_6JNc3SSJOg0_wB4JsNagEkN4Wm2pOaAeUe7ZQ-0@z> This makes the tests pass, and also ensures that on platforms where the testing is supported, we can properly test the implementation specific code. One edge case is when we run on x86_64 systems that don't support AVX2, but where the compiler can generate such instructions. That could be an enhancement in the future, but for now at least the tests will pass. Signed-off-by: Aaron Conole --- app/test/test_acl.c | 62 +++++++++++++-------------------- lib/librte_acl/Makefile | 1 + lib/librte_acl/acl_run_notsup.c | 46 ++++++++++++++++++++++++ lib/librte_acl/meson.build | 4 +-- 4 files changed, 73 insertions(+), 40 deletions(-) create mode 100644 lib/librte_acl/acl_run_notsup.c diff --git a/app/test/test_acl.c b/app/test/test_acl.c index b1f75d1bc..c44faa251 100644 --- a/app/test/test_acl.c +++ b/app/test/test_acl.c @@ -408,6 +408,9 @@ test_classify(void) return -1; } + /* Always use the scalar testing for now. */ + rte_acl_set_ctx_classify(acx, RTE_ACL_CLASSIFY_SCALAR); + ret = 0; for (i = 0; i != TEST_CLASSIFY_ITER; i++) { @@ -547,6 +550,7 @@ test_build_ports_range(void) for (i = 0; i != RTE_DIM(test_data); i++) data[i] = (uint8_t *)&test_data[i]; + rte_acl_set_ctx_classify(acx, RTE_ACL_CLASSIFY_SCALAR); for (i = 0; i != RTE_DIM(test_rules); i++) { rte_acl_reset(acx); ret = test_classify_buid(acx, test_rules, i + 1); @@ -911,6 +915,8 @@ test_convert_rules(const char *desc, return -1; } + rte_acl_set_ctx_classify(acx, RTE_ACL_CLASSIFY_SCALAR); + rc = convert_rules(acx, convert, acl_test_rules, RTE_DIM(acl_test_rules)); if (rc != 0) @@ -1352,7 +1358,7 @@ test_invalid_parameters(void) struct rte_acl_param param; struct rte_acl_ctx *acx; struct rte_acl_ipv4vlan_rule rule; - int result; + int i, result; uint32_t layout[RTE_ACL_IPV4VLAN_NUM] = {0}; @@ -1513,45 +1519,25 @@ test_invalid_parameters(void) return -1; } - /* SSE classify test */ - - /* cover zero categories in classify (should not fail) */ - result = rte_acl_classify(acx, NULL, NULL, 0, 0); - if (result != 0) { - printf("Line %i: SSE classify with zero categories " - "failed!\n", __LINE__); - rte_acl_free(acx); - return -1; - } - - /* cover invalid but positive categories in classify */ - result = rte_acl_classify(acx, NULL, NULL, 0, 3); - if (result == 0) { - printf("Line %i: SSE classify with 3 categories " - "should have failed!\n", __LINE__); - rte_acl_free(acx); - return -1; - } - - /* scalar classify test */ + for (i = RTE_ACL_CLASSIFY_DEFAULT; i < RTE_ACL_CLASSIFY_NUM; ++i) { + rte_acl_set_ctx_classify(acx, i); /* set up the classify code */ - /* cover zero categories in classify (should not fail) */ - result = rte_acl_classify_alg(acx, NULL, NULL, 0, 0, - RTE_ACL_CLASSIFY_SCALAR); - if (result != 0) { - printf("Line %i: Scalar classify with zero categories " - "failed!\n", __LINE__); - rte_acl_free(acx); - return -1; - } + /* cover zero categories in classify (should not fail) */ + result = rte_acl_classify(acx, NULL, NULL, 0, 0); + if (result != 0 && result != -ENOTSUP) { + printf("AGL: %d, ACL classify with zero categories failed: %d!\n", + i, result); + return -1; + } - /* cover invalid but positive categories in classify */ - result = rte_acl_classify(acx, NULL, NULL, 0, 3); - if (result == 0) { - printf("Line %i: Scalar classify with 3 categories " - "should have failed!\n", __LINE__); - rte_acl_free(acx); - return -1; + /* cover invalid but positive categories in classify */ + result = rte_acl_classify(acx, NULL, NULL, 0, 3); + /* we don't check for -ENOTSUP here, since it is a failure */ + if (result == 0) { + printf("AGL: %d, ACL classify with 3 categories should fail!\n", + i); + return -1; + } } /* free ACL context */ diff --git a/lib/librte_acl/Makefile b/lib/librte_acl/Makefile index ea5edf00a..c5dfdb832 100644 --- a/lib/librte_acl/Makefile +++ b/lib/librte_acl/Makefile @@ -21,6 +21,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_ACL) += rte_acl.c SRCS-$(CONFIG_RTE_LIBRTE_ACL) += acl_bld.c SRCS-$(CONFIG_RTE_LIBRTE_ACL) += acl_gen.c SRCS-$(CONFIG_RTE_LIBRTE_ACL) += acl_run_scalar.c +SRCS-$(CONFIG_RTE_LIBRTE_ACL) += acl_run_notsup.c ifneq ($(filter y,$(CONFIG_RTE_ARCH_ARM) $(CONFIG_RTE_ARCH_ARM64)),) SRCS-$(CONFIG_RTE_LIBRTE_ACL) += acl_run_neon.c diff --git a/lib/librte_acl/acl_run_notsup.c b/lib/librte_acl/acl_run_notsup.c new file mode 100644 index 000000000..2bcc6e67f --- /dev/null +++ b/lib/librte_acl/acl_run_notsup.c @@ -0,0 +1,46 @@ +#include +#include "acl.h" + +/* + * If the compiler doesn't support AVX2 instructions, + * then the dummy one would be used instead for AVX2 classify method. + */ +int __rte_weak +rte_acl_classify_avx2(__rte_unused const struct rte_acl_ctx *ctx, + __rte_unused const uint8_t **data, + __rte_unused uint32_t *results, + __rte_unused uint32_t num, + __rte_unused uint32_t categories) +{ + return -ENOTSUP; +} + +int __rte_weak +rte_acl_classify_sse(__rte_unused const struct rte_acl_ctx *ctx, + __rte_unused const uint8_t **data, + __rte_unused uint32_t *results, + __rte_unused uint32_t num, + __rte_unused uint32_t categories) +{ + return -ENOTSUP; +} + +int __rte_weak +rte_acl_classify_neon(__rte_unused const struct rte_acl_ctx *ctx, + __rte_unused const uint8_t **data, + __rte_unused uint32_t *results, + __rte_unused uint32_t num, + __rte_unused uint32_t categories) +{ + return -ENOTSUP; +} + +int __rte_weak +rte_acl_classify_altivec(__rte_unused const struct rte_acl_ctx *ctx, + __rte_unused const uint8_t **data, + __rte_unused uint32_t *results, + __rte_unused uint32_t num, + __rte_unused uint32_t categories) +{ + return -ENOTSUP; +} diff --git a/lib/librte_acl/meson.build b/lib/librte_acl/meson.build index 03c19e4e5..fc8689aa9 100644 --- a/lib/librte_acl/meson.build +++ b/lib/librte_acl/meson.build @@ -2,8 +2,8 @@ # Copyright(c) 2017 Intel Corporation version = 2 -sources = files('acl_bld.c', 'acl_gen.c', 'acl_run_scalar.c', - 'rte_acl.c', 'tb_mem.c') +sources = files('acl_bld.c', 'acl_gen.c', 'acl_run_notsup.c', + 'acl_run_scalar.c', 'rte_acl.c', 'tb_mem.c') headers = files('rte_acl.h', 'rte_acl_osdep.h') if arch_subdir == 'x86' -- 2.19.1