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. CIDR (e.g. 198.18.0.0/15) is also allowed"
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"
22 echo " -w : (\$DELAY) Tx Delay value (ns)"
23 echo " -a : (\$APPEND) Script will not reset generator's state, but will append its config"
27 ## --- Parse command line arguments / parameters ---
28 ## echo "Commandline options:"
29 while getopts "s:i:d:m:p:f:t:c:n:b:w:vxh6a" option; do
33 info "Output device set to: DEV=$DEV"
36 export PKT_SIZE=$OPTARG
37 info "Packet size set to: PKT_SIZE=$PKT_SIZE bytes"
40 export DEST_IP=$OPTARG
41 info "Destination IP set to: DEST_IP=$DEST_IP"
44 export DST_MAC=$OPTARG
45 info "Destination MAC set to: DST_MAC=$DST_MAC"
48 export DST_PORT=$OPTARG
49 info "Destination PORT set to: DST_PORT=$DST_PORT"
52 export F_THREAD=$OPTARG
53 info "Index of first thread (zero indexed CPU number): $F_THREAD"
56 export THREADS=$OPTARG
57 info "Number of threads to start: $THREADS"
60 export CLONE_SKB=$OPTARG
61 info "CLONE_SKB=$CLONE_SKB"
69 info "SKB bursting: BURST=$BURST"
77 info "Verbose mode: VERBOSE=$VERBOSE"
81 info "Debug mode: DEBUG=$DEBUG"
89 info "Append mode: APPEND=$APPEND"
93 err 2 "[ERROR] Unknown parameters!!!"
96 shift $(( $OPTIND - 1 ))
98 if [ -z "$PKT_SIZE" ]; then
99 # NIC adds 4 bytes CRC
101 info "Default packet size set to: set to: $PKT_SIZE bytes"
104 if [ -z "$F_THREAD" ]; then
105 # First thread (F_THREAD) reference the zero indexed CPU number
109 if [ -z "$THREADS" ]; then
114 [ -z "$DELAY" ] && export DELAY=0 # Zero means max speed
116 export L_THREAD=$(( THREADS + F_THREAD - 1 ))
118 if [ -z "$DEV" ]; then
120 err 2 "Please specify output device"
123 if [ -z "$DST_MAC" ]; then
124 warn "Missing destination MAC address"
127 if [ -z "$DEST_IP" ]; then
128 warn "Missing destination IP address"
131 if [ ! -d /proc/net/pktgen ]; then
132 info "Loading kernel module: pktgen"