DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/2] net/mlx5: remove unused interface name query
@ 2017-02-21 14:37 Shahaf Shuler
  2017-02-21 14:37 ` [dpdk-dev] [PATCH 2/2] net/mlx5: fix extended statistics wrong number Shahaf Shuler
  2017-02-22 19:16 ` [dpdk-dev] [PATCH 1/2] net/mlx5: remove unused interface name query Ferruh Yigit
  0 siblings, 2 replies; 3+ messages in thread
From: Shahaf Shuler @ 2017-02-21 14:37 UTC (permalink / raw)
  To: adrien.mazarguil, nelio.laranjeiro; +Cc: dev

Interface name is queried, however never used.

Signed-off-by: Shahaf Shuler <shahafs@mellanox.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
---
 drivers/net/mlx5/mlx5_stats.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_stats.c b/drivers/net/mlx5/mlx5_stats.c
index 20c957e..0c80e4f 100644
--- a/drivers/net/mlx5/mlx5_stats.c
+++ b/drivers/net/mlx5/mlx5_stats.c
@@ -177,17 +177,12 @@ struct mlx5_counter_ctrl {
 	struct mlx5_xstats_ctrl *xstats_ctrl = &priv->xstats_ctrl;
 	unsigned int i;
 	unsigned int j;
-	char ifname[IF_NAMESIZE];
 	struct ifreq ifr;
 	struct ethtool_drvinfo drvinfo;
 	struct ethtool_gstrings *strings = NULL;
 	unsigned int dev_stats_n;
 	unsigned int str_sz;
 
-	if (priv_get_ifname(priv, &ifname)) {
-		WARN("unable to get interface name");
-		return;
-	}
 	/* How many statistics are available. */
 	drvinfo.cmd = ETHTOOL_GDRVINFO;
 	ifr.ifr_data = (caddr_t)&drvinfo;
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [dpdk-dev] [PATCH 2/2] net/mlx5: fix extended statistics wrong number
  2017-02-21 14:37 [dpdk-dev] [PATCH 1/2] net/mlx5: remove unused interface name query Shahaf Shuler
@ 2017-02-21 14:37 ` Shahaf Shuler
  2017-02-22 19:16 ` [dpdk-dev] [PATCH 1/2] net/mlx5: remove unused interface name query Ferruh Yigit
  1 sibling, 0 replies; 3+ messages in thread
From: Shahaf Shuler @ 2017-02-21 14:37 UTC (permalink / raw)
  To: adrien.mazarguil, nelio.laranjeiro; +Cc: dev, stable

The number of extended statistics counters is queried through ETHTOOL.
ETHTOOL provides a different number when the link is up or down.
Since extended statistics query occurs at device start,
segmentation fault might happen when changing the link state before and
after the device start.

this commit address this issue, and query the number of statistics
before every call to ETHTOOL.

Fixes: a4193ae3bc4f ("net/mlx5: support extended statistics")
CC: stable@dpdk.org

Signed-off-by: Shahaf Shuler <shahafs@mellanox.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
---
 drivers/net/mlx5/mlx5_stats.c | 48 +++++++++++++++++++++++++++++++++++--------
 1 file changed, 39 insertions(+), 9 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_stats.c b/drivers/net/mlx5/mlx5_stats.c
index 0c80e4f..60ffbaa 100644
--- a/drivers/net/mlx5/mlx5_stats.c
+++ b/drivers/net/mlx5/mlx5_stats.c
@@ -166,6 +166,29 @@ struct mlx5_counter_ctrl {
 }
 
 /**
+ * Query the number of statistics provided by ETHTOOL.
+ *
+ * @param priv
+ *   Pointer to private structure.
+ *
+ * @return
+ *   Number of statistics on success, -1 on error.
+ */
+static int
+priv_ethtool_get_stats_n(struct priv *priv) {
+	struct ethtool_drvinfo drvinfo;
+	struct ifreq ifr;
+
+	drvinfo.cmd = ETHTOOL_GDRVINFO;
+	ifr.ifr_data = (caddr_t)&drvinfo;
+	if (priv_ifreq(priv, SIOCETHTOOL, &ifr) != 0) {
+		WARN("unable to query number of statistics");
+		return -1;
+	}
+	return drvinfo.n_stats;
+}
+
+/**
  * Init the structures to read device counters.
  *
  * @param priv
@@ -178,19 +201,11 @@ struct mlx5_counter_ctrl {
 	unsigned int i;
 	unsigned int j;
 	struct ifreq ifr;
-	struct ethtool_drvinfo drvinfo;
 	struct ethtool_gstrings *strings = NULL;
 	unsigned int dev_stats_n;
 	unsigned int str_sz;
 
-	/* How many statistics are available. */
-	drvinfo.cmd = ETHTOOL_GDRVINFO;
-	ifr.ifr_data = (caddr_t)&drvinfo;
-	if (priv_ifreq(priv, SIOCETHTOOL, &ifr) != 0) {
-		WARN("unable to get driver info");
-		return;
-	}
-	dev_stats_n = drvinfo.n_stats;
+	dev_stats_n = priv_ethtool_get_stats_n(priv);
 	if (dev_stats_n < 1) {
 		WARN("no extended statistics available");
 		return;
@@ -410,7 +425,15 @@ struct mlx5_counter_ctrl {
 	int ret = xstats_n;
 
 	if (n >= xstats_n && stats) {
+		struct mlx5_xstats_ctrl *xstats_ctrl = &priv->xstats_ctrl;
+		int stats_n;
+
 		priv_lock(priv);
+		stats_n = priv_ethtool_get_stats_n(priv);
+		if (stats_n < 0)
+			return -1;
+		if (xstats_ctrl->stats_n != stats_n)
+			priv_xstats_init(priv);
 		ret = priv_xstats_get(priv, stats);
 		priv_unlock(priv);
 	}
@@ -427,8 +450,15 @@ struct mlx5_counter_ctrl {
 mlx5_xstats_reset(struct rte_eth_dev *dev)
 {
 	struct priv *priv = mlx5_get_priv(dev);
+	struct mlx5_xstats_ctrl *xstats_ctrl = &priv->xstats_ctrl;
+	int stats_n;
 
 	priv_lock(priv);
+	stats_n = priv_ethtool_get_stats_n(priv);
+	if (stats_n < 0)
+		return;
+	if (xstats_ctrl->stats_n != stats_n)
+		priv_xstats_init(priv);
 	priv_xstats_reset(priv);
 	priv_unlock(priv);
 }
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH 1/2] net/mlx5: remove unused interface name query
  2017-02-21 14:37 [dpdk-dev] [PATCH 1/2] net/mlx5: remove unused interface name query Shahaf Shuler
  2017-02-21 14:37 ` [dpdk-dev] [PATCH 2/2] net/mlx5: fix extended statistics wrong number Shahaf Shuler
@ 2017-02-22 19:16 ` Ferruh Yigit
  1 sibling, 0 replies; 3+ messages in thread
From: Ferruh Yigit @ 2017-02-22 19:16 UTC (permalink / raw)
  To: Shahaf Shuler, adrien.mazarguil, nelio.laranjeiro; +Cc: dev

On 2/21/2017 2:37 PM, Shahaf Shuler wrote:
> Interface name is queried, however never used.
> 
> Signed-off-by: Shahaf Shuler <shahafs@mellanox.com>
> Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-02-22 19:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-21 14:37 [dpdk-dev] [PATCH 1/2] net/mlx5: remove unused interface name query Shahaf Shuler
2017-02-21 14:37 ` [dpdk-dev] [PATCH 2/2] net/mlx5: fix extended statistics wrong number Shahaf Shuler
2017-02-22 19:16 ` [dpdk-dev] [PATCH 1/2] net/mlx5: remove unused interface name query Ferruh Yigit

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