The announce message from the External source is passed by virtual port for BMCA participation so that it becomes a selection source along with other ports for linuxPTP.
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> v1->v2: - amended commit message --- ts2phc_phc_pps_source.c | 23 +++++++++++++++++++++++ ts2phc_phc_pps_source.h | 2 ++ ts2phc_pps_sink.c | 6 +++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/ts2phc_phc_pps_source.c b/ts2phc_phc_pps_source.c index 5f15e8e..0546913 100644 --- a/ts2phc_phc_pps_source.c +++ b/ts2phc_phc_pps_source.c @@ -14,10 +14,12 @@ #include "print.h" #include "ts2phc_phc_pps_source.h" #include "ts2phc_pps_source_private.h" +#include "ts2phc_vport.h" #include "util.h" struct ts2phc_phc_pps_source { struct ts2phc_pps_source pps_source; + struct ts2phc_vport *vport; clockid_t clkid; int channel; int fd; @@ -71,6 +73,9 @@ static void ts2phc_phc_pps_source_destroy(struct ts2phc_pps_source *src) pr_err(PTP_PEROUT_REQUEST_FAILED); } posix_clock_close(m->clkid); + if (m->vport) { + free(m->vport); + } free(m); } @@ -82,11 +87,21 @@ static int ts2phc_phc_pps_source_getppstime(struct ts2phc_pps_source *src, return clock_gettime(s->clkid, ts); } +int ts2phc_phc_pps_source_vport_transmit(struct ts2phc_pps_source *src, + struct timespec *ts) +{ + struct ts2phc_phc_pps_source *s = + container_of(src, struct ts2phc_phc_pps_source, pps_source); + return ts2phc_vport_tx_announce(s->vport); +} + + struct ts2phc_pps_source *ts2phc_phc_pps_source_create(struct config *cfg, const char *dev) { struct ts2phc_phc_pps_source *s; int junk; + const char *iface_name; s = calloc(1, sizeof(*s)); if (!s) { @@ -95,6 +110,14 @@ struct ts2phc_pps_source *ts2phc_phc_pps_source_create(struct config *cfg, s->pps_source.destroy = ts2phc_phc_pps_source_destroy; s->pps_source.getppstime = ts2phc_phc_pps_source_getppstime; + iface_name = config_get_string(cfg, NULL, "vport_address"); + if (iface_name && iface_name[0]) { + s->vport = ts2phc_vport_create(cfg); + if (!s->vport) { + pr_warning("Error in vport creation: %s\n", iface_name); + } + } + s->clkid = posix_clock_open(dev, &junk); if (s->clkid == CLOCK_INVALID) { free(s); diff --git a/ts2phc_phc_pps_source.h b/ts2phc_phc_pps_source.h index c9ab54e..01c1d8d 100644 --- a/ts2phc_phc_pps_source.h +++ b/ts2phc_phc_pps_source.h @@ -11,4 +11,6 @@ struct ts2phc_pps_source *ts2phc_phc_pps_source_create(struct config *cfg, const char *dev); +int ts2phc_phc_pps_source_vport_transmit(struct ts2phc_pps_source *src, + struct timespec *ts); #endif diff --git a/ts2phc_pps_sink.c b/ts2phc_pps_sink.c index 91bd7c9..6e6acc0 100644 --- a/ts2phc_pps_sink.c +++ b/ts2phc_pps_sink.c @@ -23,6 +23,7 @@ #include "servo.h" #include "ts2phc_pps_sink.h" #include "ts2phc_pps_source.h" +#include "ts2phc_phc_pps_source.h" #include "util.h" #define NS_PER_SEC 1000000000LL @@ -426,7 +427,10 @@ int ts2phc_pps_sink_poll(struct ts2phc_pps_source *src) err = ts2phc_pps_source_getppstime(src, &source_ts.ts); source_ts.valid = err ? false : true; - + if (source_ts.valid) { + /* Send Announce and Sync Message on Virtual Port */ + ts2phc_phc_pps_source_vport_transmit(src, &source_ts.ts); + } for (i = 0; i < ts2phc_n_sinks; i++) { if (polling_array.pfd[i].revents & (POLLIN|POLLPRI)) { ts2phc_pps_sink_event(polling_array.sink[i], source_ts); -- 2.25.1 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel