Re: [PATCH net-next v3 2/6] net: bcmgenet: register xdp_rxq_info for each RX ring

Justin Chen
2026-03-19T21:18:50Z

On 3/19/26 4:53 AM, Nicolai Buchwitz wrote:
> Register an xdp_rxq_info per RX ring and associate it with the ring's
> page_pool via MEM_TYPE_PAGE_POOL. This is required infrastructure for
> XDP program execution: the XDP framework needs to know the memory model
> backing each RX queue for correct page lifecycle management.
>
> No functional change - XDP programs are not yet attached or executed.
>
> Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
> ---
> .../net/ethernet/broadcom/genet/bcmgenet.c | 22 +++++++++++++++++--
> .../net/ethernet/broadcom/genet/bcmgenet.h | 2 ++
> 2 files changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> index 7410034d9bdc..6e610e73e12f 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> @@ -2771,16 +2771,32 @@ static int bcmgenet_rx_ring_create_pool(struct bcmgenet_priv *priv,
> .offset = GENET_XDP_HEADROOM,
> .max_len = RX_BUF_LENGTH,
> };
> + int err;
>
> ring->page_pool = page_pool_create(&pp_params);
> if (IS_ERR(ring->page_pool)) {
> - int err = PTR_ERR(ring->page_pool);
> -
> + err = PTR_ERR(ring->page_pool);

This should go in the patch before this.

> ring->page_pool = NULL;
> return err;
> }
>
> + err = xdp_rxq_info_reg(&ring->xdp_rxq, priv->dev, ring->index, 0);
> + if (err)
> + goto err_free_pp;
> +
> + err = xdp_rxq_info_reg_mem_model(&ring->xdp_rxq, MEM_TYPE_PAGE_POOL,
> + ring->page_pool);
> + if (err)
> + goto err_unreg_rxq;
> +
> return 0;
> +
> +err_unreg_rxq:
> + xdp_rxq_info_unreg(&ring->xdp_rxq);
> +err_free_pp:
> + page_pool_destroy(ring->page_pool);
> + ring->page_pool = NULL;
> + return err;
> }
>
> /* Initialize a RDMA ring */
> @@ -2807,6 +2823,7 @@ static int bcmgenet_init_rx_ring(struct bcmgenet_priv *priv,
>
> ret = bcmgenet_alloc_rx_buffers(priv, ring);
> if (ret) {
> + xdp_rxq_info_unreg(&ring->xdp_rxq);
> page_pool_destroy(ring->page_pool);
> ring->page_pool = NULL;
> return ret;
> @@ -3012,6 +3029,7 @@ static void bcmgenet_destroy_rx_page_pools(struct bcmgenet_priv *priv)
> for (i = 0; i <= priv->hw_params->rx_queues; ++i) {
> ring = &priv->rx_rings[i];
> if (ring->page_pool) {
> + xdp_rxq_info_unreg(&ring->xdp_rxq);
> page_pool_destroy(ring->page_pool);
> ring->page_pool = NULL;
> }
> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h b/drivers/net/ethernet/broadcom/genet/bcmgenet.h
> index 11a0ec563a89..82a6d29f481d 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h
> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h
> @@ -16,6 +16,7 @@
> #include <linux/dim.h>
> #include <linux/ethtool.h>
> #include <net/page_pool/helpers.h>
> +#include <net/xdp.h>
>
> #include "../unimac.h"
>
> @@ -579,6 +580,7 @@ struct bcmgenet_rx_ring {
> u32 rx_max_coalesced_frames;
> u32 rx_coalesce_usecs;
> struct page_pool *page_pool;
> + struct xdp_rxq_info xdp_rxq;
> struct bcmgenet_priv *priv;
> };
>