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/+S17ESnyAcHKMmjpFljki81duCmO2mKsaa7P5Dwxdv4roXf1QRJrQk2az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t45t2rM5bZm/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); } /*