Skip to content

Commit be7e87f

Browse files
author
Saeed Mahameed
committed
net/mlx5e: Fail safe cqe compressing/moderation mode setting
Use the new fail-safe channels switch mechanism to set new CQE compressing and CQE moderation mode settings. We also move RX CQE compression modify function out of en_rx file to a more appropriate place. Signed-off-by: Saeed Mahameed <[email protected]> Reviewed-by: Tariq Toukan <[email protected]>
1 parent 546f18e commit be7e87f

File tree

4 files changed

+51
-34
lines changed

4 files changed

+51
-34
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ void mlx5e_pps_event_handler(struct mlx5e_priv *priv,
833833
struct ptp_clock_event *event);
834834
int mlx5e_hwstamp_set(struct net_device *dev, struct ifreq *ifr);
835835
int mlx5e_hwstamp_get(struct net_device *dev, struct ifreq *ifr);
836-
void mlx5e_modify_rx_cqe_compression_locked(struct mlx5e_priv *priv, bool val);
836+
int mlx5e_modify_rx_cqe_compression_locked(struct mlx5e_priv *priv, bool val);
837837

838838
int mlx5e_vlan_rx_add_vid(struct net_device *dev, __always_unused __be16 proto,
839839
u16 vid);

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ int mlx5e_hwstamp_set(struct net_device *dev, struct ifreq *ifr)
9090
{
9191
struct mlx5e_priv *priv = netdev_priv(dev);
9292
struct hwtstamp_config config;
93+
int err;
9394

9495
if (!MLX5_CAP_GEN(priv->mdev, device_frequency_khz))
9596
return -EOPNOTSUPP;
@@ -129,7 +130,12 @@ int mlx5e_hwstamp_set(struct net_device *dev, struct ifreq *ifr)
129130
case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
130131
/* Disable CQE compression */
131132
netdev_warn(dev, "Disabling cqe compression");
132-
mlx5e_modify_rx_cqe_compression_locked(priv, false);
133+
err = mlx5e_modify_rx_cqe_compression_locked(priv, false);
134+
if (err) {
135+
netdev_err(dev, "Failed disabling cqe compression err=%d\n", err);
136+
mutex_unlock(&priv->state_lock);
137+
return err;
138+
}
133139
config.rx_filter = HWTSTAMP_FILTER_ALL;
134140
break;
135141
default:

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

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,10 +1474,10 @@ static int set_pflag_rx_cqe_based_moder(struct net_device *netdev, bool enable)
14741474
{
14751475
struct mlx5e_priv *priv = netdev_priv(netdev);
14761476
struct mlx5_core_dev *mdev = priv->mdev;
1477+
struct mlx5e_channels new_channels = {};
14771478
bool rx_mode_changed;
14781479
u8 rx_cq_period_mode;
14791480
int err = 0;
1480-
bool reset;
14811481

14821482
rx_cq_period_mode = enable ?
14831483
MLX5_CQ_PERIOD_MODE_START_FROM_CQE :
@@ -1491,16 +1491,51 @@ static int set_pflag_rx_cqe_based_moder(struct net_device *netdev, bool enable)
14911491
if (!rx_mode_changed)
14921492
return 0;
14931493

1494-
reset = test_bit(MLX5E_STATE_OPENED, &priv->state);
1495-
if (reset)
1496-
mlx5e_close_locked(netdev);
1494+
new_channels.params = priv->channels.params;
1495+
mlx5e_set_rx_cq_mode_params(&new_channels.params, rx_cq_period_mode);
14971496

1498-
mlx5e_set_rx_cq_mode_params(&priv->channels.params, rx_cq_period_mode);
1497+
if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) {
1498+
priv->channels.params = new_channels.params;
1499+
return 0;
1500+
}
1501+
1502+
err = mlx5e_open_channels(priv, &new_channels);
1503+
if (err)
1504+
return err;
14991505

1500-
if (reset)
1501-
err = mlx5e_open_locked(netdev);
1506+
mlx5e_switch_priv_channels(priv, &new_channels);
1507+
return 0;
1508+
}
15021509

1503-
return err;
1510+
int mlx5e_modify_rx_cqe_compression_locked(struct mlx5e_priv *priv, bool new_val)
1511+
{
1512+
bool curr_val = MLX5E_GET_PFLAG(&priv->channels.params, MLX5E_PFLAG_RX_CQE_COMPRESS);
1513+
struct mlx5e_channels new_channels = {};
1514+
int err = 0;
1515+
1516+
if (!MLX5_CAP_GEN(priv->mdev, cqe_compression))
1517+
return new_val ? -EOPNOTSUPP : 0;
1518+
1519+
if (curr_val == new_val)
1520+
return 0;
1521+
1522+
new_channels.params = priv->channels.params;
1523+
MLX5E_SET_PFLAG(&new_channels.params, MLX5E_PFLAG_RX_CQE_COMPRESS, new_val);
1524+
1525+
mlx5e_set_rq_type_params(priv->mdev, &new_channels.params,
1526+
new_channels.params.rq_wq_type);
1527+
1528+
if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) {
1529+
priv->channels.params = new_channels.params;
1530+
return 0;
1531+
}
1532+
1533+
err = mlx5e_open_channels(priv, &new_channels);
1534+
if (err)
1535+
return err;
1536+
1537+
mlx5e_switch_priv_channels(priv, &new_channels);
1538+
return 0;
15041539
}
15051540

15061541
static int set_pflag_rx_cqe_compress(struct net_device *netdev,
@@ -1519,8 +1554,6 @@ static int set_pflag_rx_cqe_compress(struct net_device *netdev,
15191554

15201555
mlx5e_modify_rx_cqe_compression_locked(priv, enable);
15211556
priv->channels.params.rx_cqe_compress_def = enable;
1522-
mlx5e_set_rq_type_params(priv->mdev, &priv->channels.params,
1523-
priv->channels.params.rq_wq_type);
15241557

15251558
return 0;
15261559
}

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

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -156,28 +156,6 @@ static inline u32 mlx5e_decompress_cqes_start(struct mlx5e_rq *rq,
156156
return mlx5e_decompress_cqes_cont(rq, cq, 1, budget_rem) - 1;
157157
}
158158

159-
void mlx5e_modify_rx_cqe_compression_locked(struct mlx5e_priv *priv, bool val)
160-
{
161-
bool was_opened;
162-
163-
if (!MLX5_CAP_GEN(priv->mdev, cqe_compression))
164-
return;
165-
166-
if (MLX5E_GET_PFLAG(&priv->channels.params, MLX5E_PFLAG_RX_CQE_COMPRESS) == val)
167-
return;
168-
169-
was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state);
170-
if (was_opened)
171-
mlx5e_close_locked(priv->netdev);
172-
173-
MLX5E_SET_PFLAG(&priv->channels.params, MLX5E_PFLAG_RX_CQE_COMPRESS, val);
174-
mlx5e_set_rq_type_params(priv->mdev, &priv->channels.params,
175-
priv->channels.params.rq_wq_type);
176-
177-
if (was_opened)
178-
mlx5e_open_locked(priv->netdev);
179-
}
180-
181159
#define RQ_PAGE_SIZE(rq) ((1 << rq->buff.page_order) << PAGE_SHIFT)
182160

183161
static inline bool mlx5e_rx_cache_put(struct mlx5e_rq *rq,

0 commit comments

Comments
 (0)