Skip to content

Commit 78dee7b

Browse files
Adham FarisSaeed Mahameed
authored andcommitted
net/mlx5e: Lower maximum allowed MTU in XSK to match XDP prerequisites
XSK redirecting XDP programs require linearity, hence applies restrictions on the MTU. For PAGE_SIZE=4K, MTU shouldn't exceed 3498. Features that contradict with XDP such HW-LRO and HW-GRO are enforced by the driver in advance, during XSK params validation, except for MTU, which was not enforced before this patch. This has been spotted during test scenario described below: Attaching xdpsock program (PAGE_SIZE=4K), with MTU < 3498, detaching XDP program, changing the MTU to arbitrary value in the range [3499, 3754], attaching XDP program again, which ended up with failure since MTU is > 3498. This commit lowers the XSK MTU limitation to be aligned with XDP MTU limitation, since XSK socket is meaningless without XDP program. Signed-off-by: Adham Faris <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 031a163 commit 78dee7b

File tree

1 file changed

+7
-3
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4169,13 +4169,17 @@ static bool mlx5e_xsk_validate_mtu(struct net_device *netdev,
41694169
struct xsk_buff_pool *xsk_pool =
41704170
mlx5e_xsk_get_pool(&chs->params, chs->params.xsk, ix);
41714171
struct mlx5e_xsk_param xsk;
4172+
int max_xdp_mtu;
41724173

41734174
if (!xsk_pool)
41744175
continue;
41754176

41764177
mlx5e_build_xsk_param(xsk_pool, &xsk);
4178+
max_xdp_mtu = mlx5e_xdp_max_mtu(new_params, &xsk);
41774179

4178-
if (!mlx5e_validate_xsk_param(new_params, &xsk, mdev)) {
4180+
/* Validate XSK params and XDP MTU in advance */
4181+
if (!mlx5e_validate_xsk_param(new_params, &xsk, mdev) ||
4182+
new_params->sw_mtu > max_xdp_mtu) {
41794183
u32 hr = mlx5e_get_linear_rq_headroom(new_params, &xsk);
41804184
int max_mtu_frame, max_mtu_page, max_mtu;
41814185

@@ -4185,9 +4189,9 @@ static bool mlx5e_xsk_validate_mtu(struct net_device *netdev,
41854189
*/
41864190
max_mtu_frame = MLX5E_HW2SW_MTU(new_params, xsk.chunk_size - hr);
41874191
max_mtu_page = MLX5E_HW2SW_MTU(new_params, SKB_MAX_HEAD(0));
4188-
max_mtu = min(max_mtu_frame, max_mtu_page);
4192+
max_mtu = min3(max_mtu_frame, max_mtu_page, max_xdp_mtu);
41894193

4190-
netdev_err(netdev, "MTU %d is too big for an XSK running on channel %u. Try MTU <= %d\n",
4194+
netdev_err(netdev, "MTU %d is too big for an XSK running on channel %u or its redirection XDP program. Try MTU <= %d\n",
41914195
new_params->sw_mtu, ix, max_mtu);
41924196
return false;
41934197
}

0 commit comments

Comments
 (0)