patch 'net/mlx5: fix end condition of reading xstats' has been queued to stable release 23.11.2

Xueming Li xuemingl at nvidia.com
Mon Aug 12 14:50:02 CEST 2024


Hi,

FYI, your patch has been queued to stable release 23.11.2

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/14/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://git.dpdk.org/dpdk-stable/log/?h=23.11-staging

This queued commit can be viewed at:
https://git.dpdk.org/dpdk-stable/commit/?h=23.11-staging&id=07ad92c1a69b27be817a22f7afd590cef0098c6b

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From 07ad92c1a69b27be817a22f7afd590cef0098c6b Mon Sep 17 00:00:00 2001
From: Bing Zhao <bingz at nvidia.com>
Date: Wed, 17 Jul 2024 19:33:37 +0300
Subject: [PATCH] net/mlx5: fix end condition of reading xstats
Cc: Xueming Li <xuemingl at nvidia.com>

[ 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 <bingz at nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo at nvidia.com>
---
 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 4f3e790c0b..1d999ef66b 100644
--- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c
+++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
@@ -1292,6 +1292,7 @@ _mlx5_os_read_dev_counters(struct rte_eth_dev *dev, int pf, uint64_t *stats)
 	struct ethtool_stats *et_stats = (struct ethtool_stats *)et_stat_buf;
 	int ret;
 	uint16_t i_idx, o_idx;
+	uint32_t total_stats = xstats_n;
 
 	et_stats->cmd = ETHTOOL_GSTATS;
 	/* Pass the maximum value, the driver may ignore this. */
@@ -1309,19 +1310,19 @@ _mlx5_os_read_dev_counters(struct rte_eth_dev *dev, int pf, uint64_t *stats)
 		return ret;
 	}
 	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];
 		}
 	}
@@ -1364,11 +1365,11 @@ mlx5_os_read_dev_counters(struct rte_eth_dev *dev, bool bond_master, uint64_t *s
 			return ret;
 	}
 	/*
-	 * 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;
 		/* return last xstats counter if fail to read. */
@@ -1618,7 +1619,7 @@ 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
 mlx5_os_get_stats_strings(struct rte_eth_dev *dev, bool bond_master,
@@ -1664,6 +1665,7 @@ 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) {
 				idx = xstats_ctrl->mlx5_stats_n++;
@@ -1705,6 +1707,7 @@ 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) {
 			idx = xstats_ctrl->mlx5_stats_n++;
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 1ac8e07d07..0c81bcab9f 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -267,6 +267,8 @@ struct mlx5_xstats_ctrl {
 	uint16_t stats_n_2nd;
 	/* 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];
 	/* Index in the output table. */
@@ -281,6 +283,9 @@ struct mlx5_xstats_ctrl {
 	uint16_t xstats_o_idx_2nd[MLX5_MAX_XSTATS];
 };
 
+/* xstats array size. */
+extern const unsigned int xstats_n;
+
 struct mlx5_stats_ctrl {
 	/* Base for imissed counter. */
 	uint64_t imissed_base;
-- 
2.34.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2024-08-12 20:44:06.454732586 +0800
+++ 0125-net-mlx5-fix-end-condition-of-reading-xstats.patch	2024-08-12 20:44:02.505069375 +0800
@@ -1 +1 @@
-From 1be61fe1333cd4a8a4bba6eb0d68780073fe3512 Mon Sep 17 00:00:00 2001
+From 07ad92c1a69b27be817a22f7afd590cef0098c6b Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit 1be61fe1333cd4a8a4bba6eb0d68780073fe3512 ]
@@ -24 +26,0 @@
-Cc: stable at dpdk.org
@@ -34 +36 @@
-index 82f651f2f3..5d64984022 100644
+index 4f3e790c0b..1d999ef66b 100644
@@ -37 +39 @@
-@@ -1201,6 +1201,7 @@ _mlx5_os_read_dev_counters(struct rte_eth_dev *dev, int pf, uint64_t *stats)
+@@ -1292,6 +1292,7 @@ _mlx5_os_read_dev_counters(struct rte_eth_dev *dev, int pf, uint64_t *stats)
@@ -45 +47 @@
-@@ -1218,19 +1219,19 @@ _mlx5_os_read_dev_counters(struct rte_eth_dev *dev, int pf, uint64_t *stats)
+@@ -1309,19 +1310,19 @@ _mlx5_os_read_dev_counters(struct rte_eth_dev *dev, int pf, uint64_t *stats)
@@ -71 +73 @@
-@@ -1273,11 +1274,11 @@ mlx5_os_read_dev_counters(struct rte_eth_dev *dev, bool bond_master, uint64_t *s
+@@ -1364,11 +1365,11 @@ mlx5_os_read_dev_counters(struct rte_eth_dev *dev, bool bond_master, uint64_t *s
@@ -86 +88 @@
-@@ -1573,7 +1574,7 @@ static const struct mlx5_counter_ctrl mlx5_counters_init[] = {
+@@ -1618,7 +1619,7 @@ static const struct mlx5_counter_ctrl mlx5_counters_init[] = {
@@ -95 +97 @@
-@@ -1619,6 +1620,7 @@ mlx5_os_get_stats_strings(struct rte_eth_dev *dev, bool bond_master,
+@@ -1664,6 +1665,7 @@ mlx5_os_get_stats_strings(struct rte_eth_dev *dev, bool bond_master,
@@ -103 +105 @@
-@@ -1660,6 +1662,7 @@ mlx5_os_get_stats_strings(struct rte_eth_dev *dev, bool bond_master,
+@@ -1705,6 +1707,7 @@ mlx5_os_get_stats_strings(struct rte_eth_dev *dev, bool bond_master,
@@ -112 +114 @@
-index 75a1e170af..869aac032b 100644
+index 1ac8e07d07..0c81bcab9f 100644
@@ -115 +117 @@
-@@ -281,6 +281,8 @@ struct mlx5_xstats_ctrl {
+@@ -267,6 +267,8 @@ struct mlx5_xstats_ctrl {
@@ -124 +126 @@
-@@ -295,6 +297,9 @@ struct mlx5_xstats_ctrl {
+@@ -281,6 +283,9 @@ struct mlx5_xstats_ctrl {


More information about the stable mailing list