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 [thread overview]
Message-ID: <20260728104548.3301214-1-wei.fang@oss.nxp.com> (raw)
From: Wei Fang <wei.fang@nxp.com>
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
next reply other threads:[~2026-07-28 10:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 10:45 wei.fang [this message]
2026-07-28 10:45 ` [PATCH net-next 1/7] ptp: netc: use ioread64_lo_hi/iowrite64_lo_hi for 64-bit register access wei.fang
2026-07-28 10:45 ` [PATCH net-next 2/7] ptp: netc: remove unnecessary pcie_flr() call in probe wei.fang
2026-07-28 10:45 ` [PATCH net-next 3/7] ptp: netc: export netc_timer_get_current_time() for cross-driver use wei.fang
2026-07-28 10:45 ` [PATCH net-next 4/7] net: dsa: netc: use entry ID instead of pointer to track host flood rule wei.fang
2026-07-28 10:45 ` [PATCH net-next 5/7] net: dsa: netc: enable ingress port filtering lookup by default wei.fang
2026-07-28 10:45 ` [PATCH net-next 6/7] net: dsa: netc: add PTP two-step timestamping support wei.fang
2026-07-28 10:45 ` [PATCH net-next 7/7] net: dsa: netc: add PTP one-step " wei.fang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260728104548.3301214-1-wei.fang@oss.nxp.com \
--to=wei.fang@oss.nxp.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=chleroy@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=imx@lists.linux.dev \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=vladimir.oltean@nxp.com \
--cc=wei.fang@nxp.com \
--cc=xiaoning.wang@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox