Commit 223459dd authored by Alessandro Rubini's avatar Alessandro Rubini

pdelay: mark stamps as invalid after use

The code is checking the sequence number of pdelay-rep and
pdelay-rep-fup, but we may miss the reply and get the f-up.

The result was something like this (first tuple is ok, next is wrong):

   diag-servo-2-wr1: servo:t3 = 1497279009:22584224:0
   diag-servo-2-wr1: servo:t4 = 1497279009:22584574:759
   diag-servo-2-wr1: servo:t5 = 1497279009:23564032:0
   diag-servo-2-wr1: servo:t6 = 1497279009:23564365:547
   diag-servo-2-wr1: ->mdelay = 0:684:306

   diag-servo-2-wr1: servo:t3 = 1497279009:663586672:0
   diag-servo-2-wr1: servo:t4 = 1497279009:22584574:759
   diag-servo-2-wr1: servo:t5 = 1497279009:683142000:0
   diag-servo-2-wr1: servo:t6 = 1497279009:23564365:547
   diag-servo-2-wr1: ->mdelay = -1:-300579732:306

Here, t4 and t6 are old. The former is the receipt of the request,
send back to the "slave" in the pdelay-reply payload; the latter is
the receive time of such frame.

We now invalidate t4 and t5 when using the tuple. They are the two
"remote" times, one sent back in the response and the other sent back
in the response-fup.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent dfeb1890
......@@ -139,11 +139,19 @@ static int presp_call_servo(struct pp_instance *ppi)
{
int ret = 0;
if (is_incorrect(&ppi->t4) || is_incorrect(&ppi->t5))
return 0; /* not an error, just no data */
pp_timeout_set(ppi, PP_TO_FAULT);
if (pp_hooks.handle_presp)
ret = pp_hooks.handle_presp(ppi);
else
pp_servo_got_presp(ppi);
/* Avoid re-using the stamps if presp is lost but f-up is recvd */
mark_incorrect(&ppi->t4);
mark_incorrect(&ppi->t5);
return ret;
}
......
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