Skip to content

Commit e0e1667

Browse files
Tariq Toukandavem330
Tariq Toukan
authored andcommitted
pktgen: Specify the index of first thread
Use "-f <num>", to specify the index of the first sender thread. In default first thread is #0. Signed-off-by: Tariq Toukan <[email protected]> Cc: Jesper Dangaard Brouer <[email protected]> Acked-by: Jesper Dangaard Brouer <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 69137ea commit e0e1667

8 files changed

+27
-18
lines changed

samples/pktgen/README.rst

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ across the sample scripts. Usage example is printed on errors::
2121
-d : ($DEST_IP) destination IP
2222
-m : ($DST_MAC) destination MAC-addr
2323
-t : ($THREADS) threads to start
24+
-f : ($F_THREAD) index of first thread (zero indexed CPU number)
2425
-c : ($SKB_CLONE) SKB clones send before alloc new SKB
2526
-n : ($COUNT) num messages to send per thread, 0 means indefinitely
2627
-b : ($BURST) HW level bursting of SKBs

samples/pktgen/parameters.sh

+14-6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ function usage() {
1010
echo " -d : (\$DEST_IP) destination IP"
1111
echo " -m : (\$DST_MAC) destination MAC-addr"
1212
echo " -t : (\$THREADS) threads to start"
13+
echo " -f : (\$F_THREAD) index of first thread (zero indexed CPU number)"
1314
echo " -c : (\$SKB_CLONE) SKB clones send before alloc new SKB"
1415
echo " -n : (\$COUNT) num messages to send per thread, 0 means indefinitely"
1516
echo " -b : (\$BURST) HW level bursting of SKBs"
@@ -21,7 +22,7 @@ function usage() {
2122

2223
## --- Parse command line arguments / parameters ---
2324
## echo "Commandline options:"
24-
while getopts "s:i:d:m:t:c:n:b:vxh6" option; do
25+
while getopts "s:i:d:m:f:t:c:n:b:vxh6" option; do
2526
case $option in
2627
i) # interface
2728
export DEV=$OPTARG
@@ -39,11 +40,13 @@ while getopts "s:i:d:m:t:c:n:b:vxh6" option; do
3940
export DST_MAC=$OPTARG
4041
info "Destination MAC set to: DST_MAC=$DST_MAC"
4142
;;
43+
f)
44+
export F_THREAD=$OPTARG
45+
info "Index of first thread (zero indexed CPU number): $F_THREAD"
46+
;;
4247
t)
4348
export THREADS=$OPTARG
44-
export CPU_THREADS=$OPTARG
45-
let "CPU_THREADS -= 1"
46-
info "Number of threads to start: $THREADS (0 to $CPU_THREADS)"
49+
info "Number of threads to start: $THREADS"
4750
;;
4851
c)
4952
export CLONE_SKB=$OPTARG
@@ -82,12 +85,17 @@ if [ -z "$PKT_SIZE" ]; then
8285
info "Default packet size set to: set to: $PKT_SIZE bytes"
8386
fi
8487

88+
if [ -z "$F_THREAD" ]; then
89+
# First thread (F_THREAD) reference the zero indexed CPU number
90+
export F_THREAD=0
91+
fi
92+
8593
if [ -z "$THREADS" ]; then
86-
# Zero CPU threads means one thread, because CPU numbers are zero indexed
87-
export CPU_THREADS=0
8894
export THREADS=1
8995
fi
9096

97+
export L_THREAD=$(( THREADS + F_THREAD - 1 ))
98+
9199
if [ -z "$DEV" ]; then
92100
usage
93101
err 2 "Please specify output device"

samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ DELAY="0" # Zero means max speed
4848
pg_ctrl "reset"
4949

5050
# Threads are specified with parameter -t value in $THREADS
51-
for ((thread = 0; thread < $THREADS; thread++)); do
51+
for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
5252
# The device name is extended with @name, using thread number to
5353
# make then unique, but any name will do.
5454
dev=${DEV}@${thread}
@@ -81,7 +81,7 @@ pg_ctrl "start"
8181
echo "Done" >&2
8282

