Skip to content

Commit 39646d9

Browse files
dtatuleaSaeed Mahameed
authored andcommitted
net/mlx5e: xsk: Fix crash on regular rq reactivation
When the regular rq is reactivated after the XSK socket is closed it could be reading stale cqes which eventually corrupts the rq. This leads to no more traffic being received on the regular rq and a crash on the next close or deactivation of the rq. Kal Cuttler Conely reported this issue as a crash on the release path when the xdpsock sample program is stopped (killed) and restarted in sequence while traffic is running. This patch flushes all cqes when during the rq flush. The cqe flushing is done in the reset state of the rq. mlx5e_rq_to_ready code is moved into the flush function to allow for this. Fixes: 082a9ed ("net/mlx5e: xsk: Flush RQ on XSK activation to save memory") Reported-by: Kal Cutter Conley <[email protected]> Closes: https://lore.kernel.org/xdp-newbies/CAHApi-nUAs4TeFWUDV915CZJo07XVg2Vp63-no7UDfj6wur9nQ@mail.gmail.com Signed-off-by: Dragos Tatulea <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent e0f5229 commit 39646d9

File tree

1 file changed

+21
-8
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+21
-8
lines changed

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

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,23 @@ static int mlx5e_modify_rq_state(struct mlx5e_rq *rq, int curr_state, int next_s
10361036
return err;
10371037
}
10381038

1039-
static int mlx5e_rq_to_ready(struct mlx5e_rq *rq, int curr_state)
1039+
static void mlx5e_flush_rq_cq(struct mlx5e_rq *rq)
1040+
{
1041+
struct mlx5_cqwq *cqwq = &rq->cq.wq;
1042+
struct mlx5_cqe64 *cqe;
1043+
1044+
if (test_bit(MLX5E_RQ_STATE_MINI_CQE_ENHANCED, &rq->state)) {
1045+
while ((cqe = mlx5_cqwq_get_cqe_enahnced_comp(cqwq)))
1046+
mlx5_cqwq_pop(cqwq);
1047+
} else {
1048+
while ((cqe = mlx5_cqwq_get_cqe(cqwq)))
1049+
mlx5_cqwq_pop(cqwq);
1050+
}
1051+
1052+
mlx5_cqwq_update_db_record(cqwq);
1053+
}
1054+
1055+
int mlx5e_flush_rq(struct mlx5e_rq *rq, int curr_state)
10401056
{
10411057
struct net_device *dev = rq->netdev;
10421058
int err;
@@ -1046,6 +1062,10 @@ static int mlx5e_rq_to_ready(struct mlx5e_rq *rq, int curr_state)
10461062
netdev_err(dev, "Failed to move rq 0x%x to reset\n", rq->rqn);
10471063
return err;
10481064
}
1065+
1066+
mlx5e_free_rx_descs(rq);
1067+
mlx5e_flush_rq_cq(rq);
1068+
10491069
err = mlx5e_modify_rq_state(rq, MLX5_RQC_STATE_RST, MLX5_RQC_STATE_RDY);
10501070
if (err) {
10511071
netdev_err(dev, "Failed to move rq 0x%x to ready\n", rq->rqn);
@@ -1055,13 +1075,6 @@ static int mlx5e_rq_to_ready(struct mlx5e_rq *rq, int curr_state)
10551075
return 0;
10561076
}
10571077

1058-
int mlx5e_flush_rq(struct mlx5e_rq *rq, int curr_state)
1059-
{
1060-
mlx5e_free_rx_descs(rq);
1061-
1062-
return mlx5e_rq_to_ready(rq, curr_state);
1063-
}
1064-
10651078
static int mlx5e_modify_rq_vsd(struct mlx5e_rq *rq, bool vsd)
10661079
{
10671080
struct mlx5_core_dev *mdev = rq->mdev;

0 commit comments

Comments
 (0)