aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/testing/selftests/drivers
diff options
context:
space:
mode:
authorPetr Machata <petrm@mellanox.com>2020-01-24 15:23:15 +0200
committerDavid S. Miller <davem@davemloft.net>2020-01-25 10:56:31 +0100
commitadc6c7ec11293117ec2763ccbe17d58349e011cf (patch)
treebf4af539ef122aa6662bfcb028367b0d4952c238 /tools/testing/selftests/drivers
parentmlxsw: spectrum_qdisc: Support offloading of TBF Qdisc (diff)
downloadwireguard-linux-adc6c7ec11293117ec2763ccbe17d58349e011cf.tar.xz
wireguard-linux-adc6c7ec11293117ec2763ccbe17d58349e011cf.zip
selftests: Move two functions from mlxsw's qos_lib to lib
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> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/testing/selftests/drivers')
-rw-r--r--tools/testing/selftests/drivers/net/mlxsw/qos_lib.sh24
1 files changed, 0 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