The current code overloads the path delay, using zero as a special case to
flag whether or not a measurement has been made.  However, when using a
short patch cable, the path delay may well work out to zero.

This patch fixes the issue by using a separate state variable to track
the presence of the path delay information.

Signed-off-by: Richard Cochran <richardcoch...@gmail.com>
---
 clock.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/clock.c b/clock.c
index 3350b3d..b448b8a 100644
--- a/clock.c
+++ b/clock.c
@@ -105,6 +105,7 @@ struct clock {
        tmv_t path_delay;
        tmv_t ingress_ts;
        struct tsproc *tsproc;
+       int have_pd;
        struct freq_estimator fest;
        struct time_status_np status;
        double nrr;
@@ -1289,6 +1290,8 @@ void clock_path_delay(struct clock *c, tmv_t req, tmv_t 
rx)
        if (c->stats.delay)
                stats_add_value(c->stats.delay,
                                tmv_to_nanoseconds(c->path_delay));
+
+       c->have_pd = 1;
 }
 
 void clock_peer_delay(struct clock *c, tmv_t ppd, tmv_t req, tmv_t rx,
@@ -1302,6 +1305,8 @@ void clock_peer_delay(struct clock *c, tmv_t ppd, tmv_t 
req, tmv_t rx,
 
        if (c->stats.delay)
                stats_add_value(c->stats.delay, tmv_to_nanoseconds(ppd));
+
+       c->have_pd = 1;
 }
 
 int clock_slave_only(struct clock *c)
@@ -1361,6 +1366,9 @@ enum servo_state clock_synchronize(struct clock *c, tmv_t 
ingress, tmv_t origin)
        if (tsproc_update_offset(c->tsproc, &c->master_offset, &weight))
                return state;
 
+       if (!c->have_pd)
+               return state;
+
        if (clock_utc_correct(c, ingress))
                return c->servo_state;
 
@@ -1474,6 +1482,7 @@ static void handle_state_decision_event(struct clock *c)
                tsproc_reset(c->tsproc, 1);
                c->ingress_ts = tmv_zero();
                c->path_delay = 0;
+               c->have_pd = 0;
                c->nrr = 1.0;
                fresh_best = 1;
        }
-- 
2.1.4


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to