2 # SPDX-License-Identifier: GPL-2.0
16 lib_dir
=$
(dirname $0)/..
/..
/..
/net
/forwarding
19 source $lib_dir/lib.sh
20 source $lib_dir/devlink_lib.sh
32 __mlnx_qos
-i $swp |
sed -n '/^PFC/,/^[^[:space:]]/p' |
33 grep buffer |
sed 's/ \+/ /g' | cut
-d' ' -f 2-
38 __mlnx_qos
-i $swp |
sed -n '/^PFC/,/^[^[:space:]]/p' |
39 grep enabled |
sed 's/ \+/ /g' | cut
-d' ' -f 2-
44 __mlnx_qos
-i $swp |
sed -n '/^tc/,$p' |
45 awk '/^tc/ { TC = $2 }
46 /priority:/ { PRIO[$2]=TC }
49 printf("%d ", PRIO[i])
57 __mlnx_qos
-i $swp |
grep Receive |
sed 's/.*: //' | cut
-d, -f $
((idx
+ 1))
62 __mlnx_qos
-i $swp |
grep Receive |
sed 's/.*total_size=//'
67 local expect
=$1; shift
69 local current
=$
(get_prio_pg
)
70 test "$current" = "$expect"
71 check_err $?
"prio2buffer is '$current', expected '$expect'"
76 local expect
=$1; shift
78 local current
=$
(get_prio_pfc
)
79 test "$current" = "$expect"
80 check_err $?
"prio PFC is '$current', expected '$expect'"
85 local expect
=$1; shift
87 local current
=$
(get_prio_tc
)
88 test "$current" = "$expect"
89 check_err $?
"prio_tc is '$current', expected '$expect'"
98 local current
=$
(get_buf_size
$idx)
100 check_err $?
"${what}buffer $idx size is '$current', expected '$expr'"
106 __check_buf_size
"$@" > /dev
/null
113 check_prio_pg
"0 0 0 0 0 0 0 0 "
114 check_prio_tc
"0 0 0 0 0 0 0 0 "
115 check_prio_pfc
"0 0 0 0 0 0 0 0 "
117 log_test
"Default headroom configuration"
124 __mlnx_qos
-i $swp --prio_tc=0,2,4,6,1,3,5,7 > /dev
/null
126 check_prio_pg
"0 2 4 6 1 3 5 7 "
127 check_prio_tc
"0 2 4 6 1 3 5 7 "
128 check_prio_pfc
"0 0 0 0 0 0 0 0 "
130 __mlnx_qos
-i $swp --prio_tc=0,0,0,0,0,0,0,0 > /dev
/null
132 check_prio_pg
"0 0 0 0 0 0 0 0 "
133 check_prio_tc
"0 0 0 0 0 0 0 0 "
135 __mlnx_qos
-i $swp --prio2buffer=1,3,5,7,0,2,4,6 &> /dev
/null
136 check_fail $?
"prio2buffer accepted in DCB mode"
138 log_test
"Configuring headroom through ETS"
148 buf0size
=$
(__check_buf_size
0 "> 0")
151 buf0size_2
=$
(__check_buf_size
0 "> $buf0size" "MTU 3000: ")
155 check_buf_size
0 "> $buf0size_2" "MTU 6000: "
158 check_buf_size
0 "== $buf0size"
160 log_test
"${what}MTU impacts buffer size"
165 # In TC mode, MTU still impacts the threshold below which a buffer is
166 # not permitted to go.
168 tc qdisc replace dev
$swp root handle
1: bfifo limit
1.5M
170 tc qdisc delete dev
$swp root
177 __mlnx_qos
-i $swp --prio_tc=0,0,0,0,0,1,2,3 > /dev
/null
179 local buf0size
=$
(get_buf_size
0)
180 local buf1size
=$
(get_buf_size
1)
181 local buf2size
=$
(get_buf_size
2)
182 local buf3size
=$
(get_buf_size
3)
183 check_buf_size
0 "> 0"
184 check_buf_size
1 "> 0"
185 check_buf_size
2 "> 0"
186 check_buf_size
3 "> 0"
187 check_buf_size
4 "== 0"
188 check_buf_size
5 "== 0"
189 check_buf_size
6 "== 0"
190 check_buf_size
7 "== 0"
192 log_test
"Buffer size sans PFC"
196 __mlnx_qos
-i $swp --pfc=0,0,0,0,0,1,1,1 --cable_len=0 > /dev
/null
198 check_prio_pg
"0 0 0 0 0 1 2 3 "
199 check_prio_pfc
"0 0 0 0 0 1 1 1 "
200 check_buf_size
0 "== $buf0size"
201 check_buf_size
1 "> $buf1size"
202 check_buf_size
2 "> $buf2size"
203 check_buf_size
3 "> $buf3size"
205 local buf1size
=$
(get_buf_size
1)
206 check_buf_size
2 "== $buf1size"
207 check_buf_size
3 "== $buf1size"
209 log_test
"PFC: Cable length 0"
213 __mlnx_qos
-i $swp --pfc=0,0,0,0,0,1,1,1 --cable_len=1000 > /dev
/null
215 check_buf_size
0 "== $buf0size"
216 check_buf_size
1 "> $buf1size"
217 check_buf_size
2 "> $buf1size"
218 check_buf_size
3 "> $buf1size"
220 log_test
"PFC: Cable length 1000"
224 __mlnx_qos
-i $swp --pfc=0,0,0,0,0,0,0,0 --cable_len=0 > /dev
/null
225 __mlnx_qos
-i $swp --prio_tc=0,0,0,0,0,0,0,0 > /dev
/null
227 check_prio_pg
"0 0 0 0 0 0 0 0 "
228 check_prio_tc
"0 0 0 0 0 0 0 0 "
229 check_buf_size
0 "> 0"
230 check_buf_size
1 "== 0"
231 check_buf_size
2 "== 0"
232 check_buf_size
3 "== 0"
233 check_buf_size
4 "== 0"
234 check_buf_size
5 "== 0"
235 check_buf_size
6 "== 0"
236 check_buf_size
7 "== 0"
238 log_test
"PFC: Restore defaults"
245 __mlnx_qos
-i $swp --prio_tc=0,1,2,3,4,5,6,7 > /dev
/null
246 check_prio_pg
"0 1 2 3 4 5 6 7 "
248 tc qdisc replace dev
$swp root handle
1: bfifo limit
1.5M
249 check_prio_pg
"0 0 0 0 0 0 0 0 "
251 __mlnx_qos
-i $swp --prio2buffer=1,3,5,7,0,2,4,6 > /dev
/null
252 check_prio_pg
"1 3 5 7 0 2 4 6 "
254 tc qdisc delete dev
$swp root
255 check_prio_pg
"0 1 2 3 4 5 6 7 "
258 tc qdisc replace dev
$swp root handle
1: bfifo limit
1.5M
259 __mlnx_qos
-i $swp --prio2buffer=0,0,0,0,0,0,0,0 > /dev
/null
260 tc qdisc delete dev
$swp root
261 __mlnx_qos
-i $swp --prio_tc=0,0,0,0,0,0,0,0 > /dev
/null
263 log_test
"TC: priomap"
268 local cell_size
=$
(devlink_cell_size_get
)
269 local size
=$
((cell_size
* 1000))
273 __mlnx_qos
-i $swp --buffer_size=$size,0,0,0,0,0,0,0 &> /dev
/null
274 check_fail $?
"buffer_size should fail before qdisc is added"
276 tc qdisc replace dev
$swp root handle
1: bfifo limit
1.5M
278 __mlnx_qos
-i $swp --buffer_size=$size,0,0,0,0,0,0,0 > /dev
/null
279 check_err $?
"buffer_size should pass after qdisc is added"
280 check_buf_size
0 "== $size" "set size: "
283 check_buf_size
0 "== $size" "set MTU: "
286 __mlnx_qos
-i $swp --buffer_size=0,0,0,0,0,0,0,0 > /dev
/null
288 # After replacing the qdisc for the same kind, buffer_size still has to
290 tc qdisc replace dev
$swp root handle
1: bfifo limit
1M
292 __mlnx_qos
-i $swp --buffer_size=$size,0,0,0,0,0,0,0 > /dev
/null
293 check_buf_size
0 "== $size" "post replace, set size: "
295 __mlnx_qos
-i $swp --buffer_size=0,0,0,0,0,0,0,0 > /dev
/null
297 # Likewise after replacing for a different kind.
298 tc qdisc replace dev
$swp root handle
2: prio bands
8
300 __mlnx_qos
-i $swp --buffer_size=$size,0,0,0,0,0,0,0 > /dev
/null
301 check_buf_size
0 "== $size" "post replace different kind, set size: "
303 tc qdisc delete dev
$swp root
305 __mlnx_qos
-i $swp --buffer_size=$size,0,0,0,0,0,0,0 &> /dev
/null
306 check_fail $?
"buffer_size should fail after qdisc is deleted"
308 log_test
"TC: buffer size"
317 local buf0size
=$
(get_buf_size
0)
318 local tot_size
=$
(get_tot_size
)
320 # Size of internal buffer and buffer 9.
321 local dsize
=$
((tot_size
- buf0size
))
323 tc qdisc add dev
$swp clsact
324 tc filter add dev
$swp egress matchall skip_sw action mirred egress mirror dev
$swp
326 local buf0size_2
=$
(get_buf_size
0)
327 local tot_size_2
=$
(get_tot_size
)
328 local dsize_2
=$
((tot_size_2
- buf0size_2
))
330 # Egress SPAN should have added to the "invisible" buffer configuration.
332 check_err $?
"Invisible buffers account for '$dsize_2', expected '> $dsize'"
336 local buf0size_3
=$
(get_buf_size
0)
337 local tot_size_3
=$
(get_tot_size
)
338 local dsize_3
=$
((tot_size_3
- buf0size_3
))
340 # MTU change might change buffer 0, which will show at total, but the
341 # hidden buffers should stay the same size.
342 ((dsize_3
== dsize_2
))
343 check_err $?
"MTU change: Invisible buffers account for '$dsize_3', expected '== $dsize_2'"
346 tc qdisc del dev
$swp clsact
348 # After SPAN removal, hidden buffers should be back to the original sizes.
349 local buf0size_4
=$
(get_buf_size
0)
350 local tot_size_4
=$
(get_tot_size
)
351 local dsize_4
=$
((tot_size_4
- buf0size_4
))
353 check_err $?
"SPAN removed: Invisible buffers account for '$dsize_4', expected '== $dsize'"
355 log_test
"${what}internal buffer size"
360 local cell_size
=$
(devlink_cell_size_get
)
361 local size
=$
((cell_size
* 1000))
363 tc qdisc replace dev
$swp root handle
1: bfifo limit
1.5M
366 __mlnx_qos
-i $swp --buffer_size=$size,0,0,0,0,0,0,0 > /dev
/null
367 test_int_buf
"TC+buffsize: "
369 __mlnx_qos
-i $swp --buffer_size=0,0,0,0,0,0,0,0 > /dev
/null
370 tc qdisc delete dev
$swp root