WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / drivers / net / mlxsw / sharedbuffer.sh
blob7d9e73a43a49b14193999814ab9ea1972200fac2
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 ALL_TESTS="
5 port_pool_test
6 port_tc_ip_test
7 port_tc_arp_test
10 NUM_NETIFS=2
11 source ../../../net/forwarding/lib.sh
12 source ../../../net/forwarding/devlink_lib.sh
13 source mlxsw_lib.sh
15 SB_POOL_ING=0
16 SB_POOL_EGR_CPU=10
18 SB_ITC_CPU_IP=2
19 SB_ITC_CPU_ARP=2
20 SB_ITC=0
22 h1_create()
24 simple_if_init $h1 192.0.1.1/24
27 h1_destroy()
29 simple_if_fini $h1 192.0.1.1/24
32 h2_create()
34 simple_if_init $h2 192.0.1.2/24
37 h2_destroy()
39 simple_if_fini $h2 192.0.1.2/24
42 sb_occ_pool_check()
44 local dl_port=$1; shift
45 local pool=$1; shift
46 local exp_max_occ=$1
47 local max_occ
48 local err=0
50 max_occ=$(devlink sb -j occupancy show $dl_port \
51 | jq -e ".[][][\"pool\"][\"$pool\"][\"max\"]")
53 if [[ "$max_occ" -ne "$exp_max_occ" ]]; then
54 err=1
57 echo $max_occ
58 return $err
61 sb_occ_itc_check()
63 local dl_port=$1; shift
64 local itc=$1; shift
65 local exp_max_occ=$1
66 local max_occ
67 local err=0
69 max_occ=$(devlink sb -j occupancy show $dl_port \
70 | jq -e ".[][][\"itc\"][\"$itc\"][\"max\"]")
72 if [[ "$max_occ" -ne "$exp_max_occ" ]]; then
73 err=1
76 echo $max_occ
77 return $err
80 sb_occ_etc_check()
82 local dl_port=$1; shift
83 local etc=$1; shift
84 local exp_max_occ=$1; shift
85 local max_occ
86 local err=0
88 max_occ=$(devlink sb -j occupancy show $dl_port \
89 | jq -e ".[][][\"etc\"][\"$etc\"][\"max\"]")
91 if [[ "$max_occ" -ne "$exp_max_occ" ]]; then
92 err=1
95 echo $max_occ
96 return $err
99 port_pool_test()
101 local exp_max_occ=288
102 local max_occ
104 devlink sb occupancy clearmax $DEVLINK_DEV
106 $MZ $h1 -c 1 -p 160 -a $h1mac -b $h2mac -A 192.0.1.1 -B 192.0.1.2 \
107 -t ip -q
109 devlink sb occupancy snapshot $DEVLINK_DEV
111 RET=0
112 max_occ=$(sb_occ_pool_check $dl_port1 $SB_POOL_ING $exp_max_occ)
113 check_err $? "Expected iPool($SB_POOL_ING) max occupancy to be $exp_max_occ, but got $max_occ"
114 log_test "physical port's($h1) ingress pool"
116 RET=0
117 max_occ=$(sb_occ_pool_check $dl_port2 $SB_POOL_ING $exp_max_occ)
118 check_err $? "Expected iPool($SB_POOL_ING) max occupancy to be $exp_max_occ, but got $max_occ"
119 log_test "physical port's($h2) ingress pool"
121 RET=0
122 max_occ=$(sb_occ_pool_check $cpu_dl_port $SB_POOL_EGR_CPU $exp_max_occ)
123 check_err $? "Expected ePool($SB_POOL_EGR_CPU) max occupancy to be $exp_max_occ, but got $max_occ"
124 log_test "CPU port's egress pool"
127 port_tc_ip_test()
129 local exp_max_occ=288
130 local max_occ
132 devlink sb occupancy clearmax $DEVLINK_DEV
134 $MZ $h1 -c 1 -p 160 -a $h1mac -b $h2mac -A 192.0.1.1 -B 192.0.1.2 \
135 -t ip -q
137 devlink sb occupancy snapshot $DEVLINK_DEV
139 RET=0
140 max_occ=$(sb_occ_itc_check $dl_port2 $SB_ITC $exp_max_occ)
141 check_err $? "Expected ingress TC($SB_ITC) max occupancy to be $exp_max_occ, but got $max_occ"
142 log_test "physical port's($h1) ingress TC - IP packet"
144 RET=0
145 max_occ=$(sb_occ_itc_check $dl_port2 $SB_ITC $exp_max_occ)
146 check_err $? "Expected ingress TC($SB_ITC) max occupancy to be $exp_max_occ, but got $max_occ"
147 log_test "physical port's($h2) ingress TC - IP packet"
149 RET=0
150 max_occ=$(sb_occ_etc_check $cpu_dl_port $SB_ITC_CPU_IP $exp_max_occ)
151 check_err $? "Expected egress TC($SB_ITC_CPU_IP) max occupancy to be $exp_max_occ, but got $max_occ"
152 log_test "CPU port's egress TC - IP packet"
155 port_tc_arp_test()
157 local exp_max_occ=96
158 local max_occ
160 if [[ $MLXSW_CHIP != "mlxsw_spectrum" ]]; then
161 exp_max_occ=144
164 devlink sb occupancy clearmax $DEVLINK_DEV
166 $MZ $h1 -c 1 -p 160 -a $h1mac -A 192.0.1.1 -t arp -q
168 devlink sb occupancy snapshot $DEVLINK_DEV
170 RET=0
171 max_occ=$(sb_occ_itc_check $dl_port2 $SB_ITC $exp_max_occ)
172 check_err $? "Expected ingress TC($SB_ITC) max occupancy to be $exp_max_occ, but got $max_occ"
173 log_test "physical port's($h1) ingress TC - ARP packet"
175 RET=0
176 max_occ=$(sb_occ_itc_check $dl_port2 $SB_ITC $exp_max_occ)
177 check_err $? "Expected ingress TC($SB_ITC) max occupancy to be $exp_max_occ, but got $max_occ"
178 log_test "physical port's($h2) ingress TC - ARP packet"
180 RET=0
181 max_occ=$(sb_occ_etc_check $cpu_dl_port $SB_ITC_CPU_ARP $exp_max_occ)
182 check_err $? "Expected egress TC($SB_ITC_IP2ME) max occupancy to be $exp_max_occ, but got $max_occ"
183 log_test "CPU port's egress TC - ARP packet"
186 setup_prepare()
188 h1=${NETIFS[p1]}
189 h2=${NETIFS[p2]}
191 h1mac=$(mac_get $h1)
192 h2mac=$(mac_get $h2)
194 dl_port1=$(devlink_port_by_netdev $h1)
195 dl_port2=$(devlink_port_by_netdev $h2)
197 cpu_dl_port=$(devlink_cpu_port_get)
199 vrf_prepare
201 h1_create
202 h2_create
205 cleanup()
207 pre_cleanup
209 h2_destroy
210 h1_destroy
212 vrf_cleanup
215 trap cleanup EXIT
217 setup_prepare
218 setup_wait
220 tests_run
222 exit $EXIT_STATUS