From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id CB64EB0A8 for ; Wed, 28 May 2014 21:27:11 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 28 May 2014 12:27:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.98,929,1392192000"; d="scan'208";a="546336349" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 28 May 2014 12:27:17 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s4SJRFvU017624; Wed, 28 May 2014 20:27:15 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id s4SJRFJT010856; Wed, 28 May 2014 20:27:15 +0100 Received: (from kananye1@localhost) by sivswdev02.ir.intel.com with id s4SJRFou010852; Wed, 28 May 2014 20:27:15 +0100 From: Konstantin Ananyev To: dev@dpdk.org Date: Wed, 28 May 2014 20:26:47 +0100 Message-Id: <1401305210-10357-3-git-send-email-konstantin.ananyev@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1401305210-10357-1-git-send-email-konstantin.ananyev@intel.com> References: <1401305210-10357-1-git-send-email-konstantin.ananyev@intel.com> To: dev@dpdk.org Subject: [dpdk-dev] [PATCHv2 2/5] acl: update UT to reflect latest changes in the librte_acl. X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 May 2014 19:27:12 -0000 Signed-off-by: Konstantin Ananyev --- app/test/test_acl.c | 128 ++++++++++++++++++++++++++++++++++----------------- 1 files changed, 85 insertions(+), 43 deletions(-) diff --git a/app/test/test_acl.c b/app/test/test_acl.c index 790cdf3..c171eac 100644 --- a/app/test/test_acl.c +++ b/app/test/test_acl.c @@ -96,47 +96,13 @@ bswap_test_data(struct ipv4_7tuple * data, int len, int to_be) * Test scalar and SSE ACL lookup. */ static int -test_classify(void) +test_classify_run(struct rte_acl_ctx * acx) { - struct rte_acl_ctx * acx; int ret, i; uint32_t result, count; - uint32_t results[RTE_DIM(acl_test_data) * RTE_ACL_MAX_CATEGORIES]; - const uint8_t * data[RTE_DIM(acl_test_data)]; - const uint32_t layout[RTE_ACL_IPV4VLAN_NUM] = { - offsetof(struct ipv4_7tuple, proto), - offsetof(struct ipv4_7tuple, vlan), - offsetof(struct ipv4_7tuple, ip_src), - offsetof(struct ipv4_7tuple, ip_dst), - offsetof(struct ipv4_7tuple, port_src), - }; - - acx = rte_acl_create(&acl_param); - if (acx == NULL) { - printf("Line %i: Error creating ACL context!\n", __LINE__); - return -1; - } - - /* add rules to the context */ - ret = rte_acl_ipv4vlan_add_rules(acx, acl_test_rules, - RTE_DIM(acl_test_rules)); - if (ret != 0) { - printf("Line %i: Adding rules to ACL context failed!\n", __LINE__); - rte_acl_free(acx); - return -1; - } - - /* try building the context */ - ret = rte_acl_ipv4vlan_build(acx, layout, RTE_ACL_MAX_CATEGORIES); - if (ret != 0) { - printf("Line %i: Building ACL context failed!\n", __LINE__); - rte_acl_free(acx); - return -1; - } - /* swap all bytes in the data to network order */ bswap_test_data(acl_test_data, RTE_DIM(acl_test_data), 1); @@ -213,21 +179,97 @@ test_classify(void) } } - /* free ACL context */ - rte_acl_free(acx); + ret = 0; +err: /* swap data back to cpu order so that next time tests don't fail */ bswap_test_data(acl_test_data, RTE_DIM(acl_test_data), 0); + return (ret); +} - return 0; -err: +static int +test_classify_buid(struct rte_acl_ctx * acx) +{ + int ret; + const uint32_t layout[RTE_ACL_IPV4VLAN_NUM] = { + offsetof(struct ipv4_7tuple, proto), + offsetof(struct ipv4_7tuple, vlan), + offsetof(struct ipv4_7tuple, ip_src), + offsetof(struct ipv4_7tuple, ip_dst), + offsetof(struct ipv4_7tuple, port_src), + }; - /* swap data back to cpu order so that next time tests don't fail */ - bswap_test_data(acl_test_data, RTE_DIM(acl_test_data), 0); + /* add rules to the context */ + ret = rte_acl_ipv4vlan_add_rules(acx, acl_test_rules, + RTE_DIM(acl_test_rules)); + if (ret != 0) { + printf("Line %i: Adding rules to ACL context failed!\n", + __LINE__); + return (ret); + } - rte_acl_free(acx); + /* try building the context */ + ret = rte_acl_ipv4vlan_build(acx, layout, RTE_ACL_MAX_CATEGORIES); + if (ret != 0) { + printf("Line %i: Building ACL context failed!\n", __LINE__); + return (ret); + } - return -1; + return (0); +} + +#define TEST_CLASSIFY_ITER 4 + +/* + * Test scalar and SSE ACL lookup. + */ +static int +test_classify(void) +{ + struct rte_acl_ctx * acx; + int i, ret; + + acx = rte_acl_create(&acl_param); + if (acx == NULL) { + printf("Line %i: Error creating ACL context!\n", __LINE__); + return -1; + } + + ret = 0; + for (i = 0; i != TEST_CLASSIFY_ITER; i++) { + + if ((i & 1) == 0) + rte_acl_reset(acx); + else + rte_acl_reset_rules(acx); + + ret = test_classify_buid(acx); + if (ret != 0) { + printf("Line %i, iter: %d: " + "Adding rules to ACL context failed!\n", + __LINE__, i); + break; + } + + ret = test_classify_run(acx); + if (ret != 0) { + printf("Line %i, iter: %d: %s failed!\n", + __LINE__, i, __func__); + break; + } + + /* reset rules and make sure that classify still works ok. */ + rte_acl_reset_rules(acx); + ret = test_classify_run(acx); + if (ret != 0) { + printf("Line %i, iter: %d: %s failed!\n", + __LINE__, i, __func__); + break; + } + } + + rte_acl_free(acx); + return (ret); } /* -- 1.7.7.6