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

Reply via email to