[openib-general] [PATCH] update libipathverbs library to the new initialization method

Ralph Campbell ralphc at pathscale.com
Fri Jun 16 15:48:53 PDT 2006


The current libipathverbs driver in the trunk doesn't
conform to the new module initialization convention for
libibverbs.so.  This patch corrects that.

Also, with this patch, we can now try testing the performance
of Roland's changes to eliminate the single ib_uverbs_idr_mutex.

Signed-off-by: Ralph Campbell <ralph.campbell at qlogic.com>

Index: src/userspace/libipathverbs/src/ipathverbs.c
===================================================================
--- src/userspace/libipathverbs/src/ipathverbs.c	(revision 8089)
+++ src/userspace/libipathverbs/src/ipathverbs.c	(working copy)
@@ -145,30 +145,24 @@
 	.free_context	= ipath_free_context
 };
 
-struct ibv_device *openib_driver_init(struct sysfs_class_device *sysdev)
+struct ibv_device *ibv_driver_init(const char *uverbs_sys_path,
+				   int abi_version)
 {
-	struct sysfs_device    *pcidev;
-	struct sysfs_attribute *attr;
+	char			value[8];
 	struct ipath_device    *dev;
-	unsigned		vendor, device;
-	int			i;
+	unsigned                vendor, device;
+	int                     i;
 
-	pcidev = sysfs_get_classdev_device(sysdev);
-	if (!pcidev)
+	if (ibv_read_sysfs_file(uverbs_sys_path, "device/vendor",
+				value, sizeof value) < 0)
 		return NULL;
+	sscanf(value, "%i", &vendor);
 
-	attr = sysfs_get_device_attr(pcidev, "vendor");
-	if (!attr)
+	if (ibv_read_sysfs_file(uverbs_sys_path, "device/device",
+				value, sizeof value) < 0)
 		return NULL;
-	sscanf(attr->value, "%i", &vendor);
-	sysfs_close_attribute(attr);
+	sscanf(value, "%i", &device);
 
-	attr = sysfs_get_device_attr(pcidev, "device");
-	if (!attr)
-		return NULL;
-	sscanf(attr->value, "%i", &device);
-	sysfs_close_attribute(attr);
-
 	for (i = 0; i < sizeof hca_table / sizeof hca_table[0]; ++i)
 		if (vendor == hca_table[i].vendor &&
 		    device == hca_table[i].device)
@@ -180,13 +174,12 @@
 	dev = malloc(sizeof *dev);
 	if (!dev) {
 		fprintf(stderr, PFX "Fatal: couldn't allocate device for %s\n",
-			sysdev->name);
-		abort();
+			uverbs_sys_path);
+		return NULL;
 	}
 
 	dev->ibv_dev.ops = ipath_dev_ops;
 	dev->hca_type    = hca_table[i].type;
-	dev->page_size   = sysconf(_SC_PAGESIZE);
 
 	return &dev->ibv_dev;
 }
Index: libipathverbs/src/ipathverbs.h
===================================================================
--- libipathverbs/src/ipathverbs.h	(revision 8089)
+++ libipathverbs/src/ipathverbs.h	(working copy)
@@ -57,7 +57,6 @@
 struct ipath_device {
 	struct ibv_device	ibv_dev;
 	enum ipath_hca_type	hca_type;
-	int			page_size;
 };
 
 struct ipath_context {


-- 
Ralph Campbell <ralphc at pathscale.com>





More information about the general mailing list