Allow to use Mellanox smart NICs for DPDK

Previously to run DPDK applications on BM hosts with
SR-IOV functionality it was necessary to rebind virtual
function on some userspace driver (vfio-pci, uio_pci_generic
etc.).

But default Mellanox drivers (mlx4_core, mlx5_core) can work
with DPDK and do not require to be changed to userspace driver.
Moreover there could be occur a problem while trying to change
driver for Mellanox virtual functions.

This patch detects devices with Mellanox default driver in
the kuryr-kubernetes binding process and skip it (do not rebind).

Closes-Bug: 1856663
Change-Id: Ic5a76a6248a50370690dee2b0d57e2ded944a909
Signed-off-by: Danil Golov <d.golov@samsung.com>
This commit is contained in:
Danil Golov
2019-12-17 11:08:53 +03:00
parent 018cbf8cac
commit 20e14a9e2b
2 changed files with 15 additions and 13 deletions

View File

@@ -195,24 +195,25 @@ class VIFSriovDriver(object):
old_driver_path = '/sys/bus/pci/devices/{}/driver'.format(pci)
old_driver_link = os.readlink(old_driver_path)
old_driver = os.path.basename(old_driver_link)
unbind_path = '/sys/bus/pci/drivers/{}/unbind'.format(old_driver)
bind_path = '/sys/bus/pci/drivers/{}/bind'.format(driver)
if old_driver not in constants.MELLANOX_DRIVERS:
unbind_path = '/sys/bus/pci/drivers/{}/unbind'.format(old_driver)
bind_path = '/sys/bus/pci/drivers/{}/bind'.format(driver)
with open(unbind_path, 'w') as unbind_fd:
unbind_fd.write(pci)
with open(unbind_path, 'w') as unbind_fd:
unbind_fd.write(pci)
override = "/sys/bus/pci/devices/{}/driver_override".format(pci)
with open(override, 'w') as override_fd:
override_fd.write("\00")
override = "/sys/bus/pci/devices/{}/driver_override".format(pci)
with open(override, 'w') as override_fd:
override_fd.write("\00")
with open(override, 'w') as override_fd:
override_fd.write(driver)
with open(override, 'w') as override_fd:
override_fd.write(driver)
with open(bind_path, 'w') as bind_fd:
bind_fd.write(pci)
with open(bind_path, 'w') as bind_fd:
bind_fd.write(pci)
LOG.info("Device %s was binded on driver %s. Old driver is %s", pci,
driver, old_driver)
LOG.info("Device %s was binded on driver %s. Old driver is %s",
pci, driver, old_driver)
return old_driver
def _annotate_device(self, pod_link, pci, old_driver, new_driver, port_id):

View File

@@ -87,3 +87,4 @@ K8S_OPERATOR_DOES_NOT_EXIST = 'doesnotexist'
K8S_OPERATOR_EXISTS = 'exists'
USERSPACE_DRIVERS = ['vfio-pci', 'uio', 'uio_pci_generic', 'igb_uio']
MELLANOX_DRIVERS = ['mlx4_core', 'mlx5_core']