On 11/06/2026 12:07, Eelco Chaudron wrote:
External email: Use caution opening links or attachments


On 18 May 2026, at 13:27, Eli Britstein wrote:

From: Ariel Levkovich <[email protected]>

Add a new option to build ovs with doca by specifying '--with-doca' in the
configure line.

This flag must be used along with '--with-dpdk'. Otherwise the configure step
will fail.

An example:

./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc \
     --with-dpdk=static --with-doca=static

Note that the value selected for doca must be the same as selected for
dpdk.
Hi Ariel/Eli,
Thanks for the new revision.  I think we should not require a separate
option for --with-doca, it should figure out the link mode from
--with-dpdk and use that.  So your last line in the commit message
can be removed as it makes no sense to explicitly configure the same.

I think there should be an explicit knob to compile with doca.

I'd prefer to keep it as is, e.g. --with-doca (and a validity check for linkage type as dpdk).

The previous suggestion "--enable-doca" is explicit, but it's not consistent with other "with" options, but if you are really against --with-doca we can go with that.

WDYT?


See some more comments below.

//Eelco

Co-authored-by: Salem Sol <[email protected]>
...
+DPDK_VERSION_FILE="${DPDK_INSTALL_DIR}/cached-version"
+if [ -f "${DPDK_VERSION_FILE}" ]; then
This is a ci script so we should always assume a cached DPDK version.
Ack

+    DPDK_LIB=${DPDK_INSTALL_DIR}/lib/x86_64-linux-gnu
+    dpdk_pc="${DPDK_LIB}/pkgconfig:${DOCA_PKGCONFIG}"
+    cfg_tail="${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}"
+    export PKG_CONFIG_PATH="${dpdk_pc}${cfg_tail}"
+    export PATH="${DPDK_INSTALL_DIR}/bin:${PATH}"
+    dv=$(cat "${DPDK_VERSION_FILE}")
+    echo "Using cached DPDK ${dv} from ${DPDK_INSTALL_DIR}"
There are quite some tmp variables making it hard to read.
They were done to keep checkpatch happy. Revised.
+else
+    cfg_tail="${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}"
...
+    vswitchd/ovs-vswitchd -V || true
+    exit 1
+fi
We should also check that the build uses our cached DPDK version.
Ack

+export DISTCHECK_CONFIGURE_FLAGS="$EXTRA_OPTS"
+make distcheck ${JOBS} CFLAGS="${CFLAGS_FOR_OVS}" \
+    TESTSUITEFLAGS="${JOBS} ${TEST_RANGE}" RECHECK=yes
Running make once should be enough, and we should use make check,
something similar to what we did recently for FreeBSD.  I guess it
could look like this (not tested):

#!/bin/bash

set -o errexit
set -x

CFLAGS_FOR_OVS="-g -O2"
EXTRA_OPTS="--enable-Werror"
JOBS=${JOBS:-"-j4"}

DOCA_LINK="${DOCA_LINK:-static}"

DPDK_INSTALL_DIR="$(pwd)/dpdk-dir"
DPDK_LIB="${DPDK_INSTALL_DIR}/lib/x86_64-linux-gnu"
DOCA_PKGCONFIG=$(find /opt/mellanox/doca -name pkgconfig -type d \
                  2>/dev/null | head -1)

if [ ! -f "${DPDK_INSTALL_DIR}/cached-version" ]; then
     echo "Could not find DPDK in ${DPDK_INSTALL_DIR}"
     exit 1
fi

echo "Found cached DPDK $(cat ${DPDK_INSTALL_DIR}/cached-version)" \
      "build in ${DPDK_INSTALL_DIR}"

export 
PKG_CONFIG_PATH="${DPDK_LIB}/pkgconfig:${DOCA_PKGCONFIG}:${PKG_CONFIG_PATH}"
export PATH="${DPDK_INSTALL_DIR}/bin:${PATH}"

if [ "$DOCA_LINK" = "shared" ]; then
     DOCA_LIB="${DOCA_PKGCONFIG%/pkgconfig}"
     export LD_LIBRARY_PATH="${DPDK_LIB}:${DOCA_LIB}:${LD_LIBRARY_PATH}"
fi

sudo ldconfig
EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=$DOCA_LINK --with-doca=$DOCA_LINK"

./boot.sh
./configure CFLAGS="${CFLAGS_FOR_OVS}" $EXTRA_OPTS
make ${JOBS} check TESTSUITEFLAGS="${JOBS} RECHECK=yes"

