summaryrefslogtreecommitdiffstats
path: root/vswitches/ovs_dpdk_vhost.py
diff options
context:
space:
mode:
Diffstat (limited to 'vswitches/ovs_dpdk_vhost.py')
-rw-r--r--vswitches/ovs_dpdk_vhost.py57
1 files changed, 48 insertions, 9 deletions
diff --git a/vswitches/ovs_dpdk_vhost.py b/vswitches/ovs_dpdk_vhost.py
index 9d29c9d1..2d424bc5 100644
--- a/vswitches/ovs_dpdk_vhost.py
+++ b/vswitches/ovs_dpdk_vhost.py
@@ -16,10 +16,13 @@
"""
import logging
+import subprocess
+import os
+
+from src.ovs import OFBridge
+from src.dpdk import dpdk
from conf import settings
from vswitches.ovs import IVSwitchOvs
-from src.ovs import VSwitchd
-from src.dpdk import dpdk
class OvsDpdkVhost(IVSwitchOvs):
""" Open vSwitch with DPDK support
@@ -36,16 +39,32 @@ class OvsDpdkVhost(IVSwitchOvs):
def __init__(self):
super(OvsDpdkVhost, self).__init__()
self._logger = logging.getLogger(__name__)
+ self._expect = r'EAL: Master l*core \d+ is ready'
+
+ vswitchd_args = []
+
+ # legacy DPDK configuration through --dpdk option of vswitchd
+ if self.old_dpdk_config():
+ vswitchd_args = ['--dpdk'] + settings.getValue('VSWITCHD_DPDK_ARGS')
+ if self._vswitchd_args:
+ self._vswitchd_args = vswitchd_args + ['--'] + self._vswitchd_args
+ else:
+ self._vswitchd_args = vswitchd_args
- self._vswitchd_args = ['--dpdk']
- self._vswitchd_args += settings.getValue('VSWITCHD_DPDK_ARGS')
if settings.getValue('VNF').endswith('Cuse'):
self._logger.info("Inserting VHOST Cuse modules into kernel...")
dpdk.insert_vhost_modules()
- self._vswitchd = VSwitchd(vswitchd_args=self._vswitchd_args,
- expected_cmd=
- r'EAL: Master l*core \d+ is ready')
+ def configure(self):
+ """ Configure vswitchd DPDK options through ovsdb if needed
+ """
+ dpdk_config = settings.getValue('VSWITCHD_DPDK_CONFIG')
+ if dpdk_config and not self.old_dpdk_config():
+ # enforce calls to ovs-vsctl with --no-wait
+ tmp_br = OFBridge(timeout=-1)
+ for option in dpdk_config:
+ tmp_br.set_db_attribute('Open_vSwitch', '.',
+ 'other_config:' + option, dpdk_config[option])
def start(self):
"""See IVswitch for general description
@@ -90,8 +109,11 @@ class OvsDpdkVhost(IVSwitchOvs):
dpdk_count = self._get_port_count('type=dpdk')
port_name = 'dpdk' + str(dpdk_count)
params = ['--', 'set', 'Interface', port_name, 'type=dpdk']
+ # multi-queue enable
+ if int(settings.getValue('VSWITCH_MULTI_QUEUES')):
+ params += ['options:n_rxq={}'.format(
+ settings.getValue('VSWITCH_MULTI_QUEUES'))]
of_port = bridge.add_port(port_name, params)
-
return (port_name, of_port)
def add_vport(self, switch_name):
@@ -111,7 +133,24 @@ class OvsDpdkVhost(IVSwitchOvs):
vhost_count = self._get_port_count('type=dpdkvhostuser')
port_name = 'dpdkvhostuser' + str(vhost_count)
params = ['--', 'set', 'Interface', port_name, 'type=dpdkvhostuser']
-
+ # multi queue enable
+ if int(settings.getValue('VSWITCH_MULTI_QUEUES')):
+ params += ['options:n_rxq={}'.format(
+ settings.getValue('VSWITCH_MULTI_QUEUES'))]
of_port = bridge.add_port(port_name, params)
return (port_name, of_port)
+
+ @staticmethod
+ def old_dpdk_config():
+ """Checks if ovs-vswitchd uses legacy dpdk configuration via --dpdk option
+
+ :returns: True if legacy --dpdk option is supported, otherwise it returns False
+ """
+
+ ovs_vswitchd_bin = os.path.join(settings.getValue('OVS_DIR'), 'vswitchd', 'ovs-vswitchd')
+ try:
+ subprocess.check_output(ovs_vswitchd_bin + r' --help | grep "\-\-dpdk"', shell=True)
+ return True
+ except subprocess.CalledProcessError:
+ return False