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 e885da1c28311a12a869e29ceb3c96886f31adc6..a87eaa2f3db5bef8fe56e12b90375bdb7f9c52e7 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -1616,6 +1616,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