aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorRoland Dreier <roland@purestorage.com>2012-02-27 12:15:08 -0500
committerRoland Dreier <roland@purestorage.com>2012-02-27 12:15:08 -0500
commite9319b0cb00d4d68792fdae37e81e316cb632cb9 (patch)
tree9947cf3123745e0cab9c587566a00a14e949459f /drivers/infiniband
parent6b21d18ed50c7d145220b0724ea7f2613abf0f95 (diff)
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/infiniband')
-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,
179{ 179{
180 struct ib_port_attr attr; 180 struct ib_port_attr attr;
181 char *speed = ""; 181 char *speed = "";
182 int rate; 182 int rate = -1; /* in deci-Gb/sec */
183 ssize_t ret; 183 ssize_t ret;
184 184
185 ret = ib_query_port(p->ibdev, p->port_num, &attr); 185 ret = ib_query_port(p->ibdev, p->port_num, &attr);
186 if (ret) 186 if (ret)
187 return ret; 187 return ret;
188 188
189 rate = (25 * attr.active_speed) / 10;
190
191 switch (attr.active_speed) { 189 switch (attr.active_speed) {
190 case 1:
191 /* SDR */
192 rate = 25;
193 break;
192 case 2: 194 case 2:
193 speed = " DDR"; 195 speed = " DDR";
196 rate = 50;
194 break; 197 break;
195 case 4: 198 case 4:
196 speed = " QDR"; 199 speed = " QDR";
200 rate = 100;
197 break; 201 break;
198 case 8: 202 case 8:
199 speed = " FDR10"; 203 speed = " FDR10";
200 rate = 10; 204 rate = 100;
201 break; 205 break;
202 case 16: 206 case 16:
203 speed = " FDR"; 207 speed = " FDR";
204 rate = 14; 208 rate = 140;
205 break; 209 break;
206 case 32: 210 case 32:
207 speed = " EDR"; 211 speed = " EDR";
208 rate = 25; 212 rate = 250;
209 break; 213 break;
210 } 214 }
211 215
@@ -214,7 +218,7 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
214 return -EINVAL; 218 return -EINVAL;
215 219
216 return sprintf(buf, "%d%s Gb/sec (%dX%s)\n", 220 return sprintf(buf, "%d%s Gb/sec (%dX%s)\n",
217 rate, (attr.active_speed == 1) ? ".5" : "", 221 rate / 10, rate % 10 ? ".5" : "",
218 ib_width_enum_to_int(attr.active_width), speed); 222 ib_width_enum_to_int(attr.active_width), speed);
219} 223}
220 224