DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ruifeng Wang <ruifeng.wang@arm.com>
To: ajit.khaparde@broadcom.com, somnath.kotur@broadcom.com
Cc: dev@dpdk.org, honnappa.nagarahalli@arm.com, nd@arm.com,
	Ruifeng Wang <ruifeng.wang@arm.com>,
	Kathleen Capella <kathleen.capella@arm.com>
Subject: [PATCH 1/2] net/bnxt: use compiler atomics for stats
Date: Tue, 10 May 2022 14:31:17 +0800	[thread overview]
Message-ID: <20220510063118.449216-2-ruifeng.wang@arm.com> (raw)
In-Reply-To: <20220510063118.449216-1-ruifeng.wang@arm.com>

Converted rte_atomic usages to compiler atomic built-ins.

Signed-off-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Kathleen Capella <kathleen.capella@arm.com>
---
 drivers/net/bnxt/bnxt_rxq.c   | 2 +-
 drivers/net/bnxt/bnxt_rxq.h   | 2 +-
 drivers/net/bnxt/bnxt_rxr.c   | 9 +++++----
 drivers/net/bnxt/bnxt_stats.c | 4 ++--
 4 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c
index cd3bb1446f..9c93cde9b3 100644
--- a/drivers/net/bnxt/bnxt_rxq.c
+++ b/drivers/net/bnxt/bnxt_rxq.c
@@ -378,7 +378,7 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
 			    "ring_dma_zone_reserve for rx_ring failed!\n");
 		goto err;
 	}
-	rte_atomic64_init(&rxq->rx_mbuf_alloc_fail);
+	rxq->rx_mbuf_alloc_fail = 0;
 
 	/* rxq 0 must not be stopped when used as async CPR */
 	if (!BNXT_NUM_ASYNC_CPR(bp) && queue_idx == 0)
diff --git a/drivers/net/bnxt/bnxt_rxq.h b/drivers/net/bnxt/bnxt_rxq.h
index 0331c23810..7b52a21497 100644
--- a/drivers/net/bnxt/bnxt_rxq.h
+++ b/drivers/net/bnxt/bnxt_rxq.h
@@ -40,7 +40,7 @@ struct bnxt_rx_queue {
 	struct bnxt_rx_ring_info	*rx_ring;
 	struct bnxt_cp_ring_info	*cp_ring;
 	struct rte_mbuf			fake_mbuf;
-	rte_atomic64_t		rx_mbuf_alloc_fail;
+	uint64_t			rx_mbuf_alloc_fail;
 	const struct rte_memzone *mz;
 };
 
diff --git a/drivers/net/bnxt/bnxt_rxr.c b/drivers/net/bnxt/bnxt_rxr.c
index 5a9cf48e67..738f2f584c 100644
--- a/drivers/net/bnxt/bnxt_rxr.c
+++ b/drivers/net/bnxt/bnxt_rxr.c
@@ -49,7 +49,7 @@ static inline int bnxt_alloc_rx_data(struct bnxt_rx_queue *rxq,
 	rx_buf = &rxr->rx_buf_ring[prod];
 	mbuf = __bnxt_alloc_rx_data(rxq->mb_pool);
 	if (!mbuf) {
-		rte_atomic64_inc(&rxq->rx_mbuf_alloc_fail);
+		__atomic_fetch_add(&rxq->rx_mbuf_alloc_fail, 1, __ATOMIC_RELAXED);
 		return -ENOMEM;
 	}
 
@@ -84,7 +84,7 @@ static inline int bnxt_alloc_ag_data(struct bnxt_rx_queue *rxq,
 
 	mbuf = __bnxt_alloc_rx_data(rxq->mb_pool);
 	if (!mbuf) {
-		rte_atomic64_inc(&rxq->rx_mbuf_alloc_fail);
+		__atomic_fetch_add(&rxq->rx_mbuf_alloc_fail, 1, __ATOMIC_RELAXED);
 		return -ENOMEM;
 	}
 
@@ -459,7 +459,7 @@ static inline struct rte_mbuf *bnxt_tpa_end(
 	struct rte_mbuf *new_data = __bnxt_alloc_rx_data(rxq->mb_pool);
 	RTE_ASSERT(new_data != NULL);
 	if (!new_data) {
-		rte_atomic64_inc(&rxq->rx_mbuf_alloc_fail);
+		__atomic_fetch_add(&rxq->rx_mbuf_alloc_fail, 1, __ATOMIC_RELAXED);
 		return NULL;
 	}
 	tpa_info->mbuf = new_data;
@@ -1369,7 +1369,8 @@ int bnxt_init_one_rx_ring(struct bnxt_rx_queue *rxq)
 				rxr->tpa_info[i].mbuf =
 					__bnxt_alloc_rx_data(rxq->mb_pool);
 				if (!rxr->tpa_info[i].mbuf) {
-					rte_atomic64_inc(&rxq->rx_mbuf_alloc_fail);
+					__atomic_fetch_add(&rxq->rx_mbuf_alloc_fail, 1,
+							__ATOMIC_RELAXED);
 					return -ENOMEM;
 				}
 			}
diff --git a/drivers/net/bnxt/bnxt_stats.c b/drivers/net/bnxt/bnxt_stats.c
index 208aa5616d..72169e8b35 100644
--- a/drivers/net/bnxt/bnxt_stats.c
+++ b/drivers/net/bnxt/bnxt_stats.c
@@ -578,7 +578,7 @@ int bnxt_stats_get_op(struct rte_eth_dev *eth_dev,
 
 		bnxt_fill_rte_eth_stats(bnxt_stats, &ring_stats, i, true);
 		bnxt_stats->rx_nombuf +=
-				rte_atomic64_read(&rxq->rx_mbuf_alloc_fail);
+				__atomic_load_n(&rxq->rx_mbuf_alloc_fail, __ATOMIC_RELAXED);
 	}
 
 	num_q_stats = RTE_MIN(bp->tx_cp_nr_rings,
@@ -632,7 +632,7 @@ int bnxt_stats_reset_op(struct rte_eth_dev *eth_dev)
 	for (i = 0; i < bp->rx_cp_nr_rings; i++) {
 		struct bnxt_rx_queue *rxq = bp->rx_queues[i];
 
-		rte_atomic64_clear(&rxq->rx_mbuf_alloc_fail);
+		rxq->rx_mbuf_alloc_fail = 0;
 	}
 
 	bnxt_clear_prev_stat(bp);
-- 
2.25.1


  reply	other threads:[~2022-05-10  6:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-10  6:31 [PATCH 0/2] atomic changes Ruifeng Wang
2022-05-10  6:31 ` Ruifeng Wang [this message]
2022-05-10  6:31 ` [PATCH 2/2] net/bnxt: remove some dead code Ruifeng Wang
2022-05-11  6:08   ` Ruifeng Wang
2022-05-23  0:55 ` [PATCH 0/2] atomic changes Ajit Khaparde

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=20220510063118.449216-2-ruifeng.wang@arm.com \
    --to=ruifeng.wang@arm.com \
    --cc=ajit.khaparde@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=honnappa.nagarahalli@arm.com \
    --cc=kathleen.capella@arm.com \
    --cc=nd@arm.com \
    --cc=somnath.kotur@broadcom.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).