]> git.openfabrics.org - ~shefty/libibverbs.git/commitdiff
Branch a libibverbs-1.0 tree for maintenance
authorRoland Dreier <rolandd@cisco.com>
Wed, 24 May 2006 21:12:21 +0000 (21:12 +0000)
committerRoland Dreier <rolandd@cisco.com>
Thu, 9 Nov 2006 19:36:01 +0000 (11:36 -0800)
Start 1.1 development in main libibverbs tree:
 - Remove libsysfs use
 - Remove deprecated symbols

Signed-off-by: Roland Dreier <rolandd@cisco.com>
23 files changed:
ChangeLog
Makefile.am
README
configure.in
debian/changelog
debian/control
debian/libibverbs1.install [deleted file]
debian/libibverbs1.postinst [deleted file]
debian/libibverbs2.install [new file with mode: 0644]
debian/libibverbs2.postinst [new file with mode: 0644]
examples/devinfo.c
include/infiniband/driver.h
include/infiniband/marshall.h
include/infiniband/sa.h
include/infiniband/verbs.h
libibverbs.spec.in
src/cmd.c
src/device.c
src/init.c
src/libibverbs.map
src/marshall.c
src/sysfs.c
src/verbs.c

index 38e52367182120794198779100f5ece3788bfda9..d5003e07c5921ac663c1e1ab0e5f4621b652f0c0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2006-05-22  Roland Dreier  <rdreier@cisco.com>
+
+       * examples/devinfo.c (print_hca_cap): Read board_id attribute from
+       sysfs using ibv_read_sysfs_file() instead of libsysfs.
+
+       * src/cmd.c, src/marshall.c, src/sysfs.c: Include <string.h>,
+       since it is no longer implicitly included via <sysfs/libsysfs.h>.
+
+       * include/infiniband/driver.h, include/infiniband/verbs.h,
+       src/device.c, src/init.c, src/verbs.c: Remove dependency on
+       libsysfs by implementing what is required directly on top of
+       filesystem operations.
+
+       * include/infiniband/driver.h, src/init.c: Change name of driver
+       entry point to ibv_driver_init(), and update prototype to remove
+       libsysfs dependency.
+
+       * src/marshall.c, include/infiniband/marshall.h,
+       include/infiniband/sa.h: Remove deprecated ib_xxx symbols.
+
+       * Makefile.am: Bump SONAME to 2, since libibverbs 1.1 will be
+       ABI-incompatible with libibverbs 1.0.
+
+       * Create libibverbs 1.1 branch and bump version number to 1.1-pre1.
+
 2006-05-22  Michael S. Tsirkin  <mst@mellanox.co.il>
 
        * include/infiniband/verbs.h: Remove trailing commas from
index a3b575a11de530a52f739d24297378780678a55c..20912e0ee27897ee4c4af8858f5f1d0360f2e1d4 100644 (file)
@@ -16,7 +16,7 @@ endif
 
 src_libibverbs_la_SOURCES = src/cmd.c src/device.c src/init.c src/marshall.c \
                            src/memory.c src/sysfs.c src/verbs.c
-src_libibverbs_la_LDFLAGS = -version-info 1 -export-dynamic \
+src_libibverbs_la_LDFLAGS = -version-info 2 -export-dynamic \
     $(libibverbs_version_script)
 src_libibverbs_la_DEPENDENCIES = $(srcdir)/src/libibverbs.map
 
@@ -49,8 +49,8 @@ man_MANS = man/ibv_asyncwatch.1 man/ibv_devices.1 man/ibv_devinfo.1 \
     man/ibv_srq_pingpong.1
 
 DEBIAN = debian/changelog debian/compat debian/control debian/copyright \
-    debian/ibverbs-utils.install debian/libibverbs1.install \
-    debian/libibverbs1.postinst debian/libibverbs-dev.install \
+    debian/ibverbs-utils.install debian/libibverbs2.install \
+    debian/libibverbs2.postinst debian/libibverbs-dev.install \
     debian/rules
 
 EXTRA_DIST = include/infiniband/driver.h include/infiniband/kern-abi.h \
diff --git a/README b/README
index 8688efd86f3e0da4f661b48d1abf04dbfd3b7355..2e1c00c8fe70fdea6241f3b8288e0f4ed6edd35d 100644 (file)
--- a/README
+++ b/README
@@ -127,15 +127,6 @@ the 1.1 release:
    driver ABI, because a new method will need to be added to struct
    ibv_context_ops. 
 
- * Eliminate the dependency on libsysfs by implementing the required
-   sysfs handling directly.  This will break the API, because the dev
-   and ibdev members of struct ibv_device will be removed.  It will
-   also break the device driver ABI, because the signature of the
-   driver initialization function will change.  The driver
-   initialization function will be changed as part of this work; this
-   has the added benefit of allowing us to choose a better name than
-   "openib_driver_init."
-
 Other possibilities
 -------------------
 
index d9becd642e4ac65dec75772ec51a006f68343c5e..44fbd0f1aaccb7e0b60a5b5f0d38134e0d7b2467 100644 (file)
@@ -1,11 +1,11 @@
 dnl Process this file with autoconf to produce a configure script.
 
 AC_PREREQ(2.57)
-AC_INIT(libibverbs, 1.0.4, openib-general@openib.org)
+AC_INIT(libibverbs, 1.1-pre1, openib-general@openib.org)
 AC_CONFIG_SRCDIR([src/ibverbs.h])
 AC_CONFIG_AUX_DIR(config)
 AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(libibverbs, 1.0.4)
+AM_INIT_AUTOMAKE(libibverbs, 1.1-pre1)
 
 AM_PROG_LIBTOOL
 
@@ -17,12 +17,8 @@ AC_CHECK_LIB(dl, dlsym, [],
     AC_MSG_ERROR([dlsym() not found.  libibverbs requires libdl.]))
 AC_CHECK_LIB(pthread, pthread_mutex_init, [],
     AC_MSG_ERROR([pthread_mutex_init() not found.  libibverbs requires libpthread.]))
-AC_CHECK_LIB(sysfs, sysfs_open_class, [],
-    AC_MSG_ERROR([sysfs_open_class() not found.  libibverbs requires libsysfs.]))
 
 dnl Checks for header files.
-AC_CHECK_HEADER(sysfs/libsysfs.h, [],
-    AC_MSG_ERROR([<sysfs/libsysfs.h> not found.  libibverbs requires libsysfs.]))
 AC_HEADER_STDC
 
 dnl Checks for typedefs, structures, and compiler characteristics.
index 8dce11cab62ee007b7f630fb14b4160a32d71564..00a73e55bf8116c2ff36fd372ddcb4e90a0e310f 100644 (file)
@@ -1,8 +1,10 @@
-libibverbs (1.0.4-1) unstable; urgency=low
+libibverbs (1.0.99+1.1-pre1-1) unstable; urgency=low
 
-  * New upstream release.
+  * New upstream prerelease.
+  * soname bumped to 2 due to ABI changes.
+  * Update to Standards-Version: 3.7.2
 
- -- Roland Dreier <rolandd@cisco.com>  Thu,  4 May 2006 13:46:44 -0700
+ -- Roland Dreier <rolandd@cisco.com>  Mon, 22 May 2006 23:13:00 -0700
 
 libibverbs (1.0.3-1) unstable; urgency=low
 
index 8f17887a1bbb0e8f10f951161716c5e7f23734a4..1aa1611d3970cae36c1fd53f17cc0bfee93c4887 100644 (file)
@@ -1,11 +1,11 @@
 Source: libibverbs
 Priority: extra
 Maintainer: Roland Dreier <rolandd@cisco.com>
-Build-Depends: cdbs (>= 0.4.25-1), debhelper (>= 5), autotools-dev, libsysfs-dev
-Standards-Version: 3.7.0
+Build-Depends: cdbs (>= 0.4.25-1), debhelper (>= 5), autotools-dev
+Standards-Version: 3.7.2
 Section: libs
 
-Package: libibverbs1
+Package: libibverbs2
 Section: libs
 Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends}, adduser
@@ -23,22 +23,22 @@ Description: A library for direct userspace use of InfiniBand
 Package: libibverbs-dev
 Section: libdevel
 Architecture: any
