diff options
author | Christian Trautman <ctrautma@redhat.com> | 2016-10-24 10:32:52 -0400 |
---|---|---|
committer | Christian Trautman <ctrautma@redhat.com> | 2016-10-24 10:32:52 -0400 |
commit | adfdd0db071cf8247434cb456cc676144323719f (patch) | |
tree | 95d0e23fe42f6026de27d542423dd8825d84bc94 /vnfs/qemu/qemu.py | |
parent | 4f207bf80169d617d9965b19494f4c7d909f0abd (diff) |
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 <ctrautma@redhat.com>
Diffstat (limited to 'vnfs/qemu/qemu.py')
-rw-r--r-- | vnfs/qemu/qemu.py | 46 |
1 files changed, 38 insertions, 8 deletions
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. |