From nobody Sun Nov 24 13:04:29 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E1631C3F32; Fri, 16 Aug 2024 17:56:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723830972; cv=none; b=En0b+R8KBmyfgksAE+g+dFJf+hbexnx6PWAqWbHAH7cGf4WzojjzJPMHApgq+XAUsF+65u+VFpIhsVwPteFV4h9yd66BRh+hWlW1f26UguoFzHCWGpIA4dukj7TmDGB2ApSvWH9/r6jm8D4xWE7GTgQT/pujr3GJqsq2Z/nESpE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723830972; c=relaxed/simple; bh=RoFVR6yT4mNH3ObeqFb9/cnsR2z5ewXxy5Jl49It58M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DpC+we7JK7UOcaAPneAIY4uoCJ9rHzEzwdYwU6Ca4MvGPMzc0xDjkUlfK6tp9smf+qAvH1anJ15GKlJV4mVpI5XmKRyer9VmOWFtP61hQ0pTJ8gCjuq8By4NBxqaNW03XcC3zdZhT3QKpbJ1sk727rZRNzU+a3P867ReLpU7uko= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=W7ZPytUm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="W7ZPytUm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 813A8C4AF0F; Fri, 16 Aug 2024 17:56:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723830972; bh=RoFVR6yT4mNH3ObeqFb9/cnsR2z5ewXxy5Jl49It58M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=W7ZPytUmP3jDEptkTeaqmKxNQJnCRJIoMu8N5O3BMKkt1tJpNBDuuapCMAowQjQUZ SN4HyfNQE544DYHqVuqmRTeJFMNgSB0CgbuiGvSWGYdALmgTOWg6I/+foF9cWpXtUX YNVXR5UhTEnTB+V92vSFUD5wBGk2PNldgJVJzpLeo/ox7MJJuzNVidOsgch7NyJGO0 uqmpq/2fm/T1kb4ORHBIBzy9/Yr+lVbvkhMBcDFLqpeEIqHTsIpYndATVdkNeqQtrq x74YirrpaGgHD7RFWH0BY+0Eo2mNErEjttwvDvxK8u/RdCnA3D6erBP9O0YMQsbhZH UNz/jv0y0UUQA== From: "Matthieu Baerts (NGI0)" Date: Fri, 16 Aug 2024 19:55:52 +0200 Subject: [PATCH bpf-next 1/2] selftests: bpf: use KHDR_INCLUDES for the UAPI headers Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240816-ups-bpf-next-selftests-use-khdr-v1-1-1e19f3d5b17a@kernel.org> References: <20240816-ups-bpf-next-selftests-use-khdr-v1-0-1e19f3d5b17a@kernel.org> In-Reply-To: <20240816-ups-bpf-next-selftests-use-khdr-v1-0-1e19f3d5b17a@kernel.org> To: mptcp@lists.linux.dev, Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer Cc: bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=8160; i=matttbe@kernel.org; h=from:subject:message-id; bh=RoFVR6yT4mNH3ObeqFb9/cnsR2z5ewXxy5Jl49It58M=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmv5KyVrlqMX2LUx/4FY3pb5V2qCzSomZi8IBY0 wiDWNoAcdOJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZr+SsgAKCRD2t4JPQmmg c0R7EACYD5d2GOAfk5hnKib0EsuAB3d50dmam5U4kLLqsYWcRspu+2t+z4roDSCxPEvhnsvL8Nm pZ3kQIb5BMZ36fzmJ2Ojq04t2QXz1zO2kL3n2qEIbiOEsxA8hg9/NBJY1FLc5hq0XYDGXIqCrvS AxAxGzG//jrUfO5Q4PQ3O5v7k6ivoxterTVwqi79lN1R7DNr3HuDse39bsvNQlzFTWkc23L/wtf VJi0FqOObawHyNTsxorOMuBKGl/AkKLARSsSi6vnt3RJG00DM58NL5aidjXT9J4L0mQOePPAJ7T k2W8tN2tzujZt+vqLEbxmR6ztD0h9XdehMIVb0Z11tqeDVMOWx+gL60X6cmGop8VFjYhxQ1NE7S 09FivtaVNd8xU703IN650fbrppPBKyH2QJKQrfmuO+EVnlIkZdSQqSibWz2V3hqLxjKMN/LuLBj ed7V4tMYNa6fxYCIjc8p5vTfz8Lu7jfYqlqE9memnHGcJ/sOtDzOUI+CSvE3qXQC4Bv09CQB0zq 6uzgWLyMnn6bYhNNI6GWR9P+uYsFP47O6jBGPuFP7Q/3WxoTGw+erOBJGPktrkKhEcbu7o+Q4wd njH32AuRp+5aePiMUu27u8ddIHpF7CFzOEtzl4fajuEf4fwOk3YhUg2WM2JZubSta8lIh/r7u1x ULixg4bqtreqoeQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Instead of duplicating UAPI header files in 'tools/include/uapi', the BPF selftests can also look at the header files inside the kernel source. To do that, the kernel selftests infrastructure provides the 'KHDR_INCLUDES' variable. This is what is being used in most selftests, because it is what is recommended in the documentation [1]. If the selftests are not executed from the kernel sources, it is possible to override the variable, e.g. make KHDR_INCLUDES=3D"-I${HDR_DIR}/include" -C "${KSFT_DIR}" ... where ${HDR_DIR} has been generated by this command: make headers_install INSTALL_HDR_PATH=3D"${HDR_DIR}" Thanks to 'KHDR_INCLUDES', it is no longer needed to duplicate header files for userspace test programs, and these programs can include UAPI header files without the 'uapi' prefix. Note that it is still required to use 'tools/include/uapi' -- APIDIR, which corresponds to TOOLS_INCLUDES from lib.mk -- for the BPF programs, not to conflict with what is already defined in vmlinux.h. Link: https://docs.kernel.org/dev-tools/kselftest.html#contributing-new-tes= ts-details [1] Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/bpf/Makefile | 2 +- tools/testing/selftests/bpf/prog_tests/assign_reuse.c | 2 +- tools/testing/selftests/bpf/prog_tests/tc_links.c | 4 ++-- tools/testing/selftests/bpf/prog_tests/tc_netkit.c | 2 +- tools/testing/selftests/bpf/prog_tests/tc_opts.c | 2 +- tools/testing/selftests/bpf/prog_tests/user_ringbuf.c | 2 +- tools/testing/selftests/bpf/prog_tests/xdp_bonding.c | 2 +- tools/testing/selftests/bpf/prog_tests/xdp_cpumap_attach.c | 2 +- tools/testing/selftests/bpf/prog_tests/xdp_devmap_attach.c | 2 +- tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c | 2 +- tools/testing/selftests/bpf/prog_tests/xdp_link.c | 2 +- tools/testing/selftests/bpf/xdp_features.c | 4 ++-- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests= /bpf/Makefile index 4eceb491a8ae..6a7aeae7e206 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -37,7 +37,7 @@ CFLAGS +=3D -g $(OPT_FLAGS) -rdynamic \ -Wall -Werror -fno-omit-frame-pointer \ $(GENFLAGS) $(SAN_CFLAGS) $(LIBELF_CFLAGS) \ -I$(CURDIR) -I$(INCLUDE_DIR) -I$(GENDIR) -I$(LIBDIR) \ - -I$(TOOLSINCDIR) -I$(APIDIR) -I$(OUTPUT) + -I$(TOOLSINCDIR) $(KHDR_INCLUDES) -I$(OUTPUT) LDFLAGS +=3D $(SAN_LDFLAGS) LDLIBS +=3D $(LIBELF_LIBS) -lz -lrt -lpthread =20 diff --git a/tools/testing/selftests/bpf/prog_tests/assign_reuse.c b/tools/= testing/selftests/bpf/prog_tests/assign_reuse.c index 989ee4d9785b..3d06bf5a1ba4 100644 --- a/tools/testing/selftests/bpf/prog_tests/assign_reuse.c +++ b/tools/testing/selftests/bpf/prog_tests/assign_reuse.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2023 Isovalent */ -#include +#include #include =20 #include diff --git a/tools/testing/selftests/bpf/prog_tests/tc_links.c b/tools/test= ing/selftests/bpf/prog_tests/tc_links.c index 1af9ec1149aa..532e162185c3 100644 --- a/tools/testing/selftests/bpf/prog_tests/tc_links.c +++ b/tools/testing/selftests/bpf/prog_tests/tc_links.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2023 Isovalent */ -#include -#include +#include +#include #include #include =20 diff --git a/tools/testing/selftests/bpf/prog_tests/tc_netkit.c b/tools/tes= ting/selftests/bpf/prog_tests/tc_netkit.c index b9135720024c..1c8b8f03e873 100644 --- a/tools/testing/selftests/bpf/prog_tests/tc_netkit.c +++ b/tools/testing/selftests/bpf/prog_tests/tc_netkit.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2023 Isovalent */ -#include +#include #include #include =20 diff --git a/tools/testing/selftests/bpf/prog_tests/tc_opts.c b/tools/testi= ng/selftests/bpf/prog_tests/tc_opts.c index 196abf223465..14aee536c519 100644 --- a/tools/testing/selftests/bpf/prog_tests/tc_opts.c +++ b/tools/testing/selftests/bpf/prog_tests/tc_opts.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2023 Isovalent */ -#include +#include #include #include =20 diff --git a/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c b/tools/= testing/selftests/bpf/prog_tests/user_ringbuf.c index dfff6feac12c..a37dda1b3cd2 100644 --- a/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c +++ b/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include =20 #include "user_ringbuf_fail.skel.h" diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_bonding.c b/tools/t= esting/selftests/bpf/prog_tests/xdp_bonding.c index 6d8b54124cb3..ee9bd8606d14 100644 --- a/tools/testing/selftests/bpf/prog_tests/xdp_bonding.c +++ b/tools/testing/selftests/bpf/prog_tests/xdp_bonding.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include =20 #include "xdp_dummy.skel.h" #include "xdp_redirect_multi_kern.skel.h" diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_cpumap_attach.c b/t= ools/testing/selftests/bpf/prog_tests/xdp_cpumap_attach.c index 481626a875d1..e63a193e29e8 100644 --- a/tools/testing/selftests/bpf/prog_tests/xdp_cpumap_attach.c +++ b/tools/testing/selftests/bpf/prog_tests/xdp_cpumap_attach.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -#include +#include #include #include =20 diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_devmap_attach.c b/t= ools/testing/selftests/bpf/prog_tests/xdp_devmap_attach.c index ce6812558287..b916fa945b15 100644 --- a/tools/testing/selftests/bpf/prog_tests/xdp_devmap_attach.c +++ b/tools/testing/selftests/bpf/prog_tests/xdp_devmap_attach.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -#include +#include #include #include =20 diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c b/too= ls/testing/selftests/bpf/prog_tests/xdp_do_redirect.c index bad0ea167be7..c40a25837233 100644 --- a/tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c +++ b/tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include "test_xdp_do_redirect.skel.h" =20 struct udp_packet { diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_link.c b/tools/test= ing/selftests/bpf/prog_tests/xdp_link.c index e7e9f3c22edf..ab92c395a7c7 100644 --- a/tools/testing/selftests/bpf/prog_tests/xdp_link.c +++ b/tools/testing/selftests/bpf/prog_tests/xdp_link.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2020 Facebook */ -#include +#include #include #include "test_xdp_link.skel.h" =20 diff --git a/tools/testing/selftests/bpf/xdp_features.c b/tools/testing/sel= ftests/bpf/xdp_features.c index 595c79141cf3..99b54674d94e 100644 --- a/tools/testing/selftests/bpf/xdp_features.c +++ b/tools/testing/selftests/bpf/xdp_features.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 -#include -#include +#include +#include #include #include #include --=20 2.45.2 From nobody Sun Nov 24 13:04:29 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71DFC1C68BC; Fri, 16 Aug 2024 17:56:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723830977; cv=none; b=f7cqhT/EPO/O8X+unFi+MUS3eR9wfZzLGqnAJIu+jWRk34d9JTvbV7zUIB0Pl3rVTwefI4AmrlUzqiecJuFLOntplstSM0DsCJ5SktOxUS/FipV08twM/FnW16i5ZQp1/1L2xdlEVs6Verh5RV+ZmJpL2oW8+fmsxcEKJQac2cs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723830977; c=relaxed/simple; bh=1nTnm/+BPLU9cVwWoXDMCuedVYe8mzXtHdP/ivu98UA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Jl7sBSW3FEtdquinvqXY6MqGZsU4i3D4omv52TYkX5jf19mn1BI/f4hsqoti+/coryCxPLNRoypoW9dPgtpuqXh0elWCVftieTBoJyzFqDKtQsQ4YrU7GxANVj54zJHNix1ssIld/RdD+/VwE4Hbj8ueAEnbyW9KXenhCnbiCP0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TW7ZmdZ7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TW7ZmdZ7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7494AC32782; Fri, 16 Aug 2024 17:56:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723830977; bh=1nTnm/+BPLU9cVwWoXDMCuedVYe8mzXtHdP/ivu98UA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=TW7ZmdZ74Qv2yYxlLEFJVTNsrLAcml2w+pZUFPw9eJhk+1el7+H1Vb6u4cPW/ZRb0 N+w3mYxSDp6r9E0PPGNCp9Wa4XpiZLmdsR6isWgtdWX+VjIXM/9T8CYF+fZubUGElQ GJ8T8I5b4CjWNUbjSKOKy6K0SyrlxQSjzula6RIfuLvS95RfMVyb1wuXQzVEcOWxRd bkxAdXsG/FnP/shnE06DgmNvT3kg31NpRkc7A3yzZu4DmB2DPDYmCcPoAdmQgT0ZP9 hA0cMexKlETeTsEPFfbZc5SkLPAOhzj2+ZCVwtlhvoF6oGXY6ZAHV+HN6px+tI8E2R G8c+yzYhqLNjA== From: "Matthieu Baerts (NGI0)" Date: Fri, 16 Aug 2024 19:55:53 +0200 Subject: [PATCH bpf-next 2/2] selftests: bpf: remove duplicated UAPI if_xdp headers Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240816-ups-bpf-next-selftests-use-khdr-v1-2-1e19f3d5b17a@kernel.org> References: <20240816-ups-bpf-next-selftests-use-khdr-v1-0-1e19f3d5b17a@kernel.org> In-Reply-To: <20240816-ups-bpf-next-selftests-use-khdr-v1-0-1e19f3d5b17a@kernel.org> To: mptcp@lists.linux.dev, Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer Cc: bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=7279; i=matttbe@kernel.org; h=from:subject:message-id; bh=1nTnm/+BPLU9cVwWoXDMCuedVYe8mzXtHdP/ivu98UA=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmv5KyWvPWfAKfgQov1oKBL4O5YXVEuXa/x49q/ lX0K61rFOWJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZr+SsgAKCRD2t4JPQmmg c36TEAC8lekkD1MbsUYRYRgb/DHI0sb8IMEjaj0UMlLgXQD3ku2Hpklqu9VujgxDK+iEJ6JAJQ6 aambDfVSOvG+C1lad1qbPGb+wK4U48+h5HN5QrjOtYRy0M80eiB0Hl0oj1Em7NTZqmUDa7Fj0d2 z4RNYIVPqYQcpOQDZtADHqnYQCsDQGADl1RVudLs7cbw974Y6DUD/D1eBvwuxH0BfffnYM5wefE 1Bp1bdhSi6xRXryz5ra5rLKcwmoQPbuF3JG6YQe4tiaqf+ZmiZ9AnQMZoaz+mMA3ApslkaDoi0r s57Qcx0/zmx4hxRkIqhycNJ7Th2LXIqGgpO5JwLGJ7ez8dvyDf1Sk0hXR7j9XTfx250XP4zuX/o DnE7L7+CSd+p7QNpUnJbtOk+5qrJdYQjSmcRxQgPNqLra1thmTDkf+fvxslnpcpxarTtJITIOrE 8PNfMPt6hHgf/DAxcz2mdeDrHOkTGr9nv+II4YXJqEKB1bULB63/nnk35xaCO0fgo/PLIG9AB+X hvj8x4CkEBkoY1hBvP6wfUvrT9lJj4mNcoLDGsJOVFZYpe11w6uA/kl0LxrhGCmnHLokkOdkPOv DK3bDHl1kil5gj0nyUxoGkrG90m+wzvMd1EmhtbbBvXtRxnkOwf+sAOuFF241DFNwe3wcM8OfOr 1W+NdxOu8TByfKA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Thanks to the previous commit, this file is no longer needed, because the BPF selftests will take the UAPI headers from the kernel source. Note that this file was an old copy of the UAPI one, which was causing a warning at compilation time: Warning: Kernel ABI header at 'tools/include/uapi/linux/if_xdp.h' differs= from latest version at 'include/uapi/linux/if_xdp.h' Signed-off-by: Matthieu Baerts (NGI0) --- tools/include/uapi/linux/if_xdp.h | 173 ----------------------------------= ---- tools/lib/bpf/Makefile | 3 - 2 files changed, 176 deletions(-) diff --git a/tools/include/uapi/linux/if_xdp.h b/tools/include/uapi/linux/i= f_xdp.h deleted file mode 100644 index 2f082b01ff22..000000000000 --- a/tools/include/uapi/linux/if_xdp.h +++ /dev/null @@ -1,173 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -/* - * if_xdp: XDP socket user-space interface - * Copyright(c) 2018 Intel Corporation. - * - * Author(s): Bj=C3=B6rn T=C3=B6pel - * Magnus Karlsson - */ - -#ifndef _LINUX_IF_XDP_H -#define _LINUX_IF_XDP_H - -#include - -/* Options for the sxdp_flags field */ -#define XDP_SHARED_UMEM (1 << 0) -#define XDP_COPY (1 << 1) /* Force copy-mode */ -#define XDP_ZEROCOPY (1 << 2) /* Force zero-copy mode */ -/* If this option is set, the driver might go sleep and in that case - * the XDP_RING_NEED_WAKEUP flag in the fill and/or Tx rings will be - * set. If it is set, the application need to explicitly wake up the - * driver with a poll() (Rx and Tx) or sendto() (Tx only). If you are - * running the driver and the application on the same core, you should - * use this option so that the kernel will yield to the user space - * application. - */ -#define XDP_USE_NEED_WAKEUP (1 << 3) -/* By setting this option, userspace application indicates that it can - * handle multiple descriptors per packet thus enabling AF_XDP to split - * multi-buffer XDP frames into multiple Rx descriptors. Without this set - * such frames will be dropped. - */ -#define XDP_USE_SG (1 << 4) - -/* Flags for xsk_umem_config flags */ -#define XDP_UMEM_UNALIGNED_CHUNK_FLAG (1 << 0) - -/* Force checksum calculation in software. Can be used for testing or - * working around potential HW issues. This option causes performance - * degradation and only works in XDP_COPY mode. - */ -#define XDP_UMEM_TX_SW_CSUM (1 << 1) - -/* Request to reserve tx_metadata_len bytes of per-chunk metadata. - */ -#define XDP_UMEM_TX_METADATA_LEN (1 << 2) - -struct sockaddr_xdp { - __u16 sxdp_family; - __u16 sxdp_flags; - __u32 sxdp_ifindex; - __u32 sxdp_queue_id; - __u32 sxdp_shared_umem_fd; -}; - -/* XDP_RING flags */ -#define XDP_RING_NEED_WAKEUP (1 << 0) - -struct xdp_ring_offset { - __u64 producer; - __u64 consumer; - __u64 desc; - __u64 flags; -}; - -struct xdp_mmap_offsets { - struct xdp_ring_offset rx; - struct xdp_ring_offset tx; - struct xdp_ring_offset fr; /* Fill */ - struct xdp_ring_offset cr; /* Completion */ -}; - -/* XDP socket options */ -#define XDP_MMAP_OFFSETS 1 -#define XDP_RX_RING 2 -#define XDP_TX_RING 3 -#define XDP_UMEM_REG 4 -#define XDP_UMEM_FILL_RING 5 -#define XDP_UMEM_COMPLETION_RING 6 -#define XDP_STATISTICS 7 -#define XDP_OPTIONS 8 - -struct xdp_umem_reg { - __u64 addr; /* Start of packet data area */ - __u64 len; /* Length of packet data area */ - __u32 chunk_size; - __u32 headroom; - __u32 flags; - __u32 tx_metadata_len; -}; - -struct xdp_statistics { - __u64 rx_dropped; /* Dropped for other reasons */ - __u64 rx_invalid_descs; /* Dropped due to invalid descriptor */ - __u64 tx_invalid_descs; /* Dropped due to invalid descriptor */ - __u64 rx_ring_full; /* Dropped due to rx ring being full */ - __u64 rx_fill_ring_empty_descs; /* Failed to retrieve item from fill ring= */ - __u64 tx_ring_empty_descs; /* Failed to retrieve item from tx ring */ -}; - -struct xdp_options { - __u32 flags; -}; - -/* Flags for the flags field of struct xdp_options */ -#define XDP_OPTIONS_ZEROCOPY (1 << 0) - -/* Pgoff for mmaping the rings */ -#define XDP_PGOFF_RX_RING 0 -#define XDP_PGOFF_TX_RING 0x80000000 -#define XDP_UMEM_PGOFF_FILL_RING 0x100000000ULL -#define XDP_UMEM_PGOFF_COMPLETION_RING 0x180000000ULL - -/* Masks for unaligned chunks mode */ -#define XSK_UNALIGNED_BUF_OFFSET_SHIFT 48 -#define XSK_UNALIGNED_BUF_ADDR_MASK \ - ((1ULL << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1) - -/* Request transmit timestamp. Upon completion, put it into tx_timestamp - * field of union xsk_tx_metadata. - */ -#define XDP_TXMD_FLAGS_TIMESTAMP (1 << 0) - -/* Request transmit checksum offload. Checksum start position and offset - * are communicated via csum_start and csum_offset fields of union - * xsk_tx_metadata. - */ -#define XDP_TXMD_FLAGS_CHECKSUM (1 << 1) - -/* AF_XDP offloads request. 'request' union member is consumed by the driv= er - * when the packet is being transmitted. 'completion' union member is - * filled by the driver when the transmit completion arrives. - */ -struct xsk_tx_metadata { - __u64 flags; - - union { - struct { - /* XDP_TXMD_FLAGS_CHECKSUM */ - - /* Offset from desc->addr where checksumming should start. */ - __u16 csum_start; - /* Offset from csum_start where checksum should be stored. */ - __u16 csum_offset; - } request; - - struct { - /* XDP_TXMD_FLAGS_TIMESTAMP */ - __u64 tx_timestamp; - } completion; - }; -}; - -/* Rx/Tx descriptor */ -struct xdp_desc { - __u64 addr; - __u32 len; - __u32 options; -}; - -/* UMEM descriptor is __u64 */ - -/* Flag indicating that the packet continues with the buffer pointed out b= y the - * next frame in the ring. The end of the packet is signalled by setting t= his - * bit to zero. For single buffer packets, every descriptor has 'options' = set - * to 0 and this maintains backward compatibility. - */ -#define XDP_PKT_CONTD (1 << 0) - -/* TX packet carries valid metadata. */ -#define XDP_TX_METADATA (1 << 1) - -#endif /* _LINUX_IF_XDP_H */ diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile index 2cf892774346..977dba26ba87 100644 --- a/tools/lib/bpf/Makefile +++ b/tools/lib/bpf/Makefile @@ -148,9 +148,6 @@ $(BPF_IN_SHARED): force $(BPF_GENERATED) @(test -f ../../include/uapi/linux/bpf_common.h -a -f ../../../include/ua= pi/linux/bpf_common.h && ( \ (diff -B ../../include/uapi/linux/bpf_common.h ../../../include/uapi/linu= x/bpf_common.h >/dev/null) || \ echo "Warning: Kernel ABI header at 'tools/include/uapi/linux/bpf_common.= h' differs from latest version at 'include/uapi/linux/bpf_common.h'" >&2 ))= || true - @(test -f ../../include/uapi/linux/if_xdp.h -a -f ../../../include/uapi/l= inux/if_xdp.h && ( \ - (diff -B ../../include/uapi/linux/if_xdp.h ../../../include/uapi/linux/if= _xdp.h >/dev/null) || \ - echo "Warning: Kernel ABI header at 'tools/include/uapi/linux/if_xdp.h' d= iffers from latest version at 'include/uapi/linux/if_xdp.h'" >&2 )) || true $(Q)$(MAKE) $(build)=3Dlibbpf OUTPUT=3D$(SHARED_OBJDIR) CFLAGS=3D"$(CFLAG= S) $(SHLIB_FLAGS)" =20 $(BPF_IN_STATIC): force $(BPF_GENERATED) --=20 2.45.2