Skip to contentSkip to conversation

net/ice: fix incorrect Rx timestamp in Windows PTP

PATCH New Simei Su 1 participant 3 messages Jan 24, 2022 – Feb 11, 2022 Network drivers

lore
Share & tools
lore

Simei Su

author
#0 lore raw

PATCH 1/1 net/ice: fix incorrect Rx timestamp in Windows PTP

Rx PHY timer init value is not same as primary timer init value when power up which will lead Rx timestamp always have big gap compared with PTP timestamp. This patch adds PHC init time in initializing PTP hardware clock.

Fixes 646dcbe6c701 ("net/ice: support IEEE 1588 PTP")
---
 drivers/net/ice/ice_ethdev.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/net/ice/ice_ethdev.c +11 -0
index 13a7a97..d57355d 100644
@@ -5501,6 +5501,8 @@ ice_timesync_enable(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);
+	uint64_t start_time;
+	struct timespec system_time;
 	int ret;
 
 	if (dev->data->dev_started && !(dev->data->dev_conf.rxmode.offloads &
@@ -5522,6 +5524,15 @@ ice_timesync_enable(struct rte_eth_dev *dev)
 				"Failed to write PHC increment time value");
 			return -1;
 		}
+
+		clock_gettime(CLOCK_MONOTONIC, &system_time);
+		start_time = system_time.tv_sec * NSEC_PER_SEC +
+			     system_time.tv_nsec;
+		ret = ice_ptp_init_time(hw, start_time);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "Failed to write PHC initial time");
+			return -1;
+		}
 	}
 
 	/* Initialize cycle counters for system time/RX/TX timestamp */
Signature · 1 line
2.9.5
author
#1 lore raw

PATCH v2 1/1 net/ice: fix missing clock initialization

Rx PHY timer init value is not same as primary timer init value when power up which will lead Rx timestamp always have big gap compared with PTP timestamp. This patch adds PHC init time in initializing PTP hardware clock.

Fixes 646dcbe6c701 ("net/ice: support IEEE 1588 PTP")

---
v2:
* Rename commit title.

 drivers/net/ice/ice_ethdev.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/net/ice/ice_ethdev.c +11 -0
index d01acb8..dbf822e 100644
@@ -5661,6 +5661,8 @@ ice_timesync_enable(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);
+	uint64_t start_time;
+	struct timespec system_time;
 	int ret;
 
 	if (dev->data->dev_started && !(dev->data->dev_conf.rxmode.offloads &
@@ -5682,6 +5684,15 @@ ice_timesync_enable(struct rte_eth_dev *dev)
 				"Failed to write PHC increment time value");
 			return -1;
 		}
+
+		clock_gettime(CLOCK_MONOTONIC, &system_time);
+		start_time = system_time.tv_sec * NSEC_PER_SEC +
+			     system_time.tv_nsec;
+		ret = ice_ptp_init_time(hw, start_time);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "Failed to write PHC initial time");
+			return -1;
+		}
 	}
 
 	/* Initialize cycle counters for system time/RX/TX timestamp */
Signature · 1 line
2.9.5
author
#2 lore raw

PATCH v3 1/1 net/ice: fix missing clock initialization

Rx PHY timer init value is not same as primary timer init value when power up which will lead Rx timestamp always have big gap compared with PTP timestamp. This patch adds PHC init time in initializing PTP hardware clock.

Fixes 646dcbe6c701 ("net/ice: support IEEE 1588 PTP")

---
v3:
* Fix use of undeclared identifier 'CLOCK_MONOTONIC'.

v2:
* Rename commit title.

 drivers/net/ice/ice_ethdev.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/ice/ice_ethdev.c +12 -0
index 1a469af..dcecf69 100644
@@ -8,6 +8,7 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/time.h>
 #include <unistd.h>
 
 #include <rte_tailq.h>
@@ -5662,6 +5663,8 @@ ice_timesync_enable(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);
+	uint64_t start_time;
+	struct timespec system_time;
 	int ret;
 
 	if (dev->data->dev_started && !(dev->data->dev_conf.rxmode.offloads &
@@ -5683,6 +5686,15 @@ ice_timesync_enable(struct rte_eth_dev *dev)
 				"Failed to write PHC increment time value");
 			return -1;
 		}
+
+		clock_gettime(CLOCK_MONOTONIC, &system_time);
+		start_time = system_time.tv_sec * NSEC_PER_SEC +
+			     system_time.tv_nsec;
+		ret = ice_ptp_init_time(hw, start_time);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "Failed to write PHC initial time");
+			return -1;
+		}
 	}
 
 	/* Initialize cycle counters for system time/RX/TX timestamp */
Signature · 1 line
2.9.5