From 2aa95a88109a96e24ea4329364a2ecc07fe575fd Mon Sep 17 00:00:00 2001 From: Sanjay Upadhyay Date: Mon, 22 May 2017 16:41:09 +0530 Subject: 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 implements: blueprint ovs-2-6-features-dpdk --- etc/os-net-config/samples/ovs_dpdk.json | 1 + etc/os-net-config/samples/ovs_dpdk.yaml | 6 +++++ os_net_config/impl_ifcfg.py | 4 +++ os_net_config/objects.py | 8 ++++-- os_net_config/tests/test_impl_ifcfg.py | 45 +++++++++++++++++++++++++++++++-- 5 files changed, 60 insertions(+), 4 deletions(-) diff --git a/etc/os-net-config/samples/ovs_dpdk.json b/etc/os-net-config/samples/ovs_dpdk.json index 37b79e0..5c84044 100644 --- a/etc/os-net-config/samples/ovs_dpdk.json +++ b/etc/os-net-config/samples/ovs_dpdk.json @@ -8,6 +8,7 @@ "name": "dpdk0", "driver": "igb_uio", "mtu": 8192, + "rx_queue": 4, "members": [ { "type": "interface", diff --git a/etc/os-net-config/samples/ovs_dpdk.yaml b/etc/os-net-config/samples/ovs_dpdk.yaml index 47fd3ab..81aa212 100644 --- a/etc/os-net-config/samples/ovs_dpdk.yaml +++ b/etc/os-net-config/samples/ovs_dpdk.yaml @@ -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 diff --git a/os_net_config/impl_ifcfg.py b/os_net_config/impl_ifcfg.py index 6f35688..4658b93 100644 --- a/os_net_config/impl_ifcfg.py +++ b/os_net_config/impl_ifcfg.py @@ -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, diff --git a/os_net_config/objects.py b/os_net_config/objects.py index 5bdbb9c..f7d5116 100644 --- a/os_net_config/objects.py +++ b/os_net_config/objects.py @@ -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): diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py index 9ff2bd6..92e14d3 100644 --- a/os_net_config/tests/test_impl_ifcfg.py +++ b/os_net_config/tests/test_impl_ifcfg.py @@ -884,9 +884,48 @@ DNS2=5.6.7.8 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]) + 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 +""" + 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) + mtu=9000, rx_queue=4) bridge = objects.OvsUserBridge('br-link', members=[dpdk_port]) def test_bind_dpdk_interfaces(ifname, driver, noop): @@ -915,8 +954,10 @@ 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']) -- cgit 1.2.3-korg