Skip to content

Commit f480fdc

Browse files
committedJan 22, 2021
append feature
1 parent e329332 commit f480fdc

11 files changed

+81
-34
lines changed
 

‎samples/pktgen/README.rst

+18
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,28 @@ across the sample scripts. Usage example is printed on errors::
2828
-b : ($BURST) HW level bursting of SKBs
2929
-v : ($VERBOSE) verbose
3030
-x : ($DEBUG) debug
31+
-6 : ($IP6) IPv6
32+
-w : ($DELAY) Tx Delay value (us)
33+
-a : ($APPENDCFG) Script will not reset generator's state, but will append its config
3134

3235
The global variable being set is also listed. E.g. the required
3336
interface/device parameter "-i" sets variable $DEV.
3437

38+
"-a" parameter may be used to create different flows simultaneously.
39+
In this mode script will keep the existing config, will append its settings.
40+
In this mode you'll have to manually run traffic with "pg_ctrl start".
41+
42+
For example you may use:
43+
44+
source ./samples/pktgen/functions.sh
45+
pg_ctrl reset
46+
# add first device
47+
./pktgen_sample06_numa_awared_queue_irq_affinity.sh -a -i ens1f0 -m 34:80:0d:a3:fc:c9 -t 8
48+
# add second device
49+
./pktgen_sample06_numa_awared_queue_irq_affinity.sh -a -i ens1f1 -m 34:80:0d:a3:fc:c9 -t 8
50+
# run joint traffic on two devs
51+
pg_ctrl start
52+
3553
Common functions
3654
----------------
3755
The functions.sh file provides; Three different shell functions for

‎samples/pktgen/functions.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function pgset() {
108108
fi
109109
}
110110

111-
[[ $EUID -eq 0 ]] && trap 'pg_ctrl "reset"' EXIT
111+
[ -z "$APPEND" ] && [ "$EUID" -eq 0 ] && trap '[ -z "$APPEND" ] && pg_ctrl "reset"' EXIT
112112

113113
## -- General shell tricks --
114114

‎samples/pktgen/parameters.sh

+14-1
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ function usage() {
1919
echo " -v : (\$VERBOSE) verbose"
2020
echo " -x : (\$DEBUG) debug"
2121
echo " -6 : (\$IP6) IPv6"
22+
echo " -w : (\$DELAY) Tx Delay value (us)"
23+
echo " -a : (\$APPENDCFG) Script will not reset generator's state, but will append its config"
2224
echo ""
2325
}
2426

2527
## --- Parse command line arguments / parameters ---
2628
## echo "Commandline options:"
27-
while getopts "s:i:d:m:p:f:t:c:n:b:vxh6" option; do
29+
while getopts "s:i:d:m:p:f:t:c:n:b:w:vxh6a" option; do
2830
case $option in
2931
i) # interface
3032
export DEV=$OPTARG
@@ -66,6 +68,10 @@ while getopts "s:i:d:m:p:f:t:c:n:b:vxh6" option; do
6668
export BURST=$OPTARG
6769
info "SKB bursting: BURST=$BURST"
6870
;;
71+
w)
72+
export DELAY=$OPTARG
73+
info "DELAY=$DELAY"
74+
;;
6975
v)
7076
export VERBOSE=yes
7177
info "Verbose mode: VERBOSE=$VERBOSE"
@@ -78,6 +84,10 @@ while getopts "s:i:d:m:p:f:t:c:n:b:vxh6" option; do
7884
export IP6=6
7985
info "IP6: IP6=$IP6"
8086
;;
87+
a)
88+
export APPEND=yes
89+
info "Append mode: APPEND=$APPEND"
90+
;;
8191
h|?|*)
8292
usage;
8393
err 2 "[ERROR] Unknown parameters!!!"
@@ -100,6 +110,9 @@ if [ -z "$THREADS" ]; then
100110
export THREADS=1
101111
fi
102112

113+
# default DELAY
114+
[ -z "$DELAY" ] && export DELAY=0 # Zero means max speed
115+
103116
export L_THREAD=$(( THREADS + F_THREAD - 1 ))
104117

105118
if [ -z "$DEV" ]; then

‎samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh

-3
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ if [ -n "$DST_PORT" ]; then
5050
validate_ports $UDP_DST_MIN $UDP_DST_MAX
5151
fi
5252

53-
# Base Config
54-
DELAY="0" # Zero means max speed
55-
5653
# General cleanup everything since last run
5754
pg_ctrl "reset"
5855

‎samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh

-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ if [ -n "$DST_PORT" ]; then
3333
validate_ports $UDP_DST_MIN $UDP_DST_MAX
3434
fi
3535

36-
# Base Config
37-
DELAY="0" # Zero means max speed
38-
3936
# General cleanup everything since last run
4037
pg_ctrl "reset"
4138

‎samples/pktgen/pktgen_sample01_simple.sh

