Commit 4be60dc4 authored by Sven Meier's avatar Sven Meier

bmc: clock clas changing in gm mode changed, variance back to 0x8000

The clock class goes only to 6 if realy in gm mode, so not even passive
The variance was changed back to 0x8000 until computed
parent 9aab76b3
......@@ -228,8 +228,8 @@ int wrc_ptp_start()
/* just tell that the link is up, if not it will anyhow not receive anything */
ppi->link_up = TRUE;
ppi->state = PPS_INITIALIZING;
wr_servo_reset(ppi);
ptp_enabled = 1;
return 0;
}
......@@ -249,6 +249,8 @@ int wrc_ptp_stop()
/* just tell that the link is down now */
ppi->link_up = FALSE;
ptp_enabled = 0;
ppi->next_state = PPS_DISABLED;
pp_leave_current_state(ppi);
wr_servo_reset(ppi);
pp_close_globals(&ppg_static);
......
......@@ -53,6 +53,8 @@ static int run_all_state_machines(struct pp_globals *ppg)
ppi->state = PPS_INITIALIZING;
}
else {
ppi->next_state = PPS_DISABLED;
pp_leave_current_state(ppi);
ppi->n_ops->exit(ppi);
ppi->frgn_rec_num = 0;
ppi->frgn_rec_best = 0;
......
......@@ -85,7 +85,7 @@ get_current_state_table_item(struct pp_instance *ppi)
/*
* Returns delay to next state, which is always zero.
*/
static int leave_current_state(struct pp_instance *ppi)
int pp_leave_current_state(struct pp_instance *ppi)
{
/* If something has to be done in an extension */
if (pp_hooks.state_change)
......@@ -263,7 +263,7 @@ int pp_state_machine(struct pp_instance *ppi, void *buf, int len)
}
if (ppi->state != ppi->next_state)
return leave_current_state(ppi);
return pp_leave_current_state(ppi);
if (!len)
ppi->received_ptp_header.messageType = PPM_NO_MESSAGE;
......@@ -275,7 +275,7 @@ int pp_state_machine(struct pp_instance *ppi, void *buf, int len)
/* done: if new state mark it, and enter it now (0 ms) */
if (ppi->state != ppi->next_state)
return leave_current_state(ppi);
return pp_leave_current_state(ppi);
/* run bmc independent of state, and since not message driven do this
* here 9.2.6.8 */
......@@ -284,7 +284,7 @@ int pp_state_machine(struct pp_instance *ppi, void *buf, int len)
/* done: if new state mark it, and enter it now (0 ms) */
if (ppi->state != ppi->next_state)
return leave_current_state(ppi);
return pp_leave_current_state(ppi);
}
pp_diag_fsm(ppi, ip->name, STATE_LOOP, 0);
......
......@@ -39,7 +39,10 @@
#define PP_DEFAULT_CLOCK_ACCURACY 0xFE
#define PP_DEFAULT_PRIORITY1 128
#define PP_DEFAULT_PRIORITY2 128
#define PP_DEFAULT_CLOCK_VARIANCE 0xFFFF /* not computed */
#define PP_DEFAULT_CLOCK_VARIANCE 0x8000 /* FIXME shall be set to
* 0xFFFF once getting calculated,
* defining it is not yet calculated
*/
#define PP_NR_FOREIGN_RECORDS 5
#define PP_FOREIGN_MASTER_TIME_WINDOW 4
......
......@@ -200,6 +200,7 @@ typedef struct DSDefault { /* page 65 */
UInteger8 priority2;
UInteger8 domainNumber;
Boolean slaveOnly;
unsigned long ext_specific; /* used by extension */
} DSDefault;
/* Current Data Set */
......
......@@ -448,6 +448,9 @@ extern pp_action pp_initializing, pp_faulty, pp_disabled, pp_listening,
pp_master, pp_passive, pp_uncalibrated,
pp_slave, pp_pclock;;
/* Enforce a state change */
extern int pp_leave_current_state(struct pp_instance *ppi);
/* The engine */
extern int pp_state_machine(struct pp_instance *ppi, void *buf, int len);
......
......@@ -41,6 +41,9 @@ static int wr_open(struct pp_globals *ppg, struct pp_runtime_opts *rt_opts)
/* FIXME check if correct: assign to each instance the same
* wr_data. May I move it to pp_globals? */
INST(ppg, i)->ext_data = ppg->global_ext_data;
/* store clock class */
DSDEF(INST(ppg, i))->ext_specific =
DSDEF(INST(ppg, i))->clockQuality.clockClass;
if (ppi->cfg.ext == PPSI_EXT_WR) {
switch (ppi->role) {
......@@ -299,6 +302,10 @@ static int wr_state_decision(struct pp_instance *ppi, int next_state)
static void wr_state_change(struct pp_instance *ppi)
{
int i;
int nr_of_ports = 0;
int is_gm = 1;
struct pp_globals *ppg = GLBS(ppi);
struct wr_dsport *wrp = WR_DSPOR(ppi);
pp_diag(ppi, ext, 2, "hook: %s\n", __func__);
......@@ -328,6 +335,26 @@ static void wr_state_change(struct pp_instance *ppi)
if (ppi->state == PPS_SLAVE)
wrp->ops->locking_reset(ppi);
if (ppi->state == PPS_MASTER) {
if (DSDEF(ppi)->numberPorts > 1) {
for (i = 0; i < ppg->defaultDS->numberPorts; i++) {
if (INST(ppg, i)->link_up == TRUE) {
nr_of_ports++;
if (INST(ppg, i)->state != PPS_MASTER)
is_gm = 0;
}
}
} else
nr_of_ports = 1;
/* if we change the state reset the clock class if we are not GM anymore */
if ((!is_gm) || (nr_of_ports == 0) ||
(DSDEF(ppi)->numberPorts == 1))
DSDEF(ppi)->clockQuality.clockClass =
DSDEF(ppi)->ext_specific;
}
}
}
......
......@@ -11,7 +11,7 @@
/* Please increment WRS_PPSI_SHMEM_VERSION if you change any exported data
* structure */
#define WRS_PPSI_SHMEM_VERSION 27 /* added locking_reset to wr_operations */
#define WRS_PPSI_SHMEM_VERSION 28 /* added extension to default dataset */
/* Don't include the Following when this file is included in assembler. */
#ifndef __ASSEMBLY__
......
......@@ -65,12 +65,15 @@ void msg_pack_announce_wr_tlv(struct pp_instance *ppi)
buf = ppi->tx_ptp;
/* GM: update clock Class, according to whether we are locked or not */
if (class < PP_CLASS_DEFAULT) {
/* GM: update clock Class, according to whether we are locked or not
* but only for grandmaster clocks in specific clocks that can anyhow
* be only master
*/
if (class <= 127) {
if (DSDEF(ppi)->numberPorts > 1) {
for (i = 0; i < ppg->defaultDS->numberPorts; i++) {
if ((INST(ppg, i)->state == PPS_UNCALIBRATED) ||
(INST(ppg, i)->state == PPS_SLAVE))
if ((INST(ppg, i)->link_up == TRUE) &&
(INST(ppg, i)->state != PPS_MASTER))
is_gm = 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