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