test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH V2] framework/crb:add check link status public method
@ 2022-01-13 14:44 Zhimin Huang
  2022-01-14  6:27 ` Tu, Lijuan
  0 siblings, 1 reply; 2+ messages in thread
From: Zhimin Huang @ 2022-01-13 14:44 UTC (permalink / raw)
  To: dts; +Cc: Zhimin Huang

when we meet testpmd or app start but link is not up.
we can loop up the interface to ensure link.

v2:
- add support interface list

Signed-off-by: Zhimin Huang <zhiminx.huang@intel.com>
---
 framework/crb.py | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/framework/crb.py b/framework/crb.py
index bd4f565d..72d0d2f5 100755
--- a/framework/crb.py
+++ b/framework/crb.py
@@ -907,3 +907,33 @@ class Crb(object):
         else:
             self.logger.info("NIC %s may be not find %s" % (intf, flag))
             return False
+
+    def check_interfaces_link(self, intf: (list, str), timeout=15):
+        """
+        loop to check port link status
+        """
+        if isinstance(intf, list):
+            for interface in intf:
+                for i in range(timeout):
+                    out = self.send_expect("ethtool {} | tail -1 ".format(interface), "# ")
+                    if 'Link detected: yes' not in out:
+                        self.send_expect("ifconfig {} up".format(interface), "# ")
+                        time.sleep(1)
+                    else:
+                        break
+                else:
+                    self.logger.error("{} link is down".format(interface))
+            else:
+                return True
+        elif isinstance(intf, str):
+            for i in range(timeout):
+                out = self.send_expect("ethtool {} | tail -1 ".format(intf), "# ")
+                if 'Link detected: yes' not in out:
+                    self.send_expect("ifconfig {} up".format(intf), "# ")
+                    time.sleep(1)
+                else:
+                    return True
+            self.logger.error("{} link is down".format(intf))
+        else:
+            raise Exception("unsupported param type, only accept list or str")
+        return False
-- 
2.17.1


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

* RE: [dts] [PATCH V2] framework/crb:add check link status public method
  2022-01-13 14:44 [dts] [PATCH V2] framework/crb:add check link status public method Zhimin Huang
@ 2022-01-14  6:27 ` Tu, Lijuan
  0 siblings, 0 replies; 2+ messages in thread
From: Tu, Lijuan @ 2022-01-14  6:27 UTC (permalink / raw)
  To: Huang, ZhiminX, dts; +Cc: Huang, ZhiminX

> -----Original Message-----
> From: Zhimin Huang <zhiminx.huang@intel.com>
> Sent: 2022年1月13日 22:44
> To: dts@dpdk.org
> Cc: Huang, ZhiminX <zhiminx.huang@intel.com>
> Subject: [dts] [PATCH V2] framework/crb:add check link status public method
> 
> when we meet testpmd or app start but link is not up.
> we can loop up the interface to ensure link.
> 	
> v2:
> - add support interface list
> 
> Signed-off-by: Zhimin Huang <zhiminx.huang@intel.com>

Applied, thanks

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

end of thread, other threads:[~2022-01-14  6:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-13 14:44 [dts] [PATCH V2] framework/crb:add check link status public method Zhimin Huang
2022-01-14  6:27 ` 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).