2 # SPDX-License-Identifier: GPL-2.0
10 lib_dir
=$
(dirname "$0")
11 source "$lib_dir"/..
/..
/..
/net
/forwarding
/lib.sh
22 local current
=$
(ip
-j link show dev
$iface | jq
-r '.[0].mtu')
23 local required
=$
((len
- ETH_HLEN
- ETH_FCS_LEN
))
25 if [ $current -lt $required ]; then
26 ip link
set dev
$iface mtu
$required ||
return 1
35 local bucket
=$1; shift
44 # Mausezahn does not include FCS bytes in its length - but the
45 # histogram counters do
46 len
=$
((len
- ETH_FCS_LEN
))
47 len
=$
((len
> 0 ? len
: 0))
49 before
=$
(ethtool
--json -S $iface --groups rmon | \
50 jq
-r ".[0].rmon[\"${set}-pktsNtoM\"][$bucket].val")
52 # Send 10k one way and 20k in the other, to detect counters
53 # mapped to the wrong direction
54 $MZ $neigh -q -c $num_rx -p $len -a own
-b bcast
-d 10us
55 $MZ $iface -q -c $num_tx -p $len -a own
-b bcast
-d 10us
57 after
=$
(ethtool
--json -S $iface --groups rmon | \
58 jq
-r ".[0].rmon[\"${set}-pktsNtoM\"][$bucket].val")
60 delta
=$
((after
- before
))
62 expected
=$
([ $set = rx
] && echo $num_rx ||
echo $num_tx)
64 # Allow some extra tolerance for other packets sent by the stack
65 [ $delta -ge $expected ] && [ $delta -le $
((expected
+ 100)) ]
78 while read -r -a bucket
; do
79 step
="$set-pkts${bucket[0]}to${bucket[1]} on $iface"
81 for if in $iface $neigh; do
82 if ! ensure_mtu
$if ${bucket[0]}; then
83 log_test_xfail
"$if does not support the required MTU for $step"
88 if ! bucket_test
$iface $neigh $set $nbuckets ${bucket[0]}; then
89 check_err
1 "$step failed"
93 nbuckets
=$
((nbuckets
+ 1))
94 done < <(ethtool
--json -S $iface --groups rmon | \
95 jq
-r ".[0].rmon[\"${set}-pktsNtoM\"][]|[.low, .high]|@tsv" 2>/dev
/null
)
97 if [ $nbuckets -eq 0 ]; then
98 log_test_xfail
"$iface does not support $set histogram counters"
105 rmon_histogram
$h1 $h2 rx
106 rmon_histogram
$h2 $h1 rx
111 rmon_histogram
$h1 $h2 tx
112 rmon_histogram
$h2 $h1 tx
120 for iface
in $h1 $h2; do
121 netif_mtu
[$iface]=$
(ip
-j link show dev
$iface | jq
-r '.[0].mtu')
122 ip link
set dev
$iface up
130 for iface
in $h2 $h1; do
131 ip link
set dev
$iface \
132 mtu
${netif_mtu[$iface]} \
137 check_ethtool_counter_group_support