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

TOMOYO Linux Cross Reference
Linux/samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ 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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0
  3 #
  4 # Benchmark script:
  5 #  - developed for benchmarking egress qdisc path, derived (more
  6 #    like cut'n'pasted) from ingress benchmark script.
  7 #
  8 # Script for injecting packets into egress qdisc path of the stack
  9 # with pktgen "xmit_mode queue_xmit".
 10 #
 11 basedir=`dirname $0`
 12 source ${basedir}/functions.sh
 13 root_check_run_with_sudo "$@"
 14 
 15 # Parameter parsing via include
 16 source ${basedir}/parameters.sh
 17 
 18 # Trap EXIT first
 19 trap_exit
 20 
 21 if [ -z "$DEST_IP" ]; then
 22     [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1"
 23 fi
 24 [ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff"
 25 
 26 # Burst greater than 1 are invalid for queue_xmit mode
 27 if [[ -n "$BURST" ]]; then
 28     err 1 "Bursting not supported for this mode"
 29 fi
 30 [ -z "$COUNT" ] && COUNT="10000000" # Zero means indefinitely
 31 if [ -n "$DEST_IP" ]; then
 32     validate_addr${IP6} $DEST_IP
 33     read -r DST_MIN DST_MAX <<< $(parse_addr${IP6} $DEST_IP)
 34 fi
 35 if [ -n "$DST_PORT" ]; then
 36     read -r UDP_DST_MIN UDP_DST_MAX <<< $(parse_ports $DST_PORT)
 37     validate_ports $UDP_DST_MIN $UDP_DST_MAX
 38 fi
 39 
 40 # General cleanup everything since last run
 41 pg_ctrl "reset"
 42 
 43 # Threads are specified with parameter -t value in $THREADS
 44 for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
 45     # The device name is extended with @name, using thread number to
 46     # make then unique, but any name will do.
 47     dev=${DEV}@${thread}
 48 
 49     # Add remove all other devices and add_device $dev to thread
 50     pg_thread $thread "rem_device_all"
 51     pg_thread $thread "add_device" $dev
 52 
 53     # Base config of dev
 54     pg_set $dev "flag QUEUE_MAP_CPU"
 55     pg_set $dev "count $COUNT"
 56     pg_set $dev "pkt_size $PKT_SIZE"
 57     pg_set $dev "delay $DELAY"
 58     pg_set $dev "flag NO_TIMESTAMP"
 59 
 60     # Destination
 61     pg_set $dev "dst_mac $DST_MAC"
 62     pg_set $dev "dst${IP6}_min $DST_MIN"
 63     pg_set $dev "dst${IP6}_max $DST_MAX"
 64 
 65     if [ -n "$DST_PORT" ]; then
 66         # Single destination port or random port range
 67         pg_set $dev "flag UDPDST_RND"
 68         pg_set $dev "udp_dst_min $UDP_DST_MIN"
 69         pg_set $dev "udp_dst_max $UDP_DST_MAX"
 70     fi
 71 
 72     # Inject packet into TX qdisc egress path of stack
 73     pg_set $dev "xmit_mode queue_xmit"
 74 done
 75 
 76 # Run if user hits control-c
 77 function print_result {
 78     # Print results
 79     for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
 80         dev=${DEV}@${thread}
 81         echo "Device: $dev"
 82         cat /proc/net/pktgen/$dev | grep -A2 "Result:"
 83     done
 84 }
 85 # trap keyboard interrupt (Ctrl-C)
 86 trap true SIGINT
 87 
 88 # start_run
 89 echo "Running... ctrl^C to stop" >&2
 90 pg_ctrl "start"
 91 echo "Done" >&2
 92 
 93 print_result

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