Commit 1171c3da authored by Jean-Claude BAU's avatar Jean-Claude BAU

Slave/Master transition when announce receipt timer fires

parent d39aa5ee
......@@ -84,6 +84,24 @@ static int is_grand_master(struct pp_instance *ppi) {
return has_master && !has_slave;
}
// Temporary hack for testing
// This function is a copy of the one in the bmc.c file
static int is_ebest(struct pp_globals *ppg, struct pp_frgn_master *foreignMaster) {
if ( ppg->ebest_idx!=-1 ) {
/* ebest exists */
struct pp_instance *ppi_best = INST(ppg, ppg->ebest_idx);
if ( ppi_best->frgn_rec_best!=-1 ) {
/* Should be always true */
struct pp_frgn_master *erbest=&ppi_best->frgn_master[ppi_best->frgn_rec_best];
if ( (erbest==foreignMaster) || bmc_pidcmp(&foreignMaster->sourcePortIdentity,&erbest->sourcePortIdentity)==0)
return 1; /* This is the ebest */
}
}
return 0;
}
/* This function should not be called when externalPortConfiguration is enabled */
int st_com_check_announce_receive_timeout(struct pp_instance *ppi)
{
......@@ -95,7 +113,26 @@ int st_com_check_announce_receive_timeout(struct pp_instance *ppi)
/* 9.2.6.11 b) reset timeout when an announce timeout happened */
pp_timeout_reset(ppi, PP_TO_ANN_RECEIPT);
bmc_flush_erbest(ppi); /* ErBest is removed from the foreign master list and ErBest need to be re-computed */
if ( !is_slaveOnly(DSDEF(ppi)) ) {
//
// HACK for testing BMCA behavior
// TO be discussed with Maciej
//
if (ppi->state==PPS_SLAVE || ppi->state==PPS_UNCALIBRATED) {
/* Before to decide to switch to MASTER state
* we must check if another qualified foreign
* master is available in this port and can become the ebest
*/
struct pp_globals *ppg=GLBS(ppi);
bmc_calculate_ebest(ppg); // To much things done in this call. Need optimization ???
int i=0;
for ( i=0; i < ppi->frgn_rec_num; i++ )
if ( is_ebest(ppg,&ppi->frgn_master[i]) )
return 0; ;
}
if ( is_grand_master(ppi) ) {
bmc_m1(ppi);
} else {
......@@ -105,7 +142,6 @@ int st_com_check_announce_receive_timeout(struct pp_instance *ppi)
} else {
ppi->next_state = PPS_LISTENING;
}
bmc_flush_erbest(ppi); /* ErBest is removed from the foreign master list and ErBest need to be re-computed */
}
}
return 0;
......
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