ovs_version=$(vswitchd/ovs-vswitchd -V 2>&1)
dpdk_version=$(cat "${DPDK_INSTALL_DIR}/cached-version")

if ! echo "$ovs_version" | grep -q 'DOCA'; then
     echo "Expected 'DOCA' in ovs-vswitchd -V output." >&2
     echo "$ovs_version"
     exit 1
fi

if ! echo "$ovs_version" | grep -q "DPDK ${dpdk_version}"; then
     echo "Expected 'DPDK ${dpdk_version}' in ovs-vswitchd -V output." >&2
     echo "Got: $ovs_version" >&2
     echo "DOCA may have overridden the upstream DPDK version." >&2
     exit 1
fi
Ack

diff --git a/.ci/doca-install.sh b/.ci/doca-install.sh
new file mode 100755
index 000000000..8e78cd8b1
--- /dev/null
+++ b/.ci/doca-install.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+set -ev
+
+# Install DOCA SDK packages.
+#
+# Download the DOCA host repo package from:
+#   https://developer.nvidia.com/doca-downloads
+#     deployment_platform=Host-Server, deployment_package=DOCA-Host,
+#     target_os=Linux, Architecture=x86_64, Profile=doca-all
+#
+
+DOCA_REPO_PKG_URL="${DOCA_REPO_PKG_URL:?Set to .deb repo package URL}"
+
+wget -q "$DOCA_REPO_PKG_URL" -O /tmp/doca-repo.deb
+sudo dpkg -i /tmp/doca-repo.deb
+sudo apt-get update
+sudo apt-get install -y libdoca-sdk-flow-dev libdoca-sdk-dpdk-bridge-dev
+
Why do this in a separate file?  We could add the DOCA packages to the
dependencies env variable, and add a step to install the repository
before the APT cache update.  This saves the additional file, as it
does not hold much value.  Something like:


   env:
     dependencies: |
       automake bc gcc libbpf-dev libdoca-sdk-dpdk-bridge-dev \
       libdoca-sdk-flow-dev libibverbs-dev libnuma-dev libssl-dev \
       libsystemd-dev libtool libunbound-dev libunwind-dev \
       libxdp-dev llvm-dev pkgconf python3-pip rdma-core wget
     DOCA_REPO_PKG_URL: "https://www.mellanox.com/...";

   - name: install DOCA repository
     run: |
       wget -q "$DOCA_REPO_PKG_URL" -O /tmp/doca-repo.deb
       sudo dpkg -i /tmp/doca-repo.deb

   - name: update APT cache
     run:  sudo apt update || true

   - name: install common dependencies
     run:  sudo apt install -y ${{ env.dependencies }}
Ack

diff --git a/.ci/dpdk-build.sh b/.ci/dpdk-build.sh
index 991b272ea..5bf1a1296 100755
--- a/.ci/dpdk-build.sh
+++ b/.ci/dpdk-build.sh
@@ -38,9 +38,12 @@ function build_dpdk()

      # OVS compilation and "normal" unit tests (run in the CI) do not depend on
      # any DPDK driver.
-    # check-dpdk unit tests requires testpmd and some net/ driver.
+    # check-dpdk unit tests require testpmd and some net/ driver.
      DPDK_OPTS="$DPDK_OPTS -Denable_apps=test-pmd"
      enable_drivers="net/null,net/af_xdp,net/tap,net/virtio"
+    # For DOCA mlx5 driver is also required. net/mlx5 pulls in common/mlx5
+    # which requires bus/auxiliary.
+    enable_drivers+=",bus/auxiliary,common/mlx5,net/mlx5,net/null"
net/null is already part of enable_drivers.
Ack

      DPDK_OPTS="$DPDK_OPTS -Denable_drivers=$enable_drivers"
      # OVS depends on the vhost library (and its dependencies).
      # net/tap depends on the gso library.
diff --git a/.github/workflows/build-and-test.yml 
b/.github/workflows/build-and-test.yml
index f3d490156..0c30422a0 100644
--- a/.github/workflows/build-and-test.yml
+++ b/.github/workflows/build-and-test.yml
@@ -11,7 +11,9 @@ jobs:
        matrix:
          runner: [ubuntu-24.04]
      env:
