From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6DDC7A04B5; Fri, 11 Sep 2020 05:30:01 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2F6681C113; Fri, 11 Sep 2020 05:29:41 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id EFC1E1C113 for ; Fri, 11 Sep 2020 05:29:39 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 72DBE113E; Thu, 10 Sep 2020 20:29:39 -0700 (PDT) Received: from phil-VirtualBox.shanghai.arm.com (phil-VirtualBox.shanghai.arm.com [10.169.182.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1FEFD3F73C; Thu, 10 Sep 2020 20:29:36 -0700 (PDT) From: Phil Yang To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, nd@arm.com, Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Date: Fri, 11 Sep 2020 11:29:27 +0800 Message-Id: <1599794967-17500-5-git-send-email-phil.yang@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1599794967-17500-1-git-send-email-phil.yang@arm.com> References: <1599794967-17500-1-git-send-email-phil.yang@arm.com> Subject: [dpdk-dev] [PATCH 4/4] ethdev: use C11 atomic builtins for link status update X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Since rte_atomicXX APIs are not allowed to be used, use C11 atomic builtins for link status update. Signed-off-by: Phil Yang Reviewed-by: Ruifeng Wang Reviewed-by: Honnappa Nagarahalli --- lib/librte_ethdev/rte_ethdev_driver.h | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev_driver.h b/lib/librte_ethdev/rte_ethdev_driver.h index 13fd049..78590dd 100644 --- a/lib/librte_ethdev/rte_ethdev_driver.h +++ b/lib/librte_ethdev/rte_ethdev_driver.h @@ -216,8 +216,7 @@ static inline int rte_eth_linkstatus_set(struct rte_eth_dev *dev, const struct rte_eth_link *new_link) { - volatile uint64_t *dev_link - = (volatile uint64_t *)&(dev->data->dev_link); + uint64_t *dev_link = (uint64_t *)&(dev->data->dev_link); union { uint64_t val64; struct rte_eth_link link; @@ -225,8 +224,8 @@ rte_eth_linkstatus_set(struct rte_eth_dev *dev, RTE_BUILD_BUG_ON(sizeof(*new_link) != sizeof(uint64_t)); - orig.val64 = rte_atomic64_exchange(dev_link, - *(const uint64_t *)new_link); + orig.val64 = __atomic_exchange_n(dev_link, (const uint64_t *)new_link, + __ATOMIC_SEQ_CST); return (orig.link.link_status == new_link->link_status) ? -1 : 0; } @@ -244,20 +243,12 @@ static inline void rte_eth_linkstatus_get(const struct rte_eth_dev *dev, struct rte_eth_link *link) { - volatile uint64_t *src = (uint64_t *)&(dev->data->dev_link); + uint64_t *src = (uint64_t *)&(dev->data->dev_link); uint64_t *dst = (uint64_t *)link; RTE_BUILD_BUG_ON(sizeof(*link) != sizeof(uint64_t)); -#ifdef __LP64__ - /* if cpu arch has 64 bit unsigned lon then implicitly atomic */ - *dst = *src; -#else - /* can't use rte_atomic64_read because it returns signed int */ - do { - *dst = *src; - } while (!rte_atomic64_cmpset(src, *dst, *dst)); -#endif + *dst = __atomic_load_n(src, __ATOMIC_SEQ_CST); } /** -- 2.7.4