diff mbox series

[ovs-dev,RFC,dpdk-latest] build: Add support for DPDK meson build.

Message ID 20200702131339.16812-1-sunil.pai.g@intel.com
State Superseded
Headers show
Series [ovs-dev,RFC,dpdk-latest] build: Add support for DPDK meson build. | expand

Commit Message

Pai G, Sunil July 2, 2020, 1:13 p.m. UTC
Make based build is deprecated in DPDK. Meson based
build to be used for future DPDK releases.

This updates travis, configure script and documentation
for using DPDK Meson with OVS.

Signed-off-by: Sunil Pai G <sunil.pai.g@intel.com>
---
 .travis.yml                           |  3 ++
 .travis/linux-build.sh                | 37 +++++++++-------
 .travis/linux-prepare.sh              |  1 +
 Documentation/intro/install/afxdp.rst |  2 +-
 Documentation/intro/install/dpdk.rst  | 56 ++++++++++++++++++++----
 Makefile.am                           |  3 +-
 acinclude.m4                          | 42 ++++++++++++------
 parse_pkg_cfg.py                      | 62 +++++++++++++++++++++++++++
 8 files changed, 167 insertions(+), 39 deletions(-)
 create mode 100644 parse_pkg_cfg.py

Comments

Ilya Maximets July 2, 2020, 1:55 p.m. UTC | #1
On 7/2/20 3:13 PM, Sunil Pai G wrote:
> Make based build is deprecated in DPDK. Meson based
> build to be used for future DPDK releases.
> 
> This updates travis, configure script and documentation
> for using DPDK Meson with OVS.
> 
> Signed-off-by: Sunil Pai G <sunil.pai.g@intel.com>

Thanks for working on this!
Not a full review, just a few quick bits.

At first, why dpdk-latest?  Is there issue with meson build on 19.11?

Few more comments inline.

Best regards, Ilya Maximets.

> ---
>  .travis.yml                           |  3 ++
>  .travis/linux-build.sh                | 37 +++++++++-------
>  .travis/linux-prepare.sh              |  1 +
>  Documentation/intro/install/afxdp.rst |  2 +-
>  Documentation/intro/install/dpdk.rst  | 56 ++++++++++++++++++++----
>  Makefile.am                           |  3 +-
>  acinclude.m4                          | 42 ++++++++++++------
>  parse_pkg_cfg.py                      | 62 +++++++++++++++++++++++++++
>  8 files changed, 167 insertions(+), 39 deletions(-)
>  create mode 100644 parse_pkg_cfg.py
> 
> diff --git a/.travis.yml b/.travis.yml
> index 97249c1ce..46d7ad9bb 100644
> --- a/.travis.yml
> +++ b/.travis.yml
> @@ -27,6 +27,9 @@ addons:
>        - selinux-policy-dev
>        - libunbound-dev
>        - libunwind-dev
> +      - python3-setuptools
> +      - python3-wheel
> +      - ninja-build
>  
>  before_install: ./.travis/${TRAVIS_OS_NAME}-prepare.sh
>  
> diff --git a/.travis/linux-build.sh b/.travis/linux-build.sh
> index 33b359a61..7fa7e738c 100755
> --- a/.travis/linux-build.sh
> +++ b/.travis/linux-build.sh
> @@ -85,17 +85,21 @@ function install_dpdk()
>  {
>      local DPDK_VER=$1
>      local VERSION_FILE="dpdk-dir/travis-dpdk-cache-version"
> +    local DPDK_OPTS=""
>  
> -    if [ -z "$TRAVIS_ARCH" ] ||
> -       [ "$TRAVIS_ARCH" == "amd64" ]; then
> -        TARGET="x86_64-native-linuxapp-gcc"
> -    elif [ "$TRAVIS_ARCH" == "aarch64" ]; then
> -        TARGET="arm64-armv8a-linuxapp-gcc"
> -    else
> +    if [ "$TRAVIS_ARCH" == "aarch64" ]; then
> +        DPDK_OPTS="$DPDK_OPTS --cross-file config/arm/arm64_armv8_linux_gcc"

We're not cross compiling, we're actually building on aarch64 here.
This option should not be needed.  IIUC, meson should detect current
architecture and build with appropriate configuration.

We should be able to just drop all the TRAVIS_ARCH checks for DPDK here.

> +    elif [ "$TRAVIS_ARCH" != "amd64" ] && [ -n "$TRAVIS_ARCH" ]; then
>          echo "Target is unknown"
>          exit 1
>      fi
>  
> +    if [ "$DPDK_SHARED" ]; then
> +        EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=shared"
> +    else
> +        EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=static"
> +    fi

I gusee we could just change the env variable and not parse it
here. i.e. have DPDK_LIB=static defined by travis.yml by default
and redefine it for matrix entries where we need shared libs.

> +
>      if [ "${DPDK_VER##refs/*/}" != "${DPDK_VER}" ]; then
>          # Avoid using cache for git tree build.
>          rm -rf dpdk-dir
> @@ -108,7 +112,8 @@ function install_dpdk()
>          if [ -f "${VERSION_FILE}" ]; then
>              VER=$(cat ${VERSION_FILE})
>              if [ "${VER}" = "${DPDK_VER}" ]; then
> -                EXTRA_OPTS="${EXTRA_OPTS} --with-dpdk=$(pwd)/dpdk-dir/build"
> +                sudo ninja -C $(pwd)/dpdk-dir/build install
> +                sudo ldconfig

I think that installing right here inside the cached folder and just
adjusting environment variables should be a bit faster than re-installing
DPDK every time.

This script also will be a good example for people like me, who really
don't want to install development versions of DPDK globally on a work
laptop while testing OVS builds.

>                  echo "Found cached DPDK ${VER} build in $(pwd)/dpdk-dir"
>                  return
>              fi
> @@ -122,16 +127,18 @@ function install_dpdk()
>          pushd dpdk-dir
>      fi
>  
> -    make config CC=gcc T=$TARGET
> +    # Disable building DPDK kernel modules. Not needed for OVS build or tests.
> +    DPDK_OPTS="$DPDK_OPTS -Denable_kmods=false"

We should also disable examples and tests at least.

>  
> -    if [ "$DPDK_SHARED" ]; then
> -        sed -i '/CONFIG_RTE_BUILD_SHARED_LIB=n/s/=n/=y/' build/.config
> -        export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/$TARGET/lib
> -    fi
> +    DPDK_OPTS="$DPDK_OPTS -Dc_args=-fPIC"
> +    CC=gcc meson $DPDK_OPTS build
> +    ninja -C build
> +    sudo ninja -C build install
> +
> +    # Update the library paths.
> +    sudo ldconfig
>  
> -    make -j4 CC=gcc EXTRA_CFLAGS='-fPIC'
> -    EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=$(pwd)/build"
> -    echo "Installed DPDK source in $(pwd)"
> +    echo "Installed DPDK source"
>      popd
>      echo "${DPDK_VER}" > ${VERSION_FILE}
>  }
> diff --git a/.travis/linux-prepare.sh b/.travis/linux-prepare.sh
> index 8cbbd5623..682f6234b 100755
> --- a/.travis/linux-prepare.sh
> +++ b/.travis/linux-prepare.sh
> @@ -16,6 +16,7 @@ cd ..
>  
>  pip3 install --disable-pip-version-check --user flake8 hacking
>  pip3 install --user --upgrade docutils
> +pip3 install --user  'meson==0.47.1'

I understand that that is the minimum required version, but why not
the most recent one or, at least, a bit more recent?

>  
>  if [ "$M32" ]; then
>      # Installing 32-bit libraries.
> diff --git a/Documentation/intro/install/afxdp.rst b/Documentation/intro/install/afxdp.rst
> index 99003e4db..f422685ba 100644
> --- a/Documentation/intro/install/afxdp.rst
> +++ b/Documentation/intro/install/afxdp.rst
> @@ -387,7 +387,7 @@ PVP using vhostuser device
>  --------------------------
>  First, build OVS with DPDK and AFXDP::
>  
> -  ./configure  --enable-afxdp --with-dpdk=<dpdk path>
> +  ./configure  --enable-afxdp --with-dpdk=shared|static|<dpdk path>
>    make -j4 && make install
>  
>  Create a vhost-user port from OVS::
> diff --git a/Documentation/intro/install/dpdk.rst b/Documentation/intro/install/dpdk.rst
> index dbf88ec43..46e63ddf9 100644
> --- a/Documentation/intro/install/dpdk.rst
> +++ b/Documentation/intro/install/dpdk.rst
> @@ -76,9 +76,31 @@ Install DPDK
>         $ export DPDK_DIR=/usr/src/dpdk-19.11
>         $ cd $DPDK_DIR
>  
> +#. Configure and install DPDK using Meson
> +
> +   Meson is the preferred tool to build recent DPDK releases
> +   as Make support is deprecated and will be removed from DPDK-20.11.
> +   OVS supports DPDK Meson builds from 19.11 onwards.
> +
> +   Build and install the DPDK library::
> +
> +       $ export DPDK_TARGET=x86_64-native-linuxapp-gcc
> +       $ export DPDK_BUILD=$DPDK_DIR/$DPDK_TARGET
> +       $ meson $DPDK_TARGET
> +       $ ninja -C $DPDK_TARGET
> +       $ sudo ninja -C $DPDK_TARGET install
> +       $ sudo ldconfig
> +
> +   Detailed information can be found at `DPDK documentation`_.
> +
> +   .. _DPDK documentation: https://doc.dpdk.org/guides/linux_gsg/build_dpdk.html
> +
>  #. (Optional) Configure DPDK as a shared library
>  
> -   DPDK can be built as either a static library or a shared library.  By
> +   When using Meson, DPDK is built both as static and shared library.
> +   So no extra configuration is required in this case.
> +
> +   In case of Make, DPDK can be built as either a static library or a shared library.  By
>     default, it is configured for the former. If you wish to use the latter, set
>     ``CONFIG_RTE_BUILD_SHARED_LIB=y`` in ``$DPDK_DIR/config/common_base``.
>  
> @@ -87,7 +109,7 @@ Install DPDK
>        Minor performance loss is expected when using OVS with a shared DPDK
>        library compared to a static DPDK library.
>  
> -#. Configure and install DPDK
> +#. Configure and install DPDK using Make
>  
>     Build and install the DPDK library::
>  
> @@ -97,11 +119,19 @@ Install DPDK
>  
>  #. (Optional) Export the DPDK shared library location
>  
> -   If DPDK was built as a shared library, export the path to this library for
> +   If DPDK was built as a shared library using Make, export the path to this library for
>     use when building OVS::
>  
>         $ export LD_LIBRARY_PATH=$DPDK_DIR/x86_64-native-linuxapp-gcc/lib
>  
> +   In case of Meson, exporting the path is not necessary if the dpdk libraries
> +   are system installed. For libraries installed using a prefix
> +   (assuming $DPDK_INSTALL in the below case), export the path to this library
> +   and update the $PKG_CONFIG_PATH for use when building OVS::
> +
> +      $ export LD_LIBRARY_PATH=$DPDK_INSTALL/lib/x86_64-linux-gnu/:$LD_LIBRARY_PATH
> +      $ export PKG_CONFIG_PATH=$DPDK_INSTALL/lib/x86_64-linux-gnu/pkgconfig/:$PKG_CONFIG_PATH
> +
>  .. _DPDK sources: http://dpdk.org/rel
>  
>  Install OVS
> @@ -121,17 +151,27 @@ has to be configured to build against the DPDK library (``--with-dpdk``).
>  
>  #. Bootstrap, if required, as described in :ref:`general-bootstrapping`
>  
> -#. Configure the package using the ``--with-dpdk`` flag::
> +#. Configure the package using the ``--with-dpdk`` flag:
> +
> +   Depending on the tool used to build DPDK and the type of
> +   DPDK library to use, one can configure OVS as follows:
> +
> +   When DPDK is built using Meson, and OVS must consume DPDK shared libraries
> +   (also equivalent to leaving --with-dpdk option empty)::
> +
> +       $ ./configure --with-dpdk=shared
> +
> +   When DPDK is built using Meson, and OVS must consume DPDK static libraries::
> +
> +       $ ./configure --with-dpdk=static
> +
> +   When DPDK is built using Make(for shared or static)::
>  
>         $ ./configure --with-dpdk=$DPDK_BUILD
>  
>     where ``DPDK_BUILD`` is the path to the built DPDK library. This can be
>     skipped if DPDK library is installed in its default location.
>  
> -   If no path is provided to ``--with-dpdk``, but a pkg-config configuration
> -   for libdpdk is available the include paths will be generated via an
> -   equivalent ``pkg-config --cflags libdpdk``.
> -
>     .. note::
>       While ``--with-dpdk`` is required, you can pass any other configuration
>       option described in :ref:`general-configuring`.
> diff --git a/Makefile.am b/Makefile.am
> index b279303d1..13141b946 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -92,7 +92,8 @@ EXTRA_DIST = \
>  	$(MAN_ROOTS) \
>  	Vagrantfile \
>  	Vagrantfile-FreeBSD \
> -	.mailmap
> +	.mailmap\
> +	parse_pkg_cfg.py
>  bin_PROGRAMS =
>  sbin_PROGRAMS =
>  bin_SCRIPTS =
> diff --git a/acinclude.m4 b/acinclude.m4
> index 3b0eea020..66d1d3583 100644
> --- a/acinclude.m4
> +++ b/acinclude.m4
> @@ -306,8 +306,8 @@ dnl
>  dnl Configure DPDK source tree
>  AC_DEFUN([OVS_CHECK_DPDK], [
>    AC_ARG_WITH([dpdk],
> -              [AC_HELP_STRING([--with-dpdk=/path/to/dpdk],
> -                              [Specify the DPDK build directory])],
> +              [AC_HELP_STRING([--with-dpdk=static|shared|/path/to/dpdk],
> +                              [Specify whether to use static or shared DPDK libraries only if built using meson OR the DPDK build directory in case of Make])],
>                [have_dpdk=true])
>  
>    AC_MSG_CHECKING([whether dpdk is enabled])
> @@ -317,13 +317,24 @@ AC_DEFUN([OVS_CHECK_DPDK], [
>    else
>      AC_MSG_RESULT([yes])
>      case "$with_dpdk" in
> -      yes)
> +      "shared" | "static" | "yes")
>          DPDK_AUTO_DISCOVER="true"
> -        PKG_CHECK_MODULES_STATIC([DPDK], [libdpdk], [
> -            DPDK_INCLUDE="$DPDK_CFLAGS"
> -            DPDK_LIB="$DPDK_LIBS"], [
> -            DPDK_INCLUDE="-I/usr/local/include/dpdk -I/usr/include/dpdk"
> -            DPDK_LIB="-ldpdk"])
> +        case "$with_dpdk" in
> +          "shared" | "yes")
> +             PKG_CHECK_MODULES([DPDK], [libdpdk], [
> +                 DPDK_INCLUDE="$DPDK_CFLAGS"
> +                 DPDK_LIB="$DPDK_LIBS"], [
> +                 DPDK_INCLUDE="-I/usr/local/include/dpdk -I/usr/include/dpdk"
> +                 DPDK_LIB="-ldpdk"])
> +                 ;;
> +           "static")
> +             PKG_CHECK_MODULES_STATIC([DPDK], [libdpdk], [
> +                 DPDK_INCLUDE="$DPDK_CFLAGS"
> +                 DPDK_LIB="$DPDK_LIBS"], [
> +                 DPDK_INCLUDE="-I/usr/local/include/dpdk -I/usr/include/dpdk"
> +                 DPDK_LIB="-ldpdk"])
> +                ;;
> +        esac
>          ;;
>        *)
>          DPDK_AUTO_DISCOVER="false"
> @@ -397,8 +408,9 @@ AC_DEFUN([OVS_CHECK_DPDK], [
>        [AC_MSG_RESULT([no])
>         if test "$DPDK_AUTO_DISCOVER" = "true"; then
>           AC_MSG_ERROR(m4_normalize([
> -            Could not find DPDK library in default search path, Use --with-dpdk
> -            to specify the DPDK library installed in non-standard location]))
> +            Could not find DPDK library in default search path, update
> +            PKG_CONFIG_PATH for pkg-config to find the .pc file in
> +            non-standard location]))
>         else
>           AC_MSG_ERROR([Could not find DPDK libraries in $DPDK_LIB_DIR])
>         fi
> @@ -424,10 +436,12 @@ AC_DEFUN([OVS_CHECK_DPDK], [
>      # OTOH newer versions of dpdk pkg-config (generated with Meson)
>      # will already have flagged just the right set of libs with
>      # --whole-archive - in those cases do not wrap it once more.
> -    case "$DPDK_LIB" in
> -      *whole-archive*) DPDK_vswitchd_LDFLAGS=$DPDK_LIB;;
> -      *) DPDK_vswitchd_LDFLAGS=-Wl,--whole-archive,$DPDK_LIB,--no-whole-archive
> -    esac
> +    if [[ "$pkg_failed" != "no" ]];then
> +      DPDK_vswitchd_LDFLAGS=-Wl,--whole-archive,$DPDK_LIB,--no-whole-archive
> +    else
> +      DPDK_vswitchd_LDFLAGS=`python3 parse_pkg_cfg.py $DPDK_LIB`
> +    fi
> +
>      AC_SUBST([DPDK_vswitchd_LDFLAGS])
>      AC_DEFINE([DPDK_NETDEV], [1], [System uses the DPDK module.])
>    fi
> diff --git a/parse_pkg_cfg.py b/parse_pkg_cfg.py
> new file mode 100644
> index 000000000..7f7e1430d
> --- /dev/null
> +++ b/parse_pkg_cfg.py
> @@ -0,0 +1,62 @@
> +#
> +#   BSD LICENSE
> +#
> +#   Copyright(c) 2020 Intel Corporation. All rights reserved.
> +#   All rights reserved.
> +#
> +#   Redistribution and use in source and binary forms, with or without
> +#   modification, are permitted provided that the following conditions
> +#   are met:
> +#
> +#     * Redistributions of source code must retain the above copyright
> +#       notice, this list of conditions and the following disclaimer.
> +#      * Redistributions in binary form must reproduce the above copyright
> +#        notice, this list of conditions and the following disclaimer in
> +#        the documentation and/or other materials provided with the
> +#        distribution.
> +#      * Neither the name of Intel Corporation nor the names of its
> +#        contributors may be used to endorse or promote products derived
> +#        from this software without specific prior written permission.
> +#
> +#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> +#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> +#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
> +#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
> +#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> +#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> +#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
> +#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
> +#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> +#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
> +#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> +#
> +
> +# The purpose of this script is to parse the libraries
> +# From pkg-config in case of dpdk meson builds.
> +import sys
> +def parse_pkg_cfg_libs(arg):
> +    final_string = ""
> +    first_linker_flag_ind=False
> +    for text in arg:
> +        text = text.strip()
> +        # Ld only understands -lpthread.
> +        if text == "-pthread":
> +            text = "-lpthread"
> +        if '-L/' in text:
> +            final_string = final_string + text + " "
> +        elif '-Wl,' == text[:4]:
> +            # Libtool requires -Wl to only appear once after
> +            # Which everything else is treated as linker input.
> +            if not first_linker_flag_ind:
> +                first_linker_flag_ind = True
> +                final_string = final_string + text + ","
> +            else:
> +                # Omit succeeding -Wl.
> +                final_string = final_string + text[4:] + ","
> +        else:
> +            # Libtool expects comma separated libraries.
> +            final_string = final_string + text + ","
> +    return final_string
> +
> +if __name__ == "__main__":
> +    print(parse_pkg_cfg_libs(sys.argv[1:])[:-1])
>
Richardson, Bruce July 2, 2020, 1:58 p.m. UTC | #2
> -----Original Message-----
> From: Pai G, Sunil <sunil.pai.g@intel.com>
> Sent: Thursday, July 2, 2020 2:14 PM
> To: dev@openvswitch.org
> Cc: Stokes, Ian <ian.stokes@intel.com>; i.maximets@ovn.org;
> david.marchand@redhat.com; Richardson, Bruce <bruce.richardson@intel.com>;
> Pai G, Sunil <sunil.pai.g@intel.com>; Tummala, Sivaprasad
> <sivaprasad.tummala@intel.com>
> Subject: [PATCH RFC dpdk-latest] build: Add support for DPDK meson build.
> 
> Make based build is deprecated in DPDK. Meson based build to be used for
> future DPDK releases.
> 
> This updates travis, configure script and documentation for using DPDK
> Meson with OVS.
> 
> Signed-off-by: Sunil Pai G <sunil.pai.g@intel.com>

Thanks for this, a couple of comments from the DPDK build side inline below.

Regards,
/Bruce

