From 8b70848bb311da1845fb9929671292d332613c7b Mon Sep 17 00:00:00 2001 From: "Russell King (Oracle)" Date: Sun, 21 Nov 2021 13:02:03 +0000 Subject: net: phylink: add phylink_pcs_inband() Add phylink_pcs_inband() to indicate whether the PCS should be using inband signalling. Signed-off-by: Russell King (Oracle) --- drivers/net/phy/phylink.c | 5 +---- include/linux/phylink.h | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index ecb8541de31c..8612baf0d829 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -3025,10 +3025,7 @@ int phylink_mii_c22_pcs_config(struct mdio_device *pcs, unsigned int mode, } /* Ensure ISOLATE bit is disabled */ - if (mode == MLO_AN_INBAND && - (interface == PHY_INTERFACE_MODE_SGMII || - interface == PHY_INTERFACE_MODE_QSGMII || - linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, advertising))) + if (phylink_pcs_inband(mode, interface, advertising)) bmcr = BMCR_ANENABLE; else bmcr = 0; diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 6d06896fc20d..e7bc8d4b306e 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -50,6 +50,25 @@ static inline bool phylink_autoneg_inband(unsigned int mode) return mode == MLO_AN_INBAND; } +/** + * phylink_pcs_inband() - helper to indicate whether to enable inband signalling + * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND. + * @interface: interface mode to be used + * @advertising: adertisement ethtool link mode mask + * + * Returns true if the mode/interface/advertising mask indicates that we + * should be using inband signalling at the PCS block, false otherwise. + */ +static inline bool phylink_pcs_inband(unsigned int mode, + phy_interface_t interface, + const unsigned long *advertising) +{ + return phylink_autoneg_inband(mode) && + (interface == PHY_INTERFACE_MODE_SGMII || + interface == PHY_INTERFACE_MODE_QSGMII || + linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, advertising)); +} + /** * struct phylink_link_state - link state structure * @advertising: ethtool bitmask containing advertised link modes -- cgit