aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2006-02-02 12:47:14 -0500
committerRoland Dreier <rolandd@cisco.com>2006-03-20 13:08:09 -0500
commitc5bcbbb9fe00128d500c2f473d5ddc8d8c2c53a7 (patch)
treec4a6feac1bc1dfd9e2fbe88c8e6ad1db4a47a817 /drivers/infiniband
parent2fa5e2ebbe2d81f741ba7bed9e07dc38cc734625 (diff)
IB: Allow userspace to set node description
Expose a writable "node_desc" sysfs attribute for InfiniBand devices. This allows userspace to update the node description with information such as the node's hostname, so that IB network management software can tie its view to the real world. Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il> Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/core/sysfs.c30
1 files changed, 29 insertions, 1 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 = {