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 <richardcochran@gmail.com>
master
Richard Cochran 2013-05-16 16:31:45 +02:00
parent 617a905643
commit 3695137619
5 changed files with 21 additions and 0 deletions

View File

@ -1127,6 +1127,8 @@ void clock_sync_interval(struct clock *c, int n)
pr_warning("summary_interval is too long"); pr_warning("summary_interval is too long");
} }
c->stats.max_count = (1 << shift); 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) struct timePropertiesDS *clock_time_properties(struct clock *c)

5
pi.c
View File

@ -132,6 +132,10 @@ static double pi_sample(struct servo *servo,
return ppb; 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 servo *pi_servo_create(int fadj, int max_ppb, int sw_ts)
{ {
struct pi_servo *s; 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.destroy = pi_destroy;
s->servo.sample = pi_sample; s->servo.sample = pi_sample;
s->servo.sync_interval = pi_sync_interval;
s->drift = fadj; s->drift = fadj;
s->maxppb = max_ppb; s->maxppb = max_ppb;
s->first_update = 1; s->first_update = 1;

View File

@ -41,3 +41,8 @@ double servo_sample(struct servo *servo,
{ {
return servo->sample(servo, offset, local_ts, state); return servo->sample(servo, offset, local_ts, state);
} }
void servo_sync_interval(struct servo *servo, double interval)
{
servo->sync_interval(servo, interval);
}

View File

@ -86,4 +86,11 @@ double servo_sample(struct servo *servo,
uint64_t local_ts, uint64_t local_ts,
enum servo_state *state); 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 #endif

View File

@ -28,6 +28,8 @@ struct servo {
double (*sample)(struct servo *servo, double (*sample)(struct servo *servo,
int64_t offset, uint64_t local_ts, int64_t offset, uint64_t local_ts,
enum servo_state *state); enum servo_state *state);
void (*sync_interval)(struct servo *servo, double interval);
}; };
#endif #endif