Skip to contentSkip to conversation

net/netvsc: xstat fixes

PATCH In review Stephen Hemminger 2 participants 4 messages Jun 20, 2019 – Jun 27, 2019 Network drivers

lore
Share & tools
lore
#0 lore raw

cover net/netvsc: xstat fixes

A couple of fixes for the xstats functionality in netvsc PMD.

Mohsin Mazhar Shaikh (1):
net/netvsc: set id in xstats_get

Stephen Hemminger (1):
net/netvsc: fix xstats for VF device

 drivers/net/netvsc/hn_ethdev.c | 14 +++++++++-----
 drivers/net/netvsc/hn_var.h    |  2 +-
 drivers/net/netvsc/hn_vf.c     | 26 ++++++++++++++++++--------
 3 files changed, 28 insertions(+), 14 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/2 net/netvsc: set id in xstats_get

From: Mohsin Mazhar Shaikh <[email protected]>

The xstats_get was not setting id correctly for each entry.

Fixes 4e9c73e96e83 ("net/netvsc: add Hyper-V network device")
---
 drivers/net/netvsc/hn_ethdev.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/net/netvsc/hn_ethdev.c +8 -4
index 9e7cf2df5472..d37db7c6a232 100644
@@ -577,9 +577,11 @@ hn_dev_xstats_get(struct rte_eth_dev *dev,
 			continue;
 
 		stats = (const char *)&txq->stats;
-		for (t = 0; t < RTE_DIM(hn_stat_strings); t++)
-			xstats[count++].value = *(const uint64_t *)
+		for (t = 0; t < RTE_DIM(hn_stat_strings); t++, count++) {
+			xstats[count].id = count;
+			xstats[count].value = *(const uint64_t *)
 				(stats + hn_stat_strings[t].offset);
+		}
 	}
 
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
@@ -589,9 +591,11 @@ hn_dev_xstats_get(struct rte_eth_dev *dev,
 			continue;
 
 		stats = (const char *)&rxq->stats;
-		for (t = 0; t < RTE_DIM(hn_stat_strings); t++)
-			xstats[count++].value = *(const uint64_t *)
+		for (t = 0; t < RTE_DIM(hn_stat_strings); t++, count++) {
+			xstats[count].id = count;
+			xstats[count].value = *(const uint64_t *)
 				(stats + hn_stat_strings[t].offset);
+		}
 	}
 
 	ret = hn_vf_xstats_get(dev, xstats + count, n - count);
Signature · 1 line
2.20.1
#2 lore raw

PATCH 2/2 net/netvsc: fix xstats for VF device

In reply to Stephen Hemminger

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")
---
 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(-)
drivers/net/netvsc/hn_ethdev.c +1 -1
index d37db7c6a232..2b1b2ba3b845 100644
@@ -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;
 
drivers/net/netvsc/hn_var.h +1 -1
index bf94d90a7635..be657af0982a 100644
@@ -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);
drivers/net/netvsc/hn_vf.c +18 -8
index 27ac87e7e975..3a833d447ac1 100644
@@ -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);
 }
Signature · 1 line
2.20.1
#3 lore raw
In reply to Stephen Hemminger
Quoted 7 lines · Stephen Hemminger

A couple of fixes for the xstats functionality in netvsc PMD.

Mohsin Mazhar Shaikh (1):
net/netvsc: set id in xstats_get

Stephen Hemminger (1):
net/netvsc: fix xstats for VF device

Series applied to dpdk-next-net/master, thanks.