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