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 5D62BA0C46; Fri, 23 Jul 2021 15:16:15 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 99A8B410E4; Fri, 23 Jul 2021 15:15:57 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 1B49B41120 for ; Fri, 23 Jul 2021 15:15:56 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id DC3167F6D4; Fri, 23 Jul 2021 16:15:55 +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 3069F7F6CB; Fri, 23 Jul 2021 16:15:24 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 3069F7F6CB Authentication-Results: shelob.oktetlabs.ru/3069F7F6CB; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: dev@dpdk.org Cc: David Marchand , Ivan Ilchenko , Andy Moreton Date: Fri, 23 Jul 2021 16:15:12 +0300 Message-Id: <20210723131515.2317168-9-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 08/11] net/sfc: simplify getting of available xstats case 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 There is no point to recalculate number of available xstats on each request. The number is calculated once on device start and may be returned on subsequent calls. Signed-off-by: Ivan Ilchenko Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc_ethdev.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index bbc22723f6..f0567a71d0 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -733,6 +733,11 @@ sfc_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, sfc_adapter_lock(sa); + if (unlikely(xstats == NULL)) { + nstats = port->mac_stats_nb_supported; + goto unlock; + } + rc = sfc_port_update_mac_stats(sa, B_FALSE); if (rc != 0) { SFC_ASSERT(rc > 0); @@ -744,7 +749,7 @@ sfc_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, for (i = 0; i < EFX_MAC_NSTATS; ++i) { if (EFX_MAC_STAT_SUPPORTED(port->mac_stats_mask, i)) { - if (xstats != NULL && nstats < (int)xstats_count) { + if (nstats < (int)xstats_count) { xstats[nstats].id = nstats; xstats[nstats].value = mac_stats[i]; } @@ -768,9 +773,16 @@ sfc_xstats_get_names(struct rte_eth_dev *dev, unsigned int i; unsigned int nstats = 0; + if (unlikely(xstats_names == NULL)) { + sfc_adapter_lock(sa); + nstats = port->mac_stats_nb_supported; + sfc_adapter_unlock(sa); + return nstats; + } + for (i = 0; i < EFX_MAC_NSTATS; ++i) { if (EFX_MAC_STAT_SUPPORTED(port->mac_stats_mask, i)) { - if (xstats_names != NULL && nstats < xstats_count) + if (nstats < xstats_count) strlcpy(xstats_names[nstats].name, efx_mac_stat_name(sa->nic, i), sizeof(xstats_names[0].name)); -- 2.30.2