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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/drivers/net/mlxsw/spectrum/devlink_lib_spectrum.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 source "../../../../net/forwarding/devlink_lib.sh"
  5 source ../mlxsw_lib.sh
  6 
  7 mlxsw_only_on_spectrum 1 || exit 1
  8 
  9 # Needed for returning to default
 10 declare -A KVD_DEFAULTS
 11 
 12 KVD_CHILDREN="linear hash_single hash_double"
 13 KVDL_CHILDREN="singles chunks large_chunks"
 14 
 15 devlink_sp_resource_minimize()
 16 {
 17         local size
 18         local i
 19 
 20         for i in $KVD_CHILDREN; do
 21                 size=$(devlink_resource_get kvd "$i" | jq '.["size_min"]')
 22                 devlink_resource_size_set "$size" kvd "$i"
 23         done
 24 
 25         for i in $KVDL_CHILDREN; do
 26                 size=$(devlink_resource_get kvd linear "$i" | \
 27                        jq '.["size_min"]')
 28                 devlink_resource_size_set "$size" kvd linear "$i"
 29         done
 30 }
 31 
 32 devlink_sp_size_kvd_to_default()
 33 {
 34         local need_reload=0
 35         local i
 36 
 37         for i in $KVD_CHILDREN; do
 38                 local size=$(echo "${KVD_DEFAULTS[kvd_$i]}" | jq '.["size"]')
 39                 current_size=$(devlink_resource_size_get kvd "$i")
 40 
 41                 if [ "$size" -ne "$current_size" ]; then
 42                         devlink_resource_size_set "$size" kvd "$i"
 43                         need_reload=1
 44                 fi
 45         done
 46 
 47         for i in $KVDL_CHILDREN; do
 48                 local size=$(echo "${KVD_DEFAULTS[kvd_linear_$i]}" | \
 49                              jq '.["size"]')
 50                 current_size=$(devlink_resource_size_get kvd linear "$i")
 51 
 52                 if [ "$size" -ne "$current_size" ]; then
 53                         devlink_resource_size_set "$size" kvd linear "$i"
 54                         need_reload=1
 55                 fi
 56         done
 57 
 58         if [ "$need_reload" -ne "0" ]; then
 59                 devlink_reload
 60         fi
 61 }
 62 
 63 devlink_sp_read_kvd_defaults()
 64 {
 65         local key
 66         local i
 67 
 68         KVD_DEFAULTS[kvd]=$(devlink_resource_get "kvd")
 69         for i in $KVD_CHILDREN; do
 70                 key=kvd_$i
 71                 KVD_DEFAULTS[$key]=$(devlink_resource_get kvd "$i")
 72         done
 73 
 74         for i in $KVDL_CHILDREN; do
 75                 key=kvd_linear_$i
 76                 KVD_DEFAULTS[$key]=$(devlink_resource_get kvd linear "$i")
 77         done
 78 }
 79 
 80 KVD_PROFILES="default scale ipv4_max"
 81 
 82 devlink_sp_resource_kvd_profile_set()
 83 {
 84         local profile=$1
 85 
 86         case "$profile" in
 87         scale)
 88                 devlink_resource_size_set 64000 kvd linear
 89                 devlink_resource_size_set 15616 kvd linear singles
 90                 devlink_resource_size_set 32000 kvd linear chunks
 91                 devlink_resource_size_set 16384 kvd linear large_chunks
 92                 devlink_resource_size_set 128000 kvd hash_single
 93                 devlink_resource_size_set 48000 kvd hash_double
 94                 devlink_reload
 95                 ;;
 96         ipv4_max)
 97                 devlink_resource_size_set 64000 kvd linear
 98                 devlink_resource_size_set 15616 kvd linear singles
 99                 devlink_resource_size_set 32000 kvd linear chunks
100                 devlink_resource_size_set 16384 kvd linear large_chunks
101                 devlink_resource_size_set 144000 kvd hash_single
102                 devlink_resource_size_set 32768 kvd hash_double
103                 devlink_reload
104                 ;;
105         default)
106                 devlink_resource_size_set 98304 kvd linear
107                 devlink_resource_size_set 16384 kvd linear singles
108                 devlink_resource_size_set 49152 kvd linear chunks
109                 devlink_resource_size_set 32768 kvd linear large_chunks
110                 devlink_resource_size_set 87040 kvd hash_single
111                 devlink_resource_size_set 60416 kvd hash_double
112                 devlink_reload
113                 ;;
114         *)
115                 check_err 1 "Unknown profile $profile"
116         esac
117 }

~ [ 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