* [PATCH net-next] eth: fbnic: Support XDP redirect
@ 2026-11-27 5:53 Björn Töpel
2026-12-03 3:46 ` willemb
2026-12-03 16:47 ` Alexander Duyck
0 siblings, 2 replies; 4+ messages in thread
From: Björn Töpel @ 2026-11-27 5:53 UTC (permalink / raw)
To: Alexander Duyck, Jakub Kicinski, Andrew Lunn, David S. Miller,
Eric Dumazet, Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, netdev, bpf
Cc: Björn Töpel, kernel-team, Stanislav Fomichev,
Simon Horman, Dimitri Daskalakis, Bobby Eshleman, Daniel Zahka,
Mike Marciniszyn (Meta), Mohsin Bashir, Breno Leitao
fbnic treats XDP_REDIRECT as an invalid action: it warns and drops the
packet, so programs on fbnic cannot redirect to devmap, cpumap or
AF_XDP sockets.
Support the verdict and advertise NETDEV_XDP_ACT_REDIRECT. The buffers
of a redirected packet go to the target, and a failed redirect drops
the packet as XDP_ABORTED does. Each RX queue flushes its redirects
once per poll.
The NAPI vector, not a variable of the RX loop, notes that a flush is
due, as one more live variable in that loop costs XDP_DROP six
instructions per packet.
Signed-off-by: Björn Töpel <bjorn@kernel.org>
---
drivers/net/ethernet/meta/fbnic/fbnic_netdev.c | 3 ++-
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 13 +++++++++++++
drivers/net/ethernet/meta/fbnic/fbnic_txrx.h | 1 +
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c b/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c
index 52244219d166..9f0d8c070d1c 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c
@@ -822,7 +822,8 @@ struct net_device *fbnic_netdev_alloc(struct fbnic_dev *fbd)
netdev->hw_enc_features |= netdev->features;
netdev->features |= NETIF_F_NTUPLE;
- netdev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_RX_SG;
+ netdev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT |
+ NETDEV_XDP_ACT_RX_SG;
netdev->min_mtu = IPV6_MIN_MTU;
netdev->max_mtu = FBNIC_MAX_JUMBO_FRAME_SIZE - ETH_HLEN;
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
index 07d4b2e92362..da38ac1146c0 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
@@ -22,6 +22,7 @@ enum {
FBNIC_XDP_PASS = 0,
FBNIC_XDP_CONSUME,
FBNIC_XDP_TX,
+ FBNIC_XDP_REDIRECT,
FBNIC_XDP_LEN_ERR,
};
@@ -1211,10 +1212,15 @@ static struct sk_buff *fbnic_run_xdp(struct fbnic_napi_vector *nv,
return fbnic_build_skb(nv, pkt);
case XDP_TX:
return ERR_PTR(fbnic_pkt_tx(nv, pkt));
+ case XDP_REDIRECT:
+ if (xdp_do_redirect(nv->napi.dev, &pkt->buff, xdp_prog))
+ goto xdp_exception;
+ return ERR_PTR(-FBNIC_XDP_REDIRECT);
default:
bpf_warn_invalid_xdp_action(nv->napi.dev, xdp_prog, act);
fallthrough;
case XDP_ABORTED:
+xdp_exception:
trace_xdp_exception(nv->napi.dev, xdp_prog, act);
fallthrough;
case XDP_DROP:
@@ -1334,6 +1340,8 @@ static int fbnic_clean_rcq(struct fbnic_napi_vector *nv,
napi_gro_receive(&nv->napi, skb);
} else if (skb == ERR_PTR(-FBNIC_XDP_TX)) {
pkt_tail = nv->qt[0].sub1.tail;
+ } else if (skb == ERR_PTR(-FBNIC_XDP_REDIRECT)) {
+ nv->xdp_flush = true;
} else if (PTR_ERR(skb) == -FBNIC_XDP_CONSUME) {
fbnic_put_pkt_buff(qt, pkt, 1);
} else {
@@ -1387,6 +1395,11 @@ static int fbnic_clean_rcq(struct fbnic_napi_vector *nv,
fbnic_clean_bdq(&qt->sub1, head1, budget);
fbnic_fill_bdq(&qt->sub1);
+ if (nv->xdp_flush) {
+ nv->xdp_flush = false;
+ xdp_do_flush();
+ }
+
/* Record the current head/tail of the queue */
if (rcq->head != head) {
rcq->head = head;
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.h b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.h
index 6ee3cce3d942..7bc0c25ac50b 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.h
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.h
@@ -173,6 +173,7 @@ struct fbnic_napi_vector {
u16 v_idx;
u8 txt_count;
u8 rxt_count;
+ bool xdp_flush; /* An XDP redirect awaits xdp_do_flush() */
struct fbnic_q_triad qt[];
};
base-commit: ccb81d5e317b0ae2cc66ca1c628c0ca907928f94
--
2.56.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] eth: fbnic: Support XDP redirect
2026-11-27 5:53 [PATCH net-next] eth: fbnic: Support XDP redirect Björn Töpel
@ 2026-12-03 3:46 ` willemb
2026-12-03 16:47 ` Alexander Duyck
1 sibling, 0 replies; 4+ messages in thread
From: willemb @ 2026-12-03 3:46 UTC (permalink / raw)
To: Björn Töpel, Alexander Duyck, Jakub Kicinski,
Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
Alexei Starovoitov, Daniel Borkmann, Jesper Dangaard Brouer,
John Fastabend, netdev, bpf
Cc: Björn Töpel, kernel-team, Stanislav Fomichev,
Simon Horman, Dimitri Daskalakis, Bobby Eshleman, Daniel Zahka,
Mike Marciniszyn (Meta), Mohsin Bashir, Breno Leitao
Björn Töpel wrote:
> fbnic treats XDP_REDIRECT as an invalid action: it warns and drops the
> packet, so programs on fbnic cannot redirect to devmap, cpumap or
> AF_XDP sockets.
> Support the verdict and advertise NETDEV_XDP_ACT_REDIRECT. The buffers
> of a redirected packet go to the target, and a failed redirect drops
> the packet as XDP_ABORTED does. Each RX queue flushes its redirects
> once per poll.
> The NAPI vector, not a variable of the RX loop, notes that a flush is
> due, as one more live variable in that loop costs XDP_DROP six
> instructions per packet.
> Signed-off-by: Björn Töpel <bjorn@kernel.org>
META driver owners, PTAL
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] eth: fbnic: Support XDP redirect
2026-11-27 5:53 [PATCH net-next] eth: fbnic: Support XDP redirect Björn Töpel
2026-12-03 3:46 ` willemb
@ 2026-12-03 16:47 ` Alexander Duyck
2026-12-03 17:59 ` Björn Töpel
1 sibling, 1 reply; 4+ messages in thread
From: Alexander Duyck @ 2026-12-03 16:47 UTC (permalink / raw)
To: Björn Töpel
Cc: Alexander Duyck, Jakub Kicinski, Andrew Lunn, David S. Miller,
Eric Dumazet, Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, netdev, bpf, kernel-team,
Stanislav Fomichev, Simon Horman, Dimitri Daskalakis,
Bobby Eshleman, Daniel Zahka, Mike Marciniszyn (Meta),
Mohsin Bashir, Breno Leitao
On Thu, Nov 26, 2026 at 9:53 PM Björn Töpel <bjorn@kernel.org> wrote:
...
> diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.h b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.h
> index 6ee3cce3d942..7bc0c25ac50b 100644
> --- a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.h
> +++ b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.h
> @@ -173,6 +173,7 @@ struct fbnic_napi_vector {
> u16 v_idx;
> u8 txt_count;
> u8 rxt_count;
> + bool xdp_flush; /* An XDP redirect awaits xdp_do_flush() */
Please make this a u8 rather than a bool. The other members of this
struct are fixed width, and coding-style.rst asks that structures laid
out for size avoid bool.
The rest looks good to me. The xdp_buff already holds the page_pool
references for the header and each frag, so a successful redirect
hands them to the target, and a failed one is dropped through the
fbnic_put_pkt_buff function as XDP_DROP is. The flush at the end of
the fbnic_clean_rcq function runs on every pass, so nothing stays
queued past the poll.
With the u8 change:
Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] eth: fbnic: Support XDP redirect
2026-12-03 16:47 ` Alexander Duyck
@ 2026-12-03 17:59 ` Björn Töpel
0 siblings, 0 replies; 4+ messages in thread
From: Björn Töpel @ 2026-12-03 17:59 UTC (permalink / raw)
To: Alexander Duyck
Cc: Alexander Duyck, Jakub Kicinski, Andrew Lunn, David S. Miller,
Eric Dumazet, Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, netdev, bpf, kernel-team,
Stanislav Fomichev, Simon Horman, Dimitri Daskalakis,
Bobby Eshleman, Daniel Zahka, Mike Marciniszyn (Meta),
Mohsin Bashir, Breno Leitao
Alexander Duyck <alexanderduyck@meta.com> writes:
> On Thu, Nov 26, 2026 at 9:53 PM Björn Töpel <bjorn@kernel.org> wrote:
>
> ...
>
>> diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.h b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.h
>> index 6ee3cce3d942..7bc0c25ac50b 100644
>> --- a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.h
>> +++ b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.h
>> @@ -173,6 +173,7 @@ struct fbnic_napi_vector {
>> u16 v_idx;
>> u8 txt_count;
>> u8 rxt_count;
>> + bool xdp_flush; /* An XDP redirect awaits xdp_do_flush() */
>
> Please make this a u8 rather than a bool. The other members of this
> struct are fixed width, and coding-style.rst asks that structures laid
> out for size avoid bool.
>
> The rest looks good to me. The xdp_buff already holds the page_pool
> references for the header and each frag, so a successful redirect
> hands them to the target, and a failed one is dropped through the
> fbnic_put_pkt_buff function as XDP_DROP is. The flush at the end of
> the fbnic_clean_rcq function runs on every pass, so nothing stays
> queued past the poll.
>
> With the u8 change:
> Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
Thank you, Alex! And thanks for taking a look.
pw-bot: cr
Björn
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-03 17:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 5:53 [PATCH net-next] eth: fbnic: Support XDP redirect Björn Töpel
2026-12-03 3:46 ` willemb
2026-12-03 16:47 ` Alexander Duyck
2026-12-03 17:59 ` Björn Töpel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.