From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9BA6745BD4 for ; Fri, 25 Oct 2024 10:54:07 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 93A9D4003C; Fri, 25 Oct 2024 10:54:07 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by mails.dpdk.org (Postfix) with ESMTP id 9F6724003C; Fri, 25 Oct 2024 10:54:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729846447; x=1761382447; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=unLh3BbM8MtMuEOlAUsOGRUTuY1xKl6vJQbTJibdNAw=; b=Cfi7GVgkoB1GF5UZZiu4jiT72xl1cde7GjX5JYTZV3Gt+DxpV33oU0Om kIVcPY2Xp82igaHCdvM2/D1GJi0atbQbwSq6NMxQIYXrHz90DENohCZeJ LjR58SV/XE5sXkIKHvff1SbeQ83rfm/XugEIUM817D4RagrI3WeWBoR4v qRI73vkhlQdM7yKRDQOcYDWh8swpP/d1BquZh2L5PCH39DvVhEUZAYwIw KnhuZfnOdvfG4ePyQWtk6wHvfXCbRBNTdbLvmkaeOxzsf4VZlIelPJytH a8zk+yaoyF3o5/SZtpWhZMNbv6BRKOsdACOJiZrgdC6f0L9ohJxRr8OXR A==; X-CSE-ConnectionGUID: gLMxJzpzT6memQGNoFGHuA== X-CSE-MsgGUID: eTTa5TCeTWOmHad4E6rDkQ== X-IronPort-AV: E=McAfee;i="6700,10204,11235"; a="28962635" X-IronPort-AV: E=Sophos;i="6.11,231,1725346800"; d="scan'208";a="28962635" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2024 01:54:06 -0700 X-CSE-ConnectionGUID: 16oNpVsGR0qNt/qM18rjsg== X-CSE-MsgGUID: FhR3SpPyRbqE/WNT1LNI9g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,231,1725346800"; d="scan'208";a="80863641" Received: from unknown (HELO npf-hyd-clx-03..) ([10.145.170.182]) by fmviesa009.fm.intel.com with ESMTP; 25 Oct 2024 01:54:04 -0700 From: Soumyadeep Hore To: bruce.richardson@intel.com, aman.deep.singh@intel.com Cc: dev@dpdk.org, shaiq.wani@intel.com, stable@dpdk.org Subject: [PATCH v4] net/ice: fix incorrect reading of PHY timestamp Date: Fri, 25 Oct 2024 07:50:25 +0000 Message-ID: <20241025075025.682290-1-soumyadeep.hore@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241025051419.679693-1-soumyadeep.hore@intel.com> References: <20241025051419.679693-1-soumyadeep.hore@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org In ICE PMD, previously the ready bitmap checking before reading PHY timestamp was not present. This caused incorrect Tx timestamping. The ready bitmap checking is enabled and PHY timestamp is read once the ready bitmap gives positive value. Fixes: 881169950d80 ("net/ice/base: implement initial PTP support for E830") Cc: stable@dpdk.org Signed-off-by: Soumyadeep Hore --- drivers/net/ice/ice_ethdev.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index 7b1bd163a2..e0db47cf28 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -6517,12 +6517,28 @@ ice_timesync_read_tx_timestamp(struct rte_eth_dev *dev, struct ice_adapter *ad = ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); uint8_t lport; - uint64_t ts_ns, ns, tstamp; + uint64_t ts_ns, ns, tstamp, tstamp_ready = 0; + uint64_t start_time, curr_time; const uint64_t mask = 0xFFFFFFFF; int ret; lport = hw->port_info->lport; + start_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000); + + while (!(tstamp_ready & BIT_ULL(0))) { + ret = ice_get_phy_tx_tstamp_ready(hw, lport, &tstamp_ready); + if (ret) { + PMD_DRV_LOG(ERR, "Failed to get phy ready for timestamp"); + return -1; + } + curr_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000); + if (curr_time - start_time > 1000) { + PMD_DRV_LOG(ERR, "Timeout to get phy ready for timestamp"); + return -1; + } + } + ret = ice_read_phy_tstamp(hw, lport, 0, &tstamp); if (ret) { PMD_DRV_LOG(ERR, "Failed to read phy timestamp"); -- 2.43.0