Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[202012][sonic-config-engine] Parse AutoNegotiation element from LinkMetadata section of minigraph file #7166

Merged
merged 2 commits into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,7 @@ def parse_linkmeta(meta, hname):
has_peer_switch = False
upper_tor_hostname = ''
lower_tor_hostname = ''
auto_negotiation = None

properties = linkmeta.find(str(QName(ns1, "Properties")))
for device_property in properties.findall(str(QName(ns1, "DeviceProperty"))):
Expand All @@ -858,6 +859,8 @@ def parse_linkmeta(meta, hname):
upper_tor_hostname = value
elif name == "LowerTOR":
lower_tor_hostname = value
elif name == "AutoNegotiation":
auto_negotiation = value

linkmetas[port] = {}
if fec_disabled:
Expand All @@ -867,6 +870,8 @@ def parse_linkmeta(meta, hname):
linkmetas[port]["PeerSwitch"] = lower_tor_hostname
else:
linkmetas[port]["PeerSwitch"] = upper_tor_hostname
if auto_negotiation:
linkmetas[port]["AutoNegotiation"] = auto_negotiation
return linkmetas


Expand Down Expand Up @@ -1318,6 +1323,11 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
if port.get('speed') == '100000' and linkmetas.get(alias, {}).get('FECDisabled', '').lower() != 'true':
port['fec'] = 'rs'

# If AutoNegotiation is available in the minigraph, we override any value we may have received from port_config.ini
autoneg = linkmetas.get(alias, {}).get('AutoNegotiation')
if autoneg:
port['autoneg'] = 'on' if autoneg.lower() == 'true' else 'off'

# If connected to a smart cable, get the connection position
for port_name, port in ports.items():
if port_name in mux_cable_ports:
Expand Down
335 changes: 269 additions & 66 deletions src/sonic-config-engine/tests/fg-ecmp-sample-minigraph.xml

Large diffs are not rendered by default.

57 changes: 48 additions & 9 deletions src/sonic-config-engine/tests/multi_npu_data/sample-minigraph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1008,12 +1008,10 @@
</PngDec>
<DeviceInfos>
<DeviceInfo>
<AutoNegotiation>true</AutoNegotiation>
<EthernetInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
<a:EthernetInterface>
<ElementType>DeviceInterface</ElementType>
<AlternateSpeeds i:nil="true"/>
<EnableAutoNegotiation>true</EnableAutoNegotiation>
<EnableFlowControl>true</EnableFlowControl>
<Index>1</Index>
<InterfaceName>Ethernet1/1</InterfaceName>
Expand All @@ -1026,7 +1024,6 @@
<a:EthernetInterface>
<ElementType>DeviceInterface</ElementType>
<AlternateSpeeds i:nil="true"/>
<EnableAutoNegotiation>true</EnableAutoNegotiation>
<EnableFlowControl>true</EnableFlowControl>
<Index>1</Index>
<InterfaceName>Ethernet1/2</InterfaceName>
Expand All @@ -1039,7 +1036,6 @@
<a:EthernetInterface>
<ElementType>DeviceInterface</ElementType>
<AlternateSpeeds i:nil="true"/>
<EnableAutoNegotiation>true</EnableAutoNegotiation>
<EnableFlowControl>true</EnableFlowControl>
<Index>1</Index>
<InterfaceName>Ethernet1/3</InterfaceName>
Expand All @@ -1052,7 +1048,6 @@
<a:EthernetInterface>
<ElementType>DeviceInterface</ElementType>
<AlternateSpeeds i:nil="true"/>
<EnableAutoNegotiation>true</EnableAutoNegotiation>
<EnableFlowControl>true</EnableFlowControl>
<Index>1</Index>
<InterfaceName>Ethernet1/4</InterfaceName>
Expand All @@ -1065,7 +1060,6 @@
<a:EthernetInterface>
<ElementType>DeviceInterface</ElementType>
<AlternateSpeeds i:nil="true"/>
<EnableAutoNegotiation>true</EnableAutoNegotiation>
<EnableFlowControl>true</EnableFlowControl>
<Index>1</Index>
<InterfaceName>Ethernet1/5</InterfaceName>
Expand All @@ -1078,7 +1072,6 @@
<a:EthernetInterface>
<ElementType>DeviceInterface</ElementType>
<AlternateSpeeds i:nil="true"/>
<EnableAutoNegotiation>true</EnableAutoNegotiation>
<EnableFlowControl>true</EnableFlowControl>
<Index>1</Index>
<InterfaceName>Ethernet1/6</InterfaceName>
Expand All @@ -1091,7 +1084,6 @@
<a:EthernetInterface>
<ElementType>DeviceInterface</ElementType>
<AlternateSpeeds i:nil="true"/>
<EnableAutoNegotiation>true</EnableAutoNegotiation>
<EnableFlowControl>true</EnableFlowControl>
<Index>1</Index>
<InterfaceName>Ethernet1/7</InterfaceName>
Expand All @@ -1104,7 +1096,6 @@
<a:EthernetInterface>
<ElementType>DeviceInterface</ElementType>
<AlternateSpeeds i:nil="true"/>
<EnableAutoNegotiation>true</EnableAutoNegotiation>
<EnableFlowControl>true</EnableFlowControl>
<Index>1</Index>
<InterfaceName>Ethernet1/8</InterfaceName>
Expand Down Expand Up @@ -1241,6 +1232,54 @@
</Devices>
<Properties xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
</MetadataDeclaration>
<LinkMetadataDeclaration>
<Link xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
<a:LinkMetadata>
<a:Name i:nil="true"/>
<a:Properties>
<a:DeviceProperty>
<a:Name>AutoNegotiation</a:Name>
<a:Reference i:nil="true"/>
<a:Value>True</a:Value>
</a:DeviceProperty>
</a:Properties>
<a:Key>multi_npu_platform_01:Ethernet1/1;01T2:Ethernet1</a:Key>
</a:LinkMetadata>
<a:LinkMetadata>
<a:Name i:nil="true"/>
<a:Properties>
<a:DeviceProperty>
<a:Name>AutoNegotiation</a:Name>
<a:Reference i:nil="true"/>
<a:Value>True</a:Value>
</a:DeviceProperty>
</a:Properties>
<a:Key>multi_npu_platform_01:Ethernet1/2;01T2:Ethernet2</a:Key>
</a:LinkMetadata>
<a:LinkMetadata>
<a:Name i:nil="true"/>
<a:Properties>
<a:DeviceProperty>
<a:Name>AutoNegotiation</a:Name>
<a:Reference i:nil="true"/>
<a:Value>True</a:Value>
</a:DeviceProperty>
</a:Properties>
<a:Key>multi_npu_platform_01:Ethernet1/5;05T2:Ethernet1</a:Key>
</a:LinkMetadata>
<a:LinkMetadata>
<a:Name i:nil="true"/>
<a:Properties>
<a:DeviceProperty>
<a:Name>AutoNegotiation</a:Name>
<a:Reference i:nil="true"/>
<a:Value>True</a:Value>
</a:DeviceProperty>
</a:Properties>
<a:Key>multi_npu_platform_01:Ethernet1/6;05T2:Ethernet2</a:Key>
</a:LinkMetadata>
</Link>
</LinkMetadataDeclaration>
<Hostname>multi_npu_platform_01</Hostname>
<HwSku>multi-npu-01</HwSku>
</DeviceMiniGraph>
Loading