Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/68610/?format=api
http://patches.dpdk.org/api/patches/68610/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200416053853.440-2-joyce.kong@arm.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": "<20200416053853.440-2-joyce.kong@arm.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20200416053853.440-2-joyce.kong@arm.com", "date": "2020-04-16T05:38:48", "name": "[v8,1/6] lib/eal: implement the family of common bit operation APIs", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "379dce5d27bf4528514e32cbb4d181a7a2d313f5", "submitter": { "id": 970, "url": "http://patches.dpdk.org/api/people/970/?format=api", "name": "Joyce Kong", "email": "joyce.kong@arm.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/20200416053853.440-2-joyce.kong@arm.com/mbox/", "series": [ { "id": 9410, "url": "http://patches.dpdk.org/api/series/9410/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=9410", "date": "2020-04-16T05:38:47", "name": "implement common bit operation APIs", "version": 8, "mbox": "http://patches.dpdk.org/series/9410/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/68610/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/68610/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 2080CA0588;\n\tThu, 16 Apr 2020 07:39:37 +0200 (CEST)", "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id BC5AB1DA82;\n\tThu, 16 Apr 2020 07:39:36 +0200 (CEST)", "from foss.arm.com (foss.arm.com [217.140.110.172])\n by dpdk.org (Postfix) with ESMTP id 33C461DA75\n for <dev@dpdk.org>; Thu, 16 Apr 2020 07:39:35 +0200 (CEST)", "from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])\n by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BB8231FB;\n Wed, 15 Apr 2020 22:39:34 -0700 (PDT)", "from net-arm-thunderx2-03.shanghai.arm.com\n (net-arm-thunderx2-03.shanghai.arm.com [10.169.41.185])\n by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E6F093F6C4;\n Wed, 15 Apr 2020 22:43:45 -0700 (PDT)" ], "From": "Joyce Kong <joyce.kong@arm.com>", "To": "thomas@monjalon.net, stephen@networkplumber.org,\n david.marchand@redhat.com,\n mb@smartsharesystems.com, jerinj@marvell.com, bruce.richardson@intel.com,\n ravi1.kumar@amd.com, rmody@marvell.com, shshaikh@marvell.com,\n xuanziyang2@huawei.com, cloud.wangxiaoyun@huawei.com,\n zhouguoyang@huawei.com, honnappa.nagarahalli@arm.com, gavin.hu@arm.com,\n phil.yang@arm.com", "Cc": "nd@arm.com,\n\tdev@dpdk.org", "Date": "Thu, 16 Apr 2020 13:38:48 +0800", "Message-Id": "<20200416053853.440-2-joyce.kong@arm.com>", "X-Mailer": "git-send-email 2.17.1", "In-Reply-To": [ "<20200416053853.440-1-joyce.kong@arm.com>", "<1571125801-45773-1-git-send-email-joyce.kong@arm.com>" ], "References": [ "<20200416053853.440-1-joyce.kong@arm.com>", "<1571125801-45773-1-git-send-email-joyce.kong@arm.com>" ], "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[dpdk-dev] [PATCH v8 1/6] lib/eal: implement the family of common\n\tbit operation APIs", "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": "Bitwise operation APIs are defined and used in a lot of PMDs,\nwhich caused a huge code duplication. To reduce duplication,\nthis patch consolidates them into a common API family.\n\nSigned-off-by: Joyce Kong <joyce.kong@arm.com>\nReviewed-by: Gavin Hu <gavin.hu@arm.com>\nReviewed-by: Phil Yang <phil.yang@arm.com>\nAcked-by: Morten Brørup <mb@smartsharesystems.com>\n---\n MAINTAINERS | 4 +\n doc/api/doxy-api-index.md | 5 +-\n lib/librte_eal/include/meson.build | 1 +\n lib/librte_eal/include/rte_bitops.h | 258 ++++++++++++++++++++++++++++\n 4 files changed, 266 insertions(+), 2 deletions(-)\n create mode 100644 lib/librte_eal/include/rte_bitops.h", "diff": "diff --git a/MAINTAINERS b/MAINTAINERS\nindex 4800f6884..1d5fad28b 100644\n--- a/MAINTAINERS\n+++ b/MAINTAINERS\n@@ -241,6 +241,10 @@ M: Cristian Dumitrescu <cristian.dumitrescu@intel.com>\n F: lib/librte_eal/include/rte_bitmap.h\n F: app/test/test_bitmap.c\n \n+Bitops\n+M: Joyce Kong <joyce.kong@arm.com>\n+F: lib/librte_eal/include/rte_bitops.h\n+\n MCSlock - EXPERIMENTAL\n M: Phil Yang <phil.yang@arm.com>\n F: lib/librte_eal/include/generic/rte_mcslock.h\ndiff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md\nindex dff496be0..b63e782ec 100644\n--- a/doc/api/doxy-api-index.md\n+++ b/doc/api/doxy-api-index.md\n@@ -9,6 +9,7 @@ API {#index}\n The public API headers are grouped by topics:\n \n - **device**:\n+ [bitops] (@ref rte_bitops.h),\n [dev] (@ref rte_dev.h),\n [ethdev] (@ref rte_ethdev.h),\n [ethctrl] (@ref rte_eth_ctrl.h),\n@@ -133,12 +134,12 @@ The public API headers are grouped by topics:\n [BPF] (@ref rte_bpf.h)\n \n - **containers**:\n+ [bitmap] (@ref rte_bitmap.h),\n [mbuf] (@ref rte_mbuf.h),\n [mbuf pool ops] (@ref rte_mbuf_pool_ops.h),\n [ring] (@ref rte_ring.h),\n [stack] (@ref rte_stack.h),\n- [tailq] (@ref rte_tailq.h),\n- [bitmap] (@ref rte_bitmap.h)\n+ [tailq] (@ref rte_tailq.h)\n \n - **packet framework**:\n * [port] (@ref rte_port.h):\ndiff --git a/lib/librte_eal/include/meson.build b/lib/librte_eal/include/meson.build\nindex 6fd427494..3afb50a5b 100644\n--- a/lib/librte_eal/include/meson.build\n+++ b/lib/librte_eal/include/meson.build\n@@ -6,6 +6,7 @@ includes += include_directories('.')\n headers += files(\n \t'rte_alarm.h',\n \t'rte_bitmap.h',\n+\t'rte_bitops.h',\n \t'rte_branch_prediction.h',\n \t'rte_bus.h',\n \t'rte_class.h',\ndiff --git a/lib/librte_eal/include/rte_bitops.h b/lib/librte_eal/include/rte_bitops.h\nnew file mode 100644\nindex 000000000..b942b677c\n--- /dev/null\n+++ b/lib/librte_eal/include/rte_bitops.h\n@@ -0,0 +1,258 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2020 Arm Limited\n+ */\n+\n+#ifndef _RTE_BITOPS_H_\n+#define _RTE_BITOPS_H_\n+\n+/**\n+ * @file\n+ * Bit Operations\n+ *\n+ * This file defines a family of APIs for bit operations\n+ * without enforcing memory ordering.\n+ */\n+\n+#include <stdint.h>\n+#include <rte_debug.h>\n+#include <rte_compat.h>\n+\n+/*---------------------------- 32 bit operations ----------------------------*/\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice\n+ *\n+ * Get the target bit from a 32-bit value without memory ordering.\n+ *\n+ * @param nr\n+ * The target bit to get.\n+ * @param addr\n+ * The address holding the bit.\n+ * @return\n+ * The target bit.\n+ */\n+__rte_experimental\n+static inline uint32_t\n+rte_get_bit32_relaxed(unsigned int nr, volatile uint32_t *addr)\n+{\n+\tRTE_ASSERT(nr < 32);\n+\n+\tuint32_t mask = UINT32_C(1) << nr;\n+\treturn (*addr) & mask;\n+}\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice\n+ *\n+ * Set the target bit in a 32-bit value to 1 without memory ordering.\n+ *\n+ * @param nr\n+ * The target bit to set.\n+ * @param addr\n+ * The address holding the bit.\n+ */\n+__rte_experimental\n+static inline void\n+rte_set_bit32_relaxed(unsigned int nr, volatile uint32_t *addr)\n+{\n+\tRTE_ASSERT(nr < 32);\n+\n+\tuint32_t mask = UINT32_C(1) << nr;\n+\t*addr = (*addr) | mask;\n+}\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice\n+ *\n+ * Clear the target bit in a 32-bit value to 0 without memory ordering.\n+ *\n+ * @param nr\n+ * The target bit to clear.\n+ * @param addr\n+ * The address holding the bit.\n+ */\n+__rte_experimental\n+static inline void\n+rte_clear_bit32_relaxed(unsigned int nr, volatile uint32_t *addr)\n+{\n+\tRTE_ASSERT(nr < 32);\n+\n+\tuint32_t mask = UINT32_C(1) << nr;\n+\t*addr = (*addr) & (~mask);\n+}\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice\n+ *\n+ * Return the original bit from a 32-bit value, then set it to 1 without\n+ * memory ordering.\n+ *\n+ * @param nr\n+ * The target bit to get and set.\n+ * @param addr\n+ * The address holding the bit.\n+ * @return\n+ * The original bit.\n+ */\n+__rte_experimental\n+static inline uint32_t\n+rte_test_and_set_bit32_relaxed(unsigned int nr, volatile uint32_t *addr)\n+{\n+\tRTE_ASSERT(nr < 32);\n+\n+\tuint32_t mask = UINT32_C(1) << nr;\n+\tuint32_t val = *addr;\n+\t*addr = (*addr) | mask;\n+\treturn val & mask;\n+}\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice\n+ *\n+ * Return the original bit from a 32-bit value, then clear it to 0 without\n+ * memory ordering.\n+ *\n+ * @param nr\n+ * The target bit to get and clear.\n+ * @param addr\n+ * The address holding the bit.\n+ * @return\n+ * The original bit.\n+ */\n+__rte_experimental\n+static inline uint32_t\n+rte_test_and_clear_bit32_relaxed(unsigned int nr, volatile uint32_t *addr)\n+{\n+\tRTE_ASSERT(nr < 32);\n+\n+\tuint32_t mask = UINT32_C(1) << nr;\n+\tuint32_t val = *addr;\n+\t*addr = (*addr) & (~mask);\n+\treturn val & mask;\n+}\n+\n+/*---------------------------- 64 bit operations ----------------------------*/\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice\n+ *\n+ * Get the target bit from a 64-bit value without memory ordering.\n+ *\n+ * @param nr\n+ * The target bit to get.\n+ * @param addr\n+ * The address holding the bit.\n+ * @return\n+ * The target bit.\n+ */\n+__rte_experimental\n+static inline uint64_t\n+rte_get_bit64_relaxed(unsigned int nr, volatile uint64_t *addr)\n+{\n+\tRTE_ASSERT(nr < 64);\n+\n+\tuint64_t mask = UINT64_C(1) << nr;\n+\treturn (*addr) & mask;\n+}\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice\n+ *\n+ * Set the target bit in a 64-bit value to 1 without memory ordering.\n+ *\n+ * @param nr\n+ * The target bit to set.\n+ * @param addr\n+ * The address holding the bit.\n+ */\n+__rte_experimental\n+static inline void\n+rte_set_bit64_relaxed(unsigned int nr, volatile uint64_t *addr)\n+{\n+\tRTE_ASSERT(nr < 64);\n+\n+\tuint64_t mask = UINT64_C(1) << nr;\n+\t(*addr) = (*addr) | mask;\n+}\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice\n+ *\n+ * Clear the target bit in a 64-bit value to 0 without memory ordering.\n+ *\n+ * @param nr\n+ * The target bit to clear.\n+ * @param addr\n+ * The address holding the bit.\n+ */\n+__rte_experimental\n+static inline void\n+rte_clear_bit64_relaxed(unsigned int nr, volatile uint64_t *addr)\n+{\n+\tRTE_ASSERT(nr < 64);\n+\n+\tuint64_t mask = UINT64_C(1) << nr;\n+\t*addr = (*addr) & (~mask);\n+}\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice\n+ *\n+ * Return the original bit from a 64-bit value, then set it to 1 without\n+ * memory ordering.\n+ *\n+ * @param nr\n+ * The target bit to get and set.\n+ * @param addr\n+ * The address holding the bit.\n+ * @return\n+ * The original bit.\n+ */\n+__rte_experimental\n+static inline uint64_t\n+rte_test_and_set_bit64_relaxed(unsigned int nr, volatile uint64_t *addr)\n+{\n+\tRTE_ASSERT(nr < 64);\n+\n+\tuint64_t mask = UINT64_C(1) << nr;\n+\tuint64_t val = *addr;\n+\t*addr = (*addr) | mask;\n+\treturn val;\n+}\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice\n+ *\n+ * Return the original bit from a 64-bit value, then clear it to 0 without\n+ * memory ordering.\n+ *\n+ * @param nr\n+ * The target bit to get and clear.\n+ * @param addr\n+ * The address holding the bit.\n+ * @return\n+ * The original bit.\n+ */\n+__rte_experimental\n+static inline uint64_t\n+rte_test_and_clear_bit64_relaxed(unsigned int nr, volatile uint64_t *addr)\n+{\n+\tRTE_ASSERT(nr < 64);\n+\n+\tuint64_t mask = UINT64_C(1) << nr;\n+\tuint64_t val = *addr;\n+\t*addr = (*addr) & (~mask);\n+\treturn val & mask;\n+}\n+\n+#endif /* _RTE_BITOPS_H_ */\n", "prefixes": [ "v8", "1/6" ] }{ "id": 68610, "url": "