2 # SPDX-License-Identifier: GPL-2.0
3 # Common parameter parsing for pktgen scripts
8 echo "Usage: $0 [-vx] -i ethX"
9 echo " -i : (\$DEV) output interface/device (required)"
10 echo " -s : (\$PKT_SIZE) packet size"
11 echo " -d : (\$DEST_IP) destination IP"
12 echo " -m : (\$DST_MAC) destination MAC-addr"
13 echo " -p : (\$DST_PORT) destination PORT range (e.g. 433-444) is also allowed"
14 echo " -t : (\$THREADS) threads to start"
15 echo " -f : (\$F_THREAD) index of first thread (zero indexed CPU number)"
16 echo " -c : (\$SKB_CLONE) SKB clones send before alloc new SKB"
17 echo " -n : (\$COUNT) num messages to send per thread, 0 means indefinitely"
18 echo " -b : (\$BURST) HW level bursting of SKBs"
19 echo " -v : (\$VERBOSE) verbose"
20 echo " -x : (\$DEBUG) debug"
21 echo " -6 : (\$IP6) IPv6"
25 ## --- Parse command line arguments / parameters ---
26 ## echo "Commandline options:"
27 while getopts "s:i:d:m:p:f:t:c:n:b:vxh6" option
; do
31 info
"Output device set to: DEV=$DEV"
34 export PKT_SIZE
=$OPTARG
35 info
"Packet size set to: PKT_SIZE=$PKT_SIZE bytes"
38 export DEST_IP
=$OPTARG
39 info
"Destination IP set to: DEST_IP=$DEST_IP"
42 export DST_MAC
=$OPTARG
43 info
"Destination MAC set to: DST_MAC=$DST_MAC"
46 export DST_PORT
=$OPTARG
47 info
"Destination PORT set to: DST_PORT=$DST_PORT"
50 export F_THREAD
=$OPTARG
51 info
"Index of first thread (zero indexed CPU number): $F_THREAD"
54 export THREADS
=$OPTARG
55 info
"Number of threads to start: $THREADS"
58 export CLONE_SKB
=$OPTARG
59 info
"CLONE_SKB=$CLONE_SKB"
67 info
"SKB bursting: BURST=$BURST"
71 info
"Verbose mode: VERBOSE=$VERBOSE"
75 info
"Debug mode: DEBUG=$DEBUG"
83 err
2 "[ERROR] Unknown parameters!!!"
86 shift $
(( $OPTIND - 1 ))
88 if [ -z "$PKT_SIZE" ]; then
89 # NIC adds 4 bytes CRC
91 info
"Default packet size set to: set to: $PKT_SIZE bytes"
94 if [ -z "$F_THREAD" ]; then
95 # First thread (F_THREAD) reference the zero indexed CPU number
99 if [ -z "$THREADS" ]; then
103 export L_THREAD
=$
(( THREADS
+ F_THREAD
- 1 ))
105 if [ -z "$DEV" ]; then
107 err
2 "Please specify output device"
110 if [ -z "$DST_MAC" ]; then
111 warn
"Missing destination MAC address"
114 if [ -z "$DEST_IP" ]; then
115 warn
"Missing destination IP address"
118 if [ ! -d /proc
/net
/pktgen
]; then
119 info
"Loading kernel module: pktgen"