Skip to content

Commit

Permalink
net/sfc: fix MAC stats lock in xstats query by ID
Browse files Browse the repository at this point in the history
[ upstream commit 9076e85 ]

Add MAC stats lock in xstats_get_by_id() callback before reading
number of supported MAC stats.

Fixes: 73280c1 ("net/sfc: support xstats retrieval by ID")

Signed-off-by: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
  • Loading branch information
ol-vanyaio authored and cpaelzer committed Aug 10, 2021
1 parent 782d2bf commit e675fd5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/net/sfc/sfc_ethdev.c
Expand Up @@ -772,12 +772,14 @@ sfc_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
int ret;
int rc;

if (unlikely(values == NULL) ||
unlikely((ids == NULL) && (n < port->mac_stats_nb_supported)))
return port->mac_stats_nb_supported;

rte_spinlock_lock(&port->mac_stats_lock);

if (unlikely(values == NULL) ||
unlikely(ids == NULL && n < port->mac_stats_nb_supported)) {
ret = port->mac_stats_nb_supported;
goto unlock;
}

rc = sfc_port_update_mac_stats(sa);
if (rc != 0) {
SFC_ASSERT(rc > 0);
Expand Down

0 comments on commit e675fd5

Please sign in to comment.