On 2/28/2019 11:54 PM, Stephen Hemminger wrote:
> XDP errors should be reported via extack (back to command)
> rather than on console.
> 
> Signed-off-by: Stephen Hemminger <step...@networkplumber.org>
> ---
>   drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 14 +++++++++-----
>   1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c 
> b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
> index c1438ae52a11..75ae06c82294 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
> @@ -2779,7 +2779,8 @@ static int mlx4_en_set_tx_maxrate(struct net_device 
> *dev, int queue_index, u32 m
>       return err;
>   }
>   
> -static int mlx4_xdp_set(struct net_device *dev, struct bpf_prog *prog)
> +static int mlx4_xdp_set(struct net_device *dev, struct bpf_prog *prog,
> +                     struct netlink_ext_ack *extack)
>   {
>       struct mlx4_en_priv *priv = netdev_priv(dev);
>       struct mlx4_en_dev *mdev = priv->mdev;
> @@ -2816,8 +2817,10 @@ static int mlx4_xdp_set(struct net_device *dev, struct 
> bpf_prog *prog)
>               return 0;
>       }
>   
> -     if (!mlx4_en_check_xdp_mtu(dev, dev->mtu))
> +     if (!mlx4_en_check_xdp_mtu(dev, dev->mtu)) {
> +             NL_SET_ERR_MSG_MOD(extack, "MTU exceeds support XDP maximum");
>               return -EOPNOTSUPP;
> +     }
>   
>       tmp = kzalloc(sizeof(*tmp), GFP_KERNEL);
>       if (!tmp)
> @@ -2870,8 +2873,8 @@ static int mlx4_xdp_set(struct net_device *dev, struct 
> bpf_prog *prog)
>       if (port_up) {
>               err = mlx4_en_start_port(dev);
>               if (err) {
> -                     en_err(priv, "Failed starting port %d for XDP change\n",
> -                            priv->port);
> +                     NL_SET_ERR_MSG_MOD(extack,
> +                                    "Failed starting port for XDP change");

Any reason not to keep the port number? It used to be printed.

>                       queue_work(mdev->workqueue, &priv->watchdog_task);
>               }
>       }
> @@ -2908,11 +2911,12 @@ static int mlx4_xdp(struct net_device *dev, struct 
> netdev_bpf *xdp)
>   {
>       switch (xdp->command) {
>       case XDP_SETUP_PROG:
> -             return mlx4_xdp_set(dev, xdp->prog);
> +             return mlx4_xdp_set(dev, xdp->prog, xdp->extack);
>       case XDP_QUERY_PROG:
>               xdp->prog_id = mlx4_xdp_query(dev);
>               return 0;
>       default:
> +             NL_SET_ERR_MSG_MOD(xdp->extack, "Unsupported XDP command");
>               return -EINVAL;
>       }
>   }
> 

Reply via email to