Commit 0443dc94 authored by Alessandro Rubini's avatar Alessandro Rubini

st_com_execute_slave: don't check delay_req any more

The function is called by several states, but only state-slave
is checking the delay request timeout. Thus, this commit removes
the associated lines from the common function and moves them back
to state-slave, the only state that issues delay_request frames.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 63eb7add
...@@ -44,7 +44,7 @@ int wr_present(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -44,7 +44,7 @@ int wr_present(struct pp_instance *ppi, unsigned char *pkt, int plen)
out: out:
if (e == 0) if (e == 0)
st_com_execute_slave(ppi, 0); st_com_execute_slave(ppi);
else else
ppi->next_state = PPS_FAULTY; ppi->next_state = PPS_FAULTY;
......
...@@ -34,7 +34,7 @@ void pp_prepare_pointers(struct pp_instance *ppi) ...@@ -34,7 +34,7 @@ void pp_prepare_pointers(struct pp_instance *ppi)
} }
/* Called by listening, passive, slave, uncalibrated */ /* Called by listening, passive, slave, uncalibrated */
int st_com_execute_slave(struct pp_instance *ppi, int check_delayreq) int st_com_execute_slave(struct pp_instance *ppi)
{ {
int ret = 0; int ret = 0;
...@@ -57,21 +57,7 @@ int st_com_execute_slave(struct pp_instance *ppi, int check_delayreq) ...@@ -57,21 +57,7 @@ int st_com_execute_slave(struct pp_instance *ppi, int check_delayreq)
pp_timeout_restart_annrec(ppi); pp_timeout_restart_annrec(ppi);
} }
} }
return 0;
if (!check_delayreq)
return 0;
if (pp_timeout_z(ppi, PP_TO_DELAYREQ)) {
ret = msg_issue_delay_req(ppi);
ppi->delay_req_send_time = ppi->last_snt_time;
/* Add latency */
add_TimeInternal(&ppi->delay_req_send_time,
&ppi->delay_req_send_time,
&OPTS(ppi)->outbound_latency);
}
return ret;
} }
/* Called by listening, master, passive, slave */ /* Called by listening, master, passive, slave */
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
/* Contains all functions common to more than one state */ /* Contains all functions common to more than one state */
/* returns -1 in case of error, see below */ /* returns -1 in case of error, see below */
int st_com_execute_slave(struct pp_instance *ppi, int check_delayreq); int st_com_execute_slave(struct pp_instance *ppi);
void st_com_restart_annrec_timer(struct pp_instance *ppi); void st_com_restart_annrec_timer(struct pp_instance *ppi);
......
...@@ -44,7 +44,7 @@ int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -44,7 +44,7 @@ int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen)
out: out:
if (e == 0) if (e == 0)
e = st_com_execute_slave(ppi, 0); e = st_com_execute_slave(ppi);
if (e != 0) if (e != 0)
ppi->next_state = PPS_FAULTY; ppi->next_state = PPS_FAULTY;
......
...@@ -40,7 +40,7 @@ int pp_passive(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -40,7 +40,7 @@ int pp_passive(struct pp_instance *ppi, unsigned char *pkt, int plen)
no_incoming_msg: no_incoming_msg:
if (e == 0) if (e == 0)
e = st_com_execute_slave(ppi, 0); e = st_com_execute_slave(ppi);
if (e != 0) if (e != 0)
ppi->next_state = PPS_FAULTY; ppi->next_state = PPS_FAULTY;
......
...@@ -112,10 +112,23 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -112,10 +112,23 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
out: out:
if (e == 0) if (e == 0)
e = st_com_execute_slave(ppi, 1); e = st_com_execute_slave(ppi);
if (e != 0) if (pp_timeout_z(ppi, PP_TO_DELAYREQ)) {
e = msg_issue_delay_req(ppi);
ppi->delay_req_send_time = ppi->last_snt_time;
/* Add latency */
add_TimeInternal(&ppi->delay_req_send_time,
&ppi->delay_req_send_time,
&OPTS(ppi)->outbound_latency);
}
if (e) {
ppi->next_state = PPS_FAULTY; ppi->next_state = PPS_FAULTY;
return 0;
}
state_updated: state_updated:
......
...@@ -34,7 +34,7 @@ int pp_uncalibrated(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -34,7 +34,7 @@ int pp_uncalibrated(struct pp_instance *ppi, unsigned char *pkt, int plen)
no_incoming_msg: no_incoming_msg:
if (e == 0) if (e == 0)
e = st_com_execute_slave(ppi, 0); e = st_com_execute_slave(ppi);
if (e != 0) if (e != 0)
ppi->next_state = PPS_FAULTY; ppi->next_state = PPS_FAULTY;
......
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