Commit 0a8739ed authored by Wesley W. Terpstra's avatar Wesley W. Terpstra Committed by Grzegorz Daniluk

t24: a bug in ptpd_netif_linearize_rx_timestamp masked the ttrans bug

The phase was used backwards. Somehow this cancelled out the systematic
error introduced by the actual bug (wrong phase offset). When both bugs
are fixed the code seems to work every time.
parent 94245412
......@@ -136,7 +136,7 @@ void ptpd_netif_linearize_rx_timestamp(wr_timestamp_t * ts, int32_t dmtd_phase,
// TS counter will appear
ts->raw_phase = dmtd_phase;
phase = clock_period - 1 - dmtd_phase;
phase = dmtd_phase;
// calculate the range within which falling edge timestamp is stable
// (no possible transitions)
......@@ -148,6 +148,8 @@ void ptpd_netif_linearize_rx_timestamp(wr_timestamp_t * ts, int32_t dmtd_phase,
if (trip_hi >= clock_period)
trip_hi -= clock_period;
// pp_printf("linearize: %d %d %d %d -- %d\n", trip_lo, transition_point, trip_hi, ep_get_bitslide(), phase);
if (inside_range(trip_lo, trip_hi, phase)) {
// We are within +- 25% range of transition area of
// rising counter. Take the falling edge counter value as the
......@@ -160,7 +162,7 @@ void ptpd_netif_linearize_rx_timestamp(wr_timestamp_t * ts, int32_t dmtd_phase,
// and eventually increase the counter by 1 to simulate a
// timestamp transition exactly at s->phase_transition
//DMTD phase value
if (inside_range(trip_lo, transition_point, phase))
if (inside_range(transition_point, trip_hi, phase))
ts->nsec += clock_period / 1000;
}
......@@ -168,7 +170,6 @@ void ptpd_netif_linearize_rx_timestamp(wr_timestamp_t * ts, int32_t dmtd_phase,
ts->phase = phase - transition_point - 1;
if (ts->phase < 0)
ts->phase += clock_period;
ts->phase = clock_period - 1 - ts->phase;
}
/* Slow, but we don't care much... */
......
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