mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 02:24:24 +02:00
IB/core: Refactor rate_show to use ib_port_attr_to_rate()
Update sysfs rate_show() to rely on ib_port_attr_to_speed_info() for converting IB port speed and width attributes to data rate and speed string. Signed-off-by: Or Har-Toov <ohartoov@nvidia.com> Reviewed-by: Maher Sanalla <msanalla@nvidia.com> Reviewed-by: Mark Bloch <mbloch@nvidia.com> Signed-off-by: Edward Srouji <edwards@nvidia.com> Signed-off-by: Leon Romanovsky <leon@kernel.org>
This commit is contained in:
parent
2941abac6d
commit
d4adeff26c
|
|
@ -292,62 +292,22 @@ static ssize_t cap_mask_show(struct ib_device *ibdev, u32 port_num,
|
|||
static ssize_t rate_show(struct ib_device *ibdev, u32 port_num,
|
||||
struct ib_port_attribute *unused, char *buf)
|
||||
{
|
||||
struct ib_port_speed_info speed_info;
|
||||
struct ib_port_attr attr;
|
||||
char *speed = "";
|
||||
int rate; /* in deci-Gb/sec */
|
||||
ssize_t ret;
|
||||
|
||||
ret = ib_query_port(ibdev, port_num, &attr);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
switch (attr.active_speed) {
|
||||
case IB_SPEED_DDR:
|
||||
speed = " DDR";
|
||||
rate = 50;
|
||||
break;
|
||||
case IB_SPEED_QDR:
|
||||
speed = " QDR";
|
||||
rate = 100;
|
||||
break;
|
||||
case IB_SPEED_FDR10:
|
||||
speed = " FDR10";
|
||||
rate = 100;
|
||||
break;
|
||||
case IB_SPEED_FDR:
|
||||
speed = " FDR";
|
||||
rate = 140;
|
||||
break;
|
||||
case IB_SPEED_EDR:
|
||||
speed = " EDR";
|
||||
rate = 250;
|
||||
break;
|
||||
case IB_SPEED_HDR:
|
||||
speed = " HDR";
|
||||
rate = 500;
|
||||
break;
|
||||
case IB_SPEED_NDR:
|
||||
speed = " NDR";
|
||||
rate = 1000;
|
||||
break;
|
||||
case IB_SPEED_XDR:
|
||||
speed = " XDR";
|
||||
rate = 2000;
|
||||
break;
|
||||
case IB_SPEED_SDR:
|
||||
default: /* default to SDR for invalid rates */
|
||||
speed = " SDR";
|
||||
rate = 25;
|
||||
break;
|
||||
}
|
||||
ret = ib_port_attr_to_speed_info(&attr, &speed_info);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
rate *= ib_width_enum_to_int(attr.active_width);
|
||||
if (rate < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return sysfs_emit(buf, "%d%s Gb/sec (%dX%s)\n", rate / 10,
|
||||
rate % 10 ? ".5" : "",
|
||||
ib_width_enum_to_int(attr.active_width), speed);
|
||||
return sysfs_emit(buf, "%d%s Gb/sec (%dX%s)\n", speed_info.rate / 10,
|
||||
speed_info.rate % 10 ? ".5" : "",
|
||||
ib_width_enum_to_int(attr.active_width),
|
||||
speed_info.str);
|
||||
}
|
||||
|
||||
static const char *phys_state_to_str(enum ib_port_phys_state phys_state)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user