Skip to content

Commit 2777e98

Browse files
authored
[201911][sonic-config-engine] Parse AutoNegotiation element from LinkMetadata section of minigraph file (#7047)
Backport of #7031 to the 201911 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.
1 parent c15b5ea commit 2777e98

16 files changed

+1590
-225
lines changed

src/sonic-config-engine/minigraph.py

+10
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ def parse_linkmeta(meta, hname):
633633
for linkmeta in link.findall(str(QName(ns1, "LinkMetadata"))):
634634
port = None
635635
fec_disabled = None
636+
auto_negotiation = None
636637

637638
# Sample: ARISTA05T1:Ethernet1/33;switch-t0:fortyGigE0/4
638639
key = linkmeta.find(str(QName(ns1, "Key"))).text
@@ -652,10 +653,14 @@ def parse_linkmeta(meta, hname):
652653
value = device_property.find(str(QName(ns1, "Value"))).text
653654
if name == "FECDisabled":
654655
fec_disabled = value
656+
elif name == "AutoNegotiation":
657+
auto_negotiation = value
655658

656659
linkmetas[port] = {}
657660
if fec_disabled:
658661
linkmetas[port]["FECDisabled"] = fec_disabled
662+
if auto_negotiation:
663+
linkmetas[port]["AutoNegotiation"] = auto_negotiation
659664
return linkmetas
660665

661666

@@ -1059,6 +1064,11 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None):
10591064
if port.get('speed') == '100000' and linkmetas.get(alias, {}).get('FECDisabled', '').lower() != 'true':
10601065
port['fec'] = 'rs'
10611066

1067+
# If AutoNegotiation is available in the minigraph, we override any value we may have received from port_config.ini
1068+
autoneg = linkmetas.get(alias, {}).get('AutoNegotiation')
1069+
if autoneg:
1070+
port['autoneg'] = '1' if autoneg.lower() == 'true' else '0'
1071+
10621072
# set port description if parsed from deviceinfo
10631073
for port_name in port_descriptions:
10641074
# ignore port not in port_config.ini

src/sonic-config-engine/tests/multi_npu_data/sample-minigraph.xml

