DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v1] net/ice: initialize PHC time with current time of day
@ 2024-08-12  5:17 Soumyadeep Hore
  2024-09-30 14:55 ` Singh, Aman Deep
  0 siblings, 1 reply; 3+ messages in thread
From: Soumyadeep Hore @ 2024-08-12  5:17 UTC (permalink / raw)
  To: bruce.richardson, anatoly.burakov, aman.deep.singh; +Cc: dev

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] net/ice: initialize PHC time with current time of day
  2024-08-12  5:17 [PATCH v1] net/ice: initialize PHC time with current time of day Soumyadeep Hore
@ 2024-09-30 14:55 ` Singh, Aman Deep
  2024-10-01 13:31   ` Bruce Richardson
  0 siblings, 1 reply; 3+ messages in thread
From: Singh, Aman Deep @ 2024-09-30 14:55 UTC (permalink / raw)
  To: Soumyadeep Hore, bruce.richardson, anatoly.burakov; +Cc: dev

[-- Attachment #1: Type: text/plain, Size: 341 bytes --]


On 12-08-2024 10:47, Soumyadeep Hore wrote:
> 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>

Acked-by: Aman Singh<aman.deep.singh@intel.com>

<snip>

[-- Attachment #2: Type: text/html, Size: 884 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] net/ice: initialize PHC time with current time of day
  2024-09-30 14:55 ` Singh, Aman Deep
@ 2024-10-01 13:31   ` Bruce Richardson
  0 siblings, 0 replies; 3+ messages in thread
From: Bruce Richardson @ 2024-10-01 13:31 UTC (permalink / raw)
  To: Singh, Aman Deep; +Cc: Soumyadeep Hore, anatoly.burakov, dev

On Mon, Sep 30, 2024 at 08:25:44PM +0530, Singh, Aman Deep wrote:
>    On 12-08-2024 10:47, Soumyadeep Hore wrote:
> 
> 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 [1]<soumyadeep.hore@intel.com>
> 
> Acked-by: Aman Singh [2]<aman.deep.singh@intel.com>
> 
Applied to dpdk-next-net-intel

Thanks,
/Bruce

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-10-01 13:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-12  5:17 [PATCH v1] net/ice: initialize PHC time with current time of day Soumyadeep Hore
2024-09-30 14:55 ` Singh, Aman Deep
2024-10-01 13:31   ` Bruce Richardson

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).