From patchwork Tue May 14 16:35:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 140105 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 249D744024; Tue, 14 May 2024 18:39:53 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 63FB1427E0; Tue, 14 May 2024 18:36:47 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 7B07340A6D for ; Tue, 14 May 2024 18:36:08 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 464F820B2CAB; Tue, 14 May 2024 09:36:00 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 464F820B2CAB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1715704562; bh=1GR6NirT6kYPmjisfxTVmHI7dux02s9YImjp1x3Zvyw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DceNx8NKYhRMj3XMLDCyxLz+y8xkD+VA95e84c6VJJKDitg3y2eY9ogKKuVYu3Kf1 i4ebGmaKJ+akS5NHR/1+aKdCt3P2pUUQ0yPmbW5FM3ycgdCKL0kdTHrokJPiDQu9KH 9d0mnz43UJwQrPChzM4jGQQFb3lJyOL1/m70O6SY= From: Tyler Retzlaff To: dev@dpdk.org Cc: =?utf-8?q?Mattias_R=C3=B6nnblom?= , =?utf-8?q?Morten_Br=C3=B8rup?= , Abdullah Sevincer , Ajit Khaparde , Alok Prasad , Anatoly Burakov , Andrew Rybchenko , Anoob Joseph , Bruce Richardson , Byron Marohn , Chenbo Xia , Chengwen Feng , Ciara Loftus , Ciara Power , Dariusz Sosnowski , David Hunt , Devendra Singh Rawat , Erik Gabriel Carrillo , Guoyang Zhou , Harman Kalra , Harry van Haaren , Honnappa Nagarahalli , Jakub Grajciar , Jerin Jacob , Jeroen de Borst , Jian Wang , Jiawen Wu , Jie Hai , Jingjing Wu , Joshua Washington , Joyce Kong , Junfeng Guo , Kevin Laatz , Konstantin Ananyev , Liang Ma , Long Li , Maciej Czekaj , Matan Azrad , Maxime Coquelin , Nicolas Chautru , Ori Kam , Pavan Nikhilesh , Peter Mccarthy , Rahul Lakkireddy , Reshma Pattan , Rosen Xu , Ruifeng Wang , Rushil Gupta , Sameh Gobriel , Sivaprasad Tummala , Somnath Kotur , Stephen Hemminger , Suanming Mou , Sunil Kumar Kori , Sunil Uttarwar , Tetsuya Mukawa , Vamsi Attunuru , Viacheslav Ovsiienko , Vladimir Medvedkin , Xiaoyun Wang , Yipeng Wang , Yisen Zhuang , Ziyang Xuan , Tyler Retzlaff Subject: [PATCH v6 32/45] net/txgbe: use rte stdatomic API Date: Tue, 14 May 2024 09:35:46 -0700 Message-Id: <1715704559-15839-33-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1715704559-15839-1-git-send-email-roretzla@linux.microsoft.com> References: <1710967892-7046-1-git-send-email-roretzla@linux.microsoft.com> <1715704559-15839-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Replace the use of gcc builtin __atomic_xxx intrinsics with corresponding rte_atomic_xxx optional rte stdatomic API. Signed-off-by: Tyler Retzlaff Acked-by: Stephen Hemminger --- drivers/net/txgbe/txgbe_ethdev.c | 12 +++++++----- drivers/net/txgbe/txgbe_ethdev.h | 2 +- drivers/net/txgbe/txgbe_ethdev_vf.c | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c index b75e889..a58f197 100644 --- a/drivers/net/txgbe/txgbe_ethdev.c +++ b/drivers/net/txgbe/txgbe_ethdev.c @@ -595,7 +595,7 @@ static int txgbe_dev_interrupt_action(struct rte_eth_dev *dev, return 0; } - __atomic_clear(&ad->link_thread_running, __ATOMIC_SEQ_CST); + rte_atomic_store_explicit(&ad->link_thread_running, 0, rte_memory_order_seq_cst); rte_eth_copy_pci_info(eth_dev, pci_dev); hw->hw_addr = (void *)pci_dev->mem_resource[0].addr; @@ -2834,7 +2834,7 @@ static int txgbe_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, struct txgbe_adapter *ad = TXGBE_DEV_ADAPTER(dev); uint32_t timeout = timeout_ms ? timeout_ms : WARNING_TIMEOUT; - while (__atomic_load_n(&ad->link_thread_running, __ATOMIC_SEQ_CST)) { + while (rte_atomic_load_explicit(&ad->link_thread_running, rte_memory_order_seq_cst)) { msec_delay(1); timeout--; @@ -2859,7 +2859,7 @@ static int txgbe_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, rte_thread_detach(rte_thread_self()); txgbe_dev_setup_link_alarm_handler(dev); - __atomic_clear(&ad->link_thread_running, __ATOMIC_SEQ_CST); + rte_atomic_store_explicit(&ad->link_thread_running, 0, rte_memory_order_seq_cst); return 0; } @@ -2908,7 +2908,8 @@ static int txgbe_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, } else if (hw->phy.media_type == txgbe_media_type_fiber && dev->data->dev_conf.intr_conf.lsc != 0) { txgbe_dev_wait_setup_link_complete(dev, 0); - if (!__atomic_test_and_set(&ad->link_thread_running, __ATOMIC_SEQ_CST)) { + if (!rte_atomic_exchange_explicit(&ad->link_thread_running, 1, + rte_memory_order_seq_cst)) { /* To avoid race condition between threads, set * the TXGBE_FLAG_NEED_LINK_CONFIG flag only * when there is no link thread running. @@ -2918,7 +2919,8 @@ static int txgbe_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, "txgbe-link", txgbe_dev_setup_link_thread_handler, dev) < 0) { PMD_DRV_LOG(ERR, "Create link thread failed!"); - __atomic_clear(&ad->link_thread_running, __ATOMIC_SEQ_CST); + rte_atomic_store_explicit(&ad->link_thread_running, 0, + rte_memory_order_seq_cst); } } else { PMD_DRV_LOG(ERR, diff --git a/drivers/net/txgbe/txgbe_ethdev.h b/drivers/net/txgbe/txgbe_ethdev.h index 7e8067c..e8f55f7 100644 --- a/drivers/net/txgbe/txgbe_ethdev.h +++ b/drivers/net/txgbe/txgbe_ethdev.h @@ -372,7 +372,7 @@ struct txgbe_adapter { /* For RSS reta table update */ uint8_t rss_reta_updated; - uint32_t link_thread_running; + RTE_ATOMIC(uint32_t) link_thread_running; rte_thread_t link_thread_tid; }; diff --git a/drivers/net/txgbe/txgbe_ethdev_vf.c b/drivers/net/txgbe/txgbe_ethdev_vf.c index f1341fb..1abc190 100644 --- a/drivers/net/txgbe/txgbe_ethdev_vf.c +++ b/drivers/net/txgbe/txgbe_ethdev_vf.c @@ -206,7 +206,7 @@ static int txgbevf_dev_link_update(struct rte_eth_dev *dev, return 0; } - __atomic_clear(&ad->link_thread_running, __ATOMIC_SEQ_CST); + rte_atomic_store_explicit(&ad->link_thread_running, 0, rte_memory_order_seq_cst); rte_eth_copy_pci_info(eth_dev, pci_dev); hw->device_id = pci_dev->id.device_id;