[01/11] net/sfc: fix get xstats by ID callback to use MAC stats lock
Checks
Commit Message
From: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
Add MAC stats lock in get xstats by id callback before reading
number of supported MAC stats.
Fixes: 73280c1e4ff ("net/sfc: support xstats retrieval by ID")
Cc: stable@dpdk.org
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>
---
drivers/net/sfc/sfc_ethdev.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
@@ -789,12 +789,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);