From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E967143D09; Wed, 20 Mar 2024 21:52:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8ABD642E02; Wed, 20 Mar 2024 21:51:48 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 1E65541148 for ; Wed, 20 Mar 2024 21:51:36 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id DD57B20B74CA; Wed, 20 Mar 2024 13:51:33 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com DD57B20B74CA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1710967893; bh=5puJyum6AsgOcSFqjskJM2IdjVf3ZA8TjYrxGX5XYAM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QVctX0alJsAwXxirVV4q0seXr2Pwy1yU/46+i+3LcjFz5ve+FqwDW3dmE1WEFwJ5w /fnqGlVcsXIV1CerK2W3A604FGxookdbpAr0VY5AF+EjciX5Fy+0NdTA4WLArj1aHv 5v45a1pKhijD6IpFFL/XklLgIg0bM0UDWgv1ZPuY= From: Tyler Retzlaff To: dev@dpdk.org Cc: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= , =?UTF-8?q?Morten=20Br=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 , Yuying Zhang , Yuying Zhang , Ziyang Xuan , Tyler Retzlaff Subject: [PATCH 10/46] net/octeon_ep: use rte stdatomic API Date: Wed, 20 Mar 2024 13:50:56 -0700 Message-Id: <1710967892-7046-11-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1710967892-7046-1-git-send-email-roretzla@linux.microsoft.com> References: <1710967892-7046-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 --- drivers/net/octeon_ep/cnxk_ep_rx.h | 5 +++-- drivers/net/octeon_ep/cnxk_ep_tx.c | 5 +++-- drivers/net/octeon_ep/cnxk_ep_vf.c | 8 ++++---- drivers/net/octeon_ep/otx2_ep_vf.c | 8 ++++---- drivers/net/octeon_ep/otx_ep_common.h | 4 ++-- drivers/net/octeon_ep/otx_ep_rxtx.c | 6 ++++-- 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/drivers/net/octeon_ep/cnxk_ep_rx.h b/drivers/net/octeon_ep/cnxk_ep_rx.h index ecf95cd..9422042 100644 --- a/drivers/net/octeon_ep/cnxk_ep_rx.h +++ b/drivers/net/octeon_ep/cnxk_ep_rx.h @@ -98,7 +98,7 @@ * This adds an extra local variable, but almost halves the * number of PCIe writes. */ - val = __atomic_load_n(droq->pkts_sent_ism, __ATOMIC_RELAXED); + val = rte_atomic_load_explicit(droq->pkts_sent_ism, rte_memory_order_relaxed); new_pkts = val - droq->pkts_sent_prev; droq->pkts_sent_prev = val; @@ -111,7 +111,8 @@ rte_mb(); rte_write64(OTX2_SDP_REQUEST_ISM, droq->pkts_sent_reg); - while (__atomic_load_n(droq->pkts_sent_ism, __ATOMIC_RELAXED) >= val) { + while (rte_atomic_load_explicit(droq->pkts_sent_ism, + rte_memory_order_relaxed) >= val) { rte_write64(OTX2_SDP_REQUEST_ISM, droq->pkts_sent_reg); rte_mb(); } diff --git a/drivers/net/octeon_ep/cnxk_ep_tx.c b/drivers/net/octeon_ep/cnxk_ep_tx.c index 233c8aa..e093140 100644 --- a/drivers/net/octeon_ep/cnxk_ep_tx.c +++ b/drivers/net/octeon_ep/cnxk_ep_tx.c @@ -15,7 +15,7 @@ * This adds an extra local variable, but almost halves the * number of PCIe writes. */ - val = __atomic_load_n(iq->inst_cnt_ism, __ATOMIC_RELAXED); + val = rte_atomic_load_explicit(iq->inst_cnt_ism, rte_memory_order_relaxed); iq->inst_cnt += val - iq->inst_cnt_prev; iq->inst_cnt_prev = val; @@ -27,7 +27,8 @@ rte_mb(); rte_write64(OTX2_SDP_REQUEST_ISM, iq->inst_cnt_reg); - while (__atomic_load_n(iq->inst_cnt_ism, __ATOMIC_RELAXED) >= val) { + while (rte_atomic_load_explicit(iq->inst_cnt_ism, + rte_memory_order_relaxed) >= val) { rte_write64(OTX2_SDP_REQUEST_ISM, iq->inst_cnt_reg); rte_mb(); } diff --git a/drivers/net/octeon_ep/cnxk_ep_vf.c b/drivers/net/octeon_ep/cnxk_ep_vf.c index 39f357e..39b28de 100644 --- a/drivers/net/octeon_ep/cnxk_ep_vf.c +++ b/drivers/net/octeon_ep/cnxk_ep_vf.c @@ -150,10 +150,10 @@ rte_write64(ism_addr, (uint8_t *)otx_ep->hw_addr + CNXK_EP_R_IN_CNTS_ISM(iq_no)); iq->inst_cnt_ism = - (uint32_t *)((uint8_t *)otx_ep->ism_buffer_mz->addr + (uint32_t __rte_atomic *)((uint8_t *)otx_ep->ism_buffer_mz->addr + CNXK_EP_IQ_ISM_OFFSET(iq_no)); otx_ep_err("SDP_R[%d] INST Q ISM virt: %p, dma: 0x%" PRIX64, iq_no, - (void *)iq->inst_cnt_ism, ism_addr); + (void *)(uintptr_t)iq->inst_cnt_ism, ism_addr); *iq->inst_cnt_ism = 0; iq->inst_cnt_prev = 0; iq->partial_ih = ((uint64_t)otx_ep->pkind) << 36; @@ -235,10 +235,10 @@ rte_write64(ism_addr, (uint8_t *)otx_ep->hw_addr + CNXK_EP_R_OUT_CNTS_ISM(oq_no)); droq->pkts_sent_ism = - (uint32_t *)((uint8_t *)otx_ep->ism_buffer_mz->addr + (uint32_t __rte_atomic *)((uint8_t *)otx_ep->ism_buffer_mz->addr + CNXK_EP_OQ_ISM_OFFSET(oq_no)); otx_ep_err("SDP_R[%d] OQ ISM virt: %p dma: 0x%" PRIX64, - oq_no, (void *)droq->pkts_sent_ism, ism_addr); + oq_no, (void *)(uintptr_t)droq->pkts_sent_ism, ism_addr); *droq->pkts_sent_ism = 0; droq->pkts_sent_prev = 0; diff --git a/drivers/net/octeon_ep/otx2_ep_vf.c b/drivers/net/octeon_ep/otx2_ep_vf.c index 25e0e5a..2aeebb4 100644 --- a/drivers/net/octeon_ep/otx2_ep_vf.c +++ b/drivers/net/octeon_ep/otx2_ep_vf.c @@ -300,10 +300,10 @@ static int otx2_vf_enable_rxq_intr(struct otx_ep_device *otx_epvf, oct_ep_write64(ism_addr, (uint8_t *)otx_ep->hw_addr + SDP_VF_R_IN_CNTS_ISM(iq_no)); iq->inst_cnt_ism = - (uint32_t *)((uint8_t *)otx_ep->ism_buffer_mz->addr + (uint32_t __rte_atomic *)((uint8_t *)otx_ep->ism_buffer_mz->addr + OTX2_EP_IQ_ISM_OFFSET(iq_no)); otx_ep_err("SDP_R[%d] INST Q ISM virt: %p, dma: 0x%x", iq_no, - (void *)iq->inst_cnt_ism, + (void *)(uintptr_t)iq->inst_cnt_ism, (unsigned int)ism_addr); *iq->inst_cnt_ism = 0; iq->inst_cnt_prev = 0; @@ -386,10 +386,10 @@ static int otx2_vf_enable_rxq_intr(struct otx_ep_device *otx_epvf, oct_ep_write64(ism_addr, (uint8_t *)otx_ep->hw_addr + SDP_VF_R_OUT_CNTS_ISM(oq_no)); droq->pkts_sent_ism = - (uint32_t *)((uint8_t *)otx_ep->ism_buffer_mz->addr + (uint32_t __rte_atomic *)((uint8_t *)otx_ep->ism_buffer_mz->addr + OTX2_EP_OQ_ISM_OFFSET(oq_no)); otx_ep_err("SDP_R[%d] OQ ISM virt: %p, dma: 0x%x", oq_no, - (void *)droq->pkts_sent_ism, + (void *)(uintptr_t)droq->pkts_sent_ism, (unsigned int)ism_addr); *droq->pkts_sent_ism = 0; droq->pkts_sent_prev = 0; diff --git a/drivers/net/octeon_ep/otx_ep_common.h b/drivers/net/octeon_ep/otx_ep_common.h index 7776940..73eb0c9 100644 --- a/drivers/net/octeon_ep/otx_ep_common.h +++ b/drivers/net/octeon_ep/otx_ep_common.h @@ -218,7 +218,7 @@ struct otx_ep_iq_config { */ struct otx_ep_instr_queue { /* Location in memory updated by SDP ISM */ - uint32_t *inst_cnt_ism; + RTE_ATOMIC(uint32_t) *inst_cnt_ism; struct rte_mbuf **mbuf_list; /* Pointer to the Virtual Base addr of the input ring. */ uint8_t *base_addr; @@ -413,7 +413,7 @@ struct otx_ep_droq { uint8_t ism_ena; /* Pointer to host memory copy of output packet count, set by ISM */ - uint32_t *pkts_sent_ism; + RTE_ATOMIC(uint32_t) *pkts_sent_ism; uint32_t pkts_sent_prev; /* Statistics for this DROQ. */ diff --git a/drivers/net/octeon_ep/otx_ep_rxtx.c b/drivers/net/octeon_ep/otx_ep_rxtx.c index 59144e0..eb2d8c1 100644 --- a/drivers/net/octeon_ep/otx_ep_rxtx.c +++ b/drivers/net/octeon_ep/otx_ep_rxtx.c @@ -475,7 +475,8 @@ rte_mb(); rte_write64(OTX2_SDP_REQUEST_ISM, iq->inst_cnt_reg); - while (__atomic_load_n(iq->inst_cnt_ism, __ATOMIC_RELAXED) >= val) { + while (rte_atomic_load_explicit(iq->inst_cnt_ism, + rte_memory_order_relaxed) >= val) { rte_write64(OTX2_SDP_REQUEST_ISM, iq->inst_cnt_reg); rte_mb(); } @@ -871,7 +872,8 @@ rte_mb(); rte_write64(OTX2_SDP_REQUEST_ISM, droq->pkts_sent_reg); - while (__atomic_load_n(droq->pkts_sent_ism, __ATOMIC_RELAXED) >= val) { + while (rte_atomic_load_explicit(droq->pkts_sent_ism, + rte_memory_order_relaxed) >= val) { rte_write64(OTX2_SDP_REQUEST_ISM, droq->pkts_sent_reg); rte_mb(); } -- 1.8.3.1