Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/103529/?format=api
http://patchwork.dpdk.org/api/patches/103529/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/1635878305-102888-3-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": "<1635878305-102888-3-git-send-email-vladimir.medvedkin@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1635878305-102888-3-git-send-email-vladimir.medvedkin@intel.com", "date": "2021-11-02T18:38:23", "name": "[v8,2/4] hash: add bulk toeplitz hash implementation", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "ae676ea98cc7080195c6056e7c42197a0a6db319", "submitter": { "id": 1216, "url": "http://patchwork.dpdk.org/api/people/1216/?format=api", "name": "Vladimir Medvedkin", "email": "vladimir.medvedkin@intel.com" }, "delegate": { "id": 1, "url": "http://patchwork.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/1635878305-102888-3-git-send-email-vladimir.medvedkin@intel.com/mbox/", "series": [ { "id": 20233, "url": "http://patchwork.dpdk.org/api/series/20233/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=20233", "date": "2021-11-02T18:38:21", "name": "optimized Toeplitz hash implementation", "version": 8, "mbox": "http://patchwork.dpdk.org/series/20233/mbox/" } ], "comments": "http://patchwork.dpdk.org/api/patches/103529/comments/", "check": "success", "checks": "http://patchwork.dpdk.org/api/patches/103529/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 1EC3CA0C4B;\n\tTue, 2 Nov 2021 19:38:46 +0100 (CET)", "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 0696641123;\n\tTue, 2 Nov 2021 19:38:36 +0100 (CET)", "from mga12.intel.com (mga12.intel.com [192.55.52.136])\n by mails.dpdk.org (Postfix) with ESMTP id 2BE144111B\n for <dev@dpdk.org>; Tue, 2 Nov 2021 19:38:34 +0100 (CET)", "from orsmga007.jf.intel.com ([10.7.209.58])\n by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 02 Nov 2021 11:38:33 -0700", "from silpixa00400072.ir.intel.com ([10.237.222.213])\n by orsmga007.jf.intel.com with ESMTP; 02 Nov 2021 11:38:31 -0700" ], "X-IronPort-AV": [ "E=McAfee;i=\"6200,9189,10156\"; a=\"211397029\"", "E=Sophos;i=\"5.87,203,1631602800\"; d=\"scan'208\";a=\"211397029\"", "E=Sophos;i=\"5.87,203,1631602800\"; d=\"scan'208\";a=\"489227698\"" ], "X-ExtLoop1": "1", "From": "Vladimir Medvedkin <vladimir.medvedkin@intel.com>", "To": "dev@dpdk.org", "Cc": "yipeng1.wang@intel.com, sameh.gobriel@intel.com,\n bruce.richardson@intel.com, konstantin.ananyev@intel.com,\n stephen@networkplumber.org, thomas@monjalon.net", "Date": "Tue, 2 Nov 2021 18:38:23 +0000", "Message-Id": "<1635878305-102888-3-git-send-email-vladimir.medvedkin@intel.com>", "X-Mailer": "git-send-email 2.7.4", "In-Reply-To": [ "<1635878305-102888-1-git-send-email-vladimir.medvedkin@intel.com>", "<1630944239-363648-1-git-send-email-vladimir.medvedkin@intel.com>" ], "References": [ "<1635878305-102888-1-git-send-email-vladimir.medvedkin@intel.com>", "<1630944239-363648-1-git-send-email-vladimir.medvedkin@intel.com>" ], "Subject": "[dpdk-dev] [PATCH v8 2/4] hash: add bulk toeplitz hash\n implementation", "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 a bulk version for the Toeplitz hash implemented\nwith Galios Fields New Instructions (GFNI).\n\nSigned-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>\nAcked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>\n---\n app/test/test_thash.c | 67 ++++++++++++++++++++++++++++-\n doc/guides/prog_guide/toeplitz_hash_lib.rst | 20 ++++++---\n lib/hash/rte_thash_gfni.h | 33 ++++++++++++++\n lib/hash/rte_thash_x86_gfni.h | 40 +++++++++++++++++\n 4 files changed, 154 insertions(+), 6 deletions(-)", "diff": "diff --git a/app/test/test_thash.c b/app/test/test_thash.c\nindex 22d784e..a625306 100644\n--- a/app/test/test_thash.c\n+++ b/app/test/test_thash.c\n@@ -230,6 +230,8 @@ enum {\n \tSCALAR_DATA_BUF_2_HASH_IDX,\n \tGFNI_DATA_BUF_1_HASH_IDX,\n \tGFNI_DATA_BUF_2_HASH_IDX,\n+\tGFNI_BULK_DATA_BUF_1_HASH_IDX,\n+\tGFNI_BULK_DATA_BUF_2_HASH_IDX,\n \tHASH_IDXES\n };\n \n@@ -241,6 +243,7 @@ test_toeplitz_hash_rand_data(void)\n \tuint32_t hash[HASH_IDXES] = { 0 };\n \tuint64_t rss_key_matrixes[RTE_DIM(default_rss_key)];\n \tint i, j;\n+\tuint8_t *bulk_data[2];\n \n \tif (!rte_thash_gfni_supported())\n \t\treturn TEST_SKIPPED;\n@@ -248,6 +251,9 @@ test_toeplitz_hash_rand_data(void)\n \trte_thash_complete_matrix(rss_key_matrixes, default_rss_key,\n \t\tRTE_DIM(default_rss_key));\n \n+\tfor (i = 0; i < 2; i++)\n+\t\tbulk_data[i] = (uint8_t *)data[i];\n+\n \tfor (i = 0; i < ITER; i++) {\n \t\tfor (j = 0; j < DATA_SZ; j++) {\n \t\t\tdata[0][j] = rte_rand();\n@@ -266,11 +272,18 @@ test_toeplitz_hash_rand_data(void)\n \t\thash[GFNI_DATA_BUF_2_HASH_IDX] = rte_thash_gfni(\n \t\t\trss_key_matrixes, (uint8_t *)data[1],\n \t\t\tDATA_SZ * sizeof(uint32_t));\n+\t\trte_thash_gfni_bulk(rss_key_matrixes,\n+\t\t\tDATA_SZ * sizeof(uint32_t), bulk_data,\n+\t\t\t&hash[GFNI_BULK_DATA_BUF_1_HASH_IDX], 2);\n \n \t\tif ((hash[SCALAR_DATA_BUF_1_HASH_IDX] !=\n \t\t\t\thash[GFNI_DATA_BUF_1_HASH_IDX]) ||\n+\t\t\t\t(hash[SCALAR_DATA_BUF_1_HASH_IDX] !=\n+\t\t\t\thash[GFNI_BULK_DATA_BUF_1_HASH_IDX]) ||\n \t\t\t\t(hash[SCALAR_DATA_BUF_2_HASH_IDX] !=\n-\t\t\t\thash[GFNI_DATA_BUF_2_HASH_IDX]))\n+\t\t\t\thash[GFNI_DATA_BUF_2_HASH_IDX]) ||\n+\t\t\t\t(hash[SCALAR_DATA_BUF_2_HASH_IDX] !=\n+\t\t\t\thash[GFNI_BULK_DATA_BUF_2_HASH_IDX]))\n \n \t\t\treturn -TEST_FAILED;\n \t}\n@@ -284,6 +297,57 @@ enum {\n };\n \n static int\n+test_toeplitz_hash_gfni_bulk(void)\n+{\n+\tuint32_t i, j;\n+\tunion rte_thash_tuple tuple[2];\n+\tuint8_t *tuples[2];\n+\tuint32_t rss[2] = { 0 };\n+\tuint64_t rss_key_matrixes[RTE_DIM(default_rss_key)];\n+\n+\tif (!rte_thash_gfni_supported())\n+\t\treturn TEST_SKIPPED;\n+\n+\t/* Convert RSS key into matrixes */\n+\trte_thash_complete_matrix(rss_key_matrixes, default_rss_key,\n+\t\tRTE_DIM(default_rss_key));\n+\n+\tfor (i = 0; i < RTE_DIM(tuples); i++) {\n+\t\t/* allocate memory enough for a biggest tuple */\n+\t\ttuples[i] = rte_zmalloc(NULL, RTE_THASH_V6_L4_LEN * 4, 0);\n+\t\tif (tuples[i] == NULL)\n+\t\t\treturn -TEST_FAILED;\n+\t}\n+\n+\tfor (i = 0; i < RTE_MIN(RTE_DIM(v4_tbl), RTE_DIM(v6_tbl)); i++) {\n+\t\t/*Load IPv4 headers and copy it into the corresponding tuple*/\n+\t\ttuple[0].v4.src_addr = rte_cpu_to_be_32(v4_tbl[i].src_ip);\n+\t\ttuple[0].v4.dst_addr = rte_cpu_to_be_32(v4_tbl[i].dst_ip);\n+\t\ttuple[0].v4.sport = rte_cpu_to_be_16(v4_tbl[i].dst_port);\n+\t\ttuple[0].v4.dport = rte_cpu_to_be_16(v4_tbl[i].src_port);\n+\t\trte_memcpy(tuples[0], &tuple[0], RTE_THASH_V4_L4_LEN * 4);\n+\n+\t\t/*Load IPv6 headers and copy it into the corresponding tuple*/\n+\t\tfor (j = 0; j < RTE_DIM(tuple[1].v6.src_addr); j++)\n+\t\t\ttuple[1].v6.src_addr[j] = v6_tbl[i].src_ip[j];\n+\t\tfor (j = 0; j < RTE_DIM(tuple[1].v6.dst_addr); j++)\n+\t\t\ttuple[1].v6.dst_addr[j] = v6_tbl[i].dst_ip[j];\n+\t\ttuple[1].v6.sport = rte_cpu_to_be_16(v6_tbl[i].dst_port);\n+\t\ttuple[1].v6.dport = rte_cpu_to_be_16(v6_tbl[i].src_port);\n+\t\trte_memcpy(tuples[1], &tuple[1], RTE_THASH_V6_L4_LEN * 4);\n+\n+\t\trte_thash_gfni_bulk(rss_key_matrixes, RTE_THASH_V6_L4_LEN * 4,\n+\t\t\ttuples, rss, 2);\n+\n+\t\tif ((rss[RSS_V4_IDX] != v4_tbl[i].hash_l3l4) ||\n+\t\t\t\t(rss[RSS_V6_IDX] != v6_tbl[i].hash_l3l4))\n+\t\t\treturn -TEST_FAILED;\n+\t}\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+static int\n test_big_tuple_gfni(void)\n {\n \tuint32_t arr[16];\n@@ -748,6 +812,7 @@ static struct unit_test_suite thash_tests = {\n \tTEST_CASE(test_toeplitz_hash_calc),\n \tTEST_CASE(test_toeplitz_hash_gfni),\n \tTEST_CASE(test_toeplitz_hash_rand_data),\n+\tTEST_CASE(test_toeplitz_hash_gfni_bulk),\n \tTEST_CASE(test_big_tuple_gfni),\n \tTEST_CASE(test_create_invalid),\n \tTEST_CASE(test_multiple_create),\ndiff --git a/doc/guides/prog_guide/toeplitz_hash_lib.rst b/doc/guides/prog_guide/toeplitz_hash_lib.rst\nindex acdd8c3..61eaafd 100644\n--- a/doc/guides/prog_guide/toeplitz_hash_lib.rst\n+++ b/doc/guides/prog_guide/toeplitz_hash_lib.rst\n@@ -19,11 +19,12 @@ to calculate the RSS hash sum to spread the traffic among the queues.\n Toeplitz hash function API\n --------------------------\n \n-There are three functions that provide calculation of the Toeplitz hash sum:\n+There are four functions that provide calculation of the Toeplitz hash sum:\n \n * ``rte_softrss()``\n * ``rte_softrss_be()``\n * ``rte_thash_gfni()``\n+* ``rte_thash_gfni_bulk()``\n \n First two functions are scalar implementation and take the parameters:\n \n@@ -38,11 +39,12 @@ to be exactly the same as the one installed on the NIC.\n The ``rte_softrss_be`` function is a faster implementation,\n but it expects ``rss_key`` to be converted to the host byte order.\n \n-The last function is vectorized implementation using\n-Galois Fields New Instructions. Could be used if ``rte_thash_gfni_supported`` returns true.\n-It expects the tuple to be in network byte order.\n+The last two functions are vectorized implementations using\n+Galois Fields New Instructions. Could be used if ``rte_thash_gfni_supported`` is true.\n+They expect the tuple to be in network byte order.\n \n-``rte_thash_gfni()`` calculates the hash value for a single tuple\n+``rte_thash_gfni()`` calculates the hash value for a single tuple, and\n+``rte_thash_gfni_bulk()`` bulk implementation of the rte_thash_gfni().\n \n ``rte_thash_gfni()`` takes the parameters:\n \n@@ -50,6 +52,14 @@ It expects the tuple to be in network byte order.\n * A pointer to the tuple.\n * A length of the tuple in bytes.\n \n+``rte_thash_gfni_bulk()`` takes the parameters:\n+\n+* A pointer to the matrices derived from the RSS hash key using ``rte_thash_complete_matrix()``.\n+* A length of the longest tuple in bytes.\n+* Array of the pointers on data to be hashed.\n+* Array of ``uint32_t`` where to put calculated Toeplitz hash values\n+* Number of tuples in a bulk.\n+\n ``rte_thash_complete_matrix()`` is a function that calculates matrices required by\n GFNI implementations from the RSS hash key. It takes the parameters:\n \ndiff --git a/lib/hash/rte_thash_gfni.h b/lib/hash/rte_thash_gfni.h\nindex bbacd41..e97d912 100644\n--- a/lib/hash/rte_thash_gfni.h\n+++ b/lib/hash/rte_thash_gfni.h\n@@ -45,6 +45,39 @@ rte_thash_gfni(const uint64_t *mtrx __rte_unused,\n \treturn 0;\n }\n \n+/**\n+ * Bulk implementation for Toeplitz hash.\n+ * Dummy implementation.\n+ *\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * @param m\n+ * Pointer to the matrices generated from the corresponding\n+ * RSS hash key using rte_thash_complete_matrix().\n+ * @param len\n+ * Length of the largest data buffer to be hashed.\n+ * @param tuple\n+ * Array of the pointers on data to be hashed.\n+ * Data must be in network byte order.\n+ * @param val\n+ * Array of uint32_t where to put calculated Toeplitz hash values\n+ * @param num\n+ * Number of tuples to hash.\n+ */\n+__rte_experimental\n+static inline void\n+rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,\n+\tint len __rte_unused, uint8_t *tuple[] __rte_unused,\n+\tuint32_t val[], uint32_t num)\n+{\n+\tunsigned int i;\n+\n+\tRTE_LOG(ERR, HASH, \"%s is undefined under given arch\\n\", __func__);\n+\tfor (i = 0; i < num; i++)\n+\t\tval[i] = 0;\n+}\n+\n #endif /* RTE_THASH_GFNI_DEFINED */\n \n #ifdef __cplusplus\ndiff --git a/lib/hash/rte_thash_x86_gfni.h b/lib/hash/rte_thash_x86_gfni.h\nindex 53486b6..c2889c3 100644\n--- a/lib/hash/rte_thash_x86_gfni.h\n+++ b/lib/hash/rte_thash_x86_gfni.h\n@@ -174,6 +174,46 @@ rte_thash_gfni(const uint64_t *m, const uint8_t *tuple, int len)\n \treturn val;\n }\n \n+/**\n+ * Bulk implementation for Toeplitz hash.\n+ *\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * @param m\n+ * Pointer to the matrices generated from the corresponding\n+ * RSS hash key using rte_thash_complete_matrix().\n+ * Note that @p len should not exceed the length of the rss_key minus 4.\n+ * @param len\n+ * Length of the largest data buffer to be hashed.\n+ * @param tuple\n+ * Array of the pointers on data to be hashed.\n+ * Data must be in network byte order.\n+ * @param val\n+ * Array of uint32_t where to put calculated Toeplitz hash values\n+ * @param num\n+ * Number of tuples to hash.\n+ */\n+__rte_experimental\n+static inline void\n+rte_thash_gfni_bulk(const uint64_t *mtrx, int len, uint8_t *tuple[],\n+\tuint32_t val[], uint32_t num)\n+{\n+\tuint32_t i;\n+\tuint32_t val_zero;\n+\t__m512i xor_acc;\n+\n+\tfor (i = 0; i != (num & ~1); i += 2) {\n+\t\txor_acc = __rte_thash_gfni(mtrx, tuple[i], tuple[i + 1], len);\n+\t\t__rte_thash_xor_reduce(xor_acc, val + i, val + i + 1);\n+\t}\n+\n+\tif (num & 1) {\n+\t\txor_acc = __rte_thash_gfni(mtrx, tuple[i], NULL, len);\n+\t\t__rte_thash_xor_reduce(xor_acc, val + i, &val_zero);\n+\t}\n+}\n+\n #endif /* _GFNI_ */\n \n #ifdef __cplusplus\n", "prefixes": [ "v8", "2/4" ] }{ "id": 103529, "url": "