public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: Daniel Machon <daniel.machon@microchip.com>,
	Horatiu Vultur <horatiu.vultur@microchip.com>,
	UNGLinuxDriver@microchip.com,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	bpf@vger.kernel.org
Subject: Re: [PATCH net-next 04/12] net: lan966x: use the FDMA library for allocation of rx buffers
Date: Tue, 10 Sep 2024 11:15:44 +0200	[thread overview]
Message-ID: <f8b58d30-cd45-4cb6-b6ca-ac076f072688@redhat.com> (raw)
In-Reply-To: <20240905-fdma-lan966x-v1-4-e083f8620165@microchip.com>

On 9/5/24 10:06, Daniel Machon wrote:
> Use the two functions: fdma_alloc_phys() and fdma_dcb_init() for rx
> buffer allocation and use the new buffers throughout.
> 
> In order to replace the old buffers with the new ones, we have to do the
> following refactoring:
> 
>      - use fdma_alloc_phys() and fdma_dcb_init()
> 
>      - replace the variables: rx->dma, rx->dcbs and rx->last_entry
>        with the equivalents from the FDMA struct.
> 
>      - make use of fdma->db_size for rx buffer size.
> 
>      - add lan966x_fdma_rx_dataptr_cb callback for obtaining the dataptr.
> 
>      - Initialize FDMA struct values.
> 
> Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
> Reviewed-by: Horatiu Vultur <horatiu.vultur@microchip.com>
> ---
>   .../net/ethernet/microchip/lan966x/lan966x_fdma.c  | 116 ++++++++++-----------
>   .../net/ethernet/microchip/lan966x/lan966x_main.h  |  15 ---
>   2 files changed, 55 insertions(+), 76 deletions(-)
> 
> diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c
> index b64f04ff99a8..99d09c97737e 100644
> --- a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c
> +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c
> @@ -6,13 +6,30 @@
>   
>   #include "lan966x_main.h"
>   
> +static int lan966x_fdma_rx_dataptr_cb(struct fdma *fdma, int dcb, int db,
> +				      u64 *dataptr)
> +{
> +	struct lan966x *lan966x = (struct lan966x *)fdma->priv;
> +	struct lan966x_rx *rx = &lan966x->rx;
> +	struct page *page;
> +
> +	page = page_pool_dev_alloc_pages(rx->page_pool);
> +	if (unlikely(!page))
> +		return -ENOMEM;
> +
> +	rx->page[dcb][db] = page;
> +	*dataptr = page_pool_get_dma_addr(page) + XDP_PACKET_HEADROOM;
> +
> +	return 0;
> +}

Very nice cleanup indeed!

Out of ENOMEM I can't recall if the following was already discussed, but 
looking at this cb, I'm wondering if a possible follow-up could replace 
the dataptr_cb() and nextptr_cb() with lib functions i.e. operating on 
page pool or doing netdev allocations according to some fdma lib flags.

Cheers,

Paolo


  reply	other threads:[~2024-09-10  9:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-05  8:06 [PATCH net-next 00/12] net: lan966x: use the newly introduced FDMA library Daniel Machon
2024-09-05  8:06 ` [PATCH net-next 01/12] net: lan966x: select " Daniel Machon
2024-09-05  8:06 ` [PATCH net-next 02/12] net: lan966x: use FDMA library symbols Daniel Machon
2024-09-05  8:06 ` [PATCH net-next 03/12] net: lan966x: replace a few variables with new equivalent ones Daniel Machon
2024-09-05  8:06 ` [PATCH net-next 04/12] net: lan966x: use the FDMA library for allocation of rx buffers Daniel Machon
2024-09-10  9:15   ` Paolo Abeni [this message]
2024-09-10  9:42     ` Daniel Machon
2024-09-05  8:06 ` [PATCH net-next 05/12] net: lan966x: use FDMA library for adding DCB's in the rx path Daniel Machon
2024-09-05  8:06 ` [PATCH net-next 06/12] net: lan966x: use library helper for freeing rx buffers Daniel Machon
2024-09-05  8:06 ` [PATCH net-next 07/12] net: lan966x: use the FDMA library for allocation of tx buffers Daniel Machon
2024-09-05  8:06 ` [PATCH net-next 08/12] net: lan966x: use FDMA library for adding DCB's in the tx path Daniel Machon
2024-09-05  8:06 ` [PATCH net-next 09/12] net: lan966x: use library helper for freeing tx buffers Daniel Machon
2024-09-05  8:06 ` [PATCH net-next 10/12] net: lan966x: ditch tx->last_in_use variable Daniel Machon
2024-09-05  8:06 ` [PATCH net-next 11/12] net: lan966x: use a few FDMA helpers throughout Daniel Machon
2024-09-05  8:06 ` [PATCH net-next 12/12] net: lan966x: refactor buffer reload function Daniel Machon
2024-09-10  9:20 ` [PATCH net-next 00/12] net: lan966x: use the newly introduced FDMA library patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f8b58d30-cd45-4cb6-b6ca-ac076f072688@redhat.com \
    --to=pabeni@redhat.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel.machon@microchip.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hawk@kernel.org \
    --cc=horatiu.vultur@microchip.com \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox