From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.17 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== 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== 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 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 ; Tue, 1 Dec 2026 00:53:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 31201606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com 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 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" 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" 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 From: Tony Nguyen To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@kernel.org, andrew+netdev@lunn.ch, netdev@vger.kernel.org Cc: Jacob Keller , 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 Subject: [PATCH net v2 3/3] ice: fix computation of ETF timestamps for E830 Date: Mon, 30 Nov 2026 16:52:56 -0800 Message-ID: <20261201005258.1323948-4-anthony.l.nguyen@intel.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20261201005258.1323948-1-anthony.l.nguyen@intel.com> References: <20261201005258.1323948-1-anthony.l.nguyen@intel.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Jacob Keller 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 Reviewed-by: Aleksandr Loktionov Signed-off-by: Tony Nguyen --- 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