~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/drivers/net/mlxsw/sharedbuffer.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0
  3 
  4 ALL_TESTS="
  5         port_pool_test
  6         port_tc_ip_test
  7         port_tc_arp_test
  8 "
  9 
 10 NUM_NETIFS=2
 11 source ../../../net/forwarding/lib.sh
 12 source ../../../net/forwarding/devlink_lib.sh
 13 source mlxsw_lib.sh
 14 
 15 SB_POOL_ING=0
 16 SB_POOL_EGR_CPU=10
 17 
 18 SB_ITC_CPU_IP=2
 19 SB_ITC_CPU_ARP=2
 20 SB_ITC=0
 21 
 22 h1_create()
 23 {
 24         simple_if_init $h1 192.0.1.1/24
 25 }
 26 
 27 h1_destroy()
 28 {
 29         simple_if_fini $h1 192.0.1.1/24
 30 }
 31 
 32 h2_create()
 33 {
 34         simple_if_init $h2 192.0.1.2/24
 35 }
 36 
 37 h2_destroy()
 38 {
 39         simple_if_fini $h2 192.0.1.2/24
 40 }
 41 
 42 sb_occ_pool_check()
 43 {
 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
 49 
 50         max_occ=$(devlink sb -j occupancy show $dl_port \
 51                   | jq -e ".[][][\"pool\"][\"$pool\"][\"max\"]")
 52 
 53         if [[ "$max_occ" -ne "$exp_max_occ" ]]; then
 54                 err=1
 55         fi
 56 
 57         echo $max_occ
 58         return $err
 59 }
 60 
 61 sb_occ_itc_check()
 62 {
 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
 68 
 69         max_occ=$(devlink sb -j occupancy show $dl_port \
 70                   | jq -e ".[][][\"itc\"][\"$itc\"][\"max\"]")
 71 
 72         if [[ "$max_occ" -ne "$exp_max_occ" ]]; then
 73                 err=1
 74         fi
 75 
 76         echo $max_occ
 77         return $err
 78 }
 79 
 80 sb_occ_etc_check()
 81 {
 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
 87 
 88         max_occ=$(devlink sb -j occupancy show $dl_port \
 89                   | jq -e ".[][][\"etc\"][\"$etc\"][\"max\"]")
 90 
 91         if [[ "$max_occ" -ne "$exp_max_occ" ]]; then
 92                 err=1
 93         fi
 94 
 95         echo $max_occ
 96         return $err
 97 }
 98 
 99 port_pool_test()
100 {
101         local exp_max_occ=$(devlink_cell_size_get)
102         local max_occ
103 
104         devlink sb occupancy clearmax $DEVLINK_DEV
105 
106         $MZ $h1 -c 1 -p 10 -a $h1mac -b $h2mac -A 192.0.1.1 -B 192.0.1.2 \
107                 -t ip -q
108 
109         devlink sb occupancy snapshot $DEVLINK_DEV
110 
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"
115 
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"
120 
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"
125 }
126 
127 port_tc_ip_test()
128 {
129         local exp_max_occ=$(devlink_cell_size_get)
130         local max_occ
131 
132         devlink sb occupancy clearmax $DEVLINK_DEV
133 
134         $MZ $h1 -c 1 -p 10 -a $h1mac -b $h2mac -A 192.0.1.1 -B 192.0.1.2 \
135                 -t ip -q
136 
137         devlink sb occupancy snapshot $DEVLINK_DEV
138 
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"
143 
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"
148 
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"
153 }
154 
155 port_tc_arp_test()
156 {
157         local exp_max_occ=$(devlink_cell_size_get)
158         local max_occ
159 
160         devlink sb occupancy clearmax $DEVLINK_DEV
161 
162         $MZ $h1 -c 1 -p 10 -a $h1mac -A 192.0.1.1 -t arp -q
163 
164         devlink sb occupancy snapshot $DEVLINK_DEV
165 
166         RET=0
167         max_occ=$(sb_occ_itc_check $dl_port2 $SB_ITC $exp_max_occ)
168         check_err $? "Expected ingress TC($SB_ITC) max occupancy to be $exp_max_occ, but got $max_occ"
169         log_test "physical port's($h1) ingress TC - ARP packet"
170 
171         RET=0
172         max_occ=$(sb_occ_itc_check $dl_port2 $SB_ITC $exp_max_occ)
173         check_err $? "Expected ingress TC($SB_ITC) max occupancy to be $exp_max_occ, but got $max_occ"
174         log_test "physical port's($h2) ingress TC - ARP packet"
175 
176         RET=0
177         max_occ=$(sb_occ_etc_check $cpu_dl_port $SB_ITC_CPU_ARP $exp_max_occ)
178         check_err $? "Expected egress TC($SB_ITC_IP2ME) max occupancy to be $exp_max_occ, but got $max_occ"
179         log_test "CPU port's egress TC - ARP packet"
180 }
181 
182 setup_prepare()
183 {
184         h1=${NETIFS[p1]}
185         h2=${NETIFS[p2]}
186 
187         h1mac=$(mac_get $h1)
188         h2mac=$(mac_get $h2)
189 
190         dl_port1=$(devlink_port_by_netdev $h1)
191         dl_port2=$(devlink_port_by_netdev $h2)
192 
193         cpu_dl_port=$(devlink_cpu_port_get)
194 
195         vrf_prepare
196 
197         h1_create
198         h2_create
199 }
200 
201 cleanup()
202 {
203         pre_cleanup
204 
205         h2_destroy
206         h1_destroy
207 
208         vrf_cleanup
209 }
210 
211 trap cleanup EXIT
212 
213 setup_prepare
214 setup_wait
215 
216 tests_run
217 
218 exit $EXIT_STATUS

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php