-Depends: ${misc:Depends}, libibverbs1 (= ${Source-Version}), libsysfs-dev
+Depends: ${misc:Depends}, libibverbs2 (= ${Source-Version})
 Description: Development files for the libibverbs library
  libibverbs is a library that allows userspace processes to use
  InfiniBand "verbs" as described in the InfiniBand Architecture
  Specification.  This includes direct hardware access for fast path
  operations.
  .
- This package is needed to compile programs against libibverbs1.
+ This package is needed to compile programs against libibverbs2.
  It contains the header files and static libraries (optionally)
  needed for compiling.
 
-Package: libibverbs1-dbg
+Package: libibverbs2-dbg
 Section: libdevel
 Priority: extra
 Architecture: any
-Depends: ${misc:Depends}, libibverbs1 (= ${Source-Version})
+Depends: ${misc:Depends}, libibverbs2 (= ${Source-Version})
 Description: Debugging symbols for the libibverbs library
  libibverbs is a library that allows userspace processes to use
  InfiniBand "verbs" as described in the InfiniBand Architecture
@@ -46,7 +46,7 @@ Description: Debugging symbols for the libibverbs library
  operations.
  .
  This package contains the debugging symbols associated with
- libibverbs1. They will automatically be used by gdb for debugging
+ libibverbs2. They will automatically be used by gdb for debugging
  libibverbs-related issues.
 
 Package: ibverbs-utils
@@ -59,5 +59,5 @@ Description: Examples for the libibverbs library
  Specification.  This includes direct hardware access for fast path
  operations.
  .
- This package contains useful libibverbs1 example programs such as
+ This package contains useful libibverbs2 example programs such as
  ibv_devinfo, which displays information about InfiniBand devices.
diff --git a/debian/libibverbs1.install b/debian/libibverbs1.install
deleted file mode 100644 (file)
index 0f3523d..0000000
+++ /dev/null
@@ -1 +0,0 @@
-usr/lib/libibverbs*.so.*
diff --git a/debian/libibverbs1.postinst b/debian/libibverbs1.postinst
deleted file mode 100644 (file)
index f7d2ee6..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-# postinst script for libibverbs1
-
-set -e
-
-if [ "$1" != configure ]; then
-    exit 0
-fi
-
-getent group rdma > /dev/null 2>&1 || addgroup --system --quiet rdma
-
-#DEBHELPER#
diff --git a/debian/libibverbs2.install b/debian/libibverbs2.install
new file mode 100644 (file)
index 0000000..0f3523d
--- /dev/null
@@ -0,0 +1 @@
+usr/lib/libibverbs*.so.*
diff --git a/debian/libibverbs2.postinst b/debian/libibverbs2.postinst
new file mode 100644 (file)
index 0000000..f7d2ee6
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+# postinst script for libibverbs1
+
+set -e
+
+if [ "$1" != configure ]; then
+    exit 0
+fi
+
+getent group rdma > /dev/null 2>&1 || addgroup --system --quiet rdma
+
+#DEBHELPER#
index 6961b7f6c564d0b811d1fcb4814233885bfdc17d..96a0a16ead5fa6ada4052e36c1836f2f39a2e8b3 100644 (file)
@@ -47,6 +47,7 @@
 #include <byteswap.h>
 
 #include <infiniband/verbs.h>
+#include <infiniband/driver.h>
 #include <infiniband/arch.h>
 
 static int verbose = 0;
@@ -169,7 +170,6 @@ static int print_hca_cap(struct ibv_device *ib_dev, uint8_t ib_port)
        struct ibv_context *ctx;
        struct ibv_device_attr device_attr;
        struct ibv_port_attr port_attr;
-       struct sysfs_attribute *attr;
        int rc = 0;
        uint8_t port;
        char buf[256];
@@ -194,11 +194,9 @@ static int print_hca_cap(struct ibv_device *ib_dev, uint8_t ib_port)
        printf("\tvendor_id:\t\t\t0x%04x\n", device_attr.vendor_id);
        printf("\tvendor_part_id:\t\t\t%d\n", device_attr.vendor_part_id);
        printf("\thw_ver:\t\t\t\t0x%X\n", device_attr.hw_ver);
