[dpdk-dev,1/3] ethdev: xstats generic Q stats refactor

Message ID 1446819175-31325-2-git-send-email-harry.van.haaren@intel.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

Van Haaren, Harry Nov. 6, 2015, 2:12 p.m. UTC
  This patch refactors the generic queue stats to be exposed
by rte_ethdev_xstats_get().

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
 lib/librte_ether/rte_ethdev.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
  

Comments

Tahhan, Maryam Nov. 8, 2015, 7:39 a.m. UTC | #1
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Harry van Haaren
> Sent: Friday, November 6, 2015 2:13 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH 1/3] ethdev: xstats generic Q stats refactor
> 
> This patch refactors the generic queue stats to be exposed by
> rte_ethdev_xstats_get().
> 
> Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
> ---

Acked-by: Maryam Tahhan <maryam.tahhan@intel.com>
  

Patch

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index e0e1dca..b464f30 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1515,7 +1515,8 @@  rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
 	dev = &rte_eth_devices[port_id];
 
 	/* Return generic statistics */
-	count = RTE_NB_STATS;
+	count = RTE_NB_STATS + (dev->data->nb_rx_queues * RTE_NB_RXQ_STATS) +
+		(dev->data->nb_tx_queues * RTE_NB_TXQ_STATS);
 
 	/* implemented by the driver */
 	if (dev->dev_ops->xstats_get != NULL) {
@@ -1527,9 +1528,6 @@  rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
 
 		if (xcount < 0)
 			return xcount;
-	} else {
-		count += dev->data->nb_rx_queues * RTE_NB_RXQ_STATS;
-		count += dev->data->nb_tx_queues * RTE_NB_TXQ_STATS;
 	}
 
 	if (n < count + xcount)
@@ -1549,10 +1547,6 @@  rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
 		xstats[count++].value = val;
 	}
 
-	/* if xstats_get() is implemented by the PMD, the Q stats are done */
-	if (dev->dev_ops->xstats_get != NULL)
-		return count + xcount;
-
 	/* per-rxq stats */
 	for (q = 0; q < dev->data->nb_rx_queues; q++) {
 		for (i = 0; i < RTE_NB_RXQ_STATS; i++) {