Skip to content

Commit 0cd6fa9

Browse files
pmachatadavem330
authored andcommitted
selftests: mlxsw: RED: Add selftests for the mark qevent
Add do_mark_test(), which is to do_ecn_test() like do_drop_test() is to do_red_test(): meant to test that actions on the RED mark qevent block are offloaded, and executed on ECN-marked packets. The test splits install_qdisc() into its constituents, install_root_qdisc() and install_qdisc_tcX(). This is in order to test that when mirroring is enabled on one TC, the other TC does not mirror. Signed-off-by: Petr Machata <petrm@nvidia.com> Signed-off-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a703b51 commit 0cd6fa9

File tree

2 files changed

+122
-5
lines changed

2 files changed

+122
-5
lines changed

tools/testing/selftests/drivers/net/mlxsw/sch_red_core.sh

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,53 @@ do_mc_backlog_test()
544544
log_test "TC $((vlan - 10)): Qdisc reports MC backlog"
545545
}
546546

547+
do_mark_test()
548+
{
549+
local vlan=$1; shift
550+
local limit=$1; shift
551+
local subtest=$1; shift
552+
local fetch_counter=$1; shift
553+
local should_fail=$1; shift
554+
local base
555+
556+
RET=0
557+
558+
start_tcp_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 3 $vlan) \
559+
$h3_mac tos=0x01
560+
561+
# Create a bit of a backlog and observe no mirroring due to marks.
562+
qevent_rule_install_$subtest
563+
564+
build_backlog $vlan $((2 * limit / 3)) tcp tos=0x01 >/dev/null
565+
566+
base=$($fetch_counter)
567+
count=$(busywait 1100 until_counter_is ">= $((base + 1))" \
568+
$fetch_counter)
569+
check_fail $? "Spurious packets ($base -> $count) observed without buffer pressure"
570+
571+
# Above limit, everything should be mirrored, we should see lots of
572+
# packets.
573+
build_backlog $vlan $((3 * limit / 2)) tcp tos=0x01 >/dev/null
574+
busywait_for_counter 1100 +10000 \
575+
$fetch_counter > /dev/null
576+
check_err_fail "$should_fail" $? "ECN-marked packets $subtest'd"
577+
578+
# When the rule is uninstalled, there should be no mirroring.
579+
qevent_rule_uninstall_$subtest
580+
busywait_for_counter 1100 +10 \
581+
$fetch_counter > /dev/null
582+
check_fail $? "Spurious packets observed after uninstall"
583+
584+
if ((should_fail)); then
585+
log_test "TC $((vlan - 10)): marked packets not $subtest'd"
586+
else
587+
log_test "TC $((vlan - 10)): marked packets $subtest'd"
588+
fi
589+
590+
stop_traffic
591+
sleep 1
592+
}
593+
547594
do_drop_test()
548595
{
549596
local vlan=$1; shift
@@ -626,6 +673,22 @@ do_drop_mirror_test()
626673
tc filter del dev $h2 ingress pref 1 handle 101 flower
627674
}
628675

676+
do_mark_mirror_test()
677+
{
678+
local vlan=$1; shift
679+
local limit=$1; shift
680+
681+
tc filter add dev $h2 ingress pref 1 handle 101 prot ip \
682+
flower skip_sw ip_proto tcp \
683+
action drop
684+
685+
do_mark_test "$vlan" "$limit" mirror \
686+
qevent_counter_fetch_mirror \
687+
$(: should_fail=)0
688+
689+
tc filter del dev $h2 ingress pref 1 handle 101 flower
690+
}
691+
629692
qevent_rule_install_trap()
630693
{
631694
tc filter add block 10 pref 1234 handle 102 matchall skip_sw \
@@ -653,3 +716,14 @@ do_drop_trap_test()
653716
do_drop_test "$vlan" "$limit" "$trap_name" trap \
654717
"qevent_counter_fetch_trap $trap_name"
655718
}
719+
720+
qevent_rule_install_trap_fwd()
721+
{
722+
tc filter add block 10 pref 1234 handle 102 matchall skip_sw \
723+
action trap_fwd hw_stats disabled
724+
}
725+
726+
qevent_rule_uninstall_trap_fwd()
727+
{
728+
tc filter del block 10 pref 1234 handle 102 matchall
729+
}

tools/testing/selftests/drivers/net/mlxsw/sch_red_ets.sh

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ ALL_TESTS="
99
mc_backlog_test
1010
red_mirror_test
1111
red_trap_test
12+
ecn_mirror_test
1213
"
1314
: ${QDISC:=ets}
1415
source sch_red_core.sh
@@ -21,28 +22,60 @@ source sch_red_core.sh
2122
BACKLOG1=200000
2223
BACKLOG2=500000
2324

24-
install_qdisc()
25+
install_root_qdisc()
2526
{
26-
local -a args=("$@")
27-
2827
tc qdisc add dev $swp3 root handle 10: $QDISC \
2928
bands 8 priomap 7 6 5 4 3 2 1 0
29+
}
30+
31+
install_qdisc_tc0()
32+
{
33+
local -a args=("$@")
34+
3035
tc qdisc add dev $swp3 parent 10:8 handle 108: red \
3136
limit 1000000 min $BACKLOG1 max $((BACKLOG1 + 1)) \
3237
probability 1.0 avpkt 8000 burst 38 "${args[@]}"
38+
}
39+
40+
install_qdisc_tc1()
41+
{
42+
local -a args=("$@")
43+
3344
tc qdisc add dev $swp3 parent 10:7 handle 107: red \
3445
limit 1000000 min $BACKLOG2 max $((BACKLOG2 + 1)) \
3546
probability 1.0 avpkt 8000 burst 63 "${args[@]}"
47+
}
48+
49+
install_qdisc()
50+
{
51+
install_root_qdisc
52+
install_qdisc_tc0 "$@"
53+
install_qdisc_tc1 "$@"
3654
sleep 1
3755
}
3856

39-
uninstall_qdisc()
57+
uninstall_qdisc_tc0()
4058
{
41-
tc qdisc del dev $swp3 parent 10:7
4259
tc qdisc del dev $swp3 parent 10:8
60+
}
61+
62+
uninstall_qdisc_tc1()
63+
{
64+
tc qdisc del dev $swp3 parent 10:7
65+
}
66+
67+
uninstall_root_qdisc()
68+
{
4369
tc qdisc del dev $swp3 root
4470
}
4571

72+
uninstall_qdisc()
73+
{
74+
uninstall_qdisc_tc0
75+
uninstall_qdisc_tc1
76+
uninstall_root_qdisc
77+
}
78+
4679
ecn_test()
4780
{
4881
install_qdisc ecn
@@ -112,6 +145,16 @@ red_trap_test()
112145
uninstall_qdisc
113146
}
114147

148+
ecn_mirror_test()
149+
{
150+
install_qdisc ecn qevent mark block 10
151+
152+
do_mark_mirror_test 10 $BACKLOG1
153+
do_mark_mirror_test 11 $BACKLOG2
154+
155+
uninstall_qdisc
156+
}
157+
115158
trap cleanup EXIT
116159

117160
setup_prepare

0 commit comments

Comments
 (0)