Skip to content

Commit

Permalink
net/mlx5: fix Rx queue completion index consistency
Browse files Browse the repository at this point in the history
[ upstream commit 70d83eb ]

The Rx queue completion consumer index got temporary
wrong value pointing to the midst of the compressed CQE
session. If application crashed at the moment the next
queue restart caused handling wrong CQEs pointed by index
and losing consuming index synchronization, that made
reliable queue restart impossible.

Fixes: 88c0733 ("net/mlx5: extend Rx completion with error handling")

Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
  • Loading branch information
viacheslavo authored and bluca committed Nov 16, 2020
1 parent b056b95 commit c8b25df
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions drivers/net/mlx5/mlx5_rxtx.c
Expand Up @@ -1125,6 +1125,7 @@ mlx5_rx_poll_len(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cqe,
} else {
int ret;
int8_t op_own;
uint32_t cq_ci;

ret = check_cqe(cqe, cqe_n, rxq->cq_ci);
if (unlikely(ret != MLX5_CQE_STATUS_SW_OWN)) {
Expand All @@ -1138,14 +1139,19 @@ mlx5_rx_poll_len(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cqe,
return 0;
}
}
++rxq->cq_ci;
/*
* Introduce the local variable to have queue cq_ci
* index in queue structure always consistent with
* actual CQE boundary (not pointing to the middle
* of compressed CQE session).
*/
cq_ci = rxq->cq_ci + 1;
op_own = cqe->op_own;
if (MLX5_CQE_FORMAT(op_own) == MLX5_COMPRESSED) {
volatile struct mlx5_mini_cqe8 (*mc)[8] =
(volatile struct mlx5_mini_cqe8 (*)[8])
(uintptr_t)(&(*rxq->cqes)
[rxq->cq_ci &
cqe_cnt].pkt_info);
[cq_ci & cqe_cnt].pkt_info);

/* Fix endianness. */
zip->cqe_cnt = rte_be_to_cpu_32(cqe->byte_cnt);
Expand All @@ -1158,10 +1164,9 @@ mlx5_rx_poll_len(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cqe,
* 7 CQEs after the initial CQE instead of 8
* for subsequent ones.
*/
zip->ca = rxq->cq_ci;
zip->ca = cq_ci;
zip->na = zip->ca + 7;
/* Compute the next non compressed CQE. */
--rxq->cq_ci;
zip->cq_ci = rxq->cq_ci + zip->cqe_cnt;
/* Get packet size to return. */
len = rte_be_to_cpu_32((*mc)[0].byte_cnt);
Expand All @@ -1176,6 +1181,7 @@ mlx5_rx_poll_len(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cqe,
++idx;
}
} else {
rxq->cq_ci = cq_ci;
len = rte_be_to_cpu_32(cqe->byte_cnt);
}
}
Expand Down

0 comments on commit c8b25df

Please sign in to comment.