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 C81B0A0032; Tue, 28 Sep 2021 13:30:15 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0BC1C41125; Tue, 28 Sep 2021 13:29:46 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id C8D314111E for ; Tue, 28 Sep 2021 13:29:43 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id 92B4F7F6D6; Tue, 28 Sep 2021 14:29:43 +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 B3DC77F6D8; Tue, 28 Sep 2021 14:29:31 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru B3DC77F6D8 Authentication-Results: shelob.oktetlabs.ru/B3DC77F6D8; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: dev@dpdk.org Cc: Ivan Ilchenko Date: Tue, 28 Sep 2021 14:29:07 +0300 Message-Id: <20210928112912.785412-7-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210928112912.785412-1-andrew.rybchenko@oktetlabs.ru> References: <20210928112912.785412-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 06/11] net/sfc: optimize getting number of SW stats 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 Optimize getting number of SW stats by caching the value during device configure since it's the only place it may change. Signed-off-by: Ivan Ilchenko Signed-off-by: Andrew Rybchenko --- drivers/net/sfc/sfc.h | 2 ++ drivers/net/sfc/sfc_sw_stats.c | 14 ++++---------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index 93d5202a24..b9ff8baed2 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -218,6 +218,8 @@ struct sfc_counter_rxq { }; struct sfc_sw_stats { + /* Number extended statistics provided by SW stats */ + unsigned int xstats_count; uint64_t *reset_vals; rte_spinlock_t queues_bitmap_lock; diff --git a/drivers/net/sfc/sfc_sw_stats.c b/drivers/net/sfc/sfc_sw_stats.c index de99e1cfaf..0f93091500 100644 --- a/drivers/net/sfc/sfc_sw_stats.c +++ b/drivers/net/sfc/sfc_sw_stats.c @@ -329,17 +329,8 @@ sfc_sw_xstat_get_values_by_id(struct sfc_adapter *sa, unsigned int sfc_sw_xstats_get_nb_supported(struct sfc_adapter *sa) { - unsigned int nb_supported = 0; - unsigned int i; - SFC_ASSERT(sfc_adapter_is_locked(sa)); - - for (i = 0; i < RTE_DIM(sfc_sw_stats_descr); i++) { - nb_supported += sfc_sw_xstat_get_nb_supported(sa, - &sfc_sw_stats_descr[i]); - } - - return nb_supported; + return sa->sw_stats.xstats_count; } void @@ -506,6 +497,7 @@ sfc_sw_xstats_configure(struct sfc_adapter *sa) for (i = 0; i < RTE_DIM(sfc_sw_stats_descr); i++) nb_supported += sfc_sw_xstat_get_nb_supported(sa, &sfc_sw_stats_descr[i]); + sa->sw_stats.xstats_count = nb_supported; *reset_vals = rte_realloc(*reset_vals, nb_supported * sizeof(**reset_vals), 0); @@ -559,6 +551,7 @@ sfc_sw_xstats_alloc_queues_bitmap(struct sfc_adapter *sa) int sfc_sw_xstats_init(struct sfc_adapter *sa) { + sa->sw_stats.xstats_count = 0; sa->sw_stats.reset_vals = NULL; return sfc_sw_xstats_alloc_queues_bitmap(sa); @@ -570,4 +563,5 @@ sfc_sw_xstats_close(struct sfc_adapter *sa) sfc_sw_xstats_free_queues_bitmap(sa); rte_free(sa->sw_stats.reset_vals); sa->sw_stats.reset_vals = NULL; + sa->sw_stats.xstats_count = 0; } -- 2.30.2