🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20725

Re: [PATCH v8 net-next 9/9] net: dsa: netc: add PTP one-step timestamping support

#20725
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 05:05
103 lines
11750 bytes
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
Technical Details
Message-ID: <179541034095.3135.13496206683389250613@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369043-linux-kernel-netdev=dewy.ru
References: <20261119030534.1892935-10-wei.fang@oss.nxp.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369043-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
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
Organization: Usenet Network
Message-ID: <179541034095.3135.13496206683389250613@kernel.org>
References: <20261119030534.1892935-10-wei.fang@oss.nxp.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3794983"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:w9qmg46QZRNVFkGkbv56rR9tnIc= sha256:dojRwUHQ01e02520J6RJ6Yukm+XaABKkDm7YJbMvjas=
	sha1:NvZc1OjYRSBIFb2FCpiF9ZzyVGs= sha256:R4WVHCGS7YH+8AvOY8Gjr9eDbTS7VnuEEi9duLdcHXw=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 6A70C125D89; Mon, 23 Nov 2026 08:06:19 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 8liCwNO_Xuop;
	Mon, 23 Nov 2026 08:06:15 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-369043-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 982D1125D8D; Mon, 23 Nov 2026 08:06:07 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 544972D4C6; Mon, 23 Nov 2026 05:05:52 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795410348;
	b=N0ctLKNtrDcnBdIxnw0A/mzZeCw+wV4DFcQp+okfqWGCi0gZ4dgxqcm7DH2FOO0TSBe1
	 ZHsS55jYXwcmxsGkjcNkn4s8YD8S/XG79l4E41WLEOnhol78602IThqjRDTn1piZ26c8l
	 55PXGQoks6qfzdeKT/Jg+H79onrFZ6+KWpozfJ+eKw3Rd4sgg3WrLuGq/G7z5/ch6K8Lh
	 Ecw/MAm+82uqtsbsDTEH2PxVWg9y0kofK1yfZO4O/WFUxUeHt4QhmdCDEsTsGqa2ErB2y
	 QAcdtQkJNZsoUsGEFg/HYn5sE1Ug2YsYij0pmSxU6eSjsEM+POe49X/vpKl7cMD5d5Q==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795410348;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=YZFYyshGMkQG/jKK+b6CCs4DmdN8U4z1ESvjudH9KZ4=;
	b=pFSOc2wAk9Er3hSuG5CV4CDb1g039QERKQiK+XINNVN1U0LmMPUN/QT2USzvcDxl1eX6
	 O584IzuUxNoI2qMywhgkyk4GH9zOke+tL8jR67vr7OH3xLYV9Y2T7X7SpbEyv2Sw8ix37
	 hWJz6ftVkoBIPI2pmdDf0l8LX1T43KkXoCuQSxs7cLtw9MPccq158Qdfe890XYlvYGHOv
	 /7aYfhULkY9nSe9JGLlfkpBTsV1lLuHbTx5ETyLdyjwk30+cWd7DuEfNLcGh6MhZ//cVc
	 kpnHDNkB926WAMCnfeXb9BXY0VowonUizznx+9WMcK+sOg06hjieoAjD/1nvQjH4e1A==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Fh3M8yiE;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id A27C3606A32D;
	Mon, 23 Nov 2026 05:05:48 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Fh3M8yiE
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795410342;
	b=bs6vh+gesfiZ4o07SraiOPYY1e01vyLqZ2qrhuXnJyy82b97QjyTgXpCg5DOWGuxB/E3
	 EHv1cDtHgackRq0UAWXD7gkYobAZS6e1LnF6Ri07sWSsqvDyZITnioiZ3xtlj586i/Mfm
	 jMEeW2iY0PpdbObUeY+SmVRb+fBqCHpNxgbr4zLBvOVI0rAQfCWvFfC30TKMxzz1gltRp
	 aGYIwzc9X2exHZugL2y4xEvhpn5tSE6kDbMQy7z0clDEEpGA8jPW+8PvbRvZW3cAGN4XW
	 Jxzy4gBiwfKbE4/tiXAyy7aRuJHTevJM54PTgDYs40WAEErbFN0weAT8JbtjlH2lECg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795410342;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=YZFYyshGMkQG/jKK+b6CCs4DmdN8U4z1ESvjudH9KZ4=;
	b=pT+SFamdi2fvJ7c84zZ+LVBWw17bbjAbCmmpXzCsWaFIt/CVeD0RGx8oe/Tv7Lz5RVx8
	 9u0Ou801Bvqh7Y61PXfW0TZTMSp3QKfJsEwlv6nqI6Pd3BtkwTEDeOaExflW127lC6N4z
	 EZrK/Z+mHTdiKGeD/hEm5XBzMQLH4f9KP7KEbEw4zaSeIN0+1sLtf/16jQPysWyNFXlzw
	 Xq6cB0kp+uoxvUi66knzm6qLuwQeJqZXYr3UZlXTCs0ysh9nWpmpbaH4n/4kSk5whwX/x
	 Ca5NKF36/mFxCYG1oYj0+LslSi70D+sK3gXCLcu/1+zogk8EMhPt2gxZ0Sf9kXos2vA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Fh3M8yiE;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3635606A688;
	Mon, 23 Nov 2026 05:05:42 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D12E1F00A03;
	Mon, 23 Nov 2026 05:05:41 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795410342;
	bh=YZFYyshGMkQG/jKK+b6CCs4DmdN8U4z1ESvjudH9KZ4=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=Fh3M8yiEUbu9z0IwRi2xmRsqpUznbp1mRezfJBcz4jVfCe80CWAs8XV4uXDRG/4v2
	 jsOXnxzOVaJHU1KbXwxyK2oBw2eZQR6aOQvulzOaylDZWcfuFTlpgqwQxotxI96HLb
	 YDrvTMouu4OYlMKYbMe7HC00jgX4mbKovooisV9t+oYVc7tHSsUa5i9o8ytCS2r+QQ
	 k+UFFfhUOLf3AOtJFXnzrV1+87e79S789G7LYselCvKdLAIlHJFm1vCvyKZbP3QjOj
	 44XpssWusv0JYzwDSg6nYihuoV91z5ZQ2xWvSPKuGS9fwzMmSbLVckcUvNSXkvdNn3
	 1NPFDor1jfbYA==
X-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
X-In-Reply-To: <20261119030534.1892935-10-wei.fang@oss.nxp.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list