staging: rtl8192u: remove redundant assignment to pointer crypt
[linux/fpc-iii.git] / tools / testing / selftests / drivers / net / mlxsw / qos_dscp_bridge.sh
blob40f16f2a3afdd3359ccae8be16f42023cef2aea1
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # Test for DSCP prioritization and rewrite. Packets ingress $swp1 with a DSCP
5 # tag and are prioritized according to the map at $swp1. They egress $swp2 and
6 # the DSCP value is updated to match the map at that interface. The updated DSCP
7 # tag is verified at $h2.
9 # ICMP responses are produced with the same DSCP tag that arrived at $h2. They
10 # go through prioritization at $swp2 and DSCP retagging at $swp1. The tag is
11 # verified at $h1--it should match the original tag.
13 # +----------------------+ +----------------------+
14 # | H1 | | H2 |
15 # | + $h1 | | $h2 + |
16 # | | 192.0.2.1/28 | | 192.0.2.2/28 | |
17 # +----|-----------------+ +----------------|-----+
18 # | |
19 # +----|----------------------------------------------------------------|-----+
20 # | SW | | |
21 # | +-|----------------------------------------------------------------|-+ |
22 # | | + $swp1 BR $swp2 + | |
23 # | | APP=0,5,10 .. 7,5,17 APP=0,5,20 .. 7,5,27 | |
24 # | +--------------------------------------------------------------------+ |
25 # +---------------------------------------------------------------------------+
27 ALL_TESTS="
28 ping_ipv4
29 test_dscp
32 lib_dir=$(dirname $0)/../../../net/forwarding
34 NUM_NETIFS=4
35 source $lib_dir/lib.sh
37 h1_create()
39 local dscp;
41 simple_if_init $h1 192.0.2.1/28
42 tc qdisc add dev $h1 clsact
43 dscp_capture_install $h1 10
46 h1_destroy()
48 dscp_capture_uninstall $h1 10
49 tc qdisc del dev $h1 clsact
50 simple_if_fini $h1 192.0.2.1/28
53 h2_create()
55 simple_if_init $h2 192.0.2.2/28
56 tc qdisc add dev $h2 clsact
57 dscp_capture_install $h2 20
60 h2_destroy()
62 dscp_capture_uninstall $h2 20
63 tc qdisc del dev $h2 clsact
64 simple_if_fini $h2 192.0.2.2/28
67 dscp_map()
69 local base=$1; shift
71 for prio in {0..7}; do
72 echo app=$prio,5,$((base + prio))
73 done
76 switch_create()
78 ip link add name br1 type bridge vlan_filtering 1
79 ip link set dev br1 up
80 ip link set dev $swp1 master br1
81 ip link set dev $swp1 up
82 ip link set dev $swp2 master br1
83 ip link set dev $swp2 up
85 lldptool -T -i $swp1 -V APP $(dscp_map 10) >/dev/null
86 lldptool -T -i $swp2 -V APP $(dscp_map 20) >/dev/null
87 lldpad_app_wait_set $swp1
88 lldpad_app_wait_set $swp2
91 switch_destroy()
93 lldptool -T -i $swp2 -V APP -d $(dscp_map 20) >/dev/null
94 lldptool -T -i $swp1 -V APP -d $(dscp_map 10) >/dev/null
95 lldpad_app_wait_del
97 ip link set dev $swp2 nomaster
98 ip link set dev $swp1 nomaster
99 ip link del dev br1
102 setup_prepare()
104 h1=${NETIFS[p1]}
105 swp1=${NETIFS[p2]}
107 swp2=${NETIFS[p3]}
108 h2=${NETIFS[p4]}
110 vrf_prepare
112 h1_create
113 h2_create
114 switch_create
117 cleanup()
119 pre_cleanup
121 switch_destroy
122 h2_destroy
123 h1_destroy
125 vrf_cleanup
128 ping_ipv4()
130 ping_test $h1 192.0.2.2
133 dscp_ping_test()
135 local vrf_name=$1; shift
136 local sip=$1; shift
137 local dip=$1; shift
138 local prio=$1; shift
139 local dev_10=$1; shift
140 local dev_20=$1; shift
142 local dscp_10=$(((prio + 10) << 2))
143 local dscp_20=$(((prio + 20) << 2))
145 RET=0
147 local -A t0s
148 eval "t0s=($(dscp_fetch_stats $dev_10 10)
149 $(dscp_fetch_stats $dev_20 20))"
151 local ping_timeout=$((PING_TIMEOUT * 5))
152 ip vrf exec $vrf_name \
153 ${PING} -Q $dscp_10 ${sip:+-I $sip} $dip \
154 -c 10 -i 0.5 -w $ping_timeout &> /dev/null
156 local -A t1s
157 eval "t1s=($(dscp_fetch_stats $dev_10 10)
158 $(dscp_fetch_stats $dev_20 20))"
160 for key in ${!t0s[@]}; do
161 local expect
162 if ((key == prio+10 || key == prio+20)); then
163 expect=10
164 else
165 expect=0
168 local delta=$((t1s[$key] - t0s[$key]))
169 ((expect == delta))
170 check_err $? "DSCP $key: Expected to capture $expect packets, got $delta."
171 done
173 log_test "DSCP rewrite: $dscp_10-(prio $prio)-$dscp_20"
176 test_dscp()
178 for prio in {0..7}; do
179 dscp_ping_test v$h1 192.0.2.1 192.0.2.2 $prio $h1 $h2
180 done
183 trap cleanup EXIT
185 setup_prepare
186 setup_wait
188 tests_run
190 exit $EXIT_STATUS