From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mail.toke.dk (Postfix) with ESMTPS id A07A0982CBF for ; Tue, 28 Jun 2022 21:49:29 +0200 (CEST) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=N5PLZcly DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656445769; x=1687981769; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=h7GfN6EnBGflCzZCdEPR/mE/rqKzDdKMQ5giru4caVw=; b=N5PLZclyKmM7ARlCJPY5Y61qzroWboWaj8BhLHUg03nAHABLHyP/gWiY inO22LRoprjVQocy8BSosfTK8j894tQGQlYcXQ0cYn5XWnoLYf/nrx+OP 9iaTDWbNx73BiAH2vGRBb38a8LNmSo4mvnFF0BfGisZys0haQUYU9ljnK AiM/wn78A1U+LQ5Eic9Ct6uXV2KfgEElJeV/TJ1V9jB8ke531sJ590NC+ TxKEjfrvGWn8nMjlcRmAeOyXYj5v2YddOhmSHsVAD0pQDn+3PDwvOfCW+ QrhN4NgbKqpkHwSj77jCLMvVQwzrMpvqE3IPil9FC6toZsn8v7cY4Gw2f A==; X-IronPort-AV: E=McAfee;i="6400,9594,10392"; a="261635652" X-IronPort-AV: E=Sophos;i="5.92,229,1650956400"; d="scan'208";a="261635652" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2022 12:49:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,229,1650956400"; d="scan'208";a="623054112" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by orsmga001.jf.intel.com with ESMTP; 28 Jun 2022 12:49:22 -0700 Received: from newjersey.igk.intel.com (newjersey.igk.intel.com [10.102.20.203]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 25SJmr9K022013; Tue, 28 Jun 2022 20:49:20 +0100 From: Alexander Lobakin To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Date: Tue, 28 Jun 2022 21:47:40 +0200 Message-Id: <20220628194812.1453059-21-alexandr.lobakin@intel.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220628194812.1453059-1-alexandr.lobakin@intel.com> References: <20220628194812.1453059-1-alexandr.lobakin@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: KDQWXU4XEVQCLO6LNULBA47IU2HJFZK3 X-Message-ID-Hash: KDQWXU4XEVQCLO6LNULBA47IU2HJFZK3 X-MailFrom: alexandr.lobakin@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Alexander Lobakin , Larysa Zaremba , Michal Swiatkowski , Jesper Dangaard Brouer , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , Toke Hoiland-Jorgensen , Lorenzo Bianconi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jesse Brandeburg , John Fastabend , Yajun Deng , Willem de Bruijn , bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, xdp-hints@xdp-project.net X-Mailman-Version: 3.3.5 Precedence: list Subject: [xdp-hints] [PATCH RFC bpf-next 20/52] net, xdp: move XDP metadata helpers into new xdp_meta.h List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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, , and move several already existing metadata helpers to it. Signed-off-by: Alexander Lobakin --- 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 diff --git a/MAINTAINERS b/MAINTAINERS index 91190e12a157..24a640c8a306 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -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 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/rx.c index 9a1553598a7c..c1fc5c79d90f 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/rx.c @@ -3,6 +3,7 @@ #include "rx.h" #include "en/xdp.h" +#include #include #include diff --git a/drivers/net/ethernet/netronome/nfp/nfd3/xsk.c b/drivers/net/ethernet/netronome/nfp/nfd3/xsk.c index 454fea4c8be2..0957e866799b 100644 --- a/drivers/net/ethernet/netronome/nfp/nfd3/xsk.c +++ b/drivers/net/ethernet/netronome/nfp/nfd3/xsk.c @@ -4,6 +4,7 @@ #include #include +#include #include "../nfp_app.h" #include "../nfp_net.h" diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 87a635aac008..0eb0cc6966e4 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -61,7 +61,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/net/xdp.h b/include/net/xdp.h index 7b8ba068d28a..1663d0b3a05a 100644 --- a/include/net/xdp.h +++ b/include/net/xdp.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; diff --git a/include/net/xdp_meta.h b/include/net/xdp_meta.h new file mode 100644 index 000000000000..e1f3df9ceb93 --- /dev/null +++ b/include/net/xdp_meta.h @@ -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 + +/* 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__ */ diff --git a/net/bpf/core.c b/net/bpf/core.c index dcd3b6ae86b7..18174d6d8687 100644 --- a/net/bpf/core.c +++ b/net/bpf/core.c @@ -14,7 +14,7 @@ #include #include -#include +#include #include /* struct xdp_mem_allocator */ #include #include diff --git a/net/bpf/prog_ops.c b/net/bpf/prog_ops.c index 33f02842e715..bf174b8d8a36 100644 --- a/net/bpf/prog_ops.c +++ b/net/bpf/prog_ops.c @@ -2,6 +2,7 @@ #include #include +#include #include #include diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c index 2ca96acbc50a..596b523ccced 100644 --- a/net/bpf/test_run.c +++ b/net/bpf/test_run.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #define CREATE_TRACE_POINTS #include diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c index 19ac872a6624..ebf6a67424cd 100644 --- a/net/xdp/xsk.c +++ b/net/xdp/xsk.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include "xsk_queue.h" #include "xdp_umem.h" -- 2.36.1