From: David Ahern <dsahern@gmail.com>
To: sameehj@amazon.com, davem@davemloft.net, netdev@vger.kernel.org
Cc: dwmw@amazon.com, zorik@amazon.com, matua@amazon.com,
saeedb@amazon.com, msw@amazon.com, aliguori@amazon.com,
nafea@amazon.com, gtzalik@amazon.com, netanel@amazon.com,
alisaidi@amazon.com, benh@amazon.com, akiyano@amazon.com
Subject: Re: [RFC V1 net-next 1/1] net: ena: implement XDP drop support
Date: Sun, 23 Jun 2019 08:28:44 -0600 [thread overview]
Message-ID: <c6bfd84e-6c40-ba86-0f3d-7efe10e0cab2@gmail.com> (raw)
In-Reply-To: <20190623070649.18447-2-sameehj@amazon.com>
On 6/23/19 1:06 AM, sameehj@amazon.com wrote:
> +static int ena_xdp_set(struct net_device *netdev, struct bpf_prog *prog)
> +{
> + struct ena_adapter *adapter = netdev_priv(netdev);
> + struct bpf_prog *old_bpf_prog;
> + int i;
> +
> + if (ena_xdp_allowed(adapter)) {
> + old_bpf_prog = xchg(&adapter->xdp_bpf_prog, prog);
> +
> + for (i = 0; i < adapter->num_queues; i++)
> + xchg(&adapter->rx_ring[i].xdp_bpf_prog, prog);
> +
> + if (old_bpf_prog)
> + bpf_prog_put(old_bpf_prog);
> +
> + } else {
> + netif_err(adapter, drv, adapter->netdev, "Failed to set xdp program, the current MTU (%d) is larger than the maximal allowed MTU (%lu) while xdp is on",
> + netdev->mtu, ENA_XDP_MAX_MTU);
> + return -EFAULT;
unfortunate that extack has not been plumbed to ndo_bpf handler so that
message is passed to the user.
And EFAULT seems like the wrong return code.
> + }
> +
> + return 0;
> +}
> +
> +/* This is the main xdp callback, it's used by the kernel to set/unset the xdp
> + * program as well as to query the current xdp program id.
> + */
> +static int ena_xdp(struct net_device *netdev, struct netdev_bpf *bpf)
> +{
> + struct ena_adapter *adapter = netdev_priv(netdev);
> +
> + switch (bpf->command) {
> + case XDP_SETUP_PROG:
> + return ena_xdp_set(netdev, bpf->prog);
> + case XDP_QUERY_PROG:
> + bpf->prog_id = adapter->xdp_bpf_prog ?
> + adapter->xdp_bpf_prog->aux->id : 0;
> + break;
> + default:
> + return -EINVAL;
> + }
> + return 0;
> +}
> +
> static int ena_change_mtu(struct net_device *dev, int new_mtu)
> {
> struct ena_adapter *adapter = netdev_priv(dev);
> int ret;
>
> + if (new_mtu > ENA_XDP_MAX_MTU && ena_xdp_present(adapter)) {
> + netif_err(adapter, drv, dev,
> + "Requested MTU value is not valid while xdp is enabled new_mtu: %d max mtu: %lu min mtu: %d\n",
> + new_mtu, ENA_XDP_MAX_MTU, ENA_MIN_MTU);
> + return -EINVAL;
> + }
If you manage dev->max_mtu as an XDP program is installed / removed this
check is not needed. Instead it is handled by the core change_mtu logic
and has better user semanitcs: link list shows the new MTU and trying to
change it above the new max a message is sent to the user as opposed to
kernel log.
> ret = ena_com_set_dev_mtu(adapter->ena_dev, new_mtu);
> if (!ret) {
> netif_dbg(adapter, drv, dev, "set MTU to %d\n", new_mtu);
next prev parent reply other threads:[~2019-06-23 14:28 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-23 7:06 [RFC V1 net-next 0/1] Introduce xdp to ena sameehj
2019-06-23 7:06 ` [RFC V1 net-next 1/1] net: ena: implement XDP drop support sameehj
2019-06-23 14:09 ` Jesper Dangaard Brouer
2019-06-23 14:21 ` Jesper Dangaard Brouer
2019-06-25 3:19 ` Machulsky, Zorik
2019-06-26 8:38 ` XDP multi-buffer incl. jumbo-frames (Was: [RFC V1 net-next 1/1] net: ena: implement XDP drop support) Jesper Dangaard Brouer
2019-06-26 11:52 ` Toke Høiland-Jørgensen
2019-06-26 14:40 ` Jesper Dangaard Brouer
2019-06-26 15:01 ` Toke Høiland-Jørgensen
2019-06-26 15:20 ` Willem de Bruijn
2019-06-26 16:42 ` Jonathan Lemon
2019-06-26 20:00 ` Jesper Dangaard Brouer
2019-06-27 22:07 ` Jonathan Lemon
2019-06-28 8:46 ` Jesper Dangaard Brouer
2019-06-26 15:14 ` Toke Høiland-Jørgensen
2019-06-26 16:36 ` Jesper Dangaard Brouer
2019-06-28 7:14 ` Eelco Chaudron
2019-06-28 7:46 ` Toke Høiland-Jørgensen
2019-06-28 11:49 ` Eelco Chaudron
2019-06-28 8:22 ` Jesper Dangaard Brouer
2019-06-23 14:28 ` David Ahern [this message]
2019-06-23 14:51 ` [RFC V1 net-next 1/1] net: ena: implement XDP drop support Maciej Fijalkowski
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=c6bfd84e-6c40-ba86-0f3d-7efe10e0cab2@gmail.com \
--to=dsahern@gmail.com \
--cc=akiyano@amazon.com \
--cc=aliguori@amazon.com \
--cc=alisaidi@amazon.com \
--cc=benh@amazon.com \
--cc=davem@davemloft.net \
--cc=dwmw@amazon.com \
--cc=gtzalik@amazon.com \
--cc=matua@amazon.com \
--cc=msw@amazon.com \
--cc=nafea@amazon.com \
--cc=netanel@amazon.com \
--cc=netdev@vger.kernel.org \
--cc=saeedb@amazon.com \
--cc=sameehj@amazon.com \
--cc=zorik@amazon.com \
/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).