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 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 5FEEAC001B0 for ; Wed, 19 Jul 2023 05:39:28 +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:In-Reply-To:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CUs15udLTwNauxooe3kqKTtxOCATkn/6FiuQ56SsD5w=; b=lfpdesZZZmMpq/ pmZ7WrYy/TIpaTIejqA3sqTKDZEdnvzGH+vng5CREkx9g7QdAiMzzur72iZDTP6SvQmjXD2uC3u3Z m0nFgbUegNLXXMr3r0nnwN7bDi/zKofE2GJee6qudCJx4yR9Yhhiwgnv5n5zkjMbjtKCAfOxaFHJV 7baHfeOiUEydzGK0BOegRdrQI0BrDDqgmtVDdJ9l9sQio5wQbRxVaCjjE0tuNwtI1L7lz3NP326ZF 0cCaViCvAFM+WKcXx7duPdeyZmjoGkvtQGc/M9frUuNpkYtMCW9cEG53UVR58QIZFovXpd7eN5qCa tMAGo5XlZIv/RtuwhwLw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qLzu1-005MmD-0F; Wed, 19 Jul 2023 05:39:09 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qLztz-005MlP-1a for linux-arm-kernel@bombadil.infradead.org; Wed, 19 Jul 2023 05:39:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=MIME-Version:In-Reply-To:Content-Type: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=oM7TtU7VlalJhGuBD4tJ6gu1lu7VYWzRSCKQrQPhkws=; b=lXj6+Hvmym/mL2LPdTQRwDlMzO nKHHNDXVOkocQgY78W3CxVGuJUaBdfuQ+hu7w/L/+HmYxWGLI2dinEf4PZ6Z1lJTbc2P2Vhf4YQkX IM/36k84Yp8O8bhcOfvAzevDUf3WuIv1BnTHyl8wyV9kPZrAWA5CeWBaMPtHx+vGJGMmzqMlqy3gt k/mSAsh9LlS7unr7S00MZAEl3nF3xDVJ6jbUHfD6SuuQZU2pK0nrMY5+puMzPwgXY/JUosPTkO2Dx ZM42xF5rxNf7yIb70Z/4xN0FsQA1lVaD7w2H3R4yWs7BbuBkl69X/UHdiC87H6R30WXN3XOB9rYOZ EIl4DfFQ==; Received: from mail-db5eur02on20625.outbound.protection.outlook.com ([2a01:111:f400:fe12::625] helo=EUR02-DB5-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qLgQo-00BJw2-2n for linux-arm-kernel@lists.infradead.org; Tue, 18 Jul 2023 08:51:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dDEjEIf7ky0o10tKLiSMc9ynfQK1WhBEaz2Vgd1dcuDQzHl69RXu3ihvqnJzvgGTw+Yr2jppMIxZkIT5b/gtMWWUt2zNhEptESYbtMl6Qv8Zn0ctki+CTzQuX7l7I8MP5iIKApJRmwbCkHjC8QPIfel9Qc649eczIi2jHVu7vdPdpXct6G5o6yTfBJDf6CZipH5XD331vKcCe3oauj5IQPckzAemz8K6kypuJIPIiGNjoph7WS7aF0Y5gyrhaIUhD4yVRPEQKQd5mSACdWp+/+3Ta4PeZLnrEv6B6jyn3qWDQ63kcmBjcoT0UZaQDMzIKt9OCS6hToXcNlGEZcJIPg== 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=oM7TtU7VlalJhGuBD4tJ6gu1lu7VYWzRSCKQrQPhkws=; b=MWF/RvlzTI2Y/ttkYYmosV0X/cgJPvyerDzFDfW94sJN7r8Gy8EqGZb762nVhJFSeS6NtClLIDpgoiakB3YUQnm2axsekeAa4O3aLO35CTwX6yxAaC0F9DHdkacwxQ9Y+MGR4oB4Eljl6yGURQFfkUaamXj0pyckO8IRW1h1LQIxY3UkIf6tB+xaO2KHEzcoErYv1UiZtjBSRhshEBuMQDIkf4tyQlyGp6jAcOBrmZ8SezaM+vmdF0kCZPBHlxN7zrX3s8Ib2Da+2yOPX743MOdXnqN57k0331Kz7dTEI2viKb2umOCbZvVQQw8ISqaz3jfLDGblr80DIWF6WxXKaA== 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=oM7TtU7VlalJhGuBD4tJ6gu1lu7VYWzRSCKQrQPhkws=; b=KTEiqKUppJOwLypakR2cLm9+ddFykp2S2ZpK5hT0YTbr/jOxZPLD0/GNicpmATHId3NKn/phd5qdGbFeASXGLJab4nyy5qiTvRzVYWfZrgGTvFK9Z7O0D96Rz3ZHZLS7IA+gEaCDG1/jFwArVH/RrC2NVwjuGtzGA9rsIDjbw1c= 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 AS8PR04MB7830.eurprd04.prod.outlook.com (2603:10a6:20b:2ac::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.33; Tue, 18 Jul 2023 08:36:09 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::c680:1128:9d53:24ae]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::c680:1128:9d53:24ae%4]) with mapi id 15.20.6588.031; Tue, 18 Jul 2023 08:36:09 +0000 Date: Tue, 18 Jul 2023 11:36:03 +0300 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?B?S8O2cnk=?= 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: Re: [PATCH v8 net-next 11/12] net: phy: provide phylib stubs for hardware timestamping operations Message-ID: <20230718083603.hl33ne4oe7f343py@skbuf> References: <20230717152709.574773-1-vladimir.oltean@nxp.com> <20230717152709.574773-12-vladimir.oltean@nxp.com> Content-Disposition: inline In-Reply-To: <20230717152709.574773-12-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1P190CA0028.EURP190.PROD.OUTLOOK.COM (2603:10a6:802:2b::41) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS8PR04MB7830:EE_ X-MS-Office365-Filtering-Correlation-Id: f6d754aa-78c4-4a59-4516-08db876a089d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ahc8A5qzYobEpoJPVknzcNrdbeTzDfbXYhL6xLEjeTEJU3Fl3yKUEbiEIJGUX07CB8gGpd9/o1QzJZSpDe2rSyVzlQGCyBsj0Fz9sN1wfKgu4m998LS+xbDeoUa2L8JHFJX1s7KNNVD2WoGhE3qsAn50nqqZobIbYDPmkBI6zkccaVWkEvYvF5v5DtLqqK6Si/XYyJjTZxncga3Pan5RH+gvNFqfPYq6gPnL2cdt3mAlTcl3B1pLr1L3WV1IG3W4QUJVKZU393VD/U+uTn8Zr6+dhypcK+F01boBsEUKwgKSiHfUvKCDmCgtwJyMqnD82uVPQONOp99BpiouHmTcOD5aE1Uz94pZ+Cw5xAA+cS0yYoJzo3KEgI7uPxt21hEEtRS8kILn+Wa47QfckQelufC985xaQ7Gq6fCt2eV1PHliWSN5dAlCS2IGl8jBq4yp7j+8voa2/pQ0gwYi1KexDdOaF2fWpgXJ5kGzWYFlJsA2rdwwKcDeD5Znn7ok6A4q/o4QRZ6A5/jlE2QwsrA7YhAyi/ZEUNcchXRAgNRQJ30OScmhWFesuJI1QAfuggv1 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)(7916004)(4636009)(376002)(136003)(346002)(366004)(39860400002)(396003)(451199021)(6666004)(6486002)(478600001)(83380400001)(1076003)(6506007)(9686003)(26005)(6512007)(4326008)(316002)(54906003)(38100700002)(6916009)(66946007)(66556008)(66476007)(186003)(5660300002)(8676002)(8936002)(33716001)(2906002)(41300700001)(7416002)(7406005)(44832011)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?IyItKMnuaLY5wbk1F4F7aKNFgNFL0hK6Uhwj5ow9pbgfK9BwgRjqoP9yESZt?= =?us-ascii?Q?cByik8o/KL0AITlt7KKMmffAvnhS6rGIx5cZrNgbxi9Wp8ziBkL/fy/Ni7SY?= =?us-ascii?Q?u+9Rjx97o3YGWN23jZHsoA2Bhrg5VyQ4ePqMjEPqp3ipdGJh6oBesF1pXPXi?= =?us-ascii?Q?g96ksy/WbEoRKltF5L+XmxJM7DVZ84kxCpb1DsOn73uVsZljffh4Kz5IvfpG?= =?us-ascii?Q?9oBC69smrELHBvjjtOX71Osq5lxnGueYb9JoWpy/g1lyPQ697c+RaKwUTcnO?= =?us-ascii?Q?U8x9C7ktnq+ypTfVawy9J3t1qd17ljNdg2GKppsSt6Kr8utOnyDzyPMLjBWe?= =?us-ascii?Q?zJnCY84MKep0ebfwg/gNMuW9m9Ywgp5W+qiwSPxBbeKT1oZltR0WXXfrv4ku?= =?us-ascii?Q?9AFR8UaiQQ05F0b9T+kIH6NHaom23tWrmHuVfCt7OTERYp3cFl/rXkjB3U8M?= =?us-ascii?Q?CkQM7urN3AIRLNI37yTU3SeIzxfTpjlDITi9lEjgO4plMChNIQMR4OhE2wNm?= =?us-ascii?Q?deeVQj5PSIQaTHBZjrcm1o+/+RWoKAhJgLquLznbELw9Xx1l5CtAs1PCp4tL?= =?us-ascii?Q?O92Oj3OuYTG7+pd+PLY9WS1RlUeYwVDfY1n+5TZdRhoapb6pPcfzIGwFpxar?= =?us-ascii?Q?551hzpPAYL057kXDvGEZJdYzost3wcO30bu1RegfSD6KAn0mAAUTTvvJnvkI?= =?us-ascii?Q?ZoruGxL4Tzzs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fqwq+ZT4Y2oM3?= =?us-ascii?Q?sg=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f6d754aa-78c4-4a59-4516-08db876a089d X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2023 08:36:09.5282 (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: j2lbcwhq1OZYSj27r3fxg2748uG2Ps6bQgM0ekyr5u3se70J6Au9Gax2YX7rESWlmThPGH2NqcGWPOOEZqrP8w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7830 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230718_095142_981681_66C73436 X-CRM114-Status: GOOD ( 19.60 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jul 17, 2023 at 06:27:08PM +0300, Vladimir Oltean wrote: > 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 > --- I should use "git add" on new files more often... Annex to this patch: diff --git a/drivers/net/phy/stubs.c b/drivers/net/phy/stubs.c new file mode 100644 index 000000000000..06498de2d16a --- /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/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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel