DPDK patches and discussions
 help / color / mirror / Atom feed
From: Konstantin Ananyev <konstantin.ananyev@intel.com>
To: dev@dpdk.org
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 2/4] acl: update UT to reflect latest changes in the librte_acl.
Date: Thu, 22 May 2014 21:48:52 +0100	[thread overview]
Message-ID: <1400791734-24479-3-git-send-email-konstantin.ananyev@intel.com> (raw)
In-Reply-To: <1400791734-24479-1-git-send-email-konstantin.ananyev@intel.com>

Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
 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

  parent reply	other threads:[~2014-05-22 20:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-22 20:48 [dpdk-dev] [PATCH 0/4] ACL library Konstantin Ananyev
2014-05-22 20:48 ` [dpdk-dev] [PATCH 1/4] acl: Add ACL library (librte_acl) into DPDK Konstantin Ananyev
2014-05-27 22:21   ` Thomas Monjalon
2014-05-22 20:48 ` Konstantin Ananyev [this message]
2014-05-22 20:48 ` [dpdk-dev] [PATCH 3/4] acl: New test-acl application Konstantin Ananyev
2014-05-22 20:48 ` [dpdk-dev] [PATCH 4/4] acl: New sample l3fwd-acl Konstantin Ananyev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1400791734-24479-3-git-send-email-konstantin.ananyev@intel.com \
    --to=konstantin.ananyev@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).