On 1/3/22 15:15, David Marchand wrote:
> 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.
> 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.
> 
> Note: with mlx5 devices, there is now more OVS/DPDK warnings to waive.
> 
> Signed-off-by: David Marchand <[email protected]>
> Reviewed-by: Maxime Coquelin <[email protected]>
> Acked-by: Eelco Chaudron <[email protected]>
> ---
> Changes since v3:
> - fixed nit from Maxime,
> 
> Changes since v2:
> - sorted logs alphabetically,
> 
> ---
>  Documentation/topics/testing.rst |  1 -
>  tests/automake.mk                |  1 +
>  tests/system-dpdk-find-device.py | 44 ++++++++++++++++++++++++++++++++
>  tests/system-dpdk-macros.at      | 10 ++------
>  tests/system-dpdk.at             |  4 ++-
>  5 files changed, 50 insertions(+), 10 deletions(-)
>  create mode 100755 tests/system-dpdk-find-device.py
> 
> diff --git a/Documentation/topics/testing.rst 
> b/Documentation/topics/testing.rst
> index c15d5b38f2..162d1c2b7d 100644
> --- a/Documentation/topics/testing.rst
> +++ b/Documentation/topics/testing.rst
> @@ -343,7 +343,6 @@ To see a list of all the available tests, run::
>  
>  These tests support a `DPDK supported NIC`_. The tests operate on a wider 
> set of
>  environments, for instance, when a virtual port is used.
> -They do require proper DPDK variables (``DPDK_DIR`` and ``DPDK_BUILD``).
>  Moreover you need to have root privileges to load the required modules and 
> to bind
>  the NIC to the DPDK-compatible driver.
>  
> diff --git a/tests/automake.mk b/tests/automake.mk
> index 43731d0973..ab2b87012e 100644
> --- a/tests/automake.mk
> +++ b/tests/automake.mk
> @@ -189,6 +189,7 @@ SYSTEM_OFFLOADS_TESTSUITE_AT = \
>  
>  SYSTEM_DPDK_TESTSUITE_AT = \
>       tests/system-common-macros.at \
> +     tests/system-dpdk-find-device.py \
>       tests/system-dpdk-macros.at \
>       tests/system-dpdk-testsuite.at \
>       tests/system-dpdk.at
> diff --git a/tests/system-dpdk-find-device.py 
> b/tests/system-dpdk-find-device.py
> new file mode 100755
> index 0000000000..4253326e75
> --- /dev/null
> +++ b/tests/system-dpdk-find-device.py
> @@ -0,0 +1,44 @@
> +#!/usr/bin/env python3
> +# Copyright (c) 2021 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)
> +
> +mlx5_ib_available = Path('/sys/module/mlx5_ib').exists()
> +
> +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
> +    # Devices of interest:
> +    # - device is bound to vfio_pci or igb_uio,
> +    # - device is bound to mlx5_core and mlx5 is loaded,
> +    if (kmod_name not in ['vfio_pci', 'igb_uio'] and
> +        (kmod_name not in ['mlx5_core'] or not mlx5_ib_available)):
> +        continue
> +    print(device.resolve().name)
> +    sys.exit(0)
> +
> +sys.exit(1)

While it's relatively safe to assume that vfio-pci/uio managed
device is not your primary network connection, I think it's not
the case for the normal mlx5 device.  IIUC, this script will
take over the first found mlx5 device and that might lead to
loosing the network connection to the test system.

Is that correct?

Maybe it's better to use mlx5 devices only if specifically asked to?

Best regards, Ilya Maximets.
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to