Skip to content

Commit 282fb58

Browse files
netoptimizerdavem330
authored andcommitted
pktgen: add sample script pktgen_sample02_multiqueue.sh
Add the pktgen samples script pktgen_sample02_multiqueue.sh that demonstrates generating packets on multiqueue NICs. Specifically notice the options "-t" that specifies how many kernel threads to activate. Also notice the flag QUEUE_MAP_CPU, which cause the SKB TX queue to be mapped to the CPU running the kernel thread. For best scalability people are also encourage to map NIC IRQ /proc/irq/*/smp_affinity to CPU number. Usage example with "-t" 4 threads and help: ./pktgen_sample02_multiqueue.sh -i eth4 -m 00:1B:21:3C:9D:F8 -t 4 Usage: ./pktgen_sample02_multiqueue.sh [-vx] -i ethX -i : ($DEV) output interface/device (required) -s : ($PKT_SIZE) packet size -d : ($DEST_IP) destination IP -m : ($DST_MAC) destination MAC-addr -t : ($THREADS) threads to start -c : ($SKB_CLONE) SKB clones send before alloc new SKB -b : ($BURST) HW level bursting of SKBs -v : ($VERBOSE) verbose -x : ($DEBUG) debug Removing pktgen.conf-2-1 and pktgen.conf-2-2 as these examples should be covered now. Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 6f09479 commit 282fb58

4 files changed

Lines changed: 75 additions & 141 deletions

File tree

‎Documentation/networking/pktgen.txt‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,6 @@ pktgen_sampleXX scripts and modify them to fit your own needs.
244244
The old scripts:
245245

246246
pktgen.conf-1-2 # 1 CPU 2 dev
247-
pktgen.conf-2-1 # 2 CPU's 1 dev
248-
pktgen.conf-2-2 # 2 CPU's 2 dev
249247
pktgen.conf-1-1-rdos # 1 CPU 1 dev w. route DoS
250248
pktgen.conf-1-1-ip6 # 1 CPU 1 dev ipv6
251249
pktgen.conf-1-1-ip6-rdos # 1 CPU 1 dev ipv6 w. route DoS

‎samples/pktgen/pktgen.conf-2-1‎

Lines changed: 0 additions & 66 deletions
This file was deleted.

‎samples/pktgen/pktgen.conf-2-2‎

Lines changed: 0 additions & 73 deletions
This file was deleted.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
[ -z "$DEST_IP" ] && DEST_IP="198.18.0.42"
27+
[ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff"
28+
29+
# General cleanup everything since last run
30+
pg_ctrl "reset"
31+
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}
37+
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
41+
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"
45+
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"
51+
52+
# Flag example disabling timestamping
53+
pg_set $dev "flag NO_TIMESTAMP"
54+
55+
# Destination
56+
pg_set $dev "dst_mac $DST_MAC"
57+
pg_set $dev "dst $DEST_IP"
58+
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
64+
65+
# start_run
66+
echo "Running... ctrl^C to stop" >&2
67+
pg_ctrl "start"
68+
echo "Done" >&2
69+
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

0 commit comments

Comments
 (0)