From 8f404ea66cac31b9b3c02342a94c6a7a3e8cdf8a Mon Sep 17 00:00:00 2001 From: Caio Bruchert Date: Fri, 18 Oct 2024 14:40:26 -0300 Subject: [PATCH] Fix GM inconsistent data In some uncommon cases, after disabling GNSS, the CGU information shows the hardware state unstable for over 20 minutes. GNSS-1PPS and DPLL status cycles through several states until stabilizing. During this time, If the clock class is 6 and DPLL moves to freerun, collectd will wrongly change the clock class to 248 but leave clockAccuracy, offsetScaledLogVariance, timeSource, timeTraceable and frequencyTraceable with the previous values. This commit improves this situation with 3 fixes: 1. When changing the clock class to 248 when DPLL is in freerun, set other GM variables accordingly 2. During collectd cycle, read CGU only once per PCI address 3. Fix clock class moving to 248 and back when restarting collectd Test Plan: PASS: ensure GM variables are correct when going from clock class 6 to 248 (freerun) PASS: ensure CGU is read once per PCI address PASS: ensure clock class does not change when restarting collectd Closes-Bug: 2084933 Change-Id: Iad43b883938a5cc7218c1a53a6318ff23cd77cfe Signed-off-by: Caio Bruchert --- collectd-extensions/src/ptp.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/collectd-extensions/src/ptp.py b/collectd-extensions/src/ptp.py index 44e7b76..f479cd9 100755 --- a/collectd-extensions/src/ptp.py +++ b/collectd-extensions/src/ptp.py @@ -1580,7 +1580,7 @@ def handle_ptp4l_g8275_fields(instance): ctrl.ptp4l_announce_settings['timeSource'] = \ G8275_PRC_HOLDOVER[ctrl.ptp4l_prtc_type]['timeSource'] - elif ctrl.ptp4l_prc_state == CLOCK_STATE_INVALID: + elif ctrl.ptp4l_prc_state in [CLOCK_STATE_INVALID, CLOCK_STATE_FREERUN]: # PRC is freerun ctrl.ptp4l_announce_settings['clockAccuracy'] = \ G8275_PRC_FREERUN[ctrl.ptp4l_prtc_type]['clockAccuracy'] @@ -1986,7 +1986,7 @@ def check_clock_class(instance): else: new_clock_class = CLOCK_CLASS_248 - if current_clock_class != new_clock_class: + if state != CLOCK_STATE_INVALID and current_clock_class != new_clock_class: # Set clockClass and timeTraceable data['clockClass'] = new_clock_class data['timeTraceable'] = int(time_traceable) @@ -2177,6 +2177,7 @@ def read_func(): collectd.info("%s no startup alarms found" % PLUGIN) obj.audits += 1 + dpll_checked = set() for instance_name, ctrl in ptpinstances.items(): collectd.debug("%s Instance: %s Instance type: %s" % (PLUGIN, instance_name, ctrl.instance_type)) @@ -2278,7 +2279,9 @@ def read_func(): [PTP_INSTANCE_TYPE_CLOCK, PTP_INSTANCE_TYPE_TS2PHC]): # Update the dpll state for each dpll owned by the instance for dpll in ptpinstances[instance].dpll_pci_slots: - read_dpll_status(dpll) + if dpll not in dpll_checked: + read_dpll_status(dpll) + dpll_checked.add(dpll) if obj.capabilities['primary_nic']: process_ptp_synce(instance)