From 9b29f62491ec0e1cb27601e6ad53cf152de5eb66 Mon Sep 17 00:00:00 2001 From: Moshe Levi Date: Sun, 31 May 2015 13:27:56 +0300 Subject: [PATCH] Refactor mlnx mechanism driver to support infiniband only The old mlnx mechanism driver was used for SR-IOV with Ethernet and infiniband support but the PCI allocation wasn't done by nova. Juno introduced sriovnicswitch mechanism driver for SR-IOV with Ethernet support. Mellanox recommends on using it. The updated mlnx mechanism driver supports SR-IOV infiniband. * support only port vnic_type 'direct' * update vif_type name to ib_hostdev (the ib_hostdev is generic vif_type for SR-IOV infiniband see https://review.openstack.org/#/c/187052/) Closes-Bug: #1460430 DocImpact Change-Id: Ia822b492afdfeb1aecf373d5a8cdb72174512884 --- neutron/extensions/portbindings.py | 4 +-- neutron/plugins/ml2/drivers/mlnx/mech_mlnx.py | 11 ++------ .../unit/plugins/ml2/_test_mech_agent.py | 22 ++++++++++------ .../ml2/drivers/mlnx/test_mech_mlnx.py | 25 ++++--------------- 4 files changed, 24 insertions(+), 38 deletions(-) diff --git a/neutron/extensions/portbindings.py b/neutron/extensions/portbindings.py index 81dde03ffeb..63fca88ec09 100644 --- a/neutron/extensions/portbindings.py +++ b/neutron/extensions/portbindings.py @@ -59,14 +59,14 @@ VIF_TYPE_802_QBG = '802.1qbg' VIF_TYPE_802_QBH = '802.1qbh' VIF_TYPE_HYPERV = 'hyperv' VIF_TYPE_MIDONET = 'midonet' -VIF_TYPE_MLNX_HOSTDEV = 'hostdev' +VIF_TYPE_IB_HOSTDEV = 'ib_hostdev' VIF_TYPE_HW_VEB = 'hw_veb' VIF_TYPE_VROUTER = 'vrouter' VIF_TYPE_OTHER = 'other' VIF_TYPES = [VIF_TYPE_UNBOUND, VIF_TYPE_BINDING_FAILED, VIF_TYPE_OVS, VIF_TYPE_IVS, VIF_TYPE_BRIDGE, VIF_TYPE_802_QBG, VIF_TYPE_802_QBH, VIF_TYPE_HYPERV, VIF_TYPE_MIDONET, - VIF_TYPE_MLNX_HOSTDEV, VIF_TYPE_HW_VEB, + VIF_TYPE_IB_HOSTDEV, VIF_TYPE_HW_VEB, VIF_TYPE_DVS, VIF_TYPE_OTHER, VIF_TYPE_DISTRIBUTED, VIF_TYPE_VROUTER] diff --git a/neutron/plugins/ml2/drivers/mlnx/mech_mlnx.py b/neutron/plugins/ml2/drivers/mlnx/mech_mlnx.py index 6205b7fcd0b..9484a61e870 100644 --- a/neutron/plugins/ml2/drivers/mlnx/mech_mlnx.py +++ b/neutron/plugins/ml2/drivers/mlnx/mech_mlnx.py @@ -36,18 +36,11 @@ class MlnxMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase): """ def __init__(self): - # REVISIT(irenab): update supported_vnic_types to contain - # only VNIC_DIRECT once its possible to specify - # vnic_type via nova API/GUI. Currently VNIC_NORMAL is included - # to enable VM creation via GUI. It should be noted, that if - # several MDs are capable to bring bind port on chosen host, the - # first listed MD will bind the port for VNIC_NORMAL super(MlnxMechanismDriver, self).__init__( agent_type=n_const.AGENT_TYPE_MLNX, - vif_type=portbindings.VIF_TYPE_MLNX_HOSTDEV, + vif_type=portbindings.VIF_TYPE_IB_HOSTDEV, vif_details={portbindings.CAP_PORT_FILTER: False}, - supported_vnic_types=[portbindings.VNIC_DIRECT, - portbindings.VNIC_NORMAL]) + supported_vnic_types=[portbindings.VNIC_DIRECT]) def get_allowed_network_types(self, agent=None): return [p_constants.TYPE_LOCAL, p_constants.TYPE_FLAT, diff --git a/neutron/tests/unit/plugins/ml2/_test_mech_agent.py b/neutron/tests/unit/plugins/ml2/_test_mech_agent.py index c69d837f9b9..c6186c4a92b 100644 --- a/neutron/tests/unit/plugins/ml2/_test_mech_agent.py +++ b/neutron/tests/unit/plugins/ml2/_test_mech_agent.py @@ -146,6 +146,7 @@ class AgentMechanismBaseTestCase(base.BaseTestCase): AGENTS = None AGENTS_DEAD = None AGENTS_BAD = None + VNIC_TYPE = portbindings.VNIC_NORMAL def _check_unbound(self, context): self.assertIsNone(context._bound_segment_id) @@ -177,7 +178,8 @@ class AgentMechanismGenericTestCase(AgentMechanismBaseTestCase): def test_unknown_type(self): context = FakePortContext(self.AGENT_TYPE, self.AGENTS, - self.UNKNOWN_TYPE_SEGMENTS) + self.UNKNOWN_TYPE_SEGMENTS, + vnic_type=self.VNIC_TYPE) self.driver.bind_port(context) self._check_unbound(context) @@ -191,14 +193,16 @@ class AgentMechanismLocalTestCase(AgentMechanismBaseTestCase): def test_type_local(self): context = FakePortContext(self.AGENT_TYPE, self.AGENTS, - self.LOCAL_SEGMENTS) + self.LOCAL_SEGMENTS, + vnic_type=self.VNIC_TYPE) self.driver.bind_port(context) self._check_bound(context, self.LOCAL_SEGMENTS[1]) def test_type_local_dead(self): context = FakePortContext(self.AGENT_TYPE, self.AGENTS_DEAD, - self.LOCAL_SEGMENTS) + self.LOCAL_SEGMENTS, + vnic_type=self.VNIC_TYPE) self.driver.bind_port(context) self._check_unbound(context) @@ -213,14 +217,16 @@ class AgentMechanismFlatTestCase(AgentMechanismBaseTestCase): def test_type_flat(self): context = FakePortContext(self.AGENT_TYPE, self.AGENTS, - self.FLAT_SEGMENTS) + self.FLAT_SEGMENTS, + vnic_type=self.VNIC_TYPE) self.driver.bind_port(context) self._check_bound(context, self.FLAT_SEGMENTS[1]) def test_type_flat_bad(self): context = FakePortContext(self.AGENT_TYPE, self.AGENTS_BAD, - self.FLAT_SEGMENTS) + self.FLAT_SEGMENTS, + vnic_type=self.VNIC_TYPE) self.driver.bind_port(context) self._check_unbound(context) @@ -236,14 +242,16 @@ class AgentMechanismVlanTestCase(AgentMechanismBaseTestCase): def test_type_vlan(self): context = FakePortContext(self.AGENT_TYPE, self.AGENTS, - self.VLAN_SEGMENTS) + self.VLAN_SEGMENTS, + vnic_type=self.VNIC_TYPE) self.driver.bind_port(context) self._check_bound(context, self.VLAN_SEGMENTS[1]) def test_type_vlan_bad(self): context = FakePortContext(self.AGENT_TYPE, self.AGENTS_BAD, - self.VLAN_SEGMENTS) + self.VLAN_SEGMENTS, + vnic_type=self.VNIC_TYPE) self.driver.bind_port(context) self._check_unbound(context) diff --git a/neutron/tests/unit/plugins/ml2/drivers/mlnx/test_mech_mlnx.py b/neutron/tests/unit/plugins/ml2/drivers/mlnx/test_mech_mlnx.py index 4aee7a4cb56..1237b8444bb 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/mlnx/test_mech_mlnx.py +++ b/neutron/tests/unit/plugins/ml2/drivers/mlnx/test_mech_mlnx.py @@ -33,9 +33,10 @@ with mock.patch.dict(sys.modules, class MlnxMechanismBaseTestCase(base.AgentMechanismBaseTestCase): - VIF_TYPE = portbindings.VIF_TYPE_MLNX_HOSTDEV + VIF_TYPE = portbindings.VIF_TYPE_IB_HOSTDEV CAP_PORT_FILTER = False AGENT_TYPE = constants.AGENT_TYPE_MLNX + VNIC_TYPE = portbindings.VNIC_DIRECT GOOD_MAPPINGS = {'fake_physical_network': 'fake_bridge'} GOOD_CONFIGS = {'interface_mappings': GOOD_MAPPINGS} @@ -77,25 +78,9 @@ class MlnxMechanismFlatTestCase(MlnxMechanismBaseTestCase, pass -class MlnxMechanismVnicTypeTestCase(MlnxMechanismBaseTestCase, - base.AgentMechanismVlanTestCase): - - def _check_vif_type_for_vnic_type(self, vnic_type, - expected_vif_type): - context = base.FakePortContext(self.AGENT_TYPE, - self.AGENTS, - self.VLAN_SEGMENTS, - vnic_type) - self.driver.bind_port(context) - self.assertEqual(expected_vif_type, context._bound_vif_type) - - def test_vnic_type_direct(self): - self._check_vif_type_for_vnic_type(portbindings.VNIC_DIRECT, - portbindings.VIF_TYPE_MLNX_HOSTDEV) - - def test_vnic_type_normal(self): - self._check_vif_type_for_vnic_type(portbindings.VNIC_NORMAL, - self.VIF_TYPE) +class MlnxMechanismVlanTestCase(MlnxMechanismBaseTestCase, + base.AgentMechanismVlanTestCase): + pass class MlnxMechanismVifDetailsTestCase(MlnxMechanismBaseTestCase):