X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FInterfaceUtil.py;h=3ab96d1b4d64d3f59188d034547ffd9a05691eb7;hb=d74acc4db2987d9ac40aae10be8453c922a16731;hp=03e0e69d42a84f7f8380918d8bedb71f066822b3;hpb=5302eeabb757ccf710568a66b8f6435c1894cd4d;p=csit.git diff --git a/resources/libraries/python/InterfaceUtil.py b/resources/libraries/python/InterfaceUtil.py index 03e0e69d42..3ab96d1b4d 100644 --- a/resources/libraries/python/InterfaceUtil.py +++ b/resources/libraries/python/InterfaceUtil.py @@ -294,6 +294,21 @@ class InterfaceUtil: cmd = f"ethtool --set-channels {pf_eth} {channel} {num_queues}" exec_cmd_no_error(node, cmd, sudo=True) + @staticmethod + def set_interface_xdp_off(node, pf_pcis): + """Detaches any currently attached XDP/BPF program from the specified + interfaces. + + :param node: Topology node. + :param pf_pcis: List of node's interfaces PCI addresses. + :type nodes: dict + :type pf_pcis: list + """ + for pf_pci in pf_pcis: + pf_eth = InterfaceUtil.pci_to_eth(node, pf_pci) + cmd = f"ip link set dev {pf_eth} xdp off" + exec_cmd_no_error(node, cmd, sudo=True) + @staticmethod def set_interface_flow_control(node, pf_pcis, rxf=u"off", txf=u"off"): """Set Ethernet flow control for specified interfaces. @@ -1869,12 +1884,20 @@ class InterfaceUtil: node, pf_dev, state=u"up" ) - DUTSetup.pci_vf_driver_unbind(node, pf_pci_addr, vf_id) - DUTSetup.pci_vf_driver_bind(node, pf_pci_addr, vf_id, uio_driver) + vf_pci_addr = DUTSetup.get_virtfn_pci_addr(node, pf_pci_addr, vf_id) + current_driver = DUTSetup.get_pci_dev_driver( + node, vf_pci_addr.replace(":", r"\:") + ) + if current_driver and current_driver != uio_driver: + DUTSetup.pci_vf_driver_unbind( + node, pf_pci_addr, vf_id + ) + DUTSetup.pci_vf_driver_bind( + node, pf_pci_addr, vf_id, uio_driver + ) # Add newly created ports into topology file vf_ifc_name = f"{ifc_key}_vif" - vf_pci_addr = DUTSetup.get_virtfn_pci_addr(node, pf_pci_addr, vf_id) vf_ifc_key = Topology.add_new_port(node, vf_ifc_name) Topology.update_interface_name( node, vf_ifc_key, vf_ifc_name+str(vf_id+1)