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 <richardcochran@gmail.com>
master
Richard Cochran 2018-03-18 21:42:09 -07:00
parent eb8507a45a
commit f26ca92f1c
1 changed files with 7 additions and 0 deletions

View File

@ -115,6 +115,7 @@ struct clock {
struct tsproc *tsproc; struct tsproc *tsproc;
struct freq_estimator fest; struct freq_estimator fest;
struct time_status_np status; struct time_status_np status;
double master_local_rr; /* maintained when free_running */
double nrr; double nrr;
struct clock_description desc; struct clock_description desc;
struct clock_stats stats; 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->origin1 = origin;
f->count = 0; f->count = 0;
c->master_local_rr = ratio;
return state; return state;
} }
@ -1063,6 +1066,7 @@ struct clock *clock_create(enum clock_type type, struct config *config,
return NULL; return NULL;
} }
c->initial_delay = dbl_tmv(config_get_int(config, NULL, "initial_delay")); c->initial_delay = dbl_tmv(config_get_int(config, NULL, "initial_delay"));
c->master_local_rr = 1.0;
c->nrr = 1.0; c->nrr = 1.0;
c->stats_interval = config_get_int(config, NULL, "summary_interval"); c->stats_interval = config_get_int(config, NULL, "summary_interval");
c->stats.offset = stats_create(); 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) double clock_rate_ratio(struct clock *c)
{ {
if (c->free_running) {
return c->master_local_rr;
}
return servo_rate_ratio(c->servo); return servo_rate_ratio(c->servo);
} }