Skip to content

Commit a011b49

Browse files
Maxim Mikityanskiyborkmann
authored andcommitted
net/mlx5e: Consider XSK in XDP MTU limit calculation
Use the existing mlx5e_get_linear_rq_headroom function to calculate the headroom for mlx5e_xdp_max_mtu. This function takes the XSK headroom into consideration, which will be used in the following patches. Signed-off-by: Maxim Mikityanskiy <maximmi@mellanox.com> Signed-off-by: Tariq Toukan <tariqt@mellanox.com> Acked-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
1 parent 84a0a23 commit a011b49

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/params.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ static inline bool mlx5e_rx_is_xdp(struct mlx5e_params *params,
99
return params->xdp_prog || xsk;
1010
}
1111

12-
static inline u16 mlx5e_get_linear_rq_headroom(struct mlx5e_params *params,
13-
struct mlx5e_xsk_param *xsk)
12+
u16 mlx5e_get_linear_rq_headroom(struct mlx5e_params *params,
13+
struct mlx5e_xsk_param *xsk)
1414
{
1515
u16 headroom = NET_IP_ALIGN;
1616

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ struct mlx5e_xsk_param {
1111
u16 chunk_size;
1212
};
1313

14+
u16 mlx5e_get_linear_rq_headroom(struct mlx5e_params *params,
15+
struct mlx5e_xsk_param *xsk);
1416
u32 mlx5e_rx_get_linear_frag_sz(struct mlx5e_params *params,
1517
struct mlx5e_xsk_param *xsk);
1618
u8 mlx5e_mpwqe_log_pkts_per_wqe(struct mlx5e_params *params);

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@
3232

3333
#include <linux/bpf_trace.h>
3434
#include "en/xdp.h"
35+
#include "en/params.h"
3536

36-
int mlx5e_xdp_max_mtu(struct mlx5e_params *params)
37+
int mlx5e_xdp_max_mtu(struct mlx5e_params *params, struct mlx5e_xsk_param *xsk)
3738
{
38-
int hr = NET_IP_ALIGN + XDP_PACKET_HEADROOM;
39+
int hr = mlx5e_get_linear_rq_headroom(params, xsk);
3940

4041
/* Let S := SKB_DATA_ALIGN(sizeof(struct skb_shared_info)).
4142
* The condition checked in mlx5e_rx_is_linear_skb is:

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
(sizeof(struct mlx5e_tx_wqe) / MLX5_SEND_WQE_DS)
4040
#define MLX5E_XDP_TX_DS_COUNT (MLX5E_XDP_TX_EMPTY_DS_COUNT + 1 /* SG DS */)
4141

42-
int mlx5e_xdp_max_mtu(struct mlx5e_params *params);
42+
struct mlx5e_xsk_param;
43+
int mlx5e_xdp_max_mtu(struct mlx5e_params *params, struct mlx5e_xsk_param *xsk);
4344
bool mlx5e_xdp_handle(struct mlx5e_rq *rq, struct mlx5e_dma_info *di,
4445
void *va, u16 *rx_headroom, u32 *len);
4546
bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3722,7 +3722,7 @@ int mlx5e_change_mtu(struct net_device *netdev, int new_mtu,
37223722
if (params->xdp_prog &&
37233723
!mlx5e_rx_is_linear_skb(&new_channels.params)) {
37243724
netdev_err(netdev, "MTU(%d) > %d is not allowed while XDP enabled\n",
3725-
new_mtu, mlx5e_xdp_max_mtu(params));
3725+
new_mtu, mlx5e_xdp_max_mtu(params, NULL));
37263726
err = -EINVAL;
37273727
goto out;
37283728
}
@@ -4167,7 +4167,7 @@ static int mlx5e_xdp_allowed(struct mlx5e_priv *priv, struct bpf_prog *prog)
41674167
if (!mlx5e_rx_is_linear_skb(&new_channels.params)) {
41684168
netdev_warn(netdev, "XDP is not allowed with MTU(%d) > %d\n",
41694169
new_channels.params.sw_mtu,
4170-
mlx5e_xdp_max_mtu(&new_channels.params));
4170+
mlx5e_xdp_max_mtu(&new_channels.params, NULL));
41714171
return -EINVAL;
41724172
}
41734173

0 commit comments

Comments
 (0)