From: Luigi Mantellini <[email protected]>
The step_window functionality should be defined at the port level because
we cannot assume that different ports have the same sync message rate.
---
clock.c | 13 +++++++++----
clock.h | 5 +++--
config.c | 2 +-
port.c | 18 +++++++++++++++++-
port.h | 7 +++++++
port_private.h | 1 +
6 files changed, 38 insertions(+), 8 deletions(-)
diff --git a/clock.c b/clock.c
index e545a9b..6072ea0 100644
--- a/clock.c
+++ b/clock.c
@@ -710,6 +710,9 @@ static void clock_update_slave(struct clock *c)
pr_info("updating UTC offset to %d", c->tds.currentUtcOffset);
c->utc_offset = c->tds.currentUtcOffset;
}
+
+ // Port changed
+ c->step_window_counter = 0;
}
static int clock_utc_correct(struct clock *c, tmv_t ingress)
@@ -1103,7 +1106,8 @@ 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");
+ c->step_window = 0;
+ c->step_window_counter = 0;
if (c->free_running) {
c->clkid = CLOCK_INVALID;
@@ -1764,8 +1768,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;
}
@@ -1783,7 +1788,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;
@@ -1841,7 +1846,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..0a3b09d 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 on which the message arrived.
* @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 4472d3d..4e964d1 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 10bb9e1..d1ead80 100644
--- a/port.c
+++ b/port.c
@@ -189,6 +189,21 @@ int port_fault_fd(struct port *port)
return port->fault_fd;
}
+int port_step_window(struct port *p)
+{
+ int step_window;
+
+ if ((p->initialLogSyncInterval - p->log_sync_interval) > 0)
+ step_window = (p->step_window << (p->initialLogSyncInterval -
p->log_sync_interval));
+ else
+ step_window = (p->step_window >> (p->log_sync_interval -
p->initialLogSyncInterval));
+
+ if (!step_window && p->step_window)
+ step_window = 1;
+
+ return step_window;
+}
+
struct fdarray *port_fda(struct port *port)
{
return &port->fda;
@@ -1194,7 +1209,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);
@@ -3141,6 +3156,7 @@ struct port *port_open(const char *phc_device,
p->delayMechanism = config_get_int(cfg, p->name, "delay_mechanism");
p->versionNumber = PTP_MAJOR_VERSION;
p->slave_event_monitor = clock_slave_monitor(clock);
+ p->step_window = config_get_int(cfg, p->name, "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 2a98ef4..1d677e5 100644
--- a/port_private.h
+++ b/port_private.h
@@ -104,6 +104,7 @@ struct port {
int inhibit_announce;
int ignore_source_id;
int inhibit_delay_req;
+ int step_window;
/* portDS */
struct PortIdentity portIdentity;
enum port_state state; /*portState*/
--
2.31.1
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel