From adfdd0db071cf8247434cb456cc676144323719f Mon Sep 17 00:00:00 2001 From: Christian Trautman Date: Mon, 24 Oct 2016 10:32:52 -0400 Subject: guest_binding: Add dpdk driver binding options for guests Adds uio_pci_generic and vfio_no_iommu options for guest driver binding. In case of SR-IOV tests with guests attached and uio_pci_generic is selected the option will be modified to use igb_uio instead as uio_pci_generic is not supported. JIRA: VSPERF-397 Change-Id: I56003addacc8bf0d024cce35d41b00dd0baa8cbc signed-off-by: Christian Trautman --- vnfs/qemu/qemu.py | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) (limited to 'vnfs/qemu/qemu.py') diff --git a/vnfs/qemu/qemu.py b/vnfs/qemu/qemu.py index 67dbfab4..87126da8 100644 --- a/vnfs/qemu/qemu.py +++ b/vnfs/qemu/qemu.py @@ -351,7 +351,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 +382,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' @@ -486,6 +480,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. -- cgit 1.2.3-korg