From patchwork Tue Sep 15 16:50:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ananyev, Konstantin" X-Patchwork-Id: 77768 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6AF75A04C7; Tue, 15 Sep 2020 18:51:49 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6A0A71C198; Tue, 15 Sep 2020 18:51:10 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id E7D451C198 for ; Tue, 15 Sep 2020 18:51:08 +0200 (CEST) IronPort-SDR: 4adVAMNmsmk6HYSzz+vUvc0KoYN/BhKqSalkgJHyyKmnTpAaISJSCvHhyrpWwMvq4yrhy6iXoe C5iLiz4DXrFw== X-IronPort-AV: E=McAfee;i="6000,8403,9745"; a="139310995" X-IronPort-AV: E=Sophos;i="5.76,430,1592895600"; d="scan'208";a="139310995" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2020 09:51:08 -0700 IronPort-SDR: Q3vXBlZw1SbjE2CF6TUCHetxOu/aKGC8d2cIL3od5+SWBeFSXiz58PrNb49ZEF0TXacnVUG1BY uTtSaWU0Klgw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,430,1592895600"; d="scan'208";a="306709423" Received: from sivswdev08.ir.intel.com ([10.237.217.47]) by orsmga006.jf.intel.com with ESMTP; 15 Sep 2020 09:51:07 -0700 From: Konstantin Ananyev To: dev@dpdk.org Cc: jerinj@marvell.com, ruifeng.wang@arm.com, vladimir.medvedkin@intel.com, Konstantin Ananyev Date: Tue, 15 Sep 2020 17:50:19 +0100 Message-Id: <20200915165025.543-7-konstantin.ananyev@intel.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20200915165025.543-1-konstantin.ananyev@intel.com> References: <20200807162829.11690-1-konstantin.ananyev@intel.com> <20200915165025.543-1-konstantin.ananyev@intel.com> Subject: [dpdk-dev] [PATCH v2 06/12] 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 316bf4d06..333b34757 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;