+8-5
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,17 @@ if [ -n "$DST_PORT" ]; then
3131
validate_ports $UDP_DST_MIN $UDP_DST_MAX
3232
fi
3333

34-
# Base Config
35-
DELAY="0" # Zero means max speed
36-
3734
# Flow variation random source port between min and max
3835
UDP_SRC_MIN=9
3936
UDP_SRC_MAX=109
4037

4138
# General cleanup everything since last run
4239
# (especially important if other threads were configured by other scripts)
43-
pg_ctrl "reset"
40+
[ -z "$APPEND" ] && pg_ctrl "reset"
4441

4542
# Add remove all other devices and add_device $DEV to thread 0
4643
thread=0
47-
pg_thread $thread "rem_device_all"
44+
[ -z "$APPEND" ] && pg_thread $thread "rem_device_all"
4845
pg_thread $thread "add_device" $DEV
4946

5047
# How many packets to send (zero means indefinitely)
@@ -80,6 +77,8 @@ pg_set $DEV "flag UDPSRC_RND"
8077
pg_set $DEV "udp_src_min $UDP_SRC_MIN"
8178
pg_set $DEV "udp_src_max $UDP_SRC_MAX"
8279

80+
if [ -z "$APPEND" ]; then
81+
8382
# start_run
8483
echo "Running... ctrl^C to stop" >&2
8584
pg_ctrl "start"
@@ -88,3 +87,7 @@ echo "Done" >&2
8887
# Print results
8988
echo "Result device: $DEV"
9089
cat /proc/net/pktgen/$DEV
90+
91+
else
92+
echo "Append mode: config done. Do more or use 'pg_ctrl start' to run"
93+
fi

‎samples/pktgen/pktgen_sample02_multiqueue.sh

+8-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ source ${basedir}/parameters.sh
1717
[ -z "$COUNT" ] && COUNT="100000" # Zero means indefinitely
1818

1919
# Base Config
20-
DELAY="0" # Zero means max speed
2120
[ -z "$CLONE_SKB" ] && CLONE_SKB="0"
2221

2322
# Flow variation random source port between min and max
@@ -39,7 +38,7 @@ if [ -n "$DST_PORT" ]; then
3938
fi
4039

4140
# General cleanup everything since last run
42-
pg_ctrl "reset"
41+
[ -z "$APPEND" ] && pg_ctrl "reset"
4342

4443
# Threads are specified with parameter -t value in $THREADS
4544
for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
@@ -48,7 +47,7 @@ for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
4847
dev=${DEV}@${thread}
4948

5049
# Add remove all other devices and add_device $dev to thread
51-
pg_thread $thread "rem_device_all"
50+
[ -z "$APPEND" ] && pg_thread $thread "rem_device_all"
5251
pg_thread $thread "add_device" $dev
5352

5453
# Notice config queue to map to cpu (mirrors smp_processor_id())
@@ -82,6 +81,8 @@ for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
8281
pg_set $dev "udp_src_max $UDP_SRC_MAX"
8382
done
8483

84+
if [ -z "$APPEND" ]; then
85+
8586
# start_run
8687
echo "Running... ctrl^C to stop" >&2
8788
pg_ctrl "start"
@@ -93,3 +94,7 @@ for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
9394
echo "Device: $dev"
9495
cat /proc/net/pktgen/$dev | grep -A2 "Result:"
9596
done
97+
98+
else
99+
echo "Append mode: config done. Do more or use 'pg_ctrl start' to run"
100+
fi

‎samples/pktgen/pktgen_sample03_burst_single_flow.sh

+8-5
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,15 @@ if [ -n "$DST_PORT" ]; then
4242
validate_ports $UDP_DST_MIN $UDP_DST_MAX
4343
fi
4444

45-
# Base Config
46-
DELAY="0" # Zero means max speed
47-
4845
# General cleanup everything since last run
49-
pg_ctrl "reset"
46+
[ -z "$APPEND" ] && pg_ctrl "reset"
5047

5148
# Threads are specified with parameter -t value in $THREADS
5249
for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
5350
dev=${DEV}@${thread}
5451

5552
# Add remove all other devices and add_device $dev to thread
56-
pg_thread $thread "rem_device_all"
53+
[ -z "$APPEND" ] && pg_thread $thread "rem_device_all"
5754
pg_thread $thread "add_device" $dev
5855