> ---
>  .travis.yml                           |  3 ++
>  .travis/linux-build.sh                | 37 +++++++++-------
>  .travis/linux-prepare.sh              |  1 +
>  Documentation/intro/install/afxdp.rst |  2 +-
> Documentation/intro/install/dpdk.rst  | 56 ++++++++++++++++++++----
>  Makefile.am                           |  3 +-
>  acinclude.m4                          | 42 ++++++++++++------
>  parse_pkg_cfg.py                      | 62 +++++++++++++++++++++++++++
>  8 files changed, 167 insertions(+), 39 deletions(-)  create mode 100644
> parse_pkg_cfg.py
> 
> diff --git a/.travis.yml b/.travis.yml
> index 97249c1ce..46d7ad9bb 100644
> --- a/.travis.yml
> +++ b/.travis.yml
> @@ -27,6 +27,9 @@ addons:
>        - selinux-policy-dev
>        - libunbound-dev
>        - libunwind-dev
> +      - python3-setuptools
> +      - python3-wheel
> +      - ninja-build
> 
>  before_install: ./.travis/${TRAVIS_OS_NAME}-prepare.sh
> 
> diff --git a/.travis/linux-build.sh b/.travis/linux-build.sh index
> 33b359a61..7fa7e738c 100755
> --- a/.travis/linux-build.sh
> +++ b/.travis/linux-build.sh
> @@ -85,17 +85,21 @@ function install_dpdk()  {
>      local DPDK_VER=$1
>      local VERSION_FILE="dpdk-dir/travis-dpdk-cache-version"
> +    local DPDK_OPTS=""
> 
> -    if [ -z "$TRAVIS_ARCH" ] ||
> -       [ "$TRAVIS_ARCH" == "amd64" ]; then
> -        TARGET="x86_64-native-linuxapp-gcc"
> -    elif [ "$TRAVIS_ARCH" == "aarch64" ]; then
> -        TARGET="arm64-armv8a-linuxapp-gcc"
> -    else
> +    if [ "$TRAVIS_ARCH" == "aarch64" ]; then
> +        DPDK_OPTS="$DPDK_OPTS --cross-file
> config/arm/arm64_armv8_linux_gcc"
> +    elif [ "$TRAVIS_ARCH" != "amd64" ] && [ -n "$TRAVIS_ARCH" ]; then
>          echo "Target is unknown"
>          exit 1
>      fi
> 
> +    if [ "$DPDK_SHARED" ]; then
> +        EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=shared"
> +    else
> +        EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=static"
> +    fi
> +
>      if [ "${DPDK_VER##refs/*/}" != "${DPDK_VER}" ]; then
>          # Avoid using cache for git tree build.
>          rm -rf dpdk-dir
> @@ -108,7 +112,8 @@ function install_dpdk()
>          if [ -f "${VERSION_FILE}" ]; then
>              VER=$(cat ${VERSION_FILE})
>              if [ "${VER}" = "${DPDK_VER}" ]; then
> -                EXTRA_OPTS="${EXTRA_OPTS} --with-dpdk=$(pwd)/dpdk-
> dir/build"
> +                sudo ninja -C $(pwd)/dpdk-dir/build install
> +                sudo ldconfig
>                  echo "Found cached DPDK ${VER} build in $(pwd)/dpdk-dir"
>                  return
>              fi
> @@ -122,16 +127,18 @@ function install_dpdk()
>          pushd dpdk-dir
>      fi
> 
> -    make config CC=gcc T=$TARGET
> +    # Disable building DPDK kernel modules. Not needed for OVS build or
> tests.
> +    DPDK_OPTS="$DPDK_OPTS -Denable_kmods=false"
> 

NOTE: enable_kmods=false is the default in DPDK, so should not need to be
specified, unless you want to be doubly sure they are not build, or for
clarity.

> -    if [ "$DPDK_SHARED" ]; then
> -        sed -i '/CONFIG_RTE_BUILD_SHARED_LIB=n/s/=n/=y/' build/.config
> -        export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/$TARGET/lib
> -    fi
> +    DPDK_OPTS="$DPDK_OPTS -Dc_args=-fPIC"

Since meson build for DPDK always links the objects into both static and
shared libs, all objects are already built with -fPIC, so this should not
be necessary.

> +    CC=gcc meson $DPDK_OPTS build
> +    ninja -C build
> +    sudo ninja -C build install
> +
> +    # Update the library paths.
> +    sudo ldconfig
> 
> -    make -j4 CC=gcc EXTRA_CFLAGS='-fPIC'
> -    EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=$(pwd)/build"
> -    echo "Installed DPDK source in $(pwd)"
> +    echo "Installed DPDK source"
>      popd
>      echo "${DPDK_VER}" > ${VERSION_FILE}  } diff --git a/.travis/linux-
> prepare.sh b/.travis/linux-prepare.sh index 8cbbd5623..682f6234b 100755
> --- a/.travis/linux-prepare.sh
> +++ b/.travis/linux-prepare.sh
> @@ -16,6 +16,7 @@ cd ..
> 
>  pip3 install --disable-pip-version-check --user flake8 hacking
>  pip3 install --user --upgrade docutils
> +pip3 install --user  'meson==0.47.1'
> 

Is there a reason for forcing this to the oldest supported  version?

>  if [ "$M32" ]; then
>      # Installing 32-bit libraries.
<snip for brevity>
Pai G, Sunil July 2, 2020, 3:25 p.m. UTC | #3
> -----Original Message-----
> From: Ilya Maximets <i.maximets@ovn.org>
> Sent: Thursday, July 2, 2020 7:26 PM
> To: Pai G, Sunil <sunil.pai.g@intel.com>; dev@openvswitch.org
> Cc: Stokes, Ian <ian.stokes@intel.com>; i.maximets@ovn.org;
> david.marchand@redhat.com; Richardson, Bruce
> <bruce.richardson@intel.com>; Tummala, Sivaprasad
> <sivaprasad.tummala@intel.com>; i.maximets@ovn.org
> Subject: Re: [PATCH RFC dpdk-latest] build: Add support for DPDK meson build.
> 
> On 7/2/20 3:13 PM, Sunil Pai G wrote:
> > Make based build is deprecated in DPDK. Meson based build to be used
> > for future DPDK releases.
> >
> > This updates travis, configure script and documentation for using DPDK
> > Meson with OVS.
> >
> > Signed-off-by: Sunil Pai G <sunil.pai.g@intel.com>
> 
> Thanks for working on this!
> Not a full review, just a few quick bits.
> 
> At first, why dpdk-latest?  Is there issue with meson build on 19.11?

The linker always picked the shared DPDK libraries over static when built with Meson
in DPDK-19.11. -Bstatic flag would get jumbled by libtool causing this.
Thanks to Bruce, there was recently merged series which fixed a bunch of issues along with this :
https://patches.dpdk.org/project/dpdk/list/?series=10690 
It is requested for a back port of this series to DPDK-19.11.
 
> 
> Few more comments inline.
> 
> Best regards, Ilya Maximets.
> 
> > ---
> >  .travis.yml                           |  3 ++
> >  .travis/linux-build.sh                | 37 +++++++++-------
> >  .travis/linux-prepare.sh              |  1 +
> >  Documentation/intro/install/afxdp.rst |  2 +-
> > Documentation/intro/install/dpdk.rst  | 56 ++++++++++++++++++++----
> >  Makefile.am                           |  3 +-
> >  acinclude.m4                          | 42 ++++++++++++------
> >  parse_pkg_cfg.py                      | 62 +++++++++++++++++++++++++++
> >  8 files changed, 167 insertions(+), 39 deletions(-)  create mode
> > 100644 parse_pkg_cfg.py
> >
> > diff --git a/.travis.yml b/.travis.yml index 97249c1ce..46d7ad9bb
> > 100644
> > --- a/.travis.yml
> > +++ b/.travis.yml
> > @@ -27,6 +27,9 @@ addons:
> >        - selinux-policy-dev
> >        - libunbound-dev
> >        - libunwind-dev
> > +      - python3-setuptools
> > +      - python3-wheel
> > +      - ninja-build
> >
> >  before_install: ./.travis/${TRAVIS_OS_NAME}-prepare.sh
> >
> > diff --git a/.travis/linux-build.sh b/.travis/linux-build.sh index
> > 33b359a61..7fa7e738c 100755
> > --- a/.travis/linux-build.sh
> > +++ b/.travis/linux-build.sh
> > @@ -85,17 +85,21 @@ function install_dpdk()  {
> >      local DPDK_VER=$1
> >      local VERSION_FILE="dpdk-dir/travis-dpdk-cache-version"
> > +    local DPDK_OPTS=""
> >
> > -    if [ -z "$TRAVIS_ARCH" ] ||
> > -       [ "$TRAVIS_ARCH" == "amd64" ]; then
> > -        TARGET="x86_64-native-linuxapp-gcc"
> > -    elif [ "$TRAVIS_ARCH" == "aarch64" ]; then
> > -        TARGET="arm64-armv8a-linuxapp-gcc"
> > -    else
> > +    if [ "$TRAVIS_ARCH" == "aarch64" ]; then
> > +        DPDK_OPTS="$DPDK_OPTS --cross-file
> config/arm/arm64_armv8_linux_gcc"
> 
> We're not cross compiling, we're actually building on aarch64 here.
> This option should not be needed.  IIUC, meson should detect current
> architecture and build with appropriate configuration.
> 
> We should be able to just drop all the TRAVIS_ARCH checks for DPDK here.

Sure ,let me check on this . I see a similar approach taken in DPDK travis. 
May be Bruce can comment as well ?

> 
> > +    elif [ "$TRAVIS_ARCH" != "amd64" ] && [ -n "$TRAVIS_ARCH" ]; then
> >          echo "Target is unknown"
> >          exit 1
> >      fi
> >
> > +    if [ "$DPDK_SHARED" ]; then
> > +        EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=shared"
> > +    else
> > +        EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=static"
> > +    fi
> 
> I gusee we could just change the env variable and not parse it here. i.e. have
> DPDK_LIB=static defined by travis.yml by default and redefine it for matrix
> entries where we need shared libs.

Yes , this could be done. But if we install the libraries in a custom path using a prefix, 
we would have to export the LD_LIBRARY_PATH for which querying whether to build 
as shared/static will be required.(This in relation to the below comment as well :))


> 
> > +
> >      if [ "${DPDK_VER##refs/*/}" != "${DPDK_VER}" ]; then
> >          # Avoid using cache for git tree build.
> >          rm -rf dpdk-dir
> > @@ -108,7 +112,8 @@ function install_dpdk()
> >          if [ -f "${VERSION_FILE}" ]; then
> >              VER=$(cat ${VERSION_FILE})
> >              if [ "${VER}" = "${DPDK_VER}" ]; then
> > -                EXTRA_OPTS="${EXTRA_OPTS} --with-dpdk=$(pwd)/dpdk-dir/build"
> > +                sudo ninja -C $(pwd)/dpdk-dir/build install
> > +                sudo ldconfig
> 
> I think that installing right here inside the cached folder and just adjusting
> environment variables should be a bit faster than re-installing DPDK every time.
> 
> This script also will be a good example for people like me, who really don't want
> to install development versions of DPDK globally on a work laptop while testing
> OVS builds.

Yes , Thanks for the suggestion. Although ,using an install to a directory with
a prefix would require this patch from Bruce: https://patches.dpdk.org/patch/72271/
 (which is not merged yet as of this writing) .without this , OVS would fail to run 
searching for few shared DPDK libraries even when built with static libraries.

> 
> >                  echo "Found cached DPDK ${VER} build in $(pwd)/dpdk-dir"
> >                  return
> >              fi
> > @@ -122,16 +127,18 @@ function install_dpdk()
> >          pushd dpdk-dir
> >      fi
> >
> > -    make config CC=gcc T=$TARGET
> > +    # Disable building DPDK kernel modules. Not needed for OVS build or tests.
> > +    DPDK_OPTS="$DPDK_OPTS -Denable_kmods=false"
> 
> We should also disable examples and tests at least.

Sure , this will reduce the build time as well.
 Will update in the next version. 

> 
> >
> > -    if [ "$DPDK_SHARED" ]; then
> > -        sed -i '/CONFIG_RTE_BUILD_SHARED_LIB=n/s/=n/=y/' build/.config
> > -        export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/$TARGET/lib
> > -    fi
> > +    DPDK_OPTS="$DPDK_OPTS -Dc_args=-fPIC"
> > +    CC=gcc meson $DPDK_OPTS build
> > +    ninja -C build
> > +    sudo ninja -C build install
> > +
> > +    # Update the library paths.
> > +    sudo ldconfig
> >
> > -    make -j4 CC=gcc EXTRA_CFLAGS='-fPIC'
> > -    EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=$(pwd)/build"
> > -    echo "Installed DPDK source in $(pwd)"
> > +    echo "Installed DPDK source"
> >      popd
> >      echo "${DPDK_VER}" > ${VERSION_FILE}  } diff --git
> > a/.travis/linux-prepare.sh b/.travis/linux-prepare.sh index
> > 8cbbd5623..682f6234b 100755
> > --- a/.travis/linux-prepare.sh
> > +++ b/.travis/linux-prepare.sh
> > @@ -16,6 +16,7 @@ cd ..
> >
> >  pip3 install --disable-pip-version-check --user flake8 hacking
> >  pip3 install --user --upgrade docutils
> > +pip3 install --user  'meson==0.47.1'
> 
> I understand that that is the minimum required version, but why not the most
> recent one or, at least, a bit more recent?
> 

Yes , quoting David's commit message from DPDK travis :
"
    meson 0.53.0 has a compatibility issue [1] with the python 3.5.2 that comes
    in Ubuntu 16.04.
    On the other hand, the minimal version supported in dpdk is 0.47.1.

    Stick to this version to avoid getting hit by regressions in meson latest
    shiny release.

    1: https://github.com/mesonbuild/meson/issues/6427
"

> >
> >  if [ "$M32" ]; then
> >      # Installing 32-bit libraries.
> > diff --git a/Documentation/intro/install/afxdp.rst
> > b/Documentation/intro/install/afxdp.rst
> > index 99003e4db..f422685ba 100644
> > --- a/Documentation/intro/install/afxdp.rst
> > +++ b/Documentation/intro/install/afxdp.rst
> > @@ -387,7 +387,7 @@ PVP using vhostuser device
> >  --------------------------
> >  First, build OVS with DPDK and AFXDP::
> >
> > -  ./configure  --enable-afxdp --with-dpdk=<dpdk path>
> > +  ./configure  --enable-afxdp --with-dpdk=shared|static|<dpdk path>
> >    make -j4 && make install
> >
> >  Create a vhost-user port from OVS::
> > diff --git a/Documentation/intro/install/dpdk.rst
> > b/Documentation/intro/install/dpdk.rst
> > index dbf88ec43..46e63ddf9 100644
> > --- a/Documentation/intro/install/dpdk.rst
> > +++ b/Documentation/intro/install/dpdk.rst
> > @@ -76,9 +76,31 @@ Install DPDK
> >         $ export DPDK_DIR=/usr/src/dpdk-19.11
> >         $ cd $DPDK_DIR
> >
> > +#. Configure and install DPDK using Meson
> > +
> > +   Meson is the preferred tool to build recent DPDK releases
> > +   as Make support is deprecated and will be removed from DPDK-20.11.
> > +   OVS supports DPDK Meson builds from 19.11 onwards.
> > +
> > +   Build and install the DPDK library::
> > +
> > +       $ export DPDK_TARGET=x86_64-native-linuxapp-gcc
> > +       $ export DPDK_BUILD=$DPDK_DIR/$DPDK_TARGET
> > +       $ meson $DPDK_TARGET
> > +       $ ninja -C $DPDK_TARGET
> > +       $ sudo ninja -C $DPDK_TARGET install
> > +       $ sudo ldconfig
> > +
> > +   Detailed information can be found at `DPDK documentation`_.
> > +
> > +   .. _DPDK documentation:
> > + https://doc.dpdk.org/guides/linux_gsg/build_dpdk.html
> > +
> >  #. (Optional) Configure DPDK as a shared library
> >
> > -   DPDK can be built as either a static library or a shared library.  By
> > +   When using Meson, DPDK is built both as static and shared library.
> > +   So no extra configuration is required in this case.
> > +
> > +   In case of Make, DPDK can be built as either a static library or a
> > + shared library.  By
> >     default, it is configured for the former. If you wish to use the latter, set
> >     ``CONFIG_RTE_BUILD_SHARED_LIB=y`` in
> ``$DPDK_DIR/config/common_base``.
> >
> > @@ -87,7 +109,7 @@ Install DPDK
> >        Minor performance loss is expected when using OVS with a shared DPDK
> >        library compared to a static DPDK library.
> >
> > -#. Configure and install DPDK
> > +#. Configure and install DPDK using Make
> >
> >     Build and install the DPDK library::
> >
> > @@ -97,11 +119,19 @@ Install DPDK
> >
> >  #. (Optional) Export the DPDK shared library location
> >
> > -   If DPDK was built as a shared library, export the path to this library for
> > +   If DPDK was built as a shared library using Make, export the path
> > + to this library for
> >     use when building OVS::
> >
> >         $ export
> > LD_LIBRARY_PATH=$DPDK_DIR/x86_64-native-linuxapp-gcc/lib
> >
> > +   In case of Meson, exporting the path is not necessary if the dpdk libraries
> > +   are system installed. For libraries installed using a prefix
> > +   (assuming $DPDK_INSTALL in the below case), export the path to this library
> > +   and update the $PKG_CONFIG_PATH for use when building OVS::
> > +
> > +      $ export LD_LIBRARY_PATH=$DPDK_INSTALL/lib/x86_64-linux-
> gnu/:$LD_LIBRARY_PATH
> > +      $ export
> > + PKG_CONFIG_PATH=$DPDK_INSTALL/lib/x86_64-linux-
> gnu/pkgconfig/:$PKG_C
> > + ONFIG_PATH
> > +
> >  .. _DPDK sources: http://dpdk.org/rel
> >
> >  Install OVS
> > @@ -121,17 +151,27 @@ has to be configured to build against the DPDK
> library (``--with-dpdk``).
> >
> >  #. Bootstrap, if required, as described in
> > :ref:`general-bootstrapping`
> >
> > -#. Configure the package using the ``--with-dpdk`` flag::
> > +#. Configure the package using the ``--with-dpdk`` flag:
> > +
> > +   Depending on the tool used to build DPDK and the type of
> > +   DPDK library to use, one can configure OVS as follows:
> > +
> > +   When DPDK is built using Meson, and OVS must consume DPDK shared
> libraries
> > +   (also equivalent to leaving --with-dpdk option empty)::
> > +
> > +       $ ./configure --with-dpdk=shared
> > +
> > +   When DPDK is built using Meson, and OVS must consume DPDK static
> libraries::
> > +
> > +       $ ./configure --with-dpdk=static
> > +
> > +   When DPDK is built using Make(for shared or static)::
> >
> >         $ ./configure --with-dpdk=$DPDK_BUILD
> >
> >     where ``DPDK_BUILD`` is the path to the built DPDK library. This can be
> >     skipped if DPDK library is installed in its default location.
> >
> > -   If no path is provided to ``--with-dpdk``, but a pkg-config configuration
> > -   for libdpdk is available the include paths will be generated via an
> > -   equivalent ``pkg-config --cflags libdpdk``.
> > -
> >     .. note::
> >       While ``--with-dpdk`` is required, you can pass any other configuration
> >       option described in :ref:`general-configuring`.
> > diff --git a/Makefile.am b/Makefile.am index b279303d1..13141b946
> > 100644
> > --- a/Makefile.am
> > +++ b/Makefile.am
> > @@ -92,7 +92,8 @@ EXTRA_DIST = \
> >  	$(MAN_ROOTS) \
> >  	Vagrantfile \
> >  	Vagrantfile-FreeBSD \
> > -	.mailmap
> > +	.mailmap\
> > +	parse_pkg_cfg.py
> >  bin_PROGRAMS =
> >  sbin_PROGRAMS =
> >  bin_SCRIPTS =
> > diff --git a/acinclude.m4 b/acinclude.m4 index 3b0eea020..66d1d3583
> > 100644
> > --- a/acinclude.m4
> > +++ b/acinclude.m4
> > @@ -306,8 +306,8 @@ dnl
> >  dnl Configure DPDK source tree
> >  AC_DEFUN([OVS_CHECK_DPDK], [
> >    AC_ARG_WITH([dpdk],
> > -              [AC_HELP_STRING([--with-dpdk=/path/to/dpdk],
> > -                              [Specify the DPDK build directory])],
> > +              [AC_HELP_STRING([--with-dpdk=static|shared|/path/to/dpdk],
> > +                              [Specify whether to use static or
> > + shared DPDK libraries only if built using meson OR the DPDK build
> > + directory in case of Make])],
> >                [have_dpdk=true])
> >
> >    AC_MSG_CHECKING([whether dpdk is enabled]) @@ -317,13 +317,24 @@
> > AC_DEFUN([OVS_CHECK_DPDK], [
> >    else
> >      AC_MSG_RESULT([yes])
> >      case "$with_dpdk" in
> > -      yes)
> > +      "shared" | "static" | "yes")
> >          DPDK_AUTO_DISCOVER="true"
> > -        PKG_CHECK_MODULES_STATIC([DPDK], [libdpdk], [
> > -            DPDK_INCLUDE="$DPDK_CFLAGS"
> > -            DPDK_LIB="$DPDK_LIBS"], [
> > -            DPDK_INCLUDE="-I/usr/local/include/dpdk -I/usr/include/dpdk"
> > -            DPDK_LIB="-ldpdk"])
> > +        case "$with_dpdk" in
> > +          "shared" | "yes")
> > +             PKG_CHECK_MODULES([DPDK], [libdpdk], [
> > +                 DPDK_INCLUDE="$DPDK_CFLAGS"
> > +                 DPDK_LIB="$DPDK_LIBS"], [
> > +                 DPDK_INCLUDE="-I/usr/local/include/dpdk -I/usr/include/dpdk"
> > +                 DPDK_LIB="-ldpdk"])
> > +                 ;;
> > +           "static")
> > +             PKG_CHECK_MODULES_STATIC([DPDK], [libdpdk], [
> > +                 DPDK_INCLUDE="$DPDK_CFLAGS"
> > +                 DPDK_LIB="$DPDK_LIBS"], [
> > +                 DPDK_INCLUDE="-I/usr/local/include/dpdk -I/usr/include/dpdk"
> > +                 DPDK_LIB="-ldpdk"])
> > +                ;;
> > +        esac
> >          ;;
> >        *)
> >          DPDK_AUTO_DISCOVER="false"
> > @@ -397,8 +408,9 @@ AC_DEFUN([OVS_CHECK_DPDK], [
> >        [AC_MSG_RESULT([no])
> >         if test "$DPDK_AUTO_DISCOVER" = "true"; then
> >           AC_MSG_ERROR(m4_normalize([
> > -            Could not find DPDK library in default search path, Use --with-dpdk
> > -            to specify the DPDK library installed in non-standard location]))
> > +            Could not find DPDK library in default search path, update
> > +            PKG_CONFIG_PATH for pkg-config to find the .pc file in
> > +            non-standard location]))
> >         else
> >           AC_MSG_ERROR([Could not find DPDK libraries in $DPDK_LIB_DIR])
> >         fi
> > @@ -424,10 +436,12 @@ AC_DEFUN([OVS_CHECK_DPDK], [
> >      # OTOH newer versions of dpdk pkg-config (generated with Meson)
> >      # will already have flagged just the right set of libs with
> >      # --whole-archive - in those cases do not wrap it once more.
> > -    case "$DPDK_LIB" in
> > -      *whole-archive*) DPDK_vswitchd_LDFLAGS=$DPDK_LIB;;
> > -      *) DPDK_vswitchd_LDFLAGS=-Wl,--whole-archive,$DPDK_LIB,--no-whole-
> archive
> > -    esac
> > +    if [[ "$pkg_failed" != "no" ]];then
> > +      DPDK_vswitchd_LDFLAGS=-Wl,--whole-archive,$DPDK_LIB,--no-whole-
> archive
> > +    else
> > +      DPDK_vswitchd_LDFLAGS=`python3 parse_pkg_cfg.py $DPDK_LIB`
> > +    fi
> > +
> >      AC_SUBST([DPDK_vswitchd_LDFLAGS])
> >      AC_DEFINE([DPDK_NETDEV], [1], [System uses the DPDK module.])
> >    fi
> > diff --git a/parse_pkg_cfg.py b/parse_pkg_cfg.py new file mode 100644
> > index 000000000..7f7e1430d
> > --- /dev/null
> > +++ b/parse_pkg_cfg.py
> > @@ -0,0 +1,62 @@
> > +#
> > +#   BSD LICENSE
> > +#
> > +#   Copyright(c) 2020 Intel Corporation. All rights reserved.
> > +#   All rights reserved.
> > +#
> > +#   Redistribution and use in source and binary forms, with or without
> > +#   modification, are permitted provided that the following conditions
> > +#   are met:
> > +#
> > +#     * Redistributions of source code must retain the above copyright
> > +#       notice, this list of conditions and the following disclaimer.
> > +#      * Redistributions in binary form must reproduce the above copyright
> > +#        notice, this list of conditions and the following disclaimer in
> > +#        the documentation and/or other materials provided with the
> > +#        distribution.
> > +#      * Neither the name of Intel Corporation nor the names of its
> > +#        contributors may be used to endorse or promote products derived
> > +#        from this software without specific prior written permission.
> > +#
> > +#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
> CONTRIBUTORS
> > +#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
> NOT
> > +#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
> FITNESS FOR
> > +#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
> COPYRIGHT
> > +#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
> INCIDENTAL,
> > +#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> NOT
> > +#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
> OF USE,
> > +#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
> AND ON ANY
> > +#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
> TORT
> > +#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
> THE USE
> > +#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
> DAMAGE.
> > +#
> > +
> > +# The purpose of this script is to parse the libraries # From
> > +pkg-config in case of dpdk meson builds.
> > +import sys
> > +def parse_pkg_cfg_libs(arg):
> > +    final_string = ""
> > +    first_linker_flag_ind=False
> > +    for text in arg:
> > +        text = text.strip()
> > +        # Ld only understands -lpthread.
> > +        if text == "-pthread":
> > +            text = "-lpthread"
> > +        if '-L/' in text:
> > +            final_string = final_string + text + " "
> > +        elif '-Wl,' == text[:4]:
> > +            # Libtool requires -Wl to only appear once after
> > +            # Which everything else is treated as linker input.
> > +            if not first_linker_flag_ind:
> > +                first_linker_flag_ind = True
> > +                final_string = final_string + text + ","
> > +            else:
> > +                # Omit succeeding -Wl.
> > +                final_string = final_string + text[4:] + ","
> > +        else:
> > +            # Libtool expects comma separated libraries.
> > +            final_string = final_string + text + ","
> > +    return final_string
> > +
> > +if __name__ == "__main__":
> > +    print(parse_pkg_cfg_libs(sys.argv[1:])[:-1])
> >

