drm/etnaviv: potential NULL dereference
[linux-2.6-microblaze.git] / samples / pktgen / parameters.sh
1 #
2 # SPDX-License-Identifier: GPL-2.0
3 # Common parameter parsing for pktgen scripts
4 #
5
6 function usage() {
7     echo ""
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"
21     echo ""
22 }
23
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
27     case $option in
28         i) # interface
29           export DEV=$OPTARG
30           info "Output device set to: DEV=$DEV"
31           ;;
32         s)
33           export PKT_SIZE=$OPTARG
34           info "Packet size set to: PKT_SIZE=$PKT_SIZE bytes"
35           ;;
36         d) # destination IP
37           export DEST_IP=$OPTARG
38           info "Destination IP set to: DEST_IP=$DEST_IP"
39           ;;
40         m) # MAC
41           export DST_MAC=$OPTARG
42           info "Destination MAC set to: DST_MAC=$DST_MAC"
43           ;;
44         f)
45           export F_THREAD=$OPTARG
46           info "Index of first thread (zero indexed CPU number): $F_THREAD"
47           ;;
48         t)
49           export THREADS=$OPTARG
50           info "Number of threads to start: $THREADS"
51           ;;
52         c)
53           export CLONE_SKB=$OPTARG
54           info "CLONE_SKB=$CLONE_SKB"
55           ;;
56         n)
57           export COUNT=$OPTARG
58           info "COUNT=$COUNT"
59           ;;
60         b)
61           export BURST=$OPTARG
62           info "SKB bursting: BURST=$BURST"
63           ;;
64         v)
65           export VERBOSE=yes
66           info "Verbose mode: VERBOSE=$VERBOSE"
67           ;;
68         x)
69           export DEBUG=yes
70           info "Debug mode: DEBUG=$DEBUG"
71           ;;
72         6)
73           export IP6=6
74           info "IP6: IP6=$IP6"
75           ;;
76         h|?|*)
77           usage;
78           err 2 "[ERROR] Unknown parameters!!!"
79     esac
80 done
81 shift $(( $OPTIND - 1 ))
82
83 if [ -z "$PKT_SIZE" ]; then
84     # NIC adds 4 bytes CRC
85     export PKT_SIZE=60
86     info "Default packet size set to: set to: $PKT_SIZE bytes"
87 fi
88
89 if [ -z "$F_THREAD" ]; then
90     # First thread (F_THREAD) reference the zero indexed CPU number
91     export F_THREAD=0
92 fi
93
94 if [ -z "$THREADS" ]; then
95     export THREADS=1
96 fi
97
98 export L_THREAD=$(( THREADS + F_THREAD - 1 ))
99
100 if [ -z "$DEV" ]; then
101     usage
102     err 2 "Please specify output device"
103 fi
104
105 if [ -z "$DST_MAC" ]; then
106     warn "Missing destination MAC address"
107 fi
108
109 if [ -z "$DEST_IP" ]; then
110     warn "Missing destination IP address"
111 fi
112
113 if [ ! -d /proc/net/pktgen ]; then
114     info "Loading kernel module: pktgen"
115     modprobe pktgen
116 fi