DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Thomas Monjalon <thomas@monjalon.net>
Cc: dev@dpdk.org, Ferruh Yigit <ferruh.yigit@intel.com>
Subject: [dpdk-dev] [PATCH v2 1/3] ethdev: extract xstat basic stat count calculation
Date: Tue, 24 Oct 2017 00:15:32 +0100	[thread overview]
Message-ID: <20171023231534.90996-1-ferruh.yigit@intel.com> (raw)
In-Reply-To: <20171023231251.90845-1-ferruh.yigit@intel.com>

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(-)

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;
 }
 
-- 
2.13.6

  parent reply	other threads:[~2017-10-23 23:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-20  0:03 [dpdk-dev] [PATCH " Ferruh Yigit
2017-10-20  0:03 ` [dpdk-dev] [PATCH 2/3] ethdev: fix xstats get by id APIS Ferruh Yigit
2017-10-20 12:33   ` Ivan Malov
2017-10-23 22:20   ` Thomas Monjalon
2017-10-20  0:03 ` [dpdk-dev] [PATCH 3/3] ethdev: fix negative return values in xstats Ferruh Yigit
2017-10-23 22:26   ` Thomas Monjalon
2017-10-23 23:12 ` [dpdk-dev] [PATCH 1/3] ethdev: extract xstat basic stat count calculation Ferruh Yigit
2017-10-23 23:12   ` [dpdk-dev] [PATCH 2/3] ethdev: fix xstats get by id APIS Ferruh Yigit
2017-10-23 23:12   ` [dpdk-dev] [PATCH 3/3] ethdev: check more errors in xstats retrieval Ferruh Yigit
2017-10-23 23:15   ` Ferruh Yigit [this message]
2017-10-23 23:15     ` [dpdk-dev] [PATCH v2 2/3] ethdev: fix xstats get by id APIS Ferruh Yigit
2017-10-23 23:33       ` Thomas Monjalon
2017-10-23 23:15     ` [dpdk-dev] [PATCH v2 3/3] ethdev: check more errors in xstats retrieval Ferruh Yigit
2017-10-24  0:31     ` [dpdk-dev] [PATCH v2 1/3] ethdev: extract xstat basic stat count calculation Ferruh Yigit

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=20171023231534.90996-1-ferruh.yigit@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=dev@dpdk.org \
    --cc=thomas@monjalon.net \
    /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).