Commit 4e230962 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'mlxsw-adjust-qos-tests-for-spectrum-4-testing'

Petr Machata says:

====================
mlxsw: Adjust QOS tests for Spectrum-4 testing

Amit writes:

Quality Of Service tests create congestion and verify the switch behavior.
To create congestion, they need to have more traffic than the port can
handle, so some of them force 1Gbps speed.

The tests assume that 1Gbps speed is supported. Spectrum-4 ASIC will not
support this speed in all ports, so to be able to run QOS tests there,
some adjustments are required.

Patch set overview:
Patch #1 adjusts qos_ets_strict, qos_mc_aware and sch_ets tests.
Patch #2 adjusts RED tests.
Patch #3 extends devlink_lib to support querying maximum pool size.
Patch #4 adds a test which can be used instead of qos_burst and do not
assume that 1Gbps speed is supported.
Patch #5 removes qos_burst test.
====================

Link: https://lore.kernel.org/r/cover.1663152826.git.petrm@nvidia.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 2dc81a0e 72981ef2
......@@ -61,3 +61,17 @@ mlxsw_only_on_spectrum()
return 1
}
mlxsw_max_descriptors_get()
{
local spectrum_rev=$MLXSW_SPECTRUM_REV
case $spectrum_rev in
1) echo 81920 ;;
2) echo 136960 ;;
3) echo 204800 ;;
4) echo 220000 ;;
*) echo "Unknown max descriptors for chip revision." > /dev/stderr
return 1 ;;
esac
}
This diff is collapsed.
......@@ -130,7 +130,8 @@ switch_create()
ip link set dev $swp3 up
mtu_set $swp3 10000
ethtool -s $swp3 speed 1000 autoneg off
tc qdisc replace dev $swp3 root handle 101: tbf rate 1gbit \
burst 128K limit 1G
vlan_create $swp1 111
vlan_create $swp2 222
......@@ -193,7 +194,7 @@ switch_destroy()
vlan_destroy $swp2 222
vlan_destroy $swp1 111
ethtool -s $swp3 autoneg on
tc qdisc del dev $swp3 root handle 101:
mtu_restore $swp3
ip link set dev $swp3 down
lldptool -T -i $swp3 -V ETS-CFG up2tc=0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0
......
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# This test sends many small packets (size is less than cell size) through the
# switch. A shaper is used in $swp2, so the traffic is limited there. Packets
# are queued till they will be sent.
#
# The idea is to verify that the switch can handle at least 85% of maximum
# supported descrpitors by hardware. Then, we verify that the driver configures
# firmware to allow infinite size of egress descriptor pool, and does not use a
# lower limitation. Increase the size of the relevant pools such that the pool's
# size does not limit the traffic.
# +-----------------------+
# | H1 |
# | + $h1.111 |
# | | 192.0.2.33/28 |
# | | |
# | + $h1 |
# +---|-------------------+
# |
# +---|-----------------------------+
# | + $swp1 |
# | | iPOOL1 |
# | | |
# | +-|------------------------+ |
# | | + $swp1.111 | |
# | | | |
# | | BR1 | |
# | | | |
# | | + $swp2.111 | |
# | +-|------------------------+ |
# | | |
# | + $swp2 |
# | | ePOOL6 |
# | | 1mbit |
# +---+-----------------------------+
# |
# +---|-------------------+
# | + $h2 H2 |
# | | |
# | + $h2.111 |
# | 192.0.2.34/28 |
# +-----------------------+
#
ALL_TESTS="
ping_ipv4
max_descriptors
"
lib_dir=$(dirname $0)/../../../net/forwarding
NUM_NETIFS=4
source $lib_dir/lib.sh
source $lib_dir/devlink_lib.sh
source mlxsw_lib.sh
MAX_POOL_SIZE=$(devlink_pool_size_get)
SHAPER_RATE=1mbit
# The current TBF qdisc interface does not allow us to configure the shaper to
# flat zero. The ASIC shaper is guaranteed to work with a granularity of
# 200Mbps. On Spectrum-2, writing a value close to zero instead of zero works
# well, but the performance on Spectrum-1 is unpredictable. Thus, do not run the
# test on Spectrum-1.
mlxsw_only_on_spectrum 2+ || exit
h1_create()
{
simple_if_init $h1
vlan_create $h1 111 v$h1 192.0.2.33/28
ip link set dev $h1.111 type vlan egress-qos-map 0:1
}
h1_destroy()
{
vlan_destroy $h1 111
simple_if_fini $h1
}
h2_create()
{
simple_if_init $h2
vlan_create $h2 111 v$h2 192.0.2.34/28
}
h2_destroy()
{
vlan_destroy $h2 111
simple_if_fini $h2
}
switch_create()
{
# pools
# -----
devlink_pool_size_thtype_save 1
devlink_pool_size_thtype_save 6
devlink_port_pool_th_save $swp1 1
devlink_port_pool_th_save $swp2 6
devlink_tc_bind_pool_th_save $swp1 1 ingress
devlink_tc_bind_pool_th_save $swp2 1 egress
devlink_pool_size_thtype_set 1 dynamic $MAX_POOL_SIZE
devlink_pool_size_thtype_set 6 static $MAX_POOL_SIZE
# $swp1
# -----
ip link set dev $swp1 up
vlan_create $swp1 111
ip link set dev $swp1.111 type vlan ingress-qos-map 0:0 1:1
devlink_port_pool_th_set $swp1 1 16
devlink_tc_bind_pool_th_set $swp1 1 ingress 1 16
tc qdisc replace dev $swp1 root handle 1: \
ets bands 8 strict 8 priomap 7 6
dcb buffer set dev $swp1 prio-buffer all:0 1:1
# $swp2
# -----
ip link set dev $swp2 up
vlan_create $swp2 111
ip link set dev $swp2.111 type vlan egress-qos-map 0:0 1:1
devlink_port_pool_th_set $swp2 6 $MAX_POOL_SIZE
devlink_tc_bind_pool_th_set $swp2 1 egress 6 $MAX_POOL_SIZE
tc qdisc replace dev $swp2 root handle 1: tbf rate $SHAPER_RATE \
burst 128K limit 500M
tc qdisc replace dev $swp2 parent 1:1 handle 11: \
ets bands 8 strict 8 priomap 7 6
# bridge
# ------
ip link add name br1 type bridge vlan_filtering 0
ip link set dev $swp1.111 master br1
ip link set dev br1 up
ip link set dev $swp2.111 master br1
}
switch_destroy()
{
# Do this first so that we can reset the limits to values that are only
# valid for the original static / dynamic setting.
devlink_pool_size_thtype_restore 6
devlink_pool_size_thtype_restore 1
# bridge
# ------
ip link set dev $swp2.111 nomaster
ip link set dev br1 down
ip link set dev $swp1.111 nomaster
ip link del dev br1
# $swp2
# -----
tc qdisc del dev $swp2 parent 1:1 handle 11:
tc qdisc del dev $swp2 root
devlink_tc_bind_pool_th_restore $swp2 1 egress
devlink_port_pool_th_restore $swp2 6
vlan_destroy $swp2 111
ip link set dev $swp2 down
# $swp1
# -----
dcb buffer set dev $swp1 prio-buffer all:0
tc qdisc del dev $swp1 root
devlink_tc_bind_pool_th_restore $swp1 1 ingress
devlink_port_pool_th_restore $swp1 1
vlan_destroy $swp1 111
ip link set dev $swp1 down
}
setup_prepare()
{
h1=${NETIFS[p1]}
swp1=${NETIFS[p2]}
swp2=${NETIFS[p3]}
h2=${NETIFS[p4]}
h2mac=$(mac_get $h2)
vrf_prepare
h1_create
h2_create
switch_create
}
cleanup()
{
pre_cleanup
switch_destroy
h2_destroy
h1_destroy
vrf_cleanup
}
ping_ipv4()
{
ping_test $h1 192.0.2.34 " h1->h2"
}
percentage_used()
{
local num_packets=$1; shift
local max_packets=$1; shift
bc <<< "
scale=2
100 * $num_packets / $max_packets
"
}
max_descriptors()
{
local cell_size=$(devlink_cell_size_get)
local exp_perc_used=85
local max_descriptors
local pktsize=30
RET=0
max_descriptors=$(mlxsw_max_descriptors_get) || exit 1
local d0=$(ethtool_stats_get $swp2 tc_no_buffer_discard_uc_tc_1)
log_info "Send many small packets, packet size = $pktsize bytes"
start_traffic_pktsize $pktsize $h1.111 192.0.2.33 192.0.2.34 $h2mac
# Sleep to wait for congestion.
sleep 5
local d1=$(ethtool_stats_get $swp2 tc_no_buffer_discard_uc_tc_1)
((d1 == d0))
check_err $? "Drops seen on egress port: $d0 -> $d1 ($((d1 - d0)))"
# Check how many packets the switch can handle, the limitation is
# maximum descriptors.
local pkts_bytes=$(ethtool_stats_get $swp2 tc_transmit_queue_tc_1)
local pkts_num=$((pkts_bytes / cell_size))
local perc_used=$(percentage_used $pkts_num $max_descriptors)
check_err $(bc <<< "$perc_used < $exp_perc_used") \
"Expected > $exp_perc_used% of descriptors, handle $perc_used%"
stop_traffic
sleep 1
log_test "Maximum descriptors usage. The percentage used is $perc_used%"
}
trap cleanup EXIT
setup_prepare
setup_wait
tests_run
exit $EXIT_STATUS
......@@ -129,9 +129,10 @@ switch_create()
vlan_create $swp2 111
vlan_create $swp3 111
ethtool -s $swp3 speed 1000 autoneg off
tc qdisc replace dev $swp3 root handle 3: \
prio bands 8 priomap 7 7 7 7 7 7 7 7
tc qdisc replace dev $swp3 root handle 3: tbf rate 1gbit \
burst 128K limit 1G
tc qdisc replace dev $swp3 parent 3:3 handle 33: \
prio bands 8 priomap 7 7 7 7 7 7 7 7
ip link add name br1 type bridge vlan_filtering 0
ip link set dev br1 up
......@@ -172,8 +173,8 @@ switch_destroy()
ip link del dev br111
ip link del dev br1
tc qdisc del dev $swp3 parent 3:3 handle 33:
tc qdisc del dev $swp3 root handle 3:
ethtool -s $swp3 autoneg on
vlan_destroy $swp3 111
vlan_destroy $swp2 111
......
......@@ -15,13 +15,15 @@ ALL_TESTS="
ets_test_dwrr
"
PARENT="parent 3:3"
switch_create()
{
ets_switch_create
# Create a bottleneck so that the DWRR process can kick in.
ethtool -s $h2 speed 1000 autoneg off
ethtool -s $swp2 speed 1000 autoneg off
tc qdisc replace dev $swp2 root handle 3: tbf rate 1gbit \
burst 128K limit 1G
ets_switch_create
# Set the ingress quota high and use the three egress TCs to limit the
# amount of traffic that is admitted to the shared buffers. This makes
......@@ -55,10 +57,9 @@ switch_destroy()
devlink_tc_bind_pool_th_restore $swp1 0 ingress
devlink_port_pool_th_restore $swp1 0
ethtool -s $swp2 autoneg on
ethtool -s $h2 autoneg on
ets_switch_destroy
tc qdisc del dev $swp2 root handle 3:
}
# Callback from sch_ets_tests.sh
......
......@@ -135,14 +135,16 @@ h2_create()
# cause packets to fail to queue up at $swp3 due to shared buffer
# quotas, and the test to spuriously fail.
#
# Prevent this by setting the speed of $h2 to 1Gbps.
# Prevent this by adding a shaper which limits the traffic in $h2 to
# 1Gbps.
ethtool -s $h2 speed 1000 autoneg off
tc qdisc replace dev $h2 root handle 10: tbf rate 1gbit \
burst 128K limit 1G
}
h2_destroy()
{
ethtool -s $h2 autoneg on
tc qdisc del dev $h2 root handle 10:
tc qdisc del dev $h2 clsact
host_destroy $h2
}
......@@ -150,12 +152,10 @@ h2_destroy()
h3_create()
{
host_create $h3 3
ethtool -s $h3 speed 1000 autoneg off
}
h3_destroy()
{
ethtool -s $h3 autoneg on
host_destroy $h3
}
......@@ -199,8 +199,9 @@ switch_create()
done
done
for intf in $swp2 $swp3 $swp4 $swp5; do
ethtool -s $intf speed 1000 autoneg off
for intf in $swp3 $swp4; do
tc qdisc replace dev $intf root handle 1: tbf rate 1gbit \
burst 128K limit 1G
done
ip link set dev br1_10 up
......@@ -220,15 +221,13 @@ switch_destroy()
devlink_port_pool_th_restore $swp3 8
tc qdisc del dev $swp3 root 2>/dev/null
ip link set dev br2_11 down
ip link set dev br2_10 down
ip link set dev br1_11 down
ip link set dev br1_10 down
for intf in $swp5 $swp4 $swp3 $swp2; do
ethtool -s $intf autoneg on
for intf in $swp4 $swp3; do
tc qdisc del dev $intf root handle 1:
done
for intf in $swp5 $swp3 $swp2 $swp4 $swp1; do
......@@ -536,7 +535,7 @@ do_red_test()
check_err $? "backlog $backlog / $limit Got $pct% marked packets, expected == 0."
local diff=$((limit - backlog))
pct=$((100 * diff / limit))
((0 <= pct && pct <= 10))
((-10 <= pct && pct <= 10))
check_err $? "backlog $backlog / $limit expected <= 10% distance"
log_test "TC $((vlan - 10)): RED backlog > limit"
......
......@@ -25,7 +25,7 @@ BACKLOG2=500000
install_root_qdisc()
{
tc qdisc add dev $swp3 root handle 10: $QDISC \
tc qdisc add dev $swp3 parent 1: handle 10: $QDISC \
bands 8 priomap 7 6 5 4 3 2 1 0
}
......@@ -67,7 +67,7 @@ uninstall_qdisc_tc1()
uninstall_root_qdisc()
{
tc qdisc del dev $swp3 root
tc qdisc del dev $swp3 parent 1:
}
uninstall_qdisc()
......
......@@ -18,7 +18,7 @@ install_qdisc()
{
local -a args=("$@")
tc qdisc add dev $swp3 root handle 108: red \
tc qdisc add dev $swp3 parent 1: handle 108: red \
limit 1000000 min $BACKLOG max $((BACKLOG + 1)) \
probability 1.0 avpkt 8000 burst 38 "${args[@]}"
sleep 1
......@@ -26,7 +26,7 @@ install_qdisc()
uninstall_qdisc()
{
tc qdisc del dev $swp3 root
tc qdisc del dev $swp3 parent 1:
}
ecn_test()
......
......@@ -584,3 +584,8 @@ devlink_cell_size_get()
devlink sb pool show "$DEVLINK_DEV" pool 0 -j \
| jq '.pool[][].cell_size'
}
devlink_pool_size_get()
{
devlink sb show "$DEVLINK_DEV" -j | jq '.[][][]["size"]'
}
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