diff options
author | Ilya Maximets <i.maximets@ovn.org> | 2022-12-22 01:06:24 +0100 |
---|---|---|
committer | Ilya Maximets <i.maximets@ovn.org> | 2023-01-03 16:06:30 +0100 |
commit | e44e80343189fcb7ec10d776f1b62747d7095c18 (patch) | |
tree | 3a3a73291c444a36764e02732c19e114b23cef52 /acinclude.m4 | |
parent | 771a55825f4a1d84c18439ae5a7485807169b0f9 (diff) | |
download | openvswitch-e44e80343189fcb7ec10d776f1b62747d7095c18.tar.gz |
acinclude.m4: Build with AF_XDP support by default if possible.
With this change we will try to detect all the netdev-afxdp
dependencies and enable AF_XDP support by default if they are
present at the build time.
Configuration script behaves in a following way:
- ./configure --enable-afxdp
Will check for AF_XDP dependencies and fail if they are
not available.
- ./configure --disable-afxdp
Disables checking for AF_XDP. Build will not support
AF_XDP even if all dependencies are installed.
- Just ./configure or ./configure --enable-afxdp=auto
Will check for AF_XDP dependencies. Will print a warning
if they are not available, but will continue without AF_XDP
support. If dependencies are available in a system, this
option is equal to --enable-afxdp.
'--disable-afxdp' added to the debian and fedora package builds
to keep predictable behavior.
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'acinclude.m4')
-rw-r--r-- | acinclude.m4 | 72 |
1 files changed, 48 insertions, 24 deletions
diff --git a/acinclude.m4 b/acinclude.m4 index e47e925b3..8aecfb63d 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -253,46 +253,70 @@ dnl OVS_CHECK_LINUX_AF_XDP dnl dnl Check both Linux kernel AF_XDP and libbpf/libxdp support AC_DEFUN([OVS_CHECK_LINUX_AF_XDP], [ - AC_ARG_ENABLE([afxdp], - [AS_HELP_STRING([--enable-afxdp], [Enable AF-XDP support])], - [], [enable_afxdp=no]) + AC_ARG_ENABLE( + [afxdp], + [AS_HELP_STRING([--disable-afxdp], [Disable AF-XDP support])], + [case "${enableval}" in + (yes | no | auto) ;; + (*) AC_MSG_ERROR([bad value ${enableval} for --enable-afxdp]) ;; + esac], + [enable_afxdp=auto]) + AC_MSG_CHECKING([whether AF_XDP is enabled]) - if test "$enable_afxdp" != yes; then + if test "$enable_afxdp" == no; then AC_MSG_RESULT([no]) AF_XDP_ENABLE=false else - AC_MSG_RESULT([yes]) + AC_MSG_RESULT([$enable_afxdp]) AF_XDP_ENABLE=true + failed_dep=none + dnl Saving libs to restore in case we will end up not building with AF_XDP. + save_LIBS=$LIBS - AC_CHECK_HEADER([bpf/libbpf.h], [], - [AC_MSG_ERROR([unable to find bpf/libbpf.h for AF_XDP support])]) + AC_CHECK_HEADER([bpf/libbpf.h], [], [failed_dep="bpf/libbpf.h"]) - AC_CHECK_HEADER([linux/if_xdp.h], [], - [AC_MSG_ERROR([unable to find linux/if_xdp.h for AF_XDP support])]) + if test "$failed_dep" = none; then + AC_CHECK_HEADER([linux/if_xdp.h], [], [failed_dep="linux/if_xdp.h"]) + fi - OVS_FIND_DEPENDENCY([libbpf_strerror], [bpf], [libbpf]) - AC_CHECK_FUNCS([bpf_xdp_query_id bpf_xdp_detach]) + if test "$failed_dep" = none; then + AC_SEARCH_LIBS([libbpf_strerror], [bpf], [], [failed_dep="libbpf"]) + AC_CHECK_FUNCS([bpf_xdp_query_id bpf_xdp_detach]) + fi - if test "x$ac_cv_func_bpf_xdp_detach" = xyes; then + if test "$failed_dep" = none -a "x$ac_cv_func_bpf_xdp_detach" = xyes; then dnl We have libbpf >= 0.7. Look for libxdp as xsk functions dnl were moved into this library. - OVS_FIND_DEPENDENCY([libxdp_strerror], [xdp], [libxdp]) - AC_CHECK_HEADER([xdp/xsk.h], - AC_DEFINE([HAVE_LIBXDP], [1], [xsk.h is supplied with libxdp]), - AC_MSG_ERROR([unable to find xdp/xsk.h for AF_XDP support])) - else + AC_SEARCH_LIBS([libxdp_strerror], [xdp], + AC_CHECK_HEADER([xdp/xsk.h], + AC_DEFINE([HAVE_LIBXDP], [1], [xsk.h is supplied with libxdp]), + [failed_dep="xdp/xsk.h"]), + [failed_dep="libxdp"]) + elif test "$failed_dep" = none; then dnl libbpf < 0.7 contains all the necessary functionality. - AC_CHECK_HEADER([bpf/xsk.h], [], - [AC_MSG_ERROR([unable to find bpf/xsk.h for AF_XDP support])]) + AC_CHECK_HEADER([bpf/xsk.h], [], [failed_dep="bpf/xsk.h"]) fi - AC_CHECK_FUNCS([pthread_spin_lock], [], - [AC_MSG_ERROR([unable to find pthread_spin_lock for AF_XDP support])]) + if test "$failed_dep" = none; then + AC_CHECK_FUNCS([pthread_spin_lock], [], [failed_dep="pthread_spin_lock"]) + fi - OVS_FIND_DEPENDENCY([numa_alloc_onnode], [numa], [libnuma]) + if test "$failed_dep" = none; then + AC_SEARCH_LIBS([numa_alloc_onnode], [numa], [], [failed_dep="libnuma"]) + fi - AC_DEFINE([HAVE_AF_XDP], [1], - [Define to 1 if AF_XDP support is available and enabled.]) + if test "$failed_dep" = none; then + AC_DEFINE([HAVE_AF_XDP], [1], + [Define to 1 if AF_XDP support is available and enabled.]) + elif test "$enable_afxdp" = yes; then + AC_MSG_ERROR([Missing $failed_dep dependency for AF_XDP support]) + else + AC_MSG_WARN(m4_normalize( + [Cannot find $failed_dep, netdev-afxdp will not be supported + (use --disable-afxdp to suppress this warning).])) + AF_XDP_ENABLE=false + LIBS=$save_LIBS + fi fi AM_CONDITIONAL([HAVE_AF_XDP], test "$AF_XDP_ENABLE" = true) ]) |