Skip to content

Commit

Permalink
[Credo][Ycable] changes for synchronizing executing Telemetry API's w…
Browse files Browse the repository at this point in the history
…hen 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 <vdahiya@microsoft.com>
  • Loading branch information
vdahiya12 committed May 24, 2022
1 parent b043372 commit f575a40
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
23 changes: 23 additions & 0 deletions sonic_y_cable/credo/y_cable_credo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
10 changes: 10 additions & 0 deletions sonic_y_cable/y_cable_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down

0 comments on commit f575a40

Please sign in to comment.