]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - samples/pktgen/parameters.sh
Merge tag 'media/v4.2-3' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
[mirror_ubuntu-zesty-kernel.git] / samples / pktgen / parameters.sh
1 #
2 # Common parameter parsing for pktgen scripts
3 #
4
5 function usage() {
6 echo ""
7 echo "Usage: $0 [-vx] -i ethX"
8 echo " -i : (\$DEV) output interface/device (required)"
9 echo " -s : (\$PKT_SIZE) packet size"
10 echo " -d : (\$DEST_IP) destination IP"
11 echo " -m : (\$DST_MAC) destination MAC-addr"
12 echo " -t : (\$THREADS) threads to start"
13 echo " -c : (\$SKB_CLONE) SKB clones send before alloc new SKB"
14 echo " -b : (\$BURST) HW level bursting of SKBs"
15 echo " -v : (\$VERBOSE) verbose"
16 echo " -x : (\$DEBUG) debug"
17 echo ""
18 }
19
20 ## --- Parse command line arguments / parameters ---
21 ## echo "Commandline options:"
22 while getopts "s:i:d:m:t:c:b:vxh" option; do
23 case $option in
24 i) # interface
25 export DEV=$OPTARG
26 info "Output device set to: DEV=$DEV"
27 ;;
28 s)
29 export PKT_SIZE=$OPTARG
30 info "Packet size set to: PKT_SIZE=$PKT_SIZE bytes"
31 ;;
32 d) # destination IP
33 export DEST_IP=$OPTARG
34 info "Destination IP set to: DEST_IP=$DEST_IP"
35 ;;
36 m) # MAC
37 export DST_MAC=$OPTARG
38 info "Destination MAC set to: DST_MAC=$DST_MAC"
39 ;;
40 t)
41 export THREADS=$OPTARG
42 export CPU_THREADS=$OPTARG
43 let "CPU_THREADS -= 1"
44 info "Number of threads to start: $THREADS (0 to $CPU_THREADS)"
45 ;;
46 c)
47 export CLONE_SKB=$OPTARG
48 info "CLONE_SKB=$CLONE_SKB"
49 ;;
50 b)
51 export BURST=$OPTARG
52 info "SKB bursting: BURST=$BURST"
53 ;;
54 v)
55 export VERBOSE=yes
56 info "Verbose mode: VERBOSE=$VERBOSE"
57 ;;
58 x)
59 export DEBUG=yes
60 info "Debug mode: DEBUG=$DEBUG"
61 ;;
62 h|?|*)
63 usage;
64 err 2 "[ERROR] Unknown parameters!!!"
65 esac
66 done
67 shift $(( $OPTIND - 1 ))
68
69 if [ -z "$PKT_SIZE" ]; then
70 # NIC adds 4 bytes CRC
71 export PKT_SIZE=60
72 info "Default packet size set to: set to: $PKT_SIZE bytes"
73 fi
74
75 if [ -z "$THREADS" ]; then
76 # Zero CPU threads means one thread, because CPU numbers are zero indexed
77 export CPU_THREADS=0
78 export THREADS=1
79 fi
80
81 if [ -z "$DEV" ]; then
82 usage
83 err 2 "Please specify output device"
84 fi
85
86 if [ -z "$DST_MAC" ]; then
87 warn "Missing destination MAC address"
88 fi
89
90 if [ -z "$DEST_IP" ]; then
91 warn "Missing destination IP address"
92 fi
93
94 if [ ! -d /proc/net/pktgen ]; then
95 info "Loading kernel module: pktgen"
96 modprobe pktgen
97 fi