From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 3C937F04 for ; Wed, 19 Sep 2018 09:55:43 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 Sep 2018 10:00:05 +0200 Received: from dev-r630-06.mtbc.labs.mlnx (dev-r630-06.mtbc.labs.mlnx [10.12.205.180]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w8J7tfLf005233; Wed, 19 Sep 2018 10:55:42 +0300 Received: from dev-r630-06.mtbc.labs.mlnx (localhost [127.0.0.1]) by dev-r630-06.mtbc.labs.mlnx (8.14.7/8.14.7) with ESMTP id w8J7teYV169601; Wed, 19 Sep 2018 15:55:40 +0800 Received: (from xuemingl@localhost) by dev-r630-06.mtbc.labs.mlnx (8.14.7/8.14.7/Submit) id w8J7ta9F169599; Wed, 19 Sep 2018 15:55:36 +0800 From: Xueming Li To: Shahaf Shuler , Yongseok Koh Cc: Xueming Li , dev@dpdk.org, adrien.mazarguil@6wind.com Date: Wed, 19 Sep 2018 15:55:26 +0800 Message-Id: <1537343726-169561-1-git-send-email-xuemingl@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1536906807-118827-1-git-send-email-xuemingl@mellanox.com> References: <1536906807-118827-1-git-send-email-xuemingl@mellanox.com> Subject: [dpdk-dev] [PATCH v3] net/mlx5: fix representor port xstats X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Sep 2018 07:55:43 -0000 This patch fixes the issue that representor port shows xstats of PF. Fixes: 2b7302638898 ("net/mlx5: probe all port representors") Cc: adrien.mazarguil@6wind.com Signed-off-by: Xueming Li --- drivers/net/mlx5/mlx5_stats.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/net/mlx5/mlx5_stats.c b/drivers/net/mlx5/mlx5_stats.c index 91f3d47..ed5b51b 100644 --- a/drivers/net/mlx5/mlx5_stats.c +++ b/drivers/net/mlx5/mlx5_stats.c @@ -146,7 +146,7 @@ struct mlx5_counter_ctrl { et_stats->cmd = ETHTOOL_GSTATS; et_stats->n_stats = xstats_ctrl->stats_n; ifr.ifr_data = (caddr_t)et_stats; - ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 1); + ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 0); if (ret) { DRV_LOG(WARNING, "port %u unable to read statistic values from device", @@ -194,7 +194,7 @@ struct mlx5_counter_ctrl { drvinfo.cmd = ETHTOOL_GDRVINFO; ifr.ifr_data = (caddr_t)&drvinfo; - ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 1); + ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 0); if (ret) { DRV_LOG(WARNING, "port %u unable to query number of statistics", dev->data->port_id); @@ -229,7 +229,6 @@ struct mlx5_counter_ctrl { return; } dev_stats_n = ret; - xstats_ctrl->stats_n = dev_stats_n; /* Allocate memory to grab stat names and values. */ str_sz = dev_stats_n * ETH_GSTRING_LEN; strings = (struct ethtool_gstrings *) @@ -244,7 +243,7 @@ struct mlx5_counter_ctrl { strings->string_set = ETH_SS_STATS; strings->len = dev_stats_n; ifr.ifr_data = (caddr_t)strings; - ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 1); + ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 0); if (ret) { DRV_LOG(WARNING, "port %u unable to get statistic names", dev->data->port_id); @@ -275,6 +274,7 @@ struct mlx5_counter_ctrl { goto free; } } + xstats_ctrl->stats_n = dev_stats_n; /* Copy to base at first time. */ assert(xstats_n <= MLX5_MAX_XSTATS); ret = mlx5_read_dev_counters(dev, xstats_ctrl->base); @@ -307,6 +307,8 @@ struct mlx5_counter_ctrl { unsigned int i; uint64_t counters[n]; + if (!priv->xstats_ctrl.stats_n) + return 0; if (n >= xstats_n && stats) { struct mlx5_xstats_ctrl *xstats_ctrl = &priv->xstats_ctrl; int stats_n; @@ -480,8 +482,11 @@ struct mlx5_counter_ctrl { mlx5_xstats_get_names(struct rte_eth_dev *dev __rte_unused, struct rte_eth_xstat_name *xstats_names, unsigned int n) { + struct priv *priv = dev->data->dev_private; unsigned int i; + if (!priv->xstats_ctrl.stats_n) + return 0; if (n >= xstats_n && xstats_names) { for (i = 0; i != xstats_n; ++i) { strncpy(xstats_names[i].name, -- 1.8.3.1