summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile6
-rwxr-xr-xsrc/dpdk/Makefile12
-rw-r--r--src/dpdk/dpdk.py26
-rwxr-xr-xsrc/ovs/Makefile26
-rw-r--r--src/ovs/daemon.py32
5 files changed, 62 insertions, 40 deletions
diff --git a/src/Makefile b/src/Makefile
index 496b717b..0b62da3e 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -21,14 +21,20 @@
include mk/master.mk
+export VHOST_USER
+
# specify upstream package as SUBDIRS - common terms as suggest by gnu-make
SUBDIRS =
SUBDIRS += l2fwd
+ifeq ($(WITH_LINUX),)
SUBDIRS += dpdk
+endif
SUBDIRS += ovs
SUBDIRS += qemu
+ifeq ($(WITH_LINUX),)
# specify package dependency here if needed
ovs: dpdk
+endif
include mk/make-subsys.mk
diff --git a/src/dpdk/Makefile b/src/dpdk/Makefile
index 1f4ca0ae..8335ed4e 100755
--- a/src/dpdk/Makefile
+++ b/src/dpdk/Makefile
@@ -24,6 +24,9 @@ include ../package-list.mk
.PHONY: install force_make
+ifndef VHOST_USER
+ VHOST_USER = n
+endif
WORK_DIR = dpdk
TAG_DONE_FLAG = $(WORK_DIR)/.$(DPDK_TAG).tag.done
@@ -41,8 +44,14 @@ all: force_make
INSTALL_TARGET = force_make
+# modify CONFIG_FILE to enable VHOST_USER build and restore original CONFIG_FILE after the build
force_make: $(TAG_DONE_FLAG)
+ $(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)
$(AT)cd $(WORK_DIR); make install T=$(DPDK_TARGET) -j
+ $(AT)cd `dirname $(CONFIG_FILE)` && git checkout `basename $(CONFIG_FILE)` && cd -
@echo "Make done"
install: $(INSTALL_TARGET)
@@ -70,7 +79,4 @@ $(WORK_DIR):
$(TAG_DONE_FLAG): $(WORK_DIR)
$(AT)cd $(WORK_DIR); git checkout $(DPDK_TAG)
- $(AT)sed -i 's/CONFIG_RTE_BUILD_COMBINE_LIBS=n/CONFIG_RTE_BUILD_COMBINE_LIBS=y/g' $(CONFIG_FILE)
- $(AT)sed -i 's/CONFIG_RTE_LIBRTE_VHOST=n/CONFIG_RTE_LIBRTE_VHOST=y/g' $(CONFIG_FILE)
- $(AT)sed -i 's/CONFIG_RTE_LIBRTE_KNI=y /CONFIG_RTE_LIBRTE_KNI=n/g' $(CONFIG_FILE)
$(AT)touch $@
diff --git a/src/dpdk/dpdk.py b/src/dpdk/dpdk.py
index 9b3d1385..01e1fb61 100644
--- a/src/dpdk/dpdk.py
+++ b/src/dpdk/dpdk.py
@@ -27,11 +27,14 @@ import locale
from tools import tasks
from conf import settings
+from tools.module_manager import ModuleManager, KernelModuleInsertMode
_LOGGER = logging.getLogger(__name__)
RTE_PCI_TOOL = os.path.join(
settings.getValue('RTE_SDK'), 'tools', 'dpdk_nic_bind.py')
+_DPDK_MODULE_MANAGER = ModuleManager(KernelModuleInsertMode.MODPROBE)
+
#
# system management
#
@@ -192,16 +195,8 @@ def _is_module_inserted(module):
def _insert_modules():
"""Ensure required modules are inserted on system.
"""
- for module in settings.getValue('SYS_MODULES'):
- if _is_module_inserted(module):
- continue
- try:
- tasks.run_task(['sudo', 'modprobe', module], _LOGGER,
- 'Inserting module \'%s\'...' % module, True)
- except subprocess.CalledProcessError:
- _LOGGER.error('Unable to insert module \'%s\'.', module)
- raise # fail catastrophically
+ _DPDK_MODULE_MANAGER.insert_modules(settings.getValue('SYS_MODULES'))
mod_path_prefix = settings.getValue('OVS_DIR')
_insert_module_group('OVS_MODULES', mod_path_prefix)
@@ -237,18 +232,7 @@ def _remove_modules():
_remove_module_group('OVS_MODULES')
_remove_module_group('DPDK_MODULES')
- for module in settings.getValue('SYS_MODULES'):
- # first check if module is loaded
- if not _is_module_inserted(module):
- continue
-
- try:
- tasks.run_task(['sudo', 'rmmod', module], _LOGGER,
- 'Removing module \'%s\'...' % module, True)
- except subprocess.CalledProcessError:
- _LOGGER.error('Unable to remove module \'%s\'.', module)
- continue
-
+ _DPDK_MODULE_MANAGER.remove_modules()
def _remove_module_group(module_group):
"""Ensure all modules in a group are removed from the system.
diff --git a/src/ovs/Makefile b/src/ovs/Makefile
index 68ac0f6d..223d2dcb 100755
--- a/src/ovs/Makefile
+++ b/src/ovs/Makefile
@@ -22,11 +22,26 @@
include ../mk/master.mk
include ../package-list.mk
+WORK_DIR = ovs
+TAG_DONE_FLAG = $(WORK_DIR)/.$(OVS_TAG).done
+CONFIG_CMD =
+CONFIG_CMD += ./configure
+
+# If WITH_LINUX is defined, OVS is built without DPDK but with kernel
+# module
+# By default, OVS is built with DPDK
+
+# WITH_LINUX is the Linux kernel build directory used for building
+# OVS kernel module as documented in OVS --with-linux switch
+ifneq ($(WITH_LINUX),) # Building with Linux kernel
+CONFIG_CMD += --with-linux=$(WITH_LINUX)
+
+else # Building with DPDK
+
# DPDK_DIR is the top directory for dpdk source tree
# it can be passed in from Makefile command
# if it is not set, try to read it in from environment
# if it is still not set, then set it using relative path
-
DPDK_DIR ?= $(shell echo $$DPDK_DIR)
ifeq ($(DPDK_DIR),)
DPDK_DIR = ../../dpdk/dpdk
@@ -35,20 +50,15 @@ endif
ifeq ($(DPDK_TARGET),)
DPDK_TARGET = x86_64-native-linuxapp-gcc
endif
+CONFIG_CMD += --with-dpdk=$(DPDK_DIR)/$(DPDK_TARGET)
+endif # Kernel vs. DPDK
.PHONY: install force_install config force_make
# install depends on make
force_install: force_make
-WORK_DIR = ovs
-TAG_DONE_FLAG = $(WORK_DIR)/.$(OVS_TAG).done
-CONFIG_CMD =
-CONFIG_CMD += ./configure
-CONFIG_CMD += --with-dpdk=$(DPDK_DIR)/$(DPDK_TARGET)
-
-
all: force_make
@echo "Finished making $(WORK_DIR) "
diff --git a/src/ovs/daemon.py b/src/ovs/daemon.py
index 323644c6..db096353 100644
--- a/src/ovs/daemon.py
+++ b/src/ovs/daemon.py
@@ -44,12 +44,12 @@ class VSwitchd(tasks.Process):
"""
_ovsdb_pid = None
_logfile = _LOG_FILE_VSWITCHD
+ _ovsdb_pidfile_path = os.path.join(settings.getValue('LOG_DIR'),
+ "ovsdb_pidfile.pid")
-
- _expect = r'EAL: Master l*core \d+ is ready'
_proc_name = 'ovs-vswitchd'
- def __init__(self, timeout=30, vswitchd_args=None):
+ def __init__(self, timeout=30, vswitchd_args=None, expected_cmd=None):
"""Initialise the wrapper with a specific start timeout and extra
parameters.
@@ -60,8 +60,8 @@ class VSwitchd(tasks.Process):
"""
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
@@ -72,6 +72,7 @@ class VSwitchd(tasks.Process):
:returns: None
:raises: pexpect.EOF, pexpect.TIMEOUT
"""
+
self._reset_ovsdb()
self._start_ovsdb() # this has to be started first
@@ -79,6 +80,7 @@ class VSwitchd(tasks.Process):
super(VSwitchd, self).start()
self.relinquish()
except (pexpect.EOF, pexpect.TIMEOUT) as exc:
+ logging.error("Exception during VSwitch start.")
self._kill_ovsdb()
raise exc
@@ -125,10 +127,11 @@ class VSwitchd(tasks.Process):
self._logger,
'Creating ovsdb configuration database...')
- self._ovsdb_pid = tasks.run_background_task(
+ 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'],
+ '--remote=db:Open_vSwitch,Open_vSwitch,manager_options',
+ '--pidfile=' + self._ovsdb_pidfile_path , '--overwrite-pidfile'],
self._logger,
'Starting ovsdb-server...')
@@ -137,6 +140,19 @@ class VSwitchd(tasks.Process):
:returns: None
"""
- if self._ovsdb_pid:
- tasks.run_task(['sudo', 'kill', '-15', str(self._ovsdb_pid)],
+ 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 getDbSockPath():
+ """Method returns location of db.sock file
+
+ :returns: path to db.sock file.
+ """
+ return os.path.join(_OVS_VAR_DIR, 'db.sock')