-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Improve: buffer configuration infrastructure #1403
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1650d64
[sonic-cfggen] allow templates to include from common folders
yxieca ca520db
[sonic build] Define folder macro for target folder /usr/sonic/share/…
yxieca 928b0e6
[Buffer config] install the buffer configuration template
yxieca 7a4321a
[Arista7260cx3] Add buffer configuration for Arista7260CX3 T0 topology
yxieca bfff3ec
[Arista7260cx3] Adding QoS configuration
yxieca 9cace7b
Address review comments
yxieca File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
{%- 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 switch_role.lower() == 'torrouter' %} | ||
{%- set filename_postfix = 't0' %} | ||
{%- elif switch_role.lower() == 'leafrouter' %} | ||
{%- 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 %} | ||
{%- set default_speed = defs.default_speed %} | ||
|
||
{# 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 %} | ||
{%- 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 switch_role.lower() == 'torrouter' %} | ||
{%- for local_port in VLAN_MEMBER %} | ||
{%- set vlan_port = local_port.split("|") %} | ||
{%- if vlan_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 = [] %} | ||
{%- set PORT_10G = [] %} | ||
{%- set PORT_25G = [] %} | ||
{%- set PORT_40G = [] %} | ||
{%- set PORT_50G = [] %} | ||
{%- set PORT_100G = [] %} | ||
|
||
{%- if PORT is not defined %} | ||
{%- if defs.generate_port_lists(PORT_10G, PORT_25G, PORT_40G, PORT_50G, PORT_100G) %} {% endif %} | ||
{%- else %} | ||
{# Determine the default speed set according to the default speed #} | ||
{%- if default_speed == '10G' %} | ||
{%- set default_set = PORT_10G %} | ||
{%- elif default_speed == '25G' %} | ||
{%- set default_set = PORT_25G %} | ||
{%- elif default_speed == '40G' %} | ||
{%- set default_set = PORT_40G %} | ||
{%- elif default_speed == '50G' %} | ||
{%- set default_set = PORT_50G %} | ||
{%- elif default_speed == '100G' %} | ||
{%- set default_set = PORT_100G %} | ||
{%- else %} | ||
{%- set default_set = PORT_50G %} | ||
{%- endif %} | ||
|
||
{# Distribute ports to speed sets #} | ||
{%- for port in PORT %} | ||
{%- if 'speed' in PORT[port] %} | ||
{%- set speed = PORT[port]['speed'] %} | ||
{%- if speed == '100000' %} | ||
{%- if PORT_100G.append(port) %}{%- endif %} | ||
{%- elif speed == '50000' %} | ||
{%- if PORT_50G.append(port) %}{%- endif %} | ||
{%- elif speed == '40000' %} | ||
{%- if PORT_40G.append(port) %}{%- endif %} | ||
{%- elif speed == '25000' %} | ||
{%- if PORT_25G.append(port) %}{%- endif %} | ||
{%- elif speed == '10000' %} | ||
{%- if PORT_10G.append(port) %}{%- endif %} | ||
{%- else %} | ||
{%- if default_set.append(port) %}{%- endif %} | ||
{%- endif %} | ||
{%- else %} | ||
{%- if default_set.append(port) %}{%- endif %} | ||
{%- endif %} | ||
{%- endfor %} | ||
{%- endif %} | ||
|
||
{# Put all ports in PORT_ALL #} | ||
{%- for port in PORT_10G + PORT_25G + PORT_40G + PORT_50G + PORT_100G %} | ||
{%- if PORT_ALL.append(port) %}{%- endif %} | ||
{%- endfor %} | ||
|
||
{%- set port_names_list_all = [] %} | ||
{%- for port in PORT_ALL %} | ||
{%- if port_names_list_all.append(port) %}{%- endif %} | ||
{%- endfor %} | ||
{%- set port_names_all = port_names_list_all | join(',') %} | ||
|
||
{ | ||
"CABLE_LENGTH": { | ||
"AZURE": { | ||
{% for port in PORT %} | ||
{%- set cable = cable_length(port) %} | ||
"{{ port }}": "{{ cable }}"{%- if not loop.last %},{% endif %} | ||
|
||
{% endfor %} | ||
} | ||
}, | ||
{% set bufs = defs.generate_buffer_pool_and_profiles() %} | ||
{{ bufs }} | ||
"BUFFER_PG": { | ||
{% for port in PORT_10G %} | ||
"{{ port }}|3-4": { | ||
"profile" : "[BUFFER_PROFILE|ingress_lossless_profile_10g]" | ||
}, | ||
{% endfor %} | ||
{% for port in PORT_25G %} | ||
"{{ port }}|3-4": { | ||
"profile" : "[BUFFER_PROFILE|ingress_lossless_profile_25g]" | ||
}, | ||
{% endfor %} | ||
{% for port in PORT_40G %} | ||
"{{ port }}|3-4": { | ||
"profile" : "[BUFFER_PROFILE|ingress_lossless_profile_40g]" | ||
}, | ||
{% endfor %} | ||
{% for port in PORT_50G %} | ||
"{{ port }}|3-4": { | ||
"profile" : "[BUFFER_PROFILE|ingress_lossless_profile_50g]" | ||
}, | ||
{% endfor %} | ||
{% for port in PORT_100G %} | ||
"{{ port }}|3-4": { | ||
"profile" : "[BUFFER_PROFILE|ingress_lossless_profile_100g]" | ||
}, | ||
{% endfor %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove default configuration for pg 3-4 |
||
{% if port_names_all|length > 0 %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove or duplicate below |
||
"{{ port_names_all }}|0-1": { | ||
"profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" | ||
} | ||
{% endif %} | ||
}, | ||
"BUFFER_QUEUE": { | ||
"{{ port_names_all }}|3-4": { | ||
"profile" : "[BUFFER_PROFILE|egress_lossless_profile]" | ||
}, | ||
"{{ port_names_all }}|0-1": { | ||
"profile" : "[BUFFER_PROFILE|egress_lossy_profile]" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
look into the possibility of looking up speed information from port_config.ini