aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dpdk/dpdk_scripts/run_l3fwd.sh
blob: 014ba2717f78e8f5dddb29b6302879a7f4616189 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash

set -x

# Setting variables
DPDK_DIR=dpdk
ROOTDIR=/tmp/openvpp-testing
L3FWDLOG=screenlog.0
PWDDIR=$(pwd)

cpu_corelist=$1
port_config=$2
adj_mac0=$3
adj_mac1=$4
jumbo_frames=$5

SCRIPT_NAME=$(basename $0)

# define a function to get the l3fwd PID
function get_l3fwd_pid()
{
    pid_l3fwd=`sudo ps -elf | grep l3fwd | grep -v grep | grep -v SCREEN | grep -v ${SCRIPT_NAME} | awk '{print $4}'`
    echo ${pid_l3fwd}
}

# Try to kill the l3fwd
# Don't use the pgrep and pkill
l3fwd_pid=`get_l3fwd_pid`
echo ${l3fwd_pid}
if [ ! -z ${l3fwd_pid} ]; then
    success=false
    sudo kill -15 ${l3fwd_pid}
    echo "RC = $?"
    for attempt in {1..5}; do
        echo "Checking if l3fwd is still alive, attempt nr ${attempt}"
        l3fwd_pid=`get_l3fwd_pid`
        if [ -z ${l3fwd_pid} ]; then
            echo "l3fwd is dead"
            success=true
            break
        fi
        echo "l3fwd is still alive, waiting 1 second"
        sleep 1
    done
    if [ "$success" = false ]; then
        echo "The command sudo kill -15 l3fwd failed"
        sudo kill -9 ${l3fwd_pid}
        echo "RC = $?"
        exit 1
    fi
else
    echo "l3fwd is not running"
fi

# Try to kill the testpmd
sudo pgrep testpmd
if [ $? -eq "0" ]; then
    success=false
    sudo pkill testpmd
    echo "RC = $?"
    for attempt in {1..5}; do
        echo "Checking if testpmd is still alive, attempt nr ${attempt}"
        sudo pgrep testpmd
        if [ $? -eq "1" ]; then
            echo "testpmd is dead"
            success=true
            break
        fi
        echo "testpmd is still alive, waiting 1 second"
        sleep 1
    done
    if [ "$success" = false ]; then
        echo "The command sudo pkill testpmd failed"
        sudo pkill -9 testpmd
        echo "RC = $?"
        exit 1
    fi
else
    echo "testpmd is not running"
fi

sudo rm -f /dev/hugepages/*

sleep 2

#run the l3fwd
cd ${ROOTDIR}/${DPDK_DIR}/
rm -f ${L3FWDLOG}
if [ "$jumbo_frames" = "yes" ]; then
    sudo sh -c "screen -dmSL DPDK-test ./examples/l3fwd/build/app/l3fwd \
    -l ${cpu_corelist} -n 4 --log-level 8 -- \
    -P -L -p 0x3 --config='${port_config}' \
    --enable-jumbo --max-pkt-len=9000 --eth-dest=0,${adj_mac0} \
    --eth-dest=1,${adj_mac1} --parse-ptype"
else
    sudo sh -c "screen -dmSL DPDK-test ./examples/l3fwd/build/app/l3fwd \
    -l ${cpu_corelist} -n 4 --log-level 8 -- \
    -P -L -p 0x3 --config='${port_config}' \
    --eth-dest=0,${adj_mac0} --eth-dest=1,${adj_mac1} --parse-ptype"
fi

sleep 10
less -r ${L3FWDLOG}

cd ${PWDDIR}