From patchwork Tue Aug 1 14:28:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13336823 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 0CFC8C04A94 for ; Tue, 1 Aug 2023 14:30:04 +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=mkqIpzemXlSk5qAR9545lO1IDsN6stGyYvsRwblUrho=; b=vJvmcRHJY1Xl11 VQ8gVhlCJy15cacGOelo7G/DmnMcw8lMFyaihbl/8X8pVOZuGzfg5tAFPGhGOGHoENFAOFXdyRlgR AR7mPfLyryyQQpQGVZ1WxxssQssCaZoGRMJ5c48Pqp4AfDaY/r2iCIp9T6dHjVOfmWaQlTJoQ0BE3 tXlrRtxZrU/iBk8s87ybM5b3FunakUkt82Rp+aKOXD8vanuQy5FmlLdXJGjiX47kXzNr+XG48pJD4 mPMJjmK6mXdy1DxtFXjmpUyxJTFodniGVEoTeZsFRA16A/kqTbhRFco6pX5eIsCgoMmoabwdRle1n +pWbTkYeJS1qyYqsIO4A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQqNT-002aFy-00; Tue, 01 Aug 2023 14:29:35 +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 1qQqNQ-002aEd-32 for linux-arm-kernel@lists.infradead.org; Tue, 01 Aug 2023 14:29:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HhuuL3uJ5J1hHoeNjriaNq3FvFNzLHVb3pcPmM7/5bMcqU+G+7nkmL1FHJ5o56WG3wNWeMYXjbaEn2ujoIN8Q83yfFQGe96zgeZTSBZs32KuAa5E8PD8Gqb+CFXsx4JvkxTa3YsmXq5ImDz+BVwkTcUICxHdxu9CPKx3dN7RC78VNSzkMUn69GG4u7+paF54VQw+dSVAZJHCToaNKHTTdTC3fGInzR4WRCZp+rsLjoxctpu4EPqaYQRPS+aQDysANB8Fui1fnpjn2rvfMxRvMn6eK6ujen5xmYLqp2FIyKUAWf+bkFGhZ1raXEel5N1xWaYtSU+s1Trv909powjXTQ== 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=Ylq0sfzWLDkaSID0Mg92hITOUDERT7QxQB0JI0eAZ7U=; b=hsFtzC+Hkxz4GDucJw3p+h3gKbUUEAA6GbofujTTEmf5Q7VtY3V8phEL+1Qop3r1VK0IukWRehvOi/UiouFMK49HVmaKDPBpYJjdRwDzgKciXCLxh6td4yJwvlPVnXpadcaKKTz2JfJWWcMsBhkhbeJKRMMGBaW0a4rDyGAqaKZ+2DxSgMz5pi5v/L0b+zu4XHfrmsLamAgKTq1SdP6htMZTYUHCvF8Ye0yZPedK4HkpbJFkyct994vTOnsbIaN8l7PnO/hYxU0/kr614cQ6tGzjcItjVdD9jf4WpE4dUtVtf2XwCtIlntiQjNrfYeD6fXzbVmwIDbeTc855BNvoXw== 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=Ylq0sfzWLDkaSID0Mg92hITOUDERT7QxQB0JI0eAZ7U=; b=pN+sZgONW3UmnACNGGb5Po7nYlIgYx60Fl2M2jOHlfh13dTUXmqc80KSZEpp98zc1epmd2JCmey3l5UNYNc4CiIi9A471hQmGgsoAvoXLdXeY0m/d+HRKyr+2/X/XiBKAd82UzMLJPhFd9ODyAPZpXnPLasxJdXl1gVboTd3naA= 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:24 +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:24 +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 01/12] net: add NDOs for configuring hardware timestamping Date: Tue, 1 Aug 2023 17:28:13 +0300 Message-Id: <20230801142824.1772134-2-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: aff70993-8e65-462b-fa59-08db929bb3ed X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BlwZXPKkx0VN9eJ0vIhhrKYtubWHxIF1zuiKNWVU7qVU2TNHxoWEIfQpS0CWyrgoVApPOVwbx/+/Ep/HZdbFnnjeDqguo3mQrpKUMpWDeaZdEn2iDyFt3IyUSP4ziFBllnT94f6oElfSOC3xp3ttEeLKfkrdKlQJii1/uMZVL0rNudUYwZPi1WSWAwvQNyJeTEkCXgwlRr3+TCQ4B+VlPDSEa0HyoFzvXA0iDijZAJXD2zx22B5yyrQ7fsxw1FczUlws7s6jMJg3reSDIOyFpBFgTiGtmqLMJQXLXke3nh4PjBMc12Cc9JJkoYNKGBr2KwDUvW3pfiV2o3ncwaGeu1yMf47cc5PdzP169rtSR/ozbPRmrFhjuPCMgpL7qDTMF7VWI3TS9Y10AZrTwKqvhSUuEsFCL/URYElADWEMr5LYJH5UNf597tn7SPSwE/ezh9y+4saChO/CpzwVLObbKN+/W+siOnOQFqHoDhNUJOg9CPo77yLbyb+mQl/05IMp92b+QVpXvK/IPJtlXSfYgLAqc+P1SEo47rCezOihhULYKSkwhBW9D+Llq71LZYHn0l9DZSW+qGvtFxTMdtFAeUxjg8ZKBiEISBt2frtZF53OQJEkGeEZWyBEtE76aDH/ 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: i4Bdi8LGrQ7opcv9m+mfIwDQxCgJr+Hcv10iAOHLZofoG4W6fW+slDPVhvTSseCX3r8GJPVk3WJlUe6i5m7H+eHtNOQ/T5ti7sXBprU2HbeOAnPcsJgHJv9pYxoycW1wrFFTinuYDmNgkMirQXk9iFFeAIv4x3hsS88+FaoQK/wwqrtsfSAQPrNuluxqGXNTdXtlA/tLngdIJxX5jWKfJm1+JT0sFJyPhWb2kxL8vBZJekmtrPG2MEPvSbpmA21TUjACralvpBjkcv1ASeqUnnrMWpz7BW/jwPfzfl8P0vpNWS87aKkja6t3tARVVYyenAC5weHYxP0+2u9Z1Jhf1kAGbPHmTjP3TuCKhP96C+B+KUJIJUl9iNAYftSKV00g7RGjQtk1luNK44T1pY6nlfIifcBziWkKC3dhh8To7O6Bl27seY0Fpb/CwNymjs2S1Xjmn5rw5i8S2/uwLioG8U6xEqdG4qjFD2n+a87nbnoJAXut602r1JgjknFHs3+Tep8CL59065k/ZtRRMpoi4s0FnQtYPuzhs+Tpsb1qiWgNLLVOUJREn+6w0H8rk8zW4Uz+x6mJ3esLWFeZBiF3vpi0YCIBWgpEBQqy9DN3/Odl0KSQt7CaUomUiDPeksxx3zPWiKiGxjIUv3IGACwddvizaAhwB6r+rtM6F3FixAjIRVJU32L3YnybqRyhvU4gF+KysM7MJiQFeRmIb58iDdyD0t8Wj1I6kCNqeyEk94sl8K2xsuhrQwCPj8yXl/Znyp43jl2vmYWe7BAZToQggJ3VnwlVql5uH06jVu5l5AWg5UpyaSJhD2y9qnhwL3O5m+idlNo0KO9ZBJlPGzMK56kvO0z+Y6IJGf9EP0JbsYEBDwOj73XfCceAsnPOgB2qAgTx7uPPND2tiTUpHQ8S0cia++26BUmU0GOcFdPqIf8zf91sLbp/NeSgtn4cWI4tNtc+KfLFolOMAKHdg72c16eDJfvcx8x09IEktrsgzDvMCGbMkvQUi/o25JAnI9D3dTmIkV6dA9gpnrChawlhSJy/4/TH7lM8sfKtuJZI0Ut/1y2EpxrcfntA6vPs9+YOTzs11N8B5xqFz846nLcZe+y7My/q1Z994gCEzipOnAgdbjRLNRdvcPU52+wV+yvL7tpAUb7X6J5zErQK7V1kUZOYITg68V0+0kD7VI9ASLdchXhfP3edct9w0T3ix7LhICH8zJkQKOcju29YqckD5gbS9Q3NaZcsetvWOnKYdnZamof/HLQSPYIsYMcqmjfHjllcjTB6qSuI24MHSOlVQ0l890UMv1la0TzoPpUZh+hnHkspLcaaDw6M2jy6EHhnxER9hH5b+vzXJ+AIckv4MsrGlapDxp94aoPLsAsZpc6Bpc770lVDieG5crYzwQp3cgqnAH6osG0jb5iRFhE7jKKPxhHMDaWbxK1IK72J7y8xesK9O0Q66Fukpx8z+kabvTa2yBhpTEN3dGfefy61v3QtTTFUO9rX/EwCYQ63RltOwB2j9Q2XmpC75d5fZ/zP2qGY3B6a/w/ns5FOT/s6SXfQZKyfq7IhtnEkO71984cIsDh7iBozSfkwZK6qQ/qXnyJR7/rP51P4AK4rSI8lyA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: aff70993-8e65-462b-fa59-08db929bb3ed 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:24.1668 (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: KUubJpm3LlonceTa+eJjz3nQn1aDXmIqeKkK6Ni5aY44cVPqMGwmHA4hIX/LTGcfEf51/L4jpZSg++KUVE1h7w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB10028 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230801_072932_981139_3A347521 X-CRM114-Status: GOOD ( 22.74 ) 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 From: Maxim Georgiev Current hardware timestamping API for NICs requires implementing .ndo_eth_ioctl() for SIOCGHWTSTAMP and SIOCSHWTSTAMP. That API has some boilerplate such as request parameter translation between user and kernel address spaces, handling possible translation failures correctly, etc. Since it is the same all across the board, it would be desirable to handle it through generic code. Here we introduce .ndo_hwtstamp_get() and .ndo_hwtstamp_set(), which implement that boilerplate and allow drivers to just act upon requests. Suggested-by: Jakub Kicinski Signed-off-by: Maxim Georgiev Signed-off-by: Vladimir Oltean Reviewed-by: Jacob Keller Tested-by: Horatiu Vultur --- Changes in v8-v9: - None Changes in v7: - Remove extack from ndo_hwtstamp_get() - Reword commit message Changes in v6: - The patch title was updated. No code changes. Changes in v4: - Renamed hwtstamp_kernel_to_config() function to hwtstamp_config_from_kernel(). - Added struct kernel_hwtstamp_config zero initialization in dev_get_hwtstamp() and in dev_get_hwtstamp(). Changes in v3: - Moved individual driver conversions to separate patches Changes in v2: - Introduced kernel_hwtstamp_config structure - Added netlink_ext_ack* and kernel_hwtstamp_config* as NDO hw timestamp function parameters - Reodered function variable declarations in dev_hwtstamp() - Refactored error handling logic in dev_hwtstamp() - Split dev_hwtstamp() into GET and SET versions - Changed net_hwtstamp_validate() to accept struct hwtstamp_config * as a parameter include/linux/net_tstamp.h | 8 +++++++ include/linux/netdevice.h | 16 +++++++++++++ net/core/dev_ioctl.c | 46 ++++++++++++++++++++++++++++++++++++-- 3 files changed, 68 insertions(+), 2 deletions(-) diff --git a/include/linux/net_tstamp.h b/include/linux/net_tstamp.h index fd67f3cc0c4b..7c59824f43f5 100644 --- a/include/linux/net_tstamp.h +++ b/include/linux/net_tstamp.h @@ -30,4 +30,12 @@ static inline void hwtstamp_config_to_kernel(struct kernel_hwtstamp_config *kern kernel_cfg->rx_filter = cfg->rx_filter; } +static inline void hwtstamp_config_from_kernel(struct hwtstamp_config *cfg, + const struct kernel_hwtstamp_config *kernel_cfg) +{ + cfg->flags = kernel_cfg->flags; + cfg->tx_type = kernel_cfg->tx_type; + cfg->rx_filter = kernel_cfg->rx_filter; +} + #endif /* _LINUX_NET_TIMESTAMPING_H_ */ diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 84c36a7f873f..08a0b8d45dc9 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -57,6 +57,7 @@ struct netpoll_info; struct device; struct ethtool_ops; +struct kernel_hwtstamp_config; struct phy_device; struct dsa_port; struct ip_tunnel_parm; @@ -1418,6 +1419,16 @@ struct netdev_net_notifier { * Get hardware timestamp based on normal/adjustable time or free running * cycle counter. This function is required if physical clock supports a * free running cycle counter. + * + * int (*ndo_hwtstamp_get)(struct net_device *dev, + * struct kernel_hwtstamp_config *kernel_config); + * Get the currently configured hardware timestamping parameters for the + * NIC device. + * + * int (*ndo_hwtstamp_set)(struct net_device *dev, + * struct kernel_hwtstamp_config *kernel_config, + * struct netlink_ext_ack *extack); + * Change the hardware timestamping parameters for NIC device. */ struct net_device_ops { int (*ndo_init)(struct net_device *dev); @@ -1652,6 +1663,11 @@ struct net_device_ops { ktime_t (*ndo_get_tstamp)(struct net_device *dev, const struct skb_shared_hwtstamps *hwtstamps, bool cycles); + int (*ndo_hwtstamp_get)(struct net_device *dev, + struct kernel_hwtstamp_config *kernel_config); + int (*ndo_hwtstamp_set)(struct net_device *dev, + struct kernel_hwtstamp_config *kernel_config, + struct netlink_ext_ack *extack); }; struct xdp_metadata_ops { diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c index 3730945ee294..10c0e173b38b 100644 --- a/net/core/dev_ioctl.c +++ b/net/core/dev_ioctl.c @@ -254,11 +254,32 @@ static int dev_eth_ioctl(struct net_device *dev, static int dev_get_hwtstamp(struct net_device *dev, struct ifreq *ifr) { - return dev_eth_ioctl(dev, ifr, SIOCGHWTSTAMP); + const struct net_device_ops *ops = dev->netdev_ops; + struct kernel_hwtstamp_config kernel_cfg = {}; + struct hwtstamp_config cfg; + int err; + + if (!ops->ndo_hwtstamp_get) + return dev_eth_ioctl(dev, ifr, SIOCGHWTSTAMP); /* legacy */ + + if (!netif_device_present(dev)) + return -ENODEV; + + err = ops->ndo_hwtstamp_get(dev, &kernel_cfg); + if (err) + return err; + + hwtstamp_config_from_kernel(&cfg, &kernel_cfg); + + if (copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg))) + return -EFAULT; + + return 0; } static int dev_set_hwtstamp(struct net_device *dev, struct ifreq *ifr) { + const struct net_device_ops *ops = dev->netdev_ops; struct kernel_hwtstamp_config kernel_cfg; struct netlink_ext_ack extack = {}; struct hwtstamp_config cfg; @@ -280,7 +301,28 @@ static int dev_set_hwtstamp(struct net_device *dev, struct ifreq *ifr) return err; } - return dev_eth_ioctl(dev, ifr, SIOCSHWTSTAMP); + if (!ops->ndo_hwtstamp_set) + return dev_eth_ioctl(dev, ifr, SIOCSHWTSTAMP); /* legacy */ + + if (!netif_device_present(dev)) + return -ENODEV; + + err = ops->ndo_hwtstamp_set(dev, &kernel_cfg, &extack); + if (err) { + if (extack._msg) + netdev_err(dev, "%s\n", extack._msg); + return err; + } + + /* The driver may have modified the configuration, so copy the + * updated version of it back to user space + */ + hwtstamp_config_from_kernel(&cfg, &kernel_cfg); + + if (copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg))) + return -EFAULT; + + return 0; } static int dev_siocbond(struct net_device *dev, From patchwork Tue Aug 1 14:28:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13336826 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 2C986C00528 for ; Tue, 1 Aug 2023 14:30:06 +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=gUYRoP6sJRAkMS+DvVKGoUlrOjb7k+CF6JnVpwXMIjo=; b=acTO39N8XJiCe8 gJZnfTlq2iVM12bw1Rx/PLBebHMqIRT9/ty5zHu7RyUUhGGu9AQ9I+sDaiANqCox/Uegs/Y3VBls1 2GD2+1XwUjBPX+f7eIFceZic/YWVhlBaEsbo1BFP3H/KyOSsJCmLk3aMnh9I9itB0RHYzokTO7o5k hR1W1ABXTBVFzy7jufb9711wVkBERTa3i8ZhzGQHKUodyANUeLmkkEPfXLNmANUhS9Fcnr94mghYn 6VhE7gFbrFrMWHicAb9g62kEw+i8S7MQKV6RZmlQotHSsy3HUDzjApxgteqcajNtckeYMVWC0SEKX RWWTdz9D69Z6abDmbsjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQqNW-002aHk-1G; Tue, 01 Aug 2023 14:29:38 +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 1qQqNS-002aEd-2p for linux-arm-kernel@lists.infradead.org; Tue, 01 Aug 2023 14:29:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UjEyVEBXaG+g0n/xMnAJ/Z9v1oevlIF9mJKCAbS5LQAQwe1jXBrSu7btiSrDK/VUqiDJIslgKoXjZU9LdF8K+NLbtpUyASWok2AJbD4EjRfnptSKVlON+PE1O9I6Xo+sGtFrqwvqV5+PFseY3KibAl5NCQkIToyHl1loOz/Hy7dkkKMnCACq+dwbB4DKGd3kSqNnxRUAnPBC3QAQDL5MzsiCjSyBXaGReJmyzcdp0JIguz4B5YpyROERRC66sO8qPFxXwSTATbsyNI9e2Zwd9OSu4wrKnQIxr75kbb1+q/cEy0rO7WL1Pc8KaE4VbmW4TOZStzhkwMOnQw9fnhp+5g== 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=AAXdw8G53XWKHZXnukLQbZQwFnfJ6/EfBR+/S0fZrGs=; b=GiwvMiGXK6EkTI1byG5zcaD3Dp2ldLVfvSUw7woPbFwvFSV4YcKEplrb1U0UzJy+iMTAWfUr+JkpJiEk7W56uNKlGUpVBTmiV1oF+01jdtFDuVQ5pWpA4gs8n5Q0j+myPl5OFs7AmeQUcA3xe0HuOrFUmhtAPg3rr2oeYswRDfyAsuSAeDGVjRYDDizdRugFRH8bok+LVyn7ZNNNIR+SpXWQWIoF71bHBMIWRJBiq0tv/FmZAFvBofMl4BhK3iOgfKxpTnVuhyFUuY1QTEMwF7VvOLCTKDYzm7KGgm4NbKqqxSGk/eNJ3uRUtdKzuX/uvFPKSt5dPP3rmz+0HGh5Ng== 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=AAXdw8G53XWKHZXnukLQbZQwFnfJ6/EfBR+/S0fZrGs=; b=bgk0F+4K8iKAMwqaz8IWPvqh5x5F/P8Rql+nfTg6VmEuD3ln5aHrVx47LzhujmQB62TuC2hqS8RQD1tw0oSE4rMwHj9vKxcPHuhfdu6l0JaA6Ou8b0r5gPRhBbzbkNXHAE8IeNjmoPG3Dipb63XjPplV38DZJetnYZzBF4xk1Qs= 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:26 +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:26 +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 02/12] net: add hwtstamping helpers for stackable net devices Date: Tue, 1 Aug 2023 17:28:14 +0300 Message-Id: <20230801142824.1772134-3-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: a8aa3645-dd80-45ea-85d7-08db929bb521 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Bp3RaGwpUhHJexYvppnSDmwrWdWMF8vPj7IUdOVJjZJ0MP5RvyEQJhlYK9bSWR3Q7Cwqzcz1SPv2VdYB4G5lWeJ/C/71q6tCw9kR8FR/YpGSi4rk3SAvsbsH+QMffVhaDSlz5aCb5dPZED4W8NCMJAnO4FcdOw3ZG3TUu5Dezas455Q8u2yxXfzES2PsRlHRPTDjuKbysPozzJGWO24lrOVzwaVZOXlYCEmAb3ZPHkHVcMkt8YP3iVkt/tOPklqAPRAHbpJCGqixe3TQlVM7h9lP1KljIP8G65BClshW3DiQOEpvIA7qttSSjFTAbT8/Nlffh2F3CMHXQKsf3MDlhbsAHB6FwsmhiXwxpsewctBSzqZOkVyOu35cuItG8znKzF6ETJPucijCuickz68garhsNWcEWzMp7tzgm1fm77oRRTKvRXnQLqzLaGw/W8n6bvHZcRx+ED/ZQQU9Mwk1amuW/ycO6g9g78f5HN5htQu9AS3BYLxQ8cs/XAVJBqKORRwui4GBu2N6wtT+wxBGAINObCCTq4F6Ax7vRJXV9tNzfYtv639GmqFZH1BnDEUMCnXWAsANf54g8AmOaXce/VBOCT4mTlD6HlHoKsDyA0+f1XrTp6tARsu9ZVazTyyN 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: O/HBus4Mm/9cboa55boDz8mQc7ZV/rlHImBlZJ8GkPoWcgoRBUgZeRNkE+vJh2rvdeFITOZVHrSLuuvyjHiW2X0lVILG/+MmlXnTLlpiyxBOrFwnjHQsMPdD3VxjPk6DKXw54dFFZzF8B1lV3jABIweNpFqEMRVRcIptGQivxu0LN5cSQ9dDzYY1SVvzVbIWN7nn/6DfKzKtZ8oAPFQ8QLavIXtr4Q/jywBj4gdh7xIG49in3A4JyDTSXpbJ6JOC0u6bDs6vz4Im52IQ3oB6EMicuiHEOMDdiEXKEPHyOe1JSm/N5NyUxyhFQz55cMCQHR7n7l35PXp+wtBVaqIkHPNKx0ighI/ZoBuKxZB0xvdKmkwM9KDK86K7sDqucxTJDXRxO1FgmQOhQBPtE6/611gQGlZhoFsDco13Ddton6LNNch16SjiQClDTMz43Z5TJRKyEydOxUuwjanfroXBkWB+gXJEIJZa2a06zKGjA73YVxDY1iYtYtPkiNwaUgkgCk1e8U3j2Z8sBxP5Epgk46Ljz1xIWQcQfc70vdc5p/yTQeNAAVdEMb2UTkKA+WoS5OuxW/0WxKnAeaysUKjWfFYEteNfOFn+OaO0vT8kesLPg+KD62ExqFyrPt5VTt+nBU4L+HsxAJiackfEr4PoLsjhazid3cs3SiXhQ3L9cIp6KJuC3/4waAfsBegwO9OZjlYf3dmXp2b9ibBmfZFWnkO8sQ4X3SFEg93jQzkqUCZ3cMCJlN7wzvMtYnFOkkQFH/vK/u64Sb19S6/xki4h2ZuaP0RETSOJ6Bs3ETm7XS37R49WzoMoZNl/NB7K1+8cXuM8j+MgEjlAngiViidLZEQXFoWvT3HMUopgrEIUImTkPWD0i2wEhK874FguEc3ATSJXdUfAnDMIIbDow2n/p1kOBpUGqpIlS2Flzns4HDTeuue2XXeX7hD3BWjfVp9lnpADeD6VG5OvH/spYqqYm0DgJ9n7btybFjsX3q6x9660k80qI09skxAluFwlJqRWJ6vUich5WyPnpH2KNDg+nytY6wIACqPSOSdMS8UQJeUV3SVWhws94vMvNv1r3gW63iARxmvStLDtuwxow39azdseJSN44SJi1EaFZZNXqrGc8JliIdRxPUDtBMuEmuHaFQRjKTTCpPO8BB5311vmsh3An7o/8kjkZrtMsvdfoJpGH9EBZSB1pbq6Whgk+yXIqh08DTq/eLUY6VqMWvzJw8AMKMh/W9/llCnh0DaSV0Px8fWEpSudKDuEMkab7uN5vHVZ2ghXxj9JGrRCOpcm8RbW7TvfQ4f0TW+K+CjJlaZ0rL2WexlQrbEwzNSSxJBRPV52xWnTQNC97N5XVWiH8YbY5vv4btxTUw3x/dm7O9W3ZnkbLDtCEcLpV7pjcbf+g9GIcEHN8bG3gkJ7YVmOuYfhS7gEBmC/BTilNA2OLhmq+7GE0fIh23fZr26hcG69k73s4EEiL1dPtjCM3MWQSS7OnGmbXXMsdoikrC4/8QCPd0TjOtwL14jBvXRAJRsKlKlSM9tNfJDgSbsLJIGiV9YLxI4/YHJMcVf5bphAPohfrq6YIGsk42U6QkE+w730SECK0NHZP3NvyTooZUznqA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a8aa3645-dd80-45ea-85d7-08db929bb521 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:26.1234 (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: cxtSo+7fnCZSlff4ehczLkpnA2dL4H47UxX5CoYE6U5XnTds3RPGz+DzLudxk+2SqDFu4ijWuABPjQ4y9O2/qw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB10028 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230801_072935_045344_E8A12710 X-CRM114-Status: GOOD ( 28.62 ) 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 From: Maxim Georgiev The stackable net devices with hwtstamping support (vlan, macvlan, bonding) only pass the hwtstamping ops to the lower (real) device. These drivers are the first that need to be converted to the new timestamping API, because if they aren't prepared to handle that, then no real device driver cannot be converted to the new API either. After studying what vlan_dev_ioctl(), macvlan_eth_ioctl() and bond_eth_ioctl() have in common, here we propose two generic implementations of ndo_hwtstamp_get() and ndo_hwtstamp_set() which can be called by those 3 drivers, with "dev" being their lower device. These helpers cover both cases, when the lower driver is converted to the new API or unconverted. We need some hacks in case of an unconverted driver, namely to stuff some pointers in struct kernel_hwtstamp_config which shouldn't have been there (since the new API isn't supposed to need it). These will be removed when all drivers will have been converted to the new API. Signed-off-by: Maxim Georgiev Signed-off-by: Vladimir Oltean Reviewed-by: Jacob Keller --- Changes in v8-v9: - None Changes in v7: - Reword commit message - Convert "int kernel_flags" to "bool copied_to_user" - Minor style fixups, and a refactor of duplicated code into a common generic_hwtstamp_ioctl_lower() Changes in v6: - Patch title was updated. No code changes. Changes in v5: - kernel_hwtstamp_config kdoc is updated with the new field descriptions. Changes in V4: - Introducing KERNEL_HWTSTAMP_FLAG_IFR_RESULT flag indicating that the operation results are returned in the ifr referred by struct kernel_hwtstamp_config instead of kernel_hwtstamp_config glags/tx_type/rx_filter fields. - Implementing generic_hwtstamp_set/set_lower() functions which will be used by vlan, maxvlan, bond and potentially other drivers translating ndo_hwtstamp_set/set calls to lower level drivers. include/linux/net_tstamp.h | 6 +++ include/linux/netdevice.h | 5 +++ net/core/dev_ioctl.c | 75 ++++++++++++++++++++++++++++++++++---- 3 files changed, 79 insertions(+), 7 deletions(-) diff --git a/include/linux/net_tstamp.h b/include/linux/net_tstamp.h index 7c59824f43f5..03e922814851 100644 --- a/include/linux/net_tstamp.h +++ b/include/linux/net_tstamp.h @@ -11,6 +11,10 @@ * @flags: see struct hwtstamp_config * @tx_type: see struct hwtstamp_config * @rx_filter: see struct hwtstamp_config + * @ifr: pointer to ifreq structure from the original ioctl request, to pass to + * a legacy implementation of a lower driver + * @copied_to_user: request was passed to a legacy implementation which already + * copied the ioctl request back to user space * * Prefer using this structure for in-kernel processing of hardware * timestamping configuration, over the inextensible struct hwtstamp_config @@ -20,6 +24,8 @@ struct kernel_hwtstamp_config { int flags; int tx_type; int rx_filter; + struct ifreq *ifr; + bool copied_to_user; }; static inline void hwtstamp_config_to_kernel(struct kernel_hwtstamp_config *kernel_cfg, diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 08a0b8d45dc9..23e335f245cf 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -3950,6 +3950,11 @@ int put_user_ifreq(struct ifreq *ifr, void __user *arg); int dev_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr, void __user *data, bool *need_copyout); int dev_ifconf(struct net *net, struct ifconf __user *ifc); +int generic_hwtstamp_get_lower(struct net_device *dev, + struct kernel_hwtstamp_config *kernel_cfg); +int generic_hwtstamp_set_lower(struct net_device *dev, + struct kernel_hwtstamp_config *kernel_cfg, + struct netlink_ext_ack *extack); int dev_ethtool(struct net *net, struct ifreq *ifr, void __user *userdata); unsigned int dev_get_flags(const struct net_device *); int __dev_change_flags(struct net_device *dev, unsigned int flags, diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c index 10c0e173b38b..d0223ecd6f6f 100644 --- a/net/core/dev_ioctl.c +++ b/net/core/dev_ioctl.c @@ -265,14 +265,20 @@ static int dev_get_hwtstamp(struct net_device *dev, struct ifreq *ifr) if (!netif_device_present(dev)) return -ENODEV; + kernel_cfg.ifr = ifr; err = ops->ndo_hwtstamp_get(dev, &kernel_cfg); if (err) return err; - hwtstamp_config_from_kernel(&cfg, &kernel_cfg); + /* If the request was resolved through an unconverted driver, omit + * the copy_to_user(), since the implementation has already done that + */ + if (!kernel_cfg.copied_to_user) { + hwtstamp_config_from_kernel(&cfg, &kernel_cfg); - if (copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg))) - return -EFAULT; + if (copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg))) + return -EFAULT; + } return 0; } @@ -280,7 +286,7 @@ static int dev_get_hwtstamp(struct net_device *dev, struct ifreq *ifr) static int dev_set_hwtstamp(struct net_device *dev, struct ifreq *ifr) { const struct net_device_ops *ops = dev->netdev_ops; - struct kernel_hwtstamp_config kernel_cfg; + struct kernel_hwtstamp_config kernel_cfg = {}; struct netlink_ext_ack extack = {}; struct hwtstamp_config cfg; int err; @@ -289,6 +295,7 @@ static int dev_set_hwtstamp(struct net_device *dev, struct ifreq *ifr) return -EFAULT; hwtstamp_config_to_kernel(&kernel_cfg, &cfg); + kernel_cfg.ifr = ifr; err = net_hwtstamp_validate(&kernel_cfg); if (err) @@ -317,14 +324,68 @@ static int dev_set_hwtstamp(struct net_device *dev, struct ifreq *ifr) /* The driver may have modified the configuration, so copy the * updated version of it back to user space */ - hwtstamp_config_from_kernel(&cfg, &kernel_cfg); + if (!kernel_cfg.copied_to_user) { + hwtstamp_config_from_kernel(&cfg, &kernel_cfg); - if (copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg))) - return -EFAULT; + if (copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg))) + return -EFAULT; + } + + return 0; +} + +static int generic_hwtstamp_ioctl_lower(struct net_device *dev, int cmd, + struct kernel_hwtstamp_config *kernel_cfg) +{ + struct ifreq ifrr; + int err; + + strscpy_pad(ifrr.ifr_name, dev->name, IFNAMSIZ); + ifrr.ifr_ifru = kernel_cfg->ifr->ifr_ifru; + + err = dev_eth_ioctl(dev, &ifrr, cmd); + if (err) + return err; + + kernel_cfg->ifr->ifr_ifru = ifrr.ifr_ifru; + kernel_cfg->copied_to_user = true; return 0; } +int generic_hwtstamp_get_lower(struct net_device *dev, + struct kernel_hwtstamp_config *kernel_cfg) +{ + const struct net_device_ops *ops = dev->netdev_ops; + + if (!netif_device_present(dev)) + return -ENODEV; + + if (ops->ndo_hwtstamp_get) + return ops->ndo_hwtstamp_get(dev, kernel_cfg); + + /* Legacy path: unconverted lower driver */ + return generic_hwtstamp_ioctl_lower(dev, SIOCGHWTSTAMP, kernel_cfg); +} +EXPORT_SYMBOL(generic_hwtstamp_get_lower); + +int generic_hwtstamp_set_lower(struct net_device *dev, + struct kernel_hwtstamp_config *kernel_cfg, + struct netlink_ext_ack *extack) +{ + const struct net_device_ops *ops = dev->netdev_ops; + + if (!netif_device_present(dev)) + return -ENODEV; + + if (ops->ndo_hwtstamp_set) + return ops->ndo_hwtstamp_set(dev, kernel_cfg, extack); + + /* Legacy path: unconverted lower driver */ + return generic_hwtstamp_ioctl_lower(dev, SIOCSHWTSTAMP, kernel_cfg); +} +EXPORT_SYMBOL(generic_hwtstamp_set_lower); + static int dev_siocbond(struct net_device *dev, struct ifreq *ifr, unsigned int cmd) { From patchwork Tue Aug 1 14:28:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13336824 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 478D9C001E0 for ; Tue, 1 Aug 2023 14:30:03 +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=GfzgigW7/Sko5EIl98RLxWj+II4znk/mi0pTywHO3KM=; b=R+2WMWcckRrQYF gM5v4nSOghOLDrhfoMJZNgch7HFDCysYa3YxS474EmYRmwJTCtdygIoiHgQIUFWh2MHQTCuuMcGiA uzjXkSR1yLccwcopnFCQm3i5jOleX+FuNzUWeKgurNE+bIsrIjq6265rvTufPJ/tBFtZCsoFfxm4E K9dFhNJtTgigceXAwbmkOHoW9KdFmmOlIrsXReYXyUpKLn7S2FVkLU3VJIZyb6yyp1T3cteO7ZJ1c w7Ixcv1cFVBD1DhDy7nSm/8bzxSaFkoZfypYMw2m7drG2Ns0Ng/oFGn530rdpTUNrztJW4L1fxs4z +mv/vNxbg81cmPhSSJ1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQqNX-002aIY-3C; Tue, 01 Aug 2023 14:29:40 +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 1qQqNV-002aEd-0C for linux-arm-kernel@lists.infradead.org; Tue, 01 Aug 2023 14:29:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JkMFAzfOXctpQclv8Rg8i2ITCrImWvZis8ndUb5CUYrk2zkdjZAyglDuOAwhHkz/mq8TgdDB5VH+rG448NQwci3oNC/2FsnCmzElBRJ4v1S2P76ACrUBsgaXMU8EgCay+eSat/wmXwibj/DItKfFNUXaM4yDTkPsaPPE9RbKJ4Dq1DpO5KCjXx3KVlas0L/xS5vC4zG6CP2VZTXwoju3cX8KXXNPug1e/30CjUz1YnF+vUihIOP21cdMF7rrKAM1iTMtuPKqfKrc9oU/Vd7C6u8+Ej40ssXNu/666eQnmFfJRCb+LkyAsep7B4x6nQwNnLOaghJCnaWwsLqXZLyArw== 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=6c9L/Fs+ATK9RZ0lYPtA2VPoujgJmkcPt/5crPCivNs=; b=QfW6pEwm+3vX9KhiYl73k9Lr3VftjJ4aYcv98y1+djDWRmxrrHczmB1xCvfgA0iAAwJSXtr++O3d4+fhY4ULK6Ju2jlonxpn7oWe3CO8JvP5SkfMi66/ZU0mZ2uLtAkGcpyCJVpGrsnoJ7YwyG9Je13v6MSiupyEXuHSpC+omlEek5BJERHbcrBz0f9MDQjJ5C1q9vi1GC6oecwU87hEcf45iAF41jFKgl1M42Ywzk+MRkpc5lh42qpwXTdz+xEUY39si8/O+V81cgKf+4k8SYvwrwQRcYMJOrjAw07gKimSKNPYZRWIqxMwpTSEfotgE+NCyz/UIo+0DzF5J8Rk/A== 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=6c9L/Fs+ATK9RZ0lYPtA2VPoujgJmkcPt/5crPCivNs=; b=FEETcA6fVLNdAEIcA6R4rKEa4093AP9Chncfbe0T2IYSd8pxGemQl7wmynCb2K27FZTvfmUH7via9vuFfFW5ep+b07Sp58DbzuNyVy+oIobooI9Eifcuj4shxJOWlVVoYsZhLHd0KiyeFtP3ju6WfE9WG4lfnR+Rt5kaLeKV0/A= 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:28 +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:28 +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 03/12] net: vlan: convert to ndo_hwtstamp_get() / ndo_hwtstamp_set() Date: Tue, 1 Aug 2023 17:28:15 +0300 Message-Id: <20230801142824.1772134-4-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: bfeabd0a-e6f9-4001-8818-08db929bb64b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oQm/qHyQro2vofnOyhRagNnMPZwWO+uQfQpMv8NqlCLOcY7nZoHxzOLtiHqCwVaWLsdBO3dDK5w+H/Oqdt/0T5GCSVr8RVbrXaAvIHGbRVxi2PFLjE+wRxzdOkkyCmMPf7v2KsKjpYnhZ0eIcMc+7DPxL9vE/17EOg9RnM0CSoBroOWBrgF9vkcWA/TXXoOG/mg0wKxxp19TxVHCVcevt7vZnMdBxD+HgoG/qAjZwQ7ls234NdNyxdko5hZDCmIaObPY6qX1y44Sd+9SX/NGOlWZWlmF/KxzOWQEN6LS5SYxEbIuvqLmJSEnKaCa/QI7klZR9NCEZ0kbvx5CAuPD5ONVsGPv9tDQHZiZ0hkoA8SCD2WAVsLwqNbSFd0/WyoLPVpyh8epHPdW0f7tVjPRtmnfZP5YE2C7gTSjrSTtG1h9rKCw//SYCa3POopTbPhK2L884f1rDxQqYKYinAG+IujuWHxqQj3b97AymH8/a3fU7J5v4EDrS/eFgvikhbS3iBHAxO8EDGVNPHnCCN59mpGprpqU8LfQbsiG4w+q6WzJ+CKEhgijSPGgApkEoRwlUahhJmyI7Qq/qxk+mmTB869ycS8XLfCqXt7Kz98BdBmfV5+oATupL+tuKUtcfZew 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: ewLd4ueXlPVPCSmrDhuHwopGZHe31Pn/otG+RzO6bG/PLpNy6ie5IIPmagN5oOMnGcljEPaXlOe5Ga5kIoY3To5bl8oDM/dBOFuer7BI8XVwIDKErO3lyr4/neo7UO6NNmb4SN97wR3tkVFPY2hg7CQm0IRRqZmZOJvp4i/7r1MjaW4WXH+bgPFT4lcU8qqkxFSmaMvGc9psh14TqIUfQZ38SZA7wLU014nwrMpT2sAMThCFTBH9bouwU7LHj+T7e6nRrwB34xu+kpvHWK2pIcEqlMmVrd1xRa8OgGWKkdKiA9ZMsxE4YtJGxfN7WbrGNrolc9A1vJdLR6Q+tLbbHk9fAjB1uXH5glah+aHGDxLTRTrh7mOsBbA2GMnFbCtXhZDqJ43AJoHNa4F49+V0Coc0oRkZQ6IDgwE0RQJ659j9kpLc1E+fQSN9uLKMj98IxijajrKdmWIjCZ7aaLcKEtZzo7DBu8Xzutf7uL1yNPY+8T3GOvrmLsZ+YMyGQhXTpHQUJP63bwg1PnS5PhHlj47ouF9IN18ALdUfHg8Iqlr2JexRvRDze5cuZX5Y8Y8TL4pR0w1nJ7Rk73AUA/AvHFCF0czFIzXxmoEmDNwplCL+kvI9ZgnePvlcpDBqH6w0KDeu49xQipvHJtJkuSAVHpo87b9qJoHNy2c/1R9/qcKMtFs6gDkVsRy83cEH+bRIEuN/R4mtXQIWPSyEltzD47wF6Z2kgZ+FiuaFPOg9eW/lC/JO6qbWAprI15yOHWVJDEr/LFw0YXpsvj/CKYI2H/f1/u3M2eEdhn1u6yilVz+GV9EwFK0z0tPm5pH/hyk8K558Ss8nGQSsJYm5fOA3t2f7IbWckMPjRs7nuFzPO3AfEYktaQscGV19f2cfSHBCuIDDw+egkBEwb0HA8EmJgQnAzXqJGRHi7sxzu30CTVmdFxDAhG1VzsfDbxFChCpEMMFf2DYMY4KAKnGv9gzv9Vc8Jgr8rfrYVcYpxSrM/dKgDat+LchqEC6B605+OJ39tGIQHlwCuhR5DaikARSxTjNT6C/5nPfm+nFXEK2tz9MSW3WqFWqvGOypPUjmp87Di9UGuZdoSyIM5dMIL2cxU1lp7I25VxYTLGRX2V76OQrZZ6QY6P081Zkmp2f3xCw6cC38zdrviKrqy+8Db0h1OKu+ZyecP3LSAP3jybVf2KvtQ++ly+wushULT9upf8kRb7yKvCj624c7gefZ/3w0tkDl/am/kmwE+YorDVvoypV/9QbTdZLZ65k3EYGWivpMK39JpBi4YrswQM6+D3tkeWPfLDtc9bluWYpF77JRURAlW7sjdBUYC/Lj/CU0DWmaIRBgKfkh8nJLt+hn14dninX5NGfYc2ns6rLuu+LbZc7K6wvH0B6Pw4PNF2QFCB9japHdX2WP4FwAT2qHAHqKb4zxV3i2XPqUFJWlXcBdSKbQ88XHqToJg9QOLVmTD5FNISV4tEwTdJ8+OHqOZGsvxlKhqtLmm26Y0er1L12FYi0+10lINSpS6mCrCIB0Os/jfbm3Lho1Zb+wD3HaO2rC53LhF+Kc+mS/HYXBju/LQS9YmkKk0Ky/g0KMXwT4INjKz7g8nEkEm8d0L/E73YQtbg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bfeabd0a-e6f9-4001-8818-08db929bb64b 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:28.1061 (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: D6AU7yFLOmjM2eF99jvW6u7t8yi7ccetMBHEf4aYPN6FY9WpgU64CP9HllH+Vi1icKbf/WEWlHtA2CYz/wYtRg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB10028 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230801_072937_100238_1FBE2E8E X-CRM114-Status: GOOD ( 17.64 ) 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 From: Maxim Georgiev 8021q is one of the stackable net devices which pass the hardware timestamping ops to the real device through ndo_eth_ioctl(). This prevents converting any device driver to the new hwtimestamping API without regressions. Remove that limitation in the vlan driver by using the newly introduced helpers for timestamping through lower devices, that handle both the new and the old driver API. Signed-off-by: Maxim Georgiev Signed-off-by: Vladimir Oltean Reviewed-by: Jacob Keller --- Changes in v8-v9: - None. Changes in v7: - Split vlan and macvlan to separate patches - Reword commit message Changes in v6: - Patch title was updated. No code changes. Changes in v5: - Re-introduced the net namespace check which was dropped in v4. Changes in v4: - Moved hw timestamp get/set request processing logic from vlan_dev_ioctl() to .ndo_hwtstamp_get/set callbacks. - Use the shared generic_hwtstamp_get/set_lower() functions to handle ndo_hwtstamp_get/set requests. - Apply the same changes to macvlan driver. net/8021q/vlan_dev.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index b90781b9ece6..2a7f1b15714a 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c @@ -354,6 +354,26 @@ static int vlan_dev_set_mac_address(struct net_device *dev, void *p) return 0; } +static int vlan_hwtstamp_get(struct net_device *dev, + struct kernel_hwtstamp_config *cfg) +{ + struct net_device *real_dev = vlan_dev_priv(dev)->real_dev; + + return generic_hwtstamp_get_lower(real_dev, cfg); +} + +static int vlan_hwtstamp_set(struct net_device *dev, + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack) +{ + struct net_device *real_dev = vlan_dev_priv(dev)->real_dev; + + if (!net_eq(dev_net(dev), dev_net(real_dev))) + return -EOPNOTSUPP; + + return generic_hwtstamp_set_lower(real_dev, cfg, extack); +} + static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) { struct net_device *real_dev = vlan_dev_priv(dev)->real_dev; @@ -365,14 +385,9 @@ static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) ifrr.ifr_ifru = ifr->ifr_ifru; switch (cmd) { - case SIOCSHWTSTAMP: - if (!net_eq(dev_net(dev), dev_net(real_dev))) - break; - fallthrough; case SIOCGMIIPHY: case SIOCGMIIREG: case SIOCSMIIREG: - case SIOCGHWTSTAMP: if (netif_device_present(real_dev) && ops->ndo_eth_ioctl) err = ops->ndo_eth_ioctl(real_dev, &ifrr, cmd); break; @@ -1081,6 +1096,8 @@ static const struct net_device_ops vlan_netdev_ops = { .ndo_fix_features = vlan_dev_fix_features, .ndo_get_iflink = vlan_dev_get_iflink, .ndo_fill_forward_path = vlan_dev_fill_forward_path, + .ndo_hwtstamp_get = vlan_hwtstamp_get, + .ndo_hwtstamp_set = vlan_hwtstamp_set, }; static void vlan_dev_free(struct net_device *dev) From patchwork Tue Aug 1 14:28:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13336825 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 DB98FC04FDF for ; Tue, 1 Aug 2023 14:30:04 +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=jE/1pn7dTaWtsu7Ot/LibXZaEdrZX1JR0ZZ+d5C/nu0=; b=iHCenozKD+VYjn DIZPpHjGTrB9uAXWVdWD9+Av8tYrRRlBZGkup03JXRZRJpD1Hr/p9DZoQLPLysNY0XoLuHErcM0i2 hpkdF7uvj+pgOlYGT6yGL7ltl78EKgry4oqTzLjng+r6WNbhKqIw/r6Gdr8mErgz02+TVPItkzblb 49rLg8FCDMjU6h8SrvfwN/GGzUsitqo+V2yT84R0eir7g0dYHVuj+puIu1NFeLMzxImRkp90WBEnw Y1m33PZRkppnlswgkUA4HxVud0q+UeSJtIY4i62EoeiIwSqMJT0OwNcL+eRkuX30JifNmdOipU8m1 ImzU1xTz65jtOoEcjPsw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQqNa-002aK0-0Z; Tue, 01 Aug 2023 14:29:42 +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 1qQqNW-002aEd-2Q for linux-arm-kernel@lists.infradead.org; Tue, 01 Aug 2023 14:29:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FUEqryHifm2Iazh1ndHuzoS17DltrVwp0YIDAYBUuQgoQvvZtFS88iXAh3nipTI3uaXxs07nlivgP4UWHIkWKwfEEuusTBsG6HKJ0DolnlwW8V3gfOgcgdZcOObal/LjC8wifOkXJwZtOUx1UEkZPE9EIMYAok9yOYhMTpXkax123ZisCJLeocu9xFLeAwr6rMf04Hc2CegKEzpNWDl3riaf4y6P6EvFik5YUcbx3YZWlyD/xL+kT2pJE+Z6etCYFc9gq3uG+gpWZSwnp5Dkw3FpaTl/ScQKn6Or8TBvKHXPi/NKy7TLGSgwxgGJC4JY1D6cG0vTTI+sB7j51D3eew== 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=y0uMid8YSWleukVlwKvvYRFiDrcxiltc2VXkuNnpQ68=; b=lDEr6rEP2xaWRD9DTqSqCpNguPxC2iac+5uImtom3wnCkVvGlJkNz8Sw2rT9T6fZvQPyxA2k53DIHLAHuUuMQVltO7n+Vs2ecgOx8QWBFEDTpkS/qPOV6nTwjwfGW4MwMSptJsEVKCMu4cg2G+D7ZwvKN50+vzRtM3yAfdIFL2exynsh8S8Kpi82TlkyV6aWFdFUez7so51a8MVQ7SO1k5FLVTwTYd06wvojsDdnjZNW2IMt78cCHOljNHDjSlBvgBIrvZYic0U0ZPsEMXu4FYVFW9gmyRSiAm2M9YkywiSnUHTU2bjaS1tjPimPtd5fu6PwdFvU3/IdcO36J4Ge0A== 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=y0uMid8YSWleukVlwKvvYRFiDrcxiltc2VXkuNnpQ68=; b=OUMkWA9fE5r5xAbMde/jB11FncZbePtbZ4Ud/PMw/iGUwSzh7oZnHLKUNhT9O2NoVqEEZDAljgYFgO0qg+FZCPmJkTlGAtX46rBMbFoOdU61e+TeyvdRPJnwh5Mihcn/4DoOIJ3RjtzWFSQBtidRrDYs1etsF1kY7vsBPOSUT7M= 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:30 +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:30 +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 04/12] net: macvlan: convert to ndo_hwtstamp_get() / ndo_hwtstamp_set() Date: Tue, 1 Aug 2023 17:28:16 +0300 Message-Id: <20230801142824.1772134-5-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: f204b6b7-c050-42a4-4efe-08db929bb77a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MRLcwNYLk5rGqLCQ0j11HmryUoVOjjjsU1UX0rRQ4RRsesZipb5ct2m/DWF8aQxLXgbHipYLYQy4sSlRh5PVPkC8JwHAff9sLOBxhdy6OFWarkJoimLk0oMWnO/EXU7zN5sq/JVDcEuJPUcY+pkZ/N401R02yPdejTiXWia6cYf5AHDhB3hfckeLxmMJuTRXQNCSgrfQirXTh/lxOXfrepya66aE4lyKVUH+oYyqVBQZKZypGh7IAQ26vr4nNWcdxVZZ1Ta/6FTb5almb0o7FC/DuhbQqlkNTT5lnVxCwoHjfRAY/+JdjP1Fmiv6cBf+30ualXOPxct8jtSHm1p2EOQuC1HHX/4ClhseZPP7CfR0JE6x43i67ETFED4yBq+XLxcLpDLUDsI+DTIgn9KK/c016D4OClwu2x6Daz5IL8cGqGFQno1QY8nqHMfqb2NKvtySNdHCnGpyT1GFfcswFKjYNVy63K1fF8exKxSzDjWuwArXTjX+tuLjhJNTsmyvrAnKEL49hzK+HswIdCpth81yCLFrKFpW17Oxa5upe5c8yFtKT0JQrxsggYKEHnecKK0Jva8utuwaIkVdB8wMeogJc7fCxVxNHtFT9Nw9eUfMNd2sdFGyQDtvMpMyHMwN 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: 5NupKeQo/4wbQFLPLEDk+mbgJ+asYDfNi1bckSw8J52qC1zTVivVoyobI4B4JLvk2cqIK2leOu4xZe16jh5/fidSBHmtDiyt5eb2PLLMrYvrZQJoR+5B5Us0cyI6hd5VH3kjvC0oQgib9i33GdgQ7XbiXaCIr/5jGlfvx0BC8ZiDcG62ngoFHTbvyl99x0ngHVv166byJajRSzdlX0U4rI5QETcf6K+oPEKUJvKrzYDgQPv67TAbK/f8/YA5w7RX02fXCjw8kk1TPoAqp8GKzLRAfywDWek/qcUJiYBkFjo0ggE5Zxpi5FdD9uXn8zGmO4AZsTldtVMVN3NaC0xI3d+BFhot6nY6dwJZqI/EpKDaoiF9sAgz7K8KaE6RI0bhxzGscBfsC33U9JAMhx0UZsDFznl0Ng08JF8OpltqoyUzjnRPblFOaUyE3PKZbeNidQlSHfV1gOSimcIYHvpURGkdIafOL6c5Cepsk4xaQEKhnji6MQywqI6gi1JObcx93vJNwxFgddlTWu8UKXayjwe4ZJfk6qawqfbmyv9G6jqOeoSOXMqf/pwNpRvNou7lcJ12J/ZAhkgtQuDFaK0+2ZviFxeIFlo4Y3II/YcQd4khLQ71nLOQ79A8zgm27yG/sSLudCOy5/VtWqG3ObFBBfNozR6teFqk18Kuc3jkWAB8ZKoVsKIHzoEixD/mV+xmDwVNwHQfFTtAoEt8IRSHnpcN1gGXPGmgSSbxVPulWQHYFYwcvvvM1SVR1s4tgxX3xrGKlERxnGKJquSX1BM2v1vBZZF+FxInCFB59iQruWjhpGjMU8q6s30cybWsd3Bbv0ymWyLeUUfBGyhNtqCDS6KYXMA9ZuSMeX6wMeEEvQG6ieNFGkDv0uu3Ac25q4z9W/kXEuAGYkILZTS16dC9HrBWYT9cFykmnW0e6tV8kRZg7K8x+jyLfYtxy2Pio1OiwGXrTaBgZjUnlWRpdrFX32vesnlvNxvOJuSle3528IdTySI9ad+t/dZ1vxEH+71cvg8Tatt1oFag2XYvfvQFtYx0vq+u+tB9l0ATv15w3+cGKyGX73Xpmna3kUc5Bxi4ilcn8OtHHV6BEsP5C9zwQ8ybvp8/j17ERTCa/O2KhyHrRnlrLBueLfBymjBu88SQoC14UpaRhXETTzRPVF37AkQCnBQ3cckt2pJlFeG54iJv7OtnohYxAOYz1ErnVstXzYfXD96U8KASVEDoO97emSVg26P2LTbESh7bBdN+/FiM4gKOkVeR7VJj4LbsMFHxwZA8rtjz8WPa+I4HNxK87qylVvoc0lgq4yYo3OL6ylmn57Ho/OhxMYxh0i6Hu6GOOGpjtNIlcKGFsfrELezbXYDQtICD5kWxmFz7go3iZUU5oyEzLwQJiA6fQH0mmcoJ7c7LoTZgsRQjIsNt0oRTIBsIZdwRT+Ok3/GzAnwdoveWwarl0EquOO1ageDs1RbT7S24L/8FEIq0QEc6xyBn4x3MKUDPA8eeU1IudF6sB0SYZlckCrYxHouptfU9xiZTxH3HhdSp26pT3MybdjKCP+uF588ZdChpDuRMmM+mzozDSsU7S3lJjjbqYZN8HkP+ayHOyCq0XeN0sTj+v7dI0Q== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f204b6b7-c050-42a4-4efe-08db929bb77a 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:30.0887 (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: KKRdIvpb5mH9HIFupjpwh2MEo/mWZnsC8DihYK/rG1sJ9KZQJ+icPyc/9WV2KdQpBkz8rTZv+oU36Wcz5xFT3A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB10028 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230801_072938_800650_BE6CFDF0 X-CRM114-Status: GOOD ( 18.75 ) 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 From: Maxim Georgiev macvlan is one of the stackable net devices which pass the hardware timestamping ops to the real device through ndo_eth_ioctl(). This prevents converting any device driver to the new hwtimestamping API without regressions. Remove that limitation in macvlan by using the newly introduced helpers for timestamping through lower devices, that handle both the new and the old driver API. macvlan only implements ndo_eth_ioctl() for these 2 operations, so delete that method. Signed-off-by: Maxim Georgiev Signed-off-by: Vladimir Oltean Reviewed-by: Jacob Keller --- Changes in v8-v9: - None. Changes in v7: - Split vlan and macvlan to separate patches - Reword commit message Changes in v6: - Patch title was updated. No code changes. Changes in v5: - Re-introduced the net namespace check which was dropped in v4. Changes in v4: - Moved hw timestamp get/set request processing logic from vlan_dev_ioctl() to .ndo_hwtstamp_get/set callbacks. - Use the shared generic_hwtstamp_get/set_lower() functions to handle ndo_hwtstamp_get/set requests. - Apply the same changes to macvlan driver. drivers/net/macvlan.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index ed908165a8b4..02bd201bc7e5 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -868,31 +868,24 @@ static int macvlan_change_mtu(struct net_device *dev, int new_mtu) return 0; } -static int macvlan_eth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) +static int macvlan_hwtstamp_get(struct net_device *dev, + struct kernel_hwtstamp_config *cfg) { struct net_device *real_dev = macvlan_dev_real_dev(dev); - const struct net_device_ops *ops = real_dev->netdev_ops; - struct ifreq ifrr; - int err = -EOPNOTSUPP; - strscpy(ifrr.ifr_name, real_dev->name, IFNAMSIZ); - ifrr.ifr_ifru = ifr->ifr_ifru; + return generic_hwtstamp_get_lower(real_dev, cfg); +} - switch (cmd) { - case SIOCSHWTSTAMP: - if (!net_eq(dev_net(dev), &init_net)) - break; - fallthrough; - case SIOCGHWTSTAMP: - if (netif_device_present(real_dev) && ops->ndo_eth_ioctl) - err = ops->ndo_eth_ioctl(real_dev, &ifrr, cmd); - break; - } +static int macvlan_hwtstamp_set(struct net_device *dev, + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack) +{ + struct net_device *real_dev = macvlan_dev_real_dev(dev); - if (!err) - ifr->ifr_ifru = ifrr.ifr_ifru; + if (!net_eq(dev_net(dev), &init_net)) + return -EOPNOTSUPP; - return err; + return generic_hwtstamp_set_lower(real_dev, cfg, extack); } /* @@ -1193,7 +1186,6 @@ static const struct net_device_ops macvlan_netdev_ops = { .ndo_stop = macvlan_stop, .ndo_start_xmit = macvlan_start_xmit, .ndo_change_mtu = macvlan_change_mtu, - .ndo_eth_ioctl = macvlan_eth_ioctl, .ndo_fix_features = macvlan_fix_features, .ndo_change_rx_flags = macvlan_change_rx_flags, .ndo_set_mac_address = macvlan_set_mac_address, @@ -1212,6 +1204,8 @@ static const struct net_device_ops macvlan_netdev_ops = { #endif .ndo_get_iflink = macvlan_dev_get_iflink, .ndo_features_check = passthru_features_check, + .ndo_hwtstamp_get = macvlan_hwtstamp_get, + .ndo_hwtstamp_set = macvlan_hwtstamp_set, }; static void macvlan_dev_free(struct net_device *dev) From patchwork Tue Aug 1 14:28:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13336827 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 97CCBC00528 for ; Tue, 1 Aug 2023 14:30:11 +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=8X5JUekOOSWcSvXI0xZlRNi3cRepg6IhyF8KgunMH1s=; b=sU5ZSwKOW1MV6A KZg32yIXjJhCg2Zy/Sb8CCkDjb1Kt2h2SNzEVN3rs6Ck9qIIvZM9uK7hjma2NhlhaJHDOU9eaOZkV wJrAy7xHim5Fx31v62R2rO3EueNlKN+wWlFMiHLhdwIgnuJqzzZ8A5YXeGaGg9i+SN3eMU4chlr1+ DH/vPVIenuLEP6ivtF78KpFdyHCiKaidY3cmFNS+wTjvVY8flFpYN2d/Tq5M5TuiZMfLrrDkwPaZG xPbgInhxC49jWt2biWG78XzYnykvUWRtxQ/GClf4iWwQgjcNCyQTDrOx1teVADxgkJKcehCOrekXE rQYldZL6tnjrn7Jh0qPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQqNb-002aKw-2R; Tue, 01 Aug 2023 14:29:43 +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 1qQqNY-002aEd-1h for linux-arm-kernel@lists.infradead.org; Tue, 01 Aug 2023 14:29:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XyzobIVCKnnQ95mvig8IAi8clxe6DGhPaZuvC8aAtk/BTRa3LU46+3s517Mhzbd+5h6kY2VF3MYjQUf55f43NfV5sp8sDykOJicFJi7Xypf/fF78BhZk+tanJPCy00FUyT6AmpAatKgECq3FTVWessPIDGUKCentwVuZW0RyDFOOPZX/D9D4OlDCz2we5YGr9qMl9AL0v5jtza/3vGRSNAeMrDcy7pyC8XS9BgbMlVmDdvvZkrG6JFJjO23dCMELYBGFmWQpOaWSZEqcQbrz5vFdgzkOH1BUHDSF6EWlzjtnoAw08oAgioK8fRUsMTCCTB4n5gcXwyU17CrD2HdV5g== 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=tQYBURbKkUTmPrffjHkBTq0TVFR/uh+Uniw/AliMY9E=; b=fAlqySElJdb4pNpqoCXDDoYpTI5B+Svx+lMPwEsp5O6KQ4KONH84JOXtoPPmr9GWBP/+SY1attor4PVnjffpi/d7/5WeInUUXigZfQo6EtrWgM1sEMdU2jgvHEMC23p7/YXfskhZhcscv/wQX1xrSQYS/UkqZjDYYd4vD/IMvzk3ty6tkHjORo7QMGRH6N+r0QHFCIdfjlRVgamWxIiztfXLkJE8OmYzsrlQCdgKs4P5KolLFpxjGXRR3cET9I1EsLZY/ZYSqldo8KlhawGleFSST/uSXr9kOme/xEo0T3gk+cRQ7j5J2n7KkDAvUscoVDYcCe8GHPQmciB9vuU/XQ== 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=tQYBURbKkUTmPrffjHkBTq0TVFR/uh+Uniw/AliMY9E=; b=hq3KZJyBhZEPl5WcCzl0bXhGAPOB9PITY/UD2hMCoCB3jhIPYJbvp2PmJTCoppXwfrIaHkbxlZYa7IeDTdS27V8W5XkxTgMxr1Zsb8RDUs1ECX8B4qSPzIkQsyPE930EgxNa0jnecASj63JlPGTahkRBeF05zgjTrLNV1ht+F1s= 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:32 +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:32 +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 05/12] net: bonding: convert to ndo_hwtstamp_get() / ndo_hwtstamp_set() Date: Tue, 1 Aug 2023 17:28:17 +0300 Message-Id: <20230801142824.1772134-6-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: ad8f43fa-8c9f-4d58-15e8-08db929bb8a9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SzQUH5OfzBPLG/abrA05IwGx43r8yTc3chsrVF3yfGOLNJ3UT/aevJ/6rr49f39fqQTJRcvgM3IdZ96NIGNiUekRj6dCPEnZyui6cx0XnNK6jxiT8t4Oiuw9WtNfS6l5lD5dcIsy/vAH+8irqAr3BBIWht2dgZ56SyGppKDOUDLZ60cPhHMlAa9Re23A4Wk/7b0Q6A5aAb6pZOqwad538lKzTlQ5Rc18+n+wO332vHyKY1etO7rswHs0/5v2qgIsdsgvX4HZqjoiyb1FhS2Fh2TZswU1BT7TqylRMBLCAC4FxUr7y9G9ulnXmMkPLKdQqqTWBPntEfAlwAA7dRYS3osHtLycc/QipeHvOTWgOZRYDkEtsFlI0QXJR7XU8apHDV4XZfPQrBct07AiLyBjsyYYXg0JNxaT3S7ohxc4nOF+mSfSAbsuVdOXYsnw1XsUGO1ig9CJQKRE1FlgJxnR+ACH6oKtlVi3D7wMzmRPT5f0kX5uhiw178AoCudvfwSavPkq+AHVcLg6sj7fSqDPmoJnjReou+C6ESFLrHtDiHhjekRD0sdMgmTqZ1HJxQw0j7fo+qWrZ0JJEpcfe0P9CVipaaJKI17oCvKQAnSDhDNKwl9HEwQx/0vJfQYWjrV5 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: Ht3CvT0P1mtOTRej/7LMRMbNvdh2LGFK7PFqxT1yQYSBCqbxgQ/Wx3AuQ9qbyKgc5UxII3CyiU+e7T1TyRmZ9nWZ7VCZp/0sorJju5OLh01QAWP+NIGCJ2BtE5UHtBvlxJNzfkVJG8LTY7bIG8hysppEp3p8+7XqOSoKHlnxaqM8FicCsz6zek9NQjwZG10QJ2mrqSC892cuIvgkC1fWEF9GgLtA6rqKnWtSb8jH3I/EjqGnvTohUobI2p2U9Kzx4mTl+1Mx138Q2U5G+HVNNL/c80NNek+jfYoYhfor7x1b9MQC+lVzPUC+8VtFoYoHr0iK5lR8DiEAEMuqqu7+v5q/ZK5+4o/BlfDi6znJVpEcFSYBG2yaL0BaQt9sUJFEyEBdAkxH1TaKg5aoijQRaOyCG/MEE2PghZICw/xslQRFP475X78aCyULrLQuqTjQQdr76bxdYC4KFBgdk9YaaKhD/1KJipkAEGZm+aq1UwI/q7XKMyfgWq1vxJGXr0//uPCnUXW2O0JhF+zHCDsHKyvfcc4ghtXcAN2iRikddckF/5lmPsz/6TyLSXsEVb/KSz6M/vEvjMtvlT2US0rUENIluJllwCm7rdNgM6bZA+mQlpP2t+ccb3sV0b5KENz0eOcfPClLxTnT5TDly+U+xlt7I4muVpaRllAKC7iXYqtUxVCS8pPi1uHahH+NMEhwjROGxjHfzlOnlUQy9BOIfOcaUQn12MlfAEhXFPiYxFGEO4QL0TVd8qBm0t1FUUAWhleqr9iJBfn9V50ltoeDUHWOnaMsmpxPOokNi7v/DpEwjORwCgfig5T+KVzJZF1W3c0xIrS7qBxQrj3qFIcksOXG5WAD3anmm+tOrtSpNafnbwXjg8hGnVMNe96FAZhFcVGHx9FpYLVlgrEsJzlC5LMk226qxu1bQzf0LWlyAPQloH+PXVEMKnJ7Trw6WA/Kiypl0DrdORHBB8kXwxZ3ly924pS4MH14M6xswK/GcY0GAogNU3sec5ze4QfgqXibxZ9oI04VLQ5Xn41qJM/x99NGtOo/fgre0si3b2nWqzg2vDaGWA1dPj69YYs1oXqhNF/rqvGiL3hkCPUyNIOIqs+Goc0XcadCOcwSVEDxZhrvsV4Fqq7XXv9kOir/w7atg6srOl4KIJKUhbyoAOckSnRlSu00xKORAy8muL5T8y8bMzp6UzJHTKRUsr76bZ3Gf6yk9yETwSw1uSSJEN0arnMX1vHJhI0UL1T0Gs/A9xjpSuC31NLBt5FGK9Rvct72vLnOjENrszsUhrsasd5rY9g5wlPc/7iVUiCuoZISnYyvjZ9OhKKF8dIklzKhDF7uLipmwysnZZ4v5lIItjo7rkaB+r4nH7zqNpwEPCr+eoyCV7BCWxB1sAPjxsqJv3niS7viQSZJnwv4VHd5XDKYLNTBPAoJOCcJ5qHFS4AHCuAXDe4KGWqVjpRoY6dtuqs7iuap2V4mzLUO+Y38sxaZG6VGGKThzl1pMVNJlDvTNZhNaEFeiq6rtihG6GcMcd8OS/Zq8yM/d2WcTeOYIOYJ1vI/O+x3L+zFiF42pfCQzOcmVBsmRbXKPQHhcxEbpfByULgTrt92GGg6nbw6/9iJWg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ad8f43fa-8c9f-4d58-15e8-08db929bb8a9 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:32.0453 (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: YJlzzGX76KyWHbETi8opeqX963bKptAI2++YaOPJY+9MG4i/kqSj9H49WZPWZE916yK0K62ajo2dnW9VsJFzFw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB10028 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230801_072940_566931_37C6542E X-CRM114-Status: GOOD ( 19.05 ) 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 From: Maxim Georgiev bonding is one of the stackable net devices which pass the hardware timestamping ops to the real device through ndo_eth_ioctl(). This prevents converting any device driver to the new hwtimestamping API without regressions. Remove that limitation in bonding by using the newly introduced helpers for timestamping through lower devices, that handle both the new and the old driver API. Signed-off-by: Maxim Georgiev Signed-off-by: Vladimir Oltean Reviewed-by: Jacob Keller --- Changes in v8-v9: - None. Changes in v7: - Use copied_to_user instead of KERNEL_HWTSTAMP_FLAG_IFR_RESULT - Reword commit message Changes in v6: - Patch title was updated. No code changes. drivers/net/bonding/bond_main.c | 105 ++++++++++++++++++++------------ 1 file changed, 65 insertions(+), 40 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 484c9e3e5e82..f04d4f28eb1a 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -4446,11 +4446,6 @@ static int bond_eth_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cm { struct bonding *bond = netdev_priv(bond_dev); struct mii_ioctl_data *mii = NULL; - const struct net_device_ops *ops; - struct net_device *real_dev; - struct hwtstamp_config cfg; - struct ifreq ifrr; - int res = 0; netdev_dbg(bond_dev, "bond_eth_ioctl: cmd=%d\n", cmd); @@ -4477,44 +4472,11 @@ static int bond_eth_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cm } break; - case SIOCSHWTSTAMP: - if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) - return -EFAULT; - - if (!(cfg.flags & HWTSTAMP_FLAG_BONDED_PHC_INDEX)) - return -EOPNOTSUPP; - - fallthrough; - case SIOCGHWTSTAMP: - real_dev = bond_option_active_slave_get_rcu(bond); - if (!real_dev) - return -EOPNOTSUPP; - - strscpy_pad(ifrr.ifr_name, real_dev->name, IFNAMSIZ); - ifrr.ifr_ifru = ifr->ifr_ifru; - - ops = real_dev->netdev_ops; - if (netif_device_present(real_dev) && ops->ndo_eth_ioctl) { - res = ops->ndo_eth_ioctl(real_dev, &ifrr, cmd); - if (res) - return res; - - ifr->ifr_ifru = ifrr.ifr_ifru; - if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) - return -EFAULT; - - /* Set the BOND_PHC_INDEX flag to notify user space */ - cfg.flags |= HWTSTAMP_FLAG_BONDED_PHC_INDEX; - - return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? - -EFAULT : 0; - } - fallthrough; default: - res = -EOPNOTSUPP; + return -EOPNOTSUPP; } - return res; + return 0; } static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd) @@ -5688,6 +5650,67 @@ static u32 bond_mode_bcast_speed(struct slave *slave, u32 speed) return speed; } +/* Set the BOND_PHC_INDEX flag to notify user space */ +static int bond_set_phc_index_flag(struct kernel_hwtstamp_config *kernel_cfg) +{ + struct ifreq *ifr = kernel_cfg->ifr; + struct hwtstamp_config cfg; + + if (kernel_cfg->copied_to_user) { + /* Lower device has a legacy implementation */ + if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) + return -EFAULT; + + cfg.flags |= HWTSTAMP_FLAG_BONDED_PHC_INDEX; + if (copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg))) + return -EFAULT; + } else { + kernel_cfg->flags |= HWTSTAMP_FLAG_BONDED_PHC_INDEX; + } + + return 0; +} + +static int bond_hwtstamp_get(struct net_device *dev, + struct kernel_hwtstamp_config *cfg) +{ + struct bonding *bond = netdev_priv(dev); + struct net_device *real_dev; + int err; + + real_dev = bond_option_active_slave_get_rcu(bond); + if (!real_dev) + return -EOPNOTSUPP; + + err = generic_hwtstamp_get_lower(real_dev, cfg); + if (err) + return err; + + return bond_set_phc_index_flag(cfg); +} + +static int bond_hwtstamp_set(struct net_device *dev, + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack) +{ + struct bonding *bond = netdev_priv(dev); + struct net_device *real_dev; + int err; + + if (!(cfg->flags & HWTSTAMP_FLAG_BONDED_PHC_INDEX)) + return -EOPNOTSUPP; + + real_dev = bond_option_active_slave_get_rcu(bond); + if (!real_dev) + return -EOPNOTSUPP; + + err = generic_hwtstamp_set_lower(real_dev, cfg, extack); + if (err) + return err; + + return bond_set_phc_index_flag(cfg); +} + static int bond_ethtool_get_link_ksettings(struct net_device *bond_dev, struct ethtool_link_ksettings *cmd) { @@ -5836,6 +5859,8 @@ static const struct net_device_ops bond_netdev_ops = { .ndo_bpf = bond_xdp, .ndo_xdp_xmit = bond_xdp_xmit, .ndo_xdp_get_xmit_slave = bond_xdp_get_xmit_slave, + .ndo_hwtstamp_get = bond_hwtstamp_get, + .ndo_hwtstamp_set = bond_hwtstamp_set, }; static const struct device_type bond_type = { From patchwork Tue Aug 1 14:28:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13336830 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 628ABC41513 for ; Tue, 1 Aug 2023 14:30:15 +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=j4mvC22BOu9O+AjuN6ylWuFWWoQksBNOS2OiTX9Dcr4=; b=sCB2Q51fO/RGuu ZVVco6LCvKDxCSXFJ8dcxW09I0dcDd/xP9ZmjpKvZEUA61Z8UyGT4wfZwLhbJC1Tph35cyaXDO9Ci U2vKyKvgcUyLODdXrCMWoUtco+ps7rVQpaRElbFLhgUvg9oXXS5aXTpyTZeJnUc93EMUBREG/WJrG QlvlH8SsIzugpw44sY0ztu06H97UJ91sd73Q+sY3si+wTIu6GOFP1FLVSrfZijuqiDW7TH7ny/Qzu Bcij6MbiGbniDAZ7zm/wOcgeCQcr5MSL4VxTElExY3hVww3eoit2Ma4yFGYofwL0FJ2+7DFGAfuvV +vxDBE4qDhGbQ2BxH4NA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQqNd-002aMo-32; Tue, 01 Aug 2023 14:29:45 +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 1qQqNa-002aEd-19 for linux-arm-kernel@lists.infradead.org; Tue, 01 Aug 2023 14:29:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bSI32wWaMSAbOZK0me8eZENRrwhzvazQaPYpNCixx6mV+z9bmTqXBTAoiygdr7kYqIHdwPudGVlhJWs+pasRUd0ji/Jz1b04eIlDg/+KZ4JR/8MDY+THe2BCEKb5tuHv8tartemT1CfXjviTQw0OyZuArX61zcVj/ZhIWRwX6q9MyUxKjTNC+rSkPWd7Pj1un02ckHvdpzpj4UlAvU4jdj4pZ3GtXO+JIBRxUoehDc3OBETudv0VxRyCiGH7ERqGJuac3fc9bYX5tq5aRMGBWAiDJ1NOd/4MQ4wfoBdhlFo+4KV7rhO0SuE3UcGx52UQ+UThOJNn8xRxhUCZ3Tglbg== 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=0fSV6n6ByWaBUFa/PhwXrGfebNqxoJ6b+fUOA+eKRH8=; b=UsPmR2jHlnmmbuYC1akyqEwAAtlWRCaSMokzCSsficRPq9QYlfiPu7QHmHNVyAjLAK89/DJHvB/S8FUJuQ+MJIFG2WyfzBj0d4trk1EqxajHaLfyFBDEFIyLBSfqVdNau9QxNp0SQDjTEESKxk2XSBUXJAhiW5Bm9JbbELx0Jt2NyaVZS0YCj0eWrNYnAxGw/VqW+vFscrCymtE9+b5xyrHKUgmMGiPqcbevKuytYk+AHrl9ATfrbqrk9g1LB9+g73e6YsaDgMTp0UjP+6Iyb+LD3sddYpDSlm2wgnk7WwAM0jlOE4O2XWlzbpBmiFQOL7FDSdFkvPgwhSuLIgjwkw== 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=0fSV6n6ByWaBUFa/PhwXrGfebNqxoJ6b+fUOA+eKRH8=; b=HE60ZLJ7K7wXUx1yQ5Zvq6oZqltDoejM1HH4vlcZG/UnIt64CZPC662AiqxoFv1hXbvpQ89OtdzlguL6/EEZYx2iwob8soMQbDy3KzF00tTYhx4bVb7/u3Fsc3i9Kb0ja4MfI7EaJpesFr0vR2swc+yUhLU9SONNyAx4D29CtVI= 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:34 +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:34 +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 06/12] net: fec: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set() Date: Tue, 1 Aug 2023 17:28:18 +0300 Message-Id: <20230801142824.1772134-7-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: 97031a46-46ee-436c-7a73-08db929bb9d5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y8hXUXeMORx4TSgKiu6YZ7b9DEKyD0Wh3xJAjrGaMWYu/2tlzSNFAZSdnf9jszgvQRhWvCsFs53z9WgTXLEEivAC791DiIUx8S8eZ1I8IU869cFss/L0kRUfoKefRUe8tEFhOYpiOQayLCGbJuPYpXGtRu2Dvt0JI533atwvR0cUCV8uMOFGaTq8NITyc7GdVZvffG5aNVyfHIpkDhoZGrq/zMG6H1OrYcAeeQBrdGPdI2cnt6g06ko8R2UrjYuukWALXKVWSZJloMhkTBNfrfHEJFYyPPeh9Zpmo0i0jyl0yglrEp5xKc7XotfIcniq9WxufbBHu25bD4af3WqePdvBkoVzrJFGUAt7+Mc7B8l2g3S2DRPds8BFFeEvSgVfz+znZ/qzd9+mMSByFQb3so0OdbIAfQKg4BtJohBWSi0eumcXdxdttv2WUEJXmY58lGqzr5jHTWDCt70qDGzXMnywyfQTtlEDpb/KPdovwH9XYC44EJh2TBFc4Z0/FHUBhG8YVmc8H5PtT7sgzQmy9G8DyNFlfkyd9S9l7n0+s/8DZMfpYVu41o3eV08IitUcR0FcEPunsfRRQl6yiBcFccO0H7CfQZ85hzTFuMjflNCPX28SEkEZOzEsWy1B6knf 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: 8h9gb4wO5jMbK3BPxjqg33vZBQGrBgq9HNMdKV0QuMCYNhRzSdS4DrBsZMhNIkOp09WVjkYskKVlUrL87K3kllbajB8MiMgWf8jKEodqBkt/lDegNEo/jkBbN62lR+IpU2asXe37nbGTcKlkslSYSbQMws6SR0L+p+rMvf8VrtMNBr96OInrRfuEGU2pNKajMiGPuqQI1peH8v51jL9F1s1wuZt72Kh3FQFQglHWLyEkwaKmnkJVAMMmsem96AuEh/UQQa6hfEIPBVmFi8I0WjlATbzZjLraFI3er/gciEqy+lBQ1N4JEqQchcaLO85XLyLODiPExPtRXA9fGjkldAzc3AAc7OdIVcqHgVH8scAVV3IAF+fmOu1OX7mWBnDZdusz4sJIXbcqt7/vQf27JQoT7k1w/DDkwtSYCdnvoDGM2X3DmabV16xpp/IK/a10Uf8NJrV/tQ6R2n4zhRfATg0Tf39lv5eXRhy96LbpsPlUP7h595q3gDQJnf/nMYILSNvrJqyXsMI1pdmRGVfrPmRHpkOyYb96T6uSBRIO94W+7bfVFfRmUPv1GFAsN8RXAMk3nAFjgo4HompppcohiT5pJjLB40acwUFX7Il9GIujaj72iVM7Aq+h5FAsSn0FrGBNpgCKuVBPCX70itNKH7Eq5nclB31sDc2x8RioZ5u542lgJxSwYiXlckvCkFjk1WdOb3n2iFdLLK7FxQ5+YSG2dU3YYXPHOQcwJBBmW1pCN4u49A+WKmBVkRToR+5Utl+CCzNpe4hy95jVJGmOBlsuR+mj14OaOz/998DVPWMZ2KMWZdpxy69h58UoUyPWoGg0VOlpGmT6lrSEk+D2VfmzRQskCZS4seZcTXAinxzyeS6GCEJuOEYLT8Qf38A6iBUebA2KbU/AcKI2qzS46f/guDtVvGzp1IZI6paRvUjTk6jpgq4olddbodcZbjKe80A7H8n7lhAogiYvm2s6/YYUoQqWLZ8MnCKsbauc3gq8pAXNkoWVDRgxPE946XqHtCt1zVLvImzrxu2BmAhWXLJYnHkbx9UWCFYnnq/EXtyIxxI3mLM1MDqtIP7jPljeeWc/tolKbbgZhV7bN6seAS+RC631Q1T1Om40w3o6vjp9zFk1Tcue42ojv5IlLn/iRNwcgLqydzr2iFGHP+igX/aTijYginbBc0R31dXS+e5xP3pDO2CnGIaz/Jl+bl6yqVI31r083Fh+p4imMbVmZ/87iTjjqc6e3LLr0jSBkNh/WtxgvFMIuEqPnWEU/W0LGaxP1L4zfRmrTJzV7gc/TGqXadkOIy0fVMC0HrH0Sw9ao9XDDz/+6bDb+nWvte8G7MZf0/spovU9C7tcY7GWGHO5PZL+TkXNGCyBCgGPSQ5s3zK/vAXvRU8bmDK8ICMqAF5ekasf28ufwAe9XTne3TCVuwIvRTHQqi4hVICOy6F9OIl5KkMEKdmSdIPRfz9P7EdHKOD2qBdlsdcnKILmA02H0HL+K50JWfmxsoFUNuJ0nQAporcWKe6JTXGeKFGLuCroIOZ5d/qmd3gjwkXi91rvX/HCSWpzZBpo/rP46gVPvKjBfKV82schJqGmuZ2W8QEGJPAQgcwuqdDQmG29uA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 97031a46-46ee-436c-7a73-08db929bb9d5 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:34.0508 (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: +RIW8uerCeAGf4eh3Nw/ethfHnFrGa89g5L3aoYjxudd+dOjt0AyRLEahrOYOz9FrLgl94mmKMgdVKKBbEikYQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB10028 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230801_072942_400918_64701706 X-CRM114-Status: GOOD ( 18.81 ) 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 The hardware timestamping through ndo_eth_ioctl() is going away. Convert the FEC driver to the new API before that can be removed. After removing the timestamping logic from fec_enet_ioctl(), the rest is equivalent to phy_do_ioctl_running(). Signed-off-by: Vladimir Oltean Reviewed-by: Jacob Keller Reviewed-by: Wei Fang --- Changes in v9: - Add back netif_running() checks Changes in v8: - Use phy_do_ioctl_running() Changes in v7: - Patch is new drivers/net/ethernet/freescale/fec.h | 5 +- drivers/net/ethernet/freescale/fec_main.c | 73 ++++++++++++++--------- drivers/net/ethernet/freescale/fec_ptp.c | 31 ++++------ 3 files changed, 59 insertions(+), 50 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h index 8f1edcca96c4..ec64067ca782 100644 --- a/drivers/net/ethernet/freescale/fec.h +++ b/drivers/net/ethernet/freescale/fec.h @@ -699,8 +699,9 @@ void fec_ptp_init(struct platform_device *pdev, int irq_idx); void fec_ptp_stop(struct platform_device *pdev); void fec_ptp_start_cyclecounter(struct net_device *ndev); void fec_ptp_disable_hwts(struct net_device *ndev); -int fec_ptp_set(struct net_device *ndev, struct ifreq *ifr); -int fec_ptp_get(struct net_device *ndev, struct ifreq *ifr); +int fec_ptp_set(struct net_device *ndev, struct kernel_hwtstamp_config *config, + struct netlink_ext_ack *extack); +void fec_ptp_get(struct net_device *ndev, struct kernel_hwtstamp_config *config); /****************************************************************************/ #endif /* FEC_H */ diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 14d0dc7ba3c9..bbd0cc97905a 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3203,33 +3203,6 @@ static const struct ethtool_ops fec_enet_ethtool_ops = { .self_test = net_selftest, }; -static int fec_enet_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd) -{ - struct fec_enet_private *fep = netdev_priv(ndev); - struct phy_device *phydev = ndev->phydev; - - if (!netif_running(ndev)) - return -EINVAL; - - if (!phydev) - return -ENODEV; - - if (fep->bufdesc_ex) { - bool use_fec_hwts = !phy_has_hwtstamp(phydev); - - if (cmd == SIOCSHWTSTAMP) { - if (use_fec_hwts) - return fec_ptp_set(ndev, rq); - fec_ptp_disable_hwts(ndev); - } else if (cmd == SIOCGHWTSTAMP) { - if (use_fec_hwts) - return fec_ptp_get(ndev, rq); - } - } - - return phy_mii_ioctl(phydev, rq, cmd); -} - static void fec_enet_free_buffers(struct net_device *ndev) { struct fec_enet_private *fep = netdev_priv(ndev); @@ -3895,6 +3868,48 @@ static int fec_enet_xdp_xmit(struct net_device *dev, return sent_frames; } +static int fec_hwtstamp_get(struct net_device *ndev, + struct kernel_hwtstamp_config *config) +{ + struct fec_enet_private *fep = netdev_priv(ndev); + struct phy_device *phydev = ndev->phydev; + + if (phy_has_hwtstamp(phydev)) + return phy_mii_ioctl(phydev, config->ifr, SIOCGHWTSTAMP); + + if (!netif_running(ndev)) + return -EINVAL; + + if (!fep->bufdesc_ex) + return -EOPNOTSUPP; + + fec_ptp_get(ndev, config); + + return 0; +} + +static int fec_hwtstamp_set(struct net_device *ndev, + struct kernel_hwtstamp_config *config, + struct netlink_ext_ack *extack) +{ + struct fec_enet_private *fep = netdev_priv(ndev); + struct phy_device *phydev = ndev->phydev; + + if (phy_has_hwtstamp(phydev)) { + fec_ptp_disable_hwts(ndev); + + return phy_mii_ioctl(phydev, config->ifr, SIOCSHWTSTAMP); + } + + if (!netif_running(ndev)) + return -EINVAL; + + if (!fep->bufdesc_ex) + return -EOPNOTSUPP; + + return fec_ptp_set(ndev, config, extack); +} + static const struct net_device_ops fec_netdev_ops = { .ndo_open = fec_enet_open, .ndo_stop = fec_enet_close, @@ -3904,13 +3919,15 @@ static const struct net_device_ops fec_netdev_ops = { .ndo_validate_addr = eth_validate_addr, .ndo_tx_timeout = fec_timeout, .ndo_set_mac_address = fec_set_mac_address, - .ndo_eth_ioctl = fec_enet_ioctl, + .ndo_eth_ioctl = phy_do_ioctl_running, #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = fec_poll_controller, #endif .ndo_set_features = fec_set_features, .ndo_bpf = fec_enet_bpf, .ndo_xdp_xmit = fec_enet_xdp_xmit, + .ndo_hwtstamp_get = fec_hwtstamp_get, + .ndo_hwtstamp_set = fec_hwtstamp_set, }; static const unsigned short offset_des_active_rxq[] = { diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c index fc4674cb65be..befd49b8bd71 100644 --- a/drivers/net/ethernet/freescale/fec_ptp.c +++ b/drivers/net/ethernet/freescale/fec_ptp.c @@ -617,16 +617,12 @@ void fec_ptp_disable_hwts(struct net_device *ndev) fep->hwts_rx_en = 0; } -int fec_ptp_set(struct net_device *ndev, struct ifreq *ifr) +int fec_ptp_set(struct net_device *ndev, struct kernel_hwtstamp_config *config, + struct netlink_ext_ack *extack) { struct fec_enet_private *fep = netdev_priv(ndev); - struct hwtstamp_config config; - - if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) - return -EFAULT; - - switch (config.tx_type) { + switch (config->tx_type) { case HWTSTAMP_TX_OFF: fep->hwts_tx_en = 0; break; @@ -637,33 +633,28 @@ int fec_ptp_set(struct net_device *ndev, struct ifreq *ifr) return -ERANGE; } - switch (config.rx_filter) { + switch (config->rx_filter) { case HWTSTAMP_FILTER_NONE: fep->hwts_rx_en = 0; break; default: fep->hwts_rx_en = 1; - config.rx_filter = HWTSTAMP_FILTER_ALL; + config->rx_filter = HWTSTAMP_FILTER_ALL; break; } - return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? - -EFAULT : 0; + return 0; } -int fec_ptp_get(struct net_device *ndev, struct ifreq *ifr) +void fec_ptp_get(struct net_device *ndev, struct kernel_hwtstamp_config *config) { struct fec_enet_private *fep = netdev_priv(ndev); - struct hwtstamp_config config; - - config.flags = 0; - config.tx_type = fep->hwts_tx_en ? HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF; - config.rx_filter = (fep->hwts_rx_en ? - HWTSTAMP_FILTER_ALL : HWTSTAMP_FILTER_NONE); - return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? - -EFAULT : 0; + config->flags = 0; + config->tx_type = fep->hwts_tx_en ? HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF; + config->rx_filter = (fep->hwts_rx_en ? + HWTSTAMP_FILTER_ALL : HWTSTAMP_FILTER_NONE); } /* From patchwork Tue Aug 1 14:28:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13336828 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 39994C001DF for ; Tue, 1 Aug 2023 14:30:13 +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=RSNS/FzeDbl5Mun1m/XVRl4KOn2sQQ34cGdEiTHY8RQ=; b=hxTtJzmFhsLtfJ CcFxStljVn7/HLD70OixhbTBp+Hcgmhmbh6i+vxDgfij7vMeqpxVmFfub53Af7DysWKIKlySI8HuW 8rFifffPlivE/zHznIhiCKHvguBoRTFJtv2/CtD2ELVIkrO0PJsJ/bxYcCfaueGnkKLR6kba2bYaV VFrvw9zOmSI96RiLUqzFiiO6WxOuNZgEHr8RUyBhXZ9OT3sXG3ow/FMhlUln4tjSolrpOcCJCKkaa H9ZHfz8hKzhdQIeFKtsyL2fkYM8LBT5W7FIT0zw9FEF8JQFgMz/q/EcKQtpQ5sMyGg1H/M4uyAcza MCwFFVXf/XesDFHk2g6w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQqNe-002aNW-25; Tue, 01 Aug 2023 14:29:46 +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 1qQqNc-002aEd-0x for linux-arm-kernel@lists.infradead.org; Tue, 01 Aug 2023 14:29:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JLm1lfLvMFnkrcdwrgx7J7Hd1UgGDkD0Z93qykvXxxMzh010tZ0dkvyyEhsAuhsaQqhCSjh4suJ8ceOEnvzQz0jqhXozoRoVFrXpkEfwmlJop+wZbs/3JTvjTmfbYvD5vGnUsHqKjChQmEmwlh1lYmAbXoRUooYGs1NkorS0lmL32M6pqeIJcEF7/ru8ZmBa4I/V2EzCKl9XFvtPKv/mvV43KdJTugJ26C9Flc13rQF7XhjjvKVl7m0Wt9uVa2dzLqOorTlw6zkYHxxC9Y/eHOF694svz3gYhN1CooLOvETTLSEdSdWh7x5Uw0lwmB739eoh/uCreOIIkupSImZjTQ== 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=bHdO4wO5z3rC5h6mj3wqvqjg01Za8sFP+SQfz+yM254=; b=elkoe1rUS+HemI6WWf8lrfVVbbsBjMj/mRJ+Cg/89z/duZO8Xf4R7Nb0fhDb6Qi4pVWYUT3Q6VtkM+zHi1mPrMgRz2ifxHQLFV5C/CPPxgoA5TT8w6VVhJL6iLE/OgevqtNxBus+AU0Vnxef5HjxvfSmctzVrBe332YAVncNSO2FRH6JJl1iGmi9VMRls3uRc2EYMJO56ZbeBjHs+vg3SNIqMAHFp/J9pvPrVAyrU52RfwVtZS1urAjhYvKx1WDi9BpMzLWP53TpIKjzYnrII+ni78KKcL3y6XUqle+hURU+HFtnsMpsY+i6Qi5rryVnhUVxOKikce8c0NVB3GZ7Uw== 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=bHdO4wO5z3rC5h6mj3wqvqjg01Za8sFP+SQfz+yM254=; b=XDgCTbvY0sGs6sPKUl5wy2C/3O7ImYTQ3qCHuWTjlMj4fTXF6uI1nXzgIKeOsj/cZalpPHM4Sm3DOKSlbgxajJPfMWwrNiJyKutDLjLNn2GziFLP3Q/YUPLrleIM1eXQgv9P14j8npVz39xTH/3dJo0C0TDYjHXDdgx0CGJ2FPc= 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:36 +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:36 +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 07/12] net: fec: delete fec_ptp_disable_hwts() Date: Tue, 1 Aug 2023 17:28:19 +0300 Message-Id: <20230801142824.1772134-8-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: 15bf1206-af56-4443-0600-08db929bbb09 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Uv7+fX5n1T2ohnCXMyJ4EUMot45iwRBwmbLl4Jh9iJLqchpWO9gO7HPw9f1qO4kYXenjR1Y4dMv8SJtdJ+IJRrXvzjfekpVSRHe/MfOQLxgU9mCDrnuBBZeY00B0tPV5V2JMGIgPDsirFqB4rsGW+JfR/glUj4rrAL8Zy1hYZmwj73vN+ialNGtIJXfXx3S2wlw6HV5SbDR5jvnrWus/YSH5zmhbNBjanaTGRAWKZoQHOam29EwAMsd7ojx1xWfhNUr1PItCEu3OzGuYX+6/EyQqhb2eR+2v72cyeSZD0guze7Nfq9Wu8HgJTl+MSGkwdie4pw2ZV1sGchyav1QmlcGPHjgpgKKCQrJMTSb3rgQMNUXXPIm0ouwnTuBujdoLJBYdHKI89Tj5CHp6fLnALvBURP0GQf6ulFikCbycf/PHmFt3tE2GUMVl20trtLVosMEz4y4IES2urqXR2tMQfk2eHBqZQMHC5faWMOIkPLpag5yEQcFoIBTouVM/VP+u33VV7UFLHOZ6m/ufos/weqEZKvFbIgFa2X+yHslMWxuVdD7dDBJ82Q7BvAZ1dD68ipyr7QKVye7NNKQOw+ewI24s1vfKmbcnxU/bq/NTx0l5FrVZVelxvGhqbbvkUACg 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: C8Vtre+t97ZVb5Rzm7Ja39wF1ScFqt7D3AcHnNY5q960zNrt6Z54G9Z4R7zvS5NOHSucDwcYGx2jhscvongH89pK8z6jweC9YZvQiYJFHhYkeIooi45zlE3YE/o6bUPly302yvGqnYAoNcbsgC78kXyFTr8G4BJWK89psqfIuFNOVanGZL9bm6+yq3dCWwiSGCjdf2/UtzIIGM5uo1eXN7HLfQtoNZP+8vhqU3ehGpo4Ca0lQpII3+UxG3WknGOdGTRjT41UT/cuAdyNhyzgcypLvj+CZHHLfckrQTy4fCkSQYXttGE1/fFJMhhmUbExMoj7/FiFTZYdzFn7MFXMnFaB+wASKyw4uZPkTI0HUqrJehDgzFb9nYIXxf6dtbTmX3s5j9GHDpLSeV3OTx33qjY/Kx4H+dzgragWO/z7Oe+n7eZHNmWRFga9kGy2FPJz+sOo2SAKK8XYsFSmyptGAOQHplPV7p8fegE3PB+NjWGcE479OJRZCo3PVV7nIASJMv39Cfhly0fqVh424yszwRshVohSVHdf6ZqiQPLg3o3UTDnbTcCiB+IAHxqlAhzNmmjlaLO3ZN1DZG5dWpzZANyBG3BlhaMrywM4DL8asrQhlB0z0QEpHi425cwF0KUc/wHzBBFihr28ui/oFab6K3zi30wBkeYUo9iWgyC8Bg8JoZzBtEpzA6NNPHGG0aW8yx6twl+K5w6MwUgEXLhqNYxWO3mIlKvzHDZle7bizL908EZILXr4Ul5sx0Q0wulreK42dwYpm0HqnxzQtuk6++3DywUY5PitK8peBVunZO+QyvU4WYJOcL+80PmreUHdVsO+cIWI3hARp6nreKe3ckB+LgT8ngPfYrmDoNK8vhck4RW27+VJ7YcTgCb9V1n4j8fiTvwiaItZ6cVBYHG/srCsFQ6cFdLVGIJWDotkF/3IP5S6E8M2ttJ55g5XaXgo2bJMwZ+kfQ5mOFqxR40rhq0lot5Y2QUre9x4oZOXBk9gYq8dVjB8DDGyeZw9Oya4LV49EhGKUxiKLPqgZB+KCFWR+i9fnqSLaGWTxAbagZqauMaVjdqgkYVa+rMplAsvskooaBlPqrZY16UFD0rT64vXuvgnUpuUNvAt1D8QvEpGjFML5l+Dg3lMVTiHOOrHgLvGCJiRvPt+hYg2Jc2T6Dn4twP8xRCnKySOtYW6xO6i5S82hcpA3R86DgjrDXHpEvR63bVX9SZWPySH6XevHL2qb1owK+oPhz9dk/DwT6uZE7UBZsGXc55zAB/TUCuOZyu5z2/heobS0zKoINWXkdQL4jiB9WbTvVFQrK5OpQJrGGYzTivHjZJrfuZ2s8SBCbJsMZ+SHFgz36vDuhOwmVP6rvZ58wqkLbj2Khdv9Z9AzLrrAeNnfqIoNrIxs1LG1bZtZ+jTgyWPz6FK5vjpQJpA6FP1nAmSXomAR1s7fPpJrKZQ4odmyE4Q26hDRl5vXWZ5pgwx4KQ2hcDOa+GFv4IKo1klZCrRrEIQi2oDF7rZsaFhNdD6D84J5JKWHDZrdj3QkocDmxQHkG8d0O6PuXOUtI0xGrPR01NkANCSdTg9dwNqJ/T2AvJ1UpMrM6Pb4hNAVASakWl6T9+fEK8PYQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 15bf1206-af56-4443-0600-08db929bbb09 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:36.0578 (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: cmiHE5HrTSoDSfQiI3vytODLkAC6DQtM1Vn+iFS1KVj7Jlb6cYRiXyCAmr4CacsTR0RYT6Bx7mEW8/u4goz+ng== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB10028 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230801_072944_337650_94E7EB48 X-CRM114-Status: GOOD ( 17.50 ) 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 Commit 340746398b67 ("net: fec: fix hardware time stamping by external devices") was overly cautious with calling fec_ptp_disable_hwts() when cmd == SIOCSHWTSTAMP and use_fec_hwts == false, because use_fec_hwts is based on a runtime invariant (phy_has_hwtstamp()). Thus, if use_fec_hwts is false, then fep->hwts_tx_en and fep->hwts_rx_en cannot be changed at runtime; their values depend on the initial memory allocation, which already sets them to zeroes. If the core will ever gain support for switching timestamping layers, it will arrange for a more organized calling convention and disable timestamping in the previous layer as a first step. This means that the code in the FEC driver is not necessary in any case. The purpose of this change is to arrange the phy_has_hwtstamp() code in a way in which it can be refactored away into generic logic. Signed-off-by: Vladimir Oltean Reviewed-by: Jacob Keller Reviewed-by: Wei Fang --- Changes in v8-v9: - None Changes in v7: - Patch is new drivers/net/ethernet/freescale/fec.h | 1 - drivers/net/ethernet/freescale/fec_main.c | 5 +---- drivers/net/ethernet/freescale/fec_ptp.c | 12 ------------ 3 files changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h index ec64067ca782..110f2e9f3e3f 100644 --- a/drivers/net/ethernet/freescale/fec.h +++ b/drivers/net/ethernet/freescale/fec.h @@ -698,7 +698,6 @@ struct fec_enet_private { void fec_ptp_init(struct platform_device *pdev, int irq_idx); void fec_ptp_stop(struct platform_device *pdev); void fec_ptp_start_cyclecounter(struct net_device *ndev); -void fec_ptp_disable_hwts(struct net_device *ndev); int fec_ptp_set(struct net_device *ndev, struct kernel_hwtstamp_config *config, struct netlink_ext_ack *extack); void fec_ptp_get(struct net_device *ndev, struct kernel_hwtstamp_config *config); diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index bbd0cc97905a..6d81fff0227e 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3895,11 +3895,8 @@ static int fec_hwtstamp_set(struct net_device *ndev, struct fec_enet_private *fep = netdev_priv(ndev); struct phy_device *phydev = ndev->phydev; - if (phy_has_hwtstamp(phydev)) { - fec_ptp_disable_hwts(ndev); - + if (phy_has_hwtstamp(phydev)) return phy_mii_ioctl(phydev, config->ifr, SIOCSHWTSTAMP); - } if (!netif_running(ndev)) return -EINVAL; diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c index befd49b8bd71..181d9bfbee22 100644 --- a/drivers/net/ethernet/freescale/fec_ptp.c +++ b/drivers/net/ethernet/freescale/fec_ptp.c @@ -605,18 +605,6 @@ static int fec_ptp_enable(struct ptp_clock_info *ptp, } } -/** - * fec_ptp_disable_hwts - disable hardware time stamping - * @ndev: pointer to net_device - */ -void fec_ptp_disable_hwts(struct net_device *ndev) -{ - struct fec_enet_private *fep = netdev_priv(ndev); - - fep->hwts_tx_en = 0; - fep->hwts_rx_en = 0; -} - int fec_ptp_set(struct net_device *ndev, struct kernel_hwtstamp_config *config, struct netlink_ext_ack *extack) { From patchwork Tue Aug 1 14:28:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13336829 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 55721C04A94 for ; Tue, 1 Aug 2023 14:30:15 +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=shgjpYPr4ZpYLlJ8ikIRFnisG9nATkZW/ZgJQEHAQPw=; b=Nx2ryGDhr20JBT Psz5Q7ubXtYxUQkL9qqMxUBnF8wL79Kfs5V61ecj7rGnQ5d/C1QnKdzrvLru0jq8uaU687tNO9j5s yXbyCgHAn3Rn9776cH2rvE6U+x8GUUgNtHw8bQwS8JB4Hofv4uqpwkanw0WUdiA4Pdfsb42E6ZbTe U1+ii7W9fflsuNCqVIbyTp49WOJ3l7MCPxJRCY75qxcWGlj9ee0UazcWgDT4WZmnOymXhafUhfI0w zwwGv7bwGTA0zX7cUW9nLMYu9fu4lf3aABBA8M4ZpXK4WebSzmjB7R6r//WxMliDyZnw8b9i7zeUd 4o1Z6P4dKJAjYyhOyb6w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQqNg-002aPQ-3A; Tue, 01 Aug 2023 14:29:48 +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 1qQqNe-002aEd-0C for linux-arm-kernel@lists.infradead.org; Tue, 01 Aug 2023 14:29:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j4P6lN1Cb58UazrCRXrIMzMYYcvnp1rkc+icivsk/6eaGqXuKH08uQNqsnpxVDKOmOUd7v1AUC7hfi9nRFRuCT2DfAwESuyaRRkrz04xz5DCp8AayI85X65e3TZgmt9bPyD44/4hc6t4+pM+4NBiBwRtR/Pvw9plXRo5tPqvJrNEm0xPp5gEczqvpJWBo+Mh9CoR/gVS6dd4L48JdKaDwjTjd7Z2yjq4+xh4XQAfnNWDFVb90sTDZ9mDrd/QPASwkiTYlm+SrMYtVMFnXFSuM8XAkXSUyIoYdlwKGzT2HesgGqj1ElgKxUIBE07mZrP6Yr3JYmqkOtipMDU72lQJMQ== 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=7pichTHHeLsSFWH+QItuhd8YCT5oT6qjBwvnWA/KbH0=; b=Y5jophNkN+zZTd3HEvebC/AAhj/nD7lnYQ+12bek1OzBOMLBYP7zT2TvJYFNQ4xNcNu5qlJ33A+JDhWXFgBEKRjt18qfYUrWTGysFtpDnE7Ncm7cfMyx/0kbMhPHkh2D0e3rizMFWQapDBMF07Hjl0xXJLegDrANcER89JkZMgVFZYNJn3BJkiinpIn0pMIOviW+StyEBT3IIlkEYev79DQUXed+9Eqi8mTGtxA7qp+vS4fgkADhGwZdP/taf1aYk7dsxO4bA5bPTyMlsUYtt6TOqo4WhSQI5XaTyYQRH/fKfeEXDP+0ZKqEZPJt7jZlLPmWEuuiBdotpBtYEhZ+1w== 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=7pichTHHeLsSFWH+QItuhd8YCT5oT6qjBwvnWA/KbH0=; b=inqs3SkhdJrJO40liPBQWEGLPO3WAnCgNuHEMxE4JOkPH1bVLnN2NHzrrYgVBPFNRbSggk4WPVjuaQiJ/RitwOGOpH9vh7LoW6v3jGTCW6Afhd+jj/qDnQsfrbqQN+V923rQBVFOAWDispX87BCaKMDRHnZU6L4OQBeRx/ZvuzM= 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:38 +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:38 +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 08/12] net: sparx5: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set() Date: Tue, 1 Aug 2023 17:28:20 +0300 Message-Id: <20230801142824.1772134-9-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: 190f4958-7887-466f-ccee-08db929bbc37 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ArCD4cm078Dz5HoGDrBzsWTYtY8DwsSMqvvf/8fCqMHT//bsv8tHBgbA3Ps0FGzTmi4dwoMJIXFFbwUDLpd9wgWoxIG5WQHyt3Zl1lGkM1OLIN3iSkhotYTcbHmDNvuVoH7EY/ALJPbb/eeHeJfEw+/rac2ciQGwdYjk4VF8IdlOdYufJ7dAPGAW1ihxq7MYGo3N2ePvyQ8SVDieg5YClxBvuwwIneWRQzsO9TWD7F76U8BnLI8zeR/Fwvx5o3ov1wF31hnv9HSECJ6HdrP2wkwvZGpZ0ISzrBnI73sxTKJ+xu9Lj+xk/BaRpb6vBreCRjfY1A4scmL478VLdUzs+BX1bYbDd8Lx6CgKZblC8qtW5Fslm7z3FRjKen3L9dAJYWsKgZ4zFgPyxdXe3Z2Hnb27MHa84bV3H3T8d+CSxGekuntvOEAUW5rhze5rRMaH9US0R4mmurlzpvNe2WOuDLM9eJYOPuGtWkuCMWl4Y1S5M7oyyVLhCitjcia3rnek+EP8Rd/fzq2Dl2sRgp9UhSyBVD2hHw1sb89wiXZM2DweJp3JvoxLQOoQsF65Kbj78kGNnEnEX/K454QD1vS4lua0vK9vWpXu336is/d8JxYlC6bxCGFGceaHMgjMfX6b 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: gfPbjETot53t8weMrhuqAwuj/HF65MuSwzxUW+P4YyhLPeuEYXVqbn4JImp9iONzwQH5aiNPDy+uAO/+N2POaXc1MH4b/qILPg5JG0RvgeEnO/0y84tj6tGN/X7wCskgPtrTwvR18TwKAHe9q/tDWaBclbFT1/Y8ljCTt+afEBmrJbyUzIX+D0w2yz9O+vAqo8WF7oj8Y0YIbHD5Vef90TZZTVer67/kUn0cwS8O1pkJIHrhRS8lvfwwa6ytAsPO4cQXoPXfORdKVmDZ+s4SrRAEPIFUTNdS+rkXmZFEHPBASJzRQeMJ3zmJ6XKW3usE7izmYdPltI1Rr9uLPjqVb9w1c/F+iOvzFGfMGPoJLCMrZQUndjxsuGd4QK1ptv9JokiTn0UfBT7GtGOAXEzgtXwM996ih87r4YPNMsxQLo2LRtdmPu4jNqsFIDZ9nme86fqyq83AHbqbAMFTVI79X3ps2ycytdaAfMuht1bfl1z356aDTX6Ig6K6t6eYkL5DuspaxNMxRE7/ehdFRfXgH3I1RnaZb2AQrYdMSZ9UuyIgbbVseUZ6Zq1TY4ZVb4p35J+/5pFkebEeSFo5KD6YhzKKUYnDM6iB2mo8gye+fQ204fD9jwAiQjqY53jij9Ql2Um5uXrVhcXmJh8ilDDwKyp+rWg+fCZEmfwtGZT9toi97guzHeRE+MKm0UolzVHTh3MV2XU/x6uPGyjhHRaNPSX5T6x/pqen0mNPKTsqneB8A5gR7WGzUBtHf5SBQwg8qEOk7noVgMi6cEV0bT3GJ7be9vNlhvt2QvIq2sykMMeA+tmq8ARJ/lBP7ywt+/2WblHbVWbkEFj+hWVV6UCvuS75JmtwoqP8O01KQDBUM649n84iyDgLXvUpeCkgEzENtTf2fkH3BkVHKUHLhX77EboU5qSBcIT6qz7HmfBaYI/MtZZNb4xP36abMxnBxatOTE0hUvbfjSnLcD3vAg4m+labd5xPR0xTjKDU/zOyzhXfRvWPd/GiQ5lKIOE4HKPhi18N4K+4L/zu6AkVprWUAiZW5/01xC+4MKfvnxBu9dHG2h2KxCcPx6S7lnCMKP+ahWE3QInHKb+A1LWQtr6WGcLSKuyNtEp2GjxuLwifokuHBBp9TvYcAYgjqqozHgNeumDNtLwMqnIdyWaicwkhxwUCUH7w+Ym5OgDMp1PQYsCD2YrCuLtgFG1e6puHG6dgIH/VFYr1BBXc+Neg0hLi59yfOTawbiQGyVN5kK8ONhpsWlJTmhzR6pYHTALC0ASeBE8sS39YU34EN8aOPz7kex+w4Ce/EKGSOiQYu+nOj0dOON5Exv3TghmoEqb26NuGf/liQkAX8BLfDQAVglJ711zZBURR+c2gE2FVclkAuYoES0v/YgweD5sHMQ9TQN+UhL45QleQpbchMso2rWR+PuZ+aO0cjSb5NkgRvFOK5frMQw1x96efFDXYbSVbynuL62DMsJzSUmxZWvfjMOhAEOPHnReHzP+PxON3WZQ/BdzoJOmqGj1CdjdGcbavWzIRS3hytRst/387ai+80owSpro1aDwKCdtm8Ag+NlpgzbwAIuiUh1IzRRlQ2GZgnZSHWDPIMF75UHXucviFQJ+fYw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 190f4958-7887-466f-ccee-08db929bbc37 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:38.0351 (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: tJJCkaLQZEBNR7u3mLFdOSFJhGphXFa25dB2x7BuwUGReXbnoe37MhJrLNCqckzJj03BnC6ikZiQVHun8vTnPw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB10028 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230801_072946_124786_01BD4D73 X-CRM114-Status: GOOD ( 18.82 ) 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 The hardware timestamping through ndo_eth_ioctl() is going away. Convert the sparx5 driver to the new API before that can be removed. After removing the timestamping logic from sparx5_port_ioctl(), the rest is equivalent to phy_do_ioctl(). Signed-off-by: Vladimir Oltean Reviewed-by: Jacob Keller Reviewed-by: Steen Hegelund --- Changes in v9: - None Changes in v8: - Use phy_do_ioctl() Changes in v7: - Patch is new .../ethernet/microchip/sparx5/sparx5_main.h | 9 ++-- .../ethernet/microchip/sparx5/sparx5_netdev.c | 41 +++++++++++++------ .../ethernet/microchip/sparx5/sparx5_ptp.c | 24 +++++------ 3 files changed, 46 insertions(+), 28 deletions(-) diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.h b/drivers/net/ethernet/microchip/sparx5/sparx5_main.h index 62c85463b634..89a9a7afa32c 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.h +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.h @@ -205,7 +205,7 @@ enum sparx5_core_clockfreq { struct sparx5_phc { struct ptp_clock *clock; struct ptp_clock_info info; - struct hwtstamp_config hwtstamp_config; + struct kernel_hwtstamp_config hwtstamp_config; struct sparx5 *sparx5; u8 index; }; @@ -388,8 +388,11 @@ void sparx5_unregister_netdevs(struct sparx5 *sparx5); /* sparx5_ptp.c */ int sparx5_ptp_init(struct sparx5 *sparx5); void sparx5_ptp_deinit(struct sparx5 *sparx5); -int sparx5_ptp_hwtstamp_set(struct sparx5_port *port, struct ifreq *ifr); -int sparx5_ptp_hwtstamp_get(struct sparx5_port *port, struct ifreq *ifr); +int sparx5_ptp_hwtstamp_set(struct sparx5_port *port, + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack); +void sparx5_ptp_hwtstamp_get(struct sparx5_port *port, + struct kernel_hwtstamp_config *cfg); void sparx5_ptp_rxtstamp(struct sparx5 *sparx5, struct sk_buff *skb, u64 timestamp); int sparx5_ptp_txtstamp_request(struct sparx5_port *port, diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c b/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c index d078156581d5..e01d3b1e17e0 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c @@ -210,22 +210,37 @@ static int sparx5_get_port_parent_id(struct net_device *dev, return 0; } -static int sparx5_port_ioctl(struct net_device *dev, struct ifreq *ifr, - int cmd) +static int sparx5_port_hwtstamp_get(struct net_device *dev, + struct kernel_hwtstamp_config *cfg) { struct sparx5_port *sparx5_port = netdev_priv(dev); struct sparx5 *sparx5 = sparx5_port->sparx5; - if (!phy_has_hwtstamp(dev->phydev) && sparx5->ptp) { - switch (cmd) { - case SIOCSHWTSTAMP: - return sparx5_ptp_hwtstamp_set(sparx5_port, ifr); - case SIOCGHWTSTAMP: - return sparx5_ptp_hwtstamp_get(sparx5_port, ifr); - } - } + if (phy_has_hwtstamp(dev->phydev)) + return phy_mii_ioctl(dev->phydev, cfg->ifr, SIOCGHWTSTAMP); + + if (!sparx5->ptp) + return -EOPNOTSUPP; + + sparx5_ptp_hwtstamp_get(sparx5_port, cfg); + + return 0; +} + +static int sparx5_port_hwtstamp_set(struct net_device *dev, + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack) +{ + struct sparx5_port *sparx5_port = netdev_priv(dev); + struct sparx5 *sparx5 = sparx5_port->sparx5; + + if (phy_has_hwtstamp(dev->phydev)) + return phy_mii_ioctl(dev->phydev, cfg->ifr, SIOCSHWTSTAMP); + + if (!sparx5->ptp) + return -EOPNOTSUPP; - return phy_mii_ioctl(dev->phydev, ifr, cmd); + return sparx5_ptp_hwtstamp_set(sparx5_port, cfg, extack); } static const struct net_device_ops sparx5_port_netdev_ops = { @@ -238,8 +253,10 @@ static const struct net_device_ops sparx5_port_netdev_ops = { .ndo_validate_addr = eth_validate_addr, .ndo_get_stats64 = sparx5_get_stats64, .ndo_get_port_parent_id = sparx5_get_port_parent_id, - .ndo_eth_ioctl = sparx5_port_ioctl, + .ndo_eth_ioctl = phy_do_ioctl, .ndo_setup_tc = sparx5_port_setup_tc, + .ndo_hwtstamp_get = sparx5_port_hwtstamp_get, + .ndo_hwtstamp_set = sparx5_port_hwtstamp_set, }; bool sparx5_netdevice_check(const struct net_device *dev) diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c b/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c index 0edb98cef7e4..5a932460db58 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c @@ -74,10 +74,11 @@ static u64 sparx5_ptp_get_nominal_value(struct sparx5 *sparx5) return res; } -int sparx5_ptp_hwtstamp_set(struct sparx5_port *port, struct ifreq *ifr) +int sparx5_ptp_hwtstamp_set(struct sparx5_port *port, + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack) { struct sparx5 *sparx5 = port->sparx5; - struct hwtstamp_config cfg; struct sparx5_phc *phc; /* For now don't allow to run ptp on ports that are part of a bridge, @@ -88,10 +89,7 @@ int sparx5_ptp_hwtstamp_set(struct sparx5_port *port, struct ifreq *ifr) if (test_bit(port->portno, sparx5->bridge_mask)) return -EINVAL; - if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) - return -EFAULT; - - switch (cfg.tx_type) { + switch (cfg->tx_type) { case HWTSTAMP_TX_ON: port->ptp_cmd = IFH_REW_OP_TWO_STEP_PTP; break; @@ -105,7 +103,7 @@ int sparx5_ptp_hwtstamp_set(struct sparx5_port *port, struct ifreq *ifr) return -ERANGE; } - switch (cfg.rx_filter) { + switch (cfg->rx_filter) { case HWTSTAMP_FILTER_NONE: break; case HWTSTAMP_FILTER_ALL: @@ -122,7 +120,7 @@ int sparx5_ptp_hwtstamp_set(struct sparx5_port *port, struct ifreq *ifr) case HWTSTAMP_FILTER_PTP_V2_SYNC: case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: case HWTSTAMP_FILTER_NTP_ALL: - cfg.rx_filter = HWTSTAMP_FILTER_ALL; + cfg->rx_filter = HWTSTAMP_FILTER_ALL; break; default: return -ERANGE; @@ -131,20 +129,20 @@ int sparx5_ptp_hwtstamp_set(struct sparx5_port *port, struct ifreq *ifr) /* Commit back the result & save it */ mutex_lock(&sparx5->ptp_lock); phc = &sparx5->phc[SPARX5_PHC_PORT]; - memcpy(&phc->hwtstamp_config, &cfg, sizeof(cfg)); + phc->hwtstamp_config = *cfg; mutex_unlock(&sparx5->ptp_lock); - return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; + return 0; } -int sparx5_ptp_hwtstamp_get(struct sparx5_port *port, struct ifreq *ifr) +void sparx5_ptp_hwtstamp_get(struct sparx5_port *port, + struct kernel_hwtstamp_config *cfg) { struct sparx5 *sparx5 = port->sparx5; struct sparx5_phc *phc; phc = &sparx5->phc[SPARX5_PHC_PORT]; - return copy_to_user(ifr->ifr_data, &phc->hwtstamp_config, - sizeof(phc->hwtstamp_config)) ? -EFAULT : 0; + *cfg = phc->hwtstamp_config; } static void sparx5_ptp_classify(struct sparx5_port *port, struct sk_buff *skb, From patchwork Tue Aug 1 14:28:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13336832 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 B8A09C001DF for ; Tue, 1 Aug 2023 14:30:17 +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=LglNIGcLIbrjItsnCm/82u/ltSn75qcYifOn0ZjQCCk=; b=sISZdnWdYwH/Lr 4tNDVS4fpm0quOjuu6NZR7oowf1yaM6ujjbV84WtnYKLzJkue0qmkSkxuDCR1xDZnwPCxbBZMcdhQ VTHp9vrFdcTsjczQzqEfODH0RuMnv67TxW4974PVlIhrrK0vCfP9ZrTCi2bEFlWZsTdHwg19/C94L KFih6IPFOIp0mF6Om1tsZO7soIQUbqcJE3FYIDjOdwgQN6YYIRXUOl1Lqj8znQOPY/TP0pZHLAkfo FzBb+lyUHNQVKHeO2L1IjhgkUbB/Z8tkQrQucs/wPAo1PmZv9W2nBZPdIrjPHzEvvg1wrqMa7StYd 0Ew2mCxokVircGxDD6lA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQqNi-002aQj-1t; Tue, 01 Aug 2023 14:29:50 +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 1qQqNg-002aEd-0I for linux-arm-kernel@lists.infradead.org; Tue, 01 Aug 2023 14:29:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RCLWwyE7R7mNHHxxUDvrTD79PqKKpzIBRZsHNW2PYyovtBzzS7I7QvBnhSFQA3OHfkeEGS0Cm2eIi7poF+D18wOutKneXEKzifmVtlN0QGRJOem9ic3qsedtK6isRn3YDCrGwhPIlthz/zO3ZaaAG2dCw6GrDpGq0pJbNTFBwxTfq/uLqwAGOhFfWRzw6phYc3tghfTEY1Lw7pzgLgpWc7G8m6XM/gWDuVRJVMFZgxb2k+yx8UZgj39UYsad6ikX1T1iy9aRZOFV10U3RyK3oyXr6TSjbd/C+CClClr2iPualQR1/ZhLASd7hxdr/RaizKiM5PdwlpZe8y4qgC1lBw== 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=jJcUSryWsFMQxeFJGDP+4inqyL1GXBMzoKsfMRvbbq0=; b=cF1uPOJhz5WYsI0LrbHiE3nXhOU8I8gdLyX1DQ9F1y1DCYQVV8+ipci5J5gOlxWD+TjmbTgAfJk5cD00tFnsy6tpjbJgmT9Q8MYljoTuiMbwOI9+9vpET7XIp42mhuMPMP8TdMsPT1ZeW9kWhci/TswWTIsIaLxWjX/xkxTaJalMgZBdM+hMdcS9PgV2psLDjSzVv8TQUR5CNyV8Y0CO3CDJ1ryoW6SzE+5IvEEq27a0edJ7Frz/oVjaSbxKyk5t6i3hguF9cwuuAyjlYQX4XnrK1nGiPfwXjkQAHM7Vg2pL9Q5VTwX5iZIql/yrpgo02VKmr2nIBECvNnw7gkS3Bg== 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=jJcUSryWsFMQxeFJGDP+4inqyL1GXBMzoKsfMRvbbq0=; b=TLDuk9V9nB3sObHe7bDzT4OPHZqqujJap59sAQuF60BJnCBWEUxhI3gYvb/QlLz8l8ymEXhb9srYFqjhEd4Vqr6wj62SJSYN8YTJfembPA4wNfVpIGVcl2zERYQwhaD8GJw1iUC+B3mN1VemkomeDGAYiQd/OWEXWENEYXhxFYg= 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:40 +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:40 +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 09/12] net: lan966x: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set() Date: Tue, 1 Aug 2023 17:28:21 +0300 Message-Id: <20230801142824.1772134-10-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: f5cba74d-965d-499c-f615-08db929bbd68 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TJvZR9QrFytH90ZeZ8DYG6oOj8iBus7Ld77L0gX47ZX67JGx42LvgRFSgA2NnSv4W9jz5Ab+XsF5OTfhbJ4ZtWX2lFL4bOhC+WXB2muAQytIIG+xedI15qLb04ySdl+2/YmmChDyDKjec0+X139fdA4fr1CUQv003OtOh4Hh0U9Ofhaf3RNclna7ugNwN8VD1dBuG83ushVzcc5ta0I5XsV1sk5R31ex1mn7bp0ZDr6Vp0en9+ac6IEDQGnFaVwYQFyGd3wrjycluIWThF44GceDHL45FrdT8yQkU4qxgfAS/EGc9yPmN6oypxkxQPlzgKzYIagwfb4poo21fEfts7rZRrLNt0dzvxDAaWVHcZ8UKVwSvi7Dw3A1qdBk3/xdgKVXSxApUQSoAMEnZSMvEaSGGvx+MYSQ5ltd2Yy+Y4nDrv2PW01z9m8zvJyS8YDhCTcUo+27SnTx1oO+78xecRLWlLHrzQ7OLSI7JVH20+BNZ1r6OCygLjzj21oaxlpDagtRZBfVg+bSdkQXCFPpPF7+qZu+jWqHXLIZ5QQIG0PaW4dLZFMXJ6+ZLv0bPMqVWsTCru6XrrZBcO8aro0IVODh655nrsKagwn8Sdu4puefX8dptcQmdU1daCkdYiAlGP7FpMjhJNip4JiF0baRLg== 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)(334744004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: v3NrxKV5fDbRV/HTOBzDKb+Cr5jcFd4w74wqAp0frMIJLDjpNdbkzc0OYD/3Pi0eNZwZSs/jtN0EzYouKtTWPEthReCPbxXrGXZgD/+IvWqcnMKPIRQ5UlF4KU5NQOJmJZ9U8Ap7Q5G3lQXn4nevLCoRLF4tbVyi+TcFhqDaUo1pDTJ171s6A7ep1wuqupHlycWs8Cq2oorDHeW+fZMjQdILMQQHH9VmJLI/KcM5WZTnu32i1iKs75XCbOKWQ000PcGpxM+taSt8sRaUyGGJwWKTz4/5duOsMB3kcZ5xatKkobRKeFnpjIgxWAWnJ1l1sIlj8uRf5eWNC+TwFjXN/u15MwNIThq6M+toDIiuUI7oiZJyuwHO7/CRZvWLAPoaQ1RCyPoHTNAV4fZYepv35Gd3t3tkzjjF8i2OTNWmaCNAi+g4tArWybGNwdOVkhUz6yrNLLpXOhmaBM3cYmWU1fX9EA/exz66XE8G3NmesyXDAcbtywmAp84CSJT3we5NXEYwKvKYvokU/uWy8oeQjRKy1tJfbEdYSALZSHIwCKTq+X/S6g79uCKF3+QA2eUOSWDBnE2CBCA9aDQWWWOADJLdgiw1Y5o0PGE30MRmutPao1iE6cwiScVs4WtEiLGj9BkItJrncPh8CRJivw+Z60K22ckduWHDXgFMCqIwyLAOcV09IvqyoJspNejdh404ombcMr3ZnhPcRvxwHx+zqToHSMe/HigGL3H60Oo9x57iFhPBgx3CEOcH9ipua5fuPEtnd+jpeHXMg9SMZJELurEa7VvfXxWne/gt5OZ6fk9dUmG7VZfe41Zfl+FFFxWd5tWnIZTh5fVeTTn7YISqkuZ7UDIVZejn20Zv7CZCJ+pKY0prv+eRy/P9xDfDJIBhisLnEQJLW5WwiiUHQ8JkUGAbQWL1C2Jufi8fGfV3PJV1EJjlNATmulP7BjWtOclyUBJgjb7Y1M+5fnweagENXPYcPbsqOVgyC6mz56//fu/BBAapx+gvyHFBDyKywpuVbusdXb/HMixS9O37aYmL05cxDs7mcHlrLxZ44KkTiZaY0LQhZGrMVTLYY2O7gXRpFNq+KFRB/JB0DKfbPSHjFHFZVn+f+MxpR1RcUMI1SC+NbUKbT8qKJCbc5By3FDVhfRfstwSAKL0oOcP+MqCFkEOtfx9kVmweenA4JU/Em87Uj2J3QgyPEgl4EMbSFHQqeTSf8jac/nxaJ6127W1N/7okMD2Llr8PDiqqt0ZUQDS5Mj09kX9X6m6TxwTlObjGX6KyYXFngmr2A2n89VLH8sgJ3nxLET3+dNKlAWZ3PUabX8gXpWWxWeb8fZosZ1zQD2W7/DcsQxGeU33XxHCBzDY3zgn1ENahcM1o5GSirIF3FAeX1+SABUNe8JJO4kiBW4Qrntqv+8WdfOoMI51KHBJC5vgZifwY1lowXnjM1eEiYGTNDby8qz5mdaqwCsbG9zMhcOqj08rleiFug19bXHqAXgCuzDu5onDnQo2QwvEbV0OcXYmrEcT0mpRG6D0uEv6B1ElriYWprCA2KXKsUMS1B6zocVoRX1zIzM/U0ztyhhDk3GqvgDbPgx2hPWEsjBaSsLgGnGIBrS2PAWlN4A== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f5cba74d-965d-499c-f615-08db929bbd68 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:40.0168 (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: PS6or3bFEnC3jt56m0pmdk/ace10FLO7zW6PPKhhe/HtMrXy53pWvCi7Jij5BZJ/k5YE3KN0Qh8o8EEovKIcBw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB10028 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230801_072948_260540_F89CD4B8 X-CRM114-Status: GOOD ( 18.93 ) 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 The hardware timestamping through ndo_eth_ioctl() is going away. Convert the lan966x driver to the new API before that can be removed. After removing the timestamping logic from lan966x_port_ioctl(), the rest is equivalent to phy_do_ioctl(). Signed-off-by: Vladimir Oltean Reviewed-by: Jacob Keller Tested-by: Horatiu Vultur --- Changes in v9: - None Changes in v8: - Use phy_do_ioctl() Changes in v7: - Patch is new .../ethernet/microchip/lan966x/lan966x_main.c | 59 +++++++++++-------- .../ethernet/microchip/lan966x/lan966x_main.h | 12 ++-- .../ethernet/microchip/lan966x/lan966x_ptp.c | 34 +++++------ 3 files changed, 55 insertions(+), 50 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c index 73f20683210e..1baa94a98fe3 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c @@ -450,39 +450,44 @@ static int lan966x_port_get_parent_id(struct net_device *dev, return 0; } -static int lan966x_port_ioctl(struct net_device *dev, struct ifreq *ifr, - int cmd) +static int lan966x_port_hwtstamp_get(struct net_device *dev, + struct kernel_hwtstamp_config *cfg) { struct lan966x_port *port = netdev_priv(dev); - int err; - if (cmd == SIOCSHWTSTAMP) { - err = lan966x_ptp_setup_traps(port, ifr); - if (err) - return err; - } + if (phy_has_hwtstamp(dev->phydev)) + return phy_mii_ioctl(dev->phydev, cfg->ifr, SIOCGHWTSTAMP); - if (!phy_has_hwtstamp(dev->phydev) && port->lan966x->ptp) { - switch (cmd) { - case SIOCSHWTSTAMP: - err = lan966x_ptp_hwtstamp_set(port, ifr); - if (err) - lan966x_ptp_del_traps(port); + if (!port->lan966x->ptp) + return -EOPNOTSUPP; - return err; - case SIOCGHWTSTAMP: - return lan966x_ptp_hwtstamp_get(port, ifr); - } - } + lan966x_ptp_hwtstamp_get(port, cfg); - if (!dev->phydev) - return -ENODEV; + return 0; +} - err = phy_mii_ioctl(dev->phydev, ifr, cmd); - if (err && cmd == SIOCSHWTSTAMP) - lan966x_ptp_del_traps(port); +static int lan966x_port_hwtstamp_set(struct net_device *dev, + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack) +{ + struct lan966x_port *port = netdev_priv(dev); + int err; - return err; + err = lan966x_ptp_setup_traps(port, cfg); + if (err) + return err; + + if (phy_has_hwtstamp(dev->phydev)) { + err = phy_mii_ioctl(dev->phydev, cfg->ifr, SIOCSHWTSTAMP); + if (err) + lan966x_ptp_del_traps(port); + return err; + } + + if (!port->lan966x->ptp) + return -EOPNOTSUPP; + + return lan966x_ptp_hwtstamp_set(port, cfg, extack); } static const struct net_device_ops lan966x_port_netdev_ops = { @@ -495,10 +500,12 @@ static const struct net_device_ops lan966x_port_netdev_ops = { .ndo_get_stats64 = lan966x_stats_get, .ndo_set_mac_address = lan966x_port_set_mac_address, .ndo_get_port_parent_id = lan966x_port_get_parent_id, - .ndo_eth_ioctl = lan966x_port_ioctl, + .ndo_eth_ioctl = phy_do_ioctl, .ndo_setup_tc = lan966x_tc_setup, .ndo_bpf = lan966x_xdp, .ndo_xdp_xmit = lan966x_xdp_xmit, + .ndo_hwtstamp_get = lan966x_port_hwtstamp_get, + .ndo_hwtstamp_set = lan966x_port_hwtstamp_set, }; bool lan966x_netdevice_check(const struct net_device *dev) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h index 27f272831ea5..b538d496e8d7 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h @@ -298,7 +298,7 @@ struct lan966x_phc { struct ptp_clock *clock; struct ptp_clock_info info; struct ptp_pin_desc pins[LAN966X_PHC_PINS_NUM]; - struct hwtstamp_config hwtstamp_config; + struct kernel_hwtstamp_config hwtstamp_config; struct lan966x *lan966x; u8 index; }; @@ -578,8 +578,11 @@ void lan966x_mdb_restore_entries(struct lan966x *lan966x); int lan966x_ptp_init(struct lan966x *lan966x); void lan966x_ptp_deinit(struct lan966x *lan966x); -int lan966x_ptp_hwtstamp_set(struct lan966x_port *port, struct ifreq *ifr); -int lan966x_ptp_hwtstamp_get(struct lan966x_port *port, struct ifreq *ifr); +int lan966x_ptp_hwtstamp_set(struct lan966x_port *port, + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack); +void lan966x_ptp_hwtstamp_get(struct lan966x_port *port, + struct kernel_hwtstamp_config *cfg); void lan966x_ptp_rxtstamp(struct lan966x *lan966x, struct sk_buff *skb, u64 src_port, u64 timestamp); int lan966x_ptp_txtstamp_request(struct lan966x_port *port, @@ -590,7 +593,8 @@ irqreturn_t lan966x_ptp_irq_handler(int irq, void *args); irqreturn_t lan966x_ptp_ext_irq_handler(int irq, void *args); u32 lan966x_ptp_get_period_ps(void); int lan966x_ptp_gettime64(struct ptp_clock_info *ptp, struct timespec64 *ts); -int lan966x_ptp_setup_traps(struct lan966x_port *port, struct ifreq *ifr); +int lan966x_ptp_setup_traps(struct lan966x_port *port, + struct kernel_hwtstamp_config *cfg); int lan966x_ptp_del_traps(struct lan966x_port *port); int lan966x_fdma_xmit(struct sk_buff *skb, __be32 *ifh, struct net_device *dev); diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c b/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c index 266a21a2d124..60bd0cff6677 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c @@ -248,29 +248,23 @@ int lan966x_ptp_del_traps(struct lan966x_port *port) return err; } -int lan966x_ptp_setup_traps(struct lan966x_port *port, struct ifreq *ifr) +int lan966x_ptp_setup_traps(struct lan966x_port *port, + struct kernel_hwtstamp_config *cfg) { - struct hwtstamp_config cfg; - - if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) - return -EFAULT; - - if (cfg.rx_filter == HWTSTAMP_FILTER_NONE) + if (cfg->rx_filter == HWTSTAMP_FILTER_NONE) return lan966x_ptp_del_traps(port); else return lan966x_ptp_add_traps(port); } -int lan966x_ptp_hwtstamp_set(struct lan966x_port *port, struct ifreq *ifr) +int lan966x_ptp_hwtstamp_set(struct lan966x_port *port, + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack) { struct lan966x *lan966x = port->lan966x; - struct hwtstamp_config cfg; struct lan966x_phc *phc; - if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) - return -EFAULT; - - switch (cfg.tx_type) { + switch (cfg->tx_type) { case HWTSTAMP_TX_ON: port->ptp_tx_cmd = IFH_REW_OP_TWO_STEP_PTP; break; @@ -284,7 +278,7 @@ int lan966x_ptp_hwtstamp_set(struct lan966x_port *port, struct ifreq *ifr) return -ERANGE; } - switch (cfg.rx_filter) { + switch (cfg->rx_filter) { case HWTSTAMP_FILTER_NONE: port->ptp_rx_cmd = false; break; @@ -303,7 +297,7 @@ int lan966x_ptp_hwtstamp_set(struct lan966x_port *port, struct ifreq *ifr) case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: case HWTSTAMP_FILTER_NTP_ALL: port->ptp_rx_cmd = true; - cfg.rx_filter = HWTSTAMP_FILTER_ALL; + cfg->rx_filter = HWTSTAMP_FILTER_ALL; break; default: return -ERANGE; @@ -312,20 +306,20 @@ int lan966x_ptp_hwtstamp_set(struct lan966x_port *port, struct ifreq *ifr) /* Commit back the result & save it */ mutex_lock(&lan966x->ptp_lock); phc = &lan966x->phc[LAN966X_PHC_PORT]; - memcpy(&phc->hwtstamp_config, &cfg, sizeof(cfg)); + phc->hwtstamp_config = *cfg; mutex_unlock(&lan966x->ptp_lock); - return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; + return 0; } -int lan966x_ptp_hwtstamp_get(struct lan966x_port *port, struct ifreq *ifr) +void lan966x_ptp_hwtstamp_get(struct lan966x_port *port, + struct kernel_hwtstamp_config *cfg) { struct lan966x *lan966x = port->lan966x; struct lan966x_phc *phc; phc = &lan966x->phc[LAN966X_PHC_PORT]; - return copy_to_user(ifr->ifr_data, &phc->hwtstamp_config, - sizeof(phc->hwtstamp_config)) ? -EFAULT : 0; + *cfg = phc->hwtstamp_config; } static int lan966x_ptp_classify(struct lan966x_port *port, struct sk_buff *skb) From patchwork Tue Aug 1 14:28:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13336831 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 3F66BC04A94 for ; Tue, 1 Aug 2023 14:30:18 +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=CFsEql8JWomBIbamK8qSSeMyxIqW49+qDaoY3lPfCds=; b=yZja48+JobJoGR fJiLJA6//jW8KHVPmxpQimIj3eeZtocj/HksjPruyFVf5mZ57LJwybf/wPY2WdsLKYz2+vBCtb6L6 lfo/xGzwJxEY5Q+yhZlizUqF70ahC5bTRDPQn0y8PED940JqTadwMhUcggFL/+iRS2n6dNRJ4J5WZ 6xRmII0Iw+56YHgh9AhrGWpv7NHVv+Zk0RrqpMEPQ9BxBQt3QEqfEwRH+Pj/yWJreXwO91Kyof2HH rnSi5B1bYnQykiDhltFIDrDdKGqJI7VXjzv7njldedHITFkEvBrGHJ341Z47EJqF9DZkJcKJq9SLD 4wNw8+gPQnEeyxITyKiQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQqNk-002aSU-2v; Tue, 01 Aug 2023 14:29:52 +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 1qQqNi-002aEd-1L for linux-arm-kernel@lists.infradead.org; Tue, 01 Aug 2023 14:29:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z8FWlOifJxbYOaufSY9oiJpNPbOtKD9OIQTFh5PvPF9wGnA8TEVbIxKOYDo1k86hS0dsWwT/P5Iw+iPyev2rApfeXODPwu40lLYb6lyTelmPyNtzZcR2nCEvx4GIqMxQZewcU82gAqptVVAO9vlc2MiWiQJDfwrlX1KWRd+ifDui+YVzEVD9riEXzao32R4HrwbqW7bJV7EbmgOL90RTUSkJNLVoRu8OnCgGvILT1Ru7C2gn2ZFubgmNa06V3TKVk4WOAYyqseYhvVJ2gDdPp6xZ7JuV1tTcpe8E6bO9m9Zhe06jpBds8G2E1TD4jEz5Om+zHRGyPGquqKbIIs6jHQ== 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=63i4RIO0hRqAdpqxIzyNOwO1JsLOxgr196bQsQPuJ6Y=; b=M/m53WsJay9vg/oK8lm/lenDB2P6TKICfnUSs/0Jzjtbl3YZig/ebZ4vIN3BRCBMAGld2+mVNcnaTbsxi0R8v96hrF5D8hfcY+9RQuZ/kwElrdhIS49cOUsoBWndSc5JvaBjvn9l22RFYR4dtROh/ChVmUZsE0eD8RZAx2KtBkgdm6tCtDoz0YOPJDEBJbPMKXt+Dkvvit7jjLlIDi8nY/JOe8lbf2WDQrz21X5geAjR4imHv4xd08mxJXh+75Fhvby5CY01R7qLGueawRT4vYWmsGTbtEJFVgy9D6Hql1Ad76jol5FLq+KgDxh2rattyve2bWVhlqwjsySP+pnAlw== 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=63i4RIO0hRqAdpqxIzyNOwO1JsLOxgr196bQsQPuJ6Y=; b=n7kIw30rsNXjn8Ev71hmQsQfbPw6b3ueaHxi1y6ACT7C2ggmtoTWEw19PMV3B4tTIIJCGtLgP4YhRvtEbOO5wF7QoKJX2z2F61/wYdKglk3PNBQSvuwuUKykzDVmtqDgUKSoPSXQ74CPFEEgkEBycPk99c7Y6DPaMbbhaWIkq4k= 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:42 +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:42 +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 10/12] net: transfer rtnl_lock() requirement from ethtool_set_ethtool_phy_ops() to caller Date: Tue, 1 Aug 2023 17:28:22 +0300 Message-Id: <20230801142824.1772134-11-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: f42c4530-c5c8-45e9-f855-08db929bbe92 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: W9lyGaZEldL6SJA0qHzRwa2XzBbdNtY1PqR+uCiBKJ3MDT37Rig432T1tdWmYHtaPfeWo1+6c7NiRJRfq0lIP9BNCz1oS5ZVGI0qCZpXLpfCU3iACaYiT0ifIzJijnTezosJV6XsndS8v3r89D/7KB8mKn9WFt+nQHyspaxTi0fG/96Cb5VOhLHhQfyEaBT+WgkHMIXrmvBGbeFvl0lO0rM9VfIYJvUnlz9cUR4XUiqCI43kmlf4vIWTdOrqWzl+wlogM47GLokGCcCg2WTtVAr8YfoUsZd5Qk0T40B2ndxh4GQus8Z6ek0tDy5wY/FuqBli+HxDOdmKQgQW3uDGvjvR2/p5zOo2mXHGLnvVJ+TR39aJwPh5nP4HLGI7sMefXu+Fv/HhZye1GR38esTZvzALNmgSmG+YqcZcoAiZna0Cy/x7qgKmxR1M8npDbtuzQIeoaRqomqRARk+w9F3z3bVq1L1c0oq4HgF1NcyewcTlPXwmp3/U1VKs/di6Pe6Uj+wzvNabcub5PjFhFcyyLp6N/wPyvlCwXz43k9TOZwv9J2uRGhLCgfHwfN73iUEUiZGvZnNynmifFFmvz0ypgFgHmIX9cKjXlIxxlz9q52Z9mZOze6yn0/JE9QaT2y7s 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: 7TS74d4mUtkRc4jqGMZufG4sHrqlqKmtR8mciPa9S1cMNoPkMO2hhNe8qgV5gtDgXprgxT9JwjzkaiV6n2KRyv6F+H23Sz9EF35Ohamoge5BIilwCMEWbs56wLcHiwR8wkkr7e+1LM1Up6CzgUWSdSZ0sg0Fw6UJFaHp5tZZ6FdOHPagiU04XcQpwT/FCut/6ks/0S3vrOVKp4OO8Xz1+v2CILKTGjORD5ZKDafrImoIS9WbrBK/hlK38qMvztjKjgBdpkGT+5dVle1XbLx8Lblgh10gNQkiShOTwqas0oeAuaDd8X/4asgKpFkcW5xbUUR4WaSyezhu84KkuVUvaxQGYbJDWPsAkOpVCMvR1M0P1zxb9vyuCJ+7vivh5MANs7CPcrWQVF+ch4MxM2RfY0GMbYSYAqiApkCX4VTNiNpEkfB1v8WZQ1tEXagk0uCYKLpwixDG9ROBj/IS/pHtVwxl2Mh87UqnVlraeUvB6yVSKceLWPbUpeqqYStgW4fqRuH1XFck4vQkkd2RbTTDvsP1BT14m0edkA5nRrk04FjDbBKEUBIagWeA/leXw7YVoBLBrl/EAK647VnmIYc9MP5oiK167zPqySTcFVs0NlTl/oJEKuOl6aW0U+GAN35oIeo8GakRWVg4oKZezoq6hNH1dlzXHDEG2qVo7BeE8JziylGgM9KEws1sF2S2h62Vv+QfqN5bz88tWjg4DBuX79M2C3W65f58KBzE3eCNLeYpZWiPGSIbE9nhf9NbH/txfF8CVrsuMMAaWYFw5adCkGaWBrPZA1w+qw2e4O+o4yPetNAWLnLuNtVzntAEI4PAJEEtdf60JhGUpESg2c1laPjeN78ZK2y6cuJBOfFh1qa0suygxeusj3p8759qxUWYdKWhkJkZ3Kpej4mD10b1TPaSQVmi7vd0qf1bl8/S25HSFq6IXxGQaFFzPwsO9idLQVAm8GK8SV8VsTwwh/06I7Yb2qnsIvF0cgjos/XtFHegiIH+8BeJXpMoXDaXQPNJ5njUSL0tFUf6YlgFnxc9qHrxJNi1LlRRSVX0XxK5IFS5ZVReCXAPNip6o4IcIN7gnkzRrOQ16M4ZUjgADFjhFSf0U8H1IeZTD9QQaNMJxCwhQHDdbcixPVCBUgE1S+imhPuPB/UUaBcfrhp2sEu9nuC7bT0ElB1cHbKiDZG9Ud7bxGxVy3vDEpa6gC/2tf8GrcH4ET30dg1ave8TCWEnyZjmzRzimdiuPGRXoosZfgE9BoJjHWEo72W6iQsji93Zp/6ZjDF3M3jeRjxamIYwv0XpEyLwePH3BybX5ZkaFseH+d//KPSrk5umETcb8hv7LhXexyBrgshN/A5A4o/YjTveJlUKVS4sgtnwclkxyvWu3NVoD7XIwsCY7EyGONYWPkAnd+hJX8x1oXGyCQacSH9fa8On1Ew16iA7XmTp+1JTSBgs194JWXayWQxk7I1IqrB4vMfN4zUPujec0iFTMNb8URDPwN3fR4AN6SJyX9/gblaqAeAH+1GbPTt9ymE2+eG6TUlIGYOtohkDiS3MaMK9oN+sDICOPb4RS9nEphrAq57bHmwkY1OFXhFd0o7Q4Zu5CEO0jwHBNBWLiyB60g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f42c4530-c5c8-45e9-f855-08db929bbe92 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:41.9508 (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: zZ/dKAaceddiaqDhbVUGwSb/K/ORzdXN9SH3uOFYuwhwvh2YE6YHB0lFLvh/Q/K9X8QccM2Q4QNLupVW+le0Vg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB10028 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230801_072950_459556_B763512B X-CRM114-Status: GOOD ( 16.45 ) 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 phy_init() and phy_exit() will have to do more stuff under rtnl_lock() in a future change. Since rtnl_unlock() -> netdev_run_todo() does a lot of stuff under the hood, it's a pity to lock and unlock the rtnetlink mutex twice in a row. Change the calling convention such that the only caller of ethtool_set_ethtool_phy_ops(), phy_device.c, provides a context where the rtnl_mutex is already acquired. Signed-off-by: Vladimir Oltean --- Changes in v9: - Rebased on top of 1c613beaf877 ("net: phy: prevent stale pointer dereference in phy_init()") Changes in v8: - Patch is new drivers/net/phy/phy_device.c | 7 +++++++ net/ethtool/common.c | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 61921d4dbb13..98b8ac28e5a1 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -3451,7 +3452,9 @@ static int __init phy_init(void) { int rc; + rtnl_lock(); ethtool_set_ethtool_phy_ops(&phy_ethtool_phy_ops); + rtnl_unlock(); rc = mdio_bus_init(); if (rc) @@ -3474,7 +3477,9 @@ static int __init phy_init(void) err_mdio_bus: mdio_bus_exit(); err_ethtool_phy_ops: + rtnl_lock(); ethtool_set_ethtool_phy_ops(NULL); + rtnl_unlock(); return rc; } @@ -3484,7 +3489,9 @@ static void __exit phy_exit(void) phy_driver_unregister(&genphy_c45_driver); phy_driver_unregister(&genphy_driver); mdio_bus_exit(); + rtnl_lock(); ethtool_set_ethtool_phy_ops(NULL); + rtnl_unlock(); } subsys_initcall(phy_init); diff --git a/net/ethtool/common.c b/net/ethtool/common.c index 5fb19050991e..f5598c5f50de 100644 --- a/net/ethtool/common.c +++ b/net/ethtool/common.c @@ -665,9 +665,8 @@ const struct ethtool_phy_ops *ethtool_phy_ops; void ethtool_set_ethtool_phy_ops(const struct ethtool_phy_ops *ops) { - rtnl_lock(); + ASSERT_RTNL(); ethtool_phy_ops = ops; - rtnl_unlock(); } EXPORT_SYMBOL_GPL(ethtool_set_ethtool_phy_ops); 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 From patchwork Tue Aug 1 14:28:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13336834 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 9E063C001DF for ; Tue, 1 Aug 2023 14:30:29 +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=8Z05W8D71RIN02/JBUTvEZntsmciQpwL1Wrfadw840E=; b=d64CO8QNu4Diwx DFVffafcqNaCe9TEPmqffa6n/Y3GFw3RQ6ohIdMWpLumweyzPISKK+/wNxL8GakfjX8oqrti3VZhA Aw7IxV36YxDEEAS+brw7EsyToiV4AoRpZu/K7OSS17UhFfbRfedrVr0elIZ0ckYg1+xTq8fiFK741 FvR61SZX8a9PSB6eTUg4VtqoX4+rppwwIxyYcOqwGkutOXV17c61PBzYot1+0PyUIF2viQXTrsuTq NcLzyUQh7FI2BKZVnIz3//SEgGrKPCohxTvO1mA5j9SqEj0oGpJa+DhA6A5VWU8qp7s/J/pmCV/tC 65DhqLOg+bJEXdjONxvg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQqNr-002aYX-0P; Tue, 01 Aug 2023 14:29:59 +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 1qQqNn-002aEd-1H for linux-arm-kernel@lists.infradead.org; Tue, 01 Aug 2023 14:29:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CAcaEnlCZbOQzdtlr8i9OHTG2KCA3kGFYj/A1DGsRbaiNtZigwL6gvaqxWUC3supez1NsPchaz/vy/Qk4yr0vPpcPdCxo6uxtCCOr0YEWjtsLLP0JpzzEJxunSjW9JGAzrBaXjlD+CIZmk4wLC7+JsQn992lgNLOiQm516YvEYyZOV6XfQE+BHRE9pz1UYbOZKE/s0CcL+wUQLFgwe9EOINscZyofXxRLcGodSJ2+i3p6SKKmHN/ry6R5OCXURAcP+g9B4u95DmH6nBVbowDgepKURFrRjQJa7lXi7wA9ti4HKzkW7FZCE/oL0DTKjxtlZXs86p4COlSmVviOAeg5Q== 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=2n64j6o4cj4g9qgaV0wW1MYChC5igOKRV6/Lh8EsK48=; b=LPGBQT8VQgWJ/OtbaedVkQDHVofS1R1Oe8bCXwGME5UEseFlP/ijxd724+px8f41oGuBj0IbevYrP6X9cJ3YPY6uCfpPL/LbCNugt8i/ZSvWUeUBdbqq46KIr8H1D/YM9j4pi10R7LboYRhXL3caEY9R94GG+XV/FWO5M9nkBf/mRjA2F4hiJrY+dEA+rJb34Rb68AZnPlzd/fDAqYhmjyOiWvp3of+hLQUaiqR6l/dxzDzAiPIMmqbt0fcSO+KGiQy8HO/cUDxO7CEHXW6lZZqHOJkJxipllTVoHyp7a6v3FGm7bdrcfz/r/aS0ON2VXzOr91354y2XK3983oJbqg== 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=2n64j6o4cj4g9qgaV0wW1MYChC5igOKRV6/Lh8EsK48=; b=VwHF9bR9EBz+1c7dfgmdU84gLjoBgbiUQ96yfODGUDJqx0nTYz0sbxdCeGVXG8VJSZzgO/d/EZqIZY+aYlVMR0OP7jB6ZZZgAGdqsuXvDhzTXBzY9SWjPNpIbY3rVkYY7D0lZ3cGrHYFDl4Do3SRpJf7bYujYno0FshmNKvQYLc= 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:46 +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:46 +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 12/12] net: remove phy_has_hwtstamp() -> phy_mii_ioctl() decision from converted drivers Date: Tue, 1 Aug 2023 17:28:24 +0300 Message-Id: <20230801142824.1772134-13-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: 6174c0f2-5956-4032-d3fa-08db929bc0fe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kH7yFCFORTRHs5cMy0YARXe+jeE8ktiySsfs0uZSaXJROwNnwvwL9rQBK86O44XZhIYp5/WCHPhY+RgHUbYm9FQDY5qtrC78QvcsuqaUZdefzslPy4SMwr6MWXb7atcjLZzY1fp1kLGpz+tigcN2Lx4vkz0KrxF1lr1s5AHo5DoMQGQZBfKyD28J0T/R2zWgCGDt/V1Bfwrj/Jff4SIRlJh4Y5IHIjAi7Gl7faOFfGibdJd87yDa4BXpqhe0nNIGWCQB68iljYYBDuky7lX0G6SVtOjjjbJ9EzeIho8DbgiqHt+X/cFLERj6PhCzNSkl7b/9WGFERyOauuSXf3JqEwgAcj1H78VskVo/35oC8tHvw9v6VCo8QswzaSbZ8VpicqELDlIbe5JINi2EzVkh5t1V2Te8qrxAUjA6FtKvav6F11oTxv+NIsylS9ssQHK7fglPMmll6z9PMmmDlqzAWx53u5JfhSFQ7qIemXSjnC4oSa3DcOOfgnZyGvWpnC8JKoBgW8MBp4C7S2+Qh1rM/RGRnXMmbhkGILuOcxhh4DoYACStllHRK9jTq0ZwTTYqIREUs2sOSLBIO/XdEHqFdCrxZiMEr5prV7/wafltUDsj1qu/951zcwD1QdRbUa5L 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)(30864003)(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: eFtoCavEKA8l3Txev3M0my2Ft18LSPrgaylNB4kHjA7dXtCPKb2os7+2ZGGMDUZeP8daQLs8nqb5dFCt8U18xrCavPb+QqjImiJ1im0KL/ACXTGhoF4lv3mv/qrDIpwUhDLNI7J51MR9IA0WyziVSeMUyl/GSaPR7CW3Ewgwy0C04Ao88LbYTZRavHKZV3whR4q2Zn301JxdMCl+2esDP/SHTxwL9PiwDdr/M5uf3sSVIx8fBtTyHL54rJt/TGHIW3Ph+lOXvnS86GYEEIpzlzI0lwxA7Lq2KVjubyBZP3TQ/d3xs11vBeM6+9XI9h0Gb7IeyTPqjRhOeo633rAntYoi5tTMqvz4SgrR+NDPcbfGOwhf+8ldEb7DQmkKCX4Qmlh8AdzoIENownRJhsaSC5+vOJM6nrfM2xNVcGW/WP5u55F3GFZVXq5KtcY6cS0xZzxr2VhoTZkEmM5ggNJRRfR09614mMDsAuDE8JRv4ZKL5CAffIeVlqRXvfhVMeDSr+6lxkUZT5ixdJZFPnsPR205tQ7YRg+RvMZj4l4YJTLqnT0V74HWjZicKmXbD9cwsWZGyABi9ny2UTazLQ3sokC0hVDkIkY5NKg7QRbIlrC7RqA02xvMkPYUV443D8mZpJVcDsCoPEEqnP1QPAGZMG26yPoIdejv+GUI+hEmmY7TQeaQz0e88MtOAz1pMjvMJkbamMbAXPiKeLwNjTQMaCRqOQN1luV5izxjFlGibP+1DZpPaLPme12NAjGtIKqCzOTV/+sg1zUb9O+/763Bffcyx7jMoxLMM2gyVJbSO7L7nelqXxNqDKenKqetclrC3y7zcj+m2aC4783djoZzSthaXb8oxSgxby4Yn+7hMYRq5CG6p95khpaFQlSrESfFOwrwOzXzgqQl64yn1YGmmBAgxN0KwYtPFUcF/dMAJXTMuonUTo4ARFtJ5o2SmA+xc/nI8fMhv/yiUzQ6twHLytyFsKkdISLeRSVUkk6oQqqWLJPTf3QwgP13yebwwfISMC0iYExXi3CNvkTnPXYLh7aqvEpWWR2gJDEACRb4uNa+CpLMdbF3C98AUSYLTCkWVaSUqLLURIl0HS63OVDgvnvSp99mxke7QT/GgBEqLGMQDxgkKlxpzzrTvlY79p90kvA/3dUJsRoGmAQF1uCgIh2ezU125KkCcWvkTqsf+YpL86R3IvOnTZ5dnolwl39JRMiWprHAAFSqyuDt3MsDGzIRlO2tPZvHkYRuYqj4m44ms+75u4Ak89nsoYg+EnKkssfIZqVeHU2zGdbHbYAbHKlTJQckpclZc54ZcEu5qpuljSsRZ+rTvfN4mroIAqhc8b5run1O+4si1FRk9JmMxlDaawggknJgKBeTVW0hb528e2lhD57/Fl8PXYbi7yvjGQ4WNHeZRwuxeIq4NE1SYAraOehpEK4+xINJu0IDqGhc70mkUgZ1FX29PUzoVz8uVXx65tCw1PlUWsVS4BbzdgQgDzs41kZRnPAZtqkgMWGu58361y/5J6P+0BKxrYWGzvymLmv4DYX6tSqJkH9vw0JmnKJZeuOA0g6W5rPPrJp/wrcFYTOFyiCnWXgoReGAtWwo8EO+xatCypNkut921g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6174c0f2-5956-4032-d3fa-08db929bc0fe 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:46.0566 (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: d+AeaIDz2V5voq0/Q5xztZ7k0rrx34vc3rvdRsfIze+tRTrIVFfiWM59al8JYXt+w1elPMQFwAlpaNzFk5jKig== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB10028 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230801_072955_469841_4FF3D5E7 X-CRM114-Status: GOOD ( 22.46 ) 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 It is desirable that the new .ndo_hwtstamp_set() API gives more uniformity, less overhead and future flexibility w.r.t. the PHY timestamping behavior. Currently there are some drivers which allow PHY timestamping through the procedure mentioned in Documentation/networking/timestamping.rst. They don't do anything locally if phy_has_hwtstamp() is set, except for lan966x which installs PTP packet traps. Centralize that behavior in a new dev_set_hwtstamp_phylib() code function, which calls either phy_mii_ioctl() for the phylib PHY, or .ndo_hwtstamp_set() of the netdev, based on a single policy (currently simplistic: phy_has_hwtstamp()). Any driver converted to .ndo_hwtstamp_set() will automatically opt into the centralized phylib timestamping policy. Unconverted drivers still get to choose whether they let the PHY handle timestamping or not. Netdev drivers with integrated PHY drivers that don't use phylib presumably don't set dev->phydev, and those will always see HWTSTAMP_SOURCE_NETDEV requests even when converted. The timestamping policy will remain 100% up to them. Signed-off-by: Vladimir Oltean Reviewed-by: Jacob Keller Tested-by: Horatiu Vultur --- Changes in v9: - None Changes in v8: - Replace direct phy_mii_ioctl() calls with indirect phy_hwtstamp_get() and phy_hwtstamp_set() stubs. - Add missing kerneldoc for kernel_hwtstamp_config :: source. Changes in v7: - Patch is new drivers/net/ethernet/freescale/fec_main.c | 8 -- .../ethernet/microchip/lan966x/lan966x_main.c | 25 ++--- .../ethernet/microchip/sparx5/sparx5_netdev.c | 6 -- include/linux/net_tstamp.h | 16 ++++ include/linux/netdevice.h | 4 + net/core/dev_ioctl.c | 91 +++++++++++++++++-- 6 files changed, 117 insertions(+), 33 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 6d81fff0227e..43f14cec91e9 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3872,10 +3872,6 @@ static int fec_hwtstamp_get(struct net_device *ndev, struct kernel_hwtstamp_config *config) { struct fec_enet_private *fep = netdev_priv(ndev); - struct phy_device *phydev = ndev->phydev; - - if (phy_has_hwtstamp(phydev)) - return phy_mii_ioctl(phydev, config->ifr, SIOCGHWTSTAMP); if (!netif_running(ndev)) return -EINVAL; @@ -3893,10 +3889,6 @@ static int fec_hwtstamp_set(struct net_device *ndev, struct netlink_ext_ack *extack) { struct fec_enet_private *fep = netdev_priv(ndev); - struct phy_device *phydev = ndev->phydev; - - if (phy_has_hwtstamp(phydev)) - return phy_mii_ioctl(phydev, config->ifr, SIOCSHWTSTAMP); if (!netif_running(ndev)) return -EINVAL; diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c index 1baa94a98fe3..4a1acc7234f6 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c @@ -455,9 +455,6 @@ static int lan966x_port_hwtstamp_get(struct net_device *dev, { struct lan966x_port *port = netdev_priv(dev); - if (phy_has_hwtstamp(dev->phydev)) - return phy_mii_ioctl(dev->phydev, cfg->ifr, SIOCGHWTSTAMP); - if (!port->lan966x->ptp) return -EOPNOTSUPP; @@ -473,21 +470,26 @@ static int lan966x_port_hwtstamp_set(struct net_device *dev, struct lan966x_port *port = netdev_priv(dev); int err; + if (cfg->source != HWTSTAMP_SOURCE_NETDEV && + cfg->source != HWTSTAMP_SOURCE_PHYLIB) + return -EOPNOTSUPP; + err = lan966x_ptp_setup_traps(port, cfg); if (err) return err; - if (phy_has_hwtstamp(dev->phydev)) { - err = phy_mii_ioctl(dev->phydev, cfg->ifr, SIOCSHWTSTAMP); - if (err) + if (cfg->source == HWTSTAMP_SOURCE_NETDEV) { + if (!port->lan966x->ptp) + return -EOPNOTSUPP; + + err = lan966x_ptp_hwtstamp_set(port, cfg, extack); + if (err) { lan966x_ptp_del_traps(port); - return err; + return err; + } } - if (!port->lan966x->ptp) - return -EOPNOTSUPP; - - return lan966x_ptp_hwtstamp_set(port, cfg, extack); + return 0; } static const struct net_device_ops lan966x_port_netdev_ops = { @@ -815,6 +817,7 @@ static int lan966x_probe_port(struct lan966x *lan966x, u32 p, NETIF_F_HW_VLAN_STAG_TX | NETIF_F_HW_TC; dev->hw_features |= NETIF_F_HW_TC; + dev->priv_flags |= IFF_SEE_ALL_HWTSTAMP_REQUESTS; dev->needed_headroom = IFH_LEN_BYTES; eth_hw_addr_gen(dev, lan966x->base_mac, p + 1); diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c b/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c index e01d3b1e17e0..705a004b324f 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c @@ -216,9 +216,6 @@ static int sparx5_port_hwtstamp_get(struct net_device *dev, struct sparx5_port *sparx5_port = netdev_priv(dev); struct sparx5 *sparx5 = sparx5_port->sparx5; - if (phy_has_hwtstamp(dev->phydev)) - return phy_mii_ioctl(dev->phydev, cfg->ifr, SIOCGHWTSTAMP); - if (!sparx5->ptp) return -EOPNOTSUPP; @@ -234,9 +231,6 @@ static int sparx5_port_hwtstamp_set(struct net_device *dev, struct sparx5_port *sparx5_port = netdev_priv(dev); struct sparx5 *sparx5 = sparx5_port->sparx5; - if (phy_has_hwtstamp(dev->phydev)) - return phy_mii_ioctl(dev->phydev, cfg->ifr, SIOCSHWTSTAMP); - if (!sparx5->ptp) return -EOPNOTSUPP; diff --git a/include/linux/net_tstamp.h b/include/linux/net_tstamp.h index 03e922814851..eb01c37e71e0 100644 --- a/include/linux/net_tstamp.h +++ b/include/linux/net_tstamp.h @@ -5,6 +5,11 @@ #include +enum hwtstamp_source { + HWTSTAMP_SOURCE_NETDEV, + HWTSTAMP_SOURCE_PHYLIB, +}; + /** * struct kernel_hwtstamp_config - Kernel copy of struct hwtstamp_config * @@ -15,6 +20,8 @@ * a legacy implementation of a lower driver * @copied_to_user: request was passed to a legacy implementation which already * copied the ioctl request back to user space + * @source: indication whether timestamps should come from the netdev or from + * an attached phylib PHY * * Prefer using this structure for in-kernel processing of hardware * timestamping configuration, over the inextensible struct hwtstamp_config @@ -26,6 +33,7 @@ struct kernel_hwtstamp_config { int rx_filter; struct ifreq *ifr; bool copied_to_user; + enum hwtstamp_source source; }; static inline void hwtstamp_config_to_kernel(struct kernel_hwtstamp_config *kernel_cfg, @@ -44,4 +52,12 @@ static inline void hwtstamp_config_from_kernel(struct hwtstamp_config *cfg, cfg->rx_filter = kernel_cfg->rx_filter; } +static inline bool kernel_hwtstamp_config_changed(const struct kernel_hwtstamp_config *a, + const struct kernel_hwtstamp_config *b) +{ + return a->flags != b->flags || + a->tx_type != b->tx_type || + a->rx_filter != b->rx_filter; +} + #endif /* _LINUX_NET_TIMESTAMPING_H_ */ diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 23e335f245cf..85d594460c66 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1724,6 +1724,9 @@ struct xdp_metadata_ops { * @IFF_TX_SKB_NO_LINEAR: device/driver is capable of xmitting frames with * skb_headlen(skb) == 0 (data starts from frag0) * @IFF_CHANGE_PROTO_DOWN: device supports setting carrier via IFLA_PROTO_DOWN + * @IFF_SEE_ALL_HWTSTAMP_REQUESTS: device wants to see calls to + * ndo_hwtstamp_set() for all timestamp requests regardless of source, + * even if those aren't HWTSTAMP_SOURCE_NETDEV. */ enum netdev_priv_flags { IFF_802_1Q_VLAN = 1<<0, @@ -1759,6 +1762,7 @@ enum netdev_priv_flags { IFF_NO_ADDRCONF = BIT_ULL(30), IFF_TX_SKB_NO_LINEAR = BIT_ULL(31), IFF_CHANGE_PROTO_DOWN = BIT_ULL(32), + IFF_SEE_ALL_HWTSTAMP_REQUESTS = BIT_ULL(33), }; #define IFF_802_1Q_VLAN IFF_802_1Q_VLAN diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c index d0223ecd6f6f..72e077022348 100644 --- a/net/core/dev_ioctl.c +++ b/net/core/dev_ioctl.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -252,6 +253,30 @@ static int dev_eth_ioctl(struct net_device *dev, return ops->ndo_eth_ioctl(dev, ifr, cmd); } +/** + * dev_get_hwtstamp_phylib() - Get hardware timestamping settings of NIC + * or of attached phylib PHY + * @dev: Network device + * @cfg: Timestamping configuration structure + * + * Helper for enforcing a common policy that phylib timestamping, if available, + * should take precedence in front of hardware timestamping provided by the + * netdev. + * + * Note: phy_mii_ioctl() only handles SIOCSHWTSTAMP (not SIOCGHWTSTAMP), and + * there only exists a phydev->mii_ts->hwtstamp() method. So this will return + * -EOPNOTSUPP for phylib for now, which is still more accurate than letting + * the netdev handle the GET request. + */ +static int dev_get_hwtstamp_phylib(struct net_device *dev, + struct kernel_hwtstamp_config *cfg) +{ + if (phy_has_hwtstamp(dev->phydev)) + return phy_hwtstamp_get(dev->phydev, cfg); + + return dev->netdev_ops->ndo_hwtstamp_get(dev, cfg); +} + static int dev_get_hwtstamp(struct net_device *dev, struct ifreq *ifr) { const struct net_device_ops *ops = dev->netdev_ops; @@ -266,7 +291,7 @@ static int dev_get_hwtstamp(struct net_device *dev, struct ifreq *ifr) return -ENODEV; kernel_cfg.ifr = ifr; - err = ops->ndo_hwtstamp_get(dev, &kernel_cfg); + err = dev_get_hwtstamp_phylib(dev, &kernel_cfg); if (err) return err; @@ -283,6 +308,59 @@ static int dev_get_hwtstamp(struct net_device *dev, struct ifreq *ifr) return 0; } +/** + * dev_set_hwtstamp_phylib() - Change hardware timestamping of NIC + * or of attached phylib PHY + * @dev: Network device + * @cfg: Timestamping configuration structure + * @extack: Netlink extended ack message structure, for error reporting + * + * Helper for enforcing a common policy that phylib timestamping, if available, + * should take precedence in front of hardware timestamping provided by the + * netdev. If the netdev driver needs to perform specific actions even for PHY + * timestamping to work properly (a switch port must trap the timestamped + * frames and not forward them), it must set IFF_SEE_ALL_HWTSTAMP_REQUESTS in + * dev->priv_flags. + */ +static int dev_set_hwtstamp_phylib(struct net_device *dev, + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack) +{ + const struct net_device_ops *ops = dev->netdev_ops; + bool phy_ts = phy_has_hwtstamp(dev->phydev); + struct kernel_hwtstamp_config old_cfg = {}; + bool changed = false; + int err; + + cfg->source = phy_ts ? HWTSTAMP_SOURCE_PHYLIB : HWTSTAMP_SOURCE_NETDEV; + + if (!phy_ts || (dev->priv_flags & IFF_SEE_ALL_HWTSTAMP_REQUESTS)) { + err = ops->ndo_hwtstamp_get(dev, &old_cfg); + if (err) + return err; + + err = ops->ndo_hwtstamp_set(dev, cfg, extack); + if (err) { + if (extack->_msg) + netdev_err(dev, "%s\n", extack->_msg); + return err; + } + + changed = kernel_hwtstamp_config_changed(&old_cfg, cfg); + } + + if (phy_ts) { + err = phy_hwtstamp_set(dev->phydev, cfg, extack); + if (err) { + if (changed) + ops->ndo_hwtstamp_set(dev, &old_cfg, NULL); + return err; + } + } + + return 0; +} + static int dev_set_hwtstamp(struct net_device *dev, struct ifreq *ifr) { const struct net_device_ops *ops = dev->netdev_ops; @@ -314,12 +392,9 @@ static int dev_set_hwtstamp(struct net_device *dev, struct ifreq *ifr) if (!netif_device_present(dev)) return -ENODEV; - err = ops->ndo_hwtstamp_set(dev, &kernel_cfg, &extack); - if (err) { - if (extack._msg) - netdev_err(dev, "%s\n", extack._msg); + err = dev_set_hwtstamp_phylib(dev, &kernel_cfg, &extack); + if (err) return err; - } /* The driver may have modified the configuration, so copy the * updated version of it back to user space @@ -362,7 +437,7 @@ int generic_hwtstamp_get_lower(struct net_device *dev, return -ENODEV; if (ops->ndo_hwtstamp_get) - return ops->ndo_hwtstamp_get(dev, kernel_cfg); + return dev_get_hwtstamp_phylib(dev, kernel_cfg); /* Legacy path: unconverted lower driver */ return generic_hwtstamp_ioctl_lower(dev, SIOCGHWTSTAMP, kernel_cfg); @@ -379,7 +454,7 @@ int generic_hwtstamp_set_lower(struct net_device *dev, return -ENODEV; if (ops->ndo_hwtstamp_set) - return ops->ndo_hwtstamp_set(dev, kernel_cfg, extack); + return dev_set_hwtstamp_phylib(dev, kernel_cfg, extack); /* Legacy path: unconverted lower driver */ return generic_hwtstamp_ioctl_lower(dev, SIOCSHWTSTAMP, kernel_cfg);