1 # SPDX-License-Identifier: GPL-2.0
4 # $put -- port under test (e.g. $swp2)
5 # collect_stats($streams...) -- A function to get stats for individual streams
6 # ets_start_traffic($band) -- Start traffic for this band
7 # ets_change_qdisc($op, $dev, $nstrict, $quanta...) -- Add or change qdisc
9 # WS describes the Qdisc configuration. It has one value per band (so the
10 # number of array elements indicates the number of bands). If the value is
11 # 0, it is a strict band, otherwise the it's a DRR band and the value is
12 # that band's quantum.
17 local nbands=${#WS[@]}
21 for ((i = 0; i < nbands; i++)); do
22 if ((!${WS[$i]})); then
27 echo -n "ets bands $nbands"
29 echo -n " strict $nstrict"
31 if ((nstrict < nbands)); then
33 for ((i = nstrict; i < nbands; i++)); do
49 check_err 1 "No traffic observed"
54 local ratio=$(echo "scale=2; 100 * $d / $total" | bc -l)
56 test $(echo "$ratio > 95.0" | bc -l) -eq 1
57 check_err $? "Not enough traffic"
59 log_info "Expected ratio >95% Measured ratio $ratio"
61 test $(echo "$ratio < 5" | bc -l) -eq 1
62 check_err $? "Too much traffic"
64 log_info "Expected ratio <5% Measured ratio $ratio"
80 local -a streams=("$@")
82 local low_stream=${streams[0]}
89 echo "Testing $(qdisc_describe), streams ${streams[@]}"
91 for stream in ${streams[@]}; do
92 ets_start_traffic $stream
97 t0=($(collect_stats "${streams[@]}"))
101 t1=($(collect_stats "${streams[@]}"))
102 d=($(for ((i = 0; i < ${#streams[@]}; i++)); do
103 echo $((${t1[$i]} - ${t0[$i]}))
105 total=$(echo ${d[@]} | sed 's/ /+/g' | bc)
107 for ((i = 0; i < ${#streams[@]}; i++)); do
108 local stream=${streams[$i]}
109 if ((seen_strict)); then
110 notraf_eval "band $stream" ${d[$i]} $total
111 elif ((${WS[$stream]} == 0)); then
112 strict_eval "band $stream" ${d[$i]} $total
114 elif ((stream == low_stream)); then
115 # Low stream is used as DWRR evaluation reference.
118 multipath_eval "bands $low_stream:$stream" \
119 ${WS[$low_stream]} ${WS[$stream]} \
124 for stream in ${streams[@]}; do
131 __ets_dwrr_test 0 1 2
147 local nstrict=$1; shift
148 local -a quanta=("$@")
150 local ndwrr=${#quanta[@]}
151 local nbands=$((nstrict + ndwrr))
152 local nstreams=$(if ((nbands > 3)); then echo 3; else echo $nbands; fi)
153 local priomap=$(seq 0 $((nstreams - 1)))
157 for ((i = 0; i < nstrict; i++)); do
160 for ((i = 0; i < ndwrr; i++)); do
165 ets_change_qdisc $dev $nstrict "$priomap" ${quanta[@]}
168 ets_set_dwrr_uniform()
170 ets_qdisc_setup $put 0 3300 3300 3300
173 ets_set_dwrr_varying()
175 ets_qdisc_setup $put 0 5000 3500 1500
180 ets_qdisc_setup $put 3
185 ets_qdisc_setup $put 1 5000 2500 1500
190 tc class change dev $put classid 10:2 ets quantum 8000
194 ets_set_dwrr_two_bands()
196 ets_qdisc_setup $put 0 5000 2500
202 xfail_on_slow ets_dwrr_test_01
203 xfail_on_slow ets_dwrr_test_12
209 xfail_on_slow ets_dwrr_test_01
210 xfail_on_slow ets_dwrr_test_12
216 xfail_on_slow ets_dwrr_test_012
219 xfail_on_slow ets_dwrr_test_012
222 xfail_on_slow ets_dwrr_test_012
224 ets_set_dwrr_two_bands
225 xfail_on_slow ets_dwrr_test_01