浏览代码

net/mlx5e: CQE compression control code reuse

This patch is intended for code reuse of mlx5e_modify_rx_cqe_compression
function.

Signed-off-by: Shaker Daibes <shakerd@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Shaker Daibes 8 年之前
父节点
当前提交
5eb0249b43

+ 1 - 1
drivers/net/ethernet/mellanox/mlx5/core/en.h

@@ -787,7 +787,7 @@ void mlx5e_pps_event_handler(struct mlx5e_priv *priv,
 			     struct ptp_clock_event *event);
 			     struct ptp_clock_event *event);
 int mlx5e_hwstamp_set(struct net_device *dev, struct ifreq *ifr);
 int mlx5e_hwstamp_set(struct net_device *dev, struct ifreq *ifr);
 int mlx5e_hwstamp_get(struct net_device *dev, struct ifreq *ifr);
 int mlx5e_hwstamp_get(struct net_device *dev, struct ifreq *ifr);
-void mlx5e_modify_rx_cqe_compression(struct mlx5e_priv *priv, bool val);
+void mlx5e_modify_rx_cqe_compression_locked(struct mlx5e_priv *priv, bool val);
 
 
 int mlx5e_vlan_rx_add_vid(struct net_device *dev, __always_unused __be16 proto,
 int mlx5e_vlan_rx_add_vid(struct net_device *dev, __always_unused __be16 proto,
 			  u16 vid);
 			  u16 vid);

+ 5 - 2
drivers/net/ethernet/mellanox/mlx5/core/en_clock.c

@@ -106,11 +106,12 @@ int mlx5e_hwstamp_set(struct net_device *dev, struct ifreq *ifr)
 		return -ERANGE;
 		return -ERANGE;
 	}
 	}
 
 
+	mutex_lock(&priv->state_lock);
 	/* RX HW timestamp */
 	/* RX HW timestamp */
 	switch (config.rx_filter) {
 	switch (config.rx_filter) {
 	case HWTSTAMP_FILTER_NONE:
 	case HWTSTAMP_FILTER_NONE:
 		/* Reset CQE compression to Admin default */
 		/* Reset CQE compression to Admin default */
-		mlx5e_modify_rx_cqe_compression(priv, priv->params.rx_cqe_compress_def);
+		mlx5e_modify_rx_cqe_compression_locked(priv, priv->params.rx_cqe_compress_def);
 		break;
 		break;
 	case HWTSTAMP_FILTER_ALL:
 	case HWTSTAMP_FILTER_ALL:
 	case HWTSTAMP_FILTER_SOME:
 	case HWTSTAMP_FILTER_SOME:
@@ -128,14 +129,16 @@ int mlx5e_hwstamp_set(struct net_device *dev, struct ifreq *ifr)
 	case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
 	case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
 		/* Disable CQE compression */
 		/* Disable CQE compression */
 		netdev_warn(dev, "Disabling cqe compression");
 		netdev_warn(dev, "Disabling cqe compression");
-		mlx5e_modify_rx_cqe_compression(priv, false);
+		mlx5e_modify_rx_cqe_compression_locked(priv, false);
 		config.rx_filter = HWTSTAMP_FILTER_ALL;
 		config.rx_filter = HWTSTAMP_FILTER_ALL;
 		break;
 		break;
 	default:
 	default:
+		mutex_unlock(&priv->state_lock);
 		return -ERANGE;
 		return -ERANGE;
 	}
 	}
 
 
 	memcpy(&priv->tstamp.hwtstamp_config, &config, sizeof(config));
 	memcpy(&priv->tstamp.hwtstamp_config, &config, sizeof(config));
+	mutex_unlock(&priv->state_lock);
 
 
 	return copy_to_user(ifr->ifr_data, &config,
 	return copy_to_user(ifr->ifr_data, &config,
 			    sizeof(config)) ? -EFAULT : 0;
 			    sizeof(config)) ? -EFAULT : 0;

+ 2 - 11
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c

@@ -1476,8 +1476,6 @@ static int set_pflag_rx_cqe_compress(struct net_device *netdev,
 {
 {
 	struct mlx5e_priv *priv = netdev_priv(netdev);
 	struct mlx5e_priv *priv = netdev_priv(netdev);
 	struct mlx5_core_dev *mdev = priv->mdev;
 	struct mlx5_core_dev *mdev = priv->mdev;
-	int err = 0;
-	bool reset;
 
 
 	if (!MLX5_CAP_GEN(mdev, cqe_compression))
 	if (!MLX5_CAP_GEN(mdev, cqe_compression))
 		return -ENOTSUPP;
 		return -ENOTSUPP;
@@ -1487,17 +1485,10 @@ static int set_pflag_rx_cqe_compress(struct net_device *netdev,
 		return -EINVAL;
 		return -EINVAL;
 	}
 	}
 
 
-	reset = test_bit(MLX5E_STATE_OPENED, &priv->state);
-
-	if (reset)
-		mlx5e_close_locked(netdev);
-
-	MLX5E_SET_PFLAG(priv, MLX5E_PFLAG_RX_CQE_COMPRESS, enable);
+	mlx5e_modify_rx_cqe_compression_locked(priv, enable);
 	priv->params.rx_cqe_compress_def = enable;
 	priv->params.rx_cqe_compress_def = enable;
 
 
-	if (reset)
-		err = mlx5e_open_locked(netdev);
-	return err;
+	return 0;
 }
 }
 
 
 static int mlx5e_handle_pflag(struct net_device *netdev,
 static int mlx5e_handle_pflag(struct net_device *netdev,

+ 2 - 6
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c

@@ -155,17 +155,15 @@ static inline u32 mlx5e_decompress_cqes_start(struct mlx5e_rq *rq,
 	return mlx5e_decompress_cqes_cont(rq, cq, 1, budget_rem) - 1;
 	return mlx5e_decompress_cqes_cont(rq, cq, 1, budget_rem) - 1;
 }
 }
 
 
-void mlx5e_modify_rx_cqe_compression(struct mlx5e_priv *priv, bool val)
+void mlx5e_modify_rx_cqe_compression_locked(struct mlx5e_priv *priv, bool val)
 {
 {
 	bool was_opened;
 	bool was_opened;
 
 
 	if (!MLX5_CAP_GEN(priv->mdev, cqe_compression))
 	if (!MLX5_CAP_GEN(priv->mdev, cqe_compression))
 		return;
 		return;
 
 
-	mutex_lock(&priv->state_lock);
-
 	if (MLX5E_GET_PFLAG(priv, MLX5E_PFLAG_RX_CQE_COMPRESS) == val)
 	if (MLX5E_GET_PFLAG(priv, MLX5E_PFLAG_RX_CQE_COMPRESS) == val)
-		goto unlock;
+		return;
 
 
 	was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state);
 	was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state);
 	if (was_opened)
 	if (was_opened)
@@ -176,8 +174,6 @@ void mlx5e_modify_rx_cqe_compression(struct mlx5e_priv *priv, bool val)
 	if (was_opened)
 	if (was_opened)
 		mlx5e_open_locked(priv->netdev);
 		mlx5e_open_locked(priv->netdev);
 
 
-unlock:
-	mutex_unlock(&priv->state_lock);
 }
 }
 
 
 #define RQ_PAGE_SIZE(rq) ((1 << rq->buff.page_order) << PAGE_SHIFT)
 #define RQ_PAGE_SIZE(rq) ((1 << rq->buff.page_order) << PAGE_SHIFT)