fbnic: Support larger io_uring zcrx buffers
Subsystems (4)
cover fbnic: Support larger io_uring zcrx buffers
Hi!
Fbnic programs receive buffers through BDQs. The hardware consumes BDQs as 4 KiB fragments, and receive completions report the consumed buffer by returning the BDQ buffer ID in the RCD.
The driver currently derives the BDQ fragment layout from PAGE_SIZE. That works while HPQ and PPQ use the same allocation size, but io_uring zcrx can provide larger receive buffers through rx_buf_len. For zcrx, the PPQ page pool allocation size and the PPQ BDQ fragment geometry need to match the requested buffer size, without changing HPQ.
Make the BDQ fragment geometry per ring, then use the rendered RX queue rx_page_size when creating the PPQ page pool. The NIC still consumes the PPQ as 4 KiB fragments; a larger zcrx buffer is represented as multiple BDQ fragments belonging to one net_iov.
Fbnic also validates rx_page_size against its own queue geometry. The core validates the zcrx request and checks that the imported memory can be represented as rx_buf_len-sized DMA chunks, but fbnic still needs to make sure the PPQ retains usable depth after expanding one software buffer into multiple 4 KiB hardware fragments.
The normal open path uses the rendered per-queue rx_page_size as well. This preserves a memory-provider binding made while the netdev is down, instead of falling back to the default PPQ geometry on open.
The selftest change adds an optional iou-zcrx helper check for manual driver testing. It is not wired into the generic large-chunk test because different drivers may legitimately return different CQE boundaries.
Manual testing
==============
The fbnic QEMU model and firmware setup are described here:
https://lore.kernel.org/netdev/[email protected]/
I use something like:
KERNEL=/path/to/linux DISK=/path/to/fedora-qemu.raw OVMF_CODE=/path/to/OVMF_CODE.fd OVMF_VARS=/path/to/OVMF_VARS.fd MODS=/tmp/fbnic-modules QEMU=/path/to/fbnic-qemu/build/qemu-system-x86_64
$QEMU \
-machine type=q35,accel=kvm \
-drive if=pflash,format=raw,unit=0,file=$OVMF_CODE,readonly=on \
-drive if=pflash,format=raw,unit=1,file=$OVMF_VARS \
-smp 16 -m 16G \
-object memory-backend-memfd,id=mem,size=16G,share=on \
-numa node,memdev=mem \
-kernel $KERNEL/arch/x86/boot/bzImage \
-append "root=/dev/vda2 rw console=ttyS0 earlycon" \
-drive file=$DISK,format=raw,if=none,id=drive0 \
-device virtio-blk-pci,drive=drive0 \
-no-user-config -nodefaults -nographic \
-virtfs local,path=$MODS/lib/modules,mount_tag=modules,security_model=none,readonly=on \
-virtfs local,path=$KERNEL,mount_tag=hostshare,security_model=none,readonly=on \
-netdev user,id=hostnet0,hostfwd=tcp::9999-:9999 \
-netdev hubport,id=hub_uplink,hubid=0,netdev=hostnet0 \
-device virtio-net-pci,netdev=n1 \
-netdev hubport,id=n1,hubid=0 \
-device pcie-root-port,id=pcie.1,bus=pcie.0,chassis=1 \
-device fbnic,bus=pcie.1,id=fbnic.1,mac=00:de:ad:be:ef:01,netdev=n2,rbt=skt.0,bar4=ctrl.1 \
-netdev hubport,id=n2,hubid=0 \
-chardev socket,id=ctrl.1,path=/tmp/fbnic-ctrl-skt \
-netdev socket,id=skt.0,connect=localhost:9000 \
-serial mon:stdio Here you'll get a fbnic device, host port forwarding for TCP port 9999, and a 9p mount for the kernel tree and modules.
Inside the guest:
mount -t 9p -o trans=virtio,version=9p2000.L hostshare /host
cd /host/tools/testing/selftests/drivers/net/hw
ethtool -L enp1s0 combined 2
ethtool -G enp1s0 tcp-data-split on hds-thresh 0 rx 64 ethtool -X enp1s0 equal 1
ethtool -N enp1s0 flow-type tcp4 dst-ip 10.0.2.15 dst-port 9999 action 1
echo 64 > /proc/sys/vm/nr_hugepages
./iou-zcrx -s -i enp1s0 -p 9999 -q 1 -x 2
On the host:
cd /path/to/linux/tools/testing/selftests/drivers/net/hw ./iou-zcrx -c -h 127.0.0.1 -p 9999 -l 12840
For fbnic-specific manual checking that traffic reaches the second 4 KiB fragment of an 8 KiB zcrx buffer, run the receiver with:
./iou-zcrx -s -i enp1s0 -p 9999 -q 1 -x 2 -F 4096
Björn Töpel (3):
fbnic: Track BDQ fragment geometry per ring
fbnic: Support larger zcrx receive buffers
selftests: drv-net: Add zcrx payload offset check
drivers/net/ethernet/meta/fbnic/fbnic_csr.h | 29 +-- .../net/ethernet/meta/fbnic/fbnic_debugfs.c | 5 +- drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 168 ++++++++++++++---- drivers/net/ethernet/meta/fbnic/fbnic_txrx.h | 6 + .../selftests/drivers/net/hw/iou-zcrx.c | 28 ++- 5 files changed, 176 insertions(+), 60 deletions(-)
base-commit: 1a1f055318d82e64485a6ff8420e5f70b4267998 --
2.53.0
PATCH 1/3 fbnic: Track BDQ fragment geometry per ring
Fbnic programs BDQs in 4 KiB fragments, but the driver has so far decoded buffer IDs using PAGE_SIZE-derived constants. That works while HPQ and PPQ both use PAGE_SIZE buffers, but it makes the fragment layout global even though the layout really belongs to the queue.
Store the fragment shift on each BDQ and use it when programming buffer descriptors and decoding receive completions. HPQ and PPQ still get the same PAGE_SIZE-derived value, so this does not change behavior yet.
This prepares PPQ to use a larger io_uring zcrx buffer size without changing the HPQ layout.
--- drivers/net/ethernet/meta/fbnic/fbnic_csr.h | 29 ++------ .../net/ethernet/meta/fbnic/fbnic_debugfs.c | 5 +- drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 68 ++++++++++++------- drivers/net/ethernet/meta/fbnic/fbnic_txrx.h | 6 ++ 4 files changed, 58 insertions(+), 50 deletions(-)
drivers/net/ethernet/meta/fbnic/fbnic_csr.h +6 -23
@@ -109,17 +109,13 @@ enum {/* Rx Buffer Descriptor Format * -* The layout of this can vary depending on the page size of the system. +* Buffer descriptors describe 4 KiB BDQ fragments. A BDQ buffer may be one +* fragment, or a power-of-two number of fragments. * -* If the page size is 4K then the layout will simply consist of ID for -* the 16 most significant bits, and the lower 46 are essentially the page -* address with the lowest 12 bits being reserved 0 due to the fact that -* a page will be aligned. -* -* If the page size is larger than 4K then the lower n bits of the ID and -* page address will be reserved for the fragment ID. This fragment will -* be 4K in size and will be used to index both the DMA address and the ID -* by the same amount. +* The address field stores the 4 KiB-aligned DMA address. The ID field stores +* the software buffer ID, with the low n bits used as the fragment ID when a +* buffer spans multiple 4 KiB fragments. The driver increments both the +* address and ID by one fragment for each descriptor belonging to a buffer. */ #define FBNIC_BD_DESC_ADDR_MASK DESC_GENMASK(45, 12)#define FBNIC_BD_DESC_ID_MASK DESC_GENMASK(63, 48)
@@ -127,16 +123,6 @@ enum { (FBNIC_BD_DESC_ADDR_MASK & ~(FBNIC_BD_DESC_ADDR_MASK - 1))#define FBNIC_BD_FRAG_COUNT \ (PAGE_SIZE / FBNIC_BD_FRAG_SIZE) -#define FBNIC_BD_FRAG_ADDR_MASK \ - (FBNIC_BD_DESC_ADDR_MASK & \ - ~(FBNIC_BD_DESC_ADDR_MASK * FBNIC_BD_FRAG_COUNT)) -#define FBNIC_BD_FRAG_ID_MASK \ - (FBNIC_BD_DESC_ID_MASK & \ - ~(FBNIC_BD_DESC_ID_MASK * FBNIC_BD_FRAG_COUNT)) -#define FBNIC_BD_PAGE_ADDR_MASK \ - (FBNIC_BD_DESC_ADDR_MASK & ~FBNIC_BD_FRAG_ADDR_MASK) -#define FBNIC_BD_PAGE_ID_MASK \ - (FBNIC_BD_DESC_ID_MASK & ~FBNIC_BD_FRAG_ID_MASK)/* Rx Completion Queue Descriptors */ #define FBNIC_RCD_TYPE_MASK DESC_GENMASK(62, 61)
@@ -151,9 +137,6 @@ enum {/* Address/Length Completion Descriptors */ #define FBNIC_RCD_AL_BUFF_ID_MASK DESC_GENMASK(15, 0) -#define FBNIC_RCD_AL_BUFF_FRAG_MASK (FBNIC_BD_FRAG_COUNT - 1) -#define FBNIC_RCD_AL_BUFF_PAGE_MASK \ - (FBNIC_RCD_AL_BUFF_ID_MASK & ~FBNIC_RCD_AL_BUFF_FRAG_MASK)#define FBNIC_RCD_AL_BUFF_LEN_MASK DESC_GENMASK(28, 16)#define FBNIC_RCD_AL_BUFF_OFF_MASK DESC_GENMASK(43, 32)#define FBNIC_RCD_AL_PAGE_FIN DESC_BIT(60)
drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c +3 -2
@@ -181,8 +181,8 @@ static int fbnic_dbg_tcq_desc_seq_show(struct seq_file *s, void *v)static int fbnic_dbg_bdq_desc_seq_show (struct seq_file *s,void *v) {struct fbnic_ring *ring = s->private; +unsigned int desc_count, i;char hdr[80 ]; -int i;/* Generate header on first entry */ fbnic_dbg_ring_show (s);
@@ -197,7 +197,8 @@ static int fbnic_dbg_bdq_desc_seq_show(struct seq_file *s, void *v)return 0 ; } -for (i =0 ; i < (ring->size_mask +1 ) *FBNIC_BD_FRAG_COUNT ; i++) { + desc_count = (ring->size_mask +1 ) *fbnic_bdq_frag_count (ring); +for (i =0 ; i < desc_count; i++) {u64 bd =le64_to_cpu (ring->desc[i]); seq_printf(s, "%04x %#04llx %#014llx\n", i,
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +43 -25
158 lines not on this page · raw message
drivers/net/ethernet/meta/fbnic/fbnic_txrx.h +6 -0
@@ -121,6 +121,7 @@ struct fbnic_ring {u16 size_mask;/* Size of ring in descriptors - 1 */ u8 q_idx;/* Logical netdev ring index */ u8 flags;/* Ring flags (FBNIC_RING_F_*) */ +u8 frag_shift;/* BDQ: ilog2(buf_size / 4096) */ u32 head, tail;/* Head/Tail of ring */
@@ -162,6 +163,11 @@ struct fbnic_napi_vector {extern const struct netdev_queue_mgmt_ops fbnic_queue_mgmt_ops; +static inline u16 fbnic_bdq_frag_count (const struct fbnic_ring *bdq) +{ +return 1U << bdq->frag_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,
Signature · 1 line
2.53.0
Jakub Kicinski
maintainerRe: [PATCH net-next 1/3] fbnic: Track BDQ fragment geometry per ring
Quoted 5 lines · On Fri, 22 May 2026 13:32:20 +0200 Björn Töpel wrote:
Fbnic programs BDQs in 4 KiB fragments, but the driver has so far decoded buffer IDs using PAGE_SIZE-derived constants. That works while HPQ and PPQ both use
PAGE_SIZEbuffers, but it makes the fragment layout global even though the layout really belongs to the queue.
Quoted 7 lines
Store the fragment shift on each BDQ and use it when programming buffer descriptors and decoding receive completions. HPQ and PPQ still get the same PAGE_SIZE-derived value, so this does not change behavior yet.
This prepares PPQ to use a larger
io_uringzcrx buffer size without changing the HPQ layout.
PAGE_SIZE can be 64kB, I'd have expected the first commit to change "page size" from a compile time constant to a runtime knob.
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c static void fbnic_add_rx_frag(struct fbnic_napi_vector *nv, u64 rcd, · line 1014
Quoted 3 lines
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +2
-1-unsigned int pg_idx =FIELD_GET (FBNIC_RCD_AL_BUFF_PAGE_MASK , rcd); +struct fbnic_ring *ppq = &qt->sub1; +unsigned int pg_idx =fbnic_rcd_bdq_idx (ppq, rcd);
This patch breaks reverse xmas tree in a lot of places.
Signature · 1 line
pw-bot: cr
PATCH 2/3 fbnic: Support larger zcrx receive buffers
In reply to Björn Töpelio_uring zcrx can provide receive buffers larger than PAGE_SIZE through QCFG_RX_PAGE_SIZE. Advertise the parameter and use the configured size when creating the PPQ page pool.
The NIC still consumes PPQ buffers as 4 KiB BDQ fragments. For larger zcrx buffers, allocate the page pool with the requested order and set the PPQ fragment shift from rx_page_size, so one net_iov can cover multiple hardware fragments.
The core validates the zcrx request and checks that the imported memory can be represented as rx_buf_len-sized DMA chunks. Fbnic still has to validate the rendered queue configuration against its own BDQ
geometry: larger receive buffers consume multiple 4 KiB PPQ entries, and the PPQ must retain usable depth after that expansion.
Use the rendered per-queue rx_page_size on the normal open path as well. This preserves a memory-provider binding made while the netdev is down instead of falling back to the default PPQ geometry on open.
--- drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 102 +++++++++++++++++-- 1 file changed, 94 insertions(+), 8 deletions(-)
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +94 -8
@@ -1559,9 +1559,62 @@ void fbnic_free_napi_vectors(struct fbnic_net *fbn)fbnic_free_napi_vector (fbn, fbn->napi[i]); } +static u32 fbnic_qcfg_rx_page_size (const struct netdev_queue_config *qcfg) +{ +return qcfg->rx_page_size ?:PAGE_SIZE ; +} + +static u32 fbnic_rx_page_frag_count (u32 rx_page_size) +{ +return rx_page_size /FBNIC_BD_FRAG_SIZE ; +} + +static u8 fbnic_rx_page_frag_shift (u32 rx_page_size) +{ +return ilog2 (fbnic_rx_page_frag_count (rx_page_size)); +} + +static int fbnic_validate_rx_page_size (struct fbnic_net *fbn,u32 rx_page_size, +struct netlink_ext_ack *extack) +{ +u32 frag_count, ppq_bufs; + +if (!is_power_of_2 (rx_page_size)) { +NL_SET_ERR_MSG_MOD (extack, +"rx_page_size must be a power of 2" ); +return -EINVAL ; + } + +if (rx_page_size <PAGE_SIZE ) { +NL_SET_ERR_MSG_MOD (extack, +"rx_page_size must be at least PAGE_SIZE" ); +return -EINVAL ; + } + +if (!IS_ALIGNED (rx_page_size,FBNIC_BD_FRAG_SIZE )) { +NL_SET_ERR_MSG_MOD (extack, +"rx_page_size must be 4K aligned" ); +return -EINVAL ; + } + + frag_count =fbnic_rx_page_frag_count (rx_page_size); + ppq_bufs = fbn->ppq_size / frag_count; +/* The PPQ is sized in 4K hardware fragments, but the software ring +* has one entry per page-pool allocation. Keep at least two entries so +* empty/full ring accounting still leaves one postable buffer. +*/ +if (ppq_bufs <2 ) { +NL_SET_ERR_MSG_MOD (extack, +"rx_page_size leaves too few PPQ buffers" ); +return -EINVAL ; + } + +return 0 ; +} +static int fbnic_alloc_qt_page_pools (struct fbnic_net *fbn,struct fbnic_q_triad *qt, -unsigned int rxq_idx) +unsigned int rxq_idx,u32 rx_page_size) {struct page_pool_params pp_params = { .order =0 ,
@@ -1596,6 +1649,8 @@ fbnic_alloc_qt_page_pools(struct fbnic_net *fbn, struct fbnic_q_triad *qt, qt->sub0.page_pool = pp;if (netif_rxq_has_unreadable_mp (fbn->netdev, rxq_idx)) { + pp_params.order =ilog2 (rx_page_size) -PAGE_SHIFT ; + pp_params.max_len = rx_page_size; pp_params.flags |=PP_FLAG_ALLOW_UNREADABLE_NETMEM ; pp_params.dma_dir =DMA_FROM_DEVICE ;
@@ -2018,12 +2073,19 @@ static int fbnic_alloc_tx_qt_resources(struct fbnic_net *fbn,static int fbnic_alloc_rx_qt_resources (struct fbnic_net *fbn,struct fbnic_napi_vector *nv, -struct fbnic_q_triad *qt) +struct fbnic_q_triad *qt, +u32 rx_page_size) {struct device *dev = fbn->netdev->dev.parent;int err; - err =fbnic_alloc_qt_page_pools (fbn, qt, qt->cmpl.q_idx); + err =fbnic_validate_rx_page_size (fbn, rx_page_size,NULL ); +if (err) +return err; + + qt->sub1.frag_shift =fbnic_rx_page_frag_shift (rx_page_size); + + err =fbnic_alloc_qt_page_pools (fbn, qt, qt->cmpl.q_idx, rx_page_size);if (err)return err;
@@ -2087,7 +2149,13 @@ static int fbnic_alloc_nv_resources(struct fbnic_net *fbn,/* Allocate Rx Resources */ for (j =0 ; j < nv->rxt_count; j++, i++) { - err =fbnic_alloc_rx_qt_resources (fbn, nv, &nv->qt[i]); +struct netdev_queue_config qcfg; +u32 rx_page_size; + +netdev_queue_config (fbn->netdev, nv->qt[i].cmpl.q_idx, &qcfg); + rx_page_size =fbnic_qcfg_rx_page_size (&qcfg); + err =fbnic_alloc_rx_qt_resources (fbn, nv, &nv->qt[i], + rx_page_size);if (err) goto free_qt_resources; }
@@ -2852,9 +2920,16 @@ static int fbnic_queue_mem_alloc(struct net_device *dev,const struct fbnic_q_triad *real;struct fbnic_q_triad *qt = qmem;struct fbnic_napi_vector *nv; +u32 rx_page_size =fbnic_qcfg_rx_page_size (qcfg); +int err; -if (!netif_running (dev)) -return fbnic_alloc_qt_page_pools (fbn, qt, idx); +if (!netif_running (dev)) { + err =fbnic_validate_rx_page_size (fbn, rx_page_size,NULL ); +if (err) +return err; + +return fbnic_alloc_qt_page_pools (fbn, qt, idx, rx_page_size); + } real = container_of(fbn->rx[idx], struct fbnic_q_triad, cmpl); nv = fbn->napi[idx % fbn->num_napi];
@@ -2864,11 +2939,20 @@ static int fbnic_queue_mem_alloc(struct net_device *dev, qt->sub0.frag_shift = real->sub0.frag_shift;fbnic_ring_init (&qt->sub1, real->sub1.doorbell, real->sub1.q_idx, real->sub1.flags); - qt->sub1.frag_shift = real->sub1.frag_shift;fbnic_ring_init (&qt->cmpl, real->cmpl.doorbell, real->cmpl.q_idx, real->cmpl.flags); -return fbnic_alloc_rx_qt_resources (fbn, nv, qt); +return fbnic_alloc_rx_qt_resources (fbn, nv, qt, rx_page_size); +} + +static int fbnic_validate_qcfg (struct net_device *dev, +struct netdev_queue_config *qcfg, +struct netlink_ext_ack *extack) +{ +struct fbnic_net *fbn =netdev_priv (dev); + +return fbnic_validate_rx_page_size (fbn,fbnic_qcfg_rx_page_size (qcfg), + extack); }static void fbnic_queue_mem_free (struct net_device *dev,void *qmem)
@@ -2970,4 +3054,6 @@ const struct netdev_queue_mgmt_ops fbnic_queue_mgmt_ops = { .ndo_queue_mem_free = fbnic_queue_mem_free, .ndo_queue_start = fbnic_queue_start, .ndo_queue_stop = fbnic_queue_stop, + .ndo_validate_qcfg = fbnic_validate_qcfg, + .supported_params = QCFG_RX_PAGE_SIZE, };
Signature · 1 line
2.53.0
Jakub Kicinski
maintainerRe: [PATCH net-next 2/3] fbnic: Support larger zcrx receive buffers
Quoted 19 lines · On Fri, 22 May 2026 13:32:21 +0200 Björn Töpel wrote:
io_uringzcrx can provide receive buffers larger thanPAGE_SIZEthroughQCFG_RX_PAGE_SIZE. Advertise the parameter and use the configured size when creating the PPQ page pool.The NIC still consumes PPQ buffers as 4 KiB BDQ fragments. For larger zcrx buffers, allocate the page pool with the requested order and set the PPQ fragment shift from
rx_page_size, so onenet_iovcan cover multiple hardware fragments.The core validates the zcrx request and checks that the imported memory can be represented as rx_buf_len-sized DMA chunks. Fbnic still has to validate the rendered queue configuration against its own BDQ
geometry: larger receive buffers consume multiple 4 KiB PPQ entries, and the PPQ must retain usable depth after that expansion.Use the rendered per-queue
rx_page_sizeon the normal open path as well. This preserves a memory-provider binding made while the netdev is down instead of falling back to the default PPQ geometry on open.
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c void fbnic_free_napi_vectors(struct fbnic_net *fbn) · line 1564
Quoted 3 lines
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +3
-0+static u32 fbnic_qcfg_rx_page_size (const struct netdev_queue_config *qcfg) +{ +return qcfg->rx_page_size ?:PAGE_SIZE ;
Isn't there a callback to set the defaults so that the driver doesn't have to do this sort of stuff?
Quoted 14 lines
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +14
-0+} + +static u32 fbnic_rx_page_frag_count (u32 rx_page_size) +{ +return rx_page_size /FBNIC_BD_FRAG_SIZE ; +} + +static u8 fbnic_rx_page_frag_shift (u32 rx_page_size) +{ +return ilog2 (fbnic_rx_page_frag_count (rx_page_size)); +} + +static int fbnic_validate_rx_page_size (struct fbnic_net *fbn,u32 rx_page_size, +struct netlink_ext_ack *extack)
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c void fbnic_free_napi_vectors(struct fbnic_net *fbn) · line 1588
Quoted 10 lines
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +10
-0+{ +u32 frag_count, ppq_bufs; + +if (!is_power_of_2 (rx_page_size)) { +NL_SET_ERR_MSG_MOD (extack, +"rx_page_size must be a power of 2" ); +return -EINVAL ; + } + +if (rx_page_size <PAGE_SIZE ) {
If the PAGE_SIZE == 64kB it should be fine to have smaller frags, no? Or something breaks?
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c void fbnic_free_napi_vectors(struct fbnic_net *fbn) · line 1596
Quoted 8 lines
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +8
-0+NL_SET_ERR_MSG_MOD (extack, +"rx_page_size must be at least PAGE_SIZE" ); +return -EINVAL ; + } + +if (!IS_ALIGNED (rx_page_size,FBNIC_BD_FRAG_SIZE )) { +NL_SET_ERR_MSG_MOD (extack, +"rx_page_size must be 4K aligned" );
"multiple" is probably a better word than "aligned" for size params?
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c void fbnic_free_napi_vectors(struct fbnic_net *fbn) · line 1608
Quoted 12 lines
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +12
-0+return -EINVAL ; + } + + frag_count =fbnic_rx_page_frag_count (rx_page_size); + ppq_bufs = fbn->ppq_size / frag_count; +/* The PPQ is sized in 4K hardware fragments, but the software ring +* has one entry per page-pool allocation. Keep at least two entries so +* empty/full ring accounting still leaves one postable buffer. +*/ +if (ppq_bufs <2 ) { +NL_SET_ERR_MSG_MOD (extack, +"rx_page_size leaves too few PPQ buffers" );
Maybe "rx-jumbo ring size too small for rx_page_size" ?
Core does revalidate the config on ring size changes, right?
Quoted 60 lines
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +25
-4+return -EINVAL ; + } + +return 0 ; +} +static int fbnic_alloc_qt_page_pools (struct fbnic_net *fbn,struct fbnic_q_triad *qt, -unsigned int rxq_idx) +unsigned int rxq_idx,u32 rx_page_size) {struct page_pool_params pp_params = { .order =0 ,@@ -1596,6 +1649,8 @@ fbnic_alloc_qt_page_pools(struct fbnic_net *fbn, struct fbnic_q_triad *qt, qt->sub0.page_pool = pp;if (netif_rxq_has_unreadable_mp (fbn->netdev, rxq_idx)) { + pp_params.order =ilog2 (rx_page_size) -PAGE_SHIFT ; + pp_params.max_len = rx_page_size; pp_params.flags |=PP_FLAG_ALLOW_UNREADABLE_NETMEM ; pp_params.dma_dir =DMA_FROM_DEVICE ;@@ -2018,12 +2073,19 @@ static int fbnic_alloc_tx_qt_resources(struct fbnic_net *fbn,static int fbnic_alloc_rx_qt_resources (struct fbnic_net *fbn,struct fbnic_napi_vector *nv, -struct fbnic_q_triad *qt) +struct fbnic_q_triad *qt, +u32 rx_page_size) {struct device *dev = fbn->netdev->dev.parent;int err; - err =fbnic_alloc_qt_page_pools (fbn, qt, qt->cmpl.q_idx); + err =fbnic_validate_rx_page_size (fbn, rx_page_size,NULL ); +if (err) +return err; + + qt->sub1.frag_shift =fbnic_rx_page_frag_shift (rx_page_size); + + err =fbnic_alloc_qt_page_pools (fbn, qt, qt->cmpl.q_idx, rx_page_size);if (err)return err;@@ -2087,7 +2149,13 @@ static int fbnic_alloc_nv_resources(struct fbnic_net *fbn,/* Allocate Rx Resources */ for (j =0 ; j < nv->rxt_count; j++, i++) { - err =fbnic_alloc_rx_qt_resources (fbn, nv, &nv->qt[i]); +struct netdev_queue_config qcfg; +u32 rx_page_size; + +netdev_queue_config (fbn->netdev, nv->qt[i].cmpl.q_idx, &qcfg); + rx_page_size =fbnic_qcfg_rx_page_size (&qcfg); + err =fbnic_alloc_rx_qt_resources (fbn, nv, &nv->qt[i], + rx_page_size);if (err) goto free_qt_resources; }
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c static int fbnic_queue_mem_alloc(struct net_device *dev, · line 2927
Quoted 10 lines
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +4
-2@@ -2852,9 +2920,16 @@ static int fbnic_queue_mem_alloc(struct net_device *dev,const struct fbnic_q_triad *real;struct fbnic_q_triad *qt = qmem;struct fbnic_napi_vector *nv; +u32 rx_page_size =fbnic_qcfg_rx_page_size (qcfg); +int err; -if (!netif_running (dev)) -return fbnic_alloc_qt_page_pools (fbn, qt, idx); +if (!netif_running (dev)) { + err =fbnic_validate_rx_page_size (fbn, rx_page_size,NULL );
Hm. Is the validate callback not called in case the device is down?
Quoted 38 lines
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +18
-2+if (err) +return err; + +return fbnic_alloc_qt_page_pools (fbn, qt, idx, rx_page_size); + } real = container_of(fbn->rx[idx], struct fbnic_q_triad, cmpl); nv = fbn->napi[idx % fbn->num_napi];@@ -2864,11 +2939,20 @@ static int fbnic_queue_mem_alloc(struct net_device *dev, qt->sub0.frag_shift = real->sub0.frag_shift;fbnic_ring_init (&qt->sub1, real->sub1.doorbell, real->sub1.q_idx, real->sub1.flags); - qt->sub1.frag_shift = real->sub1.frag_shift;fbnic_ring_init (&qt->cmpl, real->cmpl.doorbell, real->cmpl.q_idx, real->cmpl.flags); -return fbnic_alloc_rx_qt_resources (fbn, nv, qt); +return fbnic_alloc_rx_qt_resources (fbn, nv, qt, rx_page_size); +} + +static int fbnic_validate_qcfg (struct net_device *dev, +struct netdev_queue_config *qcfg, +struct netlink_ext_ack *extack) +{ +struct fbnic_net *fbn =netdev_priv (dev); + +return fbnic_validate_rx_page_size (fbn,fbnic_qcfg_rx_page_size (qcfg), + extack); }static void fbnic_queue_mem_free (struct net_device *dev,void *qmem)@@ -2970,4 +3054,6 @@ const struct netdev_queue_mgmt_ops fbnic_queue_mgmt_ops = { .ndo_queue_mem_free = fbnic_queue_mem_free, .ndo_queue_start = fbnic_queue_start, .ndo_queue_stop = fbnic_queue_stop, + .ndo_validate_qcfg = fbnic_validate_qcfg, + .supported_params = QCFG_RX_PAGE_SIZE, };
PATCH 3/3 selftests: drv-net: Add zcrx payload offset check
In reply to Björn TöpelAdd an optional iou-zcrx receiver check for payload CQE offsets. With -F, the receiver fails if no zero-copy receive CQE lands at or beyond the requested offset within an rx_buf_len-sized buffer.
This is useful for manual driver testing where the driver is expected to split a larger zcrx buffer into smaller hardware receive fragments. Do not wire it into the generic large-chunk test, since different drivers may legitimately return different CQE boundaries.
--- .../selftests/drivers/net/hw/iou-zcrx.c | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-)
tools/testing/selftests/drivers/net/hw/iou-zcrx.c +25 -3
@@ -85,6 +85,8 @@ static int cfg_send_size = SEND_SIZE;static struct sockaddr_in6 cfg_addr;static unsigned int cfg_rx_buf_len;static bool cfg_dry_run; +static bool cfg_check_payload_offset, cfg_seen_payload_offset; +static unsigned int cfg_min_payload_offset;static char *payload;static void *area_ptr;
@@ -298,6 +300,13 @@ static void process_recvzc(struct io_uring *ring, struct io_uring_cqe *cqe) mask = (1ULL <<IORING_ZCRX_AREA_SHIFT ) -1 ; data = (char *)area_ptr + (rcqe->off & mask); +if (cfg_check_payload_offset) { +unsigned int rx_buf_len = cfg_rx_buf_len ?: page_size; + +if ((rcqe->off & mask) % rx_buf_len >= cfg_min_payload_offset) + cfg_seen_payload_offset = true; + } +for (i =0 ; i < n; i++) {if (*(data + i) != payload[(received + i)])error (1 ,0 ,"payload mismatch at %d" , i);
@@ -374,6 +383,9 @@ static void run_server(void)if (!stop)error (1 ,0 ,"test failed\n" ); +if (cfg_check_payload_offset && !cfg_seen_payload_offset) +error (1 ,0 ,"no payload CQE at offset >= %u\n" , + cfg_min_payload_offset); }static void run_client (void )
@@ -406,8 +418,11 @@ static void run_client(void)static void usage (const char *filepath) { -error (1 ,0 ,"Usage: %s (-4|-6) (-s|-c) -h<server_ip> -p<port> " -"-l<payload_size> -i<ifname> -q<rxq_id>" , filepath); +error (1 ,0 , +"Usage: %s (-4|-6) (-s|-c) -h<server_ip> -p<port>\n" +"\t-l<payload_size> -i<ifname> -q<rxq_id>\n" +"\t[-x<rx_buf_pages>] [-F<min_payload_offset>] [-d]\n" , + filepath); }static void parse_opts (int argc,char **argv)
@@ -425,7 +440,7 @@ static void parse_opts(int argc, char **argv)usage (argv[0 ]); cfg_payload_len = max_payload_len; -while ((c =getopt (argc, argv,"sch:p:l:i:q:o:z:x:d" )) !=-1 ) { +while ((c =getopt (argc, argv,"sch:p:l:i:q:o:z:x:F:d" )) !=-1 ) {switch (c) {case 's' :if (cfg_client)
@@ -463,6 +478,10 @@ static void parse_opts(int argc, char **argv)case 'x' : cfg_rx_buf_len = page_size *strtoul (optarg,NULL ,0 );break ; +case 'F' : + cfg_check_payload_offset = true; + cfg_min_payload_offset =strtoul (optarg,NULL ,0 ); +break ;case 'd' : cfg_dry_run = true;break ;
@@ -484,6 +503,9 @@ static void parse_opts(int argc, char **argv)if (cfg_payload_len > max_payload_len)error (1 ,0 ,"-l: payload exceeds max (%d)" , max_payload_len); +if (cfg_check_payload_offset && + cfg_min_payload_offset >= (cfg_rx_buf_len ?: page_size)) +error (1 ,0 ,"-F: offset outside rx_buf_len" ); }int main (int argc,char **argv)
Signature · 1 line
2.53.0
Jakub Kicinski
maintainerQuoted 6 lines · On Fri, 22 May 2026 13:32:19 +0200 Björn Töpel wrote:
drivers/net/ethernet/meta/fbnic/fbnic_csr.h | 29 +-- .../net/ethernet/meta/fbnic/fbnic_debugfs.c | 5 +- drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 168 ++++++++++++++---- drivers/net/ethernet/meta/fbnic/fbnic_txrx.h | 6 + .../selftests/drivers/net/hw/iou-zcrx.c | 28 ++- 5 files changed, 176 insertions(+), 60 deletions(-)
Hm. What's merging the frags? the hw will serve them back to us in 4kB chunks. Frankly the iou zc hurts me less that the fact that we run out of nr_frags in GRO :(
Hey!
Quoted 9 lines · Jakub Kicinski
Quoted 6 lines · On Fri, 22 May 2026 13:32:19 +0200 Björn Töpel wrote:
drivers/net/ethernet/meta/fbnic/fbnic_csr.h | 29 +-- .../net/ethernet/meta/fbnic/fbnic_debugfs.c | 5 +- drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 168 ++++++++++++++---- drivers/net/ethernet/meta/fbnic/fbnic_txrx.h | 6 + .../selftests/drivers/net/hw/iou-zcrx.c | 28 ++- 5 files changed, 176 insertions(+), 60 deletions(-)
Quoted 3 lines
Hm. What's merging the frags? the hw will serve them back to us in 4kB chunks. Frankly the iou zc hurts me less that the fact that we run out of
nr_fragsin GRO :(
Thanks for taking a look, Jakub!
The driver relies on the generic XDP frag coalescing (xdp_buff_add_frag()). So, adjacent 4K completions are extended into the same frag. IOW, GRO should see coalesced skb frab, rather than one graf per HW BDQ frag
I'll address all the other comments in the next rev!
Björn
Jakub Kicinski
maintainerQuoted 4 lines · On Mon, 25 May 2026 13:08:59 +0200 Björn Töpel wrote:
The driver relies on the generic XDP frag coalescing (
xdp_buff_add_frag()). So, adjacent 4K completions are extended into the same frag. IOW, GRO should see coalesced skb frab, rather than one graf per HW BDQ frag
🙂↔️️ I'm taking about coalescing across packets.
You should enable RSS-hash gated payload packing, and then we should be able to combine frags from multiple packets. But only GRO can do that safely.