integ/base/linuxptp/debian/patches/0056-Fixed-event-port-id-map.patch
Cole Walker aca42c6d4c Implement logic to skip updates with offset spike in ts2phc.
This change allows ts2phc to be configured to ignore timing updates that
have a large offset spike in order to mitigate the resulting timing
skew.

In some circumstances on realtime systems with high CPU load, the
timestamp consumed by ts2phc can be delayed in reaching ts2phc and
results in the offset calculation attempting to speed the clock up by a
large margin.

This change causes ts2phc to ignore updates that would greatly skew the
clock when ts2phc is already in a synchronized state.

The global configuration option "max_phc_update_skip_cnt" is provided to
allow users to specify how many consecutive offset spike incidents will
be ignored before adjusting the clock. The default value is 120. The
behaviour can be disabled by setting max_phc_update_skip_cnt to 0.

This code is ported from a proposed upstream patch found here:
https://sourceforge.net/p/linuxptp/mailman/message/44114092/

Test-plan:
Pass: Verify linuxptp package build
Pass: Deploy ts2phc binary and verify system time sync
Pass: Manually trigger offset spike and verify that ts2phc maintains
stable time sync

Closes-bug: https://bugs.launchpad.net/starlingx/+bug/2059955

Change-Id: I13cd5c3440682ec9256e11449fe62d5fe28f66fa
Signed-off-by: Cole Walker <cole.walker@windriver.com>
2024-04-01 14:53:06 -04:00

83 lines
2.9 KiB
Diff

From adfe866226b758f789a3127447d37e19f442311f Mon Sep 17 00:00:00 2001
From: Andre Mauricio Zelak <andre.zelak@windriver.com>
Date: Mon, 15 Jan 2024 16:19:59 -0300
Subject: [PATCH 56/58] Fixed event port id map
Fixed the port id map in the Port Data Set event handling. The port id
is composed by port number and node index after the HA implementation.
Code tidying. As definition, the port id and the port number are
different. An existing port number variable was rennamed to
prevent missinterpretation.
Code tidying. The HA node state change processing was disabled
when HA feature is not enabled.
Test plan:
PASS: Verify the phc2sys executable recognizes the port in the port
state change event, when -a configuration option is used
PASS: Verify the events in the HA scenario are being recognized
Story: 2010723
Task: 49405
Signed-off-by: Andre Mauricio Zelak <andre.zelak@windriver.com>
---
phc2sys.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/phc2sys.c b/phc2sys.c
index 1f6b6c2..d89fb23 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1638,7 +1638,7 @@ static int do_loop(struct phc2sys_private *priv, struct config *cfg, int subscri
continue;
}
- if (node->new_dds || node->new_tpds || node->new_pds) {
+ if (ha_enabled && (node->new_dds || node->new_tpds || node->new_pds)) {
pr_debug("pmc agent index %d clock state changed by %s%s%s",
node->index, node->new_dds ? "new dds " : "",
node->new_tpds ? "new tpds " : "",
@@ -1789,6 +1789,7 @@ static int phc2sys_recv_subscribed(struct pmc_agent *node, void *context, struct
struct portDS *pds;
struct port *port;
struct clock *clock;
+ unsigned int port_id;
mgt_id = management_tlv_id(msg);
if (mgt_id == excluded)
@@ -1796,7 +1797,8 @@ static int phc2sys_recv_subscribed(struct pmc_agent *node, void *context, struct
switch (mgt_id) {
case MID_PORT_DATA_SET:
pds = (struct portDS *)management_tlv_data(msg);
- port = port_get(priv, pds->portIdentity.portNumber);
+ port_id = PORT_INDEX_TO_PORT_ID(pds->portIdentity.portNumber, node->index);
+ port = port_get(priv, port_id);
if (!port) {
pr_info("received data for unknown port %s",
pid2str(&pds->portIdentity));
@@ -1827,7 +1829,7 @@ static int auto_init_ports(struct phc2sys_private *priv, int add_rt)
struct port *port;
unsigned int i;
struct pmc_agent *node = NULL;
- unsigned int retries, port_number;
+ unsigned int retries, port_id;
LIST_FOREACH(node, &priv->pmc_agents, list) {
retries = 0;
@@ -1875,8 +1877,8 @@ static int auto_init_ports(struct phc2sys_private *priv, int add_rt)
/* ignore ports with software time stamping */
continue;
}
- port_number = PORT_INDEX_TO_PORT_ID(i, node->index);
- port = port_add(priv, port_number, iface);
+ port_id = PORT_INDEX_TO_PORT_ID(i, node->index);
+ port = port_add(priv, port_id, iface);
if (!port)
return -1;
port->state = normalize_state(state);
--
2.30.2