From: Roland Dreier Date: Wed, 24 May 2006 21:12:21 +0000 (+0000) Subject: Branch a libibverbs-1.0 tree for maintenance X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=bdbfcaa09c1f03506dc983f76fb1f23b993aaebf;p=~shefty%2Flibibverbs.git Branch a libibverbs-1.0 tree for maintenance Start 1.1 development in main libibverbs tree: - Remove libsysfs use - Remove deprecated symbols Signed-off-by: Roland Dreier --- diff --git a/ChangeLog b/ChangeLog index 38e5236..d5003e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,28 @@ +2006-05-22 Roland Dreier + + * 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 , + since it is no longer implicitly included via . + + * 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 * include/infiniband/verbs.h: Remove trailing commas from diff --git a/Makefile.am b/Makefile.am index a3b575a..20912e0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 8688efd..2e1c00c 100644 --- 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 ------------------- diff --git a/configure.in b/configure.in index d9becd6..44fbd0f 100644 --- a/configure.in +++ b/configure.in @@ -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([ not found. libibverbs requires libsysfs.])) AC_HEADER_STDC dnl Checks for typedefs, structures, and compiler characteristics. diff --git a/debian/changelog b/debian/changelog index 8dce11c..00a73e5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 Thu, 4 May 2006 13:46:44 -0700 + -- Roland Dreier Mon, 22 May 2006 23:13:00 -0700 libibverbs (1.0.3-1) unstable; urgency=low diff --git a/debian/control b/debian/control index 8f17887..1aa1611 100644 --- a/debian/control +++ b/debian/control @@ -1,11 +1,11 @@ Source: libibverbs Priority: extra Maintainer: Roland Dreier -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 index 0f3523d..0000000 --- a/debian/libibverbs1.install +++ /dev/null @@ -1 +0,0 @@ -usr/lib/libibverbs*.so.* diff --git a/debian/libibverbs1.postinst b/debian/libibverbs1.postinst deleted file mode 100644 index f7d2ee6..0000000 --- a/debian/libibverbs1.postinst +++ /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 index 0000000..0f3523d --- /dev/null +++ b/debian/libibverbs2.install @@ -0,0 +1 @@ +usr/lib/libibverbs*.so.* diff --git a/debian/libibverbs2.postinst b/debian/libibverbs2.postinst new file mode 100644 index 0000000..f7d2ee6 --- /dev/null +++ b/debian/libibverbs2.postinst @@ -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# diff --git a/examples/devinfo.c b/examples/devinfo.c index 6961b7f..96a0a16 100644 --- a/examples/devinfo.c +++ b/examples/devinfo.c @@ -47,6 +47,7 @@ #include #include +#include #include 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); diff --git a/include/infiniband/driver.h b/include/infiniband/driver.h index 6b01275..8db8bdb 100644 --- a/include/infiniband/driver.h +++ b/include/infiniband/driver.h @@ -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 - #include #include @@ -54,16 +52,17 @@ * 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, diff --git a/include/infiniband/marshall.h b/include/infiniband/marshall.h index fe2bb1e..8b85736 100644 --- a/include/infiniband/marshall.h +++ b/include/infiniband/marshall.h @@ -46,12 +46,6 @@ # 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 */ diff --git a/include/infiniband/sa.h b/include/infiniband/sa.h index dc2f3b5..ff14a29 100644 --- a/include/infiniband/sa.h +++ b/include/infiniband/sa.h @@ -38,13 +38,6 @@ #include -/* - * 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 */ diff --git a/include/infiniband/verbs.h b/include/infiniband/verbs.h index 8d4cfc1..82c1078 100644 --- a/include/infiniband/verbs.h +++ b/include/infiniband/verbs.h @@ -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 #include -#include - #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 { diff --git a/libibverbs.spec.in b/libibverbs.spec.in index 3ae860f..ad5ea76 100644 --- a/libibverbs.spec.in +++ b/libibverbs.spec.in @@ -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 - 1.1-0.1.pre1 +- New upstream release +- Remove dependency on libsysfs, since it is no longer used + * Thu May 4 2006 Roland Dreier - 1.0.4-1 - New upstream release diff --git a/src/cmd.c b/src/cmd.c index bd33951..7021d5a 100644 --- 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 #include #include +#include #include "ibverbs.h" diff --git a/src/device.c b/src/device.c index 3ab6ceb..a3a0394 100644 --- a/src/device.c +++ b/src/device.c @@ -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; diff --git a/src/init.c b/src/init.c index 4b943b8..1df5f17 100644 --- a/src/init.c +++ b/src/init.c @@ -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 #include #include +#include #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; } diff --git a/src/libibverbs.map b/src/libibverbs.map index fba7026..4d71549 100644 --- a/src/libibverbs.map +++ b/src/libibverbs.map @@ -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: *; }; diff --git a/src/marshall.c b/src/marshall.c index 1284f64..c23a926 100644 --- a/src/marshall.c +++ b/src/marshall.c @@ -34,6 +34,8 @@ # include #endif /* HAVE_CONFIG_H */ +#include + #include 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); -} diff --git a/src/sysfs.c b/src/sysfs.c index 52fbd5a..b325b43 100644 --- a/src/sysfs.c +++ b/src/sysfs.c @@ -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 #include #include +#include #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; diff --git a/src/verbs.c b/src/verbs.c index 4f63763..5aca9bc 100644 --- a/src/verbs.c +++ b/src/verbs.c @@ -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;