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 94F5045804 for ; Fri, 23 Aug 2024 18:23:50 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8E6D04336F; Fri, 23 Aug 2024 18:23:50 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 679AE4336D for ; Fri, 23 Aug 2024 18:23:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724430229; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6okJtghwv7VaA6j9iKXV3awXT/sVCPomcaPtHTosIxU=; b=L2/56sTlzYXkCJDc45aj6Q+wnroVY85mLmHT9DqyPzY2d4qODolMyIt9skWLIwTh3vvp7Z 47w7vm92RA4wq+/NFGvuHAejc9M8GX7i5zj6p1Us9fkSNIa2gpu6jWCKREcRJdrmYpvSId Wr0z/cf3/rzePCrAmYxp3jpKuoAYTlY= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-274-Xrf1pOXlMYWDWcTb94QwiA-1; Fri, 23 Aug 2024 12:23:45 -0400 X-MC-Unique: Xrf1pOXlMYWDWcTb94QwiA-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C4A241955BF4; Fri, 23 Aug 2024 16:23:44 +0000 (UTC) Received: from rh.redhat.com (unknown [10.39.193.224]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1B78B1956053; Fri, 23 Aug 2024 16:23:42 +0000 (UTC) From: Kevin Traynor To: Bing Zhao Cc: Viacheslav Ovsiienko , dpdk stable Subject: patch 'net/mlx5: fix end condition of reading xstats' has been queued to stable release 21.11.8 Date: Fri, 23 Aug 2024 17:19:07 +0100 Message-ID: <20240823161929.1004778-119-ktraynor@redhat.com> In-Reply-To: <20240823161929.1004778-1-ktraynor@redhat.com> References: <20240823161929.1004778-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 21.11.8 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 08/28/24. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/6a7d2c982887e5a4730e923cb48797c626a75574 Thanks. Kevin --- >From 6a7d2c982887e5a4730e923cb48797c626a75574 Mon Sep 17 00:00:00 2001 From: Bing Zhao Date: Wed, 17 Jul 2024 19:33:37 +0300 Subject: [PATCH] net/mlx5: fix end condition of reading xstats [ upstream commit 1be61fe1333cd4a8a4bba6eb0d68780073fe3512 ] The "mlx5_stats_n" in the "struct mlx5_xstats_ctrl" is the number of device stats identified by PMD. Right now, the mapping of device stats to the xstats is not compact. The "input index" of the device stats would remain UINT16_MAX and be skipped when reading counters. If some DPDK stats cannot be identified in the middle of the map, the end condition should be bigger than the "mlx5_stats_n". Or else, some counters would not be read and calculated. Using the global const "xstats_n" as the end condition to traverse the whole array in case some counters are missed. The "xstats_o_idx" should be used instead of the iteration to check if the statistics is an IB device counter. In the meanwhile, adding another field to record the start index of the IB counters to reduce the redundancy iterations. Fixes: a687c3e658c2 ("net/mlx5: fix counters map in bonding mode") Signed-off-by: Bing Zhao Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/linux/mlx5_ethdev_os.c | 23 +++++++++++++---------- drivers/net/mlx5/mlx5.h | 5 +++++ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c index a181a19f29..6d98657917 100644 --- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c +++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c @@ -1363,4 +1363,5 @@ _mlx5_os_read_dev_counters(struct rte_eth_dev *dev, int pf, uint64_t *stats) int ret; uint16_t i_idx, o_idx; + uint32_t total_stats = xstats_n; et_stats->cmd = ETHTOOL_GSTATS; @@ -1380,17 +1381,17 @@ _mlx5_os_read_dev_counters(struct rte_eth_dev *dev, int pf, uint64_t *stats) } if (pf <= 0) { - for (i = 0; i != xstats_ctrl->mlx5_stats_n; i++) { + for (i = 0; i != total_stats; i++) { i_idx = xstats_ctrl->dev_table_idx[i]; - if (i_idx == UINT16_MAX || xstats_ctrl->info[i].dev) - continue; o_idx = xstats_ctrl->xstats_o_idx[i]; + if (i_idx == UINT16_MAX || xstats_ctrl->info[o_idx].dev) + continue; stats[o_idx] += (uint64_t)et_stats->data[i_idx]; } } else { - for (i = 0; i != xstats_ctrl->mlx5_stats_n; i++) { + for (i = 0; i != total_stats; i++) { i_idx = xstats_ctrl->dev_table_idx_2nd[i]; - if (i_idx == UINT16_MAX) - continue; o_idx = xstats_ctrl->xstats_o_idx_2nd[i]; + if (i_idx == UINT16_MAX || xstats_ctrl->info[o_idx].dev) + continue; stats[o_idx] += (uint64_t)et_stats->data[i_idx]; } @@ -1435,9 +1436,9 @@ mlx5_os_read_dev_counters(struct rte_eth_dev *dev, bool bond_master, uint64_t *s } /* - * Read IB counters. - * The counters are unique per IB device but not per net IF. + * Read IB dev counters. + * The counters are unique per IB device but not per netdev IF. * In bonding mode, getting the stats name only from 1 port is enough. */ - for (i = 0; i != xstats_ctrl->mlx5_stats_n; i++) { + for (i = xstats_ctrl->dev_cnt_start; i < xstats_ctrl->mlx5_stats_n; i++) { if (!xstats_ctrl->info[i].dev) continue; @@ -1625,5 +1626,5 @@ static const struct mlx5_counter_ctrl mlx5_counters_init[] = { }; -static const unsigned int xstats_n = RTE_DIM(mlx5_counters_init); +const unsigned int xstats_n = RTE_DIM(mlx5_counters_init); static int @@ -1671,4 +1672,5 @@ mlx5_os_get_stats_strings(struct rte_eth_dev *dev, bool bond_master, if (!bond_master) { /* Add dev counters, unique per IB device. */ + xstats_ctrl->dev_cnt_start = xstats_ctrl->mlx5_stats_n; for (j = 0; j != xstats_n; j++) { if (mlx5_counters_init[j].dev) { @@ -1712,4 +1714,5 @@ mlx5_os_get_stats_strings(struct rte_eth_dev *dev, bool bond_master, } /* Dev counters are always at the last now. */ + xstats_ctrl->dev_cnt_start = xstats_ctrl->mlx5_stats_n; for (j = 0; j != xstats_n; j++) { if (mlx5_counters_init[j].dev) { diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index cddb9435df..80c1c0b7b1 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -204,4 +204,6 @@ struct mlx5_xstats_ctrl { /* Number of device stats identified by PMD. */ uint16_t mlx5_stats_n; + /* First device counters index. */ + uint16_t dev_cnt_start; /* Index in the device counters table. */ uint16_t dev_table_idx[MLX5_MAX_XSTATS]; @@ -218,4 +220,7 @@ struct mlx5_xstats_ctrl { }; +/* xstats array size. */ +extern const unsigned int xstats_n; + struct mlx5_stats_ctrl { /* Base for imissed counter. */ -- 2.46.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-08-23 17:18:13.301003997 +0100 +++ 0119-net-mlx5-fix-end-condition-of-reading-xstats.patch 2024-08-23 17:18:09.875430647 +0100 @@ -1 +1 @@ -From 1be61fe1333cd4a8a4bba6eb0d68780073fe3512 Mon Sep 17 00:00:00 2001 +From 6a7d2c982887e5a4730e923cb48797c626a75574 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 1be61fe1333cd4a8a4bba6eb0d68780073fe3512 ] + @@ -24 +25,0 @@ -Cc: stable@dpdk.org @@ -34 +35 @@ -index 82f651f2f3..5d64984022 100644 +index a181a19f29..6d98657917 100644 @@ -37 +38 @@ -@@ -1202,4 +1202,5 @@ _mlx5_os_read_dev_counters(struct rte_eth_dev *dev, int pf, uint64_t *stats) +@@ -1363,4 +1363,5 @@ _mlx5_os_read_dev_counters(struct rte_eth_dev *dev, int pf, uint64_t *stats) @@ -43 +44 @@ -@@ -1219,17 +1220,17 @@ _mlx5_os_read_dev_counters(struct rte_eth_dev *dev, int pf, uint64_t *stats) +@@ -1380,17 +1381,17 @@ _mlx5_os_read_dev_counters(struct rte_eth_dev *dev, int pf, uint64_t *stats) @@ -67 +68 @@ -@@ -1274,9 +1275,9 @@ mlx5_os_read_dev_counters(struct rte_eth_dev *dev, bool bond_master, uint64_t *s +@@ -1435,9 +1436,9 @@ mlx5_os_read_dev_counters(struct rte_eth_dev *dev, bool bond_master, uint64_t *s @@ -80 +81 @@ -@@ -1574,5 +1575,5 @@ static const struct mlx5_counter_ctrl mlx5_counters_init[] = { +@@ -1625,5 +1626,5 @@ static const struct mlx5_counter_ctrl mlx5_counters_init[] = { @@ -87 +88 @@ -@@ -1620,4 +1621,5 @@ mlx5_os_get_stats_strings(struct rte_eth_dev *dev, bool bond_master, +@@ -1671,4 +1672,5 @@ mlx5_os_get_stats_strings(struct rte_eth_dev *dev, bool bond_master, @@ -93 +94 @@ -@@ -1661,4 +1663,5 @@ mlx5_os_get_stats_strings(struct rte_eth_dev *dev, bool bond_master, +@@ -1712,4 +1714,5 @@ mlx5_os_get_stats_strings(struct rte_eth_dev *dev, bool bond_master, @@ -100 +101 @@ -index 75a1e170af..869aac032b 100644 +index cddb9435df..80c1c0b7b1 100644 @@ -103 +104 @@ -@@ -282,4 +282,6 @@ struct mlx5_xstats_ctrl { +@@ -204,4 +204,6 @@ struct mlx5_xstats_ctrl { @@ -110 +111 @@ -@@ -296,4 +298,7 @@ struct mlx5_xstats_ctrl { +@@ -218,4 +220,7 @@ struct mlx5_xstats_ctrl {