Skip to content

Commit

Permalink
Fix optional params not applying to all interfaces (sonic-net#20313)
Browse files Browse the repository at this point in the history
Currently optional params only get applied to the first child port in group. We want optional parameters to apply to all child ports in group.

For example:

        "Ethernet0": {
            "default_brkout_mode": "2x400G",
            "autoneg": "on"
        },
In this scenario we want autoneg on to be in the config_db entry for
both interfaces that belong to the group; Ethernet0 and Ethernet4.

Currently this only gets applied to Ethernet0:

(Pdb++) pp child_ports
{'Ethernet0': {'alias': 'Ethernet1/1',
               'autoneg': 'on',
               'index': '1',
               'lanes': '17,18,19,20',
               'speed': '400000',
               'subport': '1'},
 'Ethernet4': {'alias': 'Ethernet1/5',
               'index': '1',
               'lanes': '21,22,23,24',
               'speed': '400000',
               'subport': '2'}}
With this change it now gets applied to all interfaces in the group as expected

(Pdb) pp child_ports
{'Ethernet0': {'alias': 'Ethernet1/1',
               'autoneg': 'on',
               'index': '1',
               'lanes': '17,18,19,20',
               'speed': '400000',
               'subport': '1'},
 'Ethernet4': {'alias': 'Ethernet1/5',
               'autoneg': 'on',
               'index': '1',
               'lanes': '21,22,23,24',
               'speed': '400000',
               'subport': '2'}}
Why I did it
I need to apply optional hwsku params for a group of interfaces.

How I did it
Just changed to iterate over every child port in group.

How to verify it
Introduction to the problem shows verification of the solution. Check the output manually and also fixed the unit test to correspond and pass.
  • Loading branch information
bobbymcgonigle authored Dec 5, 2024
1 parent 368ace2 commit f222ff9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/sonic-config-engine/portconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@ def parse_platform_json_file(hwsku_json_file, platform_json_file):
if child_port in hwsku_entry:
for key, item in hwsku_entry[child_port].items():
if key in OPTIONAL_HWSKU_ATTRIBUTES:
child_ports.get(child_port)[key] = item
for child in child_ports:
child_ports.get(child)[key] = item

ports.update(child_ports)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,8 @@
"alias": "Eth36/1",
"pfc_asym": "off",
"subport": "1",
"speed": "25000"
"speed": "25000",
"role": "Dpc"
},
"Ethernet141": {
"index": "36",
Expand All @@ -987,7 +988,8 @@
"alias": "Eth36/2",
"pfc_asym": "off",
"speed": "25000",
"subport": "2"
"subport": "2",
"role": "Dpc"
},
"Ethernet142": {
"index": "36",
Expand Down

0 comments on commit f222ff9

Please sign in to comment.