If synchronizing a PHC to the system clock, use one of the PTP_SYS_OFFSET ioctls (if supported) to measure the offset between the two clocks. Negate the offset and switch the timestamp before passing them to the servo.
This makes the synchronization between PHC and system clock symmetric. Signed-off-by: Miroslav Lichvar <mlich...@redhat.com> --- phc2sys.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/phc2sys.c b/phc2sys.c index 2cd477a..b8f1ea0 100644 --- a/phc2sys.c +++ b/phc2sys.c @@ -790,6 +790,16 @@ static int do_loop(struct node *node, int subscriptions) node->phc_readings, &offset, &ts, &delay) < 0) return -1; + } else if (node->master->clkid == CLOCK_REALTIME && + clock->sysoff_method >= 0) { + /* use reversed sysoff */ + if (sysoff_measure(CLOCKID_TO_FD(clock->clkid), + clock->sysoff_method, + node->phc_readings, + &offset, &ts, &delay) < 0) + return -1; + ts += offset; + offset = -offset; } else { /* use phc */ if (!read_phc(node->master->clkid, clock->clkid, -- 2.17.2 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel