test suite reviews and discussions
 help / color / mirror / Atom feed
From: Jiale Song <songx.jiale@intel.com>
To: dts@dpdk.org
Cc: Jiale Song <songx.jiale@intel.com>
Subject: [dts] [PATCH V1] framework/dut: optimize scripts
Date: Fri, 14 Jul 2023 23:23:04 +0800	[thread overview]
Message-ID: <20230714152304.1129546-1-songx.jiale@intel.com> (raw)

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


                 reply	other threads:[~2023-07-14  7:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230714152304.1129546-1-songx.jiale@intel.com \
    --to=songx.jiale@intel.com \
    --cc=dts@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).