aboutsummaryrefslogtreecommitdiffstats
path: root/dpdk-tests/dpdk_scripts/cleanup_dpdk.sh
blob: 915d383bfa406635e025a003ed812038e88b52d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash

ROOTDIR=/tmp/openvpp-testing
PWDDIR=$(pwd)

TESTPMD_LOG=/tmp/testpmd.log
TESTPMD_PID=/tmp/testpmd.pid

port1_driver=$1
port1_pci=$2
port2_driver=$3
port2_pci=$4

#kill the dpdk application
sudo pgrep testpmd
if [ $? -eq "0" ]; then
    success=false
    sudo pkill testpmd
    for attempt in {1..5}; do
        sudo pgrep testpmd
        if [ $? -eq "1" ]; then
            success=true
            break
        fi
        sleep 1
    done
    if [ ${success} -eq false ]; then
        echo "The command sudo pkill testpmd failed"
        exit 1
    fi
fi

sudo rm -f ${TESTPMD_PID}
sudo rm -f /dev/hugepages/*
cat ${TESTPMD_LOG}

cd ${ROOTDIR}/dpdk-16.07/
./tools/dpdk-devbind.py -b ${port1_driver} ${port1_pci}
./tools/dpdk-devbind.py -b ${port2_driver} ${port2_pci}

sleep 2

if1_name=`./tools/dpdk-devbind.py --s | grep "${port1_pci}" | sed -n 's/.*if=\(\S\)/\1/p' | awk -F' ' '{print $1}'`
if2_name=`./tools/dpdk-devbind.py --s | grep "${port2_pci}" | sed -n 's/.*if=\(\S\)/\1/p' | awk -F' ' '{print $1}'`

ifconfig ${if1_name} up
ifconfig ${if2_name} up

rmmod igb_uio
rmmod uio

cd ${PWDDIR}