[PATCH net 2/3] net/mlx5e: Sync CQE moderation params with pflags in set_pflag_cqe_based_moder
From: Tariq Toukan
Date: Wed Oct 14 2026 - 08:53:56 EST
From: Yael Chemla <ychemla@xxxxxxxxxx>
When CQE-based moderation is toggled via the priv-flag path
(ethtool --set-priv-flags ... rx_cqe_moder / tx_cqe_moder),
set_pflag_cqe_based_moder() updates only params->pflags and does not
update rx_moder_use_cqe_mode / tx_moder_use_cqe_mode. After the toggle,
--show-priv-flags reflects the new state but get_coalesce (and thus
ethtool -c) still reports the old state because it reads from the
params fields.
Fix by setting new_params.rx_moder_use_cqe_mode or
new_params.tx_moder_use_cqe_mode in set_pflag_cqe_based_moder() when
toggling the corresponding priv flag, so both representations stay
in sync.
Additionally, new_params.rx_cq_moderation / new_params.tx_cq_moderation
are left as a copy of the old params, so ethtool -c reports stale
rx_coalesce_usecs after the toggle. Fix by calling
mlx5e_reset_rx/tx_moderation() on new_params to overwrite usec with
the default for the new period mode before storing it into
priv->channels.params.
Reproducer:
ethtool -C eth2 adaptive-rx off
ethtool --show-priv-flags eth2 | grep -E 'rx_cqe_moder|tx_cqe_moder'
rx_cqe_moder : on
tx_cqe_moder : off
ethtool -c eth2 | grep -E 'rx-usecs:|CQE mode'
rx-usecs: 3
CQE mode RX: on TX: off
ethtool --set-priv-flags eth2 rx_cqe_moder off
ethtool --set-priv-flags eth2 tx_cqe_moder on
ethtool --show-priv-flags eth2 | grep -E 'rx_cqe_moder|tx_cqe_moder'
rx_cqe_moder : off
tx_cqe_moder : on
ethtool -c eth2 | grep -E 'rx-usecs:|CQE mode'
rx-usecs: 3 # stale: EQE default is 16
CQE mode RX: on TX: off # stale: priv-flags changed, CQE mode did not
Fixes: 445a25f6e1a2 ("net/mlx5e: Support updating coalescing configuration without resetting channels")
Signed-off-by: Yael Chemla <ychemla@xxxxxxxxxx>
Reviewed-by: Dragos Tatulea <dtatulea@xxxxxxxxxx>
Signed-off-by: Tariq Toukan <tariqt@xxxxxxxxxx>
---
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index 3ed59ced0407..c2bee69c26af 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -2193,12 +2193,20 @@ static int set_pflag_cqe_based_moder(struct net_device *netdev, bool enable,
mlx5e_channels_rx_toggle_dim(&priv->channels);
MLX5E_SET_PFLAG(&new_params, MLX5E_PFLAG_RX_CQE_BASED_MODER,
cq_period_mode);
+ new_params.rx_moder_use_cqe_mode = enable;
+ mlx5e_reset_rx_moderation(&new_params.rx_cq_moderation,
+ cq_period_mode,
+ new_params.rx_dim_enabled);
} else {
mlx5e_reset_tx_channels_moderation(&priv->channels, cq_period_mode,
false, true);
mlx5e_channels_tx_toggle_dim(&priv->channels);
MLX5E_SET_PFLAG(&new_params, MLX5E_PFLAG_TX_CQE_BASED_MODER,
cq_period_mode);
+ new_params.tx_moder_use_cqe_mode = enable;
+ mlx5e_reset_tx_moderation(&new_params.tx_cq_moderation,
+ cq_period_mode,
+ new_params.tx_dim_enabled);
}
/* Update pflags of existing channels without resetting them */
--
2.44.0