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 44909A0032; Tue, 28 Sep 2021 13:30:28 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5F45A4113A; Tue, 28 Sep 2021 13:29:48 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 3C2114111A for ; Tue, 28 Sep 2021 13:29:44 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id 0F9ED7F6D6; Tue, 28 Sep 2021 14:29:44 +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 ED36B7F6DA; Tue, 28 Sep 2021 14:29:31 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru ED36B7F6DA Authentication-Results: shelob.oktetlabs.ru/ED36B7F6DA; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: dev@dpdk.org Cc: Ivan Ilchenko Date: Tue, 28 Sep 2021 14:29:09 +0300 Message-Id: <20210928112912.785412-9-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 08/11] net/sfc: add toggle to disable total stat 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 toggle to disable total SW stat. This is useful for per-queue 'packets' and 'bytes' to not conflict with corresponding basic stats. These stats will be added in the following patches. Signed-off-by: Ivan Ilchenko Signed-off-by: Andrew Rybchenko --- drivers/net/sfc/sfc_sw_stats.c | 54 +++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/drivers/net/sfc/sfc_sw_stats.c b/drivers/net/sfc/sfc_sw_stats.c index a9ab29064a..63fc334d2b 100644 --- a/drivers/net/sfc/sfc_sw_stats.c +++ b/drivers/net/sfc/sfc_sw_stats.c @@ -21,6 +21,7 @@ struct sfc_sw_stat_descr { const char *name; enum sfc_sw_stats_type type; sfc_get_sw_stat_val_t *get_val; + bool provide_total; }; static sfc_get_sw_stat_val_t sfc_get_sw_stat_val_rx_dbells; @@ -54,11 +55,13 @@ const struct sfc_sw_stat_descr sfc_sw_stats_descr[] = { .name = "dbells", .type = SFC_SW_STATS_RX, .get_val = sfc_get_sw_stat_val_rx_dbells, + .provide_total = true, }, { .name = "dbells", .type = SFC_SW_STATS_TX, .get_val = sfc_get_sw_stat_val_tx_dbells, + .provide_total = true, } }; @@ -83,7 +86,7 @@ sfc_sw_stat_get_name(struct sfc_adapter *sa, return -EINVAL; } - if (id_off == 0) { + if (sw_stat->provide_total && id_off == 0) { ret = snprintf(name, name_size, "%s_%s", prefix, sw_stat->name); if (ret < 0 || ret >= (int)name_size) { @@ -92,7 +95,7 @@ sfc_sw_stat_get_name(struct sfc_adapter *sa, return ret > 0 ? -EINVAL : ret; } } else { - uint16_t qid = id_off - 1; + uint16_t qid = id_off - sw_stat->provide_total; ret = snprintf(name, name_size, "%s_q%u_%s", prefix, qid, sw_stat->name); if (ret < 0 || ret >= (int)name_size) { @@ -124,10 +127,11 @@ sfc_sw_stat_get_queue_count(struct sfc_adapter *sa, } static unsigned int -sfc_sw_xstat_per_queue_get_count(unsigned int nb_queues) +sfc_sw_xstat_per_queue_get_count(const struct sfc_sw_stat_descr *sw_stat, + unsigned int nb_queues) { /* Take into account the total xstat of all queues */ - return nb_queues > 0 ? 1 + nb_queues : 0; + return nb_queues > 0 ? sw_stat->provide_total + nb_queues : 0; } static unsigned int @@ -137,7 +141,7 @@ sfc_sw_xstat_get_nb_supported(struct sfc_adapter *sa, unsigned int nb_queues; nb_queues = sfc_sw_stat_get_queue_count(sa, sw_stat); - return sfc_sw_xstat_per_queue_get_count(nb_queues); + return sfc_sw_xstat_per_queue_get_count(sw_stat, nb_queues); } static int @@ -157,13 +161,13 @@ sfc_sw_stat_get_names(struct sfc_adapter *sa, nb_queues = sfc_sw_stat_get_queue_count(sa, sw_stat); if (nb_queues == 0) return 0; - *nb_supported += sfc_sw_xstat_per_queue_get_count(nb_queues); + *nb_supported += sfc_sw_xstat_per_queue_get_count(sw_stat, nb_queues); /* * The order of each software xstat type is the total xstat * followed by per-queue xstats. */ - if (*nb_written < xstats_names_sz) { + if (*nb_written < xstats_names_sz && sw_stat->provide_total) { rc = sfc_sw_stat_get_name(sa, sw_stat, xstats_names[*nb_written].name, name_size, *nb_written - id_base); @@ -196,6 +200,7 @@ sfc_sw_xstat_get_names_by_id(struct sfc_adapter *sa, { const size_t name_size = sizeof(xstats_names[0].name); unsigned int id_base = *nb_supported; + unsigned int id_end; unsigned int nb_queues; unsigned int i; int rc; @@ -203,14 +208,15 @@ sfc_sw_xstat_get_names_by_id(struct sfc_adapter *sa, nb_queues = sfc_sw_stat_get_queue_count(sa, sw_stat); if (nb_queues == 0) return 0; - *nb_supported += sfc_sw_xstat_per_queue_get_count(nb_queues); + *nb_supported += sfc_sw_xstat_per_queue_get_count(sw_stat, nb_queues); /* * The order of each software xstat type is the total xstat * followed by per-queue xstats. */ + id_end = id_base + sw_stat->provide_total + nb_queues; for (i = 0; i < size; i++) { - if (id_base <= ids[i] && ids[i] <= id_base + nb_queues) { + if (id_base <= ids[i] && ids[i] < id_end) { rc = sfc_sw_stat_get_name(sa, sw_stat, xstats_names[i].name, name_size, ids[i] - id_base); @@ -239,13 +245,13 @@ sfc_sw_xstat_get_values(struct sfc_adapter *sa, nb_queues = sfc_sw_stat_get_queue_count(sa, sw_stat); if (nb_queues == 0) return; - *nb_supported += sfc_sw_xstat_per_queue_get_count(nb_queues); + *nb_supported += sfc_sw_xstat_per_queue_get_count(sw_stat, nb_queues); /* * The order of each software xstat type is the total xstat * followed by per-queue xstats. */ - if (*nb_written < xstats_size) { + if (*nb_written < xstats_size && sw_stat->provide_total) { count_total_value = true; total_xstat = &xstats[*nb_written]; xstats[*nb_written].id = *nb_written; @@ -278,6 +284,8 @@ sfc_sw_xstat_get_values_by_id(struct sfc_adapter *sa, rte_spinlock_t *bmp_lock = &sa->sw_stats.queues_bitmap_lock; struct rte_bitmap *bmp = sa->sw_stats.queues_bitmap; unsigned int id_base = *nb_supported; + unsigned int id_base_q; + unsigned int id_end; bool count_total_value = false; unsigned int total_value_idx; uint64_t total_value = 0; @@ -291,20 +299,23 @@ sfc_sw_xstat_get_values_by_id(struct sfc_adapter *sa, nb_queues = sfc_sw_stat_get_queue_count(sa, sw_stat); if (nb_queues == 0) goto unlock; - *nb_supported += sfc_sw_xstat_per_queue_get_count(nb_queues); + *nb_supported += sfc_sw_xstat_per_queue_get_count(sw_stat, nb_queues); /* * The order of each software xstat type is the total xstat * followed by per-queue xstats. */ + id_end = id_base + sw_stat->provide_total + nb_queues; for (i = 0; i < ids_size; i++) { - if (id_base <= ids[i] && ids[i] <= (id_base + nb_queues)) { - if (ids[i] == id_base) { /* Accumulative value */ + if (id_base <= ids[i] && ids[i] < id_end) { + if (sw_stat->provide_total && ids[i] == id_base) { + /* Accumulative value */ count_total_value = true; total_value_idx = i; continue; } - qid = ids[i] - id_base - 1; + id_base_q = id_base + sw_stat->provide_total; + qid = ids[i] - id_base_q; values[i] = sw_stat->get_val(sa, qid); total_value += values[i]; @@ -453,7 +464,7 @@ sfc_sw_xstat_reset(struct sfc_adapter *sa, { unsigned int nb_queues; unsigned int qid; - uint64_t *total_xstat_reset; + uint64_t *total_xstat_reset = NULL; SFC_ASSERT(sfc_adapter_is_locked(sa)); @@ -465,13 +476,16 @@ sfc_sw_xstat_reset(struct sfc_adapter *sa, * The order of each software xstat type is the total xstat * followed by per-queue xstats. */ - total_xstat_reset = reset_vals; - *total_xstat_reset = 0; - reset_vals++; + if (sw_stat->provide_total) { + total_xstat_reset = reset_vals; + *total_xstat_reset = 0; + reset_vals++; + } for (qid = 0; qid < nb_queues; ++qid) { reset_vals[qid] = sw_stat->get_val(sa, qid); - *total_xstat_reset += reset_vals[qid]; + if (sw_stat->provide_total) + *total_xstat_reset += reset_vals[qid]; } } -- 2.30.2