mirror of
				git://git.openwrt.org/openwrt/openwrt.git
				synced 2025-10-31 14:04:26 -04:00 
			
		
		
		
	All patches automatically rebased.
Build system: x86_64
Build-tested: ramips/mt7621*
*FS#4149 affects me so I had to revert 7f1edbd412
in order to downgrade to 2.35.1
Signed-off-by: John Audia <graysky@archlinux.us>
		
	
			
		
			
				
	
	
		
			134 lines
		
	
	
		
			4.3 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			134 lines
		
	
	
		
			4.3 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
| From a155893c9c272b2ed1dc3b236d55ca8f651a6ea1 Mon Sep 17 00:00:00 2001
 | |
| From: Vladimir Oltean <vladimir.oltean@nxp.com>
 | |
| Date: Sat, 9 Nov 2019 15:02:54 +0200
 | |
| Subject: [PATCH] net: mscc: ocelot: refactor ethtool callbacks
 | |
| 
 | |
| Convert them into an implementation that can be called from DSA as well.
 | |
| 
 | |
| Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
 | |
| Signed-off-by: David S. Miller <davem@davemloft.net>
 | |
| ---
 | |
|  drivers/net/ethernet/mscc/ocelot.c | 64 ++++++++++++++++++++++++++++----------
 | |
|  1 file changed, 47 insertions(+), 17 deletions(-)
 | |
| 
 | |
| --- a/drivers/net/ethernet/mscc/ocelot.c
 | |
| +++ b/drivers/net/ethernet/mscc/ocelot.c
 | |
| @@ -1185,10 +1185,9 @@ static const struct net_device_ops ocelo
 | |
|  	.ndo_do_ioctl			= ocelot_ioctl,
 | |
|  };
 | |
|  
 | |
| -static void ocelot_get_strings(struct net_device *netdev, u32 sset, u8 *data)
 | |
| +static void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset,
 | |
| +			       u8 *data)
 | |
|  {
 | |
| -	struct ocelot_port_private *priv = netdev_priv(netdev);
 | |
| -	struct ocelot *ocelot = priv->port.ocelot;
 | |
|  	int i;
 | |
|  
 | |
|  	if (sset != ETH_SS_STATS)
 | |
| @@ -1199,6 +1198,16 @@ static void ocelot_get_strings(struct ne
 | |
|  		       ETH_GSTRING_LEN);
 | |
|  }
 | |
|  
 | |
| +static void ocelot_port_get_strings(struct net_device *netdev, u32 sset,
 | |
| +				    u8 *data)
 | |
| +{
 | |
| +	struct ocelot_port_private *priv = netdev_priv(netdev);
 | |
| +	struct ocelot *ocelot = priv->port.ocelot;
 | |
| +	int port = priv->chip_port;
 | |
| +
 | |
| +	ocelot_get_strings(ocelot, port, sset, data);
 | |
| +}
 | |
| +
 | |
|  static void ocelot_update_stats(struct ocelot *ocelot)
 | |
|  {
 | |
|  	int i, j;
 | |
| @@ -1239,12 +1248,8 @@ static void ocelot_check_stats_work(stru
 | |
|  			   OCELOT_STATS_CHECK_DELAY);
 | |
|  }
 | |
|  
 | |
| -static void ocelot_get_ethtool_stats(struct net_device *dev,
 | |
| -				     struct ethtool_stats *stats, u64 *data)
 | |
| +static void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data)
 | |
|  {
 | |
| -	struct ocelot_port_private *priv = netdev_priv(dev);
 | |
| -	struct ocelot *ocelot = priv->port.ocelot;
 | |
| -	int port = priv->chip_port;
 | |
|  	int i;
 | |
|  
 | |
|  	/* check and update now */
 | |
| @@ -1255,25 +1260,37 @@ static void ocelot_get_ethtool_stats(str
 | |
|  		*data++ = ocelot->stats[port * ocelot->num_stats + i];
 | |
|  }
 | |
|  
 | |
| -static int ocelot_get_sset_count(struct net_device *dev, int sset)
 | |
| +static void ocelot_port_get_ethtool_stats(struct net_device *dev,
 | |
| +					  struct ethtool_stats *stats,
 | |
| +					  u64 *data)
 | |
|  {
 | |
|  	struct ocelot_port_private *priv = netdev_priv(dev);
 | |
|  	struct ocelot *ocelot = priv->port.ocelot;
 | |
| +	int port = priv->chip_port;
 | |
|  
 | |
| +	ocelot_get_ethtool_stats(ocelot, port, data);
 | |
| +}
 | |
| +
 | |
| +static int ocelot_get_sset_count(struct ocelot *ocelot, int port, int sset)
 | |
| +{
 | |
|  	if (sset != ETH_SS_STATS)
 | |
|  		return -EOPNOTSUPP;
 | |
| +
 | |
|  	return ocelot->num_stats;
 | |
|  }
 | |
|  
 | |
| -static int ocelot_get_ts_info(struct net_device *dev,
 | |
| -			      struct ethtool_ts_info *info)
 | |
| +static int ocelot_port_get_sset_count(struct net_device *dev, int sset)
 | |
|  {
 | |
|  	struct ocelot_port_private *priv = netdev_priv(dev);
 | |
|  	struct ocelot *ocelot = priv->port.ocelot;
 | |
| +	int port = priv->chip_port;
 | |
|  
 | |
| -	if (!ocelot->ptp)
 | |
| -		return ethtool_op_get_ts_info(dev, info);
 | |
| +	return ocelot_get_sset_count(ocelot, port, sset);
 | |
| +}
 | |
|  
 | |
| +static int ocelot_get_ts_info(struct ocelot *ocelot, int port,
 | |
| +			      struct ethtool_ts_info *info)
 | |
| +{
 | |
|  	info->phc_index = ocelot->ptp_clock ?
 | |
|  			  ptp_clock_index(ocelot->ptp_clock) : -1;
 | |
|  	info->so_timestamping |= SOF_TIMESTAMPING_TX_SOFTWARE |
 | |
| @@ -1292,13 +1309,26 @@ static int ocelot_get_ts_info(struct net
 | |
|  	return 0;
 | |
|  }
 | |
|  
 | |
| +static int ocelot_port_get_ts_info(struct net_device *dev,
 | |
| +				   struct ethtool_ts_info *info)
 | |
| +{
 | |
| +	struct ocelot_port_private *priv = netdev_priv(dev);
 | |
| +	struct ocelot *ocelot = priv->port.ocelot;
 | |
| +	int port = priv->chip_port;
 | |
| +
 | |
| +	if (!ocelot->ptp)
 | |
| +		return ethtool_op_get_ts_info(dev, info);
 | |
| +
 | |
| +	return ocelot_get_ts_info(ocelot, port, info);
 | |
| +}
 | |
| +
 | |
|  static const struct ethtool_ops ocelot_ethtool_ops = {
 | |
| -	.get_strings		= ocelot_get_strings,
 | |
| -	.get_ethtool_stats	= ocelot_get_ethtool_stats,
 | |
| -	.get_sset_count		= ocelot_get_sset_count,
 | |
| +	.get_strings		= ocelot_port_get_strings,
 | |
| +	.get_ethtool_stats	= ocelot_port_get_ethtool_stats,
 | |
| +	.get_sset_count		= ocelot_port_get_sset_count,
 | |
|  	.get_link_ksettings	= phy_ethtool_get_link_ksettings,
 | |
|  	.set_link_ksettings	= phy_ethtool_set_link_ksettings,
 | |
| -	.get_ts_info		= ocelot_get_ts_info,
 | |
| +	.get_ts_info		= ocelot_port_get_ts_info,
 | |
|  };
 | |
|  
 | |
|  static void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port,
 |