Article View: linux.kernel.netdev
Article #24878[PATCH net v2 3/3] ice: fix computation of ETF timestamps for E830
From: Tony Nguyen
Date: Tue, 01 Dec 2026 00:52
Date: Tue, 01 Dec 2026 00:52
101 lines
13136 bytes
13136 bytes
From: Jacob Keller <jacob.e.keller@intel.com>
When Earliest TxTime First offload is enabled, the ice_tx_map() function
computes the appropriate timestamps for the timestamp ring used to set the
transmit times for each packet.
It computes this by converting the skb->tstamp into a timespec and then
taking the sub-second portion from tv_nsec and dividing it by the timestamp
resolution. This value is then inserted into the timestamp descriptor using
ice_build_tstamp_desc().
At first glance this may seem reasonable. After all, the Tx timestamp
descriptor field has a mask defined by ICE_TXTIME_STAMP_M which is
GENMASK(31,13). This is a 19-bit wide field. With a unit size of 128
nanoseconds, the maximum representable time is only ~67 milliseconds, far
below the size of the tv_nsec field (just shy of one second).
The E830 device time is represented as a single 64-bit nanosecond value as
seen by ice_ptp_read_src_clk_reg() using a simple rd64 on the GLTSYN_TIME_L
register.
According to the data sheet, the hardware uses the following flow to
determine when to transmit the next packet in the paced queue:
half_window = window_size / 2
if (ts <= timer) {
if (timer - ts < half_window) {
// timestamp expired
pass
} else {
// wait before sending
stall
}
} else {
// Handle possible rollover case
if (ts - timer < half_window) {
// wait before sending
stall
} else {
// timestamp expired
pass
}
}
Here, window_size is the maximum value that fix in the 19 bit sized
timestamp field, ts is the next packet timestamp waiting in the queue, and
timer is the 19 bits of the GLTSYN_TIME MAC timer. The configured timestamp
"resolution" determines at which bit position to capture from the
GLTSYN_TIME registers. This logic does not perform any computation to
divide out seconds or to handle anything like a timespec. The timestamp and
timer values are compared directly with logic to account for handling
rollover.
Because of the faulty logic, all of the timestamps computed and placed in
the ring will result in the transmit time not matching the desired time per
the skb. Consider a timestamp exactly on a second boundary. The computed
timestamp will be 0, while the actual value should be (1,000,000,000 / 128)
mod 2^19 or 472,468 (0x73594).
Fix this by directly converting the ktime to nanoseconds rather than
converting to a timespec64.
Fixes: ccde82e90946 ("ice: add E830 Earliest TxTime First Offload support")
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
drivers/net/ethernet/intel/ice/ice_txrx.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c
index 35a480a1e172..ca98394caa04 100644
--- a/drivers/net/ethernet/intel/ice/ice_txrx.c
+++ b/drivers/net/ethernet/intel/ice/ice_txrx.c
@@ -1522,10 +1522,9 @@ ice_tx_map(struct ice_tx_ring *tx_ring, struct ice_tx_buf *first,
if (ice_is_txtime_cfg(tx_ring)) {
struct ice_tstamp_ring *tstamp_ring;
- u32 tstamp_count, j;
struct ice_ts_desc *ts_desc;
- struct timespec64 ts;
- u32 tstamp;
+ u32 tstamp_count, j;
+ u64 tstamp;
smp_rmb(); /* order flag read before pointer read */
tstamp_ring = READ_ONCE(tx_ring->tstamp_ring);
@@ -1535,8 +1534,8 @@ ice_tx_map(struct ice_tx_ring *tx_ring, struct ice_tx_buf *first,
tstamp_count = tstamp_ring->count;
j = tstamp_ring->next_to_use;
- ts = ktime_to_timespec64(first->skb->tstamp);
- tstamp = ts.tv_nsec >> ICE_TXTIME_CTX_RESOLUTION_128NS;
+ tstamp = ktime_to_ns(first->skb->tstamp);
+ tstamp >>= ICE_TXTIME_CTX_RESOLUTION_128NS;
ts_desc = ICE_TS_DESC(tstamp_ring, j);
ts_desc->tx_desc_idx_tstamp = ice_build_tstamp_desc(i, tstamp);
--
2.47.1
Technical Details
Message-ID:
<20261201005258.1323948-4-anthony.l.nguyen@intel.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374569-linux-kernel-netdev=dewy.ruReferences:
<20261201005258.1323948-1-anthony.l.nguyen@intel.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374569-linux-kernel-netdev=dewy.ru From: anthony.l.nguyen@intel.com (Tony Nguyen) Newsgroups: linux.kernel.netdev Subject: [PATCH net v2 3/3] ice: fix computation of ETF timestamps for E830 Date: Mon, 30 Nov 2026 16:52:56 -0800 Organization: Usenet Network Message-ID: <20261201005258.1323948-4-anthony.l.nguyen@intel.com> References: <20261201005258.1323948-1-anthony.l.nguyen@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1578416"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:5ASpdrcFXw12EuHk+og+2pecRZ4= sha256:q16f3yFybaeO1Ze9hIarF64723jGycTvqHmN795VdfU= sha1:d9M+5yQ99HAEAfmXSYGs1+QPCK4= sha256:Egq5PtUD0mE0RbKcuedbTiaiqme5WU9zbWugpzWJA+Q= 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 E0C2B126017; Tue, 1 Dec 2026 03:53:32 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 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, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=intel.com 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 lPpZQVzyEjrW; Tue, 1 Dec 2026 03:53:30 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374569-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=intel.com X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 34DEC126013; Tue, 1 Dec 2026 03:53:19 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 18F0A27BBD; Tue, 1 Dec 2026 00:53:13 +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=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796086391; b=uPwqZXjckJs8X93D1j2r2RyknHZ9LaWpY1nfh3T+Vue97l56aFhU7klPYfkO8m/soJ9Y AP7UZKQscDYpJbFsxEBnrahDeFhSCwtCT6blyNmA1iGiGfDzM7L+jOwqCjIVGBulTLR8n 8lZMtLHvCrDmkuVl7g5FM1CFYVdrWeL5bglZPq8inirs4p6bY0MHCthL5raYjn5LrcI7h sSzVxCOJWzY5NANPjYuIybN6IIA9N3y+A35V6L388FQ3V28AEcJjqCXu8G7Kj2KHzTGKf V3tiUIjukpEqUBSlGE2S+i+NxOBg7+jNnzYCz+pTg1T4VputaR+4nMD7cssx/2PDw5A== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796086391; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature: X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-IronPort-AV:X-IronPort-AV: Received:X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV: Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding; bh=oJrJyMNmrKL/ZQxW1vxX+5H2Q2kLOwqPRFLeu5FlTjE=; b=LsL1vZN/PMMYq9ef+1CXcrxwMckwoNcCwt6r6x9oY//jfo8GC9V9idQnxdeTj8NK/q8y GFpVilWJQ1m8xYDDZbXFlINE7YabxskkEavRYa8JpDswNAmecUlmG4u1oKNATVI3bqGPo qfjW/15udYkF84MkDmbkWqEafwtubB0+TttARwZMkLPWFAhySj83zKE1O32UkhTNuKZOA 4QVShzeVabX8FOYv9EVA+s7iVCXY8obSrtjHIQ50xgp822X0xCJkGl17OsaMs2KfDRo2f ZrKi92sy1mjlCB2FjF5GoSiaoci14Ycl8zCvh/Tn9gQocYNQp2L43Z8lyLDV8WlufhQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=hvt5YEQu; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; 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 66B64606A687; Tue, 1 Dec 2026 00:53:11 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=hvt5YEQu X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.17 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796086390; b=TXhdmm57oxWpKc/gHk+dErTyHXv0iM9CJXCZvpQHvKGS68o4+dpckokTITuwd6eh5FdJ OcjXpebwyzusf+YzlGQYzdkK8s9UD5ZVF1gkeeDTBK4/afzgfxNJCTQOlRP3N8IQuVOgA Te5VnIUy4T6o24gwzt2kzCW7LVIKZz04dKm8styjA8oC8jK6/4kdD/wI7L8ey5+ZtXG/b 02wxH5jJaTLLoI6WszN99KmWRc3ODuJhZN9lHwqUEYJ+T6BbyWa1JpBv0EoSjnclAEncW ygLABSFhGGo54O9whAFW6BjlozpdE73PeA1kCmYZGFoFLMMH6jGgU1qy14fmpdTx7OQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796086390; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=oJrJyMNmrKL/ZQxW1vxX+5H2Q2kLOwqPRFLeu5FlTjE=; b=Kd1MU8P1JyYvZO1mkEpYolYotMLIAyzB13dTcyauDJdYVzuMOsFb1uRiwvAcBXgYoE+u frsBOPJ8Grp8aONBQqNnFTLX6jDUB6yXlflZlP1U/DyptZkylT0HIX58fTkW/DMpDxmsC c/asUz+wEUcCcDDYk1DRKSKHuToRc/ngeLsVS82OgHdoFpUVLcTj3KiYi9pxfgJYeGPlQ BCrPQAHgcLLiOmjjL6BWk0PKnmg5bbwq0pK5gOG7twKjfojAUbzb69MQgLtnw0gsMO0BN qMzUeqrlLSH+Bid5IQ4f5l1jWrWzoy9CFBdzM3ZUbWOdd8C7gJMZt9lSh0HKLG55dyA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=hvt5YEQu; arc=none smtp.remote-ip=198.175.65.17 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31201606A32D for <netdev@vger.kernel.org>; Tue, 1 Dec 2026 00:53:10 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 31201606A32D X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796086390; x=1827622390; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oJrJyMNmrKL/ZQxW1vxX+5H2Q2kLOwqPRFLeu5FlTjE=; b=hvt5YEQucHAwc1UgZac/G+QNm+T8lvwupjmbZECwyqVYyXMO+fJHQI62 ty3wb54VYn1fB0uAAJpU1fByRLbXSS9nFNRKm4ZefWw0psTa5afZjw8oU Y1cx5e3II1+o/Tj4sDZQ/MC8J5AlcY2lmQUYKCad6cgKH6Ajwed1TScaO v+IgG1W2YJw3Sn40DGftaJxQdk2I5UfZi+sSpTKs2YrjNx5TDmHDXg/yN bzB2Gx4LyrjO4zUFpUDjngjFt6Jh+pWE0s9OQnMm36DsUuDgzPv72mXo1 I99cx5sYCRrmxvxPgMupH3iFfWEBLlrvSXdORiooUEqw7DUAiNPgqk9sO A==; X-CSE-ConnectionGUID: LEJr+n41ToetS2A6h6v9uA== X-CSE-MsgGUID: 33cBX6j/Qsq+NEdBx3EP1Q== X-IronPort-AV: E=McAfee;i="6800,10657,11982"; a="4941452" X-IronPort-AV: E=Sophos;i="6.27,243,1787036400"; d="scan'208";a="4941452" X-Received: from fmviesa011.fm.intel.com ([10.60.135.151]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 16:53:10 -0800 X-CSE-ConnectionGUID: qkrliHIxSuigWii5WYp4tw== X-CSE-MsgGUID: WcINi/pZR7WNpf4qMVjX8g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,243,1787036400"; d="scan'208";a="14837750" X-Received: from anguy11-upstream.jf.intel.com ([10.166.9.133]) by fmviesa011.fm.intel.com with ESMTP; 30 Nov 2026 16:53:09 -0800 X-Cc: Jacob Keller <jacob.e.keller@intel.com>, anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com, maciej.machnikowski@intel.com, grzegorz.nitka@intel.com, paul.greenwalt@intel.com, maciej.fijalkowski@intel.com, richardcochran@gmail.com, Aleksandr Loktionov <aleksandr.loktionov@intel.com> X-Mailer: git-send-email 2.47.1 X-In-Reply-To: <20261201005258.1323948-1-anthony.l.nguyen@intel.com> 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