Commit ae4899bb authored by Russell King (Oracle)'s avatar Russell King (Oracle) Committed by Jakub Kicinski

net: phylink: provide phylink_pcs_config() and phylink_pcs_link_up()

Add two helper functions for calling PCS methods. phylink_pcs_config()
allows us to handle PCS configuration specifics in one location, rather
than the two call sites. phylink_pcs_link_up() gives us consistency.
Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://lore.kernel.org/r/E1q1TzK-007Exd-Rs@rmk-PC.armlinux.org.ukSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 8a5ad2ea
...@@ -992,6 +992,25 @@ static void phylink_resolve_an_pause(struct phylink_link_state *state) ...@@ -992,6 +992,25 @@ static void phylink_resolve_an_pause(struct phylink_link_state *state)
} }
} }
static int phylink_pcs_config(struct phylink_pcs *pcs, unsigned int mode,
const struct phylink_link_state *state,
bool permit_pause_to_mac)
{
if (!pcs)
return 0;
return pcs->ops->pcs_config(pcs, mode, state->interface,
state->advertising, permit_pause_to_mac);
}
static void phylink_pcs_link_up(struct phylink_pcs *pcs, unsigned int mode,
phy_interface_t interface, int speed,
int duplex)
{
if (pcs && pcs->ops->pcs_link_up)
pcs->ops->pcs_link_up(pcs, mode, interface, speed, duplex);
}
static void phylink_pcs_poll_stop(struct phylink *pl) static void phylink_pcs_poll_stop(struct phylink *pl)
{ {
if (pl->cfg_link_an_mode == MLO_AN_INBAND) if (pl->cfg_link_an_mode == MLO_AN_INBAND)
...@@ -1075,18 +1094,15 @@ static void phylink_major_config(struct phylink *pl, bool restart, ...@@ -1075,18 +1094,15 @@ static void phylink_major_config(struct phylink *pl, bool restart,
phylink_mac_config(pl, state); phylink_mac_config(pl, state);
if (pl->pcs) { err = phylink_pcs_config(pl->pcs, pl->cur_link_an_mode, state,
err = pl->pcs->ops->pcs_config(pl->pcs, pl->cur_link_an_mode,
state->interface,
state->advertising,
!!(pl->link_config.pause & !!(pl->link_config.pause &
MLO_PAUSE_AN)); MLO_PAUSE_AN));
if (err < 0) if (err < 0)
phylink_err(pl, "pcs_config failed: %pe\n", phylink_err(pl, "pcs_config failed: %pe\n",
ERR_PTR(err)); ERR_PTR(err));
if (err > 0) else if (err > 0)
restart = true; restart = true;
}
if (restart) if (restart)
phylink_mac_pcs_an_restart(pl); phylink_mac_pcs_an_restart(pl);
...@@ -1137,11 +1153,9 @@ static int phylink_change_inband_advert(struct phylink *pl) ...@@ -1137,11 +1153,9 @@ static int phylink_change_inband_advert(struct phylink *pl)
* restart negotiation if the pcs_config() helper indicates that * restart negotiation if the pcs_config() helper indicates that
* the programmed advertisement has changed. * the programmed advertisement has changed.
*/ */
ret = pl->pcs->ops->pcs_config(pl->pcs, pl->cur_link_an_mode, ret = phylink_pcs_config(pl->pcs, pl->cur_link_an_mode,
pl->link_config.interface, &pl->link_config,
pl->link_config.advertising, !!(pl->link_config.pause & MLO_PAUSE_AN));
!!(pl->link_config.pause &
MLO_PAUSE_AN));
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1273,9 +1287,8 @@ static void phylink_link_up(struct phylink *pl, ...@@ -1273,9 +1287,8 @@ static void phylink_link_up(struct phylink *pl,
pl->cur_interface = link_state.interface; pl->cur_interface = link_state.interface;
if (pl->pcs && pl->pcs->ops->pcs_link_up) phylink_pcs_link_up(pl->pcs, pl->cur_link_an_mode, pl->cur_interface,
pl->pcs->ops->pcs_link_up(pl->pcs, pl->cur_link_an_mode, speed, duplex);
pl->cur_interface, speed, duplex);
pl->mac_ops->mac_link_up(pl->config, pl->phydev, pl->cur_link_an_mode, pl->mac_ops->mac_link_up(pl->config, pl->phydev, pl->cur_link_an_mode,
pl->cur_interface, speed, duplex, pl->cur_interface, speed, duplex,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment