Skip to content

Commit 7512a71

Browse files
authored
Enable link training support in sonic-mgmt (sonic-net#23107)
Signed-off-by: Dashuai Zhang <[email protected]>
1 parent 49a808f commit 7512a71

4 files changed

Lines changed: 39 additions & 2 deletions

File tree

ansible/library/generate_golden_config_db.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,23 @@ def generate_lt2_ft2_golden_config_db(self):
623623

624624
return json.dumps({"PORT": port_config}, indent=4)
625625

626+
def generate_t0_f2_golden_config_db(self):
627+
"""
628+
Generate golden_config for t0-f2 to enable link_training on server facing ports.
629+
"""
630+
SUPPORTED_TOPO = ["t0-f2-d40u8"]
631+
if self.topo_name not in SUPPORTED_TOPO:
632+
return "{}"
633+
ori_config = json.loads(self.get_config_from_minigraph())
634+
golden_config = ori_config
635+
golden_config["PORT"] = ori_config.get("PORT", {})
636+
for _, config in golden_config["PORT"].items():
637+
# Enable link_training for server facing ports
638+
if "Server" in config.get("description", ""):
639+
config["link_training"] = "on"
640+
641+
return json.dumps({'PORT': golden_config['PORT']}, indent=4)
642+
626643
def generate(self):
627644
module_msg = "Success to generate golden_config_db.json"
628645
# topo check
@@ -635,6 +652,9 @@ def generate(self):
635652
config = self.generate_smartswitch_golden_config_db()
636653
module_msg = module_msg + " for smartswitch"
637654
self.module.run_command("sudo rm -f {}".format(TEMP_SMARTSWITCH_CONFIG_PATH))
655+
elif "t0-f2" in self.topo_name:
656+
config = self.generate_t0_f2_golden_config_db()
657+
module_msg = module_msg + " for t0-f2"
638658
elif "ft2" in self.topo_name or "lt2" in self.topo_name:
639659
config = self.generate_lt2_ft2_golden_config_db()
640660
elif "t2" in self.topo_name and self.macsec_profile:

ansible/module_utils/graph_utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ def csv_to_graph_facts(self):
264264
end_port_mac = link.get("EndPortMac", None)
265265
autoneg_mode = link.get("AutoNeg")
266266
fec_disable = link.get("FECDisable", False)
267+
linktraining_mode = link.get("LinkTraining", "")
267268

268269
links.setdefault(start_device, {})
269270
links.setdefault(end_device, {})
@@ -293,6 +294,10 @@ def csv_to_graph_facts(self):
293294
start_port_linked_port.update({"autoneg": autoneg_mode})
294295
end_port_linked_port.update({"autoneg": autoneg_mode})
295296

297+
if linktraining_mode:
298+
start_port_linked_port.update({"linktraining": linktraining_mode})
299+
end_port_linked_port.update({"linktraining": linktraining_mode})
300+
296301
if start_port_mac:
297302
start_port_linked_port.update({"mac": start_port_mac})
298303

ansible/roles/fanout/templates/sonic_deploy_202405.j2

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,15 @@
1919
{% if fanout_hwsku == "Arista-720DT-G48S4" and (fanout_port_config[port_name]['lanes'] | int) <= 24 %}
2020
"autoneg": "on",
2121
{% endif %}
22-
{% if fanout_port_config[port_name]['speed'] | default('100000') in ["100000", "400000", "800000"] %}
22+
{% if fanout_port_config[port_name]['speed'] | default('100000') in ["100000", "200000", "400000", "800000"] %}
2323
"fec" : "rs",
2424
{% endif %}
2525
{% if port_name in device_conn[inventory_hostname] %}
26+
{% if 'linktraining' in device_conn[inventory_hostname][port_name] %}
27+
{% if 'on' in device_conn[inventory_hostname][port_name]['linktraining'] %}
28+
"link_training": "on",
29+
{% endif %}
30+
{% endif %}
2631
{% if 'autoneg' in device_conn[inventory_hostname][port_name] %}
2732
{% if 'on' in device_conn[inventory_hostname][port_name]['autoneg'] %}
2833
"autoneg": "on",

ansible/roles/fanout/templates/sonic_deploy_202505.j2

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,17 @@
2222
{% if fanout_hwsku == "Arista-720DT-G48S4" and (fanout_port_config[port_name]['lanes'] | int) <= 24 %}
2323
"autoneg": "on",
2424
{% endif %}
25-
{% if fanout_port_config[port_name]['speed'] | default('100000') == "100000" %}
25+
{% if fanout_port_config[port_name]['speed'] | default('100000') in ["100000", "200000", "400000", "800000"] %}
2626
"fec" : "rs",
2727
{% endif %}
2828
{% if port_name in device_conn[inventory_hostname] %}
29+
{% if 'linktraining' in device_conn[inventory_hostname][port_name] %}
30+
{% if 'on' in device_conn[inventory_hostname][port_name]['linktraining'] %}
31+
"link_training": "on",
32+
{% elif 'off' in device_conn[inventory_hostname][port_name]['linktraining'] %}
33+
"link_training": "off",
34+
{% endif %}
35+
{% endif %}
2936
{% if 'autoneg' in device_conn[inventory_hostname][port_name] %}
3037
{% if 'on' in device_conn[inventory_hostname][port_name]['autoneg'] %}
3138
"autoneg": "on",

0 commit comments

Comments
 (0)