Skip to content

Commit 770a8f3

Browse files
andriymoroz-mlnxShuotian Cheng
authored and
Shuotian Cheng
committed
[swssconfig]: Update buffer profile template to work with CONF_DB (#319)
1 parent 982efc3 commit 770a8f3

File tree

1 file changed

+31
-38
lines changed

1 file changed

+31
-38
lines changed

swssconfig/sample/msn27xx.32ports.buffers.json.j2

+31-38
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[
2-
{% set ethernet_interfaces_names_list = [] %}
3-
{% for interface in ethernet_interfaces %}
4-
{%- if ethernet_interfaces_names_list.append(interface['name']) %}{% endif %}
2+
{% set port_names_list = [] %}
3+
{% for port in PORT %}
4+
{%- if port_names_list.append(port) %}{% endif %}
55
{% endfor %}
6-
{% set ethernet_interfaces_names = ethernet_interfaces_names_list | join(',') %}
6+
{% set port_names = port_names_list | join(',') %}
77
{
88
"BUFFER_POOL_TABLE:ingress_lossless_pool": {
99
"size": "3024486",
@@ -68,16 +68,6 @@
6868
},
6969
"OP": "SET"
7070
},
71-
{
72-
"BUFFER_PROFILE_TABLE:pg_lossless_profile": {
73-
"pool":"[BUFFER_POOL_TABLE:ingress_lossless_pool]",
74-
"xon":"35616",
75-
"xoff":"31814",
76-
"size":"67430",
77-
"dynamic_th":"1"
78-
},
79-
"OP": "SET"
80-
},
8171
{
8272
"BUFFER_PROFILE_TABLE:pg_lossy_profile": {
8373
"pool":"[BUFFER_POOL_TABLE:ingress_lossy_pool]",
@@ -103,13 +93,13 @@
10393
"OP": "SET"
10494
},
10595
{
106-
"BUFFER_PORT_INGRESS_PROFILE_LIST:{{ ethernet_interfaces_names }}": {
96+
"BUFFER_PORT_INGRESS_PROFILE_LIST:{{ port_names }}": {
10797
"profile_list" : "[BUFFER_PROFILE_TABLE:ingress_lossless_profile],[BUFFER_PROFILE_TABLE:ingress_lossy_profile]"
10898
},
10999
"OP": "SET"
110100
},
111101
{
112-
"BUFFER_PORT_EGRESS_PROFILE_LIST:{{ ethernet_interfaces_names }}": {
102+
"BUFFER_PORT_EGRESS_PROFILE_LIST:{{ port_names }}": {
113103
"profile_list" : "[BUFFER_PROFILE_TABLE:egress_lossless_profile],[BUFFER_PROFILE_TABLE:egress_lossy_profile]"
114104
},
115105
"OP": "SET"
@@ -176,20 +166,23 @@
176166
}
177167
%}
178168

179-
{% set switch_role = minigraph_devices[minigraph_hostname]['type'] %}
169+
{% set switch_role = DEVICE_METADATA['localhost']['type'] %}
180170

181-
{%- macro cable_length(interface_name) -%}
182-
{% set nei = '"'+minigraph_neighbors[interface_name]['name']+'"' -%}
183-
{% set nei_role = minigraph_devices[nei]['type'] -%}
184-
{% set roles1 = switch_role + '_' + nei_role %}
185-
{%- set roles2 = nei_role + '_' + switch_role -%}
186-
{%- if roles1 in ports2cable -%}
187-
{{ ports2cable[roles1] }}
188-
{%- elif roles2 in ports2cable -%}
189-
{{ ports2cable[roles2] }}
190-
{%- else -%}
191-
{{ supported_cable | last }}
192-
{%- endif -%}
171+
{%- macro cable_length(port_name) -%}
172+
{%- for neighbor in DEVICE_NEIGHBOR -%}
173+
{%- if DEVICE_NEIGHBOR[neighbor]['local_port'] == port_name -%}
174+
{%- set neighbor_role = DEVICE_NEIGHBOR[neighbor]['type'] -%}
175+
{%- set roles1 = switch_role + '_' + neighbor_role %}
176+
{%- set roles2 = neighbor_role + '_' + switch_role -%}
177+
{%- if roles1 in ports2cable -%}
178+
{{ ports2cable[roles1] }}
179+
{%- elif roles2 in ports2cable -%}
180+
{{ ports2cable[roles2] }}
181+
{%- else -%}
182+
{{ supported_cable | last }}
183+
{%- endif -%}
184+
{% endif %}
185+
{%- endfor -%}
193186
{% endmacro %}
194187

195188
{%- macro find_closest_greater_config(speed, cable) -%}
@@ -210,9 +203,9 @@
210203

211204
{% set ingress_lossless_pg_pool_size = [] %}
212205
{% set used_pg_profiles = [] %}
213-
{% for interface in ethernet_interfaces %}
214-
{%- set speed = interface['speed'] -%}
215-
{%- set cable = cable_length(interface['name']) -%}
206+
{% for port in PORT %}
207+
{%- set speed = PORT[port]['speed'] -%}
208+
{%- set cable = cable_length(port) -%}
216209
{%- set port_config = speed + '_' + cable -%}
217210
{%- if not port_config in portconfig2profile -%}
218211
{% set port_config = find_closest_greater_config(speed, cable) -%}
@@ -222,15 +215,15 @@
222215
{# add to list profiles which were actually used #}
223216
{%- if profile not in used_pg_profiles and used_pg_profiles.append(profile) %}{% endif -%}
224217
{
225-
"BUFFER_PG_TABLE:{{ interface['name'] }}:{{ pg_range }}": {
218+
"BUFFER_PG_TABLE:{{ port }}:{{ pg_range }}": {
226219
"profile" : "[BUFFER_PROFILE_TABLE:{{ profile }}]"
227220
},
228221
"OP": "SET"
229222
},
230-
231223
{% endfor -%}
232224

233225
{# PG profiles declaration #}
226+
234227
{% for profile_name in used_pg_profiles %}
235228
{%- set profile_config = pg_profiles[profile_name] %}
236229
{
@@ -255,19 +248,19 @@
255248
"OP": "SET"
256249
},
257250
{
258-
"BUFFER_PG_TABLE:{{ ethernet_interfaces_names }}:0-1": {
251+
"BUFFER_PG_TABLE:{{ port_names }}:0-1": {
259252
"profile" : "[BUFFER_PROFILE_TABLE:pg_lossy_profile]"
260253
},
261254
"OP": "SET"
262255
},
263256
{
264-
"BUFFER_QUEUE_TABLE:{{ ethernet_interfaces_names }}:3-4": {
257+
"BUFFER_QUEUE_TABLE:{{ port_names }}:3-4": {
265258
"profile" : "[BUFFER_PROFILE_TABLE:q_lossless_profile]"
266259
},
267260
"OP": "SET"
268261
},
269262
{
270-
"BUFFER_QUEUE_TABLE:{{ ethernet_interfaces_names }}:0-1": {
263+
"BUFFER_QUEUE_TABLE:{{ port_names }}:0-1": {
271264
"profile" : "[BUFFER_PROFILE_TABLE:q_lossy_profile]"
272265
},
273266
"OP": "SET"
@@ -282,7 +275,7 @@
282275
"OP": "SET"
283276
},
284277
{
285-
"PORT_QOS_MAP_TABLE:{{ ethernet_interfaces_names }}": {
278+
"PORT_QOS_MAP_TABLE:{{ port_names }}": {
286279
"pfc_to_pg_map" : "[PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_TABLE:AZURE]"
287280
},
288281
"OP": "SET"

0 commit comments

Comments
 (0)