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 9019D4569C for ; Wed, 24 Jul 2024 13:34:15 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 88F6D42D89; Wed, 24 Jul 2024 13:34:15 +0200 (CEST) Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) by mails.dpdk.org (Postfix) with ESMTP id 031CB42D28 for ; Wed, 24 Jul 2024 13:34:15 +0200 (CEST) Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2eeb1ba0468so90693871fa.0 for ; Wed, 24 Jul 2024 04:34:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721820854; x=1722425654; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SWzf4IvGm8coQh/DUq76SD0h9QPGrkx5bOtpGio3Chs=; b=DYe/Rw/Qn1pKJkCEbLQsvRbRte++rkaatsnIFVkUGB0ignshqjbYd6QwcDJyhzsu+5 zAO4GBzeT5mw/zmAkDZb90gXTUXDDfN6LjySL1YzyRJC/ftwlZh3lTyfYUOchMGMCf/L wi8zaf6k1JZNsQiqh2CbbR7HrjKGe7eydrPFnjWIBFKkrrvWQQnOlvXWacxkcPKCCpzt qfUH2QLn5wDXmA9FYWlrsYCGJ9qrtaMqG2KFgNKl0FJa13nrW+HWhpy2mDzv6xNMIjjs bx7HqqifRjOS6uausdDv4QG2nxfZIY6/RA9eFqKvJyVz3mUCfmBsuDki4KBMKPD7bKU2 7cZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721820854; x=1722425654; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SWzf4IvGm8coQh/DUq76SD0h9QPGrkx5bOtpGio3Chs=; b=v2HGrk9snVEqsPsDg3Q5DvDF97Xfcc7axaldmzyj+0+3558AIZddIVhd0CAlTgrl+U zubDbvEmWae75vlZ+LFapgZl4XEV9ShiQZPwohnqnpI5FJFvYmoxWMXKw9jT1vhzKnqv M/9Ib2k1AXmTKNy1SYAbD+7FYxYc8EbpDMDSKru6XOioic/djHDj2YebgfnhB1bG+DXI 1+h/tjj3+G8sz2KrrpavlBpMo4NPedRqO/yT2BUEjVGjgk3p78WK4tU/S/AJ4sQI58YX V2sfay95SQbpltj3tI2LDhPhB+vLRl4zhtEAqsu31rygk+DQnXxycdGHH2lREPmn4III Epyw== X-Forwarded-Encrypted: i=1; AJvYcCVrmkBzePjWYgxm7VqGDRHmOJ9AZKrkR+hxCaHnbebGWRdLQIMA6HlTEb2FqwbqTMdlIQIP8GwyOKx45MrxjdU= X-Gm-Message-State: AOJu0Yw3fx8VK0BbK3njEJxTCfVx9eBL74K7rUAAH90XzWa9iJNhreoz LSH2HB5U8jLImaAcANsDV5RQtdBZ9CP7ri2gF6mJy8E3j47IZkF+qO2Z2w0u X-Google-Smtp-Source: AGHT+IGnh4bTrq6z4WIUXkKYC5/Z/wNa6cKqsndSjE5ecw/iQAzhapJeiUht1Gqc4E4fP76qFlijig== X-Received: by 2002:a2e:9f42:0:b0:2ef:22e6:233f with SMTP id 38308e7fff4ca-2f0324fcc75mr12921811fa.21.1721820853961; Wed, 24 Jul 2024 04:34:13 -0700 (PDT) Received: from localhost ([2a01:4b00:d036:ae00:7aef:1aaa:3dff:d546]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427f935dc1bsm26070425e9.6.2024.07.24.04.34.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 04:34:13 -0700 (PDT) From: luca.boccassi@gmail.com To: Bing Zhao Cc: Viacheslav Ovsiienko , dpdk stable Subject: patch 'net/mlx5: fix end condition of reading xstats' has been queued to stable release 22.11.6 Date: Wed, 24 Jul 2024 12:32:54 +0100 Message-Id: <20240724113318.616754-16-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240724113318.616754-1-luca.boccassi@gmail.com> References: <20240715152704.2229503-86-luca.boccassi@gmail.com> <20240724113318.616754-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 22.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/26/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/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/f06e1a4e4942098357ea2875b50edcd3a9beb382 Thanks. Luca Boccassi --- >From f06e1a4e4942098357ea2875b50edcd3a9beb382 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 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 80dcaf96a3..5d826527b2 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -238,6 +238,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. */ @@ -252,6 +254,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.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-07-24 12:29:22.008907585 +0100 +++ 0016-net-mlx5-fix-end-condition-of-reading-xstats.patch 2024-07-24 12:29:20.727025246 +0100 @@ -1 +1 @@ -From 1be61fe1333cd4a8a4bba6eb0d68780073fe3512 Mon Sep 17 00:00:00 2001 +From f06e1a4e4942098357ea2875b50edcd3a9beb382 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 4f3e790c0b..1d999ef66b 100644 @@ -37 +38 @@ -@@ -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 +46 @@ -@@ -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 +72 @@ -@@ -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 +87 @@ -@@ -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 +96 @@ -@@ -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 +104 @@ -@@ -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 +113 @@ -index 75a1e170af..869aac032b 100644 +index 80dcaf96a3..5d826527b2 100644 @@ -115 +116 @@ -@@ -281,6 +281,8 @@ struct mlx5_xstats_ctrl { +@@ -238,6 +238,8 @@ struct mlx5_xstats_ctrl { @@ -124 +125 @@ -@@ -295,6 +297,9 @@ struct mlx5_xstats_ctrl { +@@ -252,6 +254,9 @@ struct mlx5_xstats_ctrl {