* Re: [PATCH] bpf: cpumap: report Rx queue index to xdp_rxq_info
2025-06-09 17:38 [PATCH] bpf: cpumap: report Rx queue index to xdp_rxq_info Ujwal Kundur
@ 2025-06-10 11:29 ` Jesper Dangaard Brouer
2025-06-10 12:01 ` Toke Høiland-Jørgensen
2025-06-10 13:15 ` Alexander Lobakin
2 siblings, 0 replies; 6+ messages in thread
From: Jesper Dangaard Brouer @ 2025-06-10 11:29 UTC (permalink / raw)
To: Ujwal Kundur, ast, daniel, davem, kuba, john.fastabend, andrii,
martin.lau, eddyz87, song, yonghong.song, kpsingh, sdf, aoluo,
jolsa
Cc: netdev, bpf, linux-kernel
On 09/06/2025 19.38, Ujwal Kundur wrote:
> Refer to the Rx queue using a XDP frame's attached netdev and ascertain
> the queue index from it.
>
> Signed-off-by: Ujwal Kundur <ujwal.kundur@gmail.com>
> ---
> kernel/bpf/cpumap.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c
> index 67e8a2fc1a99..8230292deac1 100644
> --- a/kernel/bpf/cpumap.c
> +++ b/kernel/bpf/cpumap.c
> @@ -34,6 +34,7 @@
> #include <linux/btf_ids.h>
>
> #include <linux/netdevice.h>
> +#include <net/netdev_rx_queue.h>
> #include <net/gro.h>
>
> /* General idea: XDP packets getting XDP redirected to another CPU,
> @@ -196,7 +197,7 @@ static int cpu_map_bpf_prog_run_xdp(struct bpf_cpu_map_entry *rcpu,
>
> rxq.dev = xdpf->dev_rx;
> rxq.mem.type = xdpf->mem_type;
> - /* TODO: report queue_index to xdp_rxq_info */
> + rxq.queue_index = get_netdev_rx_queue_index(xdpf->dev_rx->_rx);
This looks wrong...
I think this will always return index 0
--Jesper
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] bpf: cpumap: report Rx queue index to xdp_rxq_info
2025-06-09 17:38 [PATCH] bpf: cpumap: report Rx queue index to xdp_rxq_info Ujwal Kundur
2025-06-10 11:29 ` Jesper Dangaard Brouer
@ 2025-06-10 12:01 ` Toke Høiland-Jørgensen
2025-06-10 13:15 ` Alexander Lobakin
2 siblings, 0 replies; 6+ messages in thread
From: Toke Høiland-Jørgensen @ 2025-06-10 12:01 UTC (permalink / raw)
To: Ujwal Kundur, ast, daniel, davem, kuba, hawk, john.fastabend,
andrii, martin.lau, eddyz87, song, yonghong.song, kpsingh, sdf,
aoluo, jolsa
Cc: netdev, bpf, linux-kernel, Ujwal Kundur
Ujwal Kundur <ujwal.kundur@gmail.com> writes:
> Refer to the Rx queue using a XDP frame's attached netdev and ascertain
> the queue index from it.
>
> Signed-off-by: Ujwal Kundur <ujwal.kundur@gmail.com>
> ---
> kernel/bpf/cpumap.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c
> index 67e8a2fc1a99..8230292deac1 100644
> --- a/kernel/bpf/cpumap.c
> +++ b/kernel/bpf/cpumap.c
> @@ -34,6 +34,7 @@
> #include <linux/btf_ids.h>
>
> #include <linux/netdevice.h>
> +#include <net/netdev_rx_queue.h>
> #include <net/gro.h>
>
> /* General idea: XDP packets getting XDP redirected to another CPU,
> @@ -196,7 +197,7 @@ static int cpu_map_bpf_prog_run_xdp(struct bpf_cpu_map_entry *rcpu,
>
> rxq.dev = xdpf->dev_rx;
> rxq.mem.type = xdpf->mem_type;
> - /* TODO: report queue_index to xdp_rxq_info */
> + rxq.queue_index = get_netdev_rx_queue_index(xdpf->dev_rx->_rx);
This is pretty nonsensical; the definition of the function you're
calling is this:
static inline unsigned int
get_netdev_rx_queue_index(struct netdev_rx_queue *queue)
{
struct net_device *dev = queue->dev;
int index = queue - dev->_rx;
BUG_ON(index >= dev->num_rx_queues);
return index;
}
So passing dev->_rx to that function will always return 0; which is what
the field is already initialised to...
-Toke
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] bpf: cpumap: report Rx queue index to xdp_rxq_info
2025-06-09 17:38 [PATCH] bpf: cpumap: report Rx queue index to xdp_rxq_info Ujwal Kundur
2025-06-10 11:29 ` Jesper Dangaard Brouer
2025-06-10 12:01 ` Toke Høiland-Jørgensen
@ 2025-06-10 13:15 ` Alexander Lobakin
2025-06-10 14:02 ` Ujwal Kundur
2 siblings, 1 reply; 6+ messages in thread
From: Alexander Lobakin @ 2025-06-10 13:15 UTC (permalink / raw)
To: Ujwal Kundur
Cc: ast, daniel, davem, kuba, hawk, john.fastabend, andrii,
martin.lau, eddyz87, song, yonghong.song, kpsingh, sdf, aoluo,
jolsa, netdev, bpf, linux-kernel
From: Ujwal Kundur <ujwal.kundur@gmail.com>
Date: Mon, 9 Jun 2025 23:08:52 +0530
> Refer to the Rx queue using a XDP frame's attached netdev and ascertain
> the queue index from it.
>
> Signed-off-by: Ujwal Kundur <ujwal.kundur@gmail.com>
> ---
> kernel/bpf/cpumap.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c
> index 67e8a2fc1a99..8230292deac1 100644
> --- a/kernel/bpf/cpumap.c
> +++ b/kernel/bpf/cpumap.c
> @@ -34,6 +34,7 @@
> #include <linux/btf_ids.h>
>
> #include <linux/netdevice.h>
> +#include <net/netdev_rx_queue.h>
> #include <net/gro.h>
>
> /* General idea: XDP packets getting XDP redirected to another CPU,
> @@ -196,7 +197,7 @@ static int cpu_map_bpf_prog_run_xdp(struct bpf_cpu_map_entry *rcpu,
>
> rxq.dev = xdpf->dev_rx;
> rxq.mem.type = xdpf->mem_type;
> - /* TODO: report queue_index to xdp_rxq_info */
> + rxq.queue_index = get_netdev_rx_queue_index(xdpf->dev_rx->_rx);
I won't repeat what the folks above already told you.
I'll just add that you may want to take a look at Lorenzo's series[0].
Rx queue index is sorta HW hint, so it shouldn't be a problem to add the
corresponding field to xdp_rx_meta.
Then, you can expand cpumap's code to try reading that HW meta if present.
>
> xdp_convert_frame_to_buff(xdpf, &xdp);
[0]
https://lore.kernel.org/bpf/174897275458.1677018.15827867832940584671.stgit@firesoul
Thanks,
Olek
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] bpf: cpumap: report Rx queue index to xdp_rxq_info
2025-06-10 13:15 ` Alexander Lobakin
@ 2025-06-10 14:02 ` Ujwal Kundur
2025-06-10 20:24 ` Toke Høiland-Jørgensen
0 siblings, 1 reply; 6+ messages in thread
From: Ujwal Kundur @ 2025-06-10 14:02 UTC (permalink / raw)
To: Alexander Lobakin
Cc: ast, daniel, davem, kuba, hawk, john.fastabend, andrii,
martin.lau, eddyz87, song, yonghong.song, kpsingh, sdf, aoluo,
jolsa, netdev, bpf, linux-kernel
> This looks wrong...
> I think this will always return index 0
> So passing dev->_rx to that function will always return 0; which is what
> the field is already initialised to...
I didn't realize that would always return 0, sorry I should've tried
to understand that statement better.
> I'll just add that you may want to take a look at Lorenzo's series[0].
> Rx queue index is sorta HW hint, so it shouldn't be a problem to add the
> corresponding field to xdp_rx_meta.
> Then, you can expand cpumap's code to try reading that HW meta if present.
Thank you! I also tried to work backwards to figure out how the
queue_index would be used if present in xdp_rxq_info but that wasn't
immediately apparent to me.
I'm keen on learning/contributing to the BPF part of the network stack
and this seemed like a good first patch to take up -- I'll understand
this better and try again.
Thanks for your time,
Ujwal
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] bpf: cpumap: report Rx queue index to xdp_rxq_info
2025-06-10 14:02 ` Ujwal Kundur
@ 2025-06-10 20:24 ` Toke Høiland-Jørgensen
0 siblings, 0 replies; 6+ messages in thread
From: Toke Høiland-Jørgensen @ 2025-06-10 20:24 UTC (permalink / raw)
To: Ujwal Kundur, Alexander Lobakin
Cc: ast, daniel, davem, kuba, hawk, john.fastabend, andrii,
martin.lau, eddyz87, song, yonghong.song, kpsingh, sdf, aoluo,
jolsa, netdev, bpf, linux-kernel
Ujwal Kundur <ujwal.kundur@gmail.com> writes:
>> This looks wrong...
>> I think this will always return index 0
>
>> So passing dev->_rx to that function will always return 0; which is what
>> the field is already initialised to...
>
> I didn't realize that would always return 0, sorry I should've tried
> to understand that statement better.
>
>> I'll just add that you may want to take a look at Lorenzo's series[0].
>> Rx queue index is sorta HW hint, so it shouldn't be a problem to add the
>> corresponding field to xdp_rx_meta.
>> Then, you can expand cpumap's code to try reading that HW meta if present.
>
> Thank you! I also tried to work backwards to figure out how the
> queue_index would be used if present in xdp_rxq_info but that wasn't
> immediately apparent to me.
> I'm keen on learning/contributing to the BPF part of the network stack
> and this seemed like a good first patch to take up -- I'll understand
> this better and try again.
Sounds good! Don't be discouraged by having to try again, that's
perfectly normal :)
-Toke
^ permalink raw reply [flat|nested] 6+ messages in thread