Translate VF network capabilities to port binding

Libvirt's node device driver accumulates and reports information
about host devices. Network capabilities reported by node device
driver for NIC contain information about HW offloads supported
by this NIC.

One of possible features reported by node device driver is
switchdev: a NIC capability to implement VFs similar to actual
HW switch ports (also referred to as SR-IOV OVS hardware offload).
From Neutron perspective, vnic-type should be set to "direct" and
"switchdev" capability should be added to port binding profile to
enable HW offload (there are also configuration steps on compute
hosts to tune NIC config).

This patch was written to automatically translate "switchdev" from
VF network capabilities reported by node device driver to Neutron
port binding profile and allow user to skip manual step that
requires admin privileges.

Other capabilities are also translated: they are not used right
now, but provide visibility and can be utilized later.

Closes-bug: #2020813
Closes-bug: #2008238
Change-Id: I3b17f386325b8f42c0c374f766fb21c520161a59
(cherry picked from commit cef3b5ef2c)
This commit is contained in:
Alexey Stupnikov
2023-05-25 21:23:32 +02:00
committed by Amit Uniyal
parent 6d5943e1b5
commit 7e4f45df91
7 changed files with 47 additions and 3 deletions

View File

@@ -589,6 +589,13 @@ class PciDevice(base.NovaPersistentObject, base.NovaObject):
"""
return self.extra_info.get('mac_address')
@property
def network_caps(self):
"""PCI device network capabilities or empty list if not available"""
caps_json = self.extra_info.get('capabilities', '{}')
caps = jsonutils.loads(caps_json)
return caps.get('network', [])
@base.NovaObjectRegistry.register
class PciDeviceList(base.ObjectListBase, base.NovaObject):