-      dependencies: gcc libnuma-dev libxdp-dev ninja-build pkgconf
+      dependencies: >
+        gcc libnuma-dev libbpf-dev libxdp-dev ninja-build pkgconf
+        libibverbs-dev rdma-core
Dependencies should be in alphabetical order. Can you fix up all
the other intances where you touch 'dependencies'?
Ack

        CC: gcc
        DPDK_GIT: https://dpdk.org/git/dpdk-stable
        DPDK_VER: 25.11
@@ -66,6 +68,7 @@ jobs:
...
+
+    - name: update APT cache
+      run:  sudo apt update || true
Add a new line here.
Ack

+    - name: install common dependencies
+      run:  sudo apt install -y ${{ env.dependencies }}
...
+dnl Configure DOCA source tree
+AC_DEFUN([OVS_CHECK_DOCA], [
+  AC_ARG_WITH([doca],
+              [AS_HELP_STRING([--with-doca=static|shared|yes],
+                              [Specify "static"/"yes" or "shared" depending
+                              on the DOCA libraries to use.
+                              Requires --with-dpdk to be set the same.])],
Continuation lines need one more space to align under the text.
Ack

+              [], [])
+
+  DOCA_LINK=
+    case "$with_doca" in
+      "shared")
+          DOCA_LINK=shared
+          ;;
+      "static" | "yes")
+          DOCA_LINK=static
+          ;;
+    esac
+
+  if test -n "$DOCA_LINK"; then
+    if test "$DOCA_LINK" != "$DPDK_LINK"; then
+      AC_MSG_ERROR(m4_normalize([DOCA requires --with-doca and --with-dpdk to 
be the same.]))
+    fi
+  fi
As mentioned in the introduction, we should not have a separate
option for --with-doca; it should silently follow the --with-dpdk
setting.  It only needs to error out if --with-dpdk is not set.
See my response above.

+  AC_MSG_CHECKING([whether doca is enabled])
+  if test -z "$DOCA_LINK"; then
+    AC_MSG_RESULT([no])
+    DOCALIB_FOUND=false
+  else
+    AC_MSG_RESULT([yes])
+
+    DOCA_PKGCONFIG="$(find /opt/mellanox/doca -type f -name doca-flow.pc -exec 
dirname {} \; | head -1)"
+    export 
PKG_CONFIG_PATH="$PKG_CONFIG_PATH${DOCA_PKGCONFIG:+${PKG_CONFIG_PATH:+:}}$DOCA_PKGCONFIG"
+
+    AC_MSG_CHECKING([for DOCA in PKG_CONFIG_PATH='${PKG_CONFIG_PATH}'])
The AC_MSG_CHECKING has no matching AC_MSG_RESULT, so its output
runs into the PKG_CHECK_MODULES status on the same line.  Either
change it to AC_MSG_NOTICE so it prints a complete line, or remove
it entirely since PKG_CHECK_MODULES already prints its own
"checking for DOCA..." status.
Ack

+    DOCA_PKGS="doca-flow doca-dpdk-bridge doca-common"
+    if test "$DOCA_LINK" = static; then
+      PKG_CHECK_MODULES_STATIC([DOCA], [$DOCA_PKGS], [],
+          [AC_MSG_ERROR([unable to use $DOCA_PKGS .pc files for $DOCA_LINK 
build])])
+    else
+      PKG_CHECK_MODULES([DOCA], [$DOCA_PKGS], [],
+          [AC_MSG_ERROR([unable to use $DOCA_PKGS .pc files for $DOCA_LINK 
build])])
+    fi
+    DOCA_INCLUDE="$DOCA_CFLAGS -DDOCA_ALLOW_EXPERIMENTAL_API"
Is DOCA_ALLOW_EXPERIMENTAL_API needed?  If so, which specific
DOCA APIs require it, and will they become non-experimental
before we release the first version?

We are checking what can be done about this.

Doca is getting mature over time and there are still API changes from time to time.

OVS should compile/link only with a supported doca version and allowing those API are specific to netdev-doca and doesn't have any affect on generic OVS.


