diff mbox series

[bpf-next,v2,6/6] net/mlx5e: Start using xdp_call.h

Message ID 20191123071226.6501-7-bjorn.topel@gmail.com
State Changes Requested
Delegated to: BPF Maintainers
Headers show
Series Introduce the BPF dispatcher and xdp_call.h | expand

Commit Message

Björn Töpel Nov. 23, 2019, 7:12 a.m. UTC
From: Björn Töpel <bjorn.topel@intel.com>

This commit starts using xdp_call.h and the BPF dispatcher to avoid
the retpoline overhead.

Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c  | 5 ++++-
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 5 +++++
 2 files changed, 9 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c b/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
index f049e0ac308a..cc11b0db950e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
@@ -32,6 +32,7 @@ 
 
 #include <linux/bpf_trace.h>
 #include <net/xdp_sock.h>
+#include <linux/xdp_call.h>
 #include "en/xdp.h"
 #include "en/params.h"
 
@@ -117,6 +118,8 @@  mlx5e_xmit_xdp_buff(struct mlx5e_xdpsq *sq, struct mlx5e_rq *rq,
 	return sq->xmit_xdp_frame(sq, &xdptxd, &xdpi, 0);
 }
 
+DECLARE_XDP_CALL(mlx5e_xdp_call);
+
 /* returns true if packet was consumed by xdp */
 bool mlx5e_xdp_handle(struct mlx5e_rq *rq, struct mlx5e_dma_info *di,
 		      void *va, u16 *rx_headroom, u32 *len, bool xsk)
@@ -138,7 +141,7 @@  bool mlx5e_xdp_handle(struct mlx5e_rq *rq, struct mlx5e_dma_info *di,
 		xdp.handle = di->xsk.handle;
 	xdp.rxq = &rq->xdp_rxq;
 
-	act = bpf_prog_run_xdp(prog, &xdp);
+	act = xdp_call_run(mlx5e_xdp_call, prog, &xdp);
 	if (xsk) {
 		u64 off = xdp.data - xdp.data_hard_start;
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index e8d799c0dfda..0b26f9d7a968 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -39,6 +39,7 @@ 
 #include <linux/if_bridge.h>
 #include <net/page_pool.h>
 #include <net/xdp_sock.h>
+#include <linux/xdp_call.h>
 #include "eswitch.h"
 #include "en.h"
 #include "en/txrx.h"
@@ -4384,6 +4385,8 @@  static int mlx5e_xdp_update_state(struct mlx5e_priv *priv)
 	return 0;
 }
 
+DEFINE_XDP_CALL(mlx5e_xdp_call);
+
 static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog)
 {
 	struct mlx5e_priv *priv = netdev_priv(netdev);
@@ -4428,6 +4431,8 @@  static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog)
 		old_prog = xchg(&priv->channels.params.xdp_prog, prog);
 	}
 
+	xdp_call_update(mlx5e_xdp_call, old_prog, prog);
+
 	if (old_prog)
 		bpf_prog_put(old_prog);