blob: c580ad62384836857a06a574add5a5111f1bb438 (
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
280
281
282
283
284
285
286
287
288
|
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
ALL_TESTS="
manual_with_verification_h1_to_h2
manual_with_verification_h2_to_h1
manual_without_verification_h1_to_h2
manual_without_verification_h2_to_h1
manual_failed_verification_h1_to_h2
manual_failed_verification_h2_to_h1
lldp
"
NUM_NETIFS=2
REQUIRE_MZ=no
PREEMPTIBLE_PRIO=0
source lib.sh
traffic_test()
{
local if=$1; shift
local src=$1; shift
local num_pkts=10000
local before=
local after=
local delta=
before=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOK" $src)
$MZ $if -q -c $num_pkts -p 64 -b bcast -t ip -R $PREEMPTIBLE_PRIO
after=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOK" $src)
delta=$((after - before))
# Allow an extra 1% tolerance for random packets sent by the stack
[ $delta -ge $num_pkts ] && [ $delta -le $((num_pkts + 100)) ]
}
manual_with_verification()
{
local tx=$1; shift
local rx=$1; shift
RET=0
# It isn't completely clear from IEEE 802.3-2018 Figure 99-5: Transmit
# Processing state diagram whether the "send_r" variable (send response
# to verification frame) should be taken into consideration while the
# MAC Merge TX direction is disabled. That being said, at least the
# NXP ENETC does not, and requires tx-enabled on in order to respond to
# the link partner's verification frames.
ethtool --set-mm $rx tx-enabled on
ethtool --set-mm $tx verify-enabled on tx-enabled on
# Wait for verification to finish
sleep 1
ethtool --json --show-mm $tx | jq -r '.[]."verify-status"' | \
grep -q 'SUCCEEDED'
check_err "$?" "Verification did not succeed"
ethtool --json --show-mm $tx | jq -r '.[]."tx-active"' | grep -q 'true'
check_err "$?" "pMAC TX is not active"
traffic_test $tx "pmac"
check_err "$?" "Traffic did not get sent through $tx's pMAC"
ethtool --set-mm $tx verify-enabled off tx-enabled off
ethtool --set-mm $rx tx-enabled off
log_test "Manual configuration with verification: $tx to $rx"
}
manual_with_verification_h1_to_h2()
{
manual_with_verification $h1 $h2
}
manual_with_verification_h2_to_h1()
{
manual_with_verification $h2 $h1
}
manual_without_verification()
{
local tx=$1; shift
local rx=$1; shift
RET=0
ethtool --set-mm $tx verify-enabled off tx-enabled on
ethtool --json --show-mm $tx | jq -r '.[]."verify-status"' | \
grep -q 'DISABLED'
check_err "$?" "Verification is not disabled"
ethtool --json --show-mm $tx | jq -r '.[]."tx-active"' | grep -q 'true'
check_err "$?" "pMAC TX is not active"
traffic_test $tx "pmac"
check_err "$?" "Traffic did not get sent through $tx's pMAC"
ethtool --set-mm $tx verify-enabled off tx-enabled off
log_test "Manual configuration without verification: $tx to $rx"
}
manual_without_verification_h1_to_h2()
{
manual_without_verification $h1 $h2
}
manual_without_verification_h2_to_h1()
{
manual_without_verification $h2 $h1
}
manual_failed_verification()
{
local tx=$1; shift
local rx=$1; shift
RET=0
ethtool --set-mm $rx pmac-enabled off
ethtool --set-mm $tx verify-enabled on tx-enabled on
# Wait for verification to time out
sleep 1
ethtool --json --show-mm $tx | jq -r '.[]."verify-status"' | \
grep -q 'SUCCEEDED'
check_fail "$?" "Verification succeeded when it shouldn't have"
ethtool --json --show-mm $tx | jq -r '.[]."tx-active"' | grep -q 'true'
check_fail "$?" "pMAC TX is active when it shouldn't have"
traffic_test $tx "emac"
check_err "$?" "Traffic did not get sent through $tx's eMAC"
ethtool --set-mm $tx verify-enabled off tx-enabled off
ethtool --set-mm $rx pmac-enabled on
log_test "Manual configuration with failed verification: $tx to $rx"
}
manual_failed_verification_h1_to_h2()
{
manual_failed_verification $h1 $h2
}
manual_failed_verification_h2_to_h1()
{
manual_failed_verification $h2 $h1
}
lldp_change_add_frag_size()
{
local add_frag_size=$1
lldptool -T -i $h1 -V addEthCaps addFragSize=$add_frag_size >/dev/null
# Wait for TLVs to be received
sleep 2
lldptool -i $h2 -t -n -V addEthCaps | \
grep -q "Additional fragment size: $add_frag_size"
}
lldp()
{
RET=0
systemctl start lldpad
# Configure the interfaces to receive and transmit LLDPDUs
lldptool -L -i $h1 adminStatus=rxtx >/dev/null
lldptool -L -i $h2 adminStatus=rxtx >/dev/null
# Enable the transmission of Additional Ethernet Capabilities TLV
lldptool -T -i $h1 -V addEthCaps enableTx=yes >/dev/null
lldptool -T -i $h2 -V addEthCaps enableTx=yes >/dev/null
# Wait for TLVs to be received
sleep 2
lldptool -i $h1 -t -n -V addEthCaps | \
grep -q "Preemption capability active"
check_err "$?" "$h1 pMAC TX is not active"
lldptool -i $h2 -t -n -V addEthCaps | \
grep -q "Preemption capability active"
check_err "$?" "$h2 pMAC TX is not active"
lldp_change_add_frag_size 3
check_err "$?" "addFragSize 3"
lldp_change_add_frag_size 2
check_err "$?" "addFragSize 2"
lldp_change_add_frag_size 1
check_err "$?" "addFragSize 1"
lldp_change_add_frag_size 0
check_err "$?" "addFragSize 0"
traffic_test $h1 "pmac"
check_err "$?" "Traffic did not get sent through $h1's pMAC"
traffic_test $h2 "pmac"
check_err "$?" "Traffic did not get sent through $h2's pMAC"
systemctl stop lldpad
log_test "LLDP"
}
h1_create()
{
ip link set dev $h1 up
tc qdisc add dev $h1 root mqprio num_tc 4 map 0 1 2 3 \
queues 1@0 1@1 1@2 1@3 \
fp P E E E \
hw 1
ethtool --set-mm $h1 pmac-enabled on tx-enabled off verify-enabled off
}
h2_create()
{
ip link set dev $h2 up
ethtool --set-mm $h2 pmac-enabled on tx-enabled off verify-enabled off
tc qdisc add dev $h2 root mqprio num_tc 4 map 0 1 2 3 \
queues 1@0 1@1 1@2 1@3 \
fp P E E E \
hw 1
}
h1_destroy()
{
ethtool --set-mm $h1 pmac-enabled off tx-enabled off verify-enabled off
tc qdisc del dev $h1 root
ip link set dev $h1 down
}
h2_destroy()
{
tc qdisc del dev $h2 root
ethtool --set-mm $h2 pmac-enabled off tx-enabled off verify-enabled off
ip link set dev $h2 down
}
setup_prepare()
{
check_ethtool_mm_support
check_tc_fp_support
require_command lldptool
bail_on_lldpad "autoconfigure the MAC Merge layer" "configure it manually"
h1=${NETIFS[p1]}
h2=${NETIFS[p2]}
h1_create
h2_create
}
cleanup()
{
pre_cleanup
h2_destroy
h1_destroy
}
trap cleanup EXIT
setup_prepare
setup_wait
tests_run
exit $EXIT_STATUS
|