From 3cdf9b43ffc0ad63ba60e7f36d429377c8207e5a Mon Sep 17 00:00:00 2001 From: Saeed Mahameed Date: Fri, 19 Oct 2018 14:59:00 -0700 Subject: [PATCH] net/mlx5e: XDP redirect bug fix Signed-off-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 + drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c | 3 +++ drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 15 +++++++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h index aea74856c702..4228aafc0165 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h @@ -620,6 +620,7 @@ struct mlx5e_channels { struct mlx5e_channel **c; unsigned int num; struct mlx5e_params params; + bool xdp_disabled; }; struct mlx5e_channel_stats { diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c b/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c index ad6d471d00dd..c338b7b8f838 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c @@ -268,6 +268,9 @@ int mlx5e_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames, if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK)) return -EINVAL; + if (unlikely(READ_ONCE(priv->channels.xdp_disabled))) + return -ENETDOWN; + sq_num = smp_processor_id(); if (unlikely(sq_num >= priv->channels.num)) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 0d495a6b3949..a2d8a52ae469 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -4237,8 +4237,17 @@ static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog) /* no need for full reset when exchanging programs */ reset = (!priv->channels.params.xdp_prog || !prog); - if (was_opened && reset) + if (was_opened && reset) { + for (i = 0; i < priv->channels.num; i++) + clear_bit(MLX5E_SQ_STATE_ENABLED, &priv->channels.c[i]->xdpsq.state); + priv->channels.xdp_disabled = true; + + synchronize_net(); + //msleep(200); + mlx5e_close_locked(netdev); + } + if (was_opened && !reset) { /* num_channels is invariant here, so we can take the * batched reference right upfront. @@ -4260,8 +4269,10 @@ static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog) if (reset) /* change RQ type according to priv->xdp_prog */ mlx5e_set_rq_type(priv->mdev, &priv->channels.params); - if (was_opened && reset) + if (was_opened && reset) { mlx5e_open_locked(netdev); + priv->channels.xdp_disabled = false; + } if (!test_bit(MLX5E_STATE_OPENED, &priv->state) || reset) goto unlock; -- 2.17.2