Thread (14 messages) 14 messages, 4 authors, 2019-03-04

[RFC v2 6/6] mlx5: report XDP errors through extack

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2019-02-28 21:54:59
Subsystem: mellanox ethernet driver (mlx5e), mellanox mlx5 core vpi driver, networking drivers, the rest · Maintainers: Saeed Mahameed, Tariq Toukan, Mark Bloch, Leon Romanovsky, Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

In case of errors in setting up XDP, report error through
extack string rather than console log.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 .../net/ethernet/mellanox/mlx5/core/en_main.c | 22 +++++++++++--------
 1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index e5f74eb986b3..555d72fb6b40 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -4177,18 +4177,20 @@ static void mlx5e_tx_timeout(struct net_device *dev)
 	queue_work(priv->wq, &priv->tx_timeout_work);
 }
 
-static int mlx5e_xdp_allowed(struct mlx5e_priv *priv, struct bpf_prog *prog)
+static int mlx5e_xdp_allowed(struct mlx5e_priv *priv, struct bpf_prog *prog,
+			     struct netlink_ext_ack *extack)
 {
-	struct net_device *netdev = priv->netdev;
 	struct mlx5e_channels new_channels = {};
 
 	if (priv->channels.params.lro_en) {
-		netdev_warn(netdev, "can't set XDP while LRO is on, disable LRO first\n");
+		NL_SET_ERR_MSG_MOD(extack,
+			       "can't set XDP while LRO is on, disable LRO first");
 		return -EINVAL;
 	}
 
 	if (MLX5_IPSEC_DEV(priv->mdev)) {
-		netdev_warn(netdev, "can't set XDP with IPSec offload\n");
+		NL_SET_ERR_MSG_MOD(extack,
+			       "can't set XDP with IPSec offload");
 		return -EINVAL;
 	}
 
@@ -4196,15 +4198,16 @@ static int mlx5e_xdp_allowed(struct mlx5e_priv *priv, struct bpf_prog *prog)
 	new_channels.params.xdp_prog = prog;
 
 	if (!mlx5e_rx_is_linear_skb(priv->mdev, &new_channels.params)) {
-		netdev_warn(netdev, "XDP is not allowed with MTU(%d) > %d\n",
-			    new_channels.params.sw_mtu, MLX5E_XDP_MAX_MTU);
+		NL_SET_ERR_MSG_MOD(extack,
+			       "XDP is not allowed with large MTU");
 		return -EINVAL;
 	}
 
 	return 0;
 }
 
-static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog)
+static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog,
+			 struct netlink_ext_ack *extack)
 {
 	struct mlx5e_priv *priv = netdev_priv(netdev);
 	struct bpf_prog *old_prog;
@@ -4215,7 +4218,7 @@ static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog)
 	mutex_lock(&priv->state_lock);
 
 	if (prog) {
-		err = mlx5e_xdp_allowed(priv, prog);
+		err = mlx5e_xdp_allowed(priv, prog, extack);
 		if (err)
 			goto unlock;
 	}
@@ -4297,11 +4300,12 @@ static int mlx5e_xdp(struct net_device *dev, struct netdev_bpf *xdp)
 {
 	switch (xdp->command) {
 	case XDP_SETUP_PROG:
-		return mlx5e_xdp_set(dev, xdp->prog);
+		return mlx5e_xdp_set(dev, xdp->prog, xdp->extack);
 	case XDP_QUERY_PROG:
 		xdp->prog_id = mlx5e_xdp_query(dev);
 		return 0;
 	default:
+		NL_SET_ERR_MSG_MOD(xdp->extack, "Unsupported XDP command");
 		return -EINVAL;
 	}
 }
-- 
2.17.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help