summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRoland Dreier <roland@purestorage.com>2012-02-27 09:15:08 -0800
committerRoland Dreier <roland@purestorage.com>2012-02-27 09:15:08 -0800
commite9319b0cb00d4d68792fdae37e81e316cb632cb9 (patch)
tree9947cf3123745e0cab9c587566a00a14e949459f /drivers
parent6b21d18ed50c7d145220b0724ea7f2613abf0f95 (diff)
downloadlinux-e9319b0cb00d4d68792fdae37e81e316cb632cb9.tar.bz2
IB/core: Fix SDR rates in sysfs
Commit 71eeba16 ("IB: Add new InfiniBand link speeds") introduced a bug where eg the rate for IB 4X SDR links iss displayed as "8.5 Gb/sec" instead of "10 Gb/sec" as it used to be. Fix that. Reported-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/infiniband/core/sysfs.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index c61bca30fd2d..a860b6ddbb61 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -179,33 +179,37 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
{
struct ib_port_attr attr;
char *speed = "";
- int rate;
+ int rate = -1; /* in deci-Gb/sec */
ssize_t ret;
ret = ib_query_port(p->ibdev, p->port_num, &attr);
if (ret)
return ret;
- rate = (25 * attr.active_speed) / 10;
-
switch (attr.active_speed) {
+ case 1:
+ /* SDR */
+ rate = 25;
+ break;
case 2:
speed = " DDR";
+ rate = 50;
break;
case 4:
speed = " QDR";
+ rate = 100;
break;
case 8:
speed = " FDR10";
- rate = 10;
+ rate = 100;
break;
case 16:
speed = " FDR";
- rate = 14;
+ rate = 140;
break;
case 32:
speed = " EDR";
- rate = 25;
+ rate = 250;
break;
}
@@ -214,7 +218,7 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
return -EINVAL;
return sprintf(buf, "%d%s Gb/sec (%dX%s)\n",
- rate, (attr.active_speed == 1) ? ".5" : "",
+ rate / 10, rate % 10 ? ".5" : "",
ib_width_enum_to_int(attr.active_width), speed);
}