2024-01-29 15:57:18

by Choong Yong Liang

[permalink] [raw]
Subject: [PATCH net-next v4 01/11] net: phylink: publish ethtool link modes that supported and advertised

Adding the allow_switch_interface flag to publish all the ethtool
link modes that can be supported and advertised.

This will allow the interface switching based on different ethtool
link modes.

Signed-off-by: Choong Yong Liang <[email protected]>
---
drivers/net/phy/phylink.c | 9 +++++----
include/linux/phylink.h | 1 +
2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index ed0b4ccaa6a6..38ee2624169c 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -1839,10 +1839,11 @@ static int phylink_validate_phy(struct phylink *pl, struct phy_device *phy,
* against all interface modes, which may lead to more ethtool link
* modes being advertised than are actually supported.
*/
- if (phy->is_c45 && state->rate_matching == RATE_MATCH_NONE &&
- state->interface != PHY_INTERFACE_MODE_RXAUI &&
- state->interface != PHY_INTERFACE_MODE_XAUI &&
- state->interface != PHY_INTERFACE_MODE_USXGMII)
+ if ((phy->is_c45 && state->rate_matching == RATE_MATCH_NONE &&
+ state->interface != PHY_INTERFACE_MODE_RXAUI &&
+ state->interface != PHY_INTERFACE_MODE_XAUI &&
+ state->interface != PHY_INTERFACE_MODE_USXGMII) ||
+ pl->config->allow_switch_interface)
state->interface = PHY_INTERFACE_MODE_NA;

return phylink_validate(pl, supported, state);
diff --git a/include/linux/phylink.h b/include/linux/phylink.h
index d589f89c612c..b362d3231aa4 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -151,6 +151,7 @@ struct phylink_config {
bool poll_fixed_state;
bool mac_managed_pm;
bool ovr_an_inband;
+ bool allow_switch_interface;
void (*get_fixed_state)(struct phylink_config *config,
struct phylink_link_state *state);
DECLARE_PHY_INTERFACE_MASK(supported_interfaces);
--
2.34.1



2024-01-30 10:03:10

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH net-next v4 01/11] net: phylink: publish ethtool link modes that supported and advertised

On Mon, Jan 29, 2024 at 09:02:43PM +0800, Choong Yong Liang wrote:
> Adding the allow_switch_interface flag to publish all the ethtool
> link modes that can be supported and advertised.
>
> This will allow the interface switching based on different ethtool
> link modes.

I don't think you need this at all. You seem to be suggesting that you
have a PHY which switches between different interface modes on its host
interface. We already support several PHYs with this capability.

Generic support for this was added, and you need the PHY driver to
fill in phydev->possible_interfaces so phylink knows which interface
modes the PHY can switch between.

Instead, you are modifying the legacy path, which eventually I want
to get rid of.

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!