brintos

brintos / linux-shallow public Read only

0
0
Text · 8.8 KiB · fee74f2 Raw
326 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.03#4# A test for strict prioritization of traffic in the switch. Run two streams of5# traffic, each through a different ingress port, one tagged with PCP of 1, the6# other with PCP of 2. Both streams converge at one egress port, where they are7# assigned TC of, respectively, 1 and 2, with strict priority configured between8# them. In H3, we expect to see (almost) exclusively the high-priority traffic.9#10# Please see qos_mc_aware.sh for an explanation of why we use mausezahn and11# counters instead of just running iperf3.12#13# +---------------------------+                 +-----------------------------+14# | H1                        |                 |                          H2 |15# |         $h1.111 +         |                 |         + $h2.222           |16# |   192.0.2.33/28 |         |                 |         | 192.0.2.65/28     |17# |   e-qos-map 0:1 |         |                 |         | e-qos-map 0:2     |18# |                 |         |                 |         |                   |19# |             $h1 +         |                 |         + $h2               |20# +-----------------|---------+                 +---------|-------------------+21#                   |                                     |22# +-----------------|-------------------------------------|-------------------+23# |           $swp1 +                                     + $swp2             |24# |          >1Gbps |                                     | >1Gbps            |25# | +---------------|-----------+              +----------|----------------+  |26# | |     $swp1.111 +           |              |          + $swp2.222      |  |27# | |                     BR111 |       SW     | BR222                     |  |28# | |     $swp3.111 +           |              |          + $swp3.222      |  |29# | +---------------|-----------+              +----------|----------------+  |30# |                 \_____________________________________/                   |31# |                                    |                                      |32# |                                    + $swp3                                |33# |                                    | 1Gbps bottleneck                     |34# |                                    | ETS: (up n->tc n for n in 0..7)      |35# |                                    |      strict priority                 |36# +------------------------------------|--------------------------------------+37#                                      |38#                 +--------------------|--------------------+39#                 |                    + $h3             H3 |40#                 |                   / \                   |41#                 |                  /   \                  |42#                 |         $h3.111 +     + $h3.222         |43#                 |  192.0.2.34/28          192.0.2.66/28   |44#                 +-----------------------------------------+45 46ALL_TESTS="47	ping_ipv448	test_ets_strict49"50 51lib_dir=$(dirname $0)/../../../net/forwarding52 53NUM_NETIFS=654source $lib_dir/lib.sh55source $lib_dir/devlink_lib.sh56source qos_lib.sh57 58h1_create()59{60	simple_if_init $h161	mtu_set $h1 1000062 63	vlan_create $h1 111 v$h1 192.0.2.33/2864	ip link set dev $h1.111 type vlan egress-qos-map 0:165}66 67h1_destroy()68{69	vlan_destroy $h1 11170 71	mtu_restore $h172	simple_if_fini $h173}74 75h2_create()76{77	simple_if_init $h278	mtu_set $h2 1000079 80	vlan_create $h2 222 v$h2 192.0.2.65/2881	ip link set dev $h2.222 type vlan egress-qos-map 0:282}83 84h2_destroy()85{86	vlan_destroy $h2 22287 88	mtu_restore $h289	simple_if_fini $h290}91 92h3_create()93{94	simple_if_init $h395	mtu_set $h3 1000096 97	vlan_create $h3 111 v$h3 192.0.2.34/2898	vlan_create $h3 222 v$h3 192.0.2.66/2899}100 101h3_destroy()102{103	vlan_destroy $h3 222104	vlan_destroy $h3 111105 106	mtu_restore $h3107	simple_if_fini $h3108}109 110switch_create()111{112	ip link set dev $swp1 up113	mtu_set $swp1 10000114 115	ip link set dev $swp2 up116	mtu_set $swp2 10000117 118	# prio n -> TC n, strict scheduling119	lldptool -T -i $swp3 -V ETS-CFG up2tc=0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7120	lldptool -T -i $swp3 -V ETS-CFG tsa=$(121			)"0:strict,"$(122			)"1:strict,"$(123			)"2:strict,"$(124			)"3:strict,"$(125			)"4:strict,"$(126			)"5:strict,"$(127			)"6:strict,"$(128			)"7:strict"129	sleep 1130 131	ip link set dev $swp3 up132	mtu_set $swp3 10000133	tc qdisc replace dev $swp3 root handle 101: tbf rate 1gbit \134		burst 128K limit 1G135 136	vlan_create $swp1 111137	vlan_create $swp2 222138	vlan_create $swp3 111139	vlan_create $swp3 222140 141	ip link add name br111 type bridge vlan_filtering 0142	ip link set dev br111 addrgenmode none143	ip link set dev br111 up144	ip link set dev $swp1.111 master br111145	ip link set dev $swp3.111 master br111146 147	ip link add name br222 type bridge vlan_filtering 0148	ip link set dev br222 addrgenmode none149	ip link set dev br222 up150	ip link set dev $swp2.222 master br222151	ip link set dev $swp3.222 master br222152 153	# Make sure that ingress quotas are smaller than egress so that there is154	# room for both streams of traffic to be admitted to shared buffer.155	devlink_pool_size_thtype_save 0156	devlink_pool_size_thtype_set 0 dynamic 10000000157	devlink_pool_size_thtype_save 4158	devlink_pool_size_thtype_set 4 dynamic 10000000159 160	devlink_port_pool_th_save $swp1 0161	devlink_port_pool_th_set $swp1 0 6162	devlink_tc_bind_pool_th_save $swp1 1 ingress163	devlink_tc_bind_pool_th_set $swp1 1 ingress 0 6164 165	devlink_port_pool_th_save $swp2 0166	devlink_port_pool_th_set $swp2 0 6167	devlink_tc_bind_pool_th_save $swp2 2 ingress168	devlink_tc_bind_pool_th_set $swp2 2 ingress 0 6169 170	devlink_tc_bind_pool_th_save $swp3 1 egress171	devlink_tc_bind_pool_th_set $swp3 1 egress 4 7172	devlink_tc_bind_pool_th_save $swp3 2 egress173	devlink_tc_bind_pool_th_set $swp3 2 egress 4 7174	devlink_port_pool_th_save $swp3 4175	devlink_port_pool_th_set $swp3 4 7176}177 178switch_destroy()179{180	devlink_port_pool_th_restore $swp3 4181	devlink_tc_bind_pool_th_restore $swp3 2 egress182	devlink_tc_bind_pool_th_restore $swp3 1 egress183 184	devlink_tc_bind_pool_th_restore $swp2 2 ingress185	devlink_port_pool_th_restore $swp2 0186 187	devlink_tc_bind_pool_th_restore $swp1 1 ingress188	devlink_port_pool_th_restore $swp1 0189 190	devlink_pool_size_thtype_restore 4191	devlink_pool_size_thtype_restore 0192 193	ip link del dev br222194	ip link del dev br111195 196	vlan_destroy $swp3 222197	vlan_destroy $swp3 111198	vlan_destroy $swp2 222199	vlan_destroy $swp1 111200 201	tc qdisc del dev $swp3 root handle 101:202	mtu_restore $swp3203	ip link set dev $swp3 down204	lldptool -T -i $swp3 -V ETS-CFG up2tc=0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0205 206	mtu_restore $swp2207	ip link set dev $swp2 down208 209	mtu_restore $swp1210	ip link set dev $swp1 down211}212 213setup_prepare()214{215	h1=${NETIFS[p1]}216	swp1=${NETIFS[p2]}217 218	swp2=${NETIFS[p3]}219	h2=${NETIFS[p4]}220 221	swp3=${NETIFS[p5]}222	h3=${NETIFS[p6]}223 224	h3mac=$(mac_get $h3)225 226	vrf_prepare227 228	h1_create229	h2_create230	h3_create231	switch_create232}233 234cleanup()235{236	pre_cleanup237 238	switch_destroy239	h3_destroy240	h2_destroy241	h1_destroy242 243	vrf_cleanup244}245 246ping_ipv4()247{248	ping_test $h1 192.0.2.34 " from H1"249	ping_test $h2 192.0.2.66 " from H2"250}251 252rel()253{254	local old=$1; shift255	local new=$1; shift256 257	bc <<< "258	    scale=2259	    ret = 100 * $new / $old260	    if (ret > 0) { ret } else { 0 }261	"262}263 264test_ets_strict()265{266	RET=0267 268	# Run high-prio traffic on its own.269	start_traffic $h2.222 192.0.2.65 192.0.2.66 $h3mac270	local -a rate_2271	rate_2=($(measure_rate $swp2 $h3 rx_octets_prio_2 "prio 2"))272	check_err $? "Could not get high enough prio-2 ingress rate"273	local rate_2_in=${rate_2[0]}274	local rate_2_eg=${rate_2[1]}275	stop_traffic # $h2.222276 277	# Start low-prio stream.278	start_traffic $h1.111 192.0.2.33 192.0.2.34 $h3mac279 280	local -a rate_1281	rate_1=($(measure_rate $swp1 $h3 rx_octets_prio_1 "prio 1"))282	check_err $? "Could not get high enough prio-1 ingress rate"283	local rate_1_in=${rate_1[0]}284	local rate_1_eg=${rate_1[1]}285 286	# High-prio and low-prio on their own should have about the same287	# throughput.288	local rel21=$(rel $rate_1_eg $rate_2_eg)289	check_err $(bc <<< "$rel21 < 95")290	check_err $(bc <<< "$rel21 > 105")291 292	# Start the high-prio stream--now both streams run.293	start_traffic $h2.222 192.0.2.65 192.0.2.66 $h3mac294	rate_3=($(measure_rate $swp2 $h3 rx_octets_prio_2 "prio 2 w/ 1"))295	check_err $? "Could not get high enough prio-2 ingress rate with prio-1"296	local rate_3_in=${rate_3[0]}297	local rate_3_eg=${rate_3[1]}298	stop_traffic # $h2.222299 300	stop_traffic # $h1.111301 302	# High-prio should have about the same throughput whether or not303	# low-prio is in the system.304	local rel32=$(rel $rate_2_eg $rate_3_eg)305	check_err $(bc <<< "$rel32 < 95")306 307	log_test "strict priority"308	echo "Ingress to switch:"309	echo "  p1 in rate            $(humanize $rate_1_in)"310	echo "  p2 in rate            $(humanize $rate_2_in)"311	echo "  p2 in rate w/ p1      $(humanize $rate_3_in)"312	echo "Egress from switch:"313	echo "  p1 eg rate            $(humanize $rate_1_eg)"314	echo "  p2 eg rate            $(humanize $rate_2_eg) ($rel21% of p1)"315	echo "  p2 eg rate w/ p1      $(humanize $rate_3_eg) ($rel32% of p2)"316}317 318trap cleanup EXIT319 320setup_prepare321setup_wait322 323tests_run324 325exit $EXIT_STATUS326