DPDK patches and discussions
 help / color / mirror / Atom feed
From: Simei Su <simei.su@intel.com>
To: qi.z.zhang@intel.com, qiming.yang@intel.com
Cc: dev@dpdk.org, Simei Su <simei.su@intel.com>, stable@dpdk.org
Subject: [PATCH v2] net/ice: fix missing clock initialization
Date: Fri, 28 Jan 2022 10:11:29 +0800	[thread overview]
Message-ID: <20220128021129.430189-1-simei.su@intel.com> (raw)
In-Reply-To: <20220124051823.32879-1-simei.su@intel.com>

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(+)

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 */
-- 
2.9.5


  reply	other threads:[~2022-01-28  2:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-24  5:18 [PATCH] net/ice: fix incorrect Rx timestamp in Windows PTP Simei Su
2022-01-28  2:11 ` Simei Su [this message]
2022-02-11  6:41   ` [PATCH v3] net/ice: fix missing clock initialization Simei Su

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220128021129.430189-1-simei.su@intel.com \
    --to=simei.su@intel.com \
    --cc=dev@dpdk.org \
    --cc=qi.z.zhang@intel.com \
    --cc=qiming.yang@intel.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).