test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH] framework/dut.py: pull the name after bound the interface to kernel driver
@ 2019-03-12  8:49 michael.luo
  2019-03-15  7:08 ` Tu, Lijuan
  0 siblings, 1 reply; 2+ messages in thread
From: michael.luo @ 2019-03-12  8:49 UTC (permalink / raw)
  To: dts

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dts] [PATCH] framework/dut.py: pull the name after bound the interface to kernel driver
  2019-03-12  8:49 [dts] [PATCH] framework/dut.py: pull the name after bound the interface to kernel driver michael.luo
@ 2019-03-15  7:08 ` Tu, Lijuan
  0 siblings, 0 replies; 2+ messages in thread
From: Tu, Lijuan @ 2019-03-15  7:08 UTC (permalink / raw)
  To: Luo, Michael, dts

Applied, thanks

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of michael.luo@intel.com
> Sent: Tuesday, March 12, 2019 4:49 PM
> To: dts@dpdk.org
> Subject: [dts] [PATCH] framework/dut.py: pull the name after bound the
> interface to kernel driver
> 
> 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-03-15  7:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-12  8:49 [dts] [PATCH] framework/dut.py: pull the name after bound the interface to kernel driver michael.luo
2019-03-15  7:08 ` Tu, Lijuan

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).