From: Phil Yang <phil.yang@arm.com> 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 <thomas@monjalon.net>, Ferruh Yigit <ferruh.yigit@intel.com>, Andrew Rybchenko <arybchenko@solarflare.com> Subject: [dpdk-dev] [PATCH v3 4/4] ethdev: use C11 atomic builtins for link status update Date: Thu, 24 Sep 2020 13:39:28 +0800 Message-ID: <1600925968-18278-5-git-send-email-phil.yang@arm.com> (raw) In-Reply-To: <1600925968-18278-1-git-send-email-phil.yang@arm.com> Since rte_atomicXX APIs are not allowed to be used, use C11 atomic builtins for link status update. Signed-off-by: Phil Yang <phil.yang@arm.com> Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> --- 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); } /** -- 2.7.4
next prev parent reply other threads:[~2020-09-24 5:40 UTC|newest] Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-09-11 3:29 [dpdk-dev] [PATCH 0/4] use C11 atomic builtins for libs Phil Yang 2020-09-11 3:29 ` [dpdk-dev] [PATCH 1/4] eal: use C11 atomic builtins for already initialized check Phil Yang 2020-09-11 3:29 ` [dpdk-dev] [PATCH 2/4] bbdev: use C11 atomic builtins for device processing counter Phil Yang 2020-09-11 3:29 ` [dpdk-dev] [PATCH 3/4] power: use C11 atomic builtins for power in use state update Phil Yang 2020-09-11 3:29 ` [dpdk-dev] [PATCH 4/4] ethdev: use C11 atomic builtins for link status update Phil Yang 2020-09-15 15:12 ` [dpdk-dev] [PATCH 0/4] use C11 atomic builtins for libs David Marchand 2020-09-16 7:32 ` Phil Yang 2020-09-16 8:23 ` [dpdk-dev] [PATCH v2 " Phil Yang 2020-09-16 8:23 ` [dpdk-dev] [PATCH v2 1/4] eal: use C11 atomic builtins for already initialized check Phil Yang 2020-09-23 13:06 ` David Marchand 2020-09-24 3:44 ` Phil Yang 2020-09-16 8:23 ` [dpdk-dev] [PATCH v2 2/4] bbdev: use C11 atomic builtins for device processing counter Phil Yang 2020-09-16 8:23 ` [dpdk-dev] [PATCH v2 3/4] power: use C11 atomic builtins for power in use state update Phil Yang 2020-09-16 8:23 ` [dpdk-dev] [PATCH v2 4/4] ethdev: use C11 atomic builtins for link status update Phil Yang 2020-09-17 16:08 ` Andrew Rybchenko 2020-09-23 13:18 ` [dpdk-dev] [PATCH v2 0/4] use C11 atomic builtins for libs David Marchand 2020-09-24 3:47 ` Phil Yang 2020-09-24 5:39 ` [dpdk-dev] [PATCH v3 " Phil Yang 2020-09-24 5:39 ` [dpdk-dev] [PATCH v3 1/4] eal: use C11 atomic builtins for already initialized check Phil Yang 2020-09-24 5:39 ` [dpdk-dev] [PATCH v3 2/4] bbdev: use C11 atomic builtins for device processing counter Phil Yang 2020-09-24 22:01 ` Chautru, Nicolas 2020-09-24 22:44 ` Honnappa Nagarahalli 2020-09-24 23:20 ` Chautru, Nicolas 2020-09-24 5:39 ` [dpdk-dev] [PATCH v3 3/4] power: use C11 atomic builtins for power in use state update Phil Yang 2020-09-24 8:34 ` David Hunt 2020-09-24 5:39 ` Phil Yang [this message] 2020-09-25 13:59 ` [dpdk-dev] [PATCH v3 0/4] use C11 atomic builtins for libs David Marchand
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1600925968-18278-5-git-send-email-phil.yang@arm.com \ --to=phil.yang@arm.com \ --cc=Honnappa.Nagarahalli@arm.com \ --cc=Ruifeng.Wang@arm.com \ --cc=arybchenko@solarflare.com \ --cc=david.hunt@intel.com \ --cc=david.marchand@redhat.com \ --cc=dev@dpdk.org \ --cc=ferruh.yigit@intel.com \ --cc=nd@arm.com \ --cc=nicolas.chautru@intel.com \ --cc=thomas@monjalon.net \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
DPDK patches and discussions This inbox may be cloned and mirrored by anyone: git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \ dev@dpdk.org public-inbox-index dev Example config snippet for mirrors. Newsgroup available over NNTP: nntp://inbox.dpdk.org/inbox.dpdk.dev AGPL code for this site: git clone https://public-inbox.org/public-inbox.git