@@ -21722,6 +21722,7 @@ L: netdev@vger.kernel.org
L: bpf@vger.kernel.org
S: Supported
F: include/net/xdp.h
+F: include/net/xdp_meta.h
F: include/net/xdp_priv.h
F: include/trace/events/xdp.h
F: kernel/bpf/cpumap.c
@@ -3,6 +3,7 @@
#include "rx.h"
#include "en/xdp.h"
+#include <net/xdp_meta.h>
#include <net/xdp_sock_drv.h>
#include <linux/filter.h>
@@ -4,6 +4,7 @@
#include <linux/bpf_trace.h>
#include <linux/netdevice.h>
+#include <net/xdp_meta.h>
#include "../nfp_app.h"
#include "../nfp_net.h"
@@ -61,7 +61,7 @@
#include <net/netns/generic.h>
#include <net/rtnetlink.h>
#include <net/sock.h>
-#include <net/xdp.h>
+#include <net/xdp_meta.h>
#include <net/ip_tunnels.h>
#include <linux/seq_file.h>
#include <linux/uio.h>
@@ -378,26 +378,6 @@ int xdp_reg_mem_model(struct xdp_mem_info *mem,
enum xdp_mem_type type, void *allocator);
void xdp_unreg_mem_model(struct xdp_mem_info *mem);
-/* Drivers not supporting XDP metadata can use this helper, which
- * rejects any room expansion for metadata as a result.
- */
-static __always_inline void
-xdp_set_data_meta_invalid(struct xdp_buff *xdp)
-{
- xdp->data_meta = xdp->data + 1;
-}
-
-static __always_inline bool
-xdp_data_meta_unsupported(const struct xdp_buff *xdp)
-{
- return unlikely(xdp->data_meta > xdp->data);
-}
-
-static inline bool xdp_metalen_invalid(unsigned long metalen)
-{
- return (metalen & (sizeof(__u32) - 1)) || (metalen > 32);
-}
-
struct xdp_attachment_info {
struct bpf_prog *prog;
u64 btf_id;
new file mode 100644
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright (C) 2022, Intel Corporation. */
+
+#ifndef __LINUX_NET_XDP_META_H__
+#define __LINUX_NET_XDP_META_H__
+
+#include <net/xdp.h>
+
+/* Drivers not supporting XDP metadata can use this helper, which
+ * rejects any room expansion for metadata as a result.
+ */
+static __always_inline void
+xdp_set_data_meta_invalid(struct xdp_buff *xdp)
+{
+ xdp->data_meta = xdp->data + 1;
+}
+
+static __always_inline bool
+xdp_data_meta_unsupported(const struct xdp_buff *xdp)
+{
+ return unlikely(xdp->data_meta > xdp->data);
+}
+
+static inline bool xdp_metalen_invalid(unsigned long metalen)
+{
+ return (metalen & (sizeof(__u32) - 1)) || (metalen > 32);
+}
+
+#endif /* __LINUX_NET_XDP_META_H__ */
@@ -14,7 +14,7 @@
#include <linux/bug.h>
#include <net/page_pool.h>
-#include <net/xdp.h>
+#include <net/xdp_meta.h>
#include <net/xdp_priv.h> /* struct xdp_mem_allocator */
#include <trace/events/xdp.h>
#include <net/xdp_sock_drv.h>
@@ -2,6 +2,7 @@
#include <linux/btf.h>
#include <linux/btf_ids.h>
+#include <net/xdp_meta.h>
#include <net/xdp_sock.h>
#include <trace/events/xdp.h>
@@ -19,7 +19,7 @@
#include <linux/error-injection.h>
#include <linux/smp.h>
#include <linux/sock_diag.h>
-#include <net/xdp.h>
+#include <net/xdp_meta.h>
#define CREATE_TRACE_POINTS
#include <trace/events/bpf_test_run.h>
@@ -24,7 +24,7 @@
#include <linux/rculist.h>
#include <net/xdp_sock_drv.h>
#include <net/busy_poll.h>
-#include <net/xdp.h>
+#include <net/xdp_meta.h>
#include "xsk_queue.h"
#include "xdp_umem.h"
<net/xdp.h> gets included indirectly into tons of different files across the kernel. To not make them dependent on the header files needed for the XDP metadata definitions, which will be used only by several driver and XDP core files, and have the metadata code logically separated, create a new header file, <net/xdp_meta.h>, and move several already existing metadata helpers to it. Signed-off-by: Alexander Lobakin <alexandr.lobakin@intel.com> --- MAINTAINERS | 1 + .../ethernet/mellanox/mlx5/core/en/xsk/rx.c | 1 + drivers/net/ethernet/netronome/nfp/nfd3/xsk.c | 1 + drivers/net/tun.c | 2 +- include/net/xdp.h | 20 ------------- include/net/xdp_meta.h | 29 +++++++++++++++++++ net/bpf/core.c | 2 +- net/bpf/prog_ops.c | 1 + net/bpf/test_run.c | 2 +- net/xdp/xsk.c | 2 +- 10 files changed, 37 insertions(+), 24 deletions(-) create mode 100644 include/net/xdp_meta.h