Skip to content

Commit 34a7987

Browse files
dtatuleaSaeed Mahameed
authored andcommitted
net/mlx5e: XDP, Fix fifo overrun on XDP_REDIRECT
Before this fix, running high rate traffic through XDP_REDIRECT with multibuf could overrun the fifo used to release the xdp frames after tx completion. This resulted in corrupted data being consumed on the free side. The culplirt was a miscalculation of the fifo size: the maximum ratio between fifo entries / data segments was incorrect. This ratio serves to calculate the max fifo size for a full sq where each packet uses the worst case number of entries in the fifo. This patch fixes the formula and names the constant. It also makes sure that future values will use a power of 2 number of entries for the fifo mask to work. Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com> Fixes: 3f734b8 ("net/mlx5e: XDP, Use multiple single-entry objects in xdpi_fifo") Reviewed-by: Tariq Toukan <tariqt@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
1 parent de4c5ef commit 34a7987

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ enum mlx5e_xdp_xmit_mode {
8484
* MLX5E_XDP_XMIT_MODE_XSK:
8585
* none.
8686
*/
87+
#define MLX5E_XDP_FIFO_ENTRIES2DS_MAX_RATIO 4
88+
8789
union mlx5e_xdp_info {
8890
enum mlx5e_xdp_xmit_mode mode;
8991
union {

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,11 +1298,13 @@ static int mlx5e_alloc_xdpsq_fifo(struct mlx5e_xdpsq *sq, int numa)
12981298
{
12991299
struct mlx5e_xdp_info_fifo *xdpi_fifo = &sq->db.xdpi_fifo;
13001300
int wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
1301-
int entries = wq_sz * MLX5_SEND_WQEBB_NUM_DS * 2; /* upper bound for maximum num of
1302-
* entries of all xmit_modes.
1303-
*/
1301+
int entries;
13041302
size_t size;
13051303

1304+
/* upper bound for maximum num of entries of all xmit_modes. */
1305+
entries = roundup_pow_of_two(wq_sz * MLX5_SEND_WQEBB_NUM_DS *
1306+
MLX5E_XDP_FIFO_ENTRIES2DS_MAX_RATIO);
1307+
13061308
size = array_size(sizeof(*xdpi_fifo->xi), entries);
13071309
xdpi_fifo->xi = kvzalloc_node(size, GFP_KERNEL, numa);
13081310
if (!xdpi_fifo->xi)

0 commit comments

Comments
 (0)