+48-9
Original file line numberDiff line numberDiff line change
@@ -1008,12 +1008,10 @@
10081008
</PngDec>
10091009
<DeviceInfos>
10101010
<DeviceInfo>
1011-
<AutoNegotiation>true</AutoNegotiation>
10121011
<EthernetInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
10131012
<a:EthernetInterface>
10141013
<ElementType>DeviceInterface</ElementType>
10151014
<AlternateSpeeds i:nil="true"/>
1016-
<EnableAutoNegotiation>true</EnableAutoNegotiation>
10171015
<EnableFlowControl>true</EnableFlowControl>
10181016
<Index>1</Index>
10191017
<InterfaceName>Ethernet1/1</InterfaceName>
@@ -1026,7 +1024,6 @@
10261024
<a:EthernetInterface>
10271025
<ElementType>DeviceInterface</ElementType>
10281026
<AlternateSpeeds i:nil="true"/>
1029-
<EnableAutoNegotiation>true</EnableAutoNegotiation>
10301027
<EnableFlowControl>true</EnableFlowControl>
10311028
<Index>1</Index>
10321029
<InterfaceName>Ethernet1/2</InterfaceName>
@@ -1039,7 +1036,6 @@
10391036
<a:EthernetInterface>
10401037
<ElementType>DeviceInterface</ElementType>
10411038
<AlternateSpeeds i:nil="true"/>
1042-
<EnableAutoNegotiation>true</EnableAutoNegotiation>
10431039
<EnableFlowControl>true</EnableFlowControl>
10441040
<Index>1</Index>
10451041
<InterfaceName>Ethernet1/3</InterfaceName>
@@ -1052,7 +1048,6 @@
10521048
<a:EthernetInterface>
10531049
<ElementType>DeviceInterface</ElementType>
10541050
<AlternateSpeeds i:nil="true"/>
1055-
<EnableAutoNegotiation>true</EnableAutoNegotiation>
10561051
<EnableFlowControl>true</EnableFlowControl>
10571052
<Index>1</Index>
10581053
<InterfaceName>Ethernet1/4</InterfaceName>
@@ -1065,7 +1060,6 @@
10651060
<a:EthernetInterface>
10661061
<ElementType>DeviceInterface</ElementType>
10671062
<AlternateSpeeds i:nil="true"/>
1068-
<EnableAutoNegotiation>true</EnableAutoNegotiation>
10691063
<EnableFlowControl>true</EnableFlowControl>
10701064
<Index>1</Index>
10711065
<InterfaceName>Ethernet1/5</InterfaceName>
@@ -1078,7 +1072,6 @@
10781072
<a:EthernetInterface>
10791073
<ElementType>DeviceInterface</ElementType>
10801074
<AlternateSpeeds i:nil="true"/>
1081-
<EnableAutoNegotiation>true</EnableAutoNegotiation>
10821075
<EnableFlowControl>true</EnableFlowControl>
10831076
<Index>1</Index>
10841077
<InterfaceName>Ethernet1/6</InterfaceName>
@@ -1091,7 +1084,6 @@
10911084
<a:EthernetInterface>
10921085
<ElementType>DeviceInterface</ElementType>
10931086
<AlternateSpeeds i:nil="true"/>
1094-
<EnableAutoNegotiation>true</EnableAutoNegotiation>
10951087
<EnableFlowControl>true</EnableFlowControl>
10961088
<Index>1</Index>
10971089
<InterfaceName>Ethernet1/7</InterfaceName>
@@ -1104,7 +1096,6 @@
11041096
<a:EthernetInterface>
11051097
<ElementType>DeviceInterface</ElementType>
11061098
<AlternateSpeeds i:nil="true"/>
1107-
<EnableAutoNegotiation>true</EnableAutoNegotiation>
11081099
<EnableFlowControl>true</EnableFlowControl>
11091100
<Index>1</Index>
11101101
<InterfaceName>Ethernet1/8</InterfaceName>
@@ -1241,6 +1232,54 @@
12411232
</Devices>
12421233
<Properties xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
12431234
</MetadataDeclaration>
1235+
<LinkMetadataDeclaration>
1236+
<Link xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
1237+
<a:LinkMetadata>
1238+
<a:Name i:nil="true"/>
1239+
<a:Properties>
1240+
<a:DeviceProperty>
1241+
<a:Name>AutoNegotiation</a:Name>
1242+
<a:Reference i:nil="true"/>
1243+
<a:Value>True</a:Value>
1244+
</a:DeviceProperty>
1245+
</a:Properties>
1246+
<a:Key>multi_npu_platform_01:Ethernet1/1;01T2:Ethernet1</a:Key>
1247+
</a:LinkMetadata>
1248+
<a:LinkMetadata>
1249+
<a:Name i:nil="true"/>
1250+
<a:Properties>
1251+
<a:DeviceProperty>
1252+
<a:Name>AutoNegotiation</a:Name>
1253+
<a:Reference i:nil="true"/>
1254+
<a:Value>True</a:Value>
1255+
</a:DeviceProperty>
1256+
</a:Properties>
1257+
<a:Key>multi_npu_platform_01:Ethernet1/2;01T2:Ethernet2</a:Key>
1258+
</a:LinkMetadata>
1259+
<a:LinkMetadata>
1260+
<a:Name i:nil="true"/>
1261+
<a:Properties>
1262+
<a:DeviceProperty>
1263+
<a:Name>AutoNegotiation</a:Name>
1264+
<a:Reference i:nil="true"/>
1265+
<a:Value>True</a:Value>
1266+
</a:DeviceProperty>
1267+
</a:Properties>
1268+
<a:Key>multi_npu_platform_01:Ethernet1/5;05T2:Ethernet1</a:Key>
1269+
</a:LinkMetadata>
1270+
<a:LinkMetadata>
1271+
<a:Name i:nil="true"/>
1272+
<a:Properties>
1273+
<a:DeviceProperty>
1274+
<a:Name>AutoNegotiation</a:Name>
1275+
<a:Reference i:nil="true"/>
1276+
<a:Value>True</a:Value>
1277+
</a:DeviceProperty>
1278+
</a:Properties>
1279+
<a:Key>multi_npu_platform_01:Ethernet1/6;05T2:Ethernet2</a:Key>
1280+
</a:LinkMetadata>
1281+
</Link>
1282+
</LinkMetadataDeclaration>
12441283
<Hostname>multi_npu_platform_01</Hostname>
12451284
<HwSku>multi-npu-01</HwSku>
12461285
</DeviceMiniGraph>

0 commit comments

Comments
 (0)