Skip to contentSkip to conversation

config: gather options for dlopen mlx dependency

PATCH Superseded Thomas Monjalon 3 participants 10 messages Jan 9, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 config: gather options for dlopen mlx dependency

Rename options CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS and CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS to a single option CONFIG_RTE_IBVERBS_LINK_DLOPEN.
Rename meson option enable_driver_mlx_glue to ibverbs_link.

There was no good reason for setting a different link option for mlx4 and mlx5. Having a single common option makes it easier to understand and unify make and meson systems.

---
 config/common_base           |  7 +++++--
 doc/guides/nics/mlx4.rst     |  4 ++--
 doc/guides/nics/mlx5.rst     |  4 ++--
 drivers/net/mlx4/Makefile    |  8 ++++----
 drivers/net/mlx4/meson.build |  4 ++--
 drivers/net/mlx4/mlx4.c      |  4 ++--
 drivers/net/mlx5/Makefile    |  8 ++++----
 drivers/net/mlx5/meson.build |  4 ++--
 drivers/net/mlx5/mlx5.c      |  4 ++--
 meson_options.txt            |  4 ++--
 mk/rte.app.mk                | 15 +++++++--------
 11 files changed, 34 insertions(+), 32 deletions(-)
config/common_base +5 -2
index 964a6956e..37f692ce1 100644
@@ -320,7 +320,6 @@ CONFIG_RTE_LIBRTE_AVF_16BYTE_RX_DESC=n
 #
 CONFIG_RTE_LIBRTE_MLX4_PMD=n
 CONFIG_RTE_LIBRTE_MLX4_DEBUG=n
-CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS=n
 
 #
 # Compile burst-oriented Mellanox ConnectX-4, ConnectX-5,
@@ -328,7 +327,11 @@ CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS=n
 #
 CONFIG_RTE_LIBRTE_MLX5_PMD=n
 CONFIG_RTE_LIBRTE_MLX5_DEBUG=n
-CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS=n
+
+# Linking method for mlx4/5 dependency on ibverbs and related libraries
+# Default linking is dynamic by linker.
+# Other option is dynamic by dlopen at run-time.
+CONFIG_RTE_IBVERBS_LINK_DLOPEN=n
 
 #
 # Compile burst-oriented Netronome NFP PMD driver
doc/guides/nics/mlx4.rst +2 -2
index 5326d916e..88d467a23 100644
@@ -60,7 +60,7 @@ These options can be modified in the ``.config`` file.
 
   Toggle compilation of librte_pmd_mlx4 itself.
 
-- ``CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS`` (default **n**)
+- ``CONFIG_RTE_IBVERBS_LINK_DLOPEN`` (default **n**)
 
   Build PMD with additional code to make it loadable without hard
   dependencies on **libibverbs** nor **libmlx4**, which may not be installed
@@ -93,7 +93,7 @@ Environment variables
   A list of directories in which to search for the rdma-core "glue" plug-in,
   separated by colons or semi-colons.
 
-  Only matters when compiled with ``CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS``
+  Only matters when compiled with ``CONFIG_RTE_IBVERBS_LINK_DLOPEN``
   enabled and most useful when ``CONFIG_RTE_EAL_PMD_PATH`` is also set,
   since ``LD_LIBRARY_PATH`` has no effect in this case.
 
doc/guides/nics/mlx5.rst +2 -2
index add8bc1ed..749acd222 100644
@@ -191,7 +191,7 @@ These options can be modified in the ``.config`` file.
 
   Toggle compilation of librte_pmd_mlx5 itself.
 
-- ``CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS`` (default **n**)
+- ``CONFIG_RTE_IBVERBS_LINK_DLOPEN`` (default **n**)
 
   Build PMD with additional code to make it loadable without hard
   dependencies on **libibverbs** nor **libmlx5**, which may not be installed
@@ -224,7 +224,7 @@ Environment variables
   A list of directories in which to search for the rdma-core "glue" plug-in,
   separated by colons or semi-colons.
 
-  Only matters when compiled with ``CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS``
+  Only matters when compiled with ``CONFIG_RTE_IBVERBS_LINK_DLOPEN``
   enabled and most useful when ``CONFIG_RTE_EAL_PMD_PATH`` is also set,
   since ``LD_LIBRARY_PATH`` has no effect in this case.
 
drivers/net/mlx4/Makefile +4 -4
index 92e932250..724a4dcbc 100644
@@ -14,7 +14,7 @@ LIB_GLUE_VERSION = 18.02.0
 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_flow.c
-ifneq ($(CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS),y)
+ifneq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_glue.c
 endif
 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_intr.c
@@ -24,7 +24,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_rxtx.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_txq.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_utils.c
 
-ifeq ($(CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS),y)
+ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 INSTALL-$(CONFIG_RTE_LIBRTE_MLX4_PMD)-lib += $(LIB_GLUE)
 endif
 
@@ -38,7 +38,7 @@ CFLAGS += -D_DEFAULT_SOURCE
 CFLAGS += -D_XOPEN_SOURCE=600
 CFLAGS += $(WERROR_FLAGS)
 CFLAGS += -DALLOW_EXPERIMENTAL_API
-ifeq ($(CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS),y)
+ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 CFLAGS += -DMLX4_GLUE='"$(LIB_GLUE)"'
 CFLAGS += -DMLX4_GLUE_VERSION='"$(LIB_GLUE_VERSION)"'
 CFLAGS_mlx4_glue.o += -fPIC
@@ -103,7 +103,7 @@ $(SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD):.c=.o): mlx4_autoconf.h
 # Generate dependency plug-in for rdma-core when the PMD must not be linked
 # directly, so that applications do not inherit this dependency.
 
-ifeq ($(CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS),y)
+ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 
 $(LIB): $(LIB_GLUE)
 
drivers/net/mlx4/meson.build +2 -2
index 7de571e2a..4bccd68e0 100644
@@ -2,12 +2,12 @@
 # Copyright 2018 6WIND S.A.
 # Copyright 2018 Mellanox Technologies, Ltd
 
-pmd_dlopen = get_option('enable_driver_mlx_glue')
+pmd_dlopen = (get_option('ibverbs_link') == 'dlopen')
 LIB_GLUE_BASE = 'librte_pmd_mlx4_glue.so'
 LIB_GLUE_VERSION = '18.02.0'
 LIB_GLUE = LIB_GLUE_BASE + '.' + LIB_GLUE_VERSION
 if pmd_dlopen
-	dpdk_conf.set('RTE_LIBRTE_MLX4_DLOPEN_DEPS', 1)
+	dpdk_conf.set('RTE_IBVERBS_LINK_DLOPEN', 1)
 	cflags += [
 		'-DMLX4_GLUE="@0@"'.format(LIB_GLUE),
 		'-DMLX4_GLUE_VERSION="@0@"'.format(LIB_GLUE_VERSION),
drivers/net/mlx4/mlx4.c +2 -2
index 7f07b8dc0..070cf7111 100644
@@ -838,7 +838,7 @@ static struct rte_pci_driver mlx4_driver = {
 		     RTE_PCI_DRV_INTR_RMV,
 };
 
-#ifdef RTE_LIBRTE_MLX4_DLOPEN_DEPS
+#ifdef RTE_IBVERBS_LINK_DLOPEN
 
 /**
  * Suffix RTE_EAL_PMD_PATH with "-glue".
@@ -986,7 +986,7 @@ RTE_INIT(rte_mlx4_pmd_init)
 	 * using this PMD, which is not supported in forked processes.
 	 */
 	setenv("RDMAV_HUGEPAGES_SAFE", "1", 1);
-#ifdef RTE_LIBRTE_MLX4_DLOPEN_DEPS
+#ifdef RTE_IBVERBS_LINK_DLOPEN
 	if (mlx4_glue_init())
 		return;
 	assert(mlx4_glue);
drivers/net/mlx5/Makefile +4 -4
index 1353c1827..47a7f4d68 100644
@@ -12,7 +12,7 @@ LIB_GLUE_VERSION = 19.02.0
 
 # Sources.
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5.c
-ifneq ($(CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS),y)
+ifneq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_glue.c
 endif
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_rxq.c
@@ -37,7 +37,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow_verbs.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_socket.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_nl.c
 
-ifeq ($(CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS),y)
+ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 INSTALL-$(CONFIG_RTE_LIBRTE_MLX5_PMD)-lib += $(LIB_GLUE)
 endif
 
@@ -52,7 +52,7 @@ CFLAGS += -D_XOPEN_SOURCE=600
 CFLAGS += $(WERROR_FLAGS)
 CFLAGS += -Wno-strict-prototypes
 CFLAGS += $(shell command -v pkg-config > /dev/null 2>&1 && pkg-config --cflags libmnl)
-ifeq ($(CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS),y)
+ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 CFLAGS += -DMLX5_GLUE='"$(LIB_GLUE)"'
 CFLAGS += -DMLX5_GLUE_VERSION='"$(LIB_GLUE_VERSION)"'
 CFLAGS_mlx5_glue.o += -fPIC
@@ -525,7 +525,7 @@ $(SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD):.c=.o): mlx5_autoconf.h
 # Generate dependency plug-in for rdma-core when the PMD must not be linked
 # directly, so that applications do not inherit this dependency.
 
