diff options
author | Yulong Pei <yulong.pei@intel.com> | 2023-03-31 09:50:17 +0000 |
---|---|---|
committer | Peter Mikus <peter.mikus@protonmail.ch> | 2023-04-03 06:31:03 +0000 |
commit | 327f93c093a163f60af19e34f20c0cba7d17e0a0 (patch) | |
tree | 9e328f188e3b6c17b29d76a950396e0f38938612 /resources/libraries/python/TrafficGenerator.py | |
parent | ca2c6c053978a8eac3674e29ffa00a90fb9afc3f (diff) |
remove dpdk_nic_bind.py dependency
dpdk_nic_bind.py from <trex>/scripts/ is out of date, often bumped into
errors when using it to bind nic port, e.g.
/usr/bin/python3 dpdk_nic_bind.py --bind=vfio-pci 0000:ca:00.0
/opt/trex-core-3.00/scripts/dpdk_nic_bind.py:40: DeprecationWarning:
The distutils package is deprecated and slated for removal in Python 3.12.
Use setuptools or check PEP 632 for potential alternatives
from distutils.util import strtobool
Error: bind failed for 0000:ca:00.0 - Cannot bind to driver vfio-pci
so remove dpdk_nic_bind.py dependency in csit.
Signed-off-by: Yulong Pei <yulong.pei@intel.com>
Change-Id: I5a3f641cd77d339aa7a213f410ce2efe7c322b8a
Signed-off-by: Yulong Pei <yulong.pei@intel.com>
Diffstat (limited to 'resources/libraries/python/TrafficGenerator.py')
-rw-r--r-- | resources/libraries/python/TrafficGenerator.py | 45 |
1 files changed, 18 insertions, 27 deletions
diff --git a/resources/libraries/python/TrafficGenerator.py b/resources/libraries/python/TrafficGenerator.py index 2a28896e63..2e03b4b1dc 100644 --- a/resources/libraries/python/TrafficGenerator.py +++ b/resources/libraries/python/TrafficGenerator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # 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: @@ -31,6 +31,7 @@ from .ssh import exec_cmd_no_error, exec_cmd from .topology import NodeType from .topology import NodeSubTypeTG from .topology import Topology +from .DUTSetup import DUTSetup as DS __all__ = [u"TGDropRateSearchImpl", u"TrafficGenerator", u"OptimizedSearch"] @@ -424,36 +425,26 @@ class TrafficGenerator(AbstractMeasurer): ) # Prepare interfaces for TRex. - mlx_ports = u"" + tg_port_drv = Constants.TREX_PORT_DRIVER mlx_driver = u"" - itl_ports = u"" for port in tg_node[u"interfaces"].values(): if u"Mellanox" in port.get(u"model"): - mlx_ports += f" {port.get(u'pci_address')}" mlx_driver = port.get(u"driver") - if u"Intel" in port.get(u"model"): - itl_ports += f" {port.get(u'pci_address')}" - - if itl_ports: - cmd = ( - f"sh -c \"cd {Constants.TREX_INSTALL_DIR}/scripts/ && ", - f"./dpdk_nic_bind.py -u {itl_ports} || ", - f"true\"" - ) - exec_cmd_no_error( - tg_node, cmd, sudo=True, - message=u"Unbind PCI ports from driver failed!" - ) - if mlx_ports: - cmd = ( - f"sh -c \"cd {Constants.TREX_INSTALL_DIR}/scripts/ && ", - f"./dpdk_nic_bind.py -b {mlx_driver} {mlx_ports} || ", - f"true\"" - ) - exec_cmd_no_error( - tg_node, cmd, sudo=True, - message=u"Bind PCI ports from driver failed!" - ) + pci_addr = port.get(u'pci_address') + cur_driver = DS.get_pci_dev_driver(tg_node, pci_addr) + if cur_driver == mlx_driver: + pass + elif not cur_driver: + DS.pci_driver_bind(tg_node, pci_addr, mlx_driver) + else: + DS.pci_driver_unbind(tg_node, pci_addr) + DS.pci_driver_bind(tg_node, pci_addr, mlx_driver) + else: + pci_addr = port.get(u'pci_address') + cur_driver = DS.get_pci_dev_driver(tg_node, pci_addr) + if cur_driver: + DS.pci_driver_unbind(tg_node, pci_addr) + DS.pci_driver_bind(tg_node, pci_addr, tg_port_drv) # Start TRex. cd_cmd = f"cd '{Constants.TREX_INSTALL_DIR}/scripts/'" |