Skip to content

Commit ebeaf08

Browse files
talgimellanoxSaeed Mahameed
authored andcommitted
net/mlx5e: Properly set default values when disabling adaptive moderation
Add a call to mlx5e_reset_rx/tx_moderation() when enabling/disabling adaptive moderation, in order to select the proper default values. In order to do so, we separate the logic of selecting the moderation values and setting moderion mode (CQE/EQE based). Fixes: 0088cbb ("net/mlx5e: Enable CQE based moderation on TX CQ") Fixes: 9908aa2 ("net/mlx5e: CQE based moderation") Signed-off-by: Tal Gilboa <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent b623603 commit ebeaf08

File tree

3 files changed

+37
-14
lines changed

3 files changed

+37
-14
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,10 +1068,12 @@ void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv);
10681068

10691069
void mlx5e_build_default_indir_rqt(u32 *indirection_rqt, int len,
10701070
int num_channels);
1071-
void mlx5e_set_tx_cq_mode_params(struct mlx5e_params *params,
1072-
u8 cq_period_mode);
1073-
void mlx5e_set_rx_cq_mode_params(struct mlx5e_params *params,
1074-
u8 cq_period_mode);
1071+
1072+
void mlx5e_reset_tx_moderation(struct mlx5e_params *params, u8 cq_period_mode);
1073+
void mlx5e_reset_rx_moderation(struct mlx5e_params *params, u8 cq_period_mode);
1074+
void mlx5e_set_tx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode);
1075+
void mlx5e_set_rx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode);
1076+
10751077
void mlx5e_set_rq_type(struct mlx5_core_dev *mdev, struct mlx5e_params *params);
10761078
void mlx5e_init_rq_type_params(struct mlx5_core_dev *mdev,
10771079
struct mlx5e_params *params);

drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,8 +527,8 @@ int mlx5e_ethtool_set_coalesce(struct mlx5e_priv *priv,
527527
struct dim_cq_moder *rx_moder, *tx_moder;
528528
struct mlx5_core_dev *mdev = priv->mdev;
529529
struct mlx5e_channels new_channels = {};
530+
bool reset_rx, reset_tx;
530531
int err = 0;
531-
bool reset;
532532

533533
if (!MLX5_CAP_GEN(mdev, cq_moderation))
534534
return -EOPNOTSUPP;
@@ -566,15 +566,28 @@ int mlx5e_ethtool_set_coalesce(struct mlx5e_priv *priv,
566566
}
567567
/* we are opened */
568568

569-
reset = (!!coal->use_adaptive_rx_coalesce != priv->channels.params.rx_dim_enabled) ||
570-
(!!coal->use_adaptive_tx_coalesce != priv->channels.params.tx_dim_enabled);
569+
reset_rx = !!coal->use_adaptive_rx_coalesce != priv->channels.params.rx_dim_enabled;
570+
reset_tx = !!coal->use_adaptive_tx_coalesce != priv->channels.params.tx_dim_enabled;
571571

572-
if (!reset) {
572+
if (!reset_rx && !reset_tx) {
573573
mlx5e_set_priv_channels_coalesce(priv, coal);
574574
priv->channels.params = new_channels.params;
575575
goto out;
576576
}
577577

578+
if (reset_rx) {
579+
u8 mode = MLX5E_GET_PFLAG(&new_channels.params,
580+
MLX5E_PFLAG_RX_CQE_BASED_MODER);
581+
582+
mlx5e_reset_rx_moderation(&new_channels.params, mode);
583+
}
584+
if (reset_tx) {
585+
u8 mode = MLX5E_GET_PFLAG(&new_channels.params,
586+
MLX5E_PFLAG_TX_CQE_BASED_MODER);
587+
588+
mlx5e_reset_tx_moderation(&new_channels.params, mode);
589+
}
590+
578591
err = mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL);
579592

580593
out:

drivers/net/ethernet/mellanox/mlx5/core/en_main.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4716,7 +4716,7 @@ static u8 mlx5_to_net_dim_cq_period_mode(u8 cq_period_mode)
47164716
DIM_CQ_PERIOD_MODE_START_FROM_EQE;
47174717
}
47184718

4719-
void mlx5e_set_tx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode)
4719+
void mlx5e_reset_tx_moderation(struct mlx5e_params *params, u8 cq_period_mode)
47204720
{
47214721
if (params->tx_dim_enabled) {
47224722
u8 dim_period_mode = mlx5_to_net_dim_cq_period_mode(cq_period_mode);
@@ -4725,13 +4725,9 @@ void mlx5e_set_tx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode)
47254725
} else {
47264726
params->tx_cq_moderation = mlx5e_get_def_tx_moderation(cq_period_mode);
47274727
}
4728-
4729-
MLX5E_SET_PFLAG(params, MLX5E_PFLAG_TX_CQE_BASED_MODER,
4730-
params->tx_cq_moderation.cq_period_mode ==
4731-
MLX5_CQ_PERIOD_MODE_START_FROM_CQE);
47324728
}
47334729

4734-
void mlx5e_set_rx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode)
4730+
void mlx5e_reset_rx_moderation(struct mlx5e_params *params, u8 cq_period_mode)
47354731
{
47364732
if (params->rx_dim_enabled) {
47374733
u8 dim_period_mode = mlx5_to_net_dim_cq_period_mode(cq_period_mode);
@@ -4740,7 +4736,19 @@ void mlx5e_set_rx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode)
47404736
} else {
47414737
params->rx_cq_moderation = mlx5e_get_def_rx_moderation(cq_period_mode);
47424738
}
4739+
}
4740+
4741+
void mlx5e_set_tx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode)
4742+
{
4743+
mlx5e_reset_tx_moderation(params, cq_period_mode);
4744+
MLX5E_SET_PFLAG(params, MLX5E_PFLAG_TX_CQE_BASED_MODER,
4745+
params->tx_cq_moderation.cq_period_mode ==
4746+
MLX5_CQ_PERIOD_MODE_START_FROM_CQE);
4747+
}
47434748

4749+
void mlx5e_set_rx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode)
4750+
{
4751+
mlx5e_reset_rx_moderation(params, cq_period_mode);
47444752
MLX5E_SET_PFLAG(params, MLX5E_PFLAG_RX_CQE_BASED_MODER,
47454753
params->rx_cq_moderation.cq_period_mode ==
47464754
MLX5_CQ_PERIOD_MODE_START_FROM_CQE);

0 commit comments

Comments
 (0)