From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: wei.fang@oss.nxp.com, 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: Re: [PATCH net-next 6/7] net: dsa: netc: add PTP two-step timestamping support
Date: Wed, 29 Jul 2026 14:41:36 +0100 [thread overview]
Message-ID: <59ecaa4e-f111-4dd4-914a-7704990ac58e@linux.dev> (raw)
In-Reply-To: <20260728104548.3301214-7-wei.fang@oss.nxp.com>
On 28/07/2026 11:45, wei.fang@oss.nxp.com wrote:
> From: Wei Fang <wei.fang@nxp.com>
>
> Add two-step TX timestamping and RX timestamping for the NETC switch.
> One-step TX timestamping is not supported yet.
>
> For RX, install ingress port filter table (IPFT) rules that redirect PTP
> frames to the CPU port. Support L2, L4 over IPv4 and L4 over IPv6, for
> both event and general messages, selected via the hwtstamp rx_filter.
> The hardware prepends a To_Host subtype 1 tag carrying the 64-bit ingress
> timestamp. The tagger extracts it into the skb control buffer, and
> netc_port_rxtstamp() copies it into skb_hwtstamps().
>
> For two-step TX, clone the skb and allocate a 4-bit timestamp request ID,
> then queue the clone on a per-port list. netc_xmit() emits a To_Port
> subtype 2 tag carrying that ID. The hardware echoes the ID back in a
> generated To_Host subtype 2 response frame together with the 64-bit
> transmit timestamp. The tagger dispatches the ID and timestamp to the
> switch driver through the twostep_tstamp_handler callback registered in
> netc_tagger_data, which matches the queued clone and completes it via
> skb_complete_tx_timestamp(), then frees the response skb. Non-PTP frames
> keep using the To_Port subtype 0 tag on the xmit fast path.
>
> The two-step response frame carries no payload; its total length is only
> 26 bytes (12 bytes of DMAC and SMAC plus a 14-byte switch tag). By the
> time netc_rcv() sees it, skb->data already points 2 bytes into the switch
> tag, past the TPID shared with the Ethernet header, so skb->len is only
> 12. Since the tag pointer is at (skb->data - 2), the pskb_may_pull() check
> must use NETC_TAG_MAX_LEN - 2 rather than NETC_TAG_MAX_LEN. Otherwise
> pskb_may_pull() drops the response frame and breaks PTP synchronization.
>
> Add the To_Port subtype 2 and To_Host subtype 1/2 tag structures, extend
> netc_xmit() to select the tag based on ptp_flag in the skb control buffer,
> and add netc_connect()/netc_disconnect() to manage the per-switch
> netc_tagger_data allocation. Grab the PTP timer's pci_dev in netc_setup()
> so get_ts_info() can report its PHC index, and release it in the teardown
> and error paths.
>
> Signed-off-by: Wei Fang <wei.fang@nxp.com>
> ---
> drivers/net/dsa/netc/Kconfig | 1 +
> drivers/net/dsa/netc/Makefile | 3 +-
> drivers/net/dsa/netc/netc_main.c | 72 +++++
> drivers/net/dsa/netc/netc_platform.c | 1 +
> drivers/net/dsa/netc/netc_ptp.c | 411 +++++++++++++++++++++++++++
> drivers/net/dsa/netc/netc_switch.h | 35 +++
> include/linux/dsa/tag_netc.h | 23 ++
> net/dsa/tag_netc.c | 120 +++++++-
> 8 files changed, 658 insertions(+), 8 deletions(-)
> create mode 100644 drivers/net/dsa/netc/netc_ptp.c
[...]
> +int netc_get_ts_info(struct dsa_switch *ds, int port,
> + struct kernel_ethtool_ts_info *info)
> +{
> + struct netc_switch *priv = ds->priv;
> +
> + info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
> + SOF_TIMESTAMPING_RX_SOFTWARE |
> + SOF_TIMESTAMPING_SOFTWARE;
SOF_TIMESTAMPING_RX_SOFTWARE and SOF_TIMESTAMPING_SOFTWARE are available
by default, no need to add them.
the code doesn't have skb_tx_timestamp() calls, I wonder how is
SOF_TIMESTAMPING_TX_SOFTWARE implemented?
> +
> + info->phc_index = netc_get_phc_index(priv);
> + if (info->phc_index < 0)
> + return 0;
> +
> + info->so_timestamping |= SOF_TIMESTAMPING_TX_HARDWARE |
> + SOF_TIMESTAMPING_RX_HARDWARE |
> + SOF_TIMESTAMPING_RAW_HARDWARE;
> +
> + info->tx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ON);
> +
> + info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) |
> + BIT(HWTSTAMP_FILTER_PTP_V2_EVENT) |
> + BIT(HWTSTAMP_FILTER_PTP_V2_L2_EVENT) |
> + BIT(HWTSTAMP_FILTER_PTP_V2_L4_EVENT);
> +
> + return 0;
> +}
next prev parent reply other threads:[~2026-07-29 13:41 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 10:45 [PATCH net-next 0/7] net: dsa: netc: add PTP support for NETC switch wei.fang
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-29 10:43 ` sashiko-bot
2026-07-28 10:45 ` [PATCH net-next 2/7] ptp: netc: remove unnecessary pcie_flr() call in probe wei.fang
2026-07-29 10:43 ` sashiko-bot
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-29 10:43 ` sashiko-bot
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-29 10:43 ` sashiko-bot
2026-07-29 13:41 ` Vadim Fedorenko [this message]
2026-07-28 10:45 ` [PATCH net-next 7/7] net: dsa: netc: add PTP one-step " wei.fang
2026-07-29 10:43 ` sashiko-bot
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=59ecaa4e-f111-4dd4-914a-7704990ac58e@linux.dev \
--to=vadim.fedorenko@linux.dev \
--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=wei.fang@oss.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.