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

[sonic-cfggen]: Add DEVICE_NEIGHBOR_METADATA field and move msn27xx template #1025

Merged
merged 1 commit into from
Oct 19, 2017
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions dockers/docker-orchagent/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["ipinip.json.j2", "/usr/share/sonic/templates/"]
COPY ["mirror.json.j2", "/usr/share/sonic/templates/"]
COPY ["ports.json.j2", "/usr/share/sonic/templates/"]
COPY ["msn27xx.32ports.buffers.json.j2", "/usr/share/sonic/templates/"]

ENTRYPOINT ["/usr/bin/supervisord"]
294 changes: 294 additions & 0 deletions dockers/docker-orchagent/msn27xx.32ports.buffers.json.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
[
{% set port_names_list = [] %}
{% for port in PORT %}
{%- if port_names_list.append(port) %}{% endif %}
{% endfor %}
{% set port_names = port_names_list | join(',') %}
{
"BUFFER_POOL_TABLE:ingress_lossless_pool": {
"size": "3024486",
"type": "ingress",
"mode": "dynamic"
},
"OP": "SET"
},
{
"BUFFER_POOL_TABLE:ingress_lossy_pool": {
"size": "6422528",
"type": "ingress",
"mode": "dynamic"
},
"OP": "SET"
},
{
"BUFFER_POOL_TABLE:egress_lossless_pool": {
"size": "7291456",
"type": "egress",
"mode": "dynamic"
},
"OP": "SET"
},
{
"BUFFER_POOL_TABLE:egress_lossy_pool": {
"size": "8254464",
"type": "egress",
"mode": "dynamic"
},
"OP": "SET"
},
{
"BUFFER_PROFILE_TABLE:ingress_lossless_profile": {
"pool":"[BUFFER_POOL_TABLE:ingress_lossless_pool]",
"size":"0",
"dynamic_th":"7"
},
"OP": "SET"
},
{
"BUFFER_PROFILE_TABLE:ingress_lossy_profile": {
"pool":"[BUFFER_POOL_TABLE:ingress_lossy_pool]",
"size":"0",
"dynamic_th":"7"
},
"OP": "SET"
},
{
"BUFFER_PROFILE_TABLE:egress_lossless_profile": {
"pool":"[BUFFER_POOL_TABLE:egress_lossless_pool]",
"size":"1518",
"dynamic_th":"7"
},
"OP": "SET"
},
{
"BUFFER_PROFILE_TABLE:egress_lossy_profile": {
"pool":"[BUFFER_POOL_TABLE:egress_lossy_pool]",
"size":"4096",
"dynamic_th":"7"
},
"OP": "SET"
},
{
"BUFFER_PROFILE_TABLE:pg_lossy_profile": {
"pool":"[BUFFER_POOL_TABLE:ingress_lossy_pool]",
"size":"0",
"dynamic_th":"3"
},
"OP": "SET"
},
{
"BUFFER_PROFILE_TABLE:q_lossless_profile": {
"pool":"[BUFFER_POOL_TABLE:egress_lossless_pool]",
"size":"0",
"dynamic_th":"7"
},
"OP": "SET"
},
{
"BUFFER_PROFILE_TABLE:q_lossy_profile": {
"pool":"[BUFFER_POOL_TABLE:egress_lossy_pool]",
"size":"0",
"dynamic_th":"1"
},
"OP": "SET"
},
{
"BUFFER_PORT_INGRESS_PROFILE_LIST:{{ port_names }}": {
"profile_list" : "[BUFFER_PROFILE_TABLE:ingress_lossless_profile],[BUFFER_PROFILE_TABLE:ingress_lossy_profile]"
},
"OP": "SET"
},
{
"BUFFER_PORT_EGRESS_PROFILE_LIST:{{ port_names }}": {
"profile_list" : "[BUFFER_PROFILE_TABLE:egress_lossless_profile],[BUFFER_PROFILE_TABLE:egress_lossy_profile]"
},
"OP": "SET"
},

{# The following template part is for variable PG profile configuration #}
{% set pg_range = '3-4' %}
{# Lists of supported speed and cable length #}
{% set supported_speed = [10000, 25000, 40000, 50000, 100000] %}
{% set supported_cable = [5, 40, 300] %}

{# The key in this lictionary consist of two parts: (port speed)_(cable length) #}
{%- set portconfig2profile = {
'10000_5' : 'pg_lossless_10G_5m_profile',
'25000_5' : 'pg_lossless_25G_5m_profile',
'40000_5' : 'pg_lossless_40G_5m_profile',
'50000_5' : 'pg_lossless_50G_5m_profile',
'100000_5' : 'pg_lossless_100G_5m_profile',

'10000_40' : 'pg_lossless_10G_40m_profile',
'25000_40' : 'pg_lossless_25G_40m_profile',
'40000_40' : 'pg_lossless_40G_40m_profile',
'50000_40' : 'pg_lossless_50G_40m_profile',
'100000_40' : 'pg_lossless_100G_40m_profile',

'10000_300' : 'pg_lossless_10G_300m_profile',
'25000_300' : 'pg_lossless_25G_300m_profile',
'40000_300' : 'pg_lossless_40G_300m_profile',
'50000_300' : 'pg_lossless_50G_300m_profile',
'100000_300': 'pg_lossless_100G_300m_profile'
}
-%}

{# PG profiles. All profiles reffered in portconfig2profile dictionary should be declared here #}
{# Only those which were actually used will be created in SAI #}
{%- set pg_profiles = {
'pg_lossless_10G_5m_profile': { 'xon': 18432, 'xoff': 16384, 'size': 34816, 'dynamic_th': 1 },
'pg_lossless_25G_5m_profile': { 'xon': 18432, 'xoff': 16384, 'size': 34816, 'dynamic_th': 1 },
'pg_lossless_40G_5m_profile': { 'xon': 18432, 'xoff': 16384, 'size': 34816, 'dynamic_th': 1 },
'pg_lossless_50G_5m_profile': { 'xon': 18432, 'xoff': 16384, 'size': 34816, 'dynamic_th': 1 },
'pg_lossless_100G_5m_profile': { 'xon': 18432, 'xoff': 18432, 'size': 36864, 'dynamic_th': 1 },

'pg_lossless_10G_40m_profile': { 'xon': 18432, 'xoff': 18432, 'size': 36864, 'dynamic_th': 1 },
'pg_lossless_25G_40m_profile': { 'xon': 18432, 'xoff': 21504, 'size': 39936, 'dynamic_th': 1 },
'pg_lossless_40G_40m_profile': { 'xon': 18432, 'xoff': 23552, 'size': 41984, 'dynamic_th': 1 },
'pg_lossless_50G_40m_profile': { 'xon': 18432, 'xoff': 23552, 'size': 41984, 'dynamic_th': 1 },
'pg_lossless_100G_40m_profile': { 'xon': 18432, 'xoff': 35840, 'size': 54272, 'dynamic_th': 1 },

'pg_lossless_10G_300m_profile': { 'xon': 18432, 'xoff': 30720, 'size': 49152, 'dynamic_th': 1 },
'pg_lossless_25G_300m_profile': { 'xon': 18432, 'xoff': 53248, 'size': 71680, 'dynamic_th': 1 },
'pg_lossless_40G_300m_profile': { 'xon': 18432, 'xoff': 75776, 'size': 94208, 'dynamic_th': 1 },
'pg_lossless_50G_300m_profile': { 'xon': 18432, 'xoff': 75776, 'size': 94208, 'dynamic_th': 1 },
'pg_lossless_100G_300m_profile':{ 'xon': 18432, 'xoff': 165888,'size': 184320,'dynamic_th': 1 },
}
-%}

{# 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' : '5',
'LeafRouter_ToRRouter' : '40',
'SpineRouter_LeafRouter' : '300'
}
%}

{% set switch_role = DEVICE_METADATA['localhost']['type'] %}

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

Choose a reason for hiding this comment

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

this condition doesn't work because DEVICE_NEIGHBOR[local_port].name is equal ARISTA07T0, for example, and corresponding key in DEVICE_NEIGHBOR_METADATA is "ARISTA07T0" (with quotes)
There was a fix in the minigraph.py in the old code: 8f3b658

Copy link
Collaborator

@andriymoroz-mlnx andriymoroz-mlnx Oct 11, 2017

Choose a reason for hiding this comment

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

Or remove quotes in minigraph generation
https://github.com/Azure/sonic-mgmt/blob/master/ansible/templates/topo/t0.j2#L192 (and other j2 files in this directory):
<Hostname>"{{ dev }}"</Hostname>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah yes. then i think we will need to remove the quotes in the minigraph generation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sonic-net/sonic-mgmt#301 please check.

{%- 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 -%}
{%- 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) -%}
{%- set new_speed = [] -%}
{%- for std_speed in supported_speed -%}
{%- if std_speed | int >= speed | int -%}
{%- if new_speed.append(std_speed) -%}{%- endif -%}
{% endif -%}
{%- endfor -%}
{%- set new_cable = [] -%}
{%- for std_cable in supported_cable -%}
{% if std_cable | int >= cable | int -%}
{%- if new_cable.append(std_cable) -%}{%- endif -%}
{% endif %}
{%- endfor -%}
{{ new_speed.0 }}_{{ new_cable.0 }}
{%- endmacro -%}

{% set ingress_lossless_pg_pool_size = [] %}
{% set used_pg_profiles = [] %}
{% for port in PORT %}
{%- 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|string + '_' + cable -%}
{%- if not port_config in portconfig2profile -%}
{% set port_config = find_closest_greater_config(speed, cable) -%}
{%- endif -%}
{% set profile = portconfig2profile[port_config] -%}
{% if ingress_lossless_pg_pool_size.append(pg_profiles[profile]['size']) %}{% endif %}
{# add to list profiles which were actually used #}
{%- if profile not in used_pg_profiles and used_pg_profiles.append(profile) %}{% endif -%}
{
"BUFFER_PG_TABLE:{{ port }}:{{ pg_range }}": {
"profile" : "[BUFFER_PROFILE_TABLE:{{ profile }}]"
},
"OP": "SET"
},
{% endfor -%}

{# PG profiles declaration #}

{% for profile_name in used_pg_profiles %}
{%- set profile_config = pg_profiles[profile_name] %}
{
"BUFFER_PROFILE_TABLE:{{ profile_name }}": {
"pool":"[BUFFER_POOL_TABLE:ingress_lossless_pg_pool]",
"xon":"{{ profile_config['xon'] }}",
"xoff":"{{ profile_config['xoff'] }}",
"size":"{{ profile_config['size'] }}",
"dynamic_th":"{{ profile_config['dynamic_th'] }}"
},
"OP": "SET"
},
{% endfor -%}

{# Pool declaration #}
{
"BUFFER_POOL_TABLE:ingress_lossless_pg_pool": {
"size": "{{ ingress_lossless_pg_pool_size | sum }}",
"type": "ingress",
"mode": "dynamic"
},
"OP": "SET"
},
{
"BUFFER_PG_TABLE:{{ port_names }}:0-1": {
"profile" : "[BUFFER_PROFILE_TABLE:pg_lossy_profile]"
},
"OP": "SET"
},
{
"BUFFER_QUEUE_TABLE:{{ port_names }}:3-4": {
"profile" : "[BUFFER_PROFILE_TABLE:q_lossless_profile]"
},
"OP": "SET"
},
{
"BUFFER_QUEUE_TABLE:{{ port_names }}:0-1": {
"profile" : "[BUFFER_PROFILE_TABLE:q_lossy_profile]"
},
"OP": "SET"
},
{
"PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_TABLE:AZURE": {
"0": "0",
"1": "1",
"3": "3",
"4": "4"
},
"OP": "SET"
},
{
"PORT_QOS_MAP_TABLE:{{ port_names }}": {
"pfc_to_pg_map" : "[PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_TABLE:AZURE]"
},
"OP": "SET"
}
]
1 change: 1 addition & 0 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
results['VLAN'] = vlans

results['DEVICE_NEIGHBOR'] = neighbors
results['DEVICE_NEIGHBOR_METADATA'] = { key:devices[key] for key in devices if key != hostname }
results['SYSLOG_SERVER'] = dict((item, {}) for item in syslog_servers)
results['DHCP_SERVER'] = dict((item, {}) for item in dhcp_servers)
results['NTP_SERVER'] = dict((item, {}) for item in ntp_servers)
Expand Down
33 changes: 33 additions & 0 deletions src/sonic-config-engine/tests/sample-port-config-mlnx.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# name lanes
Ethernet0 0,1,2,3
Ethernet4 4,5,6,7
Ethernet8 8,9,10,11
Ethernet12 12,13,14,15
Ethernet16 16,17,18,19
Ethernet20 20,21,22,23
Ethernet24 24,25,26,27
Ethernet28 28,29,30,31
Ethernet32 32,33,34,35
Ethernet36 36,37,38,39
Ethernet40 40,41,42,43
Ethernet44 44,45,46,47
Ethernet48 48,49,50,51
Ethernet52 52,53,54,55
Ethernet56 56,57,58,59
Ethernet60 60,61,62,63
Ethernet64 64,65,66,67
Ethernet68 68,69,70,71
Ethernet72 72,73,74,75
Ethernet76 76,77,78,79
Ethernet80 80,81,82,83
Ethernet84 84,85,86,87
Ethernet88 88,89,90,91
Ethernet92 92,93,94,95
Ethernet96 96,97,98,99
Ethernet100 100,101,102,103
Ethernet104 104,105,106,107
Ethernet108 108,109,110,111
Ethernet112 112,113,114,115
Ethernet116 116,117,118,119
Ethernet120 120,121,122,123
Ethernet124 124,125,126,127
Loading