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 " -t : (\$THREADS) threads to start"
14 echo " -f : (\$F_THREAD) index of first thread (zero indexed CPU number)"
15 echo " -c : (\$SKB_CLONE) SKB clones send before alloc new SKB"
16 echo " -n : (\$COUNT) num messages to send per thread, 0 means indefinitely"
17 echo " -b : (\$BURST) HW level bursting of SKBs"
18 echo " -v : (\$VERBOSE) verbose"
19 echo " -x : (\$DEBUG) debug"
20 echo " -6 : (\$IP6) IPv6"
24 ## --- Parse command line arguments / parameters ---
25 ## echo "Commandline options:"
26 while getopts "s:i:d:m:f:t:c:n:b:vxh6" option; do
30 info "Output device set to: DEV=$DEV"
33 export PKT_SIZE=$OPTARG
34 info "Packet size set to: PKT_SIZE=$PKT_SIZE bytes"
37 export DEST_IP=$OPTARG
38 info "Destination IP set to: DEST_IP=$DEST_IP"
41 export DST_MAC=$OPTARG
42 info "Destination MAC set to: DST_MAC=$DST_MAC"
45 export F_THREAD=$OPTARG
46 info "Index of first thread (zero indexed CPU number): $F_THREAD"
49 export THREADS=$OPTARG
50 info "Number of threads to start: $THREADS"
53 export CLONE_SKB=$OPTARG
54 info "CLONE_SKB=$CLONE_SKB"
62 info "SKB bursting: BURST=$BURST"
66 info "Verbose mode: VERBOSE=$VERBOSE"
70 info "Debug mode: DEBUG=$DEBUG"
78 err 2 "[ERROR] Unknown parameters!!!"
81 shift $(( $OPTIND - 1 ))
83 if [ -z "$PKT_SIZE" ]; then
84 # NIC adds 4 bytes CRC
86 info "Default packet size set to: set to: $PKT_SIZE bytes"
89 if [ -z "$F_THREAD" ]; then
90 # First thread (F_THREAD) reference the zero indexed CPU number
94 if [ -z "$THREADS" ]; then
98 export L_THREAD=$(( THREADS + F_THREAD - 1 ))
100 if [ -z "$DEV" ]; then
102 err 2 "Please specify output device"
105 if [ -z "$DST_MAC" ]; then
106 warn "Missing destination MAC address"
109 if [ -z "$DEST_IP" ]; then
110 warn "Missing destination IP address"
113 if [ ! -d /proc/net/pktgen ]; then
114 info "Loading kernel module: pktgen"