Commit da552755 authored by Aurelio Colosimo's avatar Aurelio Colosimo

servo.c: restored behaviour as it was in ptpd

This patch is temporary and is thought only to guarantee the correct
convergence of the algorithm. Some of the latest changes in servo.c, about
how time is adjusted and how the max value for observed drift is set,
made it unstable. With this patch, the behaviour is restored to the same as
ptpd, though it still needs to be reviewed to increase performance, readability
and easier maintainability.
Signed-off-by: Aurelio Colosimo's avatarAurelio Colosimo <aurelio@aureliocolosimo.it>
parent f760717f
......@@ -52,9 +52,13 @@ int posix_time_adjust(struct pp_instance *ppi, long offset_ns, long freq_ppm)
if (freq_ppm < -PP_ADJ_FREQ_MAX)
freq_ppm = -PP_ADJ_FREQ_MAX;
t.offset = offset_ns / 1000;
t.freq = freq_ppm; /* was: "adj * ((1 << 16) / 1000)" */
t.modes = MOD_FREQUENCY | MOD_OFFSET;
t.freq = freq_ppm * ((1 << 16) / 1000);
t.modes = MOD_FREQUENCY;
if (offset_ns) {
t.offset = offset_ns / 1000;
t.modes |= MOD_OFFSET;
}
ret = adjtimex(&t);
pp_diag(ppi, time, 1, "%s: %li %li\n", __func__, offset_ns, freq_ppm);
......
......@@ -145,12 +145,12 @@ struct pp_time_operations {
unsigned long (*calc_timeout)(struct pp_instance *ppi, int millisec);
};
/* IF the configuration prevents jumps, this is the max jump (0.5ms) */
/* FIXME this define is no more used; check whether it should be
* introduced again */
#define PP_ADJ_NS_MAX (500*1000)
/* In geeneral, we can't adjust the rate by more than 200ppm */
#define PP_ADJ_FREQ_MAX (200 << 16)
/* FIXME Restored to value of ptpd. What does this stand for, exactly? */
#define PP_ADJ_FREQ_MAX 512000
/*
* Timeouts. I renamed from "timer" to "timeout" to avoid
......
......@@ -195,8 +195,8 @@ static void __pp_update_clock(struct pp_instance *ppi)
pp_init_clock(ppi);
} else {
adj = DSCUR(ppi)->offsetFromMaster.nanoseconds
> 0 ? PP_ADJ_NS_MAX:-PP_ADJ_NS_MAX;
ppi->t_ops->adjust(ppi, -adj, 0);
> 0 ? PP_ADJ_FREQ_MAX:-PP_ADJ_FREQ_MAX;
ppi->t_ops->adjust(ppi, 0, -adj);
}
}
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment