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

Upgrade HA extension

parent 58ebc132
...@@ -307,19 +307,19 @@ int main(int argc, char **argv) ...@@ -307,19 +307,19 @@ int main(int argc, char **argv)
break; break;
case PPSI_PROFILE_HA : case PPSI_PROFILE_HA :
#if CONFIG_HAS_PROFILE_HA #if CONFIG_HAS_PROFILE_HA
if ( !enable_l1Sync(ppi,TRUE) ) if ( !enable_l1Sync(ppi,TRUE) )
goto exit_out_of_memory; goto exit_out_of_memory;
/* Force mandatory attributes - Do not take care of the configuration */ /* Force mandatory attributes - Do not take care of the configuration */
L1E_DSPOR_BS(ppi)->rxCoherentIsRequired = L1E_DSPOR_BS(ppi)->rxCoherentIsRequired =
L1E_DSPOR_BS(ppi)->txCoherentIsRequired = L1E_DSPOR_BS(ppi)->txCoherentIsRequired =
L1E_DSPOR_BS(ppi)->congruentIsRequired= L1E_DSPOR_BS(ppi)->congruentIsRequired=
L1E_DSPOR_BS(ppi)->L1SyncEnabled=TRUE; L1E_DSPOR_BS(ppi)->L1SyncEnabled=TRUE;
L1E_DSPOR_BS(ppi)->optParamsEnabled=FALSE; L1E_DSPOR_BS(ppi)->optParamsEnabled=FALSE;
enable_asymmetryCorrection(ppi,TRUE); enable_asymmetryCorrection(ppi,TRUE);
}
#else #else
fprintf(stderr, "ppsi: Profile HA not supported"); fprintf(stderr, "ppsi: Profile HA not supported");
exit(1); exit(1);
#endif #endif
break; break;
case PPSI_PROFILE_PTP : case PPSI_PROFILE_PTP :
...@@ -331,17 +331,16 @@ int main(int argc, char **argv) ...@@ -331,17 +331,16 @@ int main(int argc, char **argv)
#if CONFIG_HAS_PROFILE_CUSTOM #if CONFIG_HAS_PROFILE_CUSTOM
ppi->protocol_extension=PPSI_EXT_NONE; /* can be changed ...*/ ppi->protocol_extension=PPSI_EXT_NONE; /* can be changed ...*/
#if CONFIG_HAS_EXT_L1SYNC #if CONFIG_HAS_EXT_L1SYNC
if (ppi->cfg.l1SyncEnabled ) { if (ppi->cfg.l1SyncEnabled ) {
if ( !enable_l1Sync(ppi,TRUE) ) if ( !enable_l1Sync(ppi,TRUE) )
goto exit_out_of_memory; goto exit_out_of_memory;
/* Read L1SYNC parameters */ /* Read L1SYNC parameters */
L1E_DSPOR_BS(ppi)->rxCoherentIsRequired =ppi->cfg.l1SyncRxCoherencyIsRequired; L1E_DSPOR_BS(ppi)->rxCoherentIsRequired =ppi->cfg.l1SyncRxCoherencyIsRequired;
L1E_DSPOR_BS(ppi)->txCoherentIsRequired =ppi->cfg.l1SyncTxCoherencyIsRequired; L1E_DSPOR_BS(ppi)->txCoherentIsRequired =ppi->cfg.l1SyncTxCoherencyIsRequired;
L1E_DSPOR_BS(ppi)->congruentIsRequired =ppi->cfg.l1SyncCongruencyIsRequired; L1E_DSPOR_BS(ppi)->congruentIsRequired =ppi->cfg.l1SyncCongruencyIsRequired;
L1E_DSPOR_BS(ppi)->optParamsEnabled=ppi->cfg.l1SyncOptParamsEnabled; L1E_DSPOR_BS(ppi)->optParamsEnabled=ppi->cfg.l1SyncOptParamsEnabled;
if ( L1E_DSPOR_BS(ppi)->optParamsEnabled ) { if ( L1E_DSPOR_BS(ppi)->optParamsEnabled ) {
L1E_DSPOR_OP(ppi)->timestampsCorrectedTx=ppi->cfg.l1SyncOptParamsTimestampsCorrectedTx; L1E_DSPOR_OP(ppi)->timestampsCorrectedTx=ppi->cfg.l1SyncOptParamsTimestampsCorrectedTx;
}
} }
} }
enable_asymmetryCorrection(ppi,ppi->cfg.asymmetryCorrectionEnable); enable_asymmetryCorrection(ppi,ppi->cfg.asymmetryCorrectionEnable);
......
...@@ -86,7 +86,7 @@ static int l1e_init(struct pp_instance *ppi, void *buf, int len) ...@@ -86,7 +86,7 @@ static int l1e_init(struct pp_instance *ppi, void *buf, int len)
/* Init configuration members of L1SyncOptParamsPortDS */ /* Init configuration members of L1SyncOptParamsPortDS */
L1E_DSPOR_OP(ppi)->timestampsCorrectedTx=TRUE; L1E_DSPOR_OP(ppi)->timestampsCorrectedTx=TRUE;
ppi->ext_enabled=TRUE; ppi->pdstate = PP_PDSTATE_WAIT_MSG;
return 0; return 0;
} }
...@@ -104,7 +104,10 @@ static int l1e_handle_signaling(struct pp_instance * ppi, void *buf, int len) ...@@ -104,7 +104,10 @@ static int l1e_handle_signaling(struct pp_instance * ppi, void *buf, int len)
pp_timeout_set(ppi, L1E_TIMEOUT_RX_SYNC, l1e_get_rx_tmo_ms(bds)); pp_timeout_set(ppi, L1E_TIMEOUT_RX_SYNC, l1e_get_rx_tmo_ms(bds));
bds->L1SyncLinkAlive = TRUE; bds->L1SyncLinkAlive = TRUE;
lstate_enable_extension(ppi); if ( ppi->extState==PP_EXSTATE_PTP ) {
// Extension need to be re-enabled
pdstate_enable_extension(ppi);
}
} }
return 0; return 0;
} }
...@@ -123,8 +126,10 @@ static int l1e_handle_resp(struct pp_instance *ppi) ...@@ -123,8 +126,10 @@ static int l1e_handle_resp(struct pp_instance *ppi)
pp_diag(ppi, ext, 2, "hook: %s\n", __func__); pp_diag(ppi, ext, 2, "hook: %s\n", __func__);
/* This correction_field we received is already part of t4 */ /* This correction_field we received is already part of t4 */
if ( ppi->ext_enabled ) { if ( ppi->extState==PP_EXSTATE_ACTIVE ) {
l1e_servo_got_resp(ppi); wr_servo_got_resp(ppi);
if ( ppi->pdstate==PP_PDSTATE_PDETECTED)
pdstate_set_state_pdetected(ppi); // Maintain state Protocol detected on MASTER side
} }
else { else {
pp_servo_got_resp(ppi,OPTS(ppi)->ptpFallbackPpsGen); pp_servo_got_resp(ppi,OPTS(ppi)->ptpFallbackPpsGen);
...@@ -132,8 +137,20 @@ static int l1e_handle_resp(struct pp_instance *ppi) ...@@ -132,8 +137,20 @@ static int l1e_handle_resp(struct pp_instance *ppi)
return 0; return 0;
} }
static int l1e_handle_dreq(struct pp_instance *ppi)
{
pp_diag(ppi, ext, 2, "hook: %s\n", __func__);
if ( ppi->extState==PP_EXSTATE_ACTIVE ) {
if ( ppi->pdstate==PP_PDSTATE_PDETECTED)
pdstate_set_state_pdetected(ppi); // Maintain state Protocol detected on MASTER side
}
return 0;
}
static int l1e_sync_followup(struct pp_instance *ppi) { static int l1e_sync_followup(struct pp_instance *ppi) {
if ( ppi->ext_enabled ) { if ( ppi->extState==PP_EXSTATE_ACTIVE ) {
l1e_servo_got_sync(ppi); l1e_servo_got_sync(ppi);
} }
else { else {
...@@ -159,9 +176,11 @@ static int l1e_handle_sync(struct pp_instance *ppi) ...@@ -159,9 +176,11 @@ static int l1e_handle_sync(struct pp_instance *ppi)
static int l1e_handle_presp(struct pp_instance *ppi) static int l1e_handle_presp(struct pp_instance *ppi)
{ {
/* FIXME: verify that last-received cField is already accounted for */ if ( ppi->extState==PP_EXSTATE_ACTIVE ) {
if ( ppi->ext_enabled )
l1e_servo_got_presp(ppi); l1e_servo_got_presp(ppi);
if ( ppi->pdstate==PP_PDSTATE_PDETECTED)
pdstate_set_state_pdetected(ppi); // Maintain state Protocol detected on MASTER side
}
else else
pp_servo_got_presp(ppi); pp_servo_got_presp(ppi);
return 0; return 0;
...@@ -181,34 +200,38 @@ static void l1e_state_change(struct pp_instance *ppi) { ...@@ -181,34 +200,38 @@ static void l1e_state_change(struct pp_instance *ppi) {
pp_diag(ppi, ext, 2, "hook: %s\n", __func__); pp_diag(ppi, ext, 2, "hook: %s\n", __func__);
if ( !ppi->ext_enabled) if ( ppi->extState==PP_EXSTATE_PTP && ppi->next_state==PPS_UNCALIBRATED ) {
return; // Extension need to be re-enabled
switch (ppi->next_state) { pdstate_enable_extension(ppi);
case PPS_DISABLED :
/* In PPSI we go to DISABLE state when the link is down */
/* For the time being, it should be done like this because fsm is not called when the link is down */
L1E_DSPOR(ppi)->basic.next_state=L1SYNC_DISABLED; /* Force L1Sync DISABLE state */
l1e_run_state_machine(ppi,NULL,0);
break;
case PPS_INITIALIZING :
L1E_DSPOR(ppi)->basic.L1SyncState=L1E_DSPOR(ppi)->basic.next_state=L1SYNC_DISABLED;
break;
} }
if ( ppi->state==PPS_SLAVE && ppi->next_state!=PPS_UNCALIBRATED ) { if ( ppi->extState==PP_EXSTATE_ACTIVE ) {
/* Leave SLAVE state : We must stop the PPS generation */ switch (ppi->next_state) {
TOPS(ppi)->enable_timing_output(GLBS(ppi),0); case PPS_DISABLED :
WRH_OPER()->locking_reset(ppi); /* In PPSI we go to DISABLE state when the link is down */
/* For the time being, it should be done like this because fsm is not called when the link is down */
L1E_DSPOR(ppi)->basic.next_state=L1SYNC_DISABLED; /* Force L1Sync DISABLE state */
l1e_run_state_machine(ppi,NULL,0);
break;
case PPS_INITIALIZING :
L1E_DSPOR(ppi)->basic.L1SyncState=L1E_DSPOR(ppi)->basic.next_state=L1SYNC_DISABLED;
break;
}
if ( ppi->state==PPS_SLAVE && ppi->next_state!=PPS_UNCALIBRATED ) {
/* Leave SLAVE state : We must stop the PPS generation */
TOPS(ppi)->enable_timing_output(GLBS(ppi),0);
WRH_OPER()->locking_reset(ppi);
}
} }
} }
static int l1e_new_slave (struct pp_instance *ppi, void *buf, int len) { static int l1e_new_slave (struct pp_instance *ppi, void *buf, int len) {
if ( ppi->ext_enabled ) if ( ppi->extState==PP_EXSTATE_ACTIVE )
l1e_servo_init(ppi); l1e_servo_init(ppi);
return 0; return 0;
} }
static int l1e_require_precise_timestamp(struct pp_instance *ppi) { static int l1e_require_precise_timestamp(struct pp_instance *ppi) {
return ppi->ext_enabled ? L1E_DSPOR_BS(ppi)->L1SyncState==L1SYNC_UP : 0; return ppi->extState==PP_EXSTATE_ACTIVE ? L1E_DSPOR_BS(ppi)->L1SyncState==L1SYNC_UP : 0;
} }
static int l1e_get_tmo_lstate_detection(struct pp_instance *ppi) { static int l1e_get_tmo_lstate_detection(struct pp_instance *ppi) {
...@@ -217,6 +240,23 @@ static int l1e_get_tmo_lstate_detection(struct pp_instance *ppi) { ...@@ -217,6 +240,23 @@ static int l1e_get_tmo_lstate_detection(struct pp_instance *ppi) {
l1e_get_rx_tmo_ms(L1E_DSPOR_BS(ppi)); l1e_get_rx_tmo_ms(L1E_DSPOR_BS(ppi));
} }
static TimeInterval l1e_get_ingress_latency (struct pp_instance *ppi) {
return ppi->timestampCorrectionPortDS.ingressLatency;
}
static TimeInterval l1e_get_egress_latency (struct pp_instance *ppi) {
return ppi->timestampCorrectionPortDS.egressLatency;
}
/* HA extension is compliant with the standard concerning the contents of the correction fields */
static int l1e_is_correction_field_compliant (struct pp_instance *ppi) {
return 1;
}
static int l1e_extension_state_changed( struct pp_instance * ppi) {
return 0;
}
/* The global structure used by ppsi */ /* The global structure used by ppsi */
struct pp_ext_hooks l1e_ext_hooks = { struct pp_ext_hooks l1e_ext_hooks = {
.open = l1e_open, .open = l1e_open,
...@@ -225,6 +265,7 @@ struct pp_ext_hooks l1e_ext_hooks = { ...@@ -225,6 +265,7 @@ struct pp_ext_hooks l1e_ext_hooks = {
.run_ext_state_machine = l1e_run_state_machine, .run_ext_state_machine = l1e_run_state_machine,
.ready_for_slave = l1e_ready_for_slave, .ready_for_slave = l1e_ready_for_slave,
.handle_resp = l1e_handle_resp, .handle_resp = l1e_handle_resp,
.handle_dreq = l1e_handle_dreq,
.handle_sync = l1e_handle_sync, .handle_sync = l1e_handle_sync,
.handle_followup = l1e_handle_followup, .handle_followup = l1e_handle_followup,
.new_slave = l1e_new_slave, .new_slave = l1e_new_slave,
...@@ -234,6 +275,11 @@ struct pp_ext_hooks l1e_ext_hooks = { ...@@ -234,6 +275,11 @@ struct pp_ext_hooks l1e_ext_hooks = {
.state_change = l1e_state_change, .state_change = l1e_state_change,
.servo_reset= l1e_servo_reset, .servo_reset= l1e_servo_reset,
.require_precise_timestamp=l1e_require_precise_timestamp, .require_precise_timestamp=l1e_require_precise_timestamp,
.get_tmo_lstate_detection=l1e_get_tmo_lstate_detection .get_tmo_lstate_detection=l1e_get_tmo_lstate_detection,
.get_ingress_latency=l1e_get_ingress_latency,
.get_egress_latency=l1e_get_egress_latency,
.is_correction_field_compliant=l1e_is_correction_field_compliant,
.extension_state_changed= l1e_extension_state_changed
}; };
...@@ -59,7 +59,7 @@ int l1e_run_state_machine(struct pp_instance *ppi, void *buf, int len) { ...@@ -59,7 +59,7 @@ int l1e_run_state_machine(struct pp_instance *ppi, void *buf, int len) {
int *execute_state_machine=&L1E_DSPOR(ppi)->execute_state_machine; int *execute_state_machine=&L1E_DSPOR(ppi)->execute_state_machine;
int delay; int delay;
if ( !ppi->ext_enabled || ppi->state==PPS_INITIALIZING) if ( ppi->extState!=PP_EXSTATE_ACTIVE || ppi->state==PPS_INITIALIZING)
return INT_MAX; /* Return a big delay. fsm will then not use it */ return INT_MAX; /* Return a big delay. fsm will then not use it */
if ( nextState>=MAX_STATE_ACTIONS) if ( nextState>=MAX_STATE_ACTIONS)
...@@ -281,7 +281,7 @@ static int l1e_handle_state_idle(struct pp_instance *ppi, Boolean new_state){ ...@@ -281,7 +281,7 @@ static int l1e_handle_state_idle(struct pp_instance *ppi, Boolean new_state){
if ( !le1_evt_L1_SYNC_ENABLED(ppi) || le1_evt_L1_SYNC_RESET(ppi) ) { if ( !le1_evt_L1_SYNC_ENABLED(ppi) || le1_evt_L1_SYNC_RESET(ppi) ) {
/* Go to DISABLE state */ /* Go to DISABLE state */
l1e_portDS->basic.next_state=L1SYNC_DISABLED; l1e_portDS->basic.next_state=L1SYNC_DISABLED;
lstate_set_link_failure(ppi); pdstate_disable_extension(ppi);
return 0; /* Treatment required asap */ return 0; /* Treatment required asap */
} }
if ( le1_evt_LINK_OK(ppi) ) { if ( le1_evt_LINK_OK(ppi) ) {
...@@ -379,7 +379,7 @@ static int l1e_handle_state_up(struct pp_instance *ppi, Boolean new_state){ ...@@ -379,7 +379,7 @@ static int l1e_handle_state_up(struct pp_instance *ppi, Boolean new_state){
if ( !le1_evt_LINK_OK(ppi) ) { if ( !le1_evt_LINK_OK(ppi) ) {
/* Go to IDLE state */ /* Go to IDLE state */
next_state=L1SYNC_IDLE; next_state=L1SYNC_IDLE;
lstate_set_link_failure(ppi); pdstate_disable_extension(ppi);
} }
if ( !le1_evt_CONFIG_OK(ppi) ) { if ( !le1_evt_CONFIG_OK(ppi) ) {
/* Return to LINK_ALIVE state */ /* Return to LINK_ALIVE state */
...@@ -397,7 +397,7 @@ static int l1e_handle_state_up(struct pp_instance *ppi, Boolean new_state){ ...@@ -397,7 +397,7 @@ static int l1e_handle_state_up(struct pp_instance *ppi, Boolean new_state){
} }
/* Iterative treatment */ /* Iterative treatment */
lstate_set_link_established(ppi); pdstate_enable_extension(ppi);
wrh_update_correction_values(ppi); wrh_update_correction_values(ppi);
l1e_send_sync_msg(ppi,0); l1e_send_sync_msg(ppi,0);
return pp_next_delay_2(ppi,L1E_TIMEOUT_TX_SYNC, L1E_TIMEOUT_RX_SYNC); /* Return the shorter timeout */ return pp_next_delay_2(ppi,L1E_TIMEOUT_TX_SYNC, L1E_TIMEOUT_RX_SYNC); /* Return the shorter timeout */
......
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