DPDK patches and discussions
 help / color / mirror / Atom feed
From: Elza Mathew <elza.mathew@intel.com>
To: thomas@monjalon.net
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 2/2] lib: optimize _xstats_by_ids APIs
Date: Tue,  5 Dec 2017 16:25:07 -0800	[thread overview]
Message-ID: <1512519907-62388-2-git-send-email-elza.mathew@intel.com> (raw)
In-Reply-To: <1512519907-62388-1-git-send-email-elza.mathew@intel.com>

Introduced a check to detect if the stats IDs being
requested are all basic stats IDs. In that case,
ensured that only the basic stats would be retrieved.
Previously, both basic stats and xstats were being
retrieved even if all the IDs were basic stats IDs.

Signed-off-by: Elza Mathew <elza.mathew@intel.com>
---
 lib/librte_ether/rte_ethdev.c | 38 +++++++++++++++++++++++++++++++++++---
 1 file changed, 35 insertions(+), 3 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index dfe8e65..210600d 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1688,7 +1688,9 @@ struct rte_eth_dev *
 {
 	struct rte_eth_xstat_name *xstats_names_copy;
 	unsigned int no_basic_stat_requested = 1;
+	unsigned int no_ext_stat_requested = 1;
 	unsigned int expected_entries;
+	unsigned int basic_count;
 	struct rte_eth_dev *dev;
 	unsigned int i;
 	int ret;
@@ -1696,6 +1698,7 @@ struct rte_eth_dev *
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
+	basic_count = get_xstats_basic_count(dev);
 	ret = get_xstats_count(port_id);
 	if (ret < 0)
 		return ret;
@@ -1713,7 +1716,6 @@ struct rte_eth_dev *
 		return -EINVAL;
 
 	if (ids && dev->dev_ops->xstats_get_names_by_id != NULL && size > 0) {
-		unsigned int basic_count = get_xstats_basic_count(dev);
 		uint64_t ids_copy[size];
 
 		for (i = 0; i < size; i++) {
@@ -1752,8 +1754,22 @@ struct rte_eth_dev *
 		return -ENOMEM;
 	}
 
+	if (ids) {
+		for (i = 0; i < size; i++) {
+			if (ids[i] > basic_count) {
+				no_ext_stat_requested = 0;
+				break;
+			}
+		}
+	}
+
 	/* Fill xstats_names_copy structure */
-	rte_eth_xstats_get_names(port_id, xstats_names_copy, expected_entries);
+	if (ids && no_ext_stat_requested) {
+		rte_eth_basic_stats_get_names(dev, xstats_names_copy);
+	} else {
+		rte_eth_xstats_get_names(port_id, xstats_names_copy,
+			expected_entries);
+	}
 
 	/* Filter stats */
 	for (i = 0; i < size; i++) {
@@ -1860,7 +1876,9 @@ struct rte_eth_dev *
 			 uint64_t *values, unsigned int size)
 {
 	unsigned int no_basic_stat_requested = 1;
+	unsigned int no_ext_stat_requested = 1;
 	unsigned int num_xstats_filled;
+	unsigned int basic_count;
 	uint16_t expected_entries;
 	struct rte_eth_dev *dev;
 	unsigned int i;
@@ -1870,6 +1888,7 @@ struct rte_eth_dev *
 	expected_entries = get_xstats_count(port_id);
 	struct rte_eth_xstat xstats[expected_entries];
 	dev = &rte_eth_devices[port_id];
+	basic_count = get_xstats_basic_count(dev);
 
 	/* Return max number of stats if no ids given */
 	if (!ids) {
@@ -1904,8 +1923,21 @@ struct rte_eth_dev *
 					values, size);
 	}
 
+	if (ids) {
+		for (i = 0; i < size; i++) {
+			if (ids[i] > basic_count) {
+				no_ext_stat_requested = 0;
+				break;
+			}
+		}
+	}
+
 	/* Fill the xstats structure */
-	ret = rte_eth_xstats_get(port_id, xstats, expected_entries);
+	if (ids && no_ext_stat_requested)
+		ret = rte_eth_basic_stats_get(port_id, xstats);
+	else
+		ret = rte_eth_xstats_get(port_id, xstats, expected_entries);
+
 	if (ret < 0)
 		return ret;
 	num_xstats_filled = (unsigned int)ret;
-- 
1.9.1

  reply	other threads:[~2017-12-06  0:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-06  0:25 [dpdk-dev] [PATCH 1/2] lib: refactor basic stats code Elza Mathew
2017-12-06  0:25 ` Elza Mathew [this message]
2017-12-11 13:27   ` [dpdk-dev] [PATCH 2/2] lib: optimize _xstats_by_ids APIs Daly, Lee
2017-12-11 13:27 ` [dpdk-dev] [PATCH 1/2] lib: refactor basic stats code Daly, Lee
2018-01-09 11:18   ` 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=1512519907-62388-2-git-send-email-elza.mathew@intel.com \
    --to=elza.mathew@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).