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 9EDBD45C11 for ; Wed, 30 Oct 2024 04:20:39 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 96C9C43278; Wed, 30 Oct 2024 04:20:39 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by mails.dpdk.org (Postfix) with ESMTP id BCE8C42EC5; Wed, 30 Oct 2024 04:20:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730258437; x=1761794437; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dgcOqHAHO3GmYAICFXHkUwHlTUSwZM2g6g5BZgCzdmg=; b=lxsYI6gSJ2IjP0/DUcTYgq9g7JJKKe8U7oW0JPTS+/LOBRIGmaQ1IIrf XBEoIG66X2a+woHsFxFdBjBiYSuKzVlMKKvTdsumUvKLeRrrbkCplzV09 EEZyB9MKaxlvpBMO/AsL88n3i9z8W4NgchnwA7ekf4kVJn9Dv/gLTX0d6 RiArXgeo9BZxlsfXLFZJa8iN9wUqSDIth41YZ7Y9uHfojl2WYise3Tz6x Gr45evNLmP09sqM/K6iljswMtjHYrE8iMFscc5dN40c7/G3WQoUqgQAVR 15Vxq1HtthYMS/SuJMHBrKJEHxEgc3jyGm9kYuRsXk03WP9kU05I7ABmG w==; X-CSE-ConnectionGUID: ZyarugCHRr2xuR9wd8IwkA== X-CSE-MsgGUID: 85YUPSzLTC+ePAcxBOQWOA== X-IronPort-AV: E=McAfee;i="6700,10204,11240"; a="33866284" X-IronPort-AV: E=Sophos;i="6.11,243,1725346800"; d="scan'208";a="33866284" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2024 20:20:35 -0700 X-CSE-ConnectionGUID: 7ERVB1kBRvGr4Pxbw5yO9g== X-CSE-MsgGUID: ieLBRJn8THmAyJqXd7mYgw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,243,1725346800"; d="scan'208";a="87306138" Received: from unknown (HELO npf-hyd-clx-03..) ([10.145.170.182]) by orviesa004.jf.intel.com with ESMTP; 29 Oct 2024 20:20:34 -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 v2] net/ice: fix incorrect reading of PHY timestamp Date: Wed, 30 Oct 2024 02:16:11 +0000 Message-ID: <20241030021611.871536-1-soumyadeep.hore@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241025102625.801994-1-soumyadeep.hore@intel.com> References: <20241025102625.801994-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 --- v2: - Addressed Bruce's comments --- 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 70298ac330..6d0d37b3a0 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -6597,10 +6597,26 @@ ice_timesync_read_tx_timestamp(struct rte_eth_dev *dev, struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct ice_adapter *ad = ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); - uint64_t ts_ns, tstamp; + uint64_t ts_ns, tstamp, tstamp_ready = 0; + uint64_t end_time; const uint64_t mask = 0xFFFFFFFF; int ret; + end_time = rte_get_timer_cycles() + rte_get_timer_hz(); + + while (!(tstamp_ready & BIT_ULL(0))) { + ret = ice_get_phy_tx_tstamp_ready(hw, ad->ptp_tx_block, &tstamp_ready); + if (ret) { + PMD_DRV_LOG(ERR, "Failed to get phy ready for timestamp"); + return -1; + } + + if (rte_get_timer_cycles() > end_time) { + PMD_DRV_LOG(ERR, "Timeout to get phy ready for timestamp"); + return -1; + } + } + ret = ice_read_phy_tstamp(hw, ad->ptp_tx_block, ad->ptp_tx_index, &tstamp); if (ret || tstamp == 0) { PMD_DRV_LOG(ERR, "Failed to read phy timestamp"); -- 2.43.0