Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
58 changes: 41 additions & 17 deletions files/build_templates/qos_config.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
{%- set PORT_UPLINK = [] %}
{%- set PORT_DOWNLINK = [] %}
{%- set PORT_SERVICE = [] %}
{%- set SYSTEM_PORT_ACTIVE [] %}
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing equals sign in list initialization. The syntax should be {%- set SYSTEM_PORT_ACTIVE = [] %} instead of {%- set SYSTEM_PORT_ACTIVE [] %}.

Suggested change
{%- set SYSTEM_PORT_ACTIVE [] %}
{%- set SYSTEM_PORT_ACTIVE = [] %}

Copilot uses AI. Check for mistakes.


{% if template_exists("buffers.json.j2") %}
{% import "buffers.json.j2" as buffer_defs with context %}
Expand All @@ -23,20 +25,38 @@
{%- endif -%}

{%- set voq_chassis = false %}
{%- set hostname = "" %}
{%- set asicname = "" %}
{%- if DEVICE_METADATA is defined and DEVICE_METADATA['localhost']['switch_type'] is defined and DEVICE_METADATA['localhost']['switch_type'] == 'voq' %}
{%- set voq_chassis = true %}
{%- endif -%}

{%- if voq_chassis %}
{%- for system_port in SYSTEM_PORT %}
{% if '|' not in system_port %}
{%- set system_port_name = system_port|join("|") %}
{% else %}
{%- set system_port_name = system_port %}
{% endif %}
{%- if 'cpu' not in system_port_name.lower() and 'IB' not in system_port_name and 'Rec' not in system_port_name %}
{%- if SYSTEM_PORT_ALL.append(system_port_name) %}{%- endif %}
{%- if DEVICE_METADATA is defined and 'localhost' in DEVICE_METADATA and 'hostname' in DEVICE_METADATA['localhost'] -%}
{%- set hostname = DEVICE_METADATA['localhost']['hostname'] -%}
{%- endif %}
{%- if DEVICE_METADATA is defined and 'localhost' in DEVICE_METADATA and 'asic_name' in DEVICE_METADATA['localhost'] -%}
{%- set asicname = DEVICE_METADATA['localhost']['asic_name'] -%}
{%- endif %}
{%- for system_port in SYSTEM_PORT -%}
{% if '|' not in system_port %}
{%- set system_port_name = system_port|join("|") -%}
{%- else %}
{%- set system_port_name = system_port -%}
{%- endif %}
{%- if 'cpu' not in system_port_name.lower() and 'IB' not in system_port_name and 'Rec' not in system_port_name -%}
{%- if SYSTEM_PORT_ALL.append(system_port_name) -%}
{%- endif %}
{#- find all system_port_name has hostname|asicname. If it is true, get the portname and check if the port name is present in the deviceNeighbor -#}
{%- if hostname != "" and asicname != "" -%}
{%- if system_port_name.startswith(hostname + '|' + asicname) -%}
{%- set port_name = system_port_name.split('|')[2] -%}
{%- if DEVICE_NEIGHBOR is defined and port_name in DEVICE_NEIGHBOR -%}
{%- if SYSTEM_PORT_ACTIVE.append(system_port_name) %}{%- endif -%}
{%- endif -%}
{%- endif -%}
{%- endif -%}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- for port in PORT %}
Expand Down Expand Up @@ -492,40 +512,44 @@
"QUEUE": {
{% for system_port in SYSTEM_PORT_ALL %}
"{{ system_port }}|3": {
"scheduler" : "scheduler.1",
{% if system_port in SYSTEM_PORT_ACTIVE -%}
"scheduler": "scheduler.1",
{% endif -%}
"wred_profile": "AZURE_LOSSLESS"
},
Comment on lines 514 to 519
Copy link

Copilot AI Nov 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conditional scheduler inclusion in queues 3 and 4 may produce invalid JSON when system_port is not in SYSTEM_PORT_ACTIVE. In such cases, the JSON would be {"wred_profile": "AZURE_LOSSLESS"} with a trailing comma from line 517 (,), creating invalid JSON. Consider restructuring to ensure valid JSON is always generated, e.g., by making the comma conditional or always including a scheduler field.

Copilot uses AI. Check for mistakes.
{% endfor %}
{% for system_port in SYSTEM_PORT_ALL %}
"{{ system_port }}|4": {
"scheduler" : "scheduler.1",
{% if system_port in SYSTEM_PORT_ACTIVE -%}
"scheduler": "scheduler.1",
{% endif -%}
"wred_profile": "AZURE_LOSSLESS"
},
{% endfor %}
{% for system_port in SYSTEM_PORT_ALL %}
}{% if not loop.last %},{% endif %}
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing comma after the closing brace. This will result in invalid JSON syntax. Should be }, to maintain proper JSON array structure.

Copilot uses AI. Check for mistakes.
{% for system_port in SYSTEM_PORT_ACTIVE %}
"{{ system_port }}|0": {
"scheduler": "scheduler.0"
},
{% endfor %}
{% for system_port in SYSTEM_PORT_ALL %}
{% for system_port in SYSTEM_PORT_ACTIVE %}
"{{ system_port }}|1": {
"scheduler": "scheduler.0"
},
{% endfor %}
{% for system_port in SYSTEM_PORT_ALL %}
{% for system_port in SYSTEM_PORT_ACTIVE %}
"{{ system_port }}|2": {
"scheduler": "scheduler.0"
},
{% endfor %}
{% for system_port in SYSTEM_PORT_ALL %}
{% for system_port in SYSTEM_PORT_ACTIVE %}
"{{ system_port }}|5": {
"scheduler": "scheduler.0"
},
{% endfor %}
{% for system_port in SYSTEM_PORT_ALL %}
{% for system_port in SYSTEM_PORT_ACTIVE %}
"{{ system_port }}|6": {
"scheduler": "scheduler.0"
}{% if not loop.last %},{% endif %}

{% endfor %}
}
{% elif generate_direction_based_queue_per_sku is defined and (PORT_DOWNLINK|length > 0 or PORT_UPLINK|length > 0) %}
Expand Down
Loading
Loading