mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-21 16:29:59 +00:00
IB/ipoib: add get_link_ksettings in ethtool
In order to let the bonding driver report the correct speed of the underlaying interfaces, when they are IPoIB, the ethtool function get_link_ksettings() in the IPoIB driver is implemented. Cc: Joe Jin <joe.jin@oracle.com> Cc: Junxiao Bi <junxiao.bi@oracle.com> Suggested-by: Håkon Bugge <Haakon.Bugge@oracle.com> Signed-off-by: Zhu Yanjun <yanjun.zhu@oracle.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
This commit is contained in:
parent
24b43c9964
commit
0d7e2d2166
2 changed files with 60 additions and 0 deletions
|
@ -155,7 +155,66 @@ static int ipoib_get_sset_count(struct net_device __always_unused *dev,
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return lane speed in unit of 1e6 bit/sec */
|
||||||
|
static inline int ib_speed_enum_to_int(int speed)
|
||||||
|
{
|
||||||
|
switch (speed) {
|
||||||
|
case IB_SPEED_SDR:
|
||||||
|
return SPEED_2500;
|
||||||
|
case IB_SPEED_DDR:
|
||||||
|
return SPEED_5000;
|
||||||
|
case IB_SPEED_QDR:
|
||||||
|
case IB_SPEED_FDR10:
|
||||||
|
return SPEED_10000;
|
||||||
|
case IB_SPEED_FDR:
|
||||||
|
return SPEED_14000;
|
||||||
|
case IB_SPEED_EDR:
|
||||||
|
return SPEED_25000;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SPEED_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ipoib_get_link_ksettings(struct net_device *netdev,
|
||||||
|
struct ethtool_link_ksettings *cmd)
|
||||||
|
{
|
||||||
|
struct ipoib_dev_priv *priv = netdev_priv(netdev);
|
||||||
|
struct ib_port_attr attr;
|
||||||
|
int ret, speed, width;
|
||||||
|
|
||||||
|
if (!netif_carrier_ok(netdev)) {
|
||||||
|
cmd->base.speed = SPEED_UNKNOWN;
|
||||||
|
cmd->base.duplex = DUPLEX_UNKNOWN;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = ib_query_port(priv->ca, priv->port, &attr);
|
||||||
|
if (ret < 0)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
speed = ib_speed_enum_to_int(attr.active_speed);
|
||||||
|
width = ib_width_enum_to_int(attr.active_width);
|
||||||
|
|
||||||
|
if (speed < 0 || width < 0)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
/* Except the following are set, the other members of
|
||||||
|
* the struct ethtool_link_settings are initialized to
|
||||||
|
* zero in the function __ethtool_get_link_ksettings.
|
||||||
|
*/
|
||||||
|
cmd->base.speed = speed * width;
|
||||||
|
cmd->base.duplex = DUPLEX_FULL;
|
||||||
|
|
||||||
|
cmd->base.phy_address = 0xFF;
|
||||||
|
|
||||||
|
cmd->base.autoneg = AUTONEG_ENABLE;
|
||||||
|
cmd->base.port = PORT_OTHER;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static const struct ethtool_ops ipoib_ethtool_ops = {
|
static const struct ethtool_ops ipoib_ethtool_ops = {
|
||||||
|
.get_link_ksettings = ipoib_get_link_ksettings,
|
||||||
.get_drvinfo = ipoib_get_drvinfo,
|
.get_drvinfo = ipoib_get_drvinfo,
|
||||||
.get_coalesce = ipoib_get_coalesce,
|
.get_coalesce = ipoib_get_coalesce,
|
||||||
.set_coalesce = ipoib_set_coalesce,
|
.set_coalesce = ipoib_set_coalesce,
|
||||||
|
|
|
@ -1494,6 +1494,7 @@ enum ethtool_link_mode_bit_indices {
|
||||||
#define SPEED_2500 2500
|
#define SPEED_2500 2500
|
||||||
#define SPEED_5000 5000
|
#define SPEED_5000 5000
|
||||||
#define SPEED_10000 10000
|
#define SPEED_10000 10000
|
||||||
|
#define SPEED_14000 14000
|
||||||
#define SPEED_20000 20000
|
#define SPEED_20000 20000
|
||||||
#define SPEED_25000 25000
|
#define SPEED_25000 25000
|
||||||
#define SPEED_40000 40000
|
#define SPEED_40000 40000
|
||||||
|
|
Loading…
Reference in a new issue