public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 1/1] ice: xsk: do not use xdp_return_frame() on tx_buf->raw_buf
@ 2022-12-20 17:54 Tony Nguyen
  2022-12-21  8:09 ` Piotr Raczynski
  2022-12-22  1:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Tony Nguyen @ 2022-12-20 17:54 UTC (permalink / raw)
  To: davem, kuba, pabeni, edumazet
  Cc: Maciej Fijalkowski, netdev, anthony.l.nguyen, magnus.karlsson,
	ast, daniel, hawk, john.fastabend, bpf, Robin Cowley,
	Chandan Kumar Rout

From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>

Previously ice XDP xmit routine was changed in a way that it avoids
xdp_buff->xdp_frame conversion as it is simply not needed for handling
XDP_TX action and what is more it saves us CPU cycles. This routine is
re-used on ZC driver to handle XDP_TX action.

Although for XDP_TX on Rx ZC xdp_buff that comes from xsk_buff_pool is
converted to xdp_frame, xdp_frame itself is not stored inside
ice_tx_buf, we only store raw data pointer. Casting this pointer to
xdp_frame and calling against it xdp_return_frame in
ice_clean_xdp_tx_buf() results in undefined behavior.

To fix this, simply call page_frag_free() on tx_buf->raw_buf.
Later intention is to remove the buff->frame conversion in order to
simplify the codebase and improve XDP_TX performance on ZC.

Fixes: 126cdfe1007a ("ice: xsk: Improve AF_XDP ZC Tx and use batching API")
Reported-and-tested-by: Robin Cowley <robin.cowley@thehutgroup.com>
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Tested-by: Chandan Kumar Rout <chandanx.rout@intel.com> (A Contingent Worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_xsk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/ethernet/intel/ice/ice_xsk.c
index 907055b77af0..7105de6fb344 100644
--- a/drivers/net/ethernet/intel/ice/ice_xsk.c
+++ b/drivers/net/ethernet/intel/ice/ice_xsk.c
@@ -783,7 +783,7 @@ int ice_clean_rx_irq_zc(struct ice_rx_ring *rx_ring, int budget)
 static void
 ice_clean_xdp_tx_buf(struct ice_tx_ring *xdp_ring, struct ice_tx_buf *tx_buf)
 {
-	xdp_return_frame((struct xdp_frame *)tx_buf->raw_buf);
+	page_frag_free(tx_buf->raw_buf);
 	xdp_ring->xdp_tx_active--;
 	dma_unmap_single(xdp_ring->dev, dma_unmap_addr(tx_buf, dma),
 			 dma_unmap_len(tx_buf, len), DMA_TO_DEVICE);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net 1/1] ice: xsk: do not use xdp_return_frame() on tx_buf->raw_buf
  2022-12-20 17:54 [PATCH net 1/1] ice: xsk: do not use xdp_return_frame() on tx_buf->raw_buf Tony Nguyen
@ 2022-12-21  8:09 ` Piotr Raczynski
  2022-12-22  1:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Piotr Raczynski @ 2022-12-21  8:09 UTC (permalink / raw)
  To: Tony Nguyen
  Cc: davem, kuba, pabeni, edumazet, Maciej Fijalkowski, netdev,
	magnus.karlsson, ast, daniel, hawk, john.fastabend, bpf,
	Robin Cowley, Chandan Kumar Rout

On Tue, Dec 20, 2022 at 09:54:48AM -0800, Tony Nguyen wrote:
> From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> 
> Previously ice XDP xmit routine was changed in a way that it avoids
> xdp_buff->xdp_frame conversion as it is simply not needed for handling
> XDP_TX action and what is more it saves us CPU cycles. This routine is
> re-used on ZC driver to handle XDP_TX action.
> 
> Although for XDP_TX on Rx ZC xdp_buff that comes from xsk_buff_pool is
> converted to xdp_frame, xdp_frame itself is not stored inside
> ice_tx_buf, we only store raw data pointer. Casting this pointer to
> xdp_frame and calling against it xdp_return_frame in
> ice_clean_xdp_tx_buf() results in undefined behavior.
> 
> To fix this, simply call page_frag_free() on tx_buf->raw_buf.
> Later intention is to remove the buff->frame conversion in order to
> simplify the codebase and improve XDP_TX performance on ZC.
> 
> Fixes: 126cdfe1007a ("ice: xsk: Improve AF_XDP ZC Tx and use batching API")
> Reported-and-tested-by: Robin Cowley <robin.cowley@thehutgroup.com>
> Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> Tested-by: Chandan Kumar Rout <chandanx.rout@intel.com> (A Contingent Worker at Intel)
> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
> ---
>  drivers/net/ethernet/intel/ice/ice_xsk.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/ethernet/intel/ice/ice_xsk.c
> index 907055b77af0..7105de6fb344 100644
> --- a/drivers/net/ethernet/intel/ice/ice_xsk.c
> +++ b/drivers/net/ethernet/intel/ice/ice_xsk.c
> @@ -783,7 +783,7 @@ int ice_clean_rx_irq_zc(struct ice_rx_ring *rx_ring, int budget)
>  static void
>  ice_clean_xdp_tx_buf(struct ice_tx_ring *xdp_ring, struct ice_tx_buf *tx_buf)
>  {
> -	xdp_return_frame((struct xdp_frame *)tx_buf->raw_buf);
> +	page_frag_free(tx_buf->raw_buf);
>  	xdp_ring->xdp_tx_active--;
>  	dma_unmap_single(xdp_ring->dev, dma_unmap_addr(tx_buf, dma),
>  			 dma_unmap_len(tx_buf, len), DMA_TO_DEVICE);
> -- 
> 2.35.1
> 
LGTM

Reviewed-by: Piotr Raczynski <piotr.raczynski@.intel.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net 1/1] ice: xsk: do not use xdp_return_frame() on tx_buf->raw_buf
  2022-12-20 17:54 [PATCH net 1/1] ice: xsk: do not use xdp_return_frame() on tx_buf->raw_buf Tony Nguyen
  2022-12-21  8:09 ` Piotr Raczynski
@ 2022-12-22  1:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-12-22  1:50 UTC (permalink / raw)
  To: Tony Nguyen
  Cc: davem, kuba, pabeni, edumazet, maciej.fijalkowski, netdev,
	magnus.karlsson, ast, daniel, hawk, john.fastabend, bpf,
	robin.cowley, chandanx.rout

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 20 Dec 2022 09:54:48 -0800 you wrote:
> From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> 
> Previously ice XDP xmit routine was changed in a way that it avoids
> xdp_buff->xdp_frame conversion as it is simply not needed for handling
> XDP_TX action and what is more it saves us CPU cycles. This routine is
> re-used on ZC driver to handle XDP_TX action.
> 
> [...]

Here is the summary with links:
  - [net,1/1] ice: xsk: do not use xdp_return_frame() on tx_buf->raw_buf
    https://git.kernel.org/netdev/net/c/53fc61be273a

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-22  1:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-20 17:54 [PATCH net 1/1] ice: xsk: do not use xdp_return_frame() on tx_buf->raw_buf Tony Nguyen
2022-12-21  8:09 ` Piotr Raczynski
2022-12-22  1:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox