From: Numan Siddique <[email protected]> This patch just adds an xdp program and the support in the Makefile to compile it. A separate target is added in the Makefile. To compile, user has to run: 'make bpf'.
Signed-off-by: Numan Siddique <[email protected]> --- Makefile.am | 6 +++++- bpf/.gitignore | 5 +++++ bpf/automake.mk | 23 +++++++++++++++++++++++ bpf/ovn_xdp.c | 11 +++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 bpf/.gitignore create mode 100644 bpf/automake.mk create mode 100644 bpf/ovn_xdp.c diff --git a/Makefile.am b/Makefile.am index 3b0df83938..518be9c101 100644 --- a/Makefile.am +++ b/Makefile.am @@ -120,6 +120,7 @@ dist_pkgdata_SCRIPTS = dist_sbin_SCRIPTS = dist_scripts_SCRIPTS = dist_scripts_DATA = +dist_bpf_DATA = EXTRA_PROGRAMS = INSTALL_DATA_LOCAL = UNINSTALL_LOCAL = @@ -139,6 +140,7 @@ sbin_SCRIPTS = scripts_SCRIPTS = completion_SCRIPTS = scripts_DATA = +bpf_DATA = SUFFIXES = check_DATA = check_SCRIPTS = @@ -152,6 +154,7 @@ endif scriptsdir = $(pkgdatadir)/scripts completiondir = $(sysconfdir)/bash_completion.d pkgconfigdir = $(libdir)/pkgconfig +bpfdir = $(pkgdatadir)/bpf # This ensures that files added to EXTRA_DIST are always distributed, # even if they are inside an Automake if...endif conditional block that is @@ -255,7 +258,7 @@ config-h-check: @cd $(srcdir); \ if test -e .git && (git --version) >/dev/null 2>&1 && \ git --no-pager grep -L '#include <config\.h>' `git ls-files | grep -v $(submodules) | grep '\.c$$' | \ - grep -vE '^python'`; \ + grep -vE '^bpf|^python'`; \ then \ echo "See above for list of violations of the rule that"; \ echo "every C source file must #include <config.h>."; \ @@ -493,6 +496,7 @@ include debian/automake.mk include lib/ovsdb_automake.mk include rhel/automake.mk include tutorial/automake.mk +include bpf/automake.mk include controller/automake.mk include controller-vtep/automake.mk include northd/automake.mk diff --git a/bpf/.gitignore b/bpf/.gitignore new file mode 100644 index 0000000000..b0f4f8eaff --- /dev/null +++ b/bpf/.gitignore @@ -0,0 +1,5 @@ +/Makefile +/Makefile.in +*.o +/distfiles + diff --git a/bpf/automake.mk b/bpf/automake.mk new file mode 100644 index 0000000000..7c44682335 --- /dev/null +++ b/bpf/automake.mk @@ -0,0 +1,23 @@ +bpf_sources = bpf/ovn_xdp.c +bpf_headers = +bpf_extra = + +dist_sources = $(bpf_sources) +dist_headers = $(bpf_headers) +build_sources = $(dist_sources) +build_headers = $(dist_headers) +build_objects = $(patsubst %.c,%.o,$(build_sources)) + +LLC ?= llc +CLANG ?= clang + +bpf: $(build_objects) +bpf/ovn_xdp.o: $(bpf_sources) $(bpf_headers) + $(MKDIR_P) $(dir $@) + @which $(CLANG) >/dev/null 2>&1 || \ + (echo "Unable to find clang, Install clang (>=3.7) package"; exit 1) + $(AM_V_CC) $(CLANG) -O3 -c $< -o - -emit-llvm | \ + $(LLC) -march=bpf - -filetype=obj -o $@ + + +EXTRA_DIST += $(dist_sources) $(dist_headers) $(bpf_extra) diff --git a/bpf/ovn_xdp.c b/bpf/ovn_xdp.c new file mode 100644 index 0000000000..9515a1d1bf --- /dev/null +++ b/bpf/ovn_xdp.c @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#include <linux/bpf.h> +#include <bpf/bpf_helpers.h> + +SEC("xdp") +int xdp_ovn_vif(struct xdp_md *xdp) +{ + return XDP_PASS; +} + +char _license[] SEC("license") = "GPL"; -- 2.35.3 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