-       attr = sysfs_get_classdev_attr(ib_dev->ibdev, "board_id");
-       if (attr) {
-               printf("\tboard_id:\t\t\t%s", attr->value);
-               sysfs_close_attribute(attr);
-       }
+
+       if (ibv_read_sysfs_file(ib_dev->ibdev_path, "board_id", buf, sizeof buf) > 0)
+               printf("\tboard_id:\t\t\t%s\n", buf);
 
        printf("\tphys_port_cnt:\t\t\t%d\n", device_attr.phys_port_cnt);
 
index 6b01275f294c367e4d8448dc68dff0b284cef43e..8db8bdbb11cfb85110b99e1a49a2df3cebe1f79d 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
- * Copyright (c) 2005, 2006 Cisco Systems.  All rights reserved.
+ * Copyright (c) 2005, 2006 Cisco Systems, Inc.  All rights reserved.
  * Copyright (c) 2005 PathScale, Inc.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -37,8 +37,6 @@
 #ifndef INFINIBAND_DRIVER_H
 #define INFINIBAND_DRIVER_H
 
-#include <sysfs/libsysfs.h>
-
 #include <infiniband/verbs.h>
 #include <infiniband/kern-abi.h>
 
  * Device-specific drivers should declare their device init function
  * as below (the name must be "openib_driver_init"):
  *
- * struct ibv_device *openib_driver_init(struct sysfs_class_device *);
+ * struct ibv_device *ibv_driver_init(const char *uverbs_sys_path,
+ *                                   int abi_version);
  *
- * libibverbs will call each driver's openib_driver_init() function
- * once for each InfiniBand device.  If the device is one that the
- * driver can support, it should return a struct ibv_device * with the
- * ops member filled in.  If the driver does not support the device,
- * it should return NULL from openib_driver_init().
+ * libibverbs will call each driver's ibv_driver_init() function once
+ * for each InfiniBand device.  If the device is one that the driver
+ * can support, it should return a struct ibv_device * with the ops
+ * member filled in.  If the driver does not support the device, it
+ * should return NULL from openib_driver_init().
  */
 
