Skip to content

Commit ce3b6db

Browse files
authored
[ycabled] fix insert events from xcvrd;cleanup some mux toggle logic (sonic-net#287)
Signed-off-by: vaibhav-dahiya [email protected] 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)
1 parent 7c0a326 commit ce3b6db

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

sonic-ycabled/tests/test_ycable.py

+10
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,16 @@ def test_DaemonYcable_init_deinit_full(self):
294294
# TODO: fow now we only simply call ycable.init/deinit without any further check, it only makes sure that
295295
# ycable.init/deinit will not raise unexpected exception. In future, probably more check will be added
296296

297+
@patch('ycable.ycable_utilities.y_cable_helper.change_ports_status_for_y_cable_change_event', MagicMock(return_value=0))
298+
def test_handle_state_update_task(self):
299+
300+
port = "Ethernet0"
301+
fvp_dict = {}
302+
y_cable_presence = False
303+
stopping_event = None
304+
rc = handle_state_update_task(port, fvp_dict, y_cable_presence, stopping_event)
305+
assert(rc == None)
306+
297307

298308
def wait_until(total_wait_time, interval, call_back, *args, **kwargs):
299309
wait_time = 0

sonic-ycabled/ycable/ycable.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ def detect_port_in_error_status(logical_port_name, status_tbl):
8080
else:
8181
return False
8282

83+
def handle_state_update_task(port, fvp_dict, y_cable_presence, stopping_event):
84+
85+
port_dict = {}
86+
port_dict[port] = fvp_dict.get('status', None)
87+
88+
y_cable_helper.change_ports_status_for_y_cable_change_event(
89+
port_dict, y_cable_presence, stopping_event)
90+
8391
#
8492
# Helper classes ===============================================================
8593
#
@@ -149,7 +157,6 @@ def task_worker(self, stopping_event, sfp_error_event, y_cable_presence):
149157

150158
# Connect to STATE_DB and listen to ycable transceiver status update tables
151159
state_db, status_tbl= {}, {}
152-
port_dict = {}
153160

154161
sel = swsscommon.Select()
155162

@@ -195,10 +202,8 @@ def task_worker(self, stopping_event, sfp_error_event, y_cable_presence):
195202
if not fvp_dict:
196203
continue
197204

198-
port_dict[port] = fvp_dict.get('status', None)
205+
handle_state_update_task(port, fvp_dict, y_cable_presence, stopping_event)
199206

200-
y_cable_helper.change_ports_status_for_y_cable_change_event(
201-
port_dict, y_cable_presence, stopping_event)
202207

203208
def task_run(self, sfp_error_event, y_cable_presence):
204209
if self.task_stopping_event.is_set():

sonic-ycabled/ycable/ycable_utilities/y_cable_helper.py

+3
Original file line numberDiff line numberDiff line change
@@ -2274,6 +2274,9 @@ def handle_config_prbs_cmd_arg_tbl_notification(fvp, xcvrd_config_prbs_cmd_arg_t
22742274
status = -1
22752275
helper_logger.log_warning("Failed to execute the disable prbs API for port {} due to {}".format(physical_port,repr(e)))
22762276
elif config_prbs_mode == "reset":
2277+
2278+
port_instance.mux_toggle_status = port_instance.MUX_TOGGLE_STATUS_NOT_INITIATED_OR_FINISHED
2279+
port_instance.download_firmware_status == port_instance.FIRMWARE_DOWNLOAD_STATUS_NOT_INITIATED_OR_FINISHED
22772280
with y_cable_port_locks[physical_port]:
22782281
try:
22792282
status = port_instance.reset(target)

0 commit comments

Comments
 (0)