xref: /linux/tools/testing/selftests/drivers/net/mlxsw/sch_red_core.sh (revision c34e9ab9a612ee8b18273398ef75c207b01f516d)
1# SPDX-License-Identifier: GPL-2.0
2
3# This test sends a >1Gbps stream of traffic from H1, to the switch, which
4# forwards it to a 1Gbps port. This 1Gbps stream is then looped back to the
5# switch and forwarded to the port under test $swp3, which is also 1Gbps.
6#
7# This way, $swp3 should be 100% filled with traffic without any of it spilling
8# to the backlog. Any extra packets sent should almost 1:1 go to backlog. That
9# is what H2 is used for--it sends the extra traffic to create backlog.
10#
11# A RED Qdisc is installed on $swp3. The configuration is such that the minimum
12# and maximum size are 1 byte apart, so there is a very clear border under which
13# no marking or dropping takes place, and above which everything is marked or
14# dropped.
15#
16# The test uses the buffer build-up behavior to test the installed RED.
17#
18# In order to test WRED, $swp3 actually contains RED under PRIO, with two
19# different configurations. Traffic is prioritized using 802.1p and relies on
20# the implicit mlxsw configuration, where packet priority is taken 1:1 from the
21# 802.1p marking.
22#
23# +--------------------------+                     +--------------------------+
24# | H1                       |                     | H2                       |
25# |     + $h1.10             |                     |     + $h2.10             |
26# |     | 192.0.2.1/28       |                     |     | 192.0.2.2/28       |
27# |     |                    |                     |     |                    |
28# |     |         $h1.11 +   |                     |     |         $h2.11 +   |
29# |     |  192.0.2.17/28 |   |                     |     |  192.0.2.18/28 |   |
30# |     |                |   |                     |     |                |   |
31# |     \______    ______/   |                     |     \______    ______/   |
32# |            \ /           |                     |            \ /           |
33# |             + $h1        |                     |             + $h2        |
34# +-------------|------------+                     +-------------|------------+
35#               | >1Gbps                                         |
36# +-------------|------------------------------------------------|------------+
37# | SW          + $swp1                                          + $swp2      |
38# |     _______/ \___________                        ___________/ \_______    |
39# |    /                     \                      /                     \   |
40# |  +-|-----------------+   |                    +-|-----------------+   |   |
41# |  | + $swp1.10        |   |                    | + $swp2.10        |   |   |
42# |  |                   |   |        .-------------+ $swp5.10        |   |   |
43# |  |     BR1_10        |   |        |           |                   |   |   |
44# |  |                   |   |        |           |     BR2_10        |   |   |
45# |  | + $swp2.10        |   |        |           |                   |   |   |
46# |  +-|-----------------+   |        |           | + $swp3.10        |   |   |
47# |    |                     |        |           +-|-----------------+   |   |
48# |    |   +-----------------|-+      |             |   +-----------------|-+ |
49# |    |   |        $swp1.11 + |      |             |   |        $swp2.11 + | |
50# |    |   |                   |      | .-----------------+ $swp5.11        | |
51# |    |   |      BR1_11       |      | |           |   |                   | |
52# |    |   |                   |      | |           |   |      BR2_11       | |
53# |    |   |        $swp2.11 + |      | |           |   |                   | |
54# |    |   +-----------------|-+      | |           |   |        $swp3.11 + | |
55# |    |                     |        | |           |   +-----------------|-+ |
56# |    \_______   ___________/        | |           \___________   _______/   |
57# |            \ /                    \ /                       \ /           |
58# |             + $swp4                + $swp5                   + $swp3      |
59# +-------------|----------------------|-------------------------|------------+
60#               |                      |                         | 1Gbps
61#               \________1Gbps_________/                         |
62#                                   +----------------------------|------------+
63#                                   | H3                         + $h3        |
64#                                   |      _____________________/ \_______    |
65#                                   |     /                               \   |
66#                                   |     |                               |   |
67#                                   |     + $h3.10                 $h3.11 +   |
68#                                   |       192.0.2.3/28    192.0.2.19/28     |
69#                                   +-----------------------------------------+
70
71NUM_NETIFS=8
72CHECK_TC="yes"
73lib_dir=$(dirname $0)/../../../net/forwarding
74source $lib_dir/lib.sh
75source $lib_dir/devlink_lib.sh
76source mlxsw_lib.sh
77
78stop_traffic_sleep()
79{
80	local pid=$1; shift
81
82	# Issuing a kill still leaves a bunch of packets lingering in the
83	# buffers. This traffic then arrives at the point where a follow-up test
84	# is already running, and can confuse the test. Therefore sleep after
85	# stopping traffic to flush any leftover packets.
86	stop_traffic "$pid"
87	sleep 1
88}
89
90ipaddr()
91{
92	local host=$1; shift
93	local vlan=$1; shift
94
95	echo 192.0.2.$((16 * (vlan - 10) + host))
96}
97
98host_create()
99{
100	local dev=$1; shift
101	local host=$1; shift
102
103	simple_if_init $dev
104	defer simple_if_fini $dev
105
106	mtu_set $dev 10000
107	defer mtu_restore $dev
108
109	vlan_create $dev 10 v$dev $(ipaddr $host 10)/28
110	defer vlan_destroy $dev 10
111	ip link set dev $dev.10 type vlan egress 0:0
112
113	vlan_create $dev 11 v$dev $(ipaddr $host 11)/28
114	defer vlan_destroy $dev 11
115	ip link set dev $dev.11 type vlan egress 0:1
116}
117
118h1_create()
119{
120	host_create $h1 1
121}
122
123h2_create()
124{
125	host_create $h2 2
126
127	tc qdisc add dev $h2 clsact
128	defer tc qdisc del dev $h2 clsact
129
130	# Some of the tests in this suite use multicast traffic. As this traffic
131	# enters BR2_10 resp. BR2_11, it is flooded to all other ports. Thus
132	# e.g. traffic ingressing through $swp2 is flooded to $swp3 (the
133	# intended destination) and $swp5 (which is intended as ingress for
134	# another stream of traffic).
135	#
136	# This is generally not a problem, but if the $swp5 throughput is lower
137	# than $swp2 throughput, there will be a build-up at $swp5. That may
138	# cause packets to fail to queue up at $swp3 due to shared buffer
139	# quotas, and the test to spuriously fail.
140	#
141	# Prevent this by adding a shaper which limits the traffic in $h2 to
142	# 1Gbps.
143
144	tc qdisc replace dev $h2 root handle 10: tbf rate 200mbit \
145		burst 128K limit 1G
146	defer tc qdisc del dev $h2 root handle 10:
147}
148
149h3_create()
150{
151	host_create $h3 3
152}
153
154switch_create()
155{
156	local intf
157	local vlan
158
159	ip link add dev br1_10 type bridge
160	defer ip link del dev br1_10
161
162	ip link add dev br1_11 type bridge
163	defer ip link del dev br1_11
164
165	ip link add dev br2_10 type bridge
166	defer ip link del dev br2_10
167
168	ip link add dev br2_11 type bridge
169	defer ip link del dev br2_11
170
171	for intf in $swp1 $swp2 $swp3 $swp4 $swp5; do
172		ip link set dev $intf up
173		defer ip link set dev $intf down
174
175		mtu_set $intf 10000
176		defer mtu_restore $intf
177	done
178
179	for intf in $swp1 $swp4; do
180		for vlan in 10 11; do
181			vlan_create $intf $vlan
182			defer vlan_destroy $intf $vlan
183
184			ip link set dev $intf.$vlan master br1_$vlan
185			defer ip link set dev $intf.$vlan nomaster
186
187			ip link set dev $intf.$vlan up
188			defer ip link set dev $intf.$vlan up
189		done
190	done
191
192	for intf in $swp2 $swp3 $swp5; do
193		for vlan in 10 11; do
194			vlan_create $intf $vlan
195			defer vlan_destroy $intf $vlan
196
197			ip link set dev $intf.$vlan master br2_$vlan
198			defer ip link set dev $intf.$vlan nomaster
199
200			ip link set dev $intf.$vlan up
201			defer ip link set dev $intf.$vlan up
202		done
203	done
204
205	ip link set dev $swp4.10 type vlan egress 0:0
206	ip link set dev $swp4.11 type vlan egress 0:1
207	for intf in $swp1 $swp2 $swp5; do
208		for vlan in 10 11; do
209			ip link set dev $intf.$vlan type vlan ingress 0:0 1:1
210		done
211	done
212
213	for intf in $swp3 $swp4; do
214		tc qdisc replace dev $intf root handle 1: tbf rate 200mbit \
215			burst 128K limit 1G
216		defer tc qdisc del dev $intf root handle 1:
217	done
218
219	ip link set dev br1_10 up
220	defer ip link set dev br1_10 down
221
222	ip link set dev br1_11 up
223	defer ip link set dev br1_11 down
224
225	ip link set dev br2_10 up
226	defer ip link set dev br2_10 down
227
228	ip link set dev br2_11 up
229	defer ip link set dev br2_11 down
230
231	local size=$(devlink_pool_size_thtype 0 | cut -d' ' -f 1)
232	devlink_port_pool_th_save $swp3 8
233	devlink_port_pool_th_set $swp3 8 $size
234	defer devlink_port_pool_th_restore $swp3 8
235}
236
237setup_prepare()
238{
239	h1=${NETIFS[p1]}
240	swp1=${NETIFS[p2]}
241
242	swp2=${NETIFS[p3]}
243	h2=${NETIFS[p4]}
244
245	swp3=${NETIFS[p5]}
246	h3=${NETIFS[p6]}
247
248	swp4=${NETIFS[p7]}
249	swp5=${NETIFS[p8]}
250
251	h3_mac=$(mac_get $h3)
252
253	vrf_prepare
254	defer vrf_cleanup
255
256	h1_create
257	h2_create
258	h3_create
259	switch_create
260}
261
262ping_ipv4()
263{
264	ping_test $h1.10 $(ipaddr 3 10) " from host 1, vlan 10"
265	ping_test $h1.11 $(ipaddr 3 11) " from host 1, vlan 11"
266	ping_test $h2.10 $(ipaddr 3 10) " from host 2, vlan 10"
267	ping_test $h2.11 $(ipaddr 3 11) " from host 2, vlan 11"
268}
269
270get_tc()
271{
272	local vlan=$1; shift
273
274	echo $((vlan - 10))
275}
276
277get_qdisc_handle()
278{
279	local vlan=$1; shift
280
281	local tc=$(get_tc $vlan)
282	local band=$((8 - tc))
283
284	# Handle is 107: for TC1, 108: for TC0.
285	echo "10$band:"
286}
287
288get_qdisc_backlog()
289{
290	local vlan=$1; shift
291
292	qdisc_stats_get $swp3 $(get_qdisc_handle $vlan) .backlog
293}
294
295get_mc_transmit_queue()
296{
297	local vlan=$1; shift
298
299	local tc=$(($(get_tc $vlan) + 8))
300	ethtool_stats_get $swp3 tc_transmit_queue_tc_$tc
301}
302
303get_nmarked()
304{
305	local vlan=$1; shift
306
307	ethtool_stats_get $swp3 ecn_marked
308}
309
310get_qdisc_nmarked()
311{
312	local vlan=$1; shift
313
314	busywait_for_counter 1100 +1 \
315		qdisc_stats_get $swp3 $(get_qdisc_handle $vlan) .marked
316}
317
318get_qdisc_npackets()
319{
320	local vlan=$1; shift
321
322	busywait_for_counter 1100 +1 \
323		qdisc_stats_get $swp3 $(get_qdisc_handle $vlan) .packets
324}
325
326send_packets()
327{
328	local vlan=$1; shift
329	local proto=$1; shift
330	local pkts=$1; shift
331
332	$MZ $h2.$vlan -p 8000 -a own -b $h3_mac \
333	    -A $(ipaddr 2 $vlan) -B $(ipaddr 3 $vlan) \
334	    -t $proto -q -c $pkts "$@"
335}
336
337# This sends traffic in an attempt to build a backlog of $size. Returns 0 on
338# success. After 10 failed attempts it bails out and returns 1. It dumps the
339# backlog size to stdout.
340build_backlog()
341{
342	local vlan=$1; shift
343	local size=$1; shift
344	local proto=$1; shift
345
346	local tc=$((vlan - 10))
347	local band=$((8 - tc))
348	local cur=-1
349	local i=0
350
351	while :; do
352		sleep 1
353		local cur=$(busywait 1100 until_counter_is "> $cur" \
354					    get_qdisc_backlog $vlan)
355		local diff=$((size - cur))
356		local pkts=$(((diff + 7999) / 8000))
357
358		if ((cur >= size)); then
359			echo $cur
360			return 0
361		elif ((i++ > 10)); then
362			echo $cur
363			return 1
364		fi
365
366		send_packets $vlan $proto $pkts "$@"
367	done
368}
369
370check_marking()
371{
372	local get_nmarked=$1; shift
373	local vlan=$1; shift
374	local cond=$1; shift
375
376	local npackets_0=$(get_qdisc_npackets $vlan)
377	local nmarked_0=$($get_nmarked $vlan)
378	sleep 5
379	local npackets_1=$(get_qdisc_npackets $vlan)
380	local nmarked_1=$($get_nmarked $vlan)
381
382	local nmarked_d=$((nmarked_1 - nmarked_0))
383	local npackets_d=$((npackets_1 - npackets_0))
384	local pct=$((100 * nmarked_d / npackets_d))
385
386	echo $pct
387	((pct $cond))
388}
389
390ecn_test_common()
391{
392	local name=$1; shift
393	local get_nmarked=$1; shift
394	local vlan=$1; shift
395	local limit=$1; shift
396	local backlog
397	local pct
398
399	# Build the below-the-limit backlog using UDP. We could use TCP just
400	# fine, but this way we get a proof that UDP is accepted when queue
401	# length is below the limit. The main stream is using TCP, and if the
402	# limit is misconfigured, we would see this traffic being ECN marked.
403	RET=0
404	backlog=$(build_backlog $vlan $((2 * limit / 3)) udp)
405	check_err $? "Could not build the requested backlog"
406	pct=$(check_marking "$get_nmarked" $vlan "== 0")
407	check_err $? "backlog $backlog / $limit Got $pct% marked packets, expected == 0."
408	log_test "TC $((vlan - 10)): $name backlog < limit"
409
410	# Now push TCP, because non-TCP traffic would be early-dropped after the
411	# backlog crosses the limit, and we want to make sure that the backlog
412	# is above the limit.
413	RET=0
414	backlog=$(build_backlog $vlan $((3 * limit / 2)) tcp tos=0x01)
415	check_err $? "Could not build the requested backlog"
416	pct=$(check_marking "$get_nmarked" $vlan ">= 95")
417	check_err $? "backlog $backlog / $limit Got $pct% marked packets, expected >= 95."
418	log_test "TC $((vlan - 10)): $name backlog > limit"
419}
420
421__do_ecn_test()
422{
423	local get_nmarked=$1; shift
424	local vlan=$1; shift
425	local limit=$1; shift
426	local name=${1-ECN}; shift
427
428	start_tcp_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 3 $vlan) \
429			  $h3_mac tos=0x01
430	defer stop_traffic_sleep $!
431	sleep 1
432
433	ecn_test_common "$name" "$get_nmarked" $vlan $limit
434
435	# Up there we saw that UDP gets accepted when backlog is below the
436	# limit. Now that it is above, it should all get dropped, and backlog
437	# building should fail.
438	RET=0
439	build_backlog $vlan $((2 * limit)) udp >/dev/null
440	check_fail $? "UDP traffic went into backlog instead of being early-dropped"
441	log_test "TC $((vlan - 10)): $name backlog > limit: UDP early-dropped"
442}
443
444do_ecn_test()
445{
446	local vlan=$1; shift
447	local limit=$1; shift
448
449	in_defer_scope \
450		__do_ecn_test get_nmarked "$vlan" "$limit"
451}
452
453do_ecn_test_perband()
454{
455	local vlan=$1; shift
456	local limit=$1; shift
457
458	mlxsw_only_on_spectrum 3+ || return
459	in_defer_scope \
460		__do_ecn_test get_qdisc_nmarked "$vlan" "$limit" "per-band ECN"
461}
462
463__do_ecn_nodrop_test()
464{
465	local vlan=$1; shift
466	local limit=$1; shift
467	local name="ECN nodrop"
468
469	start_tcp_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 3 $vlan) \
470			  $h3_mac tos=0x01
471	defer stop_traffic_sleep $!
472	sleep 1
473
474	ecn_test_common "$name" get_nmarked $vlan $limit
475
476	# Up there we saw that UDP gets accepted when backlog is below the
477	# limit. Now that it is above, in nodrop mode, make sure it goes to
478	# backlog as well.
479	RET=0
480	build_backlog $vlan $((2 * limit)) udp >/dev/null
481	check_err $? "UDP traffic was early-dropped instead of getting into backlog"
482	log_test "TC $((vlan - 10)): $name backlog > limit: UDP not dropped"
483}
484
485do_ecn_nodrop_test()
486{
487	in_defer_scope \
488		__do_ecn_nodrop_test "$@"
489}
490
491__do_red_test()
492{
493	local vlan=$1; shift
494	local limit=$1; shift
495	local backlog
496	local pct
497
498	# Use ECN-capable TCP to verify there's no marking even though the queue
499	# is above limit.
500	start_tcp_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 3 $vlan) \
501			  $h3_mac tos=0x01
502	defer stop_traffic_sleep $!
503
504	# Pushing below the queue limit should work.
505	RET=0
506	backlog=$(build_backlog $vlan $((2 * limit / 3)) tcp tos=0x01)
507	check_err $? "Could not build the requested backlog"
508	pct=$(check_marking get_nmarked $vlan "== 0")
509	check_err $? "backlog $backlog / $limit Got $pct% marked packets, expected == 0."
510	log_test "TC $((vlan - 10)): RED backlog < limit"
511
512	# Pushing above should not.
513	RET=0
514	backlog=$(build_backlog $vlan $((3 * limit / 2)) tcp tos=0x01)
515	check_fail $? "Traffic went into backlog instead of being early-dropped"
516	pct=$(check_marking get_nmarked $vlan "== 0")
517	check_err $? "backlog $backlog / $limit Got $pct% marked packets, expected == 0."
518	backlog=$(get_qdisc_backlog $vlan)
519	local diff=$((limit - backlog))
520	pct=$((100 * diff / limit))
521	((-15 <= pct && pct <= 15))
522	check_err $? "backlog $backlog / $limit expected <= 15% distance"
523	log_test "TC $((vlan - 10)): RED backlog > limit"
524}
525
526do_red_test()
527{
528	in_defer_scope \
529		__do_red_test "$@"
530}
531
532__do_mc_backlog_test()
533{
534	local vlan=$1; shift
535	local limit=$1; shift
536	local backlog
537	local pct
538
539	RET=0
540
541	start_tcp_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 3 $vlan) bc
542	defer stop_traffic_sleep $!
543
544	start_tcp_traffic $h2.$vlan $(ipaddr 2 $vlan) $(ipaddr 3 $vlan) bc
545	defer stop_traffic_sleep $!
546
547	qbl=$(busywait 5000 until_counter_is ">= 500000" \
548		       get_qdisc_backlog $vlan)
549	check_err $? "Could not build MC backlog"
550
551	# Verify that we actually see the backlog on BUM TC. Do a busywait as
552	# well, performance blips might cause false fail.
553	local ebl
554	ebl=$(busywait 5000 until_counter_is ">= 500000" \
555		       get_mc_transmit_queue $vlan)
556	check_err $? "MC backlog reported by qdisc not visible in ethtool"
557
558	log_test "TC $((vlan - 10)): Qdisc reports MC backlog"
559}
560
561do_mc_backlog_test()
562{
563	in_defer_scope \
564		__do_mc_backlog_test "$@"
565}
566
567__do_mark_test()
568{
569	local vlan=$1; shift
570	local limit=$1; shift
571	local subtest=$1; shift
572	local fetch_counter=$1; shift
573	local should_fail=$1; shift
574	local base
575
576	mlxsw_only_on_spectrum 2+ || return
577
578	RET=0
579
580	start_tcp_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 3 $vlan) \
581			  $h3_mac tos=0x01
582	defer stop_traffic_sleep $!
583
584	# Create a bit of a backlog and observe no mirroring due to marks.
585	qevent_rule_install_$subtest
586
587	build_backlog $vlan $((2 * limit / 3)) tcp tos=0x01 >/dev/null
588
589	base=$($fetch_counter)
590	count=$(busywait 1100 until_counter_is ">= $((base + 1))" \
591		$fetch_counter)
592	check_fail $? "Spurious packets ($base -> $count) observed without buffer pressure"
593
594	# Above limit, everything should be mirrored, we should see lots of
595	# packets.
596	build_backlog $vlan $((3 * limit / 2)) tcp tos=0x01 >/dev/null
597	busywait_for_counter 1100 +2500 \
598		 $fetch_counter > /dev/null
599	check_err_fail "$should_fail" $? "ECN-marked packets $subtest'd"
600
601	# When the rule is uninstalled, there should be no mirroring.
602	qevent_rule_uninstall_$subtest
603	busywait_for_counter 1100 +10 \
604		 $fetch_counter > /dev/null
605	check_fail $? "Spurious packets observed after uninstall"
606
607	if ((should_fail)); then
608		log_test "TC $((vlan - 10)): marked packets not $subtest'd"
609	else
610		log_test "TC $((vlan - 10)): marked packets $subtest'd"
611	fi
612}
613
614do_mark_test()
615{
616	in_defer_scope \
617		__do_mark_test "$@"
618}
619
620__do_drop_test()
621{
622	local vlan=$1; shift
623	local limit=$1; shift
624	local trigger=$1; shift
625	local subtest=$1; shift
626	local fetch_counter=$1; shift
627	local base
628	local now
629
630	mlxsw_only_on_spectrum 2+ || return
631
632	RET=0
633
634	start_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 3 $vlan) $h3_mac
635	defer stop_traffic_sleep $!
636
637	# Create a bit of a backlog and observe no mirroring due to drops.
638	qevent_rule_install_$subtest
639	base=$($fetch_counter)
640
641	build_backlog $vlan $((2 * limit / 3)) udp >/dev/null
642
643	busywait 1100 until_counter_is ">= $((base + 1))" $fetch_counter >/dev/null
644	check_fail $? "Spurious packets observed without buffer pressure"
645
646	# Push to the queue until it's at the limit. The configured limit is
647	# rounded by the qdisc and then by the driver, so this is the best we
648	# can do to get to the real limit of the system.
649	build_backlog $vlan $((3 * limit / 2)) udp >/dev/null
650
651	base=$($fetch_counter)
652	send_packets $vlan udp 100
653
654	now=$(busywait 1100 until_counter_is ">= $((base + 95))" $fetch_counter)
655	check_err $? "${trigger}ped packets not observed: 100 expected, $((now - base)) seen"
656
657	# When no extra traffic is injected, there should be no mirroring.
658	busywait 1100 until_counter_is ">= $((base + 110))" \
659		 $fetch_counter >/dev/null
660	check_fail $? "Spurious packets observed"
661
662	# When the rule is uninstalled, there should be no mirroring.
663	qevent_rule_uninstall_$subtest
664	send_packets $vlan udp 100
665	now=$(busywait 1100 until_counter_is ">= $((base + 110))" \
666		       $fetch_counter)
667	check_fail $? "$((now - base)) spurious packets observed after uninstall"
668
669	log_test "TC $((vlan - 10)): ${trigger}ped packets $subtest'd"
670}
671
672do_drop_test()
673{
674	in_defer_scope \
675		__do_drop_test "$@"
676}
677
678qevent_rule_install_mirror()
679{
680	tc filter add block 10 pref 1234 handle 102 matchall skip_sw \
681	   action mirred egress mirror dev $swp2 hw_stats disabled
682}
683
684qevent_rule_uninstall_mirror()
685{
686	tc filter del block 10 pref 1234 handle 102 matchall
687}
688
689qevent_counter_fetch_mirror()
690{
691	tc_rule_handle_stats_get "dev $h2 ingress" 101
692}
693
694do_drop_mirror_test()
695{
696	local vlan=$1; shift
697	local limit=$1; shift
698	local qevent_name=$1; shift
699
700	tc filter add dev $h2 ingress pref 1 handle 101 prot ip \
701	   flower skip_sw ip_proto udp \
702	   action drop
703
704	do_drop_test "$vlan" "$limit" "$qevent_name" mirror \
705		     qevent_counter_fetch_mirror
706
707	tc filter del dev $h2 ingress pref 1 handle 101 flower
708}
709
710do_mark_mirror_test()
711{
712	local vlan=$1; shift
713	local limit=$1; shift
714
715	tc filter add dev $h2 ingress pref 1 handle 101 prot ip \
716	   flower skip_sw ip_proto tcp \
717	   action drop
718
719	do_mark_test "$vlan" "$limit" mirror \
720		     qevent_counter_fetch_mirror \
721		     $(: should_fail=)0
722
723	tc filter del dev $h2 ingress pref 1 handle 101 flower
724}
725
726qevent_rule_install_trap()
727{
728	tc filter add block 10 pref 1234 handle 102 matchall skip_sw \
729	   action trap hw_stats disabled
730}
731
732qevent_rule_uninstall_trap()
733{
734	tc filter del block 10 pref 1234 handle 102 matchall
735}
736
737qevent_counter_fetch_trap()
738{
739	local trap_name=$1; shift
740
741	devlink_trap_rx_packets_get "$trap_name"
742}
743
744do_drop_trap_test()
745{
746	local vlan=$1; shift
747	local limit=$1; shift
748	local trap_name=$1; shift
749
750	do_drop_test "$vlan" "$limit" "$trap_name" trap \
751		     "qevent_counter_fetch_trap $trap_name"
752}
753
754qevent_rule_install_trap_fwd()
755{
756	tc filter add block 10 pref 1234 handle 102 matchall skip_sw \
757	   action trap_fwd hw_stats disabled
758}
759
760qevent_rule_uninstall_trap_fwd()
761{
762	tc filter del block 10 pref 1234 handle 102 matchall
763}
764