Introduce an event recommending the grand master state.

We already have a grand master state. Adding this event will simplify the
overall logic, since it will avoid the silly requirement to set the
qualification timeout to zero when entering the grand master state.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2011-12-27 11:04:50 +01:00
parent 10753faccf
commit b76c4e108f
4 changed files with 19 additions and 1 deletions

View File

@ -451,7 +451,8 @@ static void handle_state_decision_event(struct clock *c)
break;
case PS_GRAND_MASTER:
clock_update_grandmaster(c);
/*fall through*/
event = EV_RS_GRAND_MASTER;
break;
case PS_MASTER:
event = EV_RS_MASTER;
break;

15
fsm.c
View File

@ -62,6 +62,9 @@ enum port_state ptp_fsm(enum port_state state, enum fsm_event event)
case EV_RS_MASTER:
next = PS_PRE_MASTER;
break;
case EV_RS_GRAND_MASTER:
next = PS_GRAND_MASTER;
break;
case EV_RS_SLAVE:
next = PS_UNCALIBRATED;
break;
@ -129,6 +132,9 @@ enum port_state ptp_fsm(enum port_state state, enum fsm_event event)
case EV_RS_MASTER:
next = PS_PRE_MASTER;
break;
case EV_RS_GRAND_MASTER:
next = PS_GRAND_MASTER;
break;
case EV_RS_SLAVE:
next = PS_UNCALIBRATED;
break;
@ -154,6 +160,9 @@ enum port_state ptp_fsm(enum port_state state, enum fsm_event event)
case EV_RS_MASTER:
next = PS_PRE_MASTER;
break;
case EV_RS_GRAND_MASTER:
next = PS_GRAND_MASTER;
break;
case EV_RS_SLAVE:
next = PS_UNCALIBRATED;
break;
@ -182,6 +191,9 @@ enum port_state ptp_fsm(enum port_state state, enum fsm_event event)
case EV_RS_MASTER:
next = PS_PRE_MASTER;
break;
case EV_RS_GRAND_MASTER:
next = PS_GRAND_MASTER;
break;
case EV_RS_SLAVE:
next = PS_UNCALIBRATED;
break;
@ -237,6 +249,7 @@ enum port_state ptp_slave_fsm(enum port_state state, enum fsm_event event)
break;
case EV_ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES:
case EV_RS_MASTER:
case EV_RS_GRAND_MASTER:
case EV_RS_PASSIVE:
next = PS_LISTENING;
break;
@ -258,6 +271,7 @@ enum port_state ptp_slave_fsm(enum port_state state, enum fsm_event event)
break;
case EV_ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES:
case EV_RS_MASTER:
case EV_RS_GRAND_MASTER:
case EV_RS_PASSIVE:
next = PS_LISTENING;
break;
@ -279,6 +293,7 @@ enum port_state ptp_slave_fsm(enum port_state state, enum fsm_event event)
break;
case EV_ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES:
case EV_RS_MASTER:
case EV_RS_GRAND_MASTER:
case EV_RS_PASSIVE:
next = PS_LISTENING;
break;

1
fsm.h
View File

@ -49,6 +49,7 @@ enum fsm_event {
EV_SYNCHRONIZATION_FAULT,
EV_MASTER_CLOCK_SELECTED,
EV_RS_MASTER,
EV_RS_GRAND_MASTER,
EV_RS_SLAVE,
EV_RS_PASSIVE,
};

1
util.c
View File

@ -48,6 +48,7 @@ char *ev_str[] = {
"SYNCHRONIZATION_FAULT",
"MASTER_CLOCK_SELECTED",
"RS_MASTER",
"RS_GRAND_MASTER",
"RS_SLAVE",
"RS_PASSIVE",
};