Skip to content

Commit

Permalink
[ycabled] fix insert events from xcvrd;cleanup some mux toggle logic (#…
Browse files Browse the repository at this point in the history
…287)

Signed-off-by: vaibhav-dahiya vdahiya@microsoft.com
This PR intends to help fix the surplus amount of insert/delete events that ycabled gets it is first spawned, it fixes the logic where an insert event is only handled the way it is collected by xcvrd one time only.

Previously there was a known issue for spurious insert/delete events captured by ycabled on config reload, this PR fixes it

This PR also cleans up some mux toggle blocking other txns logic.

Description
Motivation and Context
How Has This Been Tested?
Unit-tests and deploying changes on Testbed

Additional Information (Optional)
  • Loading branch information
vdahiya12 authored Sep 2, 2022
1 parent 7c0a326 commit ce3b6db
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
10 changes: 10 additions & 0 deletions sonic-ycabled/tests/test_ycable.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,16 @@ def test_DaemonYcable_init_deinit_full(self):
# TODO: fow now we only simply call ycable.init/deinit without any further check, it only makes sure that
# ycable.init/deinit will not raise unexpected exception. In future, probably more check will be added

@patch('ycable.ycable_utilities.y_cable_helper.change_ports_status_for_y_cable_change_event', MagicMock(return_value=0))
def test_handle_state_update_task(self):

port = "Ethernet0"
fvp_dict = {}
y_cable_presence = False
stopping_event = None
rc = handle_state_update_task(port, fvp_dict, y_cable_presence, stopping_event)
assert(rc == None)


def wait_until(total_wait_time, interval, call_back, *args, **kwargs):
wait_time = 0
Expand Down
13 changes: 9 additions & 4 deletions sonic-ycabled/ycable/ycable.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ def detect_port_in_error_status(logical_port_name, status_tbl):
else:
return False

def handle_state_update_task(port, fvp_dict, y_cable_presence, stopping_event):

port_dict = {}
port_dict[port] = fvp_dict.get('status', None)

y_cable_helper.change_ports_status_for_y_cable_change_event(
port_dict, y_cable_presence, stopping_event)

#
# Helper classes ===============================================================
#
Expand Down Expand Up @@ -149,7 +157,6 @@ def task_worker(self, stopping_event, sfp_error_event, y_cable_presence):

# Connect to STATE_DB and listen to ycable transceiver status update tables
state_db, status_tbl= {}, {}
port_dict = {}

sel = swsscommon.Select()

Expand Down Expand Up @@ -195,10 +202,8 @@ def task_worker(self, stopping_event, sfp_error_event, y_cable_presence):
if not fvp_dict:
continue

port_dict[port] = fvp_dict.get('status', None)
handle_state_update_task(port, fvp_dict, y_cable_presence, stopping_event)

y_cable_helper.change_ports_status_for_y_cable_change_event(
port_dict, y_cable_presence, stopping_event)

def task_run(self, sfp_error_event, y_cable_presence):
if self.task_stopping_event.is_set():
Expand Down
3 changes: 3 additions & 0 deletions sonic-ycabled/ycable/ycable_utilities/y_cable_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2274,6 +2274,9 @@ def handle_config_prbs_cmd_arg_tbl_notification(fvp, xcvrd_config_prbs_cmd_arg_t
status = -1
helper_logger.log_warning("Failed to execute the disable prbs API for port {} due to {}".format(physical_port,repr(e)))
elif config_prbs_mode == "reset":

port_instance.mux_toggle_status = port_instance.MUX_TOGGLE_STATUS_NOT_INITIATED_OR_FINISHED
port_instance.download_firmware_status == port_instance.FIRMWARE_DOWNLOAD_STATUS_NOT_INITIATED_OR_FINISHED
with y_cable_port_locks[physical_port]:
try:
status = port_instance.reset(target)
Expand Down

0 comments on commit ce3b6db

Please sign in to comment.