summaryrefslogtreecommitdiffstats
path: root/nfvbenchvm/dib/elements
diff options
context:
space:
mode:
Diffstat (limited to 'nfvbenchvm/dib/elements')
-rw-r--r--nfvbenchvm/dib/elements/nfvbenchvm/element-deps5
-rw-r--r--nfvbenchvm/dib/elements/nfvbenchvm/fdio-release.repo5
-rwxr-xr-xnfvbenchvm/dib/elements/nfvbenchvm/finalise.d/51-add-cpu-isolation4
-rwxr-xr-xnfvbenchvm/dib/elements/nfvbenchvm/finalise.d/52-change-resolution3
-rw-r--r--nfvbenchvm/dib/elements/nfvbenchvm/package-installs.yaml13
-rwxr-xr-xnfvbenchvm/dib/elements/nfvbenchvm/post-install.d/01-update-kernel14
-rwxr-xr-xnfvbenchvm/dib/elements/nfvbenchvm/post-install.d/02-testpmd-script25
-rwxr-xr-xnfvbenchvm/dib/elements/nfvbenchvm/post-install.d/03-add-execute-attribute4
-rwxr-xr-xnfvbenchvm/dib/elements/nfvbenchvm/post-install.d/50-pip-package8
-rwxr-xr-xnfvbenchvm/dib/elements/nfvbenchvm/post-install.d/51-cloudcfg-edit33
-rwxr-xr-xnfvbenchvm/dib/elements/nfvbenchvm/post-install.d/99-cleanup3
-rw-r--r--nfvbenchvm/dib/elements/nfvbenchvm/static/etc/cloud/cloud.cfg.d/99-disable-network-config.cfg2
-rw-r--r--nfvbenchvm/dib/elements/nfvbenchvm/static/etc/rc.d/rc.local86
-rw-r--r--nfvbenchvm/dib/elements/nfvbenchvm/static/etc/sysconfig/network-scripts/ifcfg-eth08
-rw-r--r--nfvbenchvm/dib/elements/nfvbenchvm/static/etc/sysconfig/network-scripts/ifcfg-eth18
-rw-r--r--nfvbenchvm/dib/elements/nfvbenchvm/static/vpp/startup.conf30
-rw-r--r--nfvbenchvm/dib/elements/nfvbenchvm/static/vpp/vm.conf8
17 files changed, 259 insertions, 0 deletions
diff --git a/nfvbenchvm/dib/elements/nfvbenchvm/element-deps b/nfvbenchvm/dib/elements/nfvbenchvm/element-deps
new file mode 100644
index 0000000..c6be0aa
--- /dev/null
+++ b/nfvbenchvm/dib/elements/nfvbenchvm/element-deps
@@ -0,0 +1,5 @@
+vm
+cloud-init-datasources
+install-static
+package-installs
+devuser
diff --git a/nfvbenchvm/dib/elements/nfvbenchvm/fdio-release.repo b/nfvbenchvm/dib/elements/nfvbenchvm/fdio-release.repo
new file mode 100644
index 0000000..a26aa42
--- /dev/null
+++ b/nfvbenchvm/dib/elements/nfvbenchvm/fdio-release.repo
@@ -0,0 +1,5 @@
+[fdio-release]
+name=fd.io release branch latest merge
+baseurl=https://nexus.fd.io/content/repositories/fd.io.stable.1707.centos7/
+enabled=1
+gpgcheck=0
diff --git a/nfvbenchvm/dib/elements/nfvbenchvm/finalise.d/51-add-cpu-isolation b/nfvbenchvm/dib/elements/nfvbenchvm/finalise.d/51-add-cpu-isolation
new file mode 100755
index 0000000..eab5817
--- /dev/null
+++ b/nfvbenchvm/dib/elements/nfvbenchvm/finalise.d/51-add-cpu-isolation
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+grubby --update-kernel=ALL --args="isolcpus=1 rcu_nocbs=1 nohz=on nohz_full=1 nmi_watchdog=0"
+grubby --update-kernel=ALL --args="default_hugepagesz=1G hugepagesz=1G hugepages=1"
diff --git a/nfvbenchvm/dib/elements/nfvbenchvm/finalise.d/52-change-resolution b/nfvbenchvm/dib/elements/nfvbenchvm/finalise.d/52-change-resolution
new file mode 100755
index 0000000..26f2f6a
--- /dev/null
+++ b/nfvbenchvm/dib/elements/nfvbenchvm/finalise.d/52-change-resolution
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+grubby --update-kernel=ALL --args="vga=792"
diff --git a/nfvbenchvm/dib/elements/nfvbenchvm/package-installs.yaml b/nfvbenchvm/dib/elements/nfvbenchvm/package-installs.yaml
new file mode 100644
index 0000000..36e0196
--- /dev/null
+++ b/nfvbenchvm/dib/elements/nfvbenchvm/package-installs.yaml
@@ -0,0 +1,13 @@
+bc:
+gcc:
+tuna:
+wget:
+screen:
+telnet:
+python-devel:
+libyaml-devel:
+vpp:
+vpp-plugins:
+kernel-firmware:
+kernel-headers:
+kernel-devel:
diff --git a/nfvbenchvm/dib/elements/nfvbenchvm/post-install.d/01-update-kernel b/nfvbenchvm/dib/elements/nfvbenchvm/post-install.d/01-update-kernel
new file mode 100755
index 0000000..d884f79
--- /dev/null
+++ b/nfvbenchvm/dib/elements/nfvbenchvm/post-install.d/01-update-kernel
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+if [ $DIB_USE_ELREPO_KERNEL != "True" ]; then
+ exit 0
+fi
+
+# Installing the latest kernel from ELRepo
+rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
+rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
+yum remove -y kernel-firmware kernel-headers kernel-devel
+yum install -y --enablerepo=elrepo-kernel kernel-ml kernel-ml-headers kernel-ml-devel
+
+# gcc will be removed with old kernel as dependency, so reinstalling it back
+yum install -y gcc
diff --git a/nfvbenchvm/dib/elements/nfvbenchvm/post-install.d/02-testpmd-script b/nfvbenchvm/dib/elements/nfvbenchvm/post-install.d/02-testpmd-script
new file mode 100755
index 0000000..b1cffc5
--- /dev/null
+++ b/nfvbenchvm/dib/elements/nfvbenchvm/post-install.d/02-testpmd-script
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+DPDK=dpdk-17.05
+DPDK_UNTAR=dpdk-17.05
+
+# pick up the kernel version for the target image
+kernel_version=`ls -t /lib/modules | awk 'NR==1 {print}'`
+
+mkdir dpdk
+wget http://fast.dpdk.org/rel/$DPDK.tar.xz
+tar xfJ $DPDK.tar.xz
+cd $DPDK_UNTAR
+
+export RTE_KERNELDIR=/lib/modules/$kernel_version/build
+export ARCH=x86
+make -j4 install T=x86_64-native-linuxapp-gcc
+
+cp usertools/dpdk-devbind.py ../dpdk
+# cp tools/dpdk_nic_bind.py ../dpdk/dpdk-devbind.py
+cp x86_64-native-linuxapp-gcc/app/testpmd ../dpdk
+cp x86_64-native-linuxapp-gcc/kmod/igb_uio.ko ../dpdk
+
+cd ..
+rm -f $DPDK.tar.xz
+rm -rf $DPDK_UNTAR
diff --git a/nfvbenchvm/dib/elements/nfvbenchvm/post-install.d/03-add-execute-attribute b/nfvbenchvm/dib/elements/nfvbenchvm/post-install.d/03-add-execute-attribute
new file mode 100755
index 0000000..a13ab95
--- /dev/null
+++ b/nfvbenchvm/dib/elements/nfvbenchvm/post-install.d/03-add-execute-attribute
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+chmod +x /etc/rc.d/rc.local
+chmod +x /etc/sysconfig/network-scripts/ifcfg-eth0
diff --git a/nfvbenchvm/dib/elements/nfvbenchvm/post-install.d/50-pip-package b/nfvbenchvm/dib/elements/nfvbenchvm/post-install.d/50-pip-package
new file mode 100755
index 0000000..2d74ff5
--- /dev/null
+++ b/nfvbenchvm/dib/elements/nfvbenchvm/post-install.d/50-pip-package
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+cd /tmp
+wget https://bootstrap.pypa.io/get-pip.py
+python get-pip.py
+
+pip install setuptools wheel
+pip install pyyaml
diff --git a/nfvbenchvm/dib/elements/nfvbenchvm/post-install.d/51-cloudcfg-edit b/nfvbenchvm/dib/elements/nfvbenchvm/post-install.d/51-cloudcfg-edit
new file mode 100755
index 0000000..3e4647a
--- /dev/null
+++ b/nfvbenchvm/dib/elements/nfvbenchvm/post-install.d/51-cloudcfg-edit
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+
+import yaml
+cloudcfg = "/etc/cloud/cloud.cfg"
+user = "cloud-user"
+
+with open(cloudcfg) as f:
+ cfg = yaml.load(f)
+
+try:
+ if cfg['system_info']['default_user']['name']:
+ synver = "2"
+except KeyError:
+ synver = "1"
+
+if synver == "1":
+ if cfg['user'] == user:
+ print("No change needed")
+ exit()
+ else:
+ cfg['user'] = user
+elif synver == "2":
+ if cfg['system_info']['default_user']['name'] == user:
+ print("No change needed")
+ exit()
+ else:
+ # Change the user to cloud-user
+ cfg['system_info']['default_user']['name'] = user
+ cfg['system_info']['default_user']['gecos'] = "Cloud User"
+ print cfg['system_info']['default_user']['name']
+
+with open(cloudcfg, "w") as f:
+ yaml.dump(cfg, f, default_flow_style=False)
diff --git a/nfvbenchvm/dib/elements/nfvbenchvm/post-install.d/99-cleanup b/nfvbenchvm/dib/elements/nfvbenchvm/post-install.d/99-cleanup
new file mode 100755
index 0000000..83d4fc5
--- /dev/null
+++ b/nfvbenchvm/dib/elements/nfvbenchvm/post-install.d/99-cleanup
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+yum erase -y python-devel libyaml-devel kernel-devel kernel-headers kernel-ml-headers kernel-ml-devel gcc
diff --git a/nfvbenchvm/dib/elements/nfvbenchvm/static/etc/cloud/cloud.cfg.d/99-disable-network-config.cfg b/nfvbenchvm/dib/elements/nfvbenchvm/static/etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
new file mode 100644
index 0000000..7d46ed7
--- /dev/null
+++ b/nfvbenchvm/dib/elements/nfvbenchvm/static/etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
@@ -0,0 +1,2 @@
+network: {config: disabled}
+
diff --git a/nfvbenchvm/dib/elements/nfvbenchvm/static/etc/rc.d/rc.local b/nfvbenchvm/dib/elements/nfvbenchvm/static/etc/rc.d/rc.local
new file mode 100644
index 0000000..114dd54
--- /dev/null
+++ b/nfvbenchvm/dib/elements/nfvbenchvm/static/etc/rc.d/rc.local
@@ -0,0 +1,86 @@
+#!/bin/bash
+
+touch /var/lock/subsys/local
+
+# Waiting for cloud-init to generate $TESTPMD_CONF, retry 60 seconds
+NFVBENCH_CONF=/etc/nfvbenchvm.conf
+retry=30
+until [ $retry -eq 0 ]; do
+ if [ -f $NFVBENCH_CONF ]; then break; fi
+ retry=$[$retry-1]
+ sleep 2
+done
+if [ ! -f $NFVBENCH_CONF ]; then
+ exit 0
+fi
+
+# Parse and obtain all configurations
+echo "Generating configurations for forwarder..."
+eval $(cat $NFVBENCH_CONF)
+touch /nfvbench_configured.flag
+NICS=`lspci -D | grep Ethernet | cut -d' ' -f1 | xargs`
+PCI_ADDRESS_1=`echo $NICS | awk '{ print $1 }'`
+PCI_ADDRESS_2=`echo $NICS | awk '{ print $2 }'`
+CPU_CORES=`grep -c ^processor /proc/cpuinfo`
+CPU_MASKS=0x`echo "obase=16; 2 ^ $CPU_CORES - 1" | bc`
+WORKER_CORES=`expr $CPU_CORES - 1`
+
+# CPU isolation optimizations
+echo 1 > /sys/bus/workqueue/devices/writeback/cpumask
+echo 1 > /sys/devices/virtual/workqueue/cpumask
+echo 1 > /proc/irq/default_smp_affinity
+for irq in `ls /proc/irq/`; do
+ echo 1 > /proc/irq/$irq/smp_affinity
+done
+tuna -c $(seq -s, 1 1 $WORKER_CORES) --isolate
+
+# Configure the forwarder
+if [ "$FORWARDER" == "testpmd" ]; then
+ echo "Configuring testpmd..."
+ if [ -z "`lsmod | grep igb_uio`" ]; then
+ modprobe uio
+ insmod /dpdk/igb_uio.ko
+ fi
+ # Binding ports to DPDK
+ /dpdk/dpdk-devbind.py -b igb_uio $PCI_ADDRESS_1
+ /dpdk/dpdk-devbind.py -b igb_uio $PCI_ADDRESS_2
+ screen -dmSL testpmd /dpdk/testpmd \
+ -c $CPU_MASKS \
+ -n 4 \
+ -- \
+ --burst=32 \
+ --txd=256 \
+ --rxd=1024 \
+ --txqflags=0xf00 \
+ --disable-hw-vlan \
+ --eth-peer=0,$TG_MAC1 \
+ --eth-peer=1,$TG_MAC2 \
+ --forward-mode=mac \
+ --nb-cores=$WORKER_CORES\
+ --max-pkt-len 9000
+else
+ echo "Configuring vpp..."
+ cp /vpp/startup.conf /etc/vpp/startup.conf
+ cp /vpp/vm.conf /etc/vpp/vm.conf
+
+ sed -i "s/{{PCI_ADDRESS_1}}/$PCI_ADDRESS_1/g" /etc/vpp/startup.conf
+ sed -i "s/{{PCI_ADDRESS_2}}/$PCI_ADDRESS_2/g" /etc/vpp/startup.conf
+ sed -i "s/{{WORKER_CORES}}/$WORKER_CORES/g" /etc/vpp/startup.conf
+ service vpp start
+
+ INTFS=`vppctl show int | grep Ethernet | xargs`
+ INTF_1=`echo $INTFS | awk '{ print $1 }'`
+ INTF_2=`echo $INTFS | awk '{ print $4 }'`
+ sed -i "s/{{INTF_1}}/${INTF_1//\//\/}/g" /etc/vpp/vm.conf
+ sed -i "s/{{INTF_2}}/${INTF_2//\//\/}/g" /etc/vpp/vm.conf
+ sed -i "s/{{VNF_GATEWAY1_CIDR}}/${VNF_GATEWAY1_CIDR//\//\/}/g" /etc/vpp/vm.conf
+ sed -i "s/{{VNF_GATEWAY2_CIDR}}/${VNF_GATEWAY2_CIDR//\//\/}/g" /etc/vpp/vm.conf
+ sed -i "s/{{TG_MAC1}}/${TG_MAC1}/g" /etc/vpp/vm.conf
+ sed -i "s/{{TG_MAC2}}/${TG_MAC2}/g" /etc/vpp/vm.conf
+ sed -i "s/{{TG_NET1}}/${TG_NET1//\//\/}/g" /etc/vpp/vm.conf
+ sed -i "s/{{TG_NET2}}/${TG_NET2//\//\/}/g" /etc/vpp/vm.conf
+ sed -i "s/{{TG_GATEWAY1_IP}}/${TG_GATEWAY1_IP}/g" /etc/vpp/vm.conf
+ sed -i "s/{{TG_GATEWAY2_IP}}/${TG_GATEWAY2_IP}/g" /etc/vpp/vm.conf
+
+ service vpp restart
+fi
diff --git a/nfvbenchvm/dib/elements/nfvbenchvm/static/etc/sysconfig/network-scripts/ifcfg-eth0 b/nfvbenchvm/dib/elements/nfvbenchvm/static/etc/sysconfig/network-scripts/ifcfg-eth0
new file mode 100644
index 0000000..c1ed6a7
--- /dev/null
+++ b/nfvbenchvm/dib/elements/nfvbenchvm/static/etc/sysconfig/network-scripts/ifcfg-eth0
@@ -0,0 +1,8 @@
+DEVICE="eth0"
+BOOTPROTO="dhcp"
+ONBOOT="no"
+TYPE="Ethernet"
+USERCTL="yes"
+PEERDNS="yes"
+IPV6INIT="no"
+PERSISTENT_DHCLIENT="0"
diff --git a/nfvbenchvm/dib/elements/nfvbenchvm/static/etc/sysconfig/network-scripts/ifcfg-eth1 b/nfvbenchvm/dib/elements/nfvbenchvm/static/etc/sysconfig/network-scripts/ifcfg-eth1
new file mode 100644
index 0000000..c5cd837
--- /dev/null
+++ b/nfvbenchvm/dib/elements/nfvbenchvm/static/etc/sysconfig/network-scripts/ifcfg-eth1
@@ -0,0 +1,8 @@
+DEVICE="eth1"
+BOOTPROTO="dhcp"
+ONBOOT="no"
+TYPE="Ethernet"
+USERCTL="yes"
+PEERDNS="yes"
+IPV6INIT="no"
+PERSISTENT_DHCLIENT="0"
diff --git a/nfvbenchvm/dib/elements/nfvbenchvm/static/vpp/startup.conf b/nfvbenchvm/dib/elements/nfvbenchvm/static/vpp/startup.conf
new file mode 100644
index 0000000..811eee1
--- /dev/null
+++ b/nfvbenchvm/dib/elements/nfvbenchvm/static/vpp/startup.conf
@@ -0,0 +1,30 @@
+unix {
+ nodaemon
+ log /tmp/vpp.log
+ full-coredump
+ startup-config /etc/vpp/vm.conf
+ cli-listen localhost:5002
+}
+
+api-trace {
+ on
+}
+
+dpdk {
+ dev default {
+ num-rx-desc 1024
+ num-tx-desc 256
+ }
+ socket-mem 1024
+ dev {{PCI_ADDRESS_1}}
+ dev {{PCI_ADDRESS_2}}
+}
+
+api-segment {
+ gid vpp
+}
+
+cpu {
+ main-core 0
+ workers {{WORKER_CORES}}
+}
diff --git a/nfvbenchvm/dib/elements/nfvbenchvm/static/vpp/vm.conf b/nfvbenchvm/dib/elements/nfvbenchvm/static/vpp/vm.conf
new file mode 100644
index 0000000..f52a045
--- /dev/null
+++ b/nfvbenchvm/dib/elements/nfvbenchvm/static/vpp/vm.conf
@@ -0,0 +1,8 @@
+set int state {{INTF_1}} up
+set int state {{INTF_2}} up
+set interface ip address {{INTF_1}} {{VNF_GATEWAY1_CIDR}}
+set interface ip address {{INTF_2}} {{VNF_GATEWAY2_CIDR}}
+set ip arp {{INTF_1}} {{TG_GATEWAY1_IP}} {{TG_MAC1}} static
+set ip arp {{INTF_2}} {{TG_GATEWAY2_IP}} {{TG_MAC2}} static
+ip route add {{TG_NET1}} via {{TG_GATEWAY1_IP}}
+ip route add {{TG_NET2}} via {{TG_GATEWAY2_IP}}