5956
# Base config
@@ -97,5 +94,11 @@ function control_c() {
9794
# trap keyboard interrupt (Ctrl-C)
9895
trap control_c SIGINT
9996

97+
if [ -z "$APPEND" ]; then
98+
10099
echo "Running... ctrl^C to stop" >&2
101100
pg_ctrl "start"
101+
102+
else
103+
echo "Append mode: config done. Do more or use 'pg_ctrl start' to run"
104+
fi

‎samples/pktgen/pktgen_sample04_many_flows.sh

+8-5
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ fi
3434
[ -z "$FLOWS" ] && FLOWS="8000"
3535
[ -z "$FLOWLEN" ] && FLOWLEN="10"
3636

37-
# Base Config
38-
DELAY="0" # Zero means max speed
39-
4037
if [[ -n "$BURST" ]]; then
4138
err 1 "Bursting not supported for this mode"
4239
fi
@@ -45,14 +42,14 @@ fi
4542
read -r SRC_MIN SRC_MAX <<< $(parse_addr 198.18.0.0/15)
4643

4744
# General cleanup everything since last run
48-
pg_ctrl "reset"
45+
[ -z "$APPEND" ] && pg_ctrl "reset"
4946

5047
# Threads are specified with parameter -t value in $THREADS
5148
for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
5249
dev=${DEV}@${thread}
5350

5451
# Add remove all other devices and add_device $dev to thread
55-
pg_thread $thread "rem_device_all"
52+
[ -z "$APPEND" ] && pg_thread $thread "rem_device_all"
5653
pg_thread $thread "add_device" $dev
5754

5855
# Base config
@@ -107,7 +104,13 @@ function print_result() {
107104
# trap keyboard interrupt (Ctrl-C)
108105
trap true SIGINT
109106

107+
if [ -z "$APPEND" ]; then
108+
110109
echo "Running... ctrl^C to stop" >&2
111110
pg_ctrl "start"
112111

113112
print_result
113+
114+
else
115+
echo "Append mode: config done. Do more or use 'pg_ctrl start' to run"
116+
fi

‎samples/pktgen/pktgen_sample05_flow_per_thread.sh

+8-5
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,15 @@ if [ -n "$DST_PORT" ]; then
3131
validate_ports $UDP_DST_MIN $UDP_DST_MAX
3232
fi
3333

34-
# Base Config
35-
DELAY="0" # Zero means max speed
36-
3734
# General cleanup everything since last run
38-
pg_ctrl "reset"
35+
[ -z "$APPEND" ] && pg_ctrl "reset"
3936

4037
# Threads are specified with parameter -t value in $THREADS
4138
for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
4239
dev=${DEV}@${thread}
4340

4441
# Add remove all other devices and add_device $dev to thread
45-
pg_thread $thread "rem_device_all"
42+
[ -z "$APPEND" ] && pg_thread $thread "rem_device_all"
4643
pg_thread $thread "add_device" $dev
4744

4845
# Base config
@@ -91,7 +88,13 @@ function print_result() {
9188
# trap keyboard interrupt (Ctrl-C)
9289
trap true SIGINT
9390

91+
if [ -z "$APPEND" ]; then
92+
9493
echo "Running... ctrl^C to stop" >&2
9594
pg_ctrl "start"
9695

9796
print_result
97+
98+
else
99+
echo "Append mode: config done. Do more or use 'pg_ctrl start' to run"
100+
fi

‎samples/pktgen/pktgen_sample06_numa_awared_queue_irq_affinity.sh

+8-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ root_check_run_with_sudo "$@"
1515
source ${basedir}/parameters.sh
1616

1717
# Base Config
18-
DELAY="0" # Zero means max speed
1918
[ -z "$COUNT" ] && COUNT="20000000" # Zero means indefinitely
2019
[ -z "$CLONE_SKB" ] && CLONE_SKB="0"
2120

@@ -45,7 +44,7 @@ if [ -n "$DST_PORT" ]; then
4544
fi
4645

4746
# General cleanup everything since last run
48-
pg_ctrl "reset"
47+
[ -z "$APPEND" ] && pg_ctrl "reset"
4948

5049
# Threads are specified with parameter -t value in $THREADS
5150
for ((i = 0; i < $THREADS; i++)); do
@@ -59,7 +58,7 @@ for ((i = 0; i < $THREADS; i++)); do
5958
info "irq ${irq_array[$i]} is set affinity to `cat /proc/irq/${irq_array[$i]}/smp_affinity_list`"
6059

6160
# Add remove all other devices and add_device $dev to thread
62-
pg_thread $thread "rem_device_all"
61+
[ -z "$APPEND" ] && pg_thread $thread "rem_device_all"
6362
pg_thread $thread "add_device" $dev
6463

6564
# select queue and bind the queue and $dev in 1:1 relationship
@@ -100,6 +99,8 @@ for ((i = 0; i < $THREADS; i++)); do
10099
done
101100

102101
# start_run
102+
if [ -z "$APPEND" ]; then
103+
103104
echo "Running... ctrl^C to stop" >&2
104105
pg_ctrl "start"
105106
echo "Done" >&2
@@ -111,3 +112,7 @@ for ((i = 0; i < $THREADS; i++)); do
111112
echo "Device: $dev"
112113
cat /proc/net/pktgen/$dev | grep -A2 "Result:"
113114
done
115+
116+
else
117+
echo "Append mode: config done. Do more or use 'pg_ctrl start' to run"
118+
fi

0 commit comments

Comments
 (0)
Please sign in to comment.