~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/net/forwarding/sch_ets_tests.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 # SPDX-License-Identifier: GPL-2.0
  2 
  3 # Global interface:
  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
  8 
  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.
 13 declare -a WS
 14 
 15 qdisc_describe()
 16 {
 17         local nbands=${#WS[@]}
 18         local nstrict=0
 19         local i
 20 
 21         for ((i = 0; i < nbands; i++)); do
 22                 if ((!${WS[$i]})); then
 23                         : $((nstrict++))
 24                 fi
 25         done
 26 
 27         echo -n "ets bands $nbands"
 28         if ((nstrict)); then
 29                 echo -n " strict $nstrict"
 30         fi
 31         if ((nstrict < nbands)); then
 32                 echo -n " quanta"
 33                 for ((i = nstrict; i < nbands; i++)); do
 34                         echo -n " ${WS[$i]}"
 35                 done
 36         fi
 37 }
 38 
 39 __strict_eval()
 40 {
 41         local desc=$1; shift
 42         local d=$1; shift
 43         local total=$1; shift
 44         local above=$1; shift
 45 
 46         RET=0
 47 
 48         if ((! total)); then
 49                 check_err 1 "No traffic observed"
 50                 log_test "$desc"
 51                 return
 52         fi
 53 
 54         local ratio=$(echo "scale=2; 100 * $d / $total" | bc -l)
 55         if ((above)); then
 56                 test $(echo "$ratio > 95.0" | bc -l) -eq 1
 57                 check_err $? "Not enough traffic"
 58                 log_test "$desc"
 59                 log_info "Expected ratio >95% Measured ratio $ratio"
 60         else
 61                 test $(echo "$ratio < 5" | bc -l) -eq 1
 62                 check_err $? "Too much traffic"
 63                 log_test "$desc"
 64                 log_info "Expected ratio <5% Measured ratio $ratio"
 65         fi
 66 }
 67 
 68 strict_eval()
 69 {
 70         __strict_eval "$@" 1
 71 }
 72 
 73 notraf_eval()
 74 {
 75         __strict_eval "$@" 0
 76 }
 77 
 78 __ets_dwrr_test()
 79 {
 80         local -a streams=("$@")
 81 
 82         local low_stream=${streams[0]}
 83         local seen_strict=0
 84         local -a t0 t1 d
 85         local stream
 86         local total
 87         local i
 88 
 89         echo "Testing $(qdisc_describe), streams ${streams[@]}"
 90 
 91         for stream in ${streams[@]}; do
 92                 ets_start_traffic $stream
 93         done
 94 
 95         sleep 10
 96 
 97         t0=($(collect_stats "${streams[@]}"))
 98 
 99         sleep 10
100 
101         t1=($(collect_stats "${streams[@]}"))
102         d=($(for ((i = 0; i < ${#streams[@]}; i++)); do
103                  echo $((${t1[$i]} - ${t0[$i]}))
104              done))
105         total=$(echo ${d[@]} | sed 's/ /+/g' | bc)
106 
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
113                         seen_strict=1
114                 elif ((stream == low_stream)); then
115                         # Low stream is used as DWRR evaluation reference.
116                         continue
117                 else
118                         multipath_eval "bands $low_stream:$stream" \
119                                        ${WS[$low_stream]} ${WS[$stream]} \
120                                        ${d[0]} ${d[$i]}
121                 fi
122         done
123 
124         for stream in ${streams[@]}; do
125                 stop_traffic
126         done
127 }
128 
129 ets_dwrr_test_012()
130 {
131         __ets_dwrr_test 0 1 2
132 }
133 
134 ets_dwrr_test_01()
135 {
136         __ets_dwrr_test 0 1
137 }
138 
139 ets_dwrr_test_12()
140 {
141         __ets_dwrr_test 1 2
142 }
143 
144 ets_qdisc_setup()
145 {
146         local dev=$1; shift
147         local nstrict=$1; shift
148         local -a quanta=("$@")
149 
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)))
154         local i
155 
156         WS=($(
157                 for ((i = 0; i < nstrict; i++)); do
158                         echo 0
159                 done
160                 for ((i = 0; i < ndwrr; i++)); do
161                         echo ${quanta[$i]}
162                 done
163         ))
164 
165         ets_change_qdisc $dev $nstrict "$priomap" ${quanta[@]}
166 }
167 
168 ets_set_dwrr_uniform()
169 {
170         ets_qdisc_setup $put 0 3300 3300 3300
171 }
172 
173 ets_set_dwrr_varying()
174 {
175         ets_qdisc_setup $put 0 5000 3500 1500
176 }
177 
178 ets_set_strict()
179 {
180         ets_qdisc_setup $put 3
181 }
182 
183 ets_set_mixed()
184 {
185         ets_qdisc_setup $put 1 5000 2500 1500
186 }
187 
188 ets_change_quantum()
189 {
190         tc class change dev $put classid 10:2 ets quantum 8000
191         WS[1]=8000
192 }
193 
194 ets_set_dwrr_two_bands()
195 {
196         ets_qdisc_setup $put 0 5000 2500
197 }
198 
199 ets_test_strict()
200 {
201         ets_set_strict
202         xfail_on_slow ets_dwrr_test_01
203         xfail_on_slow ets_dwrr_test_12
204 }
205 
206 ets_test_mixed()
207 {
208         ets_set_mixed
209         xfail_on_slow ets_dwrr_test_01
210         xfail_on_slow ets_dwrr_test_12
211 }
212 
213 ets_test_dwrr()
214 {
215         ets_set_dwrr_uniform
216         xfail_on_slow ets_dwrr_test_012
217 
218         ets_set_dwrr_varying
219         xfail_on_slow ets_dwrr_test_012
220 
221         ets_change_quantum
222         xfail_on_slow ets_dwrr_test_012
223 
224         ets_set_dwrr_two_bands
225         xfail_on_slow ets_dwrr_test_01
226 }

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php