From: Zhimin Huang <zhiminx.huang@intel.com>
To: dts@dpdk.org
Cc: Zhimin Huang <zhiminx.huang@intel.com>
Subject: [dts] [PATCH V2] framework/crb:add check link status public method
Date: Thu, 13 Jan 2022 22:44:17 +0800 [thread overview]
Message-ID: <20220113144417.26180-1-zhiminx.huang@intel.com> (raw)
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
next reply other threads:[~2022-01-13 6:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-13 14:44 Zhimin Huang [this message]
2022-01-14 6:27 ` 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=20220113144417.26180-1-zhiminx.huang@intel.com \
--to=zhiminx.huang@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).