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 E043F45BD2 for ; Fri, 25 Oct 2024 08:18:18 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DA20E4026B; Fri, 25 Oct 2024 08:18:18 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) by mails.dpdk.org (Postfix) with ESMTP id 074D94026B; Fri, 25 Oct 2024 08:18:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729837098; x=1761373098; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=unLh3BbM8MtMuEOlAUsOGRUTuY1xKl6vJQbTJibdNAw=; b=ixE/OyfpCDgcVHLDCmXoNHpycwsy64ZsnMZzxjuIHvosQWMdTvgds3su tQNDZoUCOf2cZfxqwxixccS3NilW5KsLVN4UHnQDZjXFviL4Q2Aaad3sZ WGNRUXmgRovS+xI8z5czHt5RLAeFlzmaeR8klZ3q6p2vMFPpXpDrNX4Tg E4jYegD/eBuxVByMJw6BAZ1/Csj/XvBdNjNEQwBoC8ZTQl8XAaE/ik1Wz gn9Ar5Xku8miQbMpCzJGiLqEjazsPoTXSkJ1MZwoTv+u8A9l86xai01nd OduMcDgXteg5NR+FSA9RAxURqOvqJejbyhRX64akn7r20WjxebOb8xDdw A==; X-CSE-ConnectionGUID: pZ6FMmBfSPOErMlVjNRBiw== X-CSE-MsgGUID: zGCuc+j4SESDbWQ4b1dOvA== X-IronPort-AV: E=McAfee;i="6700,10204,11235"; a="29396676" X-IronPort-AV: E=Sophos;i="6.11,231,1725346800"; d="scan'208";a="29396676" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2024 23:18:16 -0700 X-CSE-ConnectionGUID: t01etWZZQEyF541F8NFxhQ== X-CSE-MsgGUID: lyaKQWgoQHyEAAM3Yunmeg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,231,1725346800"; d="scan'208";a="81655513" Received: from unknown (HELO npf-hyd-clx-03..) ([10.145.170.182]) by orviesa008.jf.intel.com with ESMTP; 24 Oct 2024 23:18:14 -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: Fri, 25 Oct 2024 05:14:18 +0000 Message-ID: <20241025051419.679693-1-soumyadeep.hore@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241011130046.642352-1-soumyadeep.hore@intel.com> References: <20241011130046.642352-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