[PATCH net-next 0/7] net: dsa: netc: add PTP support for NETC switch
From: wei . fang
Date: Tue Jul 28 2026 - 06:54:58 EST
From: Wei Fang <wei.fang@xxxxxxx>
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 <linux/fsl/netc_global.h> 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