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

Buffers configuration update on port speed change #1250

Merged
merged 9 commits into from
Jan 26, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
151 changes: 151 additions & 0 deletions device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers.json.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
{# Default values which will be used if no actual configura available #}
{% set default_cable = '300m' %}
{% set default_speed = '100G' %}
{% set default_ports_num = 32 -%}

{# 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 -%}
{%- if roles1 in ports2cable -%}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have enforcement elsewhere to make sure that the switch_role and neighbor_role's case is as expected?

If we cannot guarantee the case, then we might want to cast the string to upper or lower case, just in case?

Same question for line 27 below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, we don't have case enforcement. Agree, need to convert to common case before the comparison

{%- 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 -%}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to test if the list is non-empty, but this test seems to be testing if the list has been defined. Which is defined in line 17 above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, thanks. I already implemented this in #1263 need to back-merge to this PR as well

{{ cable_len.0 }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under what circumstances would there be more than one length in the list?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should be no more than one value in the list. cable_len.0 is the way to get first (and only) element of the list. All that weird usage of the cable_len list here is the workaround for jinja templates limitation for variables visibility in blocks. Only list or dictionary can be modified in block and maintain that value outside the block.

{%- else -%}
{{ default_cable }}
{%- 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*4)) %}{% 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": "6764966",
"type": "ingress",
"mode": "dynamic"
},
"ingress_lossy_pool": {
"size": "6422528",
"type": "ingress",
"mode": "dynamic"
},
"egress_lossless_pool": {
"size": "7291456",
"type": "egress",
"mode": "dynamic"
},
"egress_lossy_pool": {
"size": "8254464",
"type": "egress",
"mode": "dynamic"
}
},
"BUFFER_PROFILE": {
"ingress_lossless_profile": {
"pool":"[BUFFER_POOL|ingress_lossless_pool]",
"size":"0",
"dynamic_th":"1"
},
"ingress_lossy_profile": {
"pool":"[BUFFER_POOL|ingress_lossy_pool]",
"size":"0",
"dynamic_th":"7"
},
"egress_lossless_profile": {
"pool":"[BUFFER_POOL|egress_lossless_pool]",
"size":"0",
"dynamic_th":"7"
},
"egress_lossy_profile": {
"pool":"[BUFFER_POOL|egress_lossy_pool]",
"size":"4096",
"dynamic_th":"7"
},
"pg_lossy_profile": {
"pool":"[BUFFER_POOL|ingress_lossy_pool]",
"size":"0",
"dynamic_th":"7"
},
"q_lossless_profile": {
"pool":"[BUFFER_POOL|egress_lossless_pool]",
"size":"0",
"dynamic_th":"7"
},
"q_lossy_profile": {
"pool":"[BUFFER_POOL|egress_lossy_pool]",
"size":"0",
"dynamic_th":"7"
}
},
"BUFFER_PORT_INGRESS_PROFILE_LIST": {
"{{ port_names }}": {
"profile_list" : "[BUFFER_PROFILE|ingress_lossless_profile],[BUFFER_PROFILE|ingress_lossy_profile]"
}
},
"BUFFER_PORT_EGRESS_PROFILE_LIST": {
"{{ port_names }}": {
"profile_list" : "[BUFFER_PROFILE|egress_lossless_profile],[BUFFER_PROFILE|egress_lossy_profile]"
}
},
"BUFFER_PG": {
"{{ port_names }}|0-1": {
"profile" : "[BUFFER_PROFILE|pg_lossy_profile]"
}
},
"BUFFER_QUEUE": {
"{{ port_names }}|3-4": {
"profile" : "[BUFFER_PROFILE|q_lossless_profile]"
},
"{{ port_names }}|0-1": {
"profile" : "[BUFFER_PROFILE|q_lossy_profile]"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# PG lossless profiles.
# speed cable size xon xoff threshold
10000 5m 34816 18432 16384 1
25000 5m 34816 18432 16384 1
40000 5m 34816 18432 16384 1
50000 5m 34816 18432 16384 1
100000 5m 36864 18432 18432 1
10000 40m 36864 18432 18432 1
25000 40m 39936 18432 21504 1
40000 40m 41984 18432 23552 1
50000 40m 41984 18432 23552 1
100000 40m 54272 18432 35840 1
10000 300m 49152 18432 30720 1
25000 300m 71680 18432 53248 1
40000 300m 94208 18432 75776 1
50000 300m 94208 18432 75776 1
100000 300m 184320 18432 165888 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see matching code using this look up table. Who is using it where and how?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loading