9959898bb6
This commit adds new support for dynamic buffer configuration. The cable_length macro is updated to return the cable length for server ports. Since the server ports are part of VLAN MEMBERS, the macro loops through the VLAN MEMBER ports and returns the cable length accordingly. If the port is not part of the SERVER port then it defaults to default cable length. The new code in the macro will be executed only if the switch is ToRRouter which is connected to the server on one side. Tested the code by loading minigraph configuration on the switch which had configuration for leaf-router as DEVICE NEIGHHOR and server ports in VLAN and ports which are not part of either server or leaf router. The dynamically generated buffer.json and config_db.json file had the cable_legnth updated accordingly for server ports with "5m" and leafrouter with "40m" and unconnected port to default "300m". The redis database also reflects the buffer profile's for 5m, 40m and 300m. Signed-off-by: Harish Venkatraman <Harish_Venkatraman@dell.com>
147 lines
4.8 KiB
Django/Jinja
147 lines
4.8 KiB
Django/Jinja
{# Default values which will be used if no actual configura available #}
|
|
{% set default_cable = '300m' %}
|
|
{% set default_speed = '100G' %}
|
|
{% set default_ports_num = 64 -%}
|
|
|
|
{# Port configuration to cable length look-up table #}
|
|
{# Each record describes mapping of DUT (DUT port) role and neighbor role to cable length #}
|
|
{# Roles described in the minigraph #}
|
|
{% set ports2cable = {
|
|
'torrouter_server' : '5m',
|
|
'leafrouter_torrouter' : '40m',
|
|
'spinerouter_leafrouter' : '300m'
|
|
}
|
|
%}
|
|
|
|
{%- macro cable_length(port_name) -%}
|
|
{%- set cable_len = [] -%}
|
|
{%- for local_port in DEVICE_NEIGHBOR -%}
|
|
{%- if local_port == port_name -%}
|
|
{%- if DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%}
|
|
{%- set neighbor = DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%}
|
|
{%- set neighbor_role = neighbor.type -%}
|
|
{%- set roles1 = switch_role + '_' + neighbor_role %}
|
|
{%- set roles2 = neighbor_role + '_' + switch_role -%}
|
|
{%- set roles1 = roles1 | lower -%}
|
|
{%- set roles2 = roles2 | lower -%}
|
|
{%- if roles1 in ports2cable -%}
|
|
{%- if cable_len.append(ports2cable[roles1]) -%}{%- endif -%}
|
|
{%- elif roles2 in ports2cable -%}
|
|
{%- if cable_len.append(ports2cable[roles2]) -%}{%- endif -%}
|
|
{%- endif -%}
|
|
{%- endif -%}
|
|
{%- endif -%}
|
|
{%- endfor -%}
|
|
{%- if cable_len -%}
|
|
{{ cable_len.0 }}
|
|
{%- else -%}
|
|
{%- if switch_role == 'ToRRouter' -%}
|
|
{%- for local_port in VLAN_MEMBER -%}
|
|
{%- set vlan_port = local_port.split("|") -%}
|
|
{%- if vlan_port[1] == port_name -%}
|
|
{%- set roles3 = switch_role + '_' + 'server' -%}
|
|
{%- set roles3 = roles3 | lower -%}
|
|
{%- if roles3 in ports2cable -%}
|
|
{%- if cable_len.append(ports2cable[roles3]) -%}{%- endif -%}
|
|
{%- endif -%}
|
|
{%- endif -%}
|
|
{%- endfor -%}
|
|
{%- if cable_len -%}
|
|
{{cable_len.0}}
|
|
{%- else -%}
|
|
{{ default_cable }}
|
|
{%- endif -%}
|
|
{%- else -%}
|
|
{{ default_cable }}
|
|
{%- endif -%}
|
|
{%- endif -%}
|
|
{% endmacro %}
|
|
|
|
{%- if DEVICE_METADATA is defined %}
|
|
{%- set switch_role = DEVICE_METADATA['localhost']['type'] %}
|
|
{%- endif -%}
|
|
|
|
{# Generate list of ports if not defined #}
|
|
{% if PORT is not defined %}
|
|
{% set PORT = [] %}
|
|
{% for port_idx in range(0,default_ports_num) %}
|
|
{% if PORT.append("Ethernet%d" % port_idx) %}{% endif %}
|
|
{% endfor %}
|
|
{% endif -%}
|
|
|
|
{% set port_names_list = [] %}
|
|
{% for port in PORT %}
|
|
{%- if port_names_list.append(port) %}{% endif %}
|
|
{% endfor %}
|
|
{% set port_names = port_names_list | join(',') -%}
|
|
|
|
{
|
|
"CABLE_LENGTH": {
|
|
"AZURE": {
|
|
{% for port in PORT %}
|
|
{% set cable = cable_length(port) -%}
|
|
"{{ port }}": "{{ cable }}"{%- if not loop.last -%},{% endif %}
|
|
|
|
{% endfor %}
|
|
}
|
|
},
|
|
"BUFFER_POOL": {
|
|
"ingress_lossless_pool": {
|
|
"size": "10443264",
|
|
"type": "ingress",
|
|
"mode": "dynamic",
|
|
"xoff": "4625920"
|
|
},
|
|
"egress_lossy_pool": {
|
|
"size": "8877440",
|
|
"type": "egress",
|
|
"mode": "dynamic"
|
|
},
|
|
"egress_lossless_pool": {
|
|
"size": "15982592",
|
|
"type": "egress",
|
|
"mode": "static"
|
|
}
|
|
},
|
|
"BUFFER_PROFILE": {
|
|
"ingress_lossless_profile": {
|
|
"pool": "[BUFFER_POOL|ingress_lossless_pool]",
|
|
"xon": "4096",
|
|
"xoff": "58448",
|
|
"size": "1248",
|
|
"dynamic_th": "-4"
|
|
},
|
|
"ingress_lossy_profile": {
|
|
"pool":"[BUFFER_POOL|ingress_lossless_pool]",
|
|
"size":"0",
|
|
"dynamic_th":"3"
|
|
},
|
|
"egress_lossless_profile": {
|
|
"pool":"[BUFFER_POOL|egress_lossless_pool]",
|
|
"size":"1518",
|
|
"static_th":"3995648"
|
|
},
|
|
"egress_lossy_profile": {
|
|
"pool":"[BUFFER_POOL|egress_lossy_pool]",
|
|
"size":"1518",
|
|
"dynamic_th":"3"
|
|
}
|
|
},
|
|
"BUFFER_PG": {
|
|
"{{ port_names }}|3-4": {
|
|
"profile" : "[BUFFER_PROFILE|ingress_lossless_profile]"
|
|
},
|
|
"{{ port_names }}|0-1": {
|
|
"profile" : "[BUFFER_PROFILE|ingress_lossy_profile]"
|
|
}
|
|
},
|
|
"BUFFER_QUEUE": {
|
|
"{{ port_names }}|3-4": {
|
|
"profile" : "[BUFFER_PROFILE|egress_lossless_profile]"
|
|
},
|
|
"{{ port_names }}|0-1": {
|
|
"profile" : "[BUFFER_PROFILE|egress_lossy_profile]"
|
|
}
|
|
}
|
|
}
|