Commit 722e8147 authored by Aurelio Colosimo's avatar Aurelio Colosimo

fix: rt_opts variable usage fix

used OPTS(ppi) everywhere instead of ppi->rt_opts
removed rt_opts as function parameter
parent c14f12fd
...@@ -275,8 +275,7 @@ extern void pp_update_clock(struct pp_instance *ppi); ...@@ -275,8 +275,7 @@ extern void pp_update_clock(struct pp_instance *ppi);
extern void m1(struct pp_instance *ppi); extern void m1(struct pp_instance *ppi);
extern void s1(struct pp_instance *ppi, MsgHeader *header, MsgAnnounce *ann); extern void s1(struct pp_instance *ppi, MsgHeader *header, MsgAnnounce *ann);
extern UInteger8 bmc(struct pp_instance *ppi, extern UInteger8 bmc(struct pp_instance *ppi,
struct pp_frgn_master *frgn_master, struct pp_frgn_master *frgn_master);
struct pp_runtime_opts *rt_opts);
/* msg.c */ /* msg.c */
extern void msg_pack_header(struct pp_instance *ppi, void *buf); extern void msg_pack_header(struct pp_instance *ppi, void *buf);
......
...@@ -238,12 +238,11 @@ Integer8 bmc_dataset_cmp(struct pp_instance *ppi, ...@@ -238,12 +238,11 @@ Integer8 bmc_dataset_cmp(struct pp_instance *ppi,
/* State decision algorithm 9.3.3 Fig 26 */ /* State decision algorithm 9.3.3 Fig 26 */
UInteger8 bmc_state_decision( struct pp_instance *ppi, UInteger8 bmc_state_decision( struct pp_instance *ppi,
MsgHeader *hdr, MsgAnnounce *ann, MsgHeader *hdr, MsgAnnounce *ann)
struct pp_runtime_opts *rt_opts)
{ {
int cmpres; int cmpres;
if (rt_opts->slave_only) { if (OPTS(ppi)->slave_only) {
s1(ppi, hdr, ann); s1(ppi, hdr, ann);
return PPS_SLAVE; return PPS_SLAVE;
} }
...@@ -289,8 +288,7 @@ UInteger8 bmc_state_decision( struct pp_instance *ppi, ...@@ -289,8 +288,7 @@ UInteger8 bmc_state_decision( struct pp_instance *ppi,
UInteger8 bmc(struct pp_instance *ppi, struct pp_frgn_master *frgn_master, UInteger8 bmc(struct pp_instance *ppi, struct pp_frgn_master *frgn_master)
struct pp_runtime_opts *rt_opts)
{ {
Integer16 i, best; Integer16 i, best;
...@@ -312,6 +310,5 @@ UInteger8 bmc(struct pp_instance *ppi, struct pp_frgn_master *frgn_master, ...@@ -312,6 +310,5 @@ UInteger8 bmc(struct pp_instance *ppi, struct pp_frgn_master *frgn_master,
ppi->foreign_record_best = best; ppi->foreign_record_best = best;
return bmc_state_decision(ppi, &frgn_master[best].hdr, return bmc_state_decision(ppi, &frgn_master[best].hdr,
&frgn_master[best].ann, &frgn_master[best].ann);
rt_opts);
} }
...@@ -23,7 +23,7 @@ int st_com_execute_slave(struct pp_instance *ppi) ...@@ -23,7 +23,7 @@ int st_com_execute_slave(struct pp_instance *ppi)
} }
} }
if (ppi->rt_opts->e2e_mode) { if (OPTS(ppi)->e2e_mode) {
if (pp_timer_expired(ppi->timers[PP_TIMER_DELAYREQ])) { if (pp_timer_expired(ppi->timers[PP_TIMER_DELAYREQ])) {
PP_VPRINTF("event DELAYREQ_INTERVAL_TIMEOUT_EXPIRES\n"); PP_VPRINTF("event DELAYREQ_INTERVAL_TIMEOUT_EXPIRES\n");
return msg_issue_delay_req(ppi); return msg_issue_delay_req(ppi);
...@@ -55,7 +55,7 @@ int st_com_check_record_update(struct pp_instance *ppi) ...@@ -55,7 +55,7 @@ int st_com_check_record_update(struct pp_instance *ppi)
if (ppi->record_update) { if (ppi->record_update) {
PP_VPRINTF("event STATE_DECISION_EVENT\n"); PP_VPRINTF("event STATE_DECISION_EVENT\n");
ppi->record_update = FALSE; ppi->record_update = FALSE;
ppi->next_state = bmc(ppi, ppi->frgn_master, ppi->rt_opts); ppi->next_state = bmc(ppi, ppi->frgn_master);
if (ppi->next_state != ppi->state) if (ppi->next_state != ppi->state)
return 1; return 1;
...@@ -182,7 +182,7 @@ int st_com_slave_handle_sync(struct pp_instance *ppi, unsigned char *buf, ...@@ -182,7 +182,7 @@ int st_com_slave_handle_sync(struct pp_instance *ppi, unsigned char *buf,
ppi->sync_receive_time.nanoseconds = time->nanoseconds; ppi->sync_receive_time.nanoseconds = time->nanoseconds;
/* FIXME diag to file? will we ever handle it? /* FIXME diag to file? will we ever handle it?
if (ppi->rt_opts->recordFP) if (OPTS(ppi)->recordFP)
fprintf(rtOpts->recordFP, "%d %llu\n", fprintf(rtOpts->recordFP, "%d %llu\n",
header->sequenceId, header->sequenceId,
((time->seconds * 1000000000ULL) + ((time->seconds * 1000000000ULL) +
...@@ -276,7 +276,7 @@ int st_com_handle_pdelay_req(struct pp_instance *ppi, unsigned char *buf, ...@@ -276,7 +276,7 @@ int st_com_handle_pdelay_req(struct pp_instance *ppi, unsigned char *buf,
if (len < PP_PDELAY_REQ_LENGTH) if (len < PP_PDELAY_REQ_LENGTH)
return -1; return -1;
if (ppi->rt_opts->e2e_mode) if (OPTS(ppi)->e2e_mode)
return 0; return 0;
time = &ppi->last_rcv_time; time = &ppi->last_rcv_time;
...@@ -292,7 +292,7 @@ int st_com_handle_pdelay_req(struct pp_instance *ppi, unsigned char *buf, ...@@ -292,7 +292,7 @@ int st_com_handle_pdelay_req(struct pp_instance *ppi, unsigned char *buf,
/*Add latency*/ /*Add latency*/
add_TimeInternal(&ppi->pdelay_req_send_time, add_TimeInternal(&ppi->pdelay_req_send_time,
&ppi->pdelay_req_send_time, &ppi->pdelay_req_send_time,
&ppi->rt_opts->outbound_latency); &OPTS(ppi)->outbound_latency);
} else { } else {
msg_copy_header(&ppi->pdelay_req_hdr, hdr); msg_copy_header(&ppi->pdelay_req_hdr, hdr);
...@@ -334,7 +334,7 @@ int st_com_master_handle_sync(struct pp_instance *ppi, unsigned char *buf, ...@@ -334,7 +334,7 @@ int st_com_master_handle_sync(struct pp_instance *ppi, unsigned char *buf,
time = &ppi->last_rcv_time; time = &ppi->last_rcv_time;
/* Add latency */ /* Add latency */
add_TimeInternal(time, time, &ppi->rt_opts->outbound_latency); add_TimeInternal(time, time, &OPTS(ppi)->outbound_latency);
msg_issue_followup(ppi, time); msg_issue_followup(ppi, time);
return 0; return 0;
} }
...@@ -238,9 +238,9 @@ int pp_parse_cmdline(struct pp_instance *ppi, int argc, char **argv) ...@@ -238,9 +238,9 @@ int pp_parse_cmdline(struct pp_instance *ppi, int argc, char **argv)
int pp_open_instance(struct pp_instance *ppi, struct pp_runtime_opts *rt_opts) int pp_open_instance(struct pp_instance *ppi, struct pp_runtime_opts *rt_opts)
{ {
if (rt_opts) if (rt_opts)
ppi->rt_opts = rt_opts; OPTS(ppi) = rt_opts;
else else
ppi->rt_opts = &default_rt_opts; OPTS(ppi) = &default_rt_opts;
ppi->state = PPS_INITIALIZING; ppi->state = PPS_INITIALIZING;
......
...@@ -12,8 +12,6 @@ ...@@ -12,8 +12,6 @@
int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen) int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen)
{ {
struct pp_runtime_opts *rt_opts = ppi->rt_opts;
pp_net_shutdown(ppi); pp_net_shutdown(ppi);
if (pp_net_init(ppi) < 0) if (pp_net_init(ppi) < 0)
...@@ -26,13 +24,13 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -26,13 +24,13 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen)
DSDEF(ppi)->clockIdentity[3] = 0xff; DSDEF(ppi)->clockIdentity[3] = 0xff;
DSDEF(ppi)->clockIdentity[4] = 0xfe; DSDEF(ppi)->clockIdentity[4] = 0xfe;
DSDEF(ppi)->numberPorts = 1; DSDEF(ppi)->numberPorts = 1;
pp_memcpy(&DSDEF(ppi)->clockQuality, &rt_opts->clock_quality, pp_memcpy(&DSDEF(ppi)->clockQuality, &OPTS(ppi)->clock_quality,
sizeof(ClockQuality)); sizeof(ClockQuality));
DSDEF(ppi)->priority1 = rt_opts->prio1; DSDEF(ppi)->priority1 = OPTS(ppi)->prio1;
DSDEF(ppi)->priority2 = rt_opts->prio2; DSDEF(ppi)->priority2 = OPTS(ppi)->prio2;
DSDEF(ppi)->domainNumber = rt_opts->domain_number; DSDEF(ppi)->domainNumber = OPTS(ppi)->domain_number;
DSDEF(ppi)->slaveOnly = rt_opts->slave_only; DSDEF(ppi)->slaveOnly = OPTS(ppi)->slave_only;
if (rt_opts->slave_only) if (OPTS(ppi)->slave_only)
ppi->defaultDS->clockQuality.clockClass = 255; ppi->defaultDS->clockQuality.clockClass = 255;
/* Initialize port data set */ /* Initialize port data set */
...@@ -42,10 +40,10 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -42,10 +40,10 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen)
DSPOR(ppi)->logMinDelayReqInterval = PP_DEFAULT_DELAYREQ_INTERVAL; DSPOR(ppi)->logMinDelayReqInterval = PP_DEFAULT_DELAYREQ_INTERVAL;
DSPOR(ppi)->peerMeanPathDelay.seconds = 0; DSPOR(ppi)->peerMeanPathDelay.seconds = 0;
DSPOR(ppi)->peerMeanPathDelay.nanoseconds = 0; DSPOR(ppi)->peerMeanPathDelay.nanoseconds = 0;
DSPOR(ppi)->logAnnounceInterval = rt_opts->announce_intvl; DSPOR(ppi)->logAnnounceInterval = OPTS(ppi)->announce_intvl;
DSPOR(ppi)->announceReceiptTimeout = DSPOR(ppi)->announceReceiptTimeout =
PP_DEFAULT_ANNOUNCE_RECEIPT_TIMEOUT; PP_DEFAULT_ANNOUNCE_RECEIPT_TIMEOUT;
DSPOR(ppi)->logSyncInterval = rt_opts->sync_intvl; DSPOR(ppi)->logSyncInterval = OPTS(ppi)->sync_intvl;
DSPOR(ppi)->delayMechanism = PP_DEFAULT_DELAY_MECHANISM; DSPOR(ppi)->delayMechanism = PP_DEFAULT_DELAY_MECHANISM;
DSPOR(ppi)->logMinPdelayReqInterval = PP_DEFAULT_PDELAYREQ_INTERVAL; DSPOR(ppi)->logMinPdelayReqInterval = PP_DEFAULT_PDELAYREQ_INTERVAL;
DSPOR(ppi)->versionNumber = PP_VERSION_PTP; DSPOR(ppi)->versionNumber = PP_VERSION_PTP;
......
...@@ -45,7 +45,7 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -45,7 +45,7 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
goto failure; goto failure;
} }
if (!ppi->rt_opts->e2e_mode) { if (!OPTS(ppi)->e2e_mode) {
if (pp_timer_expired(ppi->timers[PP_TIMER_PDELAYREQ])) { if (pp_timer_expired(ppi->timers[PP_TIMER_PDELAYREQ])) {
PP_VPRINTF("event PDELAYREQ_INTERVAL_TOUT_EXPIRES\n"); PP_VPRINTF("event PDELAYREQ_INTERVAL_TOUT_EXPIRES\n");
if (msg_issue_pdelay_req(ppi) < 0) if (msg_issue_pdelay_req(ppi) < 0)
...@@ -77,13 +77,13 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -77,13 +77,13 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
case PPM_PDELAY_RESP: case PPM_PDELAY_RESP:
/* Loopback Timestamp */ /* Loopback Timestamp */
if (ppi->rt_opts->e2e_mode) if (OPTS(ppi)->e2e_mode)
break; break;
if (ppi->is_from_self) { if (ppi->is_from_self) {
/*Add latency*/ /*Add latency*/
add_TimeInternal(time, time, add_TimeInternal(time, time,
&ppi->rt_opts->outbound_latency); &OPTS(ppi)->outbound_latency);
e = msg_issue_pdelay_resp_follow_up(ppi, time); e = msg_issue_pdelay_resp_follow_up(ppi, time);
break; break;
......
...@@ -34,7 +34,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -34,7 +34,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
st_com_restart_annrec_timer(ppi); st_com_restart_annrec_timer(ppi);
if (ppi->rt_opts->e2e_mode) if (OPTS(ppi)->e2e_mode)
pp_timer_start(1 << DSPOR(ppi)->logMinDelayReqInterval, pp_timer_start(1 << DSPOR(ppi)->logMinDelayReqInterval,
ppi->timers[PP_TIMER_DELAYREQ]); ppi->timers[PP_TIMER_DELAYREQ]);
else else
...@@ -78,7 +78,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -78,7 +78,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
/* Add latency */ /* Add latency */
add_TimeInternal(&ppi->delay_req_send_time, add_TimeInternal(&ppi->delay_req_send_time,
&ppi->delay_req_send_time, &ppi->delay_req_send_time,
&ppi->rt_opts->outbound_latency); &OPTS(ppi)->outbound_latency);
} }
break; break;
...@@ -89,7 +89,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -89,7 +89,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
if (e) if (e)
break; break;
if (!ppi->rt_opts->e2e_mode) if (!OPTS(ppi)->e2e_mode)
break; break;
msg_unpack_delay_resp(pkt, &ppi->msg_tmp.resp); msg_unpack_delay_resp(pkt, &ppi->msg_tmp.resp);
...@@ -131,7 +131,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -131,7 +131,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
break; break;
case PPM_PDELAY_RESP: case PPM_PDELAY_RESP:
if (ppi->rt_opts->e2e_mode) if (OPTS(ppi)->e2e_mode)
break; break;
e = (plen < PP_PDELAY_RESP_LENGTH); e = (plen < PP_PDELAY_RESP_LENGTH);
...@@ -141,7 +141,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -141,7 +141,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
if (ppi->is_from_self) { if (ppi->is_from_self) {
add_TimeInternal(time, time, add_TimeInternal(time, time,
&ppi->rt_opts->outbound_latency); &OPTS(ppi)->outbound_latency);
msg_issue_pdelay_resp_follow_up(ppi, time); msg_issue_pdelay_resp_follow_up(ppi, time);
break; break;
} }
...@@ -200,7 +200,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -200,7 +200,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
case PPM_PDELAY_RESP_FOLLOW_UP: case PPM_PDELAY_RESP_FOLLOW_UP:
if (ppi->rt_opts->e2e_mode) if (OPTS(ppi)->e2e_mode)
break; break;
e = (plen < PP_PDELAY_RESP_FOLLOW_UP_LENGTH); e = (plen < PP_PDELAY_RESP_FOLLOW_UP_LENGTH);
...@@ -254,7 +254,7 @@ state_updated: ...@@ -254,7 +254,7 @@ state_updated:
if (ppi->next_state != ppi->state) { if (ppi->next_state != ppi->state) {
pp_timer_stop(ppi->timers[PP_TIMER_ANN_RECEIPT]); pp_timer_stop(ppi->timers[PP_TIMER_ANN_RECEIPT]);
if (ppi->rt_opts->e2e_mode) if (OPTS(ppi)->e2e_mode)
pp_timer_stop(ppi->timers[PP_TIMER_DELAYREQ]); pp_timer_stop(ppi->timers[PP_TIMER_DELAYREQ]);
else else
pp_timer_stop(ppi->timers[PP_TIMER_PDELAYREQ]); pp_timer_stop(ppi->timers[PP_TIMER_PDELAYREQ]);
......
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