Signed-off-by: Miroslav Lichvar <mlich...@redhat.com> --- 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 ------------------------------------------------------------------------------ Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel