netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: ethtool: allow MAC drivers to override ethtool get_ts_info
@ 2021-01-10 11:13 Russell King
  2021-01-10 16:35 ` Andrew Lunn
  2021-01-14 12:55 ` Richard Cochran
  0 siblings, 2 replies; 19+ messages in thread
From: Russell King @ 2021-01-10 11:13 UTC (permalink / raw)
  To: Richard Cochran, Andrew Lunn, Heiner Kallweit
  Cc: David S. Miller, Jakub Kicinski, netdev

Check whether the MAC driver has implemented the get_ts_info()
method first, and call it if present.  If this method returns
-EOPNOTSUPP, defer to the phylib or default implementation.

This allows network drivers such as mvpp2 to use their more accurate
timestamping implementation than using a less accurate implementation
in the PHY. Network drivers can opt to defer to phylib by returning
-EOPNOTSUPP.

This change will be needed if the Marvell PHY drivers add support for
PTP.

Note: this may cause a change for any drivers that use phylib and
provide get_ts_info(). It is not obvious if any such cases exist.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 net/ethtool/common.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/ethtool/common.c b/net/ethtool/common.c
index 24036e3055a1..9ec93e24f239 100644
--- a/net/ethtool/common.c
+++ b/net/ethtool/common.c
@@ -385,14 +385,18 @@ int __ethtool_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info)
 {
 	const struct ethtool_ops *ops = dev->ethtool_ops;
 	struct phy_device *phydev = dev->phydev;
+	int ret;
 
 	memset(info, 0, sizeof(*info));
 	info->cmd = ETHTOOL_GET_TS_INFO;
 
+	if (ops->get_ts_info) {
+		ret = ops->get_ts_info(dev, info);
+		if (ret != -EOPNOTSUPP)
+			return ret;
+	}
 	if (phy_has_tsinfo(phydev))
 		return phy_ts_info(phydev, info);
-	if (ops->get_ts_info)
-		return ops->get_ts_info(dev, info);
 
 	info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE |
 				SOF_TIMESTAMPING_SOFTWARE;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2021-01-21 23:01 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-10 11:13 [PATCH net-next] net: ethtool: allow MAC drivers to override ethtool get_ts_info Russell King
2021-01-10 16:35 ` Andrew Lunn
2021-01-14  3:05   ` Jakub Kicinski
2021-01-14 17:09   ` Russell King - ARM Linux admin
2021-01-14 17:27     ` Russell King - ARM Linux admin
2021-01-14 12:55 ` Richard Cochran
2021-01-14 13:22   ` Russell King - ARM Linux admin
2021-01-14 13:32     ` Russell King - ARM Linux admin
2021-01-14 17:27       ` Richard Cochran
2021-01-14 17:31         ` Russell King - ARM Linux admin
2021-01-14 22:38           ` Russell King - ARM Linux admin
2021-01-21  4:04             ` Richard Cochran
2021-01-21 10:27               ` Russell King - ARM Linux admin
2021-01-21 15:06                 ` Richard Cochran
2021-01-21 16:22                   ` Andrew Lunn
2021-01-21 17:03                     ` Richard Cochran
2021-01-21 18:55                       ` Andrew Lunn
2021-01-21 22:59                         ` Russell King - ARM Linux admin
2021-01-21 18:18                   ` Russell King - ARM Linux admin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).