Commit 0cd6fa99 authored by Petr Machata's avatar Petr Machata Committed by David S. Miller

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: default avatarPetr Machata <petrm@nvidia.com>
Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a703b517
......@@ -544,6 +544,53 @@ do_mc_backlog_test()
log_test "TC $((vlan - 10)): Qdisc reports MC backlog"
}
do_mark_test()
{
local vlan=$1; shift
local limit=$1; shift
local subtest=$1; shift
local fetch_counter=$1; shift
local should_fail=$1; shift
local base
RET=0
start_tcp_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 3 $vlan) \
$h3_mac tos=0x01
# Create a bit of a backlog and observe no mirroring due to marks.
qevent_rule_install_$subtest
build_backlog $vlan $((2 * limit / 3)) tcp tos=0x01 >/dev/null
base=$($fetch_counter)
count=$(busywait 1100 until_counter_is ">= $((base + 1))" \
$fetch_counter)
check_fail $? "Spurious packets ($base -> $count) observed without buffer pressure"
# Above limit, everything should be mirrored, we should see lots of
# packets.
build_backlog $vlan $((3 * limit / 2)) tcp tos=0x01 >/dev/null
busywait_for_counter 1100 +10000 \
$fetch_counter > /dev/null
check_err_fail "$should_fail" $? "ECN-marked packets $subtest'd"
# When the rule is uninstalled, there should be no mirroring.
qevent_rule_uninstall_$subtest
busywait_for_counter 1100 +10 \
$fetch_counter > /dev/null
check_fail $? "Spurious packets observed after uninstall"
if ((should_fail)); then
log_test "TC $((vlan - 10)): marked packets not $subtest'd"
else
log_test "TC $((vlan - 10)): marked packets $subtest'd"
fi
stop_traffic
sleep 1
}
do_drop_test()
{
local vlan=$1; shift
......@@ -626,6 +673,22 @@ do_drop_mirror_test()
tc filter del dev $h2 ingress pref 1 handle 101 flower
}
do_mark_mirror_test()
{
local vlan=$1; shift
local limit=$1; shift
tc filter add dev $h2 ingress pref 1 handle 101 prot ip \
flower skip_sw ip_proto tcp \
action drop
do_mark_test "$vlan" "$limit" mirror \
qevent_counter_fetch_mirror \
$(: should_fail=)0
tc filter del dev $h2 ingress pref 1 handle 101 flower
}
qevent_rule_install_trap()
{
tc filter add block 10 pref 1234 handle 102 matchall skip_sw \
......@@ -653,3 +716,14 @@ do_drop_trap_test()
do_drop_test "$vlan" "$limit" "$trap_name" trap \
"qevent_counter_fetch_trap $trap_name"
}
qevent_rule_install_trap_fwd()
{
tc filter add block 10 pref 1234 handle 102 matchall skip_sw \
action trap_fwd hw_stats disabled
}
qevent_rule_uninstall_trap_fwd()
{
tc filter del block 10 pref 1234 handle 102 matchall
}
......@@ -9,6 +9,7 @@ ALL_TESTS="
mc_backlog_test
red_mirror_test
red_trap_test
ecn_mirror_test
"
: ${QDISC:=ets}
source sch_red_core.sh
......@@ -21,28 +22,60 @@ source sch_red_core.sh
BACKLOG1=200000
BACKLOG2=500000
install_qdisc()
install_root_qdisc()
{
local -a args=("$@")
tc qdisc add dev $swp3 root handle 10: $QDISC \
bands 8 priomap 7 6 5 4 3 2 1 0
}
install_qdisc_tc0()
{
local -a args=("$@")
tc qdisc add dev $swp3 parent 10:8 handle 108: red \
limit 1000000 min $BACKLOG1 max $((BACKLOG1 + 1)) \
probability 1.0 avpkt 8000 burst 38 "${args[@]}"
}
install_qdisc_tc1()
{
local -a args=("$@")
tc qdisc add dev $swp3 parent 10:7 handle 107: red \
limit 1000000 min $BACKLOG2 max $((BACKLOG2 + 1)) \
probability 1.0 avpkt 8000 burst 63 "${args[@]}"
}
install_qdisc()
{
install_root_qdisc
install_qdisc_tc0 "$@"
install_qdisc_tc1 "$@"
sleep 1
}
uninstall_qdisc()
uninstall_qdisc_tc0()
{
tc qdisc del dev $swp3 parent 10:7
tc qdisc del dev $swp3 parent 10:8
}
uninstall_qdisc_tc1()
{
tc qdisc del dev $swp3 parent 10:7
}
uninstall_root_qdisc()
{
tc qdisc del dev $swp3 root
}
uninstall_qdisc()
{
uninstall_qdisc_tc0
uninstall_qdisc_tc1
uninstall_root_qdisc
}
ecn_test()
{
install_qdisc ecn
......@@ -112,6 +145,16 @@ red_trap_test()
uninstall_qdisc
}
ecn_mirror_test()
{
install_qdisc ecn qevent mark block 10
do_mark_mirror_test 10 $BACKLOG1
do_mark_mirror_test 11 $BACKLOG2
uninstall_qdisc
}
trap cleanup EXIT
setup_prepare
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment