Skip to content

Commit

Permalink
selftests: mlxsw: RED: Test per-TC ECN counters
Browse files Browse the repository at this point in the history
Add a variant of ECN test that uses qdisc marked counter (supported on
Spectrum-3 and above) instead of the aggregate ethtool ecn_marked counter.

Signed-off-by: Petr Machata <[email protected]>
Signed-off-by: Ido Schimmel <[email protected]>
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
pmachata authored and kuba-moo committed Oct 14, 2021
1 parent 15be36b commit bf86273
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 10 deletions.
51 changes: 41 additions & 10 deletions tools/testing/selftests/drivers/net/mlxsw/sch_red_core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,14 @@ get_nmarked()
ethtool_stats_get $swp3 ecn_marked
}

get_qdisc_nmarked()
{
local vlan=$1; shift

busywait_for_counter 1100 +1 \
qdisc_stats_get $swp3 $(get_qdisc_handle $vlan) .marked
}

get_qdisc_npackets()
{
local vlan=$1; shift
Expand Down Expand Up @@ -384,14 +392,15 @@ build_backlog()

check_marking()
{
local get_nmarked=$1; shift
local vlan=$1; shift
local cond=$1; shift

local npackets_0=$(get_qdisc_npackets $vlan)
local nmarked_0=$(get_nmarked $vlan)
local nmarked_0=$($get_nmarked $vlan)
sleep 5
local npackets_1=$(get_qdisc_npackets $vlan)
local nmarked_1=$(get_nmarked $vlan)
local nmarked_1=$($get_nmarked $vlan)

local nmarked_d=$((nmarked_1 - nmarked_0))
local npackets_d=$((npackets_1 - npackets_0))
Expand All @@ -404,6 +413,7 @@ check_marking()
ecn_test_common()
{
local name=$1; shift
local get_nmarked=$1; shift
local vlan=$1; shift
local limit=$1; shift
local backlog
Expand All @@ -416,7 +426,7 @@ ecn_test_common()
RET=0
backlog=$(build_backlog $vlan $((2 * limit / 3)) udp)
check_err $? "Could not build the requested backlog"
pct=$(check_marking $vlan "== 0")
pct=$(check_marking "$get_nmarked" $vlan "== 0")
check_err $? "backlog $backlog / $limit Got $pct% marked packets, expected == 0."
log_test "TC $((vlan - 10)): $name backlog < limit"

Expand All @@ -426,22 +436,23 @@ ecn_test_common()
RET=0
backlog=$(build_backlog $vlan $((3 * limit / 2)) tcp tos=0x01)
check_err $? "Could not build the requested backlog"
pct=$(check_marking $vlan ">= 95")
pct=$(check_marking "$get_nmarked" $vlan ">= 95")
check_err $? "backlog $backlog / $limit Got $pct% marked packets, expected >= 95."
log_test "TC $((vlan - 10)): $name backlog > limit"
}

do_ecn_test()
__do_ecn_test()
{
local get_nmarked=$1; shift
local vlan=$1; shift
local limit=$1; shift
local name=ECN
local name=${1-ECN}; shift

start_tcp_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 3 $vlan) \
$h3_mac tos=0x01
sleep 1

ecn_test_common "$name" $vlan $limit
ecn_test_common "$name" "$get_nmarked" $vlan $limit

# Up there we saw that UDP gets accepted when backlog is below the
# limit. Now that it is above, it should all get dropped, and backlog
Expand All @@ -455,6 +466,26 @@ do_ecn_test()
sleep 1
}

do_ecn_test()
{
local vlan=$1; shift
local limit=$1; shift

__do_ecn_test get_nmarked "$vlan" "$limit"
}

do_ecn_test_perband()
{
local vlan=$1; shift
local limit=$1; shift

# Per-band ECN counters are not supported on Spectrum-1 and Spectrum-2.
[[ "$DEVLINK_VIDDID" == "15b3:cb84" ||
"$DEVLINK_VIDDID" == "15b3:cf6c" ]] && return

__do_ecn_test get_qdisc_nmarked "$vlan" "$limit" "per-band ECN"
}

do_ecn_nodrop_test()
{
local vlan=$1; shift
Expand All @@ -465,7 +496,7 @@ do_ecn_nodrop_test()
$h3_mac tos=0x01
sleep 1

ecn_test_common "$name" $vlan $limit
ecn_test_common "$name" get_nmarked $vlan $limit

# Up there we saw that UDP gets accepted when backlog is below the
# limit. Now that it is above, in nodrop mode, make sure it goes to
Expand Down Expand Up @@ -495,15 +526,15 @@ do_red_test()
RET=0
backlog=$(build_backlog $vlan $((2 * limit / 3)) tcp tos=0x01)
check_err $? "Could not build the requested backlog"
pct=$(check_marking $vlan "== 0")
pct=$(check_marking get_nmarked $vlan "== 0")
check_err $? "backlog $backlog / $limit Got $pct% marked packets, expected == 0."
log_test "TC $((vlan - 10)): RED backlog < limit"

# Pushing above should not.
RET=0
backlog=$(build_backlog $vlan $((3 * limit / 2)) tcp tos=0x01)
check_fail $? "Traffic went into backlog instead of being early-dropped"
pct=$(check_marking $vlan "== 0")
pct=$(check_marking get_nmarked $vlan "== 0")
check_err $? "backlog $backlog / $limit Got $pct% marked packets, expected == 0."
local diff=$((limit - backlog))
pct=$((100 * diff / limit))
Expand Down
11 changes: 11 additions & 0 deletions tools/testing/selftests/drivers/net/mlxsw/sch_red_ets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
ALL_TESTS="
ping_ipv4
ecn_test
ecn_test_perband
ecn_nodrop_test
red_test
mc_backlog_test
Expand Down Expand Up @@ -86,6 +87,16 @@ ecn_test()
uninstall_qdisc
}

ecn_test_perband()
{
install_qdisc ecn

do_ecn_test_perband 10 $BACKLOG1
do_ecn_test_perband 11 $BACKLOG2

uninstall_qdisc
}

ecn_nodrop_test()
{
install_qdisc ecn nodrop
Expand Down
8 changes: 8 additions & 0 deletions tools/testing/selftests/drivers/net/mlxsw/sch_red_root.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
ALL_TESTS="
ping_ipv4
ecn_test
ecn_test_perband
ecn_nodrop_test
red_test
mc_backlog_test
Expand Down Expand Up @@ -35,6 +36,13 @@ ecn_test()
uninstall_qdisc
}

ecn_test_perband()
{
install_qdisc ecn
do_ecn_test_perband 10 $BACKLOG
uninstall_qdisc
}

ecn_nodrop_test()
{
install_qdisc ecn nodrop
Expand Down

0 comments on commit bf86273

Please sign in to comment.