blob: 0525a29a7b29846bd3f2bf60a1474ca44da6b92c [file] [log] [blame]
Josep Puigdemont3598bcc2017-03-20 13:34:46 +01001#!/bin/bash
2
3exit_error() {
4 echo "-- SERVER ERROR"
5 lava-test-case server_up --status fail
6}
7trap exit_error ERR
8
9do_configure_system() {
10 local cores=$1
11 local vland_iface=$2
12 local server_ip=$3
13 local driver=${DPDK_DRIVER:-igb_uio}
14 local pci_dev
15
16 pci_dev=$(basename "$(readlink -f "/sys/class/net/${vland_iface}/device")")
17
18 if ! which dpdk-devbind &>/dev/null; then
19 echo "ERROR: dpdk not installed"
20 exit 1
21 fi
22
23 modprobe uio
24 insmod "$RTE_SDK/$RTE_TARGET/lib/modules/$(uname -r)/extra/dpdk/${driver}.ko"
25
26 dpdk-devbind -u "$pci_dev"
27 dpdk-devbind -b "$driver" "$pci_dev"
28 dpdk-devbind -s
29
30 # when using write_config, we need to have /www mounted
31 configure_ramdisk
32
33 # shellcheck disable=SC2034
34 WRITE_CONFIG_CORE=""
35 WRITE_CONFIG_EVENTS="use select;"
36 WRITE_CONFIG_LISTEN="listen $server_ip:80 default_server so_keepalive=off;"
Milosz Wasilewski60152062020-03-02 18:53:29 +000037 cat <<-EOF
Josep Puigdemont3598bcc2017-03-20 13:34:46 +010038 WRITE_CONFIG_CORE=$WRITE_CONFIG_CORE
39 WRITE_CONFIG_EVENTS=$WRITE_CONFIG_EVENTS
40 WRITE_CONFIG_LISTEN=$WRITE_CONFIG_LISTEN
41 EOF
42}
43
44do_stop_nginx() {
45 if [ -f "${BASE_DIR}/install/run/nginx.pid" ]; then
46 stop_nginx.sh 1
47 fi
48}
49
50do_start_nginx() {
51 start_nginx.sh 1
52}
53
54do_write_nginx_config() {
55 local cores=$1
56
57 # when using write_config, we need to have /www mounted
58 write_config "$cores" "${BASE_DIR}/install/etc/nginx/nginx.conf"
59}
60
61do_pre_test_cb() {
62 rm -rf /dev/hugepages/*
63}
64
65do_post_test_cb() {
66 local cores=$1
67 local pid
68
69 echo "-- AFFINITY $cores"
70 for pid in $(pgrep nginx); do
71 taskset -p "$pid"
72 done
73}
74
75BASE_DIR=${BASE_DIR:-/build}
76
77if [ ! -f "${BASE_DIR}/environ" ]; then
78 echo "ERROR: ${BASE_DIR}/environ file not found!" >&2
79 exit 1
80fi
81
82# shellcheck disable=SC1090
83. "${BASE_DIR}/environ"
84
85echo "-- odp-dpdk-git NGiNX initialized" >&2