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 F31535B3A for ; Fri, 14 Sep 2018 08:33:32 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@mellanox.com) with ESMTPS (AES256-SHA encrypted); 14 Sep 2018 09:37:48 +0300 Received: from dev-r630-05.mtbc.labs.mlnx (dev-r630-05.mtbc.labs.mlnx [10.12.205.160]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w8E6XUjW001084; Fri, 14 Sep 2018 09:33:31 +0300 Received: from dev-r630-05.mtbc.labs.mlnx (localhost [127.0.0.1]) by dev-r630-05.mtbc.labs.mlnx (8.14.7/8.14.7) with ESMTP id w8E6XUps118866; Fri, 14 Sep 2018 14:33:30 +0800 Received: (from xuemingl@localhost) by dev-r630-05.mtbc.labs.mlnx (8.14.7/8.14.7/Submit) id w8E6XUWk118865; Fri, 14 Sep 2018 14:33:30 +0800 From: Xueming Li To: Shahaf Shuler , Yongseok Koh Cc: Xueming Li , dev@dpdk.org Date: Fri, 14 Sep 2018 14:33:27 +0800 Message-Id: <1536906807-118827-1-git-send-email-xuemingl@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1536229686-81003-1-git-send-email-xuemingl@mellanox.com> References: <1536229686-81003-1-git-send-email-xuemingl@mellanox.com> Subject: [dpdk-dev] [PATCH v2] 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: Fri, 14 Sep 2018 06:33:33 -0000 This patch fixes the issue that representor port shows xstats of PF. Fixes: 5a4b8e2612c5 ("net/mlx5: probe all port representors") 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