Thank you for the review Ilya!
Please find my response inline.
Thanks and regards,
Sunil
Pai G, Sunil July 2, 2020, 3:27 p.m. UTC | #4
> -----Original Message-----
> From: Richardson, Bruce <bruce.richardson@intel.com>
> Sent: Thursday, July 2, 2020 7:29 PM
> To: Pai G, Sunil <sunil.pai.g@intel.com>; dev@openvswitch.org
> Cc: Stokes, Ian <ian.stokes@intel.com>; i.maximets@ovn.org;
> david.marchand@redhat.com; Tummala, Sivaprasad
> <sivaprasad.tummala@intel.com>
> Subject: RE: [PATCH RFC dpdk-latest] build: Add support for DPDK meson build.
> 
> 
> 
> > -----Original Message-----
> > From: Pai G, Sunil <sunil.pai.g@intel.com>
> > Sent: Thursday, July 2, 2020 2:14 PM
> > To: dev@openvswitch.org
> > Cc: Stokes, Ian <ian.stokes@intel.com>; i.maximets@ovn.org;
> > david.marchand@redhat.com; Richardson, Bruce
> > <bruce.richardson@intel.com>; Pai G, Sunil <sunil.pai.g@intel.com>;
> > Tummala, Sivaprasad <sivaprasad.tummala@intel.com>
> > Subject: [PATCH RFC dpdk-latest] build: Add support for DPDK meson build.
> >
> > Make based build is deprecated in DPDK. Meson based build to be used
> > for future DPDK releases.
> >
> > This updates travis, configure script and documentation for using DPDK
> > Meson with OVS.
> >
> > Signed-off-by: Sunil Pai G <sunil.pai.g@intel.com>
> 
> Thanks for this, a couple of comments from the DPDK build side inline below.
> 
> Regards,
> /Bruce
> 
> > ---
> >  .travis.yml                           |  3 ++
> >  .travis/linux-build.sh                | 37 +++++++++-------
> >  .travis/linux-prepare.sh              |  1 +
> >  Documentation/intro/install/afxdp.rst |  2 +-
> > Documentation/intro/install/dpdk.rst  | 56 ++++++++++++++++++++----
> >  Makefile.am                           |  3 +-
> >  acinclude.m4                          | 42 ++++++++++++------
> >  parse_pkg_cfg.py                      | 62 +++++++++++++++++++++++++++
> >  8 files changed, 167 insertions(+), 39 deletions(-)  create mode
> > 100644 parse_pkg_cfg.py
> >
> > diff --git a/.travis.yml b/.travis.yml index 97249c1ce..46d7ad9bb
> > 100644
> > --- a/.travis.yml
> > +++ b/.travis.yml
> > @@ -27,6 +27,9 @@ addons:
> >        - selinux-policy-dev
> >        - libunbound-dev
> >        - libunwind-dev
> > +      - python3-setuptools
> > +      - python3-wheel
> > +      - ninja-build
> >
> >  before_install: ./.travis/${TRAVIS_OS_NAME}-prepare.sh
> >
> > diff --git a/.travis/linux-build.sh b/.travis/linux-build.sh index
> > 33b359a61..7fa7e738c 100755
> > --- a/.travis/linux-build.sh
> > +++ b/.travis/linux-build.sh
> > @@ -85,17 +85,21 @@ function install_dpdk()  {
> >      local DPDK_VER=$1
> >      local VERSION_FILE="dpdk-dir/travis-dpdk-cache-version"
> > +    local DPDK_OPTS=""
> >
> > -    if [ -z "$TRAVIS_ARCH" ] ||
> > -       [ "$TRAVIS_ARCH" == "amd64" ]; then
> > -        TARGET="x86_64-native-linuxapp-gcc"
> > -    elif [ "$TRAVIS_ARCH" == "aarch64" ]; then
> > -        TARGET="arm64-armv8a-linuxapp-gcc"
> > -    else
> > +    if [ "$TRAVIS_ARCH" == "aarch64" ]; then
> > +        DPDK_OPTS="$DPDK_OPTS --cross-file
> > config/arm/arm64_armv8_linux_gcc"
> > +    elif [ "$TRAVIS_ARCH" != "amd64" ] && [ -n "$TRAVIS_ARCH" ]; then
> >          echo "Target is unknown"
> >          exit 1
> >      fi
> >
> > +    if [ "$DPDK_SHARED" ]; then
> > +        EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=shared"
> > +    else
> > +        EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=static"
> > +    fi
> > +
> >      if [ "${DPDK_VER##refs/*/}" != "${DPDK_VER}" ]; then
> >          # Avoid using cache for git tree build.
> >          rm -rf dpdk-dir
> > @@ -108,7 +112,8 @@ function install_dpdk()
> >          if [ -f "${VERSION_FILE}" ]; then
> >              VER=$(cat ${VERSION_FILE})
> >              if [ "${VER}" = "${DPDK_VER}" ]; then
> > -                EXTRA_OPTS="${EXTRA_OPTS} --with-dpdk=$(pwd)/dpdk-
> > dir/build"
> > +                sudo ninja -C $(pwd)/dpdk-dir/build install
> > +                sudo ldconfig
> >                  echo "Found cached DPDK ${VER} build in $(pwd)/dpdk-dir"
> >                  return
> >              fi
> > @@ -122,16 +127,18 @@ function install_dpdk()
> >          pushd dpdk-dir
> >      fi
> >
> > -    make config CC=gcc T=$TARGET
> > +    # Disable building DPDK kernel modules. Not needed for OVS build
> > + or
> > tests.
> > +    DPDK_OPTS="$DPDK_OPTS -Denable_kmods=false"
> >
> 
> NOTE: enable_kmods=false is the default in DPDK, so should not need to be
> specified, unless you want to be doubly sure they are not build, or for clarity.

Understood. Shall address this in the next version.

> 
> > -    if [ "$DPDK_SHARED" ]; then
> > -        sed -i '/CONFIG_RTE_BUILD_SHARED_LIB=n/s/=n/=y/' build/.config
> > -        export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/$TARGET/lib
> > -    fi
> > +    DPDK_OPTS="$DPDK_OPTS -Dc_args=-fPIC"
> 
> Since meson build for DPDK always links the objects into both static and shared
> libs, all objects are already built with -fPIC, so this should not be necessary.

Sure , will address this in the next patch as well.

> > +    CC=gcc meson $DPDK_OPTS build
> > +    ninja -C build
> > +    sudo ninja -C build install
> > +
> > +    # Update the library paths.
> > +    sudo ldconfig
> >
> > -    make -j4 CC=gcc EXTRA_CFLAGS='-fPIC'
> > -    EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=$(pwd)/build"
> > -    echo "Installed DPDK source in $(pwd)"
> > +    echo "Installed DPDK source"
> >      popd
> >      echo "${DPDK_VER}" > ${VERSION_FILE}  } diff --git
> > a/.travis/linux- prepare.sh b/.travis/linux-prepare.sh index
> > 8cbbd5623..682f6234b 100755
> > --- a/.travis/linux-prepare.sh
> > +++ b/.travis/linux-prepare.sh
> > @@ -16,6 +16,7 @@ cd ..
> >
> >  pip3 install --disable-pip-version-check --user flake8 hacking
> >  pip3 install --user --upgrade docutils
> > +pip3 install --user  'meson==0.47.1'
> >
> 
> Is there a reason for forcing this to the oldest supported version?

Yes , quoting David's commit message from DPDK travis, 
which is a concise explanation of why (Thanks David! :)):
"
    meson 0.53.0 has a compatibility issue [1] with the python 3.5.2 that comes
    in Ubuntu 16.04.
    On the other hand, the minimal version supported in dpdk is 0.47.1.

    Stick to this version to avoid getting hit by regressions in meson latest
    shiny release.

    1: https://github.com/mesonbuild/meson/issues/6427
"

> 
> >  if [ "$M32" ]; then
> >      # Installing 32-bit libraries.
> <snip for brevity>

Hi Bruce , Thank you for the review.
Please find my response inline.
Thanks and regards,
Sunil
Richardson, Bruce July 2, 2020, 4:01 p.m. UTC | #5
> -----Original Message-----
> From: Pai G, Sunil <sunil.pai.g@intel.com>
> Sent: Thursday, July 2, 2020 4:25 PM
> To: Ilya Maximets <i.maximets@ovn.org>; dev@openvswitch.org
> Cc: Stokes, Ian <ian.stokes@intel.com>; david.marchand@redhat.com;
> Richardson, Bruce <bruce.richardson@intel.com>; Tummala, Sivaprasad
> <sivaprasad.tummala@intel.com>
> Subject: RE: [PATCH RFC dpdk-latest] build: Add support for DPDK meson
> build.
> 
> > -----Original Message-----
> > From: Ilya Maximets <i.maximets@ovn.org>
> > Sent: Thursday, July 2, 2020 7:26 PM
> > To: Pai G, Sunil <sunil.pai.g@intel.com>; dev@openvswitch.org
> > Cc: Stokes, Ian <ian.stokes@intel.com>; i.maximets@ovn.org;
> > david.marchand@redhat.com; Richardson, Bruce
> > <bruce.richardson@intel.com>; Tummala, Sivaprasad
> > <sivaprasad.tummala@intel.com>; i.maximets@ovn.org
> > Subject: Re: [PATCH RFC dpdk-latest] build: Add support for DPDK meson
> build.
> >
> > On 7/2/20 3:13 PM, Sunil Pai G wrote:
> > > Make based build is deprecated in DPDK. Meson based build to be used
> > > for future DPDK releases.
> > >
> > > This updates travis, configure script and documentation for using
> > > DPDK Meson with OVS.
> > >
> > > Signed-off-by: Sunil Pai G <sunil.pai.g@intel.com>
> >
> > Thanks for working on this!
> > Not a full review, just a few quick bits.
> >
> > At first, why dpdk-latest?  Is there issue with meson build on 19.11?
> 
> The linker always picked the shared DPDK libraries over static when built
> with Meson in DPDK-19.11. -Bstatic flag would get jumbled by libtool
> causing this.
> Thanks to Bruce, there was recently merged series which fixed a bunch of
> issues along with this :
> https://patches.dpdk.org/project/dpdk/list/?series=10690
> It is requested for a back port of this series to DPDK-19.11.
> 
> >
> > Few more comments inline.
> >
> > Best regards, Ilya Maximets.
> >
> > > ---
> > >  .travis.yml                           |  3 ++
> > >  .travis/linux-build.sh                | 37 +++++++++-------
> > >  .travis/linux-prepare.sh              |  1 +
> > >  Documentation/intro/install/afxdp.rst |  2 +-
> > > Documentation/intro/install/dpdk.rst  | 56 ++++++++++++++++++++----
> > >  Makefile.am                           |  3 +-
> > >  acinclude.m4                          | 42 ++++++++++++------
> > >  parse_pkg_cfg.py                      | 62
> +++++++++++++++++++++++++++
> > >  8 files changed, 167 insertions(+), 39 deletions(-)  create mode
> > > 100644 parse_pkg_cfg.py
> > >
> > > diff --git a/.travis.yml b/.travis.yml index 97249c1ce..46d7ad9bb
> > > 100644
> > > --- a/.travis.yml
> > > +++ b/.travis.yml
> > > @@ -27,6 +27,9 @@ addons:
> > >        - selinux-policy-dev
> > >        - libunbound-dev
> > >        - libunwind-dev
> > > +      - python3-setuptools
> > > +      - python3-wheel
> > > +      - ninja-build
> > >
> > >  before_install: ./.travis/${TRAVIS_OS_NAME}-prepare.sh
> > >
> > > diff --git a/.travis/linux-build.sh b/.travis/linux-build.sh index
> > > 33b359a61..7fa7e738c 100755
> > > --- a/.travis/linux-build.sh
> > > +++ b/.travis/linux-build.sh
> > > @@ -85,17 +85,21 @@ function install_dpdk()  {
> > >      local DPDK_VER=$1
> > >      local VERSION_FILE="dpdk-dir/travis-dpdk-cache-version"
> > > +    local DPDK_OPTS=""
> > >
> > > -    if [ -z "$TRAVIS_ARCH" ] ||
> > > -       [ "$TRAVIS_ARCH" == "amd64" ]; then
> > > -        TARGET="x86_64-native-linuxapp-gcc"
> > > -    elif [ "$TRAVIS_ARCH" == "aarch64" ]; then
> > > -        TARGET="arm64-armv8a-linuxapp-gcc"
> > > -    else
> > > +    if [ "$TRAVIS_ARCH" == "aarch64" ]; then
> > > +        DPDK_OPTS="$DPDK_OPTS --cross-file
> > config/arm/arm64_armv8_linux_gcc"
> >
> > We're not cross compiling, we're actually building on aarch64 here.
> > This option should not be needed.  IIUC, meson should detect current
> > architecture and build with appropriate configuration.
> >
> > We should be able to just drop all the TRAVIS_ARCH checks for DPDK here.
> 
> Sure ,let me check on this . I see a similar approach taken in DPDK
> travis.
> May be Bruce can comment as well ?
> 
> >
> > > +    elif [ "$TRAVIS_ARCH" != "amd64" ] && [ -n "$TRAVIS_ARCH" ];
> > > + then
> > >          echo "Target is unknown"
> > >          exit 1
> > >      fi
> > >
> > > +    if [ "$DPDK_SHARED" ]; then
> > > +        EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=shared"
> > > +    else
> > > +        EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=static"
> > > +    fi
> >
> > I gusee we could just change the env variable and not parse it here.
> > i.e. have DPDK_LIB=static defined by travis.yml by default and
> > redefine it for matrix entries where we need shared libs.
> 
> Yes , this could be done. But if we install the libraries in a custom path
> using a prefix, we would have to export the LD_LIBRARY_PATH for which
> querying whether to build as shared/static will be required.(This in
> relation to the below comment as well :))
> 
> 
> >
> > > +
> > >      if [ "${DPDK_VER##refs/*/}" != "${DPDK_VER}" ]; then
> > >          # Avoid using cache for git tree build.
> > >          rm -rf dpdk-dir
> > > @@ -108,7 +112,8 @@ function install_dpdk()
> > >          if [ -f "${VERSION_FILE}" ]; then
> > >              VER=$(cat ${VERSION_FILE})
> > >              if [ "${VER}" = "${DPDK_VER}" ]; then
> > > -                EXTRA_OPTS="${EXTRA_OPTS} --with-dpdk=$(pwd)/dpdk-
> dir/build"
> > > +                sudo ninja -C $(pwd)/dpdk-dir/build install
> > > +                sudo ldconfig
> >
> > I think that installing right here inside the cached folder and just
> > adjusting environment variables should be a bit faster than re-
> installing DPDK every time.
> >
> > This script also will be a good example for people like me, who really
> > don't want to install development versions of DPDK globally on a work
> > laptop while testing OVS builds.
> 
> Yes , Thanks for the suggestion. Although ,using an install to a directory
> with a prefix would require this patch from Bruce:
> https://patches.dpdk.org/patch/72271/
>  (which is not merged yet as of this writing) .without this , OVS would
> fail to run searching for few shared DPDK libraries even when built with
> static libraries.
> 
> >
> > >                  echo "Found cached DPDK ${VER} build in $(pwd)/dpdk-
> dir"
> > >                  return
> > >              fi
> > > @@ -122,16 +127,18 @@ function install_dpdk()
> > >          pushd dpdk-dir
> > >      fi
> > >
> > > -    make config CC=gcc T=$TARGET
> > > +    # Disable building DPDK kernel modules. Not needed for OVS build
> or tests.
> > > +    DPDK_OPTS="$DPDK_OPTS -Denable_kmods=false"
> >
> > We should also disable examples and tests at least.
> 
> Sure , this will reduce the build time as well.
>  Will update in the next version.
> 

