From patchwork Thu Jul 13 12:18:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13311953 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 BA54CEB64DD for ; Thu, 13 Jul 2023 12:20:14 +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=mgNEgmeiMac9VjrURBIbdWeuX9Rnm090bWRSPtPqKjU=; b=ojgjos+KkDWb9w n3pnxJfEmRC8H3YIrZamunO6foDc/mVKSLw7xTfALVN0BoNME6yGizgAE9Q4sdX0bLtSqnCdh+Mi4 otfjeG0chDMgTsOYcDYfe57lZL1n7AB6Lv7V2uf6A7VXuabQoXJZPpbqPhPdytuwRypUTTJrUuUzr RJevZ51DFyzAPFXVpeRMlxhWDZTzzy/5Uq6jHJnc/FDJeiuvbXlJeNiBCvPBKRrjvVOLYHZRAmxaO Vzh9Gf87JUgbjpkhINsgXuqp7nFZbeExSj6urHFSe9dQkV8hUKH1Npx7cV5lMPqhcoTvkwl1nCW0W ehcyhhML22ZUaWd+OkxA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qJvIO-003DNa-2N; Thu, 13 Jul 2023 12:19:44 +0000 Received: from mail-dbaeur03on20600.outbound.protection.outlook.com ([2a01:111:f400:fe1a::600] helo=EUR03-DBA-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qJvII-003DL0-2T for linux-arm-kernel@lists.infradead.org; Thu, 13 Jul 2023 12:19:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n9Lj1FSmn46iQca72EXRctKcbd80onpCMKFbTCuESXLeeDqTN1oT1I4RRoQKmc/gECuPkadHRYBzjcDcj5gGHo5g4XGZMh9JWJJq/qXBjMfPY9gvAPyY5pGUHgEGNP8v8hLKttbmXtzp4QquftueUJZ3fDx7cdEd5eaofzF+/YBxbSbOR/ICfWySDlXotf4BwZuKCU8WYpZAuzzDCW5NqIeeQLP2aAufucWlG/YDKPd0oAtmi5gZXgQjTB+5xDnL8oGgVwPxoYbvqbainFu1zVnzUzrcPoh5MwbmjrGLZmrQg81mng1hsc2zDf5e8+vH/pLzPiTVNCs3hlvWObmlVA== 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=5CiXt8/qYpORRjk3gY2/uz8cHJvXxKiQHD9i9t0WgKM=; b=OdYWpyBdr/10gihxfZe3r24+pXy5qygWeTcDv6r8EhfEpMFsaM0cHnzkE6cZFeg67hQZXN1t21Y4KewweqCMufMqX0nCSBEhTZTLbDfl1HMzGULwX0fuH/9K4K1yebUaG17VAbS5IQFb6FFqlTmFdXsOOAZG+8VMFRFoZM4sGjS39lq+g1R3upRh3r3yBDCNEqldh/Vkc0rQiwNJOnbg8A7VLILehVsv6z0wTmyTGU4SPq0RZsfPuh3ByvnT6GWkMsd8nJuOjqNpX5NFGSFMkIGPPXE8YwDrpv0or/8bSOZBKdxxRKZngA4xbS8sY0ZnJG5Tt+O595vszMaov6hlwg== 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=5CiXt8/qYpORRjk3gY2/uz8cHJvXxKiQHD9i9t0WgKM=; b=GAlGJ9eHGiFhn90f38OmZBQ8WJewLlia8RP/wXYGm9cs1QaFTcV4o/eCgHEnCKRXBcPizf7bwcGpSvxvcIk4P8LWeta6ctTYTCAlMYajqtn5ZCCAD/ifrMf3Pdt2CaHypSdL+NdhimVCnh8tVLXqfamY6E4H1VaAr6BRUGX0vjQ= 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 DBBPR04MB8010.eurprd04.prod.outlook.com (2603:10a6:10:1f1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.20; Thu, 13 Jul 2023 12:19:32 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::cc2a:5d80:9dbd:d850]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::cc2a:5d80:9dbd:d850%7]) with mapi id 15.20.6588.017; Thu, 13 Jul 2023 12:19:31 +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 , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 net-next 01/10] net: add NDOs for configuring hardware timestamping Date: Thu, 13 Jul 2023 15:18:58 +0300 Message-Id: <20230713121907.3249291-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230713121907.3249291-1-vladimir.oltean@nxp.com> References: <20230713121907.3249291-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0157.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:99::18) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|DBBPR04MB8010:EE_ X-MS-Office365-Filtering-Correlation-Id: 978580c5-e89c-4b50-70fe-08db839b696f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kjje17W1JDfTZIDZ2rLue7Ng+qL7jg/vrRhc+aIoq+FjDtkEgrWDhsTOrdMm9ORX79FJtMEeI+PZ5IImLmUdcyFRE43a2AEgC+woRS3i2SsRr310LxOQQraqF7IwVf8QYBEXRb++1DwUJImpFh80zolDt147R1smh6wPZxzvxMtCajMMb451Wy4p+F2xCP/YfHCqW1ih+wEgymrUREQpToaqdpdaJL4V8e2oyzGqPCdqYYFPeCOGZE8ip54XRky1G+lyJGgXTOqBx7DN+OADednQD/3pyBLkhP+8uKBBUDl7D6sDUIxRc/B9wPoCsTOkkndeTLzGb+cJsFWk0Ue0aiephogboJlI8eMDcb9tFBNF83Z/EamoUHTavaGmXX9W2tC1CVyrYq2DezCZ3EmslECJQpZFheAz2Vu31mF+e6FR6GYQCyb/DyusDfNJ9kcWG/ES/Y2NHCHyxAT0pzqT8NhjzBL8Nd09AFmv3UBfIhm87g4HdR4uk5i8vvi7HBT0cviPW1rlU50FOYhV6prdwmu3KECzvblQVzzM9G1FcFV9h6OtHALztJ47JzgKvu/nwNZVH/KFiywZXj4LGSpEUUN3HPjWlvYXLH1fdNxuj09XFHuBoOboLhbW/POfdzp1 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)(136003)(366004)(346002)(39860400002)(376002)(396003)(451199021)(6512007)(6916009)(4326008)(66556008)(66946007)(66476007)(38350700002)(38100700002)(86362001)(186003)(1076003)(26005)(6506007)(2616005)(83380400001)(52116002)(36756003)(478600001)(54906003)(41300700001)(5660300002)(8676002)(8936002)(44832011)(6486002)(6666004)(316002)(2906002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: skrtnNHxhkaBpuOB0T5QT0nweBw+uqAXvMdUCfUmszOsABSTZ2KXzr/2t8S5I9UGB2KJbxKW2tKOQm+BVkNy3gTcsOKWp3D+q5BqSU3I3bw7QfkK7b4Iifi7VtliW4OYZHeQRzulu6FthmG/Jkgn+4ix5zq+wYm0vXY/6iMijl9+OnxoBf23o8n1bM7OGqwq9Ri3P9YMBBqS8sCuNuxUdqrzh4vBlZBThkbAWzVjFiPVWY8tv7jvxba6vRZGqdMurs23OSl1FCPduUqrODxhrVOqZSMtM536JjbCZ0B0s6+srRU3Su9ydsQfJMGDPuPJTB/AzioyJSKhePXb8MUsPXTkeKlky5yO7hEARZvpMF5GRVsZ8IN9OBmtJNFgUjoi2JoXG4UWvVv+kovCyDa10rq36R4EhUKEK4zH8bC328ly58/W/skK0yLpU5vCxFv3dq8XXbarO/OeCVHFZ6wGWVyRc0N6MvCveR1pz4O0lfudqyFl1svC+mxEw5z2YDYie886640epHH8ze0IhQ0rPqhinVJFQ2r2h7akP7vLUHlczr0hA8m5hmg+xDozzoOovpgCf1S07uBxogmmlb2PgKZu39pIS3JeGM1WClkZ+twavJYSNT1TZ171qXpvmxQ9pWzkGVnqCgpir9pfLFE8Fen6KWi4ETk91u3iGhstbmcYQ13WOQLNM7MDZrOAnNhnAsGIP1uR0GBJd/BFm7iw45+0SK6q/JgQZDYdRHovqPeWzvw0EVy+sVtTcNuZVo2Ni8GcvAEq7+IHz4MEsuJTuffg/V8MFZbfgHuoURA+zvdiOQ8X5sxruOW9loGfqwySJishQUF2VFFOZt1pPkeCMZBfm1S/EbawvlwbO+W0u79AT4uFVJ7UlPEehuHU4V8MUIoLJLeP6/MueSgZadqwjtMo+3tS6mF8WGXmbNrV4/TR54g5gAq2E1P7owj6dFAti7J3DP4W2lL076vcX+13O/MyK2USD8K9WdrNCU0sXsS2xsmB0ajjVR+ncIJvavVE4U+Y9BU7FBWvwPMsB0qQPAXhw4/QCGdBZWPlbHRC3xoMiEQc+Z+1cuw+MaSwEVZ01LsZTe/1llXou9FIiCI+QNi/mKMtWbKHcLOvCz35ixGZ5jFv5XJdnAKVQGQn8OvkcesFrP2ZTmvMaQmOqWRE53IYnPX8XGM7XO0llyLmhxIvH6QdAfiMmeM5yeZbm7QlWmu6PkuS4WoZRRw1Qq02UPXhTZyFqKYFj+hHhVzUV7nZuC340wocUfChLjO/RiRSVJhhjzg+M1eXm4IMYDbJD+gdb5rcxd/RKOCKg5yryyXSUjRIqDoGdPiOcInO4PkX3Y6wYQTgtsE95KLdaIw3cI+EKTU1TVw//r06ugF7rsdsLX0H1aKxRM1M1H+Iz8atGQXRw9UwU/0y7fnEoRgCWOKS7foaHBmKXJv49GLB38hwOoD1UV6iFekgBd92uWhKXsWrdRHzEf8/GUeP+WvHHPUlb04Rfjj7YRcXfV8TJGgc0vcJzdDa4UpFscV2etvLwtRJCj4PNUI2TOcTh+iKtLv/j3tsaJ8HhF4fVmulXIoXSJilHu3ID0ur2rYc9KC6poThwqicT31jserdKy3Vtw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 978580c5-e89c-4b50-70fe-08db839b696f X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2023 12:19:31.6794 (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: 7jg0thKYXNmrrjOvPCPlCo5Gn0lRCQ0wUuPWkSyOy8C1j1fFCvg+yMGHmOm7yiozSlODSr9NKPOuGMJjj0jrBw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB8010 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230713_051938_827932_9E4B77DE X-CRM114-Status: GOOD ( 21.80 ) 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 --- 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 b828c7a75be2..17a442ed683b 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 Thu Jul 13 12:18:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13311954 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 9F2A0C001DC for ; Thu, 13 Jul 2023 12:20: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=tofxe8eu8zpyHHxQ8uBrMeroyPKRi5ZAP8PiPoT3yXw=; b=VFscqO8WXw3Dxk r+JVSDCprcSzTdJ7V+XoUIrKo3a9VMKOHcQlmQyZ9MCHAZujyh09tRUq3XbtYSpiK7jKtDj1fwm8Y kyHgXcy3/iH05Y9u7sI7K4momyWjjecXB0dL09HoRKEB/sHWqC0S6MBfDnGl+GTrL+56/VQq7ZoLM rSURL+G0zOUXUZiVxDQHYC5udvFDKEc++2TTLKSBobYEVAZhxyGzkmk913Pl8glNiY2ejUmRFLNvd 5prR5PBndoYARumPfwmQIA1BphM88DqY1jSXnszn+XfXiy+9LoZics+H/27VELpbVzJj6+sLuDVRg LI36e4bwqbSO6MIXCbSw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qJvIP-003DNu-13; Thu, 13 Jul 2023 12:19:45 +0000 Received: from mail-dbaeur03on20600.outbound.protection.outlook.com ([2a01:111:f400:fe1a::600] helo=EUR03-DBA-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qJvIK-003DL0-27 for linux-arm-kernel@lists.infradead.org; Thu, 13 Jul 2023 12:19:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N8O9rArhbNuAwySIZw5FPCvdNwPyO6e5wWFsA/Ah5jhy5IxKt6hx4cvgOy+xdcmsssZBmGrvrVgYu30zE9jKowFIJFFYba1r273d71RvoqAJm7tcBWCfSTM9ttxirtL8CUhZE2tb81Sy1eSl7wx9WzldkY5X33yndNvAmX8YSAq9W4OKGMXGpCbyHSGwi/pJq5LANMNw/n1a+3l7zhvJqSfgfgsVWxz3DaLf4U81X1u5lLpkaEGV39P5xB+f489/fx+dtdgfh+VM+ux17Fyh6WGying6y6lP8IFMnT7LhnrOyVwxoskHl9zzfg7i7qIcuOZt0edKmMhXz+gbAIDyfA== 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=bulMk2xGDx0dc5wKTUBgF9zvUYsD9GrtbH0qhpPtI6Q=; b=JtH1dP3cBSC8SlxIhNwQ5Q6ii9qrzdjpZlyiQcl96Iw7EpaG11cnDmJTI89ZXF2+dbCMLvYQtg3v9/HTnAz9X9oonDQg3+XJBt9ZuGShZtKaOn1Xb8fvX0ugQJlwsEtfsd0F+ampBMhDLoq0ssmwMB/TyBvmgzyjgwhbzouRPB3yl50phJU8u7aKQOYNQnvvBGm/hZWcShQudZSVZCtPbYcBFkYYfKEz8p+HX4A5L2dZ6nUFLJyykHBYzlKye9djMr82+3+iFdOvPajsAF3cGs+/gLUA2SNqo0j15BhLftIPnNFjjSOEEEWADbDFNfC1nTRtt7ETusVdvlCCsxzJIg== 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=bulMk2xGDx0dc5wKTUBgF9zvUYsD9GrtbH0qhpPtI6Q=; b=POE8LHBuxJGDd/w3nDdg9nYeWXdM1s4gzurM4QGurH7aHz4Thshi6jmFKxESDZy6MXGJJvkvcGuUQr1G9SciDCem7Y/D3sEOOodsU/WFww0sKpW2hdGLjPT+2bM3lOcBndwC1VS2Ou33YkXkSudz0pql+mZoVBY2kerDBN5TLI8= 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 DBBPR04MB8010.eurprd04.prod.outlook.com (2603:10a6:10:1f1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.20; Thu, 13 Jul 2023 12:19:33 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::cc2a:5d80:9dbd:d850]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::cc2a:5d80:9dbd:d850%7]) with mapi id 15.20.6588.017; Thu, 13 Jul 2023 12:19:33 +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 , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 net-next 02/10] net: add hwtstamping helpers for stackable net devices Date: Thu, 13 Jul 2023 15:18:59 +0300 Message-Id: <20230713121907.3249291-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230713121907.3249291-1-vladimir.oltean@nxp.com> References: <20230713121907.3249291-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0157.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:99::18) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|DBBPR04MB8010:EE_ X-MS-Office365-Filtering-Correlation-Id: fbcf0fc9-c773-4715-ebd8-08db839b6a70 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GJ6ZjwDwS55M+tEj3DjD+lmLMd6TCFBjceyOz2Pm97arLlAu0vQsLHToOWM/cBAKI3MeJm66xgx7jEPeu89E/QrmaGQDVi4NqI9kFLdplpzOr8o9F05ClsfCzTs4nYH4u8DMQO3TfKukjl7Pcp2HWSvQ+NNBqfrsFaYEHy1i/wywie2DkmIKRZaKHMtKQ7yEQqi9gSitDSE41zOXchBJtDxfs1mzBeBl3W4xevP/1t/4FpS0/4cNNWcLvPtkTuJX9j0krgfe59ZLoq5Fwq1BxHTSi4BOzHzMIC2DICzo1bw5jJ0qCmmhDPzNQZL4CZgYfEJLgc+ri0VaqRetglmfKNCejsRKMPtCaSgKc+Xk5XVNtzxeTCnonWNAm8oX65JV7mhnQAcNqaR5G9KiPjvqzPRnq9qL1damYcjYybOyS8gEV3ud+IW35eKsi64vY9tUQnq3LwU/hzBGOWxm54dRzF3b44EX0x9J0kPqW2bWSs05alw9lYQ+Vo13EAIszrNr+YYKKnR5A1f7MOCg/Y0nmeYMLvcy2fG7L3HrVSM8MPBVL92MU4brVLraWZ3QuW0232rkGhi93KcX56Qi2kN7y5Jh3uNg3Fz9k10N4ZKBHJIWod9B2GgwGoVrtuclB/wb 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)(136003)(366004)(346002)(39860400002)(376002)(396003)(451199021)(6512007)(6916009)(4326008)(66556008)(66946007)(66476007)(38350700002)(38100700002)(86362001)(186003)(1076003)(26005)(6506007)(2616005)(83380400001)(52116002)(36756003)(478600001)(54906003)(41300700001)(5660300002)(8676002)(8936002)(44832011)(6486002)(6666004)(316002)(2906002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mhddB65bJ9brveBH1lJJZvRW4Vnajqvn3g8zH8C9FrMSrFTVhXIWFCPs5ZMJOlGaEcMhbC1lDWtMLiEFEbres7vb3jVJKuuKDLn3sRHDuIxlJ8Lmpabwc2/TYkZqsfZ9cJ9DcJXJ+LBFUu77kkOsuPlrAVIF6qbGgu0wDMpp7RgUxFnmlDaWr352M2iacvyY3nW9qF5CnJnGcfYWX7JlCjd8kwfLxhrGZcvreBIDSlgoVR8d8FRVH9TDPNAedFj0A9vAac5DuhuGdKhMEmGSxcx9Xys4M9rKb+tz/mIwOOkoYiCVOKOHTdv6NSxt+8coUI7hknyv8RHqwMaVlQmxeyJhfx470SGgCeAKstuQk6n9E2dYhy0tJrk+C9XizFJY67he4PrpxrUku20qahgnEvCwp5csNsnNGJZMVhdAIDfdjaUgu+9N5IgyDAZWvcCl7rQNhwzZwgAhUJiADbLcLYHJ8fdhlUBI0Q4auQMQjsk9yBbkRjZny3yCB5un5MTks8l2p49SMIo7Mp3T1yExM2VCNrh/UXf8XjwI8WbHuLi8LbpdXnyRSTUnEA79OdEJ67aroM0tcwDpPkCyheL/Q4sw1JEFm23V0kILQ0rMWpa7YwP7HrCn4FWJ8FLeeTMjyQBCTMWpbgM1MqYnsjhjDygF+kccnZvahr52pq7eyzo24oXe3wi9n43P4NFGC8rc4HJgRY+4geqQsrZNXl1DAtSjrrEMwdnTGNT9xDmwMLAhjrt5qrvL6QzmFyzTtAvdf/tiUF9WW0EqhdNGpxRaYWY0ysjpD6rZkq5+33aN0S4uj3H37uPbs9A79EXPCy4NvyTLU5SD2+5n/5A5YxtKU5hvHBSINdeNIJhRRMZTCQJkCnXv/OKahsZhTd1wYOT7r9hYFJBMTZMwyakPslZvdbYKdqaHAqxBLwSs1Tn0dQWEIACCimJdJx3vI1SOTmDaJ5IiSflWlRLw/ZXH3vIwND6fFDwp1kiMJA90vq/0QndwH5bgyTB0G5idpvpStul49cVadUR7Ip3tzNkubCeKaYHQDU53+7UmHtoctpEgPnC3KgK4yRFs/HJ+I/Tk7s6Hir7+oaGCTSiEjOXDbK/ZZrQp83H7tT3JMoXUa9dfrdOOGr9gIvWNPtIXP7SbKsciXI4/ZvSsyB8CKmNQfoik0FruPEi2D/bS66ixl+RzcGkFdB75jwYPYy1fda09UqBWhxRFEE+1Pv8bOvaRSkI8ADSeFBR+2mmGg/gN0uXjNY/0tZiirju57YLzpS7JwkH6VKATUyhTdUz1Mpll1Shnu7Yu/z2TaRynjfO5Gk/aTA+9VIbVKNEIv0l3WYlYJ36VcT7SZ8ho6Z8V6IfAAuM9XuXzT15jc7xJOfckE6vzFNhoW+7EhONvnvaSDsB9LN8fq0HT/6fze4HwDEdhCLUuUHxhuP/4f4Sy8oIahiWOobCi2+IUf99ojydqZi+dIt5VEX/6y/KHlmPdbxBch2QP8MmAF8F8WHQysSP/qhScvAYVkdZuUMQGMrUeqbOipdX2Hln4yq4w4g8tBsUY1XATm6fvsM/LgGNfNcw1jQpLUncSwS7YtNueS0zlKgFLILEgX6utcnl/EPw7imEHyBG03w== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fbcf0fc9-c773-4715-ebd8-08db839b6a70 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2023 12:19:33.3609 (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: 8ppwr0rT8r/REDuzQ/SR4f2sIZuuOV0MgfwDUaPsnpLpTIdeCPhp2zDx4b4GPQV3FZmed98+nf3W+dChCy0kYQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB8010 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230713_051940_821896_BA5B8378 X-CRM114-Status: GOOD ( 27.79 ) 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 --- 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 17a442ed683b..ca3bcf2257c0 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -3949,6 +3949,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 Thu Jul 13 12:19:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13311956 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 416A2EB64DD for ; Thu, 13 Jul 2023 12:20:20 +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=HVtk2VsJJxAIRBmYY3LZXladrvSWg4G6DEKUPYCSBNQ=; b=gXzGUvMZUacVCZ Zj+edn3NOJThTxcyx8yDZs/Y0ss+rEcrYFw/7WMsS9UZSP50/D+n/L81sRiPkSOHfJHJoBKjW0iLC oIeDryAwHUHOoHFN5kpTRswVgnf3HSNyKKWHxWAdRqCNsNxcYIP7IbUgMXLZYycc5u1tBbOdpGpcU Ho0VR5icESFLlBGvGtu5jLNOc/jI+jlZkpr90Zz6S5lIqKQjSOie+RhJ+Yb8hgwFaLRmjmCwXY8Zn urcBt6HlMzwbg6hgoUhhFL6dg/QVKSWPV/d0WinNxHG7ru2SWMZgy6TS7pSwJirkvWQblCNM0dVVw nMqBa43j6EX95q+37E7g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qJvIV-003DRJ-2R; Thu, 13 Jul 2023 12:19:51 +0000 Received: from mail-dbaeur03on20600.outbound.protection.outlook.com ([2a01:111:f400:fe1a::600] helo=EUR03-DBA-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qJvIM-003DL0-2K for linux-arm-kernel@lists.infradead.org; Thu, 13 Jul 2023 12:19:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nJgYx75w6rvVtIx3g2qaDftZlyK+s4DMyn8WfMNmgHUMnZUR24Vh8CgRoTE9tZz4QtmeBMIi3XF4sfN7zl/HCH7T3va/VvOhIA4yK9/YVsOyzxX4yFyfES+vBd2E+yaA2u37dd1nDyWMRO5ivEZ33z0OpaR94upqHzrEF0x7e2ViK5RJj7vI7iQi+HaKeEfS8xaylfqKqO4MkFWFoYHWmSIVZVo95xCKOpiCZpf4IguDJuzUSf+uIpT6z6VI07pbU3NIb2McIPouxuUx217O1DQXXIVQPL/0Dp04pK9xZEUdihWZv8+lHmPSNEfkV33HacZ9yr99KcS3sv/mXJNPLQ== 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=tmKDwlwWKQU4hWJ7ZfCZjKndM34V/hNit1pWKU6enrk=; b=IonQudxPada9SB9J8PXZ0JY+llWvYsOU7NqnQzMToplYQoVxgYklNdBfe6EndJbxTq0z2lLvHUZV07SBPHn12T5EYUjwMBPPg8Rq/uWDns3ej/NA9PDq1C32TpbRQTarnL8aKgnVumoHurQ3FOdnRgFTry5SI7OOdpeBZTDTWMlPYDwnoIrx86b9byzyNEXmMypf7chX1PPycHgYV5NM8eo3nj+0HYHxHv42XzV/nJelm7zsTXUxY+CFPYY4Mwz4s8wv1vk64e1bAm07DuTnPi/EtEdc5nZmWui/wVexfVls+5//YhydvFEeLi8OkweP/C3k/dgnLStmN97WZqiC6Q== 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=tmKDwlwWKQU4hWJ7ZfCZjKndM34V/hNit1pWKU6enrk=; b=QcYXpA1ksduNiIsal6j2OQIvCVRmuAq1iOiGPgKF03XxiEdkcfBGaOv7WUu3hivCurZMR823bEKTsJxyIOaGlYzVIOndiU9Ix1NmqhAx5fUq1imIxhDj6kpJtHt1hkTaEA1UP6UjxQiVj3K2Y4p67ZZifGLfecDRYlZB4vifGd8= 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 DBBPR04MB8010.eurprd04.prod.outlook.com (2603:10a6:10:1f1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.20; Thu, 13 Jul 2023 12:19:35 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::cc2a:5d80:9dbd:d850]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::cc2a:5d80:9dbd:d850%7]) with mapi id 15.20.6588.017; Thu, 13 Jul 2023 12:19:35 +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 , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 net-next 03/10] net: vlan: convert to ndo_hwtstamp_get() / ndo_hwtstamp_set() Date: Thu, 13 Jul 2023 15:19:00 +0300 Message-Id: <20230713121907.3249291-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230713121907.3249291-1-vladimir.oltean@nxp.com> References: <20230713121907.3249291-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0157.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:99::18) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|DBBPR04MB8010:EE_ X-MS-Office365-Filtering-Correlation-Id: 205fbfff-df90-4eb4-66b0-08db839b6b72 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bOw5crCzX5E3yVB6TED//fEIQrSKOG93z3pq4z0wsnLj2vqLfBaG3CdaSlk/nDoKog7IJoWLmuJ5AKZLfMl8lKzGC7qheY2kd+fOtdfwT889ZK8/BKI8KJtta+5z2TAwi6uTu/JA+4NnyPlqYEkl8lTYiQYEfQ8Clkg1CLR7WozJw2W+4IPpuh1gtNvIFiWrBkqKUiR3GJIZbsXyWJt82WJTWBanXbbSBnDCFCM/VOEXBT/vP7rQF1+qjDdEkZcqIG97yoozV9B0Kct5GN7SvVdfGtMlnwnDps5giSAF2TDyxY4hddNX1rt42FQVEW3AirVrp47Xdn4dF4357mFWrjms40UxGj3sG2uWzjosEdfahB7J5Uwgt34LHqSPGVSpNXrmBFAtMVoBd7QnJiTpew1tsuJkTa43vqlcXhG3yyGeBSbMOga1QHHwGx7DqHYABnbLC4ckQdUbdc7tUpLOyoqw7i+wiKLUFsma2UjRo87WlHengKeWmkj1BNedU7PCXj37stT/coaQevex8h0d5kjgWn3DQfipaVlVg7VYsyJ8o1BWYnqq1Fz2KL0UvB318DO36MngsbOyqf9Lt3TOgGBKX0MtuPKHshJhdCMJn5LmDD1ep6W+KBywaD88Nhgd 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)(136003)(366004)(346002)(39860400002)(376002)(396003)(451199021)(6512007)(6916009)(4326008)(66556008)(66946007)(66476007)(38350700002)(38100700002)(86362001)(186003)(1076003)(26005)(6506007)(2616005)(83380400001)(52116002)(36756003)(478600001)(54906003)(41300700001)(5660300002)(8676002)(8936002)(44832011)(6486002)(6666004)(316002)(2906002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ob+LB5FZ5NhKOjvY/pNqP1b2Hp5N6t7psfGmHzo/lgO1RRg+6rb4z8xmkGmGYZAaAtUTdGKhDvdUv82PHaV4+AiI1nFNpllwEiBzl1YfjYfu+9RMlo9XDwJDhIDNDmyHfGpl+qv4c1i6z5/1hIdPi7wcnHBGlxgjYRzVBfNvzzOV5lpPIN2lV/mjbNuL4+LKRHlvUAc/gqEq+Ot7ZgriQDPqV0LNpZOnvmrORCMQyuegjMgW+HvAaDlVgbhhkNcu9pEC4vvvqs3+DjRG1fddpiWL47oezVLtBAgLUDzrHD6rGad+sfeT5xjbAxRvmcTIJ75dXy22vom1WEEEWr2uQgZ8aPTAnzjThZH5CPbjAKHLgpiiOURFqnWI+AbSFGMGavyjt1aKnNZJO7mdJW2+MWIofWERAwEQcRNauxzRyLLrHmSLpT+LqkINatMxVRgGRIoPgY6i6Q0iPmqszEJZDhxKZxlobFP2oeJsGTnLSUJO4IGIlodr8dc8d2P63DPODVcYi/EwQ3QjfYc+4jvM5+KOGPI0kAa/M9dXpZ2h/6iXcNBzCFK9NF/tHNdAVHBFYW/9egFATU1SUT169PEAmgub4QJCbre65eco9/1XVkcIsSX7incY4WYQ/uq1eGqg3j8DwF4w+NQMoXenvGp8i/4FkYeg6OLLhohQvwb8NaskjBVTBZ9s0qyak6Uwa1uPc5HvIjealC/ZQvWZxIvfoFTuZI+bDkutMMauEQoX93eSLpbAmq5OwR4++8Q44EGc6XuNbwADiSiQhOcoPD6S/giN9xP7K5LyItXEcu7sQ7N1gxAa861AyJfZyriwWzUa/qQAlqZBmhLwmeLOHVwaWjNiWcPHkw5X+7refsSNnhphYZp70kdWzfxIeqED5cBXDi2cHBlgRX9jTf55dw3sxNCW7/A2EXbc7PvWI+ltJeIFDkHOwMQ19HlIV2CH0pPQrfTxMDuThsdzsfDwxujdm+w1EEG9lAW/lXEmwESNK9g461jmsK9uoCydEGIZADv/0VxuFGeoZPvM8l2DHVTed83+o98PLkpFCo6v13v+gbYZlibtrThcsQ9TtsK1zYiiZneryOL1eReNqYBv3S5GEZtY7+ipYRJpWpo+vvygYC+NMPZHwTtb9VNdmtYqxMsisS0MhE+/AQIx13pnuCtYnPe2Dab7R43GcX/Qeb8gpdv17AejZPEgz2RxJ0kBG5e8SLjN9IMLyRSG5SUhuZ4ObZ76Glh4vjyQZ6TL0FaX42BTh0vbCjdi7yjmFbjVLXaJ23Mk3W6a5nFkAyo/xftgKkRmuqUjIqVPbV9AOvduP+Vr5Gchk64W60t6gvxGb+ThJCxnGMQp72Gwq9+eVT+S601wTHy2O4v6d7Fyd9hYc+uKJB4iNWqUhldbiTQHG7DIKz0YC8CxXiLAOYub5ePNaJTOBFS2IRf1uyNl5CSbOH6MNPX720AI/2yJolCPIcNYuW9ED82PbQ7bSfAZB0HH/Kc2euNdtN00r2vdZy/KV1GVlq7QrzzT8cMmR+bvE33KFJYadPNLQBbw9jFQCdu7s3e18aDnxYP9sviokIrOc8gD4FP4N6naiQgYVyAHl+YTMr9u6WlTM/v7nvkHY9ZfNg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 205fbfff-df90-4eb4-66b0-08db839b6b72 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2023 12:19:35.0420 (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: pL3teI09DW2agfLnZBIkDjciJZ8n6XdldG9utsvH8RtlIC6MEFpe5FrhM9+xmKHK6ysf+jS0lfFwiRqLu0+/3A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB8010 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230713_051942_759088_111E5F91 X-CRM114-Status: GOOD ( 16.73 ) 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 --- 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 Thu Jul 13 12:19:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13311957 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 3E75EC0015E for ; Thu, 13 Jul 2023 12:20:24 +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=o6r5HqhTd4pwJKU9jt5H15FjQSf/WveFIOIsIuippX0=; b=Bad8WPwjJ0Kbpv /0gdX8ICAALlndVnDvffoz2LqXWUKq6ZoqO2VooJFbIzJ1K04QJCkArluhLQZkwJDpNtPSCOHI0E0 f6jRqMEhZL4ftGtMr2bM0NVXTDAeZuOHYbrF2acRX2swgPDAdVvvu8hmOFS/jXtMSz6+/STsOWUXr nh1m52QjaScmcyaVkiirpL408hyw8N2nhZy+rzCReciZBbBb+Wew3daQGcgILqJ3gsJNWePAmUOwG tfHdRTfvStEhZNqxPClMZEFy6h7roSUwSVcjAgSf+vNquXBpUfJnu8myHm16dUA83TdFoV2ayTTEa Vu/XhgXCseRx5ff3ZJpg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qJvIW-003DRw-1L; Thu, 13 Jul 2023 12:19:52 +0000 Received: from mail-dbaeur03on20600.outbound.protection.outlook.com ([2a01:111:f400:fe1a::600] helo=EUR03-DBA-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qJvIO-003DL0-1A for linux-arm-kernel@lists.infradead.org; Thu, 13 Jul 2023 12:19:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NaHIim9c2u45E9sCEN3TIbMLqSONX/ZNgKx1g6ZC851wsIvlHBOHj+EpvF0kYfkNtsFC9LwUy7wqIYcSUakLjF1oK1Z+qRc7Ih8wnTETUbWefOq4TG3IikSKN5TE3MjEyy06wl6cyM/WtdnKeeKdud0n8JwHLKBHh7rauaAOenvKWMZHLY2GsPjp8dh5effJ5EtLBHCP32JDlZTMiaqjoPHvXffIVhuk3HxfC4jvwnAktPhyHQ3TJYdRHAxvi6FCdrQ2LxUwbfhXxr0ASIWP8dY11Afflnsru6jLOyFrWiJNufC78h+ceHj04RxvLzQuiFl4Fu30WQgDbJ+OGAm9vg== 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=Dzv1QQHSPaR13TxtFe64iUOelDgDCSZdcFx+VbkWXy8=; b=LrTWS4WMz9RQjKchYpGV40YHmBzZktGbWaOuaFm7kqrzCQweXO+NfmXh3rGkeaECWgxRGEvX0JUfD6cXnF02wv9mYRtOwcQYj2HJ562Gw7W2IXRV5tYXIPNn22UPEdL4BtDlvS1nose/uoiUqE9ONabFgtgM3q9+oBgWgLAPRub2OoUnkeAf/XDW89inBoJbCeDOVCwkBqRKf7NKwihaxOWV3pXDVxhoPrbn/exsIRAYx56qSG0mNhgpj6CVwNdcktPqYDoOwRDsMLLtE4LBAdHMcpRGEyJa3ZsFGfcn1yWlLG3o70motwES2oLodAC1ydpktgWh3yB3wZ++wbqaiA== 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=Dzv1QQHSPaR13TxtFe64iUOelDgDCSZdcFx+VbkWXy8=; b=gUN1vDTtha8D56YCWmFx6Sv7nTiVTOjuepqhi/IZ6Ra5fClIIL0VIcosbx968J6vFSgf2F6WDv25XAEfM+4H3cPM/+YV+vf2HSjmJOOWCwH7DeGLW9YnuyMzJkS8ffyHr2A5IuljutSPoFswP5vBUJ15iQ0bgheSOOZm0N7oieQ= 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 DBBPR04MB8010.eurprd04.prod.outlook.com (2603:10a6:10:1f1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.20; Thu, 13 Jul 2023 12:19:36 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::cc2a:5d80:9dbd:d850]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::cc2a:5d80:9dbd:d850%7]) with mapi id 15.20.6588.017; Thu, 13 Jul 2023 12:19: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 , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 net-next 04/10] net: macvlan: convert to ndo_hwtstamp_get() / ndo_hwtstamp_set() Date: Thu, 13 Jul 2023 15:19:01 +0300 Message-Id: <20230713121907.3249291-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230713121907.3249291-1-vladimir.oltean@nxp.com> References: <20230713121907.3249291-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0157.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:99::18) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|DBBPR04MB8010:EE_ X-MS-Office365-Filtering-Correlation-Id: c8fd8661-c4b2-4af1-7f41-08db839b6c71 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: i2HuRdMb50bnRi/KabfCibyoBdfeLRxU55QlDeV1tD4Yg+IozNzfCp0UfBtCdsZWZNy1cqy7XdZC3OmQROuv8sfxynGAuJDg3RUSc9vaCvDGxDJJZYvDPaYrJ9axlLGPjuSuq3F3lSFfMsdglj/WTyHw13WtzL0Wf/RiNTE07DZHgZjhc3fv1lFiTUOTDDP7TRCqtBaUn6k+JndQmNaTYF4KFZJdg95E0ikjlYF5sG2eVaLZH6NyXyTLormrfeAutVjjgrENzM37mbd/fFc32srflJrrXMz7Cfg+AK8A+fa4XQkcuSXLDgyNKbc0K1uxRVp3BHHD6A0p95P8eJ5AMFNHFq0aCDJ84p1DaUn0gh+WwCrq8fNe1XyXY8Y/H6+rOgqbqzlEqPNQyoUhUe0O2T741vOtIOy+JUGMdYhA2Yzl0oAuXhNNF+DBtnf/HMTAY0vdQGM4Fph3/L1Jg/TtqGKgfvVKFFVIjKL4F7pq6v7wGcfIVynnlETW8cqqJOfw8DCMdeWJM6Z+BaiffQjgx/JHz5rw5EO+u0OFv6RmHKKTs7Arn5sgyrdSrAlCnKmv+Pto9f9ixZ2RFppdPeqTrxpGH3YiH22Ea0LIBf+T1qlXspDCxI1DWF1onpony5BD 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)(136003)(366004)(346002)(39860400002)(376002)(396003)(451199021)(6512007)(6916009)(4326008)(66556008)(66946007)(66476007)(38350700002)(38100700002)(86362001)(186003)(1076003)(26005)(6506007)(2616005)(83380400001)(52116002)(36756003)(478600001)(54906003)(41300700001)(5660300002)(8676002)(8936002)(44832011)(6486002)(6666004)(316002)(2906002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RbY2+gdIQ79670ZxEgF2QxFDJSJYyrSAE1QKpOv3e8Ew27EYefAYzFNumeOSFw0AtnNPUqYqh35R8DdIW3eBnJLCgtiynQ744DVKgQG0visBJEe9+wj6S4uGf76pQ86Y10wAITcHrvyGReCoOOZy5KuRBSIWjy6bpiyEZohUBnj2oA3tOvF08RmiJa30B+LfRODRTygzBd/ABkFVHISoJ9kKBoo90UeJkGijr/SmbYRZzoWRDr89vSEvX3zfFehBlPUNqI+7Ea0cCLfxuDFx3Gwbef8TSls0ScLtj+5f6tnu5W2CpKdDJm5+2lthqnJx7mzur9w0OmpYoQX4nLdtxLwhS1HGw0ztTQ3NhA8oBHkkLG81b7HSbQwqn3cIWuvS2vP77Itsayc8N+Tn6VPXbqF4l1HrRodFHsGV6RCJ3p59Viv+Aj2X3uokDDAvfMzgSrpPpnLTys/QSMKpiwDJ9JnmQVy4H6k5uDbHaGxncWvXjP5esq2jRq2Eaip6Ba/tY2/t2KtJJQvJrduwIwVfQLfATs67t1FSAo8/pLNdkbxL0o6pOPlF/SjxmKy145JitBYVjs4rcDzWxlk6YIjT2xAfMdXfWnmgyYcOyid8c+JKmwbSLQMIp9K/ICCP/ufth4/aU/MQ/vwPC6EVr0nX3trGreDa27bTycRCin18U0gsknUBmckulcT5pe0WHBDXWNMDtu6CP73rFOXOlqPg80058wxaB31cFfvE7qIS8PY1VLg2toPDr1m9sh5KRBwWhY/YKWmhWkKshlAGlqAstYO1KuvdTJ35TOEVwYQGe5+eQqAUTnVxQiz8AIPpAJFiNxnKtueKCg8pYnzH/E0NEcuuxCMkmu1K9Mhe7XbTzUn1Dgcg9IBkon0LMH+MQ70CWCApA1eXBU7FdxVtC909mP/DWwjWXoreBejBnGwWk6OzrNKXcA72fvYOSrl1FkHvB22FlSD6IAwBfBrJaM5HlwVrpAMk7ijvD1JfRIaoo351D1VpaLQO6AGdGsTgMzwomLDmJ0RPlUAd2quM4PkAlxwcXctOF56T8Z2sUo6+7JecOM6FvIinWR4H7YK+OYEL01XKHQuLL8sh8Vn1aH8FLvaEhKsTiIp4w6zUJEd65fOgVgnGEmlnyyVVvwR1qeHhliqYgewSZTWvXskqXyvQdA+irpo9O/17cQGmLGw7GQqClWoY6s0oGcrKra7F95wO2YMF3MjfXt/geM0W+71ujXvvRCGTCaxpXoYBzXUX4PegFrz3bJq1QTNXxX3xXHS7PtFZH8aY2yJY081xOgWuBJrqaoML0E30Dyl1JGPKncnqap3q1m7O1FLalda0i7coPx1KKO6Q5e4Ch84Kb8oNAYVdHqrqYkQj0WrNGJzJhe5hXcrorQkWh3mufcWVTtGhDAmNtEgMTGMfXieAilFcwnXIYJEtk8FFiJAle1huMJgeODfqeMm5Ylv/diFdRGgEEGTVV2pePotZxPAA7l3LsWTfyL2lFpcQqUbbNovE5Wd66r4S7zCIbGSYmevnSgvyqFSks+mRFNXA0Xa1lCPFArTW0DzJLx3/Q9u2YuqgXPcyx2V5M7f+tLB968xOJGMdcPHv/pIsLue5pT0betYhxQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c8fd8661-c4b2-4af1-7f41-08db839b6c71 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2023 12:19:36.7386 (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: fIekbsl4WnA1+1d3HKh5Ik9s4hTwhrXN9GbOnZu+2PSBksmQmKyty1CO9spUgmVUhCujYpE9aRa1GjP04bwnqg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB8010 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230713_051944_401234_2F2D2B80 X-CRM114-Status: GOOD ( 17.65 ) 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 --- 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 4a53debf9d7c..01acb57aa40c 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 Thu Jul 13 12:19:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13311959 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 F330AC001DC for ; Thu, 13 Jul 2023 12:20: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=ZdpJ2rwl7XlJN9X62jdBbAC0PP1IC6lIiVz8AMW4lvM=; b=E3D1zwKCi7Onbu K+I6me6hQGOGQnV99NlCDgJn5xXqP/Z99r7TsFOc17CWhFaD9Yfb/CqgFeGdkoGC79K09NuumRidz fzwjmAMNqnvovGBgR7Fp3oRbH1a4AL+ELQirzntmHSwugSGY3hwERXp66FBKXk+eGgJQWamAMypFA gCC/fwfhoksz+0lksf5u8/0kZ1kzZD9bb6/tmFpi7Srmd0t1ecSCFT10UoQeg2TmQHHkRj6ejqtbt Ynp4BKumZnNJ/lixXFcj16j+/nDMVeMl+sjO6lJahYj52dTBWaiicpoIEwDTrni+Mzez3fjv4Zjw6 xZrotVPS+TX83KK2zgYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qJvIX-003DSK-07; Thu, 13 Jul 2023 12:19:53 +0000 Received: from mail-dbaeur03on20600.outbound.protection.outlook.com ([2a01:111:f400:fe1a::600] helo=EUR03-DBA-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qJvIP-003DL0-3D for linux-arm-kernel@lists.infradead.org; Thu, 13 Jul 2023 12:19:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ADVi/Hni37mzr34iZZTx+WHOOBevXjonOcNxrvt4RSGaVTA3MH8RaqQugMm5HsbztHUDwzg7uEQi2w9PNkCt2Lk+Y6F4euh8tcvOeUTiBL7z6DUNrfGJq25GovdKXU6fbJMTZeKEbvbIxNxT0pAxhAmcn/L0l8MpMooEyLyBQsERg3JKRhIDfnUGAjiwZkQnTqbh1sBEwC5+cD5Vh7yOESIvFCMQweIs+xeXRRPad2unHpENwZbe6tZnn09xeLSs0w+IlxsiGNU+tr5V63kEP9hKJ3Adfxsc1Iiq4J7QkOgBix/N8+H1SRJIOlQSwoMfb6IfYLIXEtKTi0p9CniYrQ== 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=Ct1I3YYpFbatY6yl7g6JtCHFuKTariKU1KzrtX40v3Q=; b=Qm2Gq3OhcRyfmq1URnrLCvyI5rh2DOKfTecD5JWXeg1sRcRGzONGxIOfZtfyffKA/4pYP893cMh5Vj6eYR04Y5DlCft0g8I+AeNRKaFURvXvm3LWvmb8bcCP/J8vJ/FQpxNylxiJtReriw3xf2Fr367MkdrwRg0usTzESPYGxAXLwK3+3LGextN8sriHlPTVwLNmBjcdz5B7WWZl3MmGL2qB9x2xUYoxnBC5/vkJ/HZOrriPURjBrMiEcW3YV7iPuocIZ172XybNJy5AqZSKIAFWI+PF+H9FxeUhLUo8pNgE4BUpZDSNjDcDwdJAprTLbMTZM2NNMPbvEgp+b6A8fg== 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=Ct1I3YYpFbatY6yl7g6JtCHFuKTariKU1KzrtX40v3Q=; b=FtOHebNJW6oDKUnSmAyW4tt9OqTyMQl/+r1SPnXeIq2cUxeNOxcWKZhKDfVnmwl4HS9w1OuemIHrdKmOBWN5+oK6e0JQkcqPRnzkGgdHgzA732QnG2L8GhfLrDs1swfi4p+ar/RjmjmQNvm77Ik3qcKDqiZmU6+SAn+HpaY2HpQ= 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 DBBPR04MB8010.eurprd04.prod.outlook.com (2603:10a6:10:1f1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.20; Thu, 13 Jul 2023 12:19:38 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::cc2a:5d80:9dbd:d850]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::cc2a:5d80:9dbd:d850%7]) with mapi id 15.20.6588.017; Thu, 13 Jul 2023 12:19: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 , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 net-next 05/10] net: bonding: convert to ndo_hwtstamp_get() / ndo_hwtstamp_set() Date: Thu, 13 Jul 2023 15:19:02 +0300 Message-Id: <20230713121907.3249291-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230713121907.3249291-1-vladimir.oltean@nxp.com> References: <20230713121907.3249291-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0157.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:99::18) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|DBBPR04MB8010:EE_ X-MS-Office365-Filtering-Correlation-Id: 574bb50d-3399-453e-beca-08db839b6d77 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: smDJxNsJVzEHw0cnXIkqCqEAQjQz9xaZpiwS0uCfFgqt8i3gmuxuwtqTIvTH9MRrVgzve/IaiSTsKTRs9bIQvMuFmDQxYB0OCCpwdpaeL7ZOkXsR5VbGNCJWYm174KIVTGdohjedR6bzLLc7alt0bW+IlwIi0XS+AGNlydu3d9vw9FdRWLFkMVWepWOrAsLu6srf9omcSStoLDn4NyRAxlQ6erfdimRUM6q6JZBlYF//H7Cle0g/cErmyKLNghA68WnCW9r2fVhemXxIZvMiBt3V9oJbzVqKwjDjUXgV+HV3itvvpJqwhAXkTf2YdaIRtDWKOiqp9PZKgBCZBOIraERrfQu5iHJ22I9NPbWKwO4OBNLl9ldEuVjx0D+fi7ydrE8tCGKBEj0YDsgQYfTM7Pm4ClJ3rI7dEbA0ZI2RNVF8Zlmme9Es9g4XvNmNV8i4r0faaHw4zvscTDrtD3tTPqiDLtWP45aSu2SQIo7uUnWEcyvx5EslY7M7E/chntbO6Q371gPCI/wUl1NDy1S4HL7Z2o8DfYOLKY71fLRO3XnOfJKbdhrwKhV6BUUf/MMdudwJ01/l71MsvQcmrAMC66cKBdeUHQBaNTgCe5El+uNrOgps1pf0geQ+Z0cWPcjD 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)(136003)(366004)(346002)(39860400002)(376002)(396003)(451199021)(6512007)(6916009)(4326008)(66556008)(66946007)(66476007)(38350700002)(38100700002)(86362001)(186003)(1076003)(26005)(6506007)(2616005)(83380400001)(52116002)(36756003)(478600001)(54906003)(41300700001)(5660300002)(8676002)(8936002)(44832011)(6486002)(6666004)(316002)(2906002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: c4S0neEr1Rf3MbKIkMKT0kQGRM2LU482SbhDxoWMbJs3E+JB7yRjBtBo9QdBfp2gVfZ2jEu/4MMZjEJs0yDvxrBLJjg44kgB2C03qX6xEl0OBeYrxmso5xJVsmjqXjLMpFRE4jNuy7ZcqI+y6i67j4eXqPod+6m0i/7OvZU5gyrlIcu9aXZtceNyIV3Yc0OMykkR5R3BNG4Us8/2lY5nJqTsD3cZn7XZ/rymuooP3QN05gWbNVYwx1C+x280+tiVuEtaNVuThSPVrWBW3Pa1x6nAM7HdvFxWHj2JG0YE7yB8w4aFepMttTpx0p+GuUFDALab0OIifQQ5yqOV4a71sFAdonJ5yXD2xTcMpa+SzcFkkIK4J+dom491cemnzesuhXsI5VcBURtXPuB/7hmdz/fJCHYRBJE+KzhmHZGjCb9LOaM3cy2QWPq7/FGExwpsdkY1rFP/Ckp60h+9qmwo0Buz1LI/KEeJfT6cKAxUl7xHbpQVK3Rfjvah0fVbJFH9poj730JmvLYULUTCFq6ixdTjW0ovLGTiQfqBo2gojKEda0uUuFtWS5hR1HCeTGmTQMVILOIne12c/BipcylFGNwr67eobLly43KP4a4SSmNPZ8nlomG15sKTBMRRJpxdbWUpXS0C+te60uqsr60oVzCaUPNGBnMit1G789vQX0mw1Er66g9J6KoVIZof9gEslSrn9M4LmeSweaSWBx6W1C2mMsXBqBHg5XH9MWq3V6E9F5BJkS6R67frEYZ4vFW/lM8/oMQhTKqcsvQ43ue+lRSZw1ilbgm6Can72daK+8gXxFhdAEK3zg7HYjFTt9g8GaQOWF7m+KQ46utHLiErn/eNgJkxauvD7QQpFDc7c3pO6mbSj0Hyg4fPN5AuJgOUNNnqX+uBKnM2h/eunHqDz6VCF4agkoM2rx7ieumWVGEpFKHeoo39eFK4UomjF4UcXj2jJzgIaLBFsbqMeTJIZ3f2XRmJx5LspPsvEjr19AFEvkXaGMyX6TU4NtfV2tBGtbjwWPRoU1svvuXfoDSOlq8EnNrj6BEvkQNnEqHDe1FXar610VxIsA65VXaZOqebGu/6c6MaNKZeBWspXkezGob95+47+kMdgMrhRCYdDTkSxh4/s9U/FYbDgtiKVKPzLLZFsZ5aYYj5EJJous0wyt+ZidGofP3hg1zxJCqESUnwHaXlEBfw2rVvKOG4/X9AE4i59cj+AlMj+BmW6t8CcrcXB5IdfF4AGaY7swsBnQ49tWSz4J1e3Zwp2R2OjN07UvRhTox64DwAmKAh0w7VmF4QXxPpgGd2F6+9DcluRnKQu5KuI5GygHc4QSXG4cTMMKvkDJykJaY6iq+G6aL3vvzjFSTVgrHuoFV3NkJ812igFzu64nB3o+Y6Z69RixmG3KF180D5h6D6u6IrRh+oTMH74lx1YBdIiLEVLoHcRXk/4jkRuNWULLk8jQNV1BFjOcVxjVnRHFbEa/GcTvx/GiVu4lsCL4ypt5NVk156lf7xcOHYWkh+8azFWDl5ycPuMq60wWD/SoIF4RD4Ue22M3tbtKzG5G+oUWEC7CT+HD13Hb06+ZgyjXSt3TqUP8daaPYFQV6BFUcrhbN0YVB7MQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 574bb50d-3399-453e-beca-08db839b6d77 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2023 12:19:38.4216 (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: B7XoAWyg1Z5vb1BqG+zksdrnb+I8ZK0BHLVLG6Ttxq6GtXwCkfjrAGQ2i2H3Z+EwD5473GQbaH/BsrAyA3ibew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB8010 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230713_051946_036758_643FC14B X-CRM114-Status: GOOD ( 18.14 ) 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 --- 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 7a0f25301f7e..d591992e3eda 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -4441,11 +4441,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); @@ -4472,44 +4467,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) @@ -5683,6 +5645,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) { @@ -5831,6 +5854,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 Thu Jul 13 12:19:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13311958 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 1B8E2EB64DD for ; Thu, 13 Jul 2023 12:20:25 +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=5cNHbX9/l8tp6HbUSZubsTjA6AI+s4uhphuZBwlMy98=; b=NOdUXkc6S0dPTW P+5JAx7xPNWywauEnuMfT0aV6k5+qJ61OriwcyJxPfoSTbTAG9odS4wr7Ls8P8O3j40KOiP9eWE8r bmfm/4cI7rQeOLHk7OaW7canm1epC2y4ik2tdy8yvlkLJWbbBKtZtbSU6ImVdbw46X08Dqnygfrcg tVtmFkwZwinG37bfBneEmDgKfEIMg7Ap+IaSf2TdHg8+9LWVAY4MqHIDVftas3iN2ulvR/Yxau1a8 zE5ro/1MAcMXmyGddvrDpLByAEYKK/icVXFYv7LHoxio+/y+t3LcYIFduqV5bVfeJu5PrczyeJzbz 3valzPGjGhIwrbTmXd/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qJvIX-003DT7-2e; Thu, 13 Jul 2023 12:19:53 +0000 Received: from mail-dbaeur03on20600.outbound.protection.outlook.com ([2a01:111:f400:fe1a::600] helo=EUR03-DBA-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qJvIR-003DL0-2k for linux-arm-kernel@lists.infradead.org; Thu, 13 Jul 2023 12:19:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fHKMIsxVFuWv+u1FlgV36epDugR5lm2g1g81ryFSnms7RRtxedATJbony0keivdRthk2RxaZbm6CctG3ZXb/kKpYxSswxsJdNs6HZ6PFDJu8U6CWc/O7z8prJ9ruiYa0n9EbkzI/3PBPjzLmE8dod1lwTQmLsPvp1p0tFG2RWCEksB8mqKhsQ63RyNM1G/Pw+SWstXOc62TDbZD2icCA78iyiCSzf/3NAal+bvsG0rnhott9rWjBLB8d3bXjvRVcKcUMnvcdDTIpV59jBcNLFSYdejWBZVvwWwAaW7NIb1v74zV2Ns3qsC64ara4klXBKZPwJ4o3948q8/WRp10o8w== 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=tAt9jn4u8b6uI1uKhfP0bkrH/svMOBmv1bRyEkomSGo=; b=hOeO0I5RhRVynyO4NeMUPhTF1HzXP2MYac6//8hH1ZR/VlBXPOhrlbBrLZgcg9j7VEhxJJen67iV3JVMAsjnwV3rzfQYuqh9E6vtedu7RNO4ZSHzOPMWq5E6logons/HxaIqmz+m7KlkLJCwHMw4fElExAffp7KGpIo/CcpO7wA187mqfkLy2Q8cHHyII2Nxb60DZzT9Frag8T0NQiQMlsvNQILu68B/z4KshWElCcvxpciqhnVWsGVLmwIStOjmJSEKTEHK3XDSY2sr7XuS4xaFySygNJSx7/fBFyqlia3YW8SUmUoxWj8pw6wgLRCFHB+n7/nNgy1CM4iMrrpL6A== 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=tAt9jn4u8b6uI1uKhfP0bkrH/svMOBmv1bRyEkomSGo=; b=aCjoZoWxhU9uuzvntqi0Zox1q60nbKEr9Xn7LJnKTzrLk0DrI16H6U+xukh2edaZJNCzVvZZgv6+sorWQBdRICH7cbp980FHLgpES7tukETp57BVBEjMZxYgU4DI113zqyfO1tXsehMFcozSSNrUTdKyvpiMImCaOBt9PTP2Aq0= 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 DBBPR04MB8010.eurprd04.prod.outlook.com (2603:10a6:10:1f1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.20; Thu, 13 Jul 2023 12:19:40 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::cc2a:5d80:9dbd:d850]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::cc2a:5d80:9dbd:d850%7]) with mapi id 15.20.6588.017; Thu, 13 Jul 2023 12:19: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 , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 net-next 06/10] net: fec: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set() Date: Thu, 13 Jul 2023 15:19:03 +0300 Message-Id: <20230713121907.3249291-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230713121907.3249291-1-vladimir.oltean@nxp.com> References: <20230713121907.3249291-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0157.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:99::18) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|DBBPR04MB8010:EE_ X-MS-Office365-Filtering-Correlation-Id: 30727cc3-e684-4c56-60a3-08db839b6e80 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /2+wSp5p/SiA7e8bky5EVt3yXTcFmzagHgHSJpZtX2Y7iZrz9J9/4wezXlXuW5zI91vo0u2wsQVtv95JVuds7po2LFDApbX4MbCDN8tA6Ii5gZ0mu3Sqx0iyJ1GuVaG+0WlMVOy6hKYJ07PHgb78hdLBMpvV/Lp+sG8Yyusq+pslxioaAQPieouFhwRsF78HSPtS1ghMhxwGP29Y/djuFJYM3MYyDRw7fqROQUdMBhflcMbMiJ9pMlvmg15ikishOiNoksmZmeAwxpep+vTahTaEEAXDc61SHLe6V+rEuxubwG+157SjySJltdUs55+YuV0YWfCI08LqazedsBtlhOrD7gtbadwCviPVNapueYxSVL0gCgNk22gVVtGOIYKSTqWDcEM+eN9YPvSBxpq3sK4tqIyc6CiVO5JhwHeW66UJlGHoAjS/aIBlpRSyaOyOCs6vgKZDzSGa8+kMFuAzAUp7QuC2x23k8QaH9NJ/8XSUoSf7WMt+3XuwJZEuUvAVCBIOyP7FK5GvzzVXZUXxL1nfOAs1BZHS/7Z7tkFnEFu9lXXyye9mxAyx697XGJPUySw5EwqtDEcuuXrYf1XGINzAY9jLbAciY5KvXrNDNuTv173/XR5FuGbBZ1Tq+qtp 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)(136003)(366004)(346002)(39860400002)(376002)(396003)(451199021)(6512007)(6916009)(4326008)(66556008)(66946007)(66476007)(38350700002)(38100700002)(86362001)(186003)(1076003)(26005)(6506007)(2616005)(83380400001)(52116002)(36756003)(478600001)(54906003)(41300700001)(5660300002)(8676002)(8936002)(44832011)(6486002)(6666004)(316002)(2906002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OtMPoGsiJyQgNRQsSonMqcpmujqFUBVc+X2Tg5rlLK3jQYtWQYmgdIgS3XAx+wU+4w8gMr2XQj5ki+2aZRvn1Q+Gt8bHT1AYGtT2/Py5KV074Vjvl6+a8k6TriVKJrbJsqkKUEHRC+WUz3VvFbt0nLyeiMo0qt0n80Q8NSmj+ZT10gMkQ2f+jNhTlb9RNPE+bhMJ2w5DlcpDwRQONEKs7lqAeFR1skCYMikqyC6uKmdsxERaWAAobLzFrXmqRjUkAL1R0VLu3q4NrwBLm1BbLY1rhI1fnq6uKkEuMAjibuQmkWukDJ7O1gQENJTKydAGYXzNOaBLFKLrxqv4pxH8Tkq7lMdpB3geqp4WEtaMa72d1i/+S17ESnyAcHKMmjpFljki81duCmO2mKsaa7P5Dwxdv4roXf1QRJrQk2azAgv+twCtfF5pfvB2R6prBp4EVAUsp5FI7btJ+y1SrMdvUuTUwt3rzz/fwheyJS0czAmg+anyLlg1rq5wnJ91l8t7eORPdo0ibTWHawdWF5DHBfpTPUUMG7DYQ9EALf+G/ctZtlCPGApj5F++rIxC4cF4dua8Daw7rpEOS8mlqSbGodX/J5vMDuFJ0ijHMtHNZrfKdmrYwmsgoctO1wAYpLe84/uONMacu5OnRQwFVRypL9QwFnznfVj3ed1Hpihhgj77uCeCEmlf3ov0zInDCQk5bcOGZHmZqtHpKTmOYWho2TY4bUSYiSzIOvBM8mbg+iTIyfTPbVxA02YVIvMPatWixBzIn5Om645Emjgoei3Nykc40Xjh4vi0WVVR4i81x5ju53BuWzwCulbnBNM15AdMYdUlHCxs3GJhSarvzvOXrGXBWLdMdDc5c8SAjz7tbSJJvs4yjafHWciY/36n5P2Wb1E0eyoy049G8uPVsYu2YthsxVhnM3bwzdlc4HM759JdZfaUy1OYVWMsbiaBZyEcCBn9rJClAiHFIIRWp/n5kDYCoWnhoKLwl2utrPR2GVgKd0HxDqdPLegXF0AA0XbmJSde33DMTD3l7Ijywa3OJYKOx0Elr4FlkN2RO/Bj0Ynuu1GY51m4SOo5UMhbWr+ij0tD9QNhADeV7Y9cT+RWCslBUv8KGpKH3RtxfUO9nHigCD/zquEFtrG1Uh+YefnDmusHkm2wOZXSQ7WCKBQaul03KqO/X39UUV7heRV5pT5xxK5c7rrib/r+PfvyJi0AbCY/JmM1GDz+89r9H+Z4CGBPxA/9zATKq9+4pLZD0vK4C06Ox1H8UVG0yn7wKd6l5eFRmIREQDm3/Fnk3UZRDBhqSEH1ny31GOFpBQS0rgz1vMRAOdus/+Fjk4q1Mq7LgxpmoGrNtD+aWjIU9o4qdDqh9waggAnyRhKTgOrZI1wqLvzM8QiS3bl9cwrwCpR3gjBCZXc+32qfMEjO+lslwRsGFFRRF3TKtOBOHrIaWfnNjip8o7fm/zJAU0BMZoBZJ8VBWRZLhDTnTt5MUyIqQveo9U94pIVtt45t2rM5bZm/GqcnkJ499a1+tBjgdFDBWzvrUkIILgpmyXRk2+sdtBfEaMTT5VsX4GLhzjGpezx/mQUlIbuBiNJi7+VaCSTNnEwPlhxPFxs6/7QpNVWoZQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 30727cc3-e684-4c56-60a3-08db839b6e80 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2023 12:19:40.2151 (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: rYUvwGL+e/loYarrmwALywTFUMMaD+Mqd0uHddnZNNLwOAhzm7V42zclADX/R5no5Fz+jQg6sQ3J2wkmsbngZw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB8010 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230713_051947_894716_66EB6A92 X-CRM114-Status: GOOD ( 17.97 ) 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. Signed-off-by: Vladimir Oltean Reviewed-by: Wei Fang < wei.fang@nxp.com > Reviewed-by: Wei Fang --- Changes in v7: - Patch is new drivers/net/ethernet/freescale/fec.h | 5 ++- drivers/net/ethernet/freescale/fec_main.c | 52 +++++++++++++++++------ drivers/net/ethernet/freescale/fec_ptp.c | 31 +++++--------- 3 files changed, 52 insertions(+), 36 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h index 9939ccafb556..d4ae0e7c0a44 100644 --- a/drivers/net/ethernet/freescale/fec.h +++ b/drivers/net/ethernet/freescale/fec.h @@ -691,8 +691,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 1280da699fa3..c0b68fc3ec8b 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3196,7 +3196,6 @@ static const struct ethtool_ops fec_enet_ethtool_ops = { 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)) @@ -3205,19 +3204,6 @@ static int fec_enet_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd) 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); } @@ -3868,6 +3854,42 @@ 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 (!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 (!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, @@ -3884,6 +3906,8 @@ static const struct net_device_ops fec_netdev_ops = { .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 ab86bb8562ef..3f53b8ae57dd 100644 --- a/drivers/net/ethernet/freescale/fec_ptp.c +++ b/drivers/net/ethernet/freescale/fec_ptp.c @@ -618,16 +618,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; @@ -638,33 +634,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 Thu Jul 13 12:19:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13311961 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 DB6CCC0015E for ; Thu, 13 Jul 2023 12:20:39 +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=hla8s7IigDJiG3OLiEikMdCBHF6fBdHJuiuzpTHvdh4=; b=H13K8/Ez9rZTVp JSDo+kf9d/uLosfB8MSRL47a3T3h11N0gX55qpQoaFMBs+lM3MXTkub0HfOdeSru68duRC6ak+IjU KWwLVrliA627t7onU40rsdxFts5eWPNgecKZcGnja4An64wdW6SNB1qj14ZJhzqedEs+3gJhz5CWr em/xAUtmkcrySqQmvn+qtvZ4NDxZIXIERKdJQKMBLT2lCvbMsCLqkksTL+cfdLpARaC7Kevum612U lBYDmwGFY5Q0QL9n9vmZIXqVZ1kClE8x+Ey8TVk+KKIExfz13AsJHP6/pggAekUpGxT0hxlOkxxtK kyLKbXNYsMeXHSbEN3Cw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qJvIm-003Dbn-1Z; Thu, 13 Jul 2023 12:20:08 +0000 Received: from mail-dbaeur03on20600.outbound.protection.outlook.com ([2a01:111:f400:fe1a::600] helo=EUR03-DBA-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qJvIT-003DL0-2B for linux-arm-kernel@lists.infradead.org; Thu, 13 Jul 2023 12:19:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z60wVrX3qFpvvnFsymNPA8f2rXxXQnqmCVR4ZCYNIAjRJie/p1iAl1x2LP8JHo2BrNVBX2AqDJ2036P5WCcAfEH0OdeZtY5MSuAiAnd3Qn2cFwRWkKS/JrMhWTmx6+VJdKyxi/rf5E9qtwWsjl/5YtDiIFjXRxQjcP2qjI+9bX18yUBdfndP2dberZsUgKeEA4jeCb0xWx6aipJEg2JUaZsoEQ0/ni39zydyrK2jX/0OPCkMx1DbKho2+1iAjj9yFBKBALOlB2VOkne8D0IEfXpsHNdvNqAPr877Bfa0zptI+oX+8v9OI40NCBzJds7VGXY9Vmjnd2dPBagf4rj1uQ== 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=vZN3LC1u84wbWSCmba9zZEM9FLZr7JSy2wnRUwg4LxQ=; b=hDE0eyEfquQHFN0K4dJTKpO0XdYY5KL6OEbIZli8sF8aya/8MWxU3CERB7DnKrhyDVkydImPpbUwe3w0onCnmw2tKoNFH+L0SvpW8enE3HzlrEPHwfG+XzXkwNwc9QiK8ERKhQ5T+nqk4tM6xqmEgIuBvLHdA9R2wQkX4tvYPUAogfeyd3DQ/Z6KhN1fKAV8R2aariNH/h2ejcKwtfOQUi7hTQpweuHrLLBJVeF3vJhY1km9YY0/7ZAE2XjxocnZVOs9tRu3fsZ2OIdqS7YJPrDaBUJHHU4d3LfuQJLMF+QpQhpty2d/ERHC5O3hJ/UV4SlqZjX6XyBquJXs8guvmg== 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=vZN3LC1u84wbWSCmba9zZEM9FLZr7JSy2wnRUwg4LxQ=; b=rU8wCBTxhHxI9Pb0ei+GXi7gqKjud8uvUr5zLZ1QgXJrPO0qw7b5dOVLq9dEzlHCNaHwp0ALR4dU3Dml69ubMKKnEyi77FHzwZde54LQXYmspuz+9P9zc52NVrk6TLOERXxNPy1gtAdHpXpRqyOZjIoRAXDgJEIZAJKxZPN/Y0M= 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 DBBPR04MB8010.eurprd04.prod.outlook.com (2603:10a6:10:1f1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.20; Thu, 13 Jul 2023 12:19:41 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::cc2a:5d80:9dbd:d850]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::cc2a:5d80:9dbd:d850%7]) with mapi id 15.20.6588.017; Thu, 13 Jul 2023 12:19:41 +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 , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 net-next 07/10] net: fec: delete fec_ptp_disable_hwts() Date: Thu, 13 Jul 2023 15:19:04 +0300 Message-Id: <20230713121907.3249291-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230713121907.3249291-1-vladimir.oltean@nxp.com> References: <20230713121907.3249291-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0157.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:99::18) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|DBBPR04MB8010:EE_ X-MS-Office365-Filtering-Correlation-Id: 5aa13af7-6970-4802-a018-08db839b6f86 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: S7uUtpWorxFa8hby1Y9VsDSlsvoiqWIH98vRX8FLyhyBDHOmrWLDpCMZt+l54D/n339ZmdFFWAJh6Zeyh6WcLGjFIqVnkMtT+wh8KeaUugaHeFkPTjoNJR2TfWa9eD9wpqAeWbO6iSVO958jSocYH9nu7+kC8q/6wBVC/Z2/uhzbpVzmV093gZxWVKK0it7shNTGv80+cBrIbT9SbV1J6E+wSqVpO7sT/wWelH8FZ3o2wyxEPelvIFanxqOza6cKoWPENW9Sy+l5B88nS3zu5q3+v020ggZXVpMYyRBevSV3aH2YgO8XY2+udv8vpJpAlEocy/mMeSk8QEAzulEQr/HSZ6vJKf4l8UiEqMry657oiDqsLvQCx/wEL+deIevVoilxIGDOa+KDImFTqKsB2auoj+Tj2462VgZ3Mht9HdRUZoI+GiggIL3l462FO50anwrwj0mdhyrmMyG3cw998fuGZP9LP92J8xjJOTuj4SS7AmhsjUQD9FyWZCTcgv/6AXUFcp/0ZuJzNDZENAvhrKJ01zSUN8CtmDDdXOJ2Hxoraxi+RQzCKLIKSRKSHYewafB+yvL9qdrsicsHLrg+D/iqaA50Y33HoxTVOsHTCM82XWI5kuu/YgO+Z234vqMH 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)(136003)(366004)(346002)(39860400002)(376002)(396003)(451199021)(6512007)(6916009)(4326008)(66556008)(66946007)(66476007)(38350700002)(38100700002)(86362001)(186003)(1076003)(26005)(6506007)(2616005)(83380400001)(52116002)(36756003)(478600001)(54906003)(41300700001)(5660300002)(8676002)(8936002)(44832011)(6486002)(6666004)(316002)(2906002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: F5JjBa29qsf58ncpZe/tDQqwh8pnYYjItFE+RNXqy2Ha/DMLQNHF7gAPa2R+JzoInO1vONNvcUTfSOSL73uYFo+wX2GF/f9lNc2U72Na8kqGjD7WCAd5AzA/T3rMmRresUrw1GwDwR32MYcPapJa4AQX/4+HgV3ZE2wqD5G1D5NY92ZUy2OdbQkK72OdRhKLsZcjFl2zP8JqJuDsO3Iyjsli5pr13s/D67UTIqi+qZTEmOBjLC3ePvXu1k+PrFBnBf3S7bZF+IjcsdLdOMBKWPyGwRdCzut91m8ZYzZS4JkY7NDma2sSogPGr2PqWg41MTz1bPK1aHQTVTNZHT5n3KTzVct+umu+roPNA6jWZWR7tofcic3BQ+tJ/ReVTi2dXPBnhKilM3x+aBRq00Hk8Zj7gH24p0cdb/CyTbVrPsDEv2QpuNSgH71rDzNoL36sCU1A3/TMDkG9r+3Ur7O8JLQ3mF7sVN+EAI7g99LIr9rkyv3QNE45UToEdIHc67kz3in2OzqnZhr7LDLwha0xLd/9QBYuY5dLqh9itYvqpnR8dNvBynHoVtgp5e4oluSEY9bbhDr2aVQ5mr+48zkroY++wX0e1iJ09HduPPWjNl8nGuRgc4sJcW9hFqldMpdHnV/Jua7xgF0NEppTWd3YtBQgXR6fC2kktT4jqDCnBL5UpT6dAUgCIuXvmTVWI5cBBv7bb77bJeZwvJzK8eNR+BCQSjldWSdStt7sgl3cN7fCRJke+1MFT/GT1HAMEcnuxnJvEyVdgZf/gmSMSpV+5nEjRzVBoObCLqfmzw4PujaThHnuGdYQbL2EDZlisRpU86skplV3VaSTlpgI7R21S147zdt7YwqAhjD5Rg47EGJrQTtrH6D5bWLRHE1fCONmB89ZM15Yq8s+vnLw2bhdTmejDU6+3dxkVd8ssxIbWS32mO4Vl9Ah0VOeu9zy3lqmoK4/Dm2SXOMKzVIDjVm4KbdE17T9EdSIPIm/dU4PICrEKAmAAzB2Tn2uZO9VFwW3qzzUmbxBiVYJJrJ3ZfI1tOJQVwb4V3ez+9Ot+Y1Z3Ldhg6Fcwlx/VNcCrPgBaHVOiqGnyHPKAR/UJxfBBOIwUuCEEZsdFXypaCAcQY5yYgfWLjVh4BeAKrZQjOMVJArjGa0hA19X75J2MvMSBv0hbnplurbP0/R5ez1YF/gUKmu2cvLwcDM6+LtCAAQoiGJSMs8wUzreEwukWTqNXHsAPEbNSPd4yIc+VsG/ylbPkFgMsjMrK16HISt/UoWCbBf+GUg67KzLy53qY6uwos0yR+cHLSb0agf6omNqaSv7l1QtU4IWtiUc2JDZ+T0sinmpdv8dFYOwkgKFFd3EuH5jWF0q60fQ1iHtejPZ1dKqoucZUO9DD+RsFqsz+TzI5yweXgWwRrXOV0yArnerlvQg8g7KWfOvEkszUucQtP1kZIUq0UPmX/od8tauYAd/o6i2pyRXTGU46bg8HKGmTs+3X3m5YFcP0DdN1QYkRPW4QTAz9i3qAELvS7WR6Q2fRdop5/VtIQZe2bgrAI96x87JjJqHZBECVL8/IsYTvatLQ4ezxisIp8l0H2XkVZIqQKob66Ndzga6ywUOH7bNktUi2A== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5aa13af7-6970-4802-a018-08db839b6f86 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2023 12:19:41.8778 (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: ZvTheOHjBPRlKT4zN0iv0xJbncTRtjBVQL+m0qolAYvylJ5t5ivHOsfuozLzuYrqo5Uo0ugXwDHpishDffO75g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB8010 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230713_051949_725768_69F12AC9 X-CRM114-Status: GOOD ( 16.56 ) 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: Wei Fang < wei.fang@nxp.com > --- 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 d4ae0e7c0a44..e273129d44c9 100644 --- a/drivers/net/ethernet/freescale/fec.h +++ b/drivers/net/ethernet/freescale/fec.h @@ -690,7 +690,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 c0b68fc3ec8b..08744e8164e3 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3878,11 +3878,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 (!fep->bufdesc_ex) return -EOPNOTSUPP; diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c index 3f53b8ae57dd..55cf98557e02 100644 --- a/drivers/net/ethernet/freescale/fec_ptp.c +++ b/drivers/net/ethernet/freescale/fec_ptp.c @@ -606,18 +606,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 Thu Jul 13 12:19:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13311960 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 2EB7EEB64DD for ; Thu, 13 Jul 2023 12:20:38 +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=gifg5d7JZfRlT5FrADcYF4KdxeYs0gSz4IQ/Vono2uI=; b=jy9xaNoheQqxtO mOqlBdMl0ygAkVDtonYbCGvj1BNFDEalss4KBHfcs8v6BRDIuT48TJ0OnTKzuGFuCxjiRjDSLEL+x RQ1E/UsexszRakIxKlYLqe1HDxfYjX1TfkYa5GNJfHxnH6gl8DRtWPyFC2h+Ia6O9ipv8nn7n0ZQJ h/r85+BBlPc3zbeZkpDm894wiZIQwbEuOQAN/uggWy+kNra2IzLXTRBT3DDnddTnvbV2+7VDbnT4/ QHjmhiip51wZ7FMLc63B3d6p/kKoemqKHYlAbZDBK/Z8hHgC772a+KvBQKo86RxpfHiXAj4p4Z7vN 4UuAOnzIVPAz1tdGgWkg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qJvIn-003DcM-16; Thu, 13 Jul 2023 12:20:09 +0000 Received: from mail-dbaeur03on20600.outbound.protection.outlook.com ([2a01:111:f400:fe1a::600] helo=EUR03-DBA-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qJvIV-003DL0-15 for linux-arm-kernel@lists.infradead.org; Thu, 13 Jul 2023 12:19:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=heztaZIfSkg+mO+ssre+YSX90ZWJO3crpc9PDtGCH6TRxrGvbJ65d3UBRkDsQ295IoOU5aTrPN6NzyB9a9gShW4JCmVPY9detBEE6swYJEBsDw4y6Oluj8GfolUBx7b7D0rn+nucFwaK96FFflrpAAyMOEIrC5TWJAbKa0yUGh985Q8Q5ZmGwBsmQ3aidtIYYtxcUkoRODB1RVaADml9okXAJK7rVhoMfNE+fan+FQt4JDAVM9mEx9dLYkqFe+0T4uIGYqKm0YURk/mVGkr7UreiGUYy0sgTK/1GmQIi0u5zCqLGWbQVJvx2X+wwBuYyf8/4vgXjf4zI3/Uqwd3qLA== 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=uLkzBOcU3Rh9goaRBRdupRrK29DioHKXaC01OtafE5c=; b=QnCHYXx/vcxbqawLXeSqpEz/AW6IbMdeBDAk9LfDngR2F9ojtyD5IUgyaC8e6QyF9SijdVgO2i8CO8qyl77/zNlE/3TmlgveEHzAru+YNXF1gdnbDRB9b36gTupFQMocEXHB5w7QcssFth6zq7MnRODfEwHmppIQriRVTTQZizD9Szw7alAhZOHW8fBesNfNpYjhY9h5elaZVQ5AJ1BSyhLGAFLGe9W4+9g0dumMXVW2kHPO8nhNNhO+bj7IE24ZwdBbipMlRUTNj9Ft2VMbzqxMoZYPFvcFvxflGsqlWtJiS5JFqoq1qpMH9jjYNC/mNNtlhfz8xPDWXe4bh5X53Q== 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=uLkzBOcU3Rh9goaRBRdupRrK29DioHKXaC01OtafE5c=; b=npM85y+9OQQ9m+WDRJYPYMY0QxcNZiIKZVP8UXgy1cFYyhU0JC/JKTGSzGpjuRWUPlq9INP+b1Gt/6xlxYx+EYy7nH4/IeWRKAEEn48eG1nVc0NZ1fwM6zEwl0IS6ijfo477poNQE0Kx/ebbHS9DDrehLUjgB8J6I9gpK3xGIeg= 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 DBBPR04MB8010.eurprd04.prod.outlook.com (2603:10a6:10:1f1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.20; Thu, 13 Jul 2023 12:19:43 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::cc2a:5d80:9dbd:d850]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::cc2a:5d80:9dbd:d850%7]) with mapi id 15.20.6588.017; Thu, 13 Jul 2023 12:19:43 +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 , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 net-next 08/10] net: sparx5: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set() Date: Thu, 13 Jul 2023 15:19:05 +0300 Message-Id: <20230713121907.3249291-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230713121907.3249291-1-vladimir.oltean@nxp.com> References: <20230713121907.3249291-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0157.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:99::18) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|DBBPR04MB8010:EE_ X-MS-Office365-Filtering-Correlation-Id: 4e5d3c5c-3e99-414d-dfa0-08db839b708c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3dfuK2+Bcm8EKIj5REnCIgbfvsY2CBXLqHQTwEqJdhkDM2CgfFuqAmd7sy102drGwqDXD9+8F0MMF+33mycBqlr8HFIvSx8+qLDKQlil5ok+hdzlSWTn9PDiiHa4KwwbvLcxK3vtosInASNSpgh4O3CPhOWxgzKjRKovaj7TNMj58J8PRvDPPAkktnDpme5aKa8XsAXy/qEqz8pDmhqWbgeYXs8xud9Gv+4VQhkB2MVrXOXNJhyePah6AeyxnuC52fFpQ0ydp4vwbaflPsocDFmTZttpqKW9XJKxVi7nqJ924+0cjcjvVyY914RVmct0HUIAoQJqR9af6OV/dNxrWYbI8K+VvumzpwNQAMcuM0Ad19CNcjEAoawYHPdkrFi1w0ofbjCKEvbXaa+W56LVq8d2eykLSoIxC84LTYwGaHwQa7Hg+P2NCtzhDm9r9eqHrYSiUo5fr6HUhQc+1xkb+X3+I+jXyxnrWAEql7UySp4tOoU8cf6OX36CpPj3ZenKd42sTODvWO+dtkKD8DBwmIOqBjDACQuZZDCeUmSNrOJi2CFsrfOGYq8UTxG+AUDvpW3jCEYJqrYLgG5e+6fp1PZ5Xg9cHhhQ/g6crE0kFHiVjjOlwo3vmX09ikZ090BI 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)(136003)(366004)(346002)(39860400002)(376002)(396003)(451199021)(6512007)(6916009)(4326008)(66556008)(66946007)(66476007)(38350700002)(38100700002)(86362001)(186003)(1076003)(26005)(6506007)(2616005)(83380400001)(52116002)(36756003)(478600001)(54906003)(41300700001)(5660300002)(8676002)(8936002)(44832011)(6486002)(6666004)(316002)(2906002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xxR+Ur1KfXiqyuc+Z0iN/PUVcjvT7XMfR9JGf0TfcyE6R4KLVVi8HPVkG+D3hJO878nqm6P8EPHipy0bPig8ukJRyXk7Fd9ApoWLX0TItlVgnPcEhQMmbo1p9Gh5FMITy4+nwCHnOSWqQJ99TeX0mXHzaLqZAF2s7Nv+cLz2zeE6Q3HDOJ2KQ6XRDnC0py7BXIt4v6FZQoriHVnDUTc7X8CMGdz8IEMCua1uXY/SJBxNxKGUmMHdYYRmK6/ITjukBvzB8RUd3uFz25eo/zLYHaZb/8hRKqgsFi59hkOxDKij3DwTR6KzeZsvC8D1WzfiAB6GmxM9FiHC2vGeKbURUZB0DnBSTGDvUtX1Df4Nia8Y8KfGi+ZqMMceJrIf0FLvsKVhNtb73rLLt29bFYMQUIVgQykgE/Be2A7st8h4xxpTuUhoMe2GTFA999zyJ/+yHpbFOokPVO8a1OwNMWJzPZtJhtUxWf2fVbWIWHoUGzY1bBcQALHwD/tkQsFQtiHBkzNUKmIOl5xmsXcpQlOJjWVgmC7Pl2/+3wtg5PU5x90akjf4ypBRj1qGGP8fqR/MGGmTKlJDSbRlJjvGcbSx0sdzmzEqrBL4x/G6OfzpjWUTGRkpILOQRsijuNyw45qZYPBuL7FPH/itObw6NmvOKbIvPuRzs61kTGD+bJZvIPrV4J1WpROcBp0sbumV0aJEHVotphQuWMaBMbwsu4WE+Kxrc+HAi1znFd2J8liZT/ShZF2FQCW3oyyq0ktTTNM4VYWDYQAkwtl+4ekLwDB1IwGZ2MbVWDDQ9NWPHI4agZIJt8+TKXsIQZkI0fvV9q5RqasvzLLBAPSi8d4yYEiK4b4sSdoDP0zx/Jj/95NuY2yp/+eWLxE3Z8p3hNDoaoaA4dX0ONqgLzC3/l3PwUBJscVExi1aPsllyMAYQT30QtGeUCb4AE2jKTtS6J6jWRz6qlNDSKGenFI2+Q2AuHtiQAdstL8mGaHjbfCUJdENksVtYok92iKIk8LaGc08Yn41d25CAauSPGE8N4WUKej3DQNMj+hgfN9xXOKh04XxZOncdyXyt3rFcuaSNowHAWB4tNz5A/SnZjTRP3/XUaxtn65Mk+X4c/6aRAE7xB/Q4bmm6NPMOfWMFHLqsU8xFBpcXE8ifj+UGXf7seCVJqSzlvlsNkf/pX01GUPkTcPov/ZVhABoTrrvMm+kQc3CWGooj6tkM6wGWnYIda0xGedDLvKCpGoByAGM0G1nmzZJNvecFAtPyBeHkdrsXD2zllxsYz+EPYJAy33jzbCeN8lxDj4ZOcV5q5cHN6s4y37tHL9Q1xoLBO3/stBObdZXioX6kH70bmC/EJM1RlfASe+ejzDGDppJX8PDD14Hg96c8Vd60qyG6CljJWoO5+TI8QgUgt9Wggo9COdPBO3Ajnb8rKbIHxwlYgDmfsVv3wiLTZj6QIWEJ6ktNfOSsy9MnyOm3OA42KMuHn7V8j0mOMPxjChaOn3iEpg69F522Gby6qB3NLeMzepRbkf1iVNtyYOk1OnOSrFOfsZ0zq1uNZy6BftIWOULbsvPMjj8WD4qmbw4dJF0ma94JmuWGY2TiZXQcVUbhWEfihIX9bGY4H/XpA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e5d3c5c-3e99-414d-dfa0-08db839b708c X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2023 12:19:43.6308 (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: tNuaWYfCNnxxMBNS7GDWs8VCg+UOwpy7Z3ExJtNh2gE9TXygVKjt8YHvqHp9ub1dWxtZ4Nf9+c6xsy/O/7nS2w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB8010 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230713_051951_378664_429DC284 X-CRM114-Status: GOOD ( 17.78 ) 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. Signed-off-by: Vladimir Oltean --- 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, 49 insertions(+), 25 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..573662d2e01a 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c @@ -212,20 +212,41 @@ static int sparx5_get_port_parent_id(struct net_device *dev, static int sparx5_port_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) +{ + return phy_mii_ioctl(dev->phydev, ifr, 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); - return phy_mii_ioctl(dev->phydev, ifr, cmd); + 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 sparx5_ptp_hwtstamp_set(sparx5_port, cfg, extack); } static const struct net_device_ops sparx5_port_netdev_ops = { @@ -240,6 +261,8 @@ static const struct net_device_ops sparx5_port_netdev_ops = { .ndo_get_port_parent_id = sparx5_get_port_parent_id, .ndo_eth_ioctl = sparx5_port_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 Thu Jul 13 12:19:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13311963 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 C05BAEB64DD for ; Thu, 13 Jul 2023 12:20:42 +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=B2K7TWIUziLKMnV8wP3QZV+Kss+my7aEMz9mDjqQZrw=; b=rxfF9QfuA+w0X6 UACgBz4ZTAwK5RldxipPQm3kH78LM3d0FOmQZgb9RmzWnMhi2powHYrTgMXlNHL+vCusmtnYW+h4O 6SUCyliWNNwaXsOgeWX9G9EkPH4EoTzjZoZsn4Iwd6QscDwSsZy+iW7pCm5JqEbHBkclYsnVe47S0 X3WE14c2oT0yjVZ/bOenXXTP0RpemnzN2aSf6NH8db4KGKzJ4v71z2MwZgd9K+Tu24WF+oWgz21sH tfwX69SIPRDT2U/XjUK9++uGxVvxzNn1MvvOpWmIBJBDETlDwrmwqXmgWcolXA8RqJ0JCxfPr03my KgC6Q64GXVF5oOiaOK8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qJvIo-003Dd7-1X; Thu, 13 Jul 2023 12:20:10 +0000 Received: from mail-dbaeur03on20600.outbound.protection.outlook.com ([2a01:111:f400:fe1a::600] helo=EUR03-DBA-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qJvIX-003DL0-0z for linux-arm-kernel@lists.infradead.org; Thu, 13 Jul 2023 12:19:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Oa8e3MPvvtyP0rCmUd0Nwcurk4okdRx74089kDJ/x7SXABH8Eh0XrVt2XOjT1mf7iSTfW2VsFN1G7gPiJNnEwStVeqebkgEVnvgaQrQq6ubwdmX4dnttm4YTHEXbvO+nrpWwh9qQHOM3kUFjEVvWkD+MfWuYoiweCUmJwDpeejAtgMyMhVPHMlMnG0iMWy816E4dLDOnomXFfTfjFDdQJcM4xRLe5iok54R1ajKZe9LF4WvKNsfAAxD/76uXkqJoBiFb+JvsG6rhObqtONy7aQOPA6xZv1uyZ3S4ypQrK6xVYaMduElQeC6goneojkHSeix3v0vbTo0tssiVZOcfkg== 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=08+LrpSnI8/cBjjmyEuc2nNng6d3fOw9tSpootjuokM=; b=RHF98BPEIonmTQATODTS5uju/bef+IEs0lGgl+5SBH4Z5EKuL9ENN7Jpx83mpuCUDiMECe5aNNsKnr4QFu5sY1yKpTWoKsL/vKNs3nOyWHhwJsbgphOSSW92SiZy31HhcZx3rn9eVBArpoMo7Tzg7/fTq/1MVN96DLfwtJGVevFj3eTWUbXmqlwUC5szoYaabRunmiQS9LPuW/gBs3cNunpnmpG6hXhVHaszfaLekjnMUHG4TjvILVhB9WmlraRjcc4upVIToLTkAS8ITPXCpuKQAgCDamJbFFg51b/pdzeg5HWg+mxJHk9Wbseum1qbktBaDvLBD1mNXrSv4VuCsQ== 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=08+LrpSnI8/cBjjmyEuc2nNng6d3fOw9tSpootjuokM=; b=Ed82wVlP8Cl7wbn+mLI6eq8uZ0J4WUz6IRYzvC6NBTnpl4sgHsLGRxZ6EoXcTX6NyadFGByYe9ofVl5I2o4sJAQNb/jKqX6SQrj4kI9B0r+ogMWmYPylnyAa4W0zVuzqLhkXqFMEX9SxD4bF0jRvSkQnC26ghbKJJQN4TrEX82s= 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 DBBPR04MB8010.eurprd04.prod.outlook.com (2603:10a6:10:1f1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.20; Thu, 13 Jul 2023 12:19:45 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::cc2a:5d80:9dbd:d850]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::cc2a:5d80:9dbd:d850%7]) with mapi id 15.20.6588.017; Thu, 13 Jul 2023 12:19:45 +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 , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 net-next 09/10] net: lan966x: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set() Date: Thu, 13 Jul 2023 15:19:06 +0300 Message-Id: <20230713121907.3249291-10-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230713121907.3249291-1-vladimir.oltean@nxp.com> References: <20230713121907.3249291-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0157.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:99::18) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|DBBPR04MB8010:EE_ X-MS-Office365-Filtering-Correlation-Id: c4c598c5-4dfc-4671-bcd1-08db839b7190 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IGJghodX4DvzFnQGUdKQuCuABFbU5ZZmkAnSsKoX5sKYaZxlr4Kf1ZcFjTUQbxxScPe04ZJj6BUe4ieOYuWObyBvgnxmB0wkBn9/G876Y+TLNepXp+i5r6lrgyXtZ+MlmsgzIwl52SwVD0YxTwOQ2GboGLzic5va1JCsVLr/RDWsNWkWsXru6nSQf7GJu6v+8sobewvdDnvuZk5mM+UpOZZ1lcnR0kcCGPhvfNfiSBgTJdCsoTjjYGLlAk1FF8vznIwcjOkeSQBxsXmo+2IOF2gTpPOrMl1LsF8YkuUSbnvy6d42nN7M9n0QRiv/MFp4t9Am3NkNPt3jdGsBvPPfqC42zMv+/WdpXxeHe3K3QfGRUVZ3Q8EWsO0IjXMYbo9zQYCElvQnprJ/D0ViszIn6Thm9jzn9DEci8nl81tuj+zKthRiWijr5khN8lWdBbS52+wQ72MCgUlAYyHyot5ucAc28VMcQmgYXFhljkDZHWReVgCzXbgz7kZjkWWpN4ClLYXaRSz25wZepuRcVZq+fwNrGFlakn6prpNGXpCf9XH4uhju4mPpWlDB2jZValQ1aErjH6JtX/zP1w4hLwh2yTRQzlSN3fgF66ZXTsUKpBtPyDSwjr/HsSwUx0FEg7Tq 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)(136003)(366004)(346002)(39860400002)(376002)(396003)(451199021)(6512007)(6916009)(4326008)(66556008)(66946007)(66476007)(38350700002)(38100700002)(86362001)(186003)(1076003)(26005)(6506007)(2616005)(83380400001)(52116002)(36756003)(478600001)(54906003)(41300700001)(5660300002)(8676002)(8936002)(44832011)(6486002)(6666004)(316002)(2906002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SPcBQ0WabC0TUfQGtnmyh21ie19lfqCGv4HwJDyXID6P+HEZZUQcuU09/G+723EEtFXU3VOs80sHGPmbxYaqIBhlFkSVsr5SJ2AN9etWBlQKxgpaL32Jh91XyrpuFKEVTUYys5pP+q1yzZfND5AgH+DZTNEBt4UXMXDgZrAvjlaoKQFmAG+D73WMtf9g5jP9tlC75jH1Ox1NxdmJbCs98ZHdRHTGwZpycD+VCYwyxwO/CO+qTiq/02gJSJuS/cZIyg4A2kxJ6oYUyy5bdit/OgcEfbivnTv72x9wWzlv5lIL8xR0HSZt+7xEskf0xSNyFB7HXHwRuQSExmI4mUQ7D+SdnS+emvZNkitF74+qPynrqfvllKHfzwV0EDFRb1BCIjXt89KH8Kq1rxCI2P+kJfCwiz8xCngq+mh2SS7ykGshd9rWsBCxGTWCM/Wdm5R5dWOtFnf3C6QbbamhlNSlDPruEuaVctOXfe69X+lmYpE14BG+nTzWkmWkdcEUsx1KJw5kkFlkI0lkjXdJDsGezUfSw3UrIWyrBS2UVrMzBhck9IS612Ye82skYSFKt/e177sdo+wRzJ/ntoA7APvqeA+rkXYG+CIkfkmSVc02FdNkQgb9T0a/1PC+UgMCimb/iQzF5TIZviZqRqhDLy6/0qmPAi4ODHGJTDQAFapbQvlYCZczDSja0Do5NF/eqW6GR8xJoJTwWLNwXQGz0tEjUyITOgLVZFBynFl8J5Utsxa+/UxT7JsAt1md/eEkqvIGNYVjBBX40eobP98e9luZl882rJjnqzcMLl1U7eWE66c4S3WVlOK8+LEBkUqDnXKNXJROtPhKoQ5Nnzj+QLU/zURDBynsgVrg8xXDIJnrBYjhQNjNrDlwssMWnFV6aoT0V5yAy/hia2iRJp/3qjrwCk3m5zIxMh2NBR/etgplTuSadFWBsbkD72/UAy1yt09rSsy5hcEuCLsf5i6WjG0kSRnvw/bUhAxMuCf5vet/mehRVDiOW8GEik2sX7Gqje3vpl4zpD+WQbFzxFHMyiMtnCbYlSXkLvTadnAp1iRTfK37kIlBmgxLtZQZcp881zk328BQ47+MQ30tRfaplONRUV9+7KGRvFwtGIRBK0OgEgrCn+8i7QBTlF9GGFC+oVRryo6PIBJ/6Cl9gyxW5GLKXTjb6SnevdJ+H6UbvZFZdMUBUxxdvFSG/x07LFfv6Foo90lRCon+5L+hQo1uUb3iZvTrGDHoqVNVX9KIKmAxz8htUQMZKw6kUKLzbaME1t/SKuVn27C1sL4SCNbj1g6Im2FN7n5bmTJGsXyQI2wotwZBSvGCmF7TgNKpNj6VIPPrvloZjwuf04TKt6Ci4lBo84JKDJNa/7TSFjQ6sGoBnUYKWDU7K+8XXhoWfLtIHU4xEso9rqVQ8O/LeZ1AgzBfoZRvxfRQgsGfU0qzOu+Ll6pxs9MOyF/5bisTTUv7+vR3NBcg/B70Y8QMJqwxRfU6+vraEM2VuRiqyaa+D8Th12bsPVl3zVubU9K8SUyaOGBT2/LdSGbMFY2aUGdPGvhkIP6ymLnFDOOR/NerQUbC1+Dc2vYdj7JfoSRHfzYnFv+EMAJ8K8DjVjtXs4su9+Of4A== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c4c598c5-4dfc-4671-bcd1-08db839b7190 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2023 12:19:45.3273 (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: uVIvghoRqtm0c+zqdE4xcrt4SLExnWNTchAXA3sJgHtZAVwyituOA4K0gJGGvxYAupuqN+/HstRAaSy6LTGqSg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB8010 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230713_051953_491379_3DE4BBBC X-CRM114-Status: GOOD ( 18.34 ) 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. Signed-off-by: Vladimir Oltean --- Changes in v7: - Patch is new .../ethernet/microchip/lan966x/lan966x_main.c | 62 ++++++++++++------- .../ethernet/microchip/lan966x/lan966x_main.h | 12 ++-- .../ethernet/microchip/lan966x/lan966x_ptp.c | 34 +++++----- 3 files changed, 61 insertions(+), 47 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c index fbb0bb4594cd..c8fce4e79c63 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c @@ -451,37 +451,51 @@ static int lan966x_port_get_parent_id(struct net_device *dev, static int lan966x_port_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) +{ + if (!dev->phydev) + return -ENODEV; + + return phy_mii_ioctl(dev->phydev, ifr, 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 = { @@ -498,6 +512,8 @@ static const struct net_device_ops lan966x_port_netdev_ops = { .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 Thu Jul 13 12:19:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13311962 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 BDEF0C001DF for ; Thu, 13 Jul 2023 12:20:41 +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=7IvlF4Sw4gzbfME257ED0Tlbu5FWQE1d2liF7SeeDio=; b=kkzk3ce/0Yi/3N lp4Slcd+/dkyTNKNrETIfQQBJwC9P27zztljmuIZnd49YGeJXNDNOwTCMznpv7jzhR3U5z0ZXTCvF p6rDGTJ60/pFtxeSVCsmkADC7XQ829TBytnu6vDg38Mc6nFIMQSMCOi9kWMpycW9gWh2QAsAxR3eC ZkIcu7Gl9Qb9inwBNavd0sLxTkmtuDxZKU3+9AruuZiNCuWSSP9Gh5haryKqi9yzuNcNnFCAoQpE+ AHjBn4tewdJLH4NJqTeeD46xqZ8mCfr82+qxZZTgqwf/FKzOq7qYrD8GbmMbtY0k+ynaMkGb8NOib oaKMmzPlJjchlLKa0ShA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qJvIp-003Ddq-2h; Thu, 13 Jul 2023 12:20:11 +0000 Received: from mail-dbaeur03on20600.outbound.protection.outlook.com ([2a01:111:f400:fe1a::600] helo=EUR03-DBA-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qJvIZ-003DL0-1f for linux-arm-kernel@lists.infradead.org; Thu, 13 Jul 2023 12:19:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WYN07h8fU/HlFd+/X7Y1mund7TJCa7xSIHaftfNcnrk3MmCcc+Wn+tTkrBu49ZH16isS1O6htkNJGOE78kiTCT6NS/46ssA6XGV14c5+8RNTmblNVgZANu2bBoHxAeQWt0p3/2Blt0doRl0otErhPEbm7BjY8IJ59BdQo2XuuXzWwkiDKc90koZV//vTgSwznKMqSguKJbhm/YE8ZiTzxQW+zz299Yz4d3we6qQCb+8mC3Bzjn/rYpE4i9NWXEvXBYltQ074X5DAsz/z3rqJ3J4cO0xE2JZiRwhoyxNs5+2tfATSudyTWwuLxhksNagr6m5dZm3VY+qQl0mum+4HSg== 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=GtEZXWH40iTCJjTrtnzMzW5xGDiQeL/VMCcTYWylmyU=; b=SGOsl32BOCHHhQ5aGmoyGVuUTQIxX6uo+SJ4rv0ZwU3akn6oqcfzExw4UGAV43ojYZ/x62JMiOshWbZN0Za4AS7vNOhWR5OQHtPey+eyGhy/afnGa6NEOsMCKwmu3SM7eTDscvQzhgwWqKccej8dbiCa3ywkuc6isS7vXE7qQlp0aMwkAlyZzRYycllYafMykqO6LQcUnLZvhagKD+ENwdV4HVew/6CEBoBqT252YHsIXL3hv81NXRgbvBmOnwIE7eWRPYS4LUXlJnSSK7OOs5dLqEvGwkQZ+MxtWM1D0nNzbqbdEmRMj8KeozoVIsH6SmyvP/X17g6i5Nc0GWP0NA== 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=GtEZXWH40iTCJjTrtnzMzW5xGDiQeL/VMCcTYWylmyU=; b=OvIU8z6LMN9o+EUjH0YObpsv4NUbv8mY7DoRPR/6nUmvaCk8yfBIK6La5z/TuDFYV7qtSyBn6yGiNbB3W6l2XWbex++KzDlO5pBbjNjBH++PykHTPm/h3Numlzc342DJrusI4QWgUcmWgp2LoOjV8OaoXPdfhwihuzgmmb30IR4= 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 DBBPR04MB8010.eurprd04.prod.outlook.com (2603:10a6:10:1f1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.20; Thu, 13 Jul 2023 12:19:47 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::cc2a:5d80:9dbd:d850]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::cc2a:5d80:9dbd:d850%7]) with mapi id 15.20.6588.017; Thu, 13 Jul 2023 12:19:47 +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 , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 net-next 10/10] net: remove phy_has_hwtstamp() -> phy_mii_ioctl() decision from converted drivers Date: Thu, 13 Jul 2023 15:19:07 +0300 Message-Id: <20230713121907.3249291-11-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230713121907.3249291-1-vladimir.oltean@nxp.com> References: <20230713121907.3249291-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0157.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:99::18) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|DBBPR04MB8010:EE_ X-MS-Office365-Filtering-Correlation-Id: 7504661b-f009-4df4-fc47-08db839b7296 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sXl7/eFXc+WVdiH7Jl7/FEu1SGpSQu3dexTEN3xZPod4ruNAkvvy52wDOo1kEgn21UW7iBu9vZGmqpGg5wYcpmcloirzX213icMsHK38pB7mrl6lMJHD4Fj3yWCvs4tb2tkStCVSmZaBSIzKlWqxthVOkxc7Ho4IVr5PUDt0lHueWvN2m3/sI+atmVRTeyVId6uX9fOtGC8QfNs6RueRbe4cdrD5xPsDT7nf188+Tzlk6pYILLHxKHVi1oMpuU3b761KJjSy9Vv74E8c/KatxnLqoeacfLYvlxT59q6WJTJ7SdPlnkUfFyxCDRKgSjwcMmLSAJL6BsngiiiroVSSSDw5B8uU81klplgiOwlRaG23+j340xgHUR0TikufDcg4VAaD+lmFaaur/c+xB6RLHFlUJ1+6sFXWgU0ivL2BSUHjy5gVmZufndLi7VIMsL7hixnVfNoGrcvimKPCcb9ZjPoPV4T3v/8UMnXVGw51uxSEAgJwKuoDk6t8xMNfpURE1vCnePy2K82KQguuV5qhKhcIXesZ0vFTL6k2R9mwjokHkbKsVnRUNtuDCF2PZJ8+3ZjgMdAGtkWH65iFaWQ83rQbOl2Zl1FOYsrzd0RIjmVJ48YME1jUkaDV8YEAp8q2 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)(136003)(366004)(346002)(39860400002)(376002)(396003)(451199021)(6512007)(6916009)(4326008)(66556008)(66946007)(66476007)(38350700002)(38100700002)(86362001)(186003)(1076003)(26005)(6506007)(2616005)(83380400001)(52116002)(36756003)(478600001)(54906003)(41300700001)(5660300002)(8676002)(8936002)(44832011)(6486002)(6666004)(30864003)(316002)(2906002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mKcPrP35ZFhj5+EBtper1GvFtudJnBXKPw3jyEzwliMhHPtWwJg5We00bg8qQb1aefv2ryUZu3u1w0GbmUbUl5CQFFvJjHePbmy5jDeYcvVvFfiDJm9fyTQ2h66yTdeeMluapqcaGr70DKvQsojNnzm/79xAshGI+KfthPJpmy2dZ47AmTKsNP9Hp/34ZDQSO18JPOvqois02P12oVEPZPRn9Wf7kZI6gqNqUVM+Bujfm3AHQZxLIbUNqXQ3V5IOap5bn41DhM49rKFt79ItevCxONORcwv99qaN/b9U75/4/Tff/VrPRDhvGK9xqVK9uYOQdGdPIOxRkP4z3bVkVd+Czq1M3MW9GtEhwXKlJca9tTEOhYbGXDEWMbAmXP47ImJ9tXCcHsJmUa58QyyGyOtwh3lam1px20JP3ml8t3HatS2LGipikna0OWBAA9a5hRRFocTuGRimGTBAFwQ+2PuxisenxYlh0IJDCoNDTHN0nJHqSLBAi6JmObXLW0iutX6T5S1D0Ni79eAIgEaGaCgcVODKO9iQV+Qix+8oRu6aEbKStcXrqiTjqbxANv+GhB45s4qef+EF8OR35FuDGA4vTSeTrAnX9K8jgOtFpJAAPf4gfYPxKyF+V9grGrU49WsQAyxMU3MwyOOKXh8w0vdRj4lR4V68hW5I/tNoArTJno8pJ1vxZU/P7i9Pq6+leyYdOvJNp2eBIc27YN5Qje6jfEt8+Mj44c3aZ7oALkkddlyyeZrR3StGgCRe4YbgcFjgDgfEwBXs53BqgxOaLrtALuiKHQvFxCOt2e4jmtTrIkegL/I4rPOyry58jsjLVHYes1M9QDquhVeV16d4qgJY7Lihz8kGcMKsQoNW98lE012FMcDyInkKcoBa2U2GpNJqCMuZQuy7iMw3sXXKjw5xZ0OLxet0nnUhbnbmJlDhx0Vdh4Z93Cepsm0YfA/zRtpLI7+P6T0lrvRtthrU/Rz6LsgBoS0Csy32Ofa9KcRjRzB6gP3rQFyzCImXk1EqiSLPGBSzheZalszm2hnWuea4WSJVl9a5tLGhpfooS40J82vRTi8ixxQYuBSDCZdcXkhIvjzVgJuE0bxw2ymc5Ble66Hk0yNK8nKjYmjHZSgFzRTjIrJgIZkInqGxkCct87/qBfC5vQ6NboP1cqkGg312Weagu+3AtyX+DHspu3jZvkGCQh/8p/OXwPibunCqBRETToqwTPHOxaEldShba1qNMp9U0ithLiTjvI1shcwayiWqvx4fMGMsnURKBxSzLV+zXwdDGkVWdblxwwUtYr2IcA5900BB0Mv5Znlfu+Q0s5Qne9exaGFs6Wd1VnDuyR6J0U107cvuDrWxahiaSvDfKBVz11yAsTIPSPnbjytVQyhYNlvM9rEs4l+mVVVXt1C+Ybdct7upM4hIJ2mKyNUAagB0N+4slMDfMXQXztJazvCzRMcx8wFvDhAdvQUXjvupDjgfWpzDNaKCWZrJEAT+kXUZ4mMhZnNFGV1QwQ7A+DOUoUu5l+BY0HDEfWWyHLR7YqtaCKXXWpAspI+Tkr6U7GEC+F05cYoQlt/82RihhzvaXnUYba4wU/GHxdC8PhoHpDYOt7rv3FNCa3bLZw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7504661b-f009-4df4-fc47-08db839b7296 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2023 12:19:47.0553 (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: pwRjC23kV8Onul9aatQlCBqqbZsTBy30YniXM+DWH4kOCCi7YsKd0/w0CtuJ7QqmC1RaZoxMf93YIvPzeWUYOA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB8010 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230713_051955_573352_9961919C X-CRM114-Status: GOOD ( 20.77 ) 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 --- 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 | 14 +++ include/linux/netdevice.h | 4 + net/core/dev_ioctl.c | 90 +++++++++++++++++-- 6 files changed, 114 insertions(+), 33 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 08744e8164e3..fa81e70eb2ab 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3858,10 +3858,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 (!fep->bufdesc_ex) return -EOPNOTSUPP; @@ -3876,10 +3872,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 (!fep->bufdesc_ex) return -EOPNOTSUPP; diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c index c8fce4e79c63..5185691e10c1 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c @@ -463,9 +463,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; @@ -481,21 +478,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 = { @@ -823,6 +825,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 573662d2e01a..48f7022d3fb7 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c @@ -222,9 +222,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; @@ -240,9 +237,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..f4aff9137724 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 * @@ -26,6 +31,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 +50,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 ca3bcf2257c0..0d8a7ac67cf1 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..caaba0db8cb3 100644 --- a/net/core/dev_ioctl.c +++ b/net/core/dev_ioctl.c @@ -252,6 +252,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_mii_ioctl(dev->phydev, cfg->ifr, SIOCGHWTSTAMP); + + 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 +290,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 +307,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_mii_ioctl(dev->phydev, cfg->ifr, SIOCSHWTSTAMP); + 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 +391,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 +436,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 +453,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);