> -----Original Message-----
> From: LKML haiyangz <[email protected]> On Behalf Of Haiyang Zhang
> Sent: Tuesday, March 25, 2025 9:33 AM
> To: [email protected]; [email protected]
> Cc: Haiyang Zhang <[email protected]>; Dexuan Cui
> <[email protected]>; [email protected]; KY Srinivasan
> <[email protected]>; Paul Rosswurm <[email protected]>;
> [email protected]; vkuznets <[email protected]>; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; Long Li <[email protected]>;
> [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected];
> [email protected]; [email protected]; [email protected]
> Subject: [PATCH net,v2] net: mana: Switch to page pool for jumbo frames
> 
> Frag allocators, such as netdev_alloc_frag(), were not designed to work for
> fragsz > PAGE_SIZE.
> 
> So, switch to page pool for jumbo frames instead of using page frag 
> allocators.
> This driver is using page pool for smaller MTUs already.
> 
> Cc: [email protected]
> Fixes: 80f6215b450e ("net: mana: Add support for jumbo frame")
> Signed-off-by: Haiyang Zhang <[email protected]>
> ---
> v2: updated the commit msg as suggested by Jakub Kicinski.
> 
> ---
>  drivers/net/ethernet/microsoft/mana/mana_en.c | 46 ++++---------------
>  1 file changed, 9 insertions(+), 37 deletions(-)
> 
> diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c
> b/drivers/net/ethernet/microsoft/mana/mana_en.c
> index 9a8171f099b6..4d41f4cca3d8 100644
> --- a/drivers/net/ethernet/microsoft/mana/mana_en.c
> +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
> @@ -661,30 +661,16 @@ int mana_pre_alloc_rxbufs(struct mana_port_context
> *mpc, int new_mtu, int num_qu
>       mpc->rxbpre_total = 0;
> 
>       for (i = 0; i < num_rxb; i++) {
> -             if (mpc->rxbpre_alloc_size > PAGE_SIZE) {
> -                     va = netdev_alloc_frag(mpc->rxbpre_alloc_size);
> -                     if (!va)
> -                             goto error;
> -
> -                     page = virt_to_head_page(va);
> -                     /* Check if the frag falls back to single page */
> -                     if (compound_order(page) <
> -                         get_order(mpc->rxbpre_alloc_size)) {
> -                             put_page(page);
> -                             goto error;
> -                     }
> -             } else {
> -                     page = dev_alloc_page();
> -                     if (!page)
> -                             goto error;
> +             page = dev_alloc_pages(get_order(mpc->rxbpre_alloc_size));
> +             if (!page)
> +                     goto error;
> 
> -                     va = page_to_virt(page);
> -             }
> +             va = page_to_virt(page);
> 
>               da = dma_map_single(dev, va + mpc->rxbpre_headroom,
>                                   mpc->rxbpre_datasize, DMA_FROM_DEVICE);
>               if (dma_mapping_error(dev, da)) {
> -                     put_page(virt_to_head_page(va));
> +                     put_page(page);

Should we use __free_pages()?


Reply via email to