提交 e9319b0c 编写于 作者: R Roland Dreier

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: NOr Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: NRoland Dreier <roland@purestorage.com>
上级 6b21d18e
...@@ -179,33 +179,37 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused, ...@@ -179,33 +179,37 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
{ {
struct ib_port_attr attr; struct ib_port_attr attr;
char *speed = ""; char *speed = "";
int rate; int rate = -1; /* in deci-Gb/sec */
ssize_t ret; ssize_t ret;
ret = ib_query_port(p->ibdev, p->port_num, &attr); ret = ib_query_port(p->ibdev, p->port_num, &attr);
if (ret) if (ret)
return ret; return ret;
rate = (25 * attr.active_speed) / 10;
switch (attr.active_speed) { switch (attr.active_speed) {
case 1:
/* SDR */
rate = 25;
break;
case 2: case 2:
speed = " DDR"; speed = " DDR";
rate = 50;
break; break;
case 4: case 4:
speed = " QDR"; speed = " QDR";
rate = 100;
break; break;
case 8: case 8:
speed = " FDR10"; speed = " FDR10";
rate = 10; rate = 100;
break; break;
case 16: case 16:
speed = " FDR"; speed = " FDR";
rate = 14; rate = 140;
break; break;
case 32: case 32:
speed = " EDR"; speed = " EDR";
rate = 25; rate = 250;
break; break;
} }
...@@ -214,7 +218,7 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused, ...@@ -214,7 +218,7 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
return -EINVAL; return -EINVAL;
return sprintf(buf, "%d%s Gb/sec (%dX%s)\n", 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); ib_width_enum_to_int(attr.active_width), speed);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册