提交 2ac78a66 编写于 作者: D Dragos Tatulea 提交者: zhaoxiaoqiang11

net/mlx5e: IPoIB, Show unknown speed instead of error

stable inclusion
from stable-v5.10.168
commit 703c3efa4b0b50a9c6a3726026c0f528857db812
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7URR4

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=703c3efa4b0b50a9c6a3726026c0f528857db812

----------------------------------------------------

[ Upstream commit 8aa5f171 ]

ethtool is returning an error for unknown speeds for the IPoIB interface:

$ ethtool ib0
netlink error: failed to retrieve link settings
netlink error: Invalid argument
netlink error: failed to retrieve link settings
netlink error: Invalid argument
Settings for ib0:
Link detected: no

After this change, ethtool will return success and show "unknown speed":

$ ethtool ib0
Settings for ib0:
Supported ports: [  ]
Supported link modes:   Not reported
Supported pause frame use: No
Supports auto-negotiation: No
Supported FEC modes: Not reported
Advertised link modes:  Not reported
Advertised pause frame use: No
Advertised auto-negotiation: No
Advertised FEC modes: Not reported
Speed: Unknown!
Duplex: Full
Auto-negotiation: off
Port: Other
PHYAD: 0
Transceiver: internal
Link detected: no

Fixes: eb234ee9 ("net/mlx5e: IPoIB, Add support for get_link_ksettings in ethtool")
Signed-off-by: NDragos Tatulea <dtatulea@nvidia.com>
Reviewed-by: NGal Pressman <gal@nvidia.com>
Reviewed-by: NTariq Toukan <tariqt@nvidia.com>
Signed-off-by: NSaeed Mahameed <saeedm@nvidia.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: Nzhaoxiaoqiang11 <zhaoxiaoqiang11@jd.com>
上级 ed50be9e
...@@ -174,16 +174,16 @@ static inline int mlx5_ptys_rate_enum_to_int(enum mlx5_ptys_rate rate) ...@@ -174,16 +174,16 @@ static inline int mlx5_ptys_rate_enum_to_int(enum mlx5_ptys_rate rate)
} }
} }
static int mlx5i_get_speed_settings(u16 ib_link_width_oper, u16 ib_proto_oper) static u32 mlx5i_get_speed_settings(u16 ib_link_width_oper, u16 ib_proto_oper)
{ {
int rate, width; int rate, width;
rate = mlx5_ptys_rate_enum_to_int(ib_proto_oper); rate = mlx5_ptys_rate_enum_to_int(ib_proto_oper);
if (rate < 0) if (rate < 0)
return -EINVAL; return SPEED_UNKNOWN;
width = mlx5_ptys_width_enum_to_int(ib_link_width_oper); width = mlx5_ptys_width_enum_to_int(ib_link_width_oper);
if (width < 0) if (width < 0)
return -EINVAL; return SPEED_UNKNOWN;
return rate * width; return rate * width;
} }
...@@ -206,16 +206,13 @@ static int mlx5i_get_link_ksettings(struct net_device *netdev, ...@@ -206,16 +206,13 @@ static int mlx5i_get_link_ksettings(struct net_device *netdev,
ethtool_link_ksettings_zero_link_mode(link_ksettings, advertising); ethtool_link_ksettings_zero_link_mode(link_ksettings, advertising);
speed = mlx5i_get_speed_settings(ib_link_width_oper, ib_proto_oper); speed = mlx5i_get_speed_settings(ib_link_width_oper, ib_proto_oper);
if (speed < 0) link_ksettings->base.speed = speed;
return -EINVAL; link_ksettings->base.duplex = speed == SPEED_UNKNOWN ? DUPLEX_UNKNOWN : DUPLEX_FULL;
link_ksettings->base.duplex = DUPLEX_FULL;
link_ksettings->base.port = PORT_OTHER; link_ksettings->base.port = PORT_OTHER;
link_ksettings->base.autoneg = AUTONEG_DISABLE; link_ksettings->base.autoneg = AUTONEG_DISABLE;
link_ksettings->base.speed = speed;
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册