Commit 6876dba5 authored by Sven Meier's avatar Sven Meier

default dataset: fixed now for spec and wrs

parent a3328e8b
......@@ -52,7 +52,7 @@ void sim_main_loop(struct pp_globals *ppg)
ppi = INST(ppg, j);
ppi->is_new_state = 1;
/* just tell that the links are up */
ppi->linkUp = TRUE;
ppi->link_up = TRUE;
}
delay_ns = run_all_state_machines(ppg) * 1000LL * 1000LL;
......
......@@ -49,7 +49,7 @@ void unix_main_loop(struct pp_globals *ppg)
ppi = INST(ppg, j);
/* just tell that the links are up */
ppi->linkUp = TRUE;
ppi->link_up = TRUE;
/*
* The main loop here is based on select. While we are not
......
......@@ -227,7 +227,7 @@ int wrc_ptp_start()
start_tics = timer_get_tics();
/* just tell that the link is up, if not it will anyhow not receive anything */
ppi->linkUP = TRUE;
ppi->link_up = TRUE;
wr_servo_reset(ppi);
ptp_enabled = 1;
......@@ -247,7 +247,7 @@ int wrc_ptp_stop()
ppi->frgn_rec_num = 0; /* no known master */
/* just tell that the link is down now */
ppi->linkUP = FALSE;
ppi->link_up = FALSE;
ptp_enabled = 0;
wr_servo_reset(ppi);
pp_close_globals(&ppg_static);
......
......@@ -29,7 +29,7 @@ static int run_all_state_machines(struct pp_globals *ppg)
for (j = 0; j < ppg->nlinks; j++) {
struct pp_instance *ppi = INST(ppg, j);
int old_lu = ppi->linkUP;
int old_lu = ppi->link_up;
struct hal_port_state *p;
/* FIXME: we should save this pointer in the ppi itself */
......@@ -40,16 +40,16 @@ static int run_all_state_machines(struct pp_globals *ppg)
continue;
}
ppi->linkUP =
ppi->link_up =
(p->state != HAL_PORT_STATE_LINK_DOWN &&
p->state != HAL_PORT_STATE_DISABLED);
if (old_lu != ppi->linkUP) {
if (old_lu != ppi->link_up) {
pp_diag(ppi, fsm, 1, "iface %s went %s\n",
ppi->iface_name, ppi->linkUP ? "up":"down");
ppi->iface_name, ppi->link_up ? "up":"down");
if (ppi->linkUP) {
if (ppi->link_up) {
ppi->state = PPS_INITIALIZING;
}
else {
......@@ -62,7 +62,7 @@ static int run_all_state_machines(struct pp_globals *ppg)
}
/* Do not call state machine if link is down */
if (ppi->linkUP)
if (ppi->link_up)
delay_ms_j = pp_state_machine(ppi, NULL, 0);
else
delay_ms_j = PP_DEFAULT_NEXT_DELAY_MS;
......
......@@ -180,7 +180,7 @@ struct pp_instance {
UInteger16 sent_seq[__PP_NR_MESSAGES_TYPES]; /* last sent this type */
MsgHeader received_ptp_header;
Boolean linkUP;
Boolean link_up;
char *iface_name; /* for direct actions on hardware */
char *port_name; /* for diagnostics, mainly */
int port_idx;
......
......@@ -25,7 +25,7 @@ void bare_main_loop(struct pp_instance *ppi)
int delay_ms;
/* just tell that the links are up */
ppi->linkUp = TRUE;
ppi->link_up = TRUE;
/*
* The main loop here is based on select. While we are not
* doing anything else but the protocol, this allows extra stuff
......
......@@ -326,7 +326,8 @@ static void wr_state_change(struct pp_instance *ppi)
wrp->parentWrModeOn = FALSE;
wrp->calibrated = !WR_DEFAULT_PHY_CALIBRATION_REQUIRED;
wrp->ops->locking_reset(ppi);
if (ppi->state == PPS_SLAVE)
wrp->ops->locking_reset(ppi);
}
}
......
......@@ -988,7 +988,7 @@ static int bmc_any_port_initializing(struct pp_globals *ppg)
ppi = INST(ppg, i);
if (ppi->linkUP && (ppi->state == PPS_INITIALIZING)) {
if (ppi->link_up && (ppi->state == PPS_INITIALIZING)) {
pp_diag(ppi, bmc, 2, "The first port in INITIALIZING "
"state is %i\n", i);
return 1;
......@@ -1015,7 +1015,7 @@ static void bmc_update_erbest(struct pp_globals *ppg)
frgn_master = ppi->frgn_master;
/* if link is down clear foreign master table */
if ((!ppi->linkUP) && (ppi->frgn_rec_num > 0))
if ((!ppi->link_up) && (ppi->frgn_rec_num > 0))
bmc_flush_frgn_master(ppi);
if (ppi->frgn_rec_num > 0) {
......@@ -1139,7 +1139,7 @@ int bmc(struct pp_instance *ppi)
/* Calulate Ebest Figure 25 */
bmc_update_ebest(ppg);
if (!ppi->linkUP) {
if (!ppi->link_up) {
/* Set it back to initializing */
next_state = PPS_INITIALIZING;
} else if (ret == 1) {
......
......@@ -44,9 +44,10 @@ int pp_initializing(struct pp_instance *ppi, void *buf, int len)
struct pp_runtime_opts *opt = OPTS(ppi);
struct pp_globals *ppg = GLBS(ppi);
int ret = 0;
int i, j;
int i;
unsigned int portidx;
unsigned int remainder;
int initds = 1;
if (ppi->n_ops->init(ppi) < 0) /* it must handle being called twice */
goto failure;
......@@ -54,32 +55,45 @@ int pp_initializing(struct pp_instance *ppi, void *buf, int len)
/* only fill in the data set when initializing */
if (DSDEF(ppi)->numberPorts > 1) {
for (i = 0; i < ppg->defaultDS->numberPorts; i++) {
if (INST(ppg, i)->state != PPS_INITIALIZING) {
/* Clock identity comes from mac address with 0xff:0xfe intermixed */
mac = ppi->ch[PP_NP_GEN].addr;
/* calculate MAC of Port 0 */
portidx = ppi - ppi->glbs->pp_instances;
remainder = portidx;
for (j = 5; j >= 0; j--) {
mac_port1[j] = mac[j] - remainder;
if (mac[j] >= remainder)
remainder = 0;
else
remainder = 1;
}
DSDEF(ppi)->clockIdentity.id[0] = mac_port1[0];
DSDEF(ppi)->clockIdentity.id[1] = mac_port1[1];
DSDEF(ppi)->clockIdentity.id[2] = mac_port1[2];
DSDEF(ppi)->clockIdentity.id[3] = 0xff;
DSDEF(ppi)->clockIdentity.id[4] = 0xfe;
DSDEF(ppi)->clockIdentity.id[5] = mac_port1[3];
DSDEF(ppi)->clockIdentity.id[6] = mac_port1[4];
DSDEF(ppi)->clockIdentity.id[7] = mac_port1[5];
init_parent_ds(ppi);
if ((INST(ppg, i)->state != PPS_INITIALIZING) && (INST(ppg, i)->link_up == TRUE))
initds = 0;
}
}
/*
* Initialize default and parent data set
*/
if (initds)
{
if (DSDEF(ppi)->numberPorts > 1) {
/* Clock identity comes from mac address with 0xff:0xfe intermixed */
mac = ppi->ch[PP_NP_GEN].addr;
/* calculate MAC of Port 0 */
portidx = ppi - ppi->glbs->pp_instances;
remainder = portidx;
for (i = 5; i >= 0; i--) {
mac_port1[i] = mac[i] - remainder;
if (mac[i] >= remainder)
remainder = 0;
else
remainder = 1;
}
}
} else {
/* Clock identity comes from mac address with 0xff:0xfe intermixed */
for (i = 5; i >= 0; i--)
mac_port1[i] = ((unsigned char*)ppi->ch[PP_NP_GEN].addr)[i];
}
DSDEF(ppi)->clockIdentity.id[0] = mac_port1[0];
DSDEF(ppi)->clockIdentity.id[1] = mac_port1[1];
DSDEF(ppi)->clockIdentity.id[2] = mac_port1[2];
DSDEF(ppi)->clockIdentity.id[3] = 0xff;
DSDEF(ppi)->clockIdentity.id[4] = 0xfe;
DSDEF(ppi)->clockIdentity.id[5] = mac_port1[3];
DSDEF(ppi)->clockIdentity.id[6] = mac_port1[4];
DSDEF(ppi)->clockIdentity.id[7] = mac_port1[5];
init_parent_ds(ppi);
}
/*
......
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