[openib-general] [PATCH 3/7] libipathverbs: Update libipathverbs for new libibverbs driver handling

Roland Dreier rolandd at cisco.com
Wed Jan 10 14:12:44 PST 2007


The latest libibverbs development tree changes how low-level drivers
are found.  The driver must be in a shared object like
libipathverbs-rdmav2.so in the ordinary library path, rather than
infiniband/ipathverbs.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.

Since the current libipathverbs tree is targeted only for libibverbs
development trees and won't work with libibverbs 1.0, this patch
changes libipathverbs to work with the new libibverbs way of loading
drivers without any autoconf tests.

Signed-off-by: Roland Dreier <rolandd at cisco.com>
---
 Makefile.am           |   15 ++++++++-------
 configure.in          |   13 +++++++++++++
 ipathverbs.driver     |    1 +
 libipathverbs.spec.in |    5 +++--
 src/ipathverbs.c      |    9 +++++++--
 5 files changed, 32 insertions(+), 11 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index f86e1e2..c1ef44f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -32,11 +32,9 @@
 # combinations of this program with other software, or any other
 # product whatsoever.
 
-ipathverbslibdir = $(libdir)/infiniband
+lib_LTLIBRARIES = src/libipathverbs.la
 
-ipathverbslib_LTLIBRARIES = src/ipathverbs.la
-
-src_ipathverbs_la_CFLAGS = -Wall -D_GNU_SOURCE
+AM_CFLAGS = -Wall -D_GNU_SOURCE
 
 if HAVE_LD_VERSION_SCRIPT
     ipathverbs_version_script = -Wl,--version-script=$(srcdir)/src/ipathverbs.map
@@ -44,14 +42,17 @@ else
     ipathverbs_version_script =
 endif
 
-src_ipathverbs_la_SOURCES = src/ipathverbs.c src/verbs.c
-src_ipathverbs_la_LDFLAGS = -avoid-version -module \
+src_libipathverbs_la_SOURCES = src/ipathverbs.c src/verbs.c
+src_libipathverbs_la_LDFLAGS = -avoid-version -release @IBV_DEVICE_LIBRARY_EXTENSION@ \
     $(ipathverbs_version_script)
+ipathverbsconfdir = $(sysconfdir)/libibverbs.d
+ipathverbsconf_DATA = ipathverbs.driver
 
 EXTRA_DIST = src/ipathverbs.h \
     src/ipath-abi.h \
     src/ipathverbs.map \
-    libipathverbs.spec.in
+    libipathverbs.spec.in \
+    ipathverbs.driver
 
 dist-hook: libipathverbs.spec
 	cp libipathverbs.spec $(distdir)
diff --git a/configure.in b/configure.in
index 727cd65..ab1a86e 100644
--- a/configure.in
+++ b/configure.in
@@ -56,6 +56,19 @@ dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
 AC_CHECK_SIZEOF(long)
 
+dnl Now check if for libibverbs device library extension
+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
+if test $IBV_DEVICE_LIBRARY_EXTENSION = IBV_DEVICE_LIBRARY_EXTENSION; then
+    AC_MSG_ERROR([IBV_DEVICE_LIBRARY_EXTENSION not defined.  Is libibverbs new enough?])
+fi
+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
         ac_cv_version_script=yes
diff --git a/ipathverbs.driver b/ipathverbs.driver
new file mode 100644
index 0000000..d212578
--- /dev/null
+++ b/ipathverbs.driver
@@ -0,0 +1 @@
+driver ipathverbs
diff --git a/libipathverbs.spec.in b/libipathverbs.spec.in
index 4726102..1a4b2bd 100644
--- a/libipathverbs.spec.in
+++ b/libipathverbs.spec.in
@@ -77,9 +77,10 @@ rm -rf $RPM_BUILD_ROOT
 
 %files
 %defattr(-,root,root)
-%{_libdir}/infiniband/ipathverbs.so
+%{_libdir}/libipathverbs*.so
 %doc AUTHORS COPYING
+%config %{_sysconfdir}/libibverbs.d/ipathverbs.driver
 
 %files devel
 %defattr(-,root,root,-)
-%{_libdir}/infiniband/ipathverbs.a
+%{_libdir}/infiniband/libipathverbs*.a
diff --git a/src/ipathverbs.c b/src/ipathverbs.c
index d9fadca..22f2f48 100644
--- a/src/ipathverbs.c
+++ b/src/ipathverbs.c
@@ -165,8 +165,8 @@ static struct ibv_device_ops ipath_dev_ops = {
 	.free_context	= ipath_free_context
 };
 
-struct ibv_device *ibv_driver_init(const char *uverbs_sys_path,
-				   int abi_version)
+static struct ibv_device *ipathverbs_driver_init(const char *uverbs_sys_path,
+						 int abi_version)
 {
 	char			value[8];
 	struct ipath_device    *dev;
@@ -204,3 +204,8 @@ found:
 
 	return &dev->ibv_dev;
 }
+
+static __attribute__((constructor)) void ipathverbs_register_driver(void)
+{
+	ibv_register_driver("ipathverbs", ipathverbs_driver_init);
+}
-- 
1.4.4.1





More information about the general mailing list