Skip to content

Commit

Permalink
ptp: disable master_utc_offset (#524)
Browse files Browse the repository at this point in the history
master_utc_offset is only for UTC clock, ptp always use raw time

Signed-off-by: Du, Frank <[email protected]>
(cherry picked from commit 5c41a525e1363196d4c67166f9cc08a657c01d6d)
  • Loading branch information
frankdjx committed May 7, 2022
1 parent c64225c commit 19f3e16
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion lib/src/st_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/src/st_ptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 19f3e16

Please sign in to comment.