In ICE PMD, previously the ready bitmap checking before reading PHY timestamp was not present. This caused incorrect Tx timestamping.
The ready bitmap checking is enabled and PHY timestamp is read once the ready bitmap gives positive value. Fixes: 881169950d80 ("net/ice/base: implement initial PTP support for E830") Cc: sta...@dpdk.org Signed-off-by: Soumyadeep Hore <soumyadeep.h...@intel.com> --- drivers/net/ice/ice_ethdev.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index 7b1bd163a2..2357d6e1da 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -6516,14 +6516,32 @@ ice_timesync_read_tx_timestamp(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); + struct ice_tx_queue *txq; uint8_t lport; - uint64_t ts_ns, ns, tstamp; + uint64_t ts_ns, ns, tstamp, tstamp_ready = 0; + uint64_t start_time, curr_time; const uint64_t mask = 0xFFFFFFFF; int ret; + txq = dev->data->tx_queues[0]; lport = hw->port_info->lport; - ret = ice_read_phy_tstamp(hw, lport, 0, &tstamp); + start_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000); + + while (!(tstamp_ready & BIT_ULL(0))) { + ret = ice_get_phy_tx_tstamp_ready(hw, lport, &tstamp_ready); + if (ret) { + PMD_DRV_LOG(ERR, "Failed to get phy ready for timestamp"); + return -1; + } + curr_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000); + if (curr_time - start_time > 1000) { + PMD_DRV_LOG(ERR, "Timeout to get phy ready for timestamp"); + return -1; + } + } + + ret = ice_read_phy_tstamp(hw, lport, txq->queue_id, &tstamp); if (ret) { PMD_DRV_LOG(ERR, "Failed to read phy timestamp"); return -1; -- 2.43.0