e010d83fc3
**- Why I did it** To support dynamic buffer calculation. This PR also depends on the following PRs for sub modules - [sonic-swss: [buffermgr/bufferorch] Support dynamic buffer calculation #1338](https://github.com/Azure/sonic-swss/pull/1338) - [sonic-swss-common: Dynamic buffer calculation #361](https://github.com/Azure/sonic-swss-common/pull/361) - [sonic-utilities: Support dynamic buffer calculation #973](https://github.com/Azure/sonic-utilities/pull/973) **- How I did it** 1. Introduce field `buffer_model` in `DEVICE_METADATA|localhost` to represent which buffer model is running in the system currently: - `dynamic` for the dynamic buffer calculation model - `traditional` for the traditional model in which the `pg_profile_lookup.ini` is used 2. Add the tables required for the feature: - ASIC_TABLE in platform/\<vendor\>/asic_table.j2 - PERIPHERAL_TABLE in platform/\<vendor\>/peripheral_table.j2 - PORT_PERIPHERAL_TABLE on a per-platform basis in device/\<vendor\>/\<platform\>/port_peripheral_config.j2 for each platform with gearbox installed. - DEFAULT_LOSSLESS_BUFFER_PARAMETER and LOSSLESS_TRAFFIC_PATTERN in files/build_templates/buffers_config.j2 - Add lossless PGs (3-4) for each port in files/build_templates/buffers_config.j2 3. Copy the newly introduced j2 files into the image and rendering them when the system starts 4. Update the CLI options for buffermgrd so that it can start with dynamic mode 5. Fetches the ASIC vendor name in orchagent: - fetch the vendor name when creates the docker and pass it as a docker environment variable - `buffermgrd` can use this passed-in variable 6. Clear buffer related tables from STATE_DB when swss docker starts 7. Update the src/sonic-config-engine/tests/sample_output/buffers-dell6100.json according to the buffer_config.j2 8. Remove buffer pool sizes for ingress pools and egress_lossy_pool Update the buffer settings for dynamic buffer calculation
195 lines
6.4 KiB
Django/Jinja
195 lines
6.4 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 and DEVICE_METADATA['localhost']['type'] is defined %}
|
|
{%- set switch_role = DEVICE_METADATA['localhost']['type'] %}
|
|
{%- if 'torrouter' in switch_role.lower() and 'mgmt' not in switch_role.lower()%}
|
|
{%- set filename_postfix = 't0' %}
|
|
{%- elif 'leafrouter' in switch_role.lower() and 'mgmt' not 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 with context %}
|
|
|
|
{%- 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 %}
|
|
{%- if 'asic' == neighbor_role | lower %}
|
|
{%- set roles1 = 'internal' %}
|
|
{%- if 'internal' not in ports2cable %}
|
|
{%- set _ = ports2cable.update({'internal': '5m'}) %}
|
|
{%- endif -%}
|
|
{%- else %}
|
|
{%- set roles1 = switch_role + '_' + neighbor_role %}
|
|
{%- set roles2 = neighbor_role + '_' + switch_role %}
|
|
{%- set roles1 = roles1 | lower %}
|
|
{%- set roles2 = roles2 | lower %}
|
|
{%- set roles1 = roles1.replace('backend', '') %}
|
|
{%- set roles2 = roles2.replace('backend', '') %}
|
|
{%- endif %}
|
|
{%- 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() and 'mgmt' not 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 %}
|
|
{%- set roles3 = roles3.replace('backend', '') %}
|
|
{%- 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 %}
|
|
{% if dynamic_mode is defined %}
|
|
"{{ port }}|3-4": {
|
|
"profile" : "NULL"
|
|
},
|
|
{% endif %}
|
|
"{{ port }}|0": {
|
|
"profile" : "[BUFFER_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" : "[BUFFER_PROFILE|egress_lossless_profile]"
|
|
},
|
|
{% endfor %}
|
|
{% for port in PORT_ACTIVE %}
|
|
"{{ port }}|0-2": {
|
|
"profile" : "[BUFFER_PROFILE|egress_lossy_profile]"
|
|
},
|
|
{% endfor %}
|
|
{% for port in PORT_ACTIVE %}
|
|
"{{ port }}|5-6": {
|
|
"profile" : "[BUFFER_PROFILE|egress_lossy_profile]"
|
|
}{% if not loop.last %},{% endif %}
|
|
|
|
{% endfor %}
|
|
}
|
|
{% endif %}
|
|
{% if dynamic_mode is defined %}
|
|
,
|
|
"DEFAULT_LOSSLESS_BUFFER_PARAMETER": {
|
|
"AZURE": {
|
|
"default_dynamic_th": "0"
|
|
}
|
|
},
|
|
"LOSSLESS_TRAFFIC_PATTERN": {
|
|
"AZURE": {
|
|
"mtu": "1024",
|
|
"small_packet_percentage": "100"
|
|
}
|
|
}
|
|
{% endif %}
|
|
}
|