Skip to content

Commit 6f8ebed

Browse files
authored
[QoS] Disable pfc and pfcwd on service ports (#24145)
<!-- Please make sure you've read and understood our contributing guidelines: https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md failure_prs.log Make sure all your commits include a signature generated with `git commit -s` ** If this is a bug fix, make sure your description includes "fixes #xxxx", or "closes #xxxx" or "resolves #xxxx" Please provide the following information: --> #### Why I did it Disable pfc and pfcwd on service ports since they carry lossy traffic and do not require any pfc config ##### Work item tracking - Microsoft ADO **(number only)**: #### How I did it Finetune buffer and qos configs #### How to verify it Copy templates onto switch, reload the config and see the new config db <!-- If PR needs to be backported, then the PR must be tested against the base branch and the earliest backport release branch and provide tested image version on these two branches. For example, if the PR is requested for master, 202211 and 202012, then the requester needs to provide test results on master and 202012. --> #### Which release branch to backport (provide reason below if selected) <!-- - Note we only backport fixes to a release branch, *not* features! - Please also provide a reason for the backporting below. - e.g. - [x] 202006 --> - [ ] 202205 - [ ] 202211 - [ ] 202305 - [ ] 202311 - [ ] 202405 - [ ] 202411 - [X] 202505 #### Tested branch (Please provide the tested image version) <!-- - Please provide tested image version - e.g. - [x] 20201231.100 --> - [ ] <!-- image version 1 --> - [ ] <!-- image version 2 --> #### Description for the changelog <!-- Write a short (one line) summary that describes the changes in this pull request for inclusion in the changelog: --> Disable PFC and PFCWD on service ports <!-- Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU. --> #### Link to config_db schema for YANG module changes <!-- Provide a link to config_db schema for the table for which YANG model is defined Link should point to correct section on https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md --> All unit tests pass ``` collected 312 items tests/test_cfggen.py .................................................................................... [ 26%] tests/test_cfggen_from_yang.py .................. [ 32%] tests/test_cfggen_pfx_filter.py . [ 33%] tests/test_cfggen_platformJson.py ...... [ 34%] tests/test_cfggen_t2_chassis_fe.py ...... [ 36%] tests/test_chassis_cfggen.py ......................................................... [ 55%] tests/test_frr.py ...... [ 57%] tests/test_j2files.py ................................................ [ 72%] tests/test_j2files_t2_chassis_fe.py ... [ 73%] tests/test_minigraph_case.py ........................................... [ 87%] tests/test_multinpu_cfggen.py ........................................ [100%] ===================================================================== 312 passed in 321.99s (0:05:21) ================================== ``` #### A picture of a cute animal (not mandatory but encouraged)
1 parent 68ba50b commit 6f8ebed

File tree

7 files changed

+10133
-0
lines changed

7 files changed

+10133
-0
lines changed

device/arista/x86_64-arista_7060x6_16pe_384c_b/Arista-7060X6-16PE-384C-B-O128S2/buffers_defaults_t0.j2

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,8 @@
3434
}
3535
},
3636
{%- endmacro %}
37+
38+
{%- macro generate_service_port_list(PORT_SERVICE) -%}
39+
{%- if PORT_SERVICE.append("Ethernet512") %}{% endif %}
40+
{%- if PORT_SERVICE.append("Ethernet513") %}{% endif %}
41+
{%- endmacro %}

device/arista/x86_64-arista_7060x6_16pe_384c_b/Arista-7060X6-16PE-384C-B-O128S2/buffers_defaults_t1.j2

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,8 @@
3434
}
3535
},
3636
{%- endmacro %}
37+
38+
{%- macro generate_service_port_list(PORT_SERVICE) -%}
39+
{%- if PORT_SERVICE.append("Ethernet512") %}{% endif %}
40+
{%- if PORT_SERVICE.append("Ethernet513") %}{% endif %}
41+
{%- endmacro %}

files/build_templates/qos_config.j2

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@
55
{%- set PORT_QOS_BYPASS = [] %}
66
{%- set PORT_UPLINK = [] %}
77
{%- set PORT_DOWNLINK = [] %}
8+
{%- set PORT_SERVICE = [] %}
9+
10+
{% if template_exists("buffers.json.j2") %}
11+
{% import "buffers.json.j2" as buffer_defs %}
12+
{%- set filename_postfix = buffer_defs.default_topo | default("def", true) %}
13+
{% else %}
14+
{%- set filename_postfix = "def" %}
15+
{% endif %}
16+
17+
{# Allow includer to pre-package defs without needing an import #}
18+
{%- if defs is not defined %}
19+
{# Import default values from device HWSKU folder #}
20+
{%- if template_exists('buffers_defaults_%s.j2' % filename_postfix) %}
21+
{%- import 'buffers_defaults_%s.j2' % filename_postfix as defs with context %}
22+
{%- endif -%}
23+
{%- endif -%}
824

925
{%- set voq_chassis = false %}
1026
{%- if DEVICE_METADATA is defined and DEVICE_METADATA['localhost']['switch_type'] is defined and DEVICE_METADATA['localhost']['switch_type'] == 'voq' %}
@@ -37,6 +53,9 @@
3753
{%- if generate_qos_bypass_port_list is defined %}
3854
{%- if generate_qos_bypass_port_list(PORT_QOS_BYPASS) %} {% endif %}
3955
{%- endif %}
56+
{%- if defs is defined and defs.generate_service_port_list is defined %}
57+
{%- if defs.generate_service_port_list(PORT_SERVICE) %}{% endif %}
58+
{%- endif %}
4059

4160
{%- if PORT_ALL | sort_by_port_index %}{% endif %}
4261

@@ -426,19 +445,28 @@
426445
{% endif %}
427446
{% endif %}
428447
{% if port not in PORT_DPC %}
448+
{% if port in PORT_SERVICE %}
449+
"pfc_enable" : "",
450+
"pfcwd_sw_enable" : "",
451+
{% else %}
429452
{% if port in port_names_list_extra_queues %}
430453
"pfc_enable" : "2,3,4,6",
431454
{% else %}
432455
"pfc_enable" : "{{ LOSSLESS_TC|join(',') }}",
433456
{% endif %}
434457
"pfcwd_sw_enable" : "{{ LOSSLESS_TC|join(',') }}",
435458
{% endif %}
459+
{% endif %}
436460
{% if port not in PORT_DPC %}
437461
"tc_to_pg_map" : "AZURE",
438462
{% else %}
439463
"tc_to_pg_map" : "AZURE_DPC",
440464
{% endif %}
465+
{% if port in PORT_SERVICE %}
466+
"pfc_to_queue_map": ""
467+
{% else %}
441468
"pfc_to_queue_map": "AZURE"
469+
{% endif %}
442470
}{% if not loop.last %},{% endif %}
443471

444472
{% endfor %}

src/sonic-config-engine/sonic-cfggen

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,17 @@ def _get_jinja2_env(paths):
301301
env.filters['b64encode'] = b64encode
302302
env.filters['b64decode'] = b64decode
303303

304+
# Introduce a 'template_exists' function to check if a template exists
305+
# This is used to conditionally import a template since jinja2 import
306+
# statement fails if the template does not exist and does not have native support
307+
def template_exists(name):
308+
try:
309+
loader.get_source(env, name)
310+
return True
311+
except jinja2.exceptions.TemplateNotFound:
312+
return False
313+
env.globals['template_exists'] = template_exists
314+
304315
return env
305316

306317
def main():

0 commit comments

Comments
 (0)