Commit 51bcc78b authored by Maciej Lipinski's avatar Maciej Lipinski

remembring active and backup slave port id. This is to enable recovery of active…

remembring active and backup slave port id. This is to enable recovery of active port (after switchover) and generally to go from one active to another... a bit messy but should work
parent 1e3e168b
......@@ -29,6 +29,8 @@ static int run_all_state_machines(struct pp_globals *ppg)
for (j = 0; j < ppg->nlinks; j++) {
struct pp_instance *ppi = INST(ppg, j);
struct wr_data_t *wd = ((struct wr_data_t *)ppi->ext_data);
int old_lu = WR_DSPOR(ppi)->linkUP;
hexp_port_state_t state;
......@@ -52,8 +54,36 @@ static int run_all_state_machines(struct pp_globals *ppg)
ppi->n_ops->exit(ppi);
ppi->frgn_rec_num = 0;
ppi->frgn_rec_best = -1;
if (ppg->ebest_idx == ppi->port_idx)
wr_servo_reset();
if (ppg->ebest_idx == ppi->port_idx && wd->backup_slave<0)
wr_servo_reset();// if there no backup slave, reset the servo
if(wd->active_slave == ppi->port_idx
&& wd->backup_slave < 0)
{
/*this was the only slave, no backup*/
wd->active_slave = -1;
}
else if(wd->active_slave == ppi->port_idx
&& wd->backup_slave >=0)
{
/* this was active slave and we switchover to backup.
* there is no backup any more */
wd->active_slave = wd->backup_slave;
wd->backup_slave = -1;
}
else if( wd->backup_slave == ppi->port_idx
&& wd->active_slave >=0)
{
/* backup slave went down, we have still active*/
wd->backup_slave = -1;
}
else
{
/* better reset */
wd->active_slave = -1;
wd->backup_slave = -1;
}
pp_diag(ppi, ext, 1, "LinkDOWN, now active slave: %d ; backup slave %d\n",
wd->active_slave, wd->backup_slave);
}
}
......
......@@ -58,7 +58,13 @@ static int wr_open(struct pp_globals *ppg, struct pp_runtime_opts *rt_opts)
else
WR_DSPOR(ppi)->wrConfig = NON_WR;
}
//init info about active/backup slaves - for the switchover thingy
wr_data.active_slave = -1;
wr_data.backup_slave = -1;
for(i=0;i<PP_MAX_LINKS;i++)
wr_data.other_backup_slaves[i] = -1;
return 0;
}
......@@ -125,7 +131,7 @@ static int wr_handle_resp(struct pp_instance *ppi)
* After we adjusted the pps counter, stamps are invalid, so
* we'll have the Unix time instead, marked by "correct"
*/
pp_diag(ppi, servo, 1,"handle response, wrModeOn=%d\n",wrp->wrModeOn);
pp_diag(ppi, ext, 1,"handle response, wrModeOn=%d\n",wrp->wrModeOn);
if (!wrp->wrModeOn) {
if (!ppi->t2.correct || !ppi->t3.correct) {
pp_diag(ppi, servo, 1,
......@@ -149,6 +155,8 @@ static int wr_handle_resp(struct pp_instance *ppi)
static void wr_s1(struct pp_instance *ppi, MsgHeader *hdr, MsgAnnounce *ann)
{
struct wr_data_t *wd = ((struct wr_data_t *)ppi->ext_data);
WR_DSPOR(ppi)->parentIsWRnode =
((ann->ext_specific & WR_NODE_MODE) != NON_WR);
WR_DSPOR(ppi)->parentWrModeOn =
......@@ -158,6 +166,38 @@ static void wr_s1(struct pp_instance *ppi, MsgHeader *hdr, MsgAnnounce *ann)
WR_DSPOR(ppi)->parentWrConfig = ann->ext_specific & WR_NODE_MODE;
DSCUR(ppi)->primarySlavePortNumber =
DSPOR(ppi)->portIdentity.portNumber;
if(ppi->slave_prio == 0)
{
if(wd->active_slave < 0)
{
/*no active slaves, so make it active*/
wd->active_slave = ppi->port_idx;
}
else
{
/* there is active slave...*/
wd->backup_slave = ppi->port_idx;
ppi->slave_prio = 1;
}
}
else
{
//TODO: how to handle a backp port being connected when there is no active ?
if(wd->active_slave == ppi->port_idx) // this guy is active (after failover)
{
/* there is no active slave, promote the backup to active */
ppi->slave_prio = 0;
}
else
{
wd->backup_slave = ppi->port_idx;
//TODO: add here prioritizing of backup slaves..
}
}
pp_diag(ppi, ext, 1, "S1: active slave: %d ; backup slave %d, prio: %d\n",
wd->active_slave, wd->backup_slave,ppi->slave_prio );
}
static int wr_execute_slave(struct pp_instance *ppi)
......
......@@ -169,6 +169,10 @@ typedef struct{
struct wr_data_t {
struct wr_servo_state_t servo_state[18]; // per-port to enable hot-swap backup,
//TODO:use some global
int active_slave; // holds the number of the active slave port
int backup_slave; // backup to be used at failover
int other_backup_slaves[PP_MAX_LINKS]; // holds the list of additional backup slaves
// (in prio of failover)
};
#endif /* __WREXT_WR_API_H__ */
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