Skip representator port(s) while discovering active NICs
When switchdev is enabled (in mellanox nics), there will be additional representator interfaces created. They have to be ignored when checking if NIC is real or virtual Change-Id: I16457778542243d6046fc145f369756e3424a503
This commit is contained in:
parent
4deb7a8171
commit
141b34ed8a
|
@ -838,6 +838,11 @@ class TestUtils(base.TestCase):
|
|||
tmpdir = tempfile.mkdtemp()
|
||||
self.stub_out('os_net_config.common.SYS_CLASS_NET', tmpdir)
|
||||
|
||||
def test_get_pci_addr(interface_name, noop):
|
||||
return "0000:18:00.2"
|
||||
self.stub_out('os_net_config.utils.get_pci_address',
|
||||
test_get_pci_addr)
|
||||
|
||||
# SR-IOV PF = ens802f0
|
||||
# SR-IOV VF = enp129s2
|
||||
for nic in ['ens802f0', 'enp129s2']:
|
||||
|
|
|
@ -105,6 +105,19 @@ def is_real_nic(interface_name):
|
|||
return False
|
||||
|
||||
|
||||
def is_representor_port_by_name(interface_name):
|
||||
|
||||
is_representor_port = False
|
||||
|
||||
bus_info = get_pci_address(interface_name, noop=False)
|
||||
if not bus_info:
|
||||
is_representor_port = True
|
||||
logger.debug("nics %s pci_addr is: %s" %
|
||||
(interface_name, bus_info))
|
||||
|
||||
return is_representor_port
|
||||
|
||||
|
||||
def _is_available_nic(interface_name, check_active=True):
|
||||
try:
|
||||
if interface_name == 'lo':
|
||||
|
@ -128,6 +141,12 @@ def _is_available_nic(interface_name, check_active=True):
|
|||
if common.is_vf_by_name(interface_name):
|
||||
return False
|
||||
|
||||
# If switchdev(offload) is enabled in a PF interface, there
|
||||
# will be additional representator ports. It has to be ignored.
|
||||
# Representator INTF will not have any pci_addr set
|
||||
if is_representor_port_by_name(interface_name):
|
||||
return False
|
||||
|
||||
# nic is available
|
||||
return True
|
||||
|
||||
|
|
Loading…
Reference in New Issue