diff options
author | Roland Dreier <roland@topspin.com> | 2005-01-14 23:18:11 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-01-14 23:18:11 -0800 |
commit | e19ab8f1d191a217fb33a7af4b057fb078a712f2 (patch) | |
tree | 619bb0a8dda35bcf57c0394c8ef12be467f789d4 /drivers | |
parent | 8f3a8f3e42217cc4886ca0e05a716a9941fa202f (diff) | |
download | history-e19ab8f1d191a217fb33a7af4b057fb078a712f2.tar.gz |
[PATCH] InfiniBand/core: add node_type and phys_state sysfs attrs
Add per-device "node_type" and per-port "phys_state" sysfs attributes for
InfiniBand devices.
Signed-off-by: Roland Dreier <roland@topspin.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/infiniband/core/sysfs.c | 39 | ||||
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_provider.c | 1 | ||||
-rw-r--r-- | drivers/infiniband/include/ib_verbs.h | 1 |
3 files changed, 41 insertions, 0 deletions
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index 06c80febd052b0..ef898282276677 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c @@ -197,6 +197,29 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused, ib_width_enum_to_int(attr.active_width), speed); } +static ssize_t phys_state_show(struct ib_port *p, struct port_attribute *unused, + char *buf) +{ + struct ib_port_attr attr; + + ssize_t ret; + + ret = ib_query_port(p->ibdev, p->port_num, &attr); + if (ret) + return ret; + + switch (attr.phys_state) { + case 1: return sprintf(buf, "1: Sleep\n"); + case 2: return sprintf(buf, "2: Polling\n"); + case 3: return sprintf(buf, "3: Disabled\n"); + case 4: return sprintf(buf, "4: PortConfigurationTraining\n"); + case 5: return sprintf(buf, "5: LinkUp\n"); + case 6: return sprintf(buf, "6: LinkErrorRecovery\n"); + case 7: return sprintf(buf, "7: Phy Test\n"); + default: return sprintf(buf, "%d: <unknown>\n", attr.phys_state); + } +} + static PORT_ATTR_RO(state); static PORT_ATTR_RO(lid); static PORT_ATTR_RO(lid_mask_count); @@ -204,6 +227,7 @@ static PORT_ATTR_RO(sm_lid); static PORT_ATTR_RO(sm_sl); static PORT_ATTR_RO(cap_mask); static PORT_ATTR_RO(rate); +static PORT_ATTR_RO(phys_state); static struct attribute *port_default_attrs[] = { &port_attr_state.attr, @@ -213,6 +237,7 @@ static struct attribute *port_default_attrs[] = { &port_attr_sm_sl.attr, &port_attr_cap_mask.attr, &port_attr_rate.attr, + &port_attr_phys_state.attr, NULL }; @@ -572,6 +597,18 @@ err: return ret; } +static ssize_t show_node_type(struct class_device *cdev, char *buf) +{ + struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); + + switch (dev->node_type) { + case IB_NODE_CA: return sprintf(buf, "%d: CA\n", dev->node_type); + case IB_NODE_SWITCH: return sprintf(buf, "%d: switch\n", dev->node_type); + case IB_NODE_ROUTER: return sprintf(buf, "%d: router\n", dev->node_type); + default: return sprintf(buf, "%d: <unknown>\n", dev->node_type); + } +} + static ssize_t show_sys_image_guid(struct class_device *cdev, char *buf) { struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); @@ -606,10 +643,12 @@ static ssize_t show_node_guid(struct class_device *cdev, char *buf) be16_to_cpu(((u16 *) &attr.node_guid)[3])); } +static CLASS_DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL); static CLASS_DEVICE_ATTR(sys_image_guid, S_IRUGO, show_sys_image_guid, NULL); static CLASS_DEVICE_ATTR(node_guid, S_IRUGO, show_node_guid, NULL); static struct class_device_attribute *ib_class_attributes[] = { + &class_device_attr_node_type, &class_device_attr_sys_image_guid, &class_device_attr_node_guid }; diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c index 57427770702d72..f3fe647d98e332 100644 --- a/drivers/infiniband/hw/mthca/mthca_provider.c +++ b/drivers/infiniband/hw/mthca/mthca_provider.c @@ -119,6 +119,7 @@ static int mthca_query_port(struct ib_device *ibdev, props->sm_lid = be16_to_cpup((u16 *) (out_mad->data + 18)); props->sm_sl = out_mad->data[36] & 0xf; props->state = out_mad->data[32] & 0xf; + props->phys_state = out_mad->data[33] >> 4; props->port_cap_flags = be32_to_cpup((u32 *) (out_mad->data + 20)); props->gid_tbl_len = to_mdev(ibdev)->limits.gid_table_len; props->pkey_tbl_len = to_mdev(ibdev)->limits.pkey_table_len; diff --git a/drivers/infiniband/include/ib_verbs.h b/drivers/infiniband/include/ib_verbs.h index 321c45f0e9f65a..9a1e19422724a5 100644 --- a/drivers/infiniband/include/ib_verbs.h +++ b/drivers/infiniband/include/ib_verbs.h @@ -212,6 +212,7 @@ struct ib_port_attr { u8 init_type_reply; u8 active_width; u8 active_speed; + u8 phys_state; }; enum ib_device_modify_flags { |