netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] xdp: report rx queue index in xdp_frame
@ 2022-07-25 10:56 Lorenzo Bianconi
  2022-08-16  9:45 ` Lorenzo Bianconi
  2022-08-17 11:17 ` Jesper Dangaard Brouer
  0 siblings, 2 replies; 6+ messages in thread
From: Lorenzo Bianconi @ 2022-07-25 10:56 UTC (permalink / raw)
  To: bpf
  Cc: ast, daniel, andrii, netdev, davem, kuba, edumazet, pabeni, hawk,
	john.fastabend, lorenzo.bianconi

Report rx queue index in xdp_frame according to the xdp_buff xdp_rxq_info
pointer. xdp_frame queue_index is currently used in cpumap code to covert
the xdp_frame into a xdp_buff.
xdp_frame size is not increased adding queue_index since an alignment padding
in the structure is used to insert queue_index field.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 include/net/xdp.h   | 2 ++
 kernel/bpf/cpumap.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/net/xdp.h b/include/net/xdp.h
index 04c852c7a77f..3567866b0af5 100644
--- a/include/net/xdp.h
+++ b/include/net/xdp.h
@@ -172,6 +172,7 @@ struct xdp_frame {
 	struct xdp_mem_info mem;
 	struct net_device *dev_rx; /* used by cpumap */
 	u32 flags; /* supported values defined in xdp_buff_flags */
+	u32 queue_index;
 };
 
 static __always_inline bool xdp_frame_has_frags(struct xdp_frame *frame)
@@ -301,6 +302,7 @@ struct xdp_frame *xdp_convert_buff_to_frame(struct xdp_buff *xdp)
 
 	/* rxq only valid until napi_schedule ends, convert to xdp_mem_info */
 	xdp_frame->mem = xdp->rxq->mem;
+	xdp_frame->queue_index = xdp->rxq->queue_index;
 
 	return xdp_frame;
 }
diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c
index f4860ac756cd..09a792d088b3 100644
--- a/kernel/bpf/cpumap.c
+++ b/kernel/bpf/cpumap.c
@@ -228,7 +228,7 @@ static int cpu_map_bpf_prog_run_xdp(struct bpf_cpu_map_entry *rcpu,
 
 		rxq.dev = xdpf->dev_rx;
 		rxq.mem = xdpf->mem;
-		/* TODO: report queue_index to xdp_rxq_info */
+		rxq.queue_index = xdpf->queue_index;
 
 		xdp_convert_frame_to_buff(xdpf, &xdp);
 
-- 
2.37.1


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

* Re: [PATCH bpf-next] xdp: report rx queue index in xdp_frame
  2022-07-25 10:56 [PATCH bpf-next] xdp: report rx queue index in xdp_frame Lorenzo Bianconi
@ 2022-08-16  9:45 ` Lorenzo Bianconi
  2022-08-16  9:54   ` Daniel Borkmann
  2022-08-17 11:17 ` Jesper Dangaard Brouer
  1 sibling, 1 reply; 6+ messages in thread
From: Lorenzo Bianconi @ 2022-08-16  9:45 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: bpf, ast, daniel, andrii, netdev, davem, kuba, edumazet, pabeni,
	hawk, john.fastabend

[-- Attachment #1: Type: text/plain, Size: 1884 bytes --]

> Report rx queue index in xdp_frame according to the xdp_buff xdp_rxq_info
> pointer. xdp_frame queue_index is currently used in cpumap code to covert
> the xdp_frame into a xdp_buff.
> xdp_frame size is not increased adding queue_index since an alignment padding
> in the structure is used to insert queue_index field.
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
>  include/net/xdp.h   | 2 ++
>  kernel/bpf/cpumap.c | 2 +-
>  2 files changed, 3 insertions(+), 1 deletion(-)


Hi Alexei and Daniel,

this patch is marked as 'new, archived' in patchwork.
Do I need to rebase and repost it?

Regards,
Lorenzo

> 
> diff --git a/include/net/xdp.h b/include/net/xdp.h
> index 04c852c7a77f..3567866b0af5 100644
> --- a/include/net/xdp.h
> +++ b/include/net/xdp.h
> @@ -172,6 +172,7 @@ struct xdp_frame {
>  	struct xdp_mem_info mem;
>  	struct net_device *dev_rx; /* used by cpumap */
>  	u32 flags; /* supported values defined in xdp_buff_flags */
> +	u32 queue_index;
>  };
>  
>  static __always_inline bool xdp_frame_has_frags(struct xdp_frame *frame)
> @@ -301,6 +302,7 @@ struct xdp_frame *xdp_convert_buff_to_frame(struct xdp_buff *xdp)
>  
>  	/* rxq only valid until napi_schedule ends, convert to xdp_mem_info */
>  	xdp_frame->mem = xdp->rxq->mem;
> +	xdp_frame->queue_index = xdp->rxq->queue_index;
>  
>  	return xdp_frame;
>  }
> diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c
> index f4860ac756cd..09a792d088b3 100644
> --- a/kernel/bpf/cpumap.c
> +++ b/kernel/bpf/cpumap.c
> @@ -228,7 +228,7 @@ static int cpu_map_bpf_prog_run_xdp(struct bpf_cpu_map_entry *rcpu,
>  
>  		rxq.dev = xdpf->dev_rx;
>  		rxq.mem = xdpf->mem;
> -		/* TODO: report queue_index to xdp_rxq_info */
> +		rxq.queue_index = xdpf->queue_index;
>  
>  		xdp_convert_frame_to_buff(xdpf, &xdp);
>  
> -- 
> 2.37.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [PATCH bpf-next] xdp: report rx queue index in xdp_frame
  2022-08-16  9:45 ` Lorenzo Bianconi
@ 2022-08-16  9:54   ` Daniel Borkmann
  2022-08-16  9:56     ` Lorenzo Bianconi
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Borkmann @ 2022-08-16  9:54 UTC (permalink / raw)
  To: Lorenzo Bianconi, Lorenzo Bianconi
  Cc: bpf, ast, andrii, netdev, davem, kuba, edumazet, pabeni, hawk,
	john.fastabend

On 8/16/22 11:45 AM, Lorenzo Bianconi wrote:
>> Report rx queue index in xdp_frame according to the xdp_buff xdp_rxq_info
>> pointer. xdp_frame queue_index is currently used in cpumap code to covert
>> the xdp_frame into a xdp_buff.
>> xdp_frame size is not increased adding queue_index since an alignment padding
>> in the structure is used to insert queue_index field.
>>
>> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
>> ---
>>   include/net/xdp.h   | 2 ++
>>   kernel/bpf/cpumap.c | 2 +-
>>   2 files changed, 3 insertions(+), 1 deletion(-)
> 
> 
> Hi Alexei and Daniel,
> 
> this patch is marked as 'new, archived' in patchwork.
> Do I need to rebase and repost it?

Yes, please rebase and resend. Perhaps also improve the commit description
a bit in terms of what it fixes, it's a bit terse to the reader above on
what effect it has.

Thanks,
Daniel

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

* Re: [PATCH bpf-next] xdp: report rx queue index in xdp_frame
  2022-08-16  9:54   ` Daniel Borkmann
@ 2022-08-16  9:56     ` Lorenzo Bianconi
  0 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Bianconi @ 2022-08-16  9:56 UTC (permalink / raw)
  To: Daniel Borkmann
  Cc: Lorenzo Bianconi, bpf, ast, andrii, netdev, davem, kuba, edumazet,
	pabeni, hawk, john.fastabend

[-- Attachment #1: Type: text/plain, Size: 996 bytes --]

> On 8/16/22 11:45 AM, Lorenzo Bianconi wrote:
> > > Report rx queue index in xdp_frame according to the xdp_buff xdp_rxq_info
> > > pointer. xdp_frame queue_index is currently used in cpumap code to covert
> > > the xdp_frame into a xdp_buff.
> > > xdp_frame size is not increased adding queue_index since an alignment padding
> > > in the structure is used to insert queue_index field.
> > > 
> > > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > > ---
> > >   include/net/xdp.h   | 2 ++
> > >   kernel/bpf/cpumap.c | 2 +-
> > >   2 files changed, 3 insertions(+), 1 deletion(-)
> > 
> > 
> > Hi Alexei and Daniel,
> > 
> > this patch is marked as 'new, archived' in patchwork.
> > Do I need to rebase and repost it?
> 
> Yes, please rebase and resend. Perhaps also improve the commit description
> a bit in terms of what it fixes, it's a bit terse to the reader above on
> what effect it has.

ack thx, will do.

Regards,
Lorenzo

> 
> Thanks,
> Daniel

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [PATCH bpf-next] xdp: report rx queue index in xdp_frame
  2022-07-25 10:56 [PATCH bpf-next] xdp: report rx queue index in xdp_frame Lorenzo Bianconi
  2022-08-16  9:45 ` Lorenzo Bianconi
@ 2022-08-17 11:17 ` Jesper Dangaard Brouer
  2022-08-17 12:35   ` Lorenzo Bianconi
  1 sibling, 1 reply; 6+ messages in thread
From: Jesper Dangaard Brouer @ 2022-08-17 11:17 UTC (permalink / raw)
  To: Lorenzo Bianconi, bpf
  Cc: brouer, ast, daniel, andrii, netdev, davem, kuba, edumazet,
	pabeni, hawk, john.fastabend, lorenzo.bianconi


On 25/07/2022 12.56, Lorenzo Bianconi wrote:
> Report rx queue index in xdp_frame according to the xdp_buff xdp_rxq_info
> pointer. xdp_frame queue_index is currently used in cpumap code to covert
> the xdp_frame into a xdp_buff.

Hmm, I'm unsure about this change, because the XDP-hints will also
contain the rx_queue number.

I do think it is relevant for the BPF-prog to get access to the rx_queue
index, because it can be used for scaling the workload.

> xdp_frame size is not increased adding queue_index since an alignment padding
> in the structure is used to insert queue_index field.

The rx_queue could be reduced from u32 to u16, but it might be faster to
keep it u32, and reduce it when others need the space.

> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
>   include/net/xdp.h   | 2 ++
>   kernel/bpf/cpumap.c | 2 +-
>   2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/include/net/xdp.h b/include/net/xdp.h
> index 04c852c7a77f..3567866b0af5 100644
> --- a/include/net/xdp.h
> +++ b/include/net/xdp.h
> @@ -172,6 +172,7 @@ struct xdp_frame {
>   	struct xdp_mem_info mem;
>   	struct net_device *dev_rx; /* used by cpumap */
>   	u32 flags; /* supported values defined in xdp_buff_flags */
> +	u32 queue_index;
>   };
>   
>   static __always_inline bool xdp_frame_has_frags(struct xdp_frame *frame)
> @@ -301,6 +302,7 @@ struct xdp_frame *xdp_convert_buff_to_frame(struct xdp_buff *xdp)
>   
>   	/* rxq only valid until napi_schedule ends, convert to xdp_mem_info */
>   	xdp_frame->mem = xdp->rxq->mem;
> +	xdp_frame->queue_index = xdp->rxq->queue_index;
>   
>   	return xdp_frame;
>   }
> diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c
> index f4860ac756cd..09a792d088b3 100644
> --- a/kernel/bpf/cpumap.c
> +++ b/kernel/bpf/cpumap.c
> @@ -228,7 +228,7 @@ static int cpu_map_bpf_prog_run_xdp(struct bpf_cpu_map_entry *rcpu,
>   
>   		rxq.dev = xdpf->dev_rx;
>   		rxq.mem = xdpf->mem;
> -		/* TODO: report queue_index to xdp_rxq_info */
> +		rxq.queue_index = xdpf->queue_index;
>   
>   		xdp_convert_frame_to_buff(xdpf, &xdp);
>   


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

* Re: [PATCH bpf-next] xdp: report rx queue index in xdp_frame
  2022-08-17 11:17 ` Jesper Dangaard Brouer
@ 2022-08-17 12:35   ` Lorenzo Bianconi
  0 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Bianconi @ 2022-08-17 12:35 UTC (permalink / raw)
  To: Jesper Dangaard Brouer
  Cc: bpf, brouer, ast, daniel, andrii, netdev, davem, kuba, edumazet,
	pabeni, hawk, john.fastabend, lorenzo.bianconi

[-- Attachment #1: Type: text/plain, Size: 2411 bytes --]

> 
> On 25/07/2022 12.56, Lorenzo Bianconi wrote:
> > Report rx queue index in xdp_frame according to the xdp_buff xdp_rxq_info
> > pointer. xdp_frame queue_index is currently used in cpumap code to covert
> > the xdp_frame into a xdp_buff.
> 
> Hmm, I'm unsure about this change, because the XDP-hints will also
> contain the rx_queue number.

ack, but in this way each driver needs to fill this info, right? Maybe we can
keep rx_queue number here and remove it from XDP-hints metadata?

> 
> I do think it is relevant for the BPF-prog to get access to the rx_queue
> index, because it can be used for scaling the workload.
> 
> > xdp_frame size is not increased adding queue_index since an alignment padding
> > in the structure is used to insert queue_index field.
> 
> The rx_queue could be reduced from u32 to u16, but it might be faster to
> keep it u32, and reduce it when others need the space.

ack, agree.

Regards,
Lorenzo

> 
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > ---
> >   include/net/xdp.h   | 2 ++
> >   kernel/bpf/cpumap.c | 2 +-
> >   2 files changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/include/net/xdp.h b/include/net/xdp.h
> > index 04c852c7a77f..3567866b0af5 100644
> > --- a/include/net/xdp.h
> > +++ b/include/net/xdp.h
> > @@ -172,6 +172,7 @@ struct xdp_frame {
> >   	struct xdp_mem_info mem;
> >   	struct net_device *dev_rx; /* used by cpumap */
> >   	u32 flags; /* supported values defined in xdp_buff_flags */
> > +	u32 queue_index;
> >   };
> >   static __always_inline bool xdp_frame_has_frags(struct xdp_frame *frame)
> > @@ -301,6 +302,7 @@ struct xdp_frame *xdp_convert_buff_to_frame(struct xdp_buff *xdp)
> >   	/* rxq only valid until napi_schedule ends, convert to xdp_mem_info */
> >   	xdp_frame->mem = xdp->rxq->mem;
> > +	xdp_frame->queue_index = xdp->rxq->queue_index;
> >   	return xdp_frame;
> >   }
> > diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c
> > index f4860ac756cd..09a792d088b3 100644
> > --- a/kernel/bpf/cpumap.c
> > +++ b/kernel/bpf/cpumap.c
> > @@ -228,7 +228,7 @@ static int cpu_map_bpf_prog_run_xdp(struct bpf_cpu_map_entry *rcpu,
> >   		rxq.dev = xdpf->dev_rx;
> >   		rxq.mem = xdpf->mem;
> > -		/* TODO: report queue_index to xdp_rxq_info */
> > +		rxq.queue_index = xdpf->queue_index;
> >   		xdp_convert_frame_to_buff(xdpf, &xdp);
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

end of thread, other threads:[~2022-08-17 12:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-25 10:56 [PATCH bpf-next] xdp: report rx queue index in xdp_frame Lorenzo Bianconi
2022-08-16  9:45 ` Lorenzo Bianconi
2022-08-16  9:54   ` Daniel Borkmann
2022-08-16  9:56     ` Lorenzo Bianconi
2022-08-17 11:17 ` Jesper Dangaard Brouer
2022-08-17 12:35   ` Lorenzo Bianconi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).