2 # SPDX-License-Identifier: GPL-2.0
5 manual_with_verification_h1_to_h2
6 manual_with_verification_h2_to_h1
7 manual_without_verification_h1_to_h2
8 manual_without_verification_h2_to_h1
9 manual_failed_verification_h1_to_h2
10 manual_failed_verification_h2_to_h1
28 before=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOK" $src)
30 $MZ $if -q -c $num_pkts -p 64 -b bcast -t ip -R $PREEMPTIBLE_PRIO
32 after=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOK" $src)
34 delta=$((after - before))
36 # Allow an extra 1% tolerance for random packets sent by the stack
37 [ $delta -ge $num_pkts ] && [ $delta -le $((num_pkts + 100)) ]
40 manual_with_verification()
47 # It isn't completely clear from IEEE 802.3-2018 Figure 99-5: Transmit
48 # Processing state diagram whether the "send_r" variable (send response
49 # to verification frame) should be taken into consideration while the
50 # MAC Merge TX direction is disabled. That being said, at least the
51 # NXP ENETC does not, and requires tx-enabled on in order to respond to
52 # the link partner's verification frames.
53 ethtool --set-mm $rx tx-enabled on
54 ethtool --set-mm $tx verify-enabled on tx-enabled on
56 # Wait for verification to finish
59 ethtool --json --show-mm $tx | jq -r '.[]."verify-status"' | \
61 check_err "$?" "Verification did not succeed"
63 ethtool --json --show-mm $tx | jq -r '.[]."tx-active"' | grep -q 'true'
64 check_err "$?" "pMAC TX is not active"
66 traffic_test $tx "pmac"
67 check_err "$?" "Traffic did not get sent through $tx's pMAC"
69 ethtool --set-mm $tx verify-enabled off tx-enabled off
70 ethtool --set-mm $rx tx-enabled off
72 log_test "Manual configuration with verification: $tx to $rx"
75 manual_with_verification_h1_to_h2()
77 manual_with_verification $h1 $h2
80 manual_with_verification_h2_to_h1()
82 manual_with_verification $h2 $h1
85 manual_without_verification()
92 ethtool --set-mm $tx verify-enabled off tx-enabled on
94 ethtool --json --show-mm $tx | jq -r '.[]."verify-status"' | \
96 check_err "$?" "Verification is not disabled"
98 ethtool --json --show-mm $tx | jq -r '.[]."tx-active"' | grep -q 'true'
99 check_err "$?" "pMAC TX is not active"
101 traffic_test $tx "pmac"
102 check_err "$?" "Traffic did not get sent through $tx's pMAC"
104 ethtool --set-mm $tx verify-enabled off tx-enabled off
106 log_test "Manual configuration without verification: $tx to $rx"
109 manual_without_verification_h1_to_h2()
111 manual_without_verification $h1 $h2
114 manual_without_verification_h2_to_h1()
116 manual_without_verification $h2 $h1
119 manual_failed_verification()
126 ethtool --set-mm $rx pmac-enabled off
127 ethtool --set-mm $tx verify-enabled on tx-enabled on
129 # Wait for verification to time out
132 ethtool --json --show-mm $tx | jq -r '.[]."verify-status"' | \
134 check_fail "$?" "Verification succeeded when it shouldn't have"
136 ethtool --json --show-mm $tx | jq -r '.[]."tx-active"' | grep -q 'true'
137 check_fail "$?" "pMAC TX is active when it shouldn't have"
139 traffic_test $tx "emac"
140 check_err "$?" "Traffic did not get sent through $tx's eMAC"
142 ethtool --set-mm $tx verify-enabled off tx-enabled off
143 ethtool --set-mm $rx pmac-enabled on
145 log_test "Manual configuration with failed verification: $tx to $rx"
148 manual_failed_verification_h1_to_h2()
150 manual_failed_verification $h1 $h2
153 manual_failed_verification_h2_to_h1()
155 manual_failed_verification $h2 $h1
158 lldp_change_add_frag_size()
160 local add_frag_size=$1
162 lldptool -T -i $h1 -V addEthCaps addFragSize=$add_frag_size >/dev/null
163 # Wait for TLVs to be received
165 lldptool -i $h2 -t -n -V addEthCaps | \
166 grep -q "Additional fragment size: $add_frag_size"
173 systemctl start lldpad
175 # Configure the interfaces to receive and transmit LLDPDUs
176 lldptool -L -i $h1 adminStatus=rxtx >/dev/null
177 lldptool -L -i $h2 adminStatus=rxtx >/dev/null
179 # Enable the transmission of Additional Ethernet Capabilities TLV
180 lldptool -T -i $h1 -V addEthCaps enableTx=yes >/dev/null
181 lldptool -T -i $h2 -V addEthCaps enableTx=yes >/dev/null
183 # Wait for TLVs to be received
186 lldptool -i $h1 -t -n -V addEthCaps | \
187 grep -q "Preemption capability active"
188 check_err "$?" "$h1 pMAC TX is not active"
190 lldptool -i $h2 -t -n -V addEthCaps | \
191 grep -q "Preemption capability active"
192 check_err "$?" "$h2 pMAC TX is not active"
194 lldp_change_add_frag_size 3
195 check_err "$?" "addFragSize 3"
197 lldp_change_add_frag_size 2
198 check_err "$?" "addFragSize 2"
200 lldp_change_add_frag_size 1
201 check_err "$?" "addFragSize 1"
203 lldp_change_add_frag_size 0
204 check_err "$?" "addFragSize 0"
206 traffic_test $h1 "pmac"
207 check_err "$?" "Traffic did not get sent through $h1's pMAC"
209 traffic_test $h2 "pmac"
210 check_err "$?" "Traffic did not get sent through $h2's pMAC"
212 systemctl stop lldpad
219 ip link set dev $h1 up
221 tc qdisc add dev $h1 root mqprio num_tc 4 map 0 1 2 3 \
222 queues 1@0 1@1 1@2 1@3 \
226 ethtool --set-mm $h1 pmac-enabled on tx-enabled off verify-enabled off
231 ip link set dev $h2 up
233 ethtool --set-mm $h2 pmac-enabled on tx-enabled off verify-enabled off
235 tc qdisc add dev $h2 root mqprio num_tc 4 map 0 1 2 3 \
236 queues 1@0 1@1 1@2 1@3 \
243 ethtool --set-mm $h1 pmac-enabled off tx-enabled off verify-enabled off
245 tc qdisc del dev $h1 root
247 ip link set dev $h1 down
252 tc qdisc del dev $h2 root
254 ethtool --set-mm $h2 pmac-enabled off tx-enabled off verify-enabled off
256 ip link set dev $h2 down
276 check_ethtool_mm_support
278 require_command lldptool
279 bail_on_lldpad "autoconfigure the MAC Merge layer" "configure it manually"
281 for netif in ${NETIFS[@]}; do
282 ethtool --show-mm $netif 2>&1 &> /dev/null
283 if [[ $? -ne 0 ]]; then
284 echo "SKIP: $netif does not support MAC Merge"