From patchwork Tue May 31 00:46:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1637175 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LBtrk5gcZz9s1l for ; Tue, 31 May 2022 10:46:46 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id E4B9F82FCE; Tue, 31 May 2022 00:46:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yzX-RQ2L4tpf; Tue, 31 May 2022 00:46:44 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 191A482DE6; Tue, 31 May 2022 00:46:43 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E0184C0032; Tue, 31 May 2022 00:46:42 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id AAF19C002D for ; Tue, 31 May 2022 00:46:41 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 5320D41C30 for ; Tue, 31 May 2022 00:46:32 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SgCxoPvlN7m0 for ; Tue, 31 May 2022 00:46:31 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by smtp4.osuosl.org (Postfix) with ESMTPS id E3F3341C2B for ; Tue, 31 May 2022 00:46:30 +0000 (UTC) Received: (Authenticated sender: numans@ovn.org) by mail.gandi.net (Postfix) with ESMTPSA id 1B648C0006; Tue, 31 May 2022 00:46:26 +0000 (UTC) From: numans@ovn.org To: dev@openvswitch.org Date: Mon, 30 May 2022 20:46:13 -0400 Message-Id: <20220531004613.3873477-1-numans@ovn.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220531004237.3872754-1-numans@ovn.org> References: <20220531004237.3872754-1-numans@ovn.org> MIME-Version: 1.0 Subject: [ovs-dev] [RFC ovn 1/2] RFC: Add basic xdp/eBPF support in OVN. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Numan Siddique 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 --- 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 ' `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 ."; \ @@ -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 +#include + +SEC("xdp") +int xdp_ovn_vif(struct xdp_md *xdp) +{ + return XDP_PASS; +} + +char _license[] SEC("license") = "GPL";