[openib-general] Plans for libibverbs 1.1

Roland Dreier rdreier at cisco.com
Tue May 23 09:57:03 PDT 2006


I'm planning on branching the libibverbs tree so that I can open a 1.1
development branch where ABI/API stability is not a requirement.  My
current plan is to copy the current src/userspace/libibverbs tree in
svn to src/userspace/libibverbs-1.0.  The libibverbs-1.0 tree would be
used for stable maintainence (only changes that preserve ABI and API
stability will be accepted), and the libibverbs tree would be used for
new development.

I would expect a libibverbs 1.1-pre1 snapshot release shortly, with
the goal of a full stable libibverbs 1.1 release in 3 or 4 months.

So far I have the changes below queued up for the new libibverbs 1.1
tree.  The main changes are getting rid of libsysfs use, and removing
the deprecated ib_XXX symbols.

If no one raises any problems, I'll commit all of this tomorrow (Weds).

Thanks,
  Roland

--- libibverbs/libibverbs.spec.in	(revision 7435)
+++ libibverbs/libibverbs.spec.in	(working copy)
@@ -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 at 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 at cisco.com> - 1.0.4-1
 - New upstream release
 
--- libibverbs/debian/control	(revision 7435)
+++ libibverbs/debian/control	(working copy)
@@ -1,11 +1,11 @@
 Source: libibverbs
 Priority: extra
 Maintainer: Roland Dreier <rolandd at 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 usersp
 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 l
  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
  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.
--- libibverbs/debian/libibverbs1.postinst	(revision 7435)
+++ libibverbs/debian/libibverbs1.postinst	(working copy)
@@ -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#
--- libibverbs/debian/changelog	(revision 7435)
+++ libibverbs/debian/changelog	(working copy)
@@ -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 at cisco.com>  Thu,  4 May 2006 13:46:44 -0700
+ -- Roland Dreier <rolandd at cisco.com>  Mon, 22 May 2006 23:13:00 -0700
 
 libibverbs (1.0.3-1) unstable; urgency=low
 
--- libibverbs/debian/libibverbs1.install	(revision 7435)
+++ libibverbs/debian/libibverbs1.install	(working copy)
@@ -1 +0,0 @@
-usr/lib/libibverbs*.so.*
--- libibverbs/include/infiniband/driver.h	(revision 7435)
+++ libibverbs/include/infiniband/driver.h	(working copy)
@@ -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>
 
@@ -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,
--- libibverbs/include/infiniband/verbs.h	(revision 7435)
+++ libibverbs/include/infiniband/verbs.h	(working copy)
@@ -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 {
--- libibverbs/include/infiniband/marshall.h	(revision 7435)
+++ libibverbs/include/infiniband/marshall.h	(working copy)
@@ -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 
 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 */
--- libibverbs/include/infiniband/sa.h	(revision 7435)
+++ libibverbs/include/infiniband/sa.h	(working copy)
@@ -38,13 +38,6 @@
 
 #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 */
--- libibverbs/configure.in	(revision 7435)
+++ libibverbs/configure.in	(working copy)
@@ -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 at openib.org)
+AC_INIT(libibverbs, 1.1-pre1, openib-general at 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.
--- libibverbs/ChangeLog	(revision 7435)
+++ libibverbs/ChangeLog	(working copy)
@@ -1,3 +1,25 @@
+2006-05-22  Roland Dreier  <rdreier at 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.
+
+	* Create libibverbs 1.1 branch and bump version number to 1.1-pre1.
+
 2006-05-22  Michael S. Tsirkin  <mst at mellanox.co.il>
 
 	* include/infiniband/verbs.h: Remove trailing commas from
--- libibverbs/src/libibverbs.map	(revision 7435)
+++ libibverbs/src/libibverbs.map	(working copy)
@@ -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: *;
 };
--- libibverbs/src/device.c	(revision 7435)
+++ libibverbs/src/device.c	(working copy)
@@ -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_dev
 
 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_
 	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(stru
 	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;
 
--- libibverbs/src/verbs.c	(revision 7435)
+++ libibverbs/src/verbs.c	(working copy)
@@ -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 *co
 
 	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 *c
 
 	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;
 
--- libibverbs/src/init.c	(revision 7435)
+++ libibverbs/src/init.c	(working copy)
@@ -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);
 
-	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, "abi_version", value, sizeof value) > 0)
+		abi_ver = strtol(value, NULL, 10);
+
+	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;
+		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;
-		}
+		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(s
 	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_devic
 	 */
 	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;
 }
--- libibverbs/src/cmd.c	(revision 7435)
+++ libibverbs/src/cmd.c	(working copy)
@@ -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"
 
--- libibverbs/src/marshall.c	(revision 7435)
+++ libibverbs/src/marshall.c	(working copy)
@@ -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 ib
 	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);
-}
--- libibverbs/src/sysfs.c	(revision 7435)
+++ libibverbs/src/sysfs.c	(working copy)
@@ -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;
--- libibverbs/Makefile.am	(revision 7435)
+++ libibverbs/Makefile.am	(working copy)
@@ -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_
     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 \
--- libibverbs/README	(revision 7435)
+++ libibverbs/README	(working copy)
@@ -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
 -------------------
 
--- libibverbs/examples/devinfo.c	(revision 7435)
+++ libibverbs/examples/devinfo.c	(working copy)
@@ -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_devi
 	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_devi
 	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);
 



More information about the general mailing list