Netdev List
 help / color / mirror / Atom feed
From: Tariq Toukan <tariqt@nvidia.com>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, <netdev@vger.kernel.org>,
	Paolo Abeni <pabeni@redhat.com>
Cc: Dragos Tatulea <dtatulea@nvidia.com>,
	Gal Pressman <gal@nvidia.com>, "Joe Damato" <joe@dama.to>,
	Leon Romanovsky <leon@kernel.org>,
	open list <linux-kernel@vger.kernel.org>,
	<linux-rdma@vger.kernel.org>, Mark Bloch <mbloch@nvidia.com>,
	"Nabil S. Alramli" <dev@nalramli.com>,
	Rahul Rameshbabu <rrameshbabu@nvidia.com>,
	Saeed Mahameed <saeedm@nvidia.com>,
	Tariq Toukan <tariqt@nvidia.com>,
	Yael Chemla <ychemla@nvidia.com>
Subject: [PATCH net 2/3] net/mlx5e: Sync CQE moderation params with pflags in set_pflag_cqe_based_moder
Date: Wed, 14 Oct 2026 15:47:03 +0300	[thread overview]
Message-ID: <20261014124704.1017782-3-tariqt@nvidia.com> (raw)
In-Reply-To: <20261014124704.1017782-1-tariqt@nvidia.com>

From: Yael Chemla <ychemla@nvidia.com>

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@nvidia.com>
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
 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


  parent reply	other threads:[~2026-10-14 12:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14 12:47 [PATCH net 0/3] net/mlx5e: Fix CQE moderation mode reporting and control Tariq Toukan
2026-10-14 12:47 ` [PATCH net 1/3] net/mlx5e: Sync CQE moderation pflags with coalesce params Tariq Toukan
2026-10-14 12:47 ` Tariq Toukan [this message]
2026-10-14 12:47 ` [PATCH net 3/3] net/mlx5e: Expose CQE moderation mode on representors Tariq Toukan
2026-10-14 12:55 ` [PATCH net 0/3] net/mlx5e: Fix CQE moderation mode reporting and control netdev-bot+sinfo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261014124704.1017782-3-tariqt@nvidia.com \
    --to=tariqt@nvidia.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dev@nalramli.com \
    --cc=dtatulea@nvidia.com \
    --cc=edumazet@kernel.org \
    --cc=gal@nvidia.com \
    --cc=joe@dama.to \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rrameshbabu@nvidia.com \
    --cc=saeedm@nvidia.com \
    --cc=ychemla@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox