Allow configuration of inactive DPDK devices as well
When DPDK ports (Mellanox) from a bond, are setup the link state is expected to be active. The patch allows the configuration of such ports even when the link state is inactive. Change-Id: I516daad62989a9edb0db2a0255b94f04fddf12d2
This commit is contained in:
parent
0350a82f19
commit
cb52368986
@ -716,12 +716,6 @@ 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)
|
||||
@ -741,19 +735,16 @@ class TestUtils(base.TestCase):
|
||||
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)
|
||||
os.makedirs(os.path.join(nic_path, 'device', 'physfn'))
|
||||
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
|
||||
# Check if devargs is derived, when the operstate is down
|
||||
os.rmdir(os.path.join(nic_path, 'device', 'physfn'))
|
||||
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)
|
||||
self.assertEqual(utils.get_dpdk_devargs(nic, False),
|
||||
'0000:00:19.0')
|
||||
|
||||
# now testing the Mellanox CX3
|
||||
with open(os.path.join(nic_path, 'device', 'device'), 'w') as f:
|
||||
|
@ -323,7 +323,7 @@ def get_dpdk_devargs(ifname, noop):
|
||||
if not noop:
|
||||
vendor_id = common.get_vendor_id(ifname)
|
||||
device_id = common.get_device_id(ifname)
|
||||
if vendor_id == "0x15b3":
|
||||
if vendor_id == common.MLNX_VENDOR_ID:
|
||||
logger.info("Getting devargs for Mellanox cards")
|
||||
if device_id == "0x1007":
|
||||
# Some NICs (i.e. Mellanox ConnectX-3) have only one PCI
|
||||
@ -331,18 +331,12 @@ def get_dpdk_devargs(ifname, noop):
|
||||
# device won’t work. Instead, we should use
|
||||
# "class=eth,mac=<MAC>"
|
||||
dpdk_devargs = f"class=eth,mac={common.interface_mac(ifname)}"
|
||||
elif is_active_nic(ifname):
|
||||
# Other Mellanox devices are active and they are not stored
|
||||
# in dpdk_mapping.yaml file, so we need to get their pci
|
||||
# address with ethtool.
|
||||
dpdk_devargs = get_pci_address(ifname, noop)
|
||||
elif common.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:
|
||||
msg = ("Unable to get devargs for interface %s" % ifname)
|
||||
raise InvalidInterfaceException(msg)
|
||||
# Get the PCI address of the devices other than CX-3.
|
||||
# It includes the VFs as well. For all Other Mellanox devices
|
||||
# the PCI address are not stored in dpdk_mapping.yaml file,
|
||||
# so we need to get their pci address with ethtool.
|
||||
dpdk_devargs = get_pci_address(ifname, noop)
|
||||
else:
|
||||
logger.info("Getting stored PCI address as devarg")
|
||||
dpdk_devargs = get_stored_pci_address(ifname, noop)
|
||||
|
Loading…
Reference in New Issue
Block a user