-ifeq ($(CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS),y)
+ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 
 $(LIB): $(LIB_GLUE)
 
drivers/net/mlx5/meson.build +2 -2
index 8ba19e818..a1130d610 100644
@@ -2,12 +2,12 @@
 # Copyright 2018 6WIND S.A.
 # Copyright 2018 Mellanox Technologies, Ltd
 
-pmd_dlopen = get_option('enable_driver_mlx_glue')
+pmd_dlopen = (get_option('ibverbs_link') == 'dlopen')
 LIB_GLUE_BASE = 'librte_pmd_mlx5_glue.so'
 LIB_GLUE_VERSION = '19.02.0'
 LIB_GLUE = LIB_GLUE_BASE + '.' + LIB_GLUE_VERSION
 if pmd_dlopen
-	dpdk_conf.set('RTE_LIBRTE_MLX5_DLOPEN_DEPS', 1)
+	dpdk_conf.set('RTE_IBVERBS_LINK_DLOPEN', 1)
 	cflags += [
 		'-DMLX5_GLUE="@0@"'.format(LIB_GLUE),
 		'-DMLX5_GLUE_VERSION="@0@"'.format(LIB_GLUE_VERSION),
drivers/net/mlx5/mlx5.c +2 -2
index 45210451d..f111e6ef8 100644
@@ -1609,7 +1609,7 @@ static struct rte_pci_driver mlx5_driver = {
 		      RTE_PCI_DRV_PROBE_AGAIN),
 };
 
-#ifdef RTE_LIBRTE_MLX5_DLOPEN_DEPS
+#ifdef RTE_IBVERBS_LINK_DLOPEN
 
 /**
  * Suffix RTE_EAL_PMD_PATH with "-glue".
@@ -1770,7 +1770,7 @@ RTE_INIT(rte_mlx5_pmd_init)
 	 * cleanup all the Verbs resources even when the device was removed.
 	 */
 	setenv("MLX5_DEVICE_FATAL_CLEANUP", "1", 1);
-#ifdef RTE_LIBRTE_MLX5_DLOPEN_DEPS
+#ifdef RTE_IBVERBS_LINK_DLOPEN
 	if (mlx5_glue_init())
 		return;
 	assert(mlx5_glue);
meson_options.txt +2 -2
index 10b541615..fab97591a 100644
@@ -2,8 +2,8 @@ option('allow_invalid_socket_id', type: 'boolean', value: false,
 	description: 'allow out-of-range NUMA socket id\'s for platforms that don\'t report the value correctly')
 option('drivers_install_subdir', type: 'string', value: 'dpdk/pmds-<VERSION>',
 	description: 'Subdirectory of libdir where to install PMDs. Defaults to using a versioned subdirectory.')
-option('enable_driver_mlx_glue', type: 'boolean', value: false,
-	description: 'Enable glue library for Mellanox PMDs')
+option('ibverbs_link', type: 'string', value: 'shared',
+	description: 'Linkage method (shared/dlopen) for Mellanox PMDs with ibverbs dependencies.')
 option('enable_kmods', type: 'boolean', value: true,
 	description: 'build kernel modules')
 option('enable_docs', type: 'boolean', value: false,
mk/rte.app.mk +7 -8
index 02e8b6f05..d5b1ec6b7 100644
@@ -169,15 +169,14 @@ ifeq ($(CONFIG_RTE_LIBRTE_KNI),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_KNI)        += -lrte_pmd_kni
 endif
 _LDLIBS-$(CONFIG_RTE_LIBRTE_LIO_PMD)        += -lrte_pmd_lio
-ifeq ($(CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS),y)
-_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD)       += -lrte_pmd_mlx4 -ldl
+_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD)       += -lrte_pmd_mlx4
+_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD)       += -lrte_pmd_mlx5 -lmnl
+ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
+_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD)       += -ldl
+_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD)       += -ldl
 else
-_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD)       += -lrte_pmd_mlx4 -libverbs -lmlx4
-endif
-ifeq ($(CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS),y)
-_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD)       += -lrte_pmd_mlx5 -ldl -lmnl
-else
-_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD)       += -lrte_pmd_mlx5 -libverbs -lmlx5 -lmnl
+_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD)       += -libverbs -lmlx4
+_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD)       += -libverbs -lmlx5
 endif
 _LDLIBS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD)      += -lrte_pmd_mvpp2
 _LDLIBS-$(CONFIG_RTE_LIBRTE_MVNETA_PMD)     += -lrte_pmd_mvneta
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/2 config: add static linkage of mlx dependency

The libraries provided by rdma-core may be statically linked
if enabling CONFIG_RTE_IBVERBS_LINK_STATIC in the make-based build. If CONFIG_RTE_BUILD_SHARED_LIB is disabled,
the applications will embed the mlx PMDs with ibverbs and the mlx libraries. If CONFIG_RTE_BUILD_SHARED_LIB is enabled,
the mlx PMDs will embed ibverbs and the mlx libraries.

Support with meson may be added later.

---
 buildtools/options-ibverbs-static.sh | 14 ++++++++++++++
 config/common_base                   |  3 ++-
 doc/guides/nics/mlx4.rst             | 18 ++++++++++++++++++
 doc/guides/nics/mlx5.rst             | 18 ++++++++++++++++++
 drivers/net/mlx4/Makefile            |  2 ++
 drivers/net/mlx5/Makefile            |  2 ++
 mk/rte.app.mk                        |  4 ++++
 7 files changed, 60 insertions(+), 1 deletion(-)
 create mode 100755 buildtools/options-ibverbs-static.sh
buildtools/options-ibverbs-static.sh new file +14 -0
new file mode 100755
index 000000000..0f285a343
@@ -0,0 +1,14 @@
+#! /bin/sh
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Print link options -l for static link of ibverbs.
+#
+# Static flavour of ibverbs and the providers libs are explicitly picked,
+# thanks to the syntax -l:libfoo.a
+# Other libs (pthread and nl) are unchanged, i.e. linked dynamically by default.
+#
+# PKG_CONFIG_PATH may be required to be set if libibverbs.pc is not installed.
+
+pkg-config --libs-only-l --static libibverbs |
+	tr '[:space:]' '\n' |
+	sed -r '/^-l(pthread|nl)/! s,(^-l)(.*),\1:lib\2.a,'
config/common_base +2 -1
index 37f692ce1..f6e5a5396 100644
@@ -330,8 +330,9 @@ CONFIG_RTE_LIBRTE_MLX5_DEBUG=n
 
 # Linking method for mlx4/5 dependency on ibverbs and related libraries
 # Default linking is dynamic by linker.
-# Other option is dynamic by dlopen at run-time.
+# Other options are: dynamic by dlopen at run-time, or statically embedded.
 CONFIG_RTE_IBVERBS_LINK_DLOPEN=n
+CONFIG_RTE_IBVERBS_LINK_STATIC=n
 
 #
 # Compile burst-oriented Netronome NFP PMD driver
doc/guides/nics/mlx4.rst +18 -0
index 88d467a23..4d4842cde 100644
@@ -79,6 +79,11 @@ These options can be modified in the ``.config`` file.
 
   This option has no performance impact.
 
+- ``CONFIG_RTE_IBVERBS_LINK_STATIC`` (default **n**)
+
+  Embed static flavour of the dependencies **libibverbs** and **libmlx4**
+  in the PMD shared library or the executable static binary.
+
 - ``CONFIG_RTE_LIBRTE_MLX4_DEBUG`` (default **n**)
 
   Toggle debugging code and stricter compilation flags. Enabling this option
