Skip to content

Commit 4a6f8d7

Browse files
stephenxsskbarista
authored andcommitted
[Mellanox] Support Mellanox-SN4600C-C64 as T1 switch in dual-ToR scenario (sonic-net#11261)
- Why I did it Support Mellanox-SN4600C-C64 as T1 switch in dual-ToR scenario This is to port sonic-net#11032 and sonic-net#11299 from 202012 to master. Support additional queue and PG in buffer templates, including both traditional and dynamic model Support mapping DSCP 2/6 to lossless traffic in the QoS template. Add macros to generate additional lossless PG in the dynamic model Adjust the order in which the generic/dedicated (with additional lossless queues) macros are checked and called to generate buffer tables in common template buffers_config.j2 Buffer tables are rendered via using macros. Both generic and dedicated macros are defined on our platform. Currently, the generic one is called as long as it is defined, which causes the generic one always being called on our platform. To avoid it, the dedicated macrio is checked and called first and then the generic ones. Support MAP_PFC_PRIORITY_TO_PRIORITY_GROUP on ports with additional lossless queues. On Mellanox-SN4600C-C64, buffer configuration for t1 is calculated as: 40 * 100G downlink ports with 4 lossless PGs/queues, 1 lossy PG, and 3 lossy queues 16 * 100G uplink ports with 2 lossless PGs/queues, 1 lossy PG, and 5 lossy queues Signed-off-by: Stephen Sun <[email protected]>
1 parent 7cb44cb commit 4a6f8d7

14 files changed

+13209
-13
lines changed

device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/buffers_defaults_objects.j2

+64-2
Original file line numberDiff line numberDiff line change
@@ -124,24 +124,55 @@
124124
}
125125
{%- endmacro %}
126126

127-
{%- macro generate_queue_buffers(port_names_active, port_names_inactive) %}
127+
{%- macro generate_queue_buffers_with_extra_lossless_queues(port_names_active, port_names_extra_queues, port_names_inactive) %}
128128
"BUFFER_QUEUE": {
129+
{% set q_loop = namespace(last_valid=false) %}
129130
{% for port in port_names_active.split(',') %}
131+
{% if port not in port_names_extra_queues.split(',') %}
130132
"{{ port }}|3-4": {
131133
"profile" : "egress_lossless_profile"
132134
},
135+
{% endif %}
133136
{% endfor %}
134137
{% for port in port_names_active.split(',') %}
138+
{% if port not in port_names_extra_queues.split(',') %}
135139
"{{ port }}|0-2": {
136140
"profile" : "q_lossy_profile"
137141
},
142+
{% endif %}
138143
{% endfor %}
139144
{% for port in port_names_active.split(',') %}
145+
{% if port not in port_names_extra_queues.split(',') %}
140146
"{{ port }}|5-6": {
141147
"profile" : "q_lossy_profile"
142148
}{% if not loop.last %},{% endif %}
143149

150+
{% set q_loop.last_valid = true %}
151+
{% else %}
152+
{% set q_loop.last_valid = false %}
153+
{% endif %}
154+
{% endfor %}
155+
{% if port_names_extra_queues|length > 0 %}
156+
{% if q_loop.last_valid %},{% endif %}
157+
{% for port in port_names_extra_queues.split(',') %}
158+
"{{ port }}|0-1": {
159+
"profile" : "q_lossy_profile"
160+
},
161+
"{{ port }}|2-4": {
162+
"profile" : "egress_lossless_profile"
163+
},
164+
"{{ port }}|5": {
165+
"profile" : "q_lossy_profile"
166+
},
167+
"{{ port }}|6": {
168+
"profile" : "egress_lossless_profile"
169+
},
170+
"{{ port }}|7": {
171+
"profile" : "q_lossy_profile"
172+
}{% if not loop.last %},{% endif %}
173+
144174
{% endfor %}
175+
{% endif %}
145176
{% if port_names_inactive|length > 0 %}
146177
,
147178
{% if dynamic_mode is defined %}
@@ -183,9 +214,15 @@
183214
}
184215
{%- endmacro %}
185216

