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 B03F745C89 for ; Tue, 5 Nov 2024 12:19:52 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A7E2040696; Tue, 5 Nov 2024 12:19:52 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) by mails.dpdk.org (Postfix) with ESMTP id 3838D40151; Tue, 5 Nov 2024 12:19:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730805590; x=1762341590; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CLgcWhGbM1a5ypR4Mc+ltTU23HvTo7CLDWAvyygEkZw=; b=KCb2yp4gRMpK1o+ZRa6DKl1vVbaCcc4SG4aJ0YHO+aixdbhaieFKLGWb RLonkBQvqZyuHorQNRjhQMDlE8V0qa6rGAQt7x6bvJkK9r8r03O8LVWW0 naGh3/o2l5SFQWVKEKVcmJRYpFwsxRfAG6L2juhbKmQnhDEp1i/7KbkCo HKH+5N1L3YcMCZy2UG2gTC7PcqBBMfWwIdX27nmPfyoMLgMhcX5hi8whI BecWe+S41+2myzRgIlXwEnZGSDedoIPmVOZih87lPLzJNmVyZ23cyVkgc 4YpXBKu9an92lPP4oT0PfhNG5yAQAIagm2JSJLJtNrba8s6Y9aUcYq7Ns A==; X-CSE-ConnectionGUID: w6O+9qJxROurXIvFS4cASA== X-CSE-MsgGUID: k52x2afNRzeCj1BfDvqZ4g== X-IronPort-AV: E=McAfee;i="6700,10204,11246"; a="30663273" X-IronPort-AV: E=Sophos;i="6.11,260,1725346800"; d="scan'208";a="30663273" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2024 03:19:41 -0800 X-CSE-ConnectionGUID: JVEkJACZSPqJ2XrqOF1Vow== X-CSE-MsgGUID: dz6nxPFbRjmP5cYJDBm24g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,260,1725346800"; d="scan'208";a="83637526" Received: from unknown (HELO npf-hyd-clx-03..) ([10.145.170.182]) by fmviesa007.fm.intel.com with ESMTP; 05 Nov 2024 03:19:36 -0800 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: Tue, 5 Nov 2024 10:14:19 +0000 Message-ID: <20241105101419.888975-1-soumyadeep.hore@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241104103112.885071-1-soumyadeep.hore@intel.com> References: <20241104103112.885071-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 --- v4: - Addressed Bruce comments for do while loop introduction --- v3: - Decreased the end time delay from 1 second to 10 microseconds --- v2: - Addressed Bruce's comments --- drivers/net/ice/ice_ethdev.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index 70298ac330..7e2c6107ff 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -6597,10 +6597,27 @@ 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; + /* Set the end time with a delay of 10 microseconds */ + end_time = rte_get_timer_cycles() + (rte_get_timer_hz() / 100000); + + do { + 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; + } + } while ((tstamp_ready & BIT_ULL(0)) == 0); + 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