aboutsummaryrefslogtreecommitdiffstats
path: root/samples
diff options
context:
space:
mode:
authorJesper Dangaard Brouer <brouer@redhat.com>2015-05-21 06:17:48 -0400
committerDavid S. Miller <davem@davemloft.net>2015-05-22 23:59:17 -0400
commit282fb58947e129dea8badf48972ea89d027a76dc (patch)
treef1be92dbeb67d70b4204cd19ae0d14740c71a897 /samples
parent6f09479758be247fef02188a275383ebaddbe291 (diff)
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>
Diffstat (limited to 'samples')
-rwxr-xr-xsamples/pktgen/pktgen.conf-2-166
-rwxr-xr-xsamples/pktgen/pktgen.conf-2-273
-rwxr-xr-xsamples/pktgen/pktgen_sample02_multiqueue.sh75
3 files changed, 75 insertions, 139 deletions
diff --git a/samples/pktgen/pktgen.conf-2-1 b/samples/pktgen/pktgen.conf-2-1
deleted file mode 100755
index e108e97d6d89..000000000000
--- a/samples/pktgen/pktgen.conf-2-1
+++ /dev/null
@@ -1,66 +0,0 @@
1#!/bin/bash
2
3#modprobe pktgen
4
5
6function pgset() {
7 local result
8
9 echo $1 > $PGDEV
10
11 result=`cat $PGDEV | fgrep "Result: OK:"`
12 if [ "$result" = "" ]; then
13 cat $PGDEV | fgrep Result:
14 fi
15}
16
17# Config Start Here -----------------------------------------------------------
18
19
20# thread config
21# Each CPU has its own thread. Two CPU example. We add eth1 to the first
22# and leave the second idle.
23
24PGDEV=/proc/net/pktgen/kpktgend_0
25 echo "Removing all devices"
26 pgset "rem_device_all"
27 echo "Adding eth1"
28 pgset "add_device eth1"
29
30# We need to remove old config since we dont use this thread. We can only
31# one NIC on one CPU due to affinity reasons.
32
33PGDEV=/proc/net/pktgen/kpktgend_1
34 echo "Removing all devices"
35 pgset "rem_device_all"
36
37# device config
38# delay 0 means maximum speed.
39
40CLONE_SKB="clone_skb 1000000"
41# NIC adds 4 bytes CRC
42PKT_SIZE="pkt_size 60"
43
44# COUNT 0 means forever
45#COUNT="count 0"
46COUNT="count 10000000"
47DELAY="delay 0"
48
49PGDEV=/proc/net/pktgen/eth1
50 echo "Configuring $PGDEV"
51 pgset "$COUNT"
52 pgset "$CLONE_SKB"
53 pgset "$PKT_SIZE"
54 pgset "$DELAY"
55 pgset "dst 10.10.11.2"
56 pgset "dst_mac 00:04:23:08:91:dc"
57
58
59# Time to run
60PGDEV=/proc/net/pktgen/pgctrl
61
62 echo "Running... ctrl^C to stop"
63 trap true INT
64 pgset "start"
65 echo "Done"
66 cat /proc/net/pktgen/eth1
diff --git a/samples/pktgen/pktgen.conf-2-2 b/samples/pktgen/pktgen.conf-2-2
deleted file mode 100755
index acea15503e71..000000000000
--- a/samples/pktgen/pktgen.conf-2-2
+++ /dev/null
@@ -1,73 +0,0 @@
1#!/bin/bash
2
3#modprobe pktgen
4
5
6function pgset() {
7 local result
8
9 echo $1 > $PGDEV
10
11 result=`cat $PGDEV | fgrep "Result: OK:"`
12 if [ "$result" = "" ]; then
13 cat $PGDEV | fgrep Result:
14 fi
15}
16
17# Config Start Here -----------------------------------------------------------
18
19
20# thread config
21# Each CPU has its own thread. Two CPU example. We add eth1, eth2 respectively.
22
23PGDEV=/proc/net/pktgen/kpktgend_0
24 echo "Removing all devices"
25 pgset "rem_device_all"
26 echo "Adding eth1"
27 pgset "add_device eth1"
28
29PGDEV=/proc/net/pktgen/kpktgend_1
30 echo "Removing all devices"
31 pgset "rem_device_all"
32 echo "Adding eth2"
33 pgset "add_device eth2"
34
35
36# device config
37# delay 0 means maximum speed.
38
39CLONE_SKB="clone_skb 1000000"
40# NIC adds 4 bytes CRC
41PKT_SIZE="pkt_size 60"
42
43# COUNT 0 means forever
44#COUNT="count 0"
45COUNT="count 10000000"
46DELAY="delay 0"
47
48PGDEV=/proc/net/pktgen/eth1
49 echo "Configuring $PGDEV"
50 pgset "$COUNT"
51 pgset "$CLONE_SKB"
52 pgset "$PKT_SIZE"
53 pgset "$DELAY"
54 pgset "dst 10.10.11.2"
55 pgset "dst_mac 00:04:23:08:91:dc"
56
57PGDEV=/proc/net/pktgen/eth2
58 echo "Configuring $PGDEV"
59 pgset "$COUNT"
60 pgset "$CLONE_SKB"
61 pgset "$PKT_SIZE"
62 pgset "$DELAY"
63 pgset "dst 192.168.2.2"
64 pgset "dst_mac 00:04:23:08:91:de"
65
66# Time to run
67PGDEV=/proc/net/pktgen/pgctrl
68
69 echo "Running... ctrl^C to stop"
70 trap true INT
71 pgset "start"
72 echo "Done"
73 cat /proc/net/pktgen/eth1 /proc/net/pktgen/eth2
diff --git a/samples/pktgen/pktgen_sample02_multiqueue.sh b/samples/pktgen/pktgen_sample02_multiqueue.sh
new file mode 100755
index 000000000000..32467aea8e47
--- /dev/null
+++ b/samples/pktgen/pktgen_sample02_multiqueue.sh
@@ -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#
9basedir=`dirname $0`
10source ${basedir}/functions.sh
11root_check_run_with_sudo "$@"
12#
13# Required param: -i dev in $DEV
14source ${basedir}/parameters.sh
15
16# Base Config
17DELAY="0" # Zero means max speed
18COUNT="100000" # Zero means indefinitely
19[ -z "$CLONE_SKB" ] && CLONE_SKB="0"
20
21# Flow variation random source port between min and max
22UDP_MIN=9
23UDP_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
30pg_ctrl "reset"
31
32# Threads are specified with parameter -t value in $THREADS
33for ((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"
63done
64
65# start_run
66echo "Running... ctrl^C to stop" >&2
67pg_ctrl "start"
68echo "Done" >&2
69
70# Print results
71for ((thread = 0; thread < $THREADS; thread++)); do
72 dev=${DEV}@${thread}
73 echo "Device: $dev"
74 cat /proc/net/pktgen/$dev | grep -A2 "Result:"
75done