Skip to content

Commit 2c62ff8

Browse files
Russell King (Oracle)kuba-moo
authored andcommitted
net: phylink: split out PHY validation from phylink_bringup_phy()
When bringing up a PHY, we need to work out which ethtool link modes it should support and advertise. Clause 22 PHYs operate in a single interface mode, which can be easily dealt with. However, clause 45 PHYs tend to switch interface mode depending on the media. We need more flexible validation at this point, so this patch splits out that code in preparation to changing it. Tested-by: Luo Jie <quic_luoj@quicinc.com> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Link: https://lore.kernel.org/r/E1r6VIQ-00DDM9-LK@rmk-PC.armlinux.org.uk Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent b7014f9 commit 2c62ff8

File tree

1 file changed

+31
-25
lines changed

1 file changed

+31
-25
lines changed

drivers/net/phy/phylink.c

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,6 +1760,35 @@ static void phylink_phy_change(struct phy_device *phydev, bool up)
17601760
phylink_pause_to_str(pl->phy_state.pause));
17611761
}
17621762

1763+
static int phylink_validate_phy(struct phylink *pl, struct phy_device *phy,
1764+
unsigned long *supported,
1765+
struct phylink_link_state *state)
1766+
{
1767+
/* Check whether we would use rate matching for the proposed interface
1768+
* mode.
1769+
*/
1770+
state->rate_matching = phy_get_rate_matching(phy, state->interface);
1771+
1772+
/* Clause 45 PHYs may switch their Serdes lane between, e.g. 10GBASE-R,
1773+
* 5GBASE-R, 2500BASE-X and SGMII if they are not using rate matching.
1774+
* For some interface modes (e.g. RXAUI, XAUI and USXGMII) switching
1775+
* their Serdes is either unnecessary or not reasonable.
1776+
*
1777+
* For these which switch interface modes, we really need to know which
1778+
* interface modes the PHY supports to properly work out which ethtool
1779+
* linkmodes can be supported. For now, as a work-around, we validate
1780+
* against all interface modes, which may lead to more ethtool link
1781+
* modes being advertised than are actually supported.
1782+
*/
1783+
if (phy->is_c45 && state->rate_matching == RATE_MATCH_NONE &&
1784+
state->interface != PHY_INTERFACE_MODE_RXAUI &&
1785+
state->interface != PHY_INTERFACE_MODE_XAUI &&
1786+
state->interface != PHY_INTERFACE_MODE_USXGMII)
1787+
state->interface = PHY_INTERFACE_MODE_NA;
1788+
1789+
return phylink_validate(pl, supported, state);
1790+
}
1791+
17631792
static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy,
17641793
phy_interface_t interface)
17651794
{
@@ -1780,32 +1809,9 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy,
17801809
memset(&config, 0, sizeof(config));
17811810
linkmode_copy(supported, phy->supported);
17821811
linkmode_copy(config.advertising, phy->advertising);
1812+
config.interface = interface;
17831813

1784-
/* Check whether we would use rate matching for the proposed interface
1785-
* mode.
1786-
*/
1787-
config.rate_matching = phy_get_rate_matching(phy, interface);
1788-
1789-
/* Clause 45 PHYs may switch their Serdes lane between, e.g. 10GBASE-R,
1790-
* 5GBASE-R, 2500BASE-X and SGMII if they are not using rate matching.
1791-
* For some interface modes (e.g. RXAUI, XAUI and USXGMII) switching
1792-
* their Serdes is either unnecessary or not reasonable.
1793-
*
1794-
* For these which switch interface modes, we really need to know which
1795-
* interface modes the PHY supports to properly work out which ethtool
1796-
* linkmodes can be supported. For now, as a work-around, we validate
1797-
* against all interface modes, which may lead to more ethtool link
1798-
* modes being advertised than are actually supported.
1799-
*/
1800-
if (phy->is_c45 && config.rate_matching == RATE_MATCH_NONE &&
1801-
interface != PHY_INTERFACE_MODE_RXAUI &&
1802-
interface != PHY_INTERFACE_MODE_XAUI &&
1803-
interface != PHY_INTERFACE_MODE_USXGMII)
1804-
config.interface = PHY_INTERFACE_MODE_NA;
1805-
else
1806-
config.interface = interface;
1807-
1808-
ret = phylink_validate(pl, supported, &config);
1814+
ret = phylink_validate_phy(pl, phy, supported, &config);
18091815
if (ret) {
18101816
phylink_warn(pl, "validation of %s with support %*pb and advertisement %*pb failed: %pe\n",
18111817
phy_modes(config.interface),

0 commit comments

Comments
 (0)