Fix: detaches the attached XDP/BPF program before af_xdp test run 48/38348/1
authorYulong Pei <yulong.pei@intel.com>
Fri, 24 Feb 2023 07:35:58 +0000 (07:35 +0000)
committerYulong Pei <yulong.pei@intel.com>
Fri, 24 Feb 2023 07:57:38 +0000 (07:57 +0000)
When call create af_xdp interface api, it will load default xdp program
(xsk_def_prog.o) on the NIC interface, the program will be unloaded
when call delete af_xdp interface api, but current csit config did not
call delete api for af_xdp test cases, that will cause af_xdp test case
fails to run on Intel E810 NIC when the interface already have xdp program
attached, so this patch is to fix this issue by to detach any attached
XDP/BPF program on the interface before af_xdp test case run.

Signed-off-by: Yulong Pei <yulong.pei@intel.com>
Change-Id: I1a557b4c4a7e88c5715cec771a001df29ac4ae6f
Signed-off-by: Yulong Pei <yulong.pei@intel.com>
resources/libraries/python/InterfaceUtil.py
resources/libraries/robot/shared/interfaces.robot

index 03e0e69..2368ee3 100644 (file)
@@ -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.
index a2e46ef..6279dd0 100644 (file)
 | | FOR | ${dut} | IN | @{duts}
 | | | Set Interface State PCI
 | | | ... | ${nodes['${dut}']} | ${${dut}_pf_pci} | state=up
+| | | Set Interface XDP off
+| | | ... | ${nodes['${dut}']} | ${${dut}_pf_pci}
 | | | Set Interface Channels
 | | | ... | ${nodes['${dut}']} | ${${dut}_pf_pci} | num_queues=${rxq_count_int}
 | | | ... | channel=combined