Skip to content

Commit

Permalink
net/mvpp2: fix xstats get return if xstats is null
Browse files Browse the repository at this point in the history
[ upstream commit d853d24 ]

Many user (e.g. telemetry) invokes rte_eth_xstats_get(port_id, NULL, 0)
to retrieve the required number of elements, but currently mvpp2 PMD
returns zero when xstats is null.

Remove the logic of "return zero when xstats is NULL", and add the logic
of "return the required number of entries when n is lower than the
required number of entries".

Fixes: a77b537 ("net/mrvl: add extended statistics")

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
  • Loading branch information
fengchengwen authored and kevintraynor committed Jun 8, 2022
1 parent 6682fda commit d26f48c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions drivers/net/mvpp2/mrvl_ethdev.c
Expand Up @@ -1626,13 +1626,14 @@ mrvl_xstats_get(struct rte_eth_dev *dev,
{
struct mrvl_priv *priv = dev->data->dev_private;
struct pp2_ppio_statistics ppio_stats;
unsigned int i;
unsigned int i, count;

if (!stats)
return 0;
count = RTE_DIM(mrvl_xstats_tbl);
if (n < count)
return count;

pp2_ppio_get_statistics(priv->ppio, &ppio_stats, 0);
for (i = 0; i < n && i < RTE_DIM(mrvl_xstats_tbl); i++) {
for (i = 0; i < count; i++) {
uint64_t val;

if (mrvl_xstats_tbl[i].size == sizeof(uint32_t))
Expand All @@ -1648,7 +1649,7 @@ mrvl_xstats_get(struct rte_eth_dev *dev,
stats[i].value = val;
}

return n;
return count;
}

/**
Expand Down

0 comments on commit d26f48c

Please sign in to comment.