aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/infiniband/core/sysfs.c30
-rw-r--r--include/rdma/ib_verbs.h5
2 files changed, 33 insertions, 2 deletions
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 5982d687a000..49601bb8475b 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -628,14 +628,42 @@ static ssize_t show_node_guid(struct class_device *cdev, char *buf)
628 be16_to_cpu(((__be16 *) &dev->node_guid)[3])); 628 be16_to_cpu(((__be16 *) &dev->node_guid)[3]));
629} 629}
630 630
631static ssize_t show_node_desc(struct class_device *cdev, char *buf)
632{
633 struct ib_device *dev = container_of(cdev, struct ib_device, class_dev);
634
635 return sprintf(buf, "%.64s\n", dev->node_desc);
636}
637
638static ssize_t set_node_desc(struct class_device *cdev, const char *buf,
639 size_t count)
640{
641 struct ib_device *dev = container_of(cdev, struct ib_device, class_dev);
642 struct ib_device_modify desc = {};
643 int ret;
644
645 if (!dev->modify_device)
646 return -EIO;
647
648 memcpy(desc.node_desc, buf, min_t(int, count, 64));
649 ret = ib_modify_device(dev, IB_DEVICE_MODIFY_NODE_DESC, &desc);
650 if (ret)
651 return ret;
652
653 return count;
654}
655
631static CLASS_DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL); 656static CLASS_DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL);
632static CLASS_DEVICE_ATTR(sys_image_guid, S_IRUGO, show_sys_image_guid, NULL); 657static CLASS_DEVICE_ATTR(sys_image_guid, S_IRUGO, show_sys_image_guid, NULL);
633static CLASS_DEVICE_ATTR(node_guid, S_IRUGO, show_node_guid, NULL); 658static CLASS_DEVICE_ATTR(node_guid, S_IRUGO, show_node_guid, NULL);
659static CLASS_DEVICE_ATTR(node_desc, S_IRUGO | S_IWUSR, show_node_desc,
660 set_node_desc);
634 661
635static struct class_device_attribute *ib_class_attributes[] = { 662static struct class_device_attribute *ib_class_attributes[] = {
636 &class_device_attr_node_type, 663 &class_device_attr_node_type,
637 &class_device_attr_sys_image_guid, 664 &class_device_attr_sys_image_guid,
638 &class_device_attr_node_guid 665 &class_device_attr_node_guid,
666 &class_device_attr_node_desc
639}; 667};
640 668
641static struct class ib_class = { 669static struct class ib_class = {
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 38fa6c082eae..1d31c8cd5ce0 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -222,11 +222,13 @@ struct ib_port_attr {
222}; 222};
223 223
224enum ib_device_modify_flags { 224enum ib_device_modify_flags {
225 IB_DEVICE_MODIFY_SYS_IMAGE_GUID = 1 225 IB_DEVICE_MODIFY_SYS_IMAGE_GUID = 1 << 0,
226 IB_DEVICE_MODIFY_NODE_DESC = 1 << 1
226}; 227};
227 228
228struct ib_device_modify { 229struct ib_device_modify {
229 u64 sys_image_guid; 230 u64 sys_image_guid;
231 char node_desc[64];
230}; 232};
231 233
232enum ib_port_modify_flags { 234enum ib_port_modify_flags {
@@ -951,6 +953,7 @@ struct ib_device {
951 u64 uverbs_cmd_mask; 953 u64 uverbs_cmd_mask;
952 int uverbs_abi_ver; 954 int uverbs_abi_ver;
953 955
956 char node_desc[64];
954 __be64 node_guid; 957 __be64 node_guid;
955 u8 node_type; 958 u8 node_type;
956 u8 phys_port_cnt; 959 u8 phys_port_cnt;