From 4454aea1d64c429a5a9f424408a9d349d8087ed4 Mon Sep 17 00:00:00 2001 From: yatishkoul Date: Fri, 7 Aug 2026 18:07:07 +0000 Subject: [PATCH] [snappi] Derive TGEN link_training from DUT instead of hardcoding it snappi_dut_base_config hardcodes auto_negotiation.link_training=True for single-DUT testbeds (added in #14361). On optical 400G single-DUT beds where the DUT runs link_training=off (e.g. NH-5010), forcing link training on at the TGEN causes mac_local/remote_fault; the link never trains, ARP never resolves, and every snappi test fails. Read link_training from the DUT CONFIG_DB PORT table (per peer_port) and apply it to the TGEN. Falls back to the previous behavior when the DUT does not set link_training, so beds that do not configure it are unchanged. Tested: test_pfcwd_basic_single_lossless_prio -> 2 passed on an NH-5010 400G single-DUT snappi testbed (previously mac_local/remote_fault, ARP not resolved). --- tests/common/snappi_tests/snappi_fixtures.py | 21 +++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/common/snappi_tests/snappi_fixtures.py b/tests/common/snappi_tests/snappi_fixtures.py index 93df72074ff..469327b3ea5 100755 --- a/tests/common/snappi_tests/snappi_fixtures.py +++ b/tests/common/snappi_tests/snappi_fixtures.py @@ -1208,7 +1208,26 @@ def snappi_dut_base_config(duthost_list, l1_config.speed = 'speed_{}_gbps'.format(speed_gbps) l1_config.ieee_media_defaults = False l1_config.auto_negotiate = False - if is_snappi_multidut(duthost_list): + + # Derive link_training from DUT CONFIG_DB if available, otherwise use legacy defaults + lt_from_dut = None + try: + dut_for_lt = duthost_list[0] if duthost_list else None + if dut_for_lt: + run_facts = dut_for_lt.config_facts(host=dut_for_lt.hostname, source="running")['ansible_facts'] + port_table = run_facts.get('PORT', {}) + for sp in new_snappi_ports: + p = sp.get('peer_port') + lt_val = port_table.get(p, {}).get('link_training') + if lt_val is not None: + lt_from_dut = str(lt_val).lower() in ['on', 'true', 'yes', '1'] + break + except Exception: + pass + + if lt_from_dut is not None: + l1_config.auto_negotiation.link_training = lt_from_dut + elif is_snappi_multidut(duthost_list): l1_config.auto_negotiation.link_training = False else: l1_config.auto_negotiation.link_training = True