Add support for ethtool options for sriov_pf ports
There are deployment cases where ethtool configurations
are required to be performed on a sriov_pf port.
Main Changes:
- Add ethtool options to sriov_pf port type.
- Add ethtool_opts to sriov_pf schema
Change-Id: Idbc07312820bda5a113d5a9204052c76f9993e80
(cherry picked from commit 2c13c0eac0
)
This commit is contained in:
parent
7010fc9c23
commit
6e440e032e
|
@ -1424,7 +1424,7 @@ class SriovPF(_BaseOpts):
|
|||
primary=False, nic_mapping=None, persist_mapping=False,
|
||||
defroute=True, dhclient_args=None, dns_servers=None,
|
||||
nm_controlled=False, onboot=True, domain=None, members=None,
|
||||
promisc=None, link_mode='legacy'):
|
||||
promisc=None, link_mode='legacy', ethtool_opts=None):
|
||||
addresses = addresses or []
|
||||
routes = routes or []
|
||||
rules = rules or []
|
||||
|
@ -1442,6 +1442,7 @@ class SriovPF(_BaseOpts):
|
|||
self.name = name
|
||||
self.promisc = promisc
|
||||
self.link_mode = link_mode
|
||||
self.ethtool_opts = ethtool_opts
|
||||
|
||||
@staticmethod
|
||||
def get_on_off(config):
|
||||
|
@ -1460,12 +1461,13 @@ class SriovPF(_BaseOpts):
|
|||
promisc = json.get('promisc', True)
|
||||
promisc = SriovPF.get_on_off(promisc)
|
||||
link_mode = json.get('link_mode', 'legacy')
|
||||
ethtool_opts = json.get('ethtool_opts', None)
|
||||
if link_mode not in ['legacy', 'switchdev']:
|
||||
msg = 'Expecting link_mode to match legacy/switchdev'
|
||||
raise InvalidConfigException(msg)
|
||||
opts = _BaseOpts.base_opts_from_json(json)
|
||||
return SriovPF(name, numvfs, *opts, promisc=promisc,
|
||||
link_mode=link_mode)
|
||||
link_mode=link_mode, ethtool_opts=ethtool_opts)
|
||||
|
||||
|
||||
class OvsDpdkBond(_BaseOpts):
|
||||
|
|
|
@ -328,6 +328,8 @@ definitions:
|
|||
$ref: "#/definitions/bool_or_param"
|
||||
hotplug:
|
||||
$ref: "#/definitions/bool_or_param"
|
||||
ethtool_opts:
|
||||
$ref: "#/definitions/string_or_param"
|
||||
# common options:
|
||||
use_dhcp:
|
||||
$ref: "#/definitions/bool_or_param"
|
||||
|
|
|
@ -554,6 +554,15 @@ DRIVER=uio_pci_generic
|
|||
CPU_LIST=2,3
|
||||
"""
|
||||
|
||||
_SRIOV_PF_IFCFG = """# This file is autogenerated by os-net-config
|
||||
DEVICE=enp3s0f0
|
||||
ONBOOT=yes
|
||||
HOTPLUG=no
|
||||
NM_CONTROLLED=no
|
||||
PEERDNS=no
|
||||
BOOTPROTO=none
|
||||
"""
|
||||
|
||||
|
||||
class TestIfcfgNetConfig(base.TestCase):
|
||||
def setUp(self):
|
||||
|
@ -1179,6 +1188,14 @@ DHCLIENTARGS=--foobar
|
|||
"""
|
||||
self.assertEqual(em1_config, self.get_interface_config('em1'))
|
||||
|
||||
def test_sriov_pf_ethtool_opts(self):
|
||||
ifc = objects.SriovPF('enp3s0f0', 16,
|
||||
ethtool_opts='speed 1000 duplex full')
|
||||
self.provider.add_interface(ifc)
|
||||
pf_config = "".join((_SRIOV_PF_IFCFG,
|
||||
"ETHTOOL_OPTS=\"speed 1000 duplex full\"\n"))
|
||||
self.assertEqual(pf_config, self.get_interface_config('enp3s0f0'))
|
||||
|
||||
def test_interface_ethtool_opts(self):
|
||||
interface1 = objects.Interface('em1',
|
||||
ethtool_opts='speed 1000 duplex full')
|
||||
|
|
|
@ -1758,6 +1758,7 @@ class TestSriovPF(base.TestCase):
|
|||
self.assertEqual("off", pf.promisc)
|
||||
self.assertFalse(pf.use_dhcp)
|
||||
self.assertEqual("legacy", pf.link_mode)
|
||||
self.assertIsNone(pf.ethtool_opts)
|
||||
|
||||
def test_from_json_numvfs_nic1(self):
|
||||
def dummy_mapped_nics(nic_mapping=None):
|
||||
|
@ -1806,6 +1807,13 @@ class TestSriovPF(base.TestCase):
|
|||
expected = 'Expecting link_mode to match legacy/switchdev'
|
||||
self.assertIn(expected, six.text_type(err))
|
||||
|
||||
def test_from_json_ethtool_opts(self):
|
||||
data = '{"type": "sriov_pf", "name": "em1", "numvfs": 16, ' \
|
||||
'"use_dhcp": false, "promisc": false, ' \
|
||||
'"ethtool_opts": "speed 1000 duplex full"}'
|
||||
pf_ifc = objects.object_from_json(json.loads(data))
|
||||
self.assertEqual("speed 1000 duplex full", pf_ifc.ethtool_opts)
|
||||
|
||||
|
||||
class TestSriovVF(base.TestCase):
|
||||
|
||||
|
|
Loading…
Reference in New Issue