staging: rtl8192u: remove redundant assignment to pointer crypt
[linux/fpc-iii.git] / tools / testing / selftests / drivers / net / mlxsw / spectrum / devlink_lib_spectrum.sh
blob73035e25085d7fae8bbb84a5b23121f447402d88
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 source "../../../../net/forwarding/devlink_lib.sh"
6 if [ "$DEVLINK_VIDDID" != "15b3:cb84" ]; then
7 echo "SKIP: test is tailored for Mellanox Spectrum"
8 exit 1
9 fi
11 # Needed for returning to default
12 declare -A KVD_DEFAULTS
14 KVD_CHILDREN="linear hash_single hash_double"
15 KVDL_CHILDREN="singles chunks large_chunks"
17 devlink_sp_resource_minimize()
19 local size
20 local i
22 for i in $KVD_CHILDREN; do
23 size=$(devlink_resource_get kvd "$i" | jq '.["size_min"]')
24 devlink_resource_size_set "$size" kvd "$i"
25 done
27 for i in $KVDL_CHILDREN; do
28 size=$(devlink_resource_get kvd linear "$i" | \
29 jq '.["size_min"]')
30 devlink_resource_size_set "$size" kvd linear "$i"
31 done
34 devlink_sp_size_kvd_to_default()
36 local need_reload=0
37 local i
39 for i in $KVD_CHILDREN; do
40 local size=$(echo "${KVD_DEFAULTS[kvd_$i]}" | jq '.["size"]')
41 current_size=$(devlink_resource_size_get kvd "$i")
43 if [ "$size" -ne "$current_size" ]; then
44 devlink_resource_size_set "$size" kvd "$i"
45 need_reload=1
47 done
49 for i in $KVDL_CHILDREN; do
50 local size=$(echo "${KVD_DEFAULTS[kvd_linear_$i]}" | \
51 jq '.["size"]')
52 current_size=$(devlink_resource_size_get kvd linear "$i")
54 if [ "$size" -ne "$current_size" ]; then
55 devlink_resource_size_set "$size" kvd linear "$i"
56 need_reload=1
58 done
60 if [ "$need_reload" -ne "0" ]; then
61 devlink_reload
65 devlink_sp_read_kvd_defaults()
67 local key
68 local i
70 KVD_DEFAULTS[kvd]=$(devlink_resource_get "kvd")
71 for i in $KVD_CHILDREN; do
72 key=kvd_$i
73 KVD_DEFAULTS[$key]=$(devlink_resource_get kvd "$i")
74 done
76 for i in $KVDL_CHILDREN; do
77 key=kvd_linear_$i
78 KVD_DEFAULTS[$key]=$(devlink_resource_get kvd linear "$i")
79 done
82 KVD_PROFILES="default scale ipv4_max"
84 devlink_sp_resource_kvd_profile_set()
86 local profile=$1
88 case "$profile" in
89 scale)
90 devlink_resource_size_set 64000 kvd linear
91 devlink_resource_size_set 15616 kvd linear singles
92 devlink_resource_size_set 32000 kvd linear chunks
93 devlink_resource_size_set 16384 kvd linear large_chunks
94 devlink_resource_size_set 128000 kvd hash_single
95 devlink_resource_size_set 48000 kvd hash_double
96 devlink_reload
98 ipv4_max)
99 devlink_resource_size_set 64000 kvd linear
100 devlink_resource_size_set 15616 kvd linear singles
101 devlink_resource_size_set 32000 kvd linear chunks
102 devlink_resource_size_set 16384 kvd linear large_chunks
103 devlink_resource_size_set 144000 kvd hash_single
104 devlink_resource_size_set 32768 kvd hash_double
105 devlink_reload
107 default)
108 devlink_resource_size_set 98304 kvd linear
109 devlink_resource_size_set 16384 kvd linear singles
110 devlink_resource_size_set 49152 kvd linear chunks
111 devlink_resource_size_set 32768 kvd linear large_chunks
112 devlink_resource_size_set 87040 kvd hash_single
113 devlink_resource_size_set 60416 kvd hash_double
114 devlink_reload
117 check_err 1 "Unknown profile $profile"
118 esac