Commit 65d34ee0 authored by Maciej Lipinski's avatar Maciej Lipinski

WIP: trying to make P2P exchange initiated by port in Master state - complies…

WIP: trying to make P2P exchange initiated by port in Master state - complies but hangs... had to stop working on this for the time being
parent a79f77e8
......@@ -126,7 +126,7 @@ static int wr_master_msg(struct pp_instance *ppi, unsigned char *pkt, int plen,
static int wr_new_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
{
wr_servo_init(ppi);
// wr_servo_init(ppi);
return 0;
}
......@@ -256,10 +256,10 @@ static int wr_handle_presp(struct pp_instance *ppi)
/*
* pps always on if offset less than 1 second,
* until ve have a configurable threshold */
if (ofm->seconds)
wrp->ops->enable_timing_output(ppi, 0);
else
wrp->ops->enable_timing_output(ppi, 1);
// if (ofm->seconds)
// wrp->ops->enable_timing_output(ppi, 0);
// else
// wrp->ops->enable_timing_output(ppi, 1);
return 0;
}
......
......@@ -34,6 +34,11 @@ int wr_link_on(struct pp_instance *ppi, unsigned char *pkt, int plen)
if (wrp->wrMode == WR_SLAVE)
ppi->next_state = PPS_SLAVE;
else
{
ppi->next_state = PPS_MASTER;
wr_servo_init(ppi);
pp_diag(ppi, ext, 1,"servo on for wr master \n");
}
return 0;
}
......@@ -12,13 +12,17 @@
int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
{
TimeInternal *time_snt;
int msgtype, d1, d2;
int msgtype, d1, d2, d3;
MsgHeader *hdr = &ppi->received_ptp_header;
MsgPDelayRespFollowUp respFllw;
int e = 0; /* error var, to check errors in msg handling */
if (ppi->is_new_state) {
pp_timeout_rand(ppi, PP_TO_SYNC, DSPOR(ppi)->logSyncInterval);
pp_timeout_rand(ppi, PP_TO_ANN_INTERVAL,
DSPOR(ppi)->logAnnounceInterval);
pp_timeout_rand(ppi, PP_TO_PDELAYREQ,
DSPOR(ppi)->logMinPDelayReqInterval);
/* Send an announce immediately, when becomes master */
if ((e = msg_issue_announce(ppi)) < 0)
......@@ -48,6 +52,17 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
DSPOR(ppi)->logAnnounceInterval);
}
if (pp_timeout_z(ppi, PP_TO_PDELAYREQ)) {
if((e = msg_issue_pdelay_req(ppi) < 0))
goto out;
ppi->t3 = ppi->last_snt_time;
/* Restart the timeout for next time */
pp_timeout_rand(ppi, PP_TO_PDELAYREQ,
DSPOR(ppi)->logMinPDelayReqInterval);
}
if (plen == 0)
goto out;
......@@ -84,11 +99,50 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
break;
case PPM_PDELAY_REQ:
msg_copy_header(&ppi->pdelay_req_hdr,
&ppi->received_ptp_header);
msg_issue_pdelay_resp(ppi, &ppi->last_rcv_time);
msg_issue_pdelay_resp_followup(ppi, &ppi->last_snt_time);
e = (plen < PP_PDELAY_RESP_LENGTH);
if (e)
break;
if (pp_hooks.handle_preq)
e = pp_hooks.handle_preq(ppi);
else
e = st_com_peer_handle_preq(ppi, pkt, plen);
if (e)
goto out;
break;
case PPM_PDELAY_RESP_FOLLOW_UP:
e = (plen < PP_PDELAY_RESP_FOLLOW_UP_LENGTH);
if (e)
break;
msg_unpack_pdelay_resp_follow_up(pkt, &respFllw);
if ((memcmp(&DSPOR(ppi)->portIdentity.clockIdentity,
&respFllw.requestingPortIdentity.clockIdentity,
PP_CLOCK_IDENTITY_LENGTH) == 0) &&
((ppi->sent_seq[PPM_PDELAY_REQ]) ==
hdr->sequenceId) &&
(DSPOR(ppi)->portIdentity.portNumber ==
respFllw.requestingPortIdentity.portNumber) &&
ppi->is_from_cur_par) {
to_TimeInternal(&ppi->t5, &respFllw.responseOriginTimestamp);
ppi->waiting_for_resp_follow = TRUE;
if (pp_hooks.handle_presp)
e = pp_hooks.handle_presp(ppi);
else
pp_servo_got_presp(ppi);
if (e)
goto out;
} else {
pp_diag(ppi, frames, 2, "pp_pclock : "
"PDelay Resp Follow doesn't match PDelay Req\n");
}
break;
default:
/* disregard, nothing to do */
......@@ -106,6 +160,7 @@ out:
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;
d3 = pp_ms_to_timeout(ppi, PP_TO_PDELAYREQ);
ppi->next_delay = d1 < d2 ? d1 : (d2 < d3 ? d2 : d3);
return 0;
}
......@@ -15,7 +15,8 @@ int pp_pclock(struct pp_instance *ppi, unsigned char *pkt, int plen)
MsgHeader *hdr = &ppi->received_ptp_header;
MsgPDelayRespFollowUp respFllw;
int d1, d2;
pp_diag(ppi, fsm, 1,"\n\nin pp_clock: is_new_state=%d\n\n",ppi->is_new_state);
if (ppi->is_new_state) {
pp_servo_init(ppi);
......
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