Commit 821b2e29 authored by Martin KaFai Lau's avatar Martin KaFai Lau Committed by David S. Miller

bpf: mlx5e: Report bpf_prog ID during XDP_QUERY_PROG

Add support to mlx5e to report bpf_prog ID during XDP_QUERY_PROG.
Signed-off-by: default avatarMartin KaFai Lau <kafai@fb.com>
Cc: Tariq Toukan <tariqt@mellanox.com>
Cc: Saeed Mahameed <saeedm@mellanox.com>
Acked-by: default avatarAlexei Starovoitov <ast@fb.com>
Acked-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2e37e9b0
...@@ -3599,11 +3599,19 @@ static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog) ...@@ -3599,11 +3599,19 @@ static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog)
return err; return err;
} }
static bool mlx5e_xdp_attached(struct net_device *dev) static u32 mlx5e_xdp_query(struct net_device *dev)
{ {
struct mlx5e_priv *priv = netdev_priv(dev); struct mlx5e_priv *priv = netdev_priv(dev);
const struct bpf_prog *xdp_prog;
u32 prog_id = 0;
return !!priv->channels.params.xdp_prog; mutex_lock(&priv->state_lock);
xdp_prog = priv->channels.params.xdp_prog;
if (xdp_prog)
prog_id = xdp_prog->aux->id;
mutex_unlock(&priv->state_lock);
return prog_id;
} }
static int mlx5e_xdp(struct net_device *dev, struct netdev_xdp *xdp) static int mlx5e_xdp(struct net_device *dev, struct netdev_xdp *xdp)
...@@ -3612,7 +3620,8 @@ static int mlx5e_xdp(struct net_device *dev, struct netdev_xdp *xdp) ...@@ -3612,7 +3620,8 @@ static int mlx5e_xdp(struct net_device *dev, struct netdev_xdp *xdp)
case XDP_SETUP_PROG: case XDP_SETUP_PROG:
return mlx5e_xdp_set(dev, xdp->prog); return mlx5e_xdp_set(dev, xdp->prog);
case XDP_QUERY_PROG: case XDP_QUERY_PROG:
xdp->prog_attached = mlx5e_xdp_attached(dev); xdp->prog_id = mlx5e_xdp_query(dev);
xdp->prog_attached = !!xdp->prog_id;
return 0; return 0;
default: default:
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment