static void phylink_resolve(struct work_struct *w) { struct phylink *pl = container_of(w, struct phylink, resolve); struct phylink_link_state link_state; struct net_device *ndev = pl->netdev; mutex_lock(&pl->state_mutex); if (pl->phylink_disable_state) { pl->mac_link_dropped = false; link_state.link = false; } else if (pl->mac_link_dropped) { link_state.link = false; } else { switch (pl->link_an_mode) { case MLO_AN_PHY: link_state = pl->phy_state; phylink_resolve_flow(pl, &link_state); phylink_mac_config(pl, &link_state); break; case MLO_AN_FIXED: phylink_get_fixed_state(pl, &link_state); phylink_mac_config(pl, &link_state); break; case MLO_AN_SGMII: phylink_get_mac_state(pl, &link_state); if (pl->phydev) { bool changed = false; link_state.link = link_state.link && pl->phy_state.link; if (pl->phy_state.interface != link_state.interface) { link_state.interface = pl->phy_state.interface; changed = true; } /* Propagate the flow control from the PHY * to the MAC. Also propagate the interface * if changed. */ if (pl->phy_state.link || changed) { link_state.pause |= pl->phy_state.pause; phylink_resolve_flow(pl, &link_state); phylink_mac_config(pl, &link_state); } } break; case MLO_AN_8023Z: phylink_get_mac_state(pl, &link_state); break; } } if (link_state.link != netif_carrier_ok(ndev)) { if (!link_state.link) { netif_carrier_off(ndev); pl->ops->mac_link_down(ndev, pl->link_an_mode); netdev_info(ndev, "Link is Down\n"); } else { pl->ops->mac_link_up(ndev, pl->link_an_mode, pl->phydev); netif_carrier_on(ndev); netdev_info(ndev, "Link is Up - %s/%s - flow control %s\n", phy_speed_to_str(link_state.speed), phy_duplex_to_str(link_state.duplex), phylink_pause_to_str(link_state.pause)); } } if (!link_state.link && pl->mac_link_dropped) { pl->mac_link_dropped = false; queue_work(system_power_efficient_wq, &pl->resolve); } mutex_unlock(&pl->state_mutex); }
static void phylink_resolve(struct work_struct *w) { struct phylink *pl = container_of(w, struct phylink, resolve); struct phylink_link_state link_state; struct net_device *ndev = pl->netdev; mutex_lock(&pl->state_mutex); if (pl->phylink_disable_state) { pl->mac_link_dropped = false; link_state.link = false; } else if (pl->mac_link_dropped) { link_state.link = false; } else { switch (pl->link_an_mode) { case MLO_AN_PHY: link_state = pl->phy_state; phylink_resolve_flow(pl, &link_state); phylink_mac_config_up(pl, &link_state); break; case MLO_AN_FIXED: phylink_get_fixed_state(pl, &link_state); phylink_mac_config_up(pl, &link_state); break; case MLO_AN_INBAND: phylink_get_mac_state(pl, &link_state); /* If we have a phy, the "up" state is the union of * both the PHY and the MAC */ if (pl->phydev) link_state.link &= pl->phy_state.link; /* Only update if the PHY link is up */ if (pl->phydev && pl->phy_state.link) { link_state.interface = pl->phy_state.interface; /* If we have a PHY, we need to update with * the pause mode bits. */ link_state.pause |= pl->phy_state.pause; phylink_resolve_flow(pl, &link_state); phylink_mac_config(pl, &link_state); } break; } } if (link_state.link != netif_carrier_ok(ndev)) { if (!link_state.link) { netif_carrier_off(ndev); pl->ops->mac_link_down(ndev, pl->link_an_mode, pl->phy_state.interface); netdev_info(ndev, "Link is Down\n"); } else { pl->ops->mac_link_up(ndev, pl->link_an_mode, pl->phy_state.interface, pl->phydev); netif_carrier_on(ndev); netdev_info(ndev, "Link is Up - %s/%s - flow control %s\n", phy_speed_to_str(link_state.speed), phy_duplex_to_str(link_state.duplex), phylink_pause_to_str(link_state.pause)); } } if (!link_state.link && pl->mac_link_dropped) { pl->mac_link_dropped = false; queue_work(system_power_efficient_wq, &pl->resolve); } mutex_unlock(&pl->state_mutex); }