diff mbox

[RFC:,add,openvswitch,actions,using,BPF,4/9] autoconf: support -with-llc options

Message ID 1423090163-19902-5-git-send-email-azhou@nicira.com
State RFC, archived
Delegated to: David Miller
Headers show

Commit Message

Andy Zhou Feb. 4, 2015, 10:49 p.m. UTC
Add a configuration option to allow specifing the LLVM backend module
for compiling BPF C source code into BPF instruction sets.

See INSTALL.BPF.md for usgae information.

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Signed-off-by: Andy Zhou <azhou@nicira.com>
---
 INSTALL.BPF.md | 42 ++++++++++++++++++++++++++++++++++++++++++
 Makefile.am    |  1 +
 acinclude.m4   | 16 ++++++++++++++++
 configure.ac   |  2 ++
 4 files changed, 61 insertions(+)
 create mode 100644 INSTALL.BPF.md

Comments

Joe Stringer Feb. 6, 2015, 6:12 p.m. UTC | #1
On 4 February 2015 at 14:49, Andy Zhou <azhou@nicira.com> wrote:
> Add a configuration option to allow specifing the LLVM backend module
> for compiling BPF C source code into BPF instruction sets.
>
> See INSTALL.BPF.md for usgae information.
>
> Signed-off-by: Joe Stringer <joestringer@nicira.com>
> Signed-off-by: Andy Zhou <azhou@nicira.com>
> ---
>  INSTALL.BPF.md | 42 ++++++++++++++++++++++++++++++++++++++++++
>  Makefile.am    |  1 +
>  acinclude.m4   | 16 ++++++++++++++++
>  configure.ac   |  2 ++
>  4 files changed, 61 insertions(+)
>  create mode 100644 INSTALL.BPF.md
>
> diff --git a/INSTALL.BPF.md b/INSTALL.BPF.md
> new file mode 100644
> index 0000000..bc1f5ad
> --- /dev/null
> +++ b/INSTALL.BPF.md
> @@ -0,0 +1,42 @@
> +# Dependencies
> +
> +- Need Clang + llvm-dev version 3.X for any (2 <= X <= 4)
> +- http://llvm.org/apt/
> +
> +apt-get install libelf-dev clang-3.4 llvm-3.4-dev
> +
> +# Build LLVM plugin
> +
> +*[Upstream] git://git.kernel.org/pub/scm/linux/kernel/git/ast/bpf*
> +
> +git clone git://github.com/joestringer/linux
> +NN=$PWD/linux
> +
> +cd $NN/tools/bpf/llvm/bld
> +make LLVM_CONFIG=`which llvm-config-3.4`
> +
> +# Configure OVS to use BPF LLC
> +
> +OVS=/path/to/openvswitch
> +cd $OVS
> +./configure --with-llc=$NN/tools/bpf/llvm/bld/Debug+Asserts/bin/llc

Naturally we'd need to update these instructions, this becomes much
simpler if we just require clang-3.7.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/INSTALL.BPF.md b/INSTALL.BPF.md
new file mode 100644
index 0000000..bc1f5ad
--- /dev/null
+++ b/INSTALL.BPF.md
@@ -0,0 +1,42 @@ 
+# Dependencies
+
+- Need Clang + llvm-dev version 3.X for any (2 <= X <= 4)
+- http://llvm.org/apt/
+
+apt-get install libelf-dev clang-3.4 llvm-3.4-dev
+
+# Build LLVM plugin
+
+*[Upstream] git://git.kernel.org/pub/scm/linux/kernel/git/ast/bpf*
+
+git clone git://github.com/joestringer/linux
+NN=$PWD/linux
+
+cd $NN/tools/bpf/llvm/bld
+make LLVM_CONFIG=`which llvm-config-3.4`
+
+# Configure OVS to use BPF LLC
+
+OVS=/path/to/openvswitch
+cd $OVS
+./configure --with-llc=$NN/tools/bpf/llvm/bld/Debug+Asserts/bin/llc
+
+# Build OVS and BPF module
+
+make
+cd datapath/bpf
+make
+
+# Load BPF module
+
+cd $NN/
+make M=samples/bpf
+samples/bpf/simple_load $OVS/datapath/bpf/simple.bpf
+
+Note down which fd was used for the program. This will be used in next step.
+
+# Install flow to use BPF
+
+$OVS/utilities/ovs-dpctl add-flow "eth(src=00:00:00:00:00:00,dst=00:00:00:00:00:00)" "bpf(<FD>, 0)"
+
+Success?
diff --git a/Makefile.am b/Makefile.am
index 1363abe..ee8fe03 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -71,6 +71,7 @@  docs = \
 	DESIGN.md \
 	FAQ.md \
 	INSTALL.md \
+	INSTALL.BPF.md \
 	INSTALL.Debian.md \
 	INSTALL.Docker.md \
 	INSTALL.DPDK.md \
diff --git a/acinclude.m4 b/acinclude.m4
index f419056..e3b5356 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -157,6 +157,22 @@  AC_DEFUN([OVS_CHECK_LINUX], [
   AM_CONDITIONAL(LINUX_ENABLED, test -n "$KBUILD")
 ])
 
+dnl OVS_CHECK_BPF
+dnl
+dnl Check clang set ups for compiling BPF
+AC_DEFUN([OVS_CHECK_LLC], [
+  AC_ARG_WITH([llc],
+              [AC_HELP_STRING([--with-llc=/path/to/llc],
+                              [Specify the bpf clang backend binrary])])
+
+  if (test X"$with_llc" != X); then
+    LLC=$with_llc
+      if (test ! -x $LLC); then
+         AC_MSG_ERROR([BPF llc backend is configured but not found ])
+      fi
+  fi
+])
+
 dnl OVS_CHECK_DPDK
 dnl
 dnl Configure DPDK source tree
diff --git a/configure.ac b/configure.ac
index d2d02ca..7510d56 100644
--- a/configure.ac
+++ b/configure.ac
@@ -160,8 +160,10 @@  OVS_ENABLE_SPARSE
 
 AC_ARG_VAR(KARCH, [Kernel Architecture String])
 AC_SUBST(KARCH)
+AC_ARG_VAR(LLC, [LLVM bpf backend processor])
 OVS_CHECK_LINUX
 OVS_CHECK_DPDK
+OVS_CHECK_LLC
 OVS_CHECK_PRAGMA_MESSAGE
 AC_SUBST([OVS_CFLAGS])
 AC_SUBST([OVS_LDFLAGS])