Update logic for PTP holdover transition on secondary NICs

If GNSS signal is lost on the primary NIC for the system, then all ptp4l
instances configured to take time from GNSS should transition to
holdover. This was previously only being applied to the ptp4l instance
associated with the primary GNSS NIC.

This fix resolves this by making ptp4l instances on secondary NICs check
the status of the primary NIC GNSS in order to determine if they should
transition to HOLDOVER.

Test plan:
Configure a node with ts2phc, two ptp4l instances (one per NIC) and SMA
connections.

PASS: Disable GNSS and verify that all ptp4l instances transition from
clockClass 6 -> 7 (HOLDOVER) -> 140 (FREERUN)

PASS: Restore GNSS and verify that all ptp4l instances return to
clockClass 6

PASS: Disable SMA connection and verify that ptp4l instances on
secondary NIC transition from 6 -> 7 -> 140

PASS: Restore SMA connection and verify that ptp4l instances return to
clockClass 6

Closes-Bug: 1995011

Signed-off-by: Cole Walker <cole.walker@windriver.com>
Change-Id: I29ac222ab0660c5a6e5691bd463b0a4332290839
This commit is contained in:
Cole Walker 2023-01-23 15:22:41 -05:00
parent f586043ff5
commit cbf2f17f44

View File

@ -1121,6 +1121,12 @@ def check_clock_class(instance):
# Determine the base port of the NIC from the interface
base_port = ctrl.interface[:-1] + '0'
pci_slot = get_pci_slot(base_port)
# Determine the value of the primary NIC PCI slot
primary_nic_pci_slot = None
if obj.capabilities['primary_nic']:
primary_nic_pci_slot = get_pci_slot(obj.capabilities['primary_nic'])
state = CLOCK_STATE_INVALID
instance_type = PTP_INSTANCE_TYPE_CLOCK
if base_port == obj.capabilities['primary_nic']:
@ -1131,6 +1137,11 @@ def check_clock_class(instance):
state = dpll_status[pci_slot][CGU_PIN_SMA1]['pps_cgu_state']
elif dpll_status[pci_slot][CGU_PIN_SMA2]['pps_cgu_state'] != CLOCK_STATE_INVALID:
state = dpll_status[pci_slot][CGU_PIN_SMA2]['pps_cgu_state']
if state != CLOCK_STATE_INVALID and state != CLOCK_STATE_HOLDOVER and primary_nic_pci_slot:
# If the base NIC cgu shows a valid lock state, check the status of the primary_nic
# GNSS connection
state = dpll_status[primary_nic_pci_slot][CGU_PIN_GNSS_1PPS]['eec_cgu_state']
instance_type = PTP_INSTANCE_TYPE_TS2PHC
time_traceable = False
new_clock_class = current_clock_class
if state in [CLOCK_STATE_LOCKED, CLOCK_STATE_LOCKED_HO_ACK,