From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id EAA346895 for ; Thu, 22 May 2014 22:49:17 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 22 May 2014 13:44:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.98,889,1392192000"; d="scan'208";a="545146131" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 22 May 2014 13:49:25 -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 s4MKnPgi011057; Thu, 22 May 2014 21:49:25 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id s4MKnPVe024960; Thu, 22 May 2014 21:49:25 +0100 Received: (from kananye1@localhost) by sivswdev02.ir.intel.com with id s4MKnP2g024956; Thu, 22 May 2014 21:49:25 +0100 From: Konstantin Ananyev To: dev@dpdk.org Date: Thu, 22 May 2014 21:48:52 +0100 Message-Id: <1400791734-24479-3-git-send-email-konstantin.ananyev@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1400791734-24479-1-git-send-email-konstantin.ananyev@intel.com> References: <1400791734-24479-1-git-send-email-konstantin.ananyev@intel.com> To: dev@dpdk.org Subject: [dpdk-dev] [PATCH 2/4] 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: Thu, 22 May 2014 20:49:18 -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