diff --git a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-C64/buffers_defaults_t0.j2 b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-C64/buffers_defaults_t0.j2 index 625ca0ab11..bee86a9b3a 100644 --- a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-C64/buffers_defaults_t0.j2 +++ b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-C64/buffers_defaults_t0.j2 @@ -7,16 +7,20 @@ {%- endfor %} {%- endmacro %} +{%- import 'buffers_pool_sizes_t0.j2' as defs with context %} +{%- set ingress_lossless_pool_size = defs.ingress_lossless_pool_size %} +{%- set egress_lossy_pool_size = defs.egress_lossy_pool_size %} + {%- macro generate_buffer_pool_and_profiles() %} "BUFFER_POOL": { "ingress_lossless_pool": { - "size": "33329088", + "size": "{{ ingress_lossless_pool_size }}", "type": "ingress", "mode": "dynamic", "xoff": "7827456" }, "egress_lossy_pool": { - "size": "26663272", + "size": "{{ egress_lossy_pool_size }}", "type": "egress", "mode": "dynamic" }, @@ -49,4 +53,4 @@ {%- macro generate_queue_buffers_with_extra_lossless_queues(port_names, port_names_require_extra_buffer) %} {{ defs.generate_queue_buffers_with_extra_lossless_queues(port_names, port_names_require_extra_buffer) }} -{%- endmacro %} \ No newline at end of file +{%- endmacro %} diff --git a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-C64/buffers_defaults_t1.j2 b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-C64/buffers_defaults_t1.j2 index 68af36a275..c5d390668a 100644 --- a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-C64/buffers_defaults_t1.j2 +++ b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-C64/buffers_defaults_t1.j2 @@ -7,11 +7,15 @@ {%- endfor %} {%- endmacro %} +{%- import 'buffers_pool_sizes_t1.j2' as defs with context %} +{%- set ingress_lossless_pool_size = defs.ingress_lossless_pool_size %} +{%- set egress_lossy_pool_size = defs.egress_lossy_pool_size %} + {%- macro generate_buffer_pool_and_profiles() %} "BUFFER_POOL": { "ingress_lossless_pool": { {# SS Tab2 Row 71 #} - "size": "33582016", + "size": "{{ ingress_lossless_pool_size }}", "type": "ingress", "mode": "dynamic", {# SS Tab2 Row 68 #} @@ -19,7 +23,7 @@ }, "egress_lossy_pool": { {# SS Tab2 Row 60 #} - "size": "26866112", + "size": "{{ egress_lossy_pool_size }}", "type": "egress", "mode": "dynamic" }, diff --git a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-C64/buffers_pool_sizes_t0.j2 b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-C64/buffers_pool_sizes_t0.j2 new file mode 100644 index 0000000000..bd82c947e4 --- /dev/null +++ b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-C64/buffers_pool_sizes_t0.j2 @@ -0,0 +1,8 @@ +{%- set ingress_lossless_pool_size = '33329088' %} +{%- set egress_lossy_pool_size = '26663272' %} + +{%- if ((SYSTEM_DEFAULTS is defined) and ('tunnel_qos_remap' in SYSTEM_DEFAULTS) and (SYSTEM_DEFAULTS['tunnel_qos_remap']['status'] == 'enabled')) and +((DEVICE_METADATA is defined) and ('localhost' in DEVICE_METADATA) and ('subtype' in DEVICE_METADATA['localhost']) and (DEVICE_METADATA['localhost']['subtype'] == 'DualToR')) %} + {%- set ingress_lossless_pool_size = '33169344' %} + {%- set egress_lossy_pool_size = '26535808' %} +{%- endif %} diff --git a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-C64/buffers_pool_sizes_t1.j2 b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-C64/buffers_pool_sizes_t1.j2 new file mode 100644 index 0000000000..43b31de8ad --- /dev/null +++ b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-C64/buffers_pool_sizes_t1.j2 @@ -0,0 +1,8 @@ +{%- set ingress_lossless_pool_size = '33582016' %} +{%- set egress_lossy_pool_size = '26866112' %} + +{%- if ((SYSTEM_DEFAULTS is defined) and ('tunnel_qos_remap' in SYSTEM_DEFAULTS) and (SYSTEM_DEFAULTS['tunnel_qos_remap']['status'] == 'enabled')) and +((DEVICE_METADATA is defined) and ('localhost' in DEVICE_METADATA) and ('type' in DEVICE_METADATA['localhost']) and (DEVICE_METADATA['localhost']['type'] == 'LeafRouter')) %} + {%- set ingress_lossless_pool_size = '33262528' %} + {%- set egress_lossy_pool_size = '26610688' %} +{%- endif %} diff --git a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C8/buffers_defaults_t0.j2 b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C8/buffers_defaults_t0.j2 index 10b9d70d24..5ac1d2d2ae 100644 --- a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C8/buffers_defaults_t0.j2 +++ b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C8/buffers_defaults_t0.j2 @@ -15,16 +15,20 @@ {%- endfor %} {%- endmacro %} +{%- import 'buffers_pool_sizes_t0.j2' as defs with context %} +{%- set ingress_lossless_pool_size = defs.ingress_lossless_pool_size %} +{%- set egress_lossy_pool_size = defs.egress_lossy_pool_size %} + {%- macro generate_buffer_pool_and_profiles() %} "BUFFER_POOL": { "ingress_lossless_pool": { - "size": "33329088", + "size": "{{ ingress_lossless_pool_size }}", "type": "ingress", "mode": "dynamic", "xoff": "7827456" }, "egress_lossy_pool": { - "size": "26663272", + "size": "{{ egress_lossy_pool_size }}", "type": "egress", "mode": "dynamic" }, diff --git a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C8/buffers_pool_sizes_t0.j2 b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C8/buffers_pool_sizes_t0.j2 new file mode 120000 index 0000000000..72e16a6082 --- /dev/null +++ b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C8/buffers_pool_sizes_t0.j2 @@ -0,0 +1 @@ +../Arista-7260CX3-C64/buffers_pool_sizes_t0.j2 \ No newline at end of file diff --git a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-Q64/buffers_defaults_t0.j2 b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-Q64/buffers_defaults_t0.j2 index 01b5a1dd8b..bee86a9b3a 100644 --- a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-Q64/buffers_defaults_t0.j2 +++ b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-Q64/buffers_defaults_t0.j2 @@ -7,16 +7,20 @@ {%- endfor %} {%- endmacro %} +{%- import 'buffers_pool_sizes_t0.j2' as defs with context %} +{%- set ingress_lossless_pool_size = defs.ingress_lossless_pool_size %} +{%- set egress_lossy_pool_size = defs.egress_lossy_pool_size %} + {%- macro generate_buffer_pool_and_profiles() %} "BUFFER_POOL": { "ingress_lossless_pool": { - "size": "33329088", + "size": "{{ ingress_lossless_pool_size }}", "type": "ingress", "mode": "dynamic", "xoff": "7827456" }, "egress_lossy_pool": { - "size": "26663272", + "size": "{{ egress_lossy_pool_size }}", "type": "egress", "mode": "dynamic" }, diff --git a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-Q64/buffers_defaults_t1.j2 b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-Q64/buffers_defaults_t1.j2 index 1d8fbb3e85..f531b5e208 100644 --- a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-Q64/buffers_defaults_t1.j2 +++ b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-Q64/buffers_defaults_t1.j2 @@ -7,16 +7,20 @@ {%- endfor %} {%- endmacro %} +{%- import 'buffers_pool_sizes_t0.j2' as defs with context %} +{%- set ingress_lossless_pool_size = defs.ingress_lossless_pool_size %} +{%- set egress_lossy_pool_size = defs.egress_lossy_pool_size %} + {%- macro generate_buffer_pool_and_profiles() %} "BUFFER_POOL": { "ingress_lossless_pool": { - "size": "33329088", + "size": "{{ ingress_lossless_pool_size }}", "type": "ingress", "mode": "dynamic", "xoff": "7827456" }, "egress_lossy_pool": { - "size": "26663272", + "size": "{{ egress_lossy_pool_size }}", "type": "egress", "mode": "dynamic" }, diff --git a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-Q64/buffers_pool_sizes_t0.j2 b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-Q64/buffers_pool_sizes_t0.j2 new file mode 120000 index 0000000000..72e16a6082 --- /dev/null +++ b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-Q64/buffers_pool_sizes_t0.j2 @@ -0,0 +1 @@ +../Arista-7260CX3-C64/buffers_pool_sizes_t0.j2 \ No newline at end of file diff --git a/src/sonic-config-engine/tests/sample_output/py3/buffer-arista7260-dualtor.json b/src/sonic-config-engine/tests/sample_output/py3/buffer-arista7260-dualtor.json index 32fbfe2437..6b1f4c433f 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/buffer-arista7260-dualtor.json +++ b/src/sonic-config-engine/tests/sample_output/py3/buffer-arista7260-dualtor.json @@ -128,13 +128,13 @@ "BUFFER_POOL": { "ingress_lossless_pool": { - "size": "33329088", + "size": "33169344", "type": "ingress", "mode": "dynamic", "xoff": "7827456" }, "egress_lossy_pool": { - "size": "26663272", + "size": "26535808", "type": "egress", "mode": "dynamic" }, diff --git a/src/sonic-config-engine/tests/sample_output/py3/buffer-arista7260-t1.json b/src/sonic-config-engine/tests/sample_output/py3/buffer-arista7260-t1.json index 2491d376c7..702076249a 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/buffer-arista7260-t1.json +++ b/src/sonic-config-engine/tests/sample_output/py3/buffer-arista7260-t1.json @@ -72,18 +72,18 @@ "BUFFER_POOL": { "ingress_lossless_pool": { - "size": "33582016", + "size": "33262528", "type": "ingress", "mode": "dynamic", - "xoff": "8965632" + "xoff": "8965632" }, "egress_lossy_pool": { - "size": "26866112", + "size": "26610688", "type": "egress", "mode": "dynamic" }, "egress_lossless_pool": { - "size": "43481152", + "size": "43481152", "type": "egress", "mode": "static" } @@ -92,12 +92,12 @@ "ingress_lossy_profile": { "pool":"ingress_lossless_pool", "size":"0", - "static_th":"44302336" + "static_th":"44302336" }, "egress_lossless_profile": { "pool":"egress_lossless_pool", "size":"0", - "static_th":"43481152" + "static_th":"43481152" }, "egress_lossy_profile": { "pool":"egress_lossy_pool", diff --git a/src/sonic-config-engine/tests/test_j2files.py b/src/sonic-config-engine/tests/test_j2files.py index ba39e15450..f728277a3a 100644 --- a/src/sonic-config-engine/tests/test_j2files.py +++ b/src/sonic-config-engine/tests/test_j2files.py @@ -42,6 +42,31 @@ class TestJ2Files(TestCase): def run_diff(self, file1, file2): return subprocess.check_output('diff -u {} {} || true'.format(file1, file2), shell=True) + def create_machine_conf(self, platform, vendor): + file_exist = True + dir_exist = True + mode = {'arista': 'aboot', + 'dell': 'onie', + 'mellanox': 'onie' + } + echo_cmd = "echo '{}_platform={}' | sudo tee -a /host/machine.conf > /dev/null".format(mode[vendor], platform) + if not os.path.exists('/host/machine.conf'): + file_exist = False + if not os.path.isdir('/host'): + dir_exist = False + os.system('sudo mkdir /host') + os.system('sudo touch /host/machine.conf') + os.system(echo_cmd) + + return file_exist, dir_exist + + def remove_machine_conf(self, file_exist, dir_exist): + if not file_exist: + os.system('sudo rm -f /host/machine.conf') + + if not dir_exist: + os.system('sudo rmdir /host') + def test_interfaces(self): interfaces_template = os.path.join(self.test_dir, '..', '..', '..', 'files', 'image_config', 'interfaces', 'interfaces.j2') argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -a \'{\"hwaddr\":\"e4:1d:2d:a5:f3:ad\"}\' -t ' + interfaces_template + ' > ' + self.output_file @@ -364,6 +389,7 @@ class TestJ2Files(TestCase): os.remove(config_test_output) def _test_buffers_render_template(self, vendor, platform, sku, minigraph, buffer_template, expected): + file_exist, dir_exist = self.create_machine_conf(platform, vendor) dir_path = os.path.join(self.test_dir, '..', '..', '..', 'device', vendor, platform, sku) buffers_file = os.path.join(dir_path, buffer_template) port_config_ini_file = os.path.join(dir_path, 'port_config.ini') @@ -379,6 +405,7 @@ class TestJ2Files(TestCase): # cleanup buffers_config_file_new = os.path.join(dir_path, 'buffers_config.j2') os.remove(buffers_config_file_new) + self.remove_machine_conf(file_exist, dir_exist) sample_output_file = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, expected) assert utils.cmp(sample_output_file, self.output_file), self.run_diff(sample_output_file, self.output_file) @@ -409,7 +436,7 @@ class TestJ2Files(TestCase): ('arista', 'x86_64-arista_7260cx3_64', 'Arista-7260CX3-C64', 'sample-arista-7260-t1-minigraph.xml', 'buffers.json.j2', 'buffer-arista7260-t1.json'), ('arista', 'x86_64-arista_7260cx3_64', 'Arista-7260CX3-C64', 'sample-arista-7260-t1-minigraph-remap-disabled.xml', 'buffers.json.j2', 'buffer-arista7260-t1-remap-disabled.json') ] - + for test_data in TEST_DATA: self._test_buffers_render_template(vendor=test_data[0], platform=test_data[1],