From: Thomas Monjalon <thomas@monjalon.net>
To: dev@dpdk.org
Cc: Matan Azrad <matan@mellanox.com>,
Shahaf Shuler <shahafs@mellanox.com>,
Viacheslav Ovsiienko <viacheslavo@mellanox.com>
Subject: [dpdk-dev] [PATCH 1/3] common/mlx5: split glue initialization
Date: Mon, 10 Feb 2020 11:32:14 +0100 [thread overview]
Message-ID: <20200210103216.1168439-2-thomas@monjalon.net> (raw)
In-Reply-To: <20200210103216.1168439-1-thomas@monjalon.net>
The function mlx5_glue_init was doing three things:
- initialize logs
- load glue library if in dlopen mode
- initialize glue layer
They are split in three functions for clarity.
The config option RTE_IBVERBS_LINK_DLOPEN is not used anymore
outside of make and meson files. It is replaced with MLX5_GLUE,
which is defined in the same condition and is already used with dlopen.
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
drivers/common/mlx5/mlx5_common.c | 77 +++++++++++++++++++------------
1 file changed, 47 insertions(+), 30 deletions(-)
diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c
index 610fb480b5..f96506c27a 100644
--- a/drivers/common/mlx5/mlx5_common.c
+++ b/drivers/common/mlx5/mlx5_common.c
@@ -160,7 +160,7 @@ mlx5_translate_port_name(const char *port_name_in,
return;
}
-#ifdef RTE_IBVERBS_LINK_DLOPEN
+#ifdef MLX5_GLUE
/**
* Suffix RTE_EAL_PMD_PATH with "-glue".
@@ -202,36 +202,12 @@ mlx5_glue_path(char *buf, size_t size)
" re-configure DPDK");
return NULL;
}
-#endif
-/**
- * Initialization routine for run-time dependency on rdma-core.
- */
-RTE_INIT_PRIO(mlx5_glue_init, CLASS)
+static int
+mlx5_glue_dlopen(void)
{
void *handle = NULL;
- /* Initialize common log type. */
- mlx5_common_logtype = rte_log_register("pmd.common.mlx5");
- if (mlx5_common_logtype >= 0)
- rte_log_set_level(mlx5_common_logtype, RTE_LOG_NOTICE);
- /*
- * RDMAV_HUGEPAGES_SAFE tells ibv_fork_init() we intend to use
- * huge pages. Calling ibv_fork_init() during init allows
- * applications to use fork() safely for purposes other than
- * using this PMD, which is not supported in forked processes.
- */
- setenv("RDMAV_HUGEPAGES_SAFE", "1", 1);
- /* Match the size of Rx completion entry to the size of a cacheline. */
- if (RTE_CACHE_LINE_SIZE == 128)
- setenv("MLX5_CQE_SIZE", "128", 0);
- /*
- * MLX5_DEVICE_FATAL_CLEANUP tells ibv_destroy functions to
- * cleanup all the Verbs resources even when the device was removed.
- */
- setenv("MLX5_DEVICE_FATAL_CLEANUP", "1", 1);
- /* 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")];
const char *path[] = {
/*
@@ -301,7 +277,49 @@ RTE_INIT_PRIO(mlx5_glue_init, CLASS)
goto glue_error;
}
mlx5_glue = *sym;
-#endif /* RTE_IBVERBS_LINK_DLOPEN */
+ return 0;
+
+glue_error:
+ if (handle)
+ dlclose(handle);
+ return -1;
+}
+
+#endif
+
+RTE_INIT_PRIO(mlx5_log_init, LOG)
+{
+ mlx5_common_logtype = rte_log_register("pmd.common.mlx5");
+ if (mlx5_common_logtype >= 0)
+ rte_log_set_level(mlx5_common_logtype, RTE_LOG_NOTICE);
+}
+
+/**
+ * Initialization routine for run-time dependency on rdma-core.
+ */
+RTE_INIT_PRIO(mlx5_glue_init, CLASS)
+{
+ /*
+ * RDMAV_HUGEPAGES_SAFE tells ibv_fork_init() we intend to use
+ * huge pages. Calling ibv_fork_init() during init allows
+ * applications to use fork() safely for purposes other than
+ * using this PMD, which is not supported in forked processes.
+ */
+ setenv("RDMAV_HUGEPAGES_SAFE", "1", 1);
+ /* Match the size of Rx completion entry to the size of a cacheline. */
+ if (RTE_CACHE_LINE_SIZE == 128)
+ setenv("MLX5_CQE_SIZE", "128", 0);
+ /*
+ * MLX5_DEVICE_FATAL_CLEANUP tells ibv_destroy functions to
+ * cleanup all the Verbs resources even when the device was removed.
+ */
+ setenv("MLX5_DEVICE_FATAL_CLEANUP", "1", 1);
+
+#ifdef MLX5_GLUE
+ if (mlx5_glue_dlopen() != 0)
+ goto glue_error;
+#endif
+
#ifdef RTE_LIBRTE_MLX5_DEBUG
/* Glue structure must not contain any NULL pointers. */
{
@@ -319,9 +337,8 @@ RTE_INIT_PRIO(mlx5_glue_init, CLASS)
}
mlx5_glue->fork_init();
return;
+
glue_error:
- if (handle)
- dlclose(handle);
DRV_LOG(WARNING, "Cannot initialize MLX5 common due to missing"
" run-time dependency on rdma-core libraries (libibverbs,"
" libmlx5)");
--
2.25.0
next prev parent reply other threads:[~2020-02-10 10:32 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-10 10:32 [dpdk-dev] [PATCH 0/3] mlx: fix build with -fno-common (gcc 10) Thomas Monjalon
2020-02-10 10:32 ` Thomas Monjalon [this message]
2020-02-10 10:32 ` [dpdk-dev] [PATCH 2/3] common/mlx5: fix build with -fno-common Thomas Monjalon
2020-02-10 10:32 ` [dpdk-dev] [PATCH 3/3] net/mlx4: " Thomas Monjalon
2020-03-17 8:34 ` [dpdk-dev] [PATCH 0/3] mlx: fix build with -fno-common (gcc 10) Matan Azrad
2020-04-07 0:19 ` Thomas Monjalon
2020-04-07 23:06 ` [dpdk-dev] [PATCH v2 " Thomas Monjalon
2020-04-07 23:06 ` [dpdk-dev] [PATCH v2 1/3] common/mlx5: split glue initialization Thomas Monjalon
2020-04-07 23:06 ` [dpdk-dev] [PATCH v2 2/3] common/mlx5: fix build with -fno-common Thomas Monjalon
2020-04-07 23:06 ` [dpdk-dev] [PATCH v2 3/3] net/mlx4: " Thomas Monjalon
2020-04-08 0:08 ` [dpdk-dev] [PATCH v3 0/3] mlx: fix build with -fno-common (gcc 10) Thomas Monjalon
2020-04-08 0:08 ` [dpdk-dev] [PATCH v3 1/3] common/mlx5: split glue initialization Thomas Monjalon
2020-04-08 0:08 ` [dpdk-dev] [PATCH v3 2/3] common/mlx5: fix build with -fno-common Thomas Monjalon
2020-04-08 0:09 ` [dpdk-dev] [PATCH v3 3/3] net/mlx4: " Thomas Monjalon
2020-04-12 15:51 ` [dpdk-dev] [PATCH v3 0/3] mlx: fix build with -fno-common (gcc 10) Raslan Darawsheh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200210103216.1168439-2-thomas@monjalon.net \
--to=thomas@monjalon.net \
--cc=dev@dpdk.org \
--cc=matan@mellanox.com \
--cc=shahafs@mellanox.com \
--cc=viacheslavo@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).