From patchwork Thu Sep 24 05:39:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Yang X-Patchwork-Id: 78649 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C6E7EA04B1; Thu, 24 Sep 2020 07:40:31 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 422731DD65; Thu, 24 Sep 2020 07:40:18 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id 3558A1DD5F for ; Thu, 24 Sep 2020 07:40:08 +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 BC36D30E; Wed, 23 Sep 2020 22:40:07 -0700 (PDT) Received: from phil-VirtualBox.shanghai.arm.com (phil-VirtualBox.shanghai.arm.com [10.169.182.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 809FE3F73B; Wed, 23 Sep 2020 22:40:04 -0700 (PDT) From: Phil Yang To: dev@dpdk.org, david.marchand@redhat.com, nicolas.chautru@intel.com, david.hunt@intel.com Cc: Ruifeng.Wang@arm.com, Honnappa.Nagarahalli@arm.com, nd@arm.com, Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Date: Thu, 24 Sep 2020 13:39:28 +0800 Message-Id: <1600925968-18278-5-git-send-email-phil.yang@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1600925968-18278-1-git-send-email-phil.yang@arm.com> References: <1600244628-13062-1-git-send-email-phil.yang@arm.com> <1600925968-18278-1-git-send-email-phil.yang@arm.com> Subject: [dpdk-dev] [PATCH v3 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 Acked-by: Andrew Rybchenko --- 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 23cc1e0..04ac8e9 100644 --- a/lib/librte_ethdev/rte_ethdev_driver.h +++ b/lib/librte_ethdev/rte_ethdev_driver.h @@ -920,8 +920,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; @@ -929,8 +928,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; } @@ -948,20 +947,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); } /**