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 E6FEF41DB5 for ; Thu, 2 Mar 2023 14:46:15 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DCCCC41611; Thu, 2 Mar 2023 14:46:15 +0100 (CET) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id BF8B140E09; Thu, 2 Mar 2023 14:46:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677764774; x=1709300774; h=from:to:cc:subject:date:message-id; bh=TQodhxanImUWh3ermcKB5FIzBpkanlp8UiqRbcWue4g=; b=PPF3ws4r09iukXcLRX6iF2KJD+AbgvC3Y61nw6ZdWupyJybtbQ6CZqSj rpGtJjLxpbLvVgy/ypzzn5n/bQANTOgAs7vzAtx+I0w+9/zOEl0Turh4g 3Gj7wdca2M8vZ4jA9N3RJaf/3STa4Pmnjss10qBeKDBXtHrD1UILyBvWf V+5rIw44OqhoQBnBDvk66pQx841qhKSJ0RS0in5MLuVpv0XPLCVUA30f4 w0zFzeRvIKc2yGUtxi5Gfpe93FVu9f4UQv22/Nh5TdzblPknu1TAmoN1V SRSXOHE1gDBzNbeDjkEW87IcYSWj0Uyc0pRolgqJYstewK7H3nOVdq93j Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10636"; a="397286786" X-IronPort-AV: E=Sophos;i="5.98,227,1673942400"; d="scan'208";a="397286786" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2023 05:46:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10636"; a="798829580" X-IronPort-AV: E=Sophos;i="5.98,227,1673942400"; d="scan'208";a="798829580" Received: from unknown (HELO npg-dpdk-simeisu-cvl-119d218.sh.intel.com) ([10.67.119.208]) by orsmga004.jf.intel.com with ESMTP; 02 Mar 2023 05:46:10 -0800 From: Simei Su To: qi.z.zhang@intel.com, qiming.yang@intel.com Cc: dev@dpdk.org, Simei Su , stable@dpdk.org Subject: [PATCH] net/ice: fix incorrect Rx timestamp for E822 Date: Thu, 2 Mar 2023 21:45:01 +0800 Message-Id: <20230302134501.201032-1-simei.su@intel.com> X-Mailer: git-send-email 2.9.5 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 The Rx timestamp is 0 due to the missing PHY clock timer setup for E822. Also, the source clock index in use is based on device capabilities instead of always being zero. Fixes: 953e74e6b73a ("net/ice: enable Rx timestamp on flex descriptor") Fixes: 646dcbe6c701 ("net/ice: support IEEE 1588 PTP") Cc: stable@dpdk.org Signed-off-by: Simei Su --- drivers/net/ice/ice_ethdev.c | 31 ++++++++++++++++++++++--------- drivers/net/ice/ice_rxtx.h | 11 ++++++----- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index 0d011bb..c01a0e4 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -2413,6 +2413,17 @@ ice_dev_init(struct rte_eth_dev *dev) /* Initialize TM configuration */ ice_tm_conf_init(dev); + if (ice_is_e810(hw)) + hw->phy_cfg = ICE_PHY_E810; + else + hw->phy_cfg = ICE_PHY_E822; + + if (hw->phy_cfg == ICE_PHY_E822) { + ret = ice_start_phy_timer_e822(hw, hw->pf_id, true); + if (ret) + PMD_INIT_LOG(ERR, "Failed to start phy timer\n"); + } + if (!ad->is_safe_mode) { ret = ice_flow_init(ad); if (ret) { @@ -5939,16 +5950,17 @@ ice_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts) 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); + uint8_t tmr_idx = hw->func_caps.ts_func_info.tmr_index_assoc; uint32_t hi, lo, lo2; uint64_t time, ns; - lo = ICE_READ_REG(hw, GLTSYN_TIME_L(0)); - hi = ICE_READ_REG(hw, GLTSYN_TIME_H(0)); - lo2 = ICE_READ_REG(hw, GLTSYN_TIME_L(0)); + lo = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx)); + hi = ICE_READ_REG(hw, GLTSYN_TIME_H(tmr_idx)); + lo2 = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx)); if (lo2 < lo) { - lo = ICE_READ_REG(hw, GLTSYN_TIME_L(0)); - hi = ICE_READ_REG(hw, GLTSYN_TIME_H(0)); + lo = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx)); + hi = ICE_READ_REG(hw, GLTSYN_TIME_H(tmr_idx)); } time = ((uint64_t)hi << 32) | lo; @@ -5964,6 +5976,7 @@ ice_timesync_disable(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); + uint8_t tmr_idx = hw->func_caps.ts_func_info.tmr_index_assoc; uint64_t val; uint8_t lport; @@ -5971,12 +5984,12 @@ ice_timesync_disable(struct rte_eth_dev *dev) ice_clear_phy_tstamp(hw, lport, 0); - val = ICE_READ_REG(hw, GLTSYN_ENA(0)); + val = ICE_READ_REG(hw, GLTSYN_ENA(tmr_idx)); val &= ~GLTSYN_ENA_TSYN_ENA_M; - ICE_WRITE_REG(hw, GLTSYN_ENA(0), val); + ICE_WRITE_REG(hw, GLTSYN_ENA(tmr_idx), val); - ICE_WRITE_REG(hw, GLTSYN_INCVAL_L(0), 0); - ICE_WRITE_REG(hw, GLTSYN_INCVAL_H(0), 0); + ICE_WRITE_REG(hw, GLTSYN_INCVAL_L(tmr_idx), 0); + ICE_WRITE_REG(hw, GLTSYN_INCVAL_H(tmr_idx), 0); ad->ptp_ena = 0; diff --git a/drivers/net/ice/ice_rxtx.h b/drivers/net/ice/ice_rxtx.h index 4947d5c..94f6bcf 100644 --- a/drivers/net/ice/ice_rxtx.h +++ b/drivers/net/ice/ice_rxtx.h @@ -349,26 +349,27 @@ static inline uint64_t ice_tstamp_convert_32b_64b(struct ice_hw *hw, struct ice_adapter *ad, uint32_t flag, uint32_t in_timestamp) { + uint8_t tmr_idx = hw->func_caps.ts_func_info.tmr_index_assoc; const uint64_t mask = 0xFFFFFFFF; uint32_t hi, lo, lo2, delta; uint64_t ns; if (flag) { - lo = ICE_READ_REG(hw, GLTSYN_TIME_L(0)); - hi = ICE_READ_REG(hw, GLTSYN_TIME_H(0)); + lo = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx)); + hi = ICE_READ_REG(hw, GLTSYN_TIME_H(tmr_idx)); /* * On typical system, the delta between lo and lo2 is ~1000ns, * so 10000 seems a large-enough but not overly-big guard band. */ if (lo > (UINT32_MAX - ICE_TIMESYNC_REG_WRAP_GUARD_BAND)) - lo2 = ICE_READ_REG(hw, GLTSYN_TIME_L(0)); + lo2 = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx)); else lo2 = lo; if (lo2 < lo) { - lo = ICE_READ_REG(hw, GLTSYN_TIME_L(0)); - hi = ICE_READ_REG(hw, GLTSYN_TIME_H(0)); + lo = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx)); + hi = ICE_READ_REG(hw, GLTSYN_TIME_H(tmr_idx)); } ad->time_hw = ((uint64_t)hi << 32) | lo; -- 2.9.5