Examples will be disabled by default, but disabling tests indeed makes sense here.

> >
> > >
> > > -    if [ "$DPDK_SHARED" ]; then
> > > -        sed -i '/CONFIG_RTE_BUILD_SHARED_LIB=n/s/=n/=y/'
> build/.config
> > > -        export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/$TARGET/lib
> > > -    fi
> > > +    DPDK_OPTS="$DPDK_OPTS -Dc_args=-fPIC"
> > > +    CC=gcc meson $DPDK_OPTS build
> > > +    ninja -C build
> > > +    sudo ninja -C build install
> > > +
> > > +    # Update the library paths.
> > > +    sudo ldconfig
> > >
> > > -    make -j4 CC=gcc EXTRA_CFLAGS='-fPIC'
> > > -    EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=$(pwd)/build"
> > > -    echo "Installed DPDK source in $(pwd)"
> > > +    echo "Installed DPDK source"
> > >      popd
> > >      echo "${DPDK_VER}" > ${VERSION_FILE}  } diff --git
> > > a/.travis/linux-prepare.sh b/.travis/linux-prepare.sh index
> > > 8cbbd5623..682f6234b 100755
> > > --- a/.travis/linux-prepare.sh
> > > +++ b/.travis/linux-prepare.sh
> > > @@ -16,6 +16,7 @@ cd ..
> > >
> > >  pip3 install --disable-pip-version-check --user flake8 hacking
> > >  pip3 install --user --upgrade docutils
> > > +pip3 install --user  'meson==0.47.1'
> >
> > I understand that that is the minimum required version, but why not
> > the most recent one or, at least, a bit more recent?
> >
> 
> Yes , quoting David's commit message from DPDK travis :
> "
>     meson 0.53.0 has a compatibility issue [1] with the python 3.5.2 that
> comes
>     in Ubuntu 16.04.
>     On the other hand, the minimal version supported in dpdk is 0.47.1.
> 
>     Stick to this version to avoid getting hit by regressions in meson
> latest
>     shiny release.
> 
>     1: https://github.com/mesonbuild/meson/issues/6427
> "
> 

Does your travis instance use 16.04 or 18.04? If possible can you standardize
on a new specific version to get some additional benefits. For example, with meson
0.54 there is support for "uninstalled" pkg-config files, which you can use for
linking against a DPDK instance which has not been installed on the system.
[https://mesonbuild.com/Release-notes-for-0-54-0.html#uninstalled-pkgconfig-files]
I think that feature may be of interest or of use for the future.
Pai G, Sunil July 2, 2020, 4:10 p.m. UTC | #6
> -----Original Message-----
> From: Richardson, Bruce <bruce.richardson@intel.com>
> Sent: Thursday, July 2, 2020 9:32 PM
> To: Pai G, Sunil <sunil.pai.g@intel.com>; Ilya Maximets
> <i.maximets@ovn.org>; dev@openvswitch.org
> Cc: Stokes, Ian <ian.stokes@intel.com>; david.marchand@redhat.com;
> Tummala, Sivaprasad <sivaprasad.tummala@intel.com>
> Subject: RE: [PATCH RFC dpdk-latest] build: Add support for DPDK meson
> build.
> 
> 
> 
> > -----Original Message-----
> > From: Pai G, Sunil <sunil.pai.g@intel.com>
> > Sent: Thursday, July 2, 2020 4:25 PM
> > To: Ilya Maximets <i.maximets@ovn.org>; dev@openvswitch.org
> > Cc: Stokes, Ian <ian.stokes@intel.com>; david.marchand@redhat.com;
> > Richardson, Bruce <bruce.richardson@intel.com>; Tummala, Sivaprasad
> > <sivaprasad.tummala@intel.com>
> > Subject: RE: [PATCH RFC dpdk-latest] build: Add support for DPDK meson
> > build.
> >
> > > -----Original Message-----
> > > From: Ilya Maximets <i.maximets@ovn.org>
> > > Sent: Thursday, July 2, 2020 7:26 PM
> > > To: Pai G, Sunil <sunil.pai.g@intel.com>; dev@openvswitch.org
> > > Cc: Stokes, Ian <ian.stokes@intel.com>; i.maximets@ovn.org;
> > > david.marchand@redhat.com; Richardson, Bruce
> > > <bruce.richardson@intel.com>; Tummala, Sivaprasad
> > > <sivaprasad.tummala@intel.com>; i.maximets@ovn.org
> > > Subject: Re: [PATCH RFC dpdk-latest] build: Add support for DPDK
> > > meson
> > build.
> > >
> > > On 7/2/20 3:13 PM, Sunil Pai G wrote:
> > > > Make based build is deprecated in DPDK. Meson based build to be
> > > > used for future DPDK releases.
> > > >
> > > > This updates travis, configure script and documentation for using
> > > > DPDK Meson with OVS.
> > > >
> > > > Signed-off-by: Sunil Pai G <sunil.pai.g@intel.com>
> > >
> > > Thanks for working on this!
> > > Not a full review, just a few quick bits.
> > >
> > > At first, why dpdk-latest?  Is there issue with meson build on 19.11?
> >
> > The linker always picked the shared DPDK libraries over static when
> > built with Meson in DPDK-19.11. -Bstatic flag would get jumbled by
> > libtool causing this.
> > Thanks to Bruce, there was recently merged series which fixed a bunch
> > of issues along with this :
> > https://patches.dpdk.org/project/dpdk/list/?series=10690
> > It is requested for a back port of this series to DPDK-19.11.
> >
> > >
> > > Few more comments inline.
> > >
> > > Best regards, Ilya Maximets.
> > >
> > > > ---
> > > >  .travis.yml                           |  3 ++
> > > >  .travis/linux-build.sh                | 37 +++++++++-------
> > > >  .travis/linux-prepare.sh              |  1 +
> > > >  Documentation/intro/install/afxdp.rst |  2 +-
> > > > Documentation/intro/install/dpdk.rst  | 56 ++++++++++++++++++++---
> -
> > > >  Makefile.am                           |  3 +-
> > > >  acinclude.m4                          | 42 ++++++++++++------
> > > >  parse_pkg_cfg.py                      | 62
> > +++++++++++++++++++++++++++
> > > >  8 files changed, 167 insertions(+), 39 deletions(-)  create mode
> > > > 100644 parse_pkg_cfg.py
> > > >
> > > > diff --git a/.travis.yml b/.travis.yml index 97249c1ce..46d7ad9bb
> > > > 100644
> > > > --- a/.travis.yml
> > > > +++ b/.travis.yml
> > > > @@ -27,6 +27,9 @@ addons:
> > > >        - selinux-policy-dev
> > > >        - libunbound-dev
> > > >        - libunwind-dev
> > > > +      - python3-setuptools
> > > > +      - python3-wheel
> > > > +      - ninja-build
> > > >
> > > >  before_install: ./.travis/${TRAVIS_OS_NAME}-prepare.sh
> > > >
> > > > diff --git a/.travis/linux-build.sh b/.travis/linux-build.sh index
> > > > 33b359a61..7fa7e738c 100755
> > > > --- a/.travis/linux-build.sh
> > > > +++ b/.travis/linux-build.sh
> > > > @@ -85,17 +85,21 @@ function install_dpdk()  {
> > > >      local DPDK_VER=$1
> > > >      local VERSION_FILE="dpdk-dir/travis-dpdk-cache-version"
> > > > +    local DPDK_OPTS=""
> > > >
> > > > -    if [ -z "$TRAVIS_ARCH" ] ||
> > > > -       [ "$TRAVIS_ARCH" == "amd64" ]; then
> > > > -        TARGET="x86_64-native-linuxapp-gcc"
> > > > -    elif [ "$TRAVIS_ARCH" == "aarch64" ]; then
> > > > -        TARGET="arm64-armv8a-linuxapp-gcc"
> > > > -    else
> > > > +    if [ "$TRAVIS_ARCH" == "aarch64" ]; then
> > > > +        DPDK_OPTS="$DPDK_OPTS --cross-file
> > > config/arm/arm64_armv8_linux_gcc"
> > >
> > > We're not cross compiling, we're actually building on aarch64 here.
> > > This option should not be needed.  IIUC, meson should detect current
> > > architecture and build with appropriate configuration.
> > >
> > > We should be able to just drop all the TRAVIS_ARCH checks for DPDK
> here.
> >
> > Sure ,let me check on this . I see a similar approach taken in DPDK
> > travis.
> > May be Bruce can comment as well ?
> >
> > >
> > > > +    elif [ "$TRAVIS_ARCH" != "amd64" ] && [ -n "$TRAVIS_ARCH" ];
> > > > + then
> > > >          echo "Target is unknown"
> > > >          exit 1
> > > >      fi
> > > >
> > > > +    if [ "$DPDK_SHARED" ]; then
> > > > +        EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=shared"
> > > > +    else
> > > > +        EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=static"
> > > > +    fi
> > >
> > > I gusee we could just change the env variable and not parse it here.
> > > i.e. have DPDK_LIB=static defined by travis.yml by default and
> > > redefine it for matrix entries where we need shared libs.
> >
> > Yes , this could be done. But if we install the libraries in a custom
> > path using a prefix, we would have to export the LD_LIBRARY_PATH for
> > which querying whether to build as shared/static will be
> > required.(This in relation to the below comment as well :))
> >
> >
> > >
> > > > +
> > > >      if [ "${DPDK_VER##refs/*/}" != "${DPDK_VER}" ]; then
> > > >          # Avoid using cache for git tree build.
> > > >          rm -rf dpdk-dir
> > > > @@ -108,7 +112,8 @@ function install_dpdk()
> > > >          if [ -f "${VERSION_FILE}" ]; then
> > > >              VER=$(cat ${VERSION_FILE})
> > > >              if [ "${VER}" = "${DPDK_VER}" ]; then
> > > > -                EXTRA_OPTS="${EXTRA_OPTS} --with-dpdk=$(pwd)/dpdk-
> > dir/build"
> > > > +                sudo ninja -C $(pwd)/dpdk-dir/build install
> > > > +                sudo ldconfig
> > >
> > > I think that installing right here inside the cached folder and just
> > > adjusting environment variables should be a bit faster than re-
> > installing DPDK every time.
> > >
> > > This script also will be a good example for people like me, who
> > > really don't want to install development versions of DPDK globally
> > > on a work laptop while testing OVS builds.
> >
> > Yes , Thanks for the suggestion. Although ,using an install to a
> > directory with a prefix would require this patch from Bruce:
> > https://patches.dpdk.org/patch/72271/
> >  (which is not merged yet as of this writing) .without this , OVS
> > would fail to run searching for few shared DPDK libraries even when
> > built with static libraries.
> >
> > >
> > > >                  echo "Found cached DPDK ${VER} build in
> > > > $(pwd)/dpdk-
> > dir"
> > > >                  return
> > > >              fi
> > > > @@ -122,16 +127,18 @@ function install_dpdk()
> > > >          pushd dpdk-dir
> > > >      fi
> > > >
> > > > -    make config CC=gcc T=$TARGET
> > > > +    # Disable building DPDK kernel modules. Not needed for OVS
> > > > + build
> > or tests.
> > > > +    DPDK_OPTS="$DPDK_OPTS -Denable_kmods=false"
> > >
> > > We should also disable examples and tests at least.
> >
> > Sure , this will reduce the build time as well.
> >  Will update in the next version.
> >
> 
> Examples will be disabled by default, but disabling tests indeed makes sense
> here.
> 
> > >
> > > >
> > > > -    if [ "$DPDK_SHARED" ]; then
> > > > -        sed -i '/CONFIG_RTE_BUILD_SHARED_LIB=n/s/=n/=y/'
> > build/.config
> > > > -        export
> LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/$TARGET/lib
> > > > -    fi
> > > > +    DPDK_OPTS="$DPDK_OPTS -Dc_args=-fPIC"
> > > > +    CC=gcc meson $DPDK_OPTS build
> > > > +    ninja -C build
> > > > +    sudo ninja -C build install
> > > > +
> > > > +    # Update the library paths.
> > > > +    sudo ldconfig
> > > >
> > > > -    make -j4 CC=gcc EXTRA_CFLAGS='-fPIC'
> > > > -    EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=$(pwd)/build"
> > > > -    echo "Installed DPDK source in $(pwd)"
> > > > +    echo "Installed DPDK source"
> > > >      popd
> > > >      echo "${DPDK_VER}" > ${VERSION_FILE}  } diff --git
> > > > a/.travis/linux-prepare.sh b/.travis/linux-prepare.sh index
> > > > 8cbbd5623..682f6234b 100755
> > > > --- a/.travis/linux-prepare.sh
> > > > +++ b/.travis/linux-prepare.sh
> > > > @@ -16,6 +16,7 @@ cd ..
> > > >
> > > >  pip3 install --disable-pip-version-check --user flake8 hacking
> > > >  pip3 install --user --upgrade docutils
> > > > +pip3 install --user  'meson==0.47.1'
> > >
> > > I understand that that is the minimum required version, but why not
> > > the most recent one or, at least, a bit more recent?
> > >
> >
> > Yes , quoting David's commit message from DPDK travis :
> > "
> >     meson 0.53.0 has a compatibility issue [1] with the python 3.5.2
> > that comes
> >     in Ubuntu 16.04.
> >     On the other hand, the minimal version supported in dpdk is 0.47.1.
> >
> >     Stick to this version to avoid getting hit by regressions in meson
> > latest
> >     shiny release.
> >
> >     1: https://github.com/mesonbuild/meson/issues/6427
> > "
> >
> 
> Does your travis instance use 16.04 or 18.04? If possible can you standardize
> on a new specific version to get some additional benefits. For example, with
> meson
> 0.54 there is support for "uninstalled" pkg-config files, which you can use for
> linking against a DPDK instance which has not been installed on the system.
> [https://mesonbuild.com/Release-notes-for-0-54-0.html#uninstalled-
> pkgconfig-files]
> I think that feature may be of interest or of use for the future.

Currently 16.04 is being used . I tried to moving to 18.04 as well. But seems like few other 
test cases which require kernel 3.16 seem to fail. Probably Ilya/David/Ian could comment if those test cases
can be removed and we could move to 18.04 travis?
Ilya Maximets July 2, 2020, 4:24 p.m. UTC | #7
On 7/2/20 6:10 PM, Pai G, Sunil wrote:
>> -----Original Message-----
>> From: Richardson, Bruce <bruce.richardson@intel.com>
>> Sent: Thursday, July 2, 2020 9:32 PM
>> To: Pai G, Sunil <sunil.pai.g@intel.com>; Ilya Maximets
>> <i.maximets@ovn.org>; dev@openvswitch.org
>> Cc: Stokes, Ian <ian.stokes@intel.com>; david.marchand@redhat.com;
>> Tummala, Sivaprasad <sivaprasad.tummala@intel.com>
>> Subject: RE: [PATCH RFC dpdk-latest] build: Add support for DPDK meson
>> build.
>>
>>
>>
>>> -----Original Message-----
>>> From: Pai G, Sunil <sunil.pai.g@intel.com>
>>> Sent: Thursday, July 2, 2020 4:25 PM
>>> To: Ilya Maximets <i.maximets@ovn.org>; dev@openvswitch.org
>>> Cc: Stokes, Ian <ian.stokes@intel.com>; david.marchand@redhat.com;
>>> Richardson, Bruce <bruce.richardson@intel.com>; Tummala, Sivaprasad
>>> <sivaprasad.tummala@intel.com>
>>> Subject: RE: [PATCH RFC dpdk-latest] build: Add support for DPDK meson
>>> build.
>>>
>>>> -----Original Message-----
>>>> From: Ilya Maximets <i.maximets@ovn.org>
>>>> Sent: Thursday, July 2, 2020 7:26 PM
>>>> To: Pai G, Sunil <sunil.pai.g@intel.com>; dev@openvswitch.org
>>>> Cc: Stokes, Ian <ian.stokes@intel.com>; i.maximets@ovn.org;
>>>> david.marchand@redhat.com; Richardson, Bruce
>>>> <bruce.richardson@intel.com>; Tummala, Sivaprasad
>>>> <sivaprasad.tummala@intel.com>; i.maximets@ovn.org
>>>> Subject: Re: [PATCH RFC dpdk-latest] build: Add support for DPDK
>>>> meson
>>> build.
>>>>
>>>> On 7/2/20 3:13 PM, Sunil Pai G wrote:
>>>>> Make based build is deprecated in DPDK. Meson based build to be
>>>>> used for future DPDK releases.
>>>>>
>>>>> This updates travis, configure script and documentation for using
>>>>> DPDK Meson with OVS.
>>>>>
>>>>> Signed-off-by: Sunil Pai G <sunil.pai.g@intel.com>
>>>>
>>>> Thanks for working on this!
>>>> Not a full review, just a few quick bits.
>>>>
>>>> At first, why dpdk-latest?  Is there issue with meson build on 19.11?
>>>
>>> The linker always picked the shared DPDK libraries over static when
>>> built with Meson in DPDK-19.11. -Bstatic flag would get jumbled by
>>> libtool causing this.
>>> Thanks to Bruce, there was recently merged series which fixed a bunch
>>> of issues along with this :
>>> https://patches.dpdk.org/project/dpdk/list/?series=10690
>>> It is requested for a back port of this series to DPDK-19.11.
>>>
>>>>
>>>> Few more comments inline.
>>>>
>>>> Best regards, Ilya Maximets.
>>>>
>>>>> ---
>>>>>  .travis.yml                           |  3 ++
>>>>>  .travis/linux-build.sh                | 37 +++++++++-------
>>>>>  .travis/linux-prepare.sh              |  1 +
>>>>>  Documentation/intro/install/afxdp.rst |  2 +-
>>>>> Documentation/intro/install/dpdk.rst  | 56 ++++++++++++++++++++---
>> -
>>>>>  Makefile.am                           |  3 +-
>>>>>  acinclude.m4                          | 42 ++++++++++++------
>>>>>  parse_pkg_cfg.py                      | 62
>>> +++++++++++++++++++++++++++
>>>>>  8 files changed, 167 insertions(+), 39 deletions(-)  create mode
>>>>> 100644 parse_pkg_cfg.py
>>>>>
>>>>> diff --git a/.travis.yml b/.travis.yml index 97249c1ce..46d7ad9bb
>>>>> 100644
>>>>> --- a/.travis.yml
>>>>> +++ b/.travis.yml
>>>>> @@ -27,6 +27,9 @@ addons:
>>>>>        - selinux-policy-dev
>>>>>        - libunbound-dev
>>>>>        - libunwind-dev
>>>>> +      - python3-setuptools
>>>>> +      - python3-wheel
>>>>> +      - ninja-build
>>>>>
>>>>>  before_install: ./.travis/${TRAVIS_OS_NAME}-prepare.sh
>>>>>
>>>>> diff --git a/.travis/linux-build.sh b/.travis/linux-build.sh index
>>>>> 33b359a61..7fa7e738c 100755
>>>>> --- a/.travis/linux-build.sh
>>>>> +++ b/.travis/linux-build.sh
>>>>> @@ -85,17 +85,21 @@ function install_dpdk()  {
>>>>>      local DPDK_VER=$1
>>>>>      local VERSION_FILE="dpdk-dir/travis-dpdk-cache-version"
>>>>> +    local DPDK_OPTS=""
>>>>>
>>>>> -    if [ -z "$TRAVIS_ARCH" ] ||
>>>>> -       [ "$TRAVIS_ARCH" == "amd64" ]; then
>>>>> -        TARGET="x86_64-native-linuxapp-gcc"
>>>>> -    elif [ "$TRAVIS_ARCH" == "aarch64" ]; then
>>>>> -        TARGET="arm64-armv8a-linuxapp-gcc"
>>>>> -    else
>>>>> +    if [ "$TRAVIS_ARCH" == "aarch64" ]; then
>>>>> +        DPDK_OPTS="$DPDK_OPTS --cross-file
>>>> config/arm/arm64_armv8_linux_gcc"
>>>>
>>>> We're not cross compiling, we're actually building on aarch64 here.
>>>> This option should not be needed.  IIUC, meson should detect current
>>>> architecture and build with appropriate configuration.
>>>>
>>>> We should be able to just drop all the TRAVIS_ARCH checks for DPDK
>> here.
>>>
>>> Sure ,let me check on this . I see a similar approach taken in DPDK
>>> travis.
>>> May be Bruce can comment as well ?
>>>
>>>>
>>>>> +    elif [ "$TRAVIS_ARCH" != "amd64" ] && [ -n "$TRAVIS_ARCH" ];
>>>>> + then
>>>>>          echo "Target is unknown"
>>>>>          exit 1
>>>>>      fi
>>>>>
>>>>> +    if [ "$DPDK_SHARED" ]; then
>>>>> +        EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=shared"
>>>>> +    else
>>>>> +        EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=static"
>>>>> +    fi
>>>>
>>>> I gusee we could just change the env variable and not parse it here.
>>>> i.e. have DPDK_LIB=static defined by travis.yml by default and
>>>> redefine it for matrix entries where we need shared libs.
>>>
>>> Yes , this could be done. But if we install the libraries in a custom
>>> path using a prefix, we would have to export the LD_LIBRARY_PATH for
>>> which querying whether to build as shared/static will be
>>> required.(This in relation to the below comment as well :))
>>>
>>>
>>>>
>>>>> +
>>>>>      if [ "${DPDK_VER##refs/*/}" != "${DPDK_VER}" ]; then
>>>>>          # Avoid using cache for git tree build.
>>>>>          rm -rf dpdk-dir
>>>>> @@ -108,7 +112,8 @@ function install_dpdk()
>>>>>          if [ -f "${VERSION_FILE}" ]; then
>>>>>              VER=$(cat ${VERSION_FILE})
>>>>>              if [ "${VER}" = "${DPDK_VER}" ]; then
>>>>> -                EXTRA_OPTS="${EXTRA_OPTS} --with-dpdk=$(pwd)/dpdk-
>>> dir/build"
>>>>> +                sudo ninja -C $(pwd)/dpdk-dir/build install
>>>>> +                sudo ldconfig
>>>>
>>>> I think that installing right here inside the cached folder and just
>>>> adjusting environment variables should be a bit faster than re-
>>> installing DPDK every time.
>>>>
>>>> This script also will be a good example for people like me, who
>>>> really don't want to install development versions of DPDK globally
>>>> on a work laptop while testing OVS builds.
>>>
>>> Yes , Thanks for the suggestion. Although ,using an install to a
>>> directory with a prefix would require this patch from Bruce:
>>> https://patches.dpdk.org/patch/72271/
>>>  (which is not merged yet as of this writing) .without this , OVS
>>> would fail to run searching for few shared DPDK libraries even when
>>> built with static libraries.
>>>
>>>>
>>>>>                  echo "Found cached DPDK ${VER} build in
>>>>> $(pwd)/dpdk-
>>> dir"
>>>>>                  return
>>>>>              fi
>>>>> @@ -122,16 +127,18 @@ function install_dpdk()
>>>>>          pushd dpdk-dir
>>>>>      fi
>>>>>
>>>>> -    make config CC=gcc T=$TARGET
>>>>> +    # Disable building DPDK kernel modules. Not needed for OVS
>>>>> + build
>>> or tests.
>>>>> +    DPDK_OPTS="$DPDK_OPTS -Denable_kmods=false"
>>>>
>>>> We should also disable examples and tests at least.
>>>
>>> Sure , this will reduce the build time as well.
>>>  Will update in the next version.
>>>
>>
>> Examples will be disabled by default, but disabling tests indeed makes sense
>> here.
>>
>>>>
>>>>>
>>>>> -    if [ "$DPDK_SHARED" ]; then
>>>>> -        sed -i '/CONFIG_RTE_BUILD_SHARED_LIB=n/s/=n/=y/'
>>> build/.config
>>>>> -        export
>> LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/$TARGET/lib
>>>>> -    fi
>>>>> +    DPDK_OPTS="$DPDK_OPTS -Dc_args=-fPIC"
>>>>> +    CC=gcc meson $DPDK_OPTS build
>>>>> +    ninja -C build
>>>>> +    sudo ninja -C build install
>>>>> +
>>>>> +    # Update the library paths.
>>>>> +    sudo ldconfig
>>>>>
>>>>> -    make -j4 CC=gcc EXTRA_CFLAGS='-fPIC'
>>>>> -    EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=$(pwd)/build"
>>>>> -    echo "Installed DPDK source in $(pwd)"
>>>>> +    echo "Installed DPDK source"
>>>>>      popd
>>>>>      echo "${DPDK_VER}" > ${VERSION_FILE}  } diff --git
>>>>> a/.travis/linux-prepare.sh b/.travis/linux-prepare.sh index
>>>>> 8cbbd5623..682f6234b 100755
>>>>> --- a/.travis/linux-prepare.sh
>>>>> +++ b/.travis/linux-prepare.sh
>>>>> @@ -16,6 +16,7 @@ cd ..
>>>>>
>>>>>  pip3 install --disable-pip-version-check --user flake8 hacking
>>>>>  pip3 install --user --upgrade docutils
>>>>> +pip3 install --user  'meson==0.47.1'
>>>>
>>>> I understand that that is the minimum required version, but why not
>>>> the most recent one or, at least, a bit more recent?
>>>>
>>>
>>> Yes , quoting David's commit message from DPDK travis :
>>> "
>>>     meson 0.53.0 has a compatibility issue [1] with the python 3.5.2
>>> that comes
>>>     in Ubuntu 16.04.
>>>     On the other hand, the minimal version supported in dpdk is 0.47.1.
>>>
>>>     Stick to this version to avoid getting hit by regressions in meson
>>> latest
>>>     shiny release.
>>>
>>>     1: https://github.com/mesonbuild/meson/issues/6427
>>> "
>>>
>>
>> Does your travis instance use 16.04 or 18.04? If possible can you standardize
>> on a new specific version to get some additional benefits. For example, with
>> meson
>> 0.54 there is support for "uninstalled" pkg-config files, which you can use for
>> linking against a DPDK instance which has not been installed on the system.
>> [https://mesonbuild.com/Release-notes-for-0-54-0.html#uninstalled-
>> pkgconfig-files]
>> I think that feature may be of interest or of use for the future.
> 
> Currently 16.04 is being used . I tried to moving to 18.04 as well. But seems like few other 
> test cases which require kernel 3.16 seem to fail. Probably Ilya/David/Ian could comment if those test cases
> can be removed and we could move to 18.04 travis? 

