of: MSI: Simplify irqdomain lookup
[linux/fpc-iii.git] / samples / pktgen / pktgen_sample02_multiqueue.sh
blob32467aea8e47848dde1ba77d5ac722c520720a2e
1 #!/bin/bash
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
9 basedir=`dirname $0`
10 source ${basedir}/functions.sh
11 root_check_run_with_sudo "$@"
13 # Required param: -i dev in $DEV
14 source ${basedir}/parameters.sh
16 # Base Config
17 DELAY="0" # Zero means max speed
18 COUNT="100000" # Zero means indefinitely
19 [ -z "$CLONE_SKB" ] && CLONE_SKB="0"
21 # Flow variation random source port between min and max
22 UDP_MIN=9
23 UDP_MAX=109
25 # (example of setting default params in your script)
26 [ -z "$DEST_IP" ] && DEST_IP="198.18.0.42"
27 [ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff"
29 # General cleanup everything since last run
30 pg_ctrl "reset"
32 # Threads are specified with parameter -t value in $THREADS
33 for ((thread = 0; thread < $THREADS; thread++)); do
34 # The device name is extended with @name, using thread number to
35 # make then unique, but any name will do.
36 dev=${DEV}@${thread}
38 # Add remove all other devices and add_device $dev to thread
39 pg_thread $thread "rem_device_all"
40 pg_thread $thread "add_device" $dev
42 # Notice config queue to map to cpu (mirrors smp_processor_id())
43 # It is beneficial to map IRQ /proc/irq/*/smp_affinity 1:1 to CPU number
44 pg_set $dev "flag QUEUE_MAP_CPU"
46 # Base config of dev
47 pg_set $dev "count $COUNT"
48 pg_set $dev "clone_skb $CLONE_SKB"
49 pg_set $dev "pkt_size $PKT_SIZE"
50 pg_set $dev "delay $DELAY"
52 # Flag example disabling timestamping
53 pg_set $dev "flag NO_TIMESTAMP"
55 # Destination
56 pg_set $dev "dst_mac $DST_MAC"
57 pg_set $dev "dst $DEST_IP"
59 # Setup random UDP port src range
60 pg_set $dev "flag UDPSRC_RND"
61 pg_set $dev "udp_src_min $UDP_MIN"
62 pg_set $dev "udp_src_max $UDP_MAX"
63 done
65 # start_run
66 echo "Running... ctrl^C to stop" >&2
67 pg_ctrl "start"
68 echo "Done" >&2
70 # Print results
71 for ((thread = 0; thread < $THREADS; thread++)); do
72 dev=${DEV}@${thread}
73 echo "Device: $dev"
74 cat /proc/net/pktgen/$dev | grep -A2 "Result:"
75 done