summaryrefslogtreecommitdiffstats
path: root/src/dpdk
diff options
context:
space:
mode:
Diffstat (limited to 'src/dpdk')
-rw-r--r--src/dpdk/dpdk.py53
1 files changed, 36 insertions, 17 deletions
diff --git a/src/dpdk/dpdk.py b/src/dpdk/dpdk.py
index 438fe40b..2f120129 100644
--- a/src/dpdk/dpdk.py
+++ b/src/dpdk/dpdk.py
@@ -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.
"""
n302' href='#n302'>302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416