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 9A4C145BD4 for ; Fri, 25 Oct 2024 10:35:55 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 87970402E3; Fri, 25 Oct 2024 10:35:55 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by mails.dpdk.org (Postfix) with ESMTP id 17F054003C; Fri, 25 Oct 2024 10:35:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729845353; x=1761381353; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=unLh3BbM8MtMuEOlAUsOGRUTuY1xKl6vJQbTJibdNAw=; b=X4XW0Bf/gz+UZkRuZLx2zgYMgKezXrFX8DH64IOBfd2W6hRuLF9QyBMY srw/uKn+buyDUVkq+RsuNe+Xwl1DK++jNhrOerAlt814OLNqE7UzXCI/l OM3sPNbUfkgThwiPf4cpgA1YeuSD22sezDusvkv7TUJAxf73u+QrG1dCv aC9kE5UX8f6Eh80MxBe9/OLNyDGnVF+l1+LXwepf5fzgQnx8k5ioJTZMf CDKBZaMrVneSVtMtob1fZh8BKSFtTNqg2Fk5vf90JN4rEIp41WPrkUujV LhLK6ppjXBEr4O8E9Luvt2gsGO06sRXTa+Og7j2mt7jCPvj0dIrGo2JGG Q==; X-CSE-ConnectionGUID: oD3wxkWFQJCVGNc4aerDwQ== X-CSE-MsgGUID: NICQX9MhRm6ct+I+shsmbQ== X-IronPort-AV: E=McAfee;i="6700,10204,11235"; a="33419063" X-IronPort-AV: E=Sophos;i="6.11,231,1725346800"; d="scan'208";a="33419063" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2024 01:35:52 -0700 X-CSE-ConnectionGUID: ZFIHnykqQfWidks9KsLmsQ== X-CSE-MsgGUID: JRo7RX++SH66ir9pM7qrww== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,231,1725346800"; d="scan'208";a="84813166" Received: from unknown (HELO npf-hyd-clx-03..) ([10.145.170.182]) by fmviesa003.fm.intel.com with ESMTP; 25 Oct 2024 01:35:50 -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 v3] net/ice: fix incorrect reading of PHY timestamp Date: Fri, 25 Oct 2024 07:32:11 +0000 Message-ID: <20241025073211.681268-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