Tara Subedi c0da3f16d4 PTP HA phc2sys not switching over when primary ptp instance is down
PHC2SYS calls pmc_agent_update periodically, which reads
DEFAULT_DATA_SET, PARENT_DATA_SET, TIME_PROPERTIES_DATA_SET through
pmc_agent_query_dds, pmc_agent_query_pds and pmc_agent_query_utc_
offset. This updates clock's internal data: clock-class, clock-
accuracy, offset, gm clock-class, gm clock-accuracy, gm offset,
time/freq traceability. Based upon these new update, clock
selection algorithm re-triggered.

When ptp4l instance is down, pmc read fails but the clock's internal
data still stays on previous read values and it won't re-trigger
clock selection algorithm.

This commit fixes this issue by resetting clock's internal data when pmc
read fails, and clock selection algorithm re-triggered. This reset
values can be seen in ha socket.

This also increases timeout of pmc_agent_query_dds, pmc_agent_query_pds
and pmc_agent_query_utc_offset polling from 0 to 1000 milliseconds, as
with 0 ms timeout, it would timeout very frequently, which is not
desirable.

TEST PLAN:
PASS: Setup HA PHY2SYS with two PTP4l instances
check clock internal data with:
echo -n "status" | socat -t 1 - UNIX-CONNECT:/var/run/phc-ha
PASS:  start ptp traffic on connected port
Both ptp4l instances has slave portstate
check phc-ha socket, primary clock has been chosen
* stop primary ptp4l instance
user.log shows "timeout reading pmc dds"
check phc-ha socket, secondary clock is selected
and primary clock data has been reset.
* start primary ptp4l instance
check phc-ha socket, primary clock is selected
and primary clock data is changed.
PASS: Setup non-HA PHY2SYS with two PTP4l instances
confirm working normally.

Story: 2011370
Task: 51927

Change-Id: I819b7fa226821f60fac89235e701cb2ff78354ab
Signed-off-by: Tara Subedi <Tara.Subedi@windriver.com>
2025-04-21 14:25:38 -04:00
..
2021-06-28 14:15:22 -04:00