Path: blob/master/tools/testing/selftests/drivers/net/netdevsim/tc-mq-visibility.sh
26299 views
#!/bin/bash1# SPDX-License-Identifier: GPL-2.0-only23source ethtool-common.sh45set -o pipefail67n_children() {8n=$(tc qdisc show dev $NDEV | grep '^qdisc' | wc -l)9echo $((n - 1))10}1112tcq() {13tc qdisc $1 dev $NDEV ${@:2}14}1516n_child_assert() {17n=$(n_children)18if [ $n -ne $1 ]; then19echo "ERROR ($root): ${@:2}, expected $1 have $n"20((num_errors++))21else22((num_passes++))23fi24}252627for root in mq mqprio; do28NDEV=$(make_netdev 1 4)2930opts=31[ $root == "mqprio" ] && opts='hw 0 num_tc 1 map 0 0 0 0 queues 1@0'3233tcq add root handle 100: $root $opts34n_child_assert 4 'Init'3536# All defaults3738for n in 3 2 1 2 3 4 1 4; do39ethtool -L $NDEV combined $n40n_child_assert $n "Change queues to $n while down"41done4243ip link set dev $NDEV up4445for n in 3 2 1 2 3 4 1 4; do46ethtool -L $NDEV combined $n47n_child_assert $n "Change queues to $n while up"48done4950# One real one51tcq replace parent 100:4 handle 204: pfifo_fast52n_child_assert 4 "One real queue"5354ethtool -L $NDEV combined 155n_child_assert 2 "One real queue, one default"5657ethtool -L $NDEV combined 458n_child_assert 4 "One real queue, rest default"5960# Remove real one61tcq del parent 100:4 handle 204:6263# Replace default with pfifo64tcq replace parent 100:1 handle 205: pfifo limit 100065n_child_assert 3 "Deleting real one, replacing default one with pfifo"6667ethtool -L $NDEV combined 168n_child_assert 1 "Grafted, one"6970cleanup_nsim71done7273if [ $num_errors -eq 0 ]; then74echo "PASSED all $((num_passes)) checks"75exit 076else77echo "FAILED $num_errors/$((num_errors+num_passes)) checks"78exit 179fi808182