This patch addresses the following issues when ptp4l is run on multiple ports
with jbod and client only mode (i.e. clientOnly=1 and boundary_clock_jbod=1):-

        1.The LISTENING port prints continuously
        "selected best master clock 000000.0000.000003
        updating UTC offset to 37"

        We limited the log such that now it prints only when there is a
        change in the best-master clock.

        2.The port other than SLAVE (LISTENING port) prints an error
        "port 1: master state recommended in slave only mode
        ptp4l[1205469.356]: port 1: defaultDS.priority1 probably misconfigured"
        for every ANNOUNCE RECEIPT Timeout.

        This log is printed when the event EV_RS_MASTER is thrown
        in clientOnly mode. But single port clientOnly mode will never
        hit this event instead EV_RS_GRAND_MASTER will be hit.
        EV_RS_MASTER is thrown when clientOnly=1 and boundary_clock_jbod=1
        which results in continuous printing. So EV_RS_MASTER check when
        clientOnly=1 to print this error can be avoided.

Signed-off-by: Amar Subramanyam <asubraman...@altiostar.com>
Signed-off-by: Karthikkumar Valoor <kval...@altiostar.com>
Signed-off-by: Ramana Reddy <rre...@altiostar.com>
---
 clock.c | 21 ++++++++++-----------
 port.c  |  2 +-
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/clock.c b/clock.c
index e545a9b..04c8951 100644
--- a/clock.c
+++ b/clock.c
@@ -681,12 +681,12 @@ static void clock_update_grandmaster(struct clock *c)
        c->tds.timeSource                       = c->time_source;
 }
 
-static void clock_update_slave(struct clock *c)
+static void clock_update_slave(struct clock *c, int mdiff)
 {
        struct parentDS *pds = &c->dad.pds;
        struct ptp_message *msg;
 
-       if (!c->best)
+       if (!c->best || !mdiff)
                return;
 
        msg                            = TAILQ_FIRST(&c->best->messages);
@@ -1939,14 +1939,6 @@ static void handle_state_decision_event(struct clock *c)
                best_id = c->dds.clockIdentity;
        }
 
-       if (cid_eq(&best_id, &c->dds.clockIdentity)) {
-               pr_notice("selected local clock %s as best master",
-                         cid2str(&best_id));
-       } else {
-               pr_notice("selected best master clock %s",
-                         cid2str(&best_id));
-       }
-
        if (!cid_eq(&best_id, &c->best_id)) {
                clock_freq_est_reset(c);
                tsproc_reset(c->tsproc, 1);
@@ -1957,6 +1949,13 @@ static void handle_state_decision_event(struct clock *c)
                c->master_local_rr = 1.0;
                c->nrr = 1.0;
                fresh_best = 1;
+               if (cid_eq(&best_id, &c->dds.clockIdentity)) {
+                       pr_notice("selected local clock %s as best master",
+                                       cid2str(&best_id));
+               } else {
+                       pr_notice("selected best master clock %s",
+                                       cid2str(&best_id));
+               }
        }
 
        c->best = best;
@@ -1983,7 +1982,7 @@ static void handle_state_decision_event(struct clock *c)
                        event = EV_RS_PASSIVE;
                        break;
                case PS_SLAVE:
-                       clock_update_slave(c);
+                       clock_update_slave(c, fresh_best);
                        event = EV_RS_SLAVE;
                        break;
                default:
diff --git a/port.c b/port.c
index 10bb9e1..650ca00 100644
--- a/port.c
+++ b/port.c
@@ -2531,7 +2531,7 @@ void port_dispatch(struct port *p, enum fsm_event event, 
int mdiff)
 static void bc_dispatch(struct port *p, enum fsm_event event, int mdiff)
 {
        if (clock_slave_only(p->clock)) {
-               if (event == EV_RS_MASTER || event == EV_RS_GRAND_MASTER) {
+               if (event == EV_RS_GRAND_MASTER) {
                        port_slave_priority_warning(p);
                }
        }
-- 
1.8.3.1



_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to