[PATCH v7 net-next 0/9] net: dsa: netc: add PTP support for NETC switch
From: wei . fang
Date: Wed Nov 11 2026 - 01:23:16 EST
From: Wei Fang <wei.fang@xxxxxxx>
This patch set adds PTP timestamping support to the NETC switch, so that
the switch ports can be used for IEEE 1588 PTP synchronization.
The NETC switch has no time registers of its own and instead shares the
PTP time of the NETC Timer, which is a separate PCIe function driven by
its own driver. The first 3 patches prepare the Timer driver for this
role: tidy up its 64-bit register access, drop an ineffective reset, and
export netc_timer_get_current_time() so the switch driver can read the
current PTP time across the driver boundary in a race-free way.
The switch redirects PTP frames to the CPU through the ingress port
filter table (IPFT). A few patches harden and simplify the existing IPFT
and host flood handling first, then enable the ingress port filtering
lookup by default so PTP filter rules take effect without extra software
tracking.
On top of that groundwork, the switch driver gains RX timestamping and
both flavours of TX timestamping. Timestamps are carried between the
hardware and the driver through dedicated switch tags: the ingress and
transmit timestamps ride in To_Host tags, and per-frame requests ride in
To_Port tags. Two-step TX matches a queued skb clone against the
timestamp response echoed back by the hardware. One-step TX defers the
Sync frame to a per-port work, where the driver reads a fresh PTP time
and writes it into the Sync frame's timestamp field, then programs the
single-step register and transmits the frame so the hardware can add the
residence time to the correction field on the wire.
Together these changes let standard user-space PTP stacks drive hardware
timestamping on the NETC switch ports.
---
v7 changes:
1. Rename in_probe to configured in struct netc_switch
2. ptp_ipft_eid[] is initialized for every port, next to ipft_hf_eid
3. Return -EOPNOTSUPP when netc_get_phc_index() is negative in
netc_port_hwtstamp_get()
4. Initialize onestep_state to NETC_ONESTEP_PORT_INACTIVE in
netc_port_ptp_init()
5. Drop the netc_port_enable_onestep() call from netc_port_enable()
6. When the frame is not known to be a one-step Sync, set *twostep to
true instead of dropping it
v6 link: https://lore.kernel.org/imx/20261103021024.3121936-1-wei.fang@xxxxxxxxxxx/
v5 link: https://lore.kernel.org/imx/20261012095924.1129312-1-wei.fang@xxxxxxxxxxx/
v4 link: https://lore.kernel.org/imx/20260918072852.501420-1-wei.fang@xxxxxxxxxxx/
v3 link: https://lore.kernel.org/imx/20260831082335.1184605-1-wei.fang@xxxxxxxxxxx/
v2 link: https://lore.kernel.org/imx/20260808032146.2335723-1-wei.fang@xxxxxxxxxxx/
v1 link: https://lore.kernel.org/imx/20260728104548.3301214-1-wei.fang@xxxxxxxxxxx/
---
Wei Fang (9):
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: tie setup resources and reset to DSA setup/teardown
net: dsa: netc: use entry ID instead of pointer to track host flood
rule
net: dsa: netc: check return value of ntmp_ipft_delete_entry()
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 | 2 +
drivers/net/dsa/netc/Makefile | 3 +-
drivers/net/dsa/netc/netc_main.c | 404 +++++++++---
drivers/net/dsa/netc/netc_platform.c | 1 +
drivers/net/dsa/netc/netc_ptp.c | 895 ++++++++++++++++++++++++++
drivers/net/dsa/netc/netc_switch.h | 67 +-
drivers/net/dsa/netc/netc_switch_hw.h | 5 +
drivers/ptp/ptp_netc.c | 136 ++--
include/linux/dsa/tag_netc.h | 38 ++
include/linux/fsl/netc_global.h | 10 +
net/dsa/tag_netc.c | 228 ++++++-
11 files changed, 1619 insertions(+), 170 deletions(-)
create mode 100644 drivers/net/dsa/netc/netc_ptp.c
--
2.34.1