File Index
Files and directories
Sign in
FILE

sch_red_core.sh

File preview with syntax highlighting.

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