Browse Source

Add NIC Partitioning support for Mellanox VFs

Change-Id: Ie48291011bb145452b6bf8e6aa843311266a07bd
(cherry picked from commit 878e6bc3ff)
changes/82/743482/1
Karthik S 1 month ago
parent
commit
f49ab161ca
2 changed files with 40 additions and 7 deletions
  1. +21
    -0
      os_net_config/tests/test_utils.py
  2. +19
    -7
      os_net_config/utils.py

+ 21
- 0
os_net_config/tests/test_utils.py View File

@@ -612,6 +612,12 @@ class TestUtils(base.TestCase):
def test_get_stored_pci_address(ifname, noop):
return "0000:00:07.0"

def test_vf_by_name(ifname):
return True

def test_not_vf_by_name(ifname):
return False

self.stub_out('oslo_concurrency.processutils.execute', test_execute)
self.stub_out('os_net_config.utils.get_stored_pci_address',
test_get_stored_pci_address)
@@ -630,6 +636,21 @@ class TestUtils(base.TestCase):
f.write('0x15b3')
self.assertEqual(utils.get_dpdk_devargs(nic, False),
'0000:00:19.0')
# Testing VFs of Mellanox Connect-X cards
self.stub_out('os_net_config.utils._is_vf_by_name',
test_vf_by_name)
self.assertEqual(utils.get_dpdk_devargs(nic, False),
'0000:00:19.0')

# Check if exception is raised, when the operstate is down
# and not VF
with open(os.path.join(nic_path, 'operstate'), 'w') as f:
f.write('down')
self.stub_out('os_net_config.utils._is_vf_by_name',
test_not_vf_by_name)
self.assertRaises(utils.InvalidInterfaceException,
utils.get_dpdk_devargs, nic, False)

# now testing the Mellanox CX3
with open(os.path.join(nic_path, 'device', 'device'), 'w') as f:
f.write('0x1007')


+ 19
- 7
os_net_config/utils.py View File

@@ -59,6 +59,10 @@ WantedBy=multi-user.target
_VPP_EXEC_FILE = '/etc/vpp/vpp-exec'


class InvalidInterfaceException(ValueError):
pass


class OvsDpdkBindException(ValueError):
pass

@@ -160,11 +164,13 @@ def _is_vf(pci_address):

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
return is_sriov_vf

# nic is not VF
return False

def _is_vf_by_name(interface_name):
vf_path_check = _SYS_CLASS_NET + '/%s/device/physfn' % interface_name
is_sriov_vf = os.path.isdir(vf_path_check)
return is_sriov_vf


def _is_available_nic(interface_name, check_active=True):
@@ -186,9 +192,7 @@ def _is_available_nic(interface_name, check_active=True):
# the nic numbering. All the VFs will have a reference to the PF with
# directory name as 'physfn', if this directory is present it should be
# ignored.
vf_path_check = _SYS_CLASS_NET + '/%s/device/physfn' % interface_name
is_sriov_vf = os.path.isdir(vf_path_check)
if is_sriov_vf:
if _is_vf_by_name(interface_name):
return False

# nic is available
@@ -420,6 +424,14 @@ def get_dpdk_devargs(ifname, noop):
# in dpdk_mapping.yaml file, so we need to get their pci
# address with ethtool.
dpdk_devargs = get_pci_address(ifname, noop)
elif _is_vf_by_name(ifname):
# For Mellanox devices the VFs bound with DPDK shall
# be treated the same as VFs of other devices
dpdk_devargs = get_pci_address(ifname, noop)
else:
logger.error("Unable to get devargs for interface %s" % ifname)
msg = ("Unable to get devargs for interface %s" % ifname)
raise InvalidInterfaceException(msg)
else:
logger.info("Getting stored PCI address as devarg")
dpdk_devargs = get_stored_pci_address(ifname, noop)


Loading…
Cancel
Save