From: Ido Schimmel <idosch@idosch.org>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, jiri@mellanox.com, jhs@mojatatu.com,
xiyou.wangcong@gmail.com, petrm@mellanox.com, mlxsw@mellanox.com,
Ido Schimmel <idosch@mellanox.com>
Subject: [PATCH net-next 11/14] selftests: Move two functions from mlxsw's qos_lib to lib
Date: Fri, 24 Jan 2020 15:23:15 +0200 [thread overview]
Message-ID: <20200124132318.712354-12-idosch@idosch.org> (raw)
In-Reply-To: <20200124132318.712354-1-idosch@idosch.org>
From: Petr Machata <petrm@mellanox.com>
The function humanize() is used for converting value in bits/s to a
human-friendly approximate value in Kbps, Mbps or Gbps. There is nothing
hardware-specific in that, so move the function to lib.sh.
Similarly for the rate() function, which just does a bit of math to
calculate a rate, given two counter values and a time interval.
Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
.../selftests/drivers/net/mlxsw/qos_lib.sh | 24 -------------------
tools/testing/selftests/net/forwarding/lib.sh | 24 +++++++++++++++++++
2 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/tools/testing/selftests/drivers/net/mlxsw/qos_lib.sh b/tools/testing/selftests/drivers/net/mlxsw/qos_lib.sh
index a5937069ac16..faa51012cdac 100644
--- a/tools/testing/selftests/drivers/net/mlxsw/qos_lib.sh
+++ b/tools/testing/selftests/drivers/net/mlxsw/qos_lib.sh
@@ -1,29 +1,5 @@
# SPDX-License-Identifier: GPL-2.0
-humanize()
-{
- local speed=$1; shift
-
- for unit in bps Kbps Mbps Gbps; do
- if (($(echo "$speed < 1024" | bc))); then
- break
- fi
-
- speed=$(echo "scale=1; $speed / 1024" | bc)
- done
-
- echo "$speed${unit}"
-}
-
-rate()
-{
- local t0=$1; shift
- local t1=$1; shift
- local interval=$1; shift
-
- echo $((8 * (t1 - t0) / interval))
-}
-
check_rate()
{
local rate=$1; shift
diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index 8dc5fac98cbc..10cdfc0adca8 100644
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -588,6 +588,30 @@ ethtool_stats_get()
ethtool -S $dev | grep "^ *$stat:" | head -n 1 | cut -d: -f2
}
+humanize()
+{
+ local speed=$1; shift
+
+ for unit in bps Kbps Mbps Gbps; do
+ if (($(echo "$speed < 1024" | bc))); then
+ break
+ fi
+
+ speed=$(echo "scale=1; $speed / 1024" | bc)
+ done
+
+ echo "$speed${unit}"
+}
+
+rate()
+{
+ local t0=$1; shift
+ local t1=$1; shift
+ local interval=$1; shift
+
+ echo $((8 * (t1 - t0) / interval))
+}
+
mac_get()
{
local if_name=$1
--
2.24.1
next prev parent reply other threads:[~2020-01-24 13:24 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-24 13:23 [PATCH net-next 00/14] mlxsw: Offload TBF Ido Schimmel
2020-01-24 13:23 ` [PATCH net-next 01/14] net: sched: sch_tbf: Don't overwrite backlog before dumping Ido Schimmel
2020-01-24 13:23 ` [PATCH net-next 02/14] net: sched: Make TBF Qdisc offloadable Ido Schimmel
2020-01-24 13:23 ` [PATCH net-next 03/14] mlxsw: spectrum_qdisc: Extract a per-TC stat function Ido Schimmel
2020-01-24 14:03 ` Jiri Pirko
2020-01-24 13:23 ` [PATCH net-next 04/14] mlxsw: spectrum_qdisc: Add mlxsw_sp_qdisc_get_class_stats() Ido Schimmel
2020-01-24 14:26 ` Jiri Pirko
2020-01-24 13:23 ` [PATCH net-next 05/14] mlxsw: spectrum_qdisc: Extract a common leaf unoffload function Ido Schimmel
2020-01-24 15:04 ` Jiri Pirko
2020-01-24 13:23 ` [PATCH net-next 06/14] mlxsw: reg: Add max_shaper_bs to QoS ETS Element Configuration Ido Schimmel
2020-01-24 15:04 ` Jiri Pirko
2020-01-24 13:23 ` [PATCH net-next 07/14] mlxsw: reg: Increase MLXSW_REG_QEEC_MAS_DIS Ido Schimmel
2020-01-24 15:05 ` Jiri Pirko
2020-01-24 13:23 ` [PATCH net-next 08/14] mlxsw: spectrum: Add lowest_shaper_bs to struct mlxsw_sp Ido Schimmel
2020-01-24 15:06 ` Jiri Pirko
2020-01-24 13:23 ` [PATCH net-next 09/14] mlxsw: spectrum: Configure shaper rate and burst size together Ido Schimmel
2020-01-24 15:07 ` Jiri Pirko
2020-01-24 13:23 ` [PATCH net-next 10/14] mlxsw: spectrum_qdisc: Support offloading of TBF Qdisc Ido Schimmel
2020-01-24 15:27 ` Jiri Pirko
2020-01-24 13:23 ` Ido Schimmel [this message]
2020-01-24 13:23 ` [PATCH net-next 12/14] selftests: forwarding: lib: Add helpers for busywaiting Ido Schimmel
2020-01-24 13:23 ` [PATCH net-next 13/14] selftests: forwarding: lib: Allow reading TC rule byte counters Ido Schimmel
2020-01-24 13:23 ` [PATCH net-next 14/14] selftests: mlxsw: Add a TBF selftest Ido Schimmel
2020-01-25 12:09 ` [PATCH net-next 00/14] mlxsw: Offload TBF David Miller
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=20200124132318.712354-12-idosch@idosch.org \
--to=idosch@idosch.org \
--cc=davem@davemloft.net \
--cc=idosch@mellanox.com \
--cc=jhs@mojatatu.com \
--cc=jiri@mellanox.com \
--cc=mlxsw@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=petrm@mellanox.com \
--cc=xiyou.wangcong@gmail.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