[openib-general] [PATCH 6/7] libamso: Update libamso for new libibverbs driver handling
Roland Dreier
rolandd at cisco.com
Wed Jan 10 14:21:50 PST 2007
The latest libibverbs development tree changes how low-level drivers
are found. The driver must be in a shared object like
libamso-rdmav2.so in the ordinary library path, rather than
infiniband/amso.so as for libibverbs 1.0. In addition, the driver
must call ibv_register_driver() to pass its entry point to libibverbs,
rather than exporting an ibv_driver_init() function.
This patch adds autoconf tests to libamso to detect whether it is
being built against a stable libibverbs 1.0 tree or the new libibverbs
development tree. Then based on the result, it builds a library with
the appropriate name and with the correct driver initialization
handling.
Signed-off-by: Roland Dreier <rolandd at cisco.com>
---
Makefile.am | 25 +++++++++++++++----------
amso.driver | 1 +
configure.in | 15 +++++++++++++--
src/amso.c | 16 +++++++++++-----
4 files changed, 40 insertions(+), 17 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 9e2cbc1..d1749fd 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,10 +1,6 @@
# $Id: $
-amsolibdir = $(libdir)/infiniband
-
-amsolib_LTLIBRARIES = src/amso.la
-
-src_amso_la_CFLAGS = -g -Wall -D_GNU_SOURCE
+AM_CFLAGS = -g -Wall -D_GNU_SOURCE
if HAVE_LD_VERSION_SCRIPT
amso_version_script = -Wl,--version-script=$(srcdir)/src/amso.map
@@ -12,16 +8,25 @@ else
amso_version_script =
endif
-src_amso_la_SOURCES = src/cq.c src/amso.c src/qp.c \
- src/verbs.c
-src_amso_la_LDFLAGS = -avoid-version -module \
- $(amso_version_script)
+AMSO_SOURCES = src/cq.c src/amso.c src/qp.c src/verbs.c
+
+if HAVE_IBV_DEVICE_LIBRARY_EXTENSION
+ lib_LTLIBRARIES = src/libamso.la
+ src_libamso_la_SOURCES = $(AMSO_SOURCES)
+ src_libamso_la_LDFLAGS = -avoid-version -release @IBV_DEVICE_LIBRARY_EXTENSION@ \
+ $(amso_version_script)
+else
+ amsolibdir = $(libdir)/infiniband
+ amsolib_LTLIBRARIES = src/amso.la
+ src_amso_la_SOURCES = $(AMSO_SOURCES)
+ src_amso_la_LDFLAGS = -avoid-version -module $(amso_version_script)
+endif
#DEBIAN = debian/changelog debian/compat debian/control debian/copyright \
# debian/libamso1.install debian/libamso-dev.install debian/rules
EXTRA_DIST = src/amso.h src/amso-abi.h \
- src/amso.map libamso.spec.in $(DEBIAN)
+ src/amso.map libamso.spec.in amso.driver
dist-hook: libamso.spec
cp libamso.spec $(distdir)
diff --git a/amso.driver b/amso.driver
new file mode 100644
index 0000000..272dcc2
--- /dev/null
+++ b/amso.driver
@@ -0,0 +1 @@
+driver amso
diff --git a/configure.in b/configure.in
index 4a920c4..d3344d2 100644
--- a/configure.in
+++ b/configure.in
@@ -16,7 +16,6 @@ AC_CHECK_LIB(ibverbs, ibv_get_device_list, [],
AC_MSG_ERROR([ibv_get_device_list() not found. libmthca requires libibverbs.]))
dnl Checks for header files.
-AC_CHECK_HEADERS(sysfs/libsysfs.h)
AC_CHECK_HEADER(infiniband/driver.h, [],
AC_MSG_ERROR([<infiniband/driver.h> not found. Is libibverbs installed?]))
AC_HEADER_STDC
@@ -26,7 +25,19 @@ AC_C_CONST
AC_CHECK_SIZEOF(long)
dnl Checks for library functions
-AC_CHECK_FUNCS(ibv_read_sysfs_file)
+AC_CHECK_FUNCS(ibv_read_sysfs_file ibv_register_driver)
+
+dnl Now check if for libibverbs 1.0 vs 1.1
+dummy=if$$
+cat <<IBV_VERSION > $dummy.c
+#include <infiniband/driver.h>
+IBV_DEVICE_LIBRARY_EXTENSION
+IBV_VERSION
+IBV_DEVICE_LIBRARY_EXTENSION=`$CC $CPPFLAGS -E $dummy.c 2> /dev/null | tail -1`
+rm -f $dummy.c
+AM_CONDITIONAL(HAVE_IBV_DEVICE_LIBRARY_EXTENSION,
+ test $IBV_DEVICE_LIBRARY_EXTENSION != IBV_DEVICE_LIBRARY_EXTENSION)
+AC_SUBST(IBV_DEVICE_LIBRARY_EXTENSION)
AC_CACHE_CHECK(whether ld accepts --version-script, ac_cv_version_script,
if test -n "`$LD --help < /dev/null 2>/dev/null | grep version-script`"; then
diff --git a/src/amso.c b/src/amso.c
index 60a44d1..bae4220 100644
--- a/src/amso.c
+++ b/src/amso.c
@@ -40,7 +40,7 @@
#include <sys/mman.h>
#include <pthread.h>
-#ifdef HAVE_SYSFS_LIBSYSFS_H
+#ifndef HAVE_IBV_REGISTER_DRIVER
#include <sysfs/libsysfs.h>
#endif
@@ -135,8 +135,8 @@ static struct ibv_device_ops amso_dev_ops = {
.free_context = amso_free_context
};
-struct ibv_device *ibv_driver_init(const char *uverbs_sys_path,
- int abi_version)
+static struct ibv_device *amso_driver_init(const char *uverbs_sys_path,
+ int abi_version)
{
char value[8];
struct amso_device *dev;
@@ -174,7 +174,13 @@ found:
return &dev->ibv_dev;
}
-#ifdef HAVE_SYSFS_LIBSYSFS_H
+
+#ifdef HAVE_IBV_REGISTER_DRIVER
+static __attribute__((constructor)) void amso_register_driver(void)
+{
+ ibv_register_driver("amso", amso_driver_init);
+}
+#else
struct ibv_device *openib_driver_init(struct sysfs_class_device *sysdev)
{
int abi_ver = 0;
@@ -186,4 +192,4 @@ struct ibv_device *openib_driver_init(struct sysfs_class_device *sysdev)
return ibv_driver_init(sysdev->path, abi_ver);
}
-#endif /* HAVE_SYSFS_LIBSYSFS_H */
+#endif /* HAVE_IBV_REGISTER_DRIVER */
--
1.4.4.1
More information about the general
mailing list