Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/986/?format=api
http://patches.dpdk.org/api/patches/986/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/1414500657-23774-7-git-send-email-david.marchand@6wind.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": "<1414500657-23774-7-git-send-email-david.marchand@6wind.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1414500657-23774-7-git-send-email-david.marchand@6wind.com", "date": "2014-10-28T12:50:53", "name": "[dpdk-dev,v3,06/10] eal: split spinlock operations to architecture specific", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "7b2d27b2fec7b3cf9cde935b6d7c795df425c9d4", "submitter": { "id": 3, "url": "http://patches.dpdk.org/api/people/3/?format=api", "name": "David Marchand", "email": "david.marchand@6wind.com" }, "delegate": null, "mbox": "http://patches.dpdk.org/project/dpdk/patch/1414500657-23774-7-git-send-email-david.marchand@6wind.com/mbox/", "series": [], "comments": "http://patches.dpdk.org/api/patches/986/comments/", "check": "pending", "checks": "http://patches.dpdk.org/api/patches/986/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 0749B7F29;\n\tTue, 28 Oct 2014 13:42:33 +0100 (CET)", "from mail-wg0-f41.google.com (mail-wg0-f41.google.com\n\t[74.125.82.41]) by dpdk.org (Postfix) with ESMTP id 4B61D7E96\n\tfor <dev@dpdk.org>; Tue, 28 Oct 2014 13:42:26 +0100 (CET)", "by mail-wg0-f41.google.com with SMTP id k14so766095wgh.24\n\tfor <dev@dpdk.org>; Tue, 28 Oct 2014 05:51:13 -0700 (PDT)", "from alcyon.dev.6wind.com (guy78-3-82-239-227-177.fbx.proxad.net.\n\t[82.239.227.177]) by mx.google.com with ESMTPSA id\n\tht9sm15314425wib.8.2014.10.28.05.51.12 for <multiple recipients>\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tTue, 28 Oct 2014 05:51:12 -0700 (PDT)" ], "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20130820;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=L40L2SU8bglcot157YV02pSq2YNGQlaotZkseLsa2CM=;\n\tb=YhR8MaL3ukZx1psKNJ/Hbbf0vGaUCrrnqgaJdExquA+WS1VthiBZ/KTm/VNJOm2U0R\n\t29SA1iUKm+EH4yCLlHxJPGAgEYP3NxlRQX8SX1hK7bDLoSgKPHjFCQwXg/ONaK3Bw+jR\n\tr/5AklzKvAHEE5KlJ7KuJv+sPyfMV2x0q31tALRpjlcXGMsoO2Y766WTDvM7IRgDdE8+\n\tHEg3+a8ojV6jFAteFAhBjO1xBtnW5Bh+4Lvgx59jmnpa7tCeYnfoK9/Prdd7Jb4XqG0a\n\tOFPPG2qQAG5bafxLgk3dgSyqVYm68L3LP2PynZS3MsWtpbgHISCqcmxQKc1R690qAEqS\n\tTVhA==", "X-Gm-Message-State": "ALoCoQlTz2YGDsCMjrI3s09FLpyD8iiJYZUctSSfnlbGzCuhJPOTTWDGITMNa034sqigYgUtGw/s", "X-Received": "by 10.194.90.175 with SMTP id bx15mr3904924wjb.25.1414500673463; \n\tTue, 28 Oct 2014 05:51:13 -0700 (PDT)", "From": "David Marchand <david.marchand@6wind.com>", "To": "dev@dpdk.org", "Date": "Tue, 28 Oct 2014 13:50:53 +0100", "Message-Id": "<1414500657-23774-7-git-send-email-david.marchand@6wind.com>", "X-Mailer": "git-send-email 1.7.10.4", "In-Reply-To": "<1414500657-23774-1-git-send-email-david.marchand@6wind.com>", "References": "<1414500657-23774-1-git-send-email-david.marchand@6wind.com>", "Cc": "bjzhuc@cn.ibm.com", "Subject": "[dpdk-dev] [PATCH v3 06/10] eal: split spinlock operations to\n\tarchitecture specific", "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": "From: Chao Zhu <bjzhuc@cn.ibm.com>\n\nThis patch splits the spinlock operations from DPDK and push them to\narchitecture specific arch directories, so that other processor\narchitecture to support DPDK can be easily adopted.\n\nSigned-off-by: Chao Zhu <bjzhuc@cn.ibm.com>\nSigned-off-by: David Marchand <david.marchand@6wind.com>\n---\n lib/librte_eal/common/Makefile | 3 +-\n .../common/include/arch/i686/rte_spinlock.h | 94 +++++++\n .../common/include/arch/x86_64/rte_spinlock.h | 94 +++++++\n .../common/include/generic/rte_spinlock.h | 226 +++++++++++++++++\n lib/librte_eal/common/include/rte_spinlock.h | 258 --------------------\n 5 files changed, 416 insertions(+), 259 deletions(-)\n create mode 100644 lib/librte_eal/common/include/arch/i686/rte_spinlock.h\n create mode 100644 lib/librte_eal/common/include/arch/x86_64/rte_spinlock.h\n create mode 100644 lib/librte_eal/common/include/generic/rte_spinlock.h\n delete mode 100644 lib/librte_eal/common/include/rte_spinlock.h", "diff": "diff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile\nindex 9808c9f..2394443 100644\n--- a/lib/librte_eal/common/Makefile\n+++ b/lib/librte_eal/common/Makefile\n@@ -35,7 +35,7 @@ INC := rte_branch_prediction.h rte_common.h\n INC += rte_debug.h rte_eal.h rte_errno.h rte_launch.h rte_lcore.h\n INC += rte_log.h rte_memcpy.h rte_memory.h rte_memzone.h rte_pci.h\n INC += rte_pci_dev_ids.h rte_per_lcore.h rte_random.h\n-INC += rte_rwlock.h rte_spinlock.h rte_tailq.h rte_interrupts.h rte_alarm.h\n+INC += rte_rwlock.h rte_tailq.h rte_interrupts.h rte_alarm.h\n INC += rte_string_fns.h rte_cpuflags.h rte_version.h rte_tailq_elem.h\n INC += rte_eal_memconfig.h rte_malloc_heap.h\n INC += rte_hexdump.h rte_devargs.h rte_dev.h\n@@ -47,6 +47,7 @@ INC += rte_warnings.h\n endif\n \n GENERIC_INC := rte_atomic.h rte_byteorder.h rte_cycles.h rte_prefetch.h\n+GENERIC_INC += rte_spinlock.h\n ARCH_INC := $(GENERIC_INC)\n \n SYMLINK-$(CONFIG_RTE_LIBRTE_EAL)-include := $(addprefix include/,$(INC))\ndiff --git a/lib/librte_eal/common/include/arch/i686/rte_spinlock.h b/lib/librte_eal/common/include/arch/i686/rte_spinlock.h\nnew file mode 100644\nindex 0000000..60cfd4d\n--- /dev/null\n+++ b/lib/librte_eal/common/include/arch/i686/rte_spinlock.h\n@@ -0,0 +1,94 @@\n+/*-\n+ * BSD LICENSE\n+ *\n+ * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n+ * All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions\n+ * are met:\n+ *\n+ * * Redistributions of source code must retain the above copyright\n+ * notice, this list of conditions and the following disclaimer.\n+ * * Redistributions in binary form must reproduce the above copyright\n+ * notice, this list of conditions and the following disclaimer in\n+ * the documentation and/or other materials provided with the\n+ * distribution.\n+ * * Neither the name of Intel Corporation nor the names of its\n+ * contributors may be used to endorse or promote products derived\n+ * from this software without specific prior written permission.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#ifndef _RTE_SPINLOCK_I686_H_\n+#define _RTE_SPINLOCK_I686_H_\n+\n+#ifdef __cplusplus\n+extern \"C\" {\n+#endif\n+\n+#include \"generic/rte_spinlock.h\"\n+\n+#ifndef RTE_FORCE_INTRINSICS\n+static inline void\n+rte_spinlock_lock(rte_spinlock_t *sl)\n+{\n+\tint lock_val = 1;\n+\tasm volatile (\n+\t\t\t\"1:\\n\"\n+\t\t\t\"xchg %[locked], %[lv]\\n\"\n+\t\t\t\"test %[lv], %[lv]\\n\"\n+\t\t\t\"jz 3f\\n\"\n+\t\t\t\"2:\\n\"\n+\t\t\t\"pause\\n\"\n+\t\t\t\"cmpl $0, %[locked]\\n\"\n+\t\t\t\"jnz 2b\\n\"\n+\t\t\t\"jmp 1b\\n\"\n+\t\t\t\"3:\\n\"\n+\t\t\t: [locked] \"=m\" (sl->locked), [lv] \"=q\" (lock_val)\n+\t\t\t: \"[lv]\" (lock_val)\n+\t\t\t: \"memory\");\n+}\n+\n+static inline void\n+rte_spinlock_unlock (rte_spinlock_t *sl)\n+{\n+\tint unlock_val = 0;\n+\tasm volatile (\n+\t\t\t\"xchg %[locked], %[ulv]\\n\"\n+\t\t\t: [locked] \"=m\" (sl->locked), [ulv] \"=q\" (unlock_val)\n+\t\t\t: \"[ulv]\" (unlock_val)\n+\t\t\t: \"memory\");\n+}\n+\n+static inline int\n+rte_spinlock_trylock (rte_spinlock_t *sl)\n+{\n+\tint lockval = 1;\n+\n+\tasm volatile (\n+\t\t\t\"xchg %[locked], %[lockval]\"\n+\t\t\t: [locked] \"=m\" (sl->locked), [lockval] \"=q\" (lockval)\n+\t\t\t: \"[lockval]\" (lockval)\n+\t\t\t: \"memory\");\n+\n+\treturn (lockval == 0);\n+}\n+#endif\n+\n+#ifdef __cplusplus\n+}\n+#endif\n+\n+#endif /* _RTE_SPINLOCK_I686_H_ */\ndiff --git a/lib/librte_eal/common/include/arch/x86_64/rte_spinlock.h b/lib/librte_eal/common/include/arch/x86_64/rte_spinlock.h\nnew file mode 100644\nindex 0000000..54fba95\n--- /dev/null\n+++ b/lib/librte_eal/common/include/arch/x86_64/rte_spinlock.h\n@@ -0,0 +1,94 @@\n+/*-\n+ * BSD LICENSE\n+ *\n+ * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n+ * All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions\n+ * are met:\n+ *\n+ * * Redistributions of source code must retain the above copyright\n+ * notice, this list of conditions and the following disclaimer.\n+ * * Redistributions in binary form must reproduce the above copyright\n+ * notice, this list of conditions and the following disclaimer in\n+ * the documentation and/or other materials provided with the\n+ * distribution.\n+ * * Neither the name of Intel Corporation nor the names of its\n+ * contributors may be used to endorse or promote products derived\n+ * from this software without specific prior written permission.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#ifndef _RTE_SPINLOCK_X86_64_H_\n+#define _RTE_SPINLOCK_X86_64_H_\n+\n+#ifdef __cplusplus\n+extern \"C\" {\n+#endif\n+\n+#include \"generic/rte_spinlock.h\"\n+\n+#ifndef RTE_FORCE_INTRINSICS\n+static inline void\n+rte_spinlock_lock(rte_spinlock_t *sl)\n+{\n+\tint lock_val = 1;\n+\tasm volatile (\n+\t\t\t\"1:\\n\"\n+\t\t\t\"xchg %[locked], %[lv]\\n\"\n+\t\t\t\"test %[lv], %[lv]\\n\"\n+\t\t\t\"jz 3f\\n\"\n+\t\t\t\"2:\\n\"\n+\t\t\t\"pause\\n\"\n+\t\t\t\"cmpl $0, %[locked]\\n\"\n+\t\t\t\"jnz 2b\\n\"\n+\t\t\t\"jmp 1b\\n\"\n+\t\t\t\"3:\\n\"\n+\t\t\t: [locked] \"=m\" (sl->locked), [lv] \"=q\" (lock_val)\n+\t\t\t: \"[lv]\" (lock_val)\n+\t\t\t: \"memory\");\n+}\n+\n+static inline void\n+rte_spinlock_unlock (rte_spinlock_t *sl)\n+{\n+\tint unlock_val = 0;\n+\tasm volatile (\n+\t\t\t\"xchg %[locked], %[ulv]\\n\"\n+\t\t\t: [locked] \"=m\" (sl->locked), [ulv] \"=q\" (unlock_val)\n+\t\t\t: \"[ulv]\" (unlock_val)\n+\t\t\t: \"memory\");\n+}\n+\n+static inline int\n+rte_spinlock_trylock (rte_spinlock_t *sl)\n+{\n+\tint lockval = 1;\n+\n+\tasm volatile (\n+\t\t\t\"xchg %[locked], %[lockval]\"\n+\t\t\t: [locked] \"=m\" (sl->locked), [lockval] \"=q\" (lockval)\n+\t\t\t: \"[lockval]\" (lockval)\n+\t\t\t: \"memory\");\n+\n+\treturn (lockval == 0);\n+}\n+#endif\n+\n+#ifdef __cplusplus\n+}\n+#endif\n+\n+#endif /* _RTE_SPINLOCK_X86_64_H_ */\ndiff --git a/lib/librte_eal/common/include/generic/rte_spinlock.h b/lib/librte_eal/common/include/generic/rte_spinlock.h\nnew file mode 100644\nindex 0000000..dea885c\n--- /dev/null\n+++ b/lib/librte_eal/common/include/generic/rte_spinlock.h\n@@ -0,0 +1,226 @@\n+/*-\n+ * BSD LICENSE\n+ *\n+ * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n+ * All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions\n+ * are met:\n+ *\n+ * * Redistributions of source code must retain the above copyright\n+ * notice, this list of conditions and the following disclaimer.\n+ * * Redistributions in binary form must reproduce the above copyright\n+ * notice, this list of conditions and the following disclaimer in\n+ * the documentation and/or other materials provided with the\n+ * distribution.\n+ * * Neither the name of Intel Corporation nor the names of its\n+ * contributors may be used to endorse or promote products derived\n+ * from this software without specific prior written permission.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#ifndef _RTE_SPINLOCK_H_\n+#define _RTE_SPINLOCK_H_\n+\n+/**\n+ * @file\n+ *\n+ * RTE Spinlocks\n+ *\n+ * This file defines an API for read-write locks, which are implemented\n+ * in an architecture-specific way. This kind of lock simply waits in\n+ * a loop repeatedly checking until the lock becomes available.\n+ *\n+ * All locks must be initialised before use, and only initialised once.\n+ *\n+ */\n+\n+#include <rte_lcore.h>\n+#ifdef RTE_FORCE_INTRINSICS\n+#include <rte_common.h>\n+#endif\n+\n+/**\n+ * The rte_spinlock_t type.\n+ */\n+typedef struct {\n+\tvolatile int locked; /**< lock status 0 = unlocked, 1 = locked */\n+} rte_spinlock_t;\n+\n+/**\n+ * A static spinlock initializer.\n+ */\n+#define RTE_SPINLOCK_INITIALIZER { 0 }\n+\n+/**\n+ * Initialize the spinlock to an unlocked state.\n+ *\n+ * @param sl\n+ * A pointer to the spinlock.\n+ */\n+static inline void\n+rte_spinlock_init(rte_spinlock_t *sl)\n+{\n+\tsl->locked = 0;\n+}\n+\n+/**\n+ * Take the spinlock.\n+ *\n+ * @param sl\n+ * A pointer to the spinlock.\n+ */\n+static inline void\n+rte_spinlock_lock(rte_spinlock_t *sl);\n+\n+#ifdef RTE_FORCE_INTRINSICS\n+static inline void\n+rte_spinlock_lock(rte_spinlock_t *sl)\n+{\n+\twhile (__sync_lock_test_and_set(&sl->locked, 1))\n+\t\twhile(sl->locked)\n+\t\t\trte_pause();\n+}\n+#endif\n+\n+/**\n+ * Release the spinlock.\n+ *\n+ * @param sl\n+ * A pointer to the spinlock.\n+ */\n+static inline void\n+rte_spinlock_unlock (rte_spinlock_t *sl);\n+\n+#ifdef RTE_FORCE_INTRINSICS\n+static inline void\n+rte_spinlock_unlock (rte_spinlock_t *sl)\n+{\n+\t__sync_lock_release(&sl->locked);\n+}\n+#endif\n+\n+/**\n+ * Try to take the lock.\n+ *\n+ * @param sl\n+ * A pointer to the spinlock.\n+ * @return\n+ * 1 if the lock is successfully taken; 0 otherwise.\n+ */\n+static inline int\n+rte_spinlock_trylock (rte_spinlock_t *sl);\n+\n+#ifdef RTE_FORCE_INTRINSICS\n+static inline int\n+rte_spinlock_trylock (rte_spinlock_t *sl)\n+{\n+\treturn (__sync_lock_test_and_set(&sl->locked,1) == 0);\n+}\n+#endif\n+\n+/**\n+ * Test if the lock is taken.\n+ *\n+ * @param sl\n+ * A pointer to the spinlock.\n+ * @return\n+ * 1 if the lock is currently taken; 0 otherwise.\n+ */\n+static inline int rte_spinlock_is_locked (rte_spinlock_t *sl)\n+{\n+\treturn sl->locked;\n+}\n+\n+/**\n+ * The rte_spinlock_recursive_t type.\n+ */\n+typedef struct {\n+\trte_spinlock_t sl; /**< the actual spinlock */\n+\tvolatile int user; /**< core id using lock, -1 for unused */\n+\tvolatile int count; /**< count of time this lock has been called */\n+} rte_spinlock_recursive_t;\n+\n+/**\n+ * A static recursive spinlock initializer.\n+ */\n+#define RTE_SPINLOCK_RECURSIVE_INITIALIZER {RTE_SPINLOCK_INITIALIZER, -1, 0}\n+\n+/**\n+ * Initialize the recursive spinlock to an unlocked state.\n+ *\n+ * @param slr\n+ * A pointer to the recursive spinlock.\n+ */\n+static inline void rte_spinlock_recursive_init(rte_spinlock_recursive_t *slr)\n+{\n+\trte_spinlock_init(&slr->sl);\n+\tslr->user = -1;\n+\tslr->count = 0;\n+}\n+\n+/**\n+ * Take the recursive spinlock.\n+ *\n+ * @param slr\n+ * A pointer to the recursive spinlock.\n+ */\n+static inline void rte_spinlock_recursive_lock(rte_spinlock_recursive_t *slr)\n+{\n+\tint id = rte_lcore_id();\n+\n+\tif (slr->user != id) {\n+\t\trte_spinlock_lock(&slr->sl);\n+\t\tslr->user = id;\n+\t}\n+\tslr->count++;\n+}\n+/**\n+ * Release the recursive spinlock.\n+ *\n+ * @param slr\n+ * A pointer to the recursive spinlock.\n+ */\n+static inline void rte_spinlock_recursive_unlock(rte_spinlock_recursive_t *slr)\n+{\n+\tif (--(slr->count) == 0) {\n+\t\tslr->user = -1;\n+\t\trte_spinlock_unlock(&slr->sl);\n+\t}\n+\n+}\n+\n+/**\n+ * Try to take the recursive lock.\n+ *\n+ * @param slr\n+ * A pointer to the recursive spinlock.\n+ * @return\n+ * 1 if the lock is successfully taken; 0 otherwise.\n+ */\n+static inline int rte_spinlock_recursive_trylock(rte_spinlock_recursive_t *slr)\n+{\n+\tint id = rte_lcore_id();\n+\n+\tif (slr->user != id) {\n+\t\tif (rte_spinlock_trylock(&slr->sl) == 0)\n+\t\t\treturn 0;\n+\t\tslr->user = id;\n+\t}\n+\tslr->count++;\n+\treturn 1;\n+}\n+\n+#endif /* _RTE_SPINLOCK_H_ */\ndiff --git a/lib/librte_eal/common/include/rte_spinlock.h b/lib/librte_eal/common/include/rte_spinlock.h\ndeleted file mode 100644\nindex 661908d..0000000\n--- a/lib/librte_eal/common/include/rte_spinlock.h\n+++ /dev/null\n@@ -1,258 +0,0 @@\n-/*-\n- * BSD LICENSE\n- *\n- * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n- * All rights reserved.\n- *\n- * Redistribution and use in source and binary forms, with or without\n- * modification, are permitted provided that the following conditions\n- * are met:\n- *\n- * * Redistributions of source code must retain the above copyright\n- * notice, this list of conditions and the following disclaimer.\n- * * Redistributions in binary form must reproduce the above copyright\n- * notice, this list of conditions and the following disclaimer in\n- * the documentation and/or other materials provided with the\n- * distribution.\n- * * Neither the name of Intel Corporation nor the names of its\n- * contributors may be used to endorse or promote products derived\n- * from this software without specific prior written permission.\n- *\n- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n- * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n- */\n-\n-#ifndef _RTE_SPINLOCK_H_\n-#define _RTE_SPINLOCK_H_\n-\n-/**\n- * @file\n- *\n- * RTE Spinlocks\n- *\n- * This file defines an API for read-write locks, which are implemented\n- * in an architecture-specific way. This kind of lock simply waits in\n- * a loop repeatedly checking until the lock becomes available.\n- *\n- * All locks must be initialised before use, and only initialised once.\n- *\n- */\n-\n-#ifdef __cplusplus\n-extern \"C\" {\n-#endif\n-\n-#include <rte_lcore.h>\n-#ifdef RTE_FORCE_INTRINSICS\n-#include <rte_common.h>\n-#endif\n-\n-/**\n- * The rte_spinlock_t type.\n- */\n-typedef struct {\n-\tvolatile int locked; /**< lock status 0 = unlocked, 1 = locked */\n-} rte_spinlock_t;\n-\n-/**\n- * A static spinlock initializer.\n- */\n-#define RTE_SPINLOCK_INITIALIZER { 0 }\n-\n-/**\n- * Initialize the spinlock to an unlocked state.\n- *\n- * @param sl\n- * A pointer to the spinlock.\n- */\n-static inline void\n-rte_spinlock_init(rte_spinlock_t *sl)\n-{\n-\tsl->locked = 0;\n-}\n-\n-/**\n- * Take the spinlock.\n- *\n- * @param sl\n- * A pointer to the spinlock.\n- */\n-static inline void\n-rte_spinlock_lock(rte_spinlock_t *sl)\n-{\n-#ifndef RTE_FORCE_INTRINSICS\n-\tint lock_val = 1;\n-\tasm volatile (\n-\t\t\t\"1:\\n\"\n-\t\t\t\"xchg %[locked], %[lv]\\n\"\n-\t\t\t\"test %[lv], %[lv]\\n\"\n-\t\t\t\"jz 3f\\n\"\n-\t\t\t\"2:\\n\"\n-\t\t\t\"pause\\n\"\n-\t\t\t\"cmpl $0, %[locked]\\n\"\n-\t\t\t\"jnz 2b\\n\"\n-\t\t\t\"jmp 1b\\n\"\n-\t\t\t\"3:\\n\"\n-\t\t\t: [locked] \"=m\" (sl->locked), [lv] \"=q\" (lock_val)\n-\t\t\t: \"[lv]\" (lock_val)\n-\t\t\t: \"memory\");\n-#else\n-\twhile (__sync_lock_test_and_set(&sl->locked, 1))\n-\t\twhile(sl->locked)\n-\t\t\trte_pause();\n-#endif\n-}\n-\n-/**\n- * Release the spinlock.\n- *\n- * @param sl\n- * A pointer to the spinlock.\n- */\n-static inline void\n-rte_spinlock_unlock (rte_spinlock_t *sl)\n-{\n-#ifndef RTE_FORCE_INTRINSICS\n-\tint unlock_val = 0;\n-\tasm volatile (\n-\t\t\t\"xchg %[locked], %[ulv]\\n\"\n-\t\t\t: [locked] \"=m\" (sl->locked), [ulv] \"=q\" (unlock_val)\n-\t\t\t: \"[ulv]\" (unlock_val)\n-\t\t\t: \"memory\");\n-#else\n-\t__sync_lock_release(&sl->locked);\n-#endif\n-}\n-\n-/**\n- * Try to take the lock.\n- *\n- * @param sl\n- * A pointer to the spinlock.\n- * @return\n- * 1 if the lock is successfully taken; 0 otherwise.\n- */\n-static inline int\n-rte_spinlock_trylock (rte_spinlock_t *sl)\n-{\n-#ifndef RTE_FORCE_INTRINSICS\n-\tint lockval = 1;\n-\n-\tasm volatile (\n-\t\t\t\"xchg %[locked], %[lockval]\"\n-\t\t\t: [locked] \"=m\" (sl->locked), [lockval] \"=q\" (lockval)\n-\t\t\t: \"[lockval]\" (lockval)\n-\t\t\t: \"memory\");\n-\n-\treturn (lockval == 0);\n-#else\n-\treturn (__sync_lock_test_and_set(&sl->locked,1) == 0);\n-#endif\n-}\n-\n-/**\n- * Test if the lock is taken.\n- *\n- * @param sl\n- * A pointer to the spinlock.\n- * @return\n- * 1 if the lock is currently taken; 0 otherwise.\n- */\n-static inline int rte_spinlock_is_locked (rte_spinlock_t *sl)\n-{\n-\treturn sl->locked;\n-}\n-\n-/**\n- * The rte_spinlock_recursive_t type.\n- */\n-typedef struct {\n-\trte_spinlock_t sl; /**< the actual spinlock */\n-\tvolatile int user; /**< core id using lock, -1 for unused */\n-\tvolatile int count; /**< count of time this lock has been called */\n-} rte_spinlock_recursive_t;\n-\n-/**\n- * A static recursive spinlock initializer.\n- */\n-#define RTE_SPINLOCK_RECURSIVE_INITIALIZER {RTE_SPINLOCK_INITIALIZER, -1, 0}\n-\n-/**\n- * Initialize the recursive spinlock to an unlocked state.\n- *\n- * @param slr\n- * A pointer to the recursive spinlock.\n- */\n-static inline void rte_spinlock_recursive_init(rte_spinlock_recursive_t *slr)\n-{\n-\trte_spinlock_init(&slr->sl);\n-\tslr->user = -1;\n-\tslr->count = 0;\n-}\n-\n-/**\n- * Take the recursive spinlock.\n- *\n- * @param slr\n- * A pointer to the recursive spinlock.\n- */\n-static inline void rte_spinlock_recursive_lock(rte_spinlock_recursive_t *slr)\n-{\n-\tint id = rte_lcore_id();\n-\n-\tif (slr->user != id) {\n-\t\trte_spinlock_lock(&slr->sl);\n-\t\tslr->user = id;\n-\t}\n-\tslr->count++;\n-}\n-/**\n- * Release the recursive spinlock.\n- *\n- * @param slr\n- * A pointer to the recursive spinlock.\n- */\n-static inline void rte_spinlock_recursive_unlock(rte_spinlock_recursive_t *slr)\n-{\n-\tif (--(slr->count) == 0) {\n-\t\tslr->user = -1;\n-\t\trte_spinlock_unlock(&slr->sl);\n-\t}\n-\n-}\n-\n-/**\n- * Try to take the recursive lock.\n- *\n- * @param slr\n- * A pointer to the recursive spinlock.\n- * @return\n- * 1 if the lock is successfully taken; 0 otherwise.\n- */\n-static inline int rte_spinlock_recursive_trylock(rte_spinlock_recursive_t *slr)\n-{\n-\tint id = rte_lcore_id();\n-\n-\tif (slr->user != id) {\n-\t\tif (rte_spinlock_trylock(&slr->sl) == 0)\n-\t\t\treturn 0;\n-\t\tslr->user = id;\n-\t}\n-\tslr->count++;\n-\treturn 1;\n-}\n-\n-#ifdef __cplusplus\n-}\n-#endif\n-\n-#endif /* _RTE_SPINLOCK_H_ */\n", "prefixes": [ "dpdk-dev", "v3", "06/10" ] }{ "id": 986, "url": "