The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: wei.fang@oss.nxp.com
Cc: xiaoning.wang@nxp.com, andrew@lunn.ch, olteanv@gmail.com,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
	richardcochran@gmail.com, linusw@kernel.org,
	linux@armlinux.org.uk, wei.fang@nxp.com, 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 v8 net-next 9/9] net: dsa: netc: add PTP one-step timestamping support
Date: Mon, 23 Nov 2026 05:05:40 +0000	[thread overview]
Message-ID: <179541034095.3135.13496206683389250613@kernel.org> (raw)
In-Reply-To: <20261119030534.1892935-10-wei.fang@oss.nxp.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] In HWTSTAMP_TX_ONESTEP_SYNC mode,
  netc_port_prepare_onestep_sync() (drivers/net/dsa/netc/netc_ptp.c)…

--

net: dsa: netc: add PTP one-step timestamping support

This adds one-step Sync offload for NETC switch ports and advertises
HWTSTAMP_TX_ONESTEP_SYNC. The tagger hands each one-step Sync to the switch
driver, which queues it per port and sends the frames one at a time from a
work after programming PM_SINGLE_STEP and the originTimestamp field.

> diff --git a/drivers/net/dsa/netc/netc_ptp.c b/drivers/net/dsa/netc/netc_ptp.c
> index bd4d0b70e7ee5..a7ab62f76e352 100644
> --- a/drivers/net/dsa/netc/netc_ptp.c
> +++ b/drivers/net/dsa/netc/netc_ptp.c

[ ... ]

> @@ -407,6 +713,67 @@ int netc_port_hwtstamp_get(struct dsa_switch *ds, int port,
>  	return 0;
>  }
>  
> +static void netc_port_prepare_onestep_sync(struct netc_port *np,
> +					   struct sk_buff *skb,
> +					   u32 ptp_class, bool *twostep)
> +{

[ ... ]

> +	/* Ensure the buffer is linear and writable so the packet can be
> +	 * parsed and updated in place. Otherwise, fall back to two-step.
> +	 */
> +	if (unlikely(skb_linearize_cow(skb))) {
> +		*twostep = true;
> +		return;
> +	}

[Severity: Medium]
What happens here if the frame is a one-step Sync and skb_linearize_cow()
fails?

skb_linearize_cow() runs before the message type is checked. It can return
-ENOMEM under GFP_ATOMIC pressure for any nonlinear or cloned skb, for
example one cloned by dev_queue_xmit_nit() while a packet tap is attached.
When that happens, the Sync goes down the two-step path:

dsa_user_xmit()
  dsa_skb_tx_timestamp()
    netc_port_txtstamp()
      netc_port_prepare_onestep_sync()
        skb_linearize_cow() fails -> *twostep = true
      netc_port_prepare_twostep()

The frame gets a To_Port subtype 2 tag, or a subtype 0 tag if
skb_clone_sk() also fails. Its twoStepFlag is still 0, but PM_SINGLE_STEP
is never programmed, and originTimestamp and correctionField are never
updated. Would the peer then accept a one-step Sync carrying whatever
originTimestamp software put there?

netc_port_txtstamp_handler() would also later deliver a hardware TX
timestamp for this Sync through skb_complete_tx_timestamp(). Doesn't that
conflict with the HWTSTAMP_TX_ONESTEP_SYNC description in
include/uapi/linux/net_tstamp.h:

    In this case, transmitted Sync packets will not received a time
    stamp via the socket error queue.

The commit message also says:

    If the originTimestamp field of the sync frame is not in the linear
    buffer of the skb or the correction offset exceeds the hardware
    capability, the frame will be dropped.

skb_linearize_cow() runs first, so the later check:

    if (unlikely(tstamp_offset + 10 > skb_headlen(skb) ||
                 correction_offset > NETC_MAX_STEP_OFFSET)) {
            NETC_SKB_CB(skb)->ptp_flag = NETC_PTP_FLAG_DROP;

only catches truncated frames. The "not linear" case falls back to
two-step and is not dropped.

Should a linearize failure on a Sync frame be handled the same way as the
other error paths in this function, with NETC_PTP_FLAG_DROP and a
tx_dropped increment?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119030534.1892935-1-wei.fang%40oss.nxp.com

      reply	other threads:[~2026-11-23  5:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19  3:05 [PATCH v8 net-next 0/9] net: dsa: netc: add PTP support for NETC switch wei.fang
2026-11-19  3:05 ` [PATCH v8 net-next 1/9] ptp: netc: use ioread64_lo_hi/iowrite64_lo_hi for 64-bit register access wei.fang
2026-11-19  3:05 ` [PATCH v8 net-next 2/9] ptp: netc: remove unnecessary pcie_flr() call in probe wei.fang
2026-11-19  3:05 ` [PATCH v8 net-next 3/9] ptp: netc: export netc_timer_get_current_time() for cross-driver use wei.fang
2026-11-19  3:05 ` [PATCH v8 net-next 4/9] net: dsa: netc: tie setup resources and reset to DSA setup/teardown wei.fang
2026-11-23  5:05   ` netdev-bot+sashiko
2026-11-19  3:05 ` [PATCH v8 net-next 5/9] net: dsa: netc: use entry ID instead of pointer to track host flood rule wei.fang
2026-11-19  3:05 ` [PATCH v8 net-next 6/9] net: dsa: netc: check return value of ntmp_ipft_delete_entry() wei.fang
2026-11-23  5:05   ` netdev-bot+sashiko
2026-11-19  3:05 ` [PATCH v8 net-next 7/9] net: dsa: netc: enable ingress port filtering lookup by default wei.fang
2026-11-19  3:05 ` [PATCH v8 net-next 8/9] net: dsa: netc: add PTP two-step timestamping support wei.fang
2026-11-23  5:05   ` netdev-bot+sashiko
2026-11-19  3:05 ` [PATCH v8 net-next 9/9] net: dsa: netc: add PTP one-step " wei.fang
2026-11-23  5:05   ` netdev-bot+sashiko [this message]

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=179541034095.3135.13496206683389250613@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=kuba@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox