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

Commit

Permalink
Add wait for lag to netplanner rebind
Browse files Browse the repository at this point in the history
  • Loading branch information
chdxD1 committed Apr 3, 2024
1 parent 6789b31 commit 5f75f05
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions netplanner/sriov/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import logging
from pathlib import Path
import subprocess
import time

from jinja2 import Environment

Expand Down Expand Up @@ -115,5 +116,10 @@ def config(configuration: NetplannerConfig, queue_rebind: bool = False):
def rebind(pci_addresses: list[str]):
for pci_address in pci_addresses:
device = pci.PCIDevice(pci_address)
# We always wait for link_aggregation_state to become active because
# delayed rebind is only used for this very specific case anyway
while device.link_aggregation_state != "active":
print("Waiting for lag state of device {} to become active".format(pci_address))
time.sleep(1)
device.sriov_drivers_autoprobe = True
pci.bind_vfs(device.vfs)
6 changes: 6 additions & 0 deletions netplanner/sriov/pci.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ def sriov_drivers_autoprobe(self, value: bool):
with open(sriov_drivers_autoprobe_file, "w") as f:
f.write("1" if value else "0")

@property
def link_aggregation_state(self) -> str:
link_aggregation_file = "/sys/kernel/debug/mlx5/{}/lag/state".format(self.pci_addr)
with open(link_aggregation_file, "r") as f:
return f.read().strip()

def __str__(self) -> str:
"""String represenation of object
Expand Down

0 comments on commit 5f75f05

Please sign in to comment.