From mboxrd@z Thu Jan 1 00:00:00 1970 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 8808AC531F9 for ; Tue, 28 Jul 2026 10:42:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding: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:In-Reply-To:References:List-Owner; bh=BT3wuPCocpfi1iaj68+sMtkg3RuwN5M4ai11tGNyBYs=; b=fKwlHaY6HJxt2CKqOqTvRNIuDs xDmww/2ePf7xvzimJhZUq8YMLlSAQlUZ3l12YWUDqzdL6wANMbTPQv11uW7skm8S4e7fakOjr5jYv TeYeD/isQsgzsXx5OSalkhrkrjF9i0oYY2kecoIjUxBhGqfr20YuDNciqNeJwoODg2yWC9eoullRZ 0pOFrybwrBCbN8abFdbGdjGp77PkNOQxFfoQ7Nv7Y3Ct52wZnNsV0cUjNLwUfg9ZPZxT/oM0pv/ke /kPTUwHCcMfrXdNytHxN6JvxcsmllaAmhqxUcjfNyB/gyIyJXMy05dFFdl2Ew8MSAX+8+wTV4UEY6 MqtkLkLw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wofGJ-00000004zCB-3J1H; Tue, 28 Jul 2026 10:42:15 +0000 Received: from mail-westeuropeazlp170100001.outbound.protection.outlook.com ([2a01:111:f403:c201::1] helo=AM0PR83CU005.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wofGH-00000004zBM-22me for linux-arm-kernel@lists.infradead.org; Tue, 28 Jul 2026 10:42:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sSQHd0zm/tsZl3GZe4ETUrDzmqx8WBo9YcfcaGkY4mUVlmR72I/l+XJR/Do3fLo/u65ZpCHo4QriU1jzH/LXsORFeTLxSNz6uuJHKoNdkSWkYnD2yKkHEkr+Qesszk9LFMxHX9aQfRVy3+W7Jk7fY4eaakg7XJO2YT+cBpl6Yf0ymolOypHW64PckX8VixAtsS9Z/tZA6zJE/NKRmwZ4elSIR7KtTVZCi3si3M+8qD3EBneYMoeqNGfik8sdvkgyUT5mjR4ZwE3c1C/7IZoDLMQRex4qC175KRnqPvZpKXttEwxQfLRtkDdlKBtFLr2tBoNY435HttaJIv9XfcfJoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=BT3wuPCocpfi1iaj68+sMtkg3RuwN5M4ai11tGNyBYs=; b=G1fKREojBVydhDaTMKVYIxv+CoVbGO7uuyOcnBtR9rXpDzD4uyITVvOHJ9MFNbq+5FleDUJPxIbTHgHO/cteFBhL2nHqXDP2EqNjvNirPHf/qoU/Sjx5rdgTOkQNO7T92wqxNpNH5/H6quPMtlur5Xs4HsFRZVve3LJMcf+HOYG70n7hk+2nBcTdiZ9q1gb6qoKL8Op/I4GLxLSO6Jhmt0KC06Y+3emaJcJRltrCTj0UKUnOY8EWz1yQHPli6XgLq5aytaqOy35DNb8KzXcUZNqvOpnxx52b1qb4tK0kdVxRar/QdiCI1ZWH2dSGBf8Olqzv3dRzbvxaucvBg1Reww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BT3wuPCocpfi1iaj68+sMtkg3RuwN5M4ai11tGNyBYs=; b=DGVEq5A1CVdCcA570691MLNvRNkCks6hkkGZojPS5dQE9m23bPLBKL2+sLxPRKsL8anxweT0YiuIJ7M+Hp9UtyUaKi3ldZKayGXmFx/QGclp0S2o1T9x2nmaRA3uWYGup9aC6vil5W5SWdQELjD54F16rFj6yjnWISpWkPqRes7KppGkw8CgKhRlZV8/vpJHlLiwjHmrjaS1D2vXw3+hVgQSDyvteC8hyg2XzrF4uxZ5kjAkBHe3uMFqasDTcBRElPKTWx8l/h6rLkCKkY7pYDsIyLvCqHVPyjTAJIIONUYRAOCcfRXr/kPfoUjwwhyM9CFTv6sMZjld23wAHXQP2g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DBAPR04MB7207.eurprd04.prod.outlook.com (2603:10a6:10:1b2::17) by GV2PR04MB11835.eurprd04.prod.outlook.com (2603:10a6:150:2fe::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.13; Tue, 28 Jul 2026 10:42:06 +0000 Received: from DBAPR04MB7207.eurprd04.prod.outlook.com ([fe80::761a:f8dc:80dc:5e14]) by DBAPR04MB7207.eurprd04.prod.outlook.com ([fe80::761a:f8dc:80dc:5e14%6]) with mapi id 15.21.0270.009; Tue, 28 Jul 2026 10:42:06 +0000 From: wei.fang@oss.nxp.com To: richardcochran@gmail.com, vladimir.oltean@nxp.com, xiaoning.wang@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew@lunn.ch, olteanv@gmail.com Cc: wei.fang@nxp.com, chleroy@kernel.org, imx@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH net-next 0/7] net: dsa: netc: add PTP support for NETC switch Date: Tue, 28 Jul 2026 18:45:41 +0800 Message-Id: <20260728104548.3301214-1-wei.fang@oss.nxp.com> X-Mailer: git-send-email 2.34.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SI3PR01CA0008.apcprd01.prod.exchangelabs.com (2603:1096:4:296::7) To DBAPR04MB7207.eurprd04.prod.outlook.com (2603:10a6:10:1b2::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBAPR04MB7207:EE_|GV2PR04MB11835:EE_ X-MS-Office365-Filtering-Correlation-Id: 9a0de393-3861-4cfc-d587-08deec94de17 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|19092799006|23010399003|366016|1800799024|7416014|376014|56012099006|10067099003|11063799006|6133799003|18002099003|921020; X-Microsoft-Antispam-Message-Info: RTkmYBLVYC/H0LktXtpBl22N04edRoTLyiJx8Dvpe5HmeOjMNIsWhOEoKSixmDCfiBCJLRJcmHUNbe7JZgDnuhVBdkmAii+sYJLNbDhdueQTVOGkAcpwsDB4HZvbVNyWPQCOxKR1/dJS2C9YYz28xAMVL3xMYIPNcqstWfbQXvrP2b1aZPyJjrh4h5n1mZ8qQyQVSefsMfOpIdGKePPimxrZG7ovgEcOH0c+mT34WJGxntaagMukiKlymeQKFqTJVd4NeLuEhcUjpS0lA5eTwByFg6S9aWeYaO9t6ps6qel49ueXvjNJFMv7tBtQCI+hUq/zC2UN+Hyhd7aPxuT/DtSgY30rda65NGhyjxcPBbNYc6InMFc1bx/2Pqjsozqs6Hqfh68cUCf6JV9nCazQznTJj6JvapJB2WZ2lZaB2lbwCTWaZnyaZ6eb/DatvnaMmDNyqj+TLX7rweTHo02mCTf9EaBVWiZruRXK1jbowkUXS+8bu8bs/xtusH4zu2OfeYoPMoYtdhosDvuKf2X7xOYGvGHNBHFrw9/7PFkeERUnrjzdVlJlUyILwSLVW9+nj73ks5DzuZkEZkUZyGct+RmCXbe6qI4E54tud2eQbVdKBxyk5AlnHQhhlaXcY4IxSzj29WwxuyXI3LJkQBZPzDlz0DVxUZPuCZhUNhcuCN+7cDoM8HitWzt4zoc5lIFIxqgdtljaCRVybYr1qGqq5w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DBAPR04MB7207.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(19092799006)(23010399003)(366016)(1800799024)(7416014)(376014)(56012099006)(10067099003)(11063799006)(6133799003)(18002099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?5uIUsLl4iXAbEnDXVOP0/O5WsM6MotPDg1jloCf+gbgd/E0tqLvReyBLVKHe?= =?us-ascii?Q?nuXozJgRQO1XQpYpEOXmFPEwno7DfVhnqaj5AD+et5pws33EcVrgOtcm0pPv?= =?us-ascii?Q?XVpZVvdV9OnsiDP8EVDw7dY9oHKSLq2zAj2RBvFv7MSjcErX2W9IMAdjmuTA?= =?us-ascii?Q?Gn9jmd3iEAeDDpjU+eN/A914C8mT2hx3fWsj/0urxX/hsUkj9YQhckhS0c7P?= =?us-ascii?Q?/xLeIzxSuwb6pbtiV6x/6VcwY8RTmAl2dGTq2qch0U4p7v5zadOgnonUUZDq?= =?us-ascii?Q?TroeiIcM94HpdYjbYpJEuff/4xjB/78OuKXPSQQV5BM4nuUnqCNb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JbeNzjhRhYz0JkyUWgd+p47bmpC/TvgsXa+7lYOz?= =?us-ascii?Q?uJPA5aZFUVVN4pA3ETE4P0KxHUlPwUcxzXzKjIlQrqxQORnTYC5Q44S1nyqI?= =?us-ascii?Q?jExI1mzjPlVvDVqu0W76TbfA32uzhNTkZi0k9StLNPnBwV1G1B8aM7t98zIU?= =?us-ascii?Q?yay/YcqMmN7GhgGUDFx+ghm5uhSW0rh+kmnJtzlrBXbN4oR0CJ6pkk8uPP40?= =?us-ascii?Q?LHUjLbeicnOfwB2s6Iyq0xXRCLGG05xO+e1LxzzDsJ9U0zWcMCQHepHS3cCJ?= =?us-ascii?Q?IYQIlaqTfYvF2Bc3v5fWxwyaMA5aQgsMEJY2zVHVfCdwr954hWeq8v0ZTpqC?= =?us-ascii?Q?y8ra0pgZPaDTn4/aWRQg2nyJLrNEa+j3INPM4soxg7sBAWjW8HGFEtEMHrrF?= =?us-ascii?Q?EqMl5V1wmpeI1gzDGzFz/4O1kgUOZeeu1WhjSrBXSN8gV43BKoXbPcekRi8q?= =?us-ascii?Q?06ezBZOtaDsypeenRLnsqcqE80Fu+LXkNVv7gxrkazDNFM29tMjmFrhyUJRa?= =?us-ascii?Q?9bvHYXTVL0t8Jl7DuvQPR3g6zdZcjplmCS4DxiT01wtrzANWbh0e?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9a0de393-3861-4cfc-d587-08deec94de17 X-MS-Exchange-CrossTenant-AuthSource: DBAPR04MB7207.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2026 10:42:06.1234 (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: gWAT2I22Kq9DZz0yeOlnmnudTiucXdxvmJ4szBHkE79xqmKksE38FpeMW5XQLhdZYln/ooSVCK9bGr5Luh4u/obPNI/4T4Y4KhZ+vQ26M6JK8lCgqpa/rBOpCnSHh82G X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR04MB11835 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260728_034213_535086_08EA8BEB X-CRM114-Status: GOOD ( 17.15 ) 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: Wei Fang This series adds PTP hardware timestamping support to the NETC switch DSA driver. The NETC switch has no time registers of its own; it shares the PTP time base of the NETC Timer, which is a separate PCIe function driven by the ptp_netc timer driver. The series therefore first prepares the timer driver to expose the current PTP time to other drivers, then builds RX, two-step TX and one-step TX timestamping on top of it in the switch driver and its DSA tagger. The series is organized in two parts. Preparation of the NETC Timer driver (patches 1-3): 1) Convert the open-coded 64-bit register accesses to the ioread64_lo_hi()/iowrite64_lo_hi() helpers, wrapped in netc_timer_rd64()/netc_timer_wr64(), to reduce boilerplate and make the access width explicit. No functional change. 2) Drop the pcie_flr() call in probe. Per the reference manual, function level reset does not apply to the Timer as a supporting function, so the call has no effect. 3) Export netc_timer_get_current_time() so the switch driver, a separate PCIe function, can read the shared PTP time. The helper is declared in under CONFIG_PTP_NETC_V4_TIMER with a stub returning 0 when the timer is disabled, so callers need no hard dependency on the timer driver, and returns 0 when the timer has not probed or is gone so the caller can handle it gracefully. NETC switch PTP support (patches 4-7): 4) Track the host flood rule by entry ID instead of by ipft_entry_data pointer, freeing the descriptor as soon as the hardware entry is committed. This removes a long-lived heap allocation and lets netc_free_host_flood_rules() go away, in preparation for the timestamping rules added next. 5) Enable the ingress port filtering lookup (IPFT) by default. A frame that matches no entry is simply passed on, so leaving the lookup always enabled simplifies the logic and avoids tracking whether a port already has an IPFT entry, which the RX timestamping rules rely on. 6) Add two-step TX timestamping and RX timestamping. RX installs IPFT rules that redirect PTP frames (L2, L4 over IPv4/IPv6, event and general) to the CPU port; the hardware prepends a To_Host tag with the 64-bit ingress timestamp, which the tagger hands to netc_port_rxtstamp(). Two-step TX clones the skb, allocates a 4-bit request ID carried in a To_Port subtype 2 tag, and completes the clone when the hardware echoes the ID and transmit timestamp back in a To_Host response frame. 7) Add one-step TX timestamping for PTP Sync frames. The MAC updates the correction field in flight using the per-port PM_SINGLE_STEP register, which is a single register that must be programmed per frame, so one-step Sync transmission is serialized per port with a per-port PTP spinlock guarding an in-flight slot and a deferral queue. This patch switches the Kconfig dependency to PTP_NETC_V4_TIMER because it reads the shared PTP time through the helper exported in patch 3. Wei Fang (7): ptp: netc: use ioread64_lo_hi/iowrite64_lo_hi for 64-bit register access ptp: netc: remove unnecessary pcie_flr() call in probe ptp: netc: export netc_timer_get_current_time() for cross-driver use net: dsa: netc: use entry ID instead of pointer to track host flood rule net: dsa: netc: enable ingress port filtering lookup by default net: dsa: netc: add PTP two-step timestamping support net: dsa: netc: add PTP one-step timestamping support drivers/net/dsa/netc/Kconfig | 1 + drivers/net/dsa/netc/Makefile | 3 +- drivers/net/dsa/netc/netc_main.c | 135 ++++-- drivers/net/dsa/netc/netc_platform.c | 1 + drivers/net/dsa/netc/netc_ptp.c | 663 ++++++++++++++++++++++++++ drivers/net/dsa/netc/netc_switch.h | 49 +- drivers/net/dsa/netc/netc_switch_hw.h | 5 + drivers/ptp/ptp_netc.c | 86 ++-- include/linux/dsa/tag_netc.h | 42 ++ include/linux/fsl/netc_global.h | 9 + net/dsa/tag_netc.c | 192 +++++++- 11 files changed, 1091 insertions(+), 95 deletions(-) create mode 100644 drivers/net/dsa/netc/netc_ptp.c -- 2.34.1