netdev.vger.kernel.org archive mirror
 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 2/6] ixgbe: use extack for xdp errors
Date: Thu, 28 Feb 2019 13:54:37 -0800	[thread overview]
Message-ID: <20190228215441.28275-3-stephen@networkplumber.org> (raw)
In-Reply-To: <20190228215441.28275-1-stephen@networkplumber.org>

Give a reason for returning error for bpf setup.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 27 ++++++++++++++-----
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index a4e7584a50cb..d5bac44df793 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -10224,18 +10224,25 @@ ixgbe_features_check(struct sk_buff *skb, struct net_device *dev,
 	return features;
 }
 
-static int ixgbe_xdp_setup(struct net_device *dev, struct bpf_prog *prog)
+static int ixgbe_xdp_setup(struct net_device *dev, struct bpf_prog *prog,
+			   struct netlink_ext_ack *extack)
 {
 	int i, frame_size = dev->mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN;
 	struct ixgbe_adapter *adapter = netdev_priv(dev);
 	struct bpf_prog *old_prog;
 	bool need_reset;
 
-	if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)
+	if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) {
+		NL_SET_ERR_MSG_MOD(extack,
+				   "XDP not supported with SRIOV enabled");
 		return -EINVAL;
+	}
 
-	if (adapter->flags & IXGBE_FLAG_DCB_ENABLED)
+	if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
+		NL_SET_ERR_MSG_MOD(extack,
+				   "XDP not supported with DCB enabled");
 		return -EINVAL;
+	}
 
 	/* verify ixgbe ring attributes are sufficient for XDP */
 	for (i = 0; i < adapter->num_rx_queues; i++) {
@@ -10244,12 +10251,17 @@ static int ixgbe_xdp_setup(struct net_device *dev, struct bpf_prog *prog)
 		if (ring_is_rsc_enabled(ring))
 			return -EINVAL;
 
-		if (frame_size > ixgbe_rx_bufsz(ring))
+		if (frame_size > ixgbe_rx_bufsz(ring)) {
+			NL_SET_ERR_MSG_MOD(extack,
+					   "XDP does not support multiple buffers");
 			return -EINVAL;
+		}
 	}
 
-	if (nr_cpu_ids > MAX_XDP_QUEUES)
+	if (nr_cpu_ids > MAX_XDP_QUEUES) {
+		NL_SET_ERR_MSG_MOD(extack, "number of cpus > MAX_XDP_QUEUES");
 		return -ENOMEM;
+	}
 
 	old_prog = xchg(&adapter->xdp_prog, prog);
 	need_reset = (!!prog != !!old_prog);
@@ -10260,7 +10272,7 @@ static int ixgbe_xdp_setup(struct net_device *dev, struct bpf_prog *prog)
 
 		if (err) {
 			rcu_assign_pointer(adapter->xdp_prog, old_prog);
-			return -EINVAL;
+			return err;
 		}
 	} else {
 		for (i = 0; i < adapter->num_rx_queues; i++)
@@ -10288,7 +10300,7 @@ static int ixgbe_xdp(struct net_device *dev, struct netdev_bpf *xdp)
 
 	switch (xdp->command) {
 	case XDP_SETUP_PROG:
-		return ixgbe_xdp_setup(dev, xdp->prog);
+		return ixgbe_xdp_setup(dev, xdp->prog, xdp->extack);
 	case XDP_QUERY_PROG:
 		xdp->prog_id = adapter->xdp_prog ?
 			adapter->xdp_prog->aux->id : 0;
@@ -10298,6 +10310,7 @@ static int ixgbe_xdp(struct net_device *dev, struct netdev_bpf *xdp)
 					    xdp->xsk.queue_id);
 
 	default:
+		NL_SET_ERR_MSG_MOD(xdp->extack, "Unknown 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 ` Stephen Hemminger [this message]
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 ` [RFC v2 6/6] mlx5: report XDP " Stephen Hemminger

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-3-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).