summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>2021-11-21 13:02:03 +0000
committerRussell King (Oracle) <rmk+kernel@armlinux.org.uk>2022-06-18 12:12:03 +0100
commit8b70848bb311da1845fb9929671292d332613c7b (patch)
tree731b6594108ee1149ed3b17cd3b44f2167f82ee6
parent6345a365c12ea582b8d4fefd595aba8116064d01 (diff)
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) <rmk+kernel@armlinux.org.uk>
-rw-r--r--drivers/net/phy/phylink.c5
-rw-r--r--include/linux/phylink.h19
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
@@ -51,6 +51,25 @@ static inline bool phylink_autoneg_inband(unsigned int mode)
}
/**
+ * 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
* @lp_advertising: ethtool bitmask containing link partner advertised link