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: 13311946 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 2A2FB17FE0 for ; Thu, 13 Jul 2023 12:19:50 +0000 (UTC) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2073.outbound.protection.outlook.com [40.107.104.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2777C268F; Thu, 13 Jul 2023 05:19:45 -0700 (PDT) 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) 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_|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+gdIQ79670ZxEgF2QxFDJSJYyrSAE1QKpOv3e8Ew27EYefAYzFNumeOSFw0AtnNPUqYqh35R8DdIW3eBnJLCgtiynQ744D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cQGmLGw7GQqClWoY6s0oGcrKra7F95wO2YMF3MjfXt/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-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_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 --- 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)