Browse Source

Skip VFs configured for DPDKs during NIC ordering

During NIC ordering all the VFs are expected to be skipped.
But if DPDK drivers are bound to a VF, then those VFs are still taken
in to account and is affecting the NIC ordering. The VFs bound to DPDK
drivers also shall be removed from the NIC ordering logic resulting in
consistency even with the re-run of os-net-config.

Change-Id: I50af9f75b01addae0e13830cc7a863072f9be34c
(cherry picked from commit 761b4621b0)
(cherry picked from commit b34a73016a)
Karthik S 11 months ago
2 changed files with 30 additions and 1 deletions
  1. +7
  2. +23

+ 7
- 0
os_net_config/tests/ View File

@ -550,6 +550,10 @@ class TestUtils(base.TestCase):
tmpdir = tempfile.mkdtemp()
self.stub_out('os_net_config.utils._SYS_CLASS_NET', tmpdir)
tmp_pci_dir = tempfile.mkdtemp()
self.stub_out('os_net_config.utils._SYS_BUS_PCI_DEV', tmp_pci_dir)
physfn_path = utils._SYS_BUS_PCI_DEV + '/0000:05:01.1/physfn'
def test_is_available_nic(interface_name, check_active):
return True
@ -565,6 +569,8 @@ class TestUtils(base.TestCase):
utils._update_dpdk_map('p3p1', '0000:04:00.0', '01:02:03:04:05:07',
utils._update_dpdk_map('p3p0_0', '0000:05:01.1', 'AA:02:03:04:05:FF',
nics = utils.ordered_active_nics()
@ -580,6 +586,7 @@ class TestUtils(base.TestCase):
self.assertEqual('z1', nics[9])
def test_interface_mac_raises(self):
self.assertRaises(IOError, utils.interface_mac, 'ens20f2p3')

+ 23
- 1
os_net_config/ View File

@ -27,6 +27,7 @@ from oslo_concurrency import processutils
logger = logging.getLogger(__name__)
_SYS_CLASS_NET = '/sys/class/net'
_SYS_BUS_PCI_DEV = '/sys/bus/pci/devices'
# File to contain the DPDK mapped nics, as nic name will not be available after
# binding driver, which is required for correct nic numbering.
# Format of the file (list mapped nic's details):
@ -149,6 +150,23 @@ def is_real_nic(interface_name):
return False
def _is_vf(pci_address):
# If DPDK drivers are bound on a VF, then the path _SYS_CLASS_NET
# wouldn't exist. Instead we look for the path
# /sys/bus/pci/devices/<PCI addr>/physfn to understand if the device
# is actually a VF. This path could be used by VFs not bound with
# DPDK drivers as well
vf_path_check = _SYS_BUS_PCI_DEV + '/%s/physfn' % pci_address
is_sriov_vf = os.path.isdir(vf_path_check)
if is_sriov_vf:
return True
# nic is not VF
return False
def _is_available_nic(interface_name, check_active=True):
if interface_name == 'lo':
@ -222,8 +240,12 @@ def _ordered_nics(check_active):
if contents:
dpdk_map = yaml.safe_load(contents)
for item in dpdk_map:
# If the DPDK drivers are bound to a VF, the same needs
# to be skipped for the NIC ordering
nic = item['name']
if _is_embedded_nic(nic):
if _is_vf(item['pci_address']):"%s is a VF, skipping it for NIC ordering" % nic)
elif _is_embedded_nic(nic):"%s is an embedded DPDK bound nic" % nic)