Configure multi-queue value for DPDK Port

The multi-queue option for DPDK is applied via ovs-vsctl command
via ovs_extra params. This patch adds support for configuring the
rx_queue (multi-queue) value to the DPDK Ports.

Change-Id: Ib9faad5e9d49f78e3a0b45ef3ae0082f3e9d14a6
Co-Authored-By: Karthik S <ksundara@redhat.com>
implements: blueprint ovs-2-6-features-dpdk
This commit is contained in:
Sanjay Upadhyay 2017-05-22 16:41:09 +05:30
parent e7e81ac011
commit 2aa95a8810
5 changed files with 61 additions and 5 deletions

View File

@ -8,6 +8,7 @@
"name": "dpdk0",
"driver": "igb_uio",
"mtu": 8192,
"rx_queue": 4,
"members": [
{
"type": "interface",

View File

@ -16,6 +16,12 @@ network_config:
driver: igb_uio
# MTU is optional, used for jumbo frames
mtu: 8192
# rx_queue is optional, used for multi-queue option. It configures the
# maximum number of queues for a physical interface. If not defined,
# the physical interface will have single queue. The number of queues
# should be less than the PMD cores as each queue will have one PMD
# thread (CPU) associated with it.
rx_queue: 4
members:
- type: interface
name: nic2

View File

@ -301,6 +301,10 @@ class IfcfgNetConfig(os_net_config.NetConfig):
data += "OVS_BRIDGE=%s\n" % base_opt.bridge_name
if base_opt.mtu:
ovs_extra.append("set Interface $DEVICE mtu_request=$MTU")
if base_opt.rx_queue:
data += "RX_QUEUE=%i\n" % base_opt.rx_queue
ovs_extra.append("set Interface $DEVICE " +
"options:n_rxq=$RX_QUEUE")
elif isinstance(base_opt, objects.OvsDpdkBond):
ovs_extra.extend(base_opt.ovs_extra)
# Referring to bug:1643026, the below commenting of the interfaces,

View File

@ -1025,7 +1025,8 @@ class OvsDpdkPort(_BaseOpts):
routes=None, mtu=None, primary=False, nic_mapping=None,
persist_mapping=False, defroute=True, dhclient_args=None,
dns_servers=None, nm_controlled=False, members=None,
driver='vfio-pci', ovs_options=None, ovs_extra=None):
driver='vfio-pci', ovs_options=None, ovs_extra=None,
rx_queue=None):
super(OvsDpdkPort, self).__init__(name, use_dhcp, use_dhcpv6,
addresses, routes, mtu, primary,
@ -1036,6 +1037,7 @@ class OvsDpdkPort(_BaseOpts):
self.ovs_options = ovs_options or []
self.ovs_extra = format_ovs_extra(self, ovs_extra)
self.driver = driver
self.rx_queue = rx_queue
@staticmethod
def from_json(json):
@ -1069,6 +1071,7 @@ class OvsDpdkPort(_BaseOpts):
msg = 'DPDK Port should have one member as Interface'
raise InvalidConfigException(msg)
rx_queue = json.get('rx_queue', None)
ovs_options = json.get('ovs_options', [])
ovs_options = ['options:%s' % opt for opt in ovs_options]
ovs_extra = json.get('ovs_extra', [])
@ -1076,7 +1079,8 @@ class OvsDpdkPort(_BaseOpts):
ovs_extra = [ovs_extra]
opts = _BaseOpts.base_opts_from_json(json)
return OvsDpdkPort(name, *opts, members=members, driver=driver,
ovs_options=ovs_options, ovs_extra=ovs_extra)
ovs_options=ovs_options, ovs_extra=ovs_extra,
rx_queue=rx_queue)
class OvsDpdkBond(_BaseOpts):

View File

@ -885,8 +885,7 @@ DNS2=5.6.7.8
self.stubbed_mapped_nics = nic_mapping
interface = objects.Interface(name='nic3')
dpdk_port = objects.OvsDpdkPort(name='dpdk0', members=[interface],
mtu=9000)
dpdk_port = objects.OvsDpdkPort(name='dpdk0', members=[interface])
bridge = objects.OvsUserBridge('br-link', members=[dpdk_port])
def test_bind_dpdk_interfaces(ifname, driver, noop):
@ -915,8 +914,50 @@ PEERDNS=no
DEVICETYPE=ovs
TYPE=OVSDPDKPort
OVS_BRIDGE=br-link
"""
self.assertEqual(br_link_config,
self.provider.bridge_data['br-link'])
self.assertEqual(dpdk0_config, self.get_interface_config('dpdk0'))
def test_network_ovs_dpdk_bridge_and_port_with_mtu_rxqueue(self):
nic_mapping = {'nic1': 'eth0', 'nic2': 'eth1', 'nic3': 'eth2'}
self.stubbed_mapped_nics = nic_mapping
interface = objects.Interface(name='nic3')
dpdk_port = objects.OvsDpdkPort(name='dpdk0', members=[interface],
mtu=9000, rx_queue=4)
bridge = objects.OvsUserBridge('br-link', members=[dpdk_port])
def test_bind_dpdk_interfaces(ifname, driver, noop):
self.assertEqual(ifname, 'eth2')
self.assertEqual(driver, 'vfio-pci')
self.stubs.Set(utils, 'bind_dpdk_interfaces',
test_bind_dpdk_interfaces)
self.provider.add_ovs_dpdk_port(dpdk_port)
self.provider.add_ovs_user_bridge(bridge)
br_link_config = """# This file is autogenerated by os-net-config
DEVICE=br-link
ONBOOT=yes
HOTPLUG=no
NM_CONTROLLED=no
PEERDNS=no
DEVICETYPE=ovs
TYPE=OVSUserBridge
"""
dpdk0_config = """# This file is autogenerated by os-net-config
DEVICE=dpdk0
ONBOOT=yes
HOTPLUG=no
NM_CONTROLLED=no
PEERDNS=no
DEVICETYPE=ovs
TYPE=OVSDPDKPort
OVS_BRIDGE=br-link
RX_QUEUE=4
MTU=9000
OVS_EXTRA="set Interface $DEVICE mtu_request=$MTU"
OVS_EXTRA="set Interface $DEVICE mtu_request=$MTU \
-- set Interface $DEVICE options:n_rxq=$RX_QUEUE"
"""
self.assertEqual(br_link_config,
self.provider.bridge_data['br-link'])