Received: by 2002:a05:7208:1509:b0:82:bbfa:f723 with SMTP id o9csp226897rbf; Wed, 24 Apr 2024 00:16:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXJiAtjkWU5EVwgO6dCBc/c6RmdJ7XiuNDAhUOaY7GBS5bt3yyNBSviN36zz3jFNLZwpF5ynAXLmUnXg8QcEAKDIWA8Cr9r26L77F/eLw== X-Google-Smtp-Source: AGHT+IFmhJIHrxDKlxBDsQEjCD2DJe1LWWnl2wbYqviHhd5H348jMUXmasfpzNjL6q7a0dT1nLnP X-Received: by 2002:a05:6a21:6d9c:b0:1a7:3d2a:7383 with SMTP id wl28-20020a056a216d9c00b001a73d2a7383mr2243576pzb.18.1713943014331; Wed, 24 Apr 2024 00:16:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713943014; cv=pass; d=google.com; s=arc-20160816; b=CJWGDC0DlAAcf14iaT/3c8eAKJ7iVlb0VdWtIaZrvW8M+786o9nF4IMfZ+1XW3YWsX dr8bGa2Ao6jeg1zOWpk1h9IBRSdXN/eD7rT/IaTbMKqvXvubqAOdC4sX14dhFVzQEJj/ eiPUzsUn5+wECXj1Emsx8ritTloXozH8ew7PLwmRbKHbLQTE2V/zU8cUz8P1q84RCi6b jvNZ4DEMds0IWk4i5i5xnYZBqnsyeNyteMBspV337RDfQmRx5ciTF/4ytnuI7b/mtfDd 2l0+cXA9tA34GVNMwi+AU25L9WU6cuLDD0M4EZzkvDdc2t2xo6t9he8viuNM4irwYOyc JO1w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:subject:cc:to:from:dkim-signature; bh=0W2mD8fr9mkHJZVb38GrfhFcqGHaTgNh0tcswSRAXA8=; fh=xMBbVcdLmzXcusPSphUKfUTNGunqKE4cJy1K4AFMi00=; b=x7NvHWooIVEIsnXy23QH8vcFuXpwsn6QdcDBGlLe+y9Aj6q1X9gqwHqT08htc5Yz00 YS8PQj6FnUXo+MIZ+6wBivtJPtRwcwYFV4xYHcvCXbVgn/9MEq1WKRcHM1aMHDFGy0m+ fy1x1XRrTJVGr3Oi8ABVZQnaKrlapsUGGVKiL/2zmPpCJoIcHEv26ZzwgDFLYu7H1eal fbCVgg2vuzlZykvNHXywSlNCfxEZidydiDLNJcLSKGDD9YP34XyNgoB6TdKtIJBEvL3f BPlzkKfl7DdHB68NAwpXOflxxdGFFYL+5sKpjECDXZcfBSYzUNB1Jby94YHVh2jGD4Gu 47kA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=PY9Mw9ZZ; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-156452-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156452-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t190-20020a6381c7000000b0060477fd110asi1693649pgd.790.2024.04.24.00.16.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 00:16:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-156452-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=PY9Mw9ZZ; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-156452-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156452-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id F05A9281721 for ; Wed, 24 Apr 2024 07:16:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F3346157E6E; Wed, 24 Apr 2024 07:16:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="PY9Mw9ZZ" Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D59D360; Wed, 24 Apr 2024 07:16:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713943005; cv=none; b=mnHulsOCR6t/OiEnfwTXU/W8oklH1hbcmXQ4FN9sp1VBf+WaffTdYROPjTKcnbqzljjkPVMD3uFmEiVg9JlJ5wablx6Au+EA3f1AI902U5UFmJSU6RokuvAeLhIrkl2xdWmC/LQ2wVDjZ6TjOWkztQ+X+FMus10yvDFD1SP7ZRg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713943005; c=relaxed/simple; bh=E1fwd1W0aXVPo9e17+huq/xHPYPSatpsHlCko4mo2wM=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=BKxBtdPO/M2louBcvKP8xgLpNqJVHSJ1hYcRLEO9oi74NWWeSBcngXA6tFkGd6l1e8QQ1a1Evl2cAlQ7vyHPzEyvtk4GNZquj+A0aYyJt6wUFpA9jnTSJrSp23VcFfaFggm+yLpiijkjS7v10ZFDFvjTIHXUiVaAVXLSmEfRvtc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=PY9Mw9ZZ; arc=none smtp.client-ip=198.47.19.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 43O7GVdB061921; Wed, 24 Apr 2024 02:16:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1713942991; bh=0W2mD8fr9mkHJZVb38GrfhFcqGHaTgNh0tcswSRAXA8=; h=From:To:CC:Subject:Date; b=PY9Mw9ZZFu/IcIQv5tAVJOkJ83LP0jZFGuaqajzWdyaWanZ3TFMB23nu+sAhguFsz d8d04JJtQdiBPiCQfMq4Y6YOqG6glORbUsqJ0tSNWm85oVob7kYXQBZ7Yl/3eBN0CW gTLlh1NvrYcPlfPlcYuDIiVaUS/deoPLtWzhQJxY= Received: from DLEE102.ent.ti.com (dlee102.ent.ti.com [157.170.170.32]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 43O7GV03026334 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 24 Apr 2024 02:16:31 -0500 Received: from DLEE100.ent.ti.com (157.170.170.30) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 24 Apr 2024 02:16:31 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Wed, 24 Apr 2024 02:16:30 -0500 Received: from uda0500640.dal.design.ti.com (uda0500640.dhcp.ti.com [172.24.227.88]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 43O7GQTH085742; Wed, 24 Apr 2024 02:16:27 -0500 From: Ravi Gunasekaran To: , , CC: , , , , , , , , , Subject: [PATCH net v2] net: ethernet: ti: am65-cpts: Fix PTPv1 message type on TX packets Date: Wed, 24 Apr 2024 12:46:26 +0530 Message-ID: <20240424071626.32558-1-r-gunasekaran@ti.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 From: Jason Reeder The CPTS, by design, captures the messageType (Sync, Delay_Req, etc.) field from the second nibble of the PTP header which is defined in the PTPv2 (1588-2008) specification. In the PTPv1 (1588-2002) specification the first two bytes of the PTP header are defined as the versionType which is always 0x0001. This means that any PTPv1 packets that are tagged for TX timestamping by the CPTS will have their messageType set to 0x0 which corresponds to a Sync message type. This causes issues when a PTPv1 stack is expecting a Delay_Req (messageType: 0x1) timestamp that never appears. Fix this by checking if the ptp_class of the timestamped TX packet is PTP_CLASS_V1 and then matching the PTP sequence ID to the stored sequence ID in the skb->cb data structure. If the sequence IDs match and the packet is of type PTPv1 then there is a chance that the messageType has been incorrectly stored by the CPTS so overwrite the messageType stored by the CPTS with the messageType from the skb->cb data structure. This allows the PTPv1 stack to receive TX timestamps for Delay_Req packets which are necessary to lock onto a PTP Leader. Fixes: f6bd59526ca5 ("net: ethernet: ti: introduce am654 common platform time sync driver") Signed-off-by: Jason Reeder Signed-off-by: Ravi Gunasekaran --- Changes since v1: ----------------- * Added Fixes tag as per Paolo's suggestion * Rebased to latest tip v1: https://lore.kernel.org/all/20240419080547.10682-1-r-gunasekaran@ti.com/ drivers/net/ethernet/ti/am65-cpts.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/ethernet/ti/am65-cpts.c b/drivers/net/ethernet/ti/am65-cpts.c index c66618d91c28..f89716b1cfb6 100644 --- a/drivers/net/ethernet/ti/am65-cpts.c +++ b/drivers/net/ethernet/ti/am65-cpts.c @@ -784,6 +784,11 @@ 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; + if (mtype_seqid == skb_cb->skb_mtype_seqid) { u64 ns = event->timestamp; base-commit: a59668a9397e7245b26e9be85d23f242ff757ae8 -- 2.17.1