Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp17963265rwd; Tue, 27 Jun 2023 09:41:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ57VC4dVPMkZZ6qWxfqmbKeMjeNVR4GLrCbjK5TxmVj16wd4nBZ/VyOM/QnriSBdpx/SHt6 X-Received: by 2002:a17:90a:7481:b0:262:e574:87a5 with SMTP id p1-20020a17090a748100b00262e57487a5mr7174356pjk.6.1687884065681; Tue, 27 Jun 2023 09:41:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687884065; cv=pass; d=google.com; s=arc-20160816; b=BlARF6z0YqdhD17E6N0RV8JBHpPXjVhNdtzdZDdiK02U+8IgAcPD0DEB/tkSKpMCfa 71Hu8N+pFX7pvnXJFNAZmdKKsipIWVXzC4dwt4WRN9X+SWe4iP1ehteoSnC+nzN58Cza V1GuyP1coF/Lg4+J/UETtRrHNtIa1XVB+9Mn0wG2z9IO/eA1MLgXqiqg/rkcVxDdCBIL K7UUcQ3iSN+V6ODYVLJHTx4OL7D11c8mZIxilhQl5zVH43m7IcKFuzb7cVEk1H04vGin Xhgzj88+Zmzzj3ZmebW5IkaYNrFJFyS1O1eOUazGyPQK0LtbUBrdvte+dI2cZBo0cV26 2c1Q== 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=zzsh9DezhFnr46zoqNwvG2xkkkAQf05VNJB7IfbkEmc=; fh=iurQRswHi9hWiYvyPjsOpfQdagiAg7Zmv5exCLcOUfA=; b=vX/pr/zJHVxPyD4j69VMEsSSSBhOZ02DcwdLxtbsEQrY9ZxkvGFG1A6aIDzhGbOvkf 7bez6SXyTM7X1ZDX2Hg50WU2yd7isTFG7ejZwQzLHe7yM7bxEZMhoFlzWwzdr7Glb/tQ PgcmRVRJ9/C/OnXatBs33F5fqUmxUyTkz5cD7F37tW14PCQw6OpMTjpReCsg2EBTyXLa 4OISg9Gi+otaoLhg54XKMKj2uojhR4c1EL6eNM92qNkFF9gGcW0DgRVEth6S0SxjYXhT IrQLicPYYKJsxRLOKk/XArYdhKkOEU1bCmRuU5kbmD3FuFie+eAj2K9mD5ogcZN5fyrG id0g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=QQfqcmXW; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kb15-20020a17090ae7cf00b00262fa96d9e6si4413923pjb.142.2023.06.27.09.40.51; Tue, 27 Jun 2023 09:41:05 -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=QQfqcmXW; 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 S232565AbjF0Qcc (ORCPT + 99 others); Tue, 27 Jun 2023 12:32:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231267AbjF0Qbx (ORCPT ); Tue, 27 Jun 2023 12:31:53 -0400 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2086.outbound.protection.outlook.com [40.107.249.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0C513AB7; Tue, 27 Jun 2023 09:31:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lJTno22RrgP1c4aEqqKmZ+axVuFTmf4KNiGAzpYzZky0SbEcRF7NsvtwaT7amiN+IsjXDjRq/L4bwIh6qTP2R/qH+FmpEZ0bAbpyPl08ZfiR05uQ2MTwCrJxJECiMAXM0dUrsTmn3CHkJLCb1SL0syJI1dRnXKNOUzYJqs+1j78WMfoC2mRE99FMfpj6YwFLC2MxM22Y3DWD6XoEZp2Rpn4SL9MvW8Ecnh3ylv8WaRlrhpJHSge+u0eagxsYQNLYqQbW9dv0qKHXRkA7wUaS7UR0IqmbO1Oovtyh6W1QhMOsdd50Fr9m7UxZWp9Accy+Ft04HeQKlhsoOtyF36041g== 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=zzsh9DezhFnr46zoqNwvG2xkkkAQf05VNJB7IfbkEmc=; b=F9gYKWY19R5Kj20Df2B+4YWmKUiwOb8pNv5V8m/oQuvRBWQC5eE7ldEdcH6qLAHdiIiI4UfmCEM+JQlnRcmVUmUNGWhRJRjnml6Z6T4ZcsKSpH+dinWBRG7EISfImOB7p+ueMWa2aWp7M1Ku9qt+7OEaHoIELB7qCe2uDwnJ4gfj/AbXL+Tb2FAC4JHSEc4JdmS3vSPICf4YjUTTJZHUl8uofT4Wh2oF9QrHMzT+S2UeVtssjWlB+awx0IghCkgSwNT3IfzL+Gog6SrvgAkuNC7ECRaqWGfy1kFWmapZRt4XoIbu42lYLERFLgFYds3DiQAsE0B7u+5qPLY6Zpq2cA== 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=zzsh9DezhFnr46zoqNwvG2xkkkAQf05VNJB7IfbkEmc=; b=QQfqcmXWJaTea9FiaS4G64o+Jc/ulPZkas+kiuXPg45T5LyByCp6OUJHqOYODuRKn59pul3ge4dkf7yT5z18C/Z0g88RoOxYt3hluJT+cTfrnoKFEfxM+Rgykx2c8f7B40vhvwbiyByIBvsu8aX6Ce7l66QLIo50d+yFrWANLuI= 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 AM8PR04MB7314.eurprd04.prod.outlook.com (2603:10a6:20b:1df::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Tue, 27 Jun 2023 16:31:32 +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; Tue, 27 Jun 2023 16:31:32 +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 v2 net 3/3] net: dsa: felix: don't drop PTP frames with tag_8021q when RX timestamping is disabled Date: Tue, 27 Jun 2023 19:31:14 +0300 Message-Id: <20230627163114.3561597-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230627163114.3561597-1-vladimir.oltean@nxp.com> References: <20230627163114.3561597-1-vladimir.oltean@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: FR3P281CA0078.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1f::19) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AM8PR04MB7314:EE_ X-MS-Office365-Filtering-Correlation-Id: ffcf2c18-e482-417d-708b-08db772bf737 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nntW6F0ly0KKK/QcYj8koJj52iXgsAZt0WU5I1MVbmldXSfEVYCjVvh/gnMBiLJGny6003CmtCagGHdPH7MhtGzGy5yVK4FrOFRzzRcUFhIXLVPLG2GtsmwkcqGj5zgdNXTVkm82KNZu5zLmCc1rtQ4EzqkAgM7HEPaVHLvaP7W7C3G3xDYAR2p6TdYyA4pn2rBCSUKGByb5mEP9Hm9W/BlC9UpGnhodTPRlRZtUpWd3evFMSXGUipQVLfrnetsJ8Zfq0aKxveDKjUhaGeWB6wNf65I3BAEy0xKKa/HNiM1joqY6Dp2AJY4esegMB2VWi3Ck4Vmnvj8/GfarYc6yfcCeiaHQvdkYI2kpzAXzFKmEvcHodHThLFJ15pzJdkQAw1od2fH54BbScenBJ6pbk+8DDUYN0zmGbZiI3CUuDJlGUdu2SqXlcJFWnDVQiuseqK48xHp51+pT9GxC9vclBfbFiHMrmRGrCmU+eboX2B2G8TVFqUCArPXaqkYTGlsjxTEUvx10uy3ScstdptumJzTuh+gadv+CHaqKXDwOQp2Vbh0pDfGxSy4Wllv+JwWep0s0MLafTVccSMqHnauj9SNMnVMb5yT8/BhgvlqClWMg6WG+dUC5BGWXwq9FT2KJ 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)(346002)(376002)(396003)(39860400002)(366004)(451199021)(6512007)(1076003)(44832011)(7416002)(66556008)(4326008)(6916009)(66946007)(478600001)(316002)(36756003)(8936002)(66476007)(5660300002)(8676002)(2906002)(86362001)(54906003)(41300700001)(26005)(52116002)(6486002)(186003)(6506007)(38100700002)(6666004)(38350700002)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?KkLbsVZXS1PZHAvS4lM4uUpcnTxJJmEFE8FilFhtkmNKvCdHImYJdIAW0u+I?= =?us-ascii?Q?8McGkwl1VGNpUtDngMYxDYMnx6G9gYuxkxA2/5dlWjPOhlASQUY20OTXeHR9?= =?us-ascii?Q?JgdLImgygPdJtRaRVUZa55H9WnyddxJtGRqN8fHvVI32jJLIA/OUpNcgFuq/?= =?us-ascii?Q?s6KQwAez6Uht+21MY4AmOqiUhrc8Ue0YXNZ5c/ITJCno0UfktEdIGuLGTXnU?= =?us-ascii?Q?K6gNqV+SgJdlRsp724SCqe7UFDBLI15dXud3hrvbrq4BYJDRwYeWVpngGUvK?= =?us-ascii?Q?SvychTOB/HBitGGOUpaPTxbB72/JRVdFdFN9Pt0IpS5nVVlKQm63i/57bFJI?= =?us-ascii?Q?5G3or8Qubo3aOUh49/WfPCL2bxLOqrLptearftr7P2+FTIPjP3rbxzSs4pKX?= =?us-ascii?Q?ympN15xHj/A79le2vTIMyBht+r+sgVg85D9JwBjss7/5LBMEn3+xzxLxkg+j?= =?us-ascii?Q?xkXI4+oG0PZdzRXuQ7gNJNKcijH5rep3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uNefkAdHk4qNdoi2ir/c7GG6+D7QDzPa0WGJWRox4w7sF9lsY8e8w?= =?us-ascii?Q?LuXCToT6O7rpflVx1Rke54989Rw3tqjhODmsHbSoIgWBYzeD98GGK/CfkkGn?= =?us-ascii?Q?p2BJTMMhBDX2EcumyE+Rrtm4KULavNPoRsN87qhdV5vzYpgTNLazNFgyvxwZ?= =?us-ascii?Q?M/6onERWq6VVW7D56P66JLBDbZorrFn7A+6mNJN2Vq5lrE9B5GlamUcz8/zd?= =?us-ascii?Q?gQ=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ffcf2c18-e482-417d-708b-08db772bf737 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2023 16:31:31.9752 (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: ZVPY/0B2djrLaqR2iROpazcwEuX3a+E7Is3ACY2Bo25TVn/L7LWIZuKn075AsFYwmunLiCeMye1amc8sJ/rk7g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7314 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, URIBL_BLOCKED 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 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 trapping configuration 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 perfectly fine. Fixes: 0a6f17c6ae21 ("net: dsa: tag_ocelot_8021q: add support for PTP timestamping") Signed-off-by: Vladimir Oltean --- v1->v2: distinguish between L2 and L4 PTP packets drivers/net/dsa/ocelot/felix.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index 80861ac090ae..70c0e2b1936b 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -1725,6 +1725,18 @@ static bool felix_rxtstamp(struct dsa_switch *ds, int port, u32 tstamp_hi; u64 tstamp; + switch (type & PTP_CLASS_PMASK) { + case PTP_CLASS_L2: + if (!(ocelot->ports[port]->trap_proto & OCELOT_PROTO_PTP_L2)) + return false; + break; + case PTP_CLASS_IPV4: + case PTP_CLASS_IPV6: + if (!(ocelot->ports[port]->trap_proto & OCELOT_PROTO_PTP_L4)) + return false; + break; + } + /* 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 -- 2.34.1