[PATCH v2 2/3] net/i40e: initialize PTP to system time

Anatoly Burakov anatoly.burakov at intel.com
Mon Nov 25 12:33:25 CET 2024


Currently, i40e driver initializes PTP timestamp to 0. This is different
from what kernel driver does (which initializes it to system time).

Align the DPDK driver to kernel driver by setting PTP timestamp to system
time when enabling PTP.

Note that i40e driver always uses zero-based timestamps for PTP, so we
would only ever update the internal timecounter and not the actual NIC
registers.

Signed-off-by: Anatoly Burakov <anatoly.burakov at intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index ca128c7556..30dcdc68a8 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -10556,6 +10556,9 @@ i40e_timesync_enable(struct rte_eth_dev *dev)
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	uint32_t tsync_ctl_l;
 	uint32_t tsync_ctl_h;
+	struct timespec ts;
+
+	memset(&ts, 0, sizeof(struct timespec));
 
 	/* Stop the timesync system time. */
 	I40E_WRITE_REG(hw, I40E_PRTTSYN_INC_L, 0x0);
@@ -10585,6 +10588,9 @@ i40e_timesync_enable(struct rte_eth_dev *dev)
 	I40E_WRITE_REG(hw, I40E_PRTTSYN_CTL0, tsync_ctl_l);
 	I40E_WRITE_REG(hw, I40E_PRTTSYN_CTL1, tsync_ctl_h);
 
+	/* i40e uses zero-based timestamping so only adjust timecounter */
+	i40e_timesync_write_time(dev, &ts);
+
 	return 0;
 }
 
-- 
2.43.5



More information about the dev mailing list