From 6daf22ce9c15c33bdc6a6a5ed646203807060dbb Mon Sep 17 00:00:00 2001 From: Jaganathan Palanisamy Date: Wed, 13 Dec 2017 04:42:44 -0500 Subject: [PATCH] OvsDpdkSocketMemory MTU Roundup in bytes This change is to update OvsDpdkSocketMemory computation in DPDK derive parameters for MTU Round off to the bytes and buffer value is 512MB instead of 500MB. Change-Id: Ib8970986b9ea66bb3c4b9b6824fbd733cba9c2bf Closes-Bug: #1737709 --- tripleo_common/actions/derive_params.py | 12 ++++++++++-- .../tests/actions/test_derive_params.py | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/tripleo_common/actions/derive_params.py b/tripleo_common/actions/derive_params.py index 0cf38520a..562ef7b88 100644 --- a/tripleo_common/actions/derive_params.py +++ b/tripleo_common/actions/derive_params.py @@ -14,6 +14,7 @@ # under the License. import logging +import math import re from mistral_lib import actions @@ -293,6 +294,12 @@ class GetDpdkSocketMemoryAction(base.TripleOAction): self.packet_size_in_buffer = packet_size_in_buffer self.minimum_socket_memory = minimum_socket_memory + # Computes round off MTU value in bytes + # example: MTU value 9000 into 9216 bytes + def roundup_mtu_bytes(self, mtu): + max_div_val = int(math.ceil(float(mtu) / float(1024))) + return (max_div_val * 1024) + # Calculates socket memory for a NUMA node def calculate_node_socket_memory( self, numa_node, dpdk_nics_numa_info, overhead, @@ -305,7 +312,8 @@ class GetDpdkSocketMemoryAction(base.TripleOAction): if (numa_node == nics_info['numa_node'] and not nics_info['mtu'] in distinct_mtu_per_node): distinct_mtu_per_node.append(nics_info['mtu']) - socket_memory += (((nics_info['mtu'] + overhead) + roundup_mtu = self.roundup_mtu_bytes(nics_info['mtu']) + socket_memory += (((roundup_mtu + overhead) * packet_size_in_buffer) / (1024 * 1024)) @@ -314,7 +322,7 @@ class GetDpdkSocketMemoryAction(base.TripleOAction): socket_memory = minimum_socket_memory # For DPDK numa node else: - socket_memory += 500 + socket_memory += 512 socket_memory_in_gb = int(socket_memory / 1024) if socket_memory % 1024 > 0: diff --git a/tripleo_common/tests/actions/test_derive_params.py b/tripleo_common/tests/actions/test_derive_params.py index d57dda267..acc3c23d8 100644 --- a/tripleo_common/tests/actions/test_derive_params.py +++ b/tripleo_common/tests/actions/test_derive_params.py @@ -423,6 +423,21 @@ class GetDpdkSocketMemoryActionTest(base.TestCase): result = action.run(mock_ctx) self.assertEqual(result, expected_result) + def test_run_valid_roundup_mtu(self): + dpdk_nics_numa_info = [{"name": "ens802f1", "numa_node": 1, + "mtu": 1200}] + numa_nodes = [0, 1] + overhead = 800 + packet_size_in_buffer = (4096 * 64) + + expected_result = "1024,2048" + mock_ctx = mock.MagicMock() + action = derive_params.GetDpdkSocketMemoryAction( + dpdk_nics_numa_info, numa_nodes, overhead, + packet_size_in_buffer) + result = action.run(mock_ctx) + self.assertEqual(result, expected_result) + class ConvertNumberToRangeListActionTest(base.TestCase):