From: "Björn Töpel" <bjorn@kernel.org>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Willem de Bruijn <willemb@google.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Jesper Dangaard Brouer <hawk@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Nikolay Aleksandrov <razor@blackwall.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Magnus Karlsson <magnus.karlsson@intel.com>,
Maciej Fijalkowski <maciej.fijalkowski@intel.com>,
Donald Hunter <donald.hunter@gmail.com>,
Alexander Duyck <alexanderduyck@fb.com>,
Saeed Mahameed <saeedm@nvidia.com>,
Tariq Toukan <tariqt@nvidia.com>, Mark Bloch <mbloch@nvidia.com>,
Leon Romanovsky <leon@kernel.org>, Shuah Khan <shuah@kernel.org>,
Jonathan Corbet <corbet@lwn.net>,
netdev@vger.kernel.org, bpf@vger.kernel.org
Cc: "Björn Töpel" <bjorn@kernel.org>,
"Simon Horman" <horms@kernel.org>,
"Stanislav Fomichev" <sdf@fomichev.me>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"Jiri Olsa" <jolsa@kernel.org>,
"Emil Tsalapatis" <emil@etsalapatis.com>,
"Ihor Solodrai" <ihor.solodrai@linux.dev>,
"David Wei" <dw@davidwei.uk>, "Tao Cui" <cuitao@kylinos.cn>,
linux-kernel@vger.kernel.org, kernel-team@meta.com,
"Mike Marciniszyn (Meta)" <mike.marciniszyn@gmail.com>,
linux-rdma@vger.kernel.org, linux-kselftest@vger.kernel.org,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Randy Dunlap" <rdunlap@infradead.org>,
linux-doc@vger.kernel.org
Subject: [PATCH net-next v2 09/15] eth: fbnic: Receive into XDP-only memory providers
Date: Fri, 4 Dec 2026 17:27:14 +0100 [thread overview]
Message-ID: <20261204162723.755897-10-bjorn@kernel.org> (raw)
In-Reply-To: <20261204162723.755897-1-bjorn@kernel.org>
fbnic still handles RX heads by page address, so an XDP-only provider
cannot back its RX pool.
Let the header page pool take an XDP-only provider, and handle heads
as netmem. The payload ring shares that pool, so both rings fill from
the provider, and header-split packets reach the program as
multi-buffer packets. Skip the prefetch of XDP-only heads, which may
cost a page walk.
Size the page pool of such a queue in the pages that the rings may
post, as the provider checks that size against its chunks. A device
that is down creates no page pool on ring changes, so refuse to grow
its BDQs with -EBUSY while a queue has such a provider, rather than
fail the next open. On a running device, the provider checks the new
pool first.
Signed-off-by: Björn Töpel <bjorn@kernel.org>
---
Notes (v2changes):
Changes in v2:
- v1 patch 9, "eth: fbnic: Support XDP redirect", was posted to
net-next on its own and is a dependency.
- Refuse to grow the BDQs while the device is down and a queue has
such a provider, as nothing checks them before the next open, and
size the page pool for the provider in the pages that the BDQs
post (Sashiko).
- The message now says that the payload ring shares the header page
pool, so both rings fill from the provider.
.../net/ethernet/meta/fbnic/fbnic_ethtool.c | 22 ++++++++++
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 41 +++++++++++--------
drivers/net/ethernet/meta/fbnic/fbnic_txrx.h | 8 ++++
3 files changed, 54 insertions(+), 17 deletions(-)
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
index 9714a89977fa..3355aadeb8ff 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
@@ -6,6 +6,7 @@
#include <linux/netdevice.h>
#include <linux/pci.h>
#include <net/ipv6.h>
+#include <net/netdev_queues.h>
#include "fbnic.h"
#include "fbnic_netdev.h"
@@ -341,6 +342,16 @@ static void fbnic_set_rings(struct fbnic_net *fbn,
fbn->hds_thresh = kernel_ring->hds_thresh;
}
+static bool fbnic_has_xdp_only_mp(struct net_device *netdev)
+{
+ unsigned int i;
+
+ for (i = 0; i < netdev->real_num_rx_queues; i++)
+ if (netif_rxq_has_xdp_only_mp(netdev, i))
+ return true;
+ return false;
+}
+
static int
fbnic_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring,
struct kernel_ethtool_ringparam *kernel_ring,
@@ -386,6 +397,17 @@ fbnic_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring,
}
if (!netif_running(netdev)) {
+ /* No page pool lets the provider check larger rings before
+ * the device opens, which would then fail
+ */
+ if (fbnic_bdq_pages(ring->rx_mini_pending,
+ ring->rx_jumbo_pending) >
+ fbnic_bdq_pages(fbn->hpq_size, fbn->ppq_size) &&
+ fbnic_has_xdp_only_mp(netdev)) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Cannot grow the BDQs while the device is down and a queue has an XDP-only memory provider");
+ return -EBUSY;
+ }
fbnic_set_rings(fbn, ring, kernel_ring);
return 0;
}
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
index 9525ad2f7e14..22e9fa5f8f15 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
@@ -765,15 +765,14 @@ static void fbnic_page_pool_init(struct fbnic_ring *ring, unsigned int idx,
rx_buf->netmem = netmem;
}
-static struct page *
+static netmem_ref
fbnic_page_pool_get_head(struct fbnic_q_triad *qt, unsigned int idx)
{
struct fbnic_rx_buf *rx_buf = &qt->sub0.rx_buf[idx];
rx_buf->pagecnt_bias--;
- /* sub0 is always fed system pages, from the NAPI-level page_pool */
- return netmem_to_page(rx_buf->netmem);
+ return rx_buf->netmem;
}
static netmem_ref
@@ -1001,13 +1000,12 @@ static void fbnic_pkt_prepare(struct fbnic_napi_vector *nv, u64 rcd,
unsigned int len = FIELD_GET(FBNIC_RCD_AL_BUFF_LEN_MASK, rcd);
unsigned int hdr_pg_idx = fbnic_rcd_bd_idx(&qt->sub0, rcd);
unsigned int frame_sz, hdr_pg_start, hdr_pg_end, headroom;
- unsigned char *hdr_start;
- struct page *page;
+ netmem_ref netmem;
/* data_hard_start should always be NULL when this is called */
WARN_ON_ONCE(pkt->buff.data_hard_start);
- page = fbnic_page_pool_get_head(qt, hdr_pg_idx);
+ netmem = fbnic_page_pool_get_head(qt, hdr_pg_idx);
/* Short-cut the end calculation if we know page is fully consumed */
hdr_pg_end = FIELD_GET(FBNIC_RCD_AL_PAGE_FIN, rcd) ?
@@ -1020,15 +1018,20 @@ static void fbnic_pkt_prepare(struct fbnic_napi_vector *nv, u64 rcd,
hdr_pg_start += fbnic_rcd_bd_page_offset(&qt->sub0, rcd);
/* Sync DMA buffer */
- dma_sync_single_range_for_cpu(nv->dev, page_pool_get_dma_addr(page),
+ dma_sync_single_range_for_cpu(nv->dev,
+ page_pool_get_dma_addr_netmem(netmem),
hdr_pg_start, frame_sz,
DMA_BIDIRECTIONAL);
/* Build frame around buffer */
- hdr_start = page_address(page) + hdr_pg_start;
- net_prefetch(hdr_start + headroom);
- xdp_prepare_buff(&pkt->buff, hdr_start, headroom,
- len - FBNIC_RX_PAD, true);
+ xdp_prepare_buff(&pkt->buff, xdp_netmem_address(netmem) + hdr_pg_start,
+ headroom, len - FBNIC_RX_PAD, true);
+ pkt->head = netmem;
+ /* The kernel reads an XDP-only head only if the program does, and a
+ * prefetch may cost a page walk
+ */
+ if (!netmem_is_net_iov(netmem))
+ net_prefetch(pkt->buff.data);
pkt->hwtstamp = 0;
pkt->add_frag_failed = false;
@@ -1072,8 +1075,6 @@ static void fbnic_add_rx_frag(struct fbnic_napi_vector *nv, u64 rcd,
static void fbnic_put_pkt_buff(struct fbnic_q_triad *qt,
struct fbnic_pkt_buff *pkt, int budget)
{
- struct page *page;
-
if (!pkt->buff.data_hard_start)
return;
@@ -1092,8 +1093,7 @@ static void fbnic_put_pkt_buff(struct fbnic_q_triad *qt,
}
}
- page = virt_to_page(pkt->buff.data_hard_start);
- page_pool_put_full_page(qt->sub0.page_pool, page, !!budget);
+ page_pool_put_full_netmem(qt->sub0.page_pool, pkt->head, !!budget);
}
static struct sk_buff *fbnic_build_skb(struct fbnic_napi_vector *nv,
@@ -1612,7 +1612,8 @@ fbnic_alloc_qt_page_pools(struct fbnic_net *fbn, struct fbnic_q_triad *qt,
struct page_pool_params pp_params = {
.order = 0,
.flags = PP_FLAG_DMA_MAP |
- PP_FLAG_DMA_SYNC_DEV,
+ PP_FLAG_DMA_SYNC_DEV |
+ PP_FLAG_ALLOW_XDP_ONLY_NETMEM,
.pool_size = fbn->hpq_size + fbn->ppq_size,
.nid = NUMA_NO_NODE,
.dev = fbn->netdev->dev.parent,
@@ -1632,8 +1633,14 @@ fbnic_alloc_qt_page_pools(struct fbnic_net *fbn, struct fbnic_q_triad *qt,
* NAPI_POLL_WEIGHT possibly make more sense? The question is how
* may pages do we need to hold in reserve to get the best return
* without hogging too much system memory.
+ *
+ * An XDP-only provider checks the size against its chunks, so it
+ * must see every page that the rings may post.
*/
- if (pp_params.pool_size > 32768)
+ if (netif_rxq_has_xdp_only_mp(fbn->netdev, rxq_idx))
+ pp_params.pool_size = fbnic_bdq_pages(fbn->hpq_size,
+ fbn->ppq_size);
+ else if (pp_params.pool_size > 32768)
pp_params.pool_size = 32768;
pp = page_pool_create(&pp_params);
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.h b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.h
index a61ac2df7c03..03b668ff8a42 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.h
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.h
@@ -81,6 +81,7 @@ struct fbnic_net;
struct fbnic_pkt_buff {
struct xdp_buff buff;
+ netmem_ref head;
ktime_t hwtstamp;
bool add_frag_failed;
};
@@ -185,6 +186,13 @@ static inline u16 fbnic_bd_page_count(const struct fbnic_ring *bdq)
return 1U << bdq->bd_page_shift;
}
+static inline u32 fbnic_bdq_pages(u32 hpq_size, u32 ppq_size)
+{
+ u32 shift = ilog2(PAGE_SIZE / FBNIC_BD_PAGE_SIZE);
+
+ return (hpq_size >> shift) + (ppq_size >> shift);
+}
+
netdev_tx_t fbnic_xmit_frame(struct sk_buff *skb, struct net_device *dev);
netdev_features_t
fbnic_features_check(struct sk_buff *skb, struct net_device *dev,
--
2.56.1
next prev parent reply other threads:[~2026-12-04 16:29 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 16:27 [PATCH net-next v2 00/15] xsk: Return UMEM chunks explicitly Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 01/15] xdp: Let memory providers expose net_iovs to XDP Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 02/15] net: Add memory providers that only feed XDP Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 03/15] page_pool: Let memory providers take back net_iovs Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 04/15] xdp: Run programs on XDP-only buffers Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 05/15] xsk: Back a queue's page pools with UMEM chunks Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 06/15] xsk: Deliver packets and return chunks explicitly Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 07/15] xsk: Receive with explicit chunk return Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 08/15] xsk: Drop references of a run of buffers at once Björn Töpel
2026-12-04 16:27 ` Björn Töpel [this message]
2026-12-04 22:34 ` [PATCH net-next v2 09/15] eth: fbnic: Receive into XDP-only memory providers Alexander Duyck
2026-12-04 16:27 ` [PATCH net-next v2 10/15] net/mlx5e: Handle restarts with XDP-only providers Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 11/15] net/mlx5e: Receive into XDP-only memory providers Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 12/15] net/mlx5e: Release XDP-only pages earlier Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 13/15] net/mlx5e: Test for XDP-only pages per RQ Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 14/15] selftests: net: xsk: Test explicit chunk return Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 15/15] Documentation: xsk: Describe " Björn Töpel
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=20261204162723.755897-10-bjorn@kernel.org \
--to=bjorn@kernel.org \
--cc=alexanderduyck@fb.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=corbet@lwn.net \
--cc=cuitao@kylinos.cn \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=dw@davidwei.uk \
--cc=eddyz87@gmail.com \
--cc=edumazet@kernel.org \
--cc=emil@etsalapatis.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=ihor.solodrai@linux.dev \
--cc=ilias.apalodimas@linaro.org \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kernel-team@meta.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=magnus.karlsson@intel.com \
--cc=martin.lau@linux.dev \
--cc=mbloch@nvidia.com \
--cc=memxor@gmail.com \
--cc=mike.marciniszyn@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=razor@blackwall.org \
--cc=rdunlap@infradead.org \
--cc=saeedm@nvidia.com \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=song@kernel.org \
--cc=tariqt@nvidia.com \
--cc=willemb@google.com \
--cc=yonghong.song@linux.dev \
/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