Skip to content

Commit 9bcc860

Browse files
Shaker Daibesdavem330
authored andcommitted
net/mlx5e: Add CQE compression user control
The user can now override the automatic driver decision using the rx_cqe_compress flag, which is the preference for CQE compression. The flag is initialized with the automatic driver decision. Signed-off-by: Shaker Daibes <shakerd@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 59ece1c commit 9bcc860

File tree

5 files changed

+51
-13
lines changed

5 files changed

+51
-13
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,12 @@ extern const char mlx5e_self_tests[][ETH_GSTRING_LEN];
171171

172172
static const char mlx5e_priv_flags[][ETH_GSTRING_LEN] = {
173173
"rx_cqe_moder",
174+
"rx_cqe_compress",
174175
};
175176

176177
enum mlx5e_priv_flag {
177178
MLX5E_PFLAG_RX_CQE_BASED_MODER = (1 << 0),
179+
MLX5E_PFLAG_RX_CQE_COMPRESS = (1 << 1),
178180
};
179181

180182
#define MLX5E_SET_PFLAG(priv, pflag, enable) \
@@ -205,8 +207,7 @@ struct mlx5e_params {
205207
u16 num_channels;
206208
u8 num_tc;
207209
u8 rx_cq_period_mode;
208-
bool rx_cqe_compress_admin;
209-
bool rx_cqe_compress;
210+
bool rx_cqe_compress_def;
210211
struct mlx5e_cq_moder rx_cq_moderation;
211212
struct mlx5e_cq_moder tx_cq_moderation;
212213
u16 min_rx_wqes;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ int mlx5e_hwstamp_set(struct net_device *dev, struct ifreq *ifr)
9494
switch (config.rx_filter) {
9595
case HWTSTAMP_FILTER_NONE:
9696
/* Reset CQE compression to Admin default */
97-
mlx5e_modify_rx_cqe_compression(priv, priv->params.rx_cqe_compress_admin);
97+
mlx5e_modify_rx_cqe_compression(priv, priv->params.rx_cqe_compress_def);
9898
break;
9999
case HWTSTAMP_FILTER_ALL:
100100
case HWTSTAMP_FILTER_SOME:
@@ -111,6 +111,7 @@ int mlx5e_hwstamp_set(struct net_device *dev, struct ifreq *ifr)
111111
case HWTSTAMP_FILTER_PTP_V2_SYNC:
112112
case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
113113
/* Disable CQE compression */
114+
netdev_warn(dev, "Disabling cqe compression");
114115
mlx5e_modify_rx_cqe_compression(priv, false);
115116
config.rx_filter = HWTSTAMP_FILTER_ALL;
116117
break;

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

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,6 +1481,35 @@ static int set_pflag_rx_cqe_based_moder(struct net_device *netdev, bool enable)
14811481
return err;
14821482
}
14831483

1484+
static int set_pflag_rx_cqe_compress(struct net_device *netdev,
1485+
bool enable)
1486+
{
1487+
struct mlx5e_priv *priv = netdev_priv(netdev);
1488+
struct mlx5_core_dev *mdev = priv->mdev;
1489+
int err = 0;
1490+
bool reset;
1491+
1492+
if (!MLX5_CAP_GEN(mdev, cqe_compression))
1493+
return -ENOTSUPP;
1494+
1495+
if (enable && priv->tstamp.hwtstamp_config.rx_filter != HWTSTAMP_FILTER_NONE) {
1496+
netdev_err(netdev, "Can't enable cqe compression while timestamping is enabled.\n");
1497+
return -EINVAL;
1498+
}
1499+
1500+
reset = test_bit(MLX5E_STATE_OPENED, &priv->state);
1501+
1502+
if (reset)
1503+
mlx5e_close_locked(netdev);
1504+
1505+
MLX5E_SET_PFLAG(priv, MLX5E_PFLAG_RX_CQE_COMPRESS, enable);
1506+
priv->params.rx_cqe_compress_def = enable;
1507+
1508+
if (reset)
1509+
err = mlx5e_open_locked(netdev);
1510+
return err;
1511+
}
1512+
14841513
static int mlx5e_handle_pflag(struct net_device *netdev,
14851514
u32 wanted_flags,
14861515
enum mlx5e_priv_flag flag,
@@ -1511,13 +1540,19 @@ static int mlx5e_set_priv_flags(struct net_device *netdev, u32 pflags)
15111540
int err;
15121541

15131542
mutex_lock(&priv->state_lock);
1514-
15151543
err = mlx5e_handle_pflag(netdev, pflags,
15161544
MLX5E_PFLAG_RX_CQE_BASED_MODER,
15171545
set_pflag_rx_cqe_based_moder);
1546+
if (err)
1547+
goto out;
15181548

1549+
err = mlx5e_handle_pflag(netdev, pflags,
1550+
MLX5E_PFLAG_RX_CQE_COMPRESS,
1551+
set_pflag_rx_cqe_compress);
1552+
1553+
out:
15191554
mutex_unlock(&priv->state_lock);
1520-
return err ? -EINVAL : 0;
1555+
return err;
15211556
}
15221557

15231558
static u32 mlx5e_get_priv_flags(struct net_device *netdev)

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ static void mlx5e_set_rq_type_params(struct mlx5e_priv *priv, u8 rq_type)
8484
switch (priv->params.rq_wq_type) {
8585
case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
8686
priv->params.log_rq_size = MLX5E_PARAMS_DEFAULT_LOG_RQ_SIZE_MPW;
87-
priv->params.mpwqe_log_stride_sz = priv->params.rx_cqe_compress ?
87+
priv->params.mpwqe_log_stride_sz =
88+
MLX5E_GET_PFLAG(priv, MLX5E_PFLAG_RX_CQE_COMPRESS) ?
8889
MLX5_MPWRQ_LOG_STRIDE_SIZE_CQE_COMPRESS :
8990
MLX5_MPWRQ_LOG_STRIDE_SIZE;
9091
priv->params.mpwqe_log_num_strides = MLX5_MPWRQ_LOG_WQE_SZ -
@@ -101,7 +102,7 @@ static void mlx5e_set_rq_type_params(struct mlx5e_priv *priv, u8 rq_type)
101102
priv->params.rq_wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ,
102103
BIT(priv->params.log_rq_size),
103104
BIT(priv->params.mpwqe_log_stride_sz),
104-
priv->params.rx_cqe_compress_admin);
105+
MLX5E_GET_PFLAG(priv, MLX5E_PFLAG_RX_CQE_COMPRESS));
105106
}
106107

