From 4a431f75a01fbdd0b802c86e27a93a6daaf70399 Mon Sep 17 00:00:00 2001 From: Nikola Dipanov Date: Wed, 30 Dec 2015 19:48:33 +0000 Subject: [PATCH] sriov-mech: Introduce a new VIF type for PF vnic type We need to tell Nova to use a specific VIF type for full PF passthrough (this is the recently added VNIC_DIRECT_PHYSICAL vnic type). Make sure that when binding ports with this vnic type, we set the appropriate vif type for Nova to be able to provision those ports correctly. Nova change that adds a vif driver for this vif type: https://review.openstack.org/#/c/262583/ DocImpact: Exposes a new vif type for PF passtrhough vnic type Change-Id: I895dab98e5e5a9369771539e51ba5c500bfe0045 Related-blueprint: sriov-pf-passthrough-neutron-port --- .../mech_sriov/mech_driver/mech_driver.py | 22 ++++++++++++------- .../mech_driver/test_mech_sriov_nic_switch.py | 2 +- ...e-for-pf-passthrough-33ec560b9b5d246f.yaml | 6 +++++ 3 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 releasenotes/notes/new-vif-type-for-pf-passthrough-33ec560b9b5d246f.yaml diff --git a/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py b/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py index 9204cc99501..0be2ceda902 100644 --- a/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py +++ b/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. - from oslo_config import cfg from oslo_log import log @@ -29,6 +28,7 @@ from neutron.services.qos import qos_consts LOG = log.getLogger(__name__) VIF_TYPE_HW_VEB = 'hw_veb' +VIF_TYPE_HOSTDEV_PHY = 'hostdev_physical' FLAT_VLAN = 0 sriov_opts = [ @@ -60,7 +60,6 @@ class SriovNicSwitchMechanismDriver(api.MechanismDriver): def __init__(self, agent_type=constants.AGENT_TYPE_NIC_SWITCH, - vif_type=VIF_TYPE_HW_VEB, vif_details={portbindings.CAP_PORT_FILTER: False}, supported_vnic_types=[portbindings.VNIC_DIRECT, portbindings.VNIC_MACVTAP, @@ -69,14 +68,18 @@ class SriovNicSwitchMechanismDriver(api.MechanismDriver): """Initialize base class for SriovNicSwitch L2 agent type. :param agent_type: Constant identifying agent type in agents_db - :param vif_type: Value for binding:vif_type when bound :param vif_details: Dictionary with details for VIF driver when bound :param supported_vnic_types: The binding:vnic_type values we can bind :param supported_pci_vendor_info: The pci_vendor_info values to bind """ self.agent_type = agent_type self.supported_vnic_types = supported_vnic_types - self.vif_type = vif_type + # NOTE(ndipanov): PF passthrough requires a different vif type + self.vnic_type_for_vif_type = ( + {vtype: VIF_TYPE_HOSTDEV_PHY + if vtype == portbindings.VNIC_DIRECT_PHYSICAL + else VIF_TYPE_HW_VEB + for vtype in self.supported_vnic_types}) self.vif_details = vif_details self.supported_network_types = (p_const.TYPE_VLAN, p_const.TYPE_FLAT) @@ -100,6 +103,9 @@ class SriovNicSwitchMechanismDriver(api.MechanismDriver): vnic_type) return + vif_type = self.vnic_type_for_vif_type.get(vnic_type, + VIF_TYPE_HW_VEB) + if not self._check_supported_pci_vendor_device(context): LOG.debug("Refusing to bind due to unsupported pci_vendor device") return @@ -112,25 +118,25 @@ class SriovNicSwitchMechanismDriver(api.MechanismDriver): # either. This should be changed in the future so physical # functions can use device mapping checks and the plugin can # get port status updates. - self.try_to_bind(context, None) + self.try_to_bind(context, None, vif_type) return for agent in context.host_agents(self.agent_type): LOG.debug("Checking agent: %s", agent) if agent['alive']: - if self.try_to_bind(context, agent): + if self.try_to_bind(context, agent, vif_type): return else: LOG.warning(_LW("Attempting to bind with dead agent: %s"), agent) - def try_to_bind(self, context, agent): + def try_to_bind(self, context, agent, vif_type): for segment in context.segments_to_bind: if self.check_segment(segment, agent): port_status = (constants.PORT_STATUS_ACTIVE if agent is None else constants.PORT_STATUS_DOWN) context.set_binding(segment[api.ID], - self.vif_type, + vif_type, self._get_vif_details(segment), port_status) LOG.debug("Bound using segment: %s", segment) diff --git a/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/mech_driver/test_mech_sriov_nic_switch.py b/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/mech_driver/test_mech_sriov_nic_switch.py index c69e0a47196..310e8cc393f 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/mech_driver/test_mech_sriov_nic_switch.py +++ b/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/mech_driver/test_mech_sriov_nic_switch.py @@ -150,7 +150,7 @@ class SriovSwitchMechVnicTypeTestCase(SriovNicSwitchMechanismBaseTestCase): def test_vnic_type_direct_physical(self): self._check_vif_type_for_vnic_type(portbindings.VNIC_DIRECT_PHYSICAL, - mech_driver.VIF_TYPE_HW_VEB) + mech_driver.VIF_TYPE_HOSTDEV_PHY) class SriovSwitchMechProfileTestCase(SriovNicSwitchMechanismBaseTestCase): diff --git a/releasenotes/notes/new-vif-type-for-pf-passthrough-33ec560b9b5d246f.yaml b/releasenotes/notes/new-vif-type-for-pf-passthrough-33ec560b9b5d246f.yaml new file mode 100644 index 00000000000..b11c89b4fa1 --- /dev/null +++ b/releasenotes/notes/new-vif-type-for-pf-passthrough-33ec560b9b5d246f.yaml @@ -0,0 +1,6 @@ +--- +features: + - SriovNicSwitchMechanismDriver driver now exposes a new VIF type + 'hostdev_physical' for ports with vnic type 'direct-physical' (used for + SR-IOV PF passthrough). This will enable Nova to provision PFs as Neutron + ports.