From patchwork Tue Aug 1 14:28:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13336824 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 478D9C001E0 for ; Tue, 1 Aug 2023 14:30:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GfzgigW7/Sko5EIl98RLxWj+II4znk/mi0pTywHO3KM=; b=R+2WMWcckRrQYF gM5v4nSOghOLDrhfoMJZNgch7HFDCysYa3YxS474EmYRmwJTCtdygIoiHgQIUFWh2MHQTCuuMcGiA uzjXkSR1yLccwcopnFCQm3i5jOleX+FuNzUWeKgurNE+bIsrIjq6265rvTufPJ/tBFtZCsoFfxm4E K9dFhNJtTgigceXAwbmkOHoW9KdFmmOlIrsXReYXyUpKLn7S2FVkLU3VJIZyb6yyp1T3cteO7ZJ1c w7Ixcv1cFVBD1DhDy7nSm/8bzxSaFkoZfypYMw2m7drG2Ns0Ng/oFGn530rdpTUNrztJW4L1fxs4z +mv/vNxbg81cmPhSSJ1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQqNX-002aIY-3C; Tue, 01 Aug 2023 14:29:40 +0000 Received: from mail-db8eur05on20604.outbound.protection.outlook.com ([2a01:111:f400:7e1a::604] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qQqNV-002aEd-0C for linux-arm-kernel@lists.infradead.org; Tue, 01 Aug 2023 14:29:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JkMFAzfOXctpQclv8Rg8i2ITCrImWvZis8ndUb5CUYrk2zkdjZAyglDuOAwhHkz/mq8TgdDB5VH+rG448NQwci3oNC/2FsnCmzElBRJ4v1S2P76ACrUBsgaXMU8EgCay+eSat/wmXwibj/DItKfFNUXaM4yDTkPsaPPE9RbKJ4Dq1DpO5KCjXx3KVlas0L/xS5vC4zG6CP2VZTXwoju3cX8KXXNPug1e/30CjUz1YnF+vUihIOP21cdMF7rrKAM1iTMtuPKqfKrc9oU/Vd7C6u8+Ej40ssXNu/666eQnmFfJRCb+LkyAsep7B4x6nQwNnLOaghJCnaWwsLqXZLyArw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6c9L/Fs+ATK9RZ0lYPtA2VPoujgJmkcPt/5crPCivNs=; b=QfW6pEwm+3vX9KhiYl73k9Lr3VftjJ4aYcv98y1+djDWRmxrrHczmB1xCvfgA0iAAwJSXtr++O3d4+fhY4ULK6Ju2jlonxpn7oWe3CO8JvP5SkfMi66/ZU0mZ2uLtAkGcpyCJVpGrsnoJ7YwyG9Je13v6MSiupyEXuHSpC+omlEek5BJERHbcrBz0f9MDQjJ5C1q9vi1GC6oecwU87hEcf45iAF41jFKgl1M42Ywzk+MRkpc5lh42qpwXTdz+xEUY39si8/O+V81cgKf+4k8SYvwrwQRcYMJOrjAw07gKimSKNPYZRWIqxMwpTSEfotgE+NCyz/UIo+0DzF5J8Rk/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6c9L/Fs+ATK9RZ0lYPtA2VPoujgJmkcPt/5crPCivNs=; b=FEETcA6fVLNdAEIcA6R4rKEa4093AP9Chncfbe0T2IYSd8pxGemQl7wmynCb2K27FZTvfmUH7via9vuFfFW5ep+b07Sp58DbzuNyVy+oIobooI9Eifcuj4shxJOWlVVoYsZhLHd0KiyeFtP3ju6WfE9WG4lfnR+Rt5kaLeKV0/A= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by VI1PR04MB10028.eurprd04.prod.outlook.com (2603:10a6:800:1db::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.43; Tue, 1 Aug 2023 14:29:28 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::6074:afac:3fae:6194]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::6074:afac:3fae:6194%4]) with mapi id 15.20.6631.043; Tue, 1 Aug 2023 14:29:28 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Florian Fainelli , Maxim Georgiev , Horatiu Vultur , =?utf-8?q?K=C3=B6ry_Maincent?= , Maxime Chevallier , Richard Cochran , Vadim Fedorenko , Gerhard Engleder , Hangbin Liu , Russell King , Heiner Kallweit , Jacob Keller , Jay Vosburgh , Andy Gospodarek , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , UNGLinuxDriver@microchip.com, Lars Povlsen , Steen Hegelund , Daniel Machon , Simon Horman , Casper Andersson , Sergey Organov , Michal Kubecek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 net-next 03/12] net: vlan: convert to ndo_hwtstamp_get() / ndo_hwtstamp_set() Date: Tue, 1 Aug 2023 17:28:15 +0300 Message-Id: <20230801142824.1772134-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230801142824.1772134-1-vladimir.oltean@nxp.com> References: <20230801142824.1772134-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR04CA0027.eurprd04.prod.outlook.com (2603:10a6:208:122::40) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|VI1PR04MB10028:EE_ X-MS-Office365-Filtering-Correlation-Id: bfeabd0a-e6f9-4001-8818-08db929bb64b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oQm/qHyQro2vofnOyhRagNnMPZwWO+uQfQpMv8NqlCLOcY7nZoHxzOLtiHqCwVaWLsdBO3dDK5w+H/Oqdt/0T5GCSVr8RVbrXaAvIHGbRVxi2PFLjE+wRxzdOkkyCmMPf7v2KsKjpYnhZ0eIcMc+7DPxL9vE/17EOg9RnM0CSoBroOWBrgF9vkcWA/TXXoOG/mg0wKxxp19TxVHCVcevt7vZnMdBxD+HgoG/qAjZwQ7ls234NdNyxdko5hZDCmIaObPY6qX1y44Sd+9SX/NGOlWZWlmF/KxzOWQEN6LS5SYxEbIuvqLmJSEnKaCa/QI7klZR9NCEZ0kbvx5CAuPD5ONVsGPv9tDQHZiZ0hkoA8SCD2WAVsLwqNbSFd0/WyoLPVpyh8epHPdW0f7tVjPRtmnfZP5YE2C7gTSjrSTtG1h9rKCw//SYCa3POopTbPhK2L884f1rDxQqYKYinAG+IujuWHxqQj3b97AymH8/a3fU7J5v4EDrS/eFgvikhbS3iBHAxO8EDGVNPHnCCN59mpGprpqU8LfQbsiG4w+q6WzJ+CKEhgijSPGgApkEoRwlUahhJmyI7Qq/qxk+mmTB869ycS8XLfCqXt7Kz98BdBmfV5+oATupL+tuKUtcfZew X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(136003)(376002)(346002)(39860400002)(396003)(451199021)(66476007)(66946007)(6916009)(66556008)(2906002)(4326008)(44832011)(5660300002)(7406005)(54906003)(41300700001)(316002)(7416002)(2616005)(52116002)(6486002)(6666004)(26005)(8936002)(6506007)(1076003)(8676002)(186003)(83380400001)(478600001)(36756003)(38100700002)(38350700002)(6512007)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ewLd4ueXlPVPCSmrDhuHwopGZHe31Pn/otG+RzO6bG/PLpNy6ie5IIPmagN5oOMnGcljEPaXlOe5Ga5kIoY3To5bl8oDM/dBOFuer7BI8XVwIDKErO3lyr4/neo7UO6NNmb4SN97wR3tkVFPY2hg7CQm0IRRqZmZOJvp4i/7r1MjaW4WXH+bgPFT4lcU8qqkxFSmaMvGc9psh14TqIUfQZ38SZA7wLU014nwrMpT2sAMThCFTBH9bouwU7LHj+T7e6nRrwB34xu+kpvHWK2pIcEqlMmVrd1xRa8OgGWKkdKiA9ZMsxE4YtJGxfN7WbrGNrolc9A1vJdLR6Q+tLbbHk9fAjB1uXH5glah+aHGDxLTRTrh7mOsBbA2GMnFbCtXhZDqJ43AJoHNa4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ISV4tEwTdJ8+OHqOZGsvxlKhqtLmm26Y0er1L12FYi0+10lINSpS6mCrCIB0Os/jfbm3Lho1Zb+wD3HaO2rC53LhF+Kc+mS/HYXBju/LQS9YmkKk0Ky/g0KMXwT4INjKz7g8nEkEm8d0L/E73YQtbg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bfeabd0a-e6f9-4001-8818-08db929bb64b X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2023 14:29:28.1061 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: D6AU7yFLOmjM2eF99jvW6u7t8yi7ccetMBHEf4aYPN6FY9WpgU64CP9HllH+Vi1icKbf/WEWlHtA2CYz/wYtRg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB10028 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230801_072937_100238_1FBE2E8E X-CRM114-Status: GOOD ( 17.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Maxim Georgiev 8021q is one of the stackable net devices which pass the hardware timestamping ops to the real device through ndo_eth_ioctl(). This prevents converting any device driver to the new hwtimestamping API without regressions. Remove that limitation in the vlan driver by using the newly introduced helpers for timestamping through lower devices, that handle both the new and the old driver API. Signed-off-by: Maxim Georgiev Signed-off-by: Vladimir Oltean Reviewed-by: Jacob Keller --- Changes in v8-v9: - None. Changes in v7: - Split vlan and macvlan to separate patches - Reword commit message Changes in v6: - Patch title was updated. No code changes. Changes in v5: - Re-introduced the net namespace check which was dropped in v4. Changes in v4: - Moved hw timestamp get/set request processing logic from vlan_dev_ioctl() to .ndo_hwtstamp_get/set callbacks. - Use the shared generic_hwtstamp_get/set_lower() functions to handle ndo_hwtstamp_get/set requests. - Apply the same changes to macvlan driver. net/8021q/vlan_dev.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index b90781b9ece6..2a7f1b15714a 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c @@ -354,6 +354,26 @@ static int vlan_dev_set_mac_address(struct net_device *dev, void *p) return 0; } +static int vlan_hwtstamp_get(struct net_device *dev, + struct kernel_hwtstamp_config *cfg) +{ + struct net_device *real_dev = vlan_dev_priv(dev)->real_dev; + + return generic_hwtstamp_get_lower(real_dev, cfg); +} + +static int vlan_hwtstamp_set(struct net_device *dev, + struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack) +{ + struct net_device *real_dev = vlan_dev_priv(dev)->real_dev; + + if (!net_eq(dev_net(dev), dev_net(real_dev))) + return -EOPNOTSUPP; + + return generic_hwtstamp_set_lower(real_dev, cfg, extack); +} + static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) { struct net_device *real_dev = vlan_dev_priv(dev)->real_dev; @@ -365,14 +385,9 @@ static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) ifrr.ifr_ifru = ifr->ifr_ifru; switch (cmd) { - case SIOCSHWTSTAMP: - if (!net_eq(dev_net(dev), dev_net(real_dev))) - break; - fallthrough; case SIOCGMIIPHY: case SIOCGMIIREG: case SIOCSMIIREG: - case SIOCGHWTSTAMP: if (netif_device_present(real_dev) && ops->ndo_eth_ioctl) err = ops->ndo_eth_ioctl(real_dev, &ifrr, cmd); break; @@ -1081,6 +1096,8 @@ static const struct net_device_ops vlan_netdev_ops = { .ndo_fix_features = vlan_dev_fix_features, .ndo_get_iflink = vlan_dev_get_iflink, .ndo_fill_forward_path = vlan_dev_fill_forward_path, + .ndo_hwtstamp_get = vlan_hwtstamp_get, + .ndo_hwtstamp_set = vlan_hwtstamp_set, }; static void vlan_dev_free(struct net_device *dev)