From: Ivan Ilchenko Date: Tue, 28 Sep 2021 11:29:07 +0000 (+0300) Subject: net/sfc: optimize getting number of SW stats X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=c704e5df3d8fc75c74235943efa68f7e0f1109f1;p=dpdk.git net/sfc: optimize getting number of SW stats 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 --- 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 @@ unlock: 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 @@ fail: 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; }