Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <tariqt@mellanox.com>
Cc: Jesper Dangaard Brouer <brouer@redhat.com>
Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Tariq Toukan and committed by
David S. Miller
e0e16672 69137ea6

+27 -18
+1
samples/pktgen/README.rst
··· 21 21 -d : ($DEST_IP) destination IP 22 22 -m : ($DST_MAC) destination MAC-addr 23 23 -t : ($THREADS) threads to start 24 + -f : ($F_THREAD) index of first thread (zero indexed CPU number) 24 25 -c : ($SKB_CLONE) SKB clones send before alloc new SKB 25 26 -n : ($COUNT) num messages to send per thread, 0 means indefinitely 26 27 -b : ($BURST) HW level bursting of SKBs
+14 -6
samples/pktgen/parameters.sh
··· 10 10 echo " -d : (\$DEST_IP) destination IP" 11 11 echo " -m : (\$DST_MAC) destination MAC-addr" 12 12 echo " -t : (\$THREADS) threads to start" 13 + echo " -f : (\$F_THREAD) index of first thread (zero indexed CPU number)" 13 14 echo " -c : (\$SKB_CLONE) SKB clones send before alloc new SKB" 14 15 echo " -n : (\$COUNT) num messages to send per thread, 0 means indefinitely" 15 16 echo " -b : (\$BURST) HW level bursting of SKBs" ··· 22 21 23 22 ## --- Parse command line arguments / parameters --- 24 23 ## echo "Commandline options:" 25 - while getopts "s:i:d:m:t:c:n:b:vxh6" option; do 24 + while getopts "s:i:d:m:f:t:c:n:b:vxh6" option; do 26 25 case $option in 27 26 i) # interface 28 27 export DEV=$OPTARG ··· 40 39 export DST_MAC=$OPTARG 41 40 info "Destination MAC set to: DST_MAC=$DST_MAC" 42 41 ;; 42 + f) 43 + export F_THREAD=$OPTARG 44 + info "Index of first thread (zero indexed CPU number): $F_THREAD" 45 + ;; 43 46 t) 44 47 export THREADS=$OPTARG 45 - export CPU_THREADS=$OPTARG 46 - let "CPU_THREADS -= 1" 47 - info "Number of threads to start: $THREADS (0 to $CPU_THREADS)" 48 + info "Number of threads to start: $THREADS" 48 49 ;; 49 50 c) 50 51 export CLONE_SKB=$OPTARG ··· 85 82 info "Default packet size set to: set to: $PKT_SIZE bytes" 86 83 fi 87 84 85 + if [ -z "$F_THREAD" ]; then 86 + # First thread (F_THREAD) reference the zero indexed CPU number 87 + export F_THREAD=0 88 + fi 89 + 88 90 if [ -z "$THREADS" ]; then 89 - # Zero CPU threads means one thread, because CPU numbers are zero indexed 90 - export CPU_THREADS=0 91 91 export THREADS=1 92 92 fi 93 + 94 + export L_THREAD=$(( THREADS + F_THREAD - 1 )) 93 95 94 96 if [ -z "$DEV" ]; then 95 97 usage
+2 -2
samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh
··· 48 48 pg_ctrl "reset" 49 49 50 50 # 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 52 52 # The device name is extended with @name, using thread number to 53 53 # make then unique, but any name will do. 54 54 dev=${DEV}@${thread} ··· 81 81 echo "Done" >&2 82 82 83 83 # Print results 84 - for ((thread = 0; thread < $THREADS; thread++)); do 84 + for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do 85 85 dev=${DEV}@${thread} 86 86 echo "Device: $dev" 87 87 cat /proc/net/pktgen/$dev | grep -A2 "Result:"
+2 -2
samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh
··· 31 31 pg_ctrl "reset" 32 32 33 33 # 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 35 35 # The device name is extended with @name, using thread number to 36 36 # make then unique, but any name will do. 37 37 dev=${DEV}@${thread} ··· 61 61 echo "Done" >&2 62 62 63 63 # Print results 64 - for ((thread = 0; thread < $THREADS; thread++)); do 64 + for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do 65 65 dev=${DEV}@${thread} 66 66 echo "Device: $dev" 67 67 cat /proc/net/pktgen/$dev | grep -A2 "Result:"
+2 -2
samples/pktgen/pktgen_sample02_multiqueue.sh
··· 33 33 pg_ctrl "reset" 34 34 35 35 # 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 37 37 # The device name is extended with @name, using thread number to 38 38 # make then unique, but any name will do. 39 39 dev=${DEV}@${thread} ··· 71 71 echo "Done" >&2 72 72 73 73 # Print results 74 - for ((thread = 0; thread < $THREADS; thread++)); do 74 + for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do 75 75 dev=${DEV}@${thread} 76 76 echo "Device: $dev" 77 77 cat /proc/net/pktgen/$dev | grep -A2 "Result:"
+2 -2
samples/pktgen/pktgen_sample03_burst_single_flow.sh
··· 40 40 pg_ctrl "reset" 41 41 42 42 # 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 44 44 dev=${DEV}@${thread} 45 45 46 46 # Add remove all other devices and add_device $dev to thread ··· 71 71 # Run if user hits control-c 72 72 function control_c() { 73 73 # Print results 74 - for ((thread = 0; thread < $THREADS; thread++)); do 74 + for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do 75 75 dev=${DEV}@${thread} 76 76 echo "Device: $dev" 77 77 cat /proc/net/pktgen/$dev | grep -A2 "Result:"
+2 -2
samples/pktgen/pktgen_sample04_many_flows.sh
··· 36 36 pg_ctrl "reset" 37 37 38 38 # 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 40 40 dev=${DEV}@${thread} 41 41 42 42 # Add remove all other devices and add_device $dev to thread ··· 78 78 # Run if user hits control-c 79 79 function print_result() { 80 80 # Print results 81 - for ((thread = 0; thread < $THREADS; thread++)); do 81 + for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do 82 82 dev=${DEV}@${thread} 83 83 echo "Device: $dev" 84 84 cat /proc/net/pktgen/$dev | grep -A2 "Result:"
+2 -2
samples/pktgen/pktgen_sample05_flow_per_thread.sh
··· 30 30 pg_ctrl "reset" 31 31 32 32 # 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 34 34 dev=${DEV}@${thread} 35 35 36 36 # Add remove all other devices and add_device $dev to thread ··· 66 66 # Run if user hits control-c 67 67 function print_result() { 68 68 # Print results 69 - for ((thread = 0; thread < $THREADS; thread++)); do 69 + for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do 70 70 dev=${DEV}@${thread} 71 71 echo "Device: $dev" 72 72 cat /proc/net/pktgen/$dev | grep -A2 "Result:"