DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: stable@dpdk.org, Stephen Hemminger <stephen@networkplumber.org>
Subject: [dpdk-dev] [PATCH 2/2] net/netvsc: fix xstats for VF device
Date: Thu, 20 Jun 2019 15:09:24 -0700	[thread overview]
Message-ID: <20190620220924.32079-3-stephen@networkplumber.org> (raw)
In-Reply-To: <20190620220924.32079-1-stephen@networkplumber.org>

The id values for VF stats were not being offset correctly.
And getting xstats for VF device only worked if VF device supported
it; it did not support the generic stats.

Fixes: dc7680e8597c ("net/netvsc: support integrated VF")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/netvsc/hn_ethdev.c |  2 +-
 drivers/net/netvsc/hn_var.h    |  2 +-
 drivers/net/netvsc/hn_vf.c     | 26 ++++++++++++++++++--------
 3 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
index d37db7c6a232..2b1b2ba3b845 100644
--- a/drivers/net/netvsc/hn_ethdev.c
+++ b/drivers/net/netvsc/hn_ethdev.c
@@ -598,7 +598,7 @@ hn_dev_xstats_get(struct rte_eth_dev *dev,
 		}
 	}
 
-	ret = hn_vf_xstats_get(dev, xstats + count, n - count);
+	ret = hn_vf_xstats_get(dev, xstats, count, n);
 	if (ret < 0)
 		return ret;
 
diff --git a/drivers/net/netvsc/hn_var.h b/drivers/net/netvsc/hn_var.h
index bf94d90a7635..be657af0982a 100644
--- a/drivers/net/netvsc/hn_var.h
+++ b/drivers/net/netvsc/hn_var.h
@@ -237,5 +237,5 @@ int	hn_vf_xstats_get_names(struct rte_eth_dev *dev,
 			       unsigned int size);
 int	hn_vf_xstats_get(struct rte_eth_dev *dev,
 			 struct rte_eth_xstat *xstats,
-			 unsigned int n);
+			 unsigned int offset, unsigned int n);
 void	hn_vf_xstats_reset(struct rte_eth_dev *dev);
diff --git a/drivers/net/netvsc/hn_vf.c b/drivers/net/netvsc/hn_vf.c
index 27ac87e7e975..3a833d447ac1 100644
--- a/drivers/net/netvsc/hn_vf.c
+++ b/drivers/net/netvsc/hn_vf.c
@@ -506,17 +506,19 @@ int hn_vf_xstats_get_names(struct rte_eth_dev *dev,
 	struct hn_data *hv = dev->data->dev_private;
 	struct rte_eth_dev *vf_dev;
 	int i, count = 0;
-	char tmp[RTE_ETH_XSTATS_NAME_SIZE];
 
 	rte_spinlock_lock(&hv->vf_lock);
 	vf_dev = hn_get_vf_dev(hv);
-	if (vf_dev && vf_dev->dev_ops->xstats_get_names)
-		count = vf_dev->dev_ops->xstats_get_names(vf_dev, names, n);
+	if (vf_dev)
+		count = rte_eth_xstats_get_names(vf_dev->data->port_id,
+						 names, n);
 	rte_spinlock_unlock(&hv->vf_lock);
 
 	/* add vf_ prefix to xstat names */
 	if (names) {
 		for (i = 0; i < count; i++) {
+			char tmp[RTE_ETH_XSTATS_NAME_SIZE];
+
 			snprintf(tmp, sizeof(tmp), "vf_%s", names[i].name);
 			strlcpy(names[i].name, tmp, sizeof(names[i].name));
 		}
@@ -527,18 +529,26 @@ int hn_vf_xstats_get_names(struct rte_eth_dev *dev,
 
 int hn_vf_xstats_get(struct rte_eth_dev *dev,
 		     struct rte_eth_xstat *xstats,
+		     unsigned int offset,
 		     unsigned int n)
 {
 	struct hn_data *hv = dev->data->dev_private;
 	struct rte_eth_dev *vf_dev;
-	int count = 0;
+	int i, count = 0;
 
 	rte_spinlock_lock(&hv->vf_lock);
 	vf_dev = hn_get_vf_dev(hv);
-	if (vf_dev && vf_dev->dev_ops->xstats_get)
-		count = vf_dev->dev_ops->xstats_get(vf_dev, xstats, n);
+	if (vf_dev)
+		count = rte_eth_xstats_get(vf_dev->data->port_id,
+					   xstats + offset, n - offset);
 	rte_spinlock_unlock(&hv->vf_lock);
 
+	/* Offset id's for VF stats */
+	if (count > 0) {
+		for (i = 0; i < count; i++)
+			xstats[i + offset].id += offset;
+	}
+
 	return count;
 }
 
@@ -549,7 +559,7 @@ void hn_vf_xstats_reset(struct rte_eth_dev *dev)
 
 	rte_spinlock_lock(&hv->vf_lock);
 	vf_dev = hn_get_vf_dev(hv);
-	if (vf_dev && vf_dev->dev_ops->xstats_reset)
-		vf_dev->dev_ops->xstats_reset(vf_dev);
+	if (vf_dev)
+		rte_eth_xstats_reset(vf_dev->data->port_id);
 	rte_spinlock_unlock(&hv->vf_lock);
 }
-- 
2.20.1


  parent reply	other threads:[~2019-06-20 22:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-20 22:09 [dpdk-dev] [PATCH 0/2] net/netvsc: xstat fixes Stephen Hemminger
2019-06-20 22:09 ` [dpdk-dev] [PATCH 1/2] net/netvsc: set id in xstats_get Stephen Hemminger
2019-06-20 22:09 ` Stephen Hemminger [this message]
2019-06-27 18:33 ` [dpdk-dev] [dpdk-stable] [PATCH 0/2] net/netvsc: xstat fixes 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=20190620220924.32079-3-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=stable@dpdk.org \
    /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).