summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/dpdk/Makefile54
-rw-r--r--src/dpdk/dpdk.py58
-rw-r--r--src/ovs/__init__.py1
-rw-r--r--src/ovs/daemon.py156
-rw-r--r--src/ovs/ofctl.py39
-rw-r--r--src/package-list.mk8
-rwxr-xr-xsrc/qemu/Makefile10
7 files changed, 107 insertions, 219 deletions
diff --git a/src/dpdk/Makefile b/src/dpdk/Makefile
index 25ec3f12..69255f75 100755
--- a/src/dpdk/Makefile
+++ b/src/dpdk/Makefile
@@ -1,7 +1,7 @@
# makefile to manage dpdk package
#
-# Copyright 2015 OPNFV
+# Copyright 2015-2016 OPNFV
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
#
# Contributors:
# Aihua Li, Huawei Technologies.
+# Martin Klozik, Intel Corporation.
include ../mk/master.mk
include ../package-list.mk
@@ -29,16 +30,31 @@ ifndef VHOST_USER
endif
WORK_DIR = dpdk
TAG_DONE_FLAG = $(WORK_DIR)/.$(DPDK_TAG).tag.done
-DPDK_VANILLA = ../../src_vanilla/dpdk
DPDK_CUSE = ../../src_cuse/dpdk
-# the name has been changed from version to version
-ifeq ($(DPDK_TAG),v1.6.0r0)
+# VHOST configuration options are stored in different files based on DPDK version
+# v1.2.3r0-v1.6.0r2 - configuration inside config/defconfig_x86_64-default-linuxapp-gcc
+# v1.7.0-rc1-v2.2.0 - configuration inside config/common_linuxapp
+# v16 and newer - configuration split between config/common_linuxapp and config/common_base
+DPDK_TAG_MAJOR = $(shell echo $(DPDK_TAG) | cut -d. -f1)
+DPDK_TAG_MINOR = $(shell echo $(DPDK_TAG) | cut -d. -f2)
+ifeq ($(DPDK_TAG_MAJOR),v1)
+ifeq ($(DPDK_TAG_MINOR), $(filter $(DPDK_TAG_MINOR), 7 8))
+ DPDK_TARGET = x86_64-native-linuxapp-gcc
+ CONFIG_FILE_LINUXAPP = $(WORK_DIR)/config/common_linuxapp
+else
DPDK_TARGET = x86_64-default-linuxapp-gcc
- CONFIG_FILE = $(WORK_DIR)/config/defconfig_x86_64-default-linuxapp-gcc
+ CONFIG_FILE_LINUXAPP = $(WORK_DIR)/config/defconfig_x86_64-default-linuxapp-gcc
+endif
+else
+ifeq ($(DPDK_TAG_MAJOR),v2)
+ DPDK_TARGET = x86_64-native-linuxapp-gcc
+ CONFIG_FILE_LINUXAPP = $(WORK_DIR)/config/common_linuxapp
else
DPDK_TARGET = x86_64-native-linuxapp-gcc
- CONFIG_FILE = $(WORK_DIR)/config/common_linuxapp
+ CONFIG_FILE_BASE = $(WORK_DIR)/config/common_base
+ CONFIG_FILE_LINUXAPP = $(WORK_DIR)/config/common_linuxapp
+endif
endif
all: force_make
@@ -47,14 +63,27 @@ all: force_make
INSTALL_TARGET = force_make
# modify CONFIG_FILE to enable VHOST_USER build and restore original CONFIG_FILE after the build
+# DPDK v16 comments:
+## CONFIG_RTE_BUILD_COMBINE_LIBS has been obsoleted
+## CONFIG_RTE_LIBRTE_VHOST and CONFIG_RTE_LIBRTE_KNI are listed in both config_base and config_linuxapp,
+## values from config_linuxapp will be used, but options are modified at both places to avoid confusion.
force_make: $(TAG_DONE_FLAG)
$(AT)cd $(WORK_DIR) && git pull $(DPDK_URL) $(DPDK_TAG)
- $(AT)sed -i -e 's/CONFIG_RTE_LIBRTE_VHOST_USER=.\+/CONFIG_RTE_LIBRTE_VHOST_USER=$(VHOST_USER)/g' $(CONFIG_FILE)
- $(AT)sed -i -e 's/CONFIG_RTE_BUILD_COMBINE_LIBS=./CONFIG_RTE_BUILD_COMBINE_LIBS=y/g' $(CONFIG_FILE)
- $(AT)sed -i -e 's/CONFIG_RTE_LIBRTE_VHOST=./CONFIG_RTE_LIBRTE_VHOST=y/g' $(CONFIG_FILE)
- $(AT)sed -i -e 's/CONFIG_RTE_LIBRTE_KNI=./CONFIG_RTE_LIBRTE_KNI=n/g' $(CONFIG_FILE)
+ifdef CONFIG_FILE_BASE
+ $(AT)sed -i -e 's/CONFIG_RTE_LIBRTE_VHOST_USER=.\+/CONFIG_RTE_LIBRTE_VHOST_USER=$(VHOST_USER)/g' $(CONFIG_FILE_BASE)
+ $(AT)sed -i -e 's/CONFIG_RTE_LIBRTE_VHOST=./CONFIG_RTE_LIBRTE_VHOST=y/g' $(CONFIG_FILE_BASE)
+ $(AT)sed -i -e 's/CONFIG_RTE_LIBRTE_KNI=./CONFIG_RTE_LIBRTE_KNI=n/g' $(CONFIG_FILE_BASE)
+else
+ $(AT)sed -i -e 's/CONFIG_RTE_LIBRTE_VHOST_USER=.\+/CONFIG_RTE_LIBRTE_VHOST_USER=$(VHOST_USER)/g' $(CONFIG_FILE_LINUXAPP)
+ $(AT)sed -i -e 's/CONFIG_RTE_BUILD_COMBINE_LIBS=./CONFIG_RTE_BUILD_COMBINE_LIBS=y/g' $(CONFIG_FILE_LINUXAPP)
+endif
+ $(AT)sed -i -e 's/CONFIG_RTE_LIBRTE_VHOST=./CONFIG_RTE_LIBRTE_VHOST=y/g' $(CONFIG_FILE_LINUXAPP)
+ $(AT)sed -i -e 's/CONFIG_RTE_LIBRTE_KNI=./CONFIG_RTE_LIBRTE_KNI=n/g' $(CONFIG_FILE_LINUXAPP)
$(AT)cd $(WORK_DIR); make install T=$(DPDK_TARGET) -j DESTDIR=$(WORK_DIR)
- $(AT)cd `dirname $(CONFIG_FILE)` && git checkout `basename $(CONFIG_FILE)` && cd -
+ $(AT)cd `dirname $(CONFIG_FILE_LINUXAPP)` && git checkout `basename $(CONFIG_FILE_LINUXAPP)` && cd -
+ifdef CONFIG_FILE_BASE
+ $(AT)cd `dirname $(CONFIG_FILE_BASE)` && git checkout `basename $(CONFIG_FILE_BASE)` && cd -
+endif
$(AT)echo "VHOST_USER = $(VHOST_USER)"
ifeq ($(VHOST_USER),n)
$(AT)cd $(WORK_DIR)/lib/librte_vhost/eventfd_link; make
@@ -70,7 +99,6 @@ clean:
$(AT)cd $(WORK_DIR) && git clean -xfd *.o
clobber:
$(AT)rm -rf $(WORK_DIR)
- $(AT)rm -rf $(DPDK_VANILLA)
$(AT)rm -rf $(DPDK_CUSE)
# distclean is for developer who would like to keep the
@@ -86,8 +114,6 @@ sanity:
$(WORK_DIR):
$(AT)git clone $(DPDK_URL)
- $(AT)mkdir -p $(DPDK_VANILLA)
- $(AT)cp -rf ./* $(DPDK_VANILLA)
$(AT)mkdir -p $(DPDK_CUSE)
$(AT)cp -rf ./* $(DPDK_CUSE)
diff --git a/src/dpdk/dpdk.py b/src/dpdk/dpdk.py
index f8cbbd81..30f228f7 100644
--- a/src/dpdk/dpdk.py
+++ b/src/dpdk/dpdk.py
@@ -23,7 +23,6 @@ from sys import platform as _platform
import os
import subprocess
import logging
-import locale
from tools import tasks
from conf import settings
@@ -31,17 +30,25 @@ from tools.module_manager import ModuleManager
_LOGGER = logging.getLogger(__name__)
RTE_PCI_TOOL = os.path.join(
- settings.getValue('RTE_SDK'), 'tools', 'dpdk_nic_bind.py')
+ settings.getValue('RTE_SDK_USER'), 'tools', 'dpdk_nic_bind.py')
_DPDK_MODULE_MANAGER = ModuleManager()
+
+# declare global NIC variables only as their content might not be known yet
+_NICS = []
+_NICS_PCI = []
+
#
# system management
#
-
def init():
"""Setup system for DPDK.
"""
+ global _NICS
+ global _NICS_PCI
+ _NICS = settings.getValue('NICS')
+ _NICS_PCI = list(nic['pci'] for nic in _NICS)
if not _is_linux():
_LOGGER.error('Not running on a compatible Linux version. Exiting...')
return
@@ -175,54 +182,35 @@ def _bind_nics():
True)
tasks.run_task(['sudo', RTE_PCI_TOOL, '--bind=' + _driver] +
- settings.getValue('WHITELIST_NICS'), _LOGGER,
- 'Binding NICs %s...' %
- settings.getValue('WHITELIST_NICS'),
+ _NICS_PCI, _LOGGER,
+ 'Binding NICs %s...' % _NICS_PCI,
True)
except subprocess.CalledProcessError:
- _LOGGER.error('Unable to bind NICs %s',
- str(settings.getValue('WHITELIST_NICS')))
-
-def _unbind_nics_get_driver():
- """Check what driver the NICs should be bound to
- after unbinding them from DPDK.
- """
- _driver_list = []
- _output = subprocess.check_output([os.path.expanduser(RTE_PCI_TOOL), '--status'])
- _my_encoding = locale.getdefaultlocale()[1]
- for line in _output.decode(_my_encoding).split('\n'):
- for nic in settings.getValue('WHITELIST_NICS'):
- if nic in line:
- _driver_list.append((line.split("unused=", 1)[1]))
- return _driver_list
+ _LOGGER.error('Unable to bind NICs %s', str(_NICS_PCI))
def _unbind_nics():
"""Unbind NICs using the Intel DPDK ``dpdk_nic_bind.py`` tool.
"""
- nic_drivers = _unbind_nics_get_driver()
try:
tasks.run_task(['sudo', RTE_PCI_TOOL, '--unbind'] +
- settings.getValue('WHITELIST_NICS'), _LOGGER,
- 'Unbinding NICs %s...' %
- str(settings.getValue('WHITELIST_NICS')),
+ _NICS_PCI, _LOGGER,
+ 'Unbinding NICs %s...' % str(_NICS_PCI),
True)
except subprocess.CalledProcessError:
- _LOGGER.error('Unable to unbind NICs %s',
- str(settings.getValue('WHITELIST_NICS')))
+ _LOGGER.error('Unable to unbind NICs %s', str(_NICS_PCI))
# Rebind NICs to their original drivers
# using the Intel DPDK ``dpdk_nic_bind.py`` tool.
- for i, nic in enumerate(settings.getValue('WHITELIST_NICS')):
+ for nic in _NICS:
try:
- if nic_drivers[i] != '':
+ if nic['driver']:
tasks.run_task(['sudo', RTE_PCI_TOOL, '--bind',
- nic_drivers[i], nic],
- _LOGGER, 'Binding NIC %s...' %
- nic,
+ nic['driver'], nic['pci']],
+ _LOGGER, 'Binding NIC %s to %s...' %
+ (nic['pci'], nic['driver']),
True)
except subprocess.CalledProcessError:
- _LOGGER.error('Unable to bind NICs %s to drivers %s',
- str(settings.getValue('WHITELIST_NICS')),
- nic_drivers)
+ _LOGGER.error('Unable to bind NIC %s to driver %s',
+ nic['pci'], nic['driver'])
class Dpdk(object):
"""A context manager for the system init/cleanup.
diff --git a/src/ovs/__init__.py b/src/ovs/__init__.py
index 8c157006..77592ea3 100644
--- a/src/ovs/__init__.py
+++ b/src/ovs/__init__.py
@@ -21,6 +21,5 @@ and external setup of vswitchd-external process, kernel modules etc.
"""
-from src.ovs.daemon import *
from src.ovs.ofctl import *
from src.ovs.dpctl import *
diff --git a/src/ovs/daemon.py b/src/ovs/daemon.py
deleted file mode 100644
index 09735600..00000000
--- a/src/ovs/daemon.py
+++ /dev/null
@@ -1,156 +0,0 @@
-# Copyright 2015 Intel Corporation.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Class wrapper for controlling an OVS instance.
-
-Wraps a pair of ``ovs-vswitchd`` and ``ovsdb-server`` processes.
-"""
-
-import os
-import logging
-import pexpect
-
-from conf import settings
-from tools import tasks
-
-_OVS_VSWITCHD_BIN = os.path.join(
- settings.getValue('OVS_DIR'), 'vswitchd', 'ovs-vswitchd')
-_OVSDB_TOOL_BIN = os.path.join(
- settings.getValue('OVS_DIR'), 'ovsdb', 'ovsdb-tool')
-_OVSDB_SERVER_BIN = os.path.join(
- settings.getValue('OVS_DIR'), 'ovsdb', 'ovsdb-server')
-
-_OVS_VAR_DIR = settings.getValue('OVS_VAR_DIR')
-_OVS_ETC_DIR = settings.getValue('OVS_ETC_DIR')
-
-_LOG_FILE_VSWITCHD = os.path.join(
- settings.getValue('LOG_DIR'), settings.getValue('LOG_FILE_VSWITCHD'))
-
-class VSwitchd(tasks.Process):
- """Class wrapper for controlling an OVS instance.
-
- Wraps a pair of ``ovs-vswitchd`` and ``ovsdb-server`` processes.
- """
- _ovsdb_pid = None
- _logfile = _LOG_FILE_VSWITCHD
- _ovsdb_pidfile_path = os.path.join(settings.getValue('LOG_DIR'), "ovsdb_pidfile.pid")
- _proc_name = 'ovs-vswitchd'
-
- def __init__(self, timeout=30, vswitchd_args=None, expected_cmd=None):
- """Initialise the wrapper with a specific start timeout and extra
- parameters.
-
- :param timeout: Timeout to wait for application to start.
- :param vswitchd_args: Command line parameters for vswitchd.
-
- :returns: None
- """
- self._logger = logging.getLogger(__name__)
- self._timeout = timeout
- self._expect = expected_cmd
- vswitchd_args = vswitchd_args or []
- self._cmd = ['sudo', '-E', _OVS_VSWITCHD_BIN] + vswitchd_args
-
- # startup/shutdown
-
- def start(self):
- """ Start ``ovsdb-server`` and ``ovs-vswitchd`` instance.
-
- :returns: None
- :raises: pexpect.EOF, pexpect.TIMEOUT
- """
-
- self._reset_ovsdb()
- self._start_ovsdb() # this has to be started first
-
- try:
- super(VSwitchd, self).start()
- self.relinquish()
- except (pexpect.EOF, pexpect.TIMEOUT) as exc:
- logging.error("Exception during VSwitch start.")
- self._kill_ovsdb()
- raise exc
-
- def kill(self, signal='-15', sleep=2):
- """Kill ``ovs-vswitchd`` instance if it is alive.
-
- :returns: None
- """
- self._logger.info('Killing ovs-vswitchd...')
-
- self._kill_ovsdb()
-
- super(VSwitchd, self).kill(signal, sleep)
-
- # helper functions
-
- def _reset_ovsdb(self):
- """Reset system for 'ovsdb'.
-
- :returns: None
- """
- self._logger.info('Resetting system after last run...')
-
- tasks.run_task(['sudo', 'rm', '-rf', _OVS_VAR_DIR], self._logger)
- tasks.run_task(['sudo', 'mkdir', '-p', _OVS_VAR_DIR], self._logger)
- tasks.run_task(['sudo', 'rm', '-rf', _OVS_ETC_DIR], self._logger)
- tasks.run_task(['sudo', 'mkdir', '-p', _OVS_ETC_DIR], self._logger)
-
- tasks.run_task(['sudo', 'rm', '-f',
- os.path.join(_OVS_ETC_DIR, 'conf.db')],
- self._logger)
-
- self._logger.info('System reset after last run.')
-
- def _start_ovsdb(self):
- """Start ``ovsdb-server`` instance.
-
- :returns: None
- """
- tasks.run_task(['sudo', _OVSDB_TOOL_BIN, 'create',
- os.path.join(_OVS_ETC_DIR, 'conf.db'),
- os.path.join(settings.getValue('OVS_DIR'), 'vswitchd',
- 'vswitch.ovsschema')],
- self._logger,
- 'Creating ovsdb configuration database...')
-
- tasks.run_background_task(
- ['sudo', _OVSDB_SERVER_BIN,
- '--remote=punix:%s' % os.path.join(_OVS_VAR_DIR, 'db.sock'),
- '--remote=db:Open_vSwitch,Open_vSwitch,manager_options',
- '--pidfile=' + self._ovsdb_pidfile_path, '--overwrite-pidfile'],
- self._logger,
- 'Starting ovsdb-server...')
-
- def _kill_ovsdb(self):
- """Kill ``ovsdb-server`` instance.
-
- :returns: None
- """
- with open(self._ovsdb_pidfile_path, "r") as pidfile:
- ovsdb_pid = pidfile.read().strip()
-
- self._logger.info("Killing ovsdb with pid: " + ovsdb_pid)
-
- if ovsdb_pid:
- tasks.run_task(['sudo', 'kill', '-15', str(ovsdb_pid)],
- self._logger, 'Killing ovsdb-server...')
-
- @staticmethod
- def get_db_sock_path():
- """Method returns location of db.sock file
-
- :returns: path to db.sock file.
- """
- return os.path.join(_OVS_VAR_DIR, 'db.sock')
diff --git a/src/ovs/ofctl.py b/src/ovs/ofctl.py
index 93894889..d7a2b320 100644
--- a/src/ovs/ofctl.py
+++ b/src/ovs/ofctl.py
@@ -57,12 +57,18 @@ class OFBase(object):
def run_vsctl(self, args, check_error=False):
"""Run ``ovs-vsctl`` with supplied arguments.
+ In case that timeout is set to -1, then ovs-vsctl
+ will be called with --no-wait option.
+
:param args: Arguments to pass to ``ovs-vsctl``
:param check_error: Throw exception on error
:return: None
"""
- cmd = ['sudo', _OVS_VSCTL_BIN, '--timeout', str(self.timeout)] + args
+ if self.timeout == -1:
+ cmd = ['sudo', _OVS_VSCTL_BIN, '--no-wait'] + args
+ else:
+ cmd = ['sudo', _OVS_VSCTL_BIN, '--timeout', str(self.timeout)] + args
return tasks.run_task(
cmd, self.logger, 'Running ovs-vsctl...', check_error)
@@ -343,6 +349,37 @@ class OFBridge(OFBase):
self.logger.debug('dump flows')
self.run_ofctl(['dump-flows', self.br_name], timeout=120)
+ def set_stp(self, enable=True):
+ """
+ Set stp status
+ :param enable: Boolean to enable or disable stp
+ :return: None
+ """
+ self.logger.debug(
+ 'Setting stp on bridge to %s', 'on' if enable else 'off')
+ self.run_vsctl(
+ ['set', 'Bridge', self.br_name, 'stp_enable={}'.format(
+ 'true' if enable else 'false')])
+
+ def set_rstp(self, enable=True):
+ """
+ Set rstp status
+ :param enable: Boolean to enable or disable rstp
+ :return: None
+ """
+ self.logger.debug(
+ 'Setting rstp on bridge to %s', 'on' if enable else 'off')
+ self.run_vsctl(
+ ['set', 'Bridge', self.br_name, 'rstp_enable={}'.format(
+ 'true' if enable else 'false')])
+
+ def bridge_info(self):
+ """
+ Get bridge info
+ :return: Returns bridge info from list bridge command
+ """
+ return self.run_vsctl(['list', 'bridge', self.br_name])
+
#
# helper functions
#
diff --git a/src/package-list.mk b/src/package-list.mk
index 4bd1159b..5aa40bd2 100644
--- a/src/package-list.mk
+++ b/src/package-list.mk
@@ -6,12 +6,14 @@
# dpdk section
# DPDK_URL ?= git://dpdk.org/dpdk
DPDK_URL ?= http://dpdk.org/git/dpdk
-DPDK_TAG ?= v2.2.0
+DPDK_TAG ?= v16.04
# OVS section
OVS_URL ?= https://github.com/openvswitch/ovs
-OVS_TAG ?= 02ab4b1a6a173979a51cabd7000a34546d517e60
+#The Tag below is for OVS v2.5.0 with backwards compatibility support for Qemu
+#versions < 2.5.
+OVS_TAG ?= 31871ee3839c35e6878debfc7926afa471dbdec6
# QEMU section
QEMU_URL ?= https://github.com/qemu/qemu.git
-QEMU_TAG ?= v2.3.0
+QEMU_TAG ?= v2.5.0
diff --git a/src/qemu/Makefile b/src/qemu/Makefile
index 4603b273..5f5e941f 100755
--- a/src/qemu/Makefile
+++ b/src/qemu/Makefile
@@ -27,9 +27,7 @@ TAG_DONE_FLAG = $(WORK_DIR)/.$(QEMU_TAG).done
INSTALL_TARGET = force_make force_install
CONFIG_CMD =
CONFIG_CMD += ./configure
-CONFIG_CMD += --target-list="x86_64-softmmu"
-QEMU_VANILLA = ../../src_vanilla/qemu
-QEMU_CUSE = ../../src_cuse/qemu
+CONFIG_CMD += --target-list="x86_64-softmmu" --python="/usr/bin/python"
all: force_make
@@ -55,8 +53,6 @@ clean:
$(AT)cd $(WORK_DIR) && git clean -xfd *.o
clobber:
$(AT)rm -rf $(WORK_DIR)
- $(AT)rm -rf $(QEMU_VANILLA)
- $(AT)rm -rf $(QEMU_CUSE)
# distclean is for developer who would like to keep the
# clone git repo, saving time to fetch again from url
@@ -73,10 +69,6 @@ $(WORK_DIR)/configure: $(TAG_DONE_FLAG)
$(WORK_DIR):
$(AT)git clone $(QEMU_URL)
- $(AT)mkdir -p $(QEMU_VANILLA)
- $(AT)cp -rf ./* $(QEMU_VANILLA)
- $(AT)mkdir -p $(QEMU_CUSE)
- $(AT)cp -rf ./* $(QEMU_CUSE)
$(TAG_DONE_FLAG): $(WORK_DIR)
$(AT)cd $(WORK_DIR); git checkout $(QEMU_TAG)