From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 74430A0C46; Fri, 23 Jul 2021 15:15:33 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9CC2E40E5A; Fri, 23 Jul 2021 15:15:31 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 0558640DDA; Fri, 23 Jul 2021 15:15:30 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id BEFC97F6D2; Fri, 23 Jul 2021 16:15:29 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id B00057F52A; Fri, 23 Jul 2021 16:15:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru B00057F52A Authentication-Results: shelob.oktetlabs.ru/B00057F52A; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: dev@dpdk.org, Ivan Malov , Remy Horton Cc: David Marchand , Ivan Ilchenko , stable@dpdk.org, Andy Moreton Date: Fri, 23 Jul 2021 16:15:05 +0300 Message-Id: <20210723131515.2317168-2-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210723131515.2317168-1-andrew.rybchenko@oktetlabs.ru> References: <20210604144225.287678-1-andrew.rybchenko@oktetlabs.ru> <20210723131515.2317168-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 01/11] net/sfc: fix get xstats by ID callback to use MAC stats lock X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Ivan Ilchenko 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 Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc_ethdev.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index 88896db1f8..d4ac61ff76 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -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); -- 2.30.2