Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Mellanox buffer profile template to work with an incomplete minigraph #332

Merged
merged 1 commit into from
Oct 2, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 23 additions & 13 deletions swssconfig/sample/msn27xx.32ports.buffers.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -169,20 +169,26 @@
{% set switch_role = DEVICE_METADATA['localhost']['type'] %}

{%- macro cable_length(port_name) -%}
{%- set cable_len = [] -%}
{%- for neighbor in DEVICE_NEIGHBOR -%}
{%- if DEVICE_NEIGHBOR[neighbor]['local_port'] == port_name -%}
{%- set neighbor_role = DEVICE_NEIGHBOR[neighbor]['type'] -%}
{%- set roles1 = switch_role + '_' + neighbor_role %}
{%- set roles2 = neighbor_role + '_' + switch_role -%}
{%- if roles1 in ports2cable -%}
{{ ports2cable[roles1] }}
{%- elif roles2 in ports2cable -%}
{{ ports2cable[roles2] }}
{%- else -%}
{{ supported_cable | last }}
{%- endif -%}
{%- if DEVICE_NEIGHBOR[neighbor].local_port and DEVICE_NEIGHBOR[neighbor].type -%}
{%- if DEVICE_NEIGHBOR[neighbor]['local_port'] == port_name -%}
{%- set neighbor_role = DEVICE_NEIGHBOR[neighbor]['type'] -%}
{%- set roles1 = switch_role + '_' + neighbor_role %}
{%- set roles2 = neighbor_role + '_' + switch_role -%}
{%- 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 -%}
{{ supported_cable | last }}
{%- endif -%}
{% endmacro %}

{%- macro find_closest_greater_config(speed, cable) -%}
Expand All @@ -204,9 +210,13 @@
{% set ingress_lossless_pg_pool_size = [] %}
{% set used_pg_profiles = [] %}
{% for port in PORT %}
{%- set speed = PORT[port]['speed'] -%}
{%- if PORT[port].speed -%}
{%- set speed = PORT[port]['speed'] -%}
{% else %}
{%- set speed = supported_speed|last -%}
{%- endif -%}
{%- set cable = cable_length(port) -%}
{%- set port_config = speed + '_' + cable -%}
{%- set port_config = speed|string + '_' + cable -%}
{%- if not port_config in portconfig2profile -%}
{% set port_config = find_closest_greater_config(speed, cable) -%}
{%- endif -%}
Expand Down