Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/65764/?format=api
http://patches.dpdk.org/api/patches/65764/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200212134745.5723-3-konstantin.ananyev@intel.com/", "project": { "id": 1, "url": "http://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20200212134745.5723-3-konstantin.ananyev@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20200212134745.5723-3-konstantin.ananyev@intel.com", "date": "2020-02-12T13:47:45", "name": "[2/2] test/acl: add 32-bit range test-case", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "06dc8dfe318a12f0b3bfcdc36b498a1b4ca2f95d", "submitter": { "id": 33, "url": "http://patches.dpdk.org/api/people/33/?format=api", "name": "Ananyev, Konstantin", "email": "konstantin.ananyev@intel.com" }, "delegate": { "id": 24651, "url": "http://patches.dpdk.org/api/users/24651/?format=api", "username": "dmarchand", "first_name": "David", "last_name": "Marchand", "email": "david.marchand@redhat.com" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20200212134745.5723-3-konstantin.ananyev@intel.com/mbox/", "series": [ { "id": 8515, "url": "http://patches.dpdk.org/api/series/8515/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=8515", "date": "2020-02-12T13:47:43", "name": "acl: fix 32-bit range field doesn't work properly", "version": 1, "mbox": "http://patches.dpdk.org/series/8515/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/65764/comments/", "check": "fail", "checks": "http://patches.dpdk.org/api/patches/65764/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 10F18A0534;\n\tWed, 12 Feb 2020 14:48:11 +0100 (CET)", "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 6C1A41BC25;\n\tWed, 12 Feb 2020 14:47:57 +0100 (CET)", "from mga05.intel.com (mga05.intel.com [192.55.52.43])\n by dpdk.org (Postfix) with ESMTP id C0F90137D\n for <dev@dpdk.org>; Wed, 12 Feb 2020 14:47:54 +0100 (CET)", "from orsmga002.jf.intel.com ([10.7.209.21])\n by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n 12 Feb 2020 05:47:54 -0800", "from sivswdev08.ir.intel.com ([10.237.217.47])\n by orsmga002.jf.intel.com with ESMTP; 12 Feb 2020 05:47:52 -0800" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.70,433,1574150400\"; d=\"scan'208\";a=\"251914327\"", "From": "Konstantin Ananyev <konstantin.ananyev@intel.com>", "To": "dev@dpdk.org", "Cc": "Ido@cgstowernetworks.com,\n Konstantin Ananyev <konstantin.ananyev@intel.com>", "Date": "Wed, 12 Feb 2020 13:47:45 +0000", "Message-Id": "<20200212134745.5723-3-konstantin.ananyev@intel.com>", "X-Mailer": "git-send-email 2.18.0", "In-Reply-To": "<20200212134745.5723-1-konstantin.ananyev@intel.com>", "References": "<20200212134745.5723-1-konstantin.ananyev@intel.com>", "Subject": "[dpdk-dev] [PATCH 2/2] test/acl: add 32-bit range test-case", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "Add new test-case to improve test coverage for 32-bit range fields.\n\nSuggested-by: Ido Goshen <Ido@cgstowernetworks.com>\nSigned-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>\n---\n app/test/test_acl.c | 164 +++++++++++++++++++++++++++++++++++++-------\n app/test/test_acl.h | 43 ++++++++++++\n 2 files changed, 184 insertions(+), 23 deletions(-)", "diff": "diff --git a/app/test/test_acl.c b/app/test/test_acl.c\nindex 9cd9e37db..501de35da 100644\n--- a/app/test/test_acl.c\n+++ b/app/test/test_acl.c\n@@ -269,25 +269,25 @@ rte_acl_ipv4vlan_build(struct rte_acl_ctx *ctx,\n * Test scalar and SSE ACL lookup.\n */\n static int\n-test_classify_run(struct rte_acl_ctx *acx)\n+test_classify_run(struct rte_acl_ctx *acx, struct ipv4_7tuple test_data[],\n+\tsize_t dim)\n {\n \tint ret, i;\n \tuint32_t result, count;\n-\tuint32_t results[RTE_DIM(acl_test_data) * RTE_ACL_MAX_CATEGORIES];\n-\tconst uint8_t *data[RTE_DIM(acl_test_data)];\n-\n+\tuint32_t results[dim * RTE_ACL_MAX_CATEGORIES];\n+\tconst uint8_t *data[dim];\n \t/* swap all bytes in the data to network order */\n-\tbswap_test_data(acl_test_data, RTE_DIM(acl_test_data), 1);\n+\tbswap_test_data(test_data, dim, 1);\n \n \t/* store pointers to test data */\n-\tfor (i = 0; i < (int) RTE_DIM(acl_test_data); i++)\n-\t\tdata[i] = (uint8_t *)&acl_test_data[i];\n+\tfor (i = 0; i < (int) dim; i++)\n+\t\tdata[i] = (uint8_t *)&test_data[i];\n \n \t/**\n \t * these will run quite a few times, it's necessary to test code paths\n \t * from num=0 to num>8\n \t */\n-\tfor (count = 0; count <= RTE_DIM(acl_test_data); count++) {\n+\tfor (count = 0; count <= dim; count++) {\n \t\tret = rte_acl_classify(acx, data, results,\n \t\t\t\tcount, RTE_ACL_MAX_CATEGORIES);\n \t\tif (ret != 0) {\n@@ -299,10 +299,10 @@ test_classify_run(struct rte_acl_ctx *acx)\n \t\tfor (i = 0; i < (int) count; i++) {\n \t\t\tresult =\n \t\t\t\tresults[i * RTE_ACL_MAX_CATEGORIES + ACL_ALLOW];\n-\t\t\tif (result != acl_test_data[i].allow) {\n+\t\t\tif (result != test_data[i].allow) {\n \t\t\t\tprintf(\"Line %i: Error in allow results at %i \"\n \t\t\t\t\t\"(expected %\"PRIu32\" got %\"PRIu32\")!\\n\",\n-\t\t\t\t\t__LINE__, i, acl_test_data[i].allow,\n+\t\t\t\t\t__LINE__, i, test_data[i].allow,\n \t\t\t\t\tresult);\n \t\t\t\tret = -EINVAL;\n \t\t\t\tgoto err;\n@@ -312,10 +312,10 @@ test_classify_run(struct rte_acl_ctx *acx)\n \t\t/* check if we deny everything we should deny */\n \t\tfor (i = 0; i < (int) count; i++) {\n \t\t\tresult = results[i * RTE_ACL_MAX_CATEGORIES + ACL_DENY];\n-\t\t\tif (result != acl_test_data[i].deny) {\n+\t\t\tif (result != test_data[i].deny) {\n \t\t\t\tprintf(\"Line %i: Error in deny results at %i \"\n \t\t\t\t\t\"(expected %\"PRIu32\" got %\"PRIu32\")!\\n\",\n-\t\t\t\t\t__LINE__, i, acl_test_data[i].deny,\n+\t\t\t\t\t__LINE__, i, test_data[i].deny,\n \t\t\t\t\tresult);\n \t\t\t\tret = -EINVAL;\n \t\t\t\tgoto err;\n@@ -325,7 +325,7 @@ test_classify_run(struct rte_acl_ctx *acx)\n \n \t/* make a quick check for scalar */\n \tret = rte_acl_classify_alg(acx, data, results,\n-\t\t\tRTE_DIM(acl_test_data), RTE_ACL_MAX_CATEGORIES,\n+\t\t\tdim, RTE_ACL_MAX_CATEGORIES,\n \t\t\tRTE_ACL_CLASSIFY_SCALAR);\n \tif (ret != 0) {\n \t\tprintf(\"Line %i: scalar classify failed!\\n\", __LINE__);\n@@ -333,12 +333,12 @@ test_classify_run(struct rte_acl_ctx *acx)\n \t}\n \n \t/* check if we allow everything we should allow */\n-\tfor (i = 0; i < (int) RTE_DIM(acl_test_data); i++) {\n+\tfor (i = 0; i < (int) dim; i++) {\n \t\tresult = results[i * RTE_ACL_MAX_CATEGORIES + ACL_ALLOW];\n-\t\tif (result != acl_test_data[i].allow) {\n+\t\tif (result != test_data[i].allow) {\n \t\t\tprintf(\"Line %i: Error in allow results at %i \"\n \t\t\t\t\t\"(expected %\"PRIu32\" got %\"PRIu32\")!\\n\",\n-\t\t\t\t\t__LINE__, i, acl_test_data[i].allow,\n+\t\t\t\t\t__LINE__, i, test_data[i].allow,\n \t\t\t\t\tresult);\n \t\t\tret = -EINVAL;\n \t\t\tgoto err;\n@@ -346,12 +346,12 @@ test_classify_run(struct rte_acl_ctx *acx)\n \t}\n \n \t/* check if we deny everything we should deny */\n-\tfor (i = 0; i < (int) RTE_DIM(acl_test_data); i++) {\n+\tfor (i = 0; i < (int) dim; i++) {\n \t\tresult = results[i * RTE_ACL_MAX_CATEGORIES + ACL_DENY];\n-\t\tif (result != acl_test_data[i].deny) {\n+\t\tif (result != test_data[i].deny) {\n \t\t\tprintf(\"Line %i: Error in deny results at %i \"\n \t\t\t\t\t\"(expected %\"PRIu32\" got %\"PRIu32\")!\\n\",\n-\t\t\t\t\t__LINE__, i, acl_test_data[i].deny,\n+\t\t\t\t\t__LINE__, i, test_data[i].deny,\n \t\t\t\t\tresult);\n \t\t\tret = -EINVAL;\n \t\t\tgoto err;\n@@ -362,7 +362,7 @@ test_classify_run(struct rte_acl_ctx *acx)\n \n err:\n \t/* swap data back to cpu order so that next time tests don't fail */\n-\tbswap_test_data(acl_test_data, RTE_DIM(acl_test_data), 0);\n+\tbswap_test_data(test_data, dim, 0);\n \treturn ret;\n }\n \n@@ -425,7 +425,8 @@ test_classify(void)\n \t\t\tbreak;\n \t\t}\n \n-\t\tret = test_classify_run(acx);\n+\t\tret = test_classify_run(acx, acl_test_data,\n+\t\t\tRTE_DIM(acl_test_data));\n \t\tif (ret != 0) {\n \t\t\tprintf(\"Line %i, iter: %d: %s failed!\\n\",\n \t\t\t\t__LINE__, i, __func__);\n@@ -434,7 +435,8 @@ test_classify(void)\n \n \t\t/* reset rules and make sure that classify still works ok. */\n \t\trte_acl_reset_rules(acx);\n-\t\tret = test_classify_run(acx);\n+\t\tret = test_classify_run(acx, acl_test_data,\n+\t\t\tRTE_DIM(acl_test_data));\n \t\tif (ret != 0) {\n \t\t\tprintf(\"Line %i, iter: %d: %s failed!\\n\",\n \t\t\t\t__LINE__, i, __func__);\n@@ -925,7 +927,8 @@ test_convert_rules(const char *desc,\n \t\t\tbreak;\n \t\t}\n \n-\t\trc = test_classify_run(acx);\n+\t\trc = test_classify_run(acx, acl_test_data,\n+\t\t\tRTE_DIM(acl_test_data));\n \t\tif (rc != 0)\n \t\t\tprintf(\"%s failed at line %i, max_size=%zu\\n\",\n \t\t\t\t__func__, __LINE__, mem_sizes[i]);\n@@ -1597,6 +1600,119 @@ test_misc(void)\n \treturn 0;\n }\n \n+static uint32_t\n+get_u32_range_max(void)\n+{\n+\tuint32_t i, max;\n+\n+\tmax = 0;\n+\tfor (i = 0; i != RTE_DIM(acl_u32_range_test_rules); i++)\n+\t\tmax = RTE_MAX(max, acl_u32_range_test_rules[i].src_mask_len);\n+\treturn max;\n+}\n+\n+static uint32_t\n+get_u32_range_min(void)\n+{\n+\tuint32_t i, min;\n+\n+\tmin = UINT32_MAX;\n+\tfor (i = 0; i != RTE_DIM(acl_u32_range_test_rules); i++)\n+\t\tmin = RTE_MIN(min, acl_u32_range_test_rules[i].src_addr);\n+\treturn min;\n+}\n+\n+static const struct rte_acl_ipv4vlan_rule *\n+find_u32_range_rule(uint32_t val)\n+{\n+\tuint32_t i;\n+\n+\tfor (i = 0; i != RTE_DIM(acl_u32_range_test_rules); i++) {\n+\t\tif (val >= acl_u32_range_test_rules[i].src_addr &&\n+\t\t\t\tval <= acl_u32_range_test_rules[i].src_mask_len)\n+\t\t\treturn acl_u32_range_test_rules + i;\n+\t}\n+\treturn NULL;\n+}\n+\n+static void\n+fill_u32_range_data(struct ipv4_7tuple tdata[], uint32_t start, uint32_t num)\n+{\n+\tuint32_t i;\n+\tconst struct rte_acl_ipv4vlan_rule *r;\n+\n+\tfor (i = 0; i != num; i++) {\n+\t\ttdata[i].ip_src = start + i;\n+\t\tr = find_u32_range_rule(start + i);\n+\t\tif (r != NULL)\n+\t\t\ttdata[i].allow = r->data.userdata;\n+\t}\n+}\n+\n+static int\n+test_u32_range(void)\n+{\n+\tint32_t rc;\n+\tuint32_t i, k, max, min;\n+\tstruct rte_acl_ctx *acx;\n+\tstruct acl_ipv4vlan_rule r;\n+\tstruct ipv4_7tuple test_data[64];\n+\n+\tacx = rte_acl_create(&acl_param);\n+\tif (acx == NULL) {\n+\t\tprintf(\"%s#%i: Error creating ACL context!\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\treturn -1;\n+\t}\n+\n+\tfor (i = 0; i != RTE_DIM(acl_u32_range_test_rules); i++) {\n+\t\tconvert_rule(&acl_u32_range_test_rules[i], &r);\n+\t\trc = rte_acl_add_rules(acx, (struct rte_acl_rule *)&r, 1);\n+\t\tif (rc != 0) {\n+\t\t\tprintf(\"%s#%i: Adding rule to ACL context \"\n+\t\t\t\t\"failed with error code: %d\\n\",\n+\t\t\t\t__func__, __LINE__, rc);\n+\t\t\trte_acl_free(acx);\n+\t\t\treturn rc;\n+\t\t}\n+\t}\n+\n+\trc = build_convert_rules(acx, convert_config_2, 0);\n+\tif (rc != 0) {\n+\t\tprintf(\"%s#%i Error @ build_convert_rules!\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\trte_acl_free(acx);\n+\t\treturn rc;\n+\t}\n+\n+\tmax = get_u32_range_max();\n+\tmin = get_u32_range_min();\n+\n+\tmax = RTE_MAX(max, max + 1);\n+\tmin = RTE_MIN(min, min - 1);\n+\n+\tprintf(\"%s#%d starting range test from %u to %u\\n\",\n+\t\t__func__, __LINE__, min, max);\n+\n+\tfor (i = min; i <= max; i += k) {\n+\n+\t\tk = RTE_MIN(max - i + 1, RTE_DIM(test_data));\n+\n+\t\tmemset(test_data, 0, sizeof(test_data));\n+\t\tfill_u32_range_data(test_data, i, k);\n+\n+\t\trc = test_classify_run(acx, test_data, k);\n+\t\tif (rc != 0) {\n+\t\t\tprintf(\"%s#%d failed at [%u, %u) interval\\n\",\n+\t\t\t\t__func__, __LINE__, i, i + k);\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\trte_acl_free(acx);\n+\treturn rc;\n+}\n+\n static int\n test_acl(void)\n {\n@@ -1616,6 +1732,8 @@ test_acl(void)\n \t\treturn -1;\n \tif (test_convert() < 0)\n \t\treturn -1;\n+\tif (test_u32_range() < 0)\n+\t\treturn -1;\n \n \treturn 0;\n }\ndiff --git a/app/test/test_acl.h b/app/test/test_acl.h\nindex 4f6e659c7..4cdead0b7 100644\n--- a/app/test/test_acl.h\n+++ b/app/test/test_acl.h\n@@ -666,4 +666,47 @@ struct ipv4_7tuple acl_test_data[] = {\n \t\t}, /* should not match */\n };\n \n+/*\n+ * ruleset for ACL 32 bit range (by src addr) unit test\n+ * keep them ordered by priority in descending order.\n+ */\n+struct rte_acl_ipv4vlan_rule acl_u32_range_test_rules[] = {\n+\t\t{\n+\t\t\t.data = {\n+\t\t\t\t.userdata = 500,\n+\t\t\t\t.category_mask = ACL_ALLOW_MASK,\n+\t\t\t\t.priority = 500\n+\t\t\t},\n+\t\t\t.src_addr = RTE_IPV4(0, 0, 0, 1),\n+\t\t\t.src_mask_len = RTE_IPV4(0, 0, 2, 58),\n+\t\t},\n+\t\t{\n+\t\t\t.data = {\n+\t\t\t\t.userdata = 400,\n+\t\t\t\t.category_mask = ACL_ALLOW_MASK,\n+\t\t\t\t.priority = 400\n+\t\t\t},\n+\t\t\t.src_addr = RTE_IPV4(0, 4, 3, 2),\n+\t\t\t.src_mask_len = RTE_IPV4(0, 4, 7, 255),\n+\t\t},\n+\t\t{\n+\t\t\t.data = {\n+\t\t\t\t.userdata = 300,\n+\t\t\t\t.category_mask = ACL_ALLOW_MASK,\n+\t\t\t\t.priority = 300\n+\t\t\t},\n+\t\t\t.src_addr = RTE_IPV4(0, 1, 12, 14),\n+\t\t\t.src_mask_len = RTE_IPV4(0, 3, 11, 13),\n+\t\t},\n+\t\t{\n+\t\t\t.data = {\n+\t\t\t\t.userdata = 200,\n+\t\t\t\t.category_mask = ACL_ALLOW_MASK,\n+\t\t\t\t.priority = 200\n+\t\t\t},\n+\t\t\t.src_addr = RTE_IPV4(0, 0, 1, 40),\n+\t\t\t.src_mask_len = RTE_IPV4(0, 4, 5, 6),\n+\t\t},\n+};\n+\n #endif /* TEST_ACL_H_ */\n", "prefixes": [ "2/2" ] }{ "id": 65764, "url": "