summaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/contexts/standalone/ovs_dpdk.py
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/benchmark/contexts/standalone/ovs_dpdk.py')
-rw-r--r--yardstick/benchmark/contexts/standalone/ovs_dpdk.py31
1 files changed, 20 insertions, 11 deletions
diff --git a/yardstick/benchmark/contexts/standalone/ovs_dpdk.py b/yardstick/benchmark/contexts/standalone/ovs_dpdk.py
index fcb7bb66c..3755b84e9 100644
--- a/yardstick/benchmark/contexts/standalone/ovs_dpdk.py
+++ b/yardstick/benchmark/contexts/standalone/ovs_dpdk.py
@@ -118,7 +118,7 @@ class OvsDpdkContext(Context):
self.connection.execute(cmd)
bind_cmd = "{dpdk_nic_bind} --force -b {driver} {port}"
phy_driver = "vfio-pci"
- for key, port in self.networks.items():
+ for _, port in self.networks.items():
vpci = port.get("phy_port")
self.connection.execute(bind_cmd.format(dpdk_nic_bind=self.dpdk_nic_bind,
driver=phy_driver, port=vpci))
@@ -129,13 +129,21 @@ class OvsDpdkContext(Context):
ovs_sock_path = '/var/run/openvswitch/db.sock'
log_path = '/var/log/openvswitch/ovs-vswitchd.log'
+ pmd_cpu_mask = self.ovs_properties.get("pmd_cpu_mask", '')
pmd_mask = hex(sum(2 ** num for num in range(pmd_nums)) << 1)
+ if pmd_cpu_mask:
+ pmd_mask = pmd_cpu_mask
+
socket0 = self.ovs_properties.get("ram", {}).get("socket_0", "2048")
socket1 = self.ovs_properties.get("ram", {}).get("socket_1", "2048")
ovs_other_config = "ovs-vsctl {0}set Open_vSwitch . other_config:{1}"
detach_cmd = "ovs-vswitchd unix:{0}{1} --pidfile --detach --log-file={2}"
+ lcore_mask = self.ovs_properties.get("lcore_mask", '')
+ if lcore_mask:
+ lcore_mask = ovs_other_config.format("--no-wait ", "dpdk-lcore-mask='%s'" % lcore_mask)
+
cmd_list = [
"mkdir -p /usr/local/var/run/openvswitch",
"mkdir -p {}".format(os.path.dirname(log_path)),
@@ -143,6 +151,7 @@ class OvsDpdkContext(Context):
ovs_sock_path),
ovs_other_config.format("--no-wait ", "dpdk-init=true"),
ovs_other_config.format("--no-wait ", "dpdk-socket-mem='%s,%s'" % (socket0, socket1)),
+ lcore_mask,
detach_cmd.format(vpath, ovs_sock_path, log_path),
ovs_other_config.format("", "pmd-cpu-mask=%s" % pmd_mask),
]
@@ -170,7 +179,7 @@ class OvsDpdkContext(Context):
]
ordered_network = OrderedDict(self.networks)
- for index, (key, vnf) in enumerate(ordered_network.items()):
+ for index, vnf in enumerate(ordered_network.values()):
if ovs_ver >= [2, 7, 0]:
dpdk_args = " options:dpdk-devargs=%s" % vnf.get("phy_port")
dpdk_list.append(ovs_add_port.format(br='br0', port='dpdk%s' % vnf.get("port_num", 0),
@@ -263,7 +272,7 @@ class OvsDpdkContext(Context):
# Bind nics back to kernel
bind_cmd = "{dpdk_nic_bind} --force -b {driver} {port}"
- for key, port in self.networks.items():
+ for port in self.networks.values():
vpci = port.get("phy_port")
phy_driver = port.get("driver")
self.connection.execute(bind_cmd.format(dpdk_nic_bind=self.dpdk_nic_bind,
@@ -296,8 +305,7 @@ class OvsDpdkContext(Context):
except StopIteration:
pass
else:
- raise ValueError("Duplicate nodes!!! Nodes: %s %s",
- (node, duplicate))
+ raise ValueError("Duplicate nodes!!! Nodes: %s %s" % (node, duplicate))
node["name"] = attr_name
return node
@@ -328,17 +336,17 @@ class OvsDpdkContext(Context):
def configure_nics_for_ovs_dpdk(self):
portlist = OrderedDict(self.networks)
- for key, ports in portlist.items():
+ for key in portlist:
mac = StandaloneContextHelper.get_mac_address()
portlist[key].update({'mac': mac})
self.networks = portlist
- LOG.info("Ports %s" % self.networks)
+ LOG.info("Ports %s", self.networks)
def _enable_interfaces(self, index, vfs, cfg):
vpath = self.ovs_properties.get("vpath", "/usr/local")
vf = self.networks[vfs[0]]
port_num = vf.get('port_num', 0)
- vpci = PciAddress.parse_address(vf['vpci'].strip(), multi_line=True)
+ vpci = PciAddress(vf['vpci'].strip())
# Generate the vpci for the interfaces
slot = index + port_num + 10
vf['vpci'] = \
@@ -357,9 +365,10 @@ class OvsDpdkContext(Context):
# 1. Check and delete VM if already exists
Libvirt.check_if_vm_exists_and_delete(vm_name, self.connection)
- vcpu, mac = Libvirt.build_vm_xml(self.connection, self.vm_flavor, cfg, vm_name, index)
+ _, mac = Libvirt.build_vm_xml(self.connection, self.vm_flavor,
+ cfg, vm_name, index)
# 2: Cleanup already available VMs
- for idx, (vkey, vfs) in enumerate(OrderedDict(vnf["network_ports"]).items()):
+ for vkey, vfs in OrderedDict(vnf["network_ports"]).items():
if vkey == "mgmt":
continue
self._enable_interfaces(index, vfs, cfg)
@@ -367,7 +376,7 @@ class OvsDpdkContext(Context):
# copy xml to target...
self.connection.put(cfg, cfg)
- # FIXME: launch through libvirt
+ # NOTE: launch through libvirt
LOG.info("virsh create ...")
Libvirt.virsh_create_vm(self.connection, cfg)