net/mlx5e: Consider XSK in XDP MTU limit calculation
authorMaxim Mikityanskiy <maximmi@mellanox.com>
Wed, 26 Jun 2019 14:35:35 +0000 (17:35 +0300)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 27 Jun 2019 20:53:28 +0000 (22:53 +0200)
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>
drivers/net/ethernet/mellanox/mlx5/core/en/params.c
drivers/net/ethernet/mellanox/mlx5/core/en/params.h
drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
drivers/net/ethernet/mellanox/mlx5/core/en/xdp.h
drivers/net/ethernet/mellanox/mlx5/core/en_main.c

index 50a458dc3836396f667d77c7cd0de6be430a5730..0de908b12fccf3a3251d9b825a52adc16ce24cb7 100644 (file)
@@ -9,8 +9,8 @@ static inline bool mlx5e_rx_is_xdp(struct mlx5e_params *params,
        return params->xdp_prog || xsk;
 }
 
-static inline u16 mlx5e_get_linear_rq_headroom(struct mlx5e_params *params,
-                                              struct mlx5e_xsk_param *xsk)
+u16 mlx5e_get_linear_rq_headroom(struct mlx5e_params *params,
+                                struct mlx5e_xsk_param *xsk)
 {
        u16 headroom = NET_IP_ALIGN;
 
index ed420f3efe52ad21dedd911e0753dd08bd3305c0..7f29b82dd8c2a50323a7d8d9ee782e98bb47ab3c 100644 (file)
@@ -11,6 +11,8 @@ struct mlx5e_xsk_param {
        u16 chunk_size;
 };
 
+u16 mlx5e_get_linear_rq_headroom(struct mlx5e_params *params,
+                                struct mlx5e_xsk_param *xsk);
 u32 mlx5e_rx_get_linear_frag_sz(struct mlx5e_params *params,
                                struct mlx5e_xsk_param *xsk);
 u8 mlx5e_mpwqe_log_pkts_per_wqe(struct mlx5e_params *params);
index 1364bdff702ca626a45fd2bef8dacf73eab9e1df..ee99efde914362cfee88ef6e4f673ffeee5979e7 100644 (file)
 
 #include <linux/bpf_trace.h>
 #include "en/xdp.h"
+#include "en/params.h"
 
-int mlx5e_xdp_max_mtu(struct mlx5e_params *params)
+int mlx5e_xdp_max_mtu(struct mlx5e_params *params, struct mlx5e_xsk_param *xsk)
 {
-       int hr = NET_IP_ALIGN + XDP_PACKET_HEADROOM;
+       int hr = mlx5e_get_linear_rq_headroom(params, xsk);
 
        /* Let S := SKB_DATA_ALIGN(sizeof(struct skb_shared_info)).
         * The condition checked in mlx5e_rx_is_linear_skb is:
index 86db5ad49a428e0a9631015080091351b48c104d..9200cb9f499b6170946d74e7cc7d83d3a5abfef5 100644 (file)
@@ -39,7 +39,8 @@
        (sizeof(struct mlx5e_tx_wqe) / MLX5_SEND_WQE_DS)
 #define MLX5E_XDP_TX_DS_COUNT (MLX5E_XDP_TX_EMPTY_DS_COUNT + 1 /* SG DS */)
 
-int mlx5e_xdp_max_mtu(struct mlx5e_params *params);
+struct mlx5e_xsk_param;
+int mlx5e_xdp_max_mtu(struct mlx5e_params *params, struct mlx5e_xsk_param *xsk);
 bool mlx5e_xdp_handle(struct mlx5e_rq *rq, struct mlx5e_dma_info *di,
                      void *va, u16 *rx_headroom, u32 *len);
 bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq);
index abc1d0f6cf53e628b3d8b30719f175be761f1d10..96fb3fa32d63e9f91af98fbc1fcd7e75fc68f2d5 100644 (file)
@@ -3722,7 +3722,7 @@ int mlx5e_change_mtu(struct net_device *netdev, int new_mtu,
        if (params->xdp_prog &&
            !mlx5e_rx_is_linear_skb(&new_channels.params)) {
                netdev_err(netdev, "MTU(%d) > %d is not allowed while XDP enabled\n",
-                          new_mtu, mlx5e_xdp_max_mtu(params));
+                          new_mtu, mlx5e_xdp_max_mtu(params, NULL));
                err = -EINVAL;
                goto out;
        }
@@ -4167,7 +4167,7 @@ static int mlx5e_xdp_allowed(struct mlx5e_priv *priv, struct bpf_prog *prog)
        if (!mlx5e_rx_is_linear_skb(&new_channels.params)) {
                netdev_warn(netdev, "XDP is not allowed with MTU(%d) > %d\n",
                            new_channels.params.sw_mtu,
-                           mlx5e_xdp_max_mtu(&new_channels.params));
+                           mlx5e_xdp_max_mtu(&new_channels.params, NULL));
                return -EINVAL;
        }