From e1ea4ea8109af1d241ac0e0b126fc1309c47600f Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Wed, 5 Nov 2014 22:55:02 +0100 Subject: [PATCH] phc2sys: automatic mode: synchronize all non-slave ports. When running a "jbod" Boundary Clock, as long as we have one slaved port, we always want the clocks on the other ports to be synchronized, regardless of their port state. Signed-off-by: Richard Cochran Acked-by: Jiri Benc --- phc2sys.c | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/phc2sys.c b/phc2sys.c index 67d8a58..9afc14e 100644 --- a/phc2sys.c +++ b/phc2sys.c @@ -313,14 +313,23 @@ static void reconfigure(struct node *node) c->new_state = 0; } - if (c->state == PS_SLAVE) { - src = c; - src_cnt++; - } else if (c->state == PS_UNCALIBRATED) { - src_cnt++; - } else if (c->state == PS_MASTER) { + switch (c->state) { + case PS_FAULTY: + case PS_DISABLED: + case PS_LISTENING: + case PS_PRE_MASTER: + case PS_MASTER: + case PS_PASSIVE: pr_info("selecting %s for synchronization", c->device); dst_cnt++; + break; + case PS_UNCALIBRATED: + src_cnt++; + break; + case PS_SLAVE: + src = c; + src_cnt++; + break; } } if (src_cnt > 1) { @@ -562,6 +571,23 @@ static int do_pps_loop(struct node *node, struct clock *clock, int fd) return 0; } +static int update_needed(struct clock *c) +{ + switch (c->state) { + case PS_FAULTY: + case PS_DISABLED: + case PS_LISTENING: + case PS_PRE_MASTER: + case PS_MASTER: + case PS_PASSIVE: + return 1; + case PS_UNCALIBRATED: + case PS_SLAVE: + break; + } + return 0; +} + static int do_loop(struct node *node, int subscriptions) { struct timespec interval; @@ -593,7 +619,7 @@ static int do_loop(struct node *node, int subscriptions) continue; LIST_FOREACH(clock, &node->clocks, list) { - if (clock->state != PS_MASTER) + if (!update_needed(clock)) continue; if (clock->clkid == CLOCK_REALTIME &&