Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Commit

Permalink
Always bind if delayed rebind is not set to use sriov_drivers_autoprobe
Browse files Browse the repository at this point in the history
  • Loading branch information
chdxD1 committed Jan 11, 2024
1 parent 9719db1 commit c1df816
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 3 additions & 2 deletions netplanner/sriov/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ def config(configuration: NetplannerConfig, queue_rebind: bool = False):
device.set_sriov_numvfs(interface_config.virtual_function_count)
if interface_config.embedded_switch_mode is not None:
device.set_eswitch_mode(
interface_config.embedded_switch_mode.value,
interface_config.delay_virtual_functions_rebind,
interface_config.embedded_switch_mode.value
)
if not interface_config.delay_virtual_functions_rebind:
device.bind_vfs()

if len(delayed_bindings) > 0:
with SERVICE_PATH.open("w") as file:
Expand Down
10 changes: 7 additions & 3 deletions netplanner/sriov/pci.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#
# inspired by https://github.com/canonical/netplan/blob/main/netplan_cli/cli/sriov.py

import logging
import json
import glob
import os
Expand Down Expand Up @@ -185,6 +186,7 @@ def bind_vfs(vfs: typing.Iterable[PCIDevice]):
bound_vfs = []
for vf in vfs:
if not vf.bound:
logging.info(f"Binding {vf.pci_addr} to mlx5_core")
with open("/sys/bus/pci/drivers/mlx5_core/bind", "wt") as f:
f.write(vf.pci_addr)
bound_vfs.append(vf)
Expand Down Expand Up @@ -412,16 +414,18 @@ def set_sriov_numvfs(self, numvfs: int) -> bool:
return True
return False

def set_eswitch_mode(self, switch_mode: str, delay_rebind: bool):
def set_eswitch_mode(self, switch_mode: str):
if self.pci_device.is_pf:
try:
unbind_vfs(self.pci_device.vfs)
self.pci_device.devlink_set("eswitch", "mode", switch_mode)
finally:
if not delay_rebind:
bind_vfs(self.pci_device.vfs)
pass
self.update_attributes()

def bind_vfs(self):
bind_vfs(self.pci_device.vfs)


class PCINetDevices(object):
def __init__(self):
Expand Down

0 comments on commit c1df816

Please sign in to comment.