- 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)