@@ -206,8 +211,21 @@ Current RDMA core package and Linux kernel (recommended)
 - Minimal Linux kernel version: 4.14.
 - Minimal RDMA core version: v15 (see `RDMA core installation documentation`_).
 
+- Starting with rdma-core v21, static libraries can be built::
+
+    cd build
+    CFLAGS=-fPIC cmake -DIN_PLACE=1 -DENABLE_STATIC=1 -GNinja ..
+    ninja
+
 .. _`RDMA core installation documentation`: https://raw.githubusercontent.com/linux-rdma/rdma-core/master/README.md
 
+If rdma-core libraries are built but not installed, DPDK makefile can link them,
+thanks to these environment variables:
+
+   - ``EXTRA_CFLAGS=-I/path/to/rdma-core/build/include``
+   - ``EXTRA_LDFLAGS=-L/path/to/rdma-core/build/lib``
+   - ``PKG_CONFIG_PATH=/path/to/rdma-core/build/lib/pkgconfig``
+
 .. _Mellanox_OFED_as_a_fallback:
 
 Mellanox OFED as a fallback
doc/guides/nics/mlx5.rst +18 -0
index 749acd222..5ddca44ee 100644
@@ -210,6 +210,11 @@ These options can be modified in the ``.config`` file.
 
   This option has no performance impact.
 
+- ``CONFIG_RTE_IBVERBS_LINK_STATIC`` (default **n**)
+
+  Embed static flavour of the dependencies **libibverbs** and **libmlx5**
+  in the PMD shared library or the executable static binary.
+
 - ``CONFIG_RTE_LIBRTE_MLX5_DEBUG`` (default **n**)
 
   Toggle debugging code and stricter compilation flags. Enabling this option
@@ -577,9 +582,22 @@ RMDA Core with Linux Kernel
   - rdma-core version 18.0 or above built with 32bit support.
   - Kernel version 4.14.41 or above.
 
+- Starting with rdma-core v21, static libraries can be built::
+
+    cd build
+    CFLAGS=-fPIC cmake -DIN_PLACE=1 -DENABLE_STATIC=1 -GNinja ..
+    ninja
+
 .. _`Linux installation documentation`: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/plain/Documentation/admin-guide/README.rst
 .. _`RDMA Core installation documentation`: https://raw.githubusercontent.com/linux-rdma/rdma-core/master/README.md
 
+If rdma-core libraries are built but not installed, DPDK makefile can link them,
+thanks to these environment variables:
+
+   - ``EXTRA_CFLAGS=-I/path/to/rdma-core/build/include``
+   - ``EXTRA_LDFLAGS=-L/path/to/rdma-core/build/lib``
+   - ``PKG_CONFIG_PATH=/path/to/rdma-core/build/lib/pkgconfig``
+
 Mellanox OFED
 ^^^^^^^^^^^^^
 
drivers/net/mlx4/Makefile +2 -0
index 724a4dcbc..1f1b92748 100644
@@ -43,6 +43,8 @@ CFLAGS += -DMLX4_GLUE='"$(LIB_GLUE)"'
 CFLAGS += -DMLX4_GLUE_VERSION='"$(LIB_GLUE_VERSION)"'
 CFLAGS_mlx4_glue.o += -fPIC
 LDLIBS += -ldl
+else ifeq ($(CONFIG_RTE_IBVERBS_LINK_STATIC),y)
+LDLIBS += $(shell $(RTE_SDK)/buildtools/options-ibverbs-static.sh)
 else
 LDLIBS += -libverbs -lmlx4
 endif
drivers/net/mlx5/Makefile +2 -0
index 47a7f4d68..28460c56f 100644
@@ -57,6 +57,8 @@ CFLAGS += -DMLX5_GLUE='"$(LIB_GLUE)"'
 CFLAGS += -DMLX5_GLUE_VERSION='"$(LIB_GLUE_VERSION)"'
 CFLAGS_mlx5_glue.o += -fPIC
 LDLIBS += -ldl
+else ifeq ($(CONFIG_RTE_IBVERBS_LINK_STATIC),y)
+LDLIBS += $(shell $(RTE_SDK)/buildtools/options-ibverbs-static.sh)
 else
 LDLIBS += -libverbs -lmlx5
 endif
mk/rte.app.mk +4 -0
index d5b1ec6b7..3ac396236 100644
@@ -174,6 +174,10 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD)       += -lrte_pmd_mlx5 -lmnl
 ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD)       += -ldl
 _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD)       += -ldl
+else ifeq ($(CONFIG_RTE_IBVERBS_LINK_STATIC),y)
+LIBS_IBVERBS_STATIC = $(shell $(RTE_SDK)/buildtools/options-ibverbs-static.sh)
+_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD)       += $(LIBS_IBVERBS_STATIC)
+_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD)       += $(LIBS_IBVERBS_STATIC)
 else
 _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD)       += -libverbs -lmlx4
 _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD)       += -libverbs -lmlx5
Signature · 1 line
2.20.1
#2 lore raw

Re: [PATCH 2/2] config: add static linkage of mlx dependency

Quoted 11 lines · Thomas Monjalon

The libraries provided by rdma-core may be statically linked
if enabling CONFIG_RTE_IBVERBS_LINK_STATIC in the make-based build. If CONFIG_RTE_BUILD_SHARED_LIB is disabled,
the applications will embed the mlx PMDs with ibverbs and the mlx libraries. If CONFIG_RTE_BUILD_SHARED_LIB is enabled,
the mlx PMDs will embed ibverbs and the mlx libraries.

Support with meson may be added later.

---

Just to clarify - if there is a shared library build, the idea is to actually link in the dependent .a files directly into the .so, rather than having the driver .so's track their dependency on the other .so files? What is the prospective use-case for this, and can it cause problems? I thought it was generally not advisable to be linking in static libraries into shared libraries.

/Bruce

#3 lore raw

Re: [PATCH 2/2] config: add static linkage of mlx dependency

09/01/2019 10:37, Bruce Richardson:

Quoted 10 lines · Thomas Monjalon
Quoted 9 lines

The libraries provided by rdma-core may be statically linked
if enabling CONFIG_RTE_IBVERBS_LINK_STATIC in the make-based build. If CONFIG_RTE_BUILD_SHARED_LIB is disabled,
the applications will embed the mlx PMDs with ibverbs and the mlx libraries. If CONFIG_RTE_BUILD_SHARED_LIB is enabled,
the mlx PMDs will embed ibverbs and the mlx libraries.

Support with meson may be added later.

Quoted 8 lines
Quoted 2 lines

---

Just to clarify - if there is a shared library build, the idea is to actually link in the dependent .a files directly into the .so, rather than having the driver .so's track their dependency on the other .so files? What is the prospective use-case for this, and can it cause problems? I thought it was generally not advisable to be linking in static libraries into shared libraries.

Yes that's it.
It is supposed to ease the packaging for some users, because there are less packages to install on the target host. For instance, VPP may be interested.

If rdma-core is not linked by the application, I don't see any issue.

Acked-by on v1 1/2
#4 lore raw
In reply to Thomas Monjalon

Wednesday, January 9, 2019 4:05 AM, Thomas Monjalon:

Quoted 13 lines

Cc: [email protected]; [email protected]; [email protected]
Subject: [PATCH 1/2] config: gather options for dlopen mlx dependency

Rename options CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS and CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS to a single option CONFIG_RTE_IBVERBS_LINK_DLOPEN.
Rename meson option enable_driver_mlx_glue to ibverbs_link.

There was no good reason for setting a different link option for mlx4 and mlx5. Having a single common option makes it easier to understand and unify make and meson systems.

Quoted 13 lines
---
 config/common_base           |  7 +++++--
 doc/guides/nics/mlx4.rst     |  4 ++--
 doc/guides/nics/mlx5.rst     |  4 ++--
 drivers/net/mlx4/Makefile    |  8 ++++----
 drivers/net/mlx4/meson.build |  4 ++--
 drivers/net/mlx4/mlx4.c      |  4 ++--
 drivers/net/mlx5/Makefile    |  8 ++++----
 drivers/net/mlx5/meson.build |  4 ++--
 drivers/net/mlx5/mlx5.c      |  4 ++--
 meson_options.txt            |  4 ++--
 mk/rte.app.mk                | 15 +++++++--------
 11 files changed, 34 insertions(+), 32 deletions(-)

