From f26ca92f1c1b337db43dd5bd525d9db1931ace3b Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Sun, 18 Mar 2018 21:42:09 -0700 Subject: [PATCH] clock: Maintain the master/local rate ratio when free running. When using long chains of transparent clocks, the recommended practice is to measure the rate ratio without adjusting the local clock. Then the residence times should be corrected to reflect the master's frequency. This patch expands the clock_rate_ratio() method to provide the estimated ratio when the clock is free running. Signed-off-by: Richard Cochran --- clock.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/clock.c b/clock.c index 1405cb4..9ffb43e 100644 --- a/clock.c +++ b/clock.c @@ -115,6 +115,7 @@ struct clock { struct tsproc *tsproc; struct freq_estimator fest; struct time_status_np status; + double master_local_rr; /* maintained when free_running */ double nrr; struct clock_description desc; struct clock_stats stats; @@ -612,6 +613,8 @@ static enum servo_state clock_no_adjust(struct clock *c, tmv_t ingress, f->origin1 = origin; f->count = 0; + c->master_local_rr = ratio; + return state; } @@ -1063,6 +1066,7 @@ struct clock *clock_create(enum clock_type type, struct config *config, return NULL; } c->initial_delay = dbl_tmv(config_get_int(config, NULL, "initial_delay")); + c->master_local_rr = 1.0; c->nrr = 1.0; c->stats_interval = config_get_int(config, NULL, "summary_interval"); c->stats.offset = stats_create(); @@ -1786,5 +1790,8 @@ void clock_check_ts(struct clock *c, uint64_t ts) double clock_rate_ratio(struct clock *c) { + if (c->free_running) { + return c->master_local_rr; + } return servo_rate_ratio(c->servo); }