net: phylink: allow ethtool -A to change flow control advertisement

When ethtool -A is used to change the pause modes, the pause
advertisement is not being changed, but the documentation in
uapi/linux/ethtool.h says we should be. Add that capability to
phylink.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: hongrongxuan <hongrongxuan@huawei.com>
This commit is contained in:
Russell King 2020-02-15 15:49:58 +00:00 committed by Jianping Liu
parent 6b1f64e2fd
commit cca40c4a30
1 changed files with 18 additions and 0 deletions

View File

@ -1344,6 +1344,7 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl,
pause->rx_pause != pause->tx_pause)
return -EINVAL;
mutex_lock(&pl->state_mutex);
config->pause = 0;
if (pause->autoneg)
config->pause |= MLO_PAUSE_AN;
@ -1352,6 +1353,22 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl,
if (pause->tx_pause)
config->pause |= MLO_PAUSE_TX;
/*
* See the comments for linkmode_set_pause(), wrt the deficiencies
* with the current implementation. A solution to this issue would
* be:
* ethtool Local device
* rx tx Pause AsymDir
* 0 0 0 0
* 1 0 1 1
* 0 1 0 1
* 1 1 1 1
* and then use the ethtool rx/tx enablement status to mask the
* rx/tx pause resolution.
*/
linkmode_set_pause(config->advertising, pause->tx_pause,
pause->rx_pause);
/* If we have a PHY, phylib will call our link state function if the
* mode has changed, which will trigger a resolve and update the MAC
* configuration.
@ -1364,6 +1381,7 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl,
phylink_mac_config(pl, &pl->link_config);
phylink_mac_an_restart(pl);
}
mutex_unlock(&pl->state_mutex);
return 0;
}