Skip to content

Commit cdabd09

Browse files
authored
[xcvrd] Change the y_cable presence logic to use "mux_cable" table as identifier from Config DB (#176)
* [xcvrd] Change the y_cable presence logic to use "mux_cable" table as identfier from Config DB This PR changes the logic to use "mux_cable" table as identifier, and only those ports which have this table inside config DB and key pair of "state:auto/active" will be processed as having a Y-Cable port. The earlier logic was using the PORT table tag with a mux_cable:true key-value pair. Description change the logic to initiate Y-Cable logic Motivation and Context Required for changing the logic, so that this can be integrated with images which don't support "mux_cable" tag inside config DB Signed-off-by: vaibhav-dahiya <vdahiya@microsoft.com>
1 parent 4be4306 commit cdabd09

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

sonic-xcvrd/xcvrd/xcvrd_utilities/y_cable_helper.py

+14-8
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,9 @@ def check_identifier_presence_and_update_mux_table_entry(state_db, port_tbl, y_c
282282
else:
283283
# Convert list of tuples to a dictionary
284284
mux_table_dict = dict(fvs)
285-
if "mux_cable" in mux_table_dict:
286-
val = mux_table_dict.get("mux_cable", None)
287-
if val == "true":
285+
if "state" in mux_table_dict:
286+
val = mux_table_dict.get("state", None)
287+
if val in ["active", "auto"]:
288288

289289
y_cable_asic_table = y_cable_tbl.get(asic_index, None)
290290
mux_asic_table = mux_tbl.get(asic_index, None)
@@ -314,6 +314,9 @@ def check_identifier_presence_and_update_mux_table_entry(state_db, port_tbl, y_c
314314
logical_port_name, y_cable_tbl[asic_index])
315315
post_port_mux_info_to_db(logical_port_name, mux_tbl[asic_index])
316316
post_port_mux_static_info_to_db(logical_port_name, static_tbl[asic_index])
317+
else:
318+
helper_logger.log_warning(
319+
"Could not retreive active or auto value for state kvp for {}, inside MUX_CABLE table".format(logical_port_name))
317320

318321

319322
def check_identifier_presence_and_delete_mux_table_entry(state_db, port_tbl, asic_index, logical_port_name, y_cable_presence, delete_change_event):
@@ -373,7 +376,7 @@ def init_ports_status_for_y_cable(platform_sfp, platform_chassis, y_cable_presen
373376
for namespace in namespaces:
374377
asic_id = multi_asic.get_asic_index_from_namespace(namespace)
375378
config_db[asic_id] = daemon_base.db_connect("CONFIG_DB", namespace)
376-
port_tbl[asic_id] = swsscommon.Table(config_db[asic_id], "PORT")
379+
port_tbl[asic_id] = swsscommon.Table(config_db[asic_id], "MUX_CABLE")
377380
port_table_keys[asic_id] = port_tbl[asic_id].getKeys()
378381

379382
# Init PORT_STATUS table if ports are on Y cable
@@ -414,7 +417,7 @@ def change_ports_status_for_y_cable_change_event(port_dict, y_cable_presence, st
414417
for namespace in namespaces:
415418
asic_id = multi_asic.get_asic_index_from_namespace(namespace)
416419
config_db[asic_id] = daemon_base.db_connect("CONFIG_DB", namespace)
417-
port_tbl[asic_id] = swsscommon.Table(config_db[asic_id], "PORT")
420+
port_tbl[asic_id] = swsscommon.Table(config_db[asic_id], "MUX_CABLE")
418421
port_table_keys[asic_id] = port_tbl[asic_id].getKeys()
419422

420423
# Init PORT_STATUS table if ports are on Y cable and an event is received
@@ -518,9 +521,9 @@ def check_identifier_presence_and_update_mux_info_entry(state_db, mux_tbl, asic_
518521
else:
519522
# Convert list of tuples to a dictionary
520523
mux_table_dict = dict(fvs)
521-
if "mux_cable" in mux_table_dict:
522-
val = mux_table_dict.get("mux_cable", None)
523-
if val == "true":
524+
if "state" in mux_table_dict:
525+
val = mux_table_dict.get("state", None)
526+
if val in ["active", "auto"]:
524527

525528
if mux_tbl.get(asic_index, None) is not None:
526529
# fill in the newly found entry
@@ -535,6 +538,9 @@ def check_identifier_presence_and_update_mux_info_entry(state_db, mux_tbl, asic_
535538
mux_tbl[asic_id] = swsscommon.Table(state_db[asic_id], MUX_CABLE_INFO_TABLE)
536539
# fill the newly found entry
537540
post_port_mux_info_to_db(logical_port_name, mux_tbl[asic_index])
541+
else:
542+
helper_logger.log_warning(
543+
"Could not retreive active or auto value for state kvp for {}, inside MUX_CABLE table".format(logical_port_name))
538544

539545

540546
def get_firmware_dict(physical_port, target, side, mux_info_dict):

0 commit comments

Comments
 (0)