[openib-general] [PATCH 5/7] libehca: Update libehca 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
libehca-rdmav2.so in the ordinary library path, rather than
infiniband/libehca.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 libehca 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      |   30 +++++++++++++++++++-----------
 config.h.in      |    6 +++---
 configure.in     |   15 +++++++++++++--
 ehca.driver      |    1 +
 src/ehca_uinit.c |   12 +++++++++---
 5 files changed, 45 insertions(+), 19 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 46d639c..ca44a45 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -37,18 +37,25 @@
 #  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 #  POSSIBILITY OF SUCH DAMAGE.
     
+AM_CFLAGS = -O2 -g -Wall -D_GNU_SOURCE -DP_SERIES -Isrc
 
-ehcalibdir = $(libdir)/infiniband
+EHCA_SOURCES = src/ehca_umain.c src/ehca_u_mrmw.c src/ehca_uinit.c \
+	src/ehca_ureqs.c src/hcp_phyp.c
 
-ehcalib_LTLIBRARIES = src/libehca.la
-
-src_libehca_la_SOURCES = src/ehca_umain.c src/ehca_u_mrmw.c src/ehca_uinit.c src/ehca_ureqs.c  src/hcp_phyp.c
-
-src_libehca_la_CFLAGS = -O2 -g -Wall  -D_GNU_SOURCE -DP_SERIES -I../libibverbs/include -Isrc
-
-src_libehca_la_LDFLAGS = -version-info 1 -export-dynamic \
-			-Wl,--version-script=$(srcdir)/src/libehca.map \
-			-lpthread -libverbs -nostdlib
+if HAVE_IBV_DEVICE_LIBRARY_EXTENSION
+    lib_LTLIBRARIES = src/libehca.la
+    src_libehca_la_SOURCES = $(EHCA_SOURCES)
+    src_libehca_la_LDFLAGS = -avoid-version -release @IBV_DEVICE_LIBRARY_EXTENSION@ \
+				-Wl,--version-script=$(srcdir)/src/libehca.map \
+				-lpthread -libverbs -nostdlib
+else
+    ehcalibdir = $(libdir)/infiniband
+    ehcalib_LTLIBRARIES = src/libehca.la
+    src_libehca_la_SOURCES = $(EHCA_SOURCES)
+    src_libehca_la_LDFLAGS = -version-info 1 -export-dynamic \
+				-Wl,--version-script=$(srcdir)/src/libehca.map \
+				-lpthread -libverbs -nostdlib
+endif
 
 EXTRA_DIST = src/ehca_asm.h \
 	src/ehca_galpa.h \
@@ -59,7 +66,8 @@ EXTRA_DIST = src/ehca_asm.h \
 	src/ehca_qes.h \
 	src/ehca_utools.h \
 	src/hipz_hw.h \
-	src/libehca.map
+	src/libehca.map \
+	src/ehca.driver
 
 # dist-hook: libehca.spec
 #     cp libehca.spec $(distdir)
diff --git a/config.h.in b/config.h.in
index 03adb6e..add7607 100644
--- a/config.h.in
+++ b/config.h.in
@@ -6,6 +6,9 @@
 /* Define to 1 if you have the `ibv_read_sysfs_file' function. */
 #undef HAVE_IBV_READ_SYSFS_FILE
 
+/* Define to 1 if you have the `ibv_register_driver' function. */
+#undef HAVE_IBV_REGISTER_DRIVER
+
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
@@ -27,9 +30,6 @@
 /* Define to 1 if you have the <string.h> header file. */
 #undef HAVE_STRING_H
 
-/* Define to 1 if you have the <sysfs/libsysfs.h> header file. */
-#undef HAVE_SYSFS_LIBSYSFS_H
-
 /* Define to 1 if you have the <sys/stat.h> header file. */
 #undef HAVE_SYS_STAT_H
 
diff --git a/configure.in b/configure.in
index 21f97ff..591b9b0 100644
--- a/configure.in
+++ b/configure.in
@@ -30,9 +30,20 @@ AC_CHECK_HEADER(infiniband/driver.h, [],
     AC_MSG_ERROR([<infiniband/driver.h> not found.  libehca requires libibverbs.]))
 
 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)
 fi
-AC_CHECK_HEADERS(sysfs/libsysfs.h)
 
 dnl Checks for programs.
 AC_PROG_CC
diff --git a/ehca.driver b/ehca.driver
new file mode 100644
index 0000000..b0000e4
--- /dev/null
+++ b/ehca.driver
@@ -0,0 +1 @@
+driver ehca
diff --git a/src/ehca_uinit.c b/src/ehca_uinit.c
index 4618601..47866cf 100644
--- a/src/ehca_uinit.c
+++ b/src/ehca_uinit.c
@@ -184,8 +184,8 @@ static int ibv_read_sysfs_file(const char *dir, const char *file,
 }
 #endif /* HAVE_IBV_READ_SYSFS_FILE */
 
-struct ibv_device *ibv_driver_init(const char *uverbs_sys_path,
-				   int abi_version)
+static struct ibv_device *ehca_driver_init(const char *uverbs_sys_path,
+					   int abi_version)
 {
 	struct ehcau_device *my_dev = NULL;
 	char value[64];
@@ -225,6 +225,7 @@ struct ibv_device *ibv_driver_init(const char *uverbs_sys_path,
 	return &my_dev->ibv_dev;
 }
 
+#ifndef HAVE_IBV_REGISTER_DRIVER
 struct ibv_device *openib_driver_init(struct sysfs_class_device *sysdev)
 {
 	int abi_ver = 0;
@@ -234,8 +235,9 @@ struct ibv_device *openib_driver_init(struct sysfs_class_device *sysdev)
 				value, sizeof value) > 0)
 		abi_ver = strtol(value, NULL, 10);
 
-	return ibv_driver_init(sysdev->path, abi_ver);
+	return ehca_driver_init(sysdev->path, abi_ver);
 }
+#endif /* HAVE_IBV_REGISTER_DRIVER */
 
 /** @brief module initialization
  */
@@ -328,6 +330,10 @@ void __attribute__ ((constructor)) ehcau_init(void)
 	} else {
 		fprintf(libehca_fh, "tracelevel is:%i\n", libehca_trlevel);
 	}
+
+#ifdef HAVE_IBV_REGISTER_DRIVER
+	ibv_register_driver("ehca", ehca_driver_init);
+#endif
 }
 
 /* eof ehca_uinit.c */
-- 
1.4.4.1





More information about the general mailing list