integ/base/linuxptp/debian/patches/0056-Fixed-event-port-id-map.patch
Andre Mauricio Zelak 06c396fbe3 Fix HA clock selection algorithm
The issue reported is a particular case of a BC configured with
redundant PTP clocks with same priority. When a clock recovers
from a failure, as both clock were configured with same priority
it's expected the active clock source to remain active. But if
the recovered clock presented a better local clock class than
active, it was being selected active. This specific case was fixed.

Closes-bug: 2084723

Test plan: BC with same priority
PASS: Start the PTP service with all clocks out of requirements,
one is selected, no matter which one.
PASS: Then, when the backup clock recovers from failure it is
selected active.
PASS: Then, when the other clock recovers from failure it remains
as backup, no matter the local clock class.
PASS: Then, when the active goes out of requirement, the backup
is set active.

Test plan: GM with same priority
PASS: Start the PTP service with all clocks out of requirements,
one is selected, no matter which one.
PASS: Then, when the backup clock recovers from failure it is selected
active.
PASS: Then, when the other clock recovers from failure it remains
as backup, no matter the local clock class.
PASS: Then, when the active goes out of requirement, the backup
is set active.

Change-Id: Id2568bc8bbaad4cbf15070314f7904d3c3bbd53d
Signed-off-by: Andre Mauricio Zelak <andre.zelak@windriver.com>
2024-10-16 18:19:55 -03:00

79 lines
2.8 KiB
Diff

From: Andre Mauricio Zelak <andre.zelak@windriver.com>
Date: Mon, 15 Jan 2024 16:19:59 -0300
Subject: [PATCH 56/61] 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);