Merge "Add NIC Partitioning support for Mellanox VFs"
This commit is contained in:
commit
bca47783bc
|
@ -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')
|
||||
|
|
|
@ -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…
Reference in New Issue