Commit 7c62f416 authored by Alessandro Rubini's avatar Alessandro Rubini

protocols: handle PP_SEND_NO_STAMP specially

This is the result of an audit of all send functions. Most are not
affected, because they send on the "general" channel. But when event
messages are sent, an error of SEND_NO_STAMP must not be fatal.
In WR, for example, after a sync the stamping engine reports invalid
stamps for a second.

I chose not to change the return type of the sending function and have
the compiler help me, because my mates are working on peer-delay and I'd
better not make the merge more difficult for us.

Unfortunately, my wrs is still not syncing with this patch, as it remains
stuck in SYNC_NSEC (in the state machine within the WR servo). See
next commit....
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 9e78f4ac
......@@ -82,7 +82,7 @@ static int wr_master_msg(struct pp_instance *ppi, unsigned char *pkt, int plen,
hdr->correctionfield.msb = 0;
hdr->correctionfield.lsb =
phase_to_cf_units(ppi->last_rcv_time.phase);
msg_issue_delay_resp(ppi, time);
msg_issue_delay_resp(ppi, time); /* no error check */
msgtype = PPM_NOTHING_TO_DO;
break;
......
......@@ -56,7 +56,7 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
msgtype = pp_hooks.master_msg(ppi, pkt, plen, msgtype);
if (msgtype < 0) {
e = msgtype;
goto out;
goto out_fault;
}
switch (msgtype) {
......@@ -89,16 +89,28 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
}
out:
if (e == 0) {
switch(e) {
case PP_SEND_OK: /* 0 */
if (DSDEF(ppi)->clockQuality.clockClass == PP_CLASS_SLAVE_ONLY
|| (ppi->role == PPSI_ROLE_SLAVE))
ppi->next_state = PPS_LISTENING;
} else {
ppi->next_state = PPS_FAULTY;
break;
case PP_SEND_ERROR:
goto out_fault;
case PP_SEND_NO_STAMP:
/* nothing, just keep the ball rolling */
e = 0;
break;
}
d1 = pp_ms_to_timeout(ppi, PP_TO_ANN_INTERVAL);
d2 = pp_ms_to_timeout(ppi, PP_TO_SYNC);
ppi->next_delay = d1 < d2 ? d1 : d2;
return 0;
return e;
out_fault:
ppi->next_state = PPS_FAULTY;
ppi->next_delay = 500; /* just a delay to releif the system */
return e;
}
......@@ -128,12 +128,18 @@ out:
&OPTS(ppi)->outbound_latency);
}
if (e) {
switch(e) {
case PP_SEND_OK: /* 0 */
break;
case PP_SEND_ERROR:
ppi->next_state = PPS_FAULTY;
return 0;
break;
case PP_SEND_NO_STAMP:
/* nothing, just keep the ball rolling */
e = 0;
break;
}
/* Leaving this state */
if (ppi->next_state != ppi->state) {
pp_timeout_clr(ppi, PP_TO_ANN_RECEIPT);
pp_timeout_clr(ppi, PP_TO_DELAYREQ);
......@@ -144,5 +150,5 @@ out:
if (ppi->timeouts[PP_TO_DELAYREQ])
d2 = pp_ms_to_timeout(ppi, PP_TO_DELAYREQ);
ppi->next_delay = d1 < d2 ? d1 : d2;
return 0;
return e;
}
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