[v3] common/mlx5: fix dynamic loading reference

Message ID 1583504839-11329-1-git-send-email-xiangxia.m.yue@gmail.com (mailing list archive)
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers
Series [v3] common/mlx5: fix dynamic loading reference |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/Intel-compilation success Compilation OK

Commit Message

Tonghao Zhang March 6, 2020, 2:27 p.m. UTC
  From: Tonghao Zhang <xiangxia.m.yue@gmail.com>

When setting the CONFIG_RTE_BUILD_SHARED_LIB to y,
and build the mlx5 pmd, there is a building error.
To fix it, add RTE_IBVERBS_LINK_DLOPEN to include
relative codes.

    mlx5_common.o: In function `mlx5_glue_init':
    drivers/common/mlx5/mlx5_common.c:324: undefined reference to `dlclose'

Fixes: 7b4f1e6bd367 ("common/mlx5: introduce common library")
Cc: stable@dpdk.org

Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
Tested-by: Ali Alnubani <alialnu@mellanox.com>
---
v3:
* rename the patch title
* mv the dlfcn.h to define area
* tested: https://travis-ci.com/ovn-open-virtual-networks/dpdk-next-net/builds/151882661

v2:
* change the patch title
---
 drivers/common/mlx5/mlx5_common.c | 10 +++++++---
 drivers/net/mlx4/mlx4.c           |  4 +++-
 2 files changed, 10 insertions(+), 4 deletions(-)
  

Comments

Matan Azrad March 8, 2020, 6:39 a.m. UTC | #1
From: xiangxia.m.yue@gmail.com
> From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> 
> When setting the CONFIG_RTE_BUILD_SHARED_LIB to y, and build the mlx5
> pmd, there is a building error.
> To fix it, add RTE_IBVERBS_LINK_DLOPEN to include relative codes.
> 
>     mlx5_common.o: In function `mlx5_glue_init':
>     drivers/common/mlx5/mlx5_common.c:324: undefined reference to
> `dlclose'
> 
> Fixes: 7b4f1e6bd367 ("common/mlx5: introduce common library")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> Tested-by: Ali Alnubani <alialnu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
  
Raslan Darawsheh March 9, 2020, 9:10 a.m. UTC | #2
Hi,

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of
> xiangxia.m.yue@gmail.com
> Sent: Friday, March 6, 2020 4:27 PM
> To: Matan Azrad <matan@mellanox.com>; Ali Alnubani
> <alialnu@mellanox.com>
> Cc: dev@dpdk.org; Tonghao Zhang <xiangxia.m.yue@gmail.com>;
> stable@dpdk.org
> Subject: [dpdk-dev] [PATCH dpdk-dev v3] common/mlx5: fix dynamic loading
> reference
> 
> From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> 
> When setting the CONFIG_RTE_BUILD_SHARED_LIB to y,
> and build the mlx5 pmd, there is a building error.
> To fix it, add RTE_IBVERBS_LINK_DLOPEN to include
> relative codes.
> 
>     mlx5_common.o: In function `mlx5_glue_init':
>     drivers/common/mlx5/mlx5_common.c:324: undefined reference to
> `dlclose'
> 
> Fixes: 7b4f1e6bd367 ("common/mlx5: introduce common library")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> Tested-by: Ali Alnubani <alialnu@mellanox.com>
> ---
> v3:
> * rename the patch title
> * mv the dlfcn.h to define area
> * tested:
> https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Ftravis
> -ci.com%2Fovn-open-virtual-networks%2Fdpdk-next-
> net%2Fbuilds%2F151882661&amp;data=02%7C01%7Crasland%40mellanox.co
> m%7Cc089a6504673460ee42c08d7c1da91c5%7Ca652971c7d2e4d9ba6a4d1492
> 56f461b%7C0%7C0%7C637191016800944332&amp;sdata=AL6s1X0NFyBtAi%2
> BfFS%2FwB41xHZBUQsvDUZ5%2FWucJTd0%3D&amp;reserved=0
> 
> v2:
> * change the patch title
> ---
>  drivers/common/mlx5/mlx5_common.c | 10 +++++++---
>  drivers/net/mlx4/mlx4.c           |  4 +++-
>  2 files changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/common/mlx5/mlx5_common.c
> b/drivers/common/mlx5/mlx5_common.c
> index 610fb48..9ea56f2 100644
> --- a/drivers/common/mlx5/mlx5_common.c
> +++ b/drivers/common/mlx5/mlx5_common.c
> @@ -2,10 +2,12 @@
>   * Copyright 2019 Mellanox Technologies, Ltd
>   */
> 

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh
  

Patch

diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c
index 610fb48..9ea56f2 100644
--- a/drivers/common/mlx5/mlx5_common.c
+++ b/drivers/common/mlx5/mlx5_common.c
@@ -2,10 +2,12 @@ 
  * Copyright 2019 Mellanox Technologies, Ltd
  */
 
-#include <dlfcn.h>
 #include <unistd.h>
 #include <string.h>
 #include <stdio.h>
+#ifdef RTE_IBVERBS_LINK_DLOPEN
+#include <dlfcn.h>
+#endif
 
 #include <rte_errno.h>
 
@@ -209,8 +211,6 @@  enum mlx5_class
  */
 RTE_INIT_PRIO(mlx5_glue_init, CLASS)
 {
-	void *handle = NULL;
-
 	/* Initialize common log type. */
 	mlx5_common_logtype = rte_log_register("pmd.common.mlx5");
 	if (mlx5_common_logtype >= 0)
@@ -233,6 +233,8 @@  enum mlx5_class
 	/* The glue initialization was done earlier by mlx5 common library. */
 #ifdef RTE_IBVERBS_LINK_DLOPEN
 	char glue_path[sizeof(RTE_EAL_PMD_PATH) - 1 + sizeof("-glue")];
+	void *handle = NULL;
+
 	const char *path[] = {
 		/*
 		 * A basic security check is necessary before trusting
@@ -320,8 +322,10 @@  enum mlx5_class
 	mlx5_glue->fork_init();
 	return;
 glue_error:
+#ifdef RTE_IBVERBS_LINK_DLOPEN
 	if (handle)
 		dlclose(handle);
+#endif
 	DRV_LOG(WARNING, "Cannot initialize MLX5 common due to missing"
 		" run-time dependency on rdma-core libraries (libibverbs,"
 		" libmlx5)");
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index a1dd658..8e29878 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -8,7 +8,6 @@ 
  * mlx4 driver initialization.
  */
 
-#include <dlfcn.h>
 #include <errno.h>
 #include <inttypes.h>
 #include <stddef.h>
@@ -18,6 +17,9 @@ 
 #include <string.h>
 #include <sys/mman.h>
 #include <unistd.h>
+#ifdef RTE_IBVERBS_LINK_DLOPEN
+#include <dlfcn.h>
+#endif
 
 /* Verbs headers do not support -pedantic. */
 #ifdef PEDANTIC