Commit 5652b46e authored by David S. Miller's avatar David S. Miller

Merge branch 'Pause-updates-for-phylib-and-phylink'

Russell King says:

====================
Pause updates for phylib and phylink

Currently, phylib resolves the speed and duplex settings, which MAC
drivers use directly. phylib also extracts the "Pause" and "AsymPause"
bits from the link partner's advertisement, and stores them in struct
phy_device's pause and asym_pause members with no further processing.
It is left up to each MAC driver to implement decoding for this
information.

phylink converted drivers are able to take advantage of code therein
which resolves the pause advertisements for the MAC driver, but this
does nothing for unconverted drivers. It also does not allow us to
make use of hardware-resolved pause states offered by several PHYs.

This series aims to address this by:

1. Providing a generic implementation, linkmode_resolve_pause(), that
   takes the ethtool linkmode arrays for the link partner and local
   advertisements, decoding the result to whether pause frames should
   be allowed to be transmitted or received and acted upon.  I call
   this the pause enablement state.

2. Providing a phylib implementation, phy_get_pause(), which allows
   MAC drivers to request the pause enablement state from phylib.

3. Providing a generic linkmode_set_pause() for setting the pause
   advertisement according to the ethtool tx/rx flags - note that this
   design has some shortcomings, see the comments in the kerneldoc for
   this function.

4. Remove the ability in phylink to set the pause states for fixed
   links, which brings them into line with how we deal with the speed
   and duplex parameters; we can reintroduce this later if anyone
   requires it.  This could be a userspace-visible change.

5. Split application of manual pause enablement state from phylink's
   resolution of the same to allow use of phylib's new phy_get_pause()
   interface by phylink, and make that switch.

6. Resolve the fixed-link pause enablement state using the generic
   linkmode_resolve_pause() helper introduced earlier. This, in
   connection with the previous commits, allows us to kill the
   MLO_PAUSE_SYM and MLO_PAUSE_ASYM flags.

7. make phylink's ethtool pause setting implementation update the
   pause advertisement in the same way that phylib does, with the
   same caveats that are present there (as mentioned above w.r.t
   linkmode_set_pause()).

8. create a more accurate initial configuration for MACs, used when
   phy_start() is called or a SFP is detected. In particular, this
   ensures that the pause bits seen by MAC drivers in state->pause
   are accurate for SGMII.

9. finally, update the kerneldoc descriptions for mac_config() for
   the above changes.

This series has been build-tested against net-next; the boot tested
patches are in my "phy" branch against v5.5 plus the queued phylink
changes that were merged for 5.6.

The next series will introduce the ability for phylib drivers to
provide hardware resolved pause enablement state.  These patches can
be found in my "phy" branch.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents ce780551 b70486f9
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
# Makefile for Linux PHY drivers and MDIO bus drivers # Makefile for Linux PHY drivers and MDIO bus drivers
libphy-y := phy.o phy-c45.o phy-core.o phy_device.o libphy-y := phy.o phy-c45.o phy-core.o phy_device.o \
linkmode.o
mdio-bus-y += mdio_bus.o mdio_device.o mdio-bus-y += mdio_bus.o mdio_device.o
ifdef CONFIG_MDIO_DEVICE ifdef CONFIG_MDIO_DEVICE
......
// SPDX-License-Identifier: GPL-2.0+
#include <linux/linkmode.h>
/**
* linkmode_resolve_pause - resolve the allowable pause modes
* @local_adv: local advertisement in ethtool format
* @partner_adv: partner advertisement in ethtool format
* @tx_pause: pointer to bool to indicate whether transmit pause should be
* enabled.
* @rx_pause: pointer to bool to indicate whether receive pause should be
* enabled.
*
* Flow control is resolved according to our and the link partners
* advertisements using the following drawn from the 802.3 specs:
* Local device Link partner
* Pause AsymDir Pause AsymDir Result
* 0 X 0 X Disabled
* 0 1 1 0 Disabled
* 0 1 1 1 TX
* 1 0 0 X Disabled
* 1 X 1 X TX+RX
* 1 1 0 1 RX
*/
void linkmode_resolve_pause(const unsigned long *local_adv,
const unsigned long *partner_adv,
bool *tx_pause, bool *rx_pause)
{
__ETHTOOL_DECLARE_LINK_MODE_MASK(m);
linkmode_and(m, local_adv, partner_adv);
if (linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT, m)) {
*tx_pause = true;
*rx_pause = true;
} else if (linkmode_test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, m)) {
*tx_pause = linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT,
partner_adv);
*rx_pause = linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT,
local_adv);
} else {
*tx_pause = false;
*rx_pause = false;
}
}
EXPORT_SYMBOL_GPL(linkmode_resolve_pause);
/**
* linkmode_set_pause - set the pause mode advertisement
* @advertisement: advertisement in ethtool format
* @tx: boolean from ethtool struct ethtool_pauseparam tx_pause member
* @rx: boolean from ethtool struct ethtool_pauseparam rx_pause member
*
* Configure the advertised Pause and Asym_Pause bits according to the
* capabilities of provided in @tx and @rx.
*
* We convert as follows:
* tx rx Pause AsymDir
* 0 0 0 0
* 0 1 1 1
* 1 0 0 1
* 1 1 1 0
*
* Note: this translation from ethtool tx/rx notation to the advertisement
* is actually very problematical. Here are some examples:
*
* For tx=0 rx=1, meaning transmit is unsupported, receive is supported:
*
* Local device Link partner
* Pause AsymDir Pause AsymDir Result
* 1 1 1 0 TX + RX - but we have no TX support.
* 1 1 0 1 Only this gives RX only
*
* For tx=1 rx=1, meaning we have the capability to transmit and receive
* pause frames:
*
* Local device Link partner
* Pause AsymDir Pause AsymDir Result
* 1 0 0 1 Disabled - but since we do support tx and rx,
* this should resolve to RX only.
*
* Hence, asking for:
* rx=1 tx=0 gives Pause+AsymDir advertisement, but we may end up
* resolving to tx+rx pause or only rx pause depending on
* the partners advertisement.
* rx=0 tx=1 gives AsymDir only, which will only give tx pause if
* the partners advertisement allows it.
* rx=1 tx=1 gives Pause only, which will only allow tx+rx pause
* if the other end also advertises Pause.
*/
void linkmode_set_pause(unsigned long *advertisement, bool tx, bool rx)
{
linkmode_mod_bit(ETHTOOL_LINK_MODE_Pause_BIT, advertisement, rx);
linkmode_mod_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, advertisement,
rx ^ tx);
}
EXPORT_SYMBOL_GPL(linkmode_set_pause);
...@@ -2361,22 +2361,7 @@ void phy_set_asym_pause(struct phy_device *phydev, bool rx, bool tx) ...@@ -2361,22 +2361,7 @@ void phy_set_asym_pause(struct phy_device *phydev, bool rx, bool tx)
__ETHTOOL_DECLARE_LINK_MODE_MASK(oldadv); __ETHTOOL_DECLARE_LINK_MODE_MASK(oldadv);
linkmode_copy(oldadv, phydev->advertising); linkmode_copy(oldadv, phydev->advertising);
linkmode_set_pause(phydev->advertising, tx, rx);
linkmode_clear_bit(ETHTOOL_LINK_MODE_Pause_BIT,
phydev->advertising);
linkmode_clear_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT,
phydev->advertising);
if (rx) {
linkmode_set_bit(ETHTOOL_LINK_MODE_Pause_BIT,
phydev->advertising);
linkmode_set_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT,
phydev->advertising);
}
if (tx)
linkmode_change_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT,
phydev->advertising);
if (!linkmode_equal(oldadv, phydev->advertising) && if (!linkmode_equal(oldadv, phydev->advertising) &&
phydev->autoneg) phydev->autoneg)
...@@ -2409,6 +2394,32 @@ bool phy_validate_pause(struct phy_device *phydev, ...@@ -2409,6 +2394,32 @@ bool phy_validate_pause(struct phy_device *phydev,
} }
EXPORT_SYMBOL(phy_validate_pause); EXPORT_SYMBOL(phy_validate_pause);
/**
* phy_get_pause - resolve negotiated pause modes
* @phydev: phy_device struct
* @tx_pause: pointer to bool to indicate whether transmit pause should be
* enabled.
* @rx_pause: pointer to bool to indicate whether receive pause should be
* enabled.
*
* Resolve and return the flow control modes according to the negotiation
* result. This includes checking that we are operating in full duplex mode.
* See linkmode_resolve_pause() for further details.
*/
void phy_get_pause(struct phy_device *phydev, bool *tx_pause, bool *rx_pause)
{
if (phydev->duplex != DUPLEX_FULL) {
*tx_pause = false;
*rx_pause = false;
return;
}
return linkmode_resolve_pause(phydev->advertising,
phydev->lp_advertising,
tx_pause, rx_pause);
}
EXPORT_SYMBOL(phy_get_pause);
static bool phy_drv_supports_irq(struct phy_driver *phydrv) static bool phy_drv_supports_irq(struct phy_driver *phydrv)
{ {
return phydrv->config_intr && phydrv->ack_interrupt; return phydrv->config_intr && phydrv->ack_interrupt;
......
...@@ -181,9 +181,11 @@ static int phylink_parse_fixedlink(struct phylink *pl, ...@@ -181,9 +181,11 @@ static int phylink_parse_fixedlink(struct phylink *pl,
/* We treat the "pause" and "asym-pause" terminology as /* We treat the "pause" and "asym-pause" terminology as
* defining the link partner's ability. */ * defining the link partner's ability. */
if (fwnode_property_read_bool(fixed_node, "pause")) if (fwnode_property_read_bool(fixed_node, "pause"))
pl->link_config.pause |= MLO_PAUSE_SYM; __set_bit(ETHTOOL_LINK_MODE_Pause_BIT,
pl->link_config.lp_advertising);
if (fwnode_property_read_bool(fixed_node, "asym-pause")) if (fwnode_property_read_bool(fixed_node, "asym-pause"))
pl->link_config.pause |= MLO_PAUSE_ASYM; __set_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT,
pl->link_config.lp_advertising);
if (ret == 0) { if (ret == 0) {
desc = fwnode_gpiod_get_index(fixed_node, "link", 0, desc = fwnode_gpiod_get_index(fixed_node, "link", 0,
...@@ -215,9 +217,11 @@ static int phylink_parse_fixedlink(struct phylink *pl, ...@@ -215,9 +217,11 @@ static int phylink_parse_fixedlink(struct phylink *pl,
DUPLEX_FULL : DUPLEX_HALF; DUPLEX_FULL : DUPLEX_HALF;
pl->link_config.speed = prop[2]; pl->link_config.speed = prop[2];
if (prop[3]) if (prop[3])
pl->link_config.pause |= MLO_PAUSE_SYM; __set_bit(ETHTOOL_LINK_MODE_Pause_BIT,
pl->link_config.lp_advertising);
if (prop[4]) if (prop[4])
pl->link_config.pause |= MLO_PAUSE_ASYM; __set_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT,
pl->link_config.lp_advertising);
} }
} }
...@@ -339,6 +343,34 @@ static int phylink_parse_mode(struct phylink *pl, struct fwnode_handle *fwnode) ...@@ -339,6 +343,34 @@ static int phylink_parse_mode(struct phylink *pl, struct fwnode_handle *fwnode)
return 0; return 0;
} }
static void phylink_apply_manual_flow(struct phylink *pl,
struct phylink_link_state *state)
{
/* If autoneg is disabled, pause AN is also disabled */
if (!state->an_enabled)
state->pause &= ~MLO_PAUSE_AN;
/* Manual configuration of pause modes */
if (!(pl->link_config.pause & MLO_PAUSE_AN))
state->pause = pl->link_config.pause;
}
static void phylink_resolve_flow(struct phylink_link_state *state)
{
bool tx_pause, rx_pause;
state->pause = MLO_PAUSE_NONE;
if (state->duplex == DUPLEX_FULL) {
linkmode_resolve_pause(state->advertising,
state->lp_advertising,
&tx_pause, &rx_pause);
if (tx_pause)
state->pause |= MLO_PAUSE_TX;
if (rx_pause)
state->pause |= MLO_PAUSE_RX;
}
}
static void phylink_mac_config(struct phylink *pl, static void phylink_mac_config(struct phylink *pl,
const struct phylink_link_state *state) const struct phylink_link_state *state)
{ {
...@@ -387,49 +419,45 @@ static void phylink_mac_pcs_get_state(struct phylink *pl, ...@@ -387,49 +419,45 @@ static void phylink_mac_pcs_get_state(struct phylink *pl,
/* The fixed state is... fixed except for the link state, /* The fixed state is... fixed except for the link state,
* which may be determined by a GPIO or a callback. * which may be determined by a GPIO or a callback.
*/ */
static void phylink_get_fixed_state(struct phylink *pl, struct phylink_link_state *state) static void phylink_get_fixed_state(struct phylink *pl,
struct phylink_link_state *state)
{ {
*state = pl->link_config; *state = pl->link_config;
if (pl->get_fixed_state) if (pl->get_fixed_state)
pl->get_fixed_state(pl->netdev, state); pl->get_fixed_state(pl->netdev, state);
else if (pl->link_gpio) else if (pl->link_gpio)
state->link = !!gpiod_get_value_cansleep(pl->link_gpio); state->link = !!gpiod_get_value_cansleep(pl->link_gpio);
phylink_resolve_flow(state);
} }
/* Flow control is resolved according to our and the link partners static void phylink_mac_initial_config(struct phylink *pl)
* advertisements using the following drawn from the 802.3 specs:
* Local device Link partner
* Pause AsymDir Pause AsymDir Result
* 1 X 1 X TX+RX
* 0 1 1 1 TX
* 1 1 0 1 RX
*/
static void phylink_resolve_flow(struct phylink *pl,
struct phylink_link_state *state)
{ {
int new_pause = 0; struct phylink_link_state link_state;
if (pl->link_config.pause & MLO_PAUSE_AN) { switch (pl->cur_link_an_mode) {
int pause = 0; case MLO_AN_PHY:
link_state = pl->phy_state;
break;
if (phylink_test(pl->link_config.advertising, Pause)) case MLO_AN_FIXED:
pause |= MLO_PAUSE_SYM; phylink_get_fixed_state(pl, &link_state);
if (phylink_test(pl->link_config.advertising, Asym_Pause)) break;
pause |= MLO_PAUSE_ASYM;
pause &= state->pause; case MLO_AN_INBAND:
link_state = pl->link_config;
if (link_state.interface == PHY_INTERFACE_MODE_SGMII)
link_state.pause = MLO_PAUSE_NONE;
break;
if (pause & MLO_PAUSE_SYM) default: /* can't happen */
new_pause = MLO_PAUSE_TX | MLO_PAUSE_RX; return;
else if (pause & MLO_PAUSE_ASYM)
new_pause = state->pause & MLO_PAUSE_SYM ?
MLO_PAUSE_TX : MLO_PAUSE_RX;
} else {
new_pause = pl->link_config.pause & MLO_PAUSE_TXRX_MASK;
} }
state->pause &= ~MLO_PAUSE_TXRX_MASK; link_state.link = false;
state->pause |= new_pause;
phylink_apply_manual_flow(pl, &link_state);
phylink_mac_config(pl, &link_state);
} }
static const char *phylink_pause_to_str(int pause) static const char *phylink_pause_to_str(int pause)
...@@ -493,7 +521,7 @@ static void phylink_resolve(struct work_struct *w) ...@@ -493,7 +521,7 @@ static void phylink_resolve(struct work_struct *w)
switch (pl->cur_link_an_mode) { switch (pl->cur_link_an_mode) {
case MLO_AN_PHY: case MLO_AN_PHY:
link_state = pl->phy_state; link_state = pl->phy_state;
phylink_resolve_flow(pl, &link_state); phylink_apply_manual_flow(pl, &link_state);
phylink_mac_config_up(pl, &link_state); phylink_mac_config_up(pl, &link_state);
break; break;
...@@ -515,9 +543,9 @@ static void phylink_resolve(struct work_struct *w) ...@@ -515,9 +543,9 @@ static void phylink_resolve(struct work_struct *w)
link_state.interface = pl->phy_state.interface; link_state.interface = pl->phy_state.interface;
/* If we have a PHY, we need to update with /* If we have a PHY, we need to update with
* the pause mode bits. */ * the PHY flow control bits. */
link_state.pause |= pl->phy_state.pause; link_state.pause = pl->phy_state.pause;
phylink_resolve_flow(pl, &link_state); phylink_apply_manual_flow(pl, &link_state);
phylink_mac_config(pl, &link_state); phylink_mac_config(pl, &link_state);
} }
break; break;
...@@ -705,15 +733,18 @@ static void phylink_phy_change(struct phy_device *phydev, bool up, ...@@ -705,15 +733,18 @@ static void phylink_phy_change(struct phy_device *phydev, bool up,
bool do_carrier) bool do_carrier)
{ {
struct phylink *pl = phydev->phylink; struct phylink *pl = phydev->phylink;
bool tx_pause, rx_pause;
phy_get_pause(phydev, &tx_pause, &rx_pause);
mutex_lock(&pl->state_mutex); mutex_lock(&pl->state_mutex);
pl->phy_state.speed = phydev->speed; pl->phy_state.speed = phydev->speed;
pl->phy_state.duplex = phydev->duplex; pl->phy_state.duplex = phydev->duplex;
pl->phy_state.pause = MLO_PAUSE_NONE; pl->phy_state.pause = MLO_PAUSE_NONE;
if (phydev->pause) if (tx_pause)
pl->phy_state.pause |= MLO_PAUSE_SYM; pl->phy_state.pause |= MLO_PAUSE_TX;
if (phydev->asym_pause) if (rx_pause)
pl->phy_state.pause |= MLO_PAUSE_ASYM; pl->phy_state.pause |= MLO_PAUSE_RX;
pl->phy_state.interface = phydev->interface; pl->phy_state.interface = phydev->interface;
pl->phy_state.link = up; pl->phy_state.link = up;
mutex_unlock(&pl->state_mutex); mutex_unlock(&pl->state_mutex);
...@@ -777,6 +808,9 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy, ...@@ -777,6 +808,9 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy,
mutex_lock(&pl->state_mutex); mutex_lock(&pl->state_mutex);
pl->phydev = phy; pl->phydev = phy;
pl->phy_state.interface = interface; pl->phy_state.interface = interface;
pl->phy_state.pause = MLO_PAUSE_NONE;
pl->phy_state.speed = SPEED_UNKNOWN;
pl->phy_state.duplex = DUPLEX_UNKNOWN;
linkmode_copy(pl->supported, supported); linkmode_copy(pl->supported, supported);
linkmode_copy(pl->link_config.advertising, config.advertising); linkmode_copy(pl->link_config.advertising, config.advertising);
...@@ -1006,8 +1040,7 @@ void phylink_start(struct phylink *pl) ...@@ -1006,8 +1040,7 @@ void phylink_start(struct phylink *pl)
* a fixed-link to start with the correct parameters, and also * a fixed-link to start with the correct parameters, and also
* ensures that we set the appropriate advertisement for Serdes links. * ensures that we set the appropriate advertisement for Serdes links.
*/ */
phylink_resolve_flow(pl, &pl->link_config); phylink_mac_initial_config(pl);
phylink_mac_config(pl, &pl->link_config);
/* Restart autonegotiation if using 802.3z to ensure that the link /* Restart autonegotiation if using 802.3z to ensure that the link
* parameters are properly negotiated. This is necessary for DSA * parameters are properly negotiated. This is necessary for DSA
...@@ -1373,6 +1406,9 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl, ...@@ -1373,6 +1406,9 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl,
ASSERT_RTNL(); ASSERT_RTNL();
if (pl->cur_link_an_mode == MLO_AN_FIXED)
return -EOPNOTSUPP;
if (!phylink_test(pl->supported, Pause) && if (!phylink_test(pl->supported, Pause) &&
!phylink_test(pl->supported, Asym_Pause)) !phylink_test(pl->supported, Asym_Pause))
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -1381,8 +1417,8 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl, ...@@ -1381,8 +1417,8 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl,
!pause->autoneg && pause->rx_pause != pause->tx_pause) !pause->autoneg && pause->rx_pause != pause->tx_pause)
return -EINVAL; return -EINVAL;
config->pause &= ~(MLO_PAUSE_AN | MLO_PAUSE_TXRX_MASK); mutex_lock(&pl->state_mutex);
config->pause = 0;
if (pause->autoneg) if (pause->autoneg)
config->pause |= MLO_PAUSE_AN; config->pause |= MLO_PAUSE_AN;
if (pause->rx_pause) if (pause->rx_pause)
...@@ -1390,6 +1426,22 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl, ...@@ -1390,6 +1426,22 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl,
if (pause->tx_pause) if (pause->tx_pause)
config->pause |= MLO_PAUSE_TX; 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 /* 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 * mode has changed, which will trigger a resolve and update the MAC
* configuration. * configuration.
...@@ -1399,19 +1451,10 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl, ...@@ -1399,19 +1451,10 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl,
pause->tx_pause); pause->tx_pause);
} else if (!test_bit(PHYLINK_DISABLE_STOPPED, } else if (!test_bit(PHYLINK_DISABLE_STOPPED,
&pl->phylink_disable_state)) { &pl->phylink_disable_state)) {
switch (pl->cur_link_an_mode) { phylink_mac_config(pl, &pl->link_config);
case MLO_AN_FIXED: phylink_mac_an_restart(pl);
/* Should we allow fixed links to change against the config? */
phylink_resolve_flow(pl, config);
phylink_mac_config(pl, config);
break;
case MLO_AN_INBAND:
phylink_mac_config(pl, config);
phylink_mac_an_restart(pl);
break;
}
} }
mutex_unlock(&pl->state_mutex);
return 0; return 0;
} }
...@@ -1503,13 +1546,14 @@ static int phylink_mii_emul_read(unsigned int reg, ...@@ -1503,13 +1546,14 @@ static int phylink_mii_emul_read(unsigned int reg,
struct phylink_link_state *state) struct phylink_link_state *state)
{ {
struct fixed_phy_status fs; struct fixed_phy_status fs;
unsigned long *lpa = state->lp_advertising;
int val; int val;
fs.link = state->link; fs.link = state->link;
fs.speed = state->speed; fs.speed = state->speed;
fs.duplex = state->duplex; fs.duplex = state->duplex;
fs.pause = state->pause & MLO_PAUSE_SYM; fs.pause = test_bit(ETHTOOL_LINK_MODE_Pause_BIT, lpa);
fs.asym_pause = state->pause & MLO_PAUSE_ASYM; fs.asym_pause = test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, lpa);
val = swphy_read_reg(reg, &fs); val = swphy_read_reg(reg, &fs);
if (reg == MII_BMSR) { if (reg == MII_BMSR) {
...@@ -1814,7 +1858,7 @@ static int phylink_sfp_config(struct phylink *pl, u8 mode, ...@@ -1814,7 +1858,7 @@ static int phylink_sfp_config(struct phylink *pl, u8 mode,
if (changed && !test_bit(PHYLINK_DISABLE_STOPPED, if (changed && !test_bit(PHYLINK_DISABLE_STOPPED,
&pl->phylink_disable_state)) &pl->phylink_disable_state))
phylink_mac_config(pl, &pl->link_config); phylink_mac_initial_config(pl);
return ret; return ret;
} }
......
...@@ -71,7 +71,7 @@ static inline void linkmode_change_bit(int nr, volatile unsigned long *addr) ...@@ -71,7 +71,7 @@ static inline void linkmode_change_bit(int nr, volatile unsigned long *addr)
__change_bit(nr, addr); __change_bit(nr, addr);
} }
static inline int linkmode_test_bit(int nr, volatile unsigned long *addr) static inline int linkmode_test_bit(int nr, const volatile unsigned long *addr)
{ {
return test_bit(nr, addr); return test_bit(nr, addr);
} }
...@@ -88,4 +88,10 @@ static inline int linkmode_subset(const unsigned long *src1, ...@@ -88,4 +88,10 @@ static inline int linkmode_subset(const unsigned long *src1,
return bitmap_subset(src1, src2, __ETHTOOL_LINK_MODE_MASK_NBITS); return bitmap_subset(src1, src2, __ETHTOOL_LINK_MODE_MASK_NBITS);
} }
void linkmode_resolve_pause(const unsigned long *local_adv,
const unsigned long *partner_adv,
bool *tx_pause, bool *rx_pause);
void linkmode_set_pause(unsigned long *advertisement, bool tx, bool rx);
#endif /* __LINKMODE_H */ #endif /* __LINKMODE_H */
...@@ -1257,6 +1257,9 @@ void phy_set_sym_pause(struct phy_device *phydev, bool rx, bool tx, ...@@ -1257,6 +1257,9 @@ void phy_set_sym_pause(struct phy_device *phydev, bool rx, bool tx,
void phy_set_asym_pause(struct phy_device *phydev, bool rx, bool tx); void phy_set_asym_pause(struct phy_device *phydev, bool rx, bool tx);
bool phy_validate_pause(struct phy_device *phydev, bool phy_validate_pause(struct phy_device *phydev,
struct ethtool_pauseparam *pp); struct ethtool_pauseparam *pp);
void phy_get_pause(struct phy_device *phydev, bool *tx_pause, bool *rx_pause);
void phy_resolve_pause(unsigned long *local_adv, unsigned long *partner_adv,
bool *tx_pause, bool *rx_pause);
int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask, int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
int (*run)(struct phy_device *)); int (*run)(struct phy_device *));
......
...@@ -12,12 +12,10 @@ struct net_device; ...@@ -12,12 +12,10 @@ struct net_device;
enum { enum {
MLO_PAUSE_NONE, MLO_PAUSE_NONE,
MLO_PAUSE_ASYM = BIT(0), MLO_PAUSE_RX = BIT(0),
MLO_PAUSE_SYM = BIT(1), MLO_PAUSE_TX = BIT(1),
MLO_PAUSE_RX = BIT(2),
MLO_PAUSE_TX = BIT(3),
MLO_PAUSE_TXRX_MASK = MLO_PAUSE_TX | MLO_PAUSE_RX, MLO_PAUSE_TXRX_MASK = MLO_PAUSE_TX | MLO_PAUSE_RX,
MLO_PAUSE_AN = BIT(4), MLO_PAUSE_AN = BIT(2),
MLO_AN_PHY = 0, /* Conventional PHY */ MLO_AN_PHY = 0, /* Conventional PHY */
MLO_AN_FIXED, /* Fixed-link mode */ MLO_AN_FIXED, /* Fixed-link mode */
...@@ -154,13 +152,20 @@ void mac_pcs_get_state(struct phylink_config *config, ...@@ -154,13 +152,20 @@ void mac_pcs_get_state(struct phylink_config *config,
* guaranteed to be correct, and so any mac_config() implementation must * guaranteed to be correct, and so any mac_config() implementation must
* never reference these fields. * never reference these fields.
* *
* In all negotiation modes, as defined by @mode, @state->pause indicates the
* pause settings which should be applied as follows. If %MLO_PAUSE_AN is not
* set, %MLO_PAUSE_TX and %MLO_PAUSE_RX indicate whether the MAC should send
* pause frames and/or act on received pause frames respectively. Otherwise,
* the results of in-band negotiation/status from the MAC PCS should be used
* to control the MAC pause mode settings.
*
* The action performed depends on the currently selected mode: * The action performed depends on the currently selected mode:
* *
* %MLO_AN_FIXED, %MLO_AN_PHY: * %MLO_AN_FIXED, %MLO_AN_PHY:
* Configure the specified @state->speed, @state->duplex and * Configure the specified @state->speed and @state->duplex over a link
* @state->pause (%MLO_PAUSE_TX / %MLO_PAUSE_RX) modes over a link * specified by @state->interface. @state->advertising may be used, but
* specified by @state->interface. @state->advertising may be used, * is not required. Pause modes as above. Other members of @state must
* but is not required. Other members of @state must be ignored. * be ignored.
* *
* Valid state members: interface, speed, duplex, pause, advertising. * Valid state members: interface, speed, duplex, pause, advertising.
* *
...@@ -172,11 +177,14 @@ void mac_pcs_get_state(struct phylink_config *config, ...@@ -172,11 +177,14 @@ void mac_pcs_get_state(struct phylink_config *config,
* mac_pcs_get_state() callback. Changes in link state must be made * mac_pcs_get_state() callback. Changes in link state must be made
* by calling phylink_mac_change(). * by calling phylink_mac_change().
* *
* Interface mode specific details are mentioned below.
*
* If in 802.3z mode, the link speed is fixed, dependent on the * If in 802.3z mode, the link speed is fixed, dependent on the
* @state->interface. Duplex is negotiated, and pause is advertised * @state->interface. Duplex and pause modes are negotiated via
* according to @state->an_enabled, @state->pause and * the in-band configuration word. Advertised pause modes are set
* @state->advertising flags. Beware of MACs which only support full * according to the @state->an_enabled and @state->advertising
* duplex at gigabit and higher speeds. * flags. Beware of MACs which only support full duplex at gigabit
* and higher speeds.
* *
* If in Cisco SGMII mode, the link speed and duplex mode are passed * If in Cisco SGMII mode, the link speed and duplex mode are passed
* in the serial bitstream 16-bit configuration word, and the MAC * in the serial bitstream 16-bit configuration word, and the MAC
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment