Example Use-Case
This is needed in the cases where T-SC/T-BC Slave might want to listen only on 
PRC clockCLass and
anything beyond that might not be acceptible and would want to go to holdover 
(with SyncE backup or
internal oscillator).

Signed-off-by: Karthikkumar V <kval...@altiostar.com>
Signed-off-by: Ramana Reddy <rre...@altiostar.com>
---
 clock.c             | 10 ++++++++++
 clock.h             |  7 +++++++
 config.c            |  1 +
 configs/default.cfg |  1 +
 ds.h                |  1 +
 port.c              |  5 +++++
 6 files changed, 25 insertions(+)

diff --git a/clock.c b/clock.c
index a34737a..11b94f5 100644
--- a/clock.c
+++ b/clock.c
@@ -132,6 +132,7 @@ struct clock {
        struct interface *udsif;
        LIST_HEAD(clock_subscribers_head, clock_subscriber) subscribers;
        struct monitor *slave_event_monitor;
+       UInteger8 clock_class_threshold;
 };
 
 struct clock the_clock;
@@ -970,6 +971,7 @@ struct clock *clock_create(enum clock_type type, struct 
config *config,
        c->default_dataset.localPriority =
                config_get_int(config, NULL, "G.8275.defaultDS.localPriority");
        c->max_steps_removed = config_get_int(config, NULL,"maxStepsRemoved");
+       c->clock_class_threshold = config_get_int(config, NULL, 
"clockClassThreshold");
 
        /* Harmonize the twoStepFlag with the time_stamping option. */
        if (config_harmonize_onestep(config)) {
@@ -1656,6 +1658,14 @@ UInteger8 clock_max_steps_removed(struct clock *c)
        return c->max_steps_removed;
 }
 
+UInteger8 clock_get_clock_class_threshold(struct clock *c)
+{
+       if(c != NULL){
+               return c->clock_class_threshold;
+       }
+       return CLOCK_CLASS_THRESHOLD_DEFAULT; /* Return Default Value  */
+}
+
 UInteger16 clock_steps_removed(struct clock *c)
 {
        return c->cur.stepsRemoved;
diff --git a/clock.h b/clock.h
index e7daf97..845d54f 100644
--- a/clock.h
+++ b/clock.h
@@ -290,6 +290,13 @@ int clock_slave_only(struct clock *c);
 UInteger8 clock_max_steps_removed(struct clock *c);
 
 /**
+ * Obtain the clock class threshold field from a clock's default data set.
+ * @param c  The clock instance.
+ * @return   Configured clock class threshold value.
+ */
+UInteger8 clock_get_clock_class_threshold(struct clock *c);
+
+/**
  * Obtain the steps removed field from a clock's current data set.
  * @param c  The clock instance.
  * @return   The value of the clock's steps removed field.
diff --git a/config.c b/config.c
index 4095b33..41735d3 100644
--- a/config.c
+++ b/config.c
@@ -332,6 +332,7 @@ struct config_item config_tab[] = {
        GLOB_ITEM_INT("utc_offset", CURRENT_UTC_OFFSET, 0, INT_MAX),
        GLOB_ITEM_INT("verbose", 0, 0, 1),
        GLOB_ITEM_INT("write_phase_mode", 0, 0, 1),
+       GLOB_ITEM_INT("clockClassThreshold", CLOCK_CLASS_THRESHOLD_DEFAULT, 6, 
CLOCK_CLASS_THRESHOLD_DEFAULT),
 };
 
 static struct unicast_master_table *current_uc_mtab;
diff --git a/configs/default.cfg b/configs/default.cfg
index 953d832..473bbb9 100644
--- a/configs/default.cfg
+++ b/configs/default.cfg
@@ -29,6 +29,7 @@ logMinDelayReqInterval        0
 logMinPdelayReqInterval        0
 operLogPdelayReqInterval 0
 announceReceiptTimeout 3
+clockClassThreshold    248
 syncReceiptTimeout     0
 delayAsymmetry         0
 fault_reset_interval   4
diff --git a/ds.h b/ds.h
index 9d9c417..dff6d5e 100644
--- a/ds.h
+++ b/ds.h
@@ -87,6 +87,7 @@ struct parent_ds {
 
 #define CURRENT_UTC_OFFSET  37 /* 1 Jan 2017 */
 #define INTERNAL_OSCILLATOR 0xA0
+#define CLOCK_CLASS_THRESHOLD_DEFAULT 248
 
 struct timePropertiesDS {
        Integer16    currentUtcOffset;
diff --git a/port.c b/port.c
index f44d239..ae2a00e 100644
--- a/port.c
+++ b/port.c
@@ -1861,6 +1861,11 @@ int process_announce(struct port *p, struct ptp_message 
*m)
                return result;
        }
 
+       /* If the clock class is greater than clock_class_threshold , ignore 
this master */
+       if(m->announce.grandmasterClockQuality.clockClass > 
clock_get_clock_class_threshold(p->clock)){
+               return result;
+       }
+
        switch (p->state) {
        case PS_INITIALIZING:
        case PS_FAULTY:
-- 
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