From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 896A1C4727F for ; Tue, 29 Sep 2020 11:47:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 445E4206E5 for ; Tue, 29 Sep 2020 11:47:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601380061; bh=g1EGPMclhwrL0wZzyYiI09ZgygyYALcabYEOu0at/SU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Othq57xJA0nHmOaf+3groiq5ZoZXNhAq0YLz3XRbjSQrI3XR+oHKIqa0N92GrSJtU hHIKVXoBpbdkgM1/rm3y/caCHfHde8zqmTmUQIXHRljdBWKRiP6fl9IbsAMXk4BJCY dIG15Y9Y1InCie1afQsw/1/WFXNEt6pzhzV4fY08= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730821AbgI2Lrj (ORCPT ); Tue, 29 Sep 2020 07:47:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:48852 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730442AbgI2LrX (ORCPT ); Tue, 29 Sep 2020 07:47:23 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F1E6B2083B; Tue, 29 Sep 2020 11:47:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601380042; bh=g1EGPMclhwrL0wZzyYiI09ZgygyYALcabYEOu0at/SU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hhq87MNTfqfehtFebB5IgpEAw4cS0fLjXRcTjHZGXaunpsfDbzWC+XjtZqNXBCNcJ /jiDiPzAsXZsxzDP4p7sM/kj5hCRgG0DWFqcsBaWPfanPv6x6ZFwY6wmTbicRjn4cC u4Y3o9wsuvBEECUhM59OCKdLz24G5g/c71vM0rAU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vinicius Costa Gomes , Aaron Brown , Tony Nguyen , Sasha Levin Subject: [PATCH 5.8 41/99] igc: Fix not considering the TX delay for timestamps Date: Tue, 29 Sep 2020 13:01:24 +0200 Message-Id: <20200929105931.747257855@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929105929.719230296@linuxfoundation.org> References: <20200929105929.719230296@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vinicius Costa Gomes [ Upstream commit 4406e977a4a1e997818b6d77c3218ef8d15b2abf ] When timestamping a packet there's a delay between the start of the packet and the point where the hardware actually captures the timestamp. This difference needs to be considered if we want accurate timestamps. This was done on the RX side, but not on the TX side. Fixes: 2c344ae24501 ("igc: Add support for TX timestamping") Signed-off-by: Vinicius Costa Gomes Tested-by: Aaron Brown Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/igc/igc_ptp.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/net/ethernet/intel/igc/igc_ptp.c b/drivers/net/ethernet/intel/igc/igc_ptp.c index 61e38853aa47d..9f191a7f3c71a 100644 --- a/drivers/net/ethernet/intel/igc/igc_ptp.c +++ b/drivers/net/ethernet/intel/igc/igc_ptp.c @@ -471,12 +471,31 @@ static void igc_ptp_tx_hwtstamp(struct igc_adapter *adapter) struct sk_buff *skb = adapter->ptp_tx_skb; struct skb_shared_hwtstamps shhwtstamps; struct igc_hw *hw = &adapter->hw; + int adjust = 0; u64 regval; regval = rd32(IGC_TXSTMPL); regval |= (u64)rd32(IGC_TXSTMPH) << 32; igc_ptp_systim_to_hwtstamp(adapter, &shhwtstamps, regval); + switch (adapter->link_speed) { + case SPEED_10: + adjust = IGC_I225_TX_LATENCY_10; + break; + case SPEED_100: + adjust = IGC_I225_TX_LATENCY_100; + break; + case SPEED_1000: + adjust = IGC_I225_TX_LATENCY_1000; + break; + case SPEED_2500: + adjust = IGC_I225_TX_LATENCY_2500; + break; + } + + shhwtstamps.hwtstamp = + ktime_add_ns(shhwtstamps.hwtstamp, adjust); + /* Clear the lock early before calling skb_tstamp_tx so that * applications are not woken up before the lock bit is clear. We use * a copy of the skb pointer to ensure other threads can't change it -- 2.25.1