Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1313/?format=api
https://patches.dpdk.org/api/patches/1313/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1416160760-16087-4-git-send-email-e_zhumabekov@sts.kz/", "project": { "id": 1, "url": "https://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": "<1416160760-16087-4-git-send-email-e_zhumabekov@sts.kz>", "list_archive_url": "https://inbox.dpdk.org/dev/1416160760-16087-4-git-send-email-e_zhumabekov@sts.kz", "date": "2014-11-16T17:59:19", "name": "[dpdk-dev,v2,3/4] hash: add fallback to software CRC32 implementation", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "939f1d8f2a4e02e34d3ed0a51557849674dc4968", "submitter": { "id": 36, "url": "https://patches.dpdk.org/api/people/36/?format=api", "name": "Yerden Zhumabekov", "email": "e_zhumabekov@sts.kz" }, "delegate": null, "mbox": "https://patches.dpdk.org/project/dpdk/patch/1416160760-16087-4-git-send-email-e_zhumabekov@sts.kz/mbox/", "series": [], "comments": "https://patches.dpdk.org/api/patches/1313/comments/", "check": "pending", "checks": "https://patches.dpdk.org/api/patches/1313/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@dpdk.org", "Delivered-To": "patchwork@dpdk.org", "Received": [ "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 5167E7FE5;\n\tSun, 16 Nov 2014 18:48:51 +0100 (CET)", "from mgw.gov.kz (mgw.gov.kz [89.218.88.242])\n\tby dpdk.org (Postfix) with ESMTP id 07B687FB4\n\tfor <dev@dpdk.org>; Sun, 16 Nov 2014 18:48:47 +0100 (CET)", "from mgw.gov.kz (mx.ctsat.kz [178.89.4.95])\n\tby mgw.gov.kz with ESMTP id sAGHww2p029789-sAGHww2r029789\n\t(version=TLSv1.0 cipher=AES128-SHA bits=128 verify=NO);\n\tSun, 16 Nov 2014 23:58:58 +0600", "from EXCASHUB2.rgp.local (192.168.40.53) by EdgeForefront.rgp.local\n\t(192.168.40.59) with Microsoft SMTP Server (TLS) id 14.2.247.3;\n\tSun, 16 Nov 2014 23:58:48 +0600", "from r220.rgp.local (192.168.59.10) by excashub2.rgp.local\n\t(192.168.40.48) with Microsoft SMTP Server (TLS) id 14.2.247.3;\n\tSun, 16 Nov 2014 23:59:03 +0600" ], "From": "Yerden Zhumabekov <e_zhumabekov@sts.kz>", "To": "<dev@dpdk.org>", "Date": "Sun, 16 Nov 2014 23:59:19 +0600", "Message-ID": "<1416160760-16087-4-git-send-email-e_zhumabekov@sts.kz>", "X-Mailer": "git-send-email 1.7.9.5", "In-Reply-To": "<1409724351-23786-1-git-send-email-e_zhumabekov@sts.kz>", "References": "<1409724351-23786-1-git-send-email-e_zhumabekov@sts.kz>", "MIME-Version": "1.0", "Content-Type": "text/plain", "X-Originating-IP": "[192.168.59.10]", "X-FEAS-SYSTEM-WL": "e_zhumabekov@sts.kz", "Subject": "[dpdk-dev] [PATCH v2 3/4] hash: add fallback to software CRC32\n\timplementation", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "patches and discussions about DPDK <dev.dpdk.org>", "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://dpdk.org/ml/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "Initially, SSE4.2 support is detected via CPUID instruction.\n\nAdded rte_hash_crc_set_alg() function to detect and set CRC32\nimplementation if necessary. SSE4.2 is allowed by default. If it's\nnot available, fall back to sw implementation.\n\nSigned-off-by: Yerden Zhumabekov <e_zhumabekov@sts.kz>\n---\n lib/librte_hash/rte_hash_crc.h | 60 ++++++++++++++++++++++++++++++++++++++--\n 1 file changed, 58 insertions(+), 2 deletions(-)", "diff": "diff --git a/lib/librte_hash/rte_hash_crc.h b/lib/librte_hash/rte_hash_crc.h\nindex 74e2d92..178b162 100644\n--- a/lib/librte_hash/rte_hash_crc.h\n+++ b/lib/librte_hash/rte_hash_crc.h\n@@ -45,7 +45,11 @@ extern \"C\" {\n #endif\n \n #include <stdint.h>\n+#ifdef RTE_MACHINE_CPUFLAG_SSE4_2\n #include <nmmintrin.h>\n+#endif\n+#include <rte_cpuflags.h>\n+#include <rte_branch_prediction.h>\n \n /* Lookup table for software implementation of CRC32C */\n static const uint32_t crc32c_table[256] = {\n@@ -152,8 +156,42 @@ crc32c_2words(uint64_t data, uint32_t init_val)\n \treturn init_val;\n }\n \n+enum crc32_alg_t {\n+\tCRC32_SW = 0,\n+\tCRC32_SSE42,\n+\tCRC32_AUTODETECT\n+};\n+\n+/* Default algorithm is left for autodetection,\n+ * it is detected on first run of hash function\n+ */\n+static enum crc32_alg_t crc32_alg = CRC32_AUTODETECT;\n+\n+/**\n+ * Allow or disallow use of SSE4.2 instrinsics for CRC32 hash\n+ * hash calculation.\n+ *\n+ * @param flag\n+ * unsigned integer flag\n+ * - (CRC32_SW) Don't use SSE4.2 intrinsics\n+ * - (CRC32_SSE42) Use SSE4.2 intrinsics if available, set by default\n+ */\n+static inline void\n+rte_hash_crc_set_alg(enum crc32_alg_t alg)\n+{\n+\tint sse42_supp = rte_cpu_get_flag_enabled(RTE_CPUFLAG_SSE4_2);\n+\tenum crc32_alg_t alg_supp = sse42_supp ? CRC32_SSE42 : CRC32_SW;\n+\n+\tif (alg == CRC32_SSE42)\n+\t\tcrc32_alg = alg_supp;\n+\telse\n+\t\tcrc32_alg = CRC32_SW;\n+}\n+\n /**\n * Use single crc32 instruction to perform a hash on a 4 byte value.\n+ * Fall back to software crc32 implementation in case SSE4.2 is\n+ * not supported\n *\n * @param data\n * Data to perform hash on.\n@@ -165,11 +203,21 @@ crc32c_2words(uint64_t data, uint32_t init_val)\n static inline uint32_t\n rte_hash_crc_4byte(uint32_t data, uint32_t init_val)\n {\n-\treturn _mm_crc32_u32(init_val, data);\n+\tif (unlikely(crc32_alg == CRC32_AUTODETECT))\n+\t\trte_hash_crc_set_alg(CRC32_SSE42);\n+\n+#ifdef RTE_MACHINE_CPUFLAG_SSE4_2\n+\tif (likely(crc32_alg == CRC32_SSE42))\n+\t\treturn _mm_crc32_u32(init_val, data);\n+#endif\n+\n+\treturn crc32c_1word(data, init_val);\n }\n \n /**\n * Use single crc32 instruction to perform a hash on a 8 byte value.\n+ * Fall back to software crc32 implementation in case SSE4.2 is\n+ * not supported\n *\n * @param data\n * Data to perform hash on.\n@@ -181,7 +229,15 @@ rte_hash_crc_4byte(uint32_t data, uint32_t init_val)\n static inline uint32_t\n rte_hash_crc_8byte(uint64_t data, uint32_t init_val)\n {\n-\treturn _mm_crc32_u64(init_val, data);\n+\tif (unlikely(crc32_alg == CRC32_AUTODETECT))\n+\t\trte_hash_crc_set_alg(CRC32_SSE42);\n+\n+#ifdef RTE_MACHINE_CPUFLAG_SSE4_2\n+\tif (likely(crc32_alg == CRC32_SSE42))\n+\t\treturn _mm_crc32_u64(init_val, data);\n+#endif\n+\n+\treturn crc32c_2words(data, init_val);\n }\n \n /**\n", "prefixes": [ "dpdk-dev", "v2", "3/4" ] }{ "id": 1313, "url": "