On Tue, 30 Aug 2022 at 13:22, Maciek Machnikowski <mac...@machnikowski.net> wrote:
> On Wed, Aug 24, 2022 at 04:32:21PM +0530, SyncMonk Technologies wrote: > > Adding virtual port support for ts2phc. > > > > Signed-off-by: Greg Armstrong <greg.armstrong...@renesas.com> > > Signed-off-by: Leon Goldin <leon.goldin...@renesas.com> > > Signed-off-by: Vipin Sharma <vipin.sha...@syncmonk.net> > > Signed-off-by: Devasish Dey <devasish....@syncmonk.net> > > --- > > makefile | 6 +- > > ts2phc_vport.c | 282 +++++++++++++++++++++++++++++++++++++++++++++++++ > > ts2phc_vport.h | 28 +++++ > > 3 files changed, 313 insertions(+), 3 deletions(-) > > create mode 100644 ts2phc_vport.c > > create mode 100644 ts2phc_vport.h > > > > +struct ts2phc_vport { > > + struct fdarray fda; > > + struct transport *trp; > > + struct interface *iface; > > + struct ts2phc_vport_message announce; > > + struct ts2phc_vport_message sync; > > + struct { > > + UInteger16 announce; > > + UInteger16 sync; > > + } seqnum; > > + struct PortIdentity portIdentity; > > + Integer16 utcOffset; > > + UInteger8 priority1; > > + struct ClockQuality clockQuality; > > + UInteger8 priority2; > > + struct ClockIdentity clockIdentity; > > + UInteger8 transportSpecific; > > + UInteger8 domainNumber; > > + UInteger8 flags; > > + Integer8 logAnnounceInterval; > > + Integer8 logSyncInterval; > > + Enumeration8 timeSource; > > +}; > > Can we use standard uint8_t and similar here? > The name 'UInteger8' comes from the IEEE standard. So I think for parameters defined in the standard, 'UInteger8' is better. For private/internal and non standard parameters 'uint8_t' is prefered. The type name can be used to emphasize :-) > > > +static int ts2phc_vport_init_announce(struct ts2phc_vport *p, > > + struct address address) > > +{ > > + > > + struct ptp_message *msg; > > + > > + msg = msg_allocate(); > > + if (!msg) { > > + return -1; > > + } > > + > > + msg->hwts.type = TS_ONESTEP; > > + msg->header.tsmt = ANNOUNCE | p->transportSpecific; > > + msg->header.ver = PTP_VERSION; > > + msg->header.messageLength = sizeof(struct announce_msg); > > + msg->header.domainNumber = p->domainNumber; > > + msg->header.sourcePortIdentity = p->portIdentity; > > + msg->header.sequenceId = p->seqnum.announce++; > > + msg->header.control = CTL_OTHER; > > + msg->header.logMessageInterval = p->logAnnounceInterval; > > + msg->header.flagField[1] = p->flags | PTP_TIMESCALE; > > + > > + msg->announce.currentUtcOffset = p->utcOffset; > > + msg->announce.grandmasterPriority1 = p->priority1; > > + msg->announce.grandmasterClockQuality = p->clockQuality; > > + msg->announce.grandmasterPriority2 = p->priority2; > > + msg->announce.grandmasterIdentity = p->clockIdentity; > > + msg->announce.stepsRemoved = 0; > > + msg->announce.timeSource = p->timeSource; > > + msg->address = address; > > + > > + p->announce.msg = msg; > > + > > + return 0; > > +} > > G.8275 defines a locally set Signal fail (SF) bit which is the only way of > keeping > track of the quality of the signal. Without it ts2phc port will be > useless, as it > will always become the best source of time. > > > +struct ts2phc_vport *ts2phc_vport_create(struct config *config) > > +{ > > > + ts2phc_vport->utcOffset = > > + config_get_int(config, NULL, "utc_offset"); > > + ts2phc_vport->transportSpecific = > > + config_get_int(config, NULL, "transportSpecific") << 4; > > + ts2phc_vport->domainNumber = > > + config_get_int(config, NULL, "domainNumber"); > > + > > + ts2phc_vport->logSyncInterval = > > + config_get_int(config, NULL, "logSyncInterval"); > > + ts2phc_vport->logAnnounceInterval = > > + config_get_int(config, NULL, "logAnnounceInterval"); > > + > > + ts2phc_vport->priority1 = > > + config_get_int(config, NULL, "priority1"); > > + ts2phc_vport->priority2 = > > + config_get_int(config, NULL, "priority2"); > > + ts2phc_vport->timeSource = > > + config_get_int(config, NULL, "timeSource"); > > + > > + ts2phc_vport->clockQuality.clockClass = > > + config_get_int(config, NULL, "clockClass"); > > + ts2phc_vport->clockQuality.clockAccuracy = > > + config_get_int(config, NULL, "clockAccuracy"); > > + ts2phc_vport->clockQuality.offsetScaledLogVariance = > > + config_get_int(config, NULL, > "offsetScaledLogVariance"); > > + > > + if (strcmp(config_get_string(config, NULL, "clockIdentity"), > > + "000000.0000.000000") == 0) { > > + pr_warning("vPort clockIdentity 000000.0000.000000"); > > + } else { > > + if (str2cid(config_get_string(config, NULL, > "clockIdentity"), > > + > &ts2phc_vport->clockIdentity)) { > > + pr_err("failed to set clock identity"); > > + return NULL; > > + } > > + } > > + > > This section add a lot of new arguments that are not documented in the man > page > > > +int ts2phc_vport_tx_sync(struct ts2phc_vport *ts2phc_vport, > > + tmv_t t1, tmv_t corr, tmv_t t2) > > +{ > > + struct ptp_message *msg; > > + int err; > > + struct address address; > > + > > + if (!ts2phc_vport_active(ts2phc_vport)) { > > + return 0; > > + } > > + > > + msg = ts2phc_vport->sync.msg; > > + address = msg->address; > > + ts2phc_vport->sync.count++; > > + > > + err = ts2phc_vport_forward(ts2phc_vport, msg); > > + msg_put(msg); > > + ts2phc_vport_init_announce(ts2phc_vport, address); > > init_sync? > > > + return err; > > +} > > Regards > Maciek > > > _______________________________________________ > 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