[Linuxptp-devel] [PATCH RFC 2/6] clock: split out calculation of sample delay.
PTP IEEE 1588 stack for Linux
Brought to you by:
rcochran
From: Miroslav L. <mli...@re...> - 2015-02-13 12:56:29
|
Signed-off-by: Miroslav Lichvar <mli...@re...> --- clock.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/clock.c b/clock.c index 9bc0352..d42d604 100644 --- a/clock.c +++ b/clock.c @@ -1292,19 +1292,11 @@ int clock_poll(struct clock *c) return 0; } -void clock_path_delay(struct clock *c, struct timespec req, struct timestamp rx, - Integer64 correction) +static tmv_t clock_get_sample_delay(struct clock *c) { tmv_t c1, c2, c3, pd, t1, t2, t3, t4; double rr; - c->t3 = timespec_to_tmv(req); - c->t4 = timestamp_to_tmv(rx); - c->c3 = correction_to_tmv(correction); - - if (tmv_is_zero(c->t1)) - return; - c1 = c->c1; c2 = c->c2; c3 = c->c3; @@ -1315,9 +1307,9 @@ void clock_path_delay(struct clock *c, struct timespec req, struct timestamp rx, rr = clock_rate_ratio(c); /* - * c->path_delay = (t2 - t3) * rr + (t4 - t1); - * c->path_delay -= c_sync + c_fup + c_delay_resp; - * c->path_delay /= 2.0; + * pd = (t2 - t3) * rr + (t4 - t1); + * pd -= c_sync + c_fup + c_delay_resp; + * pd /= 2.0; */ pd = tmv_sub(t2, t3); @@ -1338,6 +1330,23 @@ void clock_path_delay(struct clock *c, struct timespec req, struct timestamp rx, pr_debug("c3 %10" PRId64, c3); } + return pd; +} + +void clock_path_delay(struct clock *c, struct timespec req, struct timestamp rx, + Integer64 correction) +{ + tmv_t pd; + + c->t3 = timespec_to_tmv(req); + c->t4 = timestamp_to_tmv(rx); + c->c3 = correction_to_tmv(correction); + + if (tmv_is_zero(c->t1)) + return; + + pd = clock_get_sample_delay(c); + c->path_delay = filter_sample(c->delay_filter, pd); c->cur.meanPathDelay = tmv_to_TimeInterval(c->path_delay); -- 2.1.0 |