From patchwork Mon Sep 16 05:18:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aakash Menon X-Patchwork-Id: 13805026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 45FE8C3ABCB for ; Mon, 16 Sep 2024 05:20:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SLz0lNADH7cCWzKMs3iTI8r4aFamVAr3tXQHItr+s68=; b=IaTj5ReSIriV2T1Lr0lpW/jb9l xITdS/moZnyLLN0rJMJSzhyPEOTLkEXd5AZ6sTYGvFXAULtp9On4QezNmvoBVsTaXmz8xgebBc7H2 /kCZfy38gGkdbZ9N6ngGPEwY3i7ydIBUZuajbPJss6JfXMSLU8O+GI/VGce/l5bj+2GxG7mX1gXmx 22KDqdvxDb3xdn8ubCmN2WHhloKfkdIrNCjQMtyVljJbWoe0EfISMvOojLompzvX6Ntj6gWwUEp2p oBcS98GaKknORHnx7B9UFouHjXZWaN9feqpVvYj1Rvu84XJcqQvAnGWMdyuljuVP4VVk47YInmnqI SfzT088Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sq4A0-000000037E5-20wq; Mon, 16 Sep 2024 05:20:28 +0000 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sq48v-0000000378H-3cgJ for linux-arm-kernel@lists.infradead.org; Mon, 16 Sep 2024 05:19:23 +0000 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-718e285544fso2221871b3a.1 for ; Sun, 15 Sep 2024 22:19:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726463960; x=1727068760; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SLz0lNADH7cCWzKMs3iTI8r4aFamVAr3tXQHItr+s68=; b=Ia56nHPya/hXz99YGQ66nQEYd6Y4r+r8WdqqUuUV9qVJFIAnZb918d4E9F4uP51juU 3tEJLpbPeRrLnUl6yf66cP98iPRHslLF2L8j5eF5OFRGnGchjTH7XEtyvCrNuUxyTbGR q92bJpk4K/NT/QElO6d8g6SPpO7CrmG0/SxszkrilVb/l/dE7l60MglctdS+aNhScVpl 16OGZ1I4DZTAilziFfUXl+zJgM57l7US5poX4BnOPGLgUqGDoNeTvYM5lUr7yqJWf2Ce Q9qrstlXJLBrfCSm1NWWSW9J3WrHrtlOIQZJY7y1kp2k0fr7ApO2OX5RQR0n0RB8sUKK cdCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726463960; x=1727068760; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SLz0lNADH7cCWzKMs3iTI8r4aFamVAr3tXQHItr+s68=; b=esIavlQ/CyOxQl5/TnYHvwtaN0IO8jnG4VkHUzsO4TBSGYG9pLgKN+PeMUh33Z/0uS yjh8n5pOV7UGJf7INd/wyOHZ9Cw5p0EOmL+NcMNInxDjD+wraRY1aAlIsxhRQ0G9gyQy bN8lF9RgYaaWefOx8BnrWk+OkCG+l++yYtqXWUrlTzUcN2S53tG3QylVgUR8O3mSYM04 yOZbZOLEdX1wO419F/bWqea0TFEqqPKaezwJn30tdSS9JJ4tKRCB5Rxg6qo+vOmnuN+Q H7cCzww/fzIXPz2a3JdMOxULAQnTzL1+KpiEieR3P5nKVdGFgjl+iHpqA8sW/baCaUy0 G+QQ== X-Forwarded-Encrypted: i=1; AJvYcCWfiFgprxIVrNoHtVLT1XY36/+/dLOGoEsG9kezR9edElNPTVDtf9f3qJDvQZmzl67No6/sdOW7j2BfVrb2IZwu@lists.infradead.org X-Gm-Message-State: AOJu0Yw8EteHjuNEGGWjQkwXjisSG5t9/FErOTKZEG+zLQA6Xm1ljuIq UT988kcineM72xLJtzlapZmlGyUi2mGCMcuwFj5q7Qo09H9Nf//X X-Google-Smtp-Source: AGHT+IECprL/e1lSJ081ju9W67Hla644iD+YJKVrm05Da9fVhYEVbjpVllpzzu7Iux0WiNmYxOBd4A== X-Received: by 2002:a05:6a00:23c3:b0:70d:3337:7820 with SMTP id d2e1a72fcca58-71936a4d269mr15666243b3a.8.1726463960194; Sun, 15 Sep 2024 22:19:20 -0700 (PDT) Received: from amenon-us-dl.hsd1.ca.comcast.net ([2601:646:a002:44b0:1457:4fcc:532f:1c65]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71944abb7a0sm3028087b3a.73.2024.09.15.22.19.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Sep 2024 22:19:19 -0700 (PDT) From: Aakash Menon X-Google-Original-From: Aakash Menon To: daniel.machon@microchip.com Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, lars.povlsen@microchip.com, Steen.Hegelund@microchip.com, UNGLinuxDriver@microchip.com, aakash.menon@protempis.com, horms@kernel.org, horatiu.vultur@microchip.com, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net] net: sparx5: Fix invalid timestamps Date: Sun, 15 Sep 2024 22:18:04 -0700 Message-ID: <20240916051804.27213-1-aakash.menon@protempis.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240914190343.rq3fhgadxeuvc5qb@DEN-DL-M70577> References: <20240914190343.rq3fhgadxeuvc5qb@DEN-DL-M70577> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240915_221921_922218_DA8C7253 X-CRM114-Status: GOOD ( 12.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Bit 270-271 are occasionally unexpectedly set by the hardware. This issue was observed with 10G SFPs causing huge time errors (> 30ms) in PTP. Only 30 bits are needed for the nanosecond part of the timestamp, clear 2 most significant bits before extracting timestamp from the internal frame header. Fixes: 70dfe25cd866 ("net: sparx5: Update extraction/injection for timestamping") Signed-off-by: Aakash Menon --- drivers/net/ethernet/microchip/sparx5/sparx5_packet.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c b/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c index f3f5fb420468..a05263488851 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c @@ -45,8 +45,12 @@ void sparx5_ifh_parse(u32 *ifh, struct frame_info *info) fwd = (fwd >> 5); info->src_port = FIELD_GET(GENMASK(7, 1), fwd); + /* + * Bit 270-271 are occasionally unexpectedly set by the hardware, + * clear bits before extracting timestamp + */ info->timestamp = - ((u64)xtr_hdr[2] << 24) | + ((u64)(xtr_hdr[2] & 0x3F) << 24) | ((u64)xtr_hdr[3] << 16) | ((u64)xtr_hdr[4] << 8) | ((u64)xtr_hdr[5] << 0);