In my setup I have ports with different sync frequency. Making
step_window at port level I can configure a fine grained TS propagation
time on each port.


Signed-off-by: Luigi Mantellini <luigi.mantell...@sm-optics.com>
---
 clock.c        | 8 ++++----
 clock.h        | 5 +++--
 config.c       | 2 +-
 port.c         | 8 +++++++-
 port.h         | 7 +++++++
 port_private.h | 1 +
 6 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/clock.c b/clock.c
index cdde645..d7621fc 100644
--- a/clock.c
+++ b/clock.c
@@ -1111,7 +1111,6 @@ struct clock *clock_create(enum clock_type type,
struct config *config,
        c->kernel_leap = config_get_int(config, NULL, "kernel_leap");
        c->utc_offset = config_get_int(config, NULL, "utc_offset");
        c->time_source = config_get_int(config, NULL, "timeSource");
-       c->step_window = config_get_int(config, NULL, "step_window");
 
        if (c->free_running) {
                c->clkid = CLOCK_INVALID;
@@ -1768,8 +1767,9 @@ int clock_switch_phc(struct clock *c, int
phc_index)
        return 0;
 }
 
-static void clock_step_window(struct clock *c)
+static void clock_step_window(struct clock *c, struct port *p)
 {
+       c->step_window = port_step_window(p);
        if (!c->step_window) {
                return;
        }
@@ -1787,7 +1787,7 @@ static void clock_synchronize_locked(struct clock
*c, double adj)
        }
 }
 
-enum servo_state clock_synchronize(struct clock *c, tmv_t ingress,
tmv_t origin)
+enum servo_state clock_synchronize(struct clock *c, struct port *p,
tmv_t ingress, tmv_t origin)
 {
        enum servo_state state = SERVO_UNLOCKED;
        double adj, weight;
@@ -1845,7 +1845,7 @@ enum servo_state clock_synchronize(struct clock
*c, tmv_t ingress, tmv_t origin)
                                        -tmv_to_nanoseconds(c-
>master_offset));
                }
                tsproc_reset(c->tsproc, 0);
-               clock_step_window(c);
+               clock_step_window(c, p);
                break;
        case SERVO_LOCKED:
                clock_synchronize_locked(c, adj);
diff --git a/clock.h b/clock.h
index 845d54f..4bf01c9 100644
--- a/clock.h
+++ b/clock.h
@@ -314,6 +314,7 @@ int clock_switch_phc(struct clock *c, int
phc_index);
 /**
  * Provide a data point to synchronize the clock.
  * @param c            The clock instance to synchronize.
+ * @param p            The port instance that asks for synchronize.
  * @param ingress      The ingress time stamp on the sync message.
  * @param origin       The reported transmission time of the sync
message,
                        including any corrections.
@@ -322,8 +323,8 @@ int clock_switch_phc(struct clock *c, int
phc_index);
  *                     Pass zero in the case of one step operation.
  * @return             The state of the clock's servo.
  */
-enum servo_state clock_synchronize(struct clock *c, tmv_t ingress,
-                                  tmv_t origin);
+enum servo_state clock_synchronize(struct clock *c, struct port *p,
+                                   tmv_t ingress, tmv_t origin);
 
 /**
  * Inform a slaved clock about the master's sync interval.
diff --git a/config.c b/config.c
index 933b540..a1d70e5 100644
--- a/config.c
+++ b/config.c
@@ -305,7 +305,7 @@ struct config_item config_tab[] = {
        GLOB_ITEM_INT("slaveOnly", 0, 0, 1), /*deprecated*/
        GLOB_ITEM_INT("socket_priority", 0, 0, 15),
        GLOB_ITEM_DBL("step_threshold", 0.0, 0.0, DBL_MAX),
-       GLOB_ITEM_INT("step_window", 0, 0, INT_MAX),
+       PORT_ITEM_INT("step_window", 0, 0, INT_MAX),
        GLOB_ITEM_INT("summary_interval", 0, INT_MIN, INT_MAX),
        PORT_ITEM_INT("syncReceiptTimeout", 0, 0, UINT8_MAX),
        GLOB_ITEM_INT("tc_spanning_tree", 0, 0, 1),
diff --git a/port.c b/port.c
index eb3b319..17362f7 100644
--- a/port.c
+++ b/port.c
@@ -189,6 +189,11 @@ int port_fault_fd(struct port *port)
        return port->fault_fd;
 }
 
+int port_step_window(struct port *p)
+{
+       return p->step_window;
+}
+
 struct fdarray *port_fda(struct port *port)
 {
        return &port->fda;
@@ -1194,7 +1199,7 @@ static void port_synchronize(struct port *p,
        }
 
        last_state = clock_servo_state(p->clock);
-       state = clock_synchronize(p->clock, t2, t1c);
+       state = clock_synchronize(p->clock, p, t2, t1c);
        switch (state) {
        case SERVO_UNLOCKED:
                port_dispatch(p, EV_SYNCHRONIZATION_FAULT, 0);
@@ -3134,6 +3139,7 @@ struct port *port_open(const char *phc_device,
        p->delayMechanism = config_get_int(cfg, p->name,
"delay_mechanism");
        p->versionNumber = PTP_VERSION;
        p->slave_event_monitor = clock_slave_monitor(clock);
+       p->step_window = config_get_int(cfg,
interface_name(interface), "step_window");
 
        if (!port_is_uds(p) && unicast_client_initialize(p)) {
                goto err_transport;
diff --git a/port.h b/port.h
index 37a4e19..e8c5792 100644
--- a/port.h
+++ b/port.h
@@ -252,6 +252,13 @@ struct fdarray *port_fda(struct port *port);
  */
 int port_fault_fd(struct port *port);
 
+/**
+ * Return the step_window starting counter
+ * @param port A port instance.
+ * @return     The step_window value.
+ */
+int port_step_window(struct port *p);
+
 /**
  * Utility function for setting or resetting a file descriptor timer.
  *
diff --git a/port_private.h b/port_private.h
index 842ee06..640bb10 100644
--- a/port_private.h
+++ b/port_private.h
@@ -155,6 +155,7 @@ struct port {
        int inhibit_multicast_service;
        /* slave event monitoring */
        struct monitor *slave_event_monitor;
+       int step_window;
 };
 
 #define portnum(p) (p->portIdentity.portNumber)
-- 
2.30.1





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

Reply via email to