blob: 8f9922c695b0ca16435365e8fe0e71af747fec9e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
|
# SPDX-License-Identifier: GPL-2.0
# This is a template for ETS Qdisc test.
#
# This test sends from H1 several traffic streams with 802.1p-tagged packets.
# The tags are used at $swp1 to prioritize the traffic. Each stream is then
# queued at a different ETS band according to the assigned priority. After
# runnig for a while, counters at H2 are consulted to determine whether the
# traffic scheduling was according to the ETS configuration.
#
# This template is supposed to be embedded by a test driver, which implements
# statistics collection, any HW-specific stuff, and prominently configures the
# system to assure that there is overcommitment at $swp2. That is necessary so
# that the ETS traffic selection algorithm kicks in and has to schedule some
# traffic at the expense of other.
#
# A driver for veth-based testing is in sch_ets.sh, an example of a driver for
# an offloaded data path is in selftests/drivers/net/mlxsw/sch_ets.sh.
#
# +---------------------------------------------------------------------+
# | H1 |
# | + $h1.10 + $h1.11 + $h1.12 |
# | | 192.0.2.1/28 | 192.0.2.17/28 | 192.0.2.33/28 |
# | | egress-qos-map | egress-qos-map | egress-qos-map |
# | | 0:0 | 0:1 | 0:2 |
# | \____________________ | ____________________/ |
# | \|/ |
# | + $h1 |
# +---------------------------|-----------------------------------------+
# |
# +---------------------------|-----------------------------------------+
# | SW + $swp1 |
# | | >1Gbps |
# | ____________________/|\____________________ |
# | / | \ |
# | +--|----------------+ +--|----------------+ +--|----------------+ |
# | | + $swp1.10 | | + $swp1.11 | | + $swp1.12 | |
# | | ingress-qos-map| | ingress-qos-map| | ingress-qos-map| |
# | | 0:0 1:1 2:2 | | 0:0 1:1 2:2 | | 0:0 1:1 2:2 | |
# | | | | | | | |
# | | BR10 | | BR11 | | BR12 | |
# | | | | | | | |
# | | + $swp2.10 | | + $swp2.11 | | + $swp2.12 | |
# | +--|----------------+ +--|----------------+ +--|----------------+ |
# | \____________________ | ____________________/ |
# | \|/ |
# | + $swp2 |
# | | 1Gbps (ethtool or HTB qdisc) |
# | | qdisc ets quanta $W0 $W1 $W2 |
# | | priomap 0 1 2 |
# +---------------------------|-----------------------------------------+
# |
# +---------------------------|-----------------------------------------+
# | H2 + $h2 |
# | ____________________/|\____________________ |
# | / | \ |
# | + $h2.10 + $h2.11 + $h2.12 |
# | 192.0.2.2/28 192.0.2.18/28 192.0.2.34/28 |
# +---------------------------------------------------------------------+
NUM_NETIFS=4
CHECK_TC=yes
source $lib_dir/lib.sh
source $lib_dir/sch_ets_tests.sh
PARENT=root
QDISC_DEV=
sip()
{
echo 192.0.2.$((16 * $1 + 1))
}
dip()
{
echo 192.0.2.$((16 * $1 + 2))
}
# Callback from sch_ets_tests.sh
ets_start_traffic()
{
local dst_mac=$(mac_get $h2)
local i=$1; shift
start_traffic $h1.1$i $(sip $i) $(dip $i) $dst_mac
}
ETS_CHANGE_QDISC=
priomap_mode()
{
echo "Running in priomap mode"
ets_delete_qdisc
ETS_CHANGE_QDISC=ets_change_qdisc_priomap
}
classifier_mode()
{
echo "Running in classifier mode"
ets_delete_qdisc
ETS_CHANGE_QDISC=ets_change_qdisc_classifier
}
ets_change_qdisc_priomap()
{
local dev=$1; shift
local nstrict=$1; shift
local priomap=$1; shift
local quanta=("${@}")
local op=$(if [[ -n $QDISC_DEV ]]; then echo change; else echo add; fi)
tc qdisc $op dev $dev $PARENT handle 10: ets \
$(if ((nstrict)); then echo strict $nstrict; fi) \
$(if ((${#quanta[@]})); then echo quanta ${quanta[@]}; fi) \
priomap $priomap
QDISC_DEV=$dev
}
ets_change_qdisc_classifier()
{
local dev=$1; shift
local nstrict=$1; shift
local priomap=$1; shift
local quanta=("${@}")
local op=$(if [[ -n $QDISC_DEV ]]; then echo change; else echo add; fi)
tc qdisc $op dev $dev $PARENT handle 10: ets \
$(if ((nstrict)); then echo strict $nstrict; fi) \
$(if ((${#quanta[@]})); then echo quanta ${quanta[@]}; fi)
if [[ $op == add ]]; then
local prio=0
local band
for band in $priomap; do
tc filter add dev $dev parent 10: basic \
match "meta(priority eq $prio)" \
flowid 10:$((band + 1))
((prio++))
done
fi
QDISC_DEV=$dev
}
# Callback from sch_ets_tests.sh
ets_change_qdisc()
{
if [[ -z "$ETS_CHANGE_QDISC" ]]; then
exit 1
fi
$ETS_CHANGE_QDISC "$@"
}
ets_delete_qdisc()
{
if [[ -n $QDISC_DEV ]]; then
tc qdisc del dev $QDISC_DEV $PARENT
QDISC_DEV=
fi
}
h1_create()
{
local i;
simple_if_init $h1
defer simple_if_fini $h1
mtu_set $h1 9900
defer mtu_restore $h1
for i in {0..2}; do
vlan_create $h1 1$i v$h1 $(sip $i)/28
defer vlan_destroy $h1 1$i
ip link set dev $h1.1$i type vlan egress 0:$i
done
}
h2_create()
{
local i
simple_if_init $h2
defer simple_if_fini $h2
mtu_set $h2 9900
defer mtu_restore $h2
for i in {0..2}; do
vlan_create $h2 1$i v$h2 $(dip $i)/28
defer vlan_destroy $h2 1$i
done
}
ets_switch_create()
{
local i
ip link set dev $swp1 up
defer ip link set dev $swp1 down
mtu_set $swp1 9900
defer mtu_restore $swp1
ip link set dev $swp2 up
defer ip link set dev $swp2 down
mtu_set $swp2 9900
defer mtu_restore $swp2
for i in {0..2}; do
vlan_create $swp1 1$i
defer vlan_destroy $swp1 1$i
ip link set dev $swp1.1$i type vlan ingress 0:0 1:1 2:2
vlan_create $swp2 1$i
defer vlan_destroy $swp2 1$i
ip link add dev br1$i type bridge
defer ip link del dev br1$i
ip link set dev $swp1.1$i master br1$i
defer ip link set dev $swp1.1$i nomaster
ip link set dev $swp2.1$i master br1$i
defer ip link set dev $swp2.1$i nomaster
ip link set dev br1$i up
defer ip link set dev br1$i down
ip link set dev $swp1.1$i up
defer ip link set dev $swp1.1$i down
ip link set dev $swp2.1$i up
defer ip link set dev $swp2.1$i down
done
defer ets_delete_qdisc
}
setup_prepare()
{
h1=${NETIFS[p1]}
swp1=${NETIFS[p2]}
swp2=${NETIFS[p3]}
h2=${NETIFS[p4]}
put=$swp2
hut=$h2
vrf_prepare
defer vrf_cleanup
h1_create
h2_create
switch_create
}
ping_ipv4()
{
ping_test $h1.10 $(dip 0) " vlan 10"
ping_test $h1.11 $(dip 1) " vlan 11"
ping_test $h1.12 $(dip 2) " vlan 12"
}
ets_run()
{
trap cleanup EXIT
setup_prepare
setup_wait
tests_run
exit $EXIT_STATUS
}
|