aboutsummaryrefslogtreecommitdiffstats
path: root/src/dpdk
diff options
context:
space:
mode:
authorMaryam Tahhan <maryam.tahhan@intel.com>2015-07-30 12:02:33 +0100
committerMaryam Tahhan <maryam.tahhan@intel.com>2015-09-01 12:25:26 +0000
commitd9a8e08292e989fd369b0564bee9e3aa02b3eef5 (patch)
tree3454850cde5b98961f01d4dc4837e0248773e180 /src/dpdk
parentf426da4469d88fc520fa7aa96576b7ca8096e4d0 (diff)
src/dpdk: Rebind DPDK ports to the original driver
Bind DPDK ports back to the original driver they were bound to. This will be useful when switching between the types of vswitches we are testing. Change-Id: I6818d3f8e3c2a5d3a5f083cf9e37e0819e0b39d1 Signed-off-by: Maryam Tahhan <maryam.tahhan@intel.com> Reviewed-by: Dino Simeon Madarang <dino.simeonx.madarang@intel.com> Reviewed-by: Billy O Mahony <billy.o.mahony@intel.com>
Diffstat (limited to 'src/dpdk')
-rw-r--r--src/dpdk/dpdk.py35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/dpdk/dpdk.py b/src/dpdk/dpdk.py
index 01e1fb61..093670c4 100644
--- a/src/dpdk/dpdk.py
+++ b/src/dpdk/dpdk.py
@@ -14,7 +14,8 @@
"""Automation of system configuration for DPDK use.
-Parts of this based on ``tools/pci_unbind.py`` script from Intel(R) DPDK.
+Parts of this based on ``tools/dpdk_nic_bind.py`` script from Intel(R)
+DPDK.
"""
from sys import platform as _platform
@@ -279,7 +280,7 @@ def _remove_vhost_net():
def _bind_nics():
- """Bind NICs using the Intel DPDK ``pci_unbind.py`` tool.
+ """Bind NICs using the Intel DPDK ``dpdk_nic_bind.py`` tool.
"""
try:
tasks.run_task(['sudo', RTE_PCI_TOOL, '--bind', 'igb_uio'] +
@@ -291,10 +292,23 @@ def _bind_nics():
_LOGGER.error('Unable to bind NICs %s',
str(settings.getValue('WHITELIST_NICS')))
+def _unbind_nics_get_driver():
+ """Check what driver the NICs should be bound to
+ after unbinding them from DPDK.
+ """
+ _driver_list = []
+ _output = subprocess.check_output([RTE_PCI_TOOL, '--status'])
+ _my_encoding = locale.getdefaultlocale()[1]
+ for line in _output.decode(_my_encoding).split('\n'):
+ for nic in settings.getValue('WHITELIST_NICS'):
+ if nic in line:
+ _driver_list.append((line.split("unused=",1)[1]))
+ return _driver_list
def _unbind_nics():
- """Unbind NICs using the Intel DPDK ``pci_unbind.py`` tool.
+ """Unbind NICs using the Intel DPDK ``dpdk_nic_bind.py`` tool.
"""
+ nic_drivers = _unbind_nics_get_driver()
try:
tasks.run_task(['sudo', RTE_PCI_TOOL, '--unbind'] +
settings.getValue('WHITELIST_NICS'), _LOGGER,
@@ -304,6 +318,21 @@ def _unbind_nics():
except subprocess.CalledProcessError:
_LOGGER.error('Unable to unbind NICs %s',
str(settings.getValue('WHITELIST_NICS')))
+ '''Rebind NICs to their original drivers
+ using the Intel DPDK ``dpdk_nic_bind.py`` tool.
+ '''
+ for i, nic in enumerate(settings.getValue('WHITELIST_NICS')):
+ try:
+ if nic_drivers[i] != '':
+ tasks.run_task(['sudo', RTE_PCI_TOOL, '--bind',
+ nic_drivers[i], nic],
+ _LOGGER, 'Binding NIC %s...' %
+ nic,
+ True)
+ except subprocess.CalledProcessError:
+ _LOGGER.error('Unable to bind NICs %s to drivers %s',
+ str(settings.getValue('WHITELIST_NICS')),
+ nic_drivers)
def _copy_dpdk_for_guest():