WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / drivers / net / mlxsw / qos_defprio.sh
blob71066bc4b886dfa7aff7ecf41a650cf4c2ee04a3
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # Test for port-default priority. Non-IP packets ingress $swp1 and are
5 # prioritized according to the default priority specified at the port.
6 # rx_octets_prio_* counters are used to verify the prioritization.
8 # +-----------------------+
9 # | H1 |
10 # | + $h1 |
11 # | | 192.0.2.1/28 |
12 # +----|------------------+
13 # |
14 # +----|------------------+
15 # | SW | |
16 # | + $swp1 |
17 # | 192.0.2.2/28 |
18 # | APP=<prio>,1,0 |
19 # +-----------------------+
21 ALL_TESTS="
22 ping_ipv4
23 test_defprio
26 lib_dir=$(dirname $0)/../../../net/forwarding
28 NUM_NETIFS=2
29 : ${HIT_TIMEOUT:=1000} # ms
30 source $lib_dir/lib.sh
32 declare -a APP
34 defprio_install()
36 local dev=$1; shift
37 local prio=$1; shift
38 local app="app=$prio,1,0"
40 lldptool -T -i $dev -V APP $app >/dev/null
41 lldpad_app_wait_set $dev
42 APP[$prio]=$app
45 defprio_uninstall()
47 local dev=$1; shift
48 local prio=$1; shift
49 local app=${APP[$prio]}
51 lldptool -T -i $dev -V APP -d $app >/dev/null
52 lldpad_app_wait_del
53 unset APP[$prio]
56 defprio_flush()
58 local dev=$1; shift
59 local prio
61 if ((${#APP[@]})); then
62 lldptool -T -i $dev -V APP -d ${APP[@]} >/dev/null
64 lldpad_app_wait_del
65 APP=()
68 h1_create()
70 simple_if_init $h1 192.0.2.1/28
73 h1_destroy()
75 simple_if_fini $h1 192.0.2.1/28
78 switch_create()
80 ip link set dev $swp1 up
81 ip addr add dev $swp1 192.0.2.2/28
84 switch_destroy()
86 defprio_flush $swp1
87 ip addr del dev $swp1 192.0.2.2/28
88 ip link set dev $swp1 down
91 setup_prepare()
93 h1=${NETIFS[p1]}
94 swp1=${NETIFS[p2]}
96 vrf_prepare
98 h1_create
99 switch_create
102 cleanup()
104 pre_cleanup
106 switch_destroy
107 h1_destroy
109 vrf_cleanup
112 ping_ipv4()
114 ping_test $h1 192.0.2.2
117 __test_defprio()
119 local prio_install=$1; shift
120 local prio_observe=$1; shift
121 local key
122 local t1
123 local i
125 RET=0
127 defprio_install $swp1 $prio_install
129 local t0=$(ethtool_stats_get $swp1 rx_frames_prio_$prio_observe)
130 mausezahn -q $h1 -d 100m -c 10 -t arp reply
131 t1=$(busywait "$HIT_TIMEOUT" until_counter_is ">= $((t0 + 10))" \
132 ethtool_stats_get $swp1 rx_frames_prio_$prio_observe)
134 check_err $? "Default priority $prio_install/$prio_observe: Expected to capture 10 packets, got $((t1 - t0))."
135 log_test "Default priority $prio_install/$prio_observe"
137 defprio_uninstall $swp1 $prio_install
140 test_defprio()
142 local prio
144 for prio in {0..7}; do
145 __test_defprio $prio $prio
146 done
148 defprio_install $swp1 3
149 __test_defprio 0 3
150 __test_defprio 1 3
151 __test_defprio 2 3
152 __test_defprio 4 4
153 __test_defprio 5 5
154 __test_defprio 6 6
155 __test_defprio 7 7
156 defprio_uninstall $swp1 3
159 trap cleanup EXIT
161 setup_prepare
162 setup_wait
164 tests_run
166 exit $EXIT_STATUS