Commit 31f08f19 authored by Alessandro Rubini's avatar Alessandro Rubini

pdelay: rework and extend prev commit

The previous commit is not enough as a fix.  This may happen:

    - we invalidate stamps after processing them
    - we send request
    - get reply, loose reply-fup
    - send request
    - loose reply, get f-up

So we now invalidate when sending the request. And invalidate t4 alone
as the beautifulness and symmetry of the previous commit is lost

Note: there no need to invalidate stamps in e2e mode, because checking
the sequence number to validate RX frames is enough.  But here all
replies match the sequence number, so the problem is not caught and
stamps from different tuples are mixed.

Example beofre this commit, with trimmed stamps (was 1497283863):

   diag-frames-1-wr1: SENT 54 bytes at 863.333173928 (pdelay_req)
   diag-frames-1-wr1: RECV 54 bytes at 863.334158796 (type 3, pdelay_resp)
   diag-frames-1-wr1: Drop received frame
   diag-frames-1-wr1: SENT 54 bytes at 864.479336104 (pdelay_req)
   diag-frames-1-wr1: Drop received frame
   diag-frames-1-wr1: RECV 54 bytes at 864.481095164 (type a, presp_follow_up)

   diag-servo-2-wr1: servo:t3 = 864:479336104:0
   diag-servo-2-wr1: servo:t4 = 863:333174267:586
   diag-servo-2-wr1: servo:t5 = 864:480295312:0
   diag-servo-2-wr1: servo:t6 = 863:334158796:773
   diag-servo-2-wr1: ->mdelay = -2:-292298352:359
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <>
parent 223459dd
......@@ -139,7 +139,7 @@ static int presp_call_servo(struct pp_instance *ppi)
int ret = 0;
if (is_incorrect(&ppi->t4) || is_incorrect(&ppi->t5))
if (is_incorrect(&ppi->t4))
return 0; /* not an error, just no data */
pp_timeout_set(ppi, PP_TO_FAULT);
......@@ -148,10 +148,6 @@ static int presp_call_servo(struct pp_instance *ppi)
/* Avoid re-using the stamps if presp is lost but f-up is recvd */
return ret;
......@@ -519,6 +519,7 @@ static int msg_issue_pdelay_req(struct pp_instance *ppi)
struct pp_time now;
int len;
mark_incorrect(&ppi->t4); /* see commit message */
ppi->t_ops->get(ppi, &now);
len = msg_pack_pdelay_req(ppi, &now);
return __send_and_log(ppi, len, PP_NP_EVT);
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