Article View: linux.kernel.netdev
Article #27025[PATCH net-next v2 09/15] eth: fbnic: Receive into XDP-only memory providers
From: Björn Töpel
Date: Fri, 04 Dec 2026 16:27
Date: Fri, 04 Dec 2026 16:27
220 lines
16537 bytes
16537 bytes
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
Technical Details
Message-ID:
<20261204162723.755897-10-bjorn@kernel.org>Path:
mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mi.newsdeef.eu!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377491-linux-kernel-netdev=dewy.ruReferences:
<20261204162723.755897-1-bjorn@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mi.newsdeef.eu!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377491-linux-kernel-netdev=dewy.ru From: bjorn@kernel.org (Björn Töpel) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next v2 09/15] eth: fbnic: Receive into XDP-only memory providers Date: Fri, 4 Dec 2026 17:27:14 +0100 Organization: Usenet Network Message-ID: <20261204162723.755897-10-bjorn@kernel.org> References: <20261204162723.755897-1-bjorn@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2806428"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:rH2Ljycgshv+xvKaaOBf4tzkP1Q= sha256:qUj13TyReyngPKbwtrqeqVqT7ME0JCZT1sA9RuKjPUo= sha1:UHHrt0RllHkQrYSua2PhKDvfr1k= sha256:EPXSg+xeH0MttJmxbMhpXtzlxcEPK8mPqijkNVf7ANI= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id E0C1A117C68; Fri, 4 Dec 2026 19:29:25 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.642 X-Spam-Status: No, score=-3.642 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lMtWHtWOo2sW; Fri, 4 Dec 2026 19:29:23 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-377491-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 41971117C66; Fri, 4 Dec 2026 19:29:14 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 514C22D6C5; Fri, 4 Dec 2026 16:29:12 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796401751; b=SbtgULACzvSFYekqt6c2lQA787PnY1eQCii3U52Q/gjodt05cNKvqMV6h4rfvN/3ocFT HX/Ayrga+zEjggc2cROt7lIDpqKCneKBZqIwBOtFlolRTxmBwbhhmWTLuvh0PYdng4L+i k19/bFClE+LhT4JI+b5iNA33V9ky5te4iWJPPdNBJcaMhrpjXDOmznuGvVBb1qhRam4tp UlHAPx5Ideu62OVNJd+XApLwaSmRYpP3T/GAoV+p46nAykWxjMXp+5Dxf8bKsKdBSSeII g5GbqBKk9wKnmRrAxwe6ryqnTJswlMpYyH7/m5qopLpGq3gIzwyJOy/TMyJGSUyBBvw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796401751; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List: List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe: List-Owner:Precedence:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=1Ud4dvn9u/cjpiRk7P1/kyP2WDjiBqPwyne6ojP2FxI=; b=LHS8nTtqeR5Qedx/EqClbDFeym9eQkLrDxC+c9yMCcsvHD275y7GYWulmkr/FV7XNRZz LCuk9gZDJwLUjizCwsBq4ukhenixK5H2rNPtUZZYhkEq6+Kkl3j0agk1+cB1NOUolf2WW ba/ctqQnCSulEL2dikmL8iwIHKGbMluay/ZFMnj5Wqxx1JDJrZpskljF+jINFkccf/Z79 vcuXKdXzUvA/wATghgz8npeumNvOgENjdFoFAq4/qsUWcuEH9pHLMZuik7PDTAbzjyzxF eSpEG99nNSMctRnGbG6iR7zzmfWWeWFqyc7tU4hT8g6SIyXL8wkNme/lu/2k8y2CXfw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="hy/cWZ0Y"; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 620B1606A682; Fri, 4 Dec 2026 16:29:11 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hy/cWZ0Y X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796401740; b=PRCqsZBSt2v4yH4HzhvCnmAT5yDhU7y1/Lqm+m4Axt2xd+dwodkdvuiw6II0cR+eMyvi 0r4fYk07osHNRIXUl9Fdyvrw/0EBhYmW6L3EajktC/QpfgCtEvUxBGxv8wqQid0MZE9Gs msOtFy+J/oT1xBOSWCrRBgLdm/SH2mYBRBUdaOnJg0nmypHCN/TJ3WQD8IRZ6Y9Bv+0Ng Lk6dYptqQ8ig3OZ81oJ8XsqdE82HaVAzJPW2isgziXAsyOzqxzVP/DspyrDF4G/mhfBbw iwzJbKGgnZQ9Vl7AVEYoYS51UYQu6andV9Aca2yoy9sDZo4Qhk5mu4/KIfVr1j94OEQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796401740; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=1Ud4dvn9u/cjpiRk7P1/kyP2WDjiBqPwyne6ojP2FxI=; b=pjAePbK9j1XXnz6DuRWkT92ZqMoPKg31ERCMPXeLpirDL1IhDpFLaT80pa4f/ECviMQ9 s3gbHa8FVWz4PIY8unTEMFFhqLKyHDUCrE2I5jf83RiU2l50Of3ejd4hI5HWDWi4m/7tY h5yuxcQnu5DMxvyxHoZ+psEPwxXWRj12/4DJ+tJJ69DcZ7nIn4sMZCLYt0l03aT4VGzVI YXnrOFwsSHtpiZAzPp2Qae+RQYCnipe5bA6F4/vcgsDGxgMPtREjtwovd978+XBCrBVmM lvH9PovsUOmLXAS6yF8ires7RILEsZbUXAlz8DUpGDBJlhY1HcdC7oNncYhB63AVJfg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="hy/cWZ0Y"; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 802C4606A32C; Fri, 4 Dec 2026 16:29:00 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0A841F00934; Fri, 4 Dec 2026 16:28:51 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796401740; bh=1Ud4dvn9u/cjpiRk7P1/kyP2WDjiBqPwyne6ojP2FxI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hy/cWZ0YkGsNMMLTzLXKkellxsUOu9M0R9RS11kUEQPh8phqFK95rj/NMKBEJM+zk wa2IJnUnBrFHrNApyC1mYTMgPVubYeBdRqbh0rzFAJiaxd/kAY7hGyB4RAH8yvlMXo oZ6nkovLefv3a44oxmC5Yjxhz9wkotXLsIRjGCf18q52g2i4klGVbYBnQthcnqvudp ULU/n+6ls70TBLuGspMiBbBJfCA5YPZ3JTyttnG/X+eFbHMURDn8PqoHpROJKSexBY xuvvoLUZbyIlup8Vn8mAnpK7yj92maOmYilPrawE28A8HSqmDxVs6ytwVB+Ez52TU+ 0BYiyYqkIb7YQ== X-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 X-Mailer: git-send-email 2.56.1 X-In-Reply-To: <20261204162723.755897-1-bjorn@kernel.org> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list