* [PATCH 1/2] net/bnxt: use compiler atomics for stats
2022-05-10 6:31 [PATCH 0/2] atomic changes Ruifeng Wang
@ 2022-05-10 6:31 ` Ruifeng Wang
2022-05-10 6:31 ` [PATCH 2/2] net/bnxt: remove some dead code Ruifeng Wang
2022-05-23 0:55 ` [PATCH 0/2] atomic changes Ajit Khaparde
2 siblings, 0 replies; 5+ messages in thread
From: Ruifeng Wang @ 2022-05-10 6:31 UTC (permalink / raw)
To: ajit.khaparde, somnath.kotur
Cc: dev, honnappa.nagarahalli, nd, Ruifeng Wang, Kathleen Capella
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] net/bnxt: remove some dead code
2022-05-10 6:31 [PATCH 0/2] atomic changes Ruifeng Wang
2022-05-10 6:31 ` [PATCH 1/2] net/bnxt: use compiler atomics for stats Ruifeng Wang
@ 2022-05-10 6:31 ` Ruifeng Wang
2022-05-11 6:08 ` Ruifeng Wang
2022-05-23 0:55 ` [PATCH 0/2] atomic changes Ajit Khaparde
2 siblings, 1 reply; 5+ messages in thread
From: Ruifeng Wang @ 2022-05-10 6:31 UTC (permalink / raw)
To: ajit.khaparde, somnath.kotur
Cc: dev, honnappa.nagarahalli, nd, Ruifeng Wang, Kathleen Capella
Removed some macros that were defined but not used in this driver.
As a result, rte_smp_xx occurrence is removed from this driver.
Signed-off-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Kathleen Capella <kathleen.capella@arm.com>
---
drivers/net/bnxt/bnxt_cpr.h | 14 --------------
1 file changed, 14 deletions(-)
diff --git a/drivers/net/bnxt/bnxt_cpr.h b/drivers/net/bnxt/bnxt_cpr.h
index 52db382c2f..dab6bed2ae 100644
--- a/drivers/net/bnxt/bnxt_cpr.h
+++ b/drivers/net/bnxt/bnxt_cpr.h
@@ -39,25 +39,11 @@ struct bnxt_db_info;
#define B_CP_DB_DISARM(cpr) (*(uint32_t *)((cpr)->cp_db.doorbell) = \
DB_KEY_CP | DB_IRQ_DIS)
-#define B_CP_DB_IDX_ARM(cpr, cons) \
- (*(uint32_t *)((cpr)->cp_db.doorbell) = (DB_CP_REARM_FLAGS | \
- (cons)))
-
-#define B_CP_DB_IDX_DISARM(cpr, cons) do { \
- rte_smp_wmb(); \
- (*(uint32_t *)((cpr)->cp_db.doorbell) = (DB_CP_FLAGS | \
- (cons)); \
-} while (0)
#define B_CP_DIS_DB(cpr, raw_cons) \
rte_write32_relaxed((DB_CP_FLAGS | \
DB_RING_IDX(&((cpr)->cp_db), raw_cons)), \
((cpr)->cp_db.doorbell))
-#define B_CP_DB(cpr, raw_cons, ring_mask) \
- rte_write32((DB_CP_FLAGS | \
- RING_CMPL((ring_mask), raw_cons)), \
- ((cpr)->cp_db.doorbell))
-
struct bnxt_db_info {
void *doorbell;
union {
--
2.25.1
^ permalink raw reply [flat|nested] 5+ messages in thread