107108
static void mlx5e_set_rq_priv_params(struct mlx5e_priv *priv)
@@ -1664,7 +1665,7 @@ static void mlx5e_build_rx_cq_param(struct mlx5e_priv *priv,
16641665
}
16651666

16661667
MLX5_SET(cqc, cqc, log_cq_size, log_cq_size);
1667-
if (priv->params.rx_cqe_compress) {
1668+
if (MLX5E_GET_PFLAG(priv, MLX5E_PFLAG_RX_CQE_COMPRESS)) {
16681669
MLX5_SET(cqc, cqc, mini_cqe_res_format, MLX5_CQE_FORMAT_CSUM);
16691670
MLX5_SET(cqc, cqc, cqe_comp_en, 1);
16701671
}
@@ -3447,17 +3448,16 @@ static void mlx5e_build_nic_netdev_priv(struct mlx5_core_dev *mdev,
34473448
priv->params.log_sq_size = MLX5E_PARAMS_DEFAULT_LOG_SQ_SIZE;
34483449

34493450
/* set CQE compression */
3450-
priv->params.rx_cqe_compress_admin = false;
3451+
priv->params.rx_cqe_compress_def = false;
34513452
if (MLX5_CAP_GEN(mdev, cqe_compression) &&
34523453
MLX5_CAP_GEN(mdev, vport_group_manager)) {
34533454
mlx5e_get_max_linkspeed(mdev, &link_speed);
34543455
mlx5e_get_pci_bw(mdev, &pci_bw);
34553456
mlx5_core_dbg(mdev, "Max link speed = %d, PCI BW = %d\n",
34563457
link_speed, pci_bw);
3457-
priv->params.rx_cqe_compress_admin =
3458+
priv->params.rx_cqe_compress_def =
34583459
cqe_compress_heuristic(link_speed, pci_bw);
34593460
}
3460-
priv->params.rx_cqe_compress = priv->params.rx_cqe_compress_admin;
34613461

34623462
mlx5e_set_rq_priv_params(priv);
34633463
if (priv->params.rq_wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ)
@@ -3490,6 +3490,7 @@ static void mlx5e_build_nic_netdev_priv(struct mlx5_core_dev *mdev,
34903490
/* Initialize pflags */
34913491
MLX5E_SET_PFLAG(priv, MLX5E_PFLAG_RX_CQE_BASED_MODER,
34923492
priv->params.rx_cq_period_mode == MLX5_CQ_PERIOD_MODE_START_FROM_CQE);
3493+
MLX5E_SET_PFLAG(priv, MLX5E_PFLAG_RX_CQE_COMPRESS, priv->params.rx_cqe_compress_def);
34933494

34943495
mutex_init(&priv->state_lock);
34953496

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,14 @@ void mlx5e_modify_rx_cqe_compression(struct mlx5e_priv *priv, bool val)
164164

165165
mutex_lock(&priv->state_lock);
166166

167-
if (priv->params.rx_cqe_compress == val)
167+
if (MLX5E_GET_PFLAG(priv, MLX5E_PFLAG_RX_CQE_COMPRESS) == val)
168168
goto unlock;
169169

170170
was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state);
171171
if (was_opened)
172172
mlx5e_close_locked(priv->netdev);
173173

174-
priv->params.rx_cqe_compress = val;
174+
MLX5E_SET_PFLAG(priv, MLX5E_PFLAG_RX_CQE_COMPRESS, val);
175175

176176
if (was_opened)
177177
mlx5e_open_locked(priv->netdev);

0 commit comments

Comments
 (0)