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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/drivers/net/mlxsw/tc_police_scale.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 # SPDX-License-Identifier: GPL-2.0
  2 
  3 TC_POLICE_NUM_NETIFS=2
  4 
  5 tc_police_h1_create()
  6 {
  7         simple_if_init $h1
  8 }
  9 
 10 tc_police_h1_destroy()
 11 {
 12         simple_if_fini $h1
 13 }
 14 
 15 tc_police_switch_create()
 16 {
 17         simple_if_init $swp1
 18         tc qdisc add dev $swp1 clsact
 19 }
 20 
 21 tc_police_switch_destroy()
 22 {
 23         tc qdisc del dev $swp1 clsact
 24         simple_if_fini $swp1
 25 }
 26 
 27 tc_police_addr()
 28 {
 29        local num=$1; shift
 30 
 31        printf "2001:db8:1::%x" $num
 32 }
 33 
 34 tc_police_rules_create()
 35 {
 36         local count=$1; shift
 37         local should_fail=$1; shift
 38 
 39         TC_POLICE_BATCH_FILE="$(mktemp)"
 40 
 41         for ((i = 0; i < count; ++i)); do
 42                 cat >> $TC_POLICE_BATCH_FILE <<-EOF
 43                         filter add dev $swp1 ingress \
 44                                 prot ipv6 \
 45                                 pref 1000 \
 46                                 flower skip_sw dst_ip $(tc_police_addr $i) \
 47                                 action police rate 10mbit burst 100k \
 48                                 conform-exceed drop/ok
 49                 EOF
 50         done
 51 
 52         tc -b $TC_POLICE_BATCH_FILE
 53         check_err_fail $should_fail $? "Rule insertion"
 54 }
 55 
 56 __tc_police_test()
 57 {
 58         local count=$1; shift
 59         local should_fail=$1; shift
 60 
 61         tc_police_rules_create $count $should_fail
 62 
 63         offload_count=$(tc -j filter show dev $swp1 ingress |
 64                         jq "[.[] | select(.options.in_hw == true)] | length")
 65         ((offload_count == count))
 66         check_err_fail $should_fail $? "tc police offload count"
 67 }
 68 
 69 tc_police_test()
 70 {
 71         local count=$1; shift
 72         local should_fail=$1; shift
 73 
 74         if ! tc_offload_check $TC_POLICE_NUM_NETIFS; then
 75                 check_err 1 "Could not test offloaded functionality"
 76                 return
 77         fi
 78 
 79         __tc_police_test $count $should_fail
 80 }
 81 
 82 tc_police_setup_prepare()
 83 {
 84         h1=${NETIFS[p1]}
 85         swp1=${NETIFS[p2]}
 86 
 87         vrf_prepare
 88 
 89         tc_police_h1_create
 90         tc_police_switch_create
 91 }
 92 
 93 tc_police_cleanup()
 94 {
 95         pre_cleanup
 96 
 97         tc_police_switch_destroy
 98         tc_police_h1_destroy
 99 
100         vrf_cleanup
101 }

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