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 1690B45C93; Wed, 6 Nov 2024 10:28:00 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9D06D427A9; Wed, 6 Nov 2024 10:27:59 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by mails.dpdk.org (Postfix) with ESMTP id 392C540265; Wed, 6 Nov 2024 10:27:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730885279; x=1762421279; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zkdxYQISzto+74IOMeMrIWG1Eisj4ggu9uI4BFKMcqE=; b=nXXK3b5feE7zjFlvrKt/huA2aIjsOl9JH/M0HSYqjfu5PiHBvGXUNyCu bWrwO3zMjWGpQFk+1muKY3pGwfzfpbHB7HKWAY5ve1YHjaFuV1IOcH14U z5r9VGRk5Tu/mW1I27bqsd7Ym+TsNVE4+FvGRdBEHkpZ3d8huhB9YpRV9 ZBYrKjMMqmW6JE3AV+zO3PGVSX2j+W5vUR9fMR7Obxhvjw9svGEPxTShN 8GaatqSwSkkspsCxMK4iMD0ti30A3wxHiFQNBzTgGMdo514ZmZNmAvgoN XfsnLYkmMiDQ3f+DTWHDVseI5GLceJw2lG35OEnJHeaYC0y1xArxYz813 g==; X-CSE-ConnectionGUID: h5RwIyg8Q2GNG/vb6O9twQ== X-CSE-MsgGUID: e8/1rn7KRxiW0azqdAjpNw== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="41220435" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="41220435" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2024 01:27:57 -0800 X-CSE-ConnectionGUID: 9CQ0TxjAQYyb8rKkW2gAng== X-CSE-MsgGUID: 8j0ADKnNRZWdQaPZ6v7jRQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,262,1725346800"; d="scan'208";a="89572373" Received: from unknown (HELO npf-hyd-clx-03..) ([10.145.170.182]) by orviesa004.jf.intel.com with ESMTP; 06 Nov 2024 01:27:55 -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 v5] net/ice: fix incorrect reading of PHY timestamp Date: Wed, 6 Nov 2024 08:22:29 +0000 Message-ID: <20241106082229.892805-1-soumyadeep.hore@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241105101419.888975-1-soumyadeep.hore@intel.com> References: <20241105101419.888975-1-soumyadeep.hore@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-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 --- v5: - Addressed edge case as specified in Bruce's comment --- 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..4a7fb2b656 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 ((tstamp_ready & BIT_ULL(0)) == 0 && 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