diff options
author | Sean Hefty <sean.hefty@intel.com> | 2006-01-10 10:39:34 -0500 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2006-01-10 10:39:34 -0500 |
commit | cf311cd49a78f1e431787068cc31d29d06a415e6 (patch) | |
tree | 369bb01420f5120df73c12903eb9e7783b8489ad /drivers/infiniband/core | |
parent | 87635b71b544563f29050a9cecaa12b5d2a3e34a (diff) |
IB: Add node_guid to struct ib_device
Add a node_guid field to struct ib_device. It is the responsibility
of the low-level driver to initialize this field before registering a
device with the midlayer. Convert everyone to looking at this field
instead of calling ib_query_device() when all they want is the node
GUID, and remove the node_guid field from struct ib_device_attr.
Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/core')
-rw-r--r-- | drivers/infiniband/core/cm.c | 29 | ||||
-rw-r--r-- | drivers/infiniband/core/sysfs.c | 22 | ||||
-rw-r--r-- | drivers/infiniband/core/uverbs_cmd.c | 2 |
3 files changed, 11 insertions, 42 deletions
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index 3a611fe5497e..c06b18102b6a 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c | |||
@@ -3163,22 +3163,6 @@ int ib_cm_init_qp_attr(struct ib_cm_id *cm_id, | |||
3163 | } | 3163 | } |
3164 | EXPORT_SYMBOL(ib_cm_init_qp_attr); | 3164 | EXPORT_SYMBOL(ib_cm_init_qp_attr); |
3165 | 3165 | ||
3166 | static __be64 cm_get_ca_guid(struct ib_device *device) | ||
3167 | { | ||
3168 | struct ib_device_attr *device_attr; | ||
3169 | __be64 guid; | ||
3170 | int ret; | ||
3171 | |||
3172 | device_attr = kmalloc(sizeof *device_attr, GFP_KERNEL); | ||
3173 | if (!device_attr) | ||
3174 | return 0; | ||
3175 | |||
3176 | ret = ib_query_device(device, device_attr); | ||
3177 | guid = ret ? 0 : device_attr->node_guid; | ||
3178 | kfree(device_attr); | ||
3179 | return guid; | ||
3180 | } | ||
3181 | |||
3182 | static void cm_add_one(struct ib_device *device) | 3166 | static void cm_add_one(struct ib_device *device) |
3183 | { | 3167 | { |
3184 | struct cm_device *cm_dev; | 3168 | struct cm_device *cm_dev; |
@@ -3200,9 +3184,7 @@ static void cm_add_one(struct ib_device *device) | |||
3200 | return; | 3184 | return; |
3201 | 3185 | ||
3202 | cm_dev->device = device; | 3186 | cm_dev->device = device; |
3203 | cm_dev->ca_guid = cm_get_ca_guid(device); | 3187 | cm_dev->ca_guid = device->node_guid; |
3204 | if (!cm_dev->ca_guid) | ||
3205 | goto error1; | ||
3206 | 3188 | ||
3207 | set_bit(IB_MGMT_METHOD_SEND, reg_req.method_mask); | 3189 | set_bit(IB_MGMT_METHOD_SEND, reg_req.method_mask); |
3208 | for (i = 1; i <= device->phys_port_cnt; i++) { | 3190 | for (i = 1; i <= device->phys_port_cnt; i++) { |
@@ -3217,11 +3199,11 @@ static void cm_add_one(struct ib_device *device) | |||
3217 | cm_recv_handler, | 3199 | cm_recv_handler, |
3218 | port); | 3200 | port); |
3219 | if (IS_ERR(port->mad_agent)) | 3201 | if (IS_ERR(port->mad_agent)) |
3220 | goto error2; | 3202 | goto error1; |
3221 | 3203 | ||
3222 | ret = ib_modify_port(device, i, 0, &port_modify); | 3204 | ret = ib_modify_port(device, i, 0, &port_modify); |
3223 | if (ret) | 3205 | if (ret) |
3224 | goto error3; | 3206 | goto error2; |
3225 | } | 3207 | } |
3226 | ib_set_client_data(device, &cm_client, cm_dev); | 3208 | ib_set_client_data(device, &cm_client, cm_dev); |
3227 | 3209 | ||
@@ -3230,9 +3212,9 @@ static void cm_add_one(struct ib_device *device) | |||
3230 | write_unlock_irqrestore(&cm.device_lock, flags); | 3212 | write_unlock_irqrestore(&cm.device_lock, flags); |
3231 | return; | 3213 | return; |
3232 | 3214 | ||
3233 | error3: | ||
3234 | ib_unregister_mad_agent(port->mad_agent); | ||
3235 | error2: | 3215 | error2: |
3216 | ib_unregister_mad_agent(port->mad_agent); | ||
3217 | error1: | ||
3236 | port_modify.set_port_cap_mask = 0; | 3218 | port_modify.set_port_cap_mask = 0; |
3237 | port_modify.clr_port_cap_mask = IB_PORT_CM_SUP; | 3219 | port_modify.clr_port_cap_mask = IB_PORT_CM_SUP; |
3238 | while (--i) { | 3220 | while (--i) { |
@@ -3240,7 +3222,6 @@ error2: | |||
3240 | ib_modify_port(device, port->port_num, 0, &port_modify); | 3222 | ib_modify_port(device, port->port_num, 0, &port_modify); |
3241 | ib_unregister_mad_agent(port->mad_agent); | 3223 | ib_unregister_mad_agent(port->mad_agent); |
3242 | } | 3224 | } |
3243 | error1: | ||
3244 | kfree(cm_dev); | 3225 | kfree(cm_dev); |
3245 | } | 3226 | } |
3246 | 3227 | ||
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index 1f1743c5c9a3..5982d687a000 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c | |||
@@ -445,13 +445,7 @@ static int ib_device_uevent(struct class_device *cdev, char **envp, | |||
445 | return -ENOMEM; | 445 | return -ENOMEM; |
446 | 446 | ||
447 | /* | 447 | /* |
448 | * It might be nice to pass the node GUID with the event, but | 448 | * It would be nice to pass the node GUID with the event... |
449 | * right now the only way to get it is to query the device | ||
450 | * provider, and this can crash during device removal because | ||
451 | * we are will be running after driver removal has started. | ||
452 | * We could add a node_guid field to struct ib_device, or we | ||
453 | * could just let userspace read the node GUID from sysfs when | ||
454 | * devices are added. | ||
455 | */ | 449 | */ |
456 | 450 | ||
457 | envp[i] = NULL; | 451 | envp[i] = NULL; |
@@ -623,21 +617,15 @@ static ssize_t show_sys_image_guid(struct class_device *cdev, char *buf) | |||
623 | static ssize_t show_node_guid(struct class_device *cdev, char *buf) | 617 | static ssize_t show_node_guid(struct class_device *cdev, char *buf) |
624 | { | 618 | { |
625 | struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); | 619 | struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); |
626 | struct ib_device_attr attr; | ||
627 | ssize_t ret; | ||
628 | 620 | ||
629 | if (!ibdev_is_alive(dev)) | 621 | if (!ibdev_is_alive(dev)) |
630 | return -ENODEV; | 622 | return -ENODEV; |
631 | 623 | ||
632 | ret = ib_query_device(dev, &attr); | ||
633 | if (ret) | ||
634 | return ret; | ||
635 | |||
636 | return sprintf(buf, "%04x:%04x:%04x:%04x\n", | 624 | return sprintf(buf, "%04x:%04x:%04x:%04x\n", |
637 | be16_to_cpu(((__be16 *) &attr.node_guid)[0]), | 625 | be16_to_cpu(((__be16 *) &dev->node_guid)[0]), |
638 | be16_to_cpu(((__be16 *) &attr.node_guid)[1]), | 626 | be16_to_cpu(((__be16 *) &dev->node_guid)[1]), |
639 | be16_to_cpu(((__be16 *) &attr.node_guid)[2]), | 627 | be16_to_cpu(((__be16 *) &dev->node_guid)[2]), |
640 | be16_to_cpu(((__be16 *) &attr.node_guid)[3])); | 628 | be16_to_cpu(((__be16 *) &dev->node_guid)[3])); |
641 | } | 629 | } |
642 | 630 | ||
643 | static CLASS_DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL); | 631 | static CLASS_DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL); |
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index a02c5a05c984..554c2057b7c1 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c | |||
@@ -157,7 +157,7 @@ ssize_t ib_uverbs_query_device(struct ib_uverbs_file *file, | |||
157 | memset(&resp, 0, sizeof resp); | 157 | memset(&resp, 0, sizeof resp); |
158 | 158 | ||
159 | resp.fw_ver = attr.fw_ver; | 159 | resp.fw_ver = attr.fw_ver; |
160 | resp.node_guid = attr.node_guid; | 160 | resp.node_guid = file->device->ib_dev->node_guid; |
161 | resp.sys_image_guid = attr.sys_image_guid; | 161 | resp.sys_image_guid = attr.sys_image_guid; |
162 | resp.max_mr_size = attr.max_mr_size; | 162 | resp.max_mr_size = attr.max_mr_size; |
163 | resp.page_size_cap = attr.page_size_cap; | 163 | resp.page_size_cap = attr.page_size_cap; |