[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191123071226.6501-6-bjorn.topel@gmail.com>
Date: Sat, 23 Nov 2019 08:12:24 +0100
From: Björn Töpel <bjorn.topel@...il.com>
To: netdev@...r.kernel.org, ast@...nel.org, daniel@...earbox.net
Cc: Björn Töpel <bjorn.topel@...el.com>,
bpf@...r.kernel.org, magnus.karlsson@...il.com,
magnus.karlsson@...el.com, jonathan.lemon@...il.com,
ecree@...arflare.com, thoiland@...hat.com,
andrii.nakryiko@...il.com, tariqt@...lanox.com,
saeedm@...lanox.com, maximmi@...lanox.com
Subject: [PATCH bpf-next v2 5/6] net/mlx4_en: start using xdp_call.h
From: Björn Töpel <bjorn.topel@...el.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@...el.com>
---
drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 7 ++++++-
drivers/net/ethernet/mellanox/mlx4/en_rx.c | 5 ++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index d4697beeacc2..f2dea32e5599 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -41,6 +41,7 @@
#include <net/ip.h>
#include <net/vxlan.h>
#include <net/devlink.h>
+#include <linux/xdp_call.h>
#include <linux/mlx4/driver.h>
#include <linux/mlx4/device.h>
@@ -2759,12 +2760,14 @@ static int mlx4_en_set_tx_maxrate(struct net_device *dev, int queue_index, u32 m
return err;
}
+DEFINE_XDP_CALL(mlx4_xdp_call);
+
static int mlx4_xdp_set(struct net_device *dev, struct bpf_prog *prog)
{
struct mlx4_en_priv *priv = netdev_priv(dev);
struct mlx4_en_dev *mdev = priv->mdev;
struct mlx4_en_port_profile new_prof;
- struct bpf_prog *old_prog;
+ struct bpf_prog *old_prog = NULL;
struct mlx4_en_priv *tmp;
int tx_changed = 0;
int xdp_ring_num;
@@ -2790,6 +2793,7 @@ static int mlx4_xdp_set(struct net_device *dev, struct bpf_prog *prog)
if (old_prog)
bpf_prog_put(old_prog);
}
+ xdp_call_update(mlx4_xdp_call, old_prog, prog);
mutex_unlock(&mdev->state_lock);
return 0;
}
@@ -2839,6 +2843,7 @@ static int mlx4_xdp_set(struct net_device *dev, struct bpf_prog *prog)
if (old_prog)
bpf_prog_put(old_prog);
}
+ xdp_call_update(mlx4_xdp_call, old_prog, prog);
if (port_up) {
err = mlx4_en_start_port(dev);
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index db3552f2d087..f2400ea36a11 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -42,6 +42,7 @@
#include <linux/if_vlan.h>
#include <linux/vmalloc.h>
#include <linux/irq.h>
+#include <linux/xdp_call.h>
#include <net/ip.h>
#if IS_ENABLED(CONFIG_IPV6)
@@ -661,6 +662,8 @@ static int check_csum(struct mlx4_cqe *cqe, struct sk_buff *skb, void *va,
#define MLX4_CQE_STATUS_IP_ANY (MLX4_CQE_STATUS_IPV4)
#endif
+DECLARE_XDP_CALL(mlx4_xdp_call);
+
int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int budget)
{
struct mlx4_en_priv *priv = netdev_priv(dev);
@@ -782,7 +785,7 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
xdp.data_end = xdp.data + length;
orig_data = xdp.data;
- act = bpf_prog_run_xdp(xdp_prog, &xdp);
+ act = xdp_call_run(mlx4_xdp_call, xdp_prog, &xdp);
length = xdp.data_end - xdp.data;
if (xdp.data != orig_data) {
--
2.20.1
Powered by blists - more mailing lists