Skip to content

Commit

Permalink
[xcvrd] Change the y_cable presence logic to use "mux_cable" table as…
Browse files Browse the repository at this point in the history
… identifier from Config DB (sonic-net#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 <[email protected]>
  • Loading branch information
vdahiya12 authored May 6, 2021
1 parent 4be4306 commit cdabd09
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions sonic-xcvrd/xcvrd/xcvrd_utilities/y_cable_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,9 @@ def check_identifier_presence_and_update_mux_table_entry(state_db, port_tbl, y_c
else:
# Convert list of tuples to a dictionary
mux_table_dict = dict(fvs)
if "mux_cable" in mux_table_dict:
val = mux_table_dict.get("mux_cable", None)
if val == "true":
if "state" in mux_table_dict:
val = mux_table_dict.get("state", None)
if val in ["active", "auto"]:

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


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

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

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

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


def get_firmware_dict(physical_port, target, side, mux_info_dict):
Expand Down

0 comments on commit cdabd09

Please sign in to comment.