On Wed, 12 Oct 2022 at 13:48, Jakub Raczynski < j.raczyn...@elpromaelectronics.com> wrote:
> Current implementation of flag "-a -rr" for phc2sys selects CLOCK_REALTIME > for > both directions of PTP synchronization. This may be impractical for Network > Not really sure what you are talking about, it can be used to "synchro‐ nize the system clock to a PTP hardware clock (PHC)". Which means it updated the PHC and only read the CLOCK_REALTIME. Why do you need to "protect" the CLOCK_REALTIME further? > 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 > What do you mean by "gPTP"? Do you mean Generalized Precision Time Protocol (gPTP, IEEE 8201.AS)? There is a project that uses the gPTP name: https://github.com/Avnu/gptp > 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). > Looks like a great idea, why is it related to "double" read-only of the system clock? Seems you want a flag that toggle the phc2sys based on the ptp4l state, whether it is source (master) or it is a client (slave). I think that a condition flag like that is better than using a 3 x 'r', which is quite confusing. I think something like: 1. Normal mode, Sys clock => PHC or PHC => Sys clock 2. PHC only, Sys clock => PHC if ptp4l is master (source) 3. both, Sys clock => PHC if ptp4l is source (maste) or PHC => Sys clock if ptp4l is client (slave) > The problem is that current implementation of autoconfiguration in gPTP > will > synchronize phc from CLOCK_REALTIME when in Slave state. > Then fix gPTP. > > 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. > I do not understand how this solves the problem. As phc2sys does communicate with ptp4l, it can probe the portState and you do not need an additional program for that. Although in most cases we want to make the decision, who is the master/grandmaster of our PTP domain, As PTP does work with "priorities", it means that in practice, any PTP entity with a higher value may become the master. So a feature like that in phc2sys does make sense :-) Erez > > 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 >
_______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel