Merge "[SR-IOV] Do not fail if ip-link vf "min_tx_rate" is not supported" into stable/victoria
This commit is contained in:
commit
699640aee4
|
@ -21,6 +21,7 @@ import tempfile
|
||||||
import netaddr
|
import netaddr
|
||||||
from neutron_lib import constants as n_consts
|
from neutron_lib import constants as n_consts
|
||||||
from neutron_lib import exceptions
|
from neutron_lib import exceptions
|
||||||
|
from neutron_lib.utils import helpers
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
|
@ -516,3 +517,36 @@ def gre_conntrack_supported():
|
||||||
return agent_utils.execute(cmd, log_fail_as_error=False)
|
return agent_utils.execute(cmd, log_fail_as_error=False)
|
||||||
except exceptions.ProcessExecutionError:
|
except exceptions.ProcessExecutionError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def min_tx_rate_support():
|
||||||
|
device_mappings = helpers.parse_mappings(
|
||||||
|
cfg.CONF.SRIOV_NIC.physical_device_mappings, unique_keys=False)
|
||||||
|
devices_to_test = set()
|
||||||
|
for devices_in_physnet in device_mappings.values():
|
||||||
|
for device in devices_in_physnet:
|
||||||
|
devices_to_test.add(device)
|
||||||
|
|
||||||
|
# NOTE(ralonsoh): the VF used by default is 0. Each SR-IOV configured
|
||||||
|
# NIC should have configured at least 1 VF.
|
||||||
|
VF_NUM = 0
|
||||||
|
devices_without_support = set()
|
||||||
|
for device in devices_to_test:
|
||||||
|
try:
|
||||||
|
ip_link = ip_lib.IpLinkCommand(device)
|
||||||
|
# NOTE(ralonsoh): to set min_tx_rate, first is needed to set
|
||||||
|
# max_tx_rate and max_tx_rate >= min_tx_rate.
|
||||||
|
vf_config = {'vf': VF_NUM, 'rate': {'min_tx_rate': int(400),
|
||||||
|
'max_tx_rate': int(500)}}
|
||||||
|
ip_link.set_vf_feature(vf_config)
|
||||||
|
vf_config = {'vf': VF_NUM, 'rate': {'min_tx_rate': 0,
|
||||||
|
'max_tx_rate': 0}}
|
||||||
|
ip_link.set_vf_feature(vf_config)
|
||||||
|
except ip_lib.InvalidArgument:
|
||||||
|
devices_without_support.add(device)
|
||||||
|
|
||||||
|
if devices_without_support:
|
||||||
|
LOG.debug('The following NICs do not support "min_tx_rate": %s',
|
||||||
|
devices_without_support)
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
|
@ -288,6 +288,15 @@ def check_ip_nonlocal_bind():
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def check_min_tx_rate_support():
|
||||||
|
result = checks.min_tx_rate_support()
|
||||||
|
if not result:
|
||||||
|
LOG.warning('There are SR-IOV network interfaces that do not support '
|
||||||
|
'setting the minimum TX rate (dataplane enforced minimum '
|
||||||
|
'guaranteed bandwidth) "ip-link vf min_tx_rate".')
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
# Define CLI opts to test specific features, with a callback for the test
|
# Define CLI opts to test specific features, with a callback for the test
|
||||||
OPTS = [
|
OPTS = [
|
||||||
BoolOptCallback('ovs_vxlan', check_ovs_vxlan, default=False,
|
BoolOptCallback('ovs_vxlan', check_ovs_vxlan, default=False,
|
||||||
|
@ -348,6 +357,10 @@ OPTS = [
|
||||||
help=_('Check ip_nonlocal_bind kernel option works with '
|
help=_('Check ip_nonlocal_bind kernel option works with '
|
||||||
'network namespaces.'),
|
'network namespaces.'),
|
||||||
default=False),
|
default=False),
|
||||||
|
BoolOptCallback('check_min_tx_rate_support', check_min_tx_rate_support,
|
||||||
|
help=_('Check if the configured SR-IOV NICs support '
|
||||||
|
'the "ip-link vf min_tx_rate" parameter.'),
|
||||||
|
default=False),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -396,6 +409,8 @@ def enable_tests_from_config():
|
||||||
'OVSHybridIptablesFirewallDriver'),
|
'OVSHybridIptablesFirewallDriver'),
|
||||||
):
|
):
|
||||||
cfg.CONF.set_default('bridge_firewalling', True)
|
cfg.CONF.set_default('bridge_firewalling', True)
|
||||||
|
if cfg.CONF.SRIOV_NIC.physical_device_mappings:
|
||||||
|
cfg.CONF.set_default('check_min_tx_rate_support', True)
|
||||||
|
|
||||||
|
|
||||||
def all_tests_passed():
|
def all_tests_passed():
|
||||||
|
|
|
@ -100,4 +100,11 @@ class PciDeviceIPWrapper(ip_lib.IPWrapper):
|
||||||
"""
|
"""
|
||||||
ip = self.device(self.dev_name)
|
ip = self.device(self.dev_name)
|
||||||
vf_config = {'vf': vf_index, 'rate': {rate_type: int(rate_value)}}
|
vf_config = {'vf': vf_index, 'rate': {rate_type: int(rate_value)}}
|
||||||
ip.link.set_vf_feature(vf_config)
|
try:
|
||||||
|
ip.link.set_vf_feature(vf_config)
|
||||||
|
except ip_lib.InvalidArgument:
|
||||||
|
# NOTE(ralonsoh): some NICs do not support "min_tx_rate" parameter.
|
||||||
|
# https://bugs.launchpad.net/neutron/+bug/1918464
|
||||||
|
LOG.error('Device %(device)s does not support ip-link vf '
|
||||||
|
'"%(rate_type)s" parameter.',
|
||||||
|
{'device': self.dev_name, 'rate_type': rate_type})
|
||||||
|
|
|
@ -100,3 +100,13 @@ class TestPciLib(base.BaseTestCase):
|
||||||
self.pci_wrapper.set_vf_rate(self.VF_INDEX, 'min_tx_rate', 10)
|
self.pci_wrapper.set_vf_rate(self.VF_INDEX, 'min_tx_rate', 10)
|
||||||
vf = {'vf': self.VF_INDEX, 'rate': {'min_tx_rate': 10}}
|
vf = {'vf': self.VF_INDEX, 'rate': {'min_tx_rate': 10}}
|
||||||
self.mock_ip_device.link.set_vf_feature.assert_called_once_with(vf)
|
self.mock_ip_device.link.set_vf_feature.assert_called_once_with(vf)
|
||||||
|
|
||||||
|
@mock.patch.object(pci_lib, 'LOG')
|
||||||
|
def test_set_vf_rate_exception(self, mock_log):
|
||||||
|
self.mock_ip_device.link.set_vf_feature.side_effect = (
|
||||||
|
ip_lib.InvalidArgument)
|
||||||
|
self.pci_wrapper.set_vf_rate(self.VF_INDEX, 'min_tx_rate', 10)
|
||||||
|
mock_log.error.assert_called_once_with(
|
||||||
|
'Device %(device)s does not support ip-link vf "%(rate_type)s" '
|
||||||
|
'parameter.', {'device': self.DEV_NAME, 'rate_type': 'min_tx_rate'}
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue