From 761bdf3e224be7abb7e4e1fe12d4d87624b1ca3f Mon Sep 17 00:00:00 2001 From: stephens Date: Fri, 8 May 2020 02:08:31 +0000 Subject: [PATCH] [Dynamic buffer calculation] Support dynamic buffer calculation 1. add tables required for the feature: - ASIC_TABLE in files/build_templates/asic_table.j2 - PERIPHERAL_TABLE in files/build_templates/peripheral_table.j2 - PORT_PERIPHERAL_TABLE on a per-platform basis in device/mellanox/x86_64-mlnx_msn3800-r0/port_peripheral_config.j2 - 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 2. copy the newly introduced j2 files into image and rendering them when system starts 3. update the CLI options for buffermgrd so that it can start with dynamic mode 4. Adjust the order in which swss daemons start, making buffermgrd start before orchagent. This is to make sure buffermgrd can get everything ready before orchagent starts especially during warm reboot. 5. Optimize the way in which orchagent fetches the asic vendor name: - fetch the vendor name when creates the docker and pass it as a docker environment variable - orchagent and 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 Signed-off-by: Stephen Sun --- .../ACS-MSN2700/buffers_defaults_t0.j2 | 14 +- .../ACS-MSN2700/buffers_defaults_t1.j2 | 14 +- .../ACS-MSN3700/buffers_defaults_t0.j2 | 14 +- .../ACS-MSN3700/buffers_defaults_t1.j2 | 14 +- .../ACS-MSN3800/buffers_defaults_t0.j2 | 12 +- .../ACS-MSN3800/buffers_defaults_t1.j2 | 12 +- .../port_peripheral_config.j2 | 10 ++ .../ACS-MSN4700/buffers_defaults_t0.j2 | 12 +- .../ACS-MSN4700/buffers_defaults_t1.j2 | 12 +- dockers/docker-orchagent/orchagent.sh | 2 +- dockers/docker-orchagent/supervisord.conf | 20 +-- files/build_templates/asic_table.j2 | 68 +++++++++ files/build_templates/buffers_config.j2 | 15 ++ files/build_templates/docker_image_ctl.j2 | 15 ++ files/build_templates/peripheral_table.j2 | 28 ++++ .../build_templates/sonic_debian_extension.j2 | 11 ++ files/scripts/swss.sh | 2 +- .../tests/sample_output/buffers-dell6100.json | 144 ++++++++++++++++++ 18 files changed, 331 insertions(+), 88 deletions(-) create mode 100644 device/mellanox/x86_64-mlnx_msn3800-r0/port_peripheral_config.j2 create mode 100644 files/build_templates/asic_table.j2 create mode 100644 files/build_templates/peripheral_table.j2 diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers_defaults_t0.j2 index 5529ee3d8598..ed61f3bf43a4 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers_defaults_t0.j2 @@ -1,8 +1,5 @@ {% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '5029836' %} -{% set ingress_lossy_pool_size = '5029836' %} -{% set egress_lossless_pool_size = '14024599' %} -{% set egress_lossy_pool_size = '5029836' %} +{% set egress_lossless_pool_size = '14024640' %} {%- macro generate_port_lists(PORT_ALL) %} {# Generate list of ports #} @@ -14,12 +11,10 @@ {%- macro generate_buffer_pool_and_profiles() %} "BUFFER_POOL": { "ingress_lossless_pool": { - "size": "{{ ingress_lossless_pool_size }}", "type": "ingress", "mode": "dynamic" }, "ingress_lossy_pool": { - "size": "{{ ingress_lossy_pool_size }}", "type": "ingress", "mode": "dynamic" }, @@ -29,7 +24,6 @@ "mode": "dynamic" }, "egress_lossy_pool": { - "size": "{{ egress_lossy_pool_size }}", "type": "egress", "mode": "dynamic" } @@ -38,7 +32,7 @@ "ingress_lossless_profile": { "pool":"[BUFFER_POOL|ingress_lossless_pool]", "size":"0", - "dynamic_th":"0" + "dynamic_th":"7" }, "ingress_lossy_profile": { "pool":"[BUFFER_POOL|ingress_lossy_pool]", @@ -52,8 +46,8 @@ }, "egress_lossy_profile": { "pool":"[BUFFER_POOL|egress_lossy_pool]", - "size":"4096", - "dynamic_th":"3" + "size":"9216", + "dynamic_th":"7" }, "q_lossy_profile": { "pool":"[BUFFER_POOL|egress_lossy_pool]", diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers_defaults_t1.j2 index f418e2ffa1db..ed61f3bf43a4 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers_defaults_t1.j2 @@ -1,8 +1,5 @@ {% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '2097100' %} -{% set ingress_lossy_pool_size = '2097100' %} -{% set egress_lossless_pool_size = '14024599' %} -{% set egress_lossy_pool_size = '2097100' %} +{% set egress_lossless_pool_size = '14024640' %} {%- macro generate_port_lists(PORT_ALL) %} {# Generate list of ports #} @@ -14,12 +11,10 @@ {%- macro generate_buffer_pool_and_profiles() %} "BUFFER_POOL": { "ingress_lossless_pool": { - "size": "{{ ingress_lossless_pool_size }}", "type": "ingress", "mode": "dynamic" }, "ingress_lossy_pool": { - "size": "{{ ingress_lossy_pool_size }}", "type": "ingress", "mode": "dynamic" }, @@ -29,7 +24,6 @@ "mode": "dynamic" }, "egress_lossy_pool": { - "size": "{{ egress_lossy_pool_size }}", "type": "egress", "mode": "dynamic" } @@ -38,7 +32,7 @@ "ingress_lossless_profile": { "pool":"[BUFFER_POOL|ingress_lossless_pool]", "size":"0", - "dynamic_th":"0" + "dynamic_th":"7" }, "ingress_lossy_profile": { "pool":"[BUFFER_POOL|ingress_lossy_pool]", @@ -52,8 +46,8 @@ }, "egress_lossy_profile": { "pool":"[BUFFER_POOL|egress_lossy_pool]", - "size":"4096", - "dynamic_th":"3" + "size":"9216", + "dynamic_th":"7" }, "q_lossy_profile": { "pool":"[BUFFER_POOL|egress_lossy_pool]", diff --git a/device/mellanox/x86_64-mlnx_msn3700-r0/ACS-MSN3700/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn3700-r0/ACS-MSN3700/buffers_defaults_t0.j2 index e26ad28b9f0e..0b0cbc71f30a 100644 --- a/device/mellanox/x86_64-mlnx_msn3700-r0/ACS-MSN3700/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn3700-r0/ACS-MSN3700/buffers_defaults_t0.j2 @@ -1,8 +1,5 @@ {% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '14983147' %} -{% set ingress_lossy_pool_size = '14983147' %} -{% set egress_lossless_pool_size = '34340822' %} -{% set egress_lossy_pool_size = '14983147' %} +{% set egress_lossless_pool_size = '34340832' %} {%- macro generate_port_lists(PORT_ALL) %} {# Generate list of ports #} @@ -14,12 +11,10 @@ {%- macro generate_buffer_pool_and_profiles() %} "BUFFER_POOL": { "ingress_lossless_pool": { - "size": "{{ ingress_lossless_pool_size }}", "type": "ingress", "mode": "dynamic" }, "ingress_lossy_pool": { - "size": "{{ ingress_lossy_pool_size }}", "type": "ingress", "mode": "dynamic" }, @@ -29,7 +24,6 @@ "mode": "dynamic" }, "egress_lossy_pool": { - "size": "{{ egress_lossy_pool_size }}", "type": "egress", "mode": "dynamic" } @@ -38,7 +32,7 @@ "ingress_lossless_profile": { "pool":"[BUFFER_POOL|ingress_lossless_pool]", "size":"0", - "dynamic_th":"0" + "dynamic_th":"7" }, "ingress_lossy_profile": { "pool":"[BUFFER_POOL|ingress_lossy_pool]", @@ -52,8 +46,8 @@ }, "egress_lossy_profile": { "pool":"[BUFFER_POOL|egress_lossy_pool]", - "size":"4096", - "dynamic_th":"3" + "size":"9216", + "dynamic_th":"7" }, "q_lossy_profile": { "pool":"[BUFFER_POOL|egress_lossy_pool]", diff --git a/device/mellanox/x86_64-mlnx_msn3700-r0/ACS-MSN3700/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn3700-r0/ACS-MSN3700/buffers_defaults_t1.j2 index b5e4ff8d1747..0b0cbc71f30a 100644 --- a/device/mellanox/x86_64-mlnx_msn3700-r0/ACS-MSN3700/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn3700-r0/ACS-MSN3700/buffers_defaults_t1.j2 @@ -1,8 +1,5 @@ {% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '9158635' %} -{% set ingress_lossy_pool_size = '9158635' %} -{% set egress_lossless_pool_size = '34340822' %} -{% set egress_lossy_pool_size = '9158635' %} +{% set egress_lossless_pool_size = '34340832' %} {%- macro generate_port_lists(PORT_ALL) %} {# Generate list of ports #} @@ -14,12 +11,10 @@ {%- macro generate_buffer_pool_and_profiles() %} "BUFFER_POOL": { "ingress_lossless_pool": { - "size": "{{ ingress_lossless_pool_size }}", "type": "ingress", "mode": "dynamic" }, "ingress_lossy_pool": { - "size": "{{ ingress_lossy_pool_size }}", "type": "ingress", "mode": "dynamic" }, @@ -29,7 +24,6 @@ "mode": "dynamic" }, "egress_lossy_pool": { - "size": "{{ egress_lossy_pool_size }}", "type": "egress", "mode": "dynamic" } @@ -38,7 +32,7 @@ "ingress_lossless_profile": { "pool":"[BUFFER_POOL|ingress_lossless_pool]", "size":"0", - "dynamic_th":"0" + "dynamic_th":"7" }, "ingress_lossy_profile": { "pool":"[BUFFER_POOL|ingress_lossy_pool]", @@ -52,8 +46,8 @@ }, "egress_lossy_profile": { "pool":"[BUFFER_POOL|egress_lossy_pool]", - "size":"4096", - "dynamic_th":"3" + "size":"9216", + "dynamic_th":"7" }, "q_lossy_profile": { "pool":"[BUFFER_POOL|egress_lossy_pool]", diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/buffers_defaults_t0.j2 index d69a0cc13835..0b0cbc71f30a 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/buffers_defaults_t0.j2 @@ -1,8 +1,5 @@ {% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '28196784' %} -{% set ingress_lossy_pool_size = '28196784' %} {% set egress_lossless_pool_size = '34340832' %} -{% set egress_lossy_pool_size = '28196784' %} {%- macro generate_port_lists(PORT_ALL) %} {# Generate list of ports #} @@ -14,12 +11,10 @@ {%- macro generate_buffer_pool_and_profiles() %} "BUFFER_POOL": { "ingress_lossless_pool": { - "size": "{{ ingress_lossless_pool_size }}", "type": "ingress", "mode": "dynamic" }, "ingress_lossy_pool": { - "size": "{{ ingress_lossy_pool_size }}", "type": "ingress", "mode": "dynamic" }, @@ -29,7 +24,6 @@ "mode": "dynamic" }, "egress_lossy_pool": { - "size": "{{ egress_lossy_pool_size }}", "type": "egress", "mode": "dynamic" } @@ -38,7 +32,7 @@ "ingress_lossless_profile": { "pool":"[BUFFER_POOL|ingress_lossless_pool]", "size":"0", - "dynamic_th":"0" + "dynamic_th":"7" }, "ingress_lossy_profile": { "pool":"[BUFFER_POOL|ingress_lossy_pool]", @@ -52,8 +46,8 @@ }, "egress_lossy_profile": { "pool":"[BUFFER_POOL|egress_lossy_pool]", - "size":"4096", - "dynamic_th":"3" + "size":"9216", + "dynamic_th":"7" }, "q_lossy_profile": { "pool":"[BUFFER_POOL|egress_lossy_pool]", diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/buffers_defaults_t1.j2 index 78d43455a424..0b0cbc71f30a 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/buffers_defaults_t1.j2 @@ -1,8 +1,5 @@ {% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '17891280' %} -{% set ingress_lossy_pool_size = '17891280' %} {% set egress_lossless_pool_size = '34340832' %} -{% set egress_lossy_pool_size = '17891280' %} {%- macro generate_port_lists(PORT_ALL) %} {# Generate list of ports #} @@ -14,12 +11,10 @@ {%- macro generate_buffer_pool_and_profiles() %} "BUFFER_POOL": { "ingress_lossless_pool": { - "size": "{{ ingress_lossless_pool_size }}", "type": "ingress", "mode": "dynamic" }, "ingress_lossy_pool": { - "size": "{{ ingress_lossy_pool_size }}", "type": "ingress", "mode": "dynamic" }, @@ -29,7 +24,6 @@ "mode": "dynamic" }, "egress_lossy_pool": { - "size": "{{ egress_lossy_pool_size }}", "type": "egress", "mode": "dynamic" } @@ -38,7 +32,7 @@ "ingress_lossless_profile": { "pool":"[BUFFER_POOL|ingress_lossless_pool]", "size":"0", - "dynamic_th":"0" + "dynamic_th":"7" }, "ingress_lossy_profile": { "pool":"[BUFFER_POOL|ingress_lossy_pool]", @@ -52,8 +46,8 @@ }, "egress_lossy_profile": { "pool":"[BUFFER_POOL|egress_lossy_pool]", - "size":"4096", - "dynamic_th":"3" + "size":"9216", + "dynamic_th":"7" }, "q_lossy_profile": { "pool":"[BUFFER_POOL|egress_lossy_pool]", diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/port_peripheral_config.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/port_peripheral_config.j2 new file mode 100644 index 000000000000..8d201517ed62 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/port_peripheral_config.j2 @@ -0,0 +1,10 @@ +[ +{%- include 'peripheral_table.j2' %} +, +{ + "PORT_PERIPHERAL_TABLE:global": { + "gearbox_model": "MELLANOX-GEARBOX-1" + }, + "OP": "SET" +} +] diff --git a/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/buffers_defaults_t0.j2 index b71e6b35fa2e..a02972dcc939 100644 --- a/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/buffers_defaults_t0.j2 @@ -1,8 +1,5 @@ {% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '56623104' %} -{% set ingress_lossy_pool_size = '56623104' %} {% set egress_lossless_pool_size = '60817392' %} -{% set egress_lossy_pool_size = '56623104' %} {%- macro generate_port_lists(PORT_ALL) %} {# Generate list of ports #} @@ -14,12 +11,10 @@ {%- macro generate_buffer_pool_and_profiles() %} "BUFFER_POOL": { "ingress_lossless_pool": { - "size": "{{ ingress_lossless_pool_size }}", "type": "ingress", "mode": "dynamic" }, "ingress_lossy_pool": { - "size": "{{ ingress_lossy_pool_size }}", "type": "ingress", "mode": "dynamic" }, @@ -29,7 +24,6 @@ "mode": "dynamic" }, "egress_lossy_pool": { - "size": "{{ egress_lossy_pool_size }}", "type": "egress", "mode": "dynamic" } @@ -38,7 +32,7 @@ "ingress_lossless_profile": { "pool":"[BUFFER_POOL|ingress_lossless_pool]", "size":"0", - "dynamic_th":"0" + "dynamic_th":"7" }, "ingress_lossy_profile": { "pool":"[BUFFER_POOL|ingress_lossy_pool]", @@ -52,8 +46,8 @@ }, "egress_lossy_profile": { "pool":"[BUFFER_POOL|egress_lossy_pool]", - "size":"4096", - "dynamic_th":"3" + "size":"9216", + "dynamic_th":"7" }, "q_lossy_profile": { "pool":"[BUFFER_POOL|egress_lossy_pool]", diff --git a/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/buffers_defaults_t1.j2 index 87e55d5a46e0..a02972dcc939 100644 --- a/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/buffers_defaults_t1.j2 @@ -1,8 +1,5 @@ {% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '36011952' %} -{% set ingress_lossy_pool_size = '36011952' %} {% set egress_lossless_pool_size = '60817392' %} -{% set egress_lossy_pool_size = '36011952' %} {%- macro generate_port_lists(PORT_ALL) %} {# Generate list of ports #} @@ -14,12 +11,10 @@ {%- macro generate_buffer_pool_and_profiles() %} "BUFFER_POOL": { "ingress_lossless_pool": { - "size": "{{ ingress_lossless_pool_size }}", "type": "ingress", "mode": "dynamic" }, "ingress_lossy_pool": { - "size": "{{ ingress_lossy_pool_size }}", "type": "ingress", "mode": "dynamic" }, @@ -29,7 +24,6 @@ "mode": "dynamic" }, "egress_lossy_pool": { - "size": "{{ egress_lossy_pool_size }}", "type": "egress", "mode": "dynamic" } @@ -38,7 +32,7 @@ "ingress_lossless_profile": { "pool":"[BUFFER_POOL|ingress_lossless_pool]", "size":"0", - "dynamic_th":"0" + "dynamic_th":"7" }, "ingress_lossy_profile": { "pool":"[BUFFER_POOL|ingress_lossy_pool]", @@ -52,8 +46,8 @@ }, "egress_lossy_profile": { "pool":"[BUFFER_POOL|egress_lossy_pool]", - "size":"4096", - "dynamic_th":"3" + "size":"9216", + "dynamic_th":"7" }, "q_lossy_profile": { "pool":"[BUFFER_POOL|egress_lossy_pool]", diff --git a/dockers/docker-orchagent/orchagent.sh b/dockers/docker-orchagent/orchagent.sh index 917205f3ebf2..ed1af12d9b0c 100755 --- a/dockers/docker-orchagent/orchagent.sh +++ b/dockers/docker-orchagent/orchagent.sh @@ -2,7 +2,7 @@ # Export platform information. Required to be able to write # vendor specific code. -export platform=`sonic-cfggen -y /etc/sonic/sonic_version.yml -v asic_type` +export platform=$ASIC_VENDOR MAC_ADDRESS=$(sonic-cfggen -d -v 'DEVICE_METADATA.localhost.mac') if [ "$MAC_ADDRESS" == "None" ] || [ -z "$MAC_ADDRESS" ]; then diff --git a/dockers/docker-orchagent/supervisord.conf b/dockers/docker-orchagent/supervisord.conf index 3cd192f24ce8..97c8e82e551a 100644 --- a/dockers/docker-orchagent/supervisord.conf +++ b/dockers/docker-orchagent/supervisord.conf @@ -26,6 +26,16 @@ stdout_logfile=syslog stderr_logfile=syslog dependent_startup=true +[program:buffermgrd] +command=/usr/bin/buffermgrd -l /usr/share/sonic/hwsku/pg_profile_lookup.ini -a /etc/sonic/asic_table.json -p /etc/sonic/peripheral_table.json +priority=2 +autostart=false +autorestart=false +stdout_logfile=syslog +stderr_logfile=syslog +dependent_startup=true +dependent_startup_wait_for=rsyslogd:running + [program:portsyncd] command=/usr/bin/portsyncd priority=3 @@ -110,16 +120,6 @@ stderr_logfile=syslog dependent_startup=true dependent_startup_wait_for=swssconfig:exited -[program:buffermgrd] -command=/usr/bin/buffermgrd -l /usr/share/sonic/hwsku/pg_profile_lookup.ini -priority=11 -autostart=false -autorestart=false -stdout_logfile=syslog -stderr_logfile=syslog -dependent_startup=true -dependent_startup_wait_for=swssconfig:exited - [program:vrfmgrd] command=/usr/bin/vrfmgrd priority=13 diff --git a/files/build_templates/asic_table.j2 b/files/build_templates/asic_table.j2 new file mode 100644 index 000000000000..4909841fd8b1 --- /dev/null +++ b/files/build_templates/asic_table.j2 @@ -0,0 +1,68 @@ +{%- if DEVICE_METADATA is defined and DEVICE_METADATA['localhost']['platform'] is defined %} +{%- set platform = DEVICE_METADATA['localhost']['platform'] %} +{%- else -%} +{%- set platform = "vs-platform" %} +{%- endif -%} + + +[ +{% set platform2asic = { + 'x86_64-mlnx_lssn2700-r0':'MELLANOX-SPECTRUM', + 'x86_64-mlnx_msn2010-r0':'MELLANOX-SPECTRUM', + 'x86_64-mlnx_msn2100-r0':'MELLANOX-SPECTRUM', + 'x86_64-mlnx_msn2410-r0':'MELLANOX-SPECTRUM', + 'x86_64-mlnx_msn2700-r0':'MELLANOX-SPECTRUM', + 'x86_64-mlnx_msn2700_simx-r0':'MELLANOX-SPECTRUM', + 'x86_64-mlnx_msn2740-r0':'MELLANOX-SPECTRUM', + 'x86_64-mlnx_msn3700c-r0':'MELLANOX-SPECTRUM-2', + 'x86_64-mlnx_msn3700-r0':'MELLANOX-SPECTRUM-2', + 'x86_64-mlnx_msn3700_simx-r0':'MELLANOX-SPECTRUM-2', + 'x86_64-mlnx_msn3800-r0':'MELLANOX-SPECTRUM-2', + 'x86_64-mlnx_msn4700_simx-r0':'MELLANOX-SPECTRUM-3', + 'x86_64-mlnx_msn4700-r0':'MELLANOX-SPECTRUM-3', + 'vs-platform':'vs' + } +%} +{% set asic_type = platform2asic[platform] %} +{% if asic_type == 'MELLANOX-SPECTRUM' %} + { + "ASIC_TABLE:MELLANOX-SPECTRUM": { + "cell_size": "96", + "pipeline_latency": "18", + "mac_phy_delay": "0.8", + "peer_response_time": "3.8" + }, + "OP": "SET" + } +{% elif asic_type == 'MELLANOX-SPECTRUM-2' %} + { + "ASIC_TABLE:MELLANOX-SPECTRUM-2": { + "cell_size": "144", + "pipeline_latency": "18", + "mac_phy_delay": "0.8", + "peer_response_time": "3.8" + }, + "OP": "SET" + } +{% elif asic_type == 'MELLANOX-SPECTRUM-3' %} + { + "ASIC_TABLE:MELLANOX-SPECTRUM-3": { + "cell_size": "144", + "pipeline_latency": "18", + "mac_phy_delay": "0.8", + "peer_response_time": "3.8" + }, + "OP": "SET" + } +{% elif asic_type == "vs" %} + { + "ASIC_TABLE:VS-ASIC": { + "cell_size": "128", + "pipeline_latency": "18", + "mac_phy_delay": "0.8", + "peer_response_time": "3.8" + }, + "OP": "SET" + } +{% endif %} +] diff --git a/files/build_templates/buffers_config.j2 b/files/build_templates/buffers_config.j2 index ba4dcf49e813..a82ae7c7d3bb 100644 --- a/files/build_templates/buffers_config.j2 +++ b/files/build_templates/buffers_config.j2 @@ -134,6 +134,9 @@ def {% for port in PORT_ACTIVE %} "{{ port }}|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" + }, + "{{ port }}|3-4": { + "NULL" : "NULL" }{% if not loop.last %},{% endif %} {% endfor %} @@ -162,4 +165,16 @@ def {% endfor %} } {% endif %} +, + "DEFAULT_LOSSLESS_BUFFER_PARAMETER": { + "AZURE": { + "default_dynamic_th": "0" + } + }, + "LOSSLESS_TRAFFIC_PATTERN": { + "AZURE": { + "mtu": "1500", + "small_packet_percentage": "100" + } + } } diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index 381480123f67..ff6a65f6be61 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -65,6 +65,13 @@ function preStartAction() fi {%- elif docker_container_name == "snmp" %} $SONIC_DB_CLI STATE_DB HSET 'DEVICE_METADATA|localhost' chassis_serial_number $(decode-syseeprom -s) +{%- elif docker_container_name == "swss" %} + if [ ! -f /etc/sonic/asic_table.json ] && [ -f /usr/share/sonic/templates/asic_table.j2 ]; then + sonic-cfggen -d -t /usr/share/sonic/templates/asic_table.j2 > /etc/sonic/asic_table.json + fi + if [ ! -f /etc/sonic/peripheral_table.json ] && [ -f /usr/share/sonic/device/$PLATFORM/port_peripheral_config.j2 ]; then + sonic-cfggen -d -t /usr/share/sonic/device/$PLATFORM/port_peripheral_config.j2 > /etc/sonic/peripheral_table.json + fi {%- else %} : # nothing {%- endif %} @@ -197,6 +204,11 @@ start() { echo "Creating new {{docker_container_name}}$DEV container with HWSKU $HWSKU" {%- endif %} + {%- if docker_container_name == "swss" %} + # Obtain the vendor name + ASIC_VENDOR=`$SONIC_CFGGEN -y /etc/sonic/sonic_version.yml -v asic_type` + {%- endif %} + # In Multi ASIC platforms the global database config file database_global.json will exist. # Parse the file and get the include path for the database_config.json files used in # various namesapces. The database_config paths are relative to the DIR of SONIC_DB_GLOBAL_JSON. @@ -282,6 +294,9 @@ start() { --tmpfs /tmp \ {%- endif %} {%- endif %} +{%- if docker_container_name == "swss" %} + -e ASIC_VENDOR=$ASIC_VENDOR \ +{%- endif -%} {%- if docker_container_name == "bgp" %} -v /etc/sonic/frr/$DEV:/etc/frr:rw \ {%- endif %} diff --git a/files/build_templates/peripheral_table.j2 b/files/build_templates/peripheral_table.j2 new file mode 100644 index 000000000000..70e664559bee --- /dev/null +++ b/files/build_templates/peripheral_table.j2 @@ -0,0 +1,28 @@ +{%- if DEVICE_METADATA is defined and DEVICE_METADATA['localhost']['platform'] is defined %} +{%- set platform = DEVICE_METADATA['localhost']['platform'] %} +{%- else -%} +{%- set platform = "vs-platform" %} +{%- endif -%} + +{% set platform2gearbox = { + 'x86_64-mlnx_msn3800-r0':'MELLANOX-GEARBOX-1', + 'vs-platform':'VS-GEARBOX' + } +%} +{% set gearbox_type = platform2gearbox[platform] %} +{% if gearbox_type == 'MELLANOX-GEARBOX-1' %} +{ + "PERIPHERAL_TABLE:MELLANOX-GEARBOX-1": { + "gearbox_delay": "400" + }, + "OP": "SET" +} +{% elif gearbox_type == 'VS-GEARBOX' %} +{ + "PERIPHERAL_TABLE:VS-GEARBOX": { + "gearbox_delay": "400" + }, + "OP": "SET" +} +{% endif %} + diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index 925998f0aef9..13fac1e30488 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -302,6 +302,17 @@ sudo cp $BUILD_TEMPLATES/buffers_config.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMP # Copy the qos configuration template sudo cp $BUILD_TEMPLATES/qos_config.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/ +# Copy the templates for dynamically buffer calculation +if [ -f $BUILD_TEMPLATES/asic_table.j2 ] +then + sudo cp $BUILD_TEMPLATES/asic_table.j2 $FILESYSTEM_ROOT/usr/share/sonic/templates/asic_table.j2 +fi + +if [ -f $BUILD_TEMPLATES/peripheral_table.j2 ] +then + sudo cp $BUILD_TEMPLATES/peripheral_table.j2 $FILESYSTEM_ROOT/usr/share/sonic/templates/peripheral_table.j2 +fi + # Copy hostname configuration scripts sudo cp $IMAGE_CONFIGS/hostname/hostname-config.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM echo "hostname-config.service" | sudo tee -a $GENERATED_SERVICE_FILE diff --git a/files/scripts/swss.sh b/files/scripts/swss.sh index 74828c740fe1..29ba96438324 100755 --- a/files/scripts/swss.sh +++ b/files/scripts/swss.sh @@ -138,7 +138,7 @@ start() { $SONIC_DB_CLI ASIC_DB FLUSHDB $SONIC_DB_CLI COUNTERS_DB FLUSHDB $SONIC_DB_CLI FLEX_COUNTER_DB FLUSHDB - clean_up_tables STATE_DB "'PORT_TABLE*', 'MGMT_PORT_TABLE*', 'VLAN_TABLE*', 'VLAN_MEMBER_TABLE*', 'LAG_TABLE*', 'LAG_MEMBER_TABLE*', 'INTERFACE_TABLE*', 'MIRROR_SESSION*', 'VRF_TABLE*', 'FDB_TABLE*'" + clean_up_tables STATE_DB "'PORT_TABLE*', 'MGMT_PORT_TABLE*', 'VLAN_TABLE*', 'VLAN_MEMBER_TABLE*', 'LAG_TABLE*', 'LAG_MEMBER_TABLE*', 'INTERFACE_TABLE*', 'MIRROR_SESSION*', 'VRF_TABLE*', 'FDB_TABLE*', 'BUFFER_POOL*', 'BUFFER_PROFILE*'" fi # start service docker diff --git a/src/sonic-config-engine/tests/sample_output/buffers-dell6100.json b/src/sonic-config-engine/tests/sample_output/buffers-dell6100.json index 5cf0472f3f11..00ebeabc2d5d 100644 --- a/src/sonic-config-engine/tests/sample_output/buffers-dell6100.json +++ b/src/sonic-config-engine/tests/sample_output/buffers-dell6100.json @@ -108,134 +108,266 @@ "Ethernet0|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet0|3-4": { + "NULL" : "NULL" + }, "Ethernet1|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet1|3-4": { + "NULL" : "NULL" + }, "Ethernet4|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet4|3-4": { + "NULL" : "NULL" + }, "Ethernet5|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet5|3-4": { + "NULL" : "NULL" + }, "Ethernet6|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet6|3-4": { + "NULL" : "NULL" + }, "Ethernet7|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet7|3-4": { + "NULL" : "NULL" + }, "Ethernet8|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet8|3-4": { + "NULL" : "NULL" + }, "Ethernet9|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet9|3-4": { + "NULL" : "NULL" + }, "Ethernet10|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet10|3-4": { + "NULL" : "NULL" + }, "Ethernet11|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet11|3-4": { + "NULL" : "NULL" + }, "Ethernet12|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet12|3-4": { + "NULL" : "NULL" + }, "Ethernet13|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet13|3-4": { + "NULL" : "NULL" + }, "Ethernet14|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet14|3-4": { + "NULL" : "NULL" + }, "Ethernet15|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet15|3-4": { + "NULL" : "NULL" + }, "Ethernet16|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet16|3-4": { + "NULL" : "NULL" + }, "Ethernet17|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet17|3-4": { + "NULL" : "NULL" + }, "Ethernet20|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet20|3-4": { + "NULL" : "NULL" + }, "Ethernet21|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet21|3-4": { + "NULL" : "NULL" + }, "Ethernet22|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet22|3-4": { + "NULL" : "NULL" + }, "Ethernet23|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet23|3-4": { + "NULL" : "NULL" + }, "Ethernet24|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet24|3-4": { + "NULL" : "NULL" + }, "Ethernet25|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet25|3-4": { + "NULL" : "NULL" + }, "Ethernet26|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet26|3-4": { + "NULL" : "NULL" + }, "Ethernet27|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet27|3-4": { + "NULL" : "NULL" + }, "Ethernet28|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet28|3-4": { + "NULL" : "NULL" + }, "Ethernet29|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet29|3-4": { + "NULL" : "NULL" + }, "Ethernet30|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet30|3-4": { + "NULL" : "NULL" + }, "Ethernet31|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet31|3-4": { + "NULL" : "NULL" + }, "Ethernet32|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet32|3-4": { + "NULL" : "NULL" + }, "Ethernet36|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet36|3-4": { + "NULL" : "NULL" + }, "Ethernet37|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet37|3-4": { + "NULL" : "NULL" + }, "Ethernet38|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet38|3-4": { + "NULL" : "NULL" + }, "Ethernet39|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet39|3-4": { + "NULL" : "NULL" + }, "Ethernet40|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet40|3-4": { + "NULL" : "NULL" + }, "Ethernet41|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet41|3-4": { + "NULL" : "NULL" + }, "Ethernet42|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet42|3-4": { + "NULL" : "NULL" + }, "Ethernet48|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet48|3-4": { + "NULL" : "NULL" + }, "Ethernet52|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet52|3-4": { + "NULL" : "NULL" + }, "Ethernet53|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet53|3-4": { + "NULL" : "NULL" + }, "Ethernet54|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet54|3-4": { + "NULL" : "NULL" + }, "Ethernet55|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet55|3-4": { + "NULL" : "NULL" + }, "Ethernet56|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet56|3-4": { + "NULL" : "NULL" + }, "Ethernet57|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" }, + "Ethernet57|3-4": { + "NULL" : "NULL" + }, "Ethernet58|0": { "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" + }, + "Ethernet58|3-4": { + "NULL" : "NULL" } }, @@ -637,4 +769,16 @@ "profile" : "[BUFFER_PROFILE|egress_lossy_profile]" } } +, + "DEFAULT_LOSSLESS_BUFFER_PARAMETER": { + "AZURE": { + "default_dynamic_th": "0" + } + }, + "LOSSLESS_TRAFFIC_PATTERN": { + "AZURE": { + "mtu": "1500", + "small_packet_percentage": "100" + } + } }