brintos

brintos / linux-shallow public Read only

0
0
Text · 6.1 KiB · 5ac4f79 Raw
283 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.03#4# This test sends many small packets (size is less than cell size) through the5# switch. A shaper is used in $swp2, so the traffic is limited there. Packets6# are queued till they will be sent.7#8# The idea is to verify that the switch can handle at least 85% of maximum9# supported descrpitors by hardware. Then, we verify that the driver configures10# firmware to allow infinite size of egress descriptor pool, and does not use a11# lower limitation. Increase the size of the relevant pools such that the pool's12# size does not limit the traffic.13 14# +-----------------------+15# | H1                    |16# |   + $h1.111           |17# |   | 192.0.2.33/28     |18# |   |                   |19# |   + $h1               |20# +---|-------------------+21#     |22# +---|-----------------------------+23# |   + $swp1                       |24# |   | iPOOL1                      |25# |   |                             |26# | +-|------------------------+    |27# | | + $swp1.111              |    |28# | |                          |    |29# | | BR1                      |    |30# | |                          |    |31# | | + $swp2.111              |    |32# | +-|------------------------+    |33# |   |                             |34# |   + $swp2                       |35# |   | ePOOL6                      |36# |   | 1mbit                       |37# +---+-----------------------------+38#     |39# +---|-------------------+40# |   + $h2            H2 |41# |   |                   |42# |   + $h2.111           |43# |     192.0.2.34/28     |44# +-----------------------+45#46 47ALL_TESTS="48	ping_ipv449	max_descriptors50"51 52lib_dir=$(dirname $0)/../../../net/forwarding53 54NUM_NETIFS=455source $lib_dir/lib.sh56source $lib_dir/devlink_lib.sh57source mlxsw_lib.sh58 59MAX_POOL_SIZE=$(devlink_pool_size_get)60SHAPER_RATE=1mbit61 62# The current TBF qdisc interface does not allow us to configure the shaper to63# flat zero. The ASIC shaper is guaranteed to work with a granularity of64# 200Mbps. On Spectrum-2, writing a value close to zero instead of zero works65# well, but the performance on Spectrum-1 is unpredictable. Thus, do not run the66# test on Spectrum-1.67mlxsw_only_on_spectrum 2+ || exit68 69h1_create()70{71	simple_if_init $h172 73	vlan_create $h1 111 v$h1 192.0.2.33/2874	ip link set dev $h1.111 type vlan egress-qos-map 0:175}76 77h1_destroy()78{79	vlan_destroy $h1 11180 81	simple_if_fini $h182}83 84h2_create()85{86	simple_if_init $h287 88	vlan_create $h2 111 v$h2 192.0.2.34/2889}90 91h2_destroy()92{93	vlan_destroy $h2 11194 95	simple_if_fini $h296}97 98switch_create()99{100	# pools101	# -----102 103	devlink_pool_size_thtype_save 1104	devlink_pool_size_thtype_save 6105 106	devlink_port_pool_th_save $swp1 1107	devlink_port_pool_th_save $swp2 6108 109	devlink_tc_bind_pool_th_save $swp1 1 ingress110	devlink_tc_bind_pool_th_save $swp2 1 egress111 112	devlink_pool_size_thtype_set 1 dynamic $MAX_POOL_SIZE113	devlink_pool_size_thtype_set 6 static $MAX_POOL_SIZE114 115	# $swp1116	# -----117 118	ip link set dev $swp1 up119	vlan_create $swp1 111120	ip link set dev $swp1.111 type vlan ingress-qos-map 0:0 1:1121 122	devlink_port_pool_th_set $swp1 1 16123	devlink_tc_bind_pool_th_set $swp1 1 ingress 1 16124 125	tc qdisc replace dev $swp1 root handle 1: \126	   ets bands 8 strict 8 priomap 7 6127	dcb buffer set dev $swp1 prio-buffer all:0 1:1128 129	# $swp2130	# -----131 132	ip link set dev $swp2 up133	vlan_create $swp2 111134	ip link set dev $swp2.111 type vlan egress-qos-map 0:0 1:1135 136	devlink_port_pool_th_set $swp2 6 $MAX_POOL_SIZE137	devlink_tc_bind_pool_th_set $swp2 1 egress 6 $MAX_POOL_SIZE138 139	tc qdisc replace dev $swp2 root handle 1: tbf rate $SHAPER_RATE \140		burst 128K limit 500M141	tc qdisc replace dev $swp2 parent 1:1 handle 11: \142		ets bands 8 strict 8 priomap 7 6143 144	# bridge145	# ------146 147	ip link add name br1 type bridge vlan_filtering 0148	ip link set dev $swp1.111 master br1149	ip link set dev br1 up150 151	ip link set dev $swp2.111 master br1152}153 154switch_destroy()155{156	# Do this first so that we can reset the limits to values that are only157	# valid for the original static / dynamic setting.158	devlink_pool_size_thtype_restore 6159	devlink_pool_size_thtype_restore 1160 161	# bridge162	# ------163 164	ip link set dev $swp2.111 nomaster165 166	ip link set dev br1 down167	ip link set dev $swp1.111 nomaster168	ip link del dev br1169 170	# $swp2171	# -----172 173	tc qdisc del dev $swp2 parent 1:1 handle 11:174	tc qdisc del dev $swp2 root175 176	devlink_tc_bind_pool_th_restore $swp2 1 egress177	devlink_port_pool_th_restore $swp2 6178 179	vlan_destroy $swp2 111180	ip link set dev $swp2 down181 182	# $swp1183	# -----184 185	dcb buffer set dev $swp1 prio-buffer all:0186	tc qdisc del dev $swp1 root187 188	devlink_tc_bind_pool_th_restore $swp1 1 ingress189	devlink_port_pool_th_restore $swp1 1190 191	vlan_destroy $swp1 111192	ip link set dev $swp1 down193}194 195setup_prepare()196{197	h1=${NETIFS[p1]}198	swp1=${NETIFS[p2]}199 200	swp2=${NETIFS[p3]}201	h2=${NETIFS[p4]}202 203	h2mac=$(mac_get $h2)204 205	vrf_prepare206 207	h1_create208	h2_create209	switch_create210}211 212cleanup()213{214	pre_cleanup215 216	switch_destroy217	h2_destroy218	h1_destroy219 220	vrf_cleanup221}222 223ping_ipv4()224{225	ping_test $h1 192.0.2.34 " h1->h2"226}227 228percentage_used()229{230	local num_packets=$1; shift231	local max_packets=$1; shift232 233	bc <<< "234	    scale=2235	    100 * $num_packets / $max_packets236	"237}238 239max_descriptors()240{241	local cell_size=$(devlink_cell_size_get)242	local exp_perc_used=85243	local max_descriptors244	local pktsize=30245 246	RET=0247 248	max_descriptors=$(mlxsw_max_descriptors_get) || exit 1249 250	local d0=$(ethtool_stats_get $swp2 tc_no_buffer_discard_uc_tc_1)251 252	log_info "Send many small packets, packet size = $pktsize bytes"253	start_traffic_pktsize $pktsize $h1.111 192.0.2.33 192.0.2.34 $h2mac254 255	# Sleep to wait for congestion.256	sleep 5257 258	local d1=$(ethtool_stats_get $swp2 tc_no_buffer_discard_uc_tc_1)259	((d1 == d0))260	check_err $? "Drops seen on egress port: $d0 -> $d1 ($((d1 - d0)))"261 262	# Check how many packets the switch can handle, the limitation is263	# maximum descriptors.264	local pkts_bytes=$(ethtool_stats_get $swp2 tc_transmit_queue_tc_1)265	local pkts_num=$((pkts_bytes / cell_size))266	local perc_used=$(percentage_used $pkts_num $max_descriptors)267 268	check_err $(bc <<< "$perc_used < $exp_perc_used") \269		"Expected > $exp_perc_used% of descriptors, handle $perc_used%"270 271	stop_traffic272	sleep 1273 274	log_test "Maximum descriptors usage. The percentage used is $perc_used%"275}276 277trap cleanup EXIT278setup_prepare279setup_wait280tests_run281 282exit $EXIT_STATUS283