The incompatibility issue was fixed in v0.53.1 release and should work fine
with 0.54 on ubuntu 16.04 without upgrading the base image to 18.04.
So, it makes sense to standardize on 0.54 for now.  Could you, please, try it?
Ilya Maximets July 2, 2020, 5:20 p.m. UTC | #8
On 7/2/20 5:25 PM, Pai G, Sunil wrote:
>>
>>> +
>>>      if [ "${DPDK_VER##refs/*/}" != "${DPDK_VER}" ]; then
>>>          # Avoid using cache for git tree build.
>>>          rm -rf dpdk-dir
>>> @@ -108,7 +112,8 @@ function install_dpdk()
>>>          if [ -f "${VERSION_FILE}" ]; then
>>>              VER=$(cat ${VERSION_FILE})
>>>              if [ "${VER}" = "${DPDK_VER}" ]; then
>>> -                EXTRA_OPTS="${EXTRA_OPTS} --with-dpdk=$(pwd)/dpdk-dir/build"
>>> +                sudo ninja -C $(pwd)/dpdk-dir/build install
>>> +                sudo ldconfig
>>
>> I think that installing right here inside the cached folder and just adjusting
>> environment variables should be a bit faster than re-installing DPDK every time.
>>
>> This script also will be a good example for people like me, who really don't want
>> to install development versions of DPDK globally on a work laptop while testing
>> OVS builds.
> 
> Yes , Thanks for the suggestion. Although ,using an install to a directory with
> a prefix would require this patch from Bruce: https://patches.dpdk.org/patch/72271/
>  (which is not merged yet as of this writing) .without this , OVS would fail to run 
> searching for few shared DPDK libraries even when built with static libraries.

