* Re: [PATCH RFC 0/4] Add XDP RX queue index metadata via kfuncs
2025-09-23 21:00 [PATCH RFC 0/4] Add XDP RX queue index metadata via kfuncs Mehdi Ben Hadj Khelifa
@ 2025-09-23 20:45 ` Stanislav Fomichev
2025-09-24 10:40 ` Mehdi Ben Hadj Khelifa
2025-09-23 21:00 ` [PATCH RFC 1/4] netlink: specs: Add XDP RX queue index to XDP metadata Mehdi Ben Hadj Khelifa
` (4 subsequent siblings)
5 siblings, 1 reply; 16+ messages in thread
From: Stanislav Fomichev @ 2025-09-23 20:45 UTC (permalink / raw)
To: Mehdi Ben Hadj Khelifa
Cc: davem, edumazet, kuba, pabeni, donald.hunter, andrew+netdev, ast,
daniel, hawk, john.fastabend, matttbe, chuck.lever, jdamato,
skhawaja, dw, mkarsten, yoong.siang.song, david.hunter.linux,
skhan, horms, sdf, netdev, linux-kernel, bpf,
linux-kernel-mentees
On 09/23, Mehdi Ben Hadj Khelifa wrote:
> ---
> Mehdi Ben Hadj Khelifa (4):
> netlink: specs: Add XDP RX queue index to XDP metadata
> net: xdp: Add xmo_rx_queue_index callback
> uapi: netdev: Add XDP RX queue index metadata flags
> net: veth: Implement RX queue index XDP hint
>
> Documentation/netlink/specs/netdev.yaml | 5 +++++
> drivers/net/veth.c | 12 ++++++++++++
> include/net/xdp.h | 5 +++++
> include/uapi/linux/netdev.h | 3 +++
> net/core/xdp.c | 15 +++++++++++++++
> tools/include/uapi/linux/netdev.h | 3 +++
> 6 files changed, 43 insertions(+)
> ---
> base-commit: 07e27ad16399afcd693be20211b0dfae63e0615f
> this is the commit of tag: v6.17-rc7 on the mainline.
> This patch series is intended to make a base for setting
> queue_index in the xdp_rxq_info struct in bpf/cpumap.c to
> the right index. Although that part I still didn't figure
> out yet,I m searching for my guidance to do that as well
> as for the correctness of the patches in this series.
But why do you need a kfunc getter? You can already get rxq index
via xdp_md rx_queue_index.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH RFC 0/4] Add XDP RX queue index metadata via kfuncs
@ 2025-09-23 21:00 Mehdi Ben Hadj Khelifa
2025-09-23 20:45 ` Stanislav Fomichev
` (5 more replies)
0 siblings, 6 replies; 16+ messages in thread
From: Mehdi Ben Hadj Khelifa @ 2025-09-23 21:00 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, donald.hunter, andrew+netdev, ast,
daniel, hawk, john.fastabend, matttbe, chuck.lever, jdamato,
skhawaja, dw, mkarsten, yoong.siang.song, david.hunter.linux,
skhan
Cc: horms, sdf, netdev, linux-kernel, bpf, linux-kernel-mentees,
Mehdi Ben Hadj Khelifa
---
Mehdi Ben Hadj Khelifa (4):
netlink: specs: Add XDP RX queue index to XDP metadata
net: xdp: Add xmo_rx_queue_index callback
uapi: netdev: Add XDP RX queue index metadata flags
net: veth: Implement RX queue index XDP hint
Documentation/netlink/specs/netdev.yaml | 5 +++++
drivers/net/veth.c | 12 ++++++++++++
include/net/xdp.h | 5 +++++
include/uapi/linux/netdev.h | 3 +++
net/core/xdp.c | 15 +++++++++++++++
tools/include/uapi/linux/netdev.h | 3 +++
6 files changed, 43 insertions(+)
---
base-commit: 07e27ad16399afcd693be20211b0dfae63e0615f
this is the commit of tag: v6.17-rc7 on the mainline.
This patch series is intended to make a base for setting
queue_index in the xdp_rxq_info struct in bpf/cpumap.c to
the right index. Although that part I still didn't figure
out yet,I m searching for my guidance to do that as well
as for the correctness of the patches in this series.
Best Regards,
Mehdi Ben Hadj Khelifa
--
2.51.0
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH RFC 1/4] netlink: specs: Add XDP RX queue index to XDP metadata
2025-09-23 21:00 [PATCH RFC 0/4] Add XDP RX queue index metadata via kfuncs Mehdi Ben Hadj Khelifa
2025-09-23 20:45 ` Stanislav Fomichev
@ 2025-09-23 21:00 ` Mehdi Ben Hadj Khelifa
2025-09-23 21:00 ` [PATCH RFC 2/4] net: xdp: Add xmo_rx_queue_index callback Mehdi Ben Hadj Khelifa
` (3 subsequent siblings)
5 siblings, 0 replies; 16+ messages in thread
From: Mehdi Ben Hadj Khelifa @ 2025-09-23 21:00 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, donald.hunter, andrew+netdev, ast,
daniel, hawk, john.fastabend, matttbe, chuck.lever, jdamato,
skhawaja, dw, mkarsten, yoong.siang.song, david.hunter.linux,
skhan
Cc: horms, sdf, netdev, linux-kernel, bpf, linux-kernel-mentees,
Mehdi Ben Hadj Khelifa
Devices will be able to communicate received packets
queue index with bpf_xdp_metadata_rx_queue_index().
Signed-off-by: Mehdi Ben Hadj Khelifa <mehdi.benhadjkhelifa@gmail.com>
---
Documentation/netlink/specs/netdev.yaml | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlink/specs/netdev.yaml
index c035dc0f64fd..25fe17ea1625 100644
--- a/Documentation/netlink/specs/netdev.yaml
+++ b/Documentation/netlink/specs/netdev.yaml
@@ -61,6 +61,11 @@ definitions:
doc: |
Device is capable of exposing receive packet VLAN tag via
bpf_xdp_metadata_rx_vlan_tag().
+ -
+ name: queue-index
+ doc: |
+ Device is capable of exposing receive packet queue index via
+ bpf_xdp_metadata_rx_queue_index().
-
type: flags
name: xsk-flags
--
2.51.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH RFC 2/4] net: xdp: Add xmo_rx_queue_index callback
2025-09-23 21:00 [PATCH RFC 0/4] Add XDP RX queue index metadata via kfuncs Mehdi Ben Hadj Khelifa
2025-09-23 20:45 ` Stanislav Fomichev
2025-09-23 21:00 ` [PATCH RFC 1/4] netlink: specs: Add XDP RX queue index to XDP metadata Mehdi Ben Hadj Khelifa
@ 2025-09-23 21:00 ` Mehdi Ben Hadj Khelifa
2025-09-23 21:00 ` [PATCH RFC 3/4] uapi: netdev: Add XDP RX queue index metadata flags Mehdi Ben Hadj Khelifa
` (2 subsequent siblings)
5 siblings, 0 replies; 16+ messages in thread
From: Mehdi Ben Hadj Khelifa @ 2025-09-23 21:00 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, donald.hunter, andrew+netdev, ast,
daniel, hawk, john.fastabend, matttbe, chuck.lever, jdamato,
skhawaja, dw, mkarsten, yoong.siang.song, david.hunter.linux,
skhan
Cc: horms, sdf, netdev, linux-kernel, bpf, linux-kernel-mentees,
Mehdi Ben Hadj Khelifa
Introduce xmo_rx_queue_index netdev callback in order allow the eBPF
program bounded to the device to retrieve the RX queue index from the
hw NIC.
Signed-off-by: Mehdi Ben Hadj Khelifa <mehdi.benhadjkhelifa@gmail.com>
---
include/net/xdp.h | 5 +++++
net/core/xdp.c | 15 +++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/include/net/xdp.h b/include/net/xdp.h
index b40f1f96cb11..edbf66c31f83 100644
--- a/include/net/xdp.h
+++ b/include/net/xdp.h
@@ -547,6 +547,10 @@ void xdp_attachment_setup(struct xdp_attachment_info *info,
NETDEV_XDP_RX_METADATA_VLAN_TAG, \
bpf_xdp_metadata_rx_vlan_tag, \
xmo_rx_vlan_tag) \
+ XDP_METADATA_KFUNC(XDP_METADATA_KFUNC_RX_QUEUE_INDEX, \
+ NETDEV_XDP_RX_METADATA_QUEUE_INDEX, \
+ bpf_xdp_metadata_rx_queue_index, \
+ xmo_rx_queue_index) \
enum xdp_rx_metadata {
#define XDP_METADATA_KFUNC(name, _, __, ___) name,
@@ -610,6 +614,7 @@ struct xdp_metadata_ops {
enum xdp_rss_hash_type *rss_type);
int (*xmo_rx_vlan_tag)(const struct xdp_md *ctx, __be16 *vlan_proto,
u16 *vlan_tci);
+ int (*xmo_rx_queue_index)(const struct xdp_md *ctx, u32 *queue_index);
};
#ifdef CONFIG_NET
diff --git a/net/core/xdp.c b/net/core/xdp.c
index 491334b9b8be..78c0c63e343c 100644
--- a/net/core/xdp.c
+++ b/net/core/xdp.c
@@ -962,6 +962,21 @@ __bpf_kfunc int bpf_xdp_metadata_rx_vlan_tag(const struct xdp_md *ctx,
return -EOPNOTSUPP;
}
+/**
+ * bpf_xdp_metadata_rx_queue_index - Read XDP frame RX queue index.
+ * @ctx: XDP context pointer.
+ * @queue_index: Return value pointer.
+ *
+ * Return:
+ * * Returns 0 on success or ``-errno`` on error.
+ * * ``-EOPNOTSUPP`` : means device driver does not implement kfunc
+ * * ``-ENODATA`` : means no RX queue index available for this frame
+ */
+__bpf_kfunc int bpf_xdp_metadata_rx_queue_index(const struct xdp_md *ctx, u32 *queue_index)
+{
+ return -EOPNOTSUPP;
+}
+
__bpf_kfunc_end_defs();
BTF_KFUNCS_START(xdp_metadata_kfunc_ids)
--
2.51.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH RFC 3/4] uapi: netdev: Add XDP RX queue index metadata flags
2025-09-23 21:00 [PATCH RFC 0/4] Add XDP RX queue index metadata via kfuncs Mehdi Ben Hadj Khelifa
` (2 preceding siblings ...)
2025-09-23 21:00 ` [PATCH RFC 2/4] net: xdp: Add xmo_rx_queue_index callback Mehdi Ben Hadj Khelifa
@ 2025-09-23 21:00 ` Mehdi Ben Hadj Khelifa
2025-09-23 21:00 ` [PATCH RFC 4/4] net: veth: Implement RX queue index XDP hint Mehdi Ben Hadj Khelifa
2025-09-25 9:43 ` [PATCH RFC 0/4] Add XDP RX queue index metadata via kfuncs Jakub Sitnicki
5 siblings, 0 replies; 16+ messages in thread
From: Mehdi Ben Hadj Khelifa @ 2025-09-23 21:00 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, donald.hunter, andrew+netdev, ast,
daniel, hawk, john.fastabend, matttbe, chuck.lever, jdamato,
skhawaja, dw, mkarsten, yoong.siang.song, david.hunter.linux,
skhan
Cc: horms, sdf, netdev, linux-kernel, bpf, linux-kernel-mentees,
Mehdi Ben Hadj Khelifa
Added NETDEV_XDP_RX_METADATA_QUEUE_INDEX flag to both netdev.h files
for the bpf_xdp_metadata_rx_queue_index() function.
Signed-off-by: Mehdi Ben Hadj Khelifa <mehdi.benhadjkhelifa@gmail.com>
---
include/uapi/linux/netdev.h | 3 +++
tools/include/uapi/linux/netdev.h | 3 +++
2 files changed, 6 insertions(+)
diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h
index 48eb49aa03d4..59033a607c16 100644
--- a/include/uapi/linux/netdev.h
+++ b/include/uapi/linux/netdev.h
@@ -46,11 +46,14 @@ enum netdev_xdp_act {
* hash via bpf_xdp_metadata_rx_hash().
* @NETDEV_XDP_RX_METADATA_VLAN_TAG: Device is capable of exposing receive
* packet VLAN tag via bpf_xdp_metadata_rx_vlan_tag().
+ * @NETDEV_XDP_RX_METADATA_QUEUE_INDEX: Device is capable of exposing receive HW
+ * queue index via bpf_xdp_metadata_rx_queue_index().
*/
enum netdev_xdp_rx_metadata {
NETDEV_XDP_RX_METADATA_TIMESTAMP = 1,
NETDEV_XDP_RX_METADATA_HASH = 2,
NETDEV_XDP_RX_METADATA_VLAN_TAG = 4,
+ NETDEV_XDP_RX_METADATA_QUEUE_INDEX = 8,
};
/**
diff --git a/tools/include/uapi/linux/netdev.h b/tools/include/uapi/linux/netdev.h
index 48eb49aa03d4..59033a607c16 100644
--- a/tools/include/uapi/linux/netdev.h
+++ b/tools/include/uapi/linux/netdev.h
@@ -46,11 +46,14 @@ enum netdev_xdp_act {
* hash via bpf_xdp_metadata_rx_hash().
* @NETDEV_XDP_RX_METADATA_VLAN_TAG: Device is capable of exposing receive
* packet VLAN tag via bpf_xdp_metadata_rx_vlan_tag().
+ * @NETDEV_XDP_RX_METADATA_QUEUE_INDEX: Device is capable of exposing receive HW
+ * queue index via bpf_xdp_metadata_rx_queue_index().
*/
enum netdev_xdp_rx_metadata {
NETDEV_XDP_RX_METADATA_TIMESTAMP = 1,
NETDEV_XDP_RX_METADATA_HASH = 2,
NETDEV_XDP_RX_METADATA_VLAN_TAG = 4,
+ NETDEV_XDP_RX_METADATA_QUEUE_INDEX = 8,
};
/**
--
2.51.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH RFC 4/4] net: veth: Implement RX queue index XDP hint
2025-09-23 21:00 [PATCH RFC 0/4] Add XDP RX queue index metadata via kfuncs Mehdi Ben Hadj Khelifa
` (3 preceding siblings ...)
2025-09-23 21:00 ` [PATCH RFC 3/4] uapi: netdev: Add XDP RX queue index metadata flags Mehdi Ben Hadj Khelifa
@ 2025-09-23 21:00 ` Mehdi Ben Hadj Khelifa
2025-09-25 9:43 ` [PATCH RFC 0/4] Add XDP RX queue index metadata via kfuncs Jakub Sitnicki
5 siblings, 0 replies; 16+ messages in thread
From: Mehdi Ben Hadj Khelifa @ 2025-09-23 21:00 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, donald.hunter, andrew+netdev, ast,
daniel, hawk, john.fastabend, matttbe, chuck.lever, jdamato,
skhawaja, dw, mkarsten, yoong.siang.song, david.hunter.linux,
skhan
Cc: horms, sdf, netdev, linux-kernel, bpf, linux-kernel-mentees,
Mehdi Ben Hadj Khelifa
Implement xmo_rx_queue_index callback in veth driver
to export queue_index for use in eBPF programs.
Signed-off-by: Mehdi Ben Hadj Khelifa <mehdi.benhadjkhelifa@gmail.com>
---
drivers/net/veth.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index a3046142cb8e..be76dd292819 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -1692,6 +1692,17 @@ static int veth_xdp_rx_vlan_tag(const struct xdp_md *ctx, __be16 *vlan_proto,
return err;
}
+static int veth_xdp_rx_queue_index(const struct xdp_md *ctx, u32 *queue_index)
+{
+ const struct veth_xdp_buff *_ctx = (void *)ctx;
+
+ if (!_ctx->xdp.rxq)
+ return -ENODATA;
+
+ *queue_index = _ctx->xdp.rxq->queue_index;
+ return 0;
+}
+
static const struct net_device_ops veth_netdev_ops = {
.ndo_init = veth_dev_init,
.ndo_open = veth_open,
@@ -1717,6 +1728,7 @@ static const struct xdp_metadata_ops veth_xdp_metadata_ops = {
.xmo_rx_timestamp = veth_xdp_rx_timestamp,
.xmo_rx_hash = veth_xdp_rx_hash,
.xmo_rx_vlan_tag = veth_xdp_rx_vlan_tag,
+ .xmo_rx_queue_index = veth_xdp_rx_queue_index,
};
#define VETH_FEATURES (NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HW_CSUM | \
--
2.51.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH RFC 0/4] Add XDP RX queue index metadata via kfuncs
2025-09-23 20:45 ` Stanislav Fomichev
@ 2025-09-24 10:40 ` Mehdi Ben Hadj Khelifa
2025-09-24 22:31 ` Stanislav Fomichev
0 siblings, 1 reply; 16+ messages in thread
From: Mehdi Ben Hadj Khelifa @ 2025-09-24 10:40 UTC (permalink / raw)
To: Stanislav Fomichev
Cc: davem, edumazet, kuba, pabeni, donald.hunter, andrew+netdev, ast,
daniel, hawk, john.fastabend, matttbe, chuck.lever, jdamato,
skhawaja, dw, mkarsten, yoong.siang.song, david.hunter.linux,
skhan, horms, sdf, netdev, linux-kernel, bpf,
linux-kernel-mentees
On 9/23/25 9:45 PM, Stanislav Fomichev wrote:
> On 09/23, Mehdi Ben Hadj Khelifa wrote:
>> ---
>> Mehdi Ben Hadj Khelifa (4):
>> netlink: specs: Add XDP RX queue index to XDP metadata
>> net: xdp: Add xmo_rx_queue_index callback
>> uapi: netdev: Add XDP RX queue index metadata flags
>> net: veth: Implement RX queue index XDP hint
>>
>> Documentation/netlink/specs/netdev.yaml | 5 +++++
>> drivers/net/veth.c | 12 ++++++++++++
>> include/net/xdp.h | 5 +++++
>> include/uapi/linux/netdev.h | 3 +++
>> net/core/xdp.c | 15 +++++++++++++++
>> tools/include/uapi/linux/netdev.h | 3 +++
>> 6 files changed, 43 insertions(+)
>> ---
>> base-commit: 07e27ad16399afcd693be20211b0dfae63e0615f
>> this is the commit of tag: v6.17-rc7 on the mainline.
>> This patch series is intended to make a base for setting
>> queue_index in the xdp_rxq_info struct in bpf/cpumap.c to
>> the right index. Although that part I still didn't figure
>> out yet,I m searching for my guidance to do that as well
>> as for the correctness of the patches in this series.
> But why do you need a kfunc getter? You can already get rxq index
> via xdp_md rx_queue_index.
Hi Stanislav, When i was looking at the available information or recent
similar patches to populate the queue_index in xdp_rxq_info inside of
the cpu map of an ebpf program to run xdp. i stumbled upon this:
https://lkml.rescloud.iu.edu/2506.1/02808.html
which suggests that in order to that, a struct called "xdp_rx_meta"
should be the route to do that. In my navigation of code i only found
the closest thing to that is xdp_rx_metadata which is an enum. I tried
to follow was done for other metadata there like timestamp in order to
see if that gets me closer to do that. which was stupid with the
information that i have now but for my lack of experience (this is my
first patch) i tried to reason with the code.So yeah, since xdp_md is
the structure for transfering metadata to ebpf programs that use xdp.
it's useless to have a kfunc to expose queue_index since it's already
present there. But how would one try to populate the queue_index in
xdp_rxq_info in cpu_map_bpf_prog_run_xdp()? Any sort of hints or guides
would be much appreciated.
Thank you for your time.
Best Regards,
Mehdi Ben Hadj Khelifa
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH RFC 0/4] Add XDP RX queue index metadata via kfuncs
2025-09-24 10:40 ` Mehdi Ben Hadj Khelifa
@ 2025-09-24 22:31 ` Stanislav Fomichev
2025-09-25 9:57 ` Mehdi Ben Hadj Khelifa
0 siblings, 1 reply; 16+ messages in thread
From: Stanislav Fomichev @ 2025-09-24 22:31 UTC (permalink / raw)
To: Mehdi Ben Hadj Khelifa
Cc: davem, edumazet, kuba, pabeni, donald.hunter, andrew+netdev, ast,
daniel, hawk, john.fastabend, matttbe, chuck.lever, jdamato,
skhawaja, dw, mkarsten, yoong.siang.song, david.hunter.linux,
skhan, horms, sdf, netdev, linux-kernel, bpf,
linux-kernel-mentees
On 09/24, Mehdi Ben Hadj Khelifa wrote:
> On 9/23/25 9:45 PM, Stanislav Fomichev wrote:
> > On 09/23, Mehdi Ben Hadj Khelifa wrote:
> > > ---
> > > Mehdi Ben Hadj Khelifa (4):
> > > netlink: specs: Add XDP RX queue index to XDP metadata
> > > net: xdp: Add xmo_rx_queue_index callback
> > > uapi: netdev: Add XDP RX queue index metadata flags
> > > net: veth: Implement RX queue index XDP hint
> > >
> > > Documentation/netlink/specs/netdev.yaml | 5 +++++
> > > drivers/net/veth.c | 12 ++++++++++++
> > > include/net/xdp.h | 5 +++++
> > > include/uapi/linux/netdev.h | 3 +++
> > > net/core/xdp.c | 15 +++++++++++++++
> > > tools/include/uapi/linux/netdev.h | 3 +++
> > > 6 files changed, 43 insertions(+)
> > > ---
> > > base-commit: 07e27ad16399afcd693be20211b0dfae63e0615f
> > > this is the commit of tag: v6.17-rc7 on the mainline.
> > > This patch series is intended to make a base for setting
> > > queue_index in the xdp_rxq_info struct in bpf/cpumap.c to
> > > the right index. Although that part I still didn't figure
> > > out yet,I m searching for my guidance to do that as well
> > > as for the correctness of the patches in this series.
>
> > But why do you need a kfunc getter? You can already get rxq index
> > via xdp_md rx_queue_index.
>
> Hi Stanislav, When i was looking at the available information or recent
> similar patches to populate the queue_index in xdp_rxq_info inside of
> the cpu map of an ebpf program to run xdp. i stumbled upon this:
> https://lkml.rescloud.iu.edu/2506.1/02808.html
>
> which suggests that in order to that, a struct called "xdp_rx_meta" should
> be the route to do that. In my navigation of code i only found
> the closest thing to that is xdp_rx_metadata which is an enum. I tried to
> follow was done for other metadata there like timestamp in order to see if
> that gets me closer to do that. which was stupid with the information that i
> have now but for my lack of experience (this is my first patch) i tried to
> reason with the code.So yeah, since xdp_md is the structure for transfering
> metadata to ebpf programs that use xdp. it's useless to have a kfunc to
> expose queue_index since it's already present there. But how would one try
> to populate the queue_index in xdp_rxq_info in cpu_map_bpf_prog_run_xdp()?
> Any sort of hints or guides would be much appreciated.
> Thank you for your time.
I don't really understand what queue_index means for the cpu map. It is
a kernel thread doing work, there is no queue. Maybe whoever added
the todo can clarify?
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH RFC 0/4] Add XDP RX queue index metadata via kfuncs
2025-09-23 21:00 [PATCH RFC 0/4] Add XDP RX queue index metadata via kfuncs Mehdi Ben Hadj Khelifa
` (4 preceding siblings ...)
2025-09-23 21:00 ` [PATCH RFC 4/4] net: veth: Implement RX queue index XDP hint Mehdi Ben Hadj Khelifa
@ 2025-09-25 9:43 ` Jakub Sitnicki
2025-09-25 10:54 ` Mehdi Ben Hadj Khelifa
5 siblings, 1 reply; 16+ messages in thread
From: Jakub Sitnicki @ 2025-09-25 9:43 UTC (permalink / raw)
To: Mehdi Ben Hadj Khelifa
Cc: davem, edumazet, kuba, pabeni, donald.hunter, andrew+netdev, ast,
daniel, hawk, john.fastabend, matttbe, chuck.lever, jdamato,
skhawaja, dw, mkarsten, yoong.siang.song, david.hunter.linux,
skhan, horms, sdf, netdev, linux-kernel, bpf,
linux-kernel-mentees
On Tue, Sep 23, 2025 at 10:00 PM +01, Mehdi Ben Hadj Khelifa wrote:
> This patch series is intended to make a base for setting
> queue_index in the xdp_rxq_info struct in bpf/cpumap.c to
> the right index. Although that part I still didn't figure
> out yet,I m searching for my guidance to do that as well
> as for the correctness of the patches in this series.
What is the use case/movtivation behind this work?
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH RFC 0/4] Add XDP RX queue index metadata via kfuncs
2025-09-24 22:31 ` Stanislav Fomichev
@ 2025-09-25 9:57 ` Mehdi Ben Hadj Khelifa
2025-09-26 6:42 ` Lorenzo Bianconi
0 siblings, 1 reply; 16+ messages in thread
From: Mehdi Ben Hadj Khelifa @ 2025-09-25 9:57 UTC (permalink / raw)
To: Stanislav Fomichev, lorenzo
Cc: davem, edumazet, kuba, pabeni, donald.hunter, andrew+netdev, ast,
daniel, hawk, john.fastabend, matttbe, chuck.lever, jdamato,
skhawaja, dw, mkarsten, yoong.siang.song, david.hunter.linux,
skhan, horms, sdf, netdev, linux-kernel, bpf,
linux-kernel-mentees
On 9/24/25 11:31 PM, Stanislav Fomichev wrote:
> On 09/24, Mehdi Ben Hadj Khelifa wrote:
>> On 9/23/25 9:45 PM, Stanislav Fomichev wrote:
>>> On 09/23, Mehdi Ben Hadj Khelifa wrote:
>>>> ---
>>>> Mehdi Ben Hadj Khelifa (4):
>>>> netlink: specs: Add XDP RX queue index to XDP metadata
>>>> net: xdp: Add xmo_rx_queue_index callback
>>>> uapi: netdev: Add XDP RX queue index metadata flags
>>>> net: veth: Implement RX queue index XDP hint
>>>>
>>>> Documentation/netlink/specs/netdev.yaml | 5 +++++
>>>> drivers/net/veth.c | 12 ++++++++++++
>>>> include/net/xdp.h | 5 +++++
>>>> include/uapi/linux/netdev.h | 3 +++
>>>> net/core/xdp.c | 15 +++++++++++++++
>>>> tools/include/uapi/linux/netdev.h | 3 +++
>>>> 6 files changed, 43 insertions(+)
>>>> ---
>>>> base-commit: 07e27ad16399afcd693be20211b0dfae63e0615f
>>>> this is the commit of tag: v6.17-rc7 on the mainline.
>>>> This patch series is intended to make a base for setting
>>>> queue_index in the xdp_rxq_info struct in bpf/cpumap.c to
>>>> the right index. Although that part I still didn't figure
>>>> out yet,I m searching for my guidance to do that as well
>>>> as for the correctness of the patches in this series.
>>
>>>
> I don't really understand what queue_index means for the cpu map. It is
> a kernel thread doing work, there is no queue. Maybe whoever added
> the todo can clarify?
Hi Lorenzo,
Can you help us clarify the todo added in cpu_map_bpf_prog_run_xdp() in
this commit:
github.com/torvalds/linux/commit/9216477449f33cdbc9c9a99d49f500b7fbb81702 ?
Regards,
Mehdi
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH RFC 0/4] Add XDP RX queue index metadata via kfuncs
2025-09-25 10:54 ` Mehdi Ben Hadj Khelifa
@ 2025-09-25 10:18 ` Jakub Sitnicki
2025-09-25 11:28 ` Mehdi Ben Hadj Khelifa
0 siblings, 1 reply; 16+ messages in thread
From: Jakub Sitnicki @ 2025-09-25 10:18 UTC (permalink / raw)
To: Mehdi Ben Hadj Khelifa
Cc: davem, edumazet, kuba, pabeni, donald.hunter, andrew+netdev, ast,
daniel, hawk, john.fastabend, matttbe, chuck.lever, jdamato,
skhawaja, dw, mkarsten, yoong.siang.song, david.hunter.linux,
skhan, horms, sdf, netdev, linux-kernel, bpf,
linux-kernel-mentees
On Thu, Sep 25, 2025 at 11:54 AM +01, Mehdi Ben Hadj Khelifa wrote:
> On 9/25/25 10:43 AM, Jakub Sitnicki wrote:
>> On Tue, Sep 23, 2025 at 10:00 PM +01, Mehdi Ben Hadj Khelifa wrote:
>>> This patch series is intended to make a base for setting
>>> queue_index in the xdp_rxq_info struct in bpf/cpumap.c to
>>> the right index. Although that part I still didn't figure
>>> out yet,I m searching for my guidance to do that as well
>>> as for the correctness of the patches in this series.
>> What is the use case/movtivation behind this work?
>
> The goal of the work is to have xdp programs have the correct packet RX queue
> index after being redirected through cpumap because currently the queue_index
> gets unset or more accurately set to 0 as a default in xdp_rxq_info. This is my
> current understanding.I still have to know how I can propogate that HW hint from
> the NICs to the function where I need it.
This explains what this series does, the desired end state of
information passing, but not why is does it - how that information is
going to be consumed? To what end?
I'd start by figuring that part out. Otherwise you're just proposing
adding code that serves no actual purpose.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH RFC 0/4] Add XDP RX queue index metadata via kfuncs
2025-09-25 11:28 ` Mehdi Ben Hadj Khelifa
@ 2025-09-25 10:47 ` Jakub Sitnicki
2025-09-25 12:03 ` Mehdi Ben Hadj Khelifa
0 siblings, 1 reply; 16+ messages in thread
From: Jakub Sitnicki @ 2025-09-25 10:47 UTC (permalink / raw)
To: Mehdi Ben Hadj Khelifa
Cc: davem, edumazet, kuba, pabeni, donald.hunter, andrew+netdev, ast,
daniel, hawk, john.fastabend, matttbe, chuck.lever, jdamato,
skhawaja, dw, mkarsten, yoong.siang.song, david.hunter.linux,
skhan, horms, sdf, netdev, linux-kernel, bpf,
linux-kernel-mentees
On Thu, Sep 25, 2025 at 12:28 PM +01, Mehdi Ben Hadj Khelifa wrote:
> On 9/25/25 11:18 AM, Jakub Sitnicki wrote:
>> On Thu, Sep 25, 2025 at 11:54 AM +01, Mehdi Ben Hadj Khelifa wrote:
>>> On 9/25/25 10:43 AM, Jakub Sitnicki wrote:
>>>> On Tue, Sep 23, 2025 at 10:00 PM +01, Mehdi Ben Hadj Khelifa wrote:
>>>>> This patch series is intended to make a base for setting
>>>>> queue_index in the xdp_rxq_info struct in bpf/cpumap.c to
>>>>> the right index. Although that part I still didn't figure
>>>>> out yet,I m searching for my guidance to do that as well
>>>>> as for the correctness of the patches in this series.
>>>> What is the use case/movtivation behind this work?
>>>
>>> The goal of the work is to have xdp programs have the correct packet RX queue
>>> index after being redirected through cpumap because currently the queue_index
>>> gets unset or more accurately set to 0 as a default in xdp_rxq_info. This is my
>>> current understanding.I still have to know how I can propogate that HW hint from
>>> the NICs to the function where I need it.
>> This explains what this series does, the desired end state of
>> information passing, but not why is does it - how that information is
>> going to be consumed? To what end?
>
> In my vision,The queue index propagated correctly through cpumap can help xdp
> programs use it for things such as per queue load balancing,Adaptive RSS tuning
> and even maybe for DDoS mitigation where they can drop traffic per queue.I mean
> if these aren't correct intents or if they don't justify the added code, I can
> abort working on it. Even if they weren't I need more guidance on how I can have
> that metadata from HW hints...
Both filtering or load balancing you'd want to do early on - in the XDP
program invoked on receive from NIC, which as Stanislav pointed out
already has access to the RX queue index in its context. Not on the
remote CPU after spending cycles on a redirect.
And even if you wanted to pass that information to the remote XDP
program, to do something with it, you can already store it in custom XDP
metadata [1].
So while perhaps there is something that you can't do today but would be
useful, I don't know what it is. Hence my question about the use case.
[1] https://docs.ebpf.io/linux/helper-function/bpf_xdp_adjust_meta/
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH RFC 0/4] Add XDP RX queue index metadata via kfuncs
2025-09-25 9:43 ` [PATCH RFC 0/4] Add XDP RX queue index metadata via kfuncs Jakub Sitnicki
@ 2025-09-25 10:54 ` Mehdi Ben Hadj Khelifa
2025-09-25 10:18 ` Jakub Sitnicki
0 siblings, 1 reply; 16+ messages in thread
From: Mehdi Ben Hadj Khelifa @ 2025-09-25 10:54 UTC (permalink / raw)
To: Jakub Sitnicki
Cc: davem, edumazet, kuba, pabeni, donald.hunter, andrew+netdev, ast,
daniel, hawk, john.fastabend, matttbe, chuck.lever, jdamato,
skhawaja, dw, mkarsten, yoong.siang.song, david.hunter.linux,
skhan, horms, sdf, netdev, linux-kernel, bpf,
linux-kernel-mentees
On 9/25/25 10:43 AM, Jakub Sitnicki wrote:
> On Tue, Sep 23, 2025 at 10:00 PM +01, Mehdi Ben Hadj Khelifa wrote:
>> This patch series is intended to make a base for setting
>> queue_index in the xdp_rxq_info struct in bpf/cpumap.c to
>> the right index. Although that part I still didn't figure
>> out yet,I m searching for my guidance to do that as well
>> as for the correctness of the patches in this series.
>
> What is the use case/movtivation behind this work?
The goal of the work is to have xdp programs have the correct packet RX
queue index after being redirected through cpumap because currently the
queue_index gets unset or more accurately set to 0 as a default in
xdp_rxq_info. This is my current understanding.I still have to know how
I can propogate that HW hint from the NICs to the function where I need it.
Regards,
Mehdi
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH RFC 0/4] Add XDP RX queue index metadata via kfuncs
2025-09-25 10:18 ` Jakub Sitnicki
@ 2025-09-25 11:28 ` Mehdi Ben Hadj Khelifa
2025-09-25 10:47 ` Jakub Sitnicki
0 siblings, 1 reply; 16+ messages in thread
From: Mehdi Ben Hadj Khelifa @ 2025-09-25 11:28 UTC (permalink / raw)
To: Jakub Sitnicki
Cc: davem, edumazet, kuba, pabeni, donald.hunter, andrew+netdev, ast,
daniel, hawk, john.fastabend, matttbe, chuck.lever, jdamato,
skhawaja, dw, mkarsten, yoong.siang.song, david.hunter.linux,
skhan, horms, sdf, netdev, linux-kernel, bpf,
linux-kernel-mentees
On 9/25/25 11:18 AM, Jakub Sitnicki wrote:
> On Thu, Sep 25, 2025 at 11:54 AM +01, Mehdi Ben Hadj Khelifa wrote:
>> On 9/25/25 10:43 AM, Jakub Sitnicki wrote:
>>> On Tue, Sep 23, 2025 at 10:00 PM +01, Mehdi Ben Hadj Khelifa wrote:
>>>> This patch series is intended to make a base for setting
>>>> queue_index in the xdp_rxq_info struct in bpf/cpumap.c to
>>>> the right index. Although that part I still didn't figure
>>>> out yet,I m searching for my guidance to do that as well
>>>> as for the correctness of the patches in this series.
>>> What is the use case/movtivation behind this work?
>>
>> The goal of the work is to have xdp programs have the correct packet RX queue
>> index after being redirected through cpumap because currently the queue_index
>> gets unset or more accurately set to 0 as a default in xdp_rxq_info. This is my
>> current understanding.I still have to know how I can propogate that HW hint from
>> the NICs to the function where I need it.
>
> This explains what this series does, the desired end state of
> information passing, but not why is does it - how that information is
> going to be consumed? To what end?
In my vision,The queue index propagated correctly through cpumap can
help xdp programs use it for things such as per queue load
balancing,Adaptive RSS tuning and even maybe for DDoS mitigation where
they can drop traffic per queue.I mean if these aren't correct intents
or if they don't justify the added code, I can abort working on it. Even
if they weren't I need more guidance on how I can have that metadata
from HW hints...
Best Regards,
Mehdi
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH RFC 0/4] Add XDP RX queue index metadata via kfuncs
2025-09-25 10:47 ` Jakub Sitnicki
@ 2025-09-25 12:03 ` Mehdi Ben Hadj Khelifa
0 siblings, 0 replies; 16+ messages in thread
From: Mehdi Ben Hadj Khelifa @ 2025-09-25 12:03 UTC (permalink / raw)
To: Jakub Sitnicki
Cc: davem, edumazet, kuba, pabeni, donald.hunter, andrew+netdev, ast,
daniel, hawk, john.fastabend, matttbe, chuck.lever, jdamato,
skhawaja, dw, mkarsten, yoong.siang.song, david.hunter.linux,
skhan, horms, sdf, netdev, linux-kernel, bpf,
linux-kernel-mentees
On 9/25/25 11:47 AM, Jakub Sitnicki wrote:
> On Thu, Sep 25, 2025 at 12:28 PM +01, Mehdi Ben Hadj Khelifa wrote:
>> On 9/25/25 11:18 AM, Jakub Sitnicki wrote:
>>> On Thu, Sep 25, 2025 at 11:54 AM +01, Mehdi Ben Hadj Khelifa wrote:
>>>> On 9/25/25 10:43 AM, Jakub Sitnicki wrote:
>>>>> On Tue, Sep 23, 2025 at 10:00 PM +01, Mehdi Ben Hadj Khelifa wrote:
>>>>>> This patch series is intended to make a base for setting
>>>>>> queue_index in the xdp_rxq_info struct in bpf/cpumap.c to
>>>>>> the right index. Although that part I still didn't figure
>>>>>> out yet,I m searching for my guidance to do that as well
>>>>>> as for the correctness of the patches in this series.
>>>>> What is the use case/movtivation behind this work?
>>>>
>>>> The goal of the work is to have xdp programs have the correct packet RX queue
>>>> index after being redirected through cpumap because currently the queue_index
>>>> gets unset or more accurately set to 0 as a default in xdp_rxq_info. This is my
>>>> current understanding.I still have to know how I can propogate that HW hint from
>>>> the NICs to the function where I need it.
>>> This explains what this series does, the desired end state of
>>> information passing, but not why is does it - how that information is
>>> going to be consumed? To what end?
>>
>> In my vision,The queue index propagated correctly through cpumap can help xdp
>> programs use it for things such as per queue load balancing,Adaptive RSS tuning
>> and even maybe for DDoS mitigation where they can drop traffic per queue.I mean
>> if these aren't correct intents or if they don't justify the added code, I can
>> abort working on it. Even if they weren't I need more guidance on how I can have
>> that metadata from HW hints...
>
> Both filtering or load balancing you'd want to do early on - in the XDP
> program invoked on receive from NIC, which as Stanislav pointed out
> already has access to the RX queue index in its context. Not on the
> remote CPU after spending cycles on a redirect.
>
> And even if you wanted to pass that information to the remote XDP
> program, to do something with it, you can already store it in custom XDP
> metadata [1].
>
> So while perhaps there is something that you can't do today but would be
> useful, I don't know what it is. Hence my question about the use case.
>
> [1] https://docs.ebpf.io/linux/helper-function/bpf_xdp_adjust_meta/
>
Very clear,
I will abort working on this since it can be passed as a custom XDP
metadata [1] until further valid use cases or when it proves to be more
useful.
Thank you for your review and time.
Best Regards,
Mehdi
[1] https://docs.ebpf.io/linux/helper-function/bpf_xdp_adjust_meta/
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH RFC 0/4] Add XDP RX queue index metadata via kfuncs
2025-09-25 9:57 ` Mehdi Ben Hadj Khelifa
@ 2025-09-26 6:42 ` Lorenzo Bianconi
0 siblings, 0 replies; 16+ messages in thread
From: Lorenzo Bianconi @ 2025-09-26 6:42 UTC (permalink / raw)
To: Mehdi Ben Hadj Khelifa
Cc: Stanislav Fomichev, davem, edumazet, kuba, pabeni, donald.hunter,
andrew+netdev, ast, daniel, hawk, john.fastabend, matttbe,
chuck.lever, jdamato, skhawaja, dw, mkarsten, yoong.siang.song,
david.hunter.linux, skhan, horms, sdf, netdev, linux-kernel, bpf,
linux-kernel-mentees
[-- Attachment #1: Type: text/plain, Size: 2001 bytes --]
> On 9/24/25 11:31 PM, Stanislav Fomichev wrote:
> > On 09/24, Mehdi Ben Hadj Khelifa wrote:
> > > On 9/23/25 9:45 PM, Stanislav Fomichev wrote:
> > > > On 09/23, Mehdi Ben Hadj Khelifa wrote:
> > > > > ---
> > > > > Mehdi Ben Hadj Khelifa (4):
> > > > > netlink: specs: Add XDP RX queue index to XDP metadata
> > > > > net: xdp: Add xmo_rx_queue_index callback
> > > > > uapi: netdev: Add XDP RX queue index metadata flags
> > > > > net: veth: Implement RX queue index XDP hint
> > > > >
> > > > > Documentation/netlink/specs/netdev.yaml | 5 +++++
> > > > > drivers/net/veth.c | 12 ++++++++++++
> > > > > include/net/xdp.h | 5 +++++
> > > > > include/uapi/linux/netdev.h | 3 +++
> > > > > net/core/xdp.c | 15 +++++++++++++++
> > > > > tools/include/uapi/linux/netdev.h | 3 +++
> > > > > 6 files changed, 43 insertions(+)
> > > > > ---
> > > > > base-commit: 07e27ad16399afcd693be20211b0dfae63e0615f
> > > > > this is the commit of tag: v6.17-rc7 on the mainline.
> > > > > This patch series is intended to make a base for setting
> > > > > queue_index in the xdp_rxq_info struct in bpf/cpumap.c to
> > > > > the right index. Although that part I still didn't figure
> > > > > out yet,I m searching for my guidance to do that as well
> > > > > as for the correctness of the patches in this series.
> > >
> > > >
> > I don't really understand what queue_index means for the cpu map. It is
> > a kernel thread doing work, there is no queue. Maybe whoever added
> > the todo can clarify?
Hi Mehdi,
IIRC it is the queue index of the NIC that received the packet from the wire.
Regards,
Lorenzo
>
> Hi Lorenzo,
> Can you help us clarify the todo added in cpu_map_bpf_prog_run_xdp() in this
> commit:
> github.com/torvalds/linux/commit/9216477449f33cdbc9c9a99d49f500b7fbb81702 ?
>
> Regards,
> Mehdi
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2025-09-26 6:42 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-23 21:00 [PATCH RFC 0/4] Add XDP RX queue index metadata via kfuncs Mehdi Ben Hadj Khelifa
2025-09-23 20:45 ` Stanislav Fomichev
2025-09-24 10:40 ` Mehdi Ben Hadj Khelifa
2025-09-24 22:31 ` Stanislav Fomichev
2025-09-25 9:57 ` Mehdi Ben Hadj Khelifa
2025-09-26 6:42 ` Lorenzo Bianconi
2025-09-23 21:00 ` [PATCH RFC 1/4] netlink: specs: Add XDP RX queue index to XDP metadata Mehdi Ben Hadj Khelifa
2025-09-23 21:00 ` [PATCH RFC 2/4] net: xdp: Add xmo_rx_queue_index callback Mehdi Ben Hadj Khelifa
2025-09-23 21:00 ` [PATCH RFC 3/4] uapi: netdev: Add XDP RX queue index metadata flags Mehdi Ben Hadj Khelifa
2025-09-23 21:00 ` [PATCH RFC 4/4] net: veth: Implement RX queue index XDP hint Mehdi Ben Hadj Khelifa
2025-09-25 9:43 ` [PATCH RFC 0/4] Add XDP RX queue index metadata via kfuncs Jakub Sitnicki
2025-09-25 10:54 ` Mehdi Ben Hadj Khelifa
2025-09-25 10:18 ` Jakub Sitnicki
2025-09-25 11:28 ` Mehdi Ben Hadj Khelifa
2025-09-25 10:47 ` Jakub Sitnicki
2025-09-25 12:03 ` Mehdi Ben Hadj Khelifa
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).