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 B32034579C; Mon, 12 Aug 2024 08:10:04 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4ED8E4014F; Mon, 12 Aug 2024 08:10:04 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by mails.dpdk.org (Postfix) with ESMTP id 0CBE5400D7 for ; Mon, 12 Aug 2024 08:10:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1723443003; x=1754979003; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=UNzxkNSuwdvLykcLzf659FBl306maeT9s0QK50PPrM4=; b=RKszsJ+idsQuHeNmEXkbLokLCUchL9Cpj4KgFj8qjM2etkKttaiHD7t/ pm1NstI4/z0aU2vJ230neLqXqTS53bFjFfeB2pkdZ2Ik1Xl4B4GI9jxRA iN0niV30xGT5gDHGbtQB6WXWrmypEAfEMs9uNlxj4g8hmDhD8GbSVoZak +0x3xjKWcKlW/CeFxN+JTRpRgXzpzhsLkHuuYqxf8YYFW0Q5wM053YQzR NRJ/TyO2yqP6/oMU70fb9/s8j34uBPBT2X1k9d/DgBbMQjTowt4Aba70E 5wAhfSzYOvFau1nriz8pJt2NenjoRZTUbOS+iLxrOX36YzMj/kqhwpKgA w==; X-CSE-ConnectionGUID: fG/E5kPiQlqg60PwFPpn/Q== X-CSE-MsgGUID: w9F67n9TTbKem8EAZ9cLEA== X-IronPort-AV: E=McAfee;i="6700,10204,11161"; a="32111087" X-IronPort-AV: E=Sophos;i="6.09,282,1716274800"; d="scan'208";a="32111087" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Aug 2024 23:10:01 -0700 X-CSE-ConnectionGUID: 7AqYu/jlRKKhdBfcZmobKg== X-CSE-MsgGUID: YeMJ6VCiSQ6FfzhenrMUQg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,282,1716274800"; d="scan'208";a="62564020" Received: from unknown (HELO npf-hyd-clx-03..) ([10.145.170.182]) by fmviesa005.fm.intel.com with ESMTP; 11 Aug 2024 23:09:59 -0700 From: Soumyadeep Hore To: bruce.richardson@intel.com, anatoly.burakov@intel.com, aman.deep.singh@intel.com Cc: dev@dpdk.org Subject: [PATCH v1] net/ice: initialize PHC time with current time of day Date: Mon, 12 Aug 2024 05:17:16 +0000 Message-ID: <20240812051716.3763713-1-soumyadeep.hore@intel.com> X-Mailer: git-send-email 2.43.0 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 The PHC main timer for ice pmd enabled drivers should be initialised to current time of day on enabling timesync else it will be initialized to 0 giving wrong timestamps. Signed-off-by: Soumyadeep Hore --- drivers/net/ice/ice_ethdev.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index 304f959b7e..da5a5eb5d6 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -6437,6 +6437,22 @@ ice_dev_udp_tunnel_port_del(struct rte_eth_dev *dev, return ret; } +/** + * ice_ptp_write_init - Set PHC time to provided value + * @hw: Hardware private structure + * + * Set the PHC time to CLOCK_REALTIME + */ +static int ice_ptp_write_init(struct ice_hw *hw) +{ + uint64_t ns; + struct timespec sys_time; + clock_gettime(CLOCK_REALTIME, &sys_time); + ns = rte_timespec_to_ns(&sys_time); + + return ice_ptp_init_time(hw, ns, true); +} + static int ice_timesync_enable(struct rte_eth_dev *dev) { @@ -6466,6 +6482,16 @@ ice_timesync_enable(struct rte_eth_dev *dev) } } + if (!ice_ptp_lock(hw)) { + ice_debug(hw, ICE_DBG_PTP, "Failed to acquire PTP semaphore\n"); + return ICE_ERR_NOT_READY; + } + + ret = ice_ptp_write_init(hw); + ice_ptp_unlock(hw); + if (ret) + PMD_INIT_LOG(ERR, "Failed to set current system time to PHC timer\n"); + /* Initialize cycle counters for system time/RX/TX timestamp */ memset(&ad->systime_tc, 0, sizeof(struct rte_timecounter)); memset(&ad->rx_tstamp_tc, 0, sizeof(struct rte_timecounter)); -- 2.43.0