From patchwork Mon Jun 26 15:40: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: 113020 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp7593609vqr; Mon, 26 Jun 2023 09:13:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7zRmCcV1TwuIRk+YJw4P/fLQQFX8qBbHhkB3P2woeQf6KQdxxBIWapgK42cqLxTL7qlOMp X-Received: by 2002:a05:6512:ea7:b0:4f6:1433:fca0 with SMTP id bi39-20020a0565120ea700b004f61433fca0mr18675694lfb.0.1687796018465; Mon, 26 Jun 2023 09:13:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687796018; cv=pass; d=google.com; s=arc-20160816; b=WVc7zFXEmhuFlODRySGPgHllgmwmngYhEAjvzM/YYlkqHfn3U2pe5J0+aplIb1C+m+ 33gMRqmKerJAqTWXEKXdKAlFQZpgxI2mgRDeHKCS/3bPguNA9wm0ek0PyipLZEMAVRRs /Mw61Hyexso3tMk3d7ZBzu6O2YfmdQ2iuwaE3zj2LhCq16QVpTGp18FjRkWVm5PbXNk0 5IuxCjU3pM7iQc/t4z+EUDdQ1vuUmCRkYXh7/YGjqDYH5gVD2gvFHJp73jjxO7SZsCNc d96L7Bx9XmuX8XW/yZ2+r40xP18Xmme3hXm3xV6gqYt4XuL8o7UeGQ9LeBBPU8Ou1y1q NYgw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zStVAQGa1K36ouN3zyKPcZNh1UiuoisDOyxr4IMqIwI=; fh=iurQRswHi9hWiYvyPjsOpfQdagiAg7Zmv5exCLcOUfA=; b=jkLjNT5mLO7xGTFBm3M0jviWiRMDrR/dDr3Afx/a2Ss39tOW5+qfJ4JEBP7mxUQX11 l33tLnydANQyTHQECvNZp6+S7GjZCaG0M4gCeMwDJC+c/98LxQ5dzXhR2XQQuzUXOUAG /yLNPLq9bM/qd7gWt/X3OAKbqjY+JcGopV1nFJmy3gH2u6CfB9N7wfZMdj4uRhz5PCpo SIbuMffrr+JcOA/3F0QJsZMaPCrTF5LqrZInb1MA5JTbDc6tPQgdMwkMfSGDYsQsqn6m yDzNwh74fZheypZjYqkueEIOfcBhItD/mqUoKq8VN2HltzACy8dWBpWhXucVQlzhhv+n 7tig== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=eNSZA3Gq; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i12-20020aa7c70c000000b0051da4e9d7cfsi205823edq.565.2023.06.26.09.13.13; Mon, 26 Jun 2023 09:13:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=eNSZA3Gq; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231377AbjFZPkd (ORCPT + 99 others); Mon, 26 Jun 2023 11:40:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230197AbjFZPk1 (ORCPT ); Mon, 26 Jun 2023 11:40:27 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2050.outbound.protection.outlook.com [40.107.7.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F9691A4; Mon, 26 Jun 2023 08:40:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lB0WAresqtMb5W0NSgliWRCoPLDPIin/HstnkteNozwIcDEy5ft8FrdV784uWzWwDpL8tCl1Q2kSV91KhBh8naU7lZMqIyRrp7tkNzdhkVea0utd9W70bgg2bdRMU+JlpF8USbQpG7aDJ/SRHcTvfPWSxbxjbcr7QBuqPdt87Laf609lr7X4wR7S0F3EEvBmnO4+ojRqmoxK+7lvZpIUf59gaYXnklDMB/eE3CJWIeO6SzjbacBiJ4jHr6MX1nbS9+jQ7hjGH9FOrWqADqjNFY3L8v/xLLK/+vEf4jrnYSZX5L9WCpnFdvpVqPOOUkpMz9Wd47q3194zoNtfDziLvw== 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=zStVAQGa1K36ouN3zyKPcZNh1UiuoisDOyxr4IMqIwI=; b=lES6UuI5bSdum/jjhZTeaSHodnKOZDZEcQxmesbvxoZt/KW/xfWFbgTkTmP2TeyFzoQHOlk7fK7HHnoTAUldrw83kOmP6R+7/nhXgZEG28kmtHurmEoX5QyT6VNN9Z2ZOF1qhOVRheMg/WgDu5K7+FTsH90DUSvahcv9h9gMdVrzUxOmwXBGkasiUASzlsnhVxqOD9ui2iXKyGM2uLAwVz4v4j6PtZxJqMiBpLSB9OPF3H1uPQt0C8cZowSC3K5oQDXd8DxDYY5MCZNu00wIIOP6ucQs2jDeQdoeEWCrYVnKWXcCDxW69Y3fp7LlQmwHiUid1tEHb0pnwALLufgnjg== 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=zStVAQGa1K36ouN3zyKPcZNh1UiuoisDOyxr4IMqIwI=; b=eNSZA3GqMN9wf/TnWhovx+qPz1rk+/agdGll1DPkuTu4MGyDvKDL6KRRXZyLeSsARLmCpuYSRbPAw11wKbPI0MJVfbY3u1OrJgnWfJHJQYqFbVMcbvrzpDJwjRl4YyoNn1LxYqeSuZ9nZ6JEiHowKoMjL5l9un5R4Nc5nQe9A90= 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 PAXPR04MB8638.eurprd04.prod.outlook.com (2603:10a6:102:21d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Mon, 26 Jun 2023 15:40:20 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::c40e:d76:fd88:f460]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::c40e:d76:fd88:f460%5]) with mapi id 15.20.6521.026; Mon, 26 Jun 2023 15:40:20 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Andrew Lunn , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Xiaoliang Yang , Richard Cochran , Antoine Tenart , linux-kernel@vger.kernel.org Subject: [PATCH net 1/3] net: mscc: ocelot: don't report that RX timestamping is enabled by default Date: Mon, 26 Jun 2023 18:40:01 +0300 Message-Id: <20230626154003.3153076-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230626154003.3153076-1-vladimir.oltean@nxp.com> References: <20230626154003.3153076-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR10CA0121.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:e6::38) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|PAXPR04MB8638:EE_ X-MS-Office365-Filtering-Correlation-Id: da21f5e2-f627-4ed8-9ec7-08db765ba63d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oSCUD1zVW3pFPGG9JYhhuKIqADee8HkGypJlYyg7Xo+LUOLY3XQ2D+/m9Lx1fK8b4eQ8LTdKkr9MI3c+RtXQRzpBF6h9YPQIFmb0UNwfNMXqitfMX89ExCyINCxu5OYkVmOO5DfOncb85d93dJsWBg5dDnCsheRu91Bl8rKSZeREye5FB9lhLOKbSDCKQWUM7ltut9BdELWqZ3piVeX1zMrfpM0FkRf1mNfCHaKoo57F7rvKKNU7NRn0reTRpYeVyQVKgzrTVm4qfBQ5S/qjg+h8jCu6Ir9GTP39vxbA0lmzZP+0/0ZLltBrM3llGVsrvASMQOqflZp9iE9LTLw9HTptEOCD9b0wCh2l0dH3h44DZgzE+txAHo1BtoI4hR7z9fpYVGpVHGh3jq3MDh59GoZNpOPOkThTEQwOXp1CG5OInWQBpJrp3BPBHh3uGPVXA2dJuMwVezOCLIFadEynj0snlFqhzfEfLeq92LmcaXZeSldThrQBXNEIIgCchiIHMCmBc25LXHalfmTJag08YuqnIhTmbqEZMQUky7Gc00npNTwsI/qCJQjqb7iygVcD0l7rKsBSPPRqPFSwjxU/Lm1JYPM5Y0WQbpGg4Pauc4TjaTsCFd1vq3Cq5DftvFEX 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)(39860400002)(376002)(346002)(396003)(451199021)(8676002)(66946007)(41300700001)(66476007)(316002)(66556008)(8936002)(4326008)(26005)(1076003)(6506007)(6512007)(186003)(6916009)(2616005)(54906003)(478600001)(6486002)(6666004)(52116002)(2906002)(5660300002)(7416002)(44832011)(38100700002)(38350700002)(36756003)(86362001)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zo9b7Cnljw2H6IUmF49DQaNjnbkx1ffbvmK8/8xBNbUvUz1EKvmcu8TmDGL7OFXtk21Oe9PR5lxv6DSe8jjJPUClNeEvzd2bMyMrOoOo8SXCbsy6j8JorgI2DK3XsJMdI43lk8ZURI1QEjyihpvV4L8/C29IBE9otXehgv5NVU6V02IltGAssHig6bwzGu02W33EFk9wQZCs5o6g8JANQx84QTnApFAe8PZZ4hDpgjkho5rSBv4i5VoQdxHB6TDkS+29QaE2qbJiTGfJShekqNlAy4N1y/EqdEL0n8FmObmuemxREYrTGHHYzZmX7IMiIRxYZAbdxO7ADV38vfA8xACehweBDtdAIZHk2A7WdyUrMx75Q/4iSJ0r8JTAKh1iO5UCj7t75Qr1Fex4Wt8tE2GqkBwgu9k69cd8E7lKu+XlInGAZaDNMnnRtWDQrGRd28sPeO+LGUmK7CHpM0+cGK4Ndl/35+9GnmsoaQHAnaK4hfo1UDJVTEvR32KAAwVoOglnv6yG0FtVNOT5KKaGJjAOKu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com X-MS-Exchange-CrossTenant-Network-Message-Id: da21f5e2-f627-4ed8-9ec7-08db765ba63d X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2023 15:40:20.8071 (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: 4Ov+PJz8nhHEUyUqGCUyED4+vTXQKXqQoA/mijUeXCPbnHdrRWXy2fQbw/U/uzgLkx3mgoeR3gJQ7JM8G+9Fxw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8638 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_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769782397917220477?= X-GMAIL-MSGID: =?utf-8?q?1769782397917220477?= PTP RX timestamping should be enabled when the user requests it, not by default. If it is enabled by default, it can be problematic when the ocelot driver is a DSA master, and it sidesteps what DSA tries to avoid through __dsa_master_hwtstamp_validate(). Additionally, after the change which made ocelot trap PTP packets only to the CPU at ocelot_hwtstamp_set() time, it is no longer even true that RX timestamping is enabled by default, because until ocelot_hwtstamp_set() is called, the PTP traps are actually not set up. So the rx_filter field of ocelot->hwtstamp_config reflects an incorrect reality. Fixes: 96ca08c05838 ("net: mscc: ocelot: set up traps for PTP packets") Fixes: 4e3b0468e6d7 ("net: mscc: PTP Hardware Clock (PHC) support") Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/mscc/ocelot_ptp.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot_ptp.c b/drivers/net/ethernet/mscc/ocelot_ptp.c index 2180ae94c744..673bfd70867a 100644 --- a/drivers/net/ethernet/mscc/ocelot_ptp.c +++ b/drivers/net/ethernet/mscc/ocelot_ptp.c @@ -824,11 +824,6 @@ int ocelot_init_timestamp(struct ocelot *ocelot, ocelot_write(ocelot, PTP_CFG_MISC_PTP_EN, PTP_CFG_MISC); - /* There is no device reconfiguration, PTP Rx stamping is always - * enabled. - */ - ocelot->hwtstamp_config.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; - return 0; } EXPORT_SYMBOL(ocelot_init_timestamp); From patchwork Mon Jun 26 15:40:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 113045 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp7604608vqr; Mon, 26 Jun 2023 09:30:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4SYIxhrwjrUNMWrSL0zI4f5nQQBBK0hqQlQtRifuladiWMVGOJXDBdFWwU/nI1BsCIGs/o X-Received: by 2002:a05:6402:34c7:b0:4fc:97d9:18ec with SMTP id w7-20020a05640234c700b004fc97d918ecmr29559131edc.21.1687797024502; Mon, 26 Jun 2023 09:30:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687797024; cv=pass; d=google.com; s=arc-20160816; b=CkhjoSSyPX/LtuObHXk3wPucfTnC6+O5nRI6yuZHuUs2ajkx0+09E2l9cJkyafHIWv HfW7qKO3/+I95SDfT7mJzfy3mfZzGYcNDS+DkeijcUoEtMFDxd4SW7qu6d5QFhaN/5pO neaKvxJPbyC9aoCjLk7i9O2DwHb1j5RicME/h28SBOVadpWb7vj+x5QLwzjtcZMI9Sml AXHxwmA3voUVKp/45YWCXhjwW6bm6qSaJ5MT1+i8merhnB5iy2kC8iMsmM74wZVNPcYA Elfn+m69z6/ecUMSsXKCjCSZmSRZdDAEgN/8BpCu0rl5qEmgvzH6cUUs1QZObVGEXAKO 3ReA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MzhDS9MgucPLdgQLjeJIB8Z0zSy5jUZ951m8iaO983E=; fh=iurQRswHi9hWiYvyPjsOpfQdagiAg7Zmv5exCLcOUfA=; b=u++Heuotlof7ihQTthrd97yvYOGJB/RjqszQ6QWyCud3gbif7ufVDmBAgM3ahtSIae g6Z0IAmI4lvsHf+AxxPa7W3t+acWMuuD2nCtJJ+KbynPlGd/NLHwQiuXS/TwYNrK/wGZ RVU+x+Ma2ch4oXcjZisQPD27hfwWuRHCogbrlVoYs2Zuv9V4FKLXaVk83w2v6C09Bt7M nCXEpANuOyb7gMms2BkmT0y2sSYMx5wC0wjTpaA1Q92P/NgUH5KbVxglgn9Q4O2wa9Zz XBFbf7cBDeWQYm/8ORQrrCbRHVd/muz53VEi7tEWyIZ6ePehecfO02AJXNK1brw/DEAb 9MkA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b="ay/E/Bwx"; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q25-20020aa7d459000000b0051a39598f1asi3003544edr.2.2023.06.26.09.29.56; Mon, 26 Jun 2023 09:30:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b="ay/E/Bwx"; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231421AbjFZPkk (ORCPT + 99 others); Mon, 26 Jun 2023 11:40:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231318AbjFZPk2 (ORCPT ); Mon, 26 Jun 2023 11:40:28 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2050.outbound.protection.outlook.com [40.107.7.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6EC710EB; Mon, 26 Jun 2023 08:40:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N88pso2D64hQdYydGEfpAp51Cf5mRoB3QBrg7jvLPPnRrWq78fEx0pWWNkhAoJTD5rPC0A4Kl6Ytej/Crue0B4qEEOw+u8HlcNZ3foMZgbj02ywvJvueog3qVGp5lhBQA5s7w9F36u8lrjfLCZEXD74Lk7b7JBAFUXcIG0I3H3eSfrbK5N+ZKfXLFPgCRbEqDrPfzHxgsJ+HavdtdfYmTaoMlLHw9V8ujpqiSXaUrbE+ru4/lhu6CWGTxo9OXICf0KyUljQgUDQSOo7m4/DVmEzCKULR7MhwYosn/47Pq+aTqIb3euYrWjcpaeQa5meeYzZsdY4/FKZBTDV0MPS7ng== 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=MzhDS9MgucPLdgQLjeJIB8Z0zSy5jUZ951m8iaO983E=; b=a1YbR8Pusmzyhw+lRdnDkiFHLeEVoyP1UDtRBu8zhmtM3ucekmwNFgvjXUp7BKSuz5En6PeQzVGG9n8GPZWMbuG3rW0FOBwd+s1fYDzZcIM0dSbcs9t3imrCbTghTEirpm6350jzmD5Jk5AqiB7WzuENCZAOUBgSQid0+Pia5cO+Q67mE9wYG8uRq/0EalzSQgIbo1I1M3dliXEFK2zJwrw+K7xrpFhQMU/bNr6mj+9dF9J6VmJ79iVTxB+UKkvQrj0j7Ia7BDnYfeDdd8Tzjjlee2WsgYKhsOviv7pTLBNkfRfzeufloEiF7Y1Xnvv2/eRH02F1JxSsQe4vE1HMXw== 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=MzhDS9MgucPLdgQLjeJIB8Z0zSy5jUZ951m8iaO983E=; b=ay/E/BwxvZSndReK7wVKemzBVjhGN0+QGIjy2QwlRMw1/06BPmsJMTIED5Z9FjMXNwGut3fNhpJHXItqdME+Dk6f8HMPkGAtapPKvYHcdcisZy9RZkQPL8zVjoGE5W+jrdk4TVWGUADPiy236UAhijAZXrw4VZTDJ0BiUjFFE4M= 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 PAXPR04MB8638.eurprd04.prod.outlook.com (2603:10a6:102:21d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Mon, 26 Jun 2023 15:40:21 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::c40e:d76:fd88:f460]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::c40e:d76:fd88:f460%5]) with mapi id 15.20.6521.026; Mon, 26 Jun 2023 15:40:21 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Andrew Lunn , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Xiaoliang Yang , Richard Cochran , Antoine Tenart , linux-kernel@vger.kernel.org Subject: [PATCH net 2/3] net: mscc: ocelot: don't keep PTP configuration of all ports in single structure Date: Mon, 26 Jun 2023 18:40:02 +0300 Message-Id: <20230626154003.3153076-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230626154003.3153076-1-vladimir.oltean@nxp.com> References: <20230626154003.3153076-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR10CA0121.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:e6::38) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|PAXPR04MB8638:EE_ X-MS-Office365-Filtering-Correlation-Id: c0b56fe4-efcc-43b4-336c-08db765ba6d6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QiCMmlHZfzRhsbvg4Ei5zrOonRuS8ntOQQu//l2ieU284WboKDUdNOMQPNPnBO2RjEPykOiciZFn9KO1NsQocdOX5/GTciCm5ixH022pvi0a+0UVfUi5YjZAGaX2fc5upHLJ+KCau+yJX58T+uvRbDQ5ZxwmkaNXkBouDleC3pOOitW5zuBpnvFjnu7fnpU1Cuc5J8HcyvLk1m2GcUOX2d7OhfGXlsYDUMqWgMUATt4Nkl5J6yvZskg/6Lp/+RNlWOOe4XGrhGv/BGNzEUFaftTJDi6eNzqZW4Evy/tVeJ7sLBmUnPIyS4Hi0hVQAU/bRh4yS7DXD9I6bXaF/4YUGgjwQz5BVYO+iGqTgUAMOrkbKwk9V5JKuPnDw+0r7OgtoXmAhRW8orxfmKQJI5VMjPfLH0gByrKlX7EEoR876fjfRwm78TMaHo79CAO5VOhmMoVac66FmDXvpIzq3KbCcI/IgLH+SZEG3fJKNAdu2F8wIFymshridGeKTPlRHmtqjsiig9P9xNkTnKxbDadFQZ6a3ybKLF8MktOomKHZZQ2kxzoGrpZ7cgy+LNv7UVBFiJjBISi2EJvQGc2wMK6Hoip9jl7eqm8utQI1G7JnbRzbpFC6UID2AOZMYq7HRUKj 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)(39860400002)(376002)(346002)(396003)(451199021)(8676002)(66946007)(41300700001)(66476007)(316002)(66556008)(8936002)(4326008)(26005)(1076003)(6506007)(6512007)(186003)(6916009)(2616005)(54906003)(478600001)(6486002)(6666004)(52116002)(2906002)(5660300002)(7416002)(44832011)(38100700002)(38350700002)(36756003)(86362001)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2gOytV5RTrf4qVKP/Wo51FIfbyOvN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2wrloF7VYK4/OVtmMXnoXMg5D5+jC2dIChz0ahne5/BgfeE+E3v7XgYVgGBCtFCfzEhf8FNGvhjsLUnU/AemHF0+YCl7fmNBoJnKqtREMCW7biW4C14kTN8GF94glS86u7aubfCO5I7hqyA6CqBcapTe21m1USX6h+Sa6rLehPn3otv3Ywz8s1qUmQYqS1po1gSSX3Mef2ldivDUYyt8KfomcjT2IRchIl47W/P/Yh2Yn9b8oauDLuMt2MpfopmTV2AssaBWz8K0cs4W6b1rdryBT4gProajaXH3y+m7bKWoxhMnscTk6srEU6JRypQXbVv2fDwuu4n+vD+D1Dy/HltSg6qugUBJLyRE26VvnTgb2kAkS/XJH4Ggj5mlYR1sZXltU9a96Ivbwfce89spboRtdqhoTrGTCI0phvSXKmRJLCc+lThWNe3unOqLdiF1yTtN5xEob1G3c+LDqrOFhvfWwMCir85xL7tsgdo0u4B4LjkKHnAaW3oZz/fEAlxD5yf1OluoQhYqmpaWqKnrghA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c0b56fe4-efcc-43b4-336c-08db765ba6d6 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2023 15:40:21.7902 (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: aFAFu+MyB9awBcSvw4F1MEPDGMg4yNAhkvboF1PEMsp8ZYITGfk1Q2MJDbwQs1fC75vBhMIT+t4SuZPu4h3y1Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8638 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_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769783452684825205?= X-GMAIL-MSGID: =?utf-8?q?1769783452684825205?= In a future change, the driver will need to determine whether PTP RX timestamping is enabled on a port (including whether traps were set up on that port in particular) and that is currently not possible. The driver supports different RX filters (L2, L4) and kinds of TX timestamping (one-step, two-step) on its ports, but it saves all configuration in a single struct hwtstamp_config that is global to the switch. So, the latest timestamping configuration on one port (including a request to disable timestamping) affects what gets reported for all ports, even though the configuration itself is still individual to each port. The port timestamping configurations are only coupled because of the common structure, so replace the hwtstamp_config with a ptp_rx_filter saved per port. We also have the ptp_cmd to distinguish between one-step and two-step PTP timestamping, so with those 2 bits of information we can fully reconstruct a descriptive struct hwtstamp_config for each port, during the SIOCGHWTSTAMP ioctl. Fixes: 4e3b0468e6d7 ("net: mscc: PTP Hardware Clock (PHC) support") Fixes: 96ca08c05838 ("net: mscc: ocelot: set up traps for PTP packets") Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/mscc/ocelot.c | 1 - drivers/net/ethernet/mscc/ocelot_ptp.c | 30 +++++++++++++++++--------- include/soc/mscc/ocelot.h | 5 ++--- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 1f5f00b30441..2fa833d041ba 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -2925,7 +2925,6 @@ int ocelot_init(struct ocelot *ocelot) } } - mutex_init(&ocelot->ptp_lock); mutex_init(&ocelot->mact_lock); mutex_init(&ocelot->fwd_domain_lock); mutex_init(&ocelot->tas_lock); diff --git a/drivers/net/ethernet/mscc/ocelot_ptp.c b/drivers/net/ethernet/mscc/ocelot_ptp.c index 673bfd70867a..d37637744bd3 100644 --- a/drivers/net/ethernet/mscc/ocelot_ptp.c +++ b/drivers/net/ethernet/mscc/ocelot_ptp.c @@ -476,8 +476,24 @@ static int ocelot_setup_ptp_traps(struct ocelot *ocelot, int port, int ocelot_hwstamp_get(struct ocelot *ocelot, int port, struct ifreq *ifr) { - return copy_to_user(ifr->ifr_data, &ocelot->hwtstamp_config, - sizeof(ocelot->hwtstamp_config)) ? -EFAULT : 0; + struct ocelot_port *ocelot_port = ocelot->ports[port]; + struct hwtstamp_config cfg = {}; + + switch (ocelot_port->ptp_cmd) { + case IFH_REW_OP_TWO_STEP_PTP: + cfg.tx_type = HWTSTAMP_TX_ON; + break; + case IFH_REW_OP_ORIGIN_PTP: + cfg.tx_type = HWTSTAMP_TX_ONESTEP_SYNC; + break; + default: + cfg.tx_type = HWTSTAMP_TX_OFF; + break; + } + + cfg.rx_filter = ocelot_port->ptp_rx_filter; + + return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; } EXPORT_SYMBOL(ocelot_hwstamp_get); @@ -509,8 +525,6 @@ int ocelot_hwstamp_set(struct ocelot *ocelot, int port, struct ifreq *ifr) return -ERANGE; } - mutex_lock(&ocelot->ptp_lock); - switch (cfg.rx_filter) { case HWTSTAMP_FILTER_NONE: break; @@ -531,15 +545,12 @@ int ocelot_hwstamp_set(struct ocelot *ocelot, int port, struct ifreq *ifr) l4 = true; break; default: - mutex_unlock(&ocelot->ptp_lock); return -ERANGE; } err = ocelot_setup_ptp_traps(ocelot, port, l2, l4); - if (err) { - mutex_unlock(&ocelot->ptp_lock); + if (err) return err; - } if (l2 && l4) cfg.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; @@ -551,8 +562,7 @@ int ocelot_hwstamp_set(struct ocelot *ocelot, int port, struct ifreq *ifr) cfg.rx_filter = HWTSTAMP_FILTER_NONE; /* Commit back the result & save it */ - memcpy(&ocelot->hwtstamp_config, &cfg, sizeof(cfg)); - mutex_unlock(&ocelot->ptp_lock); + ocelot_port->ptp_rx_filter = cfg.rx_filter; return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; } diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index cb8fbb241879..8fc6a07ab966 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -775,6 +775,8 @@ struct ocelot_port { unsigned int ptp_skbs_in_flight; struct sk_buff_head tx_skbs; + int ptp_rx_filter; + u16 mrp_ring_id; u8 ptp_cmd; @@ -868,12 +870,9 @@ struct ocelot { u8 mm_supported:1; struct ptp_clock *ptp_clock; struct ptp_clock_info ptp_info; - struct hwtstamp_config hwtstamp_config; unsigned int ptp_skbs_in_flight; /* Protects the 2-step TX timestamp ID logic */ spinlock_t ts_id_lock; - /* Protects the PTP interface state */ - struct mutex ptp_lock; /* Protects the PTP clock */ spinlock_t ptp_clock_lock; struct ptp_pin_desc ptp_pins[OCELOT_PTP_PINS_NUM]; From patchwork Mon Jun 26 15:40: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: 113033 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp7602265vqr; Mon, 26 Jun 2023 09:26:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5W0FGrVhHMhcRBvwe8LUaR9xSQnfyj03Q84+U25ReuLcG9R/ocDgS/zwBe849MItN5aLkW X-Received: by 2002:a17:907:e90:b0:991:e24f:b293 with SMTP id ho16-20020a1709070e9000b00991e24fb293mr1421804ejc.12.1687796801537; Mon, 26 Jun 2023 09:26:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687796801; cv=pass; d=google.com; s=arc-20160816; b=nu3MhpWay/gFOb5W6tyZExY3VTy0dhjn/cAU77M6IaPgTPDLtaXt/nkJa70mRAInr1 205NZ0mmoI50IgIQgGskURQ6SwMPl3kRRfHspRuiPbnY7CubITJLt5W6F/jKDkvoDnC7 iBeBDylF1AJr6itQN9OzCwOZ4FVp/Lfr7TverNEK28TT2K6mfoWqiqnXBrOgBBDT7DdB xVKisJqYVPWvmemTkpnbxk/BbLjhzNmQlWf1HaaYvM1Hv4J5lfXvWR/iwN5eKFhftRod rUvuxfTUmi/1/nEU4NeWjQPAEQMID3iBmfynqnL+45ufO0gW33AimGVWemdxy/WETN3k ENsA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=i0j/nqHqDpvEjXYb8h1shYRMos067V+5iSrxQMD/IY0=; fh=iurQRswHi9hWiYvyPjsOpfQdagiAg7Zmv5exCLcOUfA=; b=NgbixyejIrfUu7dW8QMLA4lqsplt0SYFD7Z2as7PXDGxm3zj4c8rMAzIcLfhY6RqKO wQHLb8A5+C5/vwf7XExThURugUywymXAEqJTvFLnUdNxB93Y2VJ+30KffO9u0NMkKs4h 3US9OrxA4uUmEYxRlR9jSFFtOMGJfqJ0KGxX/vqPqYWx09qS6Fc08kYGUQsqreg/v2+e 5DQc5eysFdPRjA3/mcHsmuF4cBZd6HNx0J7ScN8vIwR3DbUeNaJDI0HjzjbZ2sleKJKR qnhyvoWXI8tptkBOD/Bkp63fDUYfs4g7m50KCq6skBU3CT9hx1MhE3UUYCd6US4b08jL 7fKw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=JZ0FZl9r; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q17-20020a170906b29100b0098869cd31adsi3167877ejz.899.2023.06.26.09.26.16; Mon, 26 Jun 2023 09:26:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=JZ0FZl9r; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231423AbjFZPko (ORCPT + 99 others); Mon, 26 Jun 2023 11:40:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231367AbjFZPk3 (ORCPT ); Mon, 26 Jun 2023 11:40:29 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2050.outbound.protection.outlook.com [40.107.7.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AD3EAB; Mon, 26 Jun 2023 08:40:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i0pGzpkMBrEZdxv8FckJnxe65vyl9hiypRo0BgENxePojem1u0JrAmO0mi9VGtORuBPdmxnxcr3Uputw/kkiw/BPCHwiMG5MQm45C0IE4J0jGAw45fzZDCWUA2Q4BBOgimuhQRUX6bfqzbohJc31/KTBGt5sBE2H2gND+WATOLRks6fsaav/EOlHH3xShP9IlZiIfPlwsPr7xjNrS2c3Wply5w/vLe6KBGA97S7Tl2EzUF85hNpcoO7R+1Cp5CqGfbyd+HjxF2T6eP8xzsluvtfJ3jrOUFxJEoqyYHq4+W9SoZ1Lm7TPleUt8x1yhHKYTtWGqaB+oMlwmk0kcMfO8w== 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=i0j/nqHqDpvEjXYb8h1shYRMos067V+5iSrxQMD/IY0=; b=BnybLaITLk1yXFq5phy3SPRYd4ESn4VQ7B+YKblMJaN/w0ryVB8YSc2+Tz9zhz5wvj2qc6IkEKNd1/cgz2UNqQy3ALqVkN6bimECoRnJGLGLkGc/Nli08aoOm52ZeAIGq4rHFFBnxcDI6HKkPzR9KNmxpzJSHaNwbFkKQKkRvDOhxKaEXWo/nsCJa8jBG+/kW+fzoX3VHgF6y3SqAIsB8uTjxM89GycZdJbuUrIy8meGvZnzTwZhS+QiFGaFiVUTXl7nROMaWdaFrSiV+18DdZolXhPCxik99GafEKNWSSRKH57oWwQ5AWsU6NbCAABL+xLAwN/1iP5hEo93SHAnKA== 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=i0j/nqHqDpvEjXYb8h1shYRMos067V+5iSrxQMD/IY0=; b=JZ0FZl9reC1lGJidsVkue1RGoVpj7vhQXwA9NR6wgcVsbFokT0MQ4dAHO9o3ay2p2czUkkCVtgsaob8na6vOTKQEhdaPrhW/LKdO+xV8/tY9CyFwSOkV8dYLq/ERkejA6Th1mBNXv6oBTywM7ILNZo3HoxbSz0R2WOn/0mjGHn4= 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 PAXPR04MB8638.eurprd04.prod.outlook.com (2603:10a6:102:21d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Mon, 26 Jun 2023 15:40:22 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::c40e:d76:fd88:f460]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::c40e:d76:fd88:f460%5]) with mapi id 15.20.6521.026; Mon, 26 Jun 2023 15:40:22 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Andrew Lunn , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Xiaoliang Yang , Richard Cochran , Antoine Tenart , linux-kernel@vger.kernel.org Subject: [PATCH net 3/3] net: dsa: felix: don't drop PTP frames with tag_8021q when RX timestamping is disabled Date: Mon, 26 Jun 2023 18:40:03 +0300 Message-Id: <20230626154003.3153076-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230626154003.3153076-1-vladimir.oltean@nxp.com> References: <20230626154003.3153076-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR10CA0121.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:e6::38) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|PAXPR04MB8638:EE_ X-MS-Office365-Filtering-Correlation-Id: 9e94864d-1cb0-42a5-65aa-08db765ba76c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E5H8EHj3NtD1NVVrfOGmFAR5pAJxTTpUxrinbq5TRBpjUsv/UctFUtFxDoeJu4Oim4WMHFHuuSyPZGbcvZa/BfR5UoOwe2+xzATjFCv2ym2/0B+1K2CX5sH8PVxyKCCIHB4VnRoV/VF58VCwvqLbYG8sbt3l26hVVcxGDmLoSWjDMKzap+RwF9qf76R3JRq/0cY2JeJ9G9RPGMda4u+zWF1ElrVp00UuWaIxPRNaMArU1Vsp7+Qyg048QIS3ouuWLTaDRyUU/nDWvbkgFPu1qLPxX2eR65STNjydN+pFNQr7Hue94rgkicXmOv0kckP0X2ko0usD7Yt3BLxjIO9WjA0X23nym/Ai5URe+qmWf0t7oruXTziWVxAAnmGN6Dd+sfhhWiNiJj/8cEsITLAJpSm8xoPhl6fCVaW4nVreHctnAoZr5XCiO75p06LTc+Dawhy0aw8SvpVuCKtlSlfNsFaxoHrcUNh6LHL1JxLBq79YSXM+yA5/Uq84V3GAl1xV9KuMR482BX4DwyWWsVPiXtfUsJdKDWaYmgCkp7gSd/fyW2SjLLabGhEtNLTm+hYp4TspTMyOCAUW15a1+by6HxYDBX4tGrztJofj5IR7avAhuc/DD/WanhiKIM8uAd/Z 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)(39860400002)(376002)(346002)(396003)(451199021)(8676002)(66946007)(41300700001)(66476007)(316002)(66556008)(8936002)(4326008)(26005)(1076003)(6506007)(6512007)(186003)(6916009)(2616005)(54906003)(478600001)(6486002)(6666004)(52116002)(2906002)(5660300002)(7416002)(44832011)(38100700002)(38350700002)(36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my/1/wKWKhf1HkLdHakQsg7a8GzDbh8fEkhwnhf2ixLEhrnUYTLdNL3BRzrypMqGgoXNorf8hdfrgbPQaCCMW7CJ8RwEcix3kBm0SdiIl/g7aTiTry+gzQmTomXXFPtVbdjlKVf02cWHcsqqlvkR4KY/xyrz6cKPgiNvBqlTh3HhHMtSFvm6hNdGiuBprGHprH8ebZrt2RmT2wCmVRIy0s56pDjv/dbsNI4cMnA/Z47GptgFS8IQVese3lZ8B7BziXPtW+DCXxptKYMJODd/HSclMAUA+nAVp5qeNWPbIiguuuYfC7wReuhneGlpoRkC4dwU1/QEkAq0lGrbT9Nt2Htkj2fuMt6AVUn4OOSpSYCa1TNarzDLhvNQJ4EWPyIobo/n1+Xf8DfqH6fI2Hqg7s5TqFcJA5CeSmD26H2QWBF742Hhtlw3FWxM4uPze+Z9SdSaDw8WDbQW0NF7LkWA97HEbh0/CTH4DYx5SR3sXpcOd8DfXs3yMkuN58UCgMUL9Wj9NR7gyYE7lG8dRloac554Hg9iypVL5B/dvus1DwwFV7sYzSemCjqSPM/AIIbKBwWYwqfkxXAv8+EtSZOkNw7UlD/BE4bYfNjDgg3Q8pNLf+NH34pitjujVUwpC07coJw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9e94864d-1cb0-42a5-65aa-08db765ba76c X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2023 15:40:22.7881 (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: 8UcRm/b0rGYU8n+p4teweupaLu/uhqs9gQ8NZnDgaOZZ3lylsHjf5YOZdkSTfBs7uc95SndjQT9M7cyjjf8IuA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8638 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_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769783218893360390?= X-GMAIL-MSGID: =?utf-8?q?1769783218893360390?= The driver implements a workaround for the fact that it doesn't have an IRQ source to tell it whether PTP frames are available through the extraction registers, for those frames to be processed and passed towards the network stack. That workaround is to configure the switch, through felix_hwtstamp_set() -> felix_update_trapping_destinations(), to create two copies of PTP packets: one sent over Ethernet to the DSA master, and one to be consumed through the aforementioned CPU extraction queue registers. The reason why we want PTP packets to be consumed through the CPU extraction registers in the first place is because we want to see their hardware RX timestamp. With tag_8021q, that is only visible that way, and it isn't visible with the copy of the packet that's transmitted over Ethernet. The problem with the workaround implementation is that it drops the packet received over Ethernet, in expectation of its copy being present in the CPU extraction registers. However, if felix_hwtstamp_set() hasn't run (aka PTP RX timestamping is disabled), the driver will drop the original PTP frame and there will be no copy of it in the CPU extraction registers. So, the network stack will simply not see any PTP frame. Look at the port's ptp_rx_filter to see whether the driver has previously enabled the CPU extraction registers. If it hasn't, just don't RX timestamp the frame and let it be passed up the stack by DSA, which is absolutely perfectly fine. Fixes: 0a6f17c6ae21 ("net: dsa: tag_ocelot_8021q: add support for PTP timestamping") Signed-off-by: Vladimir Oltean --- drivers/net/dsa/ocelot/felix.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index 80861ac090ae..7b494d975073 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -1725,6 +1725,9 @@ static bool felix_rxtstamp(struct dsa_switch *ds, int port, u32 tstamp_hi; u64 tstamp; + if (ocelot->ports[port]->ptp_rx_filter == HWTSTAMP_FILTER_NONE) + return false; + /* If the "no XTR IRQ" workaround is in use, tell DSA to defer this skb * for RX timestamping. Then free it, and poll for its copy through * MMIO in the CPU port module, and inject that into the stack from