net/mlx5: fix statistics read on Linux
authorGeoffrey Le Gourriérec <geoffrey.le_gourrierec@6wind.com>
Thu, 17 Mar 2022 13:23:48 +0000 (14:23 +0100)
committerRaslan Darawsheh <rasland@nvidia.com>
Thu, 2 Jun 2022 15:01:11 +0000 (17:01 +0200)
commiteadc35df59a1a1a5017c0db1c7a9978ca8eb56e9
treee1312f4393c9ae3d0b99b3a9c4e0e258d73b47b8
parent2bd03a4361ed6498555215fe57ba530616f0821f
net/mlx5: fix statistics read on Linux

This patch encompasses a few fixes carried by a previous patch
that aimed to support bonding device stats counting.

- If mlx5_os_read_dev_stat fails, it returns 1 instead of a
  negative value, causing mlx5_xstats_get to return an invalid
  number of counters. Since this error is not blocking, do not
  mess ret value with mlx5_os_read_dev_stat returned value.

  This allows avoiding the very annoying log:
  "n_xstats != n_xstats_names => skipping"

- Invert the check for mlx5_os_read_dev_stat(), currently leading
  us to store the result if the function failed, and use a
  backup value if it succeeded, which is the opposite of what we
  actually want. Revert to the original (correct) test.

- Add missing test on _mlx5_os_read_dev_counters() to prevent
  using trash stats values.

Fixes: 7ed15acdcd69 ("net/mlx5: improve xstats of bonding port")
Cc: stable@dpdk.org
Signed-off-by: Didier Pallard <didier.pallard@6wind.com>
Signed-off-by: Geoffrey Le Gourriérec <geoffrey.le_gourrierec@6wind.com>
Tested-by: Bassam Zaid AlKilani <bzalkilani@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
drivers/net/mlx5/linux/mlx5_ethdev_os.c