Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp474309lqt; Fri, 19 Apr 2024 01:06:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXA2ocVt6qnpgCx2SnafrX2fHvIRnDG7s7FyAmMisGNulV7Lzx1tqxFaOXwyeAEU0SVT/tfXY5CVmepHvaBL1szYIJIWb3Yuit5eyR2uA== X-Google-Smtp-Source: AGHT+IH3CzMKOziPZVi3ONcJjUha/rWMj03WpR6ebtasE+HhadoJTnHIlIcUyLVFLY1jJob75Yzm X-Received: by 2002:a05:6a20:12c5:b0:1a7:807:ca2 with SMTP id v5-20020a056a2012c500b001a708070ca2mr1891609pzg.29.1713513983096; Fri, 19 Apr 2024 01:06:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713513983; cv=pass; d=google.com; s=arc-20160816; b=QdBUCQHATICZXZYgMjNam3RvOwFJ0maHhSZDmSJNWFknlTUmlBwbGL58TA3g1WxBPS 2qgFXDXxVDYlCqqaqXP9NzE1hmkum7YSSd5k2aBRY/4Zd3DRmJB8snEi9c7vSgBFKHUG lkMY9qFWrPDhO3rXzLmoYhL7syTgUtz4tEPQcpMKckVtPtv9CVH0EGpzakVuqwcGVi5l tF/qowwC26KbY8fDjqhS36pKFZLOx7ArZm6/HpYC5vJLNro6GfTn6x2r/hdivCAM6QWb Wjq8hX7Ju5YH1V6TSdsuQKCf9n9nZRry3c20MLITmWB5AZnW92CkcIuSw1RRNESIfWgv B3gg== 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=wywIflZZILgds45tSLlMBSxHlOVP+lLAO8bVR1MGrzw=; fh=Mv2i6DKmQqE/it6ylUCO/GEBNMFa8S90hobYma7So44=; b=wo+M79FHkwygt+vsanh/sMpNgNXiyej9Y7w0QH5Q6PuEacBXZuH6Ya5u9qjdnVx6wP d7uACB+RQQkJvbYZaQifHV4d1pTU6HGmkGdOW2NIZZ+H3ii1wd5rfc5xDT6aXswKKC6D fQUTkBha9St4OpjiBU2+QmgHgQi4c8ArOgIDd7WN8Qz/aSLXytzmw36ushMKL9xiH7Op gsj+UUwJZjimtpmmmg5Ht69DHiG1XBO6S6JTSK5uHt7i+c8aYhigrEdlp6+wjVul7fVp /xn92McBHNq2EqNZrJuOYzrPP4W3O190tiMWZ3APL/QGkZzQ4TBNaV8bx71nAm7YTU2T jtFQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=jxHJaZzW; 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-151146-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151146-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b7-20020a056a000a8700b006eccec776c3si3012177pfl.377.2024.04.19.01.06.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 01:06:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-151146-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=jxHJaZzW; 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-151146-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151146-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 A753F282891 for ; Fri, 19 Apr 2024 08:06:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 469FF4D9F7; Fri, 19 Apr 2024 08:06:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="jxHJaZzW" Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) (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 C34C8321D; Fri, 19 Apr 2024 08:06:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.249 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713513972; cv=none; b=lOXJUlBp7EbuuPCHa3F4Er0SjgLoORYQ2XK7+ygCDUURSvob6VN003ElrybOSJNVu1Tm5GN7a71cBiNu1qUyzkL+5DcVirG1tfYvA2b7dB0thbzlLDR5o3MmFwGtnAtjOyuJyEdwel+cMORTkodIfqWGm5WT9OyrqZRa7KSr6r8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713513972; c=relaxed/simple; bh=VRorQ8SHhWit+mZr7S2o3kkAkzG3qTTdyzmayMCRpZw=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=VhZsjvH/T6GJ1ohYBGPc+Tq2gqS9KflI3/cyjB5CZsCA3QW/6vbnPqiXqog9ihwjSr1PvK9ubz50D92dQiB+L6ja+KOzGGmsgngxXgajGzLAAIu+effjdwLftoA0SDsPZiqpamoRBpPPNBAbDXLjeN0LlA1uJsZCk+pnywca81Y= 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=jxHJaZzW; arc=none smtp.client-ip=198.47.23.249 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 fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 43J85q4U061750; Fri, 19 Apr 2024 03:05:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1713513952; bh=wywIflZZILgds45tSLlMBSxHlOVP+lLAO8bVR1MGrzw=; h=From:To:CC:Subject:Date; b=jxHJaZzWqDbn4u4dyNkSDtPScNKU/HiEe56NDPzGB65+OKPOpCQQHYuB4wmUiyY9S 0OXEncyjGJ2GuM/fgTwlWDKwsvQY0IN67Bp5vB4EiYwarVMz6xjZ58JIRaqxY+U8j6 Ta5GkbeEiVIAzmwpda3NFNcmbmOwSp4glILmvk/E= Received: from DFLE106.ent.ti.com (dfle106.ent.ti.com [10.64.6.27]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 43J85qIi107255 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 19 Apr 2024 03:05:52 -0500 Received: from DFLE106.ent.ti.com (10.64.6.27) by DFLE106.ent.ti.com (10.64.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 19 Apr 2024 03:05:51 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE106.ent.ti.com (10.64.6.27) 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; Fri, 19 Apr 2024 03:05:51 -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 43J85lCd123132; Fri, 19 Apr 2024 03:05:48 -0500 From: Ravi Gunasekaran To: , CC: , , , , , , , , , Subject: [PATCH net] net: ethernet: ti: am65-cpts: Fix PTPv1 message type on TX packets Date: Fri, 19 Apr 2024 13:35:47 +0530 Message-ID: <20240419080547.10682-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. Signed-off-by: Jason Reeder Signed-off-by: Ravi Gunasekaran --- 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: a35e92ef04c07bd473404b9b73d489aea19a60a8 -- 2.17.1