This patch adds the node_guid to struct ib_device to avoid ULPs needing
to query for it.

It will also make it possible to give users the attributes of a device
as part of their add_device routine.

If this patch is okay with everyone, I will submit patches to remove
the device attribute queries in the CM, SRP, and sysfs.

Signed-off-by: Sean Hefty <[EMAIL PROTECTED]>

Index: include/rdma/ib_verbs.h
===================================================================
--- include/rdma/ib_verbs.h     (revision 3340)
+++ include/rdma/ib_verbs.h     (working copy)
@@ -952,6 +952,7 @@ struct ib_device {
                IB_DEV_UNREGISTERED
        }                            reg_state;
 
+       __be64                       node_guid;
        u8                           node_type;
        u8                           phys_port_cnt;
 };
Index: core/device.c
===================================================================
--- core/device.c       (revision 3340)
+++ core/device.c       (working copy)
@@ -227,8 +227,15 @@ static int add_client_context(struct ib_
  */
 int ib_register_device(struct ib_device *device)
 {
+       struct ib_device_attr *device_attr = NULL;
        int ret;
 
+       device_attr = kmalloc(sizeof *device_attr, GFP_KERNEL);
+       if (!device_attr) {
+               ret = -ENOMEM;
+               goto out;
+       }
+
        down(&device_sem);
 
        if (strchr(device->name, '%')) {
@@ -247,6 +254,12 @@ int ib_register_device(struct ib_device 
        spin_lock_init(&device->event_handler_lock);
        spin_lock_init(&device->client_data_lock);
 
+       ret = ib_query_device(device, device_attr);
+       if (ret)
+               goto out;
+
+       device->node_guid = device_attr->node_guid;
+
        ret = ib_device_register_sysfs(device);
        if (ret) {
                printk(KERN_WARNING "Couldn't register device %s with driver 
model\n",
@@ -268,6 +281,7 @@ int ib_register_device(struct ib_device 
 
  out:
        up(&device_sem);
+       kfree(device_attr);
        return ret;
 }
 EXPORT_SYMBOL(ib_register_device);



_______________________________________________
openib-general mailing list
[email protected]
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to