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 BF876A00BE for ; Fri, 11 Feb 2022 08:00:29 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A288B410E5; Fri, 11 Feb 2022 08:00:29 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id D1E63410E5; Fri, 11 Feb 2022 08:00:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1644562828; x=1676098828; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=Frbc1g1l2k3MhJBgTKQQYIGTeFfQ5tPtIJZbL6iIm14=; b=mTxVNb65ETb6ersldOY4bt8qgbSu6A448ewwsz1shPK9NwL4L54fiDRA M9+FsPA/KqE5V7b6yi917YdqqBm/8mET604UqxfDSJdq6IUbQ/XCHFNP3 KhL+fuYgHWAYCkoNrixp+sj0HWz4xUf41Jmfs6bLOny37Kyjuz9kMdp7l aba1VioiMhVsfsPb+QM0Zxo1alocYJK812hYGLIswP08IGaXcGuzgiiGt qsL+S8yVwC/UdEN96BPI1Cxe2RojoVMzgdV+5dHHNMfJ003rRWQfTLgF7 lR7iLpWm8xLoWp9o30LDrQCxDTJEY7qELbPhvomfXodfsiH54YnCetS4X A==; X-IronPort-AV: E=McAfee;i="6200,9189,10254"; a="274231359" X-IronPort-AV: E=Sophos;i="5.88,359,1635231600"; d="scan'208";a="274231359" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:00:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,359,1635231600"; d="scan'208";a="602293029" Received: from unknown (HELO npg-dpdk-simeisu-cvl-119d218.sh.intel.com) ([10.67.119.218]) by fmsmga004.fm.intel.com with ESMTP; 10 Feb 2022 23:00:25 -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 v3] net/ice: fix missing clock initialization Date: Fri, 11 Feb 2022 14:41:00 +0800 Message-Id: <20220211064100.403354-1-simei.su@intel.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20220128021129.430189-1-simei.su@intel.com> References: <20220128021129.430189-1-simei.su@intel.com> 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 Rx PHY timer init value is not same as primary timer init value when power up which will lead Rx timestamp always have big gap compared with PTP timestamp. This patch adds PHC init time in initializing PTP hardware clock. Fixes: 646dcbe6c701 ("net/ice: support IEEE 1588 PTP") Cc: stable@dpdk.org Signed-off-by: Simei Su --- v3: * Fix use of undeclared identifier 'CLOCK_MONOTONIC'. v2: * Rename commit title. drivers/net/ice/ice_ethdev.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index 1a469af..dcecf69 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -5662,6 +5663,8 @@ ice_timesync_enable(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 start_time; + struct timespec system_time; int ret; if (dev->data->dev_started && !(dev->data->dev_conf.rxmode.offloads & @@ -5683,6 +5686,15 @@ ice_timesync_enable(struct rte_eth_dev *dev) "Failed to write PHC increment time value"); return -1; } + + clock_gettime(CLOCK_MONOTONIC, &system_time); + start_time = system_time.tv_sec * NSEC_PER_SEC + + system_time.tv_nsec; + ret = ice_ptp_init_time(hw, start_time); + if (ret) { + PMD_DRV_LOG(ERR, "Failed to write PHC initial time"); + return -1; + } } /* Initialize cycle counters for system time/RX/TX timestamp */ -- 2.9.5