test suite reviews and discussions
 help / color / mirror / Atom feed
From: michael.luo@intel.com
To: dts@dpdk.org
Subject: [dts] [PATCH] framework/dut.py: pull the name after bound the interface to kernel driver
Date: Tue, 12 Mar 2019 16:49:26 +0800	[thread overview]
Message-ID: <1552380566-30145-1-git-send-email-michael.luo@intel.com> (raw)

From: Luo Gaoliang <michael.luo@intel.com>

When restoring the interface, it will do unbinding, then bind the interface
with the kernel driver, it's better to pull the interface name with 1s interval.
Because on some system, especially on VMs, if try to get the name immediately
after bind the interface with the driver, it may not be ready in its sysfs.

Signed-off-by: Luo Gaoliang <michael.luo@intel.com>
---
 framework/dut.py | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/framework/dut.py b/framework/dut.py
index ab0eb32..541ab7b 100644
--- a/framework/dut.py
+++ b/framework/dut.py
@@ -281,8 +281,18 @@ class Dut(Crb):
                 self.send_expect('modprobe %s' % driver, '# ')
                 self.send_expect('echo %s > /sys/bus/pci/drivers/%s/bind'
                                  % (pci_bus, driver), '# ')
-                itf = port.get_interface_name()
-                self.send_expect("ifconfig %s up" % itf, "# ")
+                pull_retries = 5
+                while pull_retries > 0:
+                    itf = port.get_interface_name()
+                    if 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:
+                    self.send_expect("ifconfig %s up" % itf, "# ")
             else:
                 self.logger.info("NOT FOUND DRIVER FOR PORT (%s|%s)!!!" % (pci_bus, pci_id))
 
-- 
2.7.4

             reply	other threads:[~2019-03-12  8:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-12  8:49 michael.luo [this message]
2019-03-15  7:08 ` Tu, Lijuan

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=1552380566-30145-1-git-send-email-michael.luo@intel.com \
    --to=michael.luo@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).