diff options
Diffstat (limited to 'drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c')
| -rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 93 | 
1 files changed, 18 insertions, 75 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c index cec51ba34296..cfd93eefb50e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -1,19 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-only  /*******************************************************************************    STMMAC Ethtool support    Copyright (C) 2007-2009  STMicroelectronics Ltd -  This program is free software; you can redistribute it and/or modify it -  under the terms and conditions of the GNU General Public License, -  version 2, as published by the Free Software Foundation. - -  This program is distributed in the hope it will be useful, but WITHOUT -  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for -  more details. - -  The full GNU General Public License is included in this distribution in -  the file called "COPYING".    Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>  *******************************************************************************/ @@ -22,7 +12,7 @@  #include <linux/ethtool.h>  #include <linux/interrupt.h>  #include <linux/mii.h> -#include <linux/phy.h> +#include <linux/phylink.h>  #include <linux/net_tstamp.h>  #include <asm/io.h> @@ -274,7 +264,6 @@ static int stmmac_ethtool_get_link_ksettings(struct net_device *dev,  					     struct ethtool_link_ksettings *cmd)  {  	struct stmmac_priv *priv = netdev_priv(dev); -	struct phy_device *phy = dev->phydev;  	if (priv->hw->pcs & STMMAC_PCS_RGMII ||  	    priv->hw->pcs & STMMAC_PCS_SGMII) { @@ -353,18 +342,7 @@ static int stmmac_ethtool_get_link_ksettings(struct net_device *dev,  		return 0;  	} -	if (phy == NULL) { -		pr_err("%s: %s: PHY is not registered\n", -		       __func__, dev->name); -		return -ENODEV; -	} -	if (!netif_running(dev)) { -		pr_err("%s: interface is disabled: we cannot track " -		"link speed / duplex setting\n", dev->name); -		return -EBUSY; -	} -	phy_ethtool_ksettings_get(phy, cmd); -	return 0; +	return phylink_ethtool_ksettings_get(priv->phylink, cmd);  }  static int @@ -372,8 +350,6 @@ stmmac_ethtool_set_link_ksettings(struct net_device *dev,  				  const struct ethtool_link_ksettings *cmd)  {  	struct stmmac_priv *priv = netdev_priv(dev); -	struct phy_device *phy = dev->phydev; -	int rc;  	if (priv->hw->pcs & STMMAC_PCS_RGMII ||  	    priv->hw->pcs & STMMAC_PCS_SGMII) { @@ -397,9 +373,7 @@ stmmac_ethtool_set_link_ksettings(struct net_device *dev,  		return 0;  	} -	rc = phy_ethtool_ksettings_set(phy, cmd); - -	return rc; +	return phylink_ethtool_ksettings_set(priv->phylink, cmd);  }  static u32 stmmac_ethtool_getmsglevel(struct net_device *dev) @@ -443,6 +417,13 @@ static void stmmac_ethtool_gregs(struct net_device *dev,  	       NUM_DWMAC1000_DMA_REGS * 4);  } +static int stmmac_nway_reset(struct net_device *dev) +{ +	struct stmmac_priv *priv = netdev_priv(dev); + +	return phylink_ethtool_nway_reset(priv->phylink); +} +  static void  stmmac_get_pauseparam(struct net_device *netdev,  		      struct ethtool_pauseparam *pause) @@ -450,28 +431,13 @@ stmmac_get_pauseparam(struct net_device *netdev,  	struct stmmac_priv *priv = netdev_priv(netdev);  	struct rgmii_adv adv_lp; -	pause->rx_pause = 0; -	pause->tx_pause = 0; -  	if (priv->hw->pcs && !stmmac_pcs_get_adv_lp(priv, priv->ioaddr, &adv_lp)) {  		pause->autoneg = 1;  		if (!adv_lp.pause)  			return;  	} else { -		if (!linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT, -				       netdev->phydev->supported) || -		    !linkmode_test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, -				      netdev->phydev->supported)) -			return; +		phylink_ethtool_get_pauseparam(priv->phylink, pause);  	} - -	pause->autoneg = netdev->phydev->autoneg; - -	if (priv->flow_ctrl & FLOW_RX) -		pause->rx_pause = 1; -	if (priv->flow_ctrl & FLOW_TX) -		pause->tx_pause = 1; -  }  static int @@ -479,39 +445,16 @@ stmmac_set_pauseparam(struct net_device *netdev,  		      struct ethtool_pauseparam *pause)  {  	struct stmmac_priv *priv = netdev_priv(netdev); -	u32 tx_cnt = priv->plat->tx_queues_to_use; -	struct phy_device *phy = netdev->phydev; -	int new_pause = FLOW_OFF;  	struct rgmii_adv adv_lp;  	if (priv->hw->pcs && !stmmac_pcs_get_adv_lp(priv, priv->ioaddr, &adv_lp)) {  		pause->autoneg = 1;  		if (!adv_lp.pause)  			return -EOPNOTSUPP; +		return 0;  	} else { -		if (!linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT, -				       phy->supported) || -		    !linkmode_test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, -				      phy->supported)) -			return -EOPNOTSUPP; +		return phylink_ethtool_set_pauseparam(priv->phylink, pause);  	} - -	if (pause->rx_pause) -		new_pause |= FLOW_RX; -	if (pause->tx_pause) -		new_pause |= FLOW_TX; - -	priv->flow_ctrl = new_pause; -	phy->autoneg = pause->autoneg; - -	if (phy->autoneg) { -		if (netif_running(netdev)) -			return phy_start_aneg(phy); -	} - -	stmmac_flow_ctrl(priv, priv->hw, phy->duplex, priv->flow_ctrl, -			priv->pause, tx_cnt); -	return 0;  }  static void stmmac_get_ethtool_stats(struct net_device *dev, @@ -549,7 +492,7 @@ static void stmmac_get_ethtool_stats(struct net_device *dev,  			}  		}  		if (priv->eee_enabled) { -			int val = phy_get_eee_err(dev->phydev); +			int val = phylink_get_eee_err(priv->phylink);  			if (val)  				priv->xstats.phy_eee_wakeup_error_n = val;  		} @@ -694,7 +637,7 @@ static int stmmac_ethtool_op_get_eee(struct net_device *dev,  	edata->eee_active = priv->eee_active;  	edata->tx_lpi_timer = priv->tx_lpi_timer; -	return phy_ethtool_get_eee(dev->phydev, edata); +	return phylink_ethtool_get_eee(priv->phylink, edata);  }  static int stmmac_ethtool_op_set_eee(struct net_device *dev, @@ -715,7 +658,7 @@ static int stmmac_ethtool_op_set_eee(struct net_device *dev,  			return -EOPNOTSUPP;  	} -	ret = phy_ethtool_set_eee(dev->phydev, edata); +	ret = phylink_ethtool_set_eee(priv->phylink, edata);  	if (ret)  		return ret; @@ -892,7 +835,7 @@ static const struct ethtool_ops stmmac_ethtool_ops = {  	.get_regs = stmmac_ethtool_gregs,  	.get_regs_len = stmmac_ethtool_get_regs_len,  	.get_link = ethtool_op_get_link, -	.nway_reset = phy_ethtool_nway_reset, +	.nway_reset = stmmac_nway_reset,  	.get_pauseparam = stmmac_get_pauseparam,  	.set_pauseparam = stmmac_set_pauseparam,  	.self_test = stmmac_selftest_run,  | 

