2 # SPDX-License-Identifier: GPL-2.0
4 # Multiqueue: Using pktgen threads for sending on multiple CPUs
5 # * adding devices to kernel threads
6 # * notice the naming scheme for keeping device names unique
7 # * nameing scheme: dev@thread_number
8 # * flow variation via random UDP source port
11 source ${basedir}/functions.sh
12 root_check_run_with_sudo
"$@"
14 # Required param: -i dev in $DEV
15 source ${basedir}/parameters.sh
17 [ -z "$COUNT" ] && COUNT
="100000" # Zero means indefinitely
20 DELAY
="0" # Zero means max speed
21 [ -z "$CLONE_SKB" ] && CLONE_SKB
="0"
23 # Flow variation random source port between min and max
27 # (example of setting default params in your script)
28 if [ -z "$DEST_IP" ]; then
29 [ -z "$IP6" ] && DEST_IP
="198.18.0.42" || DEST_IP
="FD00::1"
31 [ -z "$DST_MAC" ] && DST_MAC
="90:e2:ba:ff:ff:ff"
33 # General cleanup everything since last run
36 # Threads are specified with parameter -t value in $THREADS
37 for ((thread
= $F_THREAD; thread
<= $L_THREAD; thread
++)); do
38 # The device name is extended with @name, using thread number to
39 # make then unique, but any name will do.
42 # Add remove all other devices and add_device $dev to thread
43 pg_thread
$thread "rem_device_all"
44 pg_thread
$thread "add_device" $dev
46 # Notice config queue to map to cpu (mirrors smp_processor_id())
47 # It is beneficial to map IRQ /proc/irq/*/smp_affinity 1:1 to CPU number
48 pg_set
$dev "flag QUEUE_MAP_CPU"
51 pg_set
$dev "count $COUNT"
52 pg_set
$dev "clone_skb $CLONE_SKB"
53 pg_set
$dev "pkt_size $PKT_SIZE"
54 pg_set
$dev "delay $DELAY"
56 # Flag example disabling timestamping
57 pg_set
$dev "flag NO_TIMESTAMP"
60 pg_set
$dev "dst_mac $DST_MAC"
61 pg_set
$dev "dst$IP6 $DEST_IP"
63 # Setup random UDP port src range
64 pg_set
$dev "flag UDPSRC_RND"
65 pg_set
$dev "udp_src_min $UDP_MIN"
66 pg_set
$dev "udp_src_max $UDP_MAX"
70 echo "Running... ctrl^C to stop" >&2
75 for ((thread
= $F_THREAD; thread
<= $L_THREAD; thread
++)); do
78 cat /proc
/net
/pktgen
/$dev |
grep -A2 "Result:"