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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/drivers/net/mlxsw/spectrum/devlink_resources.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 lib_dir=$(dirname $0)/../../../../net/forwarding
  5 
  6 NUM_NETIFS=1
  7 source $lib_dir/lib.sh
  8 source devlink_lib_spectrum.sh
  9 
 10 setup_prepare()
 11 {
 12         devlink_sp_read_kvd_defaults
 13 }
 14 
 15 cleanup()
 16 {
 17         pre_cleanup
 18         devlink_sp_size_kvd_to_default
 19 }
 20 
 21 trap cleanup EXIT
 22 
 23 setup_prepare
 24 
 25 profiles_test()
 26 {
 27         local i
 28 
 29         log_info "Running profile tests"
 30 
 31         for i in $KVD_PROFILES; do
 32                 RET=0
 33                 devlink_sp_resource_kvd_profile_set $i
 34                 log_test "'$i' profile"
 35         done
 36 
 37         # Default is explicitly tested at end to ensure it's actually applied
 38         RET=0
 39         devlink_sp_resource_kvd_profile_set "default"
 40         log_test "'default' profile"
 41 }
 42 
 43 resources_min_test()
 44 {
 45         local size
 46         local i
 47         local j
 48 
 49         log_info "Running KVD-minimum tests"
 50 
 51         for i in $KVD_CHILDREN; do
 52                 RET=0
 53                 size=$(devlink_resource_get kvd "$i" | jq '.["size_min"]')
 54                 devlink_resource_size_set "$size" kvd "$i"
 55 
 56                 # In case of linear, need to minimize sub-resources as well
 57                 if [[ "$i" == "linear" ]]; then
 58                         for j in $KVDL_CHILDREN; do
 59                                 devlink_resource_size_set 0 kvd linear "$j"
 60                         done
 61                 fi
 62 
 63                 devlink_reload
 64                 devlink_sp_size_kvd_to_default
 65                 log_test "'$i' minimize [$size]"
 66         done
 67 }
 68 
 69 resources_max_test()
 70 {
 71         local min_size
 72         local size
 73         local i
 74         local j
 75 
 76         log_info "Running KVD-maximum tests"
 77         for i in $KVD_CHILDREN; do
 78                 RET=0
 79                 devlink_sp_resource_minimize
 80 
 81                 # Calculate the maximum possible size for the given partition
 82                 size=$(devlink_resource_size_get kvd)
 83                 for j in $KVD_CHILDREN; do
 84                         if [ "$i" != "$j" ]; then
 85                                 min_size=$(devlink_resource_get kvd "$j" | \
 86                                            jq '.["size_min"]')
 87                                 size=$((size - min_size))
 88                         fi
 89                 done
 90 
 91                 # Test almost maximum size
 92                 devlink_resource_size_set "$((size - 128))" kvd "$i"
 93                 devlink_reload
 94                 log_test "'$i' almost maximize [$((size - 128))]"
 95 
 96                 # Test above maximum size
 97                 devlink resource set "$DEVLINK_DEV" \
 98                         path "kvd/$i" size $((size + 128)) &> /dev/null
 99                 check_fail $? "Set kvd/$i to size $((size + 128)) should fail"
100                 log_test "'$i' Overflow rejection [$((size + 128))]"
101 
102                 # Test maximum size
103                 if [ "$i" == "hash_single" ] || [ "$i" == "hash_double" ]; then
104                         echo "SKIP: Observed problem with exact max $i"
105                         continue
106                 fi
107 
108                 devlink_resource_size_set "$size" kvd "$i"
109                 devlink_reload
110                 log_test "'$i' maximize [$size]"
111 
112                 devlink_sp_size_kvd_to_default
113         done
114 }
115 
116 profiles_test
117 resources_min_test
118 resources_max_test
119 
120 exit "$RET"

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