From: Soumyadeep Hore <soumyadeep.hore@intel.com>
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 [thread overview]
Message-ID: <20240812051716.3763713-1-soumyadeep.hore@intel.com> (raw)
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 <soumyadeep.hore@intel.com>
---
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
reply other threads:[~2024-08-12 6:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240812051716.3763713-1-soumyadeep.hore@intel.com \
--to=soumyadeep.hore@intel.com \
--cc=aman.deep.singh@intel.com \
--cc=anatoly.burakov@intel.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).