On Thu, Sep 13, 2018 at 08:35:22PM -0700, Richard Cochran wrote: > Yes, I'll get to it as soon as I can. Overall I'm happy with this > series, but I wanted to sit down and think through the automatic > switch to MASTER state that we discussed.
Okay, I took your series and hacked the following diff on top of it. The main difference is that my version doesn't touch clock_poll(). Also, there is no need for the master mode to go into the listening state. In addition, you need to implement the asCapable thing. I suggest turning it into an enum with something like: enum { NOT_CAPABLE, AS_CAPABLE, ALWAYS_CAPABLE } asCapable; Thanks, Richard --- diff --git a/clock.c b/clock.c index eef534a..0f2e319 100644 --- a/clock.c +++ b/clock.c @@ -1136,15 +1136,6 @@ struct clock *clock_create(enum clock_type type, struct config *config, LIST_FOREACH(p, &c->ports, list) { port_dispatch(p, EV_INITIALIZE, 0); - - /* - * Generate an event to trigger a transition from PS_LISTENING - * to the respective PS_MASTER/PS_SLAVE state for BMCA with - * designated master and slave. - */ - if (port_bmca(p) == BMCA_NOOP) { - port_dispatch(p, EV_ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES, 0); - } } port_dispatch(c->uds_port, EV_INITIALIZE, 0); @@ -1511,14 +1502,6 @@ int clock_poll(struct clock *c) if (PS_FAULTY == port_state(p)) { clock_fault_timeout(p, 1); break; - } else if (port_state(p) == PS_LISTENING && - port_bmca(p) == BMCA_NOOP) { - /* - * PS_LISTENING is just a transitory - * state in BMCA with designated master - * and slave. - */ - port_dispatch(p, EV_ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES, 0); } } } diff --git a/configs/automotive-slave.cfg b/configs/automotive-slave.cfg index 9cabe7a..66b6141 100644 --- a/configs/automotive-slave.cfg +++ b/configs/automotive-slave.cfg @@ -28,3 +28,5 @@ BMCA noop slaveOnly 1 inhibit_announce 1 ignore_source_id 1 +announceReceiptTimeout 2 +logAnnounceInterval -20 diff --git a/designated_fsm.c b/designated_fsm.c index a56f962..9ccf4c9 100644 --- a/designated_fsm.c +++ b/designated_fsm.c @@ -36,19 +36,13 @@ enum port_state designated_master_fsm(enum port_state state, next = PS_FAULTY; break; case EV_INIT_COMPLETE: - next = PS_LISTENING; + next = PS_MASTER; break; default: break; } break; - case PS_LISTENING: - if (event == EV_ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES) { - next = PS_MASTER; - } - break; - case PS_FAULTY: if (event == EV_FAULT_CLEARED) { next = PS_INITIALIZING; @@ -113,14 +107,6 @@ enum port_state designated_slave_fsm(enum port_state state, case EV_FAULT_DETECTED: next = PS_FAULTY; break; - /* - * Go to PS_UNCALIBRATED when there is a loss of sync messages. - * This will also be useful in changing the Sync Interval (to - * be implemented). - */ - case EV_ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES: - next = PS_UNCALIBRATED; - break; default: break; } diff --git a/port.c b/port.c index b326b9c..95c1bf8 100644 --- a/port.c +++ b/port.c @@ -743,6 +743,10 @@ static int port_sync_incapable(struct port *p) static int port_is_ieee8021as(struct port *p) { + // HACK - actually need an option for asCapable always true! + if (p->bmca == BMCA_NOOP) { + return 0; + } return p->follow_up_info ? 1 : 0; } @@ -1036,10 +1040,6 @@ static void port_nrate_initialize(struct port *p) int port_set_announce_tmo(struct port *p) { - if (p->inhibit_announce) { - return 0; - } - return set_tmo_random(p->fda.fd[FD_ANNOUNCE_TIMER], p->announceReceiptTimeout, p->announce_span, p->logAnnounceInterval); @@ -1632,6 +1632,9 @@ int port_initialize(struct port *p) /* No need to open rtnl socket on UDS port. */ if (transport_type(p->trp) != TRANS_UDS) { + if (p->bmca == BMCA_NOOP) { + port_set_delay_tmo(p); + } if (p->fda.fd[FD_RTNL] == -1) p->fda.fd[FD_RTNL] = rtnl_open(); if (p->fda.fd[FD_RTNL] >= 0) @@ -2479,9 +2482,14 @@ static enum fsm_event bc_event(struct port *p, int fd_index) case FD_SYNC_RX_TIMER: pr_debug("port %hu: %s timeout", portnum(p), fd_index == FD_SYNC_RX_TIMER ? "rx sync" : "announce"); - if (p->best) + if (p->best) { fc_clear(p->best); - port_set_announce_tmo(p); + } + if (p->inhibit_announce) { + port_clr_tmo(p->fda.fd[FD_ANNOUNCE_TIMER]); + } else { + port_set_announce_tmo(p); + } delay_req_prune(p); if (clock_slave_only(p->clock) && p->delayMechanism != DM_P2P && port_renew_transport(p)) { _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel