diff options
-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 | ||||
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_provider.c | 40 | ||||
-rw-r--r-- | drivers/infiniband/ulp/srp/ib_srp.c | 23 | ||||
-rw-r--r-- | include/rdma/ib_verbs.h | 2 |
6 files changed, 54 insertions, 64 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; |
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c index 488757766a5d..db35690c91de 100644 --- a/drivers/infiniband/hw/mthca/mthca_provider.c +++ b/drivers/infiniband/hw/mthca/mthca_provider.c | |||
@@ -33,7 +33,7 @@ | |||
33 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | 33 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
34 | * SOFTWARE. | 34 | * SOFTWARE. |
35 | * | 35 | * |
36 | * $Id: mthca_provider.c 1397 2004-12-28 05:09:00Z roland $ | 36 | * $Id: mthca_provider.c 4859 2006-01-09 21:55:10Z roland $ |
37 | */ | 37 | */ |
38 | 38 | ||
39 | #include <rdma/ib_smi.h> | 39 | #include <rdma/ib_smi.h> |
@@ -91,7 +91,6 @@ static int mthca_query_device(struct ib_device *ibdev, | |||
91 | props->vendor_part_id = be16_to_cpup((__be16 *) (out_mad->data + 30)); | 91 | props->vendor_part_id = be16_to_cpup((__be16 *) (out_mad->data + 30)); |
92 | props->hw_ver = be32_to_cpup((__be32 *) (out_mad->data + 32)); | 92 | props->hw_ver = be32_to_cpup((__be32 *) (out_mad->data + 32)); |
93 | memcpy(&props->sys_image_guid, out_mad->data + 4, 8); | 93 | memcpy(&props->sys_image_guid, out_mad->data + 4, 8); |
94 | memcpy(&props->node_guid, out_mad->data + 12, 8); | ||
95 | 94 | ||
96 | props->max_mr_size = ~0ull; | 95 | props->max_mr_size = ~0ull; |
97 | props->page_size_cap = mdev->limits.page_size_cap; | 96 | props->page_size_cap = mdev->limits.page_size_cap; |
@@ -1054,11 +1053,48 @@ static struct class_device_attribute *mthca_class_attributes[] = { | |||
1054 | &class_device_attr_board_id | 1053 | &class_device_attr_board_id |
1055 | }; | 1054 | }; |
1056 | 1055 | ||
1056 | static int mthca_init_node_data(struct mthca_dev *dev) | ||
1057 | { | ||
1058 | struct ib_smp *in_mad = NULL; | ||
1059 | struct ib_smp *out_mad = NULL; | ||
1060 | int err = -ENOMEM; | ||
1061 | u8 status; | ||
1062 | |||
1063 | in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL); | ||
1064 | out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL); | ||
1065 | if (!in_mad || !out_mad) | ||
1066 | goto out; | ||
1067 | |||
1068 | init_query_mad(in_mad); | ||
1069 | in_mad->attr_id = IB_SMP_ATTR_NODE_INFO; | ||
1070 | |||
1071 | err = mthca_MAD_IFC(dev, 1, 1, | ||
1072 | 1, NULL, NULL, in_mad, out_mad, | ||
1073 | &status); | ||
1074 | if (err) | ||
1075 | goto out; | ||
1076 | if (status) { | ||
1077 | err = -EINVAL; | ||
1078 | goto out; | ||
1079 | } | ||
1080 | |||
1081 | memcpy(&dev->ib_dev.node_guid, out_mad->data + 12, 8); | ||
1082 | |||
1083 | out: | ||
1084 | kfree(in_mad); | ||
1085 | kfree(out_mad); | ||
1086 | return err; | ||
1087 | } | ||
1088 | |||
1057 | int mthca_register_device(struct mthca_dev *dev) | 1089 | int mthca_register_device(struct mthca_dev *dev) |
1058 | { | 1090 | { |
1059 | int ret; | 1091 | int ret; |
1060 | int i; | 1092 | int i; |
1061 | 1093 | ||
1094 | ret = mthca_init_node_data(dev); | ||
1095 | if (ret) | ||
1096 | return ret; | ||
1097 | |||
1062 | strlcpy(dev->ib_dev.name, "mthca%d", IB_DEVICE_NAME_MAX); | 1098 | strlcpy(dev->ib_dev.name, "mthca%d", IB_DEVICE_NAME_MAX); |
1063 | dev->ib_dev.owner = THIS_MODULE; | 1099 | dev->ib_dev.owner = THIS_MODULE; |
1064 | 1100 | ||
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index dd488d3cffa9..31207e664148 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c | |||
@@ -1516,8 +1516,7 @@ static ssize_t show_port(struct class_device *class_dev, char *buf) | |||
1516 | 1516 | ||
1517 | static CLASS_DEVICE_ATTR(port, S_IRUGO, show_port, NULL); | 1517 | static CLASS_DEVICE_ATTR(port, S_IRUGO, show_port, NULL); |
1518 | 1518 | ||
1519 | static struct srp_host *srp_add_port(struct ib_device *device, | 1519 | static struct srp_host *srp_add_port(struct ib_device *device, u8 port) |
1520 | __be64 node_guid, u8 port) | ||
1521 | { | 1520 | { |
1522 | struct srp_host *host; | 1521 | struct srp_host *host; |
1523 | 1522 | ||
@@ -1532,7 +1531,7 @@ static struct srp_host *srp_add_port(struct ib_device *device, | |||
1532 | host->port = port; | 1531 | host->port = port; |
1533 | 1532 | ||
1534 | host->initiator_port_id[7] = port; | 1533 | host->initiator_port_id[7] = port; |
1535 | memcpy(host->initiator_port_id + 8, &node_guid, 8); | 1534 | memcpy(host->initiator_port_id + 8, &device->node_guid, 8); |
1536 | 1535 | ||
1537 | host->pd = ib_alloc_pd(device); | 1536 | host->pd = ib_alloc_pd(device); |
1538 | if (IS_ERR(host->pd)) | 1537 | if (IS_ERR(host->pd)) |
@@ -1580,22 +1579,11 @@ static void srp_add_one(struct ib_device *device) | |||
1580 | { | 1579 | { |
1581 | struct list_head *dev_list; | 1580 | struct list_head *dev_list; |
1582 | struct srp_host *host; | 1581 | struct srp_host *host; |
1583 | struct ib_device_attr *dev_attr; | ||
1584 | int s, e, p; | 1582 | int s, e, p; |
1585 | 1583 | ||
1586 | dev_attr = kmalloc(sizeof *dev_attr, GFP_KERNEL); | ||
1587 | if (!dev_attr) | ||
1588 | return; | ||
1589 | |||
1590 | if (ib_query_device(device, dev_attr)) { | ||
1591 | printk(KERN_WARNING PFX "Couldn't query node GUID for %s.\n", | ||
1592 | device->name); | ||
1593 | goto out; | ||
1594 | } | ||
1595 | |||
1596 | dev_list = kmalloc(sizeof *dev_list, GFP_KERNEL); | 1584 | dev_list = kmalloc(sizeof *dev_list, GFP_KERNEL); |
1597 | if (!dev_list) | 1585 | if (!dev_list) |
1598 | goto out; | 1586 | return; |
1599 | 1587 | ||
1600 | INIT_LIST_HEAD(dev_list); | 1588 | INIT_LIST_HEAD(dev_list); |
1601 | 1589 | ||
@@ -1608,15 +1596,12 @@ static void srp_add_one(struct ib_device *device) | |||
1608 | } | 1596 | } |
1609 | 1597 | ||
1610 | for (p = s; p <= e; ++p) { | 1598 | for (p = s; p <= e; ++p) { |
1611 | host = srp_add_port(device, dev_attr->node_guid, p); | 1599 | host = srp_add_port(device, p); |
1612 | if (host) | 1600 | if (host) |
1613 | list_add_tail(&host->list, dev_list); | 1601 | list_add_tail(&host->list, dev_list); |
1614 | } | 1602 | } |
1615 | 1603 | ||
1616 | ib_set_client_data(device, &srp_client, dev_list); | 1604 | ib_set_client_data(device, &srp_client, dev_list); |
1617 | |||
1618 | out: | ||
1619 | kfree(dev_attr); | ||
1620 | } | 1605 | } |
1621 | 1606 | ||
1622 | static void srp_remove_one(struct ib_device *device) | 1607 | static void srp_remove_one(struct ib_device *device) |
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index a7f4c355a91f..22fc886b9695 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h | |||
@@ -88,7 +88,6 @@ enum ib_atomic_cap { | |||
88 | 88 | ||
89 | struct ib_device_attr { | 89 | struct ib_device_attr { |
90 | u64 fw_ver; | 90 | u64 fw_ver; |
91 | __be64 node_guid; | ||
92 | __be64 sys_image_guid; | 91 | __be64 sys_image_guid; |
93 | u64 max_mr_size; | 92 | u64 max_mr_size; |
94 | u64 page_size_cap; | 93 | u64 page_size_cap; |
@@ -951,6 +950,7 @@ struct ib_device { | |||
951 | u64 uverbs_cmd_mask; | 950 | u64 uverbs_cmd_mask; |
952 | int uverbs_abi_ver; | 951 | int uverbs_abi_ver; |
953 | 952 | ||
953 | __be64 node_guid; | ||
954 | u8 node_type; | 954 | u8 node_type; |
955 | u8 phys_port_cnt; | 955 | u8 phys_port_cnt; |
956 | }; | 956 | }; |