aboutsummaryrefslogtreecommitdiffstats
path: root/vnfs
diff options
context:
space:
mode:
Diffstat (limited to 'vnfs')
-rw-r--r--vnfs/qemu/qemu.py154
-rw-r--r--vnfs/qemu/qemu_dpdk_vhost_user.py5
2 files changed, 67 insertions, 92 deletions
diff --git a/vnfs/qemu/qemu.py b/vnfs/qemu/qemu.py
index ae0056dc..997f93e0 100644
--- a/vnfs/qemu/qemu.py
+++ b/vnfs/qemu/qemu.py
@@ -24,7 +24,6 @@ import time
import pexpect
from conf import settings as S
-from conf import get_test_param
from vnfs.vnf.vnf import IVnf
class IVnfQemu(IVnf):
@@ -69,7 +68,6 @@ class IVnfQemu(IVnf):
self._nics = S.getValue('GUEST_NICS')[self._number][:nics_nr]
# set guest loopback application based on VNF configuration
- # cli option take precedence to config file values
self._guest_loopback = S.getValue('GUEST_LOOPBACK')[self._number]
self._testpmd_fwd_mode = S.getValue('GUEST_TESTPMD_FWD_MODE')[self._number]
@@ -81,11 +79,6 @@ class IVnfQemu(IVnf):
self._testpmd_fwd_mode, 'io')
self._testpmd_fwd_mode = 'io'
- guest_smp = int(get_test_param('guest_smp', 0))
- if guest_smp:
- override_list = [guest_smp] * (self._number + 1)
- S.setValue('GUEST_SMP', override_list)
-
name = 'Client%d' % self._number
vnc = ':%d' % self._number
# NOTE: affinization of main qemu process can cause hangup of 2nd VM
@@ -151,27 +144,28 @@ class IVnfQemu(IVnf):
"""
Stops VNF instance gracefully first.
"""
- try:
- # exit testpmd if needed
- if self._guest_loopback == 'testpmd':
- self.execute_and_wait('stop', 120, "Done")
- self.execute_and_wait('quit', 120, "[bB]ye")
+ if self.is_running():
+ try:
+ # exit testpmd if needed
+ if self._guest_loopback == 'testpmd':
+ self.execute_and_wait('stop', 120, "Done")
+ self.execute_and_wait('quit', 120, "[bB]ye")
- # turn off VM
- self.execute_and_wait('poweroff', 120, "Power down")
+ # turn off VM
+ self.execute_and_wait('poweroff', 120, "Power down")
- except pexpect.TIMEOUT:
- self.kill()
+ except pexpect.TIMEOUT:
+ self.kill()
- # wait until qemu shutdowns
- self._logger.debug('Wait for QEMU to terminate')
- for dummy in range(30):
- time.sleep(1)
- if not self.is_running():
- break
+ # wait until qemu shutdowns
+ self._logger.debug('Wait for QEMU to terminate')
+ for dummy in range(30):
+ time.sleep(1)
+ if not self.is_running():
+ break
- # just for case that graceful shutdown failed
- super(IVnfQemu, self).stop()
+ # just for case that graceful shutdown failed
+ super(IVnfQemu, self).stop()
# helper functions
@@ -237,18 +231,14 @@ class IVnfQemu(IVnf):
stdin=proc.stdout)
proc.wait()
- guest_core_binding = int(get_test_param('guest_core_binding', 0))
for cpu in range(0, int(S.getValue('GUEST_SMP')[self._number])):
match = None
for line in output.decode(cur_locale).split('\n'):
match = re.search(thread_id % cpu, line)
if match:
- if guest_core_binding:
- self._affinitize_pid(guest_core_binding, match.group(1))
- else:
- self._affinitize_pid(
- S.getValue('GUEST_CORE_BINDING')[self._number][cpu],
- match.group(1))
+ self._affinitize_pid(
+ S.getValue('GUEST_CORE_BINDING')[self._number][cpu],
+ match.group(1))
break
if not match:
@@ -351,7 +341,6 @@ class IVnfQemu(IVnf):
self.execute_and_wait("{} -t {} -F".format(iptables, table))
self.execute_and_wait("{} -t {} -X".format(iptables, table))
-
def _configure_testpmd(self):
"""
Configure VM to perform L2 forwarding between NICs by DPDK's testpmd
@@ -383,16 +372,11 @@ class IVnfQemu(IVnf):
for nic in self._nics:
self.execute_and_wait('ifdown ' + nic['device'])
- # build and insert igb_uio and rebind interfaces to it
- self.execute_and_wait('make RTE_OUTPUT=$RTE_SDK/$RTE_TARGET -C '
- '$RTE_SDK/lib/librte_eal/linuxapp/igb_uio')
- self.execute_and_wait('modprobe uio')
- self.execute_and_wait('insmod %s/kmod/igb_uio.ko' %
- S.getValue('RTE_TARGET'))
self.execute_and_wait('./tools/dpdk*bind.py --status')
pci_list = ' '.join([nic['pci'] for nic in self._nics])
self.execute_and_wait('./tools/dpdk*bind.py -u ' + pci_list)
- self.execute_and_wait('./tools/dpdk*bind.py -b igb_uio ' + pci_list)
+ self._bind_dpdk_driver(S.getValue(
+ 'GUEST_DPDK_BIND_DRIVER')[self._number], pci_list)
self.execute_and_wait('./tools/dpdk*bind.py --status')
# build and run 'test-pmd'
@@ -401,48 +385,12 @@ class IVnfQemu(IVnf):
self.execute_and_wait('make clean')
self.execute_and_wait('make')
- # get multi-queue settings from CLI
- guest_testpmd_txq = int(get_test_param('guest_testpmd_txq', 0))
- if guest_testpmd_txq:
- override_list = [guest_testpmd_txq] * (self._number + 1)
- S.setValue('GUEST_TESTPMD_TXQ', override_list)
-
- guest_testpmd_rxq = int(get_test_param('guest_testpmd_rxq', 0))
- if guest_testpmd_rxq:
- override_list = [guest_testpmd_rxq] * (self._number + 1)
- S.setValue('GUEST_TESTPMD_RXQ', override_list)
-
- guest_testpmd_nb_cores = \
- int(get_test_param('guest_testpmd_nb_cores', 0))
- if guest_testpmd_nb_cores:
- override_list = [guest_testpmd_nb_cores] * (self._number + 1)
- S.setValue('GUEST_TESTPMD_NB_CORES', override_list)
-
- guest_testpmd_cpu_mask = \
- int(get_test_param('guest_testpmd_cpu_mask', 0))
- if guest_testpmd_cpu_mask:
- override_list = [guest_testpmd_cpu_mask] * (self._number + 1)
- S.setValue('GUEST_TESTPMD_CPU_MASK', override_list)
+ # get testpmd settings from CLI
+ testpmd_params = S.getValue('GUEST_TESTPMD_PARAMS')[self._number]
- if int(S.getValue('GUEST_NIC_QUEUES')[self._number]):
- self.execute_and_wait(
- './testpmd {} -n4 --socket-mem 512 --'.format(
- S.getValue('GUEST_TESTPMD_CPU_MASK')[self._number]) +
- ' --burst=64 -i --txqflags=0xf00 ' +
- '--nb-cores={} --rxq={} --txq={} '.format(
- S.getValue('GUEST_TESTPMD_NB_CORES')[self._number],
- S.getValue('GUEST_TESTPMD_TXQ')[self._number],
- S.getValue('GUEST_TESTPMD_RXQ')[self._number]) +
- '--disable-hw-vlan', 60, "Done")
- else:
- self.execute_and_wait(
- './testpmd {} -n 4 --socket-mem 512 --'.format(
- S.getValue('GUEST_TESTPMD_CPU_MASK')[self._number]) +
- ' --burst=64 -i --txqflags=0xf00 ' +
- '--disable-hw-vlan', 60, "Done")
+ self.execute_and_wait('./testpmd {}'.format(testpmd_params), 60, "Done")
self.execute('set fwd ' + self._testpmd_fwd_mode, 1)
- self.execute_and_wait('start', 20,
- 'TX RS bit threshold=.+ - TXQ flags=0xf00')
+ self.execute_and_wait('start', 20, 'testpmd>')
def _configure_l2fwd(self):
"""
@@ -498,17 +446,13 @@ class IVnfQemu(IVnf):
# Add the arp entries for the IXIA ports and the bridge you are using.
# Use command line values if provided.
- trafficgen_mac = get_test_param('vanilla_tgen_port1_mac',
- S.getValue('VANILLA_TGEN_PORT1_MAC'))
- trafficgen_ip = get_test_param('vanilla_tgen_port1_ip',
- S.getValue('VANILLA_TGEN_PORT1_IP'))
+ trafficgen_mac = S.getValue('VANILLA_TGEN_PORT1_MAC')
+ trafficgen_ip = S.getValue('VANILLA_TGEN_PORT1_IP')
self.execute('arp -s ' + trafficgen_ip + ' ' + trafficgen_mac)
- trafficgen_mac = get_test_param('vanilla_tgen_port2_mac',
- S.getValue('VANILLA_TGEN_PORT2_MAC'))
- trafficgen_ip = get_test_param('vanilla_tgen_port2_ip',
- S.getValue('VANILLA_TGEN_PORT2_IP'))
+ trafficgen_mac = S.getValue('VANILLA_TGEN_PORT2_MAC')
+ trafficgen_ip = S.getValue('VANILLA_TGEN_PORT2_IP')
self.execute('arp -s ' + trafficgen_ip + ' ' + trafficgen_mac)
@@ -521,6 +465,42 @@ class IVnfQemu(IVnf):
for nic in self._nics:
self.execute('sysctl -w net.ipv4.conf.' + nic['device'] + '.rp_filter=0')
+ def _bind_dpdk_driver(self, driver, pci_slots):
+ """
+ Bind the virtual nics to the driver specific in the conf file
+ :return: None
+ """
+ if driver == 'uio_pci_generic':
+ if S.getValue('VNF') == 'QemuPciPassthrough':
+ # unsupported config, bind to igb_uio instead and exit the
+ # outer function after completion.
+ self._logger.error('SR-IOV does not support uio_pci_generic. '
+ 'Igb_uio will be used instead.')
+ self._bind_dpdk_driver('igb_uio_from_src', pci_slots)
+ return
+ self.execute_and_wait('modprobe uio_pci_generic')
+ self.execute_and_wait('./tools/dpdk*bind.py -b uio_pci_generic '+
+ pci_slots)
+ elif driver == 'vfio_no_iommu':
+ self.execute_and_wait('modprobe -r vfio')
+ self.execute_and_wait('modprobe -r vfio_iommu_type1')
+ self.execute_and_wait('modprobe vfio enable_unsafe_noiommu_mode=Y')
+ self.execute_and_wait('modprobe vfio-pci')
+ self.execute_and_wait('./tools/dpdk*bind.py -b vfio-pci ' +
+ pci_slots)
+ elif driver == 'igb_uio_from_src':
+ # build and insert igb_uio and rebind interfaces to it
+ self.execute_and_wait('make RTE_OUTPUT=$RTE_SDK/$RTE_TARGET -C '
+ '$RTE_SDK/lib/librte_eal/linuxapp/igb_uio')
+ self.execute_and_wait('modprobe uio')
+ self.execute_and_wait('insmod %s/kmod/igb_uio.ko' %
+ S.getValue('RTE_TARGET'))
+ self.execute_and_wait('./tools/dpdk*bind.py -b igb_uio ' + pci_slots)
+ else:
+ self._logger.error(
+ 'Unknown driver for binding specified, defaulting to igb_uio')
+ self._bind_dpdk_driver('igb_uio_from_src', pci_slots)
+
def _set_multi_queue_nic(self):
"""
Enable multi-queue in guest kernel with ethool.
diff --git a/vnfs/qemu/qemu_dpdk_vhost_user.py b/vnfs/qemu/qemu_dpdk_vhost_user.py
index a25c61ef..51c10242 100644
--- a/vnfs/qemu/qemu_dpdk_vhost_user.py
+++ b/vnfs/qemu/qemu_dpdk_vhost_user.py
@@ -18,7 +18,6 @@
import logging
from conf import settings as S
-from conf import get_test_param
from vnfs.qemu.qemu import IVnfQemu
class QemuDpdkVhostUser(IVnfQemu):
@@ -33,10 +32,6 @@ class QemuDpdkVhostUser(IVnfQemu):
self._logger = logging.getLogger(__name__)
# multi-queue values
- guest_nic_queues = int(get_test_param('guest_nic_queues', 0))
- if guest_nic_queues:
- override_list = [guest_nic_queues] * (self._number + 1)
- S.setValue('GUEST_NIC_QUEUES', override_list)
if int(S.getValue('GUEST_NIC_QUEUES')[self._number]):
queue_str = ',queues={}'.format(S.getValue('GUEST_NIC_QUEUES')[self._number])
mq_vector_str = ',mq=on,vectors={}'.format(