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 1151C45C76; Mon, 4 Nov 2024 12:36:27 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EF0F840BA4; Mon, 4 Nov 2024 12:36:26 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by mails.dpdk.org (Postfix) with ESMTP id D279F400D5; Mon, 4 Nov 2024 12:36:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730720185; x=1762256185; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/9sDdsR2TbQboPkfJncIMwgOIs88QEpuYRMNhx+notg=; b=O8UpYYnLBxuVVIvlnpnuyCKiJTpCHj0jLxHQhm+X4QB10JumPhkZMnGw a3fkNQwpWIZI352z20r9ZVhUZQ0x++bA5NuzQdxXMdqvY/rnP3T2gArVP 4I9951WZNo1Evg/XGTI5hJc3pEiJj03ABzB3ssIAvzCK3HNBS1azVR+wr 6V5CHW/8OkYkEGyszfmwyxwvNwMuyvyWE1uP4mHqFdawMRnEGi9Yakg8U Y5bUwsAD+Ww2DB95o9Rcv5whjReusNTiyHyemVvviZtwK3sm4Dq/q0QQ8 0TvY85Rg66A9+CMyLu9Gw5rlHexwIyxVh3FXilCWCWKI6MQNFi7jY9mYM Q==; X-CSE-ConnectionGUID: EZXKkIiiTDyAnJXk0wbfjw== X-CSE-MsgGUID: kn1cYLjsSh2EwcM7NNIxUg== X-IronPort-AV: E=McAfee;i="6700,10204,11245"; a="55811640" X-IronPort-AV: E=Sophos;i="6.11,256,1725346800"; d="scan'208";a="55811640" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2024 03:36:24 -0800 X-CSE-ConnectionGUID: mHSn37J2TYmnvQim6tJEtQ== X-CSE-MsgGUID: emFi68GySfyFK1Bg+EqYtA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,256,1725346800"; d="scan'208";a="83742390" Received: from unknown (HELO npf-hyd-clx-03..) ([10.145.170.182]) by fmviesa008.fm.intel.com with ESMTP; 04 Nov 2024 03:36:22 -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 v3] net/ice: fix incorrect reading of PHY timestamp Date: Mon, 4 Nov 2024 10:31:12 +0000 Message-ID: <20241104103112.885071-1-soumyadeep.hore@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241030021611.871536-1-soumyadeep.hore@intel.com> References: <20241030021611.871536-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 --- 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..3c768b6d0b 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); + + while (!(tstamp_ready & BIT_ULL(0))) { + 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; + } + } + 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