Skip to content

Commit 3b009ca

Browse files
desou-devbruce-richardson
authored andcommitted
net/ice: initialize PHC time with current time
The PHC main timer for ice pmd enabled drivers should be initialised to current time on enabling timesync. Otherwise, it will be initialized to 0 giving wrong timestamps. Signed-off-by: Soumyadeep Hore <[email protected]> Acked-by: Aman Singh <[email protected]>
1 parent b8cdc85 commit 3b009ca

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

drivers/net/ice/ice_ethdev.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6437,6 +6437,22 @@ ice_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
64376437
return ret;
64386438
}
64396439

6440+
/**
6441+
* ice_ptp_write_init - Set PHC time to provided value
6442+
* @hw: Hardware private structure
6443+
*
6444+
* Set the PHC time to CLOCK_REALTIME
6445+
*/
6446+
static int ice_ptp_write_init(struct ice_hw *hw)
6447+
{
6448+
uint64_t ns;
6449+
struct timespec sys_time;
6450+
clock_gettime(CLOCK_REALTIME, &sys_time);
6451+
ns = rte_timespec_to_ns(&sys_time);
6452+
6453+
return ice_ptp_init_time(hw, ns, true);
6454+
}
6455+
64406456
static int
64416457
ice_timesync_enable(struct rte_eth_dev *dev)
64426458
{
@@ -6466,6 +6482,16 @@ ice_timesync_enable(struct rte_eth_dev *dev)
64666482
}
64676483
}
64686484

6485+
if (!ice_ptp_lock(hw)) {
6486+
ice_debug(hw, ICE_DBG_PTP, "Failed to acquire PTP semaphore\n");
6487+
return ICE_ERR_NOT_READY;
6488+
}
6489+
6490+
ret = ice_ptp_write_init(hw);
6491+
ice_ptp_unlock(hw);
6492+
if (ret)
6493+
PMD_INIT_LOG(ERR, "Failed to set current system time to PHC timer\n");
6494+
64696495
/* Initialize cycle counters for system time/RX/TX timestamp */
64706496
memset(&ad->systime_tc, 0, sizeof(struct rte_timecounter));
64716497
memset(&ad->rx_tstamp_tc, 0, sizeof(struct rte_timecounter));

0 commit comments

Comments
 (0)