All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: netdev@vger.kernel.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [RFC v2 6/6] mlx5: report XDP errors through extack
Date: Thu, 28 Feb 2019 13:54:41 -0800	[thread overview]
Message-ID: <20190228215441.28275-7-stephen@networkplumber.org> (raw)
In-Reply-To: <20190228215441.28275-1-stephen@networkplumber.org>

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


      parent reply	other threads:[~2019-02-28 21:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-28 21:54 [RFC v2 0/6] use extack when setting up XDP Stephen Hemminger
2019-02-28 21:54 ` [RFC v2 1/6] bnxt: use extack for xdp error messages Stephen Hemminger
2019-02-28 21:54 ` [RFC v2 2/6] ixgbe: use extack for xdp errors Stephen Hemminger
2019-02-28 21:54 ` [RFC v2 3/6] i40e: use extack for bpf errors Stephen Hemminger
2019-03-01  3:06   ` Jakub Kicinski
2019-03-01 11:31     ` Maciej Fijalkowski
2019-03-01 16:28       ` Jakub Kicinski
2019-03-01 21:55         ` Stephen Hemminger
2019-03-01 22:03           ` Jakub Kicinski
2019-02-28 21:54 ` [RFC v2 4/6] ixgebvf: report xdp errors through extack Stephen Hemminger
2019-02-28 21:54 ` [RFC v2 5/6] mlx4: report " Stephen Hemminger
2019-03-01  3:07   ` Jakub Kicinski
2019-03-04 11:54   ` Tariq Toukan
2019-02-28 21:54 ` Stephen Hemminger [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190228215441.28275-7-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.