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 7AEE445B13 for ; Fri, 11 Oct 2024 16:02:47 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 80C394028B; Fri, 11 Oct 2024 16:02:46 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) by mails.dpdk.org (Postfix) with ESMTP id 757254028B; Fri, 11 Oct 2024 16:02:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1728655366; x=1760191366; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=VeBNOPzzsshOkfRjO1FS5d8FGF1fP1zzBcF3qbEe+kI=; b=NpAjbtWdXHvfXQzzzVlz7vwjNALM6DvnO7QumeQ0hIiwJcxT45i76agI GC0w627dd0QhJenCWuurHGTCJXpDLp4juDX8y0Oce5eVm9S9qi4MiCUJZ b3pudPoB/YTpKgK8sGx/xBqkufUStiJ1N4lrtSdj1Bgt1tgBW8MhEIKFE CfXF3Q2RZjso1Q1NCUz3mP3qTaRq4Ugr1+9mEIrzCyTtuPeEHe+VvOlTn aDDCzAamUxyX5i5OqkQ18D+tSvbmEeugLHK8DVUkLHXzjUhSzD7+u64qA 7ztmKhEPDNUqJpyVLLgncAiu78hpQYpYYKz2Bxpx68dUeXaywqoxSoIrD g==; X-CSE-ConnectionGUID: kgLU3JpVSB63gZfFFAnCmA== X-CSE-MsgGUID: VS5Xvoy/RDaE7rpRLri92w== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="28003909" X-IronPort-AV: E=Sophos;i="6.11,196,1725346800"; d="scan'208";a="28003909" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2024 07:02:45 -0700 X-CSE-ConnectionGUID: SCRf25ElTNy8ZIgJGK58Eg== X-CSE-MsgGUID: peAO6bZ5RN60MrR0V6lGmw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,196,1725346800"; d="scan'208";a="80930224" Received: from unknown (HELO npf-hyd-clx-03..) ([10.145.170.182]) by fmviesa003.fm.intel.com with ESMTP; 11 Oct 2024 07:02:42 -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 v1] net/ice: fix incorrect reading of PHY timestamp Date: Fri, 11 Oct 2024 13:00:46 +0000 Message-ID: <20241011130046.642352-1-soumyadeep.hore@intel.com> X-Mailer: git-send-email 2.43.0 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 | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index 7b1bd163a2..2357d6e1da 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -6516,14 +6516,32 @@ 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); + struct ice_tx_queue *txq; 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; + txq = dev->data->tx_queues[0]; lport = hw->port_info->lport; - ret = ice_read_phy_tstamp(hw, lport, 0, &tstamp); + 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, txq->queue_id, &tstamp); if (ret) { PMD_DRV_LOG(ERR, "Failed to read phy timestamp"); return -1; -- 2.43.0