]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net/mlx5e: Refactor set_pflag_cqe_based_moder
authorSaeed Mahameed <saeedm@nvidia.com>
Wed, 15 Sep 2021 06:26:17 +0000 (23:26 -0700)
committerSaeed Mahameed <saeedm@nvidia.com>
Fri, 7 Jan 2022 00:22:54 +0000 (16:22 -0800)
Rearrange the code and use cqe_mode_to_period_mode() helper.

Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c

index 536fcb2c5e904bea53df0d1c38ba817311aa79f5..57d755db1cf5a92a434c6dec196e27863bfade93 100644 (file)
@@ -1883,24 +1883,19 @@ static int set_pflag_cqe_based_moder(struct net_device *netdev, bool enable,
                                     bool is_rx_cq)
 {
        struct mlx5e_priv *priv = netdev_priv(netdev);
-       struct mlx5_core_dev *mdev = priv->mdev;
-       struct mlx5e_params new_params;
-       bool mode_changed;
        u8 cq_period_mode, current_cq_period_mode;
+       struct mlx5e_params new_params;
+
+       if (enable && !MLX5_CAP_GEN(priv->mdev, cq_period_start_from_cqe))
+               return -EOPNOTSUPP;
+
+       cq_period_mode = cqe_mode_to_period_mode(enable);
 
-       cq_period_mode = enable ?
-               MLX5_CQ_PERIOD_MODE_START_FROM_CQE :
-               MLX5_CQ_PERIOD_MODE_START_FROM_EQE;
        current_cq_period_mode = is_rx_cq ?
                priv->channels.params.rx_cq_moderation.cq_period_mode :
                priv->channels.params.tx_cq_moderation.cq_period_mode;
-       mode_changed = cq_period_mode != current_cq_period_mode;
-
-       if (cq_period_mode == MLX5_CQ_PERIOD_MODE_START_FROM_CQE &&
-           !MLX5_CAP_GEN(mdev, cq_period_start_from_cqe))
-               return -EOPNOTSUPP;
 
-       if (!mode_changed)
+       if (cq_period_mode == current_cq_period_mode)
                return 0;
 
        new_params = priv->channels.params;