test suite reviews and discussions
 help / color / mirror / Atom feed
From: "Niklas Söderlund" <niklas.soderlund@corigine.com>
To: dts@dpdk.org
Cc: oss-drivers@corigine.com, "Qin Ke" <qin.ke@corigine.com>,
	"Niklas Söderlund" <niklas.soderlund@corigine.com>
Subject: [PATCH 1/2] framework/pmd_output: report link speed in Mbps
Date: Mon,  3 Jul 2023 21:25:41 +0200	[thread overview]
Message-ID: <20230703192542.36809-2-niklas.soderlund@corigine.com> (raw)
In-Reply-To: <20230703192542.36809-1-niklas.soderlund@corigine.com>

From: Qin Ke <qin.ke@corigine.com>

Link speeds read with get_port_link_speed() have no documented unit.
This leads to issues as different PMD reports speed in both Mbps and
Gbps. The only test-case making use of get_port_link_speed(),
TestSuite_speed_capabilities.py, assumes the speed is returned in Mbps
or an empty string if the speed could not be read.

Document this behavior and extend the get_port_link_speed()
implementations to convert links speeds reported by in Gbps to Mbps.

Signed-off-by: Qin Ke <qin.ke@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
 framework/pmd_output.py          | 12 +++++++++++-
 tests/TestSuite_pmd_bonded.py    | 12 +++++++++++-
 tests/TestSuite_vf_pmd_bonded.py | 12 +++++++++++-
 3 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/framework/pmd_output.py b/framework/pmd_output.py
index c8e8b50f1711..274a02eb32da 100644
--- a/framework/pmd_output.py
+++ b/framework/pmd_output.py
@@ -235,8 +235,18 @@ class PmdOutput:
     def get_port_link_speed(self, port_id):
         """
         Get the specified port link speed now.
+        Return the link speed in Mbps or an empty string if speed can't be read.
         """
-        return self.get_detail_from_port_info("Link speed: ", "\d+", port_id)
+        linkspeed = self.get_detail_from_port_info("Link speed: ", ".+", port_id)
+        s = re.compile(r"(\d+).*([MG])")
+        res = s.search(linkspeed)
+        if res:
+            if res.group(2) == "M":
+                return res.group(1)
+
+            if res.group(2) == "G":
+                return f"{res.group(1)}000"
+        return ""
 
     def get_port_link_duplex(self, port_id):
         """
diff --git a/tests/TestSuite_pmd_bonded.py b/tests/TestSuite_pmd_bonded.py
index f957d4e75077..931f74c77d5a 100644
--- a/tests/TestSuite_pmd_bonded.py
+++ b/tests/TestSuite_pmd_bonded.py
@@ -364,8 +364,18 @@ UDP(sport=srcport, dport=destport)/Raw(load="\x50"*%s)], iface="%s", count=%d)'
     def get_port_link_speed(self, port_id):
         """
         Get the specified port link speed now.
+        Return the link speed in Mbps or an empty string if speed can't be read.
         """
-        return self.get_detail_from_port_info("Link speed: ", "\d+", port_id)
+        linkspeed = self.get_detail_from_port_info("Link speed: ", ".+", port_id)
+        s = re.compile(r"(\d+).*([MG])")
+        res = s.search(linkspeed)
+        if res:
+            if res.group(2) == "M":
+                return res.group(1)
+
+            if res.group(2) == "G":
+                return f"{res.group(1)}000"
+        return ""
 
     def get_port_link_duplex(self, port_id):
         """
diff --git a/tests/TestSuite_vf_pmd_bonded.py b/tests/TestSuite_vf_pmd_bonded.py
index 8cc45380283a..ae74822ea259 100644
--- a/tests/TestSuite_vf_pmd_bonded.py
+++ b/tests/TestSuite_vf_pmd_bonded.py
@@ -335,8 +335,18 @@ UDP(sport=srcport, dport=destport)/Raw(load="\x50"*%s)], iface="%s", count=%d, v
     def get_port_link_speed(self, port_id):
         """
         Get the specified port link speed now.
+        Return the link speed in Mbps or an empty string if speed can't be read.
         """
-        return self.get_detail_from_port_info("Link speed: ", "\d+", port_id)
+        linkspeed = self.get_detail_from_port_info("Link speed: ", ".+", port_id)
+        s = re.compile(r"(\d+).*([MG])")
+        res = s.search(linkspeed)
+        if res:
+            if res.group(2) == "M":
+                return res.group(1)
+
+            if res.group(2) == "G":
+                return f"{res.group(1)}000"
+        return ""
 
     def get_port_link_duplex(self, port_id):
         """
-- 
2.41.0


  reply	other threads:[~2023-07-03 19:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-03 19:25 [PATCH 0/2] tests/speed_capabilities: Document and convert to a common speed unit Niklas Söderlund
2023-07-03 19:25 ` Niklas Söderlund [this message]
2023-07-03 19:25 ` [PATCH 2/2] tests/speed_capabilities: optimize code sequence of test case Niklas Söderlund

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=20230703192542.36809-2-niklas.soderlund@corigine.com \
    --to=niklas.soderlund@corigine.com \
    --cc=dts@dpdk.org \
    --cc=oss-drivers@corigine.com \
    --cc=qin.ke@corigine.com \
    /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).