sonic-buildimage/device/marvell/arm64-marvell_db98cx8580_16cd-r0/db98cx8580_16cd/buffers_config.j2
Ashok Daparthi-Dell 6cbdf11e53
SONIC QOS YANG - Remove qos tables field value refernce format (#7752)
Depends on Azure/sonic-utilities#1626
Depends on Azure/sonic-swss#1754

QOS tables in config db used ABNF format i.e "[TABLE_NAME|name] to refer fieldvalue to other qos tables.

Example:
Config DB:
"Ethernet92|3": {
"scheduler": "[SCHEDULER|scheduler.1]",
"wred_profile": "[WRED_PROFILE|AZURE_LOSSLESS]"
},
"Ethernet0|0": {
"profile": "[BUFFER_PROFILE|ingress_lossy_profile]"
},
"Ethernet0": {
"dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]",
"pfc_enable": "3,4",
"pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]",
"tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]",
"tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]"
},

This format is not consistent with other DB schema followed in sonic.
And also this reference in DB is not required, This is taken care by YANG "leafref".

Removed this format from all platform files to consistent with other sonic db schema.
Example:
"Ethernet92|3": {
"scheduler": "scheduler.1",
"wred_profile": "AZURE_LOSSLESS"
},

Dependent pull requests:
#7752 - To modify platfrom files
#7281 - Yang model
Azure/sonic-utilities#1626 - DB migration
Azure/sonic-swss#1754 - swss change to remove ABNF format
2021-09-28 09:21:24 -07:00

166 lines
5.1 KiB
Django/Jinja

{%- macro set_default_topology() %}
{%- if default_topo is defined %}
{{ default_topo }}
{%- else %}
def
{%- endif %}
{%- endmacro -%}
{# Determine device topology and filename postfix #}
{%- if DEVICE_METADATA is defined %}
{%- set switch_role = DEVICE_METADATA['localhost']['type'] %}
{%- if 'torrouter' in switch_role.lower() %}
{%- set filename_postfix = 't0' %}
{%- elif 'leafrouter' in switch_role.lower() %}
{%- set filename_postfix = 't1' %}
{%- else %}
{%- set filename_postfix = set_default_topology() %}
{%- endif %}
{%- else %}
{%- set filename_postfix = set_default_topology() %}
{%- set switch_role = '' %}
{%- endif -%}
{# Import default values from device HWSKU folder #}
{%- import 'buffers_defaults_%s.j2' % filename_postfix as defs %}
{%- set default_cable = defs.default_cable -%}
{# 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 #}
{%- if defs.ports2cable is defined %}
{%- set ports2cable = defs.ports2cable %}
{%- else %}
{%- set ports2cable = {
'torrouter_server' : '5m',
'leafrouter_torrouter' : '40m',
'spinerouter_leafrouter' : '300m'
}
-%}
{%- endif %}
{%- macro cable_length(port_name) %}
{%- set cable_len = [] %}
{%- for local_port in DEVICE_NEIGHBOR %}
{%- if local_port == port_name %}
{%- if DEVICE_NEIGHBOR_METADATA is defined and 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 'torrouter' in switch_role.lower() %}
{%- for local_port in VLAN_MEMBER %}
{%- if local_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 %}
{%- set PORT_ALL = [] %}
{%- if PORT is not defined %}
{%- if defs.generate_port_lists(PORT_ALL) %} {% endif %}
{%- else %}
{%- for port in PORT %}
{%- if PORT_ALL.append(port) %}{%- endif %}
{%- endfor %}
{%- endif %}
{%- set PORT_ACTIVE = [] %}
{%- if DEVICE_NEIGHBOR is not defined %}
{%- set PORT_ACTIVE = PORT_ALL %}
{%- else %}
{%- for port in DEVICE_NEIGHBOR.keys() %}
{%- if PORT_ACTIVE.append(port) %}{%- endif %}
{%- endfor %}
{%- endif %}
{%- set port_names_list_active = [] %}
{%- for port in PORT_ACTIVE %}
{%- if port_names_list_active.append(port) %}{%- endif %}
{%- endfor %}
{%- set port_names_active = port_names_list_active | join(',') %}
{
"CABLE_LENGTH": {
"AZURE": {
{% for port in PORT_ALL %}
{%- set cable = cable_length(port) %}
"{{ port }}": "{{ cable }}"{%- if not loop.last %},{% endif %}
{% endfor %}
}
},
{% if defs.generate_buffer_pool_and_profiles is defined %}
{{ defs.generate_buffer_pool_and_profiles() }}
{% endif %}
{%- if defs.generate_profile_lists is defined %}
{{ defs.generate_profile_lists(port_names_active) }},
{% endif %}
{%- if defs.generate_pg_profils is defined %}
{{ defs.generate_pg_profils(port_names_active) }}
{% else %}
"BUFFER_PG": {
{% for port in PORT_ACTIVE %}
"{{ port }}|0": {
"profile" : "ingress_lossy_profile"
}{% if not loop.last %},{% endif %}
{% endfor %}
},
{% endif %}
{% if defs.generate_queue_buffers is defined %}
{{ defs.generate_queue_buffers(port_names_active) }}
{% else %}
"BUFFER_QUEUE": {
{% for port in PORT_ACTIVE %}
"{{ port }}|3-4": {
"profile" : "egress_lossless_profile"
},
{% endfor %}
{% for port in PORT_ACTIVE %}
"{{ port }}|0-2": {
"profile" : "egress_lossy_profile"
},
{% endfor %}
{% for port in PORT_ACTIVE %}
"{{ port }}|5-6": {
"profile" : "egress_lossy_profile"
}{% if not loop.last %},{% endif %}
{% endfor %}
}
{% endif %}
}