@ -704,6 +704,8 @@ class TestIfcfgNetConfig(base.TestCase):
return " 0000:00:09.0 "
if ' em3 ' in ifname :
return " 0000:00:03.0 "
if ' em2 ' in ifname :
return " 0000:00:02.0 "
if ' em1 ' in ifname :
return " 0000:00:01.0 "
@ -1767,6 +1769,67 @@ OVS_EXTRA="set Interface $DEVICE options:dpdk-devargs=0000:00:09.0"
self . provider . bridge_data [ ' br-link ' ] )
self . assertEqual ( dpdk0_config , self . get_interface_config ( ' dpdk0 ' ) )
def test_network_ovs_mellanox_dpdk_bridge_and_port ( self ) :
nic_mapping = { ' nic1 ' : ' em1 ' , ' nic2 ' : ' em2 ' , ' nic3 ' : ' em3 ' }
self . stubbed_mapped_nics = nic_mapping
def stub_vendor_id_mellanox ( ifname ) :
return True
self . stub_out ( ' os_net_config.utils.is_mellanox_interface ' ,
stub_vendor_id_mellanox )
interface = objects . Interface ( name = ' nic1 ' )
dpdk_port = objects . OvsDpdkPort ( name = ' dpdk-link1-port ' ,
members = [ interface ] ,
driver = ' mlx5_core ' )
bridge = objects . OvsUserBridge ( ' br-link1 ' , members = [ dpdk_port ] )
def test_bind_dpdk_interfaces ( ifname , driver , noop ) :
self . assertEqual ( ifname , ' em1 ' )
self . assertEqual ( driver , ' mlx5_core ' )
self . stub_out ( ' os_net_config.utils.bind_dpdk_interfaces ' ,
test_bind_dpdk_interfaces )
self . stub_out ( ' os_net_config.utils.get_stored_pci_address ' ,
self . stub_get_stored_pci_address )
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 - link1
ONBOOT = yes
HOTPLUG = no
NM_CONTROLLED = no
PEERDNS = no
DEVICETYPE = ovs
TYPE = OVSUserBridge
"""
dpdk0_config = """ # This file is autogenerated by os-net-config
DEVICE = dpdk - link1 - port
ONBOOT = yes
HOTPLUG = no
NM_CONTROLLED = no
PEERDNS = no
DEVICETYPE = ovs
TYPE = OVSDPDKPort
OVS_BRIDGE = br - link1
OVS_EXTRA = " set Interface $DEVICE options:dpdk-devargs=0000:00:01.0 "
"""
self . assertEqual ( br_link_config ,
self . provider . bridge_data [ ' br-link1 ' ] )
self . assertEqual ( dpdk0_config ,
self . get_interface_config ( ' dpdk-link1-port ' ) )
if_config = """ # This file is autogenerated by os-net-config
DEVICE = em1
ONBOOT = yes
HOTPLUG = no
NM_CONTROLLED = no
PEERDNS = no
BOOTPROTO = none
"""
self . assertEqual ( if_config ,
self . get_interface_config ( ' em1 ' ) )
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
@ -1852,6 +1915,72 @@ OVS_EXTRA="set Interface dpdk0 options:dpdk-devargs=0000:00:08.0 \
self . assertEqual ( dpdk_bond_config ,
self . get_interface_config ( ' dpdkbond0 ' ) )
def test_network_ovs_mellanox_dpdk_bond ( self ) :
nic_mapping = { ' nic1 ' : ' em1 ' , ' nic2 ' : ' em2 ' , ' nic3 ' : ' em3 ' }
self . stubbed_mapped_nics = nic_mapping
def stub_vendor_id_mellanox ( ifname ) :
return True
self . stub_out ( ' os_net_config.utils.is_mellanox_interface ' ,
stub_vendor_id_mellanox )
iface0 = objects . Interface ( name = ' nic1 ' )
dpdk0 = objects . OvsDpdkPort ( name = ' dpdk0 ' ,
members = [ iface0 ] , driver = ' mlx5_core ' )
iface1 = objects . Interface ( name = ' nic2 ' )
dpdk1 = objects . OvsDpdkPort ( name = ' dpdk1 ' ,
members = [ iface1 ] , driver = ' mlx5_core ' )
bond = objects . OvsDpdkBond ( ' dpdkbond0 ' , members = [ dpdk0 , dpdk1 ] )
bridge = objects . OvsUserBridge ( ' br-link ' , members = [ bond ] )
def test_bind_dpdk_interfaces ( ifname , driver , noop ) :
self . assertIn ( ifname , [ ' em1 ' , ' em2 ' ] )
self . assertEqual ( driver , ' mlx5_core ' )
self . stub_out ( ' os_net_config.utils.bind_dpdk_interfaces ' ,
test_bind_dpdk_interfaces )
self . stub_out ( ' os_net_config.utils.get_stored_pci_address ' ,
self . stub_get_stored_pci_address )
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 "
OVS_EXTRA = " set Interface dpdk0 options:dpdk-devargs=0000:00:01.0 \
- - set Interface dpdk1 options : dpdk - devargs = 0000 : 00 : 02.0 "
"""
self . assertEqual ( dpdk_bond_config ,
self . get_interface_config ( ' dpdkbond0 ' ) )
if_cfg1 = """ # This file is autogenerated by os-net-config
DEVICE = em1
ONBOOT = yes
HOTPLUG = no
NM_CONTROLLED = no
PEERDNS = no
BOOTPROTO = none
"""
if_cfg2 = """ # This file is autogenerated by os-net-config
DEVICE = em2
ONBOOT = yes
HOTPLUG = no
NM_CONTROLLED = no
PEERDNS = no
BOOTPROTO = none
"""
self . assertEqual ( if_cfg1 ,
self . get_interface_config ( ' em1 ' ) )
self . assertEqual ( if_cfg2 ,
self . get_interface_config ( ' em2 ' ) )
def test_network_ovs_dpdk_bond_with_mtu ( self ) :
nic_mapping = { ' nic1 ' : ' eth0 ' , ' nic2 ' : ' eth1 ' , ' nic3 ' : ' eth2 ' }
self . stubbed_mapped_nics = nic_mapping