Path: blob/master/tools/testing/selftests/drivers/net/mlxsw/qos_lib.sh
26292 views
# SPDX-License-Identifier: GPL-2.012check_rate()3{4local rate=$1; shift5local min=$1; shift6local what=$1; shift78if ((rate > min)); then9return 010fi1112echo "$what $(humanize $ir) < $(humanize $min)" > /dev/stderr13return 114}1516measure_rate()17{18local sw_in=$1; shift # Where the traffic ingresses the switch19local host_in=$1; shift # Where it ingresses another host20local counter=$1; shift # Counter to use for measurement21local what=$1; shift2223local interval=1024local i25local ret=02627# Dips in performance might cause momentary ingress rate to drop below28# 1Gbps. That wouldn't saturate egress and MC would thus get through,29# seemingly winning bandwidth on account of UC. Demand at least 2Gbps30# average ingress rate to somewhat mitigate this.31local min_ingress=21474836483233for i in {5..0}; do34local t0=$(ethtool_stats_get $host_in $counter)35local u0=$(ethtool_stats_get $sw_in $counter)36sleep $interval37local t1=$(ethtool_stats_get $host_in $counter)38local u1=$(ethtool_stats_get $sw_in $counter)3940local ir=$(rate $u0 $u1 $interval)41local er=$(rate $t0 $t1 $interval)4243if check_rate $ir $min_ingress "$what ingress rate"; then44break45fi4647# Fail the test if we can't get the throughput.48if ((i == 0)); then49ret=150fi51done5253echo $ir $er54return $ret55}565758