Re: [PATCH net-next] net: lan966x: Don't use xdp_frame when action is XDP_TX

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Horatiu Vultur <horatiu.vultur@xxxxxxxxxxxxx>
Date: Thu, 20 Apr 2023 14:11:52 +0200

> When the action of an xdp program was XDP_TX, lan966x was creating
> a xdp_frame and use this one to send the frame back. But it is also
> possible to send back the frame without needing a xdp_frame, because
> it possible to send it back using the page.
> And then once the frame is transmitted is possible to use directly
> page_pool_recycle_direct as lan966x is using page pools.
> This would save some CPU usage on this path.
> 
> Signed-off-by: Horatiu Vultur <horatiu.vultur@xxxxxxxxxxxxx>

[...]

> @@ -702,6 +704,7 @@ static void lan966x_fdma_tx_start(struct lan966x_tx *tx, int next_to_use)
>  int lan966x_fdma_xmit_xdpf(struct lan966x_port *port,
>  			   struct xdp_frame *xdpf,
>  			   struct page *page,
> +			   u32 len,
>  			   bool dma_map)

I think you can cut the number of arguments by almost a half:

int lan966x_fdma_xmit_xdpf(struct lan966x_port *port,
			   void *ptr, u32 len)
{
	if (len) {
		/* XDP_TX, ptr is page */
		page = ptr;

		dma_sync_here(page, len);
	} else {
		/* XDP_REDIR, ptr is xdp_frame */
		xdpf = ptr;

		dma_map_here(xdpf->data, xdpf->len);
	}

@page and @xdpf are mutually exclusive. When @xdpf is non-null, @len is
excessive (xdpf->len is here), so you can use @len as logical
`len * !dma_map`, i.e. zero for REDIR and the actual frame length for TX.

I generally enjoy seeing how you constantly improve stuff in your driver :)

>  {
>  	struct lan966x *lan966x = port->lan966x;
> @@ -722,6 +725,15 @@ int lan966x_fdma_xmit_xdpf(struct lan966x_port *port,
>  		goto out;
>  	}
[...]

Thanks,
Olek



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux