Skip to content

Commit

Permalink
r8152: support setting rx coalesce
Browse files Browse the repository at this point in the history
Support setting the rx coalesce. Then someone could change the rx
agg timeout value through ethtool.

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
hayeswang authored and David S. Miller committed Feb 19, 2015
1 parent 396e2e2 commit efb3dd8
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions drivers/net/usb/r8152.c
Original file line number Diff line number Diff line change
Expand Up @@ -3713,6 +3713,61 @@ static int rtl8152_nway_reset(struct net_device *dev)
return ret;
}

static int rtl8152_get_coalesce(struct net_device *netdev,
struct ethtool_coalesce *coalesce)
{
struct r8152 *tp = netdev_priv(netdev);

switch (tp->version) {
case RTL_VER_01:
case RTL_VER_02:
return -EOPNOTSUPP;
default:
break;
}

coalesce->rx_coalesce_usecs = tp->coalesce;

return 0;
}

static int rtl8152_set_coalesce(struct net_device *netdev,
struct ethtool_coalesce *coalesce)
{
struct r8152 *tp = netdev_priv(netdev);
int ret;

switch (tp->version) {
case RTL_VER_01:
case RTL_VER_02:
return -EOPNOTSUPP;
default:
break;
}

if (coalesce->rx_coalesce_usecs > COALESCE_SLOW)
return -EINVAL;

ret = usb_autopm_get_interface(tp->intf);
if (ret < 0)
return ret;

mutex_lock(&tp->control);

if (tp->coalesce != coalesce->rx_coalesce_usecs) {
tp->coalesce = coalesce->rx_coalesce_usecs;

if (netif_running(tp->netdev) && netif_carrier_ok(netdev))
r8153_set_rx_early_timeout(tp);
}

mutex_unlock(&tp->control);

usb_autopm_put_interface(tp->intf);

return ret;
}

static struct ethtool_ops ops = {
.get_drvinfo = rtl8152_get_drvinfo,
.get_settings = rtl8152_get_settings,
Expand All @@ -3726,6 +3781,8 @@ static struct ethtool_ops ops = {
.get_strings = rtl8152_get_strings,
.get_sset_count = rtl8152_get_sset_count,
.get_ethtool_stats = rtl8152_get_ethtool_stats,
.get_coalesce = rtl8152_get_coalesce,
.set_coalesce = rtl8152_set_coalesce,
.get_eee = rtl_ethtool_get_eee,
.set_eee = rtl_ethtool_set_eee,
};
Expand Down

0 comments on commit efb3dd8

Please sign in to comment.