Skip to content

Commit

Permalink
[202012][sonic-config-engine] Parse AutoNegotiation element from Link…
Browse files Browse the repository at this point in the history
…Metadata section of minigraph file (#7166)

Backport of #7031 to the 202012 branch

#### Why I did it

To enable parsing the `AutoNegotiation` element from the LinkMetadata section of minigraph file

#### How I did it

Parse the value `AutoNegotiation` element from the `LinkMetadata` section of minigraph file. If the element is present, an `autoneg` key will be added to the port in the `PORT` table of Config DB with a value of either `0` or `1`

If an `autoneg` value is present in port_config.ini, the value from the minigraph will take precedence, overriding that value.

Also remove `AutoNegotiation` and `EnableAutoNegotiation` elements from the `DeviceInfo` section, as we will use this data in the `LinkMetadata` section to determine whether to enable auto-negotiation for a port.
  • Loading branch information
jleveque authored Mar 31, 2021
1 parent 576864b commit 7155d02
Show file tree
Hide file tree
Showing 17 changed files with 1,897 additions and 313 deletions.
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'] = '1' if autoneg.lower() == 'true' else '0'

# 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

0 comments on commit 7155d02

Please sign in to comment.