mirror of
https://github.com/openvswitch/ovs
synced 2025-08-22 09:58:01 +00:00
The DPDK unit test only runs if vfio or igb_uio kernel modules are loaded: on systems with only mlx5, this test is always skipped. Besides, the test tries to grab the first device listed by dpdk-devbind.py, regardless of the PCI device status regarding kmod binding. Remove dependency on this DPDK script and use a minimal script that reads PCI sysfs. This script is not perfect, as one can imagine PCI devices bound to vfio-pci for virtual machines. Plus, this script only tries to take over vfio-pci devices. mlx5 devices can't be taken over blindly as it could mean losing connectivity to the machine if the netdev was in use for this system. For those two reasons, add a new environment variable DPDK_PCI_ADDR for testers to select the PCI device of their liking. For consistency and grep, the temporary file PCI_ADDR is renamed to DPDK_PCI_ADDR. Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com> Acked-by: Eelco Chaudron <echaudro@redhat.com> Signed-off-by: David Marchand <david.marchand@redhat.com> Acked-by: Kevin Traynor <ktraynor@redhat.com> Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
40 lines
1.3 KiB
Python
Executable File
40 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) 2024 Red Hat, Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at:
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
|
|
from pathlib import Path
|
|
import os
|
|
import sys
|
|
|
|
# The tester might want to select a PCI device, if so, trust it.
|
|
if 'DPDK_PCI_ADDR' in os.environ:
|
|
print(os.environ['DPDK_PCI_ADDR'])
|
|
sys.exit(0)
|
|
|
|
for device in sorted(Path('/sys/bus/pci/devices').iterdir()):
|
|
class_path = device / 'class'
|
|
# Only consider Network class devices
|
|
if class_path.read_text().strip() != '0x020000':
|
|
continue
|
|
kmod_path = device / 'driver' / 'module'
|
|
kmod_name = kmod_path.resolve().name
|
|
# Only care about devices bound to vfio_pci or igb_uio.
|
|
if kmod_name not in ['vfio_pci', 'igb_uio']:
|
|
continue
|
|
print(device.resolve().name)
|
|
sys.exit(0)
|
|
|
|
sys.exit(1)
|