-typedef struct ibv_device *(*ibv_driver_init_func)(struct sysfs_class_device *);
+typedef struct ibv_device *(*ibv_driver_init_func)(const char *, int);
 
 int ibv_cmd_get_context(struct ibv_context *context, struct ibv_get_context *cmd,
                        size_t cmd_size, struct ibv_get_context_resp *resp,
index fe2bb1e18e8ce790a26f7f68c8dc58dba3142268..8b85736564d48393aa17920ac04c6f9fadc0eddd 100644 (file)
 #  define END_C_DECLS
 #endif /* __cplusplus */
 
-#if __GNUC__ >= 3
-#  define __attribute_deprecated       __attribute__((deprecated))
-#else
-#  define __attribute_deprecated
-#endif
-
 BEGIN_C_DECLS
 
 void ibv_copy_qp_attr_from_kern(struct ibv_qp_attr *dst,
@@ -63,21 +57,6 @@ void ibv_copy_path_rec_from_kern(struct ibv_sa_path_rec *dst,
 void ibv_copy_path_rec_to_kern(struct ibv_kern_path_rec *dst,
                               struct ibv_sa_path_rec *src);
 
-/*
- * Obsolete, deprecated names.  Will be removed in libibverbs 1.1.
- */
-
-void ib_copy_qp_attr_from_kern(struct ibv_qp_attr *dst,
-                              struct ibv_kern_qp_attr *src) __attribute_deprecated;
-
-void ib_copy_path_rec_from_kern(struct ib_sa_path_rec *dst,
-                               struct ib_kern_path_rec *src) __attribute_deprecated;
-
-void ib_copy_path_rec_to_kern(struct ib_kern_path_rec *dst,
-                             struct ib_sa_path_rec *src) __attribute_deprecated;
-
 END_C_DECLS
 
-#undef __attribute_deprecated
-
 #endif /* INFINIBAND_MARSHALL_H */
index dc2f3b5146c646545dfdcdbe156871d6a9d799e4..ff14a29bd525a1a40c6107ef53bffd1e91aff540 100644 (file)
 
 #include <infiniband/verbs.h>
 
-/*
- * Obsolete, deprecated names.  Will be removed in libibverbs 1.1.
- */
-#define ib_sa_path_rec         ibv_sa_path_rec
-#define ib_sa_mcmember_rec     ibv_sa_mcmember_rec
-#define ib_sa_service_rec      ibv_sa_service_rec
-
 struct ibv_sa_path_rec {
        /* reserved */
        /* reserved */
index 8d4cfc10e1f5d4b920c3fd495bfee2d30c4c16e3..82c1078e3acaa7521e469cdf0a0a48a3e8118b37 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2004 Intel Corporation.  All rights reserved.
- * Copyright (c) 2005, 2006 Cisco Systems.  All rights reserved.
+ * Copyright (c) 2005, 2006 Cisco Systems, Inc.  All rights reserved.
  * Copyright (c) 2005 PathScale, Inc.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -41,8 +41,6 @@
 #include <stdint.h>
 #include <pthread.h>
 
-#include <sysfs/libsysfs.h>
-
 #ifdef __cplusplus
 #  define BEGIN_C_DECLS extern "C" {
 #  define END_C_DECLS   }
@@ -559,11 +557,22 @@ struct ibv_device_ops {
        void                    (*free_context)(struct ibv_context *context);
 };
 
+enum {
+       IBV_SYSFS_NAME_MAX      = 64,
+       IBV_SYSFS_PATH_MAX      = 256
+};
+
 struct ibv_device {
-       struct sysfs_class_device *dev;
-       struct sysfs_class_device *ibdev;
-       struct ibv_driver         *driver;
-       struct ibv_device_ops      ops;
+       struct ibv_driver      *driver;
+       struct ibv_device_ops   ops;
+       /* Name of underlying kernel IB device, eg "mthca0" */
+       char                    name[IBV_SYSFS_NAME_MAX];
+       /* Name of uverbs device, eg "uverbs0" */
+       char                    dev_name[IBV_SYSFS_NAME_MAX];
+       /* Path to infiniband_verbs class device in sysfs */
+       char                    dev_path[IBV_SYSFS_PATH_MAX];
+       /* Path to infiniband class device in sysfs */
+       char                    ibdev_path[IBV_SYSFS_PATH_MAX];
 };
 
 struct ibv_context_ops {
index 3ae860f9a26023aae7566d5a790004fa172b9354..ad5ea760fe1dde2fcfc54f09a4710c3775e75a84 100644 (file)
@@ -3,18 +3,16 @@
 %define ver      @VERSION@
 
 Name: libibverbs
-Version: 1.0.4
-Release: 1%{?dist}
+Version: 1.1
+Release: 0.1.pre1%{?dist}
 Summary: A library for direct userspace use of InfiniBand
 
 Group: System Environment/Libraries
 License: GPL/BSD
 Url: http://openib.org/
-Source: http://openib.org/downloads/libibverbs-1.0.4.tar.gz
+Source: http://openib.org/downloads/libibverbs-1.1-pre1.tar.gz
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
-BuildRequires: %{_includedir}/sysfs/libsysfs.h
-
 %description
 libibverbs is a library that allows userspace processes to use
 InfiniBand "verbs" as described in the InfiniBand Architecture
@@ -27,7 +25,6 @@ also be installed.
 %package devel
 Summary: Development files for the libibverbs library
 Group: System Environment/Libraries
-Requires: %{name} = %{version}-%{release} %{_includedir}/sysfs/libsysfs.h
 
 %description devel
 Static libraries and header files for the libibverbs verbs library.
@@ -77,6 +74,10 @@ rm -rf $RPM_BUILD_ROOT
 %{_mandir}/man1/*
 
 %changelog
+* Mon May 22 2006 Roland Dreier <rdreier@cisco.com> - 1.1-0.1.pre1
+- New upstream release
+- Remove dependency on libsysfs, since it is no longer used
+
 * Thu May  4 2006 Roland Dreier <rdreier@cisco.com> - 1.0.4-1
 - New upstream release
 
index bd339516cb761b4e0e5644f5a7bd3568c51c34c4..7021d5aa80bbfa938ca6c176015c29a6e38fd211 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 PathScale, Inc.  All rights reserved.
- * Copyright (c) 2006 Cisco Systems.  All rights reserved.
+ * Copyright (c) 2006 Cisco Systems, Inc.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -43,6 +43,7 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <alloca.h>
+#include <string.h>
 
 #include "ibverbs.h"
 
index 3ab6cebc11c464d8c0bb34bfeadc15f457a44922..a3a03943bfef3723e6ffa9ddd925e1820a6dd285 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
+ * Copyright (c) 2006 Cisco Systems, Inc.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -82,7 +83,7 @@ void ibv_free_device_list(struct ibv_device **list)
 
 const char *ibv_get_device_name(struct ibv_device *device)
 {
-       return device->ibdev->name;
+       return device->name;
 }
 
 uint64_t ibv_get_device_guid(struct ibv_device *device)
@@ -92,7 +93,7 @@ uint64_t ibv_get_device_guid(struct ibv_device *device)
        uint16_t parts[4];
        int i;
 
-       if (ibv_read_sysfs_file(device->ibdev->path, "node_guid",
+       if (ibv_read_sysfs_file(device->ibdev_path, "node_guid",
                                attr, sizeof attr) < 0)
                return 0;
 
@@ -112,13 +113,15 @@ struct ibv_context *ibv_open_device(struct ibv_device *device)
        int cmd_fd;
        struct ibv_context *context;
 
-       asprintf(&devpath, "/dev/infiniband/%s", device->dev->name);
+       asprintf(&devpath, "/dev/infiniband/%s", device->dev_name);
 
        /*
         * We'll only be doing writes, but we need O_RDWR in case the
         * provider needs to mmap() the file.
         */
        cmd_fd = open(devpath, O_RDWR);
+       free(devpath);
+
        if (cmd_fd < 0)
                return NULL;
 
index 4b943b81066dcd27aecd9c6ab608a48059d689b6..1df5f17904f8532c3aa94abe42a86a9d04c323fe 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
+ * Copyright (c) 2006 Cisco Systems, Inc.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -43,6 +44,7 @@
 #include <dlfcn.h>
 #include <unistd.h>
 #include <sys/types.h>
+#include <dirent.h>
 
 #include "ibverbs.h"
 
@@ -71,7 +73,7 @@ static void load_driver(char *so_path)
        }
 
        dlerror();
-       init_func = dlsym(dlhandle, "openib_driver_init");
+       init_func = dlsym(dlhandle, "ibv_driver_init");
        if (dlerror() != NULL || !init_func) {
                dlclose(dlhandle);
                return;
@@ -118,40 +120,45 @@ static void find_drivers(char *dir)
        globfree(&so_glob);
 }
 
-static struct ibv_device *init_drivers(struct sysfs_class_device *verbs_dev)
+static struct ibv_device *init_drivers(const char *class_path,
+                                      const char *dev_name)
 {
-       struct sysfs_class_device *ib_dev;
        struct ibv_driver *driver;
        struct ibv_device *dev;
-       char ibdev_name[64];
+       int abi_ver = 0;
+       char sys_path[IBV_SYSFS_PATH_MAX];
+       char ibdev_name[IBV_SYSFS_NAME_MAX];
+       char value[8];
 
-       if (ibv_read_sysfs_file(verbs_dev->path, "ibdev",
-                               ibdev_name, sizeof ibdev_name) < 0) {
-               fprintf(stderr, PFX "Warning: no ibdev class attr for %s\n",
-                       verbs_dev->name);
-               return NULL;
-       }
+       snprintf(sys_path, sizeof sys_path, "%s/%s",
+                class_path, dev_name);
+
+       if (ibv_read_sysfs_file(sys_path, "abi_version", value, sizeof value) > 0)
+               abi_ver = strtol(value, NULL, 10);
 
-       ib_dev = sysfs_open_class_device("infiniband", ibdev_name);
-       if (!ib_dev) {
-               fprintf(stderr, PFX "Warning: no infiniband class device %s for %s\n",
-                       ibdev_name, verbs_dev->name);
+       if (ibv_read_sysfs_file(sys_path, "ibdev", ibdev_name, sizeof ibdev_name) < 0) {
+               fprintf(stderr, PFX "Warning: no ibdev class attr for %s\n",
+                       sys_path);
                return NULL;
        }
 
        for (driver = driver_list; driver; driver = driver->next) {
-               dev = driver->init_func(verbs_dev);
-               if (dev) {
-                       dev->dev    = verbs_dev;
-                       dev->ibdev  = ib_dev;
-                       dev->driver = driver;
-
-                       return dev;
-               }
+               dev = driver->init_func(sys_path, abi_ver);
+               if (!dev)
+                       continue;
+
+               dev->driver = driver;
+               strcpy(dev->dev_path, sys_path);
+               snprintf(dev->ibdev_path, IBV_SYSFS_PATH_MAX, "%s/class/infiniband/%s",
+                        ibv_get_sysfs_path(), ibdev_name);
+               strcpy(dev->dev_name, dev_name);
+               strcpy(dev->name, ibdev_name);
+
+               return dev;
        }
 
        fprintf(stderr, PFX "Warning: no userspace device-specific driver found for %s\n"
-               "       driver search path: ", verbs_dev->name);
+               "       driver search path: ", dev_name);
        if (user_path)
                fprintf(stderr, "%s:", user_path);
        fprintf(stderr, "%s\n", default_path);
@@ -159,17 +166,10 @@ static struct ibv_device *init_drivers(struct sysfs_class_device *verbs_dev)
        return NULL;
 }
 
-static int check_abi_version(void)
+static int check_abi_version(const char *path)
 {
-       const char *path;
        char value[8];
 
-       path = ibv_get_sysfs_path();
-       if (!path) {
-               fprintf(stderr, PFX "Fatal: couldn't find sysfs mount.\n");
-               return -1;
-       }
-
        if (ibv_read_sysfs_file(path, "class/infiniband_verbs/abi_version",
                                value, sizeof value) < 0) {
                fprintf(stderr, PFX "Fatal: couldn't read uverbs ABI version.\n");
@@ -191,10 +191,11 @@ static int check_abi_version(void)
 
 HIDDEN int ibverbs_init(struct ibv_device ***list)
 {
+       const char *sysfs_path;
        char *wr_path, *dir;
-       struct sysfs_class *cls;
-       struct dlist *verbs_dev_list;
-       struct sysfs_class_device *verbs_dev;
+       char class_path[IBV_SYSFS_PATH_MAX];
+       DIR *class_dir;
+       struct dirent *dent;
        struct ibv_device *device;
        struct ibv_device **new_list;
        int num_devices = 0;
@@ -227,35 +228,45 @@ HIDDEN int ibverbs_init(struct ibv_device ***list)
         */
        load_driver(NULL);
 
-       cls = sysfs_open_class("infiniband_verbs");
-       if (!cls) {
-               fprintf(stderr, PFX "Fatal: couldn't open sysfs class 'infiniband_verbs'.\n");
+       sysfs_path = ibv_get_sysfs_path();
+       if (!sysfs_path) {
+               fprintf(stderr, PFX "Fatal: couldn't find sysfs mount.\n");
                return 0;
        }
 
-       if (check_abi_version())
+       if (check_abi_version(sysfs_path))
                return 0;
 
-       verbs_dev_list = sysfs_get_class_devices(cls);
-       if (!verbs_dev_list) {
-               fprintf(stderr, PFX "Fatal: no infiniband class devices found.\n");
+       snprintf(class_path, sizeof class_path, "%s/class/infiniband_verbs",
+                sysfs_path);
+       class_dir = opendir(class_path);
+       if (!class_dir) {
+               fprintf(stderr, PFX "Fatal: couldn't open sysfs class "
+                       "directory '%s'.\n", class_path);
                return 0;
        }
 
-       dlist_for_each_data(verbs_dev_list, verbs_dev, struct sysfs_class_device) {
-               device = init_drivers(verbs_dev);
-               if (device) {
-                       if (list_size <= num_devices) {
-                               list_size = list_size ? list_size * 2 : 1;
-                               new_list = realloc(*list, list_size * sizeof (struct ibv_device *));
-                               if (!new_list)
-                                       goto out;
-                               *list = new_list;
-                       }
-                       (*list)[num_devices++] = device;
+       while ((dent = readdir(class_dir))) {
+               if (dent->d_name[0] == '.' || dent->d_type == DT_REG)
+                       continue;
+
+               device = init_drivers(class_path, dent->d_name);
+               if (!device)
+                       continue;
+
+               if (list_size <= num_devices) {
+                       list_size = list_size ? list_size * 2 : 1;
+                       new_list = realloc(*list, list_size * sizeof (struct ibv_device *));
+                       if (!new_list)
+                               goto out;
+                       *list = new_list;
                }
+
+               (*list)[num_devices++] = device;
        }
 
+       closedir(class_dir);
+
 out:
        return num_devices;
 }
index fba70263ed796c39050371d12b775a31644eac48..4d7154970b61bff68d3527655607baa56fa6c198 100644 (file)
@@ -72,8 +72,5 @@ IBVERBS_1.0 {
                ibv_get_sysfs_path;
                ibv_read_sysfs_file;
 
-               ib_copy_qp_attr_from_kern;
-               ib_copy_path_rec_from_kern;
-               ib_copy_path_rec_to_kern;
        local: *;
 };
index 1284f64b6001f4565de98938f8c79006444407bc..c23a92623559813c9eb4586aec2c5fe20f421eb1 100644 (file)
@@ -34,6 +34,8 @@
 #  include <config.h>
 #endif /* HAVE_CONFIG_H */
 
+#include <string.h>
+
 #include <infiniband/marshall.h>
 
 static void ibv_copy_ah_attr_from_kern(struct ibv_ah_attr *dst,
@@ -138,21 +140,3 @@ void ibv_copy_path_rec_to_kern(struct ibv_kern_path_rec *dst,
        dst->preference         = src->preference;
        dst->packet_life_time_selector = src->packet_life_time_selector;
 }
-
-void ib_copy_qp_attr_from_kern(struct ibv_qp_attr *dst,
-                              struct ibv_kern_qp_attr *src)
-{
-       return ibv_copy_qp_attr_from_kern(dst, src);
-}
-
-void ib_copy_path_rec_from_kern(struct ib_sa_path_rec *dst,
-                               struct ib_kern_path_rec *src)
-{
-       return ibv_copy_path_rec_from_kern(dst, src);
-}
-
-void ib_copy_path_rec_to_kern(struct ib_kern_path_rec *dst,
-                             struct ib_sa_path_rec *src)
-{
-       return ibv_copy_path_rec_to_kern(dst, src);
-}
index 52fbd5a536fe514031af5c0dd8d3c0f1b98e94dd..b325b43c5cbd452fe71718e14581dba416aaf23d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006 Cisco Systems.  All rights reserved.
+ * Copyright (c) 2006 Cisco Systems, Inc.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -42,6 +42,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <string.h>
 
 #include "ibverbs.h"
 
@@ -64,7 +65,7 @@ const char *ibv_get_sysfs_path(void)
        if (env) {
                int len;
 
-               sysfs_path = strndup(env, 256);
+               sysfs_path = strndup(env, IBV_SYSFS_PATH_MAX);
                len = strlen(sysfs_path);
                while (len > 0 && sysfs_path[len - 1] == '/') {
                        --len;
index 4f63763506ba744e5f380905537934dcb2017d36..5aca9bc223669f243e174c76ea3fa40ebced9606 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2005 Topspin Communications.  All rights reserved.
- * Copyright (c) 2006 Cisco Systems.  All rights reserved.
+ * Copyright (c) 2006 Cisco Systems, Inc.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -99,7 +99,7 @@ int ibv_query_gid(struct ibv_context *context, uint8_t port_num,
 
        snprintf(name, sizeof name, "ports/%d/gids/%d", port_num, index);
 
-       if (ibv_read_sysfs_file(context->device->ibdev->path, name,
+       if (ibv_read_sysfs_file(context->device->ibdev_path, name,
                                attr, sizeof attr) < 0)
                return -1;
 
@@ -122,7 +122,7 @@ int ibv_query_pkey(struct ibv_context *context, uint8_t port_num,
 
        snprintf(name, sizeof name, "ports/%d/pkeys/%d", port_num, index);
 
-       if (ibv_read_sysfs_file(context->device->ibdev->path, name,
+       if (ibv_read_sysfs_file(context->device->ibdev_path, name,
                                attr, sizeof attr) < 0)
                return -1;