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+AbSFGMGavyjt1aKnNZJO7mdJ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fAZB0HH/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)