Merge "OvsDpdkSocketMemory MTU Roundup in bytes"

This commit is contained in:
Zuul 2018-01-16 15:34:55 +00:00 committed by Gerrit Code Review
commit a18f3ae063
2 changed files with 25 additions and 2 deletions

View File

@ -14,6 +14,7 @@
# under the License. # under the License.
import logging import logging
import math
import re import re
from mistral_lib import actions from mistral_lib import actions
@ -293,6 +294,12 @@ class GetDpdkSocketMemoryAction(base.TripleOAction):
self.packet_size_in_buffer = packet_size_in_buffer self.packet_size_in_buffer = packet_size_in_buffer
self.minimum_socket_memory = minimum_socket_memory 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 # Calculates socket memory for a NUMA node
def calculate_node_socket_memory( def calculate_node_socket_memory(
self, numa_node, dpdk_nics_numa_info, overhead, self, numa_node, dpdk_nics_numa_info, overhead,
@ -305,7 +312,8 @@ class GetDpdkSocketMemoryAction(base.TripleOAction):
if (numa_node == nics_info['numa_node'] and if (numa_node == nics_info['numa_node'] and
not nics_info['mtu'] in distinct_mtu_per_node): not nics_info['mtu'] in distinct_mtu_per_node):
distinct_mtu_per_node.append(nics_info['mtu']) 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) / * packet_size_in_buffer) /
(1024 * 1024)) (1024 * 1024))
@ -314,7 +322,7 @@ class GetDpdkSocketMemoryAction(base.TripleOAction):
socket_memory = minimum_socket_memory socket_memory = minimum_socket_memory
# For DPDK numa node # For DPDK numa node
else: else:
socket_memory += 500 socket_memory += 512
socket_memory_in_gb = int(socket_memory / 1024) socket_memory_in_gb = int(socket_memory / 1024)
if socket_memory % 1024 > 0: if socket_memory % 1024 > 0:

View File

@ -423,6 +423,21 @@ class GetDpdkSocketMemoryActionTest(base.TestCase):
result = action.run(mock_ctx) result = action.run(mock_ctx)
self.assertEqual(result, expected_result) 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): class ConvertNumberToRangeListActionTest(base.TestCase):