mirror of
https://github.com/torvalds/linux.git
synced 2024-12-09 04:31:39 +00:00
net: stmmac: Move MAC caps init to phylink MAC caps getter
After a set of recent fixes the stmmac_phy_setup() and stmmac_reinit_queues() methods have turned to having some duplicated code. Let's get rid from the duplication by moving the MAC-capabilities initialization to the PHYLINK MAC-capabilities getter. The getter is called during each network device interface open/close cycle. So the MAC-capabilities will be initialized in generic device open procedure and in case of the Tx/Rx queues re-initialization as the original code semantics implies. Signed-off-by: Serge Semin <fancer.lancer@gmail.com> Reviewed-by: Romain Gantois <romain.gantois@bootlin.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
dc144baeb4
commit
f951a64922
@ -936,6 +936,22 @@ static void stmmac_mac_flow_ctrl(struct stmmac_priv *priv, u32 duplex)
|
||||
priv->pause, tx_cnt);
|
||||
}
|
||||
|
||||
static unsigned long stmmac_mac_get_caps(struct phylink_config *config,
|
||||
phy_interface_t interface)
|
||||
{
|
||||
struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
|
||||
|
||||
/* Refresh the MAC-specific capabilities */
|
||||
stmmac_mac_update_caps(priv);
|
||||
|
||||
config->mac_capabilities = priv->hw->link.caps;
|
||||
|
||||
if (priv->plat->max_speed)
|
||||
phylink_limit_mac_speed(config, priv->plat->max_speed);
|
||||
|
||||
return config->mac_capabilities;
|
||||
}
|
||||
|
||||
static struct phylink_pcs *stmmac_mac_select_pcs(struct phylink_config *config,
|
||||
phy_interface_t interface)
|
||||
{
|
||||
@ -1102,6 +1118,7 @@ static void stmmac_mac_link_up(struct phylink_config *config,
|
||||
}
|
||||
|
||||
static const struct phylink_mac_ops stmmac_phylink_mac_ops = {
|
||||
.mac_get_caps = stmmac_mac_get_caps,
|
||||
.mac_select_pcs = stmmac_mac_select_pcs,
|
||||
.mac_config = stmmac_mac_config,
|
||||
.mac_link_down = stmmac_mac_link_down,
|
||||
@ -1201,7 +1218,6 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
|
||||
int mode = priv->plat->phy_interface;
|
||||
struct fwnode_handle *fwnode;
|
||||
struct phylink *phylink;
|
||||
int max_speed;
|
||||
|
||||
priv->phylink_config.dev = &priv->dev->dev;
|
||||
priv->phylink_config.type = PHYLINK_NETDEV;
|
||||
@ -1225,15 +1241,6 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
|
||||
xpcs_get_interfaces(priv->hw->xpcs,
|
||||
priv->phylink_config.supported_interfaces);
|
||||
|
||||
/* Refresh the MAC-specific capabilities */
|
||||
stmmac_mac_update_caps(priv);
|
||||
|
||||
priv->phylink_config.mac_capabilities = priv->hw->link.caps;
|
||||
|
||||
max_speed = priv->plat->max_speed;
|
||||
if (max_speed)
|
||||
phylink_limit_mac_speed(&priv->phylink_config, max_speed);
|
||||
|
||||
fwnode = priv->plat->port_node;
|
||||
if (!fwnode)
|
||||
fwnode = dev_fwnode(priv->device);
|
||||
@ -7329,7 +7336,6 @@ int stmmac_reinit_queues(struct net_device *dev, u32 rx_cnt, u32 tx_cnt)
|
||||
{
|
||||
struct stmmac_priv *priv = netdev_priv(dev);
|
||||
int ret = 0, i;
|
||||
int max_speed;
|
||||
|
||||
if (netif_running(dev))
|
||||
stmmac_release(dev);
|
||||
@ -7343,14 +7349,6 @@ int stmmac_reinit_queues(struct net_device *dev, u32 rx_cnt, u32 tx_cnt)
|
||||
priv->rss.table[i] = ethtool_rxfh_indir_default(i,
|
||||
rx_cnt);
|
||||
|
||||
stmmac_mac_update_caps(priv);
|
||||
|
||||
priv->phylink_config.mac_capabilities = priv->hw->link.caps;
|
||||
|
||||
max_speed = priv->plat->max_speed;
|
||||
if (max_speed)
|
||||
phylink_limit_mac_speed(&priv->phylink_config, max_speed);
|
||||
|
||||
stmmac_napi_add(dev);
|
||||
|
||||
if (netif_running(dev))
|
||||
|
Loading…
Reference in New Issue
Block a user