Skip to content

Commit 2491d66

Browse files
vladimirolteandavem330
authored andcommitted
selftests: forwarding: ethtool_mm: support devices with higher rx-min-frag-size
Some devices have errata due to which they cannot report ETH_ZLEN (60) in the rx-min-frag-size. This was foreseen of course, and lldpad has logic that when we request it to advertise addFragSize 0, it will round it up to the lowest value that is _actually_ supported by the hardware. The problem is that the selftest expects lldpad to report back to us the same value as we requested. Make the selftest smarter by figuring out on its own what is a reasonable value to expect. Cc: Shuah Khan <[email protected]> Signed-off-by: Vladimir Oltean <[email protected]> Tested-by: Roger Quadros <[email protected]> Signed-off-by: Roger Quadros <[email protected]> Tested-by: Vladimir Oltean <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2437c0f commit 2491d66

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

tools/testing/selftests/net/forwarding/ethtool_mm.sh

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,48 @@ manual_failed_verification_h2_to_h1()
155155
manual_failed_verification $h2 $h1
156156
}
157157

158+
smallest_supported_add_frag_size()
159+
{
160+
local iface=$1
161+
local rx_min_frag_size=
162+
163+
rx_min_frag_size=$(ethtool --json --show-mm $iface | \
164+
jq '.[]."rx-min-frag-size"')
165+
166+
if [ $rx_min_frag_size -le 60 ]; then
167+
echo 0
168+
elif [ $rx_min_frag_size -le 124 ]; then
169+
echo 1
170+
elif [ $rx_min_frag_size -le 188 ]; then
171+
echo 2
172+
elif [ $rx_min_frag_size -le 252 ]; then
173+
echo 3
174+
else
175+
echo "$iface: RX min frag size $rx_min_frag_size cannot be advertised over LLDP"
176+
exit 1
177+
fi
178+
}
179+
180+
expected_add_frag_size()
181+
{
182+
local iface=$1
183+
local requested=$2
184+
local min=$(smallest_supported_add_frag_size $iface)
185+
186+
[ $requested -le $min ] && echo $min || echo $requested
187+
}
188+
158189
lldp_change_add_frag_size()
159190
{
160191
local add_frag_size=$1
192+
local pattern=
161193

162194
lldptool -T -i $h1 -V addEthCaps addFragSize=$add_frag_size >/dev/null
163195
# Wait for TLVs to be received
164196
sleep 2
165-
lldptool -i $h2 -t -n -V addEthCaps | \
166-
grep -q "Additional fragment size: $add_frag_size"
197+
pattern=$(printf "Additional fragment size: %d" \
198+
$(expected_add_frag_size $h1 $add_frag_size))
199+
lldptool -i $h2 -t -n -V addEthCaps | grep -q "$pattern"
167200
}
168201

169202
lldp()

0 commit comments

Comments
 (0)