]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - samples/pktgen/pktgen_sample02_multiqueue.sh
UBUNTU: SAUCE: aufs: bugfix, for v4.10, copy-up on XFS branch
[mirror_ubuntu-zesty-kernel.git] / samples / pktgen / pktgen_sample02_multiqueue.sh
1 #!/bin/bash
2 #
3 # Multiqueue: Using pktgen threads for sending on multiple CPUs
4 # * adding devices to kernel threads
5 # * notice the naming scheme for keeping device names unique
6 # * nameing scheme: dev@thread_number
7 # * flow variation via random UDP source port
8 #
9 basedir=`dirname $0`
10 source ${basedir}/functions.sh
11 root_check_run_with_sudo "$@"
12 #
13 # Required param: -i dev in $DEV
14 source ${basedir}/parameters.sh
15
16 # Base Config
17 DELAY="0" # Zero means max speed
18 COUNT="100000" # Zero means indefinitely
19 [ -z "$CLONE_SKB" ] && CLONE_SKB="0"
20
21 # Flow variation random source port between min and max
22 UDP_MIN=9
23 UDP_MAX=109
24
25 # (example of setting default params in your script)
26 if [ -z "$DEST_IP" ]; then
27 [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1"
28 fi
29 [ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff"
30
31 # General cleanup everything since last run
32 pg_ctrl "reset"
33
34 # Threads are specified with parameter -t value in $THREADS
35 for ((thread = 0; thread < $THREADS; thread++)); do
36 # The device name is extended with @name, using thread number to
37 # make then unique, but any name will do.
38 dev=${DEV}@${thread}
39
40 # Add remove all other devices and add_device $dev to thread
41 pg_thread $thread "rem_device_all"
42 pg_thread $thread "add_device" $dev
43
44 # Notice config queue to map to cpu (mirrors smp_processor_id())
45 # It is beneficial to map IRQ /proc/irq/*/smp_affinity 1:1 to CPU number
46 pg_set $dev "flag QUEUE_MAP_CPU"
47
48 # Base config of dev
49 pg_set $dev "count $COUNT"
50 pg_set $dev "clone_skb $CLONE_SKB"
51 pg_set $dev "pkt_size $PKT_SIZE"
52 pg_set $dev "delay $DELAY"
53
54 # Flag example disabling timestamping
55 pg_set $dev "flag NO_TIMESTAMP"
56
57 # Destination
58 pg_set $dev "dst_mac $DST_MAC"
59 pg_set $dev "dst$IP6 $DEST_IP"
60
61 # Setup random UDP port src range
62 pg_set $dev "flag UDPSRC_RND"
63 pg_set $dev "udp_src_min $UDP_MIN"
64 pg_set $dev "udp_src_max $UDP_MAX"
65 done
66
67 # start_run
68 echo "Running... ctrl^C to stop" >&2
69 pg_ctrl "start"
70 echo "Done" >&2
71
72 # Print results
73 for ((thread = 0; thread < $THREADS; thread++)); do
74 dev=${DEV}@${thread}
75 echo "Device: $dev"
76 cat /proc/net/pktgen/$dev | grep -A2 "Result:"
77 done