Make OvS max_idle & queues configuration optional 79/64679/2
authorMytnyk, Volodymyr <volodymyrx.mytnyk@intel.com>
Fri, 12 Oct 2018 16:53:17 +0000 (17:53 +0100)
committerAbhijit Sinha <abhijit.sinha@intel.com>
Wed, 7 Nov 2018 16:10:12 +0000 (16:10 +0000)
Remove hardcoded rx queue value

JIRA: YARDSTICK-1493

Change-Id: Ia4944db21d94399c724bcabf4e0eae809518e7e9
Signed-off-by: Mytnyk, Volodymyr <volodymyrx.mytnyk@intel.com>
(cherry picked from commit 68c127e17028e9961abcbd1c9a72fe2b878c427b)

yardstick/benchmark/contexts/standalone/model.py
yardstick/benchmark/contexts/standalone/ovs_dpdk.py
yardstick/tests/unit/benchmark/contexts/standalone/test_model.py
yardstick/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py

index 1004c62..2921a37 100644 (file)
@@ -161,7 +161,8 @@ class Libvirt(object):
         return vm_pci
 
     @classmethod
-    def add_ovs_interface(cls, vpath, port_num, vpci, vports_mac, xml_str):
+    def add_ovs_interface(cls, vpath, port_num, vpci, vports_mac, xml_str,
+                          queues):
         """Add a DPDK OVS 'interface' XML node in 'devices' node
 
         <devices>
@@ -203,7 +204,7 @@ class Libvirt(object):
         model.set('type', 'virtio')
 
         driver = ET.SubElement(interface, 'driver')
-        driver.set('queues', '4')
+        driver.set('queues', str(queues))
 
         host = ET.SubElement(driver, 'host')
         host.set('mrg_rxbuf', 'off')
index a1af3c7..c2707fd 100644 (file)
@@ -143,6 +143,10 @@ class OvsDpdkContext(base.Context):
         if lcore_mask:
             lcore_mask = ovs_other_config.format("--no-wait ", "dpdk-lcore-mask='%s'" % lcore_mask)
 
+        max_idle = self.ovs_properties.get("max_idle", '')
+        if max_idle:
+            max_idle = ovs_other_config.format("", "max-idle=%s" % max_idle)
+
         cmd_list = [
             "mkdir -p /usr/local/var/run/openvswitch",
             "mkdir -p {}".format(os.path.dirname(log_path)),
@@ -153,6 +157,7 @@ class OvsDpdkContext(base.Context):
             lcore_mask,
             detach_cmd.format(vpath, ovs_sock_path, log_path),
             ovs_other_config.format("", "pmd-cpu-mask=%s" % pmd_mask),
+            max_idle,
         ]
 
         for cmd in cmd_list:
@@ -176,8 +181,10 @@ class OvsDpdkContext(base.Context):
             'ovs-vsctl add-br {0} -- set bridge {0} datapath_type=netdev'.
             format(MAIN_BRIDGE)
         ]
-        dpdk_rxq = " options:n_rxq={queue}".format(
-            queue=self.ovs_properties.get("queues", 1))
+        dpdk_rxq = ""
+        queues = self.ovs_properties.get("queues")
+        if queues:
+            dpdk_rxq = " options:n_rxq={queue}".format(queue=queues)
 
         ordered_network = collections.OrderedDict(self.networks)
         for index, vnf in enumerate(ordered_network.values()):
@@ -375,6 +382,7 @@ class OvsDpdkContext(base.Context):
 
     def _enable_interfaces(self, index, vfs, xml_str):
         vpath = self.ovs_properties.get("vpath", "/usr/local")
+        queue = self.ovs_properties.get("queues", 1)
         vf = self.networks[vfs[0]]
         port_num = vf.get('port_num', 0)
         vpci = utils.PciAddress(vf['vpci'].strip())
@@ -383,7 +391,7 @@ class OvsDpdkContext(base.Context):
         vf['vpci'] = \
             "{}:{}:{:02x}.{}".format(vpci.domain, vpci.bus, slot, vpci.function)
         return model.Libvirt.add_ovs_interface(
-            vpath, port_num, vf['vpci'], vf['mac'], xml_str)
+            vpath, port_num, vf['vpci'], vf['mac'], xml_str, queue)
 
     def setup_ovs_dpdk_context(self):
         nodes = []
index 98d2b18..d87ebe0 100644 (file)
@@ -123,7 +123,7 @@ class ModelLibvirtTestCase(unittest.TestCase):
     def test_add_ovs_interfaces(self):
         xml_input = copy.deepcopy(XML_SAMPLE)
         xml_output = model.Libvirt.add_ovs_interface(
-            '/usr/local', 0, self.pci_address_str, self.mac, xml_input)
+            '/usr/local', 0, self.pci_address_str, self.mac, xml_input, 4)
 
         root = ElementTree.fromstring(xml_output)
         et_out = ElementTree.ElementTree(element=root)
index 6cc8b11..a03d908 100644 (file)
@@ -389,7 +389,7 @@ class OvsDpdkContextTestCase(unittest.TestCase):
         self.ovs_dpdk._enable_interfaces(0, ["private_0"], 'test')
         mock_add_ovs_interface.assert_called_once_with(
             'fake_path', 0, self.NETWORKS['private_0']['vpci'],
-            self.NETWORKS['private_0']['mac'], 'test')
+            self.NETWORKS['private_0']['mac'], 'test', 1)
 
     @mock.patch.object(model.StandaloneContextHelper, 'check_update_key')
     @mock.patch.object(model.Libvirt, 'write_file')