For the series,

Since the release schedule is tight I applied to series to next-net-mlx tree (as it is almost exclusively Mellanox). If you object to it, please shout ASAP.

#5 lore raw
In reply to Thomas Monjalon
Quoted 24 lines · Thomas Monjalon

Rename options CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS and CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS to a single option CONFIG_RTE_IBVERBS_LINK_DLOPEN.
Rename meson option enable_driver_mlx_glue to ibverbs_link.

There was no good reason for setting a different link option for mlx4 and mlx5. Having a single common option makes it easier to understand and unify make and meson systems.

---
 config/common_base           |  7 +++++--
 doc/guides/nics/mlx4.rst     |  4 ++--
 doc/guides/nics/mlx5.rst     |  4 ++--
 drivers/net/mlx4/Makefile    |  8 ++++----
 drivers/net/mlx4/meson.build |  4 ++--
 drivers/net/mlx4/mlx4.c      |  4 ++--
 drivers/net/mlx5/Makefile    |  8 ++++----
 drivers/net/mlx5/meson.build |  4 ++--
 drivers/net/mlx5/mlx5.c      |  4 ++--
 meson_options.txt            |  4 ++--
 mk/rte.app.mk                | 15 +++++++--------
 11 files changed, 34 insertions(+), 32 deletions(-)

<snip>

