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 2B6ECA04BB; Tue, 6 Oct 2020 17:10:32 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E1B971BAB9; Tue, 6 Oct 2020 17:08:28 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 7B1BD1BA9F for ; Tue, 6 Oct 2020 17:08:26 +0200 (CEST) IronPort-SDR: mH1X+hj65DVV8eB/vA24VQbeV5Q8xKd1IbYiewbTi6XrgEtrFdsmWcxp4j/p/1rBNPzqVXqPG+ 2RonGE8JyHJA== X-IronPort-AV: E=McAfee;i="6000,8403,9765"; a="143919594" X-IronPort-AV: E=Sophos;i="5.77,343,1596524400"; d="scan'208";a="143919594" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Oct 2020 08:03:42 -0700 IronPort-SDR: EWIoS6FIDucncTXkTfck/kQUXyZozDWGWjPeOsM70gkxxPs19sMoGulsL9VQ+kt+z8ri1/dUxl CGwArLtm3SAg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,343,1596524400"; d="scan'208";a="518315410" Received: from sivswdev08.ir.intel.com ([10.237.217.47]) by fmsmga005.fm.intel.com with ESMTP; 06 Oct 2020 08:03:41 -0700 From: Konstantin Ananyev To: dev@dpdk.org Cc: jerinj@marvell.com, ruifeng.wang@arm.com, vladimir.medvedkin@intel.com, Konstantin Ananyev Date: Tue, 6 Oct 2020 16:03:08 +0100 Message-Id: <20201006150316.5776-7-konstantin.ananyev@intel.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20201006150316.5776-1-konstantin.ananyev@intel.com> References: <20201005184526.7465-1-konstantin.ananyev@intel.com> <20201006150316.5776-1-konstantin.ananyev@intel.com> Subject: [dpdk-dev] [PATCH v4 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