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