diff options
Diffstat (limited to 'drivers/infiniband/core/sysfs.c')
-rw-r--r-- | drivers/infiniband/core/sysfs.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index 9ab5df72df7b..c61bca30fd2d 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include "core_priv.h" | 35 | #include "core_priv.h" |
36 | 36 | ||
37 | #include <linux/slab.h> | 37 | #include <linux/slab.h> |
38 | #include <linux/stat.h> | ||
38 | #include <linux/string.h> | 39 | #include <linux/string.h> |
39 | 40 | ||
40 | #include <rdma/ib_mad.h> | 41 | #include <rdma/ib_mad.h> |
@@ -185,17 +186,35 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused, | |||
185 | if (ret) | 186 | if (ret) |
186 | return ret; | 187 | return ret; |
187 | 188 | ||
189 | rate = (25 * attr.active_speed) / 10; | ||
190 | |||
188 | switch (attr.active_speed) { | 191 | switch (attr.active_speed) { |
189 | case 2: speed = " DDR"; break; | 192 | case 2: |
190 | case 4: speed = " QDR"; break; | 193 | speed = " DDR"; |
194 | break; | ||
195 | case 4: | ||
196 | speed = " QDR"; | ||
197 | break; | ||
198 | case 8: | ||
199 | speed = " FDR10"; | ||
200 | rate = 10; | ||
201 | break; | ||
202 | case 16: | ||
203 | speed = " FDR"; | ||
204 | rate = 14; | ||
205 | break; | ||
206 | case 32: | ||
207 | speed = " EDR"; | ||
208 | rate = 25; | ||
209 | break; | ||
191 | } | 210 | } |
192 | 211 | ||
193 | rate = 25 * ib_width_enum_to_int(attr.active_width) * attr.active_speed; | 212 | rate *= ib_width_enum_to_int(attr.active_width); |
194 | if (rate < 0) | 213 | if (rate < 0) |
195 | return -EINVAL; | 214 | return -EINVAL; |
196 | 215 | ||
197 | return sprintf(buf, "%d%s Gb/sec (%dX%s)\n", | 216 | return sprintf(buf, "%d%s Gb/sec (%dX%s)\n", |
198 | rate / 10, rate % 10 ? ".5" : "", | 217 | rate, (attr.active_speed == 1) ? ".5" : "", |
199 | ib_width_enum_to_int(attr.active_width), speed); | 218 | ib_width_enum_to_int(attr.active_width), speed); |
200 | } | 219 | } |
201 | 220 | ||