meson_options.txt option('allow_invalid_socket_id', type: 'boolean', value: false, · line 6

Quoted 12 lines
meson_options.txt +2 -2
index 10b541615..fab97591a 100644
@@ -2,8 +2,8 @@ option('allow_invalid_socket_id', type: 'boolean', value: false,
 	description: 'allow out-of-range NUMA socket id\'s for platforms that don\'t report the value correctly')
 option('drivers_install_subdir', type: 'string', value: 'dpdk/pmds-<VERSION>',
 	description: 'Subdirectory of libdir where to install PMDs. Defaults to using a versioned subdirectory.')
-option('enable_driver_mlx_glue', type: 'boolean', value: false,
-	description: 'Enable glue library for Mellanox PMDs')
+option('ibverbs_link', type: 'string', value: 'shared',
+	description: 'Linkage method (shared/dlopen) for Mellanox PMDs with ibverbs dependencies.')

I think it's better to use the "combo" option type here rather than a generic string. That way we get proper protection against typos when configuring.
[Ref: https://mesonbuild.com/Build-options.html]

#6 lore raw

09/01/2019 10:33, Bruce Richardson:

Quoted 9 lines · Thomas Monjalon
Quoted 8 lines

Rename options CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS and CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS to a single option CONFIG_RTE_IBVERBS_LINK_DLOPEN.
Rename meson option enable_driver_mlx_glue to ibverbs_link.

There was no good reason for setting a different link option for mlx4 and mlx5. Having a single common option makes it easier to understand and unify make and meson systems.

[...]

Quoted 7 lines
Quoted 7 lines
meson_options.txt +0 -1
@@ -2,8 +2,8 @@ option('allow_invalid_socket_id', type: 'boolean', value: false,
 	description: 'allow out-of-range NUMA socket id\'s for platforms that don\'t report the value correctly')
 option('drivers_install_subdir', type: 'string', value: 'dpdk/pmds-<VERSION>',
 	description: 'Subdirectory of libdir where to install PMDs. Defaults to using a versioned subdirectory.')
-option('enable_driver_mlx_glue', type: 'boolean', value: false,
Quoted 8 lines

meson_options.txt option('allow_invalid_socket_id', type: 'boolean', value: false, · line 6

Quoted 3 lines
meson_options.txt +2 -1
-	description: 'Enable glue library for Mellanox PMDs')
+option('ibverbs_link', type: 'string', value: 'shared',
+	description: 'Linkage method (shared/dlopen) for Mellanox PMDs with ibverbs dependencies.')

I think it's better to use the "combo" option type here rather than a generic string. That way we get proper protection against typos when configuring.
[Ref: https://mesonbuild.com/Build-options.html]

Good suggestion, I did not check such option exists. I will send a v2.

#7 lore raw

PATCH v2 1/2 config: gather options for dlopen mlx dependency

In reply to Thomas Monjalon

Rename options CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS and CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS to a single option CONFIG_RTE_IBVERBS_LINK_DLOPEN.
Rename meson option enable_driver_mlx_glue to ibverbs_link.

There was no good reason for setting a different link option for mlx4 and mlx5. Having a single common option makes it easier to understand and unify make and meson systems.

---
v2: use "combo" option type (Bruce review)

---
 config/common_base           |  7 +++++--
 doc/guides/nics/mlx4.rst     |  4 ++--
 doc/guides/nics/mlx5.rst     |  4 ++--
 drivers/net/mlx4/Makefile    |  8 ++++----
 drivers/net/mlx4/meson.build |  4 ++--
 drivers/net/mlx4/mlx4.c      |  4 ++--
 drivers/net/mlx5/Makefile    |  8 ++++----
 drivers/net/mlx5/meson.build |  4 ++--
 drivers/net/mlx5/mlx5.c      |  4 ++--
 meson_options.txt            |  4 ++--
 mk/rte.app.mk                | 15 +++++++--------
 11 files changed, 34 insertions(+), 32 deletions(-)
config/common_base +5 -2
index 964a6956e..37f692ce1 100644
@@ -320,7 +320,6 @@ CONFIG_RTE_LIBRTE_AVF_16BYTE_RX_DESC=n
 #
 CONFIG_RTE_LIBRTE_MLX4_PMD=n
 CONFIG_RTE_LIBRTE_MLX4_DEBUG=n
-CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS=n
 
 #
 # Compile burst-oriented Mellanox ConnectX-4, ConnectX-5,
@@ -328,7 +327,11 @@ CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS=n
 #
 CONFIG_RTE_LIBRTE_MLX5_PMD=n
 CONFIG_RTE_LIBRTE_MLX5_DEBUG=n
-CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS=n
+
+# Linking method for mlx4/5 dependency on ibverbs and related libraries
+# Default linking is dynamic by linker.
+# Other option is dynamic by dlopen at run-time.
+CONFIG_RTE_IBVERBS_LINK_DLOPEN=n
 
 #
 # Compile burst-oriented Netronome NFP PMD driver
doc/guides/nics/mlx4.rst +2 -2
index 5326d916e..88d467a23 100644
@@ -60,7 +60,7 @@ These options can be modified in the ``.config`` file.
 
   Toggle compilation of librte_pmd_mlx4 itself.
 
-- ``CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS`` (default **n**)
+- ``CONFIG_RTE_IBVERBS_LINK_DLOPEN`` (default **n**)
 
   Build PMD with additional code to make it loadable without hard
   dependencies on **libibverbs** nor **libmlx4**, which may not be installed
@@ -93,7 +93,7 @@ Environment variables
   A list of directories in which to search for the rdma-core "glue" plug-in,
   separated by colons or semi-colons.
 
-  Only matters when compiled with ``CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS``
+  Only matters when compiled with ``CONFIG_RTE_IBVERBS_LINK_DLOPEN``
   enabled and most useful when ``CONFIG_RTE_EAL_PMD_PATH`` is also set,
   since ``LD_LIBRARY_PATH`` has no effect in this case.
 
doc/guides/nics/mlx5.rst +2 -2
index add8bc1ed..749acd222 100644
@@ -191,7 +191,7 @@ These options can be modified in the ``.config`` file.
 
   Toggle compilation of librte_pmd_mlx5 itself.
 
-- ``CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS`` (default **n**)
+- ``CONFIG_RTE_IBVERBS_LINK_DLOPEN`` (default **n**)
 
   Build PMD with additional code to make it loadable without hard
   dependencies on **libibverbs** nor **libmlx5**, which may not be installed
@@ -224,7 +224,7 @@ Environment variables
   A list of directories in which to search for the rdma-core "glue" plug-in,
   separated by colons or semi-colons.
 
-  Only matters when compiled with ``CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS``
+  Only matters when compiled with ``CONFIG_RTE_IBVERBS_LINK_DLOPEN``
   enabled and most useful when ``CONFIG_RTE_EAL_PMD_PATH`` is also set,
   since ``LD_LIBRARY_PATH`` has no effect in this case.
 
drivers/net/mlx4/Makefile +4 -4
index 92e932250..724a4dcbc 100644
@@ -14,7 +14,7 @@ LIB_GLUE_VERSION = 18.02.0
 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_flow.c
-ifneq ($(CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS),y)
+ifneq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_glue.c
 endif
 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_intr.c
@@ -24,7 +24,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_rxtx.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_txq.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_utils.c
 
-ifeq ($(CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS),y)
+ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 INSTALL-$(CONFIG_RTE_LIBRTE_MLX4_PMD)-lib += $(LIB_GLUE)
 endif
 
@@ -38,7 +38,7 @@ CFLAGS += -D_DEFAULT_SOURCE
 CFLAGS += -D_XOPEN_SOURCE=600
 CFLAGS += $(WERROR_FLAGS)
 CFLAGS += -DALLOW_EXPERIMENTAL_API
-ifeq ($(CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS),y)
+ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 CFLAGS += -DMLX4_GLUE='"$(LIB_GLUE)"'
 CFLAGS += -DMLX4_GLUE_VERSION='"$(LIB_GLUE_VERSION)"'
 CFLAGS_mlx4_glue.o += -fPIC
@@ -103,7 +103,7 @@ $(SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD):.c=.o): mlx4_autoconf.h
 # Generate dependency plug-in for rdma-core when the PMD must not be linked
 # directly, so that applications do not inherit this dependency.
 
-ifeq ($(CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS),y)
+ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 
 $(LIB): $(LIB_GLUE)
 
drivers/net/mlx4/meson.build +2 -2
index 7de571e2a..4bccd68e0 100644
@@ -2,12 +2,12 @@
 # Copyright 2018 6WIND S.A.
 # Copyright 2018 Mellanox Technologies, Ltd
 
-pmd_dlopen = get_option('enable_driver_mlx_glue')
+pmd_dlopen = (get_option('ibverbs_link') == 'dlopen')
 LIB_GLUE_BASE = 'librte_pmd_mlx4_glue.so'
 LIB_GLUE_VERSION = '18.02.0'
 LIB_GLUE = LIB_GLUE_BASE + '.' + LIB_GLUE_VERSION
 if pmd_dlopen
-	dpdk_conf.set('RTE_LIBRTE_MLX4_DLOPEN_DEPS', 1)
+	dpdk_conf.set('RTE_IBVERBS_LINK_DLOPEN', 1)
 	cflags += [
 		'-DMLX4_GLUE="@0@"'.format(LIB_GLUE),
 		'-DMLX4_GLUE_VERSION="@0@"'.format(LIB_GLUE_VERSION),
drivers/net/mlx4/mlx4.c +2 -2
index 7f07b8dc0..070cf7111 100644
@@ -838,7 +838,7 @@ static struct rte_pci_driver mlx4_driver = {
 		     RTE_PCI_DRV_INTR_RMV,
 };
 
-#ifdef RTE_LIBRTE_MLX4_DLOPEN_DEPS
+#ifdef RTE_IBVERBS_LINK_DLOPEN
 
 /**
  * Suffix RTE_EAL_PMD_PATH with "-glue".
@@ -986,7 +986,7 @@ RTE_INIT(rte_mlx4_pmd_init)
 	 * using this PMD, which is not supported in forked processes.
 	 */
 	setenv("RDMAV_HUGEPAGES_SAFE", "1", 1);
-#ifdef RTE_LIBRTE_MLX4_DLOPEN_DEPS
+#ifdef RTE_IBVERBS_LINK_DLOPEN
 	if (mlx4_glue_init())
 		return;
 	assert(mlx4_glue);
drivers/net/mlx5/Makefile +4 -4
index 1353c1827..47a7f4d68 100644
@@ -12,7 +12,7 @@ LIB_GLUE_VERSION = 19.02.0
 
 # Sources.
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5.c
-ifneq ($(CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS),y)
+ifneq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_glue.c
 endif
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_rxq.c
@@ -37,7 +37,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow_verbs.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_socket.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_nl.c
 
-ifeq ($(CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS),y)
+ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 INSTALL-$(CONFIG_RTE_LIBRTE_MLX5_PMD)-lib += $(LIB_GLUE)
 endif
 
@@ -52,7 +52,7 @@ CFLAGS += -D_XOPEN_SOURCE=600
 CFLAGS += $(WERROR_FLAGS)
 CFLAGS += -Wno-strict-prototypes
 CFLAGS += $(shell command -v pkg-config > /dev/null 2>&1 && pkg-config --cflags libmnl)
-ifeq ($(CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS),y)
+ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 CFLAGS += -DMLX5_GLUE='"$(LIB_GLUE)"'
 CFLAGS += -DMLX5_GLUE_VERSION='"$(LIB_GLUE_VERSION)"'
 CFLAGS_mlx5_glue.o += -fPIC
@@ -525,7 +525,7 @@ $(SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD):.c=.o): mlx5_autoconf.h
 # Generate dependency plug-in for rdma-core when the PMD must not be linked
 # directly, so that applications do not inherit this dependency.
 
-ifeq ($(CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS),y)
+ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 
 $(LIB): $(LIB_GLUE)
 
drivers/net/mlx5/meson.build +2 -2
index 8ba19e818..a1130d610 100644
@@ -2,12 +2,12 @@
 # Copyright 2018 6WIND S.A.
 # Copyright 2018 Mellanox Technologies, Ltd
 
-pmd_dlopen = get_option('enable_driver_mlx_glue')
+pmd_dlopen = (get_option('ibverbs_link') == 'dlopen')
 LIB_GLUE_BASE = 'librte_pmd_mlx5_glue.so'
 LIB_GLUE_VERSION = '19.02.0'
 LIB_GLUE = LIB_GLUE_BASE + '.' + LIB_GLUE_VERSION
 if pmd_dlopen
-	dpdk_conf.set('RTE_LIBRTE_MLX5_DLOPEN_DEPS', 1)
+	dpdk_conf.set('RTE_IBVERBS_LINK_DLOPEN', 1)
 	cflags += [
 		'-DMLX5_GLUE="@0@"'.format(LIB_GLUE),
 		'-DMLX5_GLUE_VERSION="@0@"'.format(LIB_GLUE_VERSION),
drivers/net/mlx5/mlx5.c +2 -2
index 45210451d..f111e6ef8 100644
@@ -1609,7 +1609,7 @@ static struct rte_pci_driver mlx5_driver = {
 		      RTE_PCI_DRV_PROBE_AGAIN),
 };
 
-#ifdef RTE_LIBRTE_MLX5_DLOPEN_DEPS
+#ifdef RTE_IBVERBS_LINK_DLOPEN
 
 /**
  * Suffix RTE_EAL_PMD_PATH with "-glue".
@@ -1770,7 +1770,7 @@ RTE_INIT(rte_mlx5_pmd_init)
 	 * cleanup all the Verbs resources even when the device was removed.
 	 */
 	setenv("MLX5_DEVICE_FATAL_CLEANUP", "1", 1);
-#ifdef RTE_LIBRTE_MLX5_DLOPEN_DEPS
+#ifdef RTE_IBVERBS_LINK_DLOPEN
 	if (mlx5_glue_init())
 		return;
 	assert(mlx5_glue);
meson_options.txt +2 -2
index 10b541615..574054597 100644
@@ -2,8 +2,8 @@ option('allow_invalid_socket_id', type: 'boolean', value: false,
 	description: 'allow out-of-range NUMA socket id\'s for platforms that don\'t report the value correctly')
 option('drivers_install_subdir', type: 'string', value: 'dpdk/pmds-<VERSION>',
 	description: 'Subdirectory of libdir where to install PMDs. Defaults to using a versioned subdirectory.')
-option('enable_driver_mlx_glue', type: 'boolean', value: false,
-	description: 'Enable glue library for Mellanox PMDs')
+option('ibverbs_link', type: 'combo', choices : ['shared', 'dlopen'], value: 'shared',
+	description: 'Linkage method (shared/dlopen) for Mellanox PMDs with ibverbs dependencies.')
 option('enable_kmods', type: 'boolean', value: true,
 	description: 'build kernel modules')
 option('enable_docs', type: 'boolean', value: false,
mk/rte.app.mk +7 -8
index 02e8b6f05..d5b1ec6b7 100644
@@ -169,15 +169,14 @@ ifeq ($(CONFIG_RTE_LIBRTE_KNI),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_KNI)        += -lrte_pmd_kni
 endif
 _LDLIBS-$(CONFIG_RTE_LIBRTE_LIO_PMD)        += -lrte_pmd_lio
-ifeq ($(CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS),y)
-_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD)       += -lrte_pmd_mlx4 -ldl
+_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD)       += -lrte_pmd_mlx4
+_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD)       += -lrte_pmd_mlx5 -lmnl
+ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
+_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD)       += -ldl
+_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD)       += -ldl
 else
