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