|
|
a6040a |
From 4e2ccd92941f2865efa749169e7f77064f501121 Mon Sep 17 00:00:00 2001
|
|
|
a6040a |
From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
|
|
|
a6040a |
Date: Thu, 1 Feb 2018 14:30:57 +0100
|
|
|
a6040a |
Subject: [PATCH 7/9] net/mlx: version rdma-core glue libraries
|
|
|
a6040a |
|
|
|
a6040a |
When built as separate objects, these libraries do not have unique names.
|
|
|
a6040a |
Since they do not maintain a stable ABI, loading an incompatible library
|
|
|
a6040a |
may result in a crash (e.g. in case multiple versions are installed).
|
|
|
a6040a |
|
|
|
a6040a |
This patch addresses the above by versioning glue libraries, both on the
|
|
|
a6040a |
file system (version suffix) and by comparing a dedicated version field
|
|
|
a6040a |
member in glue structures.
|
|
|
a6040a |
|
|
|
a6040a |
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
|
|
|
a6040a |
(cherry picked from commit a193e731131f460d3c2d59cac0b4f1a34eac92d2)
|
|
|
a6040a |
---
|
|
|
a6040a |
drivers/net/mlx4/Makefile | 8 ++++++--
|
|
|
a6040a |
drivers/net/mlx4/mlx4.c | 5 +++++
|
|
|
a6040a |
drivers/net/mlx4/mlx4_glue.c | 1 +
|
|
|
a6040a |
drivers/net/mlx4/mlx4_glue.h | 6 ++++++
|
|
|
a6040a |
drivers/net/mlx5/Makefile | 8 ++++++--
|
|
|
a6040a |
drivers/net/mlx5/mlx5.c | 5 +++++
|
|
|
a6040a |
drivers/net/mlx5/mlx5_glue.c | 1 +
|
|
|
a6040a |
drivers/net/mlx5/mlx5_glue.h | 6 ++++++
|
|
|
a6040a |
8 files changed, 36 insertions(+), 4 deletions(-)
|
|
|
a6040a |
|
|
|
a6040a |
diff --git a/drivers/net/mlx4/Makefile b/drivers/net/mlx4/Makefile
|
|
|
a6040a |
index 60ee120..d24565c 100644
|
|
|
a6040a |
--- a/drivers/net/mlx4/Makefile
|
|
|
a6040a |
+++ b/drivers/net/mlx4/Makefile
|
|
|
a6040a |
@@ -33,7 +33,9 @@ include $(RTE_SDK)/mk/rte.vars.mk
|
|
|
a6040a |
|
|
|
a6040a |
# Library name.
|
|
|
a6040a |
LIB = librte_pmd_mlx4.a
|
|
|
a6040a |
-LIB_GLUE = librte_pmd_mlx4_glue.so
|
|
|
a6040a |
+LIB_GLUE = $(LIB_GLUE_BASE).$(LIB_GLUE_VERSION)
|
|
|
a6040a |
+LIB_GLUE_BASE = librte_pmd_mlx4_glue.so
|
|
|
a6040a |
+LIB_GLUE_VERSION = 17.11.1
|
|
|
a6040a |
|
|
|
a6040a |
# Sources.
|
|
|
a6040a |
SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4.c
|
|
|
a6040a |
@@ -64,6 +66,7 @@ CFLAGS += -D_XOPEN_SOURCE=600
|
|
|
a6040a |
CFLAGS += $(WERROR_FLAGS)
|
|
|
a6040a |
ifeq ($(CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS),y)
|
|
|
a6040a |
CFLAGS += -DMLX4_GLUE='"$(LIB_GLUE)"'
|
|
|
a6040a |
+CFLAGS += -DMLX4_GLUE_VERSION='"$(LIB_GLUE_VERSION)"'
|
|
|
a6040a |
CFLAGS_mlx4_glue.o += -fPIC
|
|
|
a6040a |
LDLIBS += -ldl
|
|
|
a6040a |
else
|
|
|
a6040a |
@@ -135,6 +138,7 @@ $(LIB): $(LIB_GLUE)
|
|
|
a6040a |
|
|
|
a6040a |
$(LIB_GLUE): mlx4_glue.o
|
|
|
a6040a |
$Q $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) \
|
|
|
a6040a |
+ -Wl,-h,$(LIB_GLUE) \
|
|
|
a6040a |
-s -shared -o $@ $< -libverbs -lmlx4
|
|
|
a6040a |
|
|
|
a6040a |
mlx4_glue.o: mlx4_autoconf.h
|
|
|
a6040a |
@@ -143,6 +147,6 @@ endif
|
|
|
a6040a |
|
|
|
a6040a |
clean_mlx4: FORCE
|
|
|
a6040a |
$Q rm -f -- mlx4_autoconf.h mlx4_autoconf.h.new
|
|
|
a6040a |
- $Q rm -f -- mlx4_glue.o $(LIB_GLUE)
|
|
|
a6040a |
+ $Q rm -f -- mlx4_glue.o $(LIB_GLUE_BASE)*
|
|
|
a6040a |
|
|
|
a6040a |
clean: clean_mlx4
|
|
|
a6040a |
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
|
|
|
a6040a |
index 43d1b0a..e41acf1 100644
|
|
|
a6040a |
--- a/drivers/net/mlx4/mlx4.c
|
|
|
a6040a |
+++ b/drivers/net/mlx4/mlx4.c
|
|
|
a6040a |
@@ -773,6 +773,11 @@ struct mlx4_conf {
|
|
|
a6040a |
assert(((const void *const *)mlx4_glue)[i]);
|
|
|
a6040a |
}
|
|
|
a6040a |
#endif
|
|
|
a6040a |
+ if (strcmp(mlx4_glue->version, MLX4_GLUE_VERSION)) {
|
|
|
a6040a |
+ ERROR("rdma-core glue \"%s\" mismatch: \"%s\" is required",
|
|
|
a6040a |
+ mlx4_glue->version, MLX4_GLUE_VERSION);
|
|
|
a6040a |
+ return;
|
|
|
a6040a |
+ }
|
|
|
a6040a |
mlx4_glue->fork_init();
|
|
|
a6040a |
rte_pci_register(&mlx4_driver);
|
|
|
a6040a |
}
|
|
|
a6040a |
diff --git a/drivers/net/mlx4/mlx4_glue.c b/drivers/net/mlx4/mlx4_glue.c
|
|
|
a6040a |
index 47ae7ad..3b79d32 100644
|
|
|
a6040a |
--- a/drivers/net/mlx4/mlx4_glue.c
|
|
|
a6040a |
+++ b/drivers/net/mlx4/mlx4_glue.c
|
|
|
a6040a |
@@ -240,6 +240,7 @@
|
|
|
a6040a |
}
|
|
|
a6040a |
|
|
|
a6040a |
const struct mlx4_glue *mlx4_glue = &(const struct mlx4_glue){
|
|
|
a6040a |
+ .version = MLX4_GLUE_VERSION,
|
|
|
a6040a |
.fork_init = mlx4_glue_fork_init,
|
|
|
a6040a |
.get_async_event = mlx4_glue_get_async_event,
|
|
|
a6040a |
.ack_async_event = mlx4_glue_ack_async_event,
|
|
|
a6040a |
diff --git a/drivers/net/mlx4/mlx4_glue.h b/drivers/net/mlx4/mlx4_glue.h
|
|
|
a6040a |
index de251c6..368f906 100644
|
|
|
a6040a |
--- a/drivers/net/mlx4/mlx4_glue.h
|
|
|
a6040a |
+++ b/drivers/net/mlx4/mlx4_glue.h
|
|
|
a6040a |
@@ -19,7 +19,13 @@
|
|
|
a6040a |
#pragma GCC diagnostic error "-Wpedantic"
|
|
|
a6040a |
#endif
|
|
|
a6040a |
|
|
|
a6040a |
+#ifndef MLX4_GLUE_VERSION
|
|
|
a6040a |
+#define MLX4_GLUE_VERSION ""
|
|
|
a6040a |
+#endif
|
|
|
a6040a |
+
|
|
|
a6040a |
+/* LIB_GLUE_VERSION must be updated every time this structure is modified. */
|
|
|
a6040a |
struct mlx4_glue {
|
|
|
a6040a |
+ const char *version;
|
|
|
a6040a |
int (*fork_init)(void);
|
|
|
a6040a |
int (*get_async_event)(struct ibv_context *context,
|
|
|
a6040a |
struct ibv_async_event *event);
|
|
|
a6040a |
diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile
|
|
|
a6040a |
index 4b20d71..e75190e 100644
|
|
|
a6040a |
--- a/drivers/net/mlx5/Makefile
|
|
|
a6040a |
+++ b/drivers/net/mlx5/Makefile
|
|
|
a6040a |
@@ -33,7 +33,9 @@ include $(RTE_SDK)/mk/rte.vars.mk
|
|
|
a6040a |
|
|
|
a6040a |
# Library name.
|
|
|
a6040a |
LIB = librte_pmd_mlx5.a
|
|
|
a6040a |
-LIB_GLUE = librte_pmd_mlx5_glue.so
|
|
|
a6040a |
+LIB_GLUE = $(LIB_GLUE_BASE).$(LIB_GLUE_VERSION)
|
|
|
a6040a |
+LIB_GLUE_BASE = librte_pmd_mlx5_glue.so
|
|
|
a6040a |
+LIB_GLUE_VERSION = 17.11.1
|
|
|
a6040a |
|
|
|
a6040a |
# Sources.
|
|
|
a6040a |
SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5.c
|
|
|
a6040a |
@@ -74,6 +76,7 @@ CFLAGS += $(WERROR_FLAGS)
|
|
|
a6040a |
CFLAGS += -Wno-strict-prototypes
|
|
|
a6040a |
ifeq ($(CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS),y)
|
|
|
a6040a |
CFLAGS += -DMLX5_GLUE='"$(LIB_GLUE)"'
|
|
|
a6040a |
+CFLAGS += -DMLX5_GLUE_VERSION='"$(LIB_GLUE_VERSION)"'
|
|
|
a6040a |
CFLAGS_mlx5_glue.o += -fPIC
|
|
|
a6040a |
LDLIBS += -ldl
|
|
|
a6040a |
else
|
|
|
a6040a |
@@ -180,6 +183,7 @@ $(LIB): $(LIB_GLUE)
|
|
|
a6040a |
|
|
|
a6040a |
$(LIB_GLUE): mlx5_glue.o
|
|
|
a6040a |
$Q $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) \
|
|
|
a6040a |
+ -Wl,-h,$(LIB_GLUE) \
|
|
|
a6040a |
-s -shared -o $@ $< -libverbs -lmlx5
|
|
|
a6040a |
|
|
|
a6040a |
mlx5_glue.o: mlx5_autoconf.h
|
|
|
a6040a |
@@ -188,6 +192,6 @@ endif
|
|
|
a6040a |
|
|
|
a6040a |
clean_mlx5: FORCE
|
|
|
a6040a |
$Q rm -f -- mlx5_autoconf.h mlx5_autoconf.h.new
|
|
|
a6040a |
- $Q rm -f -- mlx5_glue.o $(LIB_GLUE)
|
|
|
a6040a |
+ $Q rm -f -- mlx5_glue.o $(LIB_GLUE_BASE)*
|
|
|
a6040a |
|
|
|
a6040a |
clean: clean_mlx5
|
|
|
a6040a |
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
|
|
|
a6040a |
index 6a3746d..6618d2c 100644
|
|
|
a6040a |
--- a/drivers/net/mlx5/mlx5.c
|
|
|
a6040a |
+++ b/drivers/net/mlx5/mlx5.c
|
|
|
a6040a |
@@ -1099,6 +1099,11 @@ struct mlx5_args {
|
|
|
a6040a |
assert(((const void *const *)mlx5_glue)[i]);
|
|
|
a6040a |
}
|
|
|
a6040a |
#endif
|
|
|
a6040a |
+ if (strcmp(mlx5_glue->version, MLX5_GLUE_VERSION)) {
|
|
|
a6040a |
+ ERROR("rdma-core glue \"%s\" mismatch: \"%s\" is required",
|
|
|
a6040a |
+ mlx5_glue->version, MLX5_GLUE_VERSION);
|
|
|
a6040a |
+ return;
|
|
|
a6040a |
+ }
|
|
|
a6040a |
mlx5_glue->fork_init();
|
|
|
a6040a |
rte_pci_register(&mlx5_driver);
|
|
|
a6040a |
}
|
|
|
a6040a |
diff --git a/drivers/net/mlx5/mlx5_glue.c b/drivers/net/mlx5/mlx5_glue.c
|
|
|
a6040a |
index ff48c1e..eba0ca0 100644
|
|
|
a6040a |
--- a/drivers/net/mlx5/mlx5_glue.c
|
|
|
a6040a |
+++ b/drivers/net/mlx5/mlx5_glue.c
|
|
|
a6040a |
@@ -314,6 +314,7 @@
|
|
|
a6040a |
}
|
|
|
a6040a |
|
|
|
a6040a |
const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue){
|
|
|
a6040a |
+ .version = MLX5_GLUE_VERSION,
|
|
|
a6040a |
.fork_init = mlx5_glue_fork_init,
|
|
|
a6040a |
.alloc_pd = mlx5_glue_alloc_pd,
|
|
|
a6040a |
.dealloc_pd = mlx5_glue_dealloc_pd,
|
|
|
a6040a |
diff --git a/drivers/net/mlx5/mlx5_glue.h b/drivers/net/mlx5/mlx5_glue.h
|
|
|
a6040a |
index a2cd18e..0e6e65f 100644
|
|
|
a6040a |
--- a/drivers/net/mlx5/mlx5_glue.h
|
|
|
a6040a |
+++ b/drivers/net/mlx5/mlx5_glue.h
|
|
|
a6040a |
@@ -19,6 +19,10 @@
|
|
|
a6040a |
#pragma GCC diagnostic error "-Wpedantic"
|
|
|
a6040a |
#endif
|
|
|
a6040a |
|
|
|
a6040a |
+#ifndef MLX5_GLUE_VERSION
|
|
|
a6040a |
+#define MLX5_GLUE_VERSION ""
|
|
|
a6040a |
+#endif
|
|
|
a6040a |
+
|
|
|
a6040a |
#ifndef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT
|
|
|
a6040a |
struct ibv_counter_set;
|
|
|
a6040a |
struct ibv_counter_set_data;
|
|
|
a6040a |
@@ -27,7 +31,9 @@
|
|
|
a6040a |
struct ibv_query_counter_set_attr;
|
|
|
a6040a |
#endif
|
|
|
a6040a |
|
|
|
a6040a |
+/* LIB_GLUE_VERSION must be updated every time this structure is modified. */
|
|
|
a6040a |
struct mlx5_glue {
|
|
|
a6040a |
+ const char *version;
|
|
|
a6040a |
int (*fork_init)(void);
|
|
|
a6040a |
struct ibv_pd *(*alloc_pd)(struct ibv_context *context);
|
|
|
a6040a |
int (*dealloc_pd)(struct ibv_pd *pd);
|
|
|
a6040a |
--
|
|
|
a6040a |
1.8.3.1
|
|
|
a6040a |
|