-_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD)       += -lrte_pmd_mlx4 -libverbs -lmlx4
-endif
-ifeq ($(CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS),y)
-_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD)       += -lrte_pmd_mlx5 -ldl -lmnl
-else
-_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD)       += -lrte_pmd_mlx5 -libverbs -lmlx5 -lmnl
+_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD)       += -libverbs -lmlx4
+_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD)       += -libverbs -lmlx5
 endif
 _LDLIBS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD)      += -lrte_pmd_mvpp2
 _LDLIBS-$(CONFIG_RTE_LIBRTE_MVNETA_PMD)     += -lrte_pmd_mvneta
Signature · 1 line
2.20.1
#8 lore raw

PATCH v2 2/2 config: add static linkage of mlx dependency

The libraries provided by rdma-core may be statically linked if enabling CONFIG_RTE_IBVERBS_LINK_STATIC in the make-based build. If CONFIG_RTE_BUILD_SHARED_LIB is disabled, the applications will embed the mlx PMDs with ibverbs and the mlx libraries. If CONFIG_RTE_BUILD_SHARED_LIB is enabled,
the mlx PMDs will embed ibverbs and the mlx libraries.

Support with meson may be added later.

---
v2: no change

---
 buildtools/options-ibverbs-static.sh | 14 ++++++++++++++
 config/common_base                   |  3 ++-
 doc/guides/nics/mlx4.rst             | 18 ++++++++++++++++++
 doc/guides/nics/mlx5.rst             | 18 ++++++++++++++++++
 drivers/net/mlx4/Makefile            |  2 ++
 drivers/net/mlx5/Makefile            |  2 ++
 mk/rte.app.mk                        |  4 ++++
 7 files changed, 60 insertions(+), 1 deletion(-)
 create mode 100755 buildtools/options-ibverbs-static.sh
buildtools/options-ibverbs-static.sh new file +14 -0
new file mode 100755
index 000000000..0f285a343
@@ -0,0 +1,14 @@
+#! /bin/sh
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Print link options -l for static link of ibverbs.
+#
+# Static flavour of ibverbs and the providers libs are explicitly picked,
+# thanks to the syntax -l:libfoo.a
+# Other libs (pthread and nl) are unchanged, i.e. linked dynamically by default.
+#
+# PKG_CONFIG_PATH may be required to be set if libibverbs.pc is not installed.
+
+pkg-config --libs-only-l --static libibverbs |
+	tr '[:space:]' '\n' |
+	sed -r '/^-l(pthread|nl)/! s,(^-l)(.*),\1:lib\2.a,'
config/common_base +2 -1
index 37f692ce1..f6e5a5396 100644
@@ -330,8 +330,9 @@ CONFIG_RTE_LIBRTE_MLX5_DEBUG=n
 
 # Linking method for mlx4/5 dependency on ibverbs and related libraries
 # Default linking is dynamic by linker.
-# Other option is dynamic by dlopen at run-time.
+# Other options are: dynamic by dlopen at run-time, or statically embedded.
 CONFIG_RTE_IBVERBS_LINK_DLOPEN=n
+CONFIG_RTE_IBVERBS_LINK_STATIC=n
 
 #
 # Compile burst-oriented Netronome NFP PMD driver
doc/guides/nics/mlx4.rst +18 -0
index 88d467a23..4d4842cde 100644
@@ -79,6 +79,11 @@ These options can be modified in the ``.config`` file.
 
   This option has no performance impact.
 
+- ``CONFIG_RTE_IBVERBS_LINK_STATIC`` (default **n**)
+
+  Embed static flavour of the dependencies **libibverbs** and **libmlx4**
+  in the PMD shared library or the executable static binary.
+
 - ``CONFIG_RTE_LIBRTE_MLX4_DEBUG`` (default **n**)
 
   Toggle debugging code and stricter compilation flags. Enabling this option
@@ -206,8 +211,21 @@ Current RDMA core package and Linux kernel (recommended)
 - Minimal Linux kernel version: 4.14.
 - Minimal RDMA core version: v15 (see `RDMA core installation documentation`_).
 
+- Starting with rdma-core v21, static libraries can be built::
+
+    cd build
+    CFLAGS=-fPIC cmake -DIN_PLACE=1 -DENABLE_STATIC=1 -GNinja ..
+    ninja
+
 .. _`RDMA core installation documentation`: https://raw.githubusercontent.com/linux-rdma/rdma-core/master/README.md
 
+If rdma-core libraries are built but not installed, DPDK makefile can link them,
+thanks to these environment variables:
+
+   - ``EXTRA_CFLAGS=-I/path/to/rdma-core/build/include``
+   - ``EXTRA_LDFLAGS=-L/path/to/rdma-core/build/lib``
+   - ``PKG_CONFIG_PATH=/path/to/rdma-core/build/lib/pkgconfig``
+
 .. _Mellanox_OFED_as_a_fallback:
 
 Mellanox OFED as a fallback
doc/guides/nics/mlx5.rst +18 -0
index 749acd222..5ddca44ee 100644
@@ -210,6 +210,11 @@ These options can be modified in the ``.config`` file.
 
   This option has no performance impact.
 
+- ``CONFIG_RTE_IBVERBS_LINK_STATIC`` (default **n**)
+
+  Embed static flavour of the dependencies **libibverbs** and **libmlx5**
+  in the PMD shared library or the executable static binary.
+
 - ``CONFIG_RTE_LIBRTE_MLX5_DEBUG`` (default **n**)
 
   Toggle debugging code and stricter compilation flags. Enabling this option
@@ -577,9 +582,22 @@ RMDA Core with Linux Kernel
   - rdma-core version 18.0 or above built with 32bit support.
   - Kernel version 4.14.41 or above.
 
+- Starting with rdma-core v21, static libraries can be built::
+
+    cd build
+    CFLAGS=-fPIC cmake -DIN_PLACE=1 -DENABLE_STATIC=1 -GNinja ..
+    ninja
+
 .. _`Linux installation documentation`: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/plain/Documentation/admin-guide/README.rst
 .. _`RDMA Core installation documentation`: https://raw.githubusercontent.com/linux-rdma/rdma-core/master/README.md
 
+If rdma-core libraries are built but not installed, DPDK makefile can link them,
+thanks to these environment variables:
+
+   - ``EXTRA_CFLAGS=-I/path/to/rdma-core/build/include``
+   - ``EXTRA_LDFLAGS=-L/path/to/rdma-core/build/lib``
+   - ``PKG_CONFIG_PATH=/path/to/rdma-core/build/lib/pkgconfig``
+
 Mellanox OFED
 ^^^^^^^^^^^^^
 
drivers/net/mlx4/Makefile +2 -0
index 724a4dcbc..1f1b92748 100644
@@ -43,6 +43,8 @@ CFLAGS += -DMLX4_GLUE='"$(LIB_GLUE)"'
 CFLAGS += -DMLX4_GLUE_VERSION='"$(LIB_GLUE_VERSION)"'
 CFLAGS_mlx4_glue.o += -fPIC
 LDLIBS += -ldl
+else ifeq ($(CONFIG_RTE_IBVERBS_LINK_STATIC),y)
+LDLIBS += $(shell $(RTE_SDK)/buildtools/options-ibverbs-static.sh)
 else
 LDLIBS += -libverbs -lmlx4
 endif
drivers/net/mlx5/Makefile +2 -0
index 47a7f4d68..28460c56f 100644
@@ -57,6 +57,8 @@ CFLAGS += -DMLX5_GLUE='"$(LIB_GLUE)"'
 CFLAGS += -DMLX5_GLUE_VERSION='"$(LIB_GLUE_VERSION)"'
 CFLAGS_mlx5_glue.o += -fPIC
 LDLIBS += -ldl
