accel/qaic: Add AIC200 support
[drm/drm-misc.git] / tools / testing / selftests / net / txtimestamp.sh
blobfe4649bb87868820bc922b61946dae744c45e74b
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # Send packets with transmit timestamps over loopback with netem
5 # Verify that timestamps correspond to netem delay
7 set -e
9 setup() {
10 # set 1ms delay on lo egress
11 tc qdisc add dev lo root netem delay 10ms
13 # set 2ms delay on ifb0 egress
14 modprobe ifb
15 ip link add ifb_netem0 type ifb
16 ip link set dev ifb_netem0 up
17 tc qdisc add dev ifb_netem0 root netem delay 20ms
19 # redirect lo ingress through ifb0 egress
20 tc qdisc add dev lo handle ffff: ingress
21 tc filter add dev lo parent ffff: \
22 u32 match mark 0 0xffff \
23 action mirred egress redirect dev ifb_netem0
26 run_test_v4v6() {
27 # SND will be delayed 10ms
28 # ACK will be delayed 60ms: 10 + 20 ms round-trip
29 # allow +/- tolerance of 8ms
30 # wait for ACK to be queued
31 local -r args="$@ -v 10000 -V 60000 -t 8000 -S 80000"
33 ./txtimestamp ${args} -4 -L 127.0.0.1
34 ./txtimestamp ${args} -6 -L ::1
37 run_test_tcpudpraw() {
38 local -r args=$@
40 run_test_v4v6 ${args} # tcp
41 run_test_v4v6 ${args} -u # udp
42 run_test_v4v6 ${args} -u -o 42 # udp with fixed tskey
43 run_test_v4v6 ${args} -r # raw
44 run_test_v4v6 ${args} -r -o 42 # raw
45 run_test_v4v6 ${args} -R # raw (IPPROTO_RAW)
46 run_test_v4v6 ${args} -P # pf_packet
49 run_test_all() {
50 setup
51 run_test_tcpudpraw # setsockopt
52 run_test_tcpudpraw -C # cmsg
53 run_test_tcpudpraw -n # timestamp w/o data
54 echo "OK. All tests passed"
57 run_test_one() {
58 setup
59 ./txtimestamp $@
62 usage() {
63 echo "Usage: $0 [ -r | --run ] <txtimestamp args> | [ -h | --help ]"
64 echo " (no args) Run all tests"
65 echo " -r|--run Run an individual test with arguments"
66 echo " -h|--help Help"
69 main() {
70 if [[ $# -eq 0 ]]; then
71 run_test_all
72 else
73 if [[ "$1" = "-r" || "$1" == "--run" ]]; then
74 shift
75 run_test_one $@
76 else
77 usage
82 if [[ -z "$(ip netns identify)" ]]; then
83 ./in_netns.sh $0 $@
84 else
85 main $@