Skip to contentSkip to conversation

net/xsc: add dev basic stats ops

PATCH Superseded WanRenyong 1 participant 1 message Sep 6, 2024 Network drivers

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

WanRenyong

author
#0 lore raw

PATCH 19/19 net/xsc: add dev basic stats ops

Implement xsc ethdev basic stats get and reset functions.

---
 doc/guides/nics/features/xsc.ini |  1 +
 drivers/net/xsc/xsc_ethdev.c     | 76 ++++++++++++++++++++++++++++++++
 drivers/net/xsc/xsc_rxtx.c       | 11 ++++-
 drivers/net/xsc/xsc_rxtx.h       | 15 +++++++
 4 files changed, 102 insertions(+), 1 deletion(-)
doc/guides/nics/features/xsc.ini +1 -0
index 84c5ff4b6b..d73cf9d136 100644
@@ -12,6 +12,7 @@ L3 checksum offload  = Y
 L4 checksum offload  = Y
 Inner L3 checksum    = Y
 Inner L4 checksum    = Y
+Basic stats          = Y
 Linux                = Y
 ARMv8                = Y
 x86-64               = Y
drivers/net/xsc/xsc_ethdev.c +76 -0

88 lines not on this page · raw message

drivers/net/xsc/xsc_rxtx.c +10 -1
index 7a31cd428c..8aed8f4b12 100644
@@ -62,6 +62,7 @@ xsc_rx_poll_len(struct xsc_rxq_data *rxq, volatile struct xsc_cqe *cqe)
 		ret = check_cqe_own(cqe, rxq->cqe_n, rxq->cq_ci);
 		if (unlikely(ret != XSC_CQE_OWNER_SW)) {
 			if (unlikely(ret == XSC_CQE_OWNER_ERR)) {
+				++rxq->stats.rx_errors;
 				/* TODO */
 				if (ret == XSC_CQE_OWNER_HW ||
 						ret == -1)
@@ -116,8 +117,10 @@ xsc_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
 		rte_prefetch0(wqe);
 
 		rep = rte_mbuf_raw_alloc(seg->pool);
-		if (unlikely(rep == NULL))
+		if (unlikely(rep == NULL)) {
+			++rxq->stats.rx_nombuf;
 			break;
+		}
 
 		if (!pkt) {
 			if (read_cqe_num) {
@@ -166,6 +169,7 @@ xsc_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
 		/* Fill wqe */
 		wqe->va = rte_cpu_to_le_64(rte_pktmbuf_iova(rep));
 		rte_pktmbuf_data_len(seg) = len;
+		rxq->stats.rx_bytes += rte_pktmbuf_pkt_len(pkt);
 
 		*(pkts++) = pkt;
 		pkt = NULL;
@@ -200,6 +204,7 @@ xsc_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
 		rxq->nb_rx_hold = 0;
 	}
 
+	rxq->stats.rx_pkts += nb_pkts;
 	return nb_pkts;
 }
 
@@ -239,6 +244,7 @@ xsc_tx_cqes_handle(struct xsc_txq_data *__rte_restrict txq)
 			++txq->cq_ci;
 			txq->cq_pi = txq->cq_ci;
 			last_cqe = NULL;
+			++txq->stats.tx_errors;
 			continue;
 		}
 
@@ -348,6 +354,7 @@ xsc_tx_wqes_fill(struct xsc_txq_data *__rte_restrict txq,
 		/* init wqe data segs */
 		xsc_tx_wqe_data_seg_init(mbuf, wqe);
 		++txq->wqe_ci;
+		txq->stats.tx_bytes += rte_pktmbuf_pkt_len(mbuf);
 	}
 
 	return wqe;
@@ -432,5 +439,7 @@ xsc_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 		goto loop;
 
 exit:
+
+	txq->stats.tx_pkts += (pkts_n - remain_n);
 	return pkts_n - remain_n;
 }
drivers/net/xsc/xsc_rxtx.h +15 -0
index ce6e47ad4c..3d1e3ba83a 100644
@@ -85,6 +85,12 @@ struct xsc_cqe {
 	uint8_t		owner:1;
 };
 
+struct xsc_txq_stats {
+	uint64_t tx_pkts;   /* Total number of tx packets */
+	uint64_t tx_bytes;  /* Total number of tx bytes */
+	uint64_t tx_errors; /* Total number of tx error packets */
+};
+
 struct __rte_cache_aligned xsc_txq_data {
 	uint16_t idx;  /*QP idx */
 	uint16_t port_id;
@@ -116,12 +122,20 @@ struct __rte_cache_aligned xsc_txq_data {
 	volatile uint32_t *qp_db;
 	volatile uint32_t *cq_db;
 	struct xsc_ethdev_priv *priv;
+	struct xsc_txq_stats stats;
 	uint32_t socket;
 	uint8_t tso_en:1; /* TSO enable 0-off 1-on */
 	uint16_t *fcqs; /* Free completion queue. */
 	struct rte_mbuf *elts[0]; /* Storage for queued packets, for free */
 };
 
+struct xsc_rxq_stats {
+	uint64_t rx_pkts;   /* Total number of rx packets */
+	uint64_t rx_bytes;  /* Total number of rx bytes */
+	uint64_t rx_errors; /* Total number of rx error packets */
+	uint64_t rx_nombuf; /* Total number of rx mbuf alloc failed */
+};
+
 struct xsc_cqe_u64 {
 	struct xsc_cqe cqe0;
 	struct xsc_cqe cqe1;
@@ -158,6 +172,7 @@ struct __rte_cache_aligned xsc_rxq_data {
 	const struct rte_memzone *rq_pas;  /* Palist memory */
 	uint32_t socket;
 	struct xsc_ethdev_priv *priv;
+	struct xsc_rxq_stats stats;
 	/* attr */
 	uint32_t csum:1;  /* Checksum offloading enable */
 	uint32_t hw_timestamp:1;
Signature · 1 line
2.25.1