+else ifeq ($(CONFIG_RTE_IBVERBS_LINK_STATIC),y)
+LDLIBS += $(shell $(RTE_SDK)/buildtools/options-ibverbs-static.sh)
 else
 LDLIBS += -libverbs -lmlx5
 endif
mk/rte.app.mk +4 -0
index d5b1ec6b7..3ac396236 100644
@@ -174,6 +174,10 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD)       += -lrte_pmd_mlx5 -lmnl
 ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD)       += -ldl
 _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD)       += -ldl
+else ifeq ($(CONFIG_RTE_IBVERBS_LINK_STATIC),y)
+LIBS_IBVERBS_STATIC = $(shell $(RTE_SDK)/buildtools/options-ibverbs-static.sh)
+_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD)       += $(LIBS_IBVERBS_STATIC)
+_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD)       += $(LIBS_IBVERBS_STATIC)
 else
 _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD)       += -libverbs -lmlx4
 _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD)       += -libverbs -lmlx5
Signature · 1 line
2.20.1
#9 lore raw
In reply to Thomas Monjalon

Wednesday, January 9, 2019 4:23 PM, Thomas Monjalon:

Quoted 7 lines

Subject: [PATCH v2 1/2] config: gather options for dlopen mlx dependency

Rename options CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS and CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS to a single option CONFIG_RTE_IBVERBS_LINK_DLOPEN.
Rename meson option enable_driver_mlx_glue to ibverbs_link.

Quoted 6 lines

There was no good reason for setting a different link option for mlx4 and mlx5. Having a single common option makes it easier to understand and unify make and meson systems.

Applied to next-net-mlx with replacement of the v1. Thanks.

Quoted 295 lines

---
v2: use "combo" option type (Bruce review)

---
 config/common_base           |  7 +++++--
 doc/guides/nics/mlx4.rst     |  4 ++--
 doc/guides/nics/mlx5.rst     |  4 ++--
 drivers/net/mlx4/Makefile    |  8 ++++----
 drivers/net/mlx4/meson.build |  4 ++--
 drivers/net/mlx4/mlx4.c      |  4 ++--
 drivers/net/mlx5/Makefile    |  8 ++++----
 drivers/net/mlx5/meson.build |  4 ++--
 drivers/net/mlx5/mlx5.c      |  4 ++--
 meson_options.txt            |  4 ++--
 mk/rte.app.mk                | 15 +++++++--------
 11 files changed, 34 insertions(+), 32 deletions(-)
config/common_base index renamed from config/common_base +0 -0

964a6956e..37f692ce1 100644

config/common_base +6 -2
@@ -320,7 +320,6 @@ CONFIG_RTE_LIBRTE_AVF_16BYTE_RX_DESC=n
 #
 CONFIG_RTE_LIBRTE_MLX4_PMD=n
 CONFIG_RTE_LIBRTE_MLX4_DEBUG=n
-CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS=n
 
 #
 # Compile burst-oriented Mellanox ConnectX-4, ConnectX-5, @@ -328,7
+327,11 @@ CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS=n
 #
 CONFIG_RTE_LIBRTE_MLX5_PMD=n
 CONFIG_RTE_LIBRTE_MLX5_DEBUG=n
-CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS=n
+
+# Linking method for mlx4/5 dependency on ibverbs and related libraries
+# Default linking is dynamic by linker.
+# Other option is dynamic by dlopen at run-time.
+CONFIG_RTE_IBVERBS_LINK_DLOPEN=n
 
 #
 # Compile burst-oriented Netronome NFP PMD driver diff --git

a/doc/guides/nics/mlx4.rst b/doc/guides/nics/mlx4.rst index 5326d916e..88d467a23 100644

doc/guides/nics/mlx4.rst +1 -2
@@ -60,7 +60,7 @@ These options can be modified in the ``.config`` file.
 
   Toggle compilation of librte_pmd_mlx4 itself.
 
-- ``CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS`` (default **n**)
+- ``CONFIG_RTE_IBVERBS_LINK_DLOPEN`` (default **n**)
 
   Build PMD with additional code to make it loadable without hard
   dependencies on **libibverbs** nor **libmlx4**, which may not be installed
@@ -93,7 +93,7 @@ Environment variables
   A list of directories in which to search for the rdma-core "glue" plug-in,
   separated by colons or semi-colons.
 
-  Only matters when compiled with

``CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS``

doc/guides/nics/mlx4.rst +1 -0
+  Only matters when compiled with ``CONFIG_RTE_IBVERBS_LINK_DLOPEN``
   enabled and most useful when ``CONFIG_RTE_EAL_PMD_PATH`` is also set,
   since ``LD_LIBRARY_PATH`` has no effect in this case.
doc/guides/nics/mlx5.rst index renamed from doc/guides/nics/mlx5.rst +0 -0

add8bc1ed..749acd222 100644

doc/guides/nics/mlx5.rst +1 -2
@@ -191,7 +191,7 @@ These options can be modified in the ``.config`` file.
 
   Toggle compilation of librte_pmd_mlx5 itself.
 
-- ``CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS`` (default **n**)
+- ``CONFIG_RTE_IBVERBS_LINK_DLOPEN`` (default **n**)
 
   Build PMD with additional code to make it loadable without hard
   dependencies on **libibverbs** nor **libmlx5**, which may not be installed
@@ -224,7 +224,7 @@ Environment variables
   A list of directories in which to search for the rdma-core "glue" plug-in,
   separated by colons or semi-colons.
 
-  Only matters when compiled with

``CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS``

doc/guides/nics/mlx5.rst +1 -0
+  Only matters when compiled with ``CONFIG_RTE_IBVERBS_LINK_DLOPEN``
   enabled and most useful when ``CONFIG_RTE_EAL_PMD_PATH`` is also set,
   since ``LD_LIBRARY_PATH`` has no effect in this case.
drivers/net/mlx4/Makefile index renamed from drivers/net/mlx4/Makefile +0 -0

92e932250..724a4dcbc 100644

drivers/net/mlx4/Makefile +1 -0
@@ -14,7 +14,7 @@ LIB_GLUE_VERSION = 18.02.0
 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_flow.c -ifneq
 ($(CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS),y)
+ifneq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_glue.c  endif
 SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_intr.c @@ -24,7 +24,7

@@ SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_rxtx.c
SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_txq.c SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_utils.c

drivers/net/mlx4/Makefile +1 -1
-ifeq ($(CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS),y)
+ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 INSTALL-$(CONFIG_RTE_LIBRTE_MLX4_PMD)-lib += $(LIB_GLUE)  endif
@@ -38,7 +38,7 @@ CFLAGS += -D_DEFAULT_SOURCE  CFLAGS += -

D_XOPEN_SOURCE=600 CFLAGS += $(WERROR_FLAGS) CFLAGS += - DALLOW_EXPERIMENTAL_API -ifeq ($(CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS),y)

drivers/net/mlx4/Makefile +1 -0
+ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 CFLAGS += -DMLX4_GLUE='"$(LIB_GLUE)"'
 CFLAGS += -DMLX4_GLUE_VERSION='"$(LIB_GLUE_VERSION)"'
 CFLAGS_mlx4_glue.o += -fPIC
@@ -103,7 +103,7 @@ $(SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD):.c=.o):

mlx4_autoconf.h # Generate dependency plug-in for rdma-core when the PMD must not be linked # directly, so that applications do not inherit this dependency.

drivers/net/mlx4/Makefile +1 -1
-ifeq ($(CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS),y)
+ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 
 $(LIB): $(LIB_GLUE)
drivers/net/mlx4/meson.build index renamed from drivers/net/mlx4/meson.build +0 -0

7de571e2a..4bccd68e0 100644

drivers/net/mlx4/meson.build +2 -2
@@ -2,12 +2,12 @@
 # Copyright 2018 6WIND S.A.
 # Copyright 2018 Mellanox Technologies, Ltd
 
-pmd_dlopen = get_option('enable_driver_mlx_glue')
+pmd_dlopen = (get_option('ibverbs_link') == 'dlopen')
 LIB_GLUE_BASE = 'librte_pmd_mlx4_glue.so'
 LIB_GLUE_VERSION = '18.02.0'
 LIB_GLUE = LIB_GLUE_BASE + '.' + LIB_GLUE_VERSION  if pmd_dlopen
