From patchwork Tue Aug 1 14:28:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13336813 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B92D25149 for ; Tue, 1 Aug 2023 14:29:34 +0000 (UTC) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2086.outbound.protection.outlook.com [40.107.20.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E24DD1728; Tue, 1 Aug 2023 07:29:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FUEqryHifm2Iazh1ndHuzoS17DltrVwp0YIDAYBUuQgoQvvZtFS88iXAh3nipTI3uaXxs07nlivgP4UWHIkWKwfEEuusTBsG6HKJ0DolnlwW8V3gfOgcgdZcOObal/LjC8wifOkXJwZtOUx1UEkZPE9EIMYAok9yOYhMTpXkax123ZisCJLeocu9xFLeAwr6rMf04Hc2CegKEzpNWDl3riaf4y6P6EvFik5YUcbx3YZWlyD/xL+kT2pJE+Z6etCYFc9gq3uG+gpWZSwnp5Dkw3FpaTl/ScQKn6Or8TBvKHXPi/NKy7TLGSgwxgGJC4JY1D6cG0vTTI+sB7j51D3eew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=y0uMid8YSWleukVlwKvvYRFiDrcxiltc2VXkuNnpQ68=; b=lDEr6rEP2xaWRD9DTqSqCpNguPxC2iac+5uImtom3wnCkVvGlJkNz8Sw2rT9T6fZvQPyxA2k53DIHLAHuUuMQVltO7n+Vs2ecgOx8QWBFEDTpkS/qPOV6nTwjwfGW4MwMSptJsEVKCMu4cg2G+D7ZwvKN50+vzRtM3yAfdIFL2exynsh8S8Kpi82TlkyV6aWFdFUez7so51a8MVQ7SO1k5FLVTwTYd06wvojsDdnjZNW2IMt78cCHOljNHDjSlBvgBIrvZYic0U0ZPsEMXu4FYVFW9gmyRSiAm2M9YkywiSnUHTU2bjaS1tjPimPtd5fu6PwdFvU3/IdcO36J4Ge0A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=y0uMid8YSWleukVlwKvvYRFiDrcxiltc2VXkuNnpQ68=; b=OUMkWA9fE5r5xAbMde/jB11FncZbePtbZ4Ud/PMw/iGUwSzh7oZnHLKUNhT9O2NoVqEEZDAljgYFgO0qg+FZCPmJkTlGAtX46rBMbFoOdU61e+TeyvdRPJnwh5Mihcn/4DoOIJ3RjtzWFSQBtidRrDYs1etsF1kY7vsBPOSUT7M= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by VI1PR04MB10028.eurprd04.prod.outlook.com (2603:10a6:800:1db::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.43; Tue, 1 Aug 2023 14:29:30 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::6074:afac:3fae:6194]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::6074:afac:3fae:6194%4]) with mapi id 15.20.6631.043; Tue, 1 Aug 2023 14:29:30 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Florian Fainelli , Maxim Georgiev , Horatiu Vultur , =?utf-8?q?K=C3=B6ry_Maincent?= , Maxime Chevallier , Richard Cochran , Vadim Fedorenko , Gerhard Engleder , Hangbin Liu , Russell King , Heiner Kallweit , Jacob Keller , Jay Vosburgh , Andy Gospodarek , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , UNGLinuxDriver@microchip.com, Lars Povlsen , Steen Hegelund , Daniel Machon , Simon Horman , Casper Andersson , Sergey Organov , Michal Kubecek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 net-next 04/12] net: macvlan: convert to ndo_hwtstamp_get() / ndo_hwtstamp_set() Date: Tue, 1 Aug 2023 17:28:16 +0300 Message-Id: <20230801142824.1772134-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230801142824.1772134-1-vladimir.oltean@nxp.com> References: <20230801142824.1772134-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR04CA0027.eurprd04.prod.outlook.com (2603:10a6:208:122::40) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|VI1PR04MB10028:EE_ X-MS-Office365-Filtering-Correlation-Id: f204b6b7-c050-42a4-4efe-08db929bb77a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MRLcwNYLk5rGqLCQ0j11HmryUoVOjjjsU1UX0rRQ4RRsesZipb5ct2m/DWF8aQxLXgbHipYLYQy4sSlRh5PVPkC8JwHAff9sLOBxhdy6OFWarkJoimLk0oMWnO/EXU7zN5sq/JVDcEuJPUcY+pkZ/N401R02yPdejTiXWia6cYf5AHDhB3hfckeLxmMJuTRXQNCSgrfQirXTh/lxOXfrepya66aE4lyKVUH+oYyqVBQZKZypGh7IAQ26vr4nNWcdxVZZ1Ta/6FTb5almb0o7FC/DuhbQqlkNTT5lnVxCwoHjfRAY/+JdjP1Fmiv6cBf+30ualXOPxct8jtSHm1p2EOQuC1HHX/4ClhseZPP7CfR0JE6x43i67ETFED4yBq+XLxcLpDLUDsI+DTIgn9KK/c016D4OClwu2x6Daz5IL8cGqGFQno1QY8nqHMfqb2NKvtySNdHCnGpyT1GFfcswFKjYNVy63K1fF8exKxSzDjWuwArXTjX+tuLjhJNTsmyvrAnKEL49hzK+HswIdCpth81yCLFrKFpW17Oxa5upe5c8yFtKT0JQrxsggYKEHnecKK0Jva8utuwaIkVdB8wMeogJc7fCxVxNHtFT9Nw9eUfMNd2sdFGyQDtvMpMyHMwN X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(136003)(376002)(346002)(39860400002)(396003)(451199021)(66476007)(66946007)(6916009)(66556008)(2906002)(4326008)(44832011)(5660300002)(7406005)(54906003)(41300700001)(316002)(7416002)(2616005)(52116002)(6486002)(6666004)(26005)(8936002)(6506007)(1076003)(8676002)(186003)(83380400001)(478600001)(36756003)(38100700002)(38350700002)(6512007)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5NupKeQo/4wbQFLPLEDk+mbgJ+asYDfNi1bckSw8J52qC1zTVivVoyobI4B4JLvk2cqIK2leOu4xZe16jh5/fidSBHmtDiyt5eb2PLLMrYvrZQJoR+5B5Us0cyI6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OYz1ErnVstXzYfXD96U8KASVEDoO97emSVg26P2LTbESh7bBdN+/FiM4gKOkVeR7VJj4LbsMFHxwZA8rtjz8WPa+I4HNxK87qylVvoc0lgq4yYo3OL6ylmn57Ho/OhxMYxh0i6Hu6GOOGpjtNIlcKGFsfrELezbXYDQtICD5kWxmFz7go3iZUU5oyEzLwQJiA6fQH0mmcoJ7c7LoTZgsRQjIsNt0oRTIBsIZdwRT+Ok3/GzAnwdoveWwarl0EquOO1ageDs1RbT7S24L/8FEIq0QEc6xyBn4x3MKUDPA8eeU1IudF6sB0SYZlckCrYxHouptfU9xiZTxH3HhdSp26pT3MybdjKCP+uF588ZdChpDuRMmM+mzozDSsU7S3lJjjbqYZN8HkP+ayHOyCq0XeN0sTj+v7dI0Q== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f204b6b7-c050-42a4-4efe-08db929bb77a X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2023 14:29:30.0887 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: KKRdIvpb5mH9HIFupjpwh2MEo/mWZnsC8DihYK/rG1sJ9KZQJ+icPyc/9WV2KdQpBkz8rTZv+oU36Wcz5xFT3A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB10028 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Maxim Georgiev macvlan is one of the stackable net devices which pass the hardware timestamping ops to the real device through ndo_eth_ioctl(). This prevents converting any device driver to the new hwtimestamping API without regressions. Remove that limitation in macvlan by using the newly introduced helpers for timestamping through lower devices, that handle both the new and the old driver API. macvlan only implements ndo_eth_ioctl() for these 2 operations, so delete that method. Signed-off-by: Maxim Georgiev Signed-off-by: Vladimir Oltean Reviewed-by: Jacob Keller --- Changes in v8-v9: - None. Changes in v7: - Split vlan and macvlan to separate patches - Reword commit message Changes in v6: - Patch title was updated. No code changes. Changes in v5: - Re-introduced the net namespace check which was dropped in v4. Changes in v4: - Moved hw timestamp get/set request processing logic from vlan_dev_ioctl() to .ndo_hwtstamp_get/set callbacks. - Use the shared generic_hwtstamp_get/set_lower() functions to handle ndo_hwtstamp_get/set requests. - Apply the same changes to macvlan driver. drivers/net/macvlan.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index ed908165a8b4..02bd201bc7e5 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -868,31 +868,24 @@ static int macvlan_change_mtu(struct net_device *dev, int new_mtu) return 0; } -static int macvlan_eth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) +static int macvlan_hwtstamp_get(struct net_device *dev, + struct kernel_hwtstamp_config *cfg) { struct net_device *real_dev = macvlan_dev_real_dev(dev); - const struct net_device_ops *ops = real_dev->netdev_ops; - struct ifreq ifrr; - int err = -EOPNOTSUPP; - strscpy(ifrr.ifr_name, real_dev->name, IFNAMSIZ); - ifrr.ifr_ifru = ifr->ifr_ifru; + return generic_hwtstamp_get_lower(real_dev, cfg); +} - switch (cmd) { - case SIOCSHWTSTAMP: - if (!net_eq(dev_net(dev), &init_net)) - break; - fallthrough; - case SIOCGHWTSTAMP: - if (netif_device_present(real_dev) && ops->ndo_eth_ioctl) - err = ops->ndo_eth_ioctl(real_dev, &ifrr, cmd); - break; - } +static int macvlan_hwtstamp_set(struct net_device *dev, + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack) +{ + struct net_device *real_dev = macvlan_dev_real_dev(dev); - if (!err) - ifr->ifr_ifru = ifrr.ifr_ifru; + if (!net_eq(dev_net(dev), &init_net)) + return -EOPNOTSUPP; - return err; + return generic_hwtstamp_set_lower(real_dev, cfg, extack); } /* @@ -1193,7 +1186,6 @@ static const struct net_device_ops macvlan_netdev_ops = { .ndo_stop = macvlan_stop, .ndo_start_xmit = macvlan_start_xmit, .ndo_change_mtu = macvlan_change_mtu, - .ndo_eth_ioctl = macvlan_eth_ioctl, .ndo_fix_features = macvlan_fix_features, .ndo_change_rx_flags = macvlan_change_rx_flags, .ndo_set_mac_address = macvlan_set_mac_address, @@ -1212,6 +1204,8 @@ static const struct net_device_ops macvlan_netdev_ops = { #endif .ndo_get_iflink = macvlan_dev_get_iflink, .ndo_features_check = passthru_features_check, + .ndo_hwtstamp_get = macvlan_hwtstamp_get, + .ndo_hwtstamp_set = macvlan_hwtstamp_set, }; static void macvlan_dev_free(struct net_device *dev)