Update DPDK to v17.11
[csit.git] / tests / dpdk / dpdk_scripts / cleanup_dpdk.sh
1 #!/bin/bash
2
3 set -x
4
5 # Setting variables
6 DPDK_VERSION=dpdk-17.11
7 ROOTDIR=/tmp/openvpp-testing
8 TESTPMDLOG=screenlog.0
9 PWDDIR=$(pwd)
10
11 # Setting command line arguments
12 port1_driver=$1
13 port1_pci=$2
14 port2_driver=$3
15 port2_pci=$4
16
17 # Try to kill the testpmd
18 sudo pgrep testpmd
19 if [ $? -eq "0" ]; then
20     success=false
21     sudo pkill testpmd
22     echo "RC = $?"
23     for attempt in {1..5}; do
24         echo "Checking if testpmd is still alive, attempt nr ${attempt}"
25         sudo pgrep testpmd
26         if [ $? -eq "1" ]; then
27             echo "testpmd is dead"
28             success=true
29             break
30         fi
31         echo "testpmd is still alive, waiting 1 second"
32         sleep 1
33     done
34     if [ "$success" = false ]; then
35         echo "The command sudo pkill testpmd failed"
36         sudo pkill -9 testpmd
37         echo "RC = $?"
38         exit 1
39     fi
40 else
41     echo "testpmd is not running"
42 fi
43
44 #also kill the l3fwd
45 sudo pgrep l3fwd
46 if [ $? -eq "0" ]; then
47     success=false
48     sudo pkill l3fwd
49     echo "RC = $?"
50     for attempt in {1..5}; do
51         echo "Checking if l3fwd is still alive, attempt nr ${attempt}"
52         sudo pgrep l3fwd
53         if [ $? -eq "1" ]; then
54             echo "l3fwd is dead"
55             success=true
56             break
57         fi
58         echo "l3fwd is still alive, waiting 1 second"
59         sleep 1
60     done
61     if [ "$success" = false ]; then
62         echo "The command sudo pkill l3fwd failed"
63         sudo pkill -9 l3fwd
64         echo "RC = $?"
65         exit 1
66     fi
67 else
68     echo "l3fwd is not running"
69 fi
70
71 # Remove hugepages
72 sudo rm -f /dev/hugepages/*
73
74 # Unbind interfaces
75 cd ${ROOTDIR}/${DPDK_VERSION}/
76 sudo ./usertools/dpdk-devbind.py -b ${port1_driver} ${port1_pci} || \
77     { echo "Unbind ${port1_pci} failed"; exit 1; }
78 sudo ./usertools/dpdk-devbind.py -b ${port2_driver} ${port2_pci} || \
79     { echo "Unbind ${port1_pci} failed"; exit 1; }
80
81 sleep 2
82
83 if1_name=`./usertools/dpdk-devbind.py --s | grep "${port1_pci}" | sed -n 's/.*if=\(\S\)/\1/p' | awk -F' ' '{print $1}'`
84 if2_name=`./usertools/dpdk-devbind.py --s | grep "${port2_pci}" | sed -n 's/.*if=\(\S\)/\1/p' | awk -F' ' '{print $1}'`
85
86 # Remove igb_uio driver
87 rmmod igb_uio || \
88     { echo "Removing igb_uio failed"; exit 1; }
89
90 cd ${PWDDIR}