Current implementation of flag "-a -rr" for phc2sys selects CLOCK_REALTIME for both directions of PTP synchronization. This may be impractical for Network Time Servers which use alternative sources of synchronization, that usually have clock adjusted by ntpd/chrony. For gPTP Grandmaster in Time Servers the most optimal solution would be to use CLOCK_REALTIME to synchronize phc when in Master state and stopping synchronization when in Slave state. This would allow to combine internal Time Server sources (using ntpd/chrony) with phc as Master/Slave.
Implementation of two-way gPTP synchronization requires two phc2sys instances: - one synchronizing CLOCK_REALTIME->phc when in Master (phc2sys -a -rr), - second synchronizing phc->ntpshm when in Slave state (phc2sys -a -r -E ntpshm). The problem is that current implementation of autoconfiguration in gPTP will synchronize phc from CLOCK_REALTIME when in Slave state. To address this issue, the additional (triple) '-r' flag was implemented. When using '-a -rrr' CLOCK_REALTIME will be used as "source only". This is probably better solution than usage of separate program detecting current portState of PTP. Signed-off-by: Jakub Raczynski <j.raczyn...@elpromaelectronics.com> --- phc2sys.8 | 5 ++++- phc2sys.c | 22 ++++++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/phc2sys.8 b/phc2sys.8 index 963df83..3858c22 100644 --- a/phc2sys.8 +++ b/phc2sys.8 @@ -75,7 +75,10 @@ to also synchronize the system clock (CLOCK_REALTIME). By default, the system clock is not considered as a possible time source. If you want the system clock to be eligible to become a time source, specify the .B \-r -option twice. +option twice. Specify +.B \-r +thrice to use CLOCK_REALTIME as source only and do not synchronize it to +other sources. .TP .BI \-f " config" Read configuration from the specified file. No configuration file is read by diff --git a/phc2sys.c b/phc2sys.c index 2c8e905..ab0376a 100644 --- a/phc2sys.c +++ b/phc2sys.c @@ -72,6 +72,7 @@ struct clock { int sysoff_method; int is_utc; int dest_only; + int src_only; int state; int new_state; int sync_offset; @@ -468,12 +469,16 @@ static void reconfigure(struct phc2sys_private *priv) src = rt; rt->state = PS_SLAVE; } else if (rt) { - if (rt->state != PS_MASTER) { + if (rt->state != PS_MASTER && !rt->src_only) { rt->state = PS_MASTER; clock_reinit(priv, rt, rt->state); } LIST_INSERT_HEAD(&priv->dst_clocks, rt, dst_list); pr_info("selecting %s for synchronization", rt->device); + if (rt && rt->src_only && rt->state != PS_MASTER) { + pr_info("clock %s selected as source only, not synchronizing", + rt->device); + } } priv->master = src; pr_info("selecting %s as the master clock", src->device); @@ -895,8 +900,21 @@ static int auto_init_ports(struct phc2sys_private *priv, int add_rt) clock = clock_add(priv, "CLOCK_REALTIME", -1); if (!clock) return -1; - if (add_rt == 1) + switch (add_rt) { + case 1: + default: clock->dest_only = 1; + clock->src_only = 0; + break; + case 2: + clock->dest_only = 0; + clock->src_only = 0; + break; + case 3: + clock->dest_only = 0; + clock->src_only = 1; + break; + } } /* get initial offset */ -- 2.25.1 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel