[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ecb6b36bf61a9d0e99b54e3951a66c253142d77c.camel@redhat.com>
Date: Thu, 28 Feb 2019 13:04:46 -0600
From: Dan Williams <dcbw@...hat.com>
To: Stephen Hemminger <stephen@...workplumber.org>,
netdev@...r.kernel.org
Subject: Re: [RFC 2/6] ixgbe: use extack for xdp errors
On Thu, 2019-02-28 at 10:38 -0800, Stephen Hemminger wrote:
> From: Stephen Hemminger <stephen@...workplumber.org>
>
> Give a reason for returning error for bpf setup.
>
> Signed-off-by: Stephen Hemminger <stephen@...workplumber.org>
> ---
> drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 25 +++++++++++++--
> ----
> 1 file changed, 18 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..9a81123074ca 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> @@ -10224,18 +10224,23 @@ 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(extack, "XDP not support with SRIOV
> enabled");
Should be "supported" I assume?
Dan
> return -EINVAL;
> + }
>
> - if (adapter->flags & IXGBE_FLAG_DCB_ENABLED)
> + if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
> + NL_SET_ERR_MSG(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 +10249,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(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(extack, "number of cpus >
> MAX_XDP_QUEUES");
> return -ENOMEM;
> + }
>
> old_prog = xchg(&adapter->xdp_prog, prog);
> need_reset = (!!prog != !!old_prog);
> @@ -10260,7 +10270,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 +10298,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 +10308,7 @@ static int ixgbe_xdp(struct net_device *dev,
> struct netdev_bpf *xdp)
> xdp->xsk.queue_id);
>
> default:
> + NL_SET_ERR_MSG(xdp->extack, "Unknown XDP command");
> return -EINVAL;
> }
> }
Powered by blists - more mailing lists