8383
# Print results
84-
for ((thread = 0; thread < $THREADS; thread++)); do
84+
for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
8585
dev=${DEV}@${thread}
8686
echo "Device: $dev"
8787
cat /proc/net/pktgen/$dev | grep -A2 "Result:"

samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ DELAY="0" # Zero means max speed
3131
pg_ctrl "reset"
3232

3333
# Threads are specified with parameter -t value in $THREADS
34-
for ((thread = 0; thread < $THREADS; thread++)); do
34+
for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
3535
# The device name is extended with @name, using thread number to
3636
# make then unique, but any name will do.
3737
dev=${DEV}@${thread}
@@ -61,7 +61,7 @@ pg_ctrl "start"
6161
echo "Done" >&2
6262

6363
# Print results
64-
for ((thread = 0; thread < $THREADS; thread++)); do
64+
for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
6565
dev=${DEV}@${thread}
6666
echo "Device: $dev"
6767
cat /proc/net/pktgen/$dev | grep -A2 "Result:"

samples/pktgen/pktgen_sample02_multiqueue.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fi
3333
pg_ctrl "reset"
3434

3535
# Threads are specified with parameter -t value in $THREADS
36-
for ((thread = 0; thread < $THREADS; thread++)); do
36+
for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
3737
# The device name is extended with @name, using thread number to
3838
# make then unique, but any name will do.
3939
dev=${DEV}@${thread}
@@ -71,7 +71,7 @@ pg_ctrl "start"
7171
echo "Done" >&2
7272

7373
# Print results
74-
for ((thread = 0; thread < $THREADS; thread++)); do
74+
for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
7575
dev=${DEV}@${thread}
7676
echo "Device: $dev"
7777
cat /proc/net/pktgen/$dev | grep -A2 "Result:"

samples/pktgen/pktgen_sample03_burst_single_flow.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ DELAY="0" # Zero means max speed
4040
pg_ctrl "reset"
4141

4242
# Threads are specified with parameter -t value in $THREADS
43-
for ((thread = 0; thread < $THREADS; thread++)); do
43+
for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
4444
dev=${DEV}@${thread}
4545

4646
# Add remove all other devices and add_device $dev to thread
@@ -71,7 +71,7 @@ done
7171
# Run if user hits control-c
7272
function control_c() {
7373
# Print results
74-
for ((thread = 0; thread < $THREADS; thread++)); do
74+
for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
7575
dev=${DEV}@${thread}
7676
echo "Device: $dev"
7777
cat /proc/net/pktgen/$dev | grep -A2 "Result:"

samples/pktgen/pktgen_sample04_many_flows.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fi
3636
pg_ctrl "reset"
3737

3838
# Threads are specified with parameter -t value in $THREADS
39-
for ((thread = 0; thread < $THREADS; thread++)); do
39+
for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
4040
dev=${DEV}@${thread}
4141

4242
# Add remove all other devices and add_device $dev to thread
@@ -78,7 +78,7 @@ done
7878
# Run if user hits control-c
7979
function print_result() {
8080
# Print results
81-
for ((thread = 0; thread < $THREADS; thread++)); do
81+
for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
8282
dev=${DEV}@${thread}
8383
echo "Device: $dev"
8484
cat /proc/net/pktgen/$dev | grep -A2 "Result:"

samples/pktgen/pktgen_sample05_flow_per_thread.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ DELAY="0" # Zero means max speed
3030
pg_ctrl "reset"
3131

3232
# Threads are specified with parameter -t value in $THREADS
33-
for ((thread = 0; thread < $THREADS; thread++)); do
33+
for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
3434
dev=${DEV}@${thread}
3535

3636
# Add remove all other devices and add_device $dev to thread
@@ -66,7 +66,7 @@ done
6666
# Run if user hits control-c
6767
function print_result() {
6868
# Print results
69-
for ((thread = 0; thread < $THREADS; thread++)); do
69+
for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
7070
dev=${DEV}@${thread}
7171
echo "Device: $dev"
7272
cat /proc/net/pktgen/$dev | grep -A2 "Result:"

0 commit comments

Comments
 (0)