Article View: linux.kernel.netdev
Article #10139[PATCH net v2] net: ethernet: ti: am65-cpts: keep port and direction when matching PTPv1 TX timestamps
From: "Jesper L. Nielsen via B4 Relay"
Date: Tue, 03 Nov 2026 08:42
Date: Tue, 03 Nov 2026 08:42
127 lines
16056 bytes
16056 bytes
From: "Jesper L. Nielsen" <jln@pascal-audio.com>
The CPTS reports the message type of a timestamp event using the PTPv2
header layout, i.e. the low nibble of the first header byte. In a PTPv1
header that byte is the upper byte of versionPTP and always 0, so every
PTPv1 event is reported as message type 0, while
am65_skb_get_mtype_seqid() reads the PTPv1 message type from the control
field. To make PTPv1 match at all, commit 1b9e743e923b ("net: ethernet:
ti: am65-cpts: Fix PTPv1 message type on TX packets") overwrites the
whole value compared against the skb with the skb's own value once the
sequence ids are equal. That throws away the event type and the port
number of the event as well, so a PTPv1 skb matches any TX event with
the same sequence id on either port. For PTPv1 this defeats
commit a23c657e332f ("net: ethernet: ti: am65-cpsw: Use also port
number to identify timestamps"). The overwritten value also sticks for
the rest of the TX queue walk.
Since every PTPv1 frame reads as message type 0, the hardware timestamps
all PTPv1 frames to UDP ports 319 and 320, including Follow_Up and
Delay_Resp, for which no skb waits. With a PTPv1 master on both ports
whose sequence ids run in step (e.g. a Dante device with primary and
secondary network started at the same time), the unclaimed TX event of
Follow_Up N on one port is still on the event list when the other port
queues Sync N, and am65_cpts_find_tx_ts() tries to match before it
checks for expiry. Sync N then gets the transmit time of the other
port's Follow_Up N, and the master announces a preciseOriginTimestamp up
to one Sync interval early to every slave on that network.
For PTPv1 replace only the message type of the event with the skb's and
keep its event type, port number and sequence id, and compute the value
per skb.
Tested on AM62x with ti-linux-6.12.y and the port number commit backported:
without this patch every boot in which both ports started PTP together
(10 of 10) sent wrong Sync timestamps, with it none did (0 of 29).
The bug was tracked down, and this fix and changelog drafted, with the
help of an AI coding assistant (Claude). I reviewed and tested it on
hardware as described above.
Fixes: a23c657e332f ("net: ethernet: ti: am65-cpsw: Use also port number to identify timestamps")
Signed-off-by: Jesper L. Nielsen <jln@pascal-audio.com>
Reviewed-by: Siddharth Vadapalli <s-vadapalli@ti.com>
---
Changes in v2:
- Wrap the commit a23c657e332f reference like the one above it (Siddharth)
- Use netdev comment style for the new comment (Siddharth)
- Collect Reviewed-by from Siddharth
- Link to v1: https://patch.msgid.link/20261030-am65-cpts-ptpv1-v1-1-0bb4c370d970@pascal-audio.com
To: Andrew Lunn <andrew+netdev@lunn.ch>
To: "David S. Miller" <davem@davemloft.net>
To: Eric Dumazet <edumazet@kernel.org>
To: Jakub Kicinski <kuba@kernel.org>
To: Paolo Abeni <pabeni@redhat.com>
To: Richard Cochran <richardcochran@gmail.com>
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
drivers/net/ethernet/ti/am65-cpts.c | 31 +++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/ti/am65-cpts.c b/drivers/net/ethernet/ti/am65-cpts.c
index df5659ead7..db5fc0f769 100644
--- a/drivers/net/ethernet/ti/am65-cpts.c
+++ b/drivers/net/ethernet/ti/am65-cpts.c
@@ -788,6 +788,28 @@ static struct ptp_clock_info am65_ptp_info = {
.do_aux_work = am65_cpts_ts_work,
};
+/* The CPTS decodes the message type of an event using the PTPv2 header
+ * layout. For PTPv1 that nibble is part of versionPTP and always reads 0,
+ * while am65_skb_get_mtype_seqid() takes the message type from the PTPv1
+ * control field. For PTPv1 take the message type from the skb, but keep
+ * the event type, port number and sequence id of the event so that an
+ * event only matches a packet of the same direction on the same port.
+ */
+static u32 am65_cpts_event_mtype_seqid(struct am65_cpts_event *event,
+ u32 skb_mtype_seqid,
+ unsigned int ptp_class)
+{
+ u32 mtype_seqid = event->event1;
+
+ if (ptp_class & PTP_CLASS_V1) {
+ mtype_seqid &= ~AM65_CPTS_EVENT_1_MESSAGE_TYPE_MASK;
+ mtype_seqid |= skb_mtype_seqid &
+ AM65_CPTS_EVENT_1_MESSAGE_TYPE_MASK;
+ }
+
+ return mtype_seqid;
+}
+
static bool am65_cpts_match_tx_ts(struct am65_cpts *cpts,
struct am65_cpts_event *event)
{
@@ -797,7 +819,6 @@ static bool am65_cpts_match_tx_ts(struct am65_cpts *cpts,
bool found = false;
u32 mtype_seqid;
- mtype_seqid = event->event1;
__skb_queue_head_init(&txq_list);
spin_lock_irqsave(&cpts->txq.lock, flags);
@@ -810,11 +831,9 @@ static bool am65_cpts_match_tx_ts(struct am65_cpts *cpts,
struct am65_cpts_skb_cb_data *skb_cb =
(struct am65_cpts_skb_cb_data *)skb->cb;
- if ((ptp_classify_raw(skb) & PTP_CLASS_V1) &&
- ((mtype_seqid & AM65_CPTS_EVENT_1_SEQUENCE_ID_MASK) ==
- (skb_cb->skb_mtype_seqid & AM65_CPTS_EVENT_1_SEQUENCE_ID_MASK)))
- mtype_seqid = skb_cb->skb_mtype_seqid;
-
+ mtype_seqid = am65_cpts_event_mtype_seqid(event,
+ skb_cb->skb_mtype_seqid,
+ ptp_classify_raw(skb));
if (mtype_seqid == skb_cb->skb_mtype_seqid) {
u64 ns = event->timestamp;
---
base-commit: 5838f10563d58afca6711edb5e4eda968ca181d9
change-id: 20261030-am65-cpts-ptpv1-45cc3c7276d2
Best regards,
--
Jesper L. Nielsen <jln@pascal-audio.com>
Technical Details
Message-ID:
<20261103-am65-cpts-ptpv1-v2-1-e1f79ed1ba60@pascal-audio.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-355293-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-355293-linux-kernel-netdev=dewy.ru
From: devnull+jln.pascal-audio.com@kernel.org ("Jesper L. Nielsen via B4 Relay")
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v2] net: ethernet: ti: am65-cpts: keep port and
direction when matching PTPv1 TX timestamps
Date: Tue, 03 Nov 2026 09:42:52 +0100
Organization: Usenet Network
Message-ID: <20261103-am65-cpts-ptpv1-v2-1-e1f79ed1ba60@pascal-audio.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
logging-data="3129277"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:vBoYNZZz70wH9zkoLCL7KTh60po= sha256:2WQFqcF43gEvPt5dkjb2iTGgs95wgtwdcb4uwoZEEwU=
sha1:XjeJtvoZSNfinANRr1/SCDccKEQ= sha256:pP/Xovh1Gl76N89RXfBs90oKqs51dKP0zwftLkAQ2fI=
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 035F6112789; Tue, 3 Nov 2026 12:15:40 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 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] 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 4NaIFFBEMI47;
Tue, 3 Nov 2026 12:15:36 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-355293-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
by mail.dewy.ru (Postfix) with ESMTPS id 4A8D111042A; Tue, 3 Nov 2026 12:15:27 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sin.lore.kernel.org (Postfix) with ESMTP id E3E4034CF0; Tue, 3 Nov 2026 08:44:28 +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=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1793695381;
b=YQBz+CEyFCVHymmKozvX3q0MT0saUnZiKzaAVL3j2W0Z5AdCyEVq1p/7BSDrWwrsIIBR
061XhxmqrheCfKw7iPiZNFa1zSezzbVJs0AQZIYS1d4hnaZKGkOA9iE20erZg7ki2JJ/+
ixKdHzwPMgVfHGAZaCE3v08en329dPahQKUGFocJVZTeX7uMQ6D3SFeJnNKj2ytoK4IsV
H+J4U42jU8E2k5Ewq0PcKexwM7THn1PR/LMfJIVMIK/7+X668NjMOmP2BJ7Z3WQJTYFUf
1eVrGFYlg8B8410HW6v+XWr6A7QruFotYnYJlgKJcZSxMkias4Rd/e76kGVvKQQ2ArQ==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793695381;
h=X-Original-To:Received:Received:DKIM-Signature:Received:From:Date:
Subject:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer:
X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
X-Original-From:Reply-To:Content-Transfer-Encoding;
bh=2iRrY/OfyFptn9d9uQx8ftgHSl/eU+8UCllnzn3P1yo=;
b=3rTiPw2KqMOVp/AhPcnxqJb/G9d6bfSy7K5bqIN7a2dMaPRn6S+mtWIw1xN0OXTulW7D
xfXLmtSOyPrxxs84kDt/fARym60IT8qDJ7Sl7HrD2OTWxETUsfo5OB9/WruKgeAtrcE2h
Cb9L8MhlAGjDKoznxvzTpcD5rE1a9PgwlICezWp5TEdnRtgMzoVdWszdmcsgu2Gz06icQ
yGiYODcEdvWwPMBZxxLCDSgwGi/uY8RtEf6nmK8sf92kKsWZpKDSdaWundRu68LXpyj4S
T0ZyejL19JozUzuAmteaZVxAykYALq1yfwhGQrZsfv+V8m3TWMwmoRXKoLRIsLN06ug==
X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org;
dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Euwa6rk3;
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 9D1DE606A963;
Tue, 3 Nov 2026 08:42:56 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Euwa6rk3
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1793695375;
b=lgx3m5Dcv21ALFAGFeR0Q58hQUj8BOHoGTCozClm0TAoOrmlo+dkcXMDHweIqc3Fchke
CJf/u/qBLzTwCrLe11ur3vcNKlQ4gCtrUf10B70OTRNO9mExg9dZSvut/LBIvgkxPAAsC
5NN7gAp5A4SG9IdjujShHe07eERGffpAat/mwph35Jr/r/+0Z+ZdsVdIMuV9t1qjkaVXV
LJD2Z+Oq/cWwBf3WTMo5KyrDNVoD0cH3qqeNljte7DrEfIoG7ruwr0+xZBmZPlC+ViqKA
YYT4IZNcwwwfemJbOQ80QtrWuZ8sa7E8W1Eb/r2kHkl+/PYwvZLQzR54qLKZGIUEUbA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793695375;
h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version:
Content-Type:Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer:
X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
X-Original-From:Reply-To:Content-Transfer-Encoding;
bh=2iRrY/OfyFptn9d9uQx8ftgHSl/eU+8UCllnzn3P1yo=;
b=Sdpj6QSBFZ4qH0/MffrIu3FASPXlxBW/VNT012s4nCFJn5Cu6Nz5SarRuJzIPNOAhaSO
/QMtZaeBdt9rrB6525VGzpJZoSkMHZLBQf0bP2MIOGPadQRPlswa9J70nR+sK6rspuPYf
2IFYxvB7PBKCnxJm0R3e/v+qkmjrTl9fBSvHIMXkTmPg3eixA2FRSTQgONxcixUWUXTDZ
NyxC/Q/G9YtDl1NYGbc7GxntwHYSCCvi+R4TX/HGzjjmlmBdAtT91LtIUZDmlH+sderrq
Vh690FQv86NmCF9T36ROA/45rmf9HL2cA9rGZQC18XjFDazLkX7k2TsMwwc4BBuUXgg==
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=Euwa6rk3;
arc=pass header.oldest-pass=0 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 77DDB606A32F;
Tue, 3 Nov 2026 08:42:55 +0000 (UTC)
X-Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77
X-ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none;
t=1793695375;
b=C0omEPmRHB3ALe8gLyqWd7GIIwzOj9s3d8IOWLaJ0PnWeXZnPCnTsxO8uQC3Yd/2ROq9
rGVLwOyvKQpGvk2vlQZle6fDSqDRkqVwTnhT+Xavfn1nEOGBBjDBoeKelqsISQzwRg7vR
LohOp3Dc8EtHRzLqc0Y1aian1ogy6E+Af+KF1O4Uz5MRHtmL1gnx9jmf0tH55JrxvpSu7
0GJtgBF8UcD0HYNCViyJs7PaABLxjiFJcOFBLwJ3BMSydM5ymTij3hpHRBGF3AlBtrF38
Naoif2mzCmEbNZNL6H+4d1v82A1WTe48MdEikIXJAAgesdanIMu3i1jL8+Ok/acYQ+Q==
X-ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256;
c=relaxed/relaxed; t=1793695375;
h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type:
Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer:
X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
X-Original-From:Reply-To:Content-Transfer-Encoding;
bh=2iRrY/OfyFptn9d9uQx8ftgHSl/eU+8UCllnzn3P1yo=;
b=s1IbI/ElR97YcLMLnPTg6L/ZjunooMBhprWTz17KMcBFVtOrZx7dVAYMgH8vNdGFro+Q
Q7X8hkj2CjkGGfHC3Xjzd+FCxirEpeB6vSKqPYH1llZYIXJ97+Mh20+WRvdPA4dfODTZy
KM2qOxLwmgusMeChSE1+G5GUYu99md9lsMI3nY0ggrqk33sxyZYsYzH3OD4okAMsbALE+
3pBGLlze0nzEMbHBrBnxTv08t/ZUpmIgrzEEKxDvXbtkSocx8VUc/kGUf5A29H6NnqJnl
zActeuiwDq8RXWPVSBgQGKdBguGc09mPtcYrpOklnr3PwAWat6d4vsyZMlblyErhGmA==
X-ARC-Authentication-Results: i=1; smtp.kernel.org;
arc=none smtp.remote-ip=100.80.115.77
X-Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.kernel.org (Postfix) with ESMTPS id 5A5CD1F000C1;
Tue, 3 Nov 2026 08:42:54 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
s=k20260515; t=1793695375;
bh=2iRrY/OfyFptn9d9uQx8ftgHSl/eU+8UCllnzn3P1yo=;
h=From:Date:Subject:To:Cc:Reply-To;
b=Euwa6rk3+OtwB1lMpX4r2BtYuyED6rGXuLT7doXqCkUfRDXaYX3cwPL1kvCeAJ8xp
osh8fnaa3iYLIC3XUv9ixxiHRzQUczRA2wxruyF4LbPhOBNx+RXxJ1sso6sPCsJI0e
Jir/0R9gfHeNT/YaYe1c+dFCYWCODERqCdhNeORlMG0xICnic0Ay6VROXY7n5kjIwW
9Bi6x1pd7Bbmgsaha/QcOj0+2axPl/ddMgUCTCH8l8jzjHzYGQTmq5VCgr6cAoi119
N4wDD9CuZDjxOiLnAU+g3O1YuAKXr0T2sA5RzkeN3hWEgiuXp6olnCokZ6BMxsi+GG
VlaVxwP4M9J8g==
X-Received: from nexus.subspace.kernel.org (localhost [IPv6:::1])
by lkml.kernel.org (Postfix) with ESMTP id D9D0346839;
Tue, 3 Nov 2026 08:42:53 +0000 (UTC)
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
X-B4-Tracking: v=1; b=H4sIAAAAAAAA/3WNzQrDIBCEXyXsuVvU/Eh76nuUHMxqm4UmitrQE
nz3Su6FuXwzzMwOyUV2Ca7NDtFtnNivFdSpAZrN+nTItjIooQYpWoFmGXqkkBOGHDaJXU/UklZ
6sApqK0T34M+xeIfVZRirOXPKPn6Pl00e0d/BKolimjpqtbAXLW7BJDIvNG/L/kx+gbGU8gPvi
O50ugAAAA==
X-Change-ID: 20261030-am65-cpts-ptpv1-45cc3c7276d2
X-Cc: Siddharth Vadapalli <s-vadapalli@ti.com>,
Roger Quadros <rogerq@kernel.org>, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, "Jesper L. Nielsen" <jln@pascal-audio.com>
X-Mailer: b4 0.16.0
X-Developer-Signature: v=1; a=ed25519-sha256; t=1793695373; l=5455;
i=jln@pascal-audio.com; s=20261030; h=from:subject:message-id;
bh=KkkM70wITXUFTStvvy/VCOMH1m9ua1ZSVUId0tiFcgA=;
b=gTigozlOmH+7swK3ZG+4vys4SMXHBYkkLZDq3Lv1RVn9F8b25ddFguGPFlE8QHiylt3+ipO7v
yTkvGb+DkueCYzbgI5QyLs60EUiMq8HYz83YsSqtvLP4JmKrORaYBAx
X-Developer-Key: i=jln@pascal-audio.com; a=ed25519;
pk=HN4GIuN0bzT/+cWaO2W1D3+3WUOlizjI/JLKLramukQ=
X-Endpoint-Received: by B4 Relay for jln@pascal-audio.com/20261030 with
auth_id=1362
X-Original-From: "Jesper L. Nielsen" <jln@pascal-audio.com>
X-Reply-To: jln@pascal-audio.com