diff --git a/neutron/plugins/ml2/drivers/openvswitch/mech_driver/mech_openvswitch.py b/neutron/plugins/ml2/drivers/openvswitch/mech_driver/mech_openvswitch.py index 30ef4c8e882..afacb7da7e1 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/mech_driver/mech_openvswitch.py +++ b/neutron/plugins/ml2/drivers/openvswitch/mech_driver/mech_openvswitch.py @@ -50,10 +50,16 @@ class OpenvswitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase): IPTABLES_FW_DRIVER_FULL, 'iptables_hybrid')) and sg_enabled vif_details = {portbindings.CAP_PORT_FILTER: sg_enabled, portbindings.OVS_HYBRID_PLUG: hybrid_plug_required} + # NOTE(moshele): Bind DIRECT (SR-IOV) port allows + # to offload the OVS flows using tc to the SR-IOV NIC. + # We are using OVS mechanism driver because the openvswitch (>=2.8.0) + # support hardware offload via tc and that allow us to manage the VF by + # OpenFlow control plane using representor net-device. super(OpenvswitchMechanismDriver, self).__init__( constants.AGENT_TYPE_OVS, portbindings.VIF_TYPE_OVS, - vif_details) + vif_details, supported_vnic_types=[portbindings.VNIC_NORMAL, + portbindings.VNIC_DIRECT]) ovs_qos_driver.register() def get_allowed_network_types(self, agent): diff --git a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/mech_driver/test_mech_openvswitch.py b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/mech_driver/test_mech_openvswitch.py index ff22690252e..9e21316b938 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/mech_driver/test_mech_openvswitch.py +++ b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/mech_driver/test_mech_openvswitch.py @@ -236,3 +236,16 @@ class OpenvswitchMechanismDPDKTestCase(OpenvswitchMechanismBaseTestCase): result = self.driver.get_vif_type(None, self.AGENT_SYSTEM, None) self.assertEqual(portbindings.VIF_TYPE_OVS, result) + + +class OpenvswitchMechanismSRIOVTestCase(OpenvswitchMechanismBaseTestCase): + + def _make_port_ctx(self, agents): + segments = [{api.ID: 'local_segment_id', api.NETWORK_TYPE: 'local'}] + return base.FakePortContext(self.AGENT_TYPE, agents, segments, + vnic_type=portbindings.VNIC_DIRECT) + + def test_get_vif_type(self): + context = self._make_port_ctx(self.AGENTS) + result = self.driver.get_vif_type(context, self.AGENTS[0], None) + self.assertEqual(self.VIF_TYPE, result) diff --git a/releasenotes/notes/ovs_hardware_offload_support-798d3896ab2c4b1d.yaml b/releasenotes/notes/ovs_hardware_offload_support-798d3896ab2c4b1d.yaml new file mode 100644 index 00000000000..287afb22f9c --- /dev/null +++ b/releasenotes/notes/ovs_hardware_offload_support-798d3896ab2c4b1d.yaml @@ -0,0 +1,7 @@ +--- +prelude: > + The ``openvswitch`` mechanism driver now supports hardware offload via SR-IOV. +features: + - The ``openvswitch`` mechanism driver now allows binding direct (SR-IOV) ports. + Using ``openvswitch`` 2.8.0 and 'Linux Kernel' 4.8 allows to control the SR-IOV VF + via OpenFlow control plane and gain accelerated 'Open vSwitch'. \ No newline at end of file