]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net/mlx5e: Don't query FEC statistics when FEC is disabled
authorCarolina Jubran <cjubran@nvidia.com>
Wed, 24 Sep 2025 12:40:34 +0000 (12:40 +0000)
committerJakub Kicinski <kuba@kernel.org>
Fri, 26 Sep 2025 23:49:20 +0000 (16:49 -0700)
Update mlx5e_stats_fec_get() to check the active FEC mode and skip
statistics collection when FEC is disabled.

Signed-off-by: Carolina Jubran <cjubran@nvidia.com>
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Reviewed-by: Yael Chemla <ychemla@nvidia.com>
Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Link: https://patch.msgid.link/20250924124037.1508846-3-vadim.fedorenko@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c

index c6185ddba04b84eed3c0d54a075ebcae900d762d..9c45c6e670ebf951a028e7afdfc5dd1bfed346c3 100644 (file)
@@ -1446,16 +1446,13 @@ static void fec_set_rs_stats(struct ethtool_fec_stats *fec_stats, u32 *ppcnt)
 }
 
 static void fec_set_block_stats(struct mlx5e_priv *priv,
+                               int mode,
                                struct ethtool_fec_stats *fec_stats)
 {
        struct mlx5_core_dev *mdev = priv->mdev;
        u32 out[MLX5_ST_SZ_DW(ppcnt_reg)] = {};
        u32 in[MLX5_ST_SZ_DW(ppcnt_reg)] = {};
        int sz = MLX5_ST_SZ_BYTES(ppcnt_reg);
-       int mode = fec_active_mode(mdev);
-
-       if (mode == MLX5E_FEC_NOFEC)
-               return;
 
        MLX5_SET(ppcnt_reg, in, local_port, 1);
        MLX5_SET(ppcnt_reg, in, grp, MLX5_PHYSICAL_LAYER_COUNTERS_GROUP);
@@ -1497,11 +1494,14 @@ static void fec_set_corrected_bits_total(struct mlx5e_priv *priv,
 void mlx5e_stats_fec_get(struct mlx5e_priv *priv,
                         struct ethtool_fec_stats *fec_stats)
 {
-       if (!MLX5_CAP_PCAM_FEATURE(priv->mdev, ppcnt_statistical_group))
+       int mode = fec_active_mode(priv->mdev);
+
+       if (mode == MLX5E_FEC_NOFEC ||
+           !MLX5_CAP_PCAM_FEATURE(priv->mdev, ppcnt_statistical_group))
                return;
 
        fec_set_corrected_bits_total(priv, fec_stats);
-       fec_set_block_stats(priv, fec_stats);
+       fec_set_block_stats(priv, mode, fec_stats);
 }
 
 #define PPORT_ETH_EXT_OFF(c) \