event/cnxk: fix clang build on Arm
[dpdk.git] / examples / ipsec-secgw / test / common_defs_secgw.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: BSD-3-Clause
3
4 # check required parameters
5 SGW_REQ_VARS="SGW_PATH SGW_PORT_CFG SGW_WAIT_DEV"
6 for reqvar in ${SGW_REQ_VARS}
7 do
8         if [[ -z "${!reqvar}" ]]; then
9                 echo "Required parameter ${reqvar} is empty"
10                 exit 127
11         fi
12 done
13
14 # check if SGW_PATH point to an executable
15 if [[ ! -x ${SGW_PATH} ]]; then
16         echo "${SGW_PATH} is not executable"
17         exit 127
18 fi
19
20 # setup SGW_LCORE
21 SGW_LCORE=${SGW_LCORE:-0}
22
23 # setup config and output filenames
24 SGW_OUT_FILE=./ipsec-secgw.out1
25 SGW_CFG_FILE=$(mktemp)
26
27 # setup secgw parameters
28 SGW_CMD_EAL_PRM="--lcores=${SGW_LCORE} -n 4"
29 SGW_CMD_CFG="(0,0,${SGW_LCORE}),(1,0,${SGW_LCORE})"
30 SGW_CMD_PRM="-p 0x3 -u 1 -P --config=\"${SGW_CMD_CFG}\""
31
32 # start ipsec-secgw
33 secgw_start()
34 {
35         SGW_EXEC_FILE=$(mktemp)
36         cat <<EOF > ${SGW_EXEC_FILE}
37 stdbuf -o0 ${SGW_PATH} ${SGW_CMD_EAL_PRM} ${CRYPTO_DEV} \
38 ${SGW_PORT_CFG} ${SGW_EAL_XPRM} \
39 -- ${SGW_CMD_PRM} ${SGW_CMD_XPRM} -f ${SGW_CFG_FILE} > \
40 ${SGW_OUT_FILE} 2>&1 &
41 p=\$!
42 echo \$p
43 EOF
44
45         cat ${SGW_EXEC_FILE}
46         cat ${SGW_CFG_FILE}
47         SGW_PID=`/bin/bash -x ${SGW_EXEC_FILE}`
48
49         # wait till ipsec-secgw start properly
50         i=0
51         st=1
52         while [[ $i -ne 10 && $st -ne 0 ]]; do
53                 sleep 1
54                 ifconfig ${SGW_WAIT_DEV}
55                 st=$?
56                 let i++
57         done
58 }
59
60 # stop ipsec-secgw and cleanup
61 secgw_stop()
62 {
63         kill ${SGW_PID}
64         rm -f ${SGW_EXEC_FILE}
65         rm -f ${SGW_CFG_FILE}
66 }