From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B4612A04B1; Mon, 5 Oct 2020 21:45:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E22681BAFD; Mon, 5 Oct 2020 21:43:23 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id A65151BACD for ; Mon, 5 Oct 2020 21:43:21 +0200 (CEST) IronPort-SDR: VWPc2gG/HLUj5wQfmCaC8nAISZSlSuAlBmgnuTEVyJdWJor2t817wf/4vvZewXXkPab7Th+qQs MDhDk9LpaSMA== X-IronPort-AV: E=McAfee;i="6000,8403,9765"; a="228046081" X-IronPort-AV: E=Sophos;i="5.77,340,1596524400"; d="scan'208";a="228046081" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2020 12:27:57 -0700 IronPort-SDR: 2BUtJE1X7kh/yYFMbGWAXENM2ppDDbNZNyiyfbbdTK9ahw4dBMyTEZrbdp1Xdxge0GoBitARUT A9MkJF4oghsg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,340,1596524400"; d="scan'208";a="526624978" Received: from sivswdev08.ir.intel.com ([10.237.217.47]) by orsmga005.jf.intel.com with ESMTP; 05 Oct 2020 11:46:14 -0700 From: Konstantin Ananyev To: dev@dpdk.org Cc: jerinj@marvell.com, ruifeng.wang@arm.com, vladimir.medvedkin@intel.com, Konstantin Ananyev Date: Mon, 5 Oct 2020 19:45:18 +0100 Message-Id: <20201005184526.7465-7-konstantin.ananyev@intel.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20201005184526.7465-1-konstantin.ananyev@intel.com> References: <20200915165025.543-1-konstantin.ananyev@intel.com> <20201005184526.7465-1-konstantin.ananyev@intel.com> Subject: [dpdk-dev] [PATCH v3 06/14] test/acl: expand classify test coverage 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" Make classify test to run for all supported methods. Signed-off-by: Konstantin Ananyev --- app/test/test_acl.c | 103 ++++++++++++++++++++++---------------------- 1 file changed, 51 insertions(+), 52 deletions(-) diff --git a/app/test/test_acl.c b/app/test/test_acl.c index 316bf4d065..333b347579 100644 --- a/app/test/test_acl.c +++ b/app/test/test_acl.c @@ -266,22 +266,20 @@ rte_acl_ipv4vlan_build(struct rte_acl_ctx *ctx, } /* - * Test scalar and SSE ACL lookup. + * Test ACL lookup (selected alg). */ static int -test_classify_run(struct rte_acl_ctx *acx, struct ipv4_7tuple test_data[], - size_t dim) +test_classify_alg(struct rte_acl_ctx *acx, struct ipv4_7tuple test_data[], + const uint8_t *data[], size_t dim, enum rte_acl_classify_alg alg) { - int ret, i; - uint32_t result, count; + int32_t ret; + uint32_t i, result, count; uint32_t results[dim * RTE_ACL_MAX_CATEGORIES]; - const uint8_t *data[dim]; - /* swap all bytes in the data to network order */ - bswap_test_data(test_data, dim, 1); - /* store pointers to test data */ - for (i = 0; i < (int) dim; i++) - data[i] = (uint8_t *)&test_data[i]; + /* set given classify alg, skip test if alg is not supported */ + ret = rte_acl_set_ctx_classify(acx, alg); + if (ret == -ENOTSUP) + return 0; /** * these will run quite a few times, it's necessary to test code paths @@ -291,12 +289,13 @@ test_classify_run(struct rte_acl_ctx *acx, struct ipv4_7tuple test_data[], ret = rte_acl_classify(acx, data, results, count, RTE_ACL_MAX_CATEGORIES); if (ret != 0) { - printf("Line %i: SSE classify failed!\n", __LINE__); - goto err; + printf("Line %i: classify(alg=%d) failed!\n", + __LINE__, alg); + return ret; } /* check if we allow everything we should allow */ - for (i = 0; i < (int) count; i++) { + for (i = 0; i < count; i++) { result = results[i * RTE_ACL_MAX_CATEGORIES + ACL_ALLOW]; if (result != test_data[i].allow) { @@ -304,63 +303,63 @@ test_classify_run(struct rte_acl_ctx *acx, struct ipv4_7tuple test_data[], "(expected %"PRIu32" got %"PRIu32")!\n", __LINE__, i, test_data[i].allow, result); - ret = -EINVAL; - goto err; + return -EINVAL; } } /* check if we deny everything we should deny */ - for (i = 0; i < (int) count; i++) { + for (i = 0; i < count; i++) { result = results[i * RTE_ACL_MAX_CATEGORIES + ACL_DENY]; if (result != test_data[i].deny) { printf("Line %i: Error in deny results at %i " "(expected %"PRIu32" got %"PRIu32")!\n", __LINE__, i, test_data[i].deny, result); - ret = -EINVAL; - goto err; + return -EINVAL; } } } - /* make a quick check for scalar */ - ret = rte_acl_classify_alg(acx, data, results, - dim, RTE_ACL_MAX_CATEGORIES, - RTE_ACL_CLASSIFY_SCALAR); - if (ret != 0) { - printf("Line %i: scalar classify failed!\n", __LINE__); - goto err; - } + /* restore default classify alg */ + return rte_acl_set_ctx_classify(acx, RTE_ACL_CLASSIFY_DEFAULT); +} - /* check if we allow everything we should allow */ - for (i = 0; i < (int) dim; i++) { - result = results[i * RTE_ACL_MAX_CATEGORIES + ACL_ALLOW]; - if (result != test_data[i].allow) { - printf("Line %i: Error in allow results at %i " - "(expected %"PRIu32" got %"PRIu32")!\n", - __LINE__, i, test_data[i].allow, - result); - ret = -EINVAL; - goto err; - } - } +/* + * Test ACL lookup (all possible methods). + */ +static int +test_classify_run(struct rte_acl_ctx *acx, struct ipv4_7tuple test_data[], + size_t dim) +{ + int32_t ret; + uint32_t i; + const uint8_t *data[dim]; - /* check if we deny everything we should deny */ - for (i = 0; i < (int) dim; i++) { - result = results[i * RTE_ACL_MAX_CATEGORIES + ACL_DENY]; - if (result != test_data[i].deny) { - printf("Line %i: Error in deny results at %i " - "(expected %"PRIu32" got %"PRIu32")!\n", - __LINE__, i, test_data[i].deny, - result); - ret = -EINVAL; - goto err; - } - } + static const enum rte_acl_classify_alg alg[] = { + RTE_ACL_CLASSIFY_SCALAR, + RTE_ACL_CLASSIFY_SSE, + RTE_ACL_CLASSIFY_AVX2, + RTE_ACL_CLASSIFY_NEON, + RTE_ACL_CLASSIFY_ALTIVEC, + }; + + /* swap all bytes in the data to network order */ + bswap_test_data(test_data, dim, 1); + + /* store pointers to test data */ + for (i = 0; i < dim; i++) + data[i] = (uint8_t *)&test_data[i]; ret = 0; + for (i = 0; i != RTE_DIM(alg); i++) { + ret = test_classify_alg(acx, test_data, data, dim, alg[i]); + if (ret < 0) { + printf("Line %i: %s() for alg=%d failed, errno=%d\n", + __LINE__, __func__, alg[i], -ret); + break; + } + } -err: /* swap data back to cpu order so that next time tests don't fail */ bswap_test_data(test_data, dim, 0); return ret; -- 2.17.1