From 47390226f5c755a083b0f181f7a81b480069c8a9 Mon Sep 17 00:00:00 2001 From: Hamdy Khader Date: Mon, 13 May 2019 13:39:57 +0300 Subject: [PATCH] OVS DPDK port representors support Adds support for OVS DPDK port representors[1], a direct port on a netdev datapath is considered a DPDK representor port. get_vif_type returns OVS VIF type in case of a direct port. [1] http://docs.openvswitch.org/en/latest/topics/dpdk/phy/#representors Closes-Bug: #1829734 Change-Id: I3956eeda19ebc93fdb0b13c1cfb3dc64abffee9f --- .../openvswitch/mech_driver/mech_openvswitch.py | 4 ++++ .../mech_driver/test_mech_openvswitch.py | 15 ++++++++++++--- .../notes/ovs-dpdk-rep-port-40fe628974040786.yaml | 5 +++++ 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/ovs-dpdk-rep-port-40fe628974040786.yaml 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 214259d5198..5cd541fe3f3 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/mech_driver/mech_openvswitch.py +++ b/neutron/plugins/ml2/drivers/openvswitch/mech_driver/mech_openvswitch.py @@ -130,6 +130,10 @@ class OpenvswitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase): super(OpenvswitchMechanismDriver, self).bind_port(context) def get_vif_type(self, context, agent, segment): + if (context.current.get(portbindings.VNIC_TYPE) == + portbindings.VNIC_DIRECT): + return portbindings.VIF_TYPE_OVS + caps = agent['configurations'].get('ovs_capabilities', {}) if (any(x in caps.get('iface_types', []) for x in [a_const.OVS_DPDK_VHOST_USER, 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 cf073b5471a..0bbd49e0c05 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 @@ -285,13 +285,22 @@ class OpenvswitchMechanismDPDKTestCase(OpenvswitchMechanismBaseTestCase): self.assertEqual(portbindings.VHOST_USER_MODE_SERVER, result) def test_get_vif_type(self): - result = self.driver.get_vif_type(None, self.AGENT, None) + normal_port_cxt = base.FakePortContext(None, None, None) + result = self.driver.get_vif_type(normal_port_cxt, self.AGENT, None) self.assertEqual(portbindings.VIF_TYPE_VHOST_USER, result) - result = self.driver.get_vif_type(None, self.AGENT_SERVER, None) + result = self.driver.get_vif_type(normal_port_cxt, + self.AGENT_SERVER, None) self.assertEqual(portbindings.VIF_TYPE_VHOST_USER, result) - result = self.driver.get_vif_type(None, self.AGENT_SYSTEM, None) + result = self.driver.get_vif_type(normal_port_cxt, + self.AGENT_SYSTEM, None) + self.assertEqual(portbindings.VIF_TYPE_OVS, result) + + direct_port_cxt = base.FakePortContext( + None, None, None, vnic_type=portbindings.VNIC_DIRECT) + result = self.driver.get_vif_type(direct_port_cxt, + self.AGENT, None) self.assertEqual(portbindings.VIF_TYPE_OVS, result) diff --git a/releasenotes/notes/ovs-dpdk-rep-port-40fe628974040786.yaml b/releasenotes/notes/ovs-dpdk-rep-port-40fe628974040786.yaml new file mode 100644 index 00000000000..677a8df9184 --- /dev/null +++ b/releasenotes/notes/ovs-dpdk-rep-port-40fe628974040786.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Adds support for OVS DPDK port representors, a direct port on + a netdev datapath is considered a DPDK representor port.