From e065c55b457be3d073f0224909064264f575c408 Mon Sep 17 00:00:00 2001 From: Boyang Yu Date: Mon, 18 Jul 2022 18:22:37 -0700 Subject: [PATCH] Add test for setting gearbox tx taps by gearbox_config.json --- tests/test_gearbox.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/test_gearbox.py b/tests/test_gearbox.py index 7d5b568661..10e10ed43b 100644 --- a/tests/test_gearbox.py +++ b/tests/test_gearbox.py @@ -70,6 +70,7 @@ def __init__(self, db_id: int, connector: str, gearbox: Gearbox): DVSDatabase.__init__(self, db_id, connector) self.gearbox = gearbox self.ports = {} + self.port_oid_to_intf_idx = {} self._wait_for_gb_asic_db_to_initialize() for connector in self.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT_CONNECTOR"): @@ -88,9 +89,29 @@ def __init__(self, db_id: int, connector: str, gearbox: Gearbox): if intf["system_lanes"] == system_lanes: assert intf["line_lanes"] == line_lanes self.ports[intf["index"]] = (system_port_oid, line_port_oid) + self.port_oid_to_intf_idx[system_port_oid] = (i, True) + self.port_oid_to_intf_idx[line_port_oid] = (i, False) assert len(self.ports) == len(self.gearbox.interfaces) + for serdes in self.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT_SERDES"): + fvs = self.get_entry("ASIC_STATE:SAI_OBJECT_TYPE_PORT_SERDES", serdes) + port_oid = fvs.get("SAI_PORT_SERDES_ATTR_PORT_ID") + intf_idx, is_system = self.port_oid_to_intf_idx[port_oid] + intf = self.gearbox.interfaces[ intf_idx ] + appl_db_key_prefix = 'system_' if is_system else 'line_' + for asic_db_key, appl_db_key_suffix in [ + ("SAI_PORT_SERDES_ATTR_TX_FIR_MAIN", "tx_fir_main"), + ("SAI_PORT_SERDES_ATTR_TX_FIR_PRE1", "tx_fir_pre1"), + ("SAI_PORT_SERDES_ATTR_TX_FIR_PRE2", "tx_fir_pre2"), + ("SAI_PORT_SERDES_ATTR_TX_FIR_POST1", "tx_fir_post1"), + ("SAI_PORT_SERDES_ATTR_TX_FIR_POST2", "tx_fir_post2"), + ]: + if asic_db_key not in fvs: + continue + asic_db_value = fvs.get(asic_db_key).split(":")[-1] + assert intf[appl_db_key_prefix + appl_db_key_suffix] == asic_db_value + def _wait_for_gb_asic_db_to_initialize(self) -> None: """Wait up to 30 seconds for the default fields to appear in ASIC DB.""" def _verify_db_contents():