driverctl: Add driverctl binding tool 95/38995/4
authorChristian Trautman <ctrautma@redhat.com>
Wed, 9 Aug 2017 19:11:15 +0000 (15:11 -0400)
committerMartin Klozik <martinx.klozik@intel.com>
Fri, 18 Aug 2017 07:13:38 +0000 (07:13 +0000)
Adds driverctl as a binding tool option for dpdk devices. JIRA
ticket contains test results to verify it works when using
dpdk-devbind or driverctl.

JIRA: VSPERF-525

Change-Id: Ia7a6e43a4b6fb3ba21f5d87d601f4ea4b95b7dab
Signed-off-by: Christian Trautman <ctrautma@redhat.com>
docs/testing/user/configguide/installation.rst
src/dpdk/dpdk.py

index f5b0b7a..207e50a 100644 (file)
@@ -256,6 +256,19 @@ running any of the above. For example:
 .. _vloop-vnf-ubuntu-14.04_20160303: http://artifacts.opnfv.org/vswitchperf/vnf/vloop-vnf-ubuntu-14.04_20160303.qcow2
 .. _vloop-vnf-ubuntu-14.04_20151216: http://artifacts.opnfv.org/vswitchperf/vnf/vloop-vnf-ubuntu-14.04_20151216.qcow2
 
+Bind Tools DPDK
+===============
+
+VSPerf supports the default DPDK bind tool, but also supports driverctl. The
+driverctl tool is a new tool being used that allows driver binding to be
+persistent across reboots. The driverctl tool is not provided by VSPerf, but can
+be downloaded from upstream sources. Once installed set the bind tool to
+driverctl to allow VSPERF to correctly bind cards for DPDK tests.
+
+.. code:: python
+
+    PATHS['dpdk']['src']['bind-tool'] = 'driverctl'
+
 Hugepage Configuration
 ----------------------
 
index 438fe40..2f12012 100644 (file)
@@ -138,7 +138,7 @@ def _vhost_user_cleanup():
 
 
 def _bind_nics():
-    """Bind NICs using the Intel DPDK ``dpdk*bind.py`` tool.
+    """Bind NICs using the bind tool specified in the configuration.
     """
     if not len(_NICS_PCI):
         _LOGGER.info('NICs are not configured - nothing to bind')
@@ -153,26 +153,39 @@ def _bind_nics():
             tasks.run_task(['sudo', 'chmod', '-R', '666', '/dev/vfio/'],
                            _LOGGER, 'Setting VFIO permissions .. 0666',
                            True)
-
-        tasks.run_task(['sudo', S.getValue('TOOLS')['bind-tool'],
-                        '--bind=' + _driver] +
-                       _NICS_PCI, _LOGGER,
-                       'Binding NICs %s...' % _NICS_PCI,
-                       True)
+        if 'driverctl' in S.getValue('TOOLS')['bind-tool'].lower():
+            for nic in _NICS_PCI:
+                tasks.run_task(['sudo', S.getValue('TOOLS')['bind-tool'], '-v',
+                                'set-override'] + [nic] + [_driver], _LOGGER,
+                               'Binding NIC %s...' % nic, True)
+        else:
+            tasks.run_task(['sudo', S.getValue('TOOLS')['bind-tool'],
+                            '--bind=' + _driver] +
+                           _NICS_PCI, _LOGGER,
+                           'Binding NICs %s...' % _NICS_PCI,
+                           True)
     except subprocess.CalledProcessError:
         _LOGGER.error('Unable to bind NICs %s', str(_NICS_PCI))
 
+
 def _unbind_nics():
-    """Unbind NICs using the Intel DPDK ``dpdk*bind.py`` tool.
+    """Unbind NICs using the bind tool specified in the configuration.
     """
     if not len(_NICS_PCI):
         _LOGGER.info('NICs are not configured - nothing to unbind')
         return
     try:
-        tasks.run_task(['sudo', S.getValue('TOOLS')['bind-tool'], '--unbind'] +
-                       _NICS_PCI, _LOGGER,
-                       'Unbinding NICs %s...' % str(_NICS_PCI),
-                       True)
+        if 'driverctl' in S.getValue('TOOLS')['bind-tool'].lower():
+            for nic in _NICS_PCI:
+                tasks.run_task(['sudo', S.getValue('TOOLS')['bind-tool'], '-v',
+                                'unset-override'] + [nic], _LOGGER,
+                               'Binding NIC %s...' % nic, True)
+        else:
+            tasks.run_task(['sudo', S.getValue('TOOLS')['bind-tool'],
+                            '--unbind'] +
+                           _NICS_PCI, _LOGGER,
+                           'Unbinding NICs %s...' % str(_NICS_PCI),
+                           True)
     except subprocess.CalledProcessError:
         _LOGGER.error('Unable to unbind NICs %s', str(_NICS_PCI))
     # Rebind NICs to their original drivers
@@ -180,15 +193,21 @@ def _unbind_nics():
     for nic in _NICS:
         try:
             if nic['driver']:
-                tasks.run_task(['sudo', S.getValue('TOOLS')['bind-tool'], '--bind',
-                                nic['driver'], nic['pci']],
-                               _LOGGER, 'Binding NIC %s to %s...' %
-                               (nic['pci'], nic['driver']),
-                               True)
+                if 'driverctl' in S.getValue('TOOLS')['bind-tool'].lower():
+                    # driverctl restores the driver automatically on unset
+                    break
+                else:
+                    tasks.run_task(['sudo', S.getValue('TOOLS')['bind-tool'],
+                                    '--bind',
+                                    nic['driver'], nic['pci']],
+                                   _LOGGER, 'Binding NIC %s to %s...' %
+                                   (nic['pci'], nic['driver']),
+                                   True)
         except subprocess.CalledProcessError:
             _LOGGER.error('Unable to bind NIC %s to driver %s',
                           nic['pci'], nic['driver'])
 
+
 class Dpdk(object):
     """A context manager for the system init/cleanup.
     """