From 36951376198a395cc6db0ee3d85037fca2dad9ea Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Thu, 16 May 2013 16:31:45 +0200 Subject: [PATCH] Let the clock servo know the expected sync interval. This patch adds a new servo method to let the algorithm know about the master clock's reported sync message interval. This information can be used by the servo to adapt its synchronization parameters. Signed-off-by: Richard Cochran --- clock.c | 2 ++ pi.c | 5 +++++ servo.c | 5 +++++ servo.h | 7 +++++++ servo_private.h | 2 ++ 5 files changed, 21 insertions(+) diff --git a/clock.c b/clock.c index f59e753..b097911 100644 --- a/clock.c +++ b/clock.c @@ -1127,6 +1127,8 @@ void clock_sync_interval(struct clock *c, int n) pr_warning("summary_interval is too long"); } c->stats.max_count = (1 << shift); + + servo_sync_interval(c->servo, n < 0 ? 1.0 / (1 << -n) : 1 << n); } struct timePropertiesDS *clock_time_properties(struct clock *c) diff --git a/pi.c b/pi.c index 89080c4..d42bf0b 100644 --- a/pi.c +++ b/pi.c @@ -132,6 +132,10 @@ static double pi_sample(struct servo *servo, return ppb; } +static void pi_sync_interval(struct servo *servo, double interval) +{ +} + struct servo *pi_servo_create(int fadj, int max_ppb, int sw_ts) { struct pi_servo *s; @@ -142,6 +146,7 @@ struct servo *pi_servo_create(int fadj, int max_ppb, int sw_ts) s->servo.destroy = pi_destroy; s->servo.sample = pi_sample; + s->servo.sync_interval = pi_sync_interval; s->drift = fadj; s->maxppb = max_ppb; s->first_update = 1; diff --git a/servo.c b/servo.c index a312ad1..45c5832 100644 --- a/servo.c +++ b/servo.c @@ -41,3 +41,8 @@ double servo_sample(struct servo *servo, { return servo->sample(servo, offset, local_ts, state); } + +void servo_sync_interval(struct servo *servo, double interval) +{ + servo->sync_interval(servo, interval); +} diff --git a/servo.h b/servo.h index 4d4a8e7..052740e 100644 --- a/servo.h +++ b/servo.h @@ -86,4 +86,11 @@ double servo_sample(struct servo *servo, uint64_t local_ts, enum servo_state *state); +/** + * Inform a clock servo about the master's sync interval. + * @param servo Pointer to a servo obtained via @ref servo_create(). + * @param interval The sync interval in seconds. + */ +void servo_sync_interval(struct servo *servo, double interval); + #endif diff --git a/servo_private.h b/servo_private.h index f9c151f..98c7db2 100644 --- a/servo_private.h +++ b/servo_private.h @@ -28,6 +28,8 @@ struct servo { double (*sample)(struct servo *servo, int64_t offset, uint64_t local_ts, enum servo_state *state); + + void (*sync_interval)(struct servo *servo, double interval); }; #endif