From patchwork Tue Aug 1 14:28:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13336833 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AA8F5C001DF for ; Tue, 1 Aug 2023 14:30:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=83ukMnsndPKwh6g2UirVG56QPB3mq+daGRYoyPBwKQs=; b=SvJkrErUl9tuEI VOtUL3I/39Rjsr/yjUtowvDGJn8OwdGNXyqOc1F5mW4Tr4877mDAQVdfXSbXDkfK26w0AZASlNNhi rEHRrEF/j+gK6AS3MEsGRbPQlxemqUKw/rd1JgKWYF6gQreXL2FPerOIqcYC5Z9W+y7iXlr7NHQe9 CxTgzXxzBsGjPz29NusHrOC7gzdoxAjXQTAKexv8HW27rh4TYW9JaE4p3Ah8EDFTH9/CW/t/MLPnI 06gX5IScrtZ3AZ3HgAzOEkt89njn4ulWK4wODDOyV4tGm0f5QvhkgR9pN+vFUbS7z9BeeyAoKejay yXMEm/U0fB/uc/tI7I5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQqNn-002aUr-1s; Tue, 01 Aug 2023 14:29:55 +0000 Received: from mail-db8eur05on20604.outbound.protection.outlook.com ([2a01:111:f400:7e1a::604] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qQqNk-002aEd-0H for linux-arm-kernel@lists.infradead.org; Tue, 01 Aug 2023 14:29:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P9iJJopknf+jBY6NT2Nddlk/LhfjA70MT9qZvQo02XCP8dtEwsOIfwzqwtCaRd543gdOQUeIGTZRDEFvMBRUCeR5TT8tXSEkwi3j1UoYN9xkG7cQnGxV3rJXGBe+2sU0rfwkMYalnu+foDeB4xdqyk+mlgnSvVp8USO92xqxg34wONJTaIRHiVXCVPJ9WVV1vje27RmUkD+S27IqvmBN83Pavi3p6BLGDDe/bonUGVEYFq8V62dfKrV+T5roK5cgJUUoYmytS23eUud0DGwULkI2eUfFlmObg8+W9bU7sCKfZtvpzMYoDx36V/GLXaqdWVfWx1hbMeDUmWW2wqf2wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=z6/qRrCi6wl6NmsjgBr8nqHZOT67YGTyop4LMMkF8DQ=; b=mxCvPa0YJ0/djKhXkogmoInPNjTDAPB23lyltInrhvmNqXh/poyTCuF1uXiLZAwQI+P6MvCobOag5X7AtWvS1ZMsyQOya+siqD3QmBiG/ZagkiJYlyJnOBp4PGrCPFpSR3NPZxQBnJF7bDhXOciF0fOQQu6ca+7IQpi7+wlY6Lcn3yJvgswasE6sEGgwCn4/QB6AwRzYlCYrZo9vwPSXnlDo4k3g5kzKr/x98zchaTJ40EsMB4+7YvoygvtBYzofcT9rJqhNs2kFJN1RZRThjulfKC98GXGuJkeV3yGXg94KZPY9+uohytsMykvdlYLJcFijiyGxRtKuF0ZckaotYg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=z6/qRrCi6wl6NmsjgBr8nqHZOT67YGTyop4LMMkF8DQ=; b=NLKQnLBG3x6M3HyoLfkod4smzpcq90jz8+D3Iu28g8HtlpKr1JQvHlsKF8Y+t6FVmTPgDlPjuCcFXa8O/aITVio+WD96551LYw4Objp7Sk0LgYlX3Dr9R3upRQ1sB6gCRLU4UdES0Whw8bsyLc5/Sq/V099PlO6CZmCFZAY3zoc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by VI1PR04MB10028.eurprd04.prod.outlook.com (2603:10a6:800:1db::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.43; Tue, 1 Aug 2023 14:29:44 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::6074:afac:3fae:6194]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::6074:afac:3fae:6194%4]) with mapi id 15.20.6631.043; Tue, 1 Aug 2023 14:29:44 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Florian Fainelli , Maxim Georgiev , Horatiu Vultur , =?utf-8?q?K=C3=B6ry_Maincent?= , Maxime Chevallier , Richard Cochran , Vadim Fedorenko , Gerhard Engleder , Hangbin Liu , Russell King , Heiner Kallweit , Jacob Keller , Jay Vosburgh , Andy Gospodarek , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , UNGLinuxDriver@microchip.com, Lars Povlsen , Steen Hegelund , Daniel Machon , Simon Horman , Casper Andersson , Sergey Organov , Michal Kubecek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 net-next 11/12] net: phy: provide phylib stubs for hardware timestamping operations Date: Tue, 1 Aug 2023 17:28:23 +0300 Message-Id: <20230801142824.1772134-12-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230801142824.1772134-1-vladimir.oltean@nxp.com> References: <20230801142824.1772134-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR04CA0027.eurprd04.prod.outlook.com (2603:10a6:208:122::40) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|VI1PR04MB10028:EE_ X-MS-Office365-Filtering-Correlation-Id: 627aa17a-90da-495a-e627-08db929bbfc8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uciq3/rDc0iZc4uY9rZtfwgGxLFcfukG5A6QGiYIycpcdSzb89kOKp2RbWKDx4x66bN4RCylT0fgBlzsvmJWWL992fqgxOevN9Ok22nV0T/wGvpIOlFqotFpc0tekSRGjZKNgiSnHysQz/3vR0QeXQ4cd7JOWVFERnnSUOCDYnTShEEWuhN7CNkmOO8+eFo76DkALyBxFfKE2LFXokxVWyOUNMMhs8aLLuVPnIia7+04vXfD48ulzDTdEwXNVnJiw2q1rgVJEkp1KHWIbco24VwL6cIlZcKJyZOn+AZb7/dyIdPWIOn4nXa/BPeTA9XUANiZWY1gfJuTEGNnhl/O3KtB2Mrou/GqGl4ioO2RKnz67qdoIwo08jzvUwy4Nv2pX8xXZDgHDOr3DNONirBQb7EUSv23p1FR2S3ZzsrEh59jFYnr/wozzfg2kuyvEz7PMCEE4z6o44BMCqcFLxDHG9v46QuhOK3nHvErVwZyrSO0hJmTbep7gLf3FacVO/malHisYYX+4VWMWR66KCcjg1DHZyDclA0kctxpIzLL6QNDIyT3rztVMtwGM7B7jcH4Cu+dx+jSE0Qi8aBNpC8QCY/sgKXyMfS8GklZqUAdhOqjxDHi1GcAhMtto7F8nYFa X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(136003)(376002)(346002)(39860400002)(396003)(451199021)(66476007)(66946007)(6916009)(66556008)(2906002)(4326008)(44832011)(5660300002)(7406005)(54906003)(41300700001)(316002)(7416002)(2616005)(52116002)(6486002)(6666004)(26005)(8936002)(6506007)(1076003)(8676002)(186003)(83380400001)(478600001)(36756003)(38100700002)(38350700002)(6512007)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rJFGh2kHA7XBYNPlTpc/VYTdSXavtoLPGilM2LrwQT0IjftOb7XHqWaRpQpPQNMWmkIAWo54ybLzWVhnUbjMydq7xEzFNFNRuOIy8x8qy1eVKrHI/yXuZghkeN7tiGSh7qe13SlfDdfw1w4e+MuWj1VnqNcNNgZcdx7WIAyzxhxqUidI/XG9nL8o/1AWDLKRtchW/tfB8RBzvvzez7MZ8uTq0LTlpG26NzON885+bLWx5SxUC/j+5A/r7ue0UnBlNWfzwiV/CRwhWFPX49SfBbE89R9fR2LxqYfreCXk240avf+bU2mWuEpT7NxQcZwB8gZVYwdCSxFtI5eYNFLK0iwDcLZYDR8zj2WXfA2uPXEHOfT/vMtaoDWtcDh4rFQktQG7v8He6B+EVn8+EP5kYxckiH2QBdyie34OovUsj9OHQha9JTUxh1to6xpa0f0pmPzvTBhbxHj3bX5ke1/xUCUkspH9h5FZZ9O85UotunXwVEA/Mwv8iozk1DZTXBhHq2leLZO/3sGMQUB+4tkESz6enr5R2obkNX6kbwxO03ig5e1anjyMZfafyOZ8gPFcFNP+5h7FWSX26bddNRrxjP5xjen4tMuMGvDniiyNgEfJNKky4MqxCQS84eSN8L5/yxFY83nX26pj8BXxWkn/44JtNjiVsw67AvZ/1x+g+PIOai8lbOIOnbAitvXwkoUWTEMMzzQPMkxqs3zkefmwLCILzBlUh1PvHBOh49W56auFLYfLcX8aqIDGymx4nyjgDEKbYpZIPXUj6x8yTnnlEgnt7vsBbya8EsP121N0sgzZnAUrJJZ3YSZzetlepnF3y1xiRVQalGfu4B00DnZCDTcKGIBSPQLiYrmHApYjdQ8rk8lw2sIP3Sfp1PFQvKkpV8sO89Ayk2OsoE0pCht6Dq0cewQF4x8hsh2D3XfL4utd3xPxasWFXjtUts9e5pD3mV4fQH/ewUZ3OkAgAd9AyBJAiCacoYk3khcZ2tLH28QDKyAyxab+qY6K5PaG5b6VqD+3nkVsasfRgOcq51HdueykKVcfNXEHtTZ70R4Oc58eA3GgSN9XzwiOl+e6qqy7CFr9vnrhf5eMFSuN7wfYSGneenjGM5lv6CXX2rk8U3djCI/LzvEr8BjhZ5ryedqOsZmXbhW1i4nOk04Dj/eJ4RpOw4o1Sq5DeYC0/uMrWW2pNfDyIWDxdHcUCAMhfz0xqGmniAME8X+n9MnqoRpTBjUdqi9OxGiy2JfyNQzAHomAsJSGF1eqpf0lh9gyt0bjbdSL0mxv7rkDHN5WGKPcHFyinNgFZmaUa/v0VIsBZgkNAC8Vu91o8jlsuhjqOrjH1SVKOGEgxbgeq2UsJSr4IFkH4xbA4GxjJT+N28k41w5DA2yHSNpPiGjBPLkUxQlruz1ukczHrmdKjGOLsmtO9J8ASPSaiyrRKfZPelWu2WXXcySiWeXTSOEKl/6j+IXoMI7P7wAGMevFqx8hKDwYa0V0S6VMHtDZMN8MPXc1wzMq5XiMeq+c/uMUSs7sYHgrPMF+bnbcyxOTa9B0+/fYfmBubICv+J3EikTe8t9/ZXTlG8I62s+4olDESKHwVFnKgcaT4EVisJePCr1OM0by0g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 627aa17a-90da-495a-e627-08db929bbfc8 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2023 14:29:44.0733 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gMDJfWDHFrM8smM5/DwFqEGdfpdoqkGgZn/zklwRegV2eh095BBG8z5FfIu6wCscL/xD9AEvFRGzQOmk1xjuRg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB10028 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230801_072952_256003_9E154AA3 X-CRM114-Status: GOOD ( 25.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org net/core/dev_ioctl.c (built-in code) will want to call phy_mii_ioctl() for hardware timestamping purposes. This is not directly possible, because phy_mii_ioctl() is a symbol provided under CONFIG_PHYLIB. Do something similar to what was done in DSA in commit 5a17818682cf ("net: dsa: replace NETDEV_PRE_CHANGE_HWTSTAMP notifier with a stub"), and arrange some indirect calls to phy_mii_ioctl() through a stub structure containing function pointers, that's provided by phylib as built-in even when CONFIG_PHYLIB=m, and which phy_init() populates at runtime (module insertion). Note: maybe the ownership of the ethtool_phy_ops singleton is backwards, and the methods exposed by that should be later merged into phylib_stubs. Signed-off-by: Vladimir Oltean --- Changes in v9: - Add MAINTAINERS entry - Add missing include/linux/phylib_stubs.h - Add missing drivers/net/phy/stubs.c Changes in v8: - Patch is new MAINTAINERS | 1 + drivers/net/phy/Makefile | 2 ++ drivers/net/phy/phy.c | 34 ++++++++++++++++++ drivers/net/phy/phy_device.c | 19 ++++++++++ drivers/net/phy/stubs.c | 10 ++++++ include/linux/phy.h | 7 ++++ include/linux/phylib_stubs.h | 68 ++++++++++++++++++++++++++++++++++++ 7 files changed, 141 insertions(+) create mode 100644 drivers/net/phy/stubs.c create mode 100644 include/linux/phylib_stubs.h diff --git a/MAINTAINERS b/MAINTAINERS index c4f95a9d03b9..069e176d607a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7752,6 +7752,7 @@ F: include/linux/mii.h F: include/linux/of_net.h F: include/linux/phy.h F: include/linux/phy_fixed.h +F: include/linux/phylib_stubs.h F: include/linux/platform_data/mdio-bcm-unimac.h F: include/linux/platform_data/mdio-gpio.h F: include/trace/events/mdio.h diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile index 35142780fc9d..c945ed9bd14b 100644 --- a/drivers/net/phy/Makefile +++ b/drivers/net/phy/Makefile @@ -14,6 +14,8 @@ endif # dedicated loadable module, so we bundle them all together into libphy.ko ifdef CONFIG_PHYLIB libphy-y += $(mdio-bus-y) +# the stubs are built-in whenever PHYLIB is built-in or module +obj-y += stubs.o else obj-$(CONFIG_MDIO_DEVICE) += mdio-bus.o endif diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index bdf00b2b2c1d..8aec8e83038c 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -455,6 +455,40 @@ int phy_do_ioctl_running(struct net_device *dev, struct ifreq *ifr, int cmd) } EXPORT_SYMBOL(phy_do_ioctl_running); +/** + * __phy_hwtstamp_get - Get hardware timestamping configuration from PHY + * + * @phydev: the PHY device structure + * @config: structure holding the timestamping configuration + * + * Query the PHY device for its current hardware timestamping configuration. + */ +int __phy_hwtstamp_get(struct phy_device *phydev, + struct kernel_hwtstamp_config *config) +{ + if (!phydev) + return -ENODEV; + + return phy_mii_ioctl(phydev, config->ifr, SIOCGHWTSTAMP); +} + +/** + * __phy_hwtstamp_set - Modify PHY hardware timestamping configuration + * + * @phydev: the PHY device structure + * @config: structure holding the timestamping configuration + * @extack: netlink extended ack structure, for error reporting + */ +int __phy_hwtstamp_set(struct phy_device *phydev, + struct kernel_hwtstamp_config *config, + struct netlink_ext_ack *extack) +{ + if (!phydev) + return -ENODEV; + + return phy_mii_ioctl(phydev, config->ifr, SIOCSHWTSTAMP); +} + /** * phy_queue_state_machine - Trigger the state machine to run soon * diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 98b8ac28e5a1..e19c4fee8d22 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -3448,12 +3449,28 @@ static const struct ethtool_phy_ops phy_ethtool_phy_ops = { .start_cable_test_tdr = phy_start_cable_test_tdr, }; +static const struct phylib_stubs __phylib_stubs = { + .hwtstamp_get = __phy_hwtstamp_get, + .hwtstamp_set = __phy_hwtstamp_set, +}; + +static void phylib_register_stubs(void) +{ + phylib_stubs = &__phylib_stubs; +} + +static void phylib_unregister_stubs(void) +{ + phylib_stubs = NULL; +} + static int __init phy_init(void) { int rc; rtnl_lock(); ethtool_set_ethtool_phy_ops(&phy_ethtool_phy_ops); + phylib_register_stubs(); rtnl_unlock(); rc = mdio_bus_init(); @@ -3478,6 +3495,7 @@ static int __init phy_init(void) mdio_bus_exit(); err_ethtool_phy_ops: rtnl_lock(); + phylib_unregister_stubs(); ethtool_set_ethtool_phy_ops(NULL); rtnl_unlock(); @@ -3490,6 +3508,7 @@ static void __exit phy_exit(void) phy_driver_unregister(&genphy_driver); mdio_bus_exit(); rtnl_lock(); + phylib_unregister_stubs(); ethtool_set_ethtool_phy_ops(NULL); rtnl_unlock(); } diff --git a/drivers/net/phy/stubs.c b/drivers/net/phy/stubs.c new file mode 100644 index 000000000000..cfb9f275eb18 --- /dev/null +++ b/drivers/net/phy/stubs.c @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Stubs for PHY library functionality called by the core network stack. + * These are necessary because CONFIG_PHYLIB can be a module, and built-in + * code cannot directly call symbols exported by modules. + */ +#include + +const struct phylib_stubs *phylib_stubs; +EXPORT_SYMBOL_GPL(phylib_stubs); diff --git a/include/linux/phy.h b/include/linux/phy.h index b254848a9c99..ba08b0e60279 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -298,6 +298,7 @@ static inline const char *phy_modes(phy_interface_t interface) #define MII_BUS_ID_SIZE 61 struct device; +struct kernel_hwtstamp_config; struct phylink; struct sfp_bus; struct sfp_upstream_ops; @@ -1955,6 +1956,12 @@ int phy_ethtool_set_plca_cfg(struct phy_device *phydev, int phy_ethtool_get_plca_status(struct phy_device *phydev, struct phy_plca_status *plca_st); +int __phy_hwtstamp_get(struct phy_device *phydev, + struct kernel_hwtstamp_config *config); +int __phy_hwtstamp_set(struct phy_device *phydev, + struct kernel_hwtstamp_config *config, + struct netlink_ext_ack *extack); + static inline int phy_package_read(struct phy_device *phydev, u32 regnum) { struct phy_package_shared *shared = phydev->shared; diff --git a/include/linux/phylib_stubs.h b/include/linux/phylib_stubs.h new file mode 100644 index 000000000000..1279f48c8a70 --- /dev/null +++ b/include/linux/phylib_stubs.h @@ -0,0 +1,68 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Stubs for the Network PHY library + */ + +#include + +struct kernel_hwtstamp_config; +struct netlink_ext_ack; +struct phy_device; + +#if IS_ENABLED(CONFIG_PHYLIB) + +extern const struct phylib_stubs *phylib_stubs; + +struct phylib_stubs { + int (*hwtstamp_get)(struct phy_device *phydev, + struct kernel_hwtstamp_config *config); + int (*hwtstamp_set)(struct phy_device *phydev, + struct kernel_hwtstamp_config *config, + struct netlink_ext_ack *extack); +}; + +static inline int phy_hwtstamp_get(struct phy_device *phydev, + struct kernel_hwtstamp_config *config) +{ + /* phylib_register_stubs() and phylib_unregister_stubs() + * also run under rtnl_lock(). + */ + ASSERT_RTNL(); + + if (!phylib_stubs) + return -EOPNOTSUPP; + + return phylib_stubs->hwtstamp_get(phydev, config); +} + +static inline int phy_hwtstamp_set(struct phy_device *phydev, + struct kernel_hwtstamp_config *config, + struct netlink_ext_ack *extack) +{ + /* phylib_register_stubs() and phylib_unregister_stubs() + * also run under rtnl_lock(). + */ + ASSERT_RTNL(); + + if (!phylib_stubs) + return -EOPNOTSUPP; + + return phylib_stubs->hwtstamp_set(phydev, config, extack); +} + +#else + +static inline int phy_hwtstamp_get(struct phy_device *phydev, + struct kernel_hwtstamp_config *config) +{ + return -EOPNOTSUPP; +} + +static inline int phy_hwtstamp_set(struct phy_device *phydev, + struct kernel_hwtstamp_config *config, + struct netlink_ext_ack *extack) +{ + return -EOPNOTSUPP; +} + +#endif