Skip to content

Commit

Permalink
net: realtek: r8169: implement set_link_ksettings()
Browse files Browse the repository at this point in the history
Commit 6fa1ba6 partially
implemented the new ethtool API, by replacing get_settings()
with get_link_ksettings(). This breaks ethtool, since the
userspace tool (according to the new API specs) never tries
the legacy set() call, when the new get() call succeeds.

All attempts to chance some setting from userspace result in:
> Cannot set new settings: Operation not supported

Implement the missing set() call.

Signed-off-by: Tobias Jakobi <[email protected]>
Tested-by: Holger Hoffstätte <[email protected]>
Reviewed-by: Andrew Lunn <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
tobiasjakobi authored and davem330 committed Nov 23, 2017
1 parent 98d1129 commit 9e77d7a
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions drivers/net/ethernet/realtek/r8169.c
Original file line number Diff line number Diff line change
Expand Up @@ -2030,21 +2030,6 @@ static int rtl8169_set_speed(struct net_device *dev,
return ret;
}

static int rtl8169_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
struct rtl8169_private *tp = netdev_priv(dev);
int ret;

del_timer_sync(&tp->timer);

rtl_lock_work(tp);
ret = rtl8169_set_speed(dev, cmd->autoneg, ethtool_cmd_speed(cmd),
cmd->duplex, cmd->advertising);
rtl_unlock_work(tp);

return ret;
}

static netdev_features_t rtl8169_fix_features(struct net_device *dev,
netdev_features_t features)
{
Expand Down Expand Up @@ -2171,6 +2156,27 @@ static int rtl8169_get_link_ksettings(struct net_device *dev,
return rc;
}

static int rtl8169_set_link_ksettings(struct net_device *dev,
const struct ethtool_link_ksettings *cmd)
{
struct rtl8169_private *tp = netdev_priv(dev);
int rc;
u32 advertising;

if (!ethtool_convert_link_mode_to_legacy_u32(&advertising,
cmd->link_modes.advertising))
return -EINVAL;

del_timer_sync(&tp->timer);

rtl_lock_work(tp);
rc = rtl8169_set_speed(dev, cmd->base.autoneg, cmd->base.speed,
cmd->base.duplex, advertising);
rtl_unlock_work(tp);

return rc;
}

static void rtl8169_get_regs(struct net_device *dev, struct ethtool_regs *regs,
void *p)
{
Expand Down Expand Up @@ -2591,7 +2597,6 @@ static const struct ethtool_ops rtl8169_ethtool_ops = {
.get_link = ethtool_op_get_link,
.get_coalesce = rtl_get_coalesce,
.set_coalesce = rtl_set_coalesce,
.set_settings = rtl8169_set_settings,
.get_msglevel = rtl8169_get_msglevel,
.set_msglevel = rtl8169_set_msglevel,
.get_regs = rtl8169_get_regs,
Expand All @@ -2603,6 +2608,7 @@ static const struct ethtool_ops rtl8169_ethtool_ops = {
.get_ts_info = ethtool_op_get_ts_info,
.nway_reset = rtl8169_nway_reset,
.get_link_ksettings = rtl8169_get_link_ksettings,
.set_link_ksettings = rtl8169_set_link_ksettings,
};

static void rtl8169_get_mac_version(struct rtl8169_private *tp,
Expand Down

0 comments on commit 9e77d7a

Please sign in to comment.