* [PATCH net-next 0/2] pktgen: scripts improvements @ 2021-01-22 15:05 Igor Russkikh 2021-01-22 15:05 ` [PATCH net-next 1/2] samples: pktgen: allow to specify delay parameter via new opt Igor Russkikh 2021-01-22 15:05 ` [PATCH net-next 2/2] samples: pktgen: new append mode Igor Russkikh 0 siblings, 2 replies; 6+ messages in thread From: Igor Russkikh @ 2021-01-22 15:05 UTC (permalink / raw) To: netdev; +Cc: David S . Miller, Jakub Kicinski, Igor Russkikh Hello netdev community, 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 Igor Russkikh (2): samples: pktgen: allow to specify delay parameter via new opt samples: pktgen: new append mode samples/pktgen/README.rst | 18 ++++++++++++++++++ samples/pktgen/functions.sh | 2 +- samples/pktgen/parameters.sh | 15 ++++++++++++++- .../pktgen_bench_xmit_mode_netif_receive.sh | 3 --- .../pktgen_bench_xmit_mode_queue_xmit.sh | 3 --- samples/pktgen/pktgen_sample01_simple.sh | 13 ++++++++----- samples/pktgen/pktgen_sample02_multiqueue.sh | 11 ++++++++--- .../pktgen_sample03_burst_single_flow.sh | 13 ++++++++----- samples/pktgen/pktgen_sample04_many_flows.sh | 13 ++++++++----- .../pktgen/pktgen_sample05_flow_per_thread.sh | 13 ++++++++----- ..._sample06_numa_awared_queue_irq_affinity.sh | 11 ++++++++--- 11 files changed, 81 insertions(+), 34 deletions(-) -- 2.17.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next 1/2] samples: pktgen: allow to specify delay parameter via new opt 2021-01-22 15:05 [PATCH net-next 0/2] pktgen: scripts improvements Igor Russkikh @ 2021-01-22 15:05 ` Igor Russkikh 2021-01-26 12:38 ` Jesper Dangaard Brouer 2021-01-22 15:05 ` [PATCH net-next 2/2] samples: pktgen: new append mode Igor Russkikh 1 sibling, 1 reply; 6+ messages in thread From: Igor Russkikh @ 2021-01-22 15:05 UTC (permalink / raw) To: netdev; +Cc: David S . Miller, Jakub Kicinski, Igor Russkikh DELAY may now be explicitly specified via common parameter -w Signed-off-by: Igor Russkikh <irusskikh@marvell.com> --- samples/pktgen/parameters.sh | 10 +++++++++- samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh | 3 --- samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh | 3 --- samples/pktgen/pktgen_sample01_simple.sh | 3 --- samples/pktgen/pktgen_sample02_multiqueue.sh | 1 - samples/pktgen/pktgen_sample03_burst_single_flow.sh | 3 --- samples/pktgen/pktgen_sample04_many_flows.sh | 3 --- samples/pktgen/pktgen_sample05_flow_per_thread.sh | 3 --- .../pktgen_sample06_numa_awared_queue_irq_affinity.sh | 1 - 9 files changed, 9 insertions(+), 21 deletions(-) diff --git a/samples/pktgen/parameters.sh b/samples/pktgen/parameters.sh index ff0ed474fee9..70cc2878d479 100644 --- a/samples/pktgen/parameters.sh +++ b/samples/pktgen/parameters.sh @@ -19,12 +19,13 @@ function usage() { echo " -v : (\$VERBOSE) verbose" echo " -x : (\$DEBUG) debug" echo " -6 : (\$IP6) IPv6" + echo " -w : (\$DELAY) Tx Delay value (us)" echo "" } ## --- Parse command line arguments / parameters --- ## 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:vxh6" option; do case $option in i) # interface export DEV=$OPTARG @@ -66,6 +67,10 @@ while getopts "s:i:d:m:p:f:t:c:n:b:vxh6" option; do export BURST=$OPTARG info "SKB bursting: BURST=$BURST" ;; + w) + export DELAY=$OPTARG + info "DELAY=$DELAY" + ;; v) export VERBOSE=yes info "Verbose mode: VERBOSE=$VERBOSE" @@ -100,6 +105,9 @@ if [ -z "$THREADS" ]; then export THREADS=1 fi +# default DELAY +[ -z "$DELAY" ] && export DELAY=0 # Zero means max speed + export L_THREAD=$(( THREADS + F_THREAD - 1 )) if [ -z "$DEV" ]; then diff --git a/samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh b/samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh index 1b6204125d2d..30a610b541ad 100755 --- a/samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh +++ b/samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh @@ -50,9 +50,6 @@ if [ -n "$DST_PORT" ]; then validate_ports $UDP_DST_MIN $UDP_DST_MAX fi -# Base Config -DELAY="0" # Zero means max speed - # General cleanup everything since last run pg_ctrl "reset" diff --git a/samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh b/samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh index e607cb369b20..a6195bd77532 100755 --- a/samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh +++ b/samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh @@ -33,9 +33,6 @@ if [ -n "$DST_PORT" ]; then validate_ports $UDP_DST_MIN $UDP_DST_MAX fi -# Base Config -DELAY="0" # Zero means max speed - # General cleanup everything since last run pg_ctrl "reset" diff --git a/samples/pktgen/pktgen_sample01_simple.sh b/samples/pktgen/pktgen_sample01_simple.sh index a4e250b45dce..c2ad1fa32d3f 100755 --- a/samples/pktgen/pktgen_sample01_simple.sh +++ b/samples/pktgen/pktgen_sample01_simple.sh @@ -31,9 +31,6 @@ if [ -n "$DST_PORT" ]; then validate_ports $UDP_DST_MIN $UDP_DST_MAX fi -# Base Config -DELAY="0" # Zero means max speed - # Flow variation random source port between min and max UDP_SRC_MIN=9 UDP_SRC_MAX=109 diff --git a/samples/pktgen/pktgen_sample02_multiqueue.sh b/samples/pktgen/pktgen_sample02_multiqueue.sh index cb2495fcdc60..49e1e81a2945 100755 --- a/samples/pktgen/pktgen_sample02_multiqueue.sh +++ b/samples/pktgen/pktgen_sample02_multiqueue.sh @@ -17,7 +17,6 @@ source ${basedir}/parameters.sh [ -z "$COUNT" ] && COUNT="100000" # Zero means indefinitely # Base Config -DELAY="0" # Zero means max speed [ -z "$CLONE_SKB" ] && CLONE_SKB="0" # Flow variation random source port between min and max diff --git a/samples/pktgen/pktgen_sample03_burst_single_flow.sh b/samples/pktgen/pktgen_sample03_burst_single_flow.sh index fff50765a5aa..f9b67affb567 100755 --- a/samples/pktgen/pktgen_sample03_burst_single_flow.sh +++ b/samples/pktgen/pktgen_sample03_burst_single_flow.sh @@ -42,9 +42,6 @@ if [ -n "$DST_PORT" ]; then validate_ports $UDP_DST_MIN $UDP_DST_MAX fi -# Base Config -DELAY="0" # Zero means max speed - # General cleanup everything since last run pg_ctrl "reset" diff --git a/samples/pktgen/pktgen_sample04_many_flows.sh b/samples/pktgen/pktgen_sample04_many_flows.sh index 2cd6b701400d..ac2d037a6160 100755 --- a/samples/pktgen/pktgen_sample04_many_flows.sh +++ b/samples/pktgen/pktgen_sample04_many_flows.sh @@ -34,9 +34,6 @@ fi [ -z "$FLOWS" ] && FLOWS="8000" [ -z "$FLOWLEN" ] && FLOWLEN="10" -# Base Config -DELAY="0" # Zero means max speed - if [[ -n "$BURST" ]]; then err 1 "Bursting not supported for this mode" fi diff --git a/samples/pktgen/pktgen_sample05_flow_per_thread.sh b/samples/pktgen/pktgen_sample05_flow_per_thread.sh index 4cb6252ade39..85256484c86f 100755 --- a/samples/pktgen/pktgen_sample05_flow_per_thread.sh +++ b/samples/pktgen/pktgen_sample05_flow_per_thread.sh @@ -31,9 +31,6 @@ if [ -n "$DST_PORT" ]; then validate_ports $UDP_DST_MIN $UDP_DST_MAX fi -# Base Config -DELAY="0" # Zero means max speed - # General cleanup everything since last run pg_ctrl "reset" diff --git a/samples/pktgen/pktgen_sample06_numa_awared_queue_irq_affinity.sh b/samples/pktgen/pktgen_sample06_numa_awared_queue_irq_affinity.sh index 728106060a02..7c73ab8fbe3c 100755 --- a/samples/pktgen/pktgen_sample06_numa_awared_queue_irq_affinity.sh +++ b/samples/pktgen/pktgen_sample06_numa_awared_queue_irq_affinity.sh @@ -15,7 +15,6 @@ root_check_run_with_sudo "$@" source ${basedir}/parameters.sh # Base Config -DELAY="0" # Zero means max speed [ -z "$COUNT" ] && COUNT="20000000" # Zero means indefinitely [ -z "$CLONE_SKB" ] && CLONE_SKB="0" -- 2.17.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 1/2] samples: pktgen: allow to specify delay parameter via new opt 2021-01-22 15:05 ` [PATCH net-next 1/2] samples: pktgen: allow to specify delay parameter via new opt Igor Russkikh @ 2021-01-26 12:38 ` Jesper Dangaard Brouer 0 siblings, 0 replies; 6+ messages in thread From: Jesper Dangaard Brouer @ 2021-01-26 12:38 UTC (permalink / raw) To: Igor Russkikh; +Cc: brouer, netdev, David S . Miller, Jakub Kicinski On Fri, 22 Jan 2021 16:05:16 +0100 Igor Russkikh <irusskikh@marvell.com> wrote: > DELAY may now be explicitly specified via common parameter -w What are you actually using this for? Notice there is also an option called "ratep" which can be used for setting the packet rate per sec. In the pktgen.c code, it will use the "delay" variable. > Signed-off-by: Igor Russkikh <irusskikh@marvell.com> > --- > samples/pktgen/parameters.sh | 10 +++++++++- > samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh | 3 --- > samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh | 3 --- > samples/pktgen/pktgen_sample01_simple.sh | 3 --- > samples/pktgen/pktgen_sample02_multiqueue.sh | 1 - > samples/pktgen/pktgen_sample03_burst_single_flow.sh | 3 --- > samples/pktgen/pktgen_sample04_many_flows.sh | 3 --- > samples/pktgen/pktgen_sample05_flow_per_thread.sh | 3 --- > .../pktgen_sample06_numa_awared_queue_irq_affinity.sh | 1 - > 9 files changed, 9 insertions(+), 21 deletions(-) > > diff --git a/samples/pktgen/parameters.sh b/samples/pktgen/parameters.sh > index ff0ed474fee9..70cc2878d479 100644 > --- a/samples/pktgen/parameters.sh > +++ b/samples/pktgen/parameters.sh > @@ -19,12 +19,13 @@ function usage() { > echo " -v : (\$VERBOSE) verbose" > echo " -x : (\$DEBUG) debug" > echo " -6 : (\$IP6) IPv6" > + echo " -w : (\$DELAY) Tx Delay value (us)" I think the resolution is in nanosec. > echo "" > } > > ## --- Parse command line arguments / parameters --- > ## 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:vxh6" option; do > case $option in > i) # interface > export DEV=$OPTARG > @@ -66,6 +67,10 @@ while getopts "s:i:d:m:p:f:t:c:n:b:vxh6" option; do > export BURST=$OPTARG > info "SKB bursting: BURST=$BURST" > ;; > + w) > + export DELAY=$OPTARG > + info "DELAY=$DELAY" > + ;; > v) > export VERBOSE=yes > info "Verbose mode: VERBOSE=$VERBOSE" > @@ -100,6 +105,9 @@ if [ -z "$THREADS" ]; then > export THREADS=1 > fi > > +# default DELAY > +[ -z "$DELAY" ] && export DELAY=0 # Zero means max speed > + Nice this allow us to remove some lines in the other scripts. As all script have line: pg_set $dev "delay $DELAY" I am the original author of the scripts, so I'm allowed to say that doing this was actually kind of pointless, because the default delay value is already zero. Although, you now took advantage of this sillyness ;-) If we want to use "ratep" instead, then we actually need to change all those lines, because pg_set "ratep" and "delay" share the same setting in the kernel. > export L_THREAD=$(( THREADS + F_THREAD - 1 )) > > if [ -z "$DEV" ]; then > diff --git a/samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh b/samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh > index 1b6204125d2d..30a610b541ad 100755 > --- a/samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh > +++ b/samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh > @@ -50,9 +50,6 @@ if [ -n "$DST_PORT" ]; then > validate_ports $UDP_DST_MIN $UDP_DST_MAX > fi > > -# Base Config > -DELAY="0" # Zero means max speed > - > # General cleanup everything since last run > pg_ctrl "reset" > > diff --git a/samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh b/samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh > index e607cb369b20..a6195bd77532 100755 > --- a/samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh > +++ b/samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh > @@ -33,9 +33,6 @@ if [ -n "$DST_PORT" ]; then > validate_ports $UDP_DST_MIN $UDP_DST_MAX > fi > > -# Base Config > -DELAY="0" # Zero means max speed > - > # General cleanup everything since last run > pg_ctrl "reset" > > diff --git a/samples/pktgen/pktgen_sample01_simple.sh b/samples/pktgen/pktgen_sample01_simple.sh > index a4e250b45dce..c2ad1fa32d3f 100755 > --- a/samples/pktgen/pktgen_sample01_simple.sh > +++ b/samples/pktgen/pktgen_sample01_simple.sh > @@ -31,9 +31,6 @@ if [ -n "$DST_PORT" ]; then > validate_ports $UDP_DST_MIN $UDP_DST_MAX > fi > > -# Base Config > -DELAY="0" # Zero means max speed > - > # Flow variation random source port between min and max > UDP_SRC_MIN=9 > UDP_SRC_MAX=109 > diff --git a/samples/pktgen/pktgen_sample02_multiqueue.sh b/samples/pktgen/pktgen_sample02_multiqueue.sh > index cb2495fcdc60..49e1e81a2945 100755 > --- a/samples/pktgen/pktgen_sample02_multiqueue.sh > +++ b/samples/pktgen/pktgen_sample02_multiqueue.sh > @@ -17,7 +17,6 @@ source ${basedir}/parameters.sh > [ -z "$COUNT" ] && COUNT="100000" # Zero means indefinitely > > # Base Config > -DELAY="0" # Zero means max speed > [ -z "$CLONE_SKB" ] && CLONE_SKB="0" > > # Flow variation random source port between min and max > diff --git a/samples/pktgen/pktgen_sample03_burst_single_flow.sh b/samples/pktgen/pktgen_sample03_burst_single_flow.sh > index fff50765a5aa..f9b67affb567 100755 > --- a/samples/pktgen/pktgen_sample03_burst_single_flow.sh > +++ b/samples/pktgen/pktgen_sample03_burst_single_flow.sh > @@ -42,9 +42,6 @@ if [ -n "$DST_PORT" ]; then > validate_ports $UDP_DST_MIN $UDP_DST_MAX > fi > > -# Base Config > -DELAY="0" # Zero means max speed > - > # General cleanup everything since last run > pg_ctrl "reset" > [...] -- Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next 2/2] samples: pktgen: new append mode 2021-01-22 15:05 [PATCH net-next 0/2] pktgen: scripts improvements Igor Russkikh 2021-01-22 15:05 ` [PATCH net-next 1/2] samples: pktgen: allow to specify delay parameter via new opt Igor Russkikh @ 2021-01-22 15:05 ` Igor Russkikh 2021-01-26 13:09 ` Jesper Dangaard Brouer 1 sibling, 1 reply; 6+ messages in thread From: Igor Russkikh @ 2021-01-22 15:05 UTC (permalink / raw) To: netdev; +Cc: David S . Miller, Jakub Kicinski, Igor Russkikh To configure various complex flows we for sure can create custom pktgen init scripts, but sometimes thats not that easy. New "-a" (append) option in all the existing sample scripts allows to append more "devices" into pktgen threads. The most straightforward usecases for that are: - using multiple devices. We have to generate full linerate on all physical functions (ports) of our multiport device. - pushing multiple flows (with different packet options) Signed-off-by: Igor Russkikh <irusskikh@marvell.com> --- samples/pktgen/README.rst | 18 ++++++++++++++++++ samples/pktgen/functions.sh | 2 +- samples/pktgen/parameters.sh | 7 ++++++- samples/pktgen/pktgen_sample01_simple.sh | 10 ++++++++-- samples/pktgen/pktgen_sample02_multiqueue.sh | 10 ++++++++-- .../pktgen_sample03_burst_single_flow.sh | 10 ++++++++-- samples/pktgen/pktgen_sample04_many_flows.sh | 10 ++++++++-- .../pktgen/pktgen_sample05_flow_per_thread.sh | 10 ++++++++-- ..._sample06_numa_awared_queue_irq_affinity.sh | 10 ++++++++-- 9 files changed, 73 insertions(+), 14 deletions(-) diff --git a/samples/pktgen/README.rst b/samples/pktgen/README.rst index f9c53ca5cf93..f7d8dd76b0c4 100644 --- a/samples/pktgen/README.rst +++ b/samples/pktgen/README.rst @@ -28,10 +28,28 @@ across the sample scripts. Usage example is printed on errors:: -b : ($BURST) HW level bursting of SKBs -v : ($VERBOSE) verbose -x : ($DEBUG) debug + -6 : ($IP6) IPv6 + -w : ($DELAY) Tx Delay value (us) + -a : ($APPENDCFG) Script will not reset generator's state, but will append its config The global variable being set is also listed. E.g. the required 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 ---------------- The functions.sh file provides; Three different shell functions for diff --git a/samples/pktgen/functions.sh b/samples/pktgen/functions.sh index dae06d5b38fa..8db945ee4f55 100644 --- a/samples/pktgen/functions.sh +++ b/samples/pktgen/functions.sh @@ -108,7 +108,7 @@ function pgset() { fi } -[[ $EUID -eq 0 ]] && trap 'pg_ctrl "reset"' EXIT +[ -z "$APPEND" ] && [ "$EUID" -eq 0 ] && trap '[ -z "$APPEND" ] && pg_ctrl "reset"' EXIT ## -- General shell tricks -- diff --git a/samples/pktgen/parameters.sh b/samples/pktgen/parameters.sh index 70cc2878d479..3fd4d5e8107a 100644 --- a/samples/pktgen/parameters.sh +++ b/samples/pktgen/parameters.sh @@ -20,12 +20,13 @@ function usage() { echo " -x : (\$DEBUG) debug" echo " -6 : (\$IP6) IPv6" echo " -w : (\$DELAY) Tx Delay value (us)" + echo " -a : (\$APPENDCFG) Script will not reset generator's state, but will append its config" echo "" } ## --- Parse command line arguments / parameters --- ## echo "Commandline options:" -while getopts "s:i:d:m:p:f:t:c:n:b:w:vxh6" option; do +while getopts "s:i:d:m:p:f:t:c:n:b:w:vxh6a" option; do case $option in i) # interface export DEV=$OPTARG @@ -83,6 +84,10 @@ while getopts "s:i:d:m:p:f:t:c:n:b:w:vxh6" option; do export IP6=6 info "IP6: IP6=$IP6" ;; + a) + export APPEND=yes + info "Append mode: APPEND=$APPEND" + ;; h|?|*) usage; err 2 "[ERROR] Unknown parameters!!!" diff --git a/samples/pktgen/pktgen_sample01_simple.sh b/samples/pktgen/pktgen_sample01_simple.sh index c2ad1fa32d3f..8ca7913eaf8a 100755 --- a/samples/pktgen/pktgen_sample01_simple.sh +++ b/samples/pktgen/pktgen_sample01_simple.sh @@ -37,11 +37,11 @@ UDP_SRC_MAX=109 # General cleanup everything since last run # (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 thread=0 -pg_thread $thread "rem_device_all" +[ -z "$APPEND" ] && pg_thread $thread "rem_device_all" pg_thread $thread "add_device" $DEV # How many packets to send (zero means indefinitely) @@ -77,6 +77,8 @@ pg_set $DEV "flag UDPSRC_RND" pg_set $DEV "udp_src_min $UDP_SRC_MIN" pg_set $DEV "udp_src_max $UDP_SRC_MAX" +if [ -z "$APPEND" ]; then + # start_run echo "Running... ctrl^C to stop" >&2 pg_ctrl "start" @@ -85,3 +87,7 @@ echo "Done" >&2 # Print results echo "Result device: $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 diff --git a/samples/pktgen/pktgen_sample02_multiqueue.sh b/samples/pktgen/pktgen_sample02_multiqueue.sh index 49e1e81a2945..ecf35d4506bf 100755 --- a/samples/pktgen/pktgen_sample02_multiqueue.sh +++ b/samples/pktgen/pktgen_sample02_multiqueue.sh @@ -38,7 +38,7 @@ if [ -n "$DST_PORT" ]; then fi # General cleanup everything since last run -pg_ctrl "reset" +[ -z "$APPEND" ] && pg_ctrl "reset" # Threads are specified with parameter -t value in $THREADS for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do @@ -47,7 +47,7 @@ for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do dev=${DEV}@${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 # Notice config queue to map to cpu (mirrors smp_processor_id()) @@ -81,6 +81,8 @@ for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do pg_set $dev "udp_src_max $UDP_SRC_MAX" done +if [ -z "$APPEND" ]; then + # start_run echo "Running... ctrl^C to stop" >&2 pg_ctrl "start" @@ -92,3 +94,7 @@ for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do echo "Device: $dev" cat /proc/net/pktgen/$dev | grep -A2 "Result:" done + +else +echo "Append mode: config done. Do more or use 'pg_ctrl start' to run" +fi diff --git a/samples/pktgen/pktgen_sample03_burst_single_flow.sh b/samples/pktgen/pktgen_sample03_burst_single_flow.sh index f9b67affb567..132ee87e9227 100755 --- a/samples/pktgen/pktgen_sample03_burst_single_flow.sh +++ b/samples/pktgen/pktgen_sample03_burst_single_flow.sh @@ -43,14 +43,14 @@ if [ -n "$DST_PORT" ]; then fi # General cleanup everything since last run -pg_ctrl "reset" +[ -z "$APPEND" ] && pg_ctrl "reset" # Threads are specified with parameter -t value in $THREADS for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do dev=${DEV}@${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 # Base config @@ -94,5 +94,11 @@ function control_c() { # trap keyboard interrupt (Ctrl-C) trap control_c SIGINT +if [ -z "$APPEND" ]; then + 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 diff --git a/samples/pktgen/pktgen_sample04_many_flows.sh b/samples/pktgen/pktgen_sample04_many_flows.sh index ac2d037a6160..b9ea9823446c 100755 --- a/samples/pktgen/pktgen_sample04_many_flows.sh +++ b/samples/pktgen/pktgen_sample04_many_flows.sh @@ -42,14 +42,14 @@ fi read -r SRC_MIN SRC_MAX <<< $(parse_addr 198.18.0.0/15) # General cleanup everything since last run -pg_ctrl "reset" +[ -z "$APPEND" ] && pg_ctrl "reset" # Threads are specified with parameter -t value in $THREADS for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do dev=${DEV}@${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 # Base config @@ -104,7 +104,13 @@ function print_result() { # trap keyboard interrupt (Ctrl-C) trap true SIGINT +if [ -z "$APPEND" ]; then + echo "Running... ctrl^C to stop" >&2 pg_ctrl "start" print_result + +else +echo "Append mode: config done. Do more or use 'pg_ctrl start' to run" +fi diff --git a/samples/pktgen/pktgen_sample05_flow_per_thread.sh b/samples/pktgen/pktgen_sample05_flow_per_thread.sh index 85256484c86f..a73f2587e11f 100755 --- a/samples/pktgen/pktgen_sample05_flow_per_thread.sh +++ b/samples/pktgen/pktgen_sample05_flow_per_thread.sh @@ -32,14 +32,14 @@ if [ -n "$DST_PORT" ]; then fi # General cleanup everything since last run -pg_ctrl "reset" +[ -z "$APPEND" ] && pg_ctrl "reset" # Threads are specified with parameter -t value in $THREADS for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do dev=${DEV}@${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 # Base config @@ -88,7 +88,13 @@ function print_result() { # trap keyboard interrupt (Ctrl-C) trap true SIGINT +if [ -z "$APPEND" ]; then + echo "Running... ctrl^C to stop" >&2 pg_ctrl "start" print_result + +else +echo "Append mode: config done. Do more or use 'pg_ctrl start' to run" +fi diff --git a/samples/pktgen/pktgen_sample06_numa_awared_queue_irq_affinity.sh b/samples/pktgen/pktgen_sample06_numa_awared_queue_irq_affinity.sh index 7c73ab8fbe3c..70fb15e67a1c 100755 --- a/samples/pktgen/pktgen_sample06_numa_awared_queue_irq_affinity.sh +++ b/samples/pktgen/pktgen_sample06_numa_awared_queue_irq_affinity.sh @@ -44,7 +44,7 @@ if [ -n "$DST_PORT" ]; then fi # General cleanup everything since last run -pg_ctrl "reset" +[ -z "$APPEND" ] && pg_ctrl "reset" # Threads are specified with parameter -t value in $THREADS for ((i = 0; i < $THREADS; i++)); do @@ -58,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`" # 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 # select queue and bind the queue and $dev in 1:1 relationship @@ -99,6 +99,8 @@ for ((i = 0; i < $THREADS; i++)); do done # start_run +if [ -z "$APPEND" ]; then + echo "Running... ctrl^C to stop" >&2 pg_ctrl "start" echo "Done" >&2 @@ -110,3 +112,7 @@ for ((i = 0; i < $THREADS; i++)); do echo "Device: $dev" cat /proc/net/pktgen/$dev | grep -A2 "Result:" done + +else +echo "Append mode: config done. Do more or use 'pg_ctrl start' to run" +fi -- 2.17.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 2/2] samples: pktgen: new append mode 2021-01-22 15:05 ` [PATCH net-next 2/2] samples: pktgen: new append mode Igor Russkikh @ 2021-01-26 13:09 ` Jesper Dangaard Brouer 2021-01-26 16:10 ` [EXT] " Igor Russkikh 0 siblings, 1 reply; 6+ messages in thread From: Jesper Dangaard Brouer @ 2021-01-26 13:09 UTC (permalink / raw) To: Igor Russkikh, Daniel T. Lee Cc: brouer, netdev, David S . Miller, Jakub Kicinski On Fri, 22 Jan 2021 16:05:17 +0100 Igor Russkikh <irusskikh@marvell.com> wrote: > To configure various complex flows we for sure can create custom > pktgen init scripts, but sometimes thats not that easy. > > New "-a" (append) option in all the existing sample scripts allows > to append more "devices" into pktgen threads. > > The most straightforward usecases for that are: > - using multiple devices. We have to generate full linerate on > all physical functions (ports) of our multiport device. > - pushing multiple flows (with different packet options) The use-case makes sense. More comment inlined below. > Signed-off-by: Igor Russkikh <irusskikh@marvell.com> > --- > samples/pktgen/README.rst | 18 ++++++++++++++++++ > samples/pktgen/functions.sh | 2 +- > samples/pktgen/parameters.sh | 7 ++++++- > samples/pktgen/pktgen_sample01_simple.sh | 10 ++++++++-- > samples/pktgen/pktgen_sample02_multiqueue.sh | 10 ++++++++-- > .../pktgen_sample03_burst_single_flow.sh | 10 ++++++++-- > samples/pktgen/pktgen_sample04_many_flows.sh | 10 ++++++++-- > .../pktgen/pktgen_sample05_flow_per_thread.sh | 10 ++++++++-- > ..._sample06_numa_awared_queue_irq_affinity.sh | 10 ++++++++-- > 9 files changed, 73 insertions(+), 14 deletions(-) > > diff --git a/samples/pktgen/README.rst b/samples/pktgen/README.rst > index f9c53ca5cf93..f7d8dd76b0c4 100644 > --- a/samples/pktgen/README.rst > +++ b/samples/pktgen/README.rst > @@ -28,10 +28,28 @@ across the sample scripts. Usage example is printed on errors:: > -b : ($BURST) HW level bursting of SKBs > -v : ($VERBOSE) verbose > -x : ($DEBUG) debug > + -6 : ($IP6) IPv6 > + -w : ($DELAY) Tx Delay value (us) > + -a : ($APPENDCFG) Script will not reset generator's state, but will append its config You called it $APPENDCFG, but code use $APPEND. > The global variable being set is also listed. E.g. the required > 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 > ---------------- > The functions.sh file provides; Three different shell functions for > diff --git a/samples/pktgen/functions.sh b/samples/pktgen/functions.sh > index dae06d5b38fa..8db945ee4f55 100644 > --- a/samples/pktgen/functions.sh > +++ b/samples/pktgen/functions.sh > @@ -108,7 +108,7 @@ function pgset() { > fi > } > > -[[ $EUID -eq 0 ]] && trap 'pg_ctrl "reset"' EXIT > +[ -z "$APPEND" ] && [ "$EUID" -eq 0 ] && trap '[ -z "$APPEND" ] && pg_ctrl "reset"' EXIT This looks confusing and wrong (I think). (e.g. is the second '[ -z "$APPEND" ] && ...' needed). In functions.sh we don't need to "compress" the lines that much. I prefer readability in this file. (Cc Daniel T. Lee as he added this line). Maybe we can make it more human readable: if [[ -z "$APPEND" ]]; then if [[ $EUID -eq 0 ]]; then # Cleanup pktgen setup on exit trap 'pg_ctrl "reset"' EXIT fi fi I'm a little confused how the "trap" got added into 'functions.sh', as my original intend was that function.sh should only provide helper functions and not have a side-effect. (But I can see I acked the change). > ## -- General shell tricks -- > > diff --git a/samples/pktgen/parameters.sh b/samples/pktgen/parameters.sh > index 70cc2878d479..3fd4d5e8107a 100644 > --- a/samples/pktgen/parameters.sh > +++ b/samples/pktgen/parameters.sh > @@ -20,12 +20,13 @@ function usage() { > echo " -x : (\$DEBUG) debug" > echo " -6 : (\$IP6) IPv6" > echo " -w : (\$DELAY) Tx Delay value (us)" > + echo " -a : (\$APPENDCFG) Script will not reset generator's state, but will append its config" You called it $APPENDCFG, but code use $APPEND. > echo "" > } > > ## --- Parse command line arguments / parameters --- > ## echo "Commandline options:" > -while getopts "s:i:d:m:p:f:t:c:n:b:w:vxh6" option; do > +while getopts "s:i:d:m:p:f:t:c:n:b:w:vxh6a" option; do > case $option in > i) # interface > export DEV=$OPTARG > @@ -83,6 +84,10 @@ while getopts "s:i:d:m:p:f:t:c:n:b:w:vxh6" option; do > export IP6=6 > info "IP6: IP6=$IP6" > ;; > + a) > + export APPEND=yes See variable name $APPEND is used here, but help says $APPENDCFG > + info "Append mode: APPEND=$APPEND" > + ;; > h|?|*) > usage; > err 2 "[ERROR] Unknown parameters!!!" > diff --git a/samples/pktgen/pktgen_sample01_simple.sh b/samples/pktgen/pktgen_sample01_simple.sh > index c2ad1fa32d3f..8ca7913eaf8a 100755 > --- a/samples/pktgen/pktgen_sample01_simple.sh > +++ b/samples/pktgen/pktgen_sample01_simple.sh > @@ -37,11 +37,11 @@ UDP_SRC_MAX=109 > > # General cleanup everything since last run > # (especially important if other threads were configured by other scripts) > -pg_ctrl "reset" > +[ -z "$APPEND" ] && pg_ctrl "reset" Makes sense. > # Add remove all other devices and add_device $DEV to thread 0 > thread=0 > -pg_thread $thread "rem_device_all" > +[ -z "$APPEND" ] && pg_thread $thread "rem_device_all" > pg_thread $thread "add_device" $DEV > > # How many packets to send (zero means indefinitely) > @@ -77,6 +77,8 @@ pg_set $DEV "flag UDPSRC_RND" > pg_set $DEV "udp_src_min $UDP_SRC_MIN" > pg_set $DEV "udp_src_max $UDP_SRC_MAX" > > +if [ -z "$APPEND" ]; then > + > # start_run > echo "Running... ctrl^C to stop" >&2 > pg_ctrl "start" > @@ -85,3 +87,7 @@ echo "Done" >&2 > # Print results > echo "Result device: $DEV" > cat /proc/net/pktgen/$DEV > + > +else > +echo "Append mode: config done. Do more or use 'pg_ctrl start' to run" > +fi Hmm, could we indent lines for readability? (Same in other files) -- Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [EXT] Re: [PATCH net-next 2/2] samples: pktgen: new append mode 2021-01-26 13:09 ` Jesper Dangaard Brouer @ 2021-01-26 16:10 ` Igor Russkikh 0 siblings, 0 replies; 6+ messages in thread From: Igor Russkikh @ 2021-01-26 16:10 UTC (permalink / raw) To: Jesper Dangaard Brouer, Daniel T. Lee Cc: netdev, David S . Miller, Jakub Kicinski Hi Jesper, Thanks for reviewing this. >> DELAY may now be explicitly specified via common parameter -w > > What are you actually using this for? Basically, for the second patch. When running multidev pktgen (using that -a option) with large amount of clones and bursts (-c and -b) I saw that some of the devices got stuck - i.e. traffic was not distributed evenly I think the reason of that is `next_to_run` selection logic, which always takes first pkt_dev in a list. Adding even a small delay param makes it consider next_tx data and creates a uniform distribution between devices. May be it makes sense to reconsider `next_to_run` selection logic, but I was concentrating on scripts, so thats it. > Notice there is also an option called "ratep" which can be used for > setting the packet rate per sec. In the pktgen.c code, it will use the > "delay" variable. Yes, I think in current form it makes no much harm if user knows what he wants. >> + -w : ($DELAY) Tx Delay value (us) >> + -a : ($APPENDCFG) Script will not reset generator's state, but will > append its config > > You called it $APPENDCFG, but code use $APPEND. Thanks, will fix. >> >> -[[ $EUID -eq 0 ]] && trap 'pg_ctrl "reset"' EXIT >> +[ -z "$APPEND" ] && [ "$EUID" -eq 0 ] && trap '[ -z "$APPEND" ] && > pg_ctrl "reset"' EXIT > > This looks confusing and wrong (I think). > (e.g. is the second '[ -z "$APPEND" ] && ...' needed). > > In functions.sh we don't need to "compress" the lines that much. I > prefer readability in this file. (Cc Daniel T. Lee as he added this > line). Maybe we can make it more human readable: Agree on style, could be fixed. > if [[ -z "$APPEND" ]]; then > if [[ $EUID -eq 0 ]]; then > # Cleanup pktgen setup on exit > trap 'pg_ctrl "reset"' EXIT > fi > fi > > I'm a little confused how the "trap" got added into 'functions.sh', as > my original intend was that function.sh should only provide helper > functions and not have a side-effect. (But I can see I acked the > change). I also don't like much the fact trap is being placed in that file. Here I've placed one extra "-z $APPEND" exactly because of that. In append mode of usage we do `source functions.sh` directly from bash. That causes a side effect that trap is installed in root shell. I can't check if thats APPEND mode or not at this moment. Thats why I do check APPEND inside of the trap. An alternative would be moving trap (or a function installing the trap) into each of the scripts. That was the old behavior BTW. >> +if [ -z "$APPEND" ]; then >> + >> # start_run >> echo "Running... ctrl^C to stop" >&2 >> pg_ctrl "start" >> @@ -85,3 +87,7 @@ echo "Done" >&2 >> # Print results >> echo "Result device: $DEV" >> cat /proc/net/pktgen/$DEV >> + >> +else >> +echo "Append mode: config done. Do more or use 'pg_ctrl start' to run" >> +fi > > Hmm, could we indent lines for readability? > (Same in other files) Agreed, will fix. Thanks, Igor ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-01-26 16:11 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-01-22 15:05 [PATCH net-next 0/2] pktgen: scripts improvements Igor Russkikh 2021-01-22 15:05 ` [PATCH net-next 1/2] samples: pktgen: allow to specify delay parameter via new opt Igor Russkikh 2021-01-26 12:38 ` Jesper Dangaard Brouer 2021-01-22 15:05 ` [PATCH net-next 2/2] samples: pktgen: new append mode Igor Russkikh 2021-01-26 13:09 ` Jesper Dangaard Brouer 2021-01-26 16:10 ` [EXT] " Igor Russkikh
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.