-	dpdk_conf.set('RTE_LIBRTE_MLX4_DLOPEN_DEPS', 1)
+	dpdk_conf.set('RTE_IBVERBS_LINK_DLOPEN', 1)
 	cflags += [
 		'-DMLX4_GLUE="@0@"'.format(LIB_GLUE),
 		'-
 DMLX4_GLUE_VERSION="@0@"'.format(LIB_GLUE_VERSION),
drivers/net/mlx4/mlx4.c index renamed from drivers/net/mlx4/mlx4.c +0 -0

7f07b8dc0..070cf7111 100644

drivers/net/mlx4/mlx4.c +1 -1
@@ -838,7 +838,7 @@ static struct rte_pci_driver mlx4_driver = {
 		     RTE_PCI_DRV_INTR_RMV,
 };
 
-#ifdef RTE_LIBRTE_MLX4_DLOPEN_DEPS
+#ifdef RTE_IBVERBS_LINK_DLOPEN
 
 /**
  * Suffix RTE_EAL_PMD_PATH with "-glue".
@@ -986,7 +986,7 @@ RTE_INIT(rte_mlx4_pmd_init)
 	 * using this PMD, which is not supported in forked processes.
 	 */
 	setenv("RDMAV_HUGEPAGES_SAFE", "1", 1); -#ifdef

RTE_LIBRTE_MLX4_DLOPEN_DEPS

drivers/net/mlx4/mlx4.c +1 -0
+#ifdef RTE_IBVERBS_LINK_DLOPEN
 	if (mlx4_glue_init())
 		return;
 	assert(mlx4_glue);
drivers/net/mlx5/Makefile index renamed from drivers/net/mlx5/Makefile +0 -0

1353c1827..47a7f4d68 100644

drivers/net/mlx5/Makefile +1 -0
@@ -12,7 +12,7 @@ LIB_GLUE_VERSION = 19.02.0
 
 # Sources.
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5.c -ifneq
 ($(CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS),y)
+ifneq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_glue.c  endif
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_rxq.c @@ -37,7 +37,7 @@

SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow_verbs.c
SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_socket.c SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_nl.c

drivers/net/mlx5/Makefile +1 -1
-ifeq ($(CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS),y)
+ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 INSTALL-$(CONFIG_RTE_LIBRTE_MLX5_PMD)-lib += $(LIB_GLUE)  endif
@@ -52,7 +52,7 @@ CFLAGS += -D_XOPEN_SOURCE=600  CFLAGS +=

$(WERROR_FLAGS) CFLAGS += -Wno-strict-prototypes CFLAGS += $(shell command -v pkg-config > /dev/null 2>&1 && pkg-config --cflags libmnl) -ifeq ($(CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS),y)

drivers/net/mlx5/Makefile +1 -0
+ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 CFLAGS += -DMLX5_GLUE='"$(LIB_GLUE)"'
 CFLAGS += -DMLX5_GLUE_VERSION='"$(LIB_GLUE_VERSION)"'
 CFLAGS_mlx5_glue.o += -fPIC
@@ -525,7 +525,7 @@ $(SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD):.c=.o):

mlx5_autoconf.h # Generate dependency plug-in for rdma-core when the PMD must not be linked # directly, so that applications do not inherit this dependency.

drivers/net/mlx5/Makefile +1 -1
-ifeq ($(CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS),y)
+ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 
 $(LIB): $(LIB_GLUE)
drivers/net/mlx5/meson.build index renamed from drivers/net/mlx5/meson.build +0 -0

8ba19e818..a1130d610 100644

drivers/net/mlx5/meson.build +2 -2
@@ -2,12 +2,12 @@
 # Copyright 2018 6WIND S.A.
 # Copyright 2018 Mellanox Technologies, Ltd
 
-pmd_dlopen = get_option('enable_driver_mlx_glue')
+pmd_dlopen = (get_option('ibverbs_link') == 'dlopen')
 LIB_GLUE_BASE = 'librte_pmd_mlx5_glue.so'
 LIB_GLUE_VERSION = '19.02.0'
 LIB_GLUE = LIB_GLUE_BASE + '.' + LIB_GLUE_VERSION  if pmd_dlopen
-	dpdk_conf.set('RTE_LIBRTE_MLX5_DLOPEN_DEPS', 1)
+	dpdk_conf.set('RTE_IBVERBS_LINK_DLOPEN', 1)
 	cflags += [
 		'-DMLX5_GLUE="@0@"'.format(LIB_GLUE),
 		'-
 DMLX5_GLUE_VERSION="@0@"'.format(LIB_GLUE_VERSION),
drivers/net/mlx5/mlx5.c index renamed from drivers/net/mlx5/mlx5.c +0 -0

45210451d..f111e6ef8 100644

drivers/net/mlx5/mlx5.c +1 -1
@@ -1609,7 +1609,7 @@ static struct rte_pci_driver mlx5_driver = {
 		      RTE_PCI_DRV_PROBE_AGAIN),
 };
 
-#ifdef RTE_LIBRTE_MLX5_DLOPEN_DEPS
+#ifdef RTE_IBVERBS_LINK_DLOPEN
 
 /**
  * Suffix RTE_EAL_PMD_PATH with "-glue".
@@ -1770,7 +1770,7 @@ RTE_INIT(rte_mlx5_pmd_init)
 	 * cleanup all the Verbs resources even when the device was removed.
 	 */
 	setenv("MLX5_DEVICE_FATAL_CLEANUP", "1", 1); -#ifdef

RTE_LIBRTE_MLX5_DLOPEN_DEPS

drivers/net/mlx5/mlx5.c +1 -0
+#ifdef RTE_IBVERBS_LINK_DLOPEN
 	if (mlx5_glue_init())
 		return;
 	assert(mlx5_glue);
meson_options.txt index renamed from meson_options.txt +0 -0

10b541615..574054597 100644

meson_options.txt +0 -0
@@ -2,8 +2,8 @@ option('allow_invalid_socket_id', type: 'boolean', value:
 false,
 	description: 'allow out-of-range NUMA socket id\'s for platforms that
 don\'t report the value correctly')  option('drivers_install_subdir', type: 'string',
 value: 'dpdk/pmds-<VERSION>',
 	description: 'Subdirectory of libdir where to install PMDs. Defaults to

using a versioned subdirectory.') -option('enable_driver_mlx_glue', type:
'boolean', value: false,

meson_options.txt +1 -1
-	description: 'Enable glue library for Mellanox PMDs')
+option('ibverbs_link', type: 'combo', choices : ['shared', 'dlopen'], value:

'shared',

meson_options.txt +2 -0
+	description: 'Linkage method (shared/dlopen) for Mellanox PMDs with
+ibverbs dependencies.')
 option('enable_kmods', type: 'boolean', value: true,
 	description: 'build kernel modules')
 option('enable_docs', type: 'boolean', value: false, diff --git a/mk/rte.app.mk

b/mk/rte.app.mk index 02e8b6f05..d5b1ec6b7 100644

mk/rte.app.mk +7 -11
@@ -169,15 +169,14 @@ ifeq ($(CONFIG_RTE_LIBRTE_KNI),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_KNI)        += -lrte_pmd_kni
 endif
 _LDLIBS-$(CONFIG_RTE_LIBRTE_LIO_PMD)        += -lrte_pmd_lio
-ifeq ($(CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS),y)
-_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD)       += -lrte_pmd_mlx4 -ldl
+_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD)       += -lrte_pmd_mlx4
+_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD)       += -lrte_pmd_mlx5 -lmnl
+ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
+_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD)       += -ldl
+_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD)       += -ldl
 else
-_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD)       += -lrte_pmd_mlx4 -libverbs
-lmlx4
-endif
-ifeq ($(CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS),y)
-_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD)       += -lrte_pmd_mlx5 -ldl -lmnl
-else
-_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD)       += -lrte_pmd_mlx5 -libverbs
-lmlx5 -lmnl
+_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD)       += -libverbs -lmlx4
+_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD)       += -libverbs -lmlx5
 endif
 _LDLIBS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD)      += -lrte_pmd_mvpp2
 _LDLIBS-$(CONFIG_RTE_LIBRTE_MVNETA_PMD)     += -lrte_pmd_mvneta
--

2.20.1