From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61546C433E0 for ; Sun, 10 Jan 2021 11:17:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 37C0122AB9 for ; Sun, 10 Jan 2021 11:17:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726379AbhAJLO2 (ORCPT ); Sun, 10 Jan 2021 06:14:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726069AbhAJLO1 (ORCPT ); Sun, 10 Jan 2021 06:14:27 -0500 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6F86C06179F for ; Sun, 10 Jan 2021 03:13:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:Reply-To:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=i5OnjgxT3w7MYNDEieE0sbIxAroRQu9a+X2fCSx0cOw=; b=MCTZDvtUn0BvsS8heU8y5N+Ajs F8Wv+MHo1BONT7glWHZHIpf0yKuu1XDIuCUUPA3dke81FbdY3ybAQd6EHIWSyAmmo9MqTR2Qoex2a 3vDlf3ZtYVyI9TZd5W+GB5vjfS8Br8LBOcVJs4VIQ2Z09tOgtFByQbTsbae1V4RZmGcu+fUs00Tym HRaCuNC0qFOorXFlpF/9eLjiHmsapPOj6bBw/He/Lbm3/Ajm3Ufwm+i3OspADZcSUhJN1y+tzHea5 dPLrSqmeVO6foVVblN9fmpAsDicXxUigTSIPzAaZslUbfJJADt8WttdGkc/39bojnSYbWq3IVeZ3L HzMtL/Eg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:52524 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kyYfJ-0005n2-44; Sun, 10 Jan 2021 11:13:45 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.92) (envelope-from ) id 1kyYfI-0004wl-Tf; Sun, 10 Jan 2021 11:13:44 +0000 From: Russell King To: Richard Cochran , Andrew Lunn , Heiner Kallweit Cc: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH net-next] net: ethtool: allow MAC drivers to override ethtool get_ts_info MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" Message-Id: Sender: Russell King Date: Sun, 10 Jan 2021 11:13:44 +0000 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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