diff mbox series

[bpf-next] xdp: report rx queue index in xdp_frame

Message ID 181f994e13c816116fa69a1e92c2f69e6330f749.1658746417.git.lorenzo@kernel.org (mailing list archive)
State New, archived
Delegated to: BPF
Headers show
Series [bpf-next] xdp: report rx queue index in xdp_frame | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 4512 this patch: 4512
netdev/cc_maintainers warning 7 maintainers not CCed: martin.lau@linux.dev song@kernel.org yhs@fb.com jolsa@kernel.org kpsingh@kernel.org sdf@google.com haoluo@google.com
netdev/build_clang success Errors and warnings before: 1110 this patch: 1110
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4671 this patch: 4671
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 22 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-1 success Logs for Kernel LATEST on ubuntu-latest with gcc
bpf/vmtest-bpf-next-VM_Test-2 success Logs for Kernel LATEST on ubuntu-latest with llvm-16
bpf/vmtest-bpf-next-VM_Test-3 success Logs for Kernel LATEST on z15 with gcc

Commit Message

Lorenzo Bianconi July 25, 2022, 10:56 a.m. UTC
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(-)

Comments

Lorenzo Bianconi Aug. 16, 2022, 9:45 a.m. UTC | #1
> 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
>
Daniel Borkmann Aug. 16, 2022, 9:54 a.m. UTC | #2
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
Lorenzo Bianconi Aug. 16, 2022, 9:56 a.m. UTC | #3
> 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
Jesper Dangaard Brouer Aug. 17, 2022, 11:17 a.m. UTC | #4
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);
>
Lorenzo Bianconi Aug. 17, 2022, 12:35 p.m. UTC | #5
> 
> 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);
>
diff mbox series

Patch

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);