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