All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: netsec: Correct dma sync for XDP_TX frames
@ 2019-10-16 11:40 Ilias Apalodimas
  2019-10-17  0:14 ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Ilias Apalodimas @ 2019-10-16 11:40 UTC (permalink / raw)
  To: netdev, jaswinder.singh, davem, brouer, lorenzo; +Cc: Ilias Apalodimas

bpf_xdp_adjust_head() can change the frame boundaries. Account for the
potential shift properly by calculating the new offset before
syncing the buffer to the device for XDP_TX

Fixes: ba2b232108d3 ("net: netsec: add XDP support")
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
 drivers/net/ethernet/socionext/netsec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
index f9e6744d8fd6..41ddd8fff2a7 100644
--- a/drivers/net/ethernet/socionext/netsec.c
+++ b/drivers/net/ethernet/socionext/netsec.c
@@ -847,8 +847,8 @@ static u32 netsec_xdp_queue_one(struct netsec_priv *priv,
 		enum dma_data_direction dma_dir =
 			page_pool_get_dma_dir(rx_ring->page_pool);
 
-		dma_handle = page_pool_get_dma_addr(page) +
-			NETSEC_RXBUF_HEADROOM;
+		dma_handle = page_pool_get_dma_addr(page) + xdpf->headroom +
+			sizeof(*xdpf);
 		dma_sync_single_for_device(priv->dev, dma_handle, xdpf->len,
 					   dma_dir);
 		tx_desc.buf_type = TYPE_NETSEC_XDP_TX;
-- 
2.23.0


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

* Re: [PATCH] net: netsec: Correct dma sync for XDP_TX frames
  2019-10-16 11:40 [PATCH] net: netsec: Correct dma sync for XDP_TX frames Ilias Apalodimas
@ 2019-10-17  0:14 ` Jakub Kicinski
  2019-10-17  6:49   ` Ilias Apalodimas
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2019-10-17  0:14 UTC (permalink / raw)
  To: Ilias Apalodimas; +Cc: netdev, jaswinder.singh, davem, brouer, lorenzo

On Wed, 16 Oct 2019 14:40:32 +0300, Ilias Apalodimas wrote:
> bpf_xdp_adjust_head() can change the frame boundaries. Account for the
> potential shift properly by calculating the new offset before
> syncing the buffer to the device for XDP_TX
> 
> Fixes: ba2b232108d3 ("net: netsec: add XDP support")
> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>

You should target this to the bpf or net tree (appropriate [PATCH xyz]
marking). Although I must admit it's unclear to me as well whether the
driver changes should be picked up by bpf maintainers or Dave :S

> diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
> index f9e6744d8fd6..41ddd8fff2a7 100644
> --- a/drivers/net/ethernet/socionext/netsec.c
> +++ b/drivers/net/ethernet/socionext/netsec.c
> @@ -847,8 +847,8 @@ static u32 netsec_xdp_queue_one(struct netsec_priv *priv,
>  		enum dma_data_direction dma_dir =
>  			page_pool_get_dma_dir(rx_ring->page_pool);
>  
> -		dma_handle = page_pool_get_dma_addr(page) +
> -			NETSEC_RXBUF_HEADROOM;
> +		dma_handle = page_pool_get_dma_addr(page) + xdpf->headroom +
> +			sizeof(*xdpf);

very nitpick: I'd personally write addr + sizeof(*xdpf) + xdpf->headroom
since that's the order in which they appear in memory

But likely not worth reposting for just that :)

>  		dma_sync_single_for_device(priv->dev, dma_handle, xdpf->len,
>  					   dma_dir);
>  		tx_desc.buf_type = TYPE_NETSEC_XDP_TX;


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

* Re: [PATCH] net: netsec: Correct dma sync for XDP_TX frames
  2019-10-17  0:14 ` Jakub Kicinski
@ 2019-10-17  6:49   ` Ilias Apalodimas
  0 siblings, 0 replies; 3+ messages in thread
From: Ilias Apalodimas @ 2019-10-17  6:49 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: netdev, jaswinder.singh, davem, brouer, lorenzo

Hi Jakub, 

On Wed, Oct 16, 2019 at 05:14:01PM -0700, Jakub Kicinski wrote:
> On Wed, 16 Oct 2019 14:40:32 +0300, Ilias Apalodimas wrote:
> > bpf_xdp_adjust_head() can change the frame boundaries. Account for the
> > potential shift properly by calculating the new offset before
> > syncing the buffer to the device for XDP_TX
> > 
> > Fixes: ba2b232108d3 ("net: netsec: add XDP support")
> > Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> 
> Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> 
> You should target this to the bpf or net tree (appropriate [PATCH xyz]
> marking). Although I must admit it's unclear to me as well whether the
> driver changes should be picked up by bpf maintainers or Dave :S

My bad i forgot to add the net-next tag. I'd prefer Dave picking that up, since
he picked all the XDP-related patches for this driver before. 
Dave shall i re-send with the proper tag?

> 
> > diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
> > index f9e6744d8fd6..41ddd8fff2a7 100644
> > --- a/drivers/net/ethernet/socionext/netsec.c
> > +++ b/drivers/net/ethernet/socionext/netsec.c
> > @@ -847,8 +847,8 @@ static u32 netsec_xdp_queue_one(struct netsec_priv *priv,
> >  		enum dma_data_direction dma_dir =
> >  			page_pool_get_dma_dir(rx_ring->page_pool);
> >  
> > -		dma_handle = page_pool_get_dma_addr(page) +
> > -			NETSEC_RXBUF_HEADROOM;
> > +		dma_handle = page_pool_get_dma_addr(page) + xdpf->headroom +
> > +			sizeof(*xdpf);
> 
> very nitpick: I'd personally write addr + sizeof(*xdpf) + xdpf->headroom
> since that's the order in which they appear in memory
> 
> But likely not worth reposting for just that :)

Isn't sizeof static anyway? If Dave needs a v2 with the proper tag i'll change
this as well 

> 
> >  		dma_sync_single_for_device(priv->dev, dma_handle, xdpf->len,
> >  					   dma_dir);
> >  		tx_desc.buf_type = TYPE_NETSEC_XDP_TX;
> 

Thanks
/Ilias

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

end of thread, other threads:[~2019-10-17  6:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-16 11:40 [PATCH] net: netsec: Correct dma sync for XDP_TX frames Ilias Apalodimas
2019-10-17  0:14 ` Jakub Kicinski
2019-10-17  6:49   ` Ilias Apalodimas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.