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

Move enable_output_timing() hook in pp_time_operations structure

As the enable_output_timing() hook  is called also in the standard PTP
part, the hook has been moved from the WR specific structure
wrh_operations to  pp_time_operations
parent e037e781
......@@ -44,8 +44,6 @@ struct wrh_operations wrh_oper = {
.adjust_phase = wrs_adjust_phase,
.read_calib_data = wrs_read_calibration_data,
.enable_timing_output = wrs_enable_timing_output,
.set_timing_mode= wrs_set_timing_mode,
.get_timing_mode= wrs_get_timing_mode,
.get_timing_mode_state= wrs_get_timing_mode_state,
......@@ -430,7 +428,7 @@ int main(int argc, char **argv)
enablePPS=(ppg->timingModeLockingState== TM_LOCKING_STATE_LOCKED && ppg->defaultDS->clockQuality.clockClass == PP_PTP_CLASS_GM_LOCKED) ||
( ppg->defaultDS->clockQuality.clockClass == PP_PTP_CLASS_GM_UNLOCKED ||
GOPTS(ppg)->forcePpsGen);
WRH_OPER()->enable_timing_output(ppg,enablePPS);
TOPS(ppi)->enable_timing_output(ppg,enablePPS);
}
seed = (unsigned long) time(NULL);
......
......@@ -260,6 +260,8 @@ struct pp_time_operations {
int (*adjust_freq)(struct pp_instance *ppi, long freq_ppb);
int (*init_servo)(struct pp_instance *ppi);
unsigned long (*calc_timeout)(struct pp_instance *ppi, int millisec);
int (*get_GM_locked_state)(struct pp_globals *ppg, pp_timing_mode_state_t *locked);
int (*enable_timing_output)(struct pp_globals *ppg,int enable);
};
#include "timeout_prot.h"
......
......@@ -196,7 +196,7 @@ static void l1e_state_change(struct pp_instance *ppi) {
}
if ( ppi->state==PPS_SLAVE && ppi->next_state!=PPS_UNCALIBRATED ) {
/* Leave SLAVE state : We must stop the PPS generation */
WRH_OPER()->enable_timing_output(GLBS(ppi),0);
TOPS(ppi)->enable_timing_output(GLBS(ppi),0);
WRH_OPER()->locking_reset(ppi);
}
}
......
......@@ -212,7 +212,7 @@ static void wr_state_change(struct pp_instance *ppi)
if ( ppi->state==PPS_SLAVE && ppi->next_state!=PPS_UNCALIBRATED ) {
/* Leave SLAVE state : We must stop the PPS generation */
WRH_OPER()->enable_timing_output(GLBS(ppi),0);
TOPS(ppi)->enable_timing_output(GLBS(ppi),0);
}
} else
wr_reset_process(ppi,WR_ROLE_NONE);
......
......@@ -40,7 +40,7 @@ int wr_abscal(struct pp_instance *ppi, void *buf, int plen, int new_state)
if (pp_timeout(ppi, wrTmoIdx)) {
uint64_t secs = t.secs;
WRH_OPER()->enable_timing_output(GLBS(ppi), 1);
TOPS()->enable_timing_output(GLBS(ppi), 1);
/* Wait for the second to tick */
while( TOPS(ppi)->get(ppi, &t), t.secs == secs)
......
......@@ -139,7 +139,7 @@ void bmc_m2(struct pp_instance *ppi)
/* Grand master by BMCA validated: The timing output can be enabled */
pp_gtimeout_disable(ppg,PP_TO_GM_BY_BMCA);
pp_diag(ppi, time, 1, "Enable timing output (Grand master by BMCA)\n");
WRH_OPER()->enable_timing_output(ppg,1);
TOPS(ppi)->enable_timing_output(ppg,1);
}
}
}
......@@ -1435,7 +1435,7 @@ static void bmc_update_clock_quality(struct pp_globals *ppg)
ppg->defaultDS->clockQuality=p->clockQuality;
pp_diag_set_msg(pp_diag_msg,p->msg);
if ( p->enable_timing_output)
WRH_OPER()->enable_timing_output(ppg,1); /* Enable PPS generation */
TOPS(INST(ppg,0))->enable_timing_output(ppg,1); /* Enable PPS generation */
break;
}
p++;
......
......@@ -5,7 +5,7 @@
static void state_change(struct pp_instance *ppi) {
if ( ppi->state==PPS_SLAVE && ppi->next_state!=PPS_UNCALIBRATED ) {
/* Leave SLAVE state : We must stop the timing output generation */
WRH_OPER()->enable_timing_output(GLBS(ppi),0);
TOPS(ppi)->enable_timing_output(GLBS(ppi),0);
}
}
struct pp_ext_hooks pp_hooks={
......
......@@ -301,13 +301,13 @@ static void control_timing_output(struct pp_instance *ppi) {
offsetFromMasterUs=-offsetFromMasterUs;
if ( offsetFromMasterUs<=ptpPpsThresholdUs ) {
WRH_OPER()->enable_timing_output(GLBS(ppi),1);
TOPS(ppi)->enable_timing_output(GLBS(ppi),1);
} else {
if ( !OPTS(ppi)->forcePpsGen ) { /* if timing output forced, never stop it */
/* disable only if abs(offsetFromMasterMs)>ptpPpsThresholdMs+20% */
ptpPpsThresholdUs+=ptpPpsThresholdUs/5;
if ( offsetFromMasterUs>ptpPpsThresholdUs ) {
WRH_OPER()->enable_timing_output(GLBS(ppi),0);
TOPS(ppi)->enable_timing_output(GLBS(ppi),0);
}
}
}
......
......@@ -486,5 +486,7 @@ struct pp_time_operations wrs_time_ops = {
.adjust = wrs_time_adjust,
.adjust_offset = wrs_time_adjust_offset,
.adjust_freq = wrs_time_adjust_freq,
.calc_timeout = wrs_calc_timeout
.calc_timeout = wrs_calc_timeout,
.get_GM_locked_state= wrs_get_GM_locked_state,
.enable_timing_output=wrs_enable_timing_output
};
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