186-
{%- macro generate_pg_profiles(port_names_active, port_names_inactive) %}
217+
{%- macro generate_queue_buffers(port_names_active, port_names_inactive) %}
218+
{{ generate_queue_buffers_with_extra_lossless_queues(port_names_active, "", port_names_inactive) }}
219+
{%- endmacro %}
220+
221+
{%- macro generate_pg_profiles_with_extra_lossless_pgs(port_names_active, port_names_extra_pgs, port_names_inactive) %}
187222
"BUFFER_PG": {
223+
{% set pg_loop = namespace(last_valid=false) %}
188224
{% for port in port_names_active.split(',') %}
225+
{% if port not in port_names_extra_pgs.split(',') %}
189226
{% if dynamic_mode is defined %}
190227
"{{ port }}|3-4": {
191228
"profile" : "NULL"
@@ -195,7 +232,28 @@
195232
"profile" : "ingress_lossy_profile"
196233
}{% if not loop.last %},{% endif %}
197234

235+
{% set pg_loop.last_valid = true %}
236+
{% else %}
237+
{% set pg_loop.last_valid = false %}
238+
{% endif %}
198239
{% endfor %}
240+
{% if port_names_extra_pgs|length > 0 %}
241+
{% if pg_loop.last_valid %},{% endif %}
242+
{% for port in port_names_extra_pgs.split(',') %}
243+
{% if dynamic_mode is defined %}
244+
"{{ port }}|2-4": {
245+
"profile" : "NULL"
246+
},
247+
"{{ port }}|6": {
248+
"profile" : "NULL"
249+
},
250+
{% endif %}
251+
"{{ port }}|0": {
252+
"profile" : "ingress_lossy_profile"
253+
}{% if not loop.last %},{% endif %}
254+
255+
{% endfor %}
256+
{% endif %}
199257
{% if port_names_inactive|length > 0 %}
200258
{%- for port in port_names_inactive.split(',') %}
201259
{%- if loop.first -%},{%- endif -%}
@@ -216,3 +274,7 @@
216274
{% endif %}
217275
}
218276
{%- endmacro %}
277+
278+
{%- macro generate_pg_profiles(port_names_active, port_names_inactive) %}
279+
{{ generate_pg_profiles_with_extra_lossless_pgs(port_names_active, "", port_names_inactive) }}
280+
{%- endmacro %}

device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/buffers_defaults_t1.j2

+15
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,17 @@
1515
limitations under the License.
1616
#}
1717
{% set default_cable = '5m' %}
18+
{%- if ((SYSTEM_DEFAULTS is defined) and ('tunnel_qos_remap' in SYSTEM_DEFAULTS) and (SYSTEM_DEFAULTS['tunnel_qos_remap']['status'] == 'enabled')) -%}
19+
{% set ingress_lossless_pool_size = '44130304' %}
20+
{% set ingress_lossless_pool_xoff = '8790016' %}
21+
{% set egress_lossless_pool_size = '60817392' %}
22+
{% set egress_lossy_pool_size = '44130304' %}
23+
{%- else -%}
1824
{% set ingress_lossless_pool_size = '48332800' %}
1925
{% set ingress_lossless_pool_xoff = '5275648' %}
2026
{% set egress_lossless_pool_size = '60817392' %}
2127
{% set egress_lossy_pool_size = '48332800' %}
28+
{%- endif -%}
2229

2330
{% import 'buffers_defaults_objects.j2' as defs with context %}
2431

@@ -30,10 +37,18 @@
3037
{{ defs.generate_profile_lists(port_names_active, port_names_inactive) }}
3138
{%- endmacro %}
3239

40+
{%- macro generate_queue_buffers_with_extra_lossless_queues_with_inactive_ports(port_names_active, port_names_extra_queues, port_names_inactive) %}
41+
{{ defs.generate_queue_buffers_with_extra_lossless_queues(port_names_active, port_names_extra_queues, port_names_inactive) }}
42+
{%- endmacro %}
43+
3344
{%- macro generate_queue_buffers_with_inactive_ports(port_names_active, port_names_inactive) %}
3445
{{ defs.generate_queue_buffers(port_names_active, port_names_inactive) }}
3546
{%- endmacro %}
3647

