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 53F9141EC0; Fri, 17 Mar 2023 21:20:31 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ADDC443014; Fri, 17 Mar 2023 21:19:58 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 01EA542FDE for ; Fri, 17 Mar 2023 21:19:51 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id C67E22057BE5; Fri, 17 Mar 2023 13:19:49 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C67E22057BE5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679084389; bh=qZSyEXfpTVJGPVhxnf5mnntfDFNG2ZYJQqEnDfm/rlI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HzkK0Zb/93o8fN/GauOjpHWdrXYC6HHcW9uI5byrmALjjgm6H2FWMPVlwK+ieqGFa Dbbmfy7i/LC3JA8EDEVKMputx59CBN/L0XXdQ31c0EFVl4PExNVhCYLtBH5Vtk9s99 tQpWTwZFGpwljPUeP3TUVqK13bIW4KR+eJCpxVfo= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 7/7] net/ring: replace rte atomics with GCC builtin atomics Date: Fri, 17 Mar 2023 13:19:48 -0700 Message-Id: <1679084388-19267-8-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679084388-19267-1-git-send-email-roretzla@linux.microsoft.com> References: <1679084388-19267-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 rte_atomic.h types and functions, instead use GCC supplied C++11 memory model builtins. Signed-off-by: Tyler Retzlaff --- drivers/net/ring/rte_eth_ring.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c index e8bc9b6..15d4a3d 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -44,8 +44,8 @@ enum dev_action { struct ring_queue { struct rte_ring *rng; - rte_atomic64_t rx_pkts; - rte_atomic64_t tx_pkts; + int64_t rx_pkts; + int64_t tx_pkts; }; struct pmd_internals { @@ -80,9 +80,9 @@ struct pmd_internals { const uint16_t nb_rx = (uint16_t)rte_ring_dequeue_burst(r->rng, ptrs, nb_bufs, NULL); if (r->rng->flags & RING_F_SC_DEQ) - r->rx_pkts.cnt += nb_rx; + r->rx_pkts += nb_rx; else - rte_atomic64_add(&(r->rx_pkts), nb_rx); + __atomic_fetch_add(&r->rx_pkts, nb_rx, __ATOMIC_SEQ_CST); return nb_rx; } @@ -94,9 +94,9 @@ struct pmd_internals { const uint16_t nb_tx = (uint16_t)rte_ring_enqueue_burst(r->rng, ptrs, nb_bufs, NULL); if (r->rng->flags & RING_F_SP_ENQ) - r->tx_pkts.cnt += nb_tx; + r->tx_pkts += nb_tx; else - rte_atomic64_add(&(r->tx_pkts), nb_tx); + __atomic_fetch_add(&r->tx_pkts, nb_tx, __ATOMIC_SEQ_CST); return nb_tx; } @@ -184,13 +184,13 @@ struct pmd_internals { for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS && i < dev->data->nb_rx_queues; i++) { - stats->q_ipackets[i] = internal->rx_ring_queues[i].rx_pkts.cnt; + stats->q_ipackets[i] = internal->rx_ring_queues[i].rx_pkts; rx_total += stats->q_ipackets[i]; } for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS && i < dev->data->nb_tx_queues; i++) { - stats->q_opackets[i] = internal->tx_ring_queues[i].tx_pkts.cnt; + stats->q_opackets[i] = internal->tx_ring_queues[i].tx_pkts; tx_total += stats->q_opackets[i]; } @@ -207,9 +207,9 @@ struct pmd_internals { struct pmd_internals *internal = dev->data->dev_private; for (i = 0; i < dev->data->nb_rx_queues; i++) - internal->rx_ring_queues[i].rx_pkts.cnt = 0; + internal->rx_ring_queues[i].rx_pkts = 0; for (i = 0; i < dev->data->nb_tx_queues; i++) - internal->tx_ring_queues[i].tx_pkts.cnt = 0; + internal->tx_ring_queues[i].tx_pkts = 0; return 0; } -- 1.8.3.1