xsk: Zero copy through page-pool memory providers
Subsystems (13)
Re: [PATCH net-next v1 11/11] eth: fbnic: Support AF_XDP page pool zero copy
In reply to Maciej FijalkowskiQuoted 13 lines · Maciej Fijalkowski
drivers/net/ethernet/meta/fbnic/fbnic_netdev.c static int fbnic_bpf(struct net_device *netdev, struct netdev_bpf *bpf) · line 552
Quoted 7 lines · Björn Töpel
drivers/net/ethernet/meta/fbnic/fbnic_netdev.c +3
-0@@ -538,6 +547,13 @@ static int fbnic_bpf(struct net_device *netdev, struct netdev_bpf *bpf) {struct bpf_prog *prog = bpf->prog, *prev_prog;struct fbnic_net *fbn =netdev_priv (netdev); +const struct xsk_rx_check *check; + +if (bpf->command ==XDP_VALIDATE_XSK_POOL ) {do you really need a separate command here? why not rely on existing
XDP_SETUP_XSK_POOL?
Quoted 2 lines
here it doesn't look like things being validated are something unique that you could not check during
XDP_SETUP_XSK_POOLandXDP_SETUP_PROG.
I'd like to keep it. XDP_SETUP_XSK_POOL means "set up driver ZC for this pool": the driver maps the UMEM and restarts its queue, and the core WARNs if it didn't map. A provider driver does neither; it only says yes or no, before the core maps and installs anything. The same question comes up on MTU and program changes of a bound device, with the new MTU or program, which XDP_SETUP_XSK_POOL can't carry. One command keeps that in one place, and v2 runs it from the core MTU path too, so a driver can't forget that case. This is only a burden for the core.
Quoted 2 lines
Overall, +400 lines for zc pp-based support...not sure what I was expecting and I know we need Tx side implementation.
fbnic had no AF_XDP at all. Of patch 11, about 120 lines are TX and 58 are docs; the rest is RX setup, refill and the checks. 08-10 add XDP redirect, netmem heads and whole buffers to fbnic, which aren't ZC-specific.
Quoted 4 lines
However, I am wondering if better example for this change set would be the driver that already supports pp *and* carries the separate ZC data path (ekhm, see ice?). Then you could show case at least in diffstat how much less work is needed for
AF_XDPsupport.
ice RX is on page pool through libeth, but ice has no queue API, and libeth can't select a provider yet; that's also why ice can't do devmem or io_uring zcrx. The provider has no unaligned mode either, which ice supports. mlx5 or gve already have page pool RX, the queue API and their own ZC path, so one of those would show the deletion with less groundwork. I can do that as a follow-up.
Björn
Re: [PATCH net-next v1 11/11] eth: fbnic: Support AF_XDP page pool zero copy
Quoted 18 lines · Björn Töpel
Quoted 13 lines · Maciej Fijalkowski
drivers/net/ethernet/meta/fbnic/fbnic_netdev.c static int fbnic_bpf(struct net_device *netdev, struct netdev_bpf *bpf) · line 552
Quoted 7 lines · Björn Töpel
drivers/net/ethernet/meta/fbnic/fbnic_netdev.c +3
-0@@ -538,6 +547,13 @@ static int fbnic_bpf(struct net_device *netdev, struct netdev_bpf *bpf) {struct bpf_prog *prog = bpf->prog, *prev_prog;struct fbnic_net *fbn =netdev_priv (netdev); +const struct xsk_rx_check *check; + +if (bpf->command ==XDP_VALIDATE_XSK_POOL ) {do you really need a separate command here? why not rely on existing
XDP_SETUP_XSK_POOL?Quoted 2 lines
here it doesn't look like things being validated are something unique that you could not check during
XDP_SETUP_XSK_POOLandXDP_SETUP_PROG.
Quoted 8 lines
I'd like to keep it.
XDP_SETUP_XSK_POOLmeans "set up driver ZC for this pool": the driver maps the UMEM and restarts its queue, and the core WARNs if it didn't map. A provider driver does neither; it only says yes or no, before the core maps and installs anything. The same question comes up on MTU and program changes of a bound device, with the new MTU or program, whichXDP_SETUP_XSK_POOLcan't carry. One command keeps that in one place, and v2 runs it from the core MTU path too, so a driver can't forget that case. This is only a burden for the core.
Thinking more about it, maybe I can drop the callback altogether, by doing what devmem, io_uring zcrx and tcp-data-split already do: the core refuses a setup that can't work, instead of asking the driver.
The driver only judges the chunk size and headroom, in ndo_validate_qcfg, which the queue API already calls when it installs the provider, with a new bit saying the buffers can't be split. A frame of up to the chunk size (minus headroom), then lands in one buffer, so the core checks the MTU itself, at bind and on MTU changes. And like tcp-data-split, a socket bound with XDP_USE_SG needs a frags XDP
program: attaching a single-buffer program fails while one is bound, and the bind fails while one is attached.
That drops XDP_VALIDATE_XSK_POOL and struct xsk_rx_check, and fbnic's MTU and program hooks with them. Not fully cooked in my head, but maybe? Wdyt?
Björn
Maciej Fijalkowski
maintainerRe: [PATCH net-next v1 11/11] eth: fbnic: Support AF_XDP page pool zero copy
Quoted 42 lines · Björn Töpel
Quoted 18 lines · Björn Töpel
Quoted 13 lines · Maciej Fijalkowski
drivers/net/ethernet/meta/fbnic/fbnic_netdev.c static int fbnic_bpf(struct net_device *netdev, struct netdev_bpf *bpf) · line 552
Quoted 7 lines · Björn Töpel
drivers/net/ethernet/meta/fbnic/fbnic_netdev.c +3
-0@@ -538,6 +547,13 @@ static int fbnic_bpf(struct net_device *netdev, struct netdev_bpf *bpf) {struct bpf_prog *prog = bpf->prog, *prev_prog;struct fbnic_net *fbn =netdev_priv (netdev); +const struct xsk_rx_check *check; + +if (bpf->command ==XDP_VALIDATE_XSK_POOL ) {do you really need a separate command here? why not rely on existing
XDP_SETUP_XSK_POOL?Quoted 2 lines
here it doesn't look like things being validated are something unique that you could not check during
XDP_SETUP_XSK_POOLandXDP_SETUP_PROG.Quoted 8 lines
I'd like to keep it.
XDP_SETUP_XSK_POOLmeans "set up driver ZC for this pool": the driver maps the UMEM and restarts its queue, and the core WARNs if it didn't map. A provider driver does neither; it only says yes or no, before the core maps and installs anything. The same question comes up on MTU and program changes of a bound device, with the new MTU or program, whichXDP_SETUP_XSK_POOLcan't carry. One command keeps that in one place, and v2 runs it from the core MTU path too, so a driver can't forget that case. This is only a burden for the core.Thinking more about it, maybe I can drop the callback altogether, by doing what devmem,
io_uringzcrx and tcp-data-split already do: the core refuses a setup that can't work, instead of asking the driver.The driver only judges the chunk size and headroom, in
ndo_validate_qcfg, which the queue API already calls when it installs the provider, with a new bit saying the buffers can't be split. A frame of up to the chunk size (minus headroom), then lands in one buffer, so the core checks the MTU itself, at bind and on MTU changes. And like tcp-data-split, a socket bound withXDP_USE_SGneeds a frags XDP
program: attaching a single-buffer program fails while one is bound, and the bind fails while one is attached.
Quoted 3 lines
That drops
XDP_VALIDATE_XSK_POOLand structxsk_rx_check, and fbnic's MTU and program hooks with them. Not fully cooked in my head, but maybe? Wdyt?
Would be nice, what I meant mostly was that a single driver can't do both 'legacy' ZC and new-age provider based xsk at the same time, so let us have a single vehicle down to drivers, adjusted to both needs?
Quoted 4 lines
Björn
Re: [PATCH net-next v1 11/11] eth: fbnic: Support AF_XDP page pool zero copy
Quoted 43 lines · Maciej Fijalkowski
Quoted 42 lines · Björn Töpel
Quoted 18 lines · Björn Töpel
Quoted 13 lines · Maciej Fijalkowski
drivers/net/ethernet/meta/fbnic/fbnic_netdev.c static int fbnic_bpf(struct net_device *netdev, struct netdev_bpf *bpf) · line 552
Quoted 7 lines · Björn Töpel
drivers/net/ethernet/meta/fbnic/fbnic_netdev.c +3
-0@@ -538,6 +547,13 @@ static int fbnic_bpf(struct net_device *netdev, struct netdev_bpf *bpf) {struct bpf_prog *prog = bpf->prog, *prev_prog;struct fbnic_net *fbn =netdev_priv (netdev); +const struct xsk_rx_check *check; + +if (bpf->command ==XDP_VALIDATE_XSK_POOL ) {do you really need a separate command here? why not rely on existing
XDP_SETUP_XSK_POOL?Quoted 2 lines
here it doesn't look like things being validated are something unique that you could not check during
XDP_SETUP_XSK_POOLandXDP_SETUP_PROG.Quoted 8 lines
I'd like to keep it.
XDP_SETUP_XSK_POOLmeans "set up driver ZC for this pool": the driver maps the UMEM and restarts its queue, and the core WARNs if it didn't map. A provider driver does neither; it only says yes or no, before the core maps and installs anything. The same question comes up on MTU and program changes of a bound device, with the new MTU or program, whichXDP_SETUP_XSK_POOLcan't carry. One command keeps that in one place, and v2 runs it from the core MTU path too, so a driver can't forget that case. This is only a burden for the core.Thinking more about it, maybe I can drop the callback altogether, by doing what devmem,
io_uringzcrx and tcp-data-split already do: the core refuses a setup that can't work, instead of asking the driver.The driver only judges the chunk size and headroom, in
ndo_validate_qcfg, which the queue API already calls when it installs the provider, with a new bit saying the buffers can't be split. A frame of up to the chunk size (minus headroom), then lands in one buffer, so the core checks the MTU itself, at bind and on MTU changes. And like tcp-data-split, a socket bound withXDP_USE_SGneeds a frags XDP
program: attaching a single-buffer program fails while one is bound, and the bind fails while one is attached.
Quoted 7 lines
Quoted 3 lines
That drops
XDP_VALIDATE_XSK_POOLand structxsk_rx_check, and fbnic's MTU and program hooks with them. Not fully cooked in my head, but maybe? Wdyt?Would be nice, what I meant mostly was that a single driver can't do both 'legacy' ZC and new-age provider based xsk at the same time, so let us have a single vehicle down to drivers, adjusted to both needs?
With the callback gone, a provider driver doesn't get an XSK command at all. It sees a queue restart with the provider's parameters, the vehicle devmem and io_uring zcrx already use, and opts in with xsk_page_pool in its queue ops. Driver ZC keeps XDP_SETUP_XSK_POOL. So each driver has one vehicle, and the provider's isn't XSK-specific. What's left of XSK in a provider driver is TX, which finds the pool with xsk_rxq_pool().
Does that cover it? I'll try to get that working in v2.
Björn
Re: [PATCH net-next v1 11/11] eth: fbnic: Support AF_XDP page pool zero copy
In reply to Björn TöpelQuoted 7 lines · Björn Töpel
Header and payload rings share one provider page pool, so refills even them out, and a short pool does not starve one of them. Payload buffers start at chunk offset 0, and the UMEM headroom rules require headroom only in the first buffer. A chunk is one 4 KiB device page, also with larger kernel pages, so rings fed by the provider post one descriptor per chunk.
[...]
Quoted 14 lines
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +4
-1qt->sub0.page_pool = pp; +fbnic_bdq_set_page_size (&qt->sub0, xsk ? rx_page_size :PAGE_SIZE ); qt->hdr_max =0 ;if (!page_pool_supports_frag (pp)) - qt->hdr_max =fbnic_whole_hdr_max (FBNIC_RX_HROOM ); + qt->hdr_max =fbnic_whole_hdr_max (qt->rx_hroom);if (netif_rxq_has_unreadable_mp (fbn->netdev, rxq_idx)) { pp_params.order =get_order (rx_page_size); pp_params.max_len = rx_page_size; pp_params.flags |=PP_FLAG_ALLOW_UNREADABLE_NETMEM ; pp_params.dma_dir =DMA_FROM_DEVICE ; + pp =page_pool_create (&pp_params); +if (IS_ERR (pp))
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c fbnic_alloc_qt_page_pools(struct fbnic_net *fbn, struct fbnic_q_triad *qt, · line 1965
Quoted 10 lines
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +7
-0+ goto err_destroy_sub0; + }else if (xsk && !xsk_pool_uses_sg (xsk)) { + pp_params.flags &= ~PP_FLAG_MEM_PROVIDER ; + pp_params.rx_roles =0 ; + pp_params.max_len =PAGE_SIZE ; + rx_page_size =PAGE_SIZE ; + pp =page_pool_create (&pp_params);if (IS_ERR (pp)) goto err_destroy_sub0;
Maybe I'm misunderstanding, but why is it necessary to create a new page pool for sub1 if !sg? All frames should be sent to sub0, and the buffers in sub1 should sit idle.
Quoted 250 lines
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +35
-29@@ -1709,6 +1967,7 @@ fbnic_alloc_qt_page_pools(struct fbnic_net *fbn, struct fbnic_q_triad *qt,page_pool_get (pp); } qt->sub1.page_pool = pp; +fbnic_bdq_set_page_size (&qt->sub1, rx_page_size);return 0 ;@@ -1717,16 +1976,6 @@ fbnic_alloc_qt_page_pools(struct fbnic_net *fbn, struct fbnic_q_triad *qt,return PTR_ERR (pp); } -static u8 fbnic_bdq_page_shift (u32 page_size) -{ -return ilog2 (page_size /FBNIC_BD_PAGE_SIZE ); -} - -static void fbnic_bdq_set_page_size (struct fbnic_ring *bdq,u32 page_size) -{ - bdq->bd_page_shift =fbnic_bdq_page_shift (page_size); -} -static void fbnic_ring_init (struct fbnic_ring *ring,u32 __iomem *doorbell,int q_idx,u8 flags) {@@ -1830,7 +2079,8 @@ static int fbnic_alloc_napi_vector(struct fbnic_dev *fbd, struct fbnic_net *fbn,if (xdp_count >0 ) {unsigned int xdp_idx =FBNIC_MAX_TXQS + rxq_idx; -fbnic_ring_init (&qt->sub1, db, xdp_idx, flags); +fbnic_ring_init (&qt->sub1, db, xdp_idx, + flags |FBNIC_RING_F_XDP ); fbn->tx[xdp_idx] = &qt->sub1; xdp_count--; }else {@@ -1977,6 +2227,9 @@ static int fbnic_alloc_tx_ring_buffer(struct fbnic_ring *txr) {size_t size =array_size (sizeof (*txr->tx_buf), txr->size_mask +1 ); +if (txr->flags &FBNIC_RING_F_XDP ) + size =array_size (sizeof (*txr->xdp_buf), txr->size_mask +1 ); + txr->tx_buf =kvzalloc (size,GFP_KERNEL | __GFP_NOWARN);return txr->tx_buf ?0 : -ENOMEM ;@@ -2126,20 +2379,19 @@ static int fbnic_alloc_tx_qt_resources(struct fbnic_net *fbn,return err; } -static int fbnic_alloc_rx_qt_resources (struct fbnic_net *fbn, -struct fbnic_napi_vector *nv, -struct fbnic_q_triad *qt, -u32 rx_page_size) +static int +fbnic_alloc_rx_qt_resources (struct fbnic_net *fbn, +struct fbnic_napi_vector *nv, +struct fbnic_q_triad *qt, +const struct netdev_queue_config *qcfg) {struct device *dev = fbn->netdev->dev.parent;int err; - err =fbnic_alloc_qt_page_pools (fbn, qt, qt->cmpl.q_idx, rx_page_size); + err =fbnic_alloc_qt_page_pools (fbn, qt, qt->cmpl.q_idx, qcfg);if (err)return err; -fbnic_bdq_set_page_size (&qt->sub1, rx_page_size); - err =xdp_rxq_info_reg (&qt->xdp_rxq, fbn->netdev, qt->cmpl.q_idx, nv->napi.napi_id);if (err)@@ -2203,8 +2455,7 @@ static int fbnic_alloc_nv_resources(struct fbnic_net *fbn,struct netdev_queue_config qcfg;netdev_queue_config (fbn->netdev, nv->qt[i].cmpl.q_idx, &qcfg); - err =fbnic_alloc_rx_qt_resources (fbn, nv, &nv->qt[i], - qcfg.rx_page_size); + err =fbnic_alloc_rx_qt_resources (fbn, nv, &nv->qt[i], &qcfg);if (err) goto free_qt_resources; }@@ -2598,9 +2849,8 @@ static void fbnic_nv_fill(struct fbnic_napi_vector *nv)for (j =0 , t = nv->txt_count; j < nv->rxt_count; j++, t++) {struct fbnic_q_triad *qt = &nv->qt[t]; -/* Populate the header and payload BDQs */ -fbnic_fill_bdq (&qt->sub0); -fbnic_fill_bdq (&qt->sub1); +/* Populate the header and payload BDQs; NAPI retries */ +fbnic_fill_bdqs (qt); } }@@ -2736,14 +2986,20 @@ static void fbnic_config_drop_mode_rcq(struct fbnic_napi_vector *nv, struct fbnic_ring *rcq, bool tx_pause, bool hdr_split) { + struct fbnic_q_triad *qt = container_of_const(rcq, struct fbnic_q_triad, + cmpl);struct fbnic_net *fbn =netdev_priv (nv->napi.dev); -u32 drop_mode, rcq_ctl; +u32 drop_mode, hroom, rcq_ctl; + +/* The device aligns the maximum value up to FBNIC_RX_HROOM_MAX. */ + hroom =min_t (u32, qt->rx_hroom, +FIELD_MAX (FBNIC_QUEUE_RDE_CTL0_MIN_HROOM_MASK )); drop_mode =fbnic_drop_mode (fbn, tx_pause);/* Specify packet layout */ rcq_ctl =FIELD_PREP (FBNIC_QUEUE_RDE_CTL0_DROP_MODE_MASK , drop_mode) | -FIELD_PREP (FBNIC_QUEUE_RDE_CTL0_MIN_HROOM_MASK ,FBNIC_RX_HROOM ) | +FIELD_PREP (FBNIC_QUEUE_RDE_CTL0_MIN_HROOM_MASK , hroom) |FIELD_PREP (FBNIC_QUEUE_RDE_CTL0_MIN_TROOM_MASK ,FBNIC_RX_TROOM ) |FIELD_PREP (FBNIC_QUEUE_RDE_CTL0_EN_HDR_SPLIT , hdr_split);@@ -3028,8 +3284,7 @@ static int fbnic_queue_mem_alloc(struct net_device *dev,struct fbnic_napi_vector *nv;if (!netif_running (dev)) -return fbnic_alloc_qt_page_pools (fbn, qt, idx, - qcfg->rx_page_size); +return fbnic_alloc_qt_page_pools (fbn, qt, idx, qcfg);/* A failed PCIe recovery or resume can leave the datapath torn down * while netif_running() is still true. This ndo runs before @@ -3049,7 +3304,7 @@ static int fbnic_queue_mem_alloc(struct net_device *dev,fbnic_ring_init (&qt->cmpl, real->cmpl.doorbell, real->cmpl.q_idx, real->cmpl.flags); -return fbnic_alloc_rx_qt_resources (fbn, nv, qt, qcfg->rx_page_size); +return fbnic_alloc_rx_qt_resources (fbn, nv, qt, qcfg); } static void fbnic_default_qcfg(struct net_device *dev,@@ -3086,6 +3341,14 @@ static int fbnic_validate_qcfg(struct net_device *dev,return -EINVAL ; } +if (qcfg->rx_headroom && + (qcfg->rx_headroom <XDP_PACKET_HEADROOM || + qcfg->rx_headroom >FBNIC_RX_HROOM_MAX || + !IS_ALIGNED (qcfg->rx_headroom,FBNIC_RX_HDR_ALIGN ))) { +NL_SET_ERR_MSG_MOD (extack,"rx_headroom is not supported" ); +return -EINVAL ; + } +/* Payload fragments occupy multiples of FBNIC_RX_PAYLD_ALIGN bytes. * Keep at least one reference in the bias until fbnic_clean_bdq() * observes a completion from a subsequent allocation. @@ -3216,5 +3479,6 @@ const struct netdev_queue_mgmt_ops fbnic_queue_mgmt_ops = { .ndo_queue_stop = fbnic_queue_stop, .ndo_default_qcfg = fbnic_default_qcfg, .ndo_validate_qcfg = fbnic_validate_qcfg, - .supported_params = QCFG_RX_PAGE_SIZE, + .supported_params = QCFG_RX_PAGE_SIZE | QCFG_RX_HEADROOM, + .xsk_page_pool = true, };drivers/net/ethernet/meta/fbnic/fbnic_txrx.h +24
-1@@ -14,7 +14,11 @@#include "fbnic_csr.h" +struct bpf_prog ;struct fbnic_net ; +struct netlink_ext_ack ; +struct xsk_buff_pool ; +struct xsk_rx_check ;/* Guarantee we have space needed for storing the buffer * To store the buffer we need: @@ -36,6 +40,8 @@ struct fbnic_net;*/ #define FBNIC_MAX_RX_PKT_DESC 7#define FBNIC_RX_DESC_MIN roundup_pow_of_two(FBNIC_MAX_RX_PKT_DESC * 2) +/* All descriptors of a packet but the two metadata ones */ +#define FBNIC_MAX_RX_BUFS (FBNIC_MAX_RX_PKT_DESC - 2)#define FBNIC_MAX_TXQS 128u#define FBNIC_MAX_RXQS 128u@@ -66,6 +72,9 @@ struct fbnic_net; (ALIGN(FBNIC_RX_TROOM + FBNIC_RX_HROOM_PAD, 128) - FBNIC_RX_TROOM)#define FBNIC_RX_PAD 0#define FBNIC_RX_HDR_ALIGN 128 +#define FBNIC_RX_HROOM_MAX \ + ALIGN(FIELD_MAX(FBNIC_QUEUE_RDE_CTL0_MIN_HROOM_MASK), \ + FBNIC_RX_HDR_ALIGN)#define FBNIC_RX_PAYLD_ALIGN 128#define FBNIC_RX_PAYLD_OFFSET 0#define FBNIC_RX_PAYLD_PG_CL 0@@ -73,6 +82,7 @@ struct fbnic_net;#define FBNIC_RING_F_DISABLED BIT(0)#define FBNIC_RING_F_CTX BIT(1)#define FBNIC_RING_F_STATS BIT(2)/* Ring's stats may be used */ +#define FBNIC_RING_F_XDP BIT(3)/* XDP TX ring */ #define FBNIC_HDS_THRESH_MAX \ (4096 - FBNIC_RX_HROOM - FBNIC_RX_TROOM - FBNIC_RX_PAD)@@ -121,12 +131,18 @@ struct fbnic_rx_buf {long pagecnt_bias; }; +/* XDP TX ring entry: an XDP_TX buffer, or an AF_XDP TX descriptor */ +struct fbnic_xdp_tx_buf { +netmem_ref netmem; +struct xsk_buff_pool *xsk; +}; +struct fbnic_ring {/* Pointer to buffer specific info */ union {struct fbnic_pkt_buff *pkt;/* RCQ */ struct fbnic_rx_buf *rx_buf;/* BDQ */ -netmem_ref *tx_netmem;/* TWQ1 */ +struct fbnic_xdp_tx_buf *xdp_buf;/* TWQ1 */ void **tx_buf;/* TWQ */ void *buffer;/* Generic pointer */ };@@ -167,6 +183,10 @@ struct fbnic_q_triad {struct fbnic_ring sub0, sub1, cmpl;struct xdp_rxq_info xdp_rxq;u16 hdr_max;/* Header bytes for whole header buffers, or 0 */ +u16 rx_hroom;/* Headroom before a header */ +u16 rx_hdr_first;/* Offset of the first header in a buffer */ +u16 rx_frame_off;/* Offset of the frame in a header buffer */ +struct xsk_buff_pool *xsk_pool;/* AF_XDP pool of an RX queue */ };struct fbnic_napi_vector {@@ -178,6 +198,7 @@ struct fbnic_napi_vector {u16 v_idx;u8 txt_count;u8 rxt_count; +u8 xsk_tx_next;/* RX queue that sends socket TX first */ struct fbnic_q_triad qt[]; };@@ -203,6 +224,8 @@ void fbnic_aggregate_ring_tx_counters(struct fbnic_net *fbn,void fbnic_aggregate_ring_xdp_counters (struct fbnic_net *fbn,struct fbnic_ring *xdpr); +int fbnic_xsk_validate (const struct xsk_rx_check *check, +struct bpf_prog *prog,struct netlink_ext_ack *extack);int fbnic_alloc_napi_vectors (struct fbnic_net *fbn);void fbnic_free_napi_vectors (struct fbnic_net *fbn);int fbnic_alloc_resources (struct fbnic_net *fbn);
Re: [PATCH net-next v1 11/11] eth: fbnic: Support AF_XDP page pool zero copy
Quoted 21 lines · Dimitri Daskalakis
Quoted 7 lines · Björn Töpel
Header and payload rings share one provider page pool, so refills even them out, and a short pool does not starve one of them. Payload buffers start at chunk offset 0, and the UMEM headroom rules require headroom only in the first buffer. A chunk is one 4 KiB device page, also with larger kernel pages, so rings fed by the provider post one descriptor per chunk.
[...]
Quoted 12 lines
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +2
-1qt->sub0.page_pool = pp; +fbnic_bdq_set_page_size (&qt->sub0, xsk ? rx_page_size :PAGE_SIZE ); qt->hdr_max =0 ;if (!page_pool_supports_frag (pp)) - qt->hdr_max =fbnic_whole_hdr_max (FBNIC_RX_HROOM ); + qt->hdr_max =fbnic_whole_hdr_max (qt->rx_hroom);if (netif_rxq_has_unreadable_mp (fbn->netdev, rxq_idx)) { pp_params.order =get_order (rx_page_size); pp_params.max_len = rx_page_size; pp_params.flags |=PP_FLAG_ALLOW_UNREADABLE_NETMEM ; pp_params.dma_dir =DMA_FROM_DEVICE ;
Quoted 15 lines
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c fbnic_alloc_qt_page_pools(struct fbnic_net *fbn, struct fbnic_q_triad *qt, · line 1965
Quoted 12 lines
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +9
-0+ pp =page_pool_create (&pp_params); +if (IS_ERR (pp)) + goto err_destroy_sub0; + }else if (xsk && !xsk_pool_uses_sg (xsk)) { + pp_params.flags &= ~PP_FLAG_MEM_PROVIDER ; + pp_params.rx_roles =0 ; + pp_params.max_len =PAGE_SIZE ; + rx_page_size =PAGE_SIZE ; + pp =page_pool_create (&pp_params);if (IS_ERR (pp)) goto err_destroy_sub0;Maybe I'm misunderstanding, but why is it necessary to create a new page pool for sub1 if !sg? All frames should be sent to sub0, and the buffers in sub1 should sit idle.
(BTW, the reply to your other mail didn't show up on lore for some reason, but I hope you got it! If not, holler!)
You're right, it is not needed. I'll fix this in the next version. Every frame fits in one chunk on the header ring, and the device drops bigger frames. With SG, both rings share one pool.
I first tried sharing the pool for non-SG too. But then up to 255 chunks sit unused in the payload ring :P
Björn
Jakub Kicinski
maintainerQuoted 2 lines · On Tue, 10 Nov 2026 11:20:21 +0100 Björn Töpel wrote:
38 files changed, 2159 insertions(+), 225 deletions(-) create mode 100644 net/xdp/xsk_pp.c
This is much larger than I expected, and doesn't seem to be a natural extension of memory providers. For reference - did you vibe code fbnic AF_XDP support without this set? What's the LoC?
Quoted 10 lines · Björn Töpel
Hi!
AF_XDPzero copy needs a second RX allocator in every driver. This series makes UMEM a page-pool memory provider instead: apage_pooldriver opts in, and keeps its refill, recycling and DMA sync code. fbnic is the first user. Patches 1-7 are core, 8-11 fbnic.Since the RFC [RFC],
net_iovis a first class netmem, the core ownsAF_XDPsetup, and a refill contract replaces the NAPI kicks. The fixes are out.
Hey,
Thanks for all the input!
TL;DR for new readers: Too much churn, especially on the driver side. net_iov was not intended to be readable from the core side of things.
The net_iov part needs some deeper thinking. UMEM memory is readable (the kernel can read the memory), but needs a non-page refcounting, and benefits from the rx_buf_len (larger chunks). iouring TCP ZC frags are also readable, and the kernel does read from it from time to time, but it still unreadable. I have some ideas how to fit UMEM to the puzzle. :-)
I'm working on a v2, but it'll have a different take than this version, to try to reduce the amount of driver churn. It'll probably be an RFC or a brand new v1. I'll try to address all input from this design.
Cheers, and thanks all!
Björn