get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/91078/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 91078,
    "url": "http://patchwork.dpdk.org/api/patches/91078/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/1618168266-338017-4-git-send-email-vladimir.medvedkin@intel.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.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": "<1618168266-338017-4-git-send-email-vladimir.medvedkin@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1618168266-338017-4-git-send-email-vladimir.medvedkin@intel.com",
    "date": "2021-04-11T19:11:06",
    "name": "[v3,3/3] test/hash: add additional thash tests",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "60191d59f7c9d8d14a047a52f8d87049ae8579e0",
    "submitter": {
        "id": 1216,
        "url": "http://patchwork.dpdk.org/api/people/1216/?format=api",
        "name": "Vladimir Medvedkin",
        "email": "vladimir.medvedkin@intel.com"
    },
    "delegate": {
        "id": 24651,
        "url": "http://patchwork.dpdk.org/api/users/24651/?format=api",
        "username": "dmarchand",
        "first_name": "David",
        "last_name": "Marchand",
        "email": "david.marchand@redhat.com"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/1618168266-338017-4-git-send-email-vladimir.medvedkin@intel.com/mbox/",
    "series": [
        {
            "id": 16279,
            "url": "http://patchwork.dpdk.org/api/series/16279/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=16279",
            "date": "2021-04-11T19:11:03",
            "name": "Predictable RSS feature",
            "version": 3,
            "mbox": "http://patchwork.dpdk.org/series/16279/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/91078/comments/",
    "check": "fail",
    "checks": "http://patchwork.dpdk.org/api/patches/91078/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 mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 6764FA0524;\n\tSun, 11 Apr 2021 21:11:37 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 1D4E4141458;\n\tSun, 11 Apr 2021 21:11:27 +0200 (CEST)",
            "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n by mails.dpdk.org (Postfix) with ESMTP id C2B5E14144C\n for <dev@dpdk.org>; Sun, 11 Apr 2021 21:11:23 +0200 (CEST)",
            "from orsmga003.jf.intel.com ([10.7.209.27])\n by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 11 Apr 2021 12:11:22 -0700",
            "from silpixa00400072.ir.intel.com ([10.237.222.213])\n by orsmga003.jf.intel.com with ESMTP; 11 Apr 2021 12:11:20 -0700"
        ],
        "IronPort-SDR": [
            "\n hOK/8SZMTqTUazu2sbl089eSvvOyIox/uedmoH1cBUVUfxCnONmruRqmCdSAq/8lA4UZuBFU5N\n ymkdquAzr7OQ==",
            "\n DVcIayDCv6+DcWY1QObpzvkRA6N26u2/hgVmTfVfXTcLOJFH9svfF+e7aC7MbayWvAScwxiPiQ\n /aY7Me6kvGKg=="
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6000,8403,9951\"; a=\"190875043\"",
            "E=Sophos;i=\"5.82,214,1613462400\"; d=\"scan'208\";a=\"190875043\"",
            "E=Sophos;i=\"5.82,214,1613462400\"; d=\"scan'208\";a=\"381304924\""
        ],
        "X-ExtLoop1": "1",
        "From": "Vladimir Medvedkin <vladimir.medvedkin@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "konstantin.ananyev@intel.com, andrey.chilikin@intel.com,\n ray.kinsella@intel.com, yipeng1.wang@intel.com, sameh.gobriel@intel.com,\n bruce.richardson@intel.com",
        "Date": "Sun, 11 Apr 2021 20:11:06 +0100",
        "Message-Id": "<1618168266-338017-4-git-send-email-vladimir.medvedkin@intel.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": [
            "<1618168266-338017-1-git-send-email-vladimir.medvedkin@intel.com>",
            "<1617738643-258635-1-git-send-email-vladimir.medvedkin@intel.com>"
        ],
        "References": [
            "<1618168266-338017-1-git-send-email-vladimir.medvedkin@intel.com>",
            "<1617738643-258635-1-git-send-email-vladimir.medvedkin@intel.com>"
        ],
        "Subject": "[dpdk-dev] [PATCH v3 3/3] test/hash: add additional thash tests",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "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": "This patch adds tests for predictable RSS feature.\n\nSigned-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>\n---\n app/test/test_thash.c | 469 +++++++++++++++++++++++++++++++++++++++++++++++++-\n 1 file changed, 463 insertions(+), 6 deletions(-)",
    "diff": "diff --git a/app/test/test_thash.c b/app/test/test_thash.c\nindex a6aadd1..d8981fb 100644\n--- a/app/test/test_thash.c\n+++ b/app/test/test_thash.c\n@@ -5,11 +5,15 @@\n #include <rte_common.h>\n #include <rte_eal.h>\n #include <rte_ip.h>\n+#include <rte_random.h>\n \n #include \"test.h\"\n \n #include <rte_thash.h>\n \n+#define HASH_MSK(reta_sz)\t((1 << reta_sz) - 1)\n+#define TUPLE_SZ\t(RTE_THASH_V4_L4_LEN * 4)\n+\n struct test_thash_v4 {\n \tuint32_t\tdst_ip;\n \tuint32_t\tsrc_ip;\n@@ -75,7 +79,7 @@ uint8_t default_rss_key[] = {\n };\n \n static int\n-test_thash(void)\n+test_toeplitz_hash_calc(void)\n {\n \tuint32_t i, j;\n \tunion rte_thash_tuple tuple;\n@@ -100,7 +104,7 @@ test_thash(void)\n \t\t\t\tRTE_THASH_V4_L4_LEN, default_rss_key);\n \t\tif ((rss_l3 != v4_tbl[i].hash_l3) ||\n \t\t\t\t(rss_l3l4 != v4_tbl[i].hash_l3l4))\n-\t\t\treturn -1;\n+\t\t\treturn -TEST_FAILED;\n \t\t/*Calculate hash with converted key*/\n \t\trss_l3 = rte_softrss_be((uint32_t *)&tuple,\n \t\t\t\tRTE_THASH_V4_L3_LEN, rss_key_be);\n@@ -108,7 +112,7 @@ test_thash(void)\n \t\t\t\tRTE_THASH_V4_L4_LEN, rss_key_be);\n \t\tif ((rss_l3 != v4_tbl[i].hash_l3) ||\n \t\t\t\t(rss_l3l4 != v4_tbl[i].hash_l3l4))\n-\t\t\treturn -1;\n+\t\t\treturn -TEST_FAILED;\n \t}\n \tfor (i = 0; i < RTE_DIM(v6_tbl); i++) {\n \t\t/*Fill ipv6 hdr*/\n@@ -127,7 +131,7 @@ test_thash(void)\n \t\t\t\tRTE_THASH_V6_L4_LEN, default_rss_key);\n \t\tif ((rss_l3 != v6_tbl[i].hash_l3) ||\n \t\t\t\t(rss_l3l4 != v6_tbl[i].hash_l3l4))\n-\t\t\treturn -1;\n+\t\t\treturn -TEST_FAILED;\n \t\t/*Calculate hash with converted key*/\n \t\trss_l3 = rte_softrss_be((uint32_t *)&tuple,\n \t\t\t\tRTE_THASH_V6_L3_LEN, rss_key_be);\n@@ -135,9 +139,462 @@ test_thash(void)\n \t\t\t\tRTE_THASH_V6_L4_LEN, rss_key_be);\n \t\tif ((rss_l3 != v6_tbl[i].hash_l3) ||\n \t\t\t\t(rss_l3l4 != v6_tbl[i].hash_l3l4))\n-\t\t\treturn -1;\n+\t\t\treturn -TEST_FAILED;\n \t}\n-\treturn 0;\n+\treturn TEST_SUCCESS;\n+}\n+\n+static int\n+test_create_invalid(void)\n+{\n+\tstruct rte_thash_ctx *ctx;\n+\tint key_len = 40;\n+\tint reta_sz = 7;\n+\n+\tctx = rte_thash_init_ctx(NULL, key_len, reta_sz, NULL, 0);\n+\tRTE_TEST_ASSERT(ctx == NULL,\n+\t\t\"Call succeeded with invalid parameters\\n\");\n+\n+\tctx = rte_thash_init_ctx(\"test\", 0, reta_sz, NULL, 0);\n+\tRTE_TEST_ASSERT(ctx == NULL,\n+\t\t\"Call succeeded with invalid parameters\\n\");\n+\n+\tctx = rte_thash_init_ctx(NULL, key_len, 1, NULL, 0);\n+\tRTE_TEST_ASSERT(ctx == NULL,\n+\t\t\"Call succeeded with invalid parameters\\n\");\n+\n+\tctx = rte_thash_init_ctx(NULL, key_len, 17, NULL, 0);\n+\tRTE_TEST_ASSERT(ctx == NULL,\n+\t\t\"Call succeeded with invalid parameters\\n\");\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+static int\n+test_multiple_create(void)\n+{\n+\tstruct rte_thash_ctx *ctx;\n+\tint key_len = 40;\n+\tint reta_sz = 7;\n+\tint i;\n+\n+\tfor (i = 0; i < 100; i++) {\n+\t\tctx = rte_thash_init_ctx(\"test\", key_len, reta_sz, NULL, 0);\n+\t\tRTE_TEST_ASSERT(ctx != NULL, \"Can not create CTX\\n\");\n+\n+\t\trte_thash_free_ctx(ctx);\n+\t}\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+static int\n+test_free_null(void)\n+{\n+\tstruct rte_thash_ctx *ctx;\n+\n+\tctx = rte_thash_init_ctx(\"test\", 40, 7, NULL, 0);\n+\tRTE_TEST_ASSERT(ctx != NULL, \"Can not create CTX\\n\");\n+\n+\trte_thash_free_ctx(ctx);\n+\trte_thash_free_ctx(NULL);\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+static int\n+test_add_invalid_helper(void)\n+{\n+\tstruct rte_thash_ctx *ctx;\n+\tconst int key_len = 40;\n+\tint reta_sz = 7;\n+\tint ret;\n+\n+\tctx = rte_thash_init_ctx(\"test\", key_len, reta_sz, NULL, 0);\n+\tRTE_TEST_ASSERT(ctx != NULL, \"can not create thash ctx\\n\");\n+\n+\tret = rte_thash_add_helper(NULL, \"test\", reta_sz, 0);\n+\tRTE_TEST_ASSERT(ret == -EINVAL,\n+\t\t\"Call succeeded with invalid parameters\\n\");\n+\n+\tret = rte_thash_add_helper(ctx, NULL, reta_sz, 0);\n+\tRTE_TEST_ASSERT(ret == -EINVAL,\n+\t\t\"Call succeeded with invalid parameters\\n\");\n+\n+\tret = rte_thash_add_helper(ctx, \"test\", reta_sz - 1, 0);\n+\tRTE_TEST_ASSERT(ret == -EINVAL,\n+\t\t\"Call succeeded with invalid parameters\\n\");\n+\n+\tret = rte_thash_add_helper(ctx, \"test\", reta_sz, key_len * 8);\n+\tRTE_TEST_ASSERT(ret == -EINVAL,\n+\t\t\"Call succeeded with invalid parameters\\n\");\n+\n+\tret = rte_thash_add_helper(ctx, \"first_range\", reta_sz, 0);\n+\tRTE_TEST_ASSERT(ret == 0, \"Can not create helper\\n\");\n+\n+\tret = rte_thash_add_helper(ctx, \"first_range\", reta_sz, 0);\n+\tRTE_TEST_ASSERT(ret == -EEXIST,\n+\t\t\"Call succeeded with duplicated name\\n\");\n+\n+\t/*\n+\t * Create second helper with offset 3 * reta_sz.\n+\t * Note first_range helper created range in key:\n+\t * [0, 32 + length{= reta_sz} - 1), i.e [0, 37).\n+\t * second range is [44, 81)\n+\t */\n+\tret = rte_thash_add_helper(ctx, \"second_range\", reta_sz,\n+\t\t32 +  2 * reta_sz);\n+\tRTE_TEST_ASSERT(ret == 0, \"Can not create helper\\n\");\n+\n+\t/*\n+\t * Try to create overlapping with first_ and second_ ranges,\n+\t * i.e. [6, 49)\n+\t */\n+\tret = rte_thash_add_helper(ctx, \"third_range\", 2 * reta_sz, reta_sz);\n+\tRTE_TEST_ASSERT(ret == -EEXIST,\n+\t\t\"Call succeeded with overlapping ranges\\n\");\n+\n+\trte_thash_free_ctx(ctx);\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+static int\n+test_find_existing(void)\n+{\n+\tstruct rte_thash_ctx *ctx, *ret_ctx;\n+\n+\tctx = rte_thash_init_ctx(\"test\", 40, 7, NULL, 0);\n+\tRTE_TEST_ASSERT(ctx != NULL, \"can not create thash ctx\\n\");\n+\n+\tret_ctx = rte_thash_find_existing(\"test\");\n+\tRTE_TEST_ASSERT(ret_ctx != NULL, \"can not find existing ctx\\n\");\n+\n+\trte_thash_free_ctx(ctx);\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+static int\n+test_get_helper(void)\n+{\n+\tstruct rte_thash_ctx *ctx;\n+\tstruct rte_thash_subtuple_helper *h;\n+\tint ret;\n+\n+\tctx = rte_thash_init_ctx(\"test\", 40, 7, NULL, 0);\n+\tRTE_TEST_ASSERT(ctx != NULL, \"Can not create thash ctx\\n\");\n+\n+\th = rte_thash_get_helper(NULL, \"first_range\");\n+\tRTE_TEST_ASSERT(h == NULL, \"Call succeeded with invalid parameters\\n\");\n+\n+\th = rte_thash_get_helper(ctx, NULL);\n+\tRTE_TEST_ASSERT(h == NULL, \"Call succeeded with invalid parameters\\n\");\n+\n+\tret = rte_thash_add_helper(ctx, \"first_range\", 8, 0);\n+\tRTE_TEST_ASSERT(ret == 0, \"Can not create helper\\n\");\n+\n+\th = rte_thash_get_helper(ctx, \"first_range\");\n+\tRTE_TEST_ASSERT(h != NULL, \"Can not find helper\\n\");\n+\n+\trte_thash_free_ctx(ctx);\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+static int\n+test_period_overflow(void)\n+{\n+\tstruct rte_thash_ctx *ctx;\n+\tint reta_sz = 7; /* reflects polynomial degree */\n+\tint ret;\n+\n+\t/* first create without RTE_THASH_IGNORE_PERIOD_OVERFLOW flag */\n+\tctx = rte_thash_init_ctx(\"test\", 40, reta_sz, NULL, 0);\n+\tRTE_TEST_ASSERT(ctx != NULL, \"Can not create thash ctx\\n\");\n+\n+\t/* requested range > (2^reta_sz) - 1 */\n+\tret = rte_thash_add_helper(ctx, \"test\", (1 << reta_sz), 0);\n+\tRTE_TEST_ASSERT(ret == -ENOSPC,\n+\t\t\"Call succeeded with invalid parameters\\n\");\n+\n+\t/* requested range == len + 32 - 1, smaller than (2^reta_sz) - 1 */\n+\tret = rte_thash_add_helper(ctx, \"test\", (1 << reta_sz) - 32, 0);\n+\tRTE_TEST_ASSERT(ret == 0, \"Can not create helper\\n\");\n+\n+\trte_thash_free_ctx(ctx);\n+\n+\t/* create with RTE_THASH_IGNORE_PERIOD_OVERFLOW flag */\n+\tctx = rte_thash_init_ctx(\"test\", 40, reta_sz, NULL,\n+\t\tRTE_THASH_IGNORE_PERIOD_OVERFLOW);\n+\tRTE_TEST_ASSERT(ctx != NULL, \"Can not create thash ctx\\n\");\n+\n+\t/* requested range > (2^reta_sz - 1) */\n+\tret = rte_thash_add_helper(ctx, \"test\", (1 << reta_sz) + 10, 0);\n+\tRTE_TEST_ASSERT(ret == 0, \"Can not create helper\\n\");\n+\n+\trte_thash_free_ctx(ctx);\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+static int\n+test_predictable_rss_min_seq(void)\n+{\n+\tstruct rte_thash_ctx *ctx;\n+\tstruct rte_thash_subtuple_helper *h;\n+\tconst int key_len = 40;\n+\tint reta_sz = 6;\n+\tuint8_t initial_key[key_len];\n+\tconst uint8_t *new_key;\n+\tint ret;\n+\tunion rte_thash_tuple tuple;\n+\tuint32_t orig_hash, adj_hash, adj;\n+\tunsigned int desired_value = 27 & HASH_MSK(reta_sz);\n+\tuint16_t port_value = 22;\n+\n+\tmemset(initial_key, 0, key_len);\n+\n+\tctx = rte_thash_init_ctx(\"test\", key_len, reta_sz, initial_key,\n+\t\tRTE_THASH_MINIMAL_SEQ);\n+\tRTE_TEST_ASSERT(ctx != NULL, \"can not create thash ctx\\n\");\n+\n+\tret = rte_thash_add_helper(ctx, \"snat\", sizeof(uint16_t) * 8,\n+\t\toffsetof(union rte_thash_tuple, v4.sport) * 8);\n+\tRTE_TEST_ASSERT(ret == 0, \"can not add helper, ret %d\\n\", ret);\n+\n+\th = rte_thash_get_helper(ctx, \"snat\");\n+\tRTE_TEST_ASSERT(h != NULL, \"can not find helper\\n\");\n+\n+\tnew_key = rte_thash_get_key(ctx);\n+\ttuple.v4.src_addr = RTE_IPV4(0, 0, 0, 0);\n+\ttuple.v4.dst_addr = RTE_IPV4(0, 0, 0, 0);\n+\ttuple.v4.sport = 0;\n+\ttuple.v4.sport = rte_cpu_to_be_16(port_value);\n+\ttuple.v4.dport = 0;\n+\ttuple.v4.sctp_tag = rte_be_to_cpu_32(tuple.v4.sctp_tag);\n+\n+\torig_hash = rte_softrss((uint32_t *)&tuple,\n+\t\tRTE_THASH_V4_L4_LEN, new_key);\n+\tadj = rte_thash_get_complement(h, orig_hash, desired_value);\n+\n+\ttuple.v4.sctp_tag = rte_cpu_to_be_32(tuple.v4.sctp_tag);\n+\ttuple.v4.sport ^= rte_cpu_to_be_16(adj);\n+\ttuple.v4.sctp_tag = rte_be_to_cpu_32(tuple.v4.sctp_tag);\n+\n+\tadj_hash = rte_softrss((uint32_t *)&tuple,\n+\t\tRTE_THASH_V4_L4_LEN, new_key);\n+\tRTE_TEST_ASSERT((adj_hash & HASH_MSK(reta_sz)) ==\n+\t\tdesired_value, \"bad desired value\\n\");\n+\n+\trte_thash_free_ctx(ctx);\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+/*\n+ * This test creates 7 subranges in the following order:\n+ * range_one\t= [56, 95),\tlen = 8, offset = 56\n+ * range_two\t= [64, 103),\tlen = 8, offset = 64\n+ * range_three\t= [120, 159),\tlen = 8, offset = 120\n+ * range_four\t= [48, 87),\tlen = 8, offset = 48\n+ * range_five\t= [57, 95),\tlen = 7, offset = 57\n+ * range_six\t= [40, 111),\tlen = 40, offset = 40\n+ * range_seven\t= [0, 39),\tlen = 8, offset = 0\n+ */\n+struct range {\n+\tconst char *name;\n+\tint len;\n+\tint offset;\n+\tint byte_idx;\n+};\n+\n+struct range rng_arr[] = {\n+\t{\"one\",   8,  56,  7},\n+\t{\"two\",   8,  64,  8},\n+\t{\"three\", 8,  120, 15},\n+\t{\"four\",  8,  48,  6},\n+\t{\"six\",   40, 40,  9},\n+\t{\"five\",  7,  57,  7},\n+\t{\"seven\", 8,  0,   0}\n+};\n+\n+static int\n+test_predictable_rss_multirange(void)\n+{\n+\tstruct rte_thash_ctx *ctx;\n+\tstruct rte_thash_subtuple_helper *h[RTE_DIM(rng_arr)];\n+\tconst uint8_t *new_key;\n+\tconst int key_len = 40;\n+\tint reta_sz = 7;\n+\tunsigned int i, j, k;\n+\tint ret;\n+\tuint32_t desired_value = rte_rand() & HASH_MSK(reta_sz);\n+\tuint8_t tuples[RTE_DIM(rng_arr)][16] = { {0} };\n+\tuint32_t *ptr;\n+\tuint32_t hashes[RTE_DIM(rng_arr)];\n+\tuint32_t adj_hashes[RTE_DIM(rng_arr)];\n+\tuint32_t adj;\n+\n+\tctx = rte_thash_init_ctx(\"test\", key_len, reta_sz, NULL, 0);\n+\tRTE_TEST_ASSERT(ctx != NULL, \"can not create thash ctx\\n\");\n+\n+\tfor (i = 0; i < RTE_DIM(rng_arr); i++) {\n+\t\tret = rte_thash_add_helper(ctx, rng_arr[i].name,\n+\t\t\trng_arr[i].len, rng_arr[i].offset);\n+\t\tRTE_TEST_ASSERT(ret == 0, \"can not add helper\\n\");\n+\n+\t\th[i] = rte_thash_get_helper(ctx, rng_arr[i].name);\n+\t\tRTE_TEST_ASSERT(h[i] != NULL, \"can not find helper\\n\");\n+\t}\n+\tnew_key = rte_thash_get_key(ctx);\n+\n+\t/*\n+\t * calculate hashes, complements, then adjust keys with\n+\t * complements and recalsulate hashes\n+\t */\n+\tfor (i = 0; i < RTE_DIM(rng_arr); i++) {\n+\t\tfor (k = 0; k < 100; k++) {\n+\t\t\t/* init with random keys */\n+\t\t\tptr = (uint32_t *)&tuples[i][0];\n+\t\t\tfor (j = 0; j < 4; j++)\n+\t\t\t\tptr[j] = rte_rand();\n+\t\t\t/* convert keys from BE to CPU byte order */\n+\t\t\tfor (j = 0; j < 4; j++)\n+\t\t\t\tptr[j] = rte_be_to_cpu_32(ptr[j]);\n+\n+\t\t\thashes[i] = rte_softrss(ptr, 4, new_key);\n+\t\t\tadj = rte_thash_get_complement(h[i], hashes[i],\n+\t\t\t\tdesired_value);\n+\t\t\t/* convert back to BE to adjust the value */\n+\t\t\tfor (j = 0; j < 4; j++)\n+\t\t\t\tptr[j] = rte_cpu_to_be_32(ptr[j]);\n+\n+\t\t\ttuples[i][rng_arr[i].byte_idx] ^= adj;\n+\n+\t\t\tfor (j = 0; j < 4; j++)\n+\t\t\t\tptr[j] = rte_be_to_cpu_32(ptr[j]);\n+\n+\t\t\tadj_hashes[i] = rte_softrss(ptr, 4, new_key);\n+\t\t\tRTE_TEST_ASSERT((adj_hashes[i] & HASH_MSK(reta_sz)) ==\n+\t\t\t\tdesired_value,\n+\t\t\t\t\"bad desired value for %d tuple\\n\", i);\n+\t\t}\n+\t}\n+\n+\trte_thash_free_ctx(ctx);\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+static int\n+cmp_tuple_eq(void *userdata, uint8_t *tuple)\n+{\n+\treturn memcmp(userdata, tuple, TUPLE_SZ);\n+}\n+\n+static int\n+test_adjust_tuple(void)\n+{\n+\tstruct rte_thash_ctx *ctx;\n+\tstruct rte_thash_subtuple_helper *h;\n+\tconst int key_len = 40;\n+\tconst uint8_t *new_key;\n+\tuint8_t tuple[TUPLE_SZ];\n+\tuint32_t tmp_tuple[TUPLE_SZ / sizeof(uint32_t)];\n+\tuint32_t tuple_copy[TUPLE_SZ / sizeof(uint32_t)];\n+\tuint32_t hash;\n+\tint reta_sz = CHAR_BIT;\n+\tint ret;\n+\tunsigned int i, desired_value = rte_rand() & HASH_MSK(reta_sz);\n+\n+\tmemset(tuple, 0xab, TUPLE_SZ);\n+\n+\tctx = rte_thash_init_ctx(\"test\", key_len, reta_sz, NULL, 0);\n+\tRTE_TEST_ASSERT(ctx != NULL, \"can not create thash ctx\\n\");\n+\n+\t/*\n+\t * set offset to be in the middle of a byte\n+\t * set size of the subtuple to be 2 * rets_sz\n+\t * to have the room for random bits\n+\t */\n+\tret = rte_thash_add_helper(ctx, \"test\", reta_sz * 2,\n+\t\t(5 * CHAR_BIT) + 4);\n+\tRTE_TEST_ASSERT(ret == 0, \"can not add helper, ret %d\\n\", ret);\n+\n+\tnew_key = rte_thash_get_key(ctx);\n+\n+\th = rte_thash_get_helper(ctx, \"test\");\n+\tRTE_TEST_ASSERT(h != NULL, \"can not find helper\\n\");\n+\n+\tret = rte_thash_adjust_tuple(ctx, h, tuple, TUPLE_SZ, desired_value,\n+\t\t1, NULL, NULL);\n+\tRTE_TEST_ASSERT(ret == 0, \"can not adjust tuple, ret %d\\n\", ret);\n+\n+\tfor (i = 0; i < (TUPLE_SZ / 4); i++)\n+\t\ttmp_tuple[i] =\n+\t\t\trte_be_to_cpu_32(*(uint32_t *)&tuple[i * 4]);\n+\n+\thash = rte_softrss(tmp_tuple, TUPLE_SZ / 4, new_key);\n+\tRTE_TEST_ASSERT((hash & HASH_MSK(reta_sz)) ==\n+\t\tdesired_value, \"bad desired value\\n\");\n+\n+\n+\t/* Pass previously calculated tuple to callback function */\n+\tmemcpy(tuple_copy, tuple, TUPLE_SZ);\n+\n+\tmemset(tuple, 0xab, TUPLE_SZ);\n+\tret = rte_thash_adjust_tuple(ctx, h, tuple, TUPLE_SZ, desired_value,\n+\t\t1, cmp_tuple_eq, tuple_copy);\n+\tRTE_TEST_ASSERT(ret == -EEXIST,\n+\t\t\"adjust tuple didn't indicate collision\\n\");\n+\n+\t/*\n+\t * Make the function to generate random bits into subtuple\n+\t * after first adjustment attempt.\n+\t */\n+\tmemset(tuple, 0xab, TUPLE_SZ);\n+\tret = rte_thash_adjust_tuple(ctx, h, tuple, TUPLE_SZ, desired_value,\n+\t\t2, cmp_tuple_eq, tuple_copy);\n+\tRTE_TEST_ASSERT(ret == 0, \"can not adjust tuple, ret %d\\n\", ret);\n+\n+\tfor (i = 0; i < (TUPLE_SZ / 4); i++)\n+\t\ttmp_tuple[i] =\n+\t\t\trte_be_to_cpu_32(*(uint32_t *)&tuple[i * 4]);\n+\n+\thash = rte_softrss(tmp_tuple, TUPLE_SZ / 4, new_key);\n+\tRTE_TEST_ASSERT((hash & HASH_MSK(reta_sz)) ==\n+\t\tdesired_value, \"bad desired value\\n\");\n+\n+\trte_thash_free_ctx(ctx);\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+static struct unit_test_suite thash_tests = {\n+\t.suite_name = \"thash autotest\",\n+\t.setup = NULL,\n+\t.teardown = NULL,\n+\t.unit_test_cases = {\n+\tTEST_CASE(test_toeplitz_hash_calc),\n+\tTEST_CASE(test_create_invalid),\n+\tTEST_CASE(test_multiple_create),\n+\tTEST_CASE(test_free_null),\n+\tTEST_CASE(test_add_invalid_helper),\n+\tTEST_CASE(test_find_existing),\n+\tTEST_CASE(test_get_helper),\n+\tTEST_CASE(test_period_overflow),\n+\tTEST_CASE(test_predictable_rss_min_seq),\n+\tTEST_CASE(test_predictable_rss_multirange),\n+\tTEST_CASE(test_adjust_tuple),\n+\tTEST_CASES_END()\n+\t}\n+};\n+\n+static int\n+test_thash(void)\n+{\n+\treturn unit_test_suite_runner(&thash_tests);\n }\n \n REGISTER_TEST_COMMAND(thash_autotest, test_thash);\n",
    "prefixes": [
        "v3",
        "3/3"
    ]
}