Skip to content

Commit

Permalink
[ycabled] fix the posting for mux_cable_static_info per downlink when…
Browse files Browse the repository at this point in the history
… ycabled is spawned; synchronizing executing Telemetry API (sonic-net#257)


This PR is meant to do two fixes.

For the Y-cable if presence is missing, currently there is no provision for posting the MUX_CABLE_STATIC_INFO, this PR puts in that fix.

ycabled now utilizes the MUX_CABLE_TABLE: to be notified/prepared to toggle the mux and blocks all ongoing i2c telemetry transactions which could be concurrently running. This PR utilizes 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.

also added a commented sub-routine to poll the mux direction after toggle
dependent on [Credo][Ycable] changes for synchronizing executing Telemetry API's when mux toggle is inprogress sonic-platform-common#280
Signed-off-by: vaibhav-dahiya vdahiya@microsoft.com

Description
Motivation and Context
How Has This Been Tested?
Unit-tests as well as ran changes on Arista7050cx3 testbed

Signed-off-by: vaibhav-dahiya <vdahiya@microsoft.com>
  • Loading branch information
vdahiya12 authored May 24, 2022
1 parent ce217c0 commit 2bcf936
Show file tree
Hide file tree
Showing 2 changed files with 216 additions and 12 deletions.
84 changes: 78 additions & 6 deletions sonic-ycabled/tests/test_y_cable_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,20 @@ def test_y_cable_toggle_mux_torA_update_status_exception(self):

with patch('ycable.ycable_utilities.y_cable_helper.y_cable_port_instances') as port_instance:

port_instance.get.return_value = "simulated_port"
port_instance.toggle_mux_to_tor_a.return_value = Exception(
NotImplementedError)
class PortInstanceHelper():
def __init__(self):
self.EEPROM_ERROR = -1
self.MUX_TOGGLE_STATUS_NOT_INITIATED_OR_FINISHED = 0

# Defining function without self argument creates an exception,
# which is what we want for this test.
def get_mux_direction():
pass
def toggle_mux_to_tor_a():
raise NotImplementedError

port_instance.get.return_value = PortInstanceHelper()


rc = y_cable_toggle_mux_torA(1)

Expand Down Expand Up @@ -379,9 +390,19 @@ def test_y_cable_toggle_mux_torB_no_port_instance(self):
def test_y_cable_toggle_mux_torB_update_status_exception(self):
with patch('ycable.ycable_utilities.y_cable_helper.y_cable_port_instances') as port_instance:

port_instance.get.return_value = "simulated_port"
port_instance.toggle_mux_to_tor_a.return_value = Exception(
NotImplementedError)
class PortInstanceHelper():
def __init__(self):
self.EEPROM_ERROR = -1
self.MUX_TOGGLE_STATUS_NOT_INITIATED_OR_FINISHED = 0

# Defining function without self argument creates an exception,
# which is what we want for this test.
def get_mux_direction():
pass
def toggle_mux_to_tor_a():
raise NotImplementedError

port_instance.get.return_value = PortInstanceHelper()

rc = y_cable_toggle_mux_torB(1)

Expand Down Expand Up @@ -1857,6 +1878,10 @@ def __init__(self):
self.FIRMWARE_DOWNLOAD_STATUS_INPROGRESS = 1
self.FIRMWARE_DOWNLOAD_STATUS_FAILED = 2
self.download_firmware_status = 0
self.MUX_TOGGLE_STATUS_INPROGRESS = 1
self.MUX_TOGGLE_STATUS_FAILED = 2
self.MUX_TOGGLE_STATUS_NOT_INITIATED_OR_FINISHED = 2
self.mux_toggle_status = 0
self.SWITCH_COUNT_MANUAL = "manual"
self.SWITCH_COUNT_AUTO = "auto"

Expand Down Expand Up @@ -1919,6 +1944,10 @@ def __init__(self):
self.FIRMWARE_DOWNLOAD_STATUS_INPROGRESS = 1
self.FIRMWARE_DOWNLOAD_STATUS_FAILED = 2
self.download_firmware_status = 0
self.MUX_TOGGLE_STATUS_INPROGRESS = 1
self.MUX_TOGGLE_STATUS_FAILED = 2
self.MUX_TOGGLE_STATUS_NOT_INITIATED_OR_FINISHED = 2
self.mux_toggle_status = 0
self.SWITCH_COUNT_MANUAL = "manual"
self.SWITCH_COUNT_AUTO = "auto"

Expand Down Expand Up @@ -1979,6 +2008,10 @@ def __init__(self):
self.FIRMWARE_DOWNLOAD_STATUS_INPROGRESS = 1
self.FIRMWARE_DOWNLOAD_STATUS_FAILED = 2
self.download_firmware_status = 0
self.MUX_TOGGLE_STATUS_INPROGRESS = 1
self.MUX_TOGGLE_STATUS_FAILED = 2
self.MUX_TOGGLE_STATUS_NOT_INITIATED_OR_FINISHED = 2
self.mux_toggle_status = 0
self.SWITCH_COUNT_MANUAL = "manual"
self.SWITCH_COUNT_AUTO = "auto"

Expand Down Expand Up @@ -2041,6 +2074,10 @@ def __init__(self):
self.FIRMWARE_DOWNLOAD_STATUS_INPROGRESS = 1
self.FIRMWARE_DOWNLOAD_STATUS_FAILED = 2
self.download_firmware_status = 0
self.MUX_TOGGLE_STATUS_INPROGRESS = 1
self.MUX_TOGGLE_STATUS_NOT_INITIATED_OR_FINISHED = 2
self.MUX_TOGGLE_STATUS_FAILED = 2
self.mux_toggle_status = 0
self.SWITCH_COUNT_MANUAL = "manual"
self.SWITCH_COUNT_AUTO = "auto"

Expand Down Expand Up @@ -2101,6 +2138,10 @@ def __init__(self):
self.FIRMWARE_DOWNLOAD_STATUS_INPROGRESS = 1
self.FIRMWARE_DOWNLOAD_STATUS_FAILED = 2
self.download_firmware_status = 0
self.MUX_TOGGLE_STATUS_INPROGRESS = 1
self.MUX_TOGGLE_STATUS_FAILED = 2
self.MUX_TOGGLE_STATUS_NOT_INITIATED_OR_FINISHED = 2
self.mux_toggle_status = 0
self.SWITCH_COUNT_MANUAL = "manual"
self.SWITCH_COUNT_AUTO = "auto"

Expand Down Expand Up @@ -2163,6 +2204,9 @@ def __init__(self):
self.FIRMWARE_DOWNLOAD_STATUS_INPROGRESS = 1
self.FIRMWARE_DOWNLOAD_STATUS_FAILED = 2
self.download_firmware_status = 0
self.MUX_TOGGLE_STATUS_INPROGRESS = 1
self.MUX_TOGGLE_STATUS_NOT_INITIATED_OR_FINISHED = 2
self.mux_toggle_status = 0
self.SWITCH_COUNT_MANUAL = "manual"
self.SWITCH_COUNT_AUTO = "auto"

Expand Down Expand Up @@ -2223,6 +2267,10 @@ def __init__(self):
self.TARGET_TOR_B = 2
self.FIRMWARE_DOWNLOAD_STATUS_INPROGRESS = 1
self.download_firmware_status = 1
self.MUX_TOGGLE_STATUS_INPROGRESS = 1
self.MUX_TOGGLE_STATUS_FAILED = 2
self.MUX_TOGGLE_STATUS_NOT_INITIATED_OR_FINISHED = 2
self.mux_toggle_status = 0
self.SWITCH_COUNT_MANUAL = "manual"
self.SWITCH_COUNT_AUTO = "auto"

Expand Down Expand Up @@ -2298,6 +2346,10 @@ def __init__(self):
self.TARGET_TOR_B = 2
self.FIRMWARE_DOWNLOAD_STATUS_INPROGRESS = 1
self.download_firmware_status = 1
self.MUX_TOGGLE_STATUS_INPROGRESS = 1
self.MUX_TOGGLE_STATUS_FAILED = 2
self.MUX_TOGGLE_STATUS_NOT_INITIATED_OR_FINISHED = 2
self.mux_toggle_status = 0
self.SWITCH_COUNT_MANUAL = "manual"
self.SWITCH_COUNT_AUTO = "auto"

Expand Down Expand Up @@ -2373,6 +2425,10 @@ def __init__(self):
self.TARGET_TOR_B = 2
self.FIRMWARE_DOWNLOAD_STATUS_INPROGRESS = 1
self.download_firmware_status = 1
self.MUX_TOGGLE_STATUS_INPROGRESS = 1
self.MUX_TOGGLE_STATUS_FAILED = 2
self.MUX_TOGGLE_STATUS_NOT_INITIATED_OR_FINISHED = 2
self.mux_toggle_status = 0
self.SWITCH_COUNT_MANUAL = "manual"
self.SWITCH_COUNT_AUTO = "auto"

Expand Down Expand Up @@ -3887,6 +3943,10 @@ def __init__(self):
self.FIRMWARE_DOWNLOAD_STATUS_INPROGRESS = 1
self.FIRMWARE_DOWNLOAD_STATUS_FAILED = 2
self.download_firmware_status = 0
self.MUX_TOGGLE_STATUS_INPROGRESS = 1
self.MUX_TOGGLE_STATUS_FAILED = 2
self.MUX_TOGGLE_STATUS_NOT_INITIATED_OR_FINISHED = 2
self.mux_toggle_status = 0
self.SWITCH_COUNT_MANUAL = "manual"
self.SWITCH_COUNT_AUTO = "auto"

Expand Down Expand Up @@ -4674,3 +4734,15 @@ def get_mux_direction(self):
rc = handle_show_hwmode_state_cmd_arg_tbl_notification(
fvp, xcvrd_show_hwmode_dir_cmd_sts_tbl, xcvrd_show_hwmode_dir_rsp_tbl, xcvrd_show_hwmode_dir_res_tbl, asic_index, port)
assert(rc == None)

def test_get_mux_cable_static_info_without_presence(self):

rc = get_muxcable_static_info_without_presence()

assert(rc['read_side'] == '-1')
assert(rc['nic_lane1_precursor1'] == 'N/A')
assert(rc['nic_lane1_precursor1'] == 'N/A')
assert(rc['nic_lane1_postcursor1'] == 'N/A')
assert(rc['nic_lane1_postcursor2'] == 'N/A')


Loading

0 comments on commit 2bcf936

Please sign in to comment.