From: "Théo Lebrun" <theo.lebrun@bootlin.com>
To: "Paolo Valerio" <pvalerio@redhat.com>,
"Théo Lebrun" <theo.lebrun@bootlin.com>,
netdev@vger.kernel.org
Cc: "Nicolas Ferre" <nicolas.ferre@microchip.com>,
"Claudiu Beznea" <claudiu.beznea@tuxon.dev>,
"Andrew Lunn" <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Lorenzo Bianconi" <lorenzo@kernel.org>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
"Grégory Clement" <gregory.clement@bootlin.com>,
"Benoît Monin" <benoit.monin@bootlin.com>
Subject: Re: [PATCH RFC net-next 4/6] cadence: macb/gem: add XDP support for gem
Date: Mon, 08 Dec 2025 11:59:23 +0100 [thread overview]
Message-ID: <DESS6PMQCC80.L2KUOYYDCWQW@bootlin.com> (raw)
In-Reply-To: <87bjkgzt52.fsf@redhat.com>
On Tue Dec 2, 2025 at 6:32 PM CET, Paolo Valerio wrote:
> On 27 Nov 2025 at 03:41:56 PM, Théo Lebrun <theo.lebrun@bootlin.com> wrote:
>> On Wed Nov 19, 2025 at 2:53 PM CET, Paolo Valerio wrote:
>>> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
>>> index 5829c1f773dd..53ea1958b8e4 100644
>>> --- a/drivers/net/ethernet/cadence/macb_main.c
>>> +++ b/drivers/net/ethernet/cadence/macb_main.c
>>> +static u32 gem_xdp_run(struct macb_queue *queue, struct xdp_buff *xdp,
>>> + struct net_device *dev)
[...]
>>> +{
>>> + struct bpf_prog *prog;
>>> + u32 act = XDP_PASS;
>>> +
>>> + rcu_read_lock();
>>> +
>>> + prog = rcu_dereference(queue->bp->prog);
>>> + if (!prog)
>>> + goto out;
>>> +
>>> + act = bpf_prog_run_xdp(prog, xdp);
>>> + switch (act) {
>>> + case XDP_PASS:
>>> + goto out;
>>> + case XDP_REDIRECT:
>>> + if (unlikely(xdp_do_redirect(dev, xdp, prog))) {
>>> + act = XDP_DROP;
>>> + break;
>>> + }
>>> + goto out;
>>
>> Why the `unlikely()`?
>
> just expecting the err path to be the exception, although this is not
> consistend with the XDP_TX path.
> Do you prefer to remove it?
No we can keep it, I had missed this was the error case.
Sorry about that.
>
>>> + default:
>>> + bpf_warn_invalid_xdp_action(dev, prog, act);
>>> + fallthrough;
>>> + case XDP_ABORTED:
>>> + trace_xdp_exception(dev, prog, act);
>>> + fallthrough;
>>> + case XDP_DROP:
>>> + break;
>>> + }
>>> +
>>> + page_pool_put_full_page(queue->page_pool,
>>> + virt_to_head_page(xdp->data), true);
>>
>> Maybe move that to the XDP_DROP, it is the only `break` in the above
>> switch statement. It will be used by the default and XDP_ABORTED cases
>> through fallthrough. We can avoid the out label and its two gotos that
>> way.
>
> We'd not put to page pool in case the redirect fails or am I missing
> something?
Ah yes there are two break statements. I missed it.
Thanks,
--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2025-12-08 10:59 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-19 13:53 [PATCH RFC net-next 0/6] net: macb: Add XDP support and page pool integration Paolo Valerio
2025-11-19 13:53 ` [PATCH RFC net-next 1/6] cadence: macb/gem: Add page pool support Paolo Valerio
2025-11-27 13:21 ` Théo Lebrun
2025-12-02 17:30 ` Paolo Valerio
2025-11-19 13:53 ` [PATCH RFC net-next 2/6] cadence: macb/gem: handle multi-descriptor frame reception Paolo Valerio
2025-11-27 13:38 ` Théo Lebrun
2025-12-02 17:32 ` Paolo Valerio
2025-12-08 10:21 ` Théo Lebrun
2025-12-08 10:22 ` [PATCH 1/8] net: macb: move Rx buffers alloc from link up to open Théo Lebrun
2025-12-08 12:53 ` [PATCH RFC net-next 2/6] cadence: macb/gem: handle multi-descriptor frame reception Paolo Valerio
2025-12-09 9:01 ` Théo Lebrun
2025-11-19 13:53 ` [PATCH RFC net-next 3/6] cadence: macb/gem: use the current queue number for stats Paolo Valerio
2025-11-19 13:53 ` [PATCH RFC net-next 4/6] cadence: macb/gem: add XDP support for gem Paolo Valerio
2025-11-27 14:41 ` Théo Lebrun
2025-12-02 17:32 ` Paolo Valerio
2025-12-08 10:59 ` Théo Lebrun [this message]
2025-11-19 13:53 ` [PATCH RFC net-next 5/6] cadence: macb/gem: make tx path skb agnostic Paolo Valerio
2025-11-27 14:49 ` Théo Lebrun
2025-12-02 17:33 ` Paolo Valerio
2025-11-19 13:53 ` [PATCH RFC net-next 6/6] cadence: macb/gem: introduce xmit support Paolo Valerio
2025-11-27 15:07 ` Théo Lebrun
2025-12-02 17:34 ` Paolo Valerio
2025-12-08 11:01 ` Théo Lebrun
2025-11-25 16:50 ` [PATCH RFC net-next 0/6] net: macb: Add XDP support and page pool integration Théo Lebrun
2025-11-25 23:11 ` Paolo Valerio
2025-11-26 18:08 ` Théo Lebrun
2025-12-02 17:24 ` Paolo Valerio
2025-12-03 14:28 ` Théo Lebrun
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=DESS6PMQCC80.L2KUOYYDCWQW@bootlin.com \
--to=theo.lebrun@bootlin.com \
--cc=andrew+netdev@lunn.ch \
--cc=benoit.monin@bootlin.com \
--cc=claudiu.beznea@tuxon.dev \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gregory.clement@bootlin.com \
--cc=kuba@kernel.org \
--cc=lorenzo@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=pabeni@redhat.com \
--cc=pvalerio@redhat.com \
--cc=thomas.petazzoni@bootlin.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).