11222c1bf8f3165db3574ab15f97af66d8dc86b9
[csit.git] / tests / dpdk / dpdk_scripts / run_l3fwd.sh
1 #!/bin/bash
2
3 set -x
4
5 # Setting variables
6 DPDK_VERSION=dpdk-18.02
7 ROOTDIR=/tmp/openvpp-testing
8 L3FWDLOG=screenlog.0
9 PWDDIR=$(pwd)
10
11 cpu_corelist=$1
12 port_config=$2
13 adj_mac0=$3
14 adj_mac1=$4
15 jumbo_frames=$5
16
17 SCRIPT_NAME=$(basename $0)
18
19 # define a function to get the l3fwd PID
20 function get_l3fwd_pid()
21 {
22     pid_l3fwd=`sudo ps -elf | grep l3fwd | grep -v grep | grep -v SCREEN | grep -v ${SCRIPT_NAME} | awk '{print $4}'`
23     echo ${pid_l3fwd}
24 }
25
26 # Try to kill the l3fwd
27 # Don't use the pgrep and pkill
28 l3fwd_pid=`get_l3fwd_pid`
29 echo ${l3fwd_pid}
30 if [ ! -z ${l3fwd_pid} ]; then
31     success=false
32     sudo kill -15 ${l3fwd_pid}
33     echo "RC = $?"
34     for attempt in {1..5}; do
35         echo "Checking if l3fwd is still alive, attempt nr ${attempt}"
36         l3fwd_pid=`get_l3fwd_pid`
37         if [ -z ${l3fwd_pid} ]; then
38             echo "l3fwd is dead"
39             success=true
40             break
41         fi
42         echo "l3fwd is still alive, waiting 1 second"
43         sleep 1
44     done
45     if [ "$success" = false ]; then
46         echo "The command sudo kill -15 l3fwd failed"
47         sudo kill -9 ${l3fwd_pid}
48         echo "RC = $?"
49         exit 1
50     fi
51 else
52     echo "l3fwd is not running"
53 fi
54
55 # Try to kill the testpmd
56 sudo pgrep testpmd
57 if [ $? -eq "0" ]; then
58     success=false
59     sudo pkill testpmd
60     echo "RC = $?"
61     for attempt in {1..5}; do
62         echo "Checking if testpmd is still alive, attempt nr ${attempt}"
63         sudo pgrep testpmd
64         if [ $? -eq "1" ]; then
65             echo "testpmd is dead"
66             success=true
67             break
68         fi
69         echo "testpmd is still alive, waiting 1 second"
70         sleep 1
71     done
72     if [ "$success" = false ]; then
73         echo "The command sudo pkill testpmd failed"
74         sudo pkill -9 testpmd
75         echo "RC = $?"
76         exit 1
77     fi
78 else
79     echo "testpmd is not running"
80 fi
81
82 sudo rm -f /dev/hugepages/*
83
84 sleep 2
85
86 #run the l3fwd
87 cd ${ROOTDIR}/${DPDK_VERSION}/
88 rm -f ${L3FWDLOG}
89 if [ "$jumbo_frames" = "yes" ]; then
90     sudo sh -c "screen -dmSL DPDK-test ./examples/l3fwd/build/app/l3fwd \
91     -l ${cpu_corelist} -n 4 --log-level 8 -- \
92     -P -L -p 0x3 --config='${port_config}' \
93     --enable-jumbo --max-pkt-len=9000 --eth-dest=0,${adj_mac0} \
94     --eth-dest=1,${adj_mac1} --parse-ptype"
95 else
96     sudo sh -c "screen -dmSL DPDK-test ./examples/l3fwd/build/app/l3fwd \
97     -l ${cpu_corelist} -n 4 --log-level 8 -- \
98     -P -L -p 0x3 --config='${port_config}' \
99     --eth-dest=0,${adj_mac0} --eth-dest=1,${adj_mac1} --parse-ptype"
100 fi
101
102 sleep 10
103 less -r ${L3FWDLOG}
104
105 cd ${PWDDIR}
106