From cc7ff987cae3452a28f85ca3cabef49a3a64a2ff Mon Sep 17 00:00:00 2001 From: Karthik S Date: Tue, 30 May 2017 07:21:52 -0400 Subject: MTU setting for OVSDpdkBond This patch allows the MTU setting for DPDK bonds. In case of DPDK bonds, the MTU setting needs to be done for each of the interfaces attached to the bond. Change-Id: Ida627313d14a674430b2aff3644fd62b2e0bcab7 Implements: blueprint ovs-2-6-features-dpdk Signed-off-by: Karthik S --- etc/os-net-config/samples/ovs_dpdk_bond.json | 1 + etc/os-net-config/samples/ovs_dpdk_bond.yaml | 2 ++ os_net_config/impl_ifcfg.py | 6 +++++ os_net_config/tests/test_impl_ifcfg.py | 38 ++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+) diff --git a/etc/os-net-config/samples/ovs_dpdk_bond.json b/etc/os-net-config/samples/ovs_dpdk_bond.json index 7964e69..a921d60 100644 --- a/etc/os-net-config/samples/ovs_dpdk_bond.json +++ b/etc/os-net-config/samples/ovs_dpdk_bond.json @@ -6,6 +6,7 @@ { "type" : "ovs_dpdk_bond", "name" : "dpdkbond0", + "mtu" : 9000, "members": [ { "type" : "ovs_dpdk_port", diff --git a/etc/os-net-config/samples/ovs_dpdk_bond.yaml b/etc/os-net-config/samples/ovs_dpdk_bond.yaml index 2fcd4f3..3fc9f7d 100644 --- a/etc/os-net-config/samples/ovs_dpdk_bond.yaml +++ b/etc/os-net-config/samples/ovs_dpdk_bond.yaml @@ -13,6 +13,8 @@ network_config: - type: ovs_dpdk_bond name: dpdkbond0 + # MTU is optional, e.g. for jumbo frames + mtu: 9000 members: - type: ovs_dpdk_port diff --git a/os_net_config/impl_ifcfg.py b/os_net_config/impl_ifcfg.py index 6f35688..18de8fc 100644 --- a/os_net_config/impl_ifcfg.py +++ b/os_net_config/impl_ifcfg.py @@ -316,6 +316,12 @@ class IfcfgNetConfig(os_net_config.NetConfig): if base_opt.members: members = [member.name for member in base_opt.members] data += ("BOND_IFACES=\"%s\"\n" % " ".join(members)) + # MTU configuration given for the OvsDpdkbond shall be applied + # to each of the members of the OvsDpdkbond + if base_opt.mtu: + for member in base_opt.members: + ovs_extra.append("set Interface %s mtu_request=$MTU" % + member.name) if base_opt.ovs_options: data += "OVS_OPTIONS=\"%s\"\n" % base_opt.ovs_options ovs_extra.extend(base_opt.ovs_extra) diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py index 9ff2bd6..0e5eca2 100644 --- a/os_net_config/tests/test_impl_ifcfg.py +++ b/os_net_config/tests/test_impl_ifcfg.py @@ -952,6 +952,44 @@ DEVICETYPE=ovs TYPE=OVSDPDKBond OVS_BRIDGE=br-link BOND_IFACES="dpdk0 dpdk1" +""" + self.assertEqual(dpdk_bond_config, + self.get_interface_config('dpdkbond0')) + + def test_network_ovs_dpdk_bond_with_mtu(self): + nic_mapping = {'nic1': 'eth0', 'nic2': 'eth1', 'nic3': 'eth2'} + self.stubbed_mapped_nics = nic_mapping + + iface0 = objects.Interface(name='nic2') + dpdk0 = objects.OvsDpdkPort(name='dpdk0', members=[iface0]) + iface1 = objects.Interface(name='nic3') + dpdk1 = objects.OvsDpdkPort(name='dpdk1', members=[iface1]) + bond = objects.OvsDpdkBond('dpdkbond0', mtu=9000, + members=[dpdk0, dpdk1]) + bridge = objects.OvsUserBridge('br-link', members=[bond]) + + def test_bind_dpdk_interfaces(ifname, driver, noop): + self.assertIn(ifname, ['eth1', 'eth2']) + self.assertEqual(driver, 'vfio-pci') + self.stubs.Set(utils, 'bind_dpdk_interfaces', + test_bind_dpdk_interfaces) + + self.provider.add_ovs_dpdk_bond(bond) + self.provider.add_ovs_user_bridge(bridge) + + dpdk_bond_config = """# This file is autogenerated by os-net-config +DEVICE=dpdkbond0 +ONBOOT=yes +HOTPLUG=no +NM_CONTROLLED=no +PEERDNS=no +DEVICETYPE=ovs +TYPE=OVSDPDKBond +OVS_BRIDGE=br-link +BOND_IFACES="dpdk0 dpdk1" +MTU=9000 +OVS_EXTRA="set Interface dpdk0 mtu_request=$MTU \ +-- set Interface dpdk1 mtu_request=$MTU" """ self.assertEqual(dpdk_bond_config, self.get_interface_config('dpdkbond0')) -- cgit 1.2.3-korg