[v2] net/ice: fix missing clock initialization

Message ID 20220128021129.430189-1-simei.su@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers
Series [v2] net/ice: fix missing clock initialization |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-compile-testing fail Testing issues
ci/iol-abi-testing warning Testing issues
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS

Commit Message

Simei Su Jan. 28, 2022, 2:11 a.m. UTC
  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")
Cc: stable@dpdk.org

Signed-off-by: Simei Su <simei.su@intel.com>
---
v2:
* Rename commit title.

 drivers/net/ice/ice_ethdev.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
  

Patch

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index d01acb8..dbf822e 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -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 */