48+
{%- macro generate_pg_profiles_with_extra_lossless_pgs_with_inactive_ports(port_names_active, port_names_extra_pgs, port_names_inactive) %}
49+
{{ defs.generate_pg_profiles_with_extra_lossless_pgs(port_names_active, port_names_extra_pgs, port_names_inactive) }}
50+
{%- endmacro %}
51+
3752
{%- macro generate_pg_profiles_with_inactive_ports(port_names_active, port_names_inactive) %}
3853
{{ defs.generate_pg_profiles(port_names_active, port_names_inactive) }}
3954
{%- endmacro %}

device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/qos.json.j2

-1
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
{#
2+
Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES.
3+
Apache-2.0
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
#}
17+
{% if ('type' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['type'] == 'LeafRouter') %}
18+
{% set different_dscp_to_tc_map = true %}
19+
{%- macro generate_dscp_to_tc_map() %}
20+
"DSCP_TO_TC_MAP": {
21+
"AZURE": {
22+
"0" : "1",
23+
"1" : "1",
24+
"2" : "2",
25+
"3" : "3",
26+
"4" : "4",
27+
"5" : "1",
28+
"6" : "6",
29+
"7" : "1",
30+
"8" : "0",
31+
"9" : "1",
32+
"10": "1",
33+
"11": "1",
34+
"12": "1",
35+
"13": "1",
36+
"14": "1",
37+
"15": "1",
38+
"16": "1",
39+
"17": "1",
40+
"18": "1",
41+
"19": "1",
42+
"20": "1",
43+
"21": "1",
44+
"22": "1",
45+
"23": "1",
46+
"24": "1",
47+
"25": "1",
48+
"26": "1",
49+
"27": "1",
50+
"28": "1",
51+
"29": "1",
52+
"30": "1",
53+
"31": "1",
54+
"32": "1",
55+
"33": "1",
56+
"34": "1",
57+
"35": "1",
58+
"36": "1",
59+
"37": "1",
60+
"38": "1",
61+
"39": "1",
62+
"40": "1",
63+
"41": "1",
64+
"42": "1",
65+
"43": "1",
66+
"44": "1",
67+
"45": "1",
68+
"46": "5",
69+
"47": "1",
70+
"48": "7",
71+
"49": "1",
72+
"50": "1",
73+
"51": "1",
74+
"52": "1",
75+
"53": "1",
76+
"54": "1",
77+
"55": "1",
78+
"56": "1",
79+
"57": "1",
80+
"58": "1",
81+
"59": "1",
82+
"60": "1",
83+
"61": "1",
84+
"62": "1",
85+
"63": "1"
86+
},
87+
"AZURE_UPLINK": {
88+
"0" : "1",
89+
"1" : "1",
90+
"2" : "1",
91+
"3" : "3",
92+
"4" : "4",
93+
"5" : "1",
94+
"6" : "1",
95+
"7" : "1",
96+
"8" : "0",
97+
"9" : "1",
98+
"10": "1",
99+
"11": "1",
100+
"12": "1",
101+
"13": "1",
102+
"14": "1",
103+
"15": "1",
104+
"16": "1",
105+
"17": "1",
106+
"18": "1",
107+
"19": "1",
108+
"20": "1",
109+
"21": "1",
110+
"22": "1",
111+
"23": "1",
112+
"24": "1",
113+
"25": "1",
114+
"26": "1",
115+
"27": "1",
116+
"28": "1",
117+
"29": "1",
118+
"30": "1",
119+
"31": "1",
120+
"32": "1",
121+
"33": "1",
122+
"34": "1",
123+
"35": "1",
124+
"36": "1",
125+
"37": "1",
126+
"38": "1",
127+
"39": "1",
128+
"40": "1",
129+
"41": "1",
130+
"42": "1",
131+
"43": "1",
132+
"44": "1",
133+
"45": "1",
134+
"46": "5",
135+
"47": "1",
136+
"48": "7",
137+
"49": "1",
138+
"50": "1",
139+
"51": "1",
140+
"52": "1",
141+
"53": "1",
142+
"54": "1",
143+
"55": "1",
144+
"56": "1",
145+
"57": "1",
146+
"58": "1",
147+
"59": "1",
148+
"60": "1",
149+
"61": "1",
150+
"62": "1",
151+
"63": "1"
152+
}
153+
},
154+
{%- endmacro %}
155+
{%- macro generate_tc_to_pg_map() %}
156+
"TC_TO_PRIORITY_GROUP_MAP": {
157+
"AZURE": {
158+
"0": "0",
159+
"1": "0",
160+
"2": "2",
161+
"3": "3",
162+
"4": "4",
163+
"5": "0",
164+
"6": "6",
165+
"7": "0"
166+
}
167+
},
168+
{%- endmacro %}
169+
{%- macro generate_global_dscp_to_tc_map() %}
170+
{# This is an empty macro since the global DSCP_TO_TC map is not required #}
171+
{%- endmacro %}
172+
173+
{% endif %}
174+
175+
{%- include 'qos_config.j2' %}

files/build_templates/buffers_config.j2

+9-7
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,16 @@ def
168168
{{ defs.generate_profile_lists_with_inactive_ports(port_names_active, port_names_inactive) }},
169169
{% endif %}
170170

171-
{%- if defs.generate_pg_profils is defined %}
172-
{{ defs.generate_pg_profils(port_names_active) }}
171+
{% if (defs.generate_pg_profiles_with_extra_lossless_pgs_with_inactive_ports is defined) and (port_names_extra_queues != '') %}
172+
{{ defs.generate_pg_profiles_with_extra_lossless_pgs_with_inactive_ports(port_names_active, port_names_extra_queues, port_names_inactive) }},
173173
{% elif defs.generate_pg_profiles_with_inactive_ports is defined %}
174174
{{ defs.generate_pg_profiles_with_inactive_ports(port_names_active, port_names_inactive) }},
175175
{% elif (defs.generate_pg_buffers_with_extra_lossy_pgs is defined) and (port_names_extra_queues != '') %}
176176
{{ defs.generate_pg_buffers_with_extra_lossy_pgs(port_names_active, port_names_extra_queues) }}
177177
{% elif (defs.generate_pg_buffers_with_extra_lossy_pgs_with_inactive_ports is defined) and (port_names_extra_queues != '') %}
178178
{{ defs.generate_pg_buffers_with_extra_lossy_pgs_with_inactive_ports(port_names_active, port_names_extra_queues, port_names_inactive) }}
179+
{% elif defs.generate_pg_profils is defined %}
180+
{{ defs.generate_pg_profils(port_names_active) }}
179181
{% else %}
180182
"BUFFER_PG": {
181183
{% for port in PORT_ACTIVE %}
@@ -192,14 +194,14 @@ def
192194
},
193195
{% endif %}
194196

195-
{% if defs.generate_queue_buffers is defined %}
196-
{{ defs.generate_queue_buffers(port_names_active) }}
197-
{% elif defs.generate_queue_buffers_with_inactive_ports is defined %}
198-
{{ defs.generate_queue_buffers_with_inactive_ports(port_names_active, port_names_inactive) }}
199-
{% elif (defs.generate_queue_buffers_with_extra_lossless_queues_with_inactive_ports is defined) and (port_names_extra_queues != '') %}
197+
{% if (defs.generate_queue_buffers_with_extra_lossless_queues_with_inactive_ports is defined) and (port_names_extra_queues != '') %}
200198
{{ defs.generate_queue_buffers_with_extra_lossless_queues_with_inactive_ports(port_names_active, port_names_extra_queues, port_names_inactive) }}
201199
{% elif (defs.generate_queue_buffers_with_extra_lossless_queues is defined) and (port_names_extra_queues != '') %}
202200
{{ defs.generate_queue_buffers_with_extra_lossless_queues(port_names_active, port_names_extra_queues) }}
201+
{% elif defs.generate_queue_buffers is defined %}
202+
{{ defs.generate_queue_buffers(port_names_active) }}
203+
{% elif defs.generate_queue_buffers_with_inactive_ports is defined %}
204+
{{ defs.generate_queue_buffers_with_inactive_ports(port_names_active, port_names_inactive) }}
203205
{% else %}
204206
"BUFFER_QUEUE": {
205207
{% for port in PORT_ACTIVE %}

0 commit comments

Comments
 (0)