From 19f3e16b356d617c27f3706adecc1bb244918d76 Mon Sep 17 00:00:00 2001 From: Frank Du Date: Sat, 7 May 2022 14:07:01 +0800 Subject: [PATCH] ptp: disable master_utc_offset (#524) master_utc_offset is only for UTC clock, ptp always use raw time Signed-off-by: Du, Frank (cherry picked from commit 5c41a525e1363196d4c67166f9cc08a657c01d6d) --- lib/src/st_main.h | 1 - lib/src/st_ptp.c | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/src/st_main.h b/lib/src/st_main.h index c4d461c2e..584151cc9 100644 --- a/lib/src/st_main.h +++ b/lib/src/st_main.h @@ -1404,7 +1404,6 @@ static inline uint64_t st_mbuf_get_hw_time_stamp(struct st_main_impl* impl, uint64_t time_stamp = *RTE_MBUF_DYNFIELD(mbuf, impl->dynfield_offset, rte_mbuf_timestamp_t*); st_ns_to_timespec(time_stamp, &spec); - spec.tv_sec -= ptp->master_utc_offset; time_stamp = st_timespec_to_ns(&spec) + ptp->ptp_delta; return time_stamp; } diff --git a/lib/src/st_ptp.c b/lib/src/st_ptp.c index b2dadb723..17ad2ca1f 100644 --- a/lib/src/st_ptp.c +++ b/lib/src/st_ptp.c @@ -73,7 +73,6 @@ static uint64_t ptp_get_time(struct st_ptp_impl* ptp) { struct timespec spec; ptp_get_time_spec(ptp, &spec); - spec.tv_sec -= ptp->master_utc_offset; return st_timespec_to_ns(&spec); } @@ -436,14 +435,14 @@ static int ptp_parse_sync(struct st_ptp_impl* ptp, struct st_ptp_sync_msg* msg, static int ptp_parse_follow_up(struct st_ptp_impl* ptp, struct st_ptp_follow_up_msg* msg) { if (msg->hdr.sequence_id != ptp->t2_sequence_id) { - dbg("%s(%d), error sequence id %d %d\n", __func__, port, msg->hdr.sequence_id, + dbg("%s(%d), error sequence id %d %d\n", __func__, ptp->port, msg->hdr.sequence_id, ptp->t2_sequence_id); return -EINVAL; } ptp->t1 = ptp_net_tmstamp_to_ns(&msg->precise_origin_timestamp); ptp->t1_domain_number = msg->hdr.domain_number; - dbg("%s(%d), t1 %" PRIu64 ", ptp %" PRIu64 "\n", __func__, port, ptp->t1, + dbg("%s(%d), t1 %" PRIu64 ", ptp %" PRIu64 "\n", __func__, ptp->port, ptp->t1, ptp_get_raw_time(ptp)); #if ST_PTP_USE_TX_TIMER @@ -755,6 +754,7 @@ void st_ptp_stat(struct st_main_impl* impl) { ns = st_get_ptp_time(impl, i); st_ns_to_timespec(ns, &spec); + spec.tv_sec -= ptp->master_utc_offset; /* display with utc offset */ localtime_r(&spec.tv_sec, &t); strftime(date_time, sizeof(date_time), "%Y-%m-%d %H:%M:%S", &t); info("PTP(%d), time %" PRIu64 ", %s\n", i, ns, date_time);