summaryrefslogtreecommitdiff
path: root/drivers/net/mlx5/mlx5_stats.c
diff options
context:
space:
mode:
authorXueming Li <xuemingl@mellanox.com>2018-09-19 15:55:26 +0800
committerFerruh Yigit <ferruh.yigit@intel.com>2018-10-11 18:53:49 +0200
commit45b83b9b0434db1f190f7fa7d30e6fed75793ae6 (patch)
treee5fb5ada68ace33d605cb64efc3be5054e8d4b2b /drivers/net/mlx5/mlx5_stats.c
parent7bc47fb839cba55a6e0c86b5f2b746ff7dcbc514 (diff)
downloaddpdk-45b83b9b0434db1f190f7fa7d30e6fed75793ae6.zip
dpdk-45b83b9b0434db1f190f7fa7d30e6fed75793ae6.tar.gz
dpdk-45b83b9b0434db1f190f7fa7d30e6fed75793ae6.tar.xz
net/mlx5: fix representor port xstats
This patch fixes the issue that representor port shows xstats of PF. Fixes: 2b7302638898 ("net/mlx5: probe all port representors") Cc: stable@dpdk.org Signed-off-by: Xueming Li <xuemingl@mellanox.com> Acked-by: Yongseok Koh <yskoh@mellanox.com>
Diffstat (limited to 'drivers/net/mlx5/mlx5_stats.c')
-rw-r--r--drivers/net/mlx5/mlx5_stats.c13
1 files 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 @@ mlx5_read_dev_counters(struct rte_eth_dev *dev, uint64_t *stats)
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 @@ mlx5_ethtool_get_stats_n(struct rte_eth_dev *dev) {
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 @@ mlx5_xstats_init(struct rte_eth_dev *dev)
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 @@ mlx5_xstats_init(struct rte_eth_dev *dev)
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 @@ mlx5_xstats_init(struct rte_eth_dev *dev)
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 @@ mlx5_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *stats,
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 @@ int
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,