Commit e037e781 authored by Jean-Claude BAU's avatar Jean-Claude BAU

Add new macro TOPS() to access timing operations

parent b66d61fe
......@@ -37,8 +37,8 @@ void __pp_diag(struct pp_instance *ppi, enum pp_diag_things th,
if (PP_DIAG_EXTRA_PRINT_TIME) {
int hours, minutes, seconds;
if (ppi && ppi->t_ops && ppi->t_ops->get_utc_time )
ppi->t_ops->get_utc_time(ppi, &hours, &minutes, &seconds);
if (ppi && TOPS(ppi) && TOPS(ppi)->get_utc_time )
TOPS(ppi)->get_utc_time(ppi, &hours, &minutes, &seconds);
else
hours=minutes=seconds=0;
pp_printf("%02d:%02d:%02d %s-%i-%s: ", hours, minutes,seconds,thing_name[th], level, name);
......
......@@ -24,7 +24,7 @@ static void pp_fsm_printf(struct pp_instance *ppi, char *fmt, ...)
/* temporarily set NOTIMELOG, as we'll print the time ourselves */
pp_global_d_flags |= PP_FLAG_NOTIMELOG;
ppi->t_ops->get(ppi, &t);
TOPS(ppi)->get(ppi, &t);
pp_global_d_flags = oflags;
pp_printf("diag-fsm-1-%s: %09d.%03d: ", ppi->port_name,
......
......@@ -143,6 +143,11 @@ static inline timePropertiesDS_t *DSPRO(struct pp_instance *ppi)
return GLBS(ppi)->timePropertiesDS;
}
static inline struct pp_time_operations *TOPS(struct pp_instance *ppi) {
return ppi->t_ops;
}
/* We used to have a "netpath" structure. Keep this until we merge pdelay */
static struct pp_instance *NP(struct pp_instance *ppi)
__attribute__((deprecated));
......
......@@ -92,7 +92,7 @@ int wrh_servo_init(struct pp_instance *ppi)
strcpy(gs->servo_state_name, wrh_servo_state_name[gs->state]);
gs->flags |= PP_SERVO_FLAG_VALID;
ppi->t_ops->get(ppi, &gs->update_time);
TOPS(ppi)->get(ppi, &gs->update_time);
s->tracking_enabled = wrh_tracking_enabled;
gs->state = WRH_SYNC_TAI;
}
......@@ -225,7 +225,7 @@ static int __wrh_servo_update(struct pp_instance *ppi)
// Servo updated
gs->update_count++;
ppi->t_ops->get(ppi, &gs->update_time);
TOPS(ppi)->get(ppi, &gs->update_time);
if (!s->readyForSync )
return 1; /* We have to wait before to start the synchronization */
......@@ -307,7 +307,7 @@ static int __wrh_servo_update(struct pp_instance *ppi)
* it. We use current WR time.
* */
struct pp_time t;
ppi->t_ops->get(ppi,&t);
TOPS(ppi)->get(ppi,&t);
unix_time_ops.set(ppi, &t);
pp_diag(ppi, time, 1, "system time set to %s TAI\n",
time_to_string(&t));
......
......@@ -188,7 +188,7 @@ static __inline__ int measure_first_time(struct pp_instance *ppi) {
struct pp_time current_time;
int ms;
ppi->t_ops->get(ppi, &current_time);
TOPS(ppi)->get(ppi, &current_time);
ms=(current_time.secs&0xFFFF)*1000; /* do not take all second - Not necessary to calculate a difference*/
ms+=((current_time.scaled_nsecs + 0x8000) >> TIME_INTERVAL_FRACBITS)/1000000;
return ms;
......
......@@ -13,7 +13,7 @@ static int next_pps_ms(struct pp_instance *ppi, struct pp_time *t)
{
int nsec;
ppi->t_ops->get(ppi, t);
TOPS(ppi)->get(ppi, t);
nsec = t->scaled_nsecs >> 16;
return 1000 - (nsec / 1000 / 1000);
}
......@@ -43,11 +43,11 @@ int wr_abscal(struct pp_instance *ppi, void *buf, int plen, int new_state)
WRH_OPER()->enable_timing_output(GLBS(ppi), 1);
/* Wait for the second to tick */
while( ppi->t_ops->get(ppi, &t), t.secs == secs)
while( TOPS(ppi)->get(ppi, &t), t.secs == secs)
;
/* Send sync, no f-up -- actually we could send any frame */
ppi->t_ops->get(ppi, &t);
TOPS(ppi)->get(ppi, &t);
len = msg_pack_sync(ppi, &t);
__send_and_log(ppi, len, PP_NP_EVT);
......
......@@ -82,7 +82,7 @@ void bmc_m1(struct pp_instance *ppi)
prop->ptpTimescale=ptpTimescale;
if (ptpTimescale) {
ret = ppi->t_ops->get_utc_offset(ppi, &offset, &leap59, &leap61);
ret = TOPS(ppi)->get_utc_offset(ppi, &offset, &leap59, &leap61);
if (ret) {
offset = PP_DEFAULT_UTC_OFFSET;
pp_diag(ppi, bmc, 1,
......@@ -94,7 +94,7 @@ void bmc_m1(struct pp_instance *ppi)
if (prop->currentUtcOffset != offset) {
pp_diag(ppi, bmc, 1, "New UTC offset: %i\n",offset);
prop->currentUtcOffset = offset;
ppi->t_ops->set(ppi, NULL);
TOPS(ppi)->set(ppi, NULL);
}
if (ret)
......@@ -181,7 +181,7 @@ void bmc_s1(struct pp_instance *ppi,
prop->ptpTimescale = ((frgn_master->flagField[1] & FFB_PTP) != 0);
if (prop->ptpTimescale) {
ret = ppi->t_ops->get_utc_time(ppi, &hours, &minutes, &seconds);
ret = TOPS(ppi)->get_utc_time(ppi, &hours, &minutes, &seconds);
if (ret) {
pp_diag(ppi, bmc, 1,
"Could not get UTC time from system, taking received flags\n");
......@@ -195,7 +195,7 @@ void bmc_s1(struct pp_instance *ppi,
(seconds >= (60 - (2 * (1 << ppi->portDS->logAnnounceInterval))))) {
pp_diag(ppi, bmc, 2,
"Approaching midnight, not updating leap flags\n");
ret = ppi->t_ops->get_utc_offset(ppi, &offset, &leap59, &leap61);
ret = TOPS(ppi)->get_utc_offset(ppi, &offset, &leap59, &leap61);
if (ret) {
pp_diag(ppi, bmc, 1,
"Could not get UTC offset from system\n");
......@@ -208,7 +208,7 @@ void bmc_s1(struct pp_instance *ppi,
offset, leap59, leap61);
}
} else {
ret = ppi->t_ops->get_utc_offset(ppi, &offset, &leap59, &leap61);
ret = TOPS(ppi)->get_utc_offset(ppi, &offset, &leap59, &leap61);
if (ret) {
pp_diag(ppi, bmc, 1,
"Could not get UTC flags from system, taking received flags\n");
......@@ -250,7 +250,7 @@ void bmc_s1(struct pp_instance *ppi,
"leap61: %i\n",
offset, leap59, leap61);
ret = ppi->t_ops->set_utc_offset(ppi, offset, leap59, leap61);
ret = TOPS(ppi)->set_utc_offset(ppi, offset, leap59, leap61);
if (ret) {
pp_diag(ppi, bmc, 1,
"Could not set UTC offset on system\n");
......@@ -265,7 +265,7 @@ void bmc_s1(struct pp_instance *ppi,
(seconds <= (0 + (2 * (1 << ppi->portDS->logAnnounceInterval))))) {
pp_diag(ppi, bmc, 2,
"short after midnight, taking local offset\n");
ret = ppi->t_ops->get_utc_offset(ppi, &offset, &leap59, &leap61);
ret = TOPS(ppi)->get_utc_offset(ppi, &offset, &leap59, &leap61);
if (ret) {
pp_diag(ppi, bmc, 1,
"Could not get UTC offset from system\n");
......@@ -285,7 +285,7 @@ void bmc_s1(struct pp_instance *ppi,
pp_diag(ppi, bmc, 1, "New UTC offset in the middle of the day: %i\n",
frgn_master->currentUtcOffset);
prop->currentUtcOffset = frgn_master->currentUtcOffset;
ppi->t_ops->set(ppi, NULL);
TOPS(ppi)->set(ppi, NULL);
}
prop->leap59 = ((frgn_master->flagField[1] & FFB_LI59) != 0);
prop->leap61 = ((frgn_master->flagField[1] & FFB_LI61) != 0);
......
......@@ -94,7 +94,7 @@ int pp_lib_may_issue_announce(struct pp_instance *ppi)
* happened before sending
*/
if (prop->ptpTimescale) {
ret = ppi->t_ops->get_utc_time(ppi, &hours, &minutes, &seconds);
ret = TOPS(ppi)->get_utc_time(ppi, &hours, &minutes, &seconds);
if (ret) {
pp_diag(ppi, frames, 1,
"Could not get UTC time from system, taking received flags\n");
......@@ -104,7 +104,7 @@ int pp_lib_may_issue_announce(struct pp_instance *ppi)
(seconds <= (0 + (2 * (1 << ppi->portDS->logAnnounceInterval))))) {
pp_diag(ppi, frames, 2,
"short after midnight, taking local offset\n");
ret = ppi->t_ops->get_utc_offset(ppi, &offset, &leap59, &leap61);
ret = TOPS(ppi)->get_utc_offset(ppi, &offset, &leap59, &leap61);
if (ret) {
pp_diag(ppi, frames, 1,
"Could not get UTC offset from system\n");
......
......@@ -146,7 +146,7 @@ int msg_issue_pdelay_req(struct pp_instance *ppi)
int len;
mark_incorrect(&ppi->t4); /* see commit message */
ppi->t_ops->get(ppi, &now);
TOPS(ppi)->get(ppi, &now);
ppi->received_dresp=
ppi->received_dresp_fup=0;
len = msg_pack_pdelay_req(ppi, &now);
......
......@@ -385,7 +385,7 @@ int msg_issue_sync_followup(struct pp_instance *ppi)
int e, len;
/* Send sync on the event channel with the "current" timestamp */
ppi->t_ops->get(ppi, &now);
TOPS(ppi)->get(ppi, &now);
len = msg_pack_sync(ppi, &now);
e = __send_and_log(ppi, len, PP_NP_EVT,PPM_SYNC_FMT);
if (e) return e;
......@@ -402,7 +402,7 @@ static int msg_issue_delay_req(struct pp_instance *ppi)
struct pp_time now;
int len;
ppi->t_ops->get(ppi, &now);
TOPS(ppi)->get(ppi, &now);
len = msg_pack_delay_req(ppi, &now);
return __send_and_log(ppi, len, PP_NP_EVT,PPM_DELAY_REQ_FMT);
......
......@@ -40,9 +40,9 @@ static void _pp_servo_init(struct pp_instance *ppi)
PP_SERVO_RESET_DATA(servo);
servo->mpd_fltr.s_exp = 0; /* clears meanDelay filter */
if (ppi->t_ops->init_servo) {
if (TOPS(ppi)->init_servo) {
/* The system may pre-set us to keep current frequency */
d = ppi->t_ops->init_servo(ppi);
d = TOPS(ppi)->init_servo(ppi);
if (d == -1) {
pp_diag(ppi, servo, 1, "error in t_ops->servo_init");
d = 0;
......@@ -51,7 +51,7 @@ static void _pp_servo_init(struct pp_instance *ppi)
} else {
/* level clock */
if (pp_can_adjust(ppi))
ppi->t_ops->adjust(ppi, 0, 0);
TOPS(ppi)->adjust(ppi, 0, 0);
servo->obs_drift = 0;
}
......@@ -413,17 +413,17 @@ static void __pp_servo_update(struct pp_instance *ppi) {
/* apply controller output as a clock tick rate adjustment, if
* provided by arch, or as a raw offset otherwise */
if (pp_can_adjust(ppi)) {
if (ppi->t_ops->adjust_freq)
ppi->t_ops->adjust_freq(ppi, adj32);
if (TOPS(ppi)->adjust_freq)
TOPS(ppi)->adjust_freq(ppi, adj32);
else
ppi->t_ops->adjust_offset(ppi, adj32);
TOPS(ppi)->adjust_offset(ppi, adj32);
}
pp_diag(ppi, servo, 2, "Observed drift: %9i\n",
(int)SRV(ppi)->obs_drift >> 10);
}
servo->update_count++;
ppi->t_ops->get(ppi, &servo->update_time);
TOPS(ppi)->get(ppi, &servo->update_time);
}
......@@ -505,9 +505,9 @@ static int pp_servo_offset_master(struct pp_instance *ppi, struct pp_time *ofm)
if (!pp_can_adjust(ppi))
return 0; /* e.g., a loopback test run... "-t" on cmdline */
ppi->t_ops->get(ppi, &time_tmp);
TOPS(ppi)->get(ppi, &time_tmp);
pp_time_add(&time_tmp, ofm);
ppi->t_ops->set(ppi, &time_tmp);
TOPS(ppi)->set(ppi, &time_tmp);
_pp_servo_init(ppi);
......
......@@ -95,7 +95,7 @@ static int unix_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len,
* get the recording time here, even though it may put a big
* spike in the offset signal sent to the clock servo
*/
ppi->t_ops->get(ppi, t);
TOPS(ppi)->get(ppi, t);
}
/* aux is only there if we asked for it, thus PROTO_VLAN */
......@@ -198,7 +198,7 @@ static int unix_net_send(struct pp_instance *ppi, void *pkt, int len,enum pp_msg
/* To fake a network frame loss, set the timestamp and do not send */
if (ppsi_drop_tx()) {
ppi->t_ops->get(ppi, t);
TOPS(ppi)->get(ppi, t);
pp_diag(ppi, frames, 1, "Drop sent frame\n");
return len;
}
......@@ -212,7 +212,7 @@ static int unix_net_send(struct pp_instance *ppi, void *pkt, int len,enum pp_msg
memcpy(hdr->h_dest, macaddr[is_pdelay], ETH_ALEN);
memcpy(hdr->h_source, ch->addr, ETH_ALEN);
ppi->t_ops->get(ppi, t);
TOPS(ppi)->get(ppi, t);
ret = send(ch->fd, hdr, len, 0);
if (ret < 0) {
......@@ -237,7 +237,7 @@ static int unix_net_send(struct pp_instance *ppi, void *pkt, int len,enum pp_msg
memcpy(hdr->h_dest, macaddr[is_pdelay], ETH_ALEN);
memcpy(vhdr->h_source, ch->addr, ETH_ALEN);
ppi->t_ops->get(ppi, t);
TOPS(ppi)->get(ppi, t);
ret = send(ch->fd, vhdr, len, 0);
if (ret < 0) {
......@@ -256,7 +256,7 @@ static int unix_net_send(struct pp_instance *ppi, void *pkt, int len,enum pp_msg
addr.sin_port = htons(udpport[chtype]);
addr.sin_addr.s_addr = ppi->mcast_addr[is_pdelay];
ppi->t_ops->get(ppi, t);
TOPS(ppi)->get(ppi, t);
ret = sendto(ppi->ch[chtype].fd, pkt, len, 0,
(struct sockaddr *)&addr,
......
......@@ -167,7 +167,7 @@ int pp_timeout_get(struct pp_instance *ppi, int index) {
static inline void __pp_timeout_set(struct pp_instance *ppi,int index , int millisec) {
timeOutInstCnt_t *tmoCnt= __pp_get_counter(ppi,index);
tmoCnt->tmo = ppi->t_ops->calc_timeout(ppi, millisec);
tmoCnt->tmo = TOPS(ppi)->calc_timeout(ppi, millisec);
}
void pp_timeout_set_rename(struct pp_instance *ppi,int index , int millisec, char *name)
......@@ -261,7 +261,7 @@ int pp_timeout(struct pp_instance *ppi, int index)
if ( tmoCnt->initValueMs==TIMEOUT_DISABLE_VALUE )
return 0; /* counter is disabled */
now=ppi->t_ops->calc_timeout(ppi, 0);
now=TOPS(ppi)->calc_timeout(ppi, 0);
ret = time_after_eq(now,tmoCnt->tmo);
if (ret)
pp_diag(ppi, time, 1, "timeout expired: %s - %lu\n",
......@@ -276,7 +276,7 @@ int pp_timeout(struct pp_instance *ppi, int index)
int pp_next_delay_1(struct pp_instance *ppi, int i1)
{
timeOutInstCnt_t *tmoCnt= __pp_get_counter(ppi,i1);
unsigned long now = ppi->t_ops->calc_timeout(ppi, 0);
unsigned long now = TOPS(ppi)->calc_timeout(ppi, 0);
signed long r1;
r1 = tmoCnt->tmo - now;
......@@ -287,7 +287,7 @@ int pp_next_delay_2(struct pp_instance *ppi, int i1, int i2)
{
timeOutInstCnt_t *tmoCnt1= __pp_get_counter(ppi,i1);
timeOutInstCnt_t *tmoCnt2= __pp_get_counter(ppi,i2);
unsigned long now = ppi->t_ops->calc_timeout(ppi, 0);
unsigned long now = TOPS(ppi)->calc_timeout(ppi, 0);
signed long r1, r2;
r1 = tmoCnt1->tmo - now;
......@@ -302,7 +302,7 @@ int pp_next_delay_3(struct pp_instance *ppi, int i1, int i2, int i3)
timeOutInstCnt_t *tmoCnt1= __pp_get_counter(ppi,i1);
timeOutInstCnt_t *tmoCnt2= __pp_get_counter(ppi,i2);
timeOutInstCnt_t *tmoCnt3= __pp_get_counter(ppi,i3);
unsigned long now = ppi->t_ops->calc_timeout(ppi, 0);
unsigned long now = TOPS(ppi)->calc_timeout(ppi, 0);
signed long r1, r2, r3;
r1 = tmoCnt1->tmo - now;
......
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