Make RXQs/TXQs configurable
[csit.git] / tests / dpdk / dpdk_scripts / run_l2fwd.sh
1 #!/usr/bin/env bash
2
3 # Copyright (c) 2020 Cisco and/or its affiliates.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 set -xuo pipefail
17
18 # Setting variables.
19 DPDK_DIR="dpdk"
20 ROOTDIR="/tmp/openvpp-testing"
21 TESTPMDLOG="screenlog.0"
22 PWDDIR="$(pwd)"
23
24 # Setting command line arguments.
25 cpu_corelist="${1}"
26 nb_cores="${2}"
27 queue_nums="${3}"
28 jumbo_frames="${4}"
29 rxd="${5:-128}"
30 txd="${6:-512}"
31 arch="$(uname -m)"
32
33 # DPDK prefers "arm64" to "aarch64" and does not allow arm64 native target.
34 if [ "${arch}" == "aarch64" ]; then
35     arch="arm64"
36     machine="armv8a"
37 else
38     machine="native"
39 fi
40
41 # Try to kill the testpmd.
42 sudo pgrep testpmd
43 if [ ${?} -eq "0" ]; then
44     success=false
45     sudo pkill testpmd
46     echo "RC = ${?}"
47     for attempt in {1..60}; do
48         echo "Checking if testpmd is still alive, attempt nr ${attempt}"
49         sudo pgrep testpmd
50         if [ ${?} -eq "1" ]; then
51             echo "testpmd is dead"
52             success=true
53             break
54         fi
55         echo "testpmd is still alive, waiting 1 second"
56         sleep 1
57     done
58     if [ "${success}" = false ]; then
59         echo "The command sudo pkill testpmd failed"
60         sudo pkill -9 testpmd
61         echo "RC = ${?}"
62         exit 1
63     fi
64 else
65     echo "testpmd is not running"
66 fi
67
68 # Try to kill the l3fwd.
69 sudo pgrep l3fwd
70 if [ ${?} -eq "0" ]; then
71     success=false
72     sudo pkill l3fwd
73     echo "RC = ${?}"
74     for attempt in {1..60}; do
75         echo "Checking if l3fwd is still alive, attempt nr ${attempt}"
76         sudo pgrep l3fwd
77         if [ ${?} -eq "1" ]; then
78             echo "l3fwd is dead"
79             success=true
80             break
81         fi
82         echo "l3fwd is still alive, waiting 1 second"
83         sleep 1
84     done
85     if [ "${success}" = false ]; then
86         echo "The command sudo pkill l3fwd failed"
87         sudo pkill -9 l3fwd
88         echo "RC = ${?}"
89         exit 1
90     fi
91 else
92     echo "l3fwd is not running"
93 fi
94
95 # Remove hugepages.
96 sudo rm -f /dev/hugepages/*
97
98 sleep 2
99
100 cd "${ROOTDIR}/${DPDK_DIR}/"
101 rm -f "${TESTPMDLOG}"
102 TESTPMD_BIN="./${arch}-${machine}-linuxapp-gcc/app/testpmd"
103
104 if [ "${jumbo_frames}" = "yes" ]; then
105     sudo sh -c "screen -dmSL DPDK-test ${TESTPMD_BIN} \
106         -l ${cpu_corelist} -n 4 --log-level 8 -v -- \
107         --numa \
108         --nb-ports=2 \
109         --portmask=0x3 \
110         --nb-cores=${nb_cores} \
111         --max-pkt-len=9000 \
112         --tx-offloads=0x7FFFFFFF \
113         --forward-mode=io \
114         --rxq=${queue_nums} \
115         --txq=$((${nb_cores} + 1)) \
116         --burst=64 \
117         --rxd=${rxd} \
118         --txd=${txd} \
119         --disable-link-check \
120         --auto-start"
121 else
122     sudo sh -c "screen -dmSL DPDK-test ${TESTPMD_BIN} \
123         -l ${cpu_corelist} -n 4 --log-level 8 -v -- \
124         --numa \
125         --nb-ports=2 \
126         --portmask=0x3 \
127         --nb-cores=${nb_cores} \
128         --forward-mode=io \
129         --rxq=${queue_nums} \
130         --txq=$((${nb_cores} + 1)) \
131         --burst=64 \
132         --rxd=${rxd} \
133         --txd=${txd} \
134         --disable-link-check \
135         --auto-start"
136 fi
137
138 for attempt in {1..60}; do
139     echo "Checking if testpmd is alive, attempt nr ${attempt}"
140     fgrep "Press enter to exit" "${TESTPMDLOG}"
141     if [ "${?}" -eq "0" ]; then
142         exit 0
143     fi
144     sleep 1
145 done
146 cat "${TESTPMDLOG}"
147
148 exit 1