DPDK patches and discussions
 help / color / mirror / Atom feed
From: Remy Horton <remy.horton@intel.com>
To: thomas.monjalon@6wind.com
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v1] ethdev: fix xstats id mismatch
Date: Fri,  8 Jul 2016 16:44:24 +0100	[thread overview]
Message-ID: <1467992664-15796-1-git-send-email-remy.horton@intel.com> (raw)

When fetching xstats values the driver specific parameters are
placed after the generic ones, but when fetching xstats names
the driver specific parameter names came first. This patch fixes
the resulting id mismatch between names and values.

Fixes: bd6aa172cf35 ("ethdev: fetch extended statistics with integer ids")

Signed-off-by: Remy Horton <remy.horton@intel.com>
---
 lib/librte_ether/rte_ethdev.c | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index eac260f..80b4d90 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1536,6 +1536,7 @@ rte_eth_xstats_get_names(uint8_t port_id,
 	struct rte_eth_dev *dev;
 	int cnt_used_entries;
 	int cnt_expected_entries;
+	int cnt_driver_entries;
 	uint32_t idx, id_queue;
 
 	cnt_expected_entries = get_xstats_count(port_id);
@@ -1545,16 +1546,7 @@ rte_eth_xstats_get_names(uint8_t port_id,
 
 	/* port_id checked in get_xstats_count() */
 	dev = &rte_eth_devices[port_id];
-	if (dev->dev_ops->xstats_get_names != NULL) {
-		cnt_used_entries = (*dev->dev_ops->xstats_get_names)(
-			dev, xstats_names, size);
-		if (cnt_used_entries < 0)
-			return cnt_used_entries;
-	} else
-		/* Driver itself does not support extended stats, but
-		 * still have basic stats.
-		 */
-		cnt_used_entries = 0;
+	cnt_used_entries = 0;
 
 	for (idx = 0; idx < RTE_NB_STATS; idx++) {
 		snprintf(xstats_names[cnt_used_entries].name,
@@ -1581,6 +1573,20 @@ rte_eth_xstats_get_names(uint8_t port_id,
 			cnt_used_entries++;
 		}
 	}
+
+	if (dev->dev_ops->xstats_get_names != NULL) {
+		/* If there are any driver-specific xstats, append them
+		 * to end of list.
+		 */
+		cnt_driver_entries = (*dev->dev_ops->xstats_get_names)(
+			dev,
+			xstats_names + cnt_used_entries,
+			size - cnt_used_entries);
+		if (cnt_driver_entries < 0)
+			return cnt_driver_entries;
+		cnt_used_entries += cnt_driver_entries;
+	}
+
 	return cnt_used_entries;
 }
 
@@ -1628,7 +1634,6 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstat *xstats,
 		stats_ptr = RTE_PTR_ADD(&eth_stats,
 					rte_stats_strings[i].offset);
 		val = *stats_ptr;
-		xstats[count].id = count + xcount;
 		xstats[count++].value = val;
 	}
 
@@ -1639,7 +1644,6 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstat *xstats,
 					rte_rxq_stats_strings[i].offset +
 					q * sizeof(uint64_t));
 			val = *stats_ptr;
-			xstats[count].id = count + xcount;
 			xstats[count++].value = val;
 		}
 	}
@@ -1651,11 +1655,13 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstat *xstats,
 					rte_txq_stats_strings[i].offset +
 					q * sizeof(uint64_t));
 			val = *stats_ptr;
-			xstats[count].id = count + xcount;
 			xstats[count++].value = val;
 		}
 	}
 
+	for (i = 0; i < count + xcount; i++)
+		xstats[i].id = i;
+
 	return count + xcount;
 }
 
-- 
2.5.5

             reply	other threads:[~2016-07-08 15:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-08 15:44 Remy Horton [this message]
2016-07-09 21:22 ` Thomas Monjalon

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=1467992664-15796-1-git-send-email-remy.horton@intel.com \
    --to=remy.horton@intel.com \
    --cc=dev@dpdk.org \
    --cc=thomas.monjalon@6wind.com \
    /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).