test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH V1] framework/dut: optimize scripts
@ 2023-07-14 15:23 Jiale Song
  0 siblings, 0 replies; only message in thread
From: Jiale Song @ 2023-07-14 15:23 UTC (permalink / raw)
  To: dts; +Cc: Jiale Song

1. delete unnecessary waiting time. the iavf driver does not need to
execute a separate wait, which is invalid and only increases the invalid
waiting time.
2. when the NIC name is N/A or empty, the name cannot be changed no
matter how long it is waiting. after obtaining N/A, it is necessary to
rebind the driver of the NIC.

Signed-off-by: Jiale Song <songx.jiale@intel.com>
---
 framework/dut.py | 48 +++++++++++++++---------------------------------
 1 file changed, 15 insertions(+), 33 deletions(-)

diff --git a/framework/dut.py b/framework/dut.py
index 0adb2786..61ef2839 100644
--- a/framework/dut.py
+++ b/framework/dut.py
@@ -416,50 +416,32 @@ class Dut(Crb):
 
                 port = GetNicObj(self, domain_id, bus_id, devfun_id)
 
-                self.send_expect(
-                    "echo %s > /sys/bus/pci/devices/%s\:%s\:%s/driver/unbind"
-                    % (pci_bus, domain_id, bus_id, devfun_id),
-                    "# ",
-                    timeout=30,
-                )
-                # bind to linux kernel driver
-                if not self.is_container:
-                    self.send_expect("modprobe %s" % driver, "# ", timeout=30)
-                self.send_expect(
-                    "echo %s > /sys/bus/pci/drivers/%s/bind" % (pci_bus, driver),
-                    "# ",
-                    timeout=30,
-                )
                 pull_retries = 5
                 itf = "N/A"
                 while pull_retries > 0:
+                    self.send_expect(
+                        "echo %s > /sys/bus/pci/devices/%s\:%s\:%s/driver/unbind"
+                        % (pci_bus, domain_id, bus_id, devfun_id),
+                        "# ",
+                        timeout=30,
+                    )
+                    # bind to linux kernel driver
+                    if not self.is_container:
+                        self.send_expect("modprobe %s" % driver, "# ", timeout=30)
+                    self.send_expect(
+                        "echo %s > /sys/bus/pci/drivers/%s/bind" % (pci_bus, driver),
+                        "# ",
+                        timeout=30,
+                    )
+                    time.sleep(1)
                     if port_info["port_id"] == 1:
                         itf = port.get_interface_name()
                     else:
                         itf = port.get_interface2_name()
                     if not itf or itf == "N/A":
-                        time.sleep(1)
                         pull_retries -= 1
                     else:
                         break
-                else:
-                    # try to bind nic with iavf
-                    if driver == "iavf":
-                        self.send_expect("modprobe %s" % driver, "# ")
-                        self.send_expect(
-                            "echo %s > /sys/bus/pci/drivers/%s/bind"
-                            % (pci_bus, driver),
-                            "# ",
-                        )
-                        pull_retries = 5
-                        itf = "N/A"
-                        while pull_retries > 0:
-                            itf = port.get_interface_name()
-                            if not itf or itf == "N/A":
-                                time.sleep(1)
-                                pull_retries -= 1
-                            else:
-                                break
                 if itf == "N/A":
                     self.logger.warning("Fail to bind the device with the linux driver")
                 else:
-- 
2.25.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-07-14  7:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-14 15:23 [dts] [PATCH V1] framework/dut: optimize scripts Jiale Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).