1 #!/bin/bash 1 #!/bin/bash 2 # SPDX-License-Identifier: GPL-2.0-only 2 # SPDX-License-Identifier: GPL-2.0-only 3 3 4 source ethtool-common.sh 4 source ethtool-common.sh 5 5 6 set -o pipefail 6 set -o pipefail 7 7 8 n_children() { 8 n_children() { 9 n=$(tc qdisc show dev $NDEV | grep '^qdisc 9 n=$(tc qdisc show dev $NDEV | grep '^qdisc' | wc -l) 10 echo $((n - 1)) 10 echo $((n - 1)) 11 } 11 } 12 12 13 tcq() { 13 tcq() { 14 tc qdisc $1 dev $NDEV ${@:2} 14 tc qdisc $1 dev $NDEV ${@:2} 15 } 15 } 16 16 17 n_child_assert() { 17 n_child_assert() { 18 n=$(n_children) 18 n=$(n_children) 19 if [ $n -ne $1 ]; then 19 if [ $n -ne $1 ]; then 20 echo "ERROR ($root): ${@:2}, expected 20 echo "ERROR ($root): ${@:2}, expected $1 have $n" 21 ((num_errors++)) 21 ((num_errors++)) 22 else 22 else 23 ((num_passes++)) 23 ((num_passes++)) 24 fi 24 fi 25 } 25 } 26 26 27 27 28 for root in mq mqprio; do 28 for root in mq mqprio; do 29 NDEV=$(make_netdev 1 4) 29 NDEV=$(make_netdev 1 4) 30 30 31 opts= 31 opts= 32 [ $root == "mqprio" ] && opts='hw 0 num_tc 32 [ $root == "mqprio" ] && opts='hw 0 num_tc 1 map 0 0 0 0 queues 1@0' 33 33 34 tcq add root handle 100: $root $opts 34 tcq add root handle 100: $root $opts 35 n_child_assert 4 'Init' 35 n_child_assert 4 'Init' 36 36 37 # All defaults 37 # All defaults 38 38 39 for n in 3 2 1 2 3 4 1 4; do 39 for n in 3 2 1 2 3 4 1 4; do 40 ethtool -L $NDEV combined $n 40 ethtool -L $NDEV combined $n 41 n_child_assert $n "Change queues to $n 41 n_child_assert $n "Change queues to $n while down" 42 done 42 done 43 43 44 ip link set dev $NDEV up 44 ip link set dev $NDEV up 45 45 46 for n in 3 2 1 2 3 4 1 4; do 46 for n in 3 2 1 2 3 4 1 4; do 47 ethtool -L $NDEV combined $n 47 ethtool -L $NDEV combined $n 48 n_child_assert $n "Change queues to $n 48 n_child_assert $n "Change queues to $n while up" 49 done 49 done 50 50 51 # One real one 51 # One real one 52 tcq replace parent 100:4 handle 204: pfifo 52 tcq replace parent 100:4 handle 204: pfifo_fast 53 n_child_assert 4 "One real queue" 53 n_child_assert 4 "One real queue" 54 54 55 ethtool -L $NDEV combined 1 55 ethtool -L $NDEV combined 1 56 n_child_assert 2 "One real queue, one defa 56 n_child_assert 2 "One real queue, one default" 57 57 58 ethtool -L $NDEV combined 4 58 ethtool -L $NDEV combined 4 59 n_child_assert 4 "One real queue, rest def 59 n_child_assert 4 "One real queue, rest default" 60 60 61 # Graft some 61 # Graft some 62 tcq replace parent 100:1 handle 204: 62 tcq replace parent 100:1 handle 204: 63 n_child_assert 3 "Grafted" 63 n_child_assert 3 "Grafted" 64 64 65 ethtool -L $NDEV combined 1 65 ethtool -L $NDEV combined 1 66 n_child_assert 1 "Grafted, one" 66 n_child_assert 1 "Grafted, one" 67 67 68 cleanup_nsim 68 cleanup_nsim 69 done 69 done 70 70 71 if [ $num_errors -eq 0 ]; then 71 if [ $num_errors -eq 0 ]; then 72 echo "PASSED all $((num_passes)) checks" 72 echo "PASSED all $((num_passes)) checks" 73 exit 0 73 exit 0 74 else 74 else 75 echo "FAILED $num_errors/$((num_errors+num 75 echo "FAILED $num_errors/$((num_errors+num_passes)) checks" 76 exit 1 76 exit 1 77 fi 77 fi
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.