~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/drivers/net/netdevsim/ethtool-coalesce.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0-only
  3 
  4 source ethtool-common.sh
  5 
  6 function get_value {
  7     local query="${SETTINGS_MAP[$1]}"
  8 
  9     echo $(ethtool -c $NSIM_NETDEV | \
 10         awk -F':' -v pattern="$query:" '$0 ~ pattern {gsub(/[ \t]/, "", $2); print $2}')
 11 }
 12 
 13 function update_current_settings {
 14     for key in ${!SETTINGS_MAP[@]}; do
 15         CURRENT_SETTINGS[$key]=$(get_value $key)
 16     done
 17     echo ${CURRENT_SETTINGS[@]}
 18 }
 19 
 20 if ! ethtool -h | grep -q coalesce; then
 21     echo "SKIP: No --coalesce support in ethtool"
 22     exit 4
 23 fi
 24 
 25 NSIM_NETDEV=$(make_netdev)
 26 
 27 set -o pipefail
 28 
 29 declare -A SETTINGS_MAP=(
 30     ["rx-frames-low"]="rx-frame-low"
 31     ["tx-frames-low"]="tx-frame-low"
 32     ["rx-frames-high"]="rx-frame-high"
 33     ["tx-frames-high"]="tx-frame-high"
 34     ["rx-usecs"]="rx-usecs"
 35     ["rx-frames"]="rx-frames"
 36     ["rx-usecs-irq"]="rx-usecs-irq"
 37     ["rx-frames-irq"]="rx-frames-irq"
 38     ["tx-usecs"]="tx-usecs"
 39     ["tx-frames"]="tx-frames"
 40     ["tx-usecs-irq"]="tx-usecs-irq"
 41     ["tx-frames-irq"]="tx-frames-irq"
 42     ["stats-block-usecs"]="stats-block-usecs"
 43     ["pkt-rate-low"]="pkt-rate-low"
 44     ["rx-usecs-low"]="rx-usecs-low"
 45     ["tx-usecs-low"]="tx-usecs-low"
 46     ["pkt-rate-high"]="pkt-rate-high"
 47     ["rx-usecs-high"]="rx-usecs-high"
 48     ["tx-usecs-high"]="tx-usecs-high"
 49     ["sample-interval"]="sample-interval"
 50 )
 51 
 52 declare -A CURRENT_SETTINGS=(
 53     ["rx-frames-low"]=""
 54     ["tx-frames-low"]=""
 55     ["rx-frames-high"]=""
 56     ["tx-frames-high"]=""
 57     ["rx-usecs"]=""
 58     ["rx-frames"]=""
 59     ["rx-usecs-irq"]=""
 60     ["rx-frames-irq"]=""
 61     ["tx-usecs"]=""
 62     ["tx-frames"]=""
 63     ["tx-usecs-irq"]=""
 64     ["tx-frames-irq"]=""
 65     ["stats-block-usecs"]=""
 66     ["pkt-rate-low"]=""
 67     ["rx-usecs-low"]=""
 68     ["tx-usecs-low"]=""
 69     ["pkt-rate-high"]=""
 70     ["rx-usecs-high"]=""
 71     ["tx-usecs-high"]=""
 72     ["sample-interval"]=""
 73 )
 74 
 75 declare -A EXPECTED_SETTINGS=(
 76     ["rx-frames-low"]=""
 77     ["tx-frames-low"]=""
 78     ["rx-frames-high"]=""
 79     ["tx-frames-high"]=""
 80     ["rx-usecs"]=""
 81     ["rx-frames"]=""
 82     ["rx-usecs-irq"]=""
 83     ["rx-frames-irq"]=""
 84     ["tx-usecs"]=""
 85     ["tx-frames"]=""
 86     ["tx-usecs-irq"]=""
 87     ["tx-frames-irq"]=""
 88     ["stats-block-usecs"]=""
 89     ["pkt-rate-low"]=""
 90     ["rx-usecs-low"]=""
 91     ["tx-usecs-low"]=""
 92     ["pkt-rate-high"]=""
 93     ["rx-usecs-high"]=""
 94     ["tx-usecs-high"]=""
 95     ["sample-interval"]=""
 96 )
 97 
 98 # populate the expected settings map
 99 for key in ${!SETTINGS_MAP[@]}; do
100     EXPECTED_SETTINGS[$key]=$(get_value $key)
101 done
102 
103 # test
104 for key in ${!SETTINGS_MAP[@]}; do
105     value=$((RANDOM % $((2**32-1))))
106 
107     ethtool -C $NSIM_NETDEV "$key" "$value"
108 
109     EXPECTED_SETTINGS[$key]="$value"
110     expected=${EXPECTED_SETTINGS[@]}
111     current=$(update_current_settings)
112 
113     check $? "$current" "$expected"
114     set +x
115 done
116 
117 # bool settings which ethtool displays on the same line
118 ethtool -C $NSIM_NETDEV adaptive-rx on
119 s=$(ethtool -c $NSIM_NETDEV | grep -q "Adaptive RX: on  TX: off")
120 check $? "$s" ""
121 
122 ethtool -C $NSIM_NETDEV adaptive-tx on
123 s=$(ethtool -c $NSIM_NETDEV | grep -q "Adaptive RX: on  TX: on")
124 check $? "$s" ""
125 
126 if [ $num_errors -eq 0 ]; then
127     echo "PASSED all $((num_passes)) checks"
128     exit 0
129 else
130     echo "FAILED $num_errors/$((num_errors+num_passes)) checks"
131     exit 1
132 fi

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php