summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/vyos/vpp/config_verify.py62
-rw-r--r--python/vyos/vpp/control_host.py36
2 files changed, 36 insertions, 62 deletions
diff --git a/python/vyos/vpp/config_verify.py b/python/vyos/vpp/config_verify.py
index 7b90b37db..c93a647f9 100644
--- a/python/vyos/vpp/config_verify.py
+++ b/python/vyos/vpp/config_verify.py
@@ -62,68 +62,6 @@ def verify_vpp_tunnel_source_address(config: dict):
)
-def verify_dev_driver(driver_type: str, driver: str) -> bool:
- # Lists of drivers compatible with DPDK and XDP
- drivers_dpdk: list[str] = [
- 'atlantic',
- 'bnx2x',
- 'e1000',
- 'ena',
- 'gve',
- 'hv_netvsc',
- 'i40e',
- 'ice',
- 'igc',
- 'ixgbe',
- 'ixgbevf',
- 'liquidio',
- 'mlx4_core',
- 'mlx5_core',
- 'qede',
- 'sfc',
- 'tap',
- 'tun',
- 'virtio_net',
- 'vmxnet3',
- ]
-
- drivers_xdp: list[str] = [
- 'atlantic',
- 'ena',
- 'gve',
- 'hv_netvsc',
- 'i40e',
- 'ice',
- 'igb',
- 'igc',
- 'ixgbe',
- 'mlx4_core',
- 'mlx5_core',
- 'qede',
- 'sfc',
- 'tap',
- 'tun',
- 'virtio_net',
- 'vmxnet3',
- ]
-
- if driver_type == 'dpdk':
- if driver in drivers_dpdk:
- return True
- # XDP support is intentionally disabled (T8202).
- # XDP is no longer configurable via the CLI.
- # This logic is kept commented out to make it easy
- # to reintroduce XDP if there is a clear need in the future.
- #
- # elif driver_type == 'xdp':
- # if driver in drivers_xdp:
- # return True
- else:
- raise ConfigError(f'"Driver type {driver_type} is wrong')
-
- return False
-
-
def create_cpu_error_message(cpus_required: int, cpus_available: int = None) -> str:
cpu_info = get_cpus()
logical_cores = sum(
diff --git a/python/vyos/vpp/control_host.py b/python/vyos/vpp/control_host.py
index 50ab4d97a..9808c9418 100644
--- a/python/vyos/vpp/control_host.py
+++ b/python/vyos/vpp/control_host.py
@@ -313,6 +313,42 @@ def get_eth_driver(iface: str) -> str:
raise Exception(f'Could not determine driver for "{iface}": {error}') from error
+def get_pci_id(iface: str) -> str | None:
+ """
+ Retrieves the PCI ID for a specified network interface.
+
+ Args:
+ iface (str): The name of the network interface (e.g., 'eth0').
+
+ Raises:
+ OSError: The interface cannot be resolved or PCI ID files cannot be read
+
+ Returns:
+ str: The PCI ID in the format 'vendor:device'.
+ None: In case a NIC is not on a PCI bus.
+ """
+ dev_id = get_dev_id(iface)
+
+ # Check if this device is on a PCI bus, return `None` if this is not a PCI device
+ pci_dev_path = Path(f'/sys/bus/pci/devices/{dev_id}')
+ if not pci_dev_path.exists():
+ return None
+
+ # Read vendor and device IDs
+ def _read_bus(file: str) -> str:
+ path = Path(f'/sys/bus/pci/devices/{dev_id}/{file}')
+ return path.read_text().removeprefix('0x').strip()
+
+ try:
+ device_id, vendor_id = _read_bus('device'), _read_bus('vendor')
+ except OSError as e:
+ # If we reached this exception, then something really weird happened,
+ # but it is still right to have it
+ raise OSError(f'PCI IDs for {iface} cannot be retrieved') from e
+
+ return f'{vendor_id}:{device_id}'.lower()
+
+
def unsafe_noiommu_mode(status: bool) -> None:
"""Control unsafe_noiommu_mode parameter of vfio module