diff options
| author | Oleksandr Kuchmystyi <o.kuchmystyi@vyos.io> | 2025-12-25 16:48:03 +0300 |
|---|---|---|
| committer | Oleksandr Kuchmystyi <o.kuchmystyi@vyos.io> | 2026-01-22 10:52:44 +0300 |
| commit | f01ff15b7530053e18bb79cd529a84e3f15b294a (patch) | |
| tree | 9c06fa894c41017ac4f70bdea4de5292622999ff /smoketest/scripts/cli | |
| parent | 774de4b11330e7d3d30ddf6af0ad75e8be0f7bb3 (diff) | |
| download | vyos-1x-f01ff15b7530053e18bb79cd529a84e3f15b294a.tar.gz vyos-1x-f01ff15b7530053e18bb79cd529a84e3f15b294a.zip | |
ethtool: T7730: Add configuration coalesce for interface
This change introduces CLI support for configuring network interface
interrupt coalescing parameters via `netlink`.
Note: Not all NIC drivers support interrupt coalescing. On unsupported interfaces,
`netlink` returns an error and the VyOS commit will fail.
Diffstat (limited to 'smoketest/scripts/cli')
| -rwxr-xr-x | smoketest/scripts/cli/test_interfaces_ethernet.py | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/test_interfaces_ethernet.py b/smoketest/scripts/cli/test_interfaces_ethernet.py index 5b87bd9d1..7c8106521 100755 --- a/smoketest/scripts/cli/test_interfaces_ethernet.py +++ b/smoketest/scripts/cli/test_interfaces_ethernet.py @@ -28,6 +28,8 @@ from base_interfaces_test import BasicInterfaceTest from base_vyostest_shim import VyOSUnitTestSHIM from vyos.configsession import ConfigSessionError +from vyos.ethtool import Ethtool +from vyos.netlink import coalesce from vyos.frrender import mgmt_daemon from vyos.ifconfig import Section from vyos.utils.file import read_file @@ -205,6 +207,85 @@ class EthernetInterfaceTest(BasicInterfaceTest.TestCase): self.assertEqual(max_rx, rx) self.assertEqual(max_tx, tx) + def test_ethtool_coalesce(self): + """ + Verify that coalesce configuration is correctly applied to the interface using netlink + """ + + for interface in self._interfaces: + base_path = self._base_path + [interface, 'interrupt-coalescing'] + ethtool = Ethtool(interface) + is_virtio = ethtool.get_driver_name() == 'virtio_net' + + with self.subTest(interface=interface): + # Verify coalesce support on the NIC before check + supported = ethtool.check_coalesce() + + # If ethtool reports completely unsupported feature, then the CLI commit + # should correctly raise a ConfigSessionError during commit + if not supported: + self.cli_set(base_path + ['rx-usecs', '32']) + self.cli_set(base_path + ['tx-usecs', '32']) + + msg = 'Driver does not fully support coalesce configuration' + with self.assertRaisesRegex(ConfigSessionError, msg): + self.cli_commit() + continue + + # To find out the supported features + supported_rx_usecs = ethtool.check_coalesce('rx_usecs') + supported_tx_usecs = ethtool.check_coalesce('tx_usecs') + supported_adaptive_rx = ethtool.check_coalesce('adaptive_rx') + supported_adaptive_tx = ethtool.check_coalesce('adaptive_tx') + + # Disabled adaptive modes and set custom values + if supported_rx_usecs: + self.cli_set(base_path + ['rx-usecs', '64']) + if supported_tx_usecs: + self.cli_set(base_path + ['tx-usecs', '64']) + + # Force adaptive to be disabled if it is already enabled + params = coalesce.get_coalesce(interface) + if supported_rx_usecs and params['adaptive_rx']: + cmd(f'sudo ethtool --coalesce {interface} adaptive-rx off') + if supported_tx_usecs and params['adaptive_tx']: + cmd(f'sudo ethtool --coalesce {interface} adaptive-tx off') + + # Commit CLI configuration to apply coalescing + self.cli_commit() + + # Query coalesce parameters after applying + params = coalesce.get_coalesce(interface) + + # Assertions: all should reflect configured values + if supported_rx_usecs: + # `virtio-net` doesn't correctly work with this parameter + self.assertEqual(params['rx_usecs'], 0 if is_virtio else 64) + if supported_tx_usecs: + # `virtio-net` doesn't correctly work with this parameter + self.assertEqual(params['tx_usecs'], 0 if is_virtio else 64) + + # Not all parameters are adjustable for some of NIC (`virtio-net`) + if supported_adaptive_rx: + # Now test enabling RX adaptive coalescing modes + self.cli_delete(base_path + ['rx-usecs']) + self.cli_set(base_path + ['adaptive-rx']) + + if supported_adaptive_tx: + # Now test enabling TX adaptive coalescing modes + self.cli_delete(base_path + ['tx-usecs']) + self.cli_set(base_path + ['adaptive-tx']) + + self.cli_commit() + + # Verify that adaptive modes turned on correctly + params = coalesce.get_coalesce(interface) + if supported_adaptive_rx: + self.assertTrue(params['adaptive_rx']) + + if supported_adaptive_tx: + self.assertTrue(params['adaptive_tx']) + def test_ethtool_flow_control(self): for interface in self._interfaces: # Disable flow-control |