+    if test "$DOCA_LINK" = static; then
+      # pkg-config --static may emit the same library in duplicate
+      # --whole-archive blocks when multiple packages share a dependency
+      # (both doca-flow and doca-dpdk-bridge pull in doca-common).
+      # Linking the same .a under --whole-archive twice causes "multiple
+      # definition" errors.  Remove the second occurrence using a sed
+      # backreference, and strip redundant shared-lib flags (-l<lib>)
+      # since the static .a is already linked via --whole-archive.
+      DOCA_DEDUP_LIBS="doca_common doca_dpdk_bridge"
+      for lib in $DOCA_DEDUP_LIBS; do
+        lib_count=$(echo "$DOCA_LIBS" | grep -o "l:lib${lib}\.a" | wc -l)
+        if test "$lib_count" -ge 2; then
+          DOCA_LIBS=$(echo "$DOCA_LIBS" | sed "s@-Wl,--whole-archive -L[[^ ]]* 
-l:lib${lib}\.a -Wl,--no-whole-archive -Wl,--as-needed @@2g")
+        fi
+        if echo "$DOCA_LIBS" | grep -q "l:lib${lib}\.a"; then
+          DOCA_LIBS=$(echo "$DOCA_LIBS" | sed "s/-l${lib}//g")
+        fi
+      done
+
+    fi
+
+    # Strip DPDK from DOCA_LIBS; it is covered by 
DPDK_LIB/DPDK_vswitchd_LDFLAGS.
+    DOCA_LIBS=$(echo "$DOCA_LIBS" | sed 's/-l:librte_[[^ ]]*\.a//g; 
s/-lrte_[[^ ]]*//g; s@-L[[^ ]]*/dpdk[[^ ]]*/lib[[^ ]]*@@g' | sed 's/  */ /g; 
s/-Wl,--whole-archive  *-Wl,--no-whole-archive//g; s/^ *//; s/ *$//')
+
+    # For shared builds, ensure doca_common is included (may only be
+    # in Requires.private and not in Libs field of .pc files).
+    if test "$DOCA_LINK" = shared; then
+      if ! echo "$DOCA_LIBS" | grep -q "\-ldoca_common"; then
+        DOCA_LIBS="$DOCA_LIBS -ldoca_common"
+      fi
+    fi
+
+    USED_PATH=$($PKG_CONFIG --variable=prefix doca-flow)
+    AC_MSG_NOTICE([Using DOCA release: '$USED_PATH'])
+
+    ovs_save_CFLAGS="$CFLAGS"
+    ovs_save_LDFLAGS="$LDFLAGS"
+    # Statically linked libraries might have been built with sanitizers 
enabled.
+    # In such case, use the generated sanitizer cflags.
+    CFLAGS="$CFLAGS $SANITIZER_CFLAGS $DOCA_INCLUDE"
Is SANITIZER_CFLAGS needed here?  It is never set anywhere in the
OVS build system, so it always expands to an empty string.
Sanitizer flags should be passed via CFLAGS to ./configure, as is
done for the rest of OVS.
Ack. We have it as an explicit option for configure in our downstream version.

+
+    AC_MSG_CHECKING([for doca_flow.h])
+    AC_COMPILE_IFELSE(
+      [AC_LANG_PROGRAM([#include <doca_flow.h>],
+                       [struct doca_flow_port *port = NULL ;])],
+      [AC_MSG_RESULT([yes])],
+      [AC_MSG_RESULT([no])
+       AC_MSG_ERROR(m4_normalize([
+          Unable to include doca_flow.h, check the config.log for more details.
+          As a DOCA library was found in the current search path, a missing 
doca_flow.h
+          usually means that it was built without DOCA-flow support.
+          Verify that you fulfilled all DOCA-flow build dependencies and that 
it
+          was not automatically disabled.]))
+      ])
+
+    # DPDK was stripped from DOCA_LIBS above; add DPDK_LIB for the link test.
+    if test "$DOCA_LINK" = static; then
+      LIBS="$DOCA_LIBS $DPDK_LIB $ovs_save_libs_before_dpdk"
+    else
+      LIBS="$DOCA_LIBS $ovs_save_libs_before_dpdk"
+    fi
The ovs_save_libs_before_dpdk pattern can be avoided if LIBS is
restored after the DPDK link test, the same way CFLAGS and LDFLAGS
are already restored.  The DPDK link test is the only consumer of
DPDK_LIB in LIBS; the actual binary uses DPDK_vswitchd_LDFLAGS.
Something like (not tested):

In OVS_CHECK_DPDK, after AC_LINK_IFELSE:

     LIBS="$ovs_save_LIBS"

Then in OVS_CHECK_DOCA the link test becomes:

     ovs_save_LIBS="$LIBS"
     if test "$DOCA_LINK" = static; then
       LIBS="$DOCA_LIBS $DPDK_LIB $LIBS"
     else
       LIBS="$DOCA_LIBS $LIBS"
     fi
     AC_LINK_IFELSE(...)
     LIBS="$ovs_save_LIBS"

This removes ovs_save_libs_before_dpdk entirely and follows the
same save/restore pattern already used for CFLAGS and LDFLAGS.

AI-assisted:

This cannot work with the current build structure.

LIBS is not used only for configure-time link tests. It becomes @LIBS@ in the generated Makefiles and is appended to every link line, and libtool uses it to populate dependency_libs in libopenvswitch.la (and Libs.private in the .pc file).

After the DPDK link test we restore CFLAGS/LDFLAGS but intentionally leave DPDK_LIB in LIBS. DPDK_vswitchd_LDFLAGS is added only for ovs-vswitchd and mainly preserves the --whole-archive ordering for PMD drivers.

Other binaries (ovsdb-server, ovs-ofctl, unit tests, etc.) link against libopenvswitch.la and depend on DPDK being present via $(LIBS) / dependency_libs.

With --with-dpdk, real DPDK code lives in libopenvswitch (not stubs), so restoring LIBS to its pre-DPDK value would drop DPDK from dependency_libs and leave undefined rte_* references in binaries other than ovs-vswitchd on static builds.

I see there is a work going on to change this structure, see:

https://patchwork.ozlabs.org/project/openvswitch/list/?series=503763

I guess we will have to adapt once this is accepted (or when we move to meson...).


+    AC_MSG_CHECKING([for DOCA-flow link])
+    AC_LINK_IFELSE(
+      [AC_LANG_PROGRAM([#include <doca_flow_net.h>
+                        #include <doca_flow.h>],
+                       [struct doca_flow_cfg *cfg;
+                        int rv;
+                        doca_flow_cfg_create(&cfg);
+                        rv = doca_flow_init(cfg);
+                        doca_flow_cfg_destroy(cfg);
+                        return rv;])],
+      [AC_MSG_RESULT([yes])
+        DOCALIB_FOUND=true],
+      [AC_MSG_RESULT([no])
+        AC_MSG_ERROR(m4_normalize([
+           Unable to link with DOCA-flow, check the config.log for more 
details.
+           If a working DOCA-flow library was not found in the current search 
path,
+           update PKG_CONFIG_PATH for pkg-config to find the .pc file in a 
proper location.]))
+      ])
+    CFLAGS="$ovs_save_CFLAGS"
+    LDFLAGS="$ovs_save_LDFLAGS"
+    # Keep bare DOCA libs (no --whole-archive) in LIBS; OVS_LDFLAGS covers the 
rest.
+    if test "$DOCA_LINK" = static; then
+      doca_libs_no_wa=$(echo "$DOCA_LIBS" | sed 's/ *-Wl,--whole-archive//g; 
s/ *-Wl,--no-whole-archive//g')
+      LIBS="$doca_libs_no_wa $ovs_save_libs_before_dpdk"
+    fi
+    OVS_CFLAGS="$OVS_CFLAGS $DOCA_INCLUDE -DALLOW_EXPERIMENTAL_API"
I guess the ALLOW_EXPERIMENTAL_API is a problem here, as we are
headed towards the direction of not allowing experimental APIs in
OVS main.

If I understand correctly, Ilya's suggestion is to use the
dpdk-latest branch, which is synced with main, but it allows
experimental APIs.

This is assuming you will get all your required APIs to
non-experimental in DPDK before the next DPDK release.  Is this
on track?  Are your patches/requests accepted in DPDK main?

With this we should be aligned for the February release.
Thoughts?

As updated OOB, those API promotion was accepted in dpdk:

4ee2f5c1cedf ("ethdev: promote flow metadata API to stable")
e8cab133645f ("net/mlx5: promote some private API to stable")

As there is no functionality change in them due to this promotion, only the attributes, I still want to post it for "main" branch and waive it until moving to updated dpdk version.

WDYT?


+
+    # DOCA libraries are very specific in their ordering and inherit DPDK
...
+void
+print_doca_version(void)
print_doca_version() does not follow the ovs_doca_ prefix pattern used
by the other two functions.  Should this be ovs_doca_print_version()
for consistency? The general one is ovs_print_version, no need to align
to dpdk.

OK. It was aligned to dpdk.

...

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to