[dpdk-dev,1/3] ethdev: extract xstat basic stat count calculation

Message ID 20171020000351.57868-1-ferruh.yigit@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Ferruh Yigit Oct. 20, 2017, 12:03 a.m. UTC
  Extract into static inline function so that can be used by other
functions.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_ether/rte_ethdev.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)
  

Patch

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 0b1e92894..798855e15 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1550,6 +1550,22 @@  rte_eth_stats_reset(uint16_t port_id)
 	return 0;
 }
 
+static inline int
+get_xstats_basic_count(struct rte_eth_dev *dev)
+{
+	uint16_t nb_rxqs, nb_txqs;
+	int count;
+
+	nb_rxqs = RTE_MIN(dev->data->nb_rx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS);
+	nb_txqs = RTE_MIN(dev->data->nb_tx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS);
+
+	count = RTE_NB_STATS;
+	count += nb_rxqs * RTE_NB_RXQ_STATS;
+	count += nb_txqs * RTE_NB_TXQ_STATS;
+
+	return count;
+}
+
 static int
 get_xstats_count(uint16_t port_id)
 {
@@ -1571,11 +1587,9 @@  get_xstats_count(uint16_t port_id)
 	} else
 		count = 0;
 
-	count += RTE_NB_STATS;
-	count += RTE_MIN(dev->data->nb_rx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS) *
-		 RTE_NB_RXQ_STATS;
-	count += RTE_MIN(dev->data->nb_tx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS) *
-		 RTE_NB_TXQ_STATS;
+
+	count += get_xstats_basic_count(dev);
+
 	return count;
 }