From b76c4e108ff3c8be9eca9349f80e1c460db180ba Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Tue, 27 Dec 2011 11:04:50 +0100 Subject: [PATCH] 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 --- clock.c | 3 ++- fsm.c | 15 +++++++++++++++ fsm.h | 1 + util.c | 1 + 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/clock.c b/clock.c index b6e96cc..a1ede51 100644 --- a/clock.c +++ b/clock.c @@ -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; diff --git a/fsm.c b/fsm.c index 1f142e4..476de45 100644 --- a/fsm.c +++ b/fsm.c @@ -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; diff --git a/fsm.h b/fsm.h index c24d82c..b4b2eff 100644 --- a/fsm.h +++ b/fsm.h @@ -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, }; diff --git a/util.c b/util.c index 0e01e21..f597c49 100644 --- a/util.c +++ b/util.c @@ -48,6 +48,7 @@ char *ev_str[] = { "SYNCHRONIZATION_FAULT", "MASTER_CLOCK_SELECTED", "RS_MASTER", + "RS_GRAND_MASTER", "RS_SLAVE", "RS_PASSIVE", };