From f575a401b83bbd5d6b6d68824ff22eae8647be16 Mon Sep 17 00:00:00 2001 From: vdahiya12 <67608553+vdahiya12@users.noreply.github.com> Date: Tue, 24 May 2022 15:12:40 -0700 Subject: [PATCH] [Credo][Ycable] changes for synchronizing executing Telemetry API's when mux toggle is inprogress (#280) In this PR, there is a support for adding a mux_toggle_status variable inside the base class for mux_cable. Using this variable the Derived classes for mux_cable can check this and return in case of a mux_toggle_status is in progress. From the higher layer this allows ycabled to synchronize the calls and not let mux_cable toggle to go in conjunction with some of the Telemetry calls. Signed-off-by: vaibhav-dahiya vdahiya@microsoft.com Description Motivation and Context To get the toggle time to a minimum/ not allow i2c to transactions on the cable to collide with each other How Has This Been Tested? Ran the changes on 7050cx3 arista testbed Signed-off-by: vaibhav-dahiya --- sonic_y_cable/credo/y_cable_credo.py | 23 +++++++++++++++++++++++ sonic_y_cable/y_cable_base.py | 10 ++++++++++ 2 files changed, 33 insertions(+) diff --git a/sonic_y_cable/credo/y_cable_credo.py b/sonic_y_cable/credo/y_cable_credo.py index e93c27866445..7b5535b7d058 100644 --- a/sonic_y_cable/credo/y_cable_credo.py +++ b/sonic_y_cable/credo/y_cable_credo.py @@ -695,6 +695,10 @@ def get_active_linked_tor_side(self): TARGET_TOR_B, if TOR B is actively linked and sending traffic. TARGET_UNKNOWN, if checking which side is linked and sending traffic API fails. """ + + if self.mux_toggle_status == self.MUX_TOGGLE_STATUS_INPROGRESS: + return YCableBase.TARGET_UNKNOWN + curr_offset = YCable.OFFSET_ACTIVE_TOR_INDICATOR if self.platform_chassis is not None: @@ -756,6 +760,10 @@ def is_link_active(self, target): a boolean, True if the link is active , False if the link is not active """ + + if self.mux_toggle_status == self.MUX_TOGGLE_STATUS_INPROGRESS: + return YCableBase.TARGET_UNKNOWN + curr_offset = YCable.OFFSET_CHECK_LINK_ACTIVE if self.platform_chassis is not None: @@ -825,6 +833,9 @@ def get_eye_heights(self, target): a list, with EYE values of lane 0 lane 1 lane 2 lane 3 with corresponding index """ + if self.mux_toggle_status == self.MUX_TOGGLE_STATUS_INPROGRESS: + return None + eye_result = [] if self.platform_chassis is not None: @@ -970,6 +981,9 @@ def get_switch_count_total(self, switch_count_type, clear_on_read=False): an integer, the number of times the Y-cable has been switched """ + if self.mux_toggle_status == self.MUX_TOGGLE_STATUS_INPROGRESS: + return 0 + count = 0 if self.platform_chassis is not None: @@ -1785,6 +1799,9 @@ def get_local_temperature(self): an Integer, the temperature of the local MCU """ + if self.mux_toggle_status == self.MUX_TOGGLE_STATUS_INPROGRESS: + return 0 + curr_offset = YCable.OFFSET_INTERNAL_TEMPERATURE if self.platform_chassis is not None: with self.rlock.acquire_timeout(RLocker.ACQUIRE_LOCK_TIMEOUT) as lock_status: @@ -1811,6 +1828,9 @@ def get_nic_voltage(self): a float, the voltage of the NIC MCU """ + if self.mux_toggle_status == self.MUX_TOGGLE_STATUS_INPROGRESS: + return 0 + if self.platform_chassis is not None: with self.rlock.acquire_timeout(RLocker.ACQUIRE_LOCK_TIMEOUT) as lock_status: if lock_status: @@ -1838,6 +1858,9 @@ def get_local_voltage(self): a float, the voltage of the local MCU """ + if self.mux_toggle_status == self.MUX_TOGGLE_STATUS_INPROGRESS: + return 0 + if self.platform_chassis is not None: with self.rlock.acquire_timeout(RLocker.ACQUIRE_LOCK_TIMEOUT) as lock_status: if lock_status: diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index 774c12db5f3a..69892da36633 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -78,6 +78,15 @@ class YCableBase(): FIRMWARE_DOWNLOAD_STATUS_FAILED = 2 + # Valid status values for mux togge + # The mux_toggle_status variable should be assigned/used + # one of these predefined values inside toggle/telemetry routine + # as to signify what is the current status of toggle in progress + + MUX_TOGGLE_STATUS_NOT_INITIATED_OR_FINISHED = 0 + MUX_TOGGLE_STATUS_INPROGRESS = 1 + + # definitions of PRBS run modes PRBS_DIRECTION_BOTH = 0 PRBS_DIRECTION_GENERATOR = 1 @@ -96,6 +105,7 @@ def __init__(self, port, logger): self.port = port self._logger = logger self.download_firmware_status = self.FIRMWARE_DOWNLOAD_STATUS_NOT_INITIATED_OR_FINISHED + self.mux_toggle_status = self.MUX_TOGGLE_STATUS_NOT_INITIATED_OR_FINISHED def log_warning(self, msg):