Add the phylink_mac_interrupt() function to phylink, which passes a link-change interrupt received by the MAC to phylib. This function can be used by drivers which want to avoid polling the PHY and instead rely on an interrupt received by the MAC when a link-change happens. Signed-off-by: Birger Koblitz Reviewed-by: Andrew Lunn Reviewed-by: Nicolai Buchwitz --- drivers/net/phy/phylink.c | 20 ++++++++++++++++++++ include/linux/phylink.h | 1 + 2 files changed, 21 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index a7d086cdc9b2516571bbcfbc3bf3fb37fc4bf6f4..a3ca7993eb7e0090941843194ca1b924cf8d9e89 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -1612,6 +1612,26 @@ static bool phylink_link_is_up(struct phylink *pl) return pl->netdev ? netif_carrier_ok(pl->netdev) : pl->old_link_state; } +/** + * phylink_mac_interrupt() - wrapper for phy_mac_interrupt() + * @pl: a pointer to a &struct phylink returned from phylink_create() + * + * Passes a link-change interrupt received by the MAC to phylib. + * This function may be called in interrupt context, and therefore cannot take + * a mutex. However, it is safe to assume that the reference to phy does not + * disappear during the call, as only an SFP module may be unplugged to make a + * PHY disappear. SFP modules however do not support interrupts. + */ +void phylink_mac_interrupt(struct phylink *pl) +{ + struct phy_device *phy; + + phy = pl->phydev; + if (phy) + phy_mac_interrupt(phy); +} +EXPORT_SYMBOL_GPL(phylink_mac_interrupt); + static void phylink_resolve(struct work_struct *w) { struct phylink *pl = container_of(w, struct phylink, resolve); diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 3a88a69882a610afb868b55df6f6e77aea918649..a7b6294cc4a075bd2aaa43ed6484de17a6cb88b1 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -768,6 +768,7 @@ int phylink_ethtool_set_eee(struct phylink *link, struct ethtool_keee *eee); int phylink_mii_ioctl(struct phylink *, struct ifreq *, int); int phylink_speed_down(struct phylink *pl, bool sync); int phylink_speed_up(struct phylink *pl); +void phylink_mac_interrupt(struct phylink *pl); #define phylink_zero(bm) \ bitmap_zero(bm, __ETHTOOL_LINK_MODE_MASK_NBITS) -- 2.47.3