IB/core: Save the device attributes on the device structure
authorIra Weiny <ira.weiny@intel.com>
Fri, 18 Dec 2015 08:59:44 +0000 (10:59 +0200)
committerDoug Ledford <dledford@redhat.com>
Tue, 22 Dec 2015 19:39:00 +0000 (14:39 -0500)
This way both the IB core and upper level drivers can access these cached
device attributes rather than querying or caching them on their own.

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/core/device.c
include/rdma/ib_verbs.h

index 179e8134d57fc13b425254d5162006f9fc201879..568592e31b443c979928b77a77edfe61ce1ce253 100644 (file)
@@ -325,6 +325,7 @@ int ib_register_device(struct ib_device *device,
 {
        int ret;
        struct ib_client *client;
+       struct ib_udata uhw = {.outlen = 0, .inlen = 0};
 
        mutex_lock(&device_mutex);
 
@@ -352,6 +353,13 @@ int ib_register_device(struct ib_device *device,
                goto out;
        }
 
+       memset(&device->attrs, 0, sizeof(device->attrs));
+       ret = device->query_device(device, &device->attrs, &uhw);
+       if (ret) {
+               printk(KERN_WARNING "Couldn't query the device attributes\n");
+               goto out;
+       }
+
        ret = ib_device_register_sysfs(device, port_callback);
        if (ret) {
                printk(KERN_WARNING "Couldn't register device %s with driver model\n",
index 120da1d7f57eb578c327507ad2affa5b89488dbb..730dcfb209b97437af9ecd7aedbaafccfe20bb58 100644 (file)
@@ -1823,6 +1823,7 @@ struct ib_device {
        u16                          is_switch:1;
        u8                           node_type;
        u8                           phys_port_cnt;
+       struct ib_device_attr        attrs;
 
        /**
         * The following mandatory functions are used only at device