integ/base/linuxptp/debian/patches/0024-pmc_agent-Perform-time-comparison-using-positive-log.patch
Tara Subedi 12e86c6fa5 PTP: smooth/transparent HA switchover
Currently we have following inconsistency between linuxptp and
ptp-notification app.
1) pmc_agent.cc: PMC polling interval (PMC_UPDATE_INTERVAL of 60
sec on pmc_agent_update)
2) ptp-notification app: 'overalltracker_context': {'holdover_seconds':
'15'}

In context of HA switchover, there is pmc polling in 60 sec interval
(pmc_agent_update uses PMC_UPDATE_INTERVAL i.e 60s ). This means when
primary ptp source lost, it would take 60 sec to switchover to secondary
clock.
On ptp-application app side, we have 'ptptracker_context':
{'holdover_seconds': 15} 'overalltracker_context': {'holdover_seconds':
'15'} With this, when the selected ptp source is lost more than 15 sec,
the ptp state and overall state would go holdover and then freerun.

For smooth transition, PMC_UPDATE_INTERVAL should be <<
holdover_seconds. This commit introduces configurable value for
PMC_UPDATE_INTERVAL with "phc2sys .. -p <int value [1, 3600]>",
and without configuration, the default value would be of 7 sec.

TEST PLAN:
PASS: deploy PTP with HA phy2sys parameter of "-p 60"
        or with file global parameter "pmc_update_interval_sec 60"
      stop primary ptp4l instance and check users.log to see
      the "timeout reading pmc" in 60 secs.
PASS: deploy PTP with HA Phy2sys without parameter of "-p"
      stop primary ptp4l instance and check users.log to see
      the "timeout reading pmc" in 7 secs.
      check HA switchover happens in 7 secs, and overall
      state won't change from Locked to holdover/freerun.

Story: 2011370
Task: 52061

Change-Id: I8a9123b15acbbff41954db42822b9f501cd5f2c9
Signed-off-by: Tara Nath Subedi <tara.subedi@windriver.com>
2025-04-29 15:45:08 -04:00

40 lines
1.1 KiB
Diff

From: Andre Mauricio Zelak <andre.zelak@windriver.com>
Date: Mon, 12 Jun 2023 15:35:23 -0300
Subject: [PATCH 24/63] pmc_agent: Perform time comparison using positive
logic.
In the update_pmc_node() method, reduce the expression
!(x < y) to (x >= y).
While we're at it, clean the coding style as well.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
[commit fb92fec7cef9ee3345950c2633a7781b8bd3ca08 upstream]
Signed-off-by: Andre Mauricio Zelak <andre.zelak@windriver.com>
---
pmc_agent.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/pmc_agent.c b/pmc_agent.c
index df3a562..ea6b3b7 100644
--- a/pmc_agent.c
+++ b/pmc_agent.c
@@ -351,12 +351,13 @@ int update_pmc_node(struct pmc_agent *node)
}
ts = tp.tv_sec * NS_PER_SEC + tp.tv_nsec;
- if (!(ts - node->pmc_last_update < PMC_UPDATE_INTERVAL)) {
+ if (ts - node->pmc_last_update >= PMC_UPDATE_INTERVAL) {
if (node->stay_subscribed) {
renew_subscription(node, 0);
}
- if (run_pmc_get_utc_offset(node, 0) > 0)
+ if (run_pmc_get_utc_offset(node, 0) > 0) {
node->pmc_last_update = ts;
+ }
}
return 0;