Commit 0f88e6f3 authored by David S. Miller's avatar David S. Miller

Merge branch 'pktgen-scripts-improvements'

Igor Russkikh says:

====================
pktgen: scripts improvements

Please consider small improvements to pktgen scripts we use in our environment.

Adding delay parameter through command line,
Adding new -a (append) parameter to make flex runs

v3: change us to ns in docs
v2: Review comments from Jesper

CC: Jesper Dangaard Brouer <brouer@redhat.com>
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 6f162909 c8fd4852
...@@ -28,10 +28,28 @@ across the sample scripts. Usage example is printed on errors:: ...@@ -28,10 +28,28 @@ across the sample scripts. Usage example is printed on errors::
-b : ($BURST) HW level bursting of SKBs -b : ($BURST) HW level bursting of SKBs
-v : ($VERBOSE) verbose -v : ($VERBOSE) verbose
-x : ($DEBUG) debug -x : ($DEBUG) debug
-6 : ($IP6) IPv6
-w : ($DELAY) Tx Delay value (ns)
-a : ($APPEND) Script will not reset generator's state, but will append its config
The global variable being set is also listed. E.g. the required The global variable being set is also listed. E.g. the required
interface/device parameter "-i" sets variable $DEV. interface/device parameter "-i" sets variable $DEV.
"-a" parameter may be used to create different flows simultaneously.
In this mode script will keep the existing config, will append its settings.
In this mode you'll have to manually run traffic with "pg_ctrl start".
For example you may use:
source ./samples/pktgen/functions.sh
pg_ctrl reset
# add first device
./pktgen_sample06_numa_awared_queue_irq_affinity.sh -a -i ens1f0 -m 34:80:0d:a3:fc:c9 -t 8
# add second device
./pktgen_sample06_numa_awared_queue_irq_affinity.sh -a -i ens1f1 -m 34:80:0d:a3:fc:c9 -t 8
# run joint traffic on two devs
pg_ctrl start
Common functions Common functions
---------------- ----------------
The functions.sh file provides; Three different shell functions for The functions.sh file provides; Three different shell functions for
......
...@@ -108,7 +108,12 @@ function pgset() { ...@@ -108,7 +108,12 @@ function pgset() {
fi fi
} }
[[ $EUID -eq 0 ]] && trap 'pg_ctrl "reset"' EXIT if [[ -z "$APPEND" ]]; then
if [[ $EUID -eq 0 ]]; then
# Cleanup pktgen setup on exit if thats not "append mode"
trap 'pg_ctrl "reset"' EXIT
fi
fi
## -- General shell tricks -- ## -- General shell tricks --
......
...@@ -19,12 +19,14 @@ function usage() { ...@@ -19,12 +19,14 @@ function usage() {
echo " -v : (\$VERBOSE) verbose" echo " -v : (\$VERBOSE) verbose"
echo " -x : (\$DEBUG) debug" echo " -x : (\$DEBUG) debug"
echo " -6 : (\$IP6) IPv6" echo " -6 : (\$IP6) IPv6"
echo " -w : (\$DELAY) Tx Delay value (ns)"
echo " -a : (\$APPEND) Script will not reset generator's state, but will append its config"
echo "" echo ""
} }
## --- Parse command line arguments / parameters --- ## --- Parse command line arguments / parameters ---
## echo "Commandline options:" ## echo "Commandline options:"
while getopts "s:i:d:m:p:f:t:c:n:b:vxh6" option; do while getopts "s:i:d:m:p:f:t:c:n:b:w:vxh6a" option; do
case $option in case $option in
i) # interface i) # interface
export DEV=$OPTARG export DEV=$OPTARG
...@@ -66,6 +68,10 @@ while getopts "s:i:d:m:p:f:t:c:n:b:vxh6" option; do ...@@ -66,6 +68,10 @@ while getopts "s:i:d:m:p:f:t:c:n:b:vxh6" option; do
export BURST=$OPTARG export BURST=$OPTARG
info "SKB bursting: BURST=$BURST" info "SKB bursting: BURST=$BURST"
;; ;;
w)
export DELAY=$OPTARG
info "DELAY=$DELAY"
;;
v) v)
export VERBOSE=yes export VERBOSE=yes
info "Verbose mode: VERBOSE=$VERBOSE" info "Verbose mode: VERBOSE=$VERBOSE"
...@@ -78,6 +84,10 @@ while getopts "s:i:d:m:p:f:t:c:n:b:vxh6" option; do ...@@ -78,6 +84,10 @@ while getopts "s:i:d:m:p:f:t:c:n:b:vxh6" option; do
export IP6=6 export IP6=6
info "IP6: IP6=$IP6" info "IP6: IP6=$IP6"
;; ;;
a)
export APPEND=yes
info "Append mode: APPEND=$APPEND"
;;
h|?|*) h|?|*)
usage; usage;
err 2 "[ERROR] Unknown parameters!!!" err 2 "[ERROR] Unknown parameters!!!"
...@@ -100,6 +110,9 @@ if [ -z "$THREADS" ]; then ...@@ -100,6 +110,9 @@ if [ -z "$THREADS" ]; then
export THREADS=1 export THREADS=1
fi fi
# default DELAY
[ -z "$DELAY" ] && export DELAY=0 # Zero means max speed
export L_THREAD=$(( THREADS + F_THREAD - 1 )) export L_THREAD=$(( THREADS + F_THREAD - 1 ))
if [ -z "$DEV" ]; then if [ -z "$DEV" ]; then
......
...@@ -50,9 +50,6 @@ if [ -n "$DST_PORT" ]; then ...@@ -50,9 +50,6 @@ if [ -n "$DST_PORT" ]; then
validate_ports $UDP_DST_MIN $UDP_DST_MAX validate_ports $UDP_DST_MIN $UDP_DST_MAX
fi fi
# Base Config
DELAY="0" # Zero means max speed
# General cleanup everything since last run # General cleanup everything since last run
pg_ctrl "reset" pg_ctrl "reset"
......
...@@ -33,9 +33,6 @@ if [ -n "$DST_PORT" ]; then ...@@ -33,9 +33,6 @@ if [ -n "$DST_PORT" ]; then
validate_ports $UDP_DST_MIN $UDP_DST_MAX validate_ports $UDP_DST_MIN $UDP_DST_MAX
fi fi
# Base Config
DELAY="0" # Zero means max speed
# General cleanup everything since last run # General cleanup everything since last run
pg_ctrl "reset" pg_ctrl "reset"
......
...@@ -31,20 +31,17 @@ if [ -n "$DST_PORT" ]; then ...@@ -31,20 +31,17 @@ if [ -n "$DST_PORT" ]; then
validate_ports $UDP_DST_MIN $UDP_DST_MAX validate_ports $UDP_DST_MIN $UDP_DST_MAX
fi fi
# Base Config
DELAY="0" # Zero means max speed
# Flow variation random source port between min and max # Flow variation random source port between min and max
UDP_SRC_MIN=9 UDP_SRC_MIN=9
UDP_SRC_MAX=109 UDP_SRC_MAX=109
# General cleanup everything since last run # General cleanup everything since last run
# (especially important if other threads were configured by other scripts) # (especially important if other threads were configured by other scripts)
pg_ctrl "reset" [ -z "$APPEND" ] && pg_ctrl "reset"
# Add remove all other devices and add_device $DEV to thread 0 # Add remove all other devices and add_device $DEV to thread 0
thread=0 thread=0
pg_thread $thread "rem_device_all" [ -z "$APPEND" ] && pg_thread $thread "rem_device_all"
pg_thread $thread "add_device" $DEV pg_thread $thread "add_device" $DEV
# How many packets to send (zero means indefinitely) # How many packets to send (zero means indefinitely)
...@@ -80,11 +77,15 @@ pg_set $DEV "flag UDPSRC_RND" ...@@ -80,11 +77,15 @@ pg_set $DEV "flag UDPSRC_RND"
pg_set $DEV "udp_src_min $UDP_SRC_MIN" pg_set $DEV "udp_src_min $UDP_SRC_MIN"
pg_set $DEV "udp_src_max $UDP_SRC_MAX" pg_set $DEV "udp_src_max $UDP_SRC_MAX"
# start_run if [ -z "$APPEND" ]; then
echo "Running... ctrl^C to stop" >&2 # start_run
pg_ctrl "start" echo "Running... ctrl^C to stop" >&2
echo "Done" >&2 pg_ctrl "start"
echo "Done" >&2
# Print results # Print results
echo "Result device: $DEV" echo "Result device: $DEV"
cat /proc/net/pktgen/$DEV cat /proc/net/pktgen/$DEV
else
echo "Append mode: config done. Do more or use 'pg_ctrl start' to run"
fi
\ No newline at end of file
...@@ -17,7 +17,6 @@ source ${basedir}/parameters.sh ...@@ -17,7 +17,6 @@ source ${basedir}/parameters.sh
[ -z "$COUNT" ] && COUNT="100000" # Zero means indefinitely [ -z "$COUNT" ] && COUNT="100000" # Zero means indefinitely
# Base Config # Base Config
DELAY="0" # Zero means max speed
[ -z "$CLONE_SKB" ] && CLONE_SKB="0" [ -z "$CLONE_SKB" ] && CLONE_SKB="0"
# Flow variation random source port between min and max # Flow variation random source port between min and max
...@@ -39,7 +38,7 @@ if [ -n "$DST_PORT" ]; then ...@@ -39,7 +38,7 @@ if [ -n "$DST_PORT" ]; then
fi fi
# General cleanup everything since last run # General cleanup everything since last run
pg_ctrl "reset" [ -z "$APPEND" ] && pg_ctrl "reset"
# Threads are specified with parameter -t value in $THREADS # Threads are specified with parameter -t value in $THREADS
for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
...@@ -48,7 +47,7 @@ for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do ...@@ -48,7 +47,7 @@ for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
dev=${DEV}@${thread} dev=${DEV}@${thread}
# Add remove all other devices and add_device $dev to thread # Add remove all other devices and add_device $dev to thread
pg_thread $thread "rem_device_all" [ -z "$APPEND" ] && pg_thread $thread "rem_device_all"
pg_thread $thread "add_device" $dev pg_thread $thread "add_device" $dev
# Notice config queue to map to cpu (mirrors smp_processor_id()) # Notice config queue to map to cpu (mirrors smp_processor_id())
...@@ -82,14 +81,18 @@ for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do ...@@ -82,14 +81,18 @@ for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
pg_set $dev "udp_src_max $UDP_SRC_MAX" pg_set $dev "udp_src_max $UDP_SRC_MAX"
done done
# start_run if [ -z "$APPEND" ]; then
echo "Running... ctrl^C to stop" >&2 # start_run
pg_ctrl "start" echo "Running... ctrl^C to stop" >&2
echo "Done" >&2 pg_ctrl "start"
echo "Done" >&2
# Print results # Print results
for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
dev=${DEV}@${thread} dev=${DEV}@${thread}
echo "Device: $dev" echo "Device: $dev"
cat /proc/net/pktgen/$dev | grep -A2 "Result:" cat /proc/net/pktgen/$dev | grep -A2 "Result:"
done done
else
echo "Append mode: config done. Do more or use 'pg_ctrl start' to run"
fi
...@@ -42,18 +42,15 @@ if [ -n "$DST_PORT" ]; then ...@@ -42,18 +42,15 @@ if [ -n "$DST_PORT" ]; then
validate_ports $UDP_DST_MIN $UDP_DST_MAX validate_ports $UDP_DST_MIN $UDP_DST_MAX
fi fi
# Base Config
DELAY="0" # Zero means max speed
# General cleanup everything since last run # General cleanup everything since last run
pg_ctrl "reset" [ -z "$APPEND" ] && pg_ctrl "reset"
# Threads are specified with parameter -t value in $THREADS # Threads are specified with parameter -t value in $THREADS
for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
dev=${DEV}@${thread} dev=${DEV}@${thread}
# Add remove all other devices and add_device $dev to thread # Add remove all other devices and add_device $dev to thread
pg_thread $thread "rem_device_all" [ -z "$APPEND" ] && pg_thread $thread "rem_device_all"
pg_thread $thread "add_device" $dev pg_thread $thread "add_device" $dev
# Base config # Base config
...@@ -97,5 +94,9 @@ function control_c() { ...@@ -97,5 +94,9 @@ function control_c() {
# trap keyboard interrupt (Ctrl-C) # trap keyboard interrupt (Ctrl-C)
trap control_c SIGINT trap control_c SIGINT
echo "Running... ctrl^C to stop" >&2 if [ -z "$APPEND" ]; then
pg_ctrl "start" echo "Running... ctrl^C to stop" >&2
pg_ctrl "start"
else
echo "Append mode: config done. Do more or use 'pg_ctrl start' to run"
fi
...@@ -34,9 +34,6 @@ fi ...@@ -34,9 +34,6 @@ fi
[ -z "$FLOWS" ] && FLOWS="8000" [ -z "$FLOWS" ] && FLOWS="8000"
[ -z "$FLOWLEN" ] && FLOWLEN="10" [ -z "$FLOWLEN" ] && FLOWLEN="10"
# Base Config
DELAY="0" # Zero means max speed
if [[ -n "$BURST" ]]; then if [[ -n "$BURST" ]]; then
err 1 "Bursting not supported for this mode" err 1 "Bursting not supported for this mode"
fi fi
...@@ -45,14 +42,14 @@ fi ...@@ -45,14 +42,14 @@ fi
read -r SRC_MIN SRC_MAX <<< $(parse_addr 198.18.0.0/15) read -r SRC_MIN SRC_MAX <<< $(parse_addr 198.18.0.0/15)
# General cleanup everything since last run # General cleanup everything since last run
pg_ctrl "reset" [ -z "$APPEND" ] && pg_ctrl "reset"
# Threads are specified with parameter -t value in $THREADS # Threads are specified with parameter -t value in $THREADS
for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
dev=${DEV}@${thread} dev=${DEV}@${thread}
# Add remove all other devices and add_device $dev to thread # Add remove all other devices and add_device $dev to thread
pg_thread $thread "rem_device_all" [ -z "$APPEND" ] && pg_thread $thread "rem_device_all"
pg_thread $thread "add_device" $dev pg_thread $thread "add_device" $dev
# Base config # Base config
...@@ -107,7 +104,11 @@ function print_result() { ...@@ -107,7 +104,11 @@ function print_result() {
# trap keyboard interrupt (Ctrl-C) # trap keyboard interrupt (Ctrl-C)
trap true SIGINT trap true SIGINT
echo "Running... ctrl^C to stop" >&2 if [ -z "$APPEND" ]; then
pg_ctrl "start" echo "Running... ctrl^C to stop" >&2
pg_ctrl "start"
print_result print_result
else
echo "Append mode: config done. Do more or use 'pg_ctrl start' to run"
fi
...@@ -31,18 +31,15 @@ if [ -n "$DST_PORT" ]; then ...@@ -31,18 +31,15 @@ if [ -n "$DST_PORT" ]; then
validate_ports $UDP_DST_MIN $UDP_DST_MAX validate_ports $UDP_DST_MIN $UDP_DST_MAX
fi fi
# Base Config
DELAY="0" # Zero means max speed
# General cleanup everything since last run # General cleanup everything since last run
pg_ctrl "reset" [ -z "$APPEND" ] && pg_ctrl "reset"
# Threads are specified with parameter -t value in $THREADS # Threads are specified with parameter -t value in $THREADS
for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
dev=${DEV}@${thread} dev=${DEV}@${thread}
# Add remove all other devices and add_device $dev to thread # Add remove all other devices and add_device $dev to thread
pg_thread $thread "rem_device_all" [ -z "$APPEND" ] && pg_thread $thread "rem_device_all"
pg_thread $thread "add_device" $dev pg_thread $thread "add_device" $dev
# Base config # Base config
...@@ -91,7 +88,11 @@ function print_result() { ...@@ -91,7 +88,11 @@ function print_result() {
# trap keyboard interrupt (Ctrl-C) # trap keyboard interrupt (Ctrl-C)
trap true SIGINT trap true SIGINT
echo "Running... ctrl^C to stop" >&2 if [ -z "$APPEND" ]; then
pg_ctrl "start" echo "Running... ctrl^C to stop" >&2
pg_ctrl "start"
print_result print_result
else
echo "Append mode: config done. Do more or use 'pg_ctrl start' to run"
fi
...@@ -15,7 +15,6 @@ root_check_run_with_sudo "$@" ...@@ -15,7 +15,6 @@ root_check_run_with_sudo "$@"
source ${basedir}/parameters.sh source ${basedir}/parameters.sh
# Base Config # Base Config
DELAY="0" # Zero means max speed
[ -z "$COUNT" ] && COUNT="20000000" # Zero means indefinitely [ -z "$COUNT" ] && COUNT="20000000" # Zero means indefinitely
[ -z "$CLONE_SKB" ] && CLONE_SKB="0" [ -z "$CLONE_SKB" ] && CLONE_SKB="0"
...@@ -45,7 +44,7 @@ if [ -n "$DST_PORT" ]; then ...@@ -45,7 +44,7 @@ if [ -n "$DST_PORT" ]; then
fi fi
# General cleanup everything since last run # General cleanup everything since last run
pg_ctrl "reset" [ -z "$APPEND" ] && pg_ctrl "reset"
# Threads are specified with parameter -t value in $THREADS # Threads are specified with parameter -t value in $THREADS
for ((i = 0; i < $THREADS; i++)); do for ((i = 0; i < $THREADS; i++)); do
...@@ -59,7 +58,7 @@ for ((i = 0; i < $THREADS; i++)); do ...@@ -59,7 +58,7 @@ for ((i = 0; i < $THREADS; i++)); do
info "irq ${irq_array[$i]} is set affinity to `cat /proc/irq/${irq_array[$i]}/smp_affinity_list`" info "irq ${irq_array[$i]} is set affinity to `cat /proc/irq/${irq_array[$i]}/smp_affinity_list`"
# Add remove all other devices and add_device $dev to thread # Add remove all other devices and add_device $dev to thread
pg_thread $thread "rem_device_all" [ -z "$APPEND" ] && pg_thread $thread "rem_device_all"
pg_thread $thread "add_device" $dev pg_thread $thread "add_device" $dev
# select queue and bind the queue and $dev in 1:1 relationship # select queue and bind the queue and $dev in 1:1 relationship
...@@ -100,14 +99,18 @@ for ((i = 0; i < $THREADS; i++)); do ...@@ -100,14 +99,18 @@ for ((i = 0; i < $THREADS; i++)); do
done done
# start_run # start_run
echo "Running... ctrl^C to stop" >&2 if [ -z "$APPEND" ]; then
pg_ctrl "start" echo "Running... ctrl^C to stop" >&2
echo "Done" >&2 pg_ctrl "start"
echo "Done" >&2
# Print results # Print results
for ((i = 0; i < $THREADS; i++)); do for ((i = 0; i < $THREADS; i++)); do
thread=${cpu_array[$((i+F_THREAD))]} thread=${cpu_array[$((i+F_THREAD))]}
dev=${DEV}@${thread} dev=${DEV}@${thread}
echo "Device: $dev" echo "Device: $dev"
cat /proc/net/pktgen/$dev | grep -A2 "Result:" cat /proc/net/pktgen/$dev | grep -A2 "Result:"
done done
else
echo "Append mode: config done. Do more or use 'pg_ctrl start' to run"
fi
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment