void phylink_mac_change(struct phylink *pl, bool up) { if (!up) pl->mac_link_dropped = true; phylink_run_resolve(pl); netdev_dbg(pl->netdev, "mac link %s\n", up ? "up" : "down"); }
/** * phylink_start() - start a phylink instance * @pl: a pointer to a &struct phylink returned from phylink_create() * * Start the phylink instance specified by @pl, configuring the MAC for the * desired link mode(s) and negotiation style. This should be called from the * network device driver's &struct net_device_ops ndo_open() method. */ void phylink_start(struct phylink *pl) { ASSERT_RTNL(); netdev_info(pl->netdev, "configuring for %s/%s link mode\n", phylink_an_mode_str(pl->link_an_mode), phy_modes(pl->link_config.interface)); /* Always set the carrier off */ netif_carrier_off(pl->netdev); /* Apply the link configuration to the MAC when starting. This allows * a fixed-link to start with the correct parameters, and also * ensures that we set the appropriate advertisement for Serdes links. */ phylink_resolve_flow(pl, &pl->link_config); phylink_mac_config(pl, &pl->link_config); /* Restart autonegotiation if using 802.3z to ensure that the link * parameters are properly negotiated. This is necessary for DSA * switches using 802.3z negotiation to ensure they see our modes. */ phylink_mac_an_restart(pl); clear_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state); phylink_run_resolve(pl); if (pl->link_an_mode == MLO_AN_FIXED && !IS_ERR(pl->link_gpio)) mod_timer(&pl->link_poll, jiffies + HZ); if (pl->sfp_bus) sfp_upstream_start(pl->sfp_bus); if (pl->phydev) phy_start(pl->phydev); }
static void phylink_fixed_poll(struct timer_list *t) { struct phylink *pl = container_of(t, struct phylink, link_poll); mod_timer(t, jiffies + HZ); phylink_run_resolve(pl); }
static void phylink_sfp_link_up(void *upstream) { struct phylink *pl = upstream; WARN_ON(!lockdep_rtnl_is_held()); clear_bit(PHYLINK_DISABLE_LINK, &pl->phylink_disable_state); phylink_run_resolve(pl); }
static void phylink_sfp_link_up(void *upstream) { struct phylink *pl = upstream; ASSERT_RTNL(); clear_bit(PHYLINK_DISABLE_LINK, &pl->phylink_disable_state); phylink_run_resolve(pl); }
int phylink_ethtool_set_pauseparam(struct phylink *pl, struct ethtool_pauseparam *pause) { struct phylink_link_state *config = &pl->link_config; WARN_ON(!lockdep_rtnl_is_held()); if (!phylink_test(pl->supported, Pause) && !phylink_test(pl->supported, Asym_Pause)) return -EOPNOTSUPP; if (!phylink_test(pl->supported, Asym_Pause) && !pause->autoneg && pause->rx_pause != pause->tx_pause) return -EINVAL; config->pause &= ~(MLO_PAUSE_AN | MLO_PAUSE_TXRX_MASK); if (pause->autoneg) config->pause |= MLO_PAUSE_AN; if (pause->rx_pause) config->pause |= MLO_PAUSE_RX; if (pause->tx_pause) config->pause |= MLO_PAUSE_TX; if (!test_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state)) { switch (pl->link_an_mode) { case MLO_AN_PHY: /* Silently mark the carrier down, and then trigger a resolve */ netif_carrier_off(pl->netdev); phylink_run_resolve(pl); break; case MLO_AN_FIXED: /* Should we allow fixed links to change against the config? */ phylink_resolve_flow(pl, config); phylink_mac_config(pl, config); break; case MLO_AN_SGMII: case MLO_AN_8023Z: phylink_mac_config(pl, config); phylink_mac_an_restart(pl); break; } } return 0; }
void phylink_start(struct phylink *pl) { WARN_ON(!lockdep_rtnl_is_held()); netdev_info(pl->netdev, "configuring for %s/%s link mode\n", phylink_an_mode_str(pl->link_an_mode), phy_modes(pl->link_config.interface)); /* Apply the link configuration to the MAC when starting. This allows * a fixed-link to start with the correct parameters, and also * ensures that we set the appropriate advertisment for Serdes links. */ phylink_resolve_flow(pl, &pl->link_config); phylink_mac_config(pl, &pl->link_config); clear_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state); phylink_run_resolve(pl); if (pl->sfp_bus) sfp_upstream_start(pl->sfp_bus); if (pl->phydev) phy_start(pl->phydev); }
static void phylink_phy_change(struct phy_device *phydev, bool up, bool do_carrier) { struct phylink *pl = phydev->phylink; mutex_lock(&pl->state_mutex); pl->phy_state.speed = phydev->speed; pl->phy_state.duplex = phydev->duplex; pl->phy_state.pause = MLO_PAUSE_NONE; if (phydev->pause) pl->phy_state.pause |= MLO_PAUSE_SYM; if (phydev->asym_pause) pl->phy_state.pause |= MLO_PAUSE_ASYM; pl->phy_state.interface = phydev->interface; pl->phy_state.link = up; mutex_unlock(&pl->state_mutex); phylink_run_resolve(pl); netdev_dbg(pl->netdev, "phy link %s %s/%s/%s\n", up ? "up" : "down", phy_modes(phydev->interface), phy_speed_to_str(phydev->speed), phy_duplex_to_str(phydev->duplex)); }