But, IIUC, we could just add a path to ld.so.conf to avoid that.
Will it work?  You're updating ldconfig here anyway.
Pai G, Sunil July 3, 2020, 1:57 p.m. UTC | #9
> -----Original Message-----
> From: Ilya Maximets <i.maximets@ovn.org>
> Sent: Thursday, July 2, 2020 9:54 PM
> To: Pai G, Sunil <sunil.pai.g@intel.com>; Richardson, Bruce
> <bruce.richardson@intel.com>; Ilya Maximets <i.maximets@ovn.org>;
> dev@openvswitch.org
> Cc: Stokes, Ian <ian.stokes@intel.com>; david.marchand@redhat.com;
> Tummala, Sivaprasad <sivaprasad.tummala@intel.com>
> Subject: Re: [PATCH RFC dpdk-latest] build: Add support for DPDK meson
> build.
> 
> On 7/2/20 6:10 PM, Pai G, Sunil wrote:
> >> -----Original Message-----
> >> From: Richardson, Bruce <bruce.richardson@intel.com>
> >> Sent: Thursday, July 2, 2020 9:32 PM
> >> To: Pai G, Sunil <sunil.pai.g@intel.com>; Ilya Maximets
> >> <i.maximets@ovn.org>; dev@openvswitch.org
> >> Cc: Stokes, Ian <ian.stokes@intel.com>; david.marchand@redhat.com;
> >> Tummala, Sivaprasad <sivaprasad.tummala@intel.com>
> >> Subject: RE: [PATCH RFC dpdk-latest] build: Add support for DPDK
> >> meson build.
> >>
> >>
> >>
> >>> -----Original Message-----
> >>> From: Pai G, Sunil <sunil.pai.g@intel.com>
> >>> Sent: Thursday, July 2, 2020 4:25 PM
> >>> To: Ilya Maximets <i.maximets@ovn.org>; dev@openvswitch.org
> >>> Cc: Stokes, Ian <ian.stokes@intel.com>; david.marchand@redhat.com;
> >>> Richardson, Bruce <bruce.richardson@intel.com>; Tummala, Sivaprasad
> >>> <sivaprasad.tummala@intel.com>
> >>> Subject: RE: [PATCH RFC dpdk-latest] build: Add support for DPDK
> >>> meson build.
> >>>
> >>>> -----Original Message-----
> >>>> From: Ilya Maximets <i.maximets@ovn.org>
> >>>> Sent: Thursday, July 2, 2020 7:26 PM
> >>>> To: Pai G, Sunil <sunil.pai.g@intel.com>; dev@openvswitch.org
> >>>> Cc: Stokes, Ian <ian.stokes@intel.com>; i.maximets@ovn.org;
> >>>> david.marchand@redhat.com; Richardson, Bruce
> >>>> <bruce.richardson@intel.com>; Tummala, Sivaprasad
> >>>> <sivaprasad.tummala@intel.com>; i.maximets@ovn.org
> >>>> Subject: Re: [PATCH RFC dpdk-latest] build: Add support for DPDK
> >>>> meson
> >>> build.
> >>>>
> >>>> On 7/2/20 3:13 PM, Sunil Pai G wrote:
> >>>>> Make based build is deprecated in DPDK. Meson based build to be
> >>>>> used for future DPDK releases.
> >>>>>
> >>>>> This updates travis, configure script and documentation for using
> >>>>> DPDK Meson with OVS.
> >>>>>
> >>>>> Signed-off-by: Sunil Pai G <sunil.pai.g@intel.com>
> >>>>
> >>>> Thanks for working on this!
> >>>> Not a full review, just a few quick bits.
> >>>>
> >>>> At first, why dpdk-latest?  Is there issue with meson build on 19.11?
> >>>
> >>> The linker always picked the shared DPDK libraries over static when
> >>> built with Meson in DPDK-19.11. -Bstatic flag would get jumbled by
> >>> libtool causing this.
> >>> Thanks to Bruce, there was recently merged series which fixed a
> >>> bunch of issues along with this :
> >>> https://patches.dpdk.org/project/dpdk/list/?series=10690
> >>> It is requested for a back port of this series to DPDK-19.11.
> >>>
> >>>>
> >>>> Few more comments inline.
> >>>>
> >>>> Best regards, Ilya Maximets.
> >>>>
> >>>>> ---
> >>>>>  .travis.yml                           |  3 ++
> >>>>>  .travis/linux-build.sh                | 37 +++++++++-------
> >>>>>  .travis/linux-prepare.sh              |  1 +
> >>>>>  Documentation/intro/install/afxdp.rst |  2 +-
> >>>>> Documentation/intro/install/dpdk.rst  | 56 ++++++++++++++++++++-
> --
> >> -
> >>>>>  Makefile.am                           |  3 +-
> >>>>>  acinclude.m4                          | 42 ++++++++++++------
> >>>>>  parse_pkg_cfg.py                      | 62
> >>> +++++++++++++++++++++++++++
> >>>>>  8 files changed, 167 insertions(+), 39 deletions(-)  create mode
> >>>>> 100644 parse_pkg_cfg.py
> >>>>>
> >>>>> diff --git a/.travis.yml b/.travis.yml index 97249c1ce..46d7ad9bb
> >>>>> 100644
> >>>>> --- a/.travis.yml
> >>>>> +++ b/.travis.yml
> >>>>> @@ -27,6 +27,9 @@ addons:
> >>>>>        - selinux-policy-dev
> >>>>>        - libunbound-dev
> >>>>>        - libunwind-dev
> >>>>> +      - python3-setuptools
> >>>>> +      - python3-wheel
> >>>>> +      - ninja-build
> >>>>>
> >>>>>  before_install: ./.travis/${TRAVIS_OS_NAME}-prepare.sh
> >>>>>
> >>>>> diff --git a/.travis/linux-build.sh b/.travis/linux-build.sh index
> >>>>> 33b359a61..7fa7e738c 100755
> >>>>> --- a/.travis/linux-build.sh
> >>>>> +++ b/.travis/linux-build.sh
> >>>>> @@ -85,17 +85,21 @@ function install_dpdk()  {
> >>>>>      local DPDK_VER=$1
> >>>>>      local VERSION_FILE="dpdk-dir/travis-dpdk-cache-version"
> >>>>> +    local DPDK_OPTS=""
> >>>>>
> >>>>> -    if [ -z "$TRAVIS_ARCH" ] ||
> >>>>> -       [ "$TRAVIS_ARCH" == "amd64" ]; then
> >>>>> -        TARGET="x86_64-native-linuxapp-gcc"
> >>>>> -    elif [ "$TRAVIS_ARCH" == "aarch64" ]; then
> >>>>> -        TARGET="arm64-armv8a-linuxapp-gcc"
> >>>>> -    else
> >>>>> +    if [ "$TRAVIS_ARCH" == "aarch64" ]; then
> >>>>> +        DPDK_OPTS="$DPDK_OPTS --cross-file
> >>>> config/arm/arm64_armv8_linux_gcc"
> >>>>
<snipped>
> >> Does your travis instance use 16.04 or 18.04? If possible can you
> >> standardize on a new specific version to get some additional
> >> benefits. For example, with meson
> >> 0.54 there is support for "uninstalled" pkg-config files, which you
> >> can use for linking against a DPDK instance which has not been installed on
> the system.
> >> [https://mesonbuild.com/Release-notes-for-0-54-0.html#uninstalled-
> >> pkgconfig-files]
> >> I think that feature may be of interest or of use for the future.
> >
> > Currently 16.04 is being used . I tried to moving to 18.04 as well.
> > But seems like few other test cases which require kernel 3.16 seem to
> > fail. Probably Ilya/David/Ian could comment if those test cases can be
> removed and we could move to 18.04 travis?
> 
> The incompatibility issue was fixed in v0.53.1 release and should work fine
> with 0.54 on ubuntu 16.04 without upgrading the base image to 18.04.
> So, it makes sense to standardize on 0.54 for now.  Could you, please, try it?

Thanks, Ilya, for pointing out.
Although I see that this works on x86 , it fails for aarch64 :(
for some reason meson doesnt seem to build properly on aarch64:
https://travis-ci.org/github/Sunil-Pai-G/ovs/builds/704635873
Please let me know if I might have missed something.
Pai G, Sunil July 3, 2020, 1:58 p.m. UTC | #10
> -----Original Message-----
> From: Ilya Maximets <i.maximets@ovn.org>
> Sent: Thursday, July 2, 2020 10:50 PM
> To: Pai G, Sunil <sunil.pai.g@intel.com>; Ilya Maximets
> <i.maximets@ovn.org>; dev@openvswitch.org
> Cc: Stokes, Ian <ian.stokes@intel.com>; david.marchand@redhat.com;
> Richardson, Bruce <bruce.richardson@intel.com>; Tummala, Sivaprasad
> <sivaprasad.tummala@intel.com>
> Subject: Re: [PATCH RFC dpdk-latest] build: Add support for DPDK meson
> build.
> 
> On 7/2/20 5:25 PM, Pai G, Sunil wrote:
> >>
> >>> +
> >>>      if [ "${DPDK_VER##refs/*/}" != "${DPDK_VER}" ]; then
> >>>          # Avoid using cache for git tree build.
> >>>          rm -rf dpdk-dir
> >>> @@ -108,7 +112,8 @@ function install_dpdk()
> >>>          if [ -f "${VERSION_FILE}" ]; then
> >>>              VER=$(cat ${VERSION_FILE})
> >>>              if [ "${VER}" = "${DPDK_VER}" ]; then
> >>> -                EXTRA_OPTS="${EXTRA_OPTS} --with-dpdk=$(pwd)/dpdk-
> dir/build"
> >>> +                sudo ninja -C $(pwd)/dpdk-dir/build install
> >>> +                sudo ldconfig
> >>
> >> I think that installing right here inside the cached folder and just
> >> adjusting environment variables should be a bit faster than re-installing
> DPDK every time.
> >>
> >> This script also will be a good example for people like me, who
> >> really don't want to install development versions of DPDK globally on
> >> a work laptop while testing OVS builds.
> >
> > Yes , Thanks for the suggestion. Although ,using an install to a
> > directory with a prefix would require this patch from Bruce:
> > https://patches.dpdk.org/patch/72271/
> >  (which is not merged yet as of this writing) .without this , OVS
> > would fail to run searching for few shared DPDK libraries even when built
> with static libraries.
> 
> But, IIUC, we could just add a path to ld.so.conf to avoid that.
> Will it work?  You're updating ldconfig here anyway.

Yes , this will probably work . exporting LD_LIBRARY_PATH will also help .
But I thought it makes sense only when OVS consumes DPDK shared libs.
Bruce also acknowledged this as a bug and gracefully gave a fix as well.
So, I thought it's better to install it system wide until the patch is merged in DPDK. 
But I am quite open to take the other approach as well and export the LD_LIBRARY_PATH :)
Let me know your thoughts.
Ilya Maximets July 3, 2020, 5:41 p.m. UTC | #11
On 7/3/20 3:57 PM, Pai G, Sunil wrote:
>> -----Original Message-----
>> From: Ilya Maximets <i.maximets@ovn.org>
>> Sent: Thursday, July 2, 2020 9:54 PM
>> To: Pai G, Sunil <sunil.pai.g@intel.com>; Richardson, Bruce
>> <bruce.richardson@intel.com>; Ilya Maximets <i.maximets@ovn.org>;
>> dev@openvswitch.org
>> Cc: Stokes, Ian <ian.stokes@intel.com>; david.marchand@redhat.com;
>> Tummala, Sivaprasad <sivaprasad.tummala@intel.com>
>> Subject: Re: [PATCH RFC dpdk-latest] build: Add support for DPDK meson
>> build.
>>
>> On 7/2/20 6:10 PM, Pai G, Sunil wrote:
>>>> -----Original Message-----
>>>> From: Richardson, Bruce <bruce.richardson@intel.com>
>>>> Sent: Thursday, July 2, 2020 9:32 PM
>>>> To: Pai G, Sunil <sunil.pai.g@intel.com>; Ilya Maximets
>>>> <i.maximets@ovn.org>; dev@openvswitch.org
>>>> Cc: Stokes, Ian <ian.stokes@intel.com>; david.marchand@redhat.com;
>>>> Tummala, Sivaprasad <sivaprasad.tummala@intel.com>
>>>> Subject: RE: [PATCH RFC dpdk-latest] build: Add support for DPDK
>>>> meson build.
>>>>
>>>>
>>>>
>>>>> -----Original Message-----
>>>>> From: Pai G, Sunil <sunil.pai.g@intel.com>
>>>>> Sent: Thursday, July 2, 2020 4:25 PM
>>>>> To: Ilya Maximets <i.maximets@ovn.org>; dev@openvswitch.org
>>>>> Cc: Stokes, Ian <ian.stokes@intel.com>; david.marchand@redhat.com;
>>>>> Richardson, Bruce <bruce.richardson@intel.com>; Tummala, Sivaprasad
>>>>> <sivaprasad.tummala@intel.com>
>>>>> Subject: RE: [PATCH RFC dpdk-latest] build: Add support for DPDK
>>>>> meson build.
>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Ilya Maximets <i.maximets@ovn.org>
>>>>>> Sent: Thursday, July 2, 2020 7:26 PM
>>>>>> To: Pai G, Sunil <sunil.pai.g@intel.com>; dev@openvswitch.org
>>>>>> Cc: Stokes, Ian <ian.stokes@intel.com>; i.maximets@ovn.org;
>>>>>> david.marchand@redhat.com; Richardson, Bruce
>>>>>> <bruce.richardson@intel.com>; Tummala, Sivaprasad
>>>>>> <sivaprasad.tummala@intel.com>; i.maximets@ovn.org
>>>>>> Subject: Re: [PATCH RFC dpdk-latest] build: Add support for DPDK
>>>>>> meson
>>>>> build.
>>>>>>
>>>>>> On 7/2/20 3:13 PM, Sunil Pai G wrote:
>>>>>>> Make based build is deprecated in DPDK. Meson based build to be
>>>>>>> used for future DPDK releases.
>>>>>>>
>>>>>>> This updates travis, configure script and documentation for using
>>>>>>> DPDK Meson with OVS.
>>>>>>>
>>>>>>> Signed-off-by: Sunil Pai G <sunil.pai.g@intel.com>
>>>>>>
>>>>>> Thanks for working on this!
>>>>>> Not a full review, just a few quick bits.
>>>>>>
>>>>>> At first, why dpdk-latest?  Is there issue with meson build on 19.11?
>>>>>
>>>>> The linker always picked the shared DPDK libraries over static when
>>>>> built with Meson in DPDK-19.11. -Bstatic flag would get jumbled by
>>>>> libtool causing this.
>>>>> Thanks to Bruce, there was recently merged series which fixed a
>>>>> bunch of issues along with this :
>>>>> https://patches.dpdk.org/project/dpdk/list/?series=10690
>>>>> It is requested for a back port of this series to DPDK-19.11.
>>>>>
>>>>>>
>>>>>> Few more comments inline.
>>>>>>
>>>>>> Best regards, Ilya Maximets.
>>>>>>
>>>>>>> ---
>>>>>>>  .travis.yml                           |  3 ++
>>>>>>>  .travis/linux-build.sh                | 37 +++++++++-------
>>>>>>>  .travis/linux-prepare.sh              |  1 +
>>>>>>>  Documentation/intro/install/afxdp.rst |  2 +-
>>>>>>> Documentation/intro/install/dpdk.rst  | 56 ++++++++++++++++++++-
>> --
>>>> -
>>>>>>>  Makefile.am                           |  3 +-
>>>>>>>  acinclude.m4                          | 42 ++++++++++++------
>>>>>>>  parse_pkg_cfg.py                      | 62
>>>>> +++++++++++++++++++++++++++
>>>>>>>  8 files changed, 167 insertions(+), 39 deletions(-)  create mode
>>>>>>> 100644 parse_pkg_cfg.py
>>>>>>>
>>>>>>> diff --git a/.travis.yml b/.travis.yml index 97249c1ce..46d7ad9bb
>>>>>>> 100644
>>>>>>> --- a/.travis.yml
>>>>>>> +++ b/.travis.yml
>>>>>>> @@ -27,6 +27,9 @@ addons:
>>>>>>>        - selinux-policy-dev
>>>>>>>        - libunbound-dev
>>>>>>>        - libunwind-dev
>>>>>>> +      - python3-setuptools
>>>>>>> +      - python3-wheel
>>>>>>> +      - ninja-build
>>>>>>>
>>>>>>>  before_install: ./.travis/${TRAVIS_OS_NAME}-prepare.sh
>>>>>>>
>>>>>>> diff --git a/.travis/linux-build.sh b/.travis/linux-build.sh index
>>>>>>> 33b359a61..7fa7e738c 100755
>>>>>>> --- a/.travis/linux-build.sh
>>>>>>> +++ b/.travis/linux-build.sh
>>>>>>> @@ -85,17 +85,21 @@ function install_dpdk()  {
>>>>>>>      local DPDK_VER=$1
>>>>>>>      local VERSION_FILE="dpdk-dir/travis-dpdk-cache-version"
>>>>>>> +    local DPDK_OPTS=""
>>>>>>>
>>>>>>> -    if [ -z "$TRAVIS_ARCH" ] ||
>>>>>>> -       [ "$TRAVIS_ARCH" == "amd64" ]; then
>>>>>>> -        TARGET="x86_64-native-linuxapp-gcc"
>>>>>>> -    elif [ "$TRAVIS_ARCH" == "aarch64" ]; then
>>>>>>> -        TARGET="arm64-armv8a-linuxapp-gcc"
>>>>>>> -    else
>>>>>>> +    if [ "$TRAVIS_ARCH" == "aarch64" ]; then
>>>>>>> +        DPDK_OPTS="$DPDK_OPTS --cross-file
>>>>>> config/arm/arm64_armv8_linux_gcc"
>>>>>>
> <snipped>
>>>> Does your travis instance use 16.04 or 18.04? If possible can you
>>>> standardize on a new specific version to get some additional
>>>> benefits. For example, with meson
>>>> 0.54 there is support for "uninstalled" pkg-config files, which you
>>>> can use for linking against a DPDK instance which has not been installed on
>> the system.
>>>> [https://mesonbuild.com/Release-notes-for-0-54-0.html#uninstalled-
>>>> pkgconfig-files]
>>>> I think that feature may be of interest or of use for the future.
>>>
>>> Currently 16.04 is being used . I tried to moving to 18.04 as well.
>>> But seems like few other test cases which require kernel 3.16 seem to
>>> fail. Probably Ilya/David/Ian could comment if those test cases can be
>> removed and we could move to 18.04 travis?
>>
>> The incompatibility issue was fixed in v0.53.1 release and should work fine
>> with 0.54 on ubuntu 16.04 without upgrading the base image to 18.04.
>> So, it makes sense to standardize on 0.54 for now.  Could you, please, try it?
> 
> Thanks, Ilya, for pointing out.
> Although I see that this works on x86 , it fails for aarch64 :(
> for some reason meson doesnt seem to build properly on aarch64:
> https://travis-ci.org/github/Sunil-Pai-G/ovs/builds/704635873
> Please let me know if I might have missed something.

There is an issue with permissions in aarch64 images on travis:
https://travis-ci.community/t/permission-issue-while-building-wheels-for-various-python-packages/7822

You could try applying following workaround before running pip:
  sudo chown -Rv $USER:$GROUP ~/.cache/pip/wheels

Best regards, Ilya Maximets.
Pai G, Sunil July 4, 2020, 1:30 p.m. UTC | #12
> -----Original Message-----
> From: Ilya Maximets <i.maximets@ovn.org>
> Sent: Friday, July 3, 2020 11:12 PM
> To: Pai G, Sunil <sunil.pai.g@intel.com>; Ilya Maximets
> <i.maximets@ovn.org>; Richardson, Bruce <bruce.richardson@intel.com>;
> dev@openvswitch.org
> Cc: Stokes, Ian <ian.stokes@intel.com>; david.marchand@redhat.com;
> Tummala, Sivaprasad <sivaprasad.tummala@intel.com>
> Subject: Re: [PATCH RFC dpdk-latest] build: Add support for DPDK meson
> build.
> 
> On 7/3/20 3:57 PM, Pai G, Sunil wrote:
> >> -----Original Message-----
> >> From: Ilya Maximets <i.maximets@ovn.org>
> >> Sent: Thursday, July 2, 2020 9:54 PM
> >> To: Pai G, Sunil <sunil.pai.g@intel.com>; Richardson, Bruce
> >> <bruce.richardson@intel.com>; Ilya Maximets <i.maximets@ovn.org>;
> >> dev@openvswitch.org
> >> Cc: Stokes, Ian <ian.stokes@intel.com>; david.marchand@redhat.com;
> >> Tummala, Sivaprasad <sivaprasad.tummala@intel.com>
> >> Subject: Re: [PATCH RFC dpdk-latest] build: Add support for DPDK
> >> meson build.
> >>
> >> On 7/2/20 6:10 PM, Pai G, Sunil wrote:
> >>>> -----Original Message-----
> >>>> From: Richardson, Bruce <bruce.richardson@intel.com>
> >>>> Sent: Thursday, July 2, 2020 9:32 PM
> >>>> To: Pai G, Sunil <sunil.pai.g@intel.com>; Ilya Maximets
> >>>> <i.maximets@ovn.org>; dev@openvswitch.org
> >>>> Cc: Stokes, Ian <ian.stokes@intel.com>; david.marchand@redhat.com;
> >>>> Tummala, Sivaprasad <sivaprasad.tummala@intel.com>
> >>>> Subject: RE: [PATCH RFC dpdk-latest] build: Add support for DPDK
> >>>> meson build.
> >>>>
> >>>>
> >>>>
> >>>>> -----Original Message-----
> >>>>> From: Pai G, Sunil <sunil.pai.g@intel.com>
> >>>>> Sent: Thursday, July 2, 2020 4:25 PM
> >>>>> To: Ilya Maximets <i.maximets@ovn.org>; dev@openvswitch.org
> >>>>> Cc: Stokes, Ian <ian.stokes@intel.com>;
> david.marchand@redhat.com;
> >>>>> Richardson, Bruce <bruce.richardson@intel.com>; Tummala,
> >>>>> Sivaprasad <sivaprasad.tummala@intel.com>
> >>>>> Subject: RE: [PATCH RFC dpdk-latest] build: Add support for DPDK
> >>>>> meson build.
> >>>>>
> >>>>>> -----Original Message-----
> >>>>>> From: Ilya Maximets <i.maximets@ovn.org>
> >>>>>> Sent: Thursday, July 2, 2020 7:26 PM
> >>>>>> To: Pai G, Sunil <sunil.pai.g@intel.com>; dev@openvswitch.org
> >>>>>> Cc: Stokes, Ian <ian.stokes@intel.com>; i.maximets@ovn.org;
> >>>>>> david.marchand@redhat.com; Richardson, Bruce
> >>>>>> <bruce.richardson@intel.com>; Tummala, Sivaprasad
> >>>>>> <sivaprasad.tummala@intel.com>; i.maximets@ovn.org
> >>>>>> Subject: Re: [PATCH RFC dpdk-latest] build: Add support for DPDK
> >>>>>> meson
> >>>>> build.
> >>>>>>
> >>>>>> On 7/2/20 3:13 PM, Sunil Pai G wrote:
> >>>>>>> Make based build is deprecated in DPDK. Meson based build to be
> >>>>>>> used for future DPDK releases.
> >>>>>>>
> >>>>>>> This updates travis, configure script and documentation for
> >>>>>>> using DPDK Meson with OVS.
> >>>>>>>
> >>>>>>> Signed-off-by: Sunil Pai G <sunil.pai.g@intel.com>
> >>>>>>
> >>>>>> Thanks for working on this!
> >>>>>> Not a full review, just a few quick bits.
> >>>>>>
> >>>>>> At first, why dpdk-latest?  Is there issue with meson build on 19.11?
> >>>>>
> >>>>> The linker always picked the shared DPDK libraries over static
> >>>>> when built with Meson in DPDK-19.11. -Bstatic flag would get
> >>>>> jumbled by libtool causing this.
> >>>>> Thanks to Bruce, there was recently merged series which fixed a
> >>>>> bunch of issues along with this :
> >>>>> https://patches.dpdk.org/project/dpdk/list/?series=10690
> >>>>> It is requested for a back port of this series to DPDK-19.11.
> >>>>>
> >>>>>>
> >>>>>> Few more comments inline.
> >>>>>>
> >>>>>> Best regards, Ilya Maximets.
> >>>>>>
> >>>>>>> ---
> >>>>>>>  .travis.yml                           |  3 ++
> >>>>>>>  .travis/linux-build.sh                | 37 +++++++++-------
> >>>>>>>  .travis/linux-prepare.sh              |  1 +
> >>>>>>>  Documentation/intro/install/afxdp.rst |  2 +-
> >>>>>>> Documentation/intro/install/dpdk.rst  | 56
> ++++++++++++++++++++-
> >> --
> >>>> -
> >>>>>>>  Makefile.am                           |  3 +-
> >>>>>>>  acinclude.m4                          | 42 ++++++++++++------
> >>>>>>>  parse_pkg_cfg.py                      | 62
> >>>>> +++++++++++++++++++++++++++
> >>>>>>>  8 files changed, 167 insertions(+), 39 deletions(-)  create
> >>>>>>> mode
> >>>>>>> 100644 parse_pkg_cfg.py
> >>>>>>>
> >>>>>>> diff --git a/.travis.yml b/.travis.yml index
> >>>>>>> 97249c1ce..46d7ad9bb
> >>>>>>> 100644
> >>>>>>> --- a/.travis.yml
> >>>>>>> +++ b/.travis.yml
> >>>>>>> @@ -27,6 +27,9 @@ addons:
> >>>>>>>        - selinux-policy-dev
> >>>>>>>        - libunbound-dev
> >>>>>>>        - libunwind-dev
> >>>>>>> +      - python3-setuptools
> >>>>>>> +      - python3-wheel
> >>>>>>> +      - ninja-build
> >>>>>>>
> >>>>>>>  before_install: ./.travis/${TRAVIS_OS_NAME}-prepare.sh
> >>>>>>>
> >>>>>>> diff --git a/.travis/linux-build.sh b/.travis/linux-build.sh
> >>>>>>> index 33b359a61..7fa7e738c 100755
> >>>>>>> --- a/.travis/linux-build.sh
> >>>>>>> +++ b/.travis/linux-build.sh
> >>>>>>> @@ -85,17 +85,21 @@ function install_dpdk()  {
> >>>>>>>      local DPDK_VER=$1
> >>>>>>>      local VERSION_FILE="dpdk-dir/travis-dpdk-cache-version"
> >>>>>>> +    local DPDK_OPTS=""
> >>>>>>>
> >>>>>>> -    if [ -z "$TRAVIS_ARCH" ] ||
> >>>>>>> -       [ "$TRAVIS_ARCH" == "amd64" ]; then
> >>>>>>> -        TARGET="x86_64-native-linuxapp-gcc"
> >>>>>>> -    elif [ "$TRAVIS_ARCH" == "aarch64" ]; then
> >>>>>>> -        TARGET="arm64-armv8a-linuxapp-gcc"
> >>>>>>> -    else
> >>>>>>> +    if [ "$TRAVIS_ARCH" == "aarch64" ]; then
> >>>>>>> +        DPDK_OPTS="$DPDK_OPTS --cross-file
> >>>>>> config/arm/arm64_armv8_linux_gcc"
> >>>>>>
> > <snipped>
> >>>> Does your travis instance use 16.04 or 18.04? If possible can you
> >>>> standardize on a new specific version to get some additional
> >>>> benefits. For example, with meson
> >>>> 0.54 there is support for "uninstalled" pkg-config files, which you
> >>>> can use for linking against a DPDK instance which has not been
> >>>> installed on
> >> the system.
> >>>> [https://mesonbuild.com/Release-notes-for-0-54-0.html#uninstalled-
> >>>> pkgconfig-files]
> >>>> I think that feature may be of interest or of use for the future.
> >>>
> >>> Currently 16.04 is being used . I tried to moving to 18.04 as well.
> >>> But seems like few other test cases which require kernel 3.16 seem
> >>> to fail. Probably Ilya/David/Ian could comment if those test cases
> >>> can be
> >> removed and we could move to 18.04 travis?
> >>
> >> The incompatibility issue was fixed in v0.53.1 release and should
> >> work fine with 0.54 on ubuntu 16.04 without upgrading the base image to
> 18.04.
> >> So, it makes sense to standardize on 0.54 for now.  Could you, please, try
> it?
> >
> > Thanks, Ilya, for pointing out.
> > Although I see that this works on x86 , it fails for aarch64 :( for
> > some reason meson doesnt seem to build properly on aarch64:
> > https://travis-ci.org/github/Sunil-Pai-G/ovs/builds/704635873
> > Please let me know if I might have missed something.
> 
> There is an issue with permissions in aarch64 images on travis:
> https://travis-ci.community/t/permission-issue-while-building-wheels-for-
> various-python-packages/7822
> 
> You could try applying following workaround before running pip:
>   sudo chown -Rv $USER:$GROUP ~/.cache/pip/wheels
> 
> Best regards, Ilya Maximets.

I gave it a try Ilya , still no luck :(
Please see : https://travis-ci.org/github/Sunil-Pai-G/ovs/jobs/704908933
I tried the solution advised here as well: https://github.com/pydata/bottleneck/issues/281 
which seemed to be quite like what I am facing , but still end up getting the same error:
"Building wheel for ninja (PEP 517): finished with status 'error'"  :(
Ilya Maximets July 4, 2020, 2:39 p.m. UTC | #13
On 7/4/20 3:30 PM, Pai G, Sunil wrote:
>> -----Original Message-----
>> From: Ilya Maximets <i.maximets@ovn.org>
>> Sent: Friday, July 3, 2020 11:12 PM
>> To: Pai G, Sunil <sunil.pai.g@intel.com>; Ilya Maximets
>> <i.maximets@ovn.org>; Richardson, Bruce <bruce.richardson@intel.com>;
>> dev@openvswitch.org
>> Cc: Stokes, Ian <ian.stokes@intel.com>; david.marchand@redhat.com;
>> Tummala, Sivaprasad <sivaprasad.tummala@intel.com>
>> Subject: Re: [PATCH RFC dpdk-latest] build: Add support for DPDK meson
>> build.
>>
>> On 7/3/20 3:57 PM, Pai G, Sunil wrote:
>>>> -----Original Message-----
>>>> From: Ilya Maximets <i.maximets@ovn.org>
>>>> Sent: Thursday, July 2, 2020 9:54 PM
>>>> To: Pai G, Sunil <sunil.pai.g@intel.com>; Richardson, Bruce
>>>> <bruce.richardson@intel.com>; Ilya Maximets <i.maximets@ovn.org>;
>>>> dev@openvswitch.org
>>>> Cc: Stokes, Ian <ian.stokes@intel.com>; david.marchand@redhat.com;
>>>> Tummala, Sivaprasad <sivaprasad.tummala@intel.com>
>>>> Subject: Re: [PATCH RFC dpdk-latest] build: Add support for DPDK
>>>> meson build.
>>>>
>>>> On 7/2/20 6:10 PM, Pai G, Sunil wrote:
>>>>>> -----Original Message-----
>>>>>> From: Richardson, Bruce <bruce.richardson@intel.com>
>>>>>> Sent: Thursday, July 2, 2020 9:32 PM
>>>>>> To: Pai G, Sunil <sunil.pai.g@intel.com>; Ilya Maximets
>>>>>> <i.maximets@ovn.org>; dev@openvswitch.org
>>>>>> Cc: Stokes, Ian <ian.stokes@intel.com>; david.marchand@redhat.com;
>>>>>> Tummala, Sivaprasad <sivaprasad.tummala@intel.com>
>>>>>> Subject: RE: [PATCH RFC dpdk-latest] build: Add support for DPDK
>>>>>> meson build.
>>>>>>
>>>>>>
>>>>>>
>>>>>>> -----Original Message-----
>>>>>>> From: Pai G, Sunil <sunil.pai.g@intel.com>
>>>>>>> Sent: Thursday, July 2, 2020 4:25 PM
>>>>>>> To: Ilya Maximets <i.maximets@ovn.org>; dev@openvswitch.org
>>>>>>> Cc: Stokes, Ian <ian.stokes@intel.com>;
>> david.marchand@redhat.com;
>>>>>>> Richardson, Bruce <bruce.richardson@intel.com>; Tummala,
>>>>>>> Sivaprasad <sivaprasad.tummala@intel.com>
>>>>>>> Subject: RE: [PATCH RFC dpdk-latest] build: Add support for DPDK
>>>>>>> meson build.
>>>>>>>
>>>>>>>> -----Original Message-----
>>>>>>>> From: Ilya Maximets <i.maximets@ovn.org>
>>>>>>>> Sent: Thursday, July 2, 2020 7:26 PM
>>>>>>>> To: Pai G, Sunil <sunil.pai.g@intel.com>; dev@openvswitch.org
>>>>>>>> Cc: Stokes, Ian <ian.stokes@intel.com>; i.maximets@ovn.org;
>>>>>>>> david.marchand@redhat.com; Richardson, Bruce
>>>>>>>> <bruce.richardson@intel.com>; Tummala, Sivaprasad
>>>>>>>> <sivaprasad.tummala@intel.com>; i.maximets@ovn.org
>>>>>>>> Subject: Re: [PATCH RFC dpdk-latest] build: Add support for DPDK
>>>>>>>> meson
>>>>>>> build.
>>>>>>>>
>>>>>>>> On 7/2/20 3:13 PM, Sunil Pai G wrote:
>>>>>>>>> Make based build is deprecated in DPDK. Meson based build to be
>>>>>>>>> used for future DPDK releases.
>>>>>>>>>
>>>>>>>>> This updates travis, configure script and documentation for
>>>>>>>>> using DPDK Meson with OVS.
>>>>>>>>>
>>>>>>>>> Signed-off-by: Sunil Pai G <sunil.pai.g@intel.com>
>>>>>>>>
>>>>>>>> Thanks for working on this!
>>>>>>>> Not a full review, just a few quick bits.
>>>>>>>>
>>>>>>>> At first, why dpdk-latest?  Is there issue with meson build on 19.11?
>>>>>>>
>>>>>>> The linker always picked the shared DPDK libraries over static
>>>>>>> when built with Meson in DPDK-19.11. -Bstatic flag would get
>>>>>>> jumbled by libtool causing this.
>>>>>>> Thanks to Bruce, there was recently merged series which fixed a
>>>>>>> bunch of issues along with this :
>>>>>>> https://patches.dpdk.org/project/dpdk/list/?series=10690
>>>>>>> It is requested for a back port of this series to DPDK-19.11.
>>>>>>>
>>>>>>>>
>>>>>>>> Few more comments inline.
>>>>>>>>
>>>>>>>> Best regards, Ilya Maximets.
>>>>>>>>
>>>>>>>>> ---
>>>>>>>>>  .travis.yml                           |  3 ++
>>>>>>>>>  .travis/linux-build.sh                | 37 +++++++++-------
>>>>>>>>>  .travis/linux-prepare.sh              |  1 +
>>>>>>>>>  Documentation/intro/install/afxdp.rst |  2 +-
>>>>>>>>> Documentation/intro/install/dpdk.rst  | 56
>> ++++++++++++++++++++-
>>>> --
>>>>>> -
>>>>>>>>>  Makefile.am                           |  3 +-
>>>>>>>>>  acinclude.m4                          | 42 ++++++++++++------
>>>>>>>>>  parse_pkg_cfg.py                      | 62
>>>>>>> +++++++++++++++++++++++++++
>>>>>>>>>  8 files changed, 167 insertions(+), 39 deletions(-)  create
>>>>>>>>> mode
>>>>>>>>> 100644 parse_pkg_cfg.py
>>>>>>>>>
>>>>>>>>> diff --git a/.travis.yml b/.travis.yml index
>>>>>>>>> 97249c1ce..46d7ad9bb
>>>>>>>>> 100644
>>>>>>>>> --- a/.travis.yml
>>>>>>>>> +++ b/.travis.yml
>>>>>>>>> @@ -27,6 +27,9 @@ addons:
>>>>>>>>>        - selinux-policy-dev
>>>>>>>>>        - libunbound-dev
>>>>>>>>>        - libunwind-dev
>>>>>>>>> +      - python3-setuptools
>>>>>>>>> +      - python3-wheel
>>>>>>>>> +      - ninja-build
>>>>>>>>>
>>>>>>>>>  before_install: ./.travis/${TRAVIS_OS_NAME}-prepare.sh
>>>>>>>>>
>>>>>>>>> diff --git a/.travis/linux-build.sh b/.travis/linux-build.sh
>>>>>>>>> index 33b359a61..7fa7e738c 100755
>>>>>>>>> --- a/.travis/linux-build.sh
>>>>>>>>> +++ b/.travis/linux-build.sh
>>>>>>>>> @@ -85,17 +85,21 @@ function install_dpdk()  {
>>>>>>>>>      local DPDK_VER=$1
>>>>>>>>>      local VERSION_FILE="dpdk-dir/travis-dpdk-cache-version"
>>>>>>>>> +    local DPDK_OPTS=""
>>>>>>>>>
>>>>>>>>> -    if [ -z "$TRAVIS_ARCH" ] ||
>>>>>>>>> -       [ "$TRAVIS_ARCH" == "amd64" ]; then
>>>>>>>>> -        TARGET="x86_64-native-linuxapp-gcc"
>>>>>>>>> -    elif [ "$TRAVIS_ARCH" == "aarch64" ]; then
>>>>>>>>> -        TARGET="arm64-armv8a-linuxapp-gcc"
>>>>>>>>> -    else
>>>>>>>>> +    if [ "$TRAVIS_ARCH" == "aarch64" ]; then
>>>>>>>>> +        DPDK_OPTS="$DPDK_OPTS --cross-file
>>>>>>>> config/arm/arm64_armv8_linux_gcc"
>>>>>>>>
>>> <snipped>
>>>>>> Does your travis instance use 16.04 or 18.04? If possible can you
>>>>>> standardize on a new specific version to get some additional
>>>>>> benefits. For example, with meson
>>>>>> 0.54 there is support for "uninstalled" pkg-config files, which you
>>>>>> can use for linking against a DPDK instance which has not been
>>>>>> installed on
>>>> the system.
>>>>>> [https://mesonbuild.com/Release-notes-for-0-54-0.html#uninstalled-
>>>>>> pkgconfig-files]
>>>>>> I think that feature may be of interest or of use for the future.
>>>>>
>>>>> Currently 16.04 is being used . I tried to moving to 18.04 as well.
>>>>> But seems like few other test cases which require kernel 3.16 seem
>>>>> to fail. Probably Ilya/David/Ian could comment if those test cases
>>>>> can be
>>>> removed and we could move to 18.04 travis?
>>>>
>>>> The incompatibility issue was fixed in v0.53.1 release and should
>>>> work fine with 0.54 on ubuntu 16.04 without upgrading the base image to
>> 18.04.
>>>> So, it makes sense to standardize on 0.54 for now.  Could you, please, try
>> it?
>>>
>>> Thanks, Ilya, for pointing out.
>>> Although I see that this works on x86 , it fails for aarch64 :( for
>>> some reason meson doesnt seem to build properly on aarch64:
>>> https://travis-ci.org/github/Sunil-Pai-G/ovs/builds/704635873
>>> Please let me know if I might have missed something.
>>
>> There is an issue with permissions in aarch64 images on travis:
>> https://travis-ci.community/t/permission-issue-while-building-wheels-for-
>> various-python-packages/7822
>>
>> You could try applying following workaround before running pip:
>>   sudo chown -Rv $USER:$GROUP ~/.cache/pip/wheels
>>
>> Best regards, Ilya Maximets.
> 
> I gave it a try Ilya , still no luck :(
> Please see : https://travis-ci.org/github/Sunil-Pai-G/ovs/jobs/704908933
> I tried the solution advised here as well: https://github.com/pydata/bottleneck/issues/281 
> which seemed to be quite like what I am facing , but still end up getting the same error:
> "Building wheel for ninja (PEP 517): finished with status 'error'"  :(
> 

According to the log, meson was installed successfully.
What failed is the attempt to install ninja by pip.  But why you're
trying to do that?  Why not installing ninja-build by apt as it done
in this patch that you sent to mail list?
Ilya Maximets July 4, 2020, 2:53 p.m. UTC | #14
On 7/3/20 3:58 PM, Pai G, Sunil wrote:
>> -----Original Message-----
>> From: Ilya Maximets <i.maximets@ovn.org>
>> Sent: Thursday, July 2, 2020 10:50 PM
>> To: Pai G, Sunil <sunil.pai.g@intel.com>; Ilya Maximets
>> <i.maximets@ovn.org>; dev@openvswitch.org
>> Cc: Stokes, Ian <ian.stokes@intel.com>; david.marchand@redhat.com;
>> Richardson, Bruce <bruce.richardson@intel.com>; Tummala, Sivaprasad
>> <sivaprasad.tummala@intel.com>
>> Subject: Re: [PATCH RFC dpdk-latest] build: Add support for DPDK meson
>> build.
>>
>> On 7/2/20 5:25 PM, Pai G, Sunil wrote:
>>>>
>>>>> +
>>>>>      if [ "${DPDK_VER##refs/*/}" != "${DPDK_VER}" ]; then
>>>>>          # Avoid using cache for git tree build.
>>>>>          rm -rf dpdk-dir
>>>>> @@ -108,7 +112,8 @@ function install_dpdk()
>>>>>          if [ -f "${VERSION_FILE}" ]; then
>>>>>              VER=$(cat ${VERSION_FILE})
>>>>>              if [ "${VER}" = "${DPDK_VER}" ]; then
>>>>> -                EXTRA_OPTS="${EXTRA_OPTS} --with-dpdk=$(pwd)/dpdk-
>> dir/build"
>>>>> +                sudo ninja -C $(pwd)/dpdk-dir/build install
>>>>> +                sudo ldconfig
>>>>
>>>> I think that installing right here inside the cached folder and just
>>>> adjusting environment variables should be a bit faster than re-installing
>> DPDK every time.
>>>>
>>>> This script also will be a good example for people like me, who
>>>> really don't want to install development versions of DPDK globally on
>>>> a work laptop while testing OVS builds.
>>>
>>> Yes , Thanks for the suggestion. Although ,using an install to a
>>> directory with a prefix would require this patch from Bruce:
>>> https://patches.dpdk.org/patch/72271/
>>>  (which is not merged yet as of this writing) .without this , OVS
>>> would fail to run searching for few shared DPDK libraries even when built
>> with static libraries.
>>
>> But, IIUC, we could just add a path to ld.so.conf to avoid that.
>> Will it work?  You're updating ldconfig here anyway.
> 
> Yes , this will probably work . exporting LD_LIBRARY_PATH will also help .
> But I thought it makes sense only when OVS consumes DPDK shared libs.
> Bruce also acknowledged this as a bug and gracefully gave a fix as well.
> So, I thought it's better to install it system wide until the patch is merged in DPDK. 
> But I am quite open to take the other approach as well and export the LD_LIBRARY_PATH :)
> Let me know your thoughts.
> 

Exporting one extra variable doesn't make any harm, but allows to save
a bit of time not installing DPDK every time.  So, I'd vote to do that.
Pai G, Sunil July 4, 2020, 3:22 p.m. UTC | #15
> -----Original Message-----
> From: Ilya Maximets <i.maximets@ovn.org>
> Sent: Saturday, July 4, 2020 8:10 PM
> To: Pai G, Sunil <sunil.pai.g@intel.com>; Ilya Maximets
> <i.maximets@ovn.org>; Richardson, Bruce <bruce.richardson@intel.com>;
> dev@openvswitch.org
> Cc: Stokes, Ian <ian.stokes@intel.com>; david.marchand@redhat.com;
> Tummala, Sivaprasad <sivaprasad.tummala@intel.com>
> Subject: Re: [PATCH RFC dpdk-latest] build: Add support for DPDK meson
> build.
> 
> On 7/4/20 3:30 PM, Pai G, Sunil wrote:
> >> -----Original Message-----
> >> From: Ilya Maximets <i.maximets@ovn.org>
> >> Sent: Friday, July 3, 2020 11:12 PM
> >> To: Pai G, Sunil <sunil.pai.g@intel.com>; Ilya Maximets
> >> <i.maximets@ovn.org>; Richardson, Bruce
> <bruce.richardson@intel.com>;
> >> dev@openvswitch.org
> >> Cc: Stokes, Ian <ian.stokes@intel.com>; david.marchand@redhat.com;
> >> Tummala, Sivaprasad <sivaprasad.tummala@intel.com>
> >> Subject: Re: [PATCH RFC dpdk-latest] build: Add support for DPDK
> >> meson build.
> >>
> >> On 7/3/20 3:57 PM, Pai G, Sunil wrote:
> >>>> -----Original Message-----
> >>>> From: Ilya Maximets <i.maximets@ovn.org>
> >>>> Sent: Thursday, July 2, 2020 9:54 PM
> >>>> To: Pai G, Sunil <sunil.pai.g@intel.com>; Richardson, Bruce
> >>>> <bruce.richardson@intel.com>; Ilya Maximets <i.maximets@ovn.org>;
> >>>> dev@openvswitch.org
> >>>> Cc: Stokes, Ian <ian.stokes@intel.com>; david.marchand@redhat.com;
> >>>> Tummala, Sivaprasad <sivaprasad.tummala@intel.com>
> >>>> Subject: Re: [PATCH RFC dpdk-latest] build: Add support for DPDK
> >>>> meson build.
> >>>>
> >>>> On 7/2/20 6:10 PM, Pai G, Sunil wrote:
> >>>>>> -----Original Message-----
> >>>>>> From: Richardson, Bruce <bruce.richardson@intel.com>
> >>>>>> Sent: Thursday, July 2, 2020 9:32 PM
> >>>>>> To: Pai G, Sunil <sunil.pai.g@intel.com>; Ilya Maximets
> >>>>>> <i.maximets@ovn.org>; dev@openvswitch.org
> >>>>>> Cc: Stokes, Ian <ian.stokes@intel.com>;
> >>>>>> david.marchand@redhat.com; Tummala, Sivaprasad
> >>>>>> <sivaprasad.tummala@intel.com>
> >>>>>> Subject: RE: [PATCH RFC dpdk-latest] build: Add support for DPDK
> >>>>>> meson build.
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>> -----Original Message-----
> >>>>>>> From: Pai G, Sunil <sunil.pai.g@intel.com>
> >>>>>>> Sent: Thursday, July 2, 2020 4:25 PM
> >>>>>>> To: Ilya Maximets <i.maximets@ovn.org>; dev@openvswitch.org
> >>>>>>> Cc: Stokes, Ian <ian.stokes@intel.com>;
> >> david.marchand@redhat.com;
> >>>>>>> Richardson, Bruce <bruce.richardson@intel.com>; Tummala,
> >>>>>>> Sivaprasad <sivaprasad.tummala@intel.com>
> >>>>>>> Subject: RE: [PATCH RFC dpdk-latest] build: Add support for DPDK
> >>>>>>> meson build.
> >>>>>>>
> >>>>>>>> -----Original Message-----
> >>>>>>>> From: Ilya Maximets <i.maximets@ovn.org>
> >>>>>>>> Sent: Thursday, July 2, 2020 7:26 PM
> >>>>>>>> To: Pai G, Sunil <sunil.pai.g@intel.com>; dev@openvswitch.org
> >>>>>>>> Cc: Stokes, Ian <ian.stokes@intel.com>; i.maximets@ovn.org;
> >>>>>>>> david.marchand@redhat.com; Richardson, Bruce
> >>>>>>>> <bruce.richardson@intel.com>; Tummala, Sivaprasad
> >>>>>>>> <sivaprasad.tummala@intel.com>; i.maximets@ovn.org
> >>>>>>>> Subject: Re: [PATCH RFC dpdk-latest] build: Add support for
> >>>>>>>> DPDK meson
> >>>>>>> build.
> >>>>>>>>
> >>>>>>>> On 7/2/20 3:13 PM, Sunil Pai G wrote:
> >>>>>>>>> Make based build is deprecated in DPDK. Meson based build to
> >>>>>>>>> be used for future DPDK releases.
> >>>>>>>>>
> >>>>>>>>> This updates travis, configure script and documentation for
> >>>>>>>>> using DPDK Meson with OVS.
> >>>>>>>>>
> >>>>>>>>> Signed-off-by: Sunil Pai G <sunil.pai.g@intel.com>
> >>>>>>>>
> >>>>>>>> Thanks for working on this!
> >>>>>>>> Not a full review, just a few quick bits.
> >>>>>>>>
> >>>>>>>> At first, why dpdk-latest?  Is there issue with meson build on
> 19.11?
> >>>>>>>
> >>>>>>> The linker always picked the shared DPDK libraries over static
> >>>>>>> when built with Meson in DPDK-19.11. -Bstatic flag would get
> >>>>>>> jumbled by libtool causing this.
> >>>>>>> Thanks to Bruce, there was recently merged series which fixed a
> >>>>>>> bunch of issues along with this :
> >>>>>>> https://patches.dpdk.org/project/dpdk/list/?series=10690
> >>>>>>> It is requested for a back port of this series to DPDK-19.11.
> >>>>>>>
> >>>>>>>>
> >>>>>>>> Few more comments inline.
> >>>>>>>>
> >>>>>>>> Best regards, Ilya Maximets.
> >>>>>>>>
> >>>>>>>>> ---
> >>>>>>>>>  .travis.yml                           |  3 ++
> >>>>>>>>>  .travis/linux-build.sh                | 37 +++++++++-------
> >>>>>>>>>  .travis/linux-prepare.sh              |  1 +
> >>>>>>>>>  Documentation/intro/install/afxdp.rst |  2 +-
> >>>>>>>>> Documentation/intro/install/dpdk.rst  | 56
> >> ++++++++++++++++++++-
> >>>> --
> >>>>>> -
> >>>>>>>>>  Makefile.am                           |  3 +-
> >>>>>>>>>  acinclude.m4                          | 42 ++++++++++++------
> >>>>>>>>>  parse_pkg_cfg.py                      | 62
> >>>>>>> +++++++++++++++++++++++++++
> >>>>>>>>>  8 files changed, 167 insertions(+), 39 deletions(-)  create
> >>>>>>>>> mode
> >>>>>>>>> 100644 parse_pkg_cfg.py
> >>>>>>>>>
> >>>>>>>>> diff --git a/.travis.yml b/.travis.yml index
> >>>>>>>>> 97249c1ce..46d7ad9bb
> >>>>>>>>> 100644
> >>>>>>>>> --- a/.travis.yml
> >>>>>>>>> +++ b/.travis.yml
> >>>>>>>>> @@ -27,6 +27,9 @@ addons:
> >>>>>>>>>        - selinux-policy-dev
> >>>>>>>>>        - libunbound-dev
> >>>>>>>>>        - libunwind-dev
> >>>>>>>>> +      - python3-setuptools
> >>>>>>>>> +      - python3-wheel
> >>>>>>>>> +      - ninja-build
> >>>>>>>>>
> >>>>>>>>>  before_install: ./.travis/${TRAVIS_OS_NAME}-prepare.sh
> >>>>>>>>>
> >>>>>>>>> diff --git a/.travis/linux-build.sh b/.travis/linux-build.sh
> >>>>>>>>> index 33b359a61..7fa7e738c 100755
> >>>>>>>>> --- a/.travis/linux-build.sh
> >>>>>>>>> +++ b/.travis/linux-build.sh
> >>>>>>>>> @@ -85,17 +85,21 @@ function install_dpdk()  {
> >>>>>>>>>      local DPDK_VER=$1
> >>>>>>>>>      local VERSION_FILE="dpdk-dir/travis-dpdk-cache-version"
> >>>>>>>>> +    local DPDK_OPTS=""
> >>>>>>>>>
> >>>>>>>>> -    if [ -z "$TRAVIS_ARCH" ] ||
> >>>>>>>>> -       [ "$TRAVIS_ARCH" == "amd64" ]; then
> >>>>>>>>> -        TARGET="x86_64-native-linuxapp-gcc"
> >>>>>>>>> -    elif [ "$TRAVIS_ARCH" == "aarch64" ]; then
> >>>>>>>>> -        TARGET="arm64-armv8a-linuxapp-gcc"
> >>>>>>>>> -    else
> >>>>>>>>> +    if [ "$TRAVIS_ARCH" == "aarch64" ]; then
> >>>>>>>>> +        DPDK_OPTS="$DPDK_OPTS --cross-file
> >>>>>>>> config/arm/arm64_armv8_linux_gcc"
> >>>>>>>>
> >>> <snipped>
> >>>>>> Does your travis instance use 16.04 or 18.04? If possible can you
> >>>>>> standardize on a new specific version to get some additional
> >>>>>> benefits. For example, with meson
> >>>>>> 0.54 there is support for "uninstalled" pkg-config files, which
> >>>>>> you can use for linking against a DPDK instance which has not
> >>>>>> been installed on
> >>>> the system.
> >>>>>> [https://mesonbuild.com/Release-notes-for-0-54-
> 0.html#uninstalled
> >>>>>> -
> >>>>>> pkgconfig-files]
> >>>>>> I think that feature may be of interest or of use for the future.
> >>>>>
> >>>>> Currently 16.04 is being used . I tried to moving to 18.04 as well.
> >>>>> But seems like few other test cases which require kernel 3.16 seem
> >>>>> to fail. Probably Ilya/David/Ian could comment if those test cases
> >>>>> can be
> >>>> removed and we could move to 18.04 travis?
> >>>>
> >>>> The incompatibility issue was fixed in v0.53.1 release and should
> >>>> work fine with 0.54 on ubuntu 16.04 without upgrading the base
> >>>> image to
> >> 18.04.
> >>>> So, it makes sense to standardize on 0.54 for now.  Could you,
> >>>> please, try
> >> it?
> >>>
> >>> Thanks, Ilya, for pointing out.
> >>> Although I see that this works on x86 , it fails for aarch64 :( for
> >>> some reason meson doesnt seem to build properly on aarch64:
> >>> https://travis-ci.org/github/Sunil-Pai-G/ovs/builds/704635873
> >>> Please let me know if I might have missed something.
> >>
> >> There is an issue with permissions in aarch64 images on travis:
> >> https://travis-ci.community/t/permission-issue-while-building-wheels-
> >> for-
> >> various-python-packages/7822
> >>
> >> You could try applying following workaround before running pip:
> >>   sudo chown -Rv $USER:$GROUP ~/.cache/pip/wheels
> >>
> >> Best regards, Ilya Maximets.
> >
> > I gave it a try Ilya , still no luck :( Please see :
> > https://travis-ci.org/github/Sunil-Pai-G/ovs/jobs/704908933
> > I tried the solution advised here as well:
> > https://github.com/pydata/bottleneck/issues/281
> > which seemed to be quite like what I am facing , but still end up getting the
> same error:
> > "Building wheel for ninja (PEP 517): finished with status 'error'"  :(
> >
> 
> According to the log, meson was installed successfully.
> What failed is the attempt to install ninja by pip.  But why you're trying to do
> that?  Why not installing ninja-build by apt as it done in this patch that you
> sent to mail list?

Hi Ilya , 
The minimum ninja version required for meson 0.54 seems to be 1.7.1 which surprisingly isn’t available for aarch64 yet on 16.04:
https://mesonbuild.com/Release-notes-for-0-54-0.html#uninstalled-pkgconfig-files 

aarch64 :
sudo apt-cache madison ninja-build
ninja-build | 1.5.1-0.1ubuntu1 | http://ports.ubuntu.com/ubuntu-ports xenial/universe arm64 Packages

amd64:
sudo apt-cache madison ninja-build
ninja-build | 1.7.1-1~ubuntu16.04.1 | http://us-east-1.ec2.archive.ubuntu.com/ubuntu xenial-backports/universe amd64 Packages
ninja-build | 1.5.1-0.1ubuntu1 | http://us-east-1.ec2.archive.ubuntu.com/ubuntu xenial/universe amd64 Packages
ninja-build | 1.5.1-0.1ubuntu1 | http://us-east-1.ec2.archive.ubuntu.com/ubuntu xenial/universe Sources
ninja-build | 1.7.1-1~ubuntu16.04.1 | http://us-east-1.ec2.archive.ubuntu.com/ubuntu xenial-backports/universe Sources

Hence, I resorted to installing ninja using pip.

An alternative now would be to download and build ninja from source , which I was trying to avoid since that will increase build time.
Let me know your thoughts :)

Thanks and regards
Sunil
Pai G, Sunil July 4, 2020, 3:25 p.m. UTC | #16
> -----Original Message-----
> From: Ilya Maximets <i.maximets@ovn.org>
> Sent: Saturday, July 4, 2020 8:23 PM
> To: Pai G, Sunil <sunil.pai.g@intel.com>; Ilya Maximets
> <i.maximets@ovn.org>; dev@openvswitch.org
> Cc: Stokes, Ian <ian.stokes@intel.com>; david.marchand@redhat.com;
> Richardson, Bruce <bruce.richardson@intel.com>; Tummala, Sivaprasad
> <sivaprasad.tummala@intel.com>
> Subject: Re: [PATCH RFC dpdk-latest] build: Add support for DPDK meson
> build.
> 
> On 7/3/20 3:58 PM, Pai G, Sunil wrote:
> >> -----Original Message-----
> >> From: Ilya Maximets <i.maximets@ovn.org>
> >> Sent: Thursday, July 2, 2020 10:50 PM
> >> To: Pai G, Sunil <sunil.pai.g@intel.com>; Ilya Maximets
> >> <i.maximets@ovn.org>; dev@openvswitch.org
> >> Cc: Stokes, Ian <ian.stokes@intel.com>; david.marchand@redhat.com;
> >> Richardson, Bruce <bruce.richardson@intel.com>; Tummala, Sivaprasad
> >> <sivaprasad.tummala@intel.com>
> >> Subject: Re: [PATCH RFC dpdk-latest] build: Add support for DPDK
> >> meson build.
> >>
> >> On 7/2/20 5:25 PM, Pai G, Sunil wrote:
> >>>>
> >>>>> +
> >>>>>      if [ "${DPDK_VER##refs/*/}" != "${DPDK_VER}" ]; then
> >>>>>          # Avoid using cache for git tree build.
> >>>>>          rm -rf dpdk-dir
> >>>>> @@ -108,7 +112,8 @@ function install_dpdk()
> >>>>>          if [ -f "${VERSION_FILE}" ]; then
> >>>>>              VER=$(cat ${VERSION_FILE})
> >>>>>              if [ "${VER}" = "${DPDK_VER}" ]; then
> >>>>> -                EXTRA_OPTS="${EXTRA_OPTS} --with-dpdk=$(pwd)/dpdk-
> >> dir/build"
> >>>>> +                sudo ninja -C $(pwd)/dpdk-dir/build install
> >>>>> +                sudo ldconfig
> >>>>
> >>>> I think that installing right here inside the cached folder and
> >>>> just adjusting environment variables should be a bit faster than
> >>>> re-installing
> >> DPDK every time.
> >>>>
> >>>> This script also will be a good example for people like me, who
> >>>> really don't want to install development versions of DPDK globally
> >>>> on a work laptop while testing OVS builds.
> >>>
> >>> Yes , Thanks for the suggestion. Although ,using an install to a
> >>> directory with a prefix would require this patch from Bruce:
> >>> https://patches.dpdk.org/patch/72271/
> >>>  (which is not merged yet as of this writing) .without this , OVS
> >>> would fail to run searching for few shared DPDK libraries even when
> >>> built
> >> with static libraries.
> >>
> >> But, IIUC, we could just add a path to ld.so.conf to avoid that.
> >> Will it work?  You're updating ldconfig here anyway.
> >
> > Yes , this will probably work . exporting LD_LIBRARY_PATH will also help .
> > But I thought it makes sense only when OVS consumes DPDK shared libs.
> > Bruce also acknowledged this as a bug and gracefully gave a fix as well.
> > So, I thought it's better to install it system wide until the patch is merged in
> DPDK.
> > But I am quite open to take the other approach as well and export the
> > LD_LIBRARY_PATH :) Let me know your thoughts.
> >
> 
> Exporting one extra variable doesn't make any harm, but allows to save a bit
> of time not installing DPDK every time.  So, I'd vote to do that.

Sure , I am happy to take this approach unless there are any objections from others.
Ian/David/Bruce/Siva let me know your thoughts as well.
diff mbox series

Patch

diff --git a/.travis.yml b/.travis.yml
index 97249c1ce..46d7ad9bb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -27,6 +27,9 @@  addons:
       - selinux-policy-dev
       - libunbound-dev
       - libunwind-dev
+      - python3-setuptools
+      - python3-wheel
+      - ninja-build
 
 before_install: ./.travis/${TRAVIS_OS_NAME}-prepare.sh
 
diff --git a/.travis/linux-build.sh b/.travis/linux-build.sh
index 33b359a61..7fa7e738c 100755
--- a/.travis/linux-build.sh
+++ b/.travis/linux-build.sh
@@ -85,17 +85,21 @@  function install_dpdk()
 {
     local DPDK_VER=$1
     local VERSION_FILE="dpdk-dir/travis-dpdk-cache-version"
+    local DPDK_OPTS=""
 
-    if [ -z "$TRAVIS_ARCH" ] ||
-       [ "$TRAVIS_ARCH" == "amd64" ]; then
-        TARGET="x86_64-native-linuxapp-gcc"
-    elif [ "$TRAVIS_ARCH" == "aarch64" ]; then
-        TARGET="arm64-armv8a-linuxapp-gcc"
-    else
+    if [ "$TRAVIS_ARCH" == "aarch64" ]; then
+        DPDK_OPTS="$DPDK_OPTS --cross-file config/arm/arm64_armv8_linux_gcc"
+    elif [ "$TRAVIS_ARCH" != "amd64" ] && [ -n "$TRAVIS_ARCH" ]; then
         echo "Target is unknown"
         exit 1
     fi
 
+    if [ "$DPDK_SHARED" ]; then
+        EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=shared"
+    else
+        EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=static"
+    fi
+
     if [ "${DPDK_VER##refs/*/}" != "${DPDK_VER}" ]; then
         # Avoid using cache for git tree build.
         rm -rf dpdk-dir
@@ -108,7 +112,8 @@  function install_dpdk()
         if [ -f "${VERSION_FILE}" ]; then
             VER=$(cat ${VERSION_FILE})
             if [ "${VER}" = "${DPDK_VER}" ]; then
-                EXTRA_OPTS="${EXTRA_OPTS} --with-dpdk=$(pwd)/dpdk-dir/build"
+                sudo ninja -C $(pwd)/dpdk-dir/build install
+                sudo ldconfig
                 echo "Found cached DPDK ${VER} build in $(pwd)/dpdk-dir"
                 return
             fi
@@ -122,16 +127,18 @@  function install_dpdk()
         pushd dpdk-dir
     fi
 
-    make config CC=gcc T=$TARGET
+    # Disable building DPDK kernel modules. Not needed for OVS build or tests.
+    DPDK_OPTS="$DPDK_OPTS -Denable_kmods=false"
 
-    if [ "$DPDK_SHARED" ]; then
-        sed -i '/CONFIG_RTE_BUILD_SHARED_LIB=n/s/=n/=y/' build/.config
-        export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/$TARGET/lib
-    fi
+    DPDK_OPTS="$DPDK_OPTS -Dc_args=-fPIC"
+    CC=gcc meson $DPDK_OPTS build
+    ninja -C build
+    sudo ninja -C build install
+
+    # Update the library paths.
+    sudo ldconfig
 
-    make -j4 CC=gcc EXTRA_CFLAGS='-fPIC'
-    EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=$(pwd)/build"
-    echo "Installed DPDK source in $(pwd)"
+    echo "Installed DPDK source"
     popd
     echo "${DPDK_VER}" > ${VERSION_FILE}
 }
diff --git a/.travis/linux-prepare.sh b/.travis/linux-prepare.sh
index 8cbbd5623..682f6234b 100755
--- a/.travis/linux-prepare.sh
+++ b/.travis/linux-prepare.sh
@@ -16,6 +16,7 @@  cd ..
 
 pip3 install --disable-pip-version-check --user flake8 hacking
 pip3 install --user --upgrade docutils
+pip3 install --user  'meson==0.47.1'
 
 if [ "$M32" ]; then
     # Installing 32-bit libraries.
diff --git a/Documentation/intro/install/afxdp.rst b/Documentation/intro/install/afxdp.rst
index 99003e4db..f422685ba 100644
--- a/Documentation/intro/install/afxdp.rst
+++ b/Documentation/intro/install/afxdp.rst
@@ -387,7 +387,7 @@  PVP using vhostuser device
 --------------------------
 First, build OVS with DPDK and AFXDP::
 
-  ./configure  --enable-afxdp --with-dpdk=<dpdk path>
+  ./configure  --enable-afxdp --with-dpdk=shared|static|<dpdk path>
   make -j4 && make install
 
 Create a vhost-user port from OVS::
diff --git a/Documentation/intro/install/dpdk.rst b/Documentation/intro/install/dpdk.rst
index dbf88ec43..46e63ddf9 100644
--- a/Documentation/intro/install/dpdk.rst
+++ b/Documentation/intro/install/dpdk.rst
@@ -76,9 +76,31 @@  Install DPDK
        $ export DPDK_DIR=/usr/src/dpdk-19.11
        $ cd $DPDK_DIR
 
+#. Configure and install DPDK using Meson
+
+   Meson is the preferred tool to build recent DPDK releases
+   as Make support is deprecated and will be removed from DPDK-20.11.
+   OVS supports DPDK Meson builds from 19.11 onwards.
+
+   Build and install the DPDK library::
+
+       $ export DPDK_TARGET=x86_64-native-linuxapp-gcc
+       $ export DPDK_BUILD=$DPDK_DIR/$DPDK_TARGET
+       $ meson $DPDK_TARGET
+       $ ninja -C $DPDK_TARGET
+       $ sudo ninja -C $DPDK_TARGET install
+       $ sudo ldconfig
+
+   Detailed information can be found at `DPDK documentation`_.
+
+   .. _DPDK documentation: https://doc.dpdk.org/guides/linux_gsg/build_dpdk.html
+
 #. (Optional) Configure DPDK as a shared library
 
-   DPDK can be built as either a static library or a shared library.  By
+   When using Meson, DPDK is built both as static and shared library.
+   So no extra configuration is required in this case.
+
+   In case of Make, DPDK can be built as either a static library or a shared library.  By
    default, it is configured for the former. If you wish to use the latter, set
    ``CONFIG_RTE_BUILD_SHARED_LIB=y`` in ``$DPDK_DIR/config/common_base``.
 
@@ -87,7 +109,7 @@  Install DPDK
       Minor performance loss is expected when using OVS with a shared DPDK
       library compared to a static DPDK library.
 
-#. Configure and install DPDK
+#. Configure and install DPDK using Make
 
    Build and install the DPDK library::
 
@@ -97,11 +119,19 @@  Install DPDK
 
 #. (Optional) Export the DPDK shared library location
 
-   If DPDK was built as a shared library, export the path to this library for
+   If DPDK was built as a shared library using Make, export the path to this library for
    use when building OVS::
 
        $ export LD_LIBRARY_PATH=$DPDK_DIR/x86_64-native-linuxapp-gcc/lib
 
+   In case of Meson, exporting the path is not necessary if the dpdk libraries
+   are system installed. For libraries installed using a prefix
+   (assuming $DPDK_INSTALL in the below case), export the path to this library
+   and update the $PKG_CONFIG_PATH for use when building OVS::
+
+      $ export LD_LIBRARY_PATH=$DPDK_INSTALL/lib/x86_64-linux-gnu/:$LD_LIBRARY_PATH
+      $ export PKG_CONFIG_PATH=$DPDK_INSTALL/lib/x86_64-linux-gnu/pkgconfig/:$PKG_CONFIG_PATH
+
 .. _DPDK sources: http://dpdk.org/rel
 
 Install OVS
@@ -121,17 +151,27 @@  has to be configured to build against the DPDK library (``--with-dpdk``).
 
 #. Bootstrap, if required, as described in :ref:`general-bootstrapping`
 
-#. Configure the package using the ``--with-dpdk`` flag::
+#. Configure the package using the ``--with-dpdk`` flag:
+
+   Depending on the tool used to build DPDK and the type of
+   DPDK library to use, one can configure OVS as follows:
+
+   When DPDK is built using Meson, and OVS must consume DPDK shared libraries
+   (also equivalent to leaving --with-dpdk option empty)::
+
+       $ ./configure --with-dpdk=shared
+
+   When DPDK is built using Meson, and OVS must consume DPDK static libraries::
+
+       $ ./configure --with-dpdk=static
+
+   When DPDK is built using Make(for shared or static)::
 
        $ ./configure --with-dpdk=$DPDK_BUILD
 
    where ``DPDK_BUILD`` is the path to the built DPDK library. This can be
    skipped if DPDK library is installed in its default location.
 
-   If no path is provided to ``--with-dpdk``, but a pkg-config configuration
-   for libdpdk is available the include paths will be generated via an
-   equivalent ``pkg-config --cflags libdpdk``.
-
    .. note::
      While ``--with-dpdk`` is required, you can pass any other configuration
      option described in :ref:`general-configuring`.
diff --git a/Makefile.am b/Makefile.am
index b279303d1..13141b946 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -92,7 +92,8 @@  EXTRA_DIST = \
 	$(MAN_ROOTS) \
 	Vagrantfile \
 	Vagrantfile-FreeBSD \
-	.mailmap
+	.mailmap\
+	parse_pkg_cfg.py
 bin_PROGRAMS =
 sbin_PROGRAMS =
 bin_SCRIPTS =
diff --git a/acinclude.m4 b/acinclude.m4
index 3b0eea020..66d1d3583 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -306,8 +306,8 @@  dnl
 dnl Configure DPDK source tree
 AC_DEFUN([OVS_CHECK_DPDK], [
   AC_ARG_WITH([dpdk],
-              [AC_HELP_STRING([--with-dpdk=/path/to/dpdk],
-                              [Specify the DPDK build directory])],
+              [AC_HELP_STRING([--with-dpdk=static|shared|/path/to/dpdk],
+                              [Specify whether to use static or shared DPDK libraries only if built using meson OR the DPDK build directory in case of Make])],
               [have_dpdk=true])
 
   AC_MSG_CHECKING([whether dpdk is enabled])
@@ -317,13 +317,24 @@  AC_DEFUN([OVS_CHECK_DPDK], [
   else
     AC_MSG_RESULT([yes])
     case "$with_dpdk" in
-      yes)
+      "shared" | "static" | "yes")
         DPDK_AUTO_DISCOVER="true"
-        PKG_CHECK_MODULES_STATIC([DPDK], [libdpdk], [
-            DPDK_INCLUDE="$DPDK_CFLAGS"
-            DPDK_LIB="$DPDK_LIBS"], [
-            DPDK_INCLUDE="-I/usr/local/include/dpdk -I/usr/include/dpdk"
-            DPDK_LIB="-ldpdk"])
+        case "$with_dpdk" in
+          "shared" | "yes")
+             PKG_CHECK_MODULES([DPDK], [libdpdk], [
+                 DPDK_INCLUDE="$DPDK_CFLAGS"
+                 DPDK_LIB="$DPDK_LIBS"], [
+                 DPDK_INCLUDE="-I/usr/local/include/dpdk -I/usr/include/dpdk"
+                 DPDK_LIB="-ldpdk"])
+                 ;;
+           "static")
+             PKG_CHECK_MODULES_STATIC([DPDK], [libdpdk], [
+                 DPDK_INCLUDE="$DPDK_CFLAGS"
+                 DPDK_LIB="$DPDK_LIBS"], [
+                 DPDK_INCLUDE="-I/usr/local/include/dpdk -I/usr/include/dpdk"
+                 DPDK_LIB="-ldpdk"])
+                ;;
+        esac
         ;;
       *)
         DPDK_AUTO_DISCOVER="false"
@@ -397,8 +408,9 @@  AC_DEFUN([OVS_CHECK_DPDK], [
       [AC_MSG_RESULT([no])
        if test "$DPDK_AUTO_DISCOVER" = "true"; then
          AC_MSG_ERROR(m4_normalize([
-            Could not find DPDK library in default search path, Use --with-dpdk
-            to specify the DPDK library installed in non-standard location]))
+            Could not find DPDK library in default search path, update
+            PKG_CONFIG_PATH for pkg-config to find the .pc file in
+            non-standard location]))
        else
          AC_MSG_ERROR([Could not find DPDK libraries in $DPDK_LIB_DIR])
        fi
@@ -424,10 +436,12 @@  AC_DEFUN([OVS_CHECK_DPDK], [
     # OTOH newer versions of dpdk pkg-config (generated with Meson)
     # will already have flagged just the right set of libs with
     # --whole-archive - in those cases do not wrap it once more.
-    case "$DPDK_LIB" in
-      *whole-archive*) DPDK_vswitchd_LDFLAGS=$DPDK_LIB;;
-      *) DPDK_vswitchd_LDFLAGS=-Wl,--whole-archive,$DPDK_LIB,--no-whole-archive
-    esac
+    if [[ "$pkg_failed" != "no" ]];then
+      DPDK_vswitchd_LDFLAGS=-Wl,--whole-archive,$DPDK_LIB,--no-whole-archive
+    else
+      DPDK_vswitchd_LDFLAGS=`python3 parse_pkg_cfg.py $DPDK_LIB`
+    fi
+
     AC_SUBST([DPDK_vswitchd_LDFLAGS])
     AC_DEFINE([DPDK_NETDEV], [1], [System uses the DPDK module.])
   fi
diff --git a/parse_pkg_cfg.py b/parse_pkg_cfg.py
new file mode 100644
index 000000000..7f7e1430d
--- /dev/null
+++ b/parse_pkg_cfg.py
@@ -0,0 +1,62 @@ 
+#
+#   BSD LICENSE
+#
+#   Copyright(c) 2020 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#      * Redistributions in binary form must reproduce the above copyright
+#        notice, this list of conditions and the following disclaimer in
+#        the documentation and/or other materials provided with the
+#        distribution.
+#      * Neither the name of Intel Corporation nor the names of its
+#        contributors may be used to endorse or promote products derived
+#        from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+# The purpose of this script is to parse the libraries
+# From pkg-config in case of dpdk meson builds.
+import sys
+def parse_pkg_cfg_libs(arg):
+    final_string = ""
+    first_linker_flag_ind=False
+    for text in arg:
+        text = text.strip()
+        # Ld only understands -lpthread.
+        if text == "-pthread":
+            text = "-lpthread"
+        if '-L/' in text:
+            final_string = final_string + text + " "
+        elif '-Wl,' == text[:4]:
+            # Libtool requires -Wl to only appear once after
+            # Which everything else is treated as linker input.
+            if not first_linker_flag_ind:
+                first_linker_flag_ind = True
+                final_string = final_string + text + ","
+            else:
+                # Omit succeeding -Wl.
+                final_string = final_string + text[4:] + ","
+        else:
+            # Libtool expects comma separated libraries.
+            final_string = final_string + text + ","
+    return final_string
+
+if __name__ == "__main__":
+    print(parse_pkg_cfg_libs(sys.argv[1:])[:-1])