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

Steve Wise swise at opengridcomputing.com
Wed Jan 10 14:20:50 PST 2007


So libibverbs 1.1 will be part of ofed 1.2?


On Wed, 2007-01-10 at 14:12 -0800, Roland Dreier wrote:
> The latest libibverbs development tree changes how low-level drivers
> are found.  The driver must be in a shared object like
> libcxgb3-rdmav2.so in the ordinary library path, rather than
> infiniband/cxgb3.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 libcxgb3 tree is targeted only for libibverbs
> development trees and won't work with libibverbs 1.0, this patch
> changes libcxgb3 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      |   14 +++++++-------
>  configure.in     |   13 +++++++++++++
>  cxgb3.driver     |    1 +
>  libcxgb3.spec.in |    7 ++++---
>  src/iwch.c       |   27 ++++-----------------------
>  5 files changed, 29 insertions(+), 33 deletions(-)
> 
> diff --git a/Makefile.am b/Makefile.am
> index 8f3a679..3dab25e 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -1,10 +1,8 @@
>  # $Id: Makefile.am 3802 2005-10-18 18:32:06Z tom $
>  
> -cxgb3libdir = $(libdir)/infiniband
> +lib_LTLIBRARIES = src/libcxgb3.la
>  
> -cxgb3lib_LTLIBRARIES = src/cxgb3.la
> -
> -src_cxgb3_la_CFLAGS = -g -Wall -D_GNU_SOURCE
> +AM_CFLAGS = -g -Wall -D_GNU_SOURCE
>  
>  if HAVE_LD_VERSION_SCRIPT
>      cxgb3_version_script = -Wl,--version-script=$(srcdir)/src/iwch.map
> @@ -12,16 +10,18 @@ else
>      cxgb3_version_script =
>  endif
>  
> -src_cxgb3_la_SOURCES = src/cq.c src/iwch.c src/qp.c \
> +src_libcxgb3_la_SOURCES = src/cq.c src/iwch.c src/qp.c \
>      src/verbs.c
> -src_cxgb3_la_LDFLAGS = -avoid-version -module \
> +src_libcxgb3_la_LDFLAGS = -avoid-version -release @IBV_DEVICE_LIBRARY_EXTENSION@ \
>      $(cxgb3_version_script)
> +cxgb3confdir = $(sysconfdir)/libibverbs.d
> +cxgb3conf_DATA = cxgb3.driver
>  
>  #DEBIAN = debian/changelog debian/compat debian/control debian/copyright \
>  #    debian/libcxgb31.install debian/libcxgb3-dev.install debian/rules
>  
>  EXTRA_DIST = src/iwch.h src/iwch-abi.h \
> -    src/iwch.map libcxgb3.spec.in $(DEBIAN)
> +    src/iwch.map libcxgb3.spec.in cxgb3.driver
>  
>  dist-hook: libcxgb3.spec
>  	cp libcxgb3.spec $(distdir)
> diff --git a/configure.in b/configure.in
> index d113da9..81b5a30 100644
> --- a/configure.in
> +++ b/configure.in
> @@ -28,6 +28,19 @@ AC_C_CONST
>  dnl Checks for library functions
>  AC_CHECK_FUNCS(ibv_read_sysfs_file)
>  
> +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/cxgb3.driver b/cxgb3.driver
> new file mode 100644
> index 0000000..cfa6186
> --- /dev/null
> +++ b/cxgb3.driver
> @@ -0,0 +1 @@
> +driver cxgb3
> diff --git a/libcxgb3.spec.in b/libcxgb3.spec.in
> index e710808..959f659 100644
> --- a/libcxgb3.spec.in
> +++ b/libcxgb3.spec.in
> @@ -39,18 +39,19 @@ make %{?_smp_mflags}
>  rm -rf $RPM_BUILD_ROOT
>  %makeinstall
>  # remove unpackaged files from the buildroot
> -rm -f $RPM_BUILD_ROOT%{_libdir}/infiniband/*.la
> +rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
>  
>  %clean
>  rm -rf $RPM_BUILD_ROOT
>  
>  %files
>  %defattr(-,root,root,-)
> -%{_libdir}/infiniband/cxgb3.so
> +%{_libdir}/libcxgb3*.so
>  %doc AUTHORS COPYING ChangeLog README
> +%config %{_sysconfdir}/libibverbs.d/cxgb3.driver
>  
>  %files devel
>  %defattr(-,root,root,-)
> -%{_libdir}/infiniband/cxgb3.a
> +%{_libdir}/libcxgb3*.a
>  
>  %changelog
> diff --git a/src/iwch.c b/src/iwch.c
> index 17f1d61..e972460 100644
> --- a/src/iwch.c
> +++ b/src/iwch.c
> @@ -41,16 +41,6 @@
>  #include <sys/mman.h>
>  #include <pthread.h>
>  
> -#ifdef HAVE_SYSFS_LIBSYSFS_H
> -#include <sysfs/libsysfs.h>
> -#endif
> -
> -#ifndef HAVE_IBV_READ_SYSFS_FILE
> -#include <sys/types.h>
> -#include <sys/stat.h>
> -#include <fcntl.h>
> -#endif
> -
>  #include "iwch.h"
>  #include "iwch-abi.h"
>  
> @@ -173,8 +163,8 @@ static struct ibv_device_ops iwch_dev_ops = {
>  	.free_context = iwch_free_context
>  };
>  
> -struct ibv_device *ibv_driver_init(const char *uverbs_sys_path,
> -				   int abi_version)
> +static struct ibv_device *cxgb3_driver_init(const char *uverbs_sys_path,
> +					    int abi_version)
>  {
>  	char value[16];
>  	char s[32];
> @@ -251,16 +241,7 @@ err1:
>  	return NULL;
>  }
>  
> -#ifdef HAVE_SYSFS_LIBSYSFS_H
> -struct ibv_device *openib_driver_init(struct sysfs_class_device *sysdev)
> +static __attribute__((constructor)) void cxgb3_register_driver(void)
>  {
> -	int abi_ver = 0;
> -	char value[8];
> -
> -	if (ibv_read_sysfs_file(sysdev->path, "abi_version",
> -				value, sizeof value) > 0)
> -		abi_ver = strtol(value, NULL, 10);
> -
> -	return ibv_driver_init(sysdev->path, abi_ver);
> +	ibv_register_driver("cxgb3", cxgb3_driver_init);
>  }
> -#endif /* HAVE_SYSFS_LIBSYSFS_H */





More information about the general mailing list