From: Andrew Lunn <andrew@lunn.ch>
To: Shenwei Wang <shenwei.wang@nxp.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Jesper Dangaard Brouer <hawk@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
imx@lists.linux.dev
Subject: Re: [PATCH 1/1] net: fec: add initial XDP support
Date: Wed, 26 Oct 2022 00:08:30 +0200 [thread overview]
Message-ID: <Y1heXnxgA6e5T8sr@lunn.ch> (raw)
In-Reply-To: <20221025201156.776576-1-shenwei.wang@nxp.com>
> +#define FEC_ENET_XDP_PASS 0
> +#define FEC_ENET_XDP_CONSUMED BIT(0)
> +#define FEC_ENET_XDP_TX BIT(1)
> +#define FEC_ENET_XDP_REDIR BIT(2)
I don't know XDP, so maybe a silly question. Are these action mutually
exclusive? Are these really bits, or should it be an enum?
fec_enet_run_xdp() does not combine them as bits.
> +static int fec_enet_bpf(struct net_device *dev, struct netdev_bpf *bpf)
> +{
> + struct fec_enet_private *fep = netdev_priv(dev);
> + bool is_run = netif_running(dev);
You have the space, so maybe call it is_running.
> + struct bpf_prog *old_prog;
> + unsigned int dsize;
> + int i;
> +
> + switch (bpf->command) {
> + case XDP_SETUP_PROG:
> + if (is_run)
> + fec_enet_close(dev);
fec_net_close() followed by fec_enet_open() is pretty expensive. The
PHY is stopped and disconnected, and then connected and started. That
will probably trigger an auto-neg, which takes around 1.5 seconds
before the link is up again.
Maybe you should optimise this. I guess the real issue here is you
need to resize the RX ring. You need to be careful with that
anyway. If the machine is under memory pressure, you might not be able
to allocate the ring, resulting in a broken interface. What is
recommended for ethtool --set-ring is that you first allocate the new
ring, and if that is successful, free the old ring. If the allocation
fails, you still have the old ring, and you can safely return -ENOMEM
and still have a working interface.
So i think you can split this patch up into a few parts:
XDP using the default ring size. Your benchmarks show it works, its
just not optimal. But the resulting smaller patch will be easier to
review.
Add support for ethtool set-ring, which will allow you to pick apart
the bits of fec_net_close() and fec_enet_open() which are needed for
changing the rings. This might actually need a refactoring patch?
And then add support for optimal ring size for XDP.
Andrew
next prev parent reply other threads:[~2022-10-25 22:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-25 20:11 [PATCH 1/1] net: fec: add initial XDP support Shenwei Wang
2022-10-25 22:08 ` Andrew Lunn [this message]
2022-10-27 1:50 ` [EXT] " Shenwei Wang
2022-10-26 7:45 ` kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2022-09-28 15:25 Shenwei Wang
2022-09-28 21:18 ` kernel test robot
2022-09-29 1:33 ` Andrew Lunn
2022-09-29 1:50 ` Andrew Lunn
2022-09-29 2:43 ` kernel test robot
2022-09-29 10:16 ` Jesper Dangaard Brouer
2022-10-03 5:41 ` kernel test robot
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=Y1heXnxgA6e5T8sr@lunn.ch \
--to=andrew@lunn.ch \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=imx@lists.linux.dev \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shenwei.wang@nxp.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