drm/bridge: adv7511: Switch to atomic operations
[drm/drm-misc.git] / tools / testing / selftests / net / fq_band_pktlimit.sh
blob977070ed42b3df00ad542a7a4395241d16a3ee9c
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # Verify that FQ has a packet limit per band:
6 # 1. set the limit to 10 per band
7 # 2. send 20 pkts on band A: verify that 10 are queued, 10 dropped
8 # 3. send 20 pkts on band A: verify that 0 are queued, 20 dropped
9 # 4. send 20 pkts on band B: verify that 10 are queued, 10 dropped
11 # Send packets with a delay to ensure that previously sent
12 # packets are still queued when later ones are sent.
13 # Use SO_TXTIME for this.
15 die() {
16 echo "$1"
17 exit 1
20 # run inside private netns
21 if [[ $# -eq 0 ]]; then
22 ./in_netns.sh "$0" __subprocess
23 exit
26 ip link add type dummy
27 ip link set dev dummy0 up
28 ip -6 addr add fdaa::1/128 dev dummy0
29 ip -6 route add fdaa::/64 dev dummy0
30 tc qdisc replace dev dummy0 root handle 1: fq quantum 1514 initial_quantum 1514 limit 10
32 DELAY=400000
34 ./cmsg_sender -6 -p u -d "${DELAY}" -n 20 fdaa::2 8000
35 OUT1="$(tc -s qdisc show dev dummy0 | grep '^\ Sent')"
37 ./cmsg_sender -6 -p u -d "${DELAY}" -n 20 fdaa::2 8000
38 OUT2="$(tc -s qdisc show dev dummy0 | grep '^\ Sent')"
40 ./cmsg_sender -6 -p u -d "${DELAY}" -n 20 -P 7 fdaa::2 8000
41 OUT3="$(tc -s qdisc show dev dummy0 | grep '^\ Sent')"
43 # Initial stats will report zero sent, as all packets are still
44 # queued in FQ. Sleep for at least the delay period and see that
45 # twenty are now sent.
46 sleep 0.6
47 OUT4="$(tc -s qdisc show dev dummy0 | grep '^\ Sent')"
49 # Log the output after the test
50 echo "${OUT1}"
51 echo "${OUT2}"
52 echo "${OUT3}"
53 echo "${OUT4}"
55 # Test the output for expected values
56 echo "${OUT1}" | grep -q '0\ pkt\ (dropped\ 10' || die "unexpected drop count at 1"
57 echo "${OUT2}" | grep -q '0\ pkt\ (dropped\ 30' || die "unexpected drop count at 2"
58 echo "${OUT3}" | grep -q '0\ pkt\ (dropped\ 40' || die "unexpected drop count at 3"
59 echo "${OUT4}" | grep -q '20\ pkt\ (dropped\ 40' || die "unexpected accept count at 4"