Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace CoalescingHWConfigMixin with MultiCoalescingHWConfigMixin #365

Merged
merged 3 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions lnst/Recipes/ENRT/BaseSRIOVNetnsTcRecipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,6 @@ def offload_nics(self):
def mtu_hw_config_dev_list(self):
raise NotImplementedError()

@property
def coalescing_hw_config_dev_list(self):
raise NotImplementedError()

@property
def dev_interrupt_hw_config_dev_list(self):
raise NotImplementedError()
Expand Down
18 changes: 1 addition & 17 deletions lnst/Recipes/ENRT/BondRecipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,22 +194,6 @@ class and :any:`MTUHWConfigMixin.mtu_hw_config_dev_list`.
"""
return [self.matched.host1.bond0, self.matched.host2.eth0]

@property
def coalescing_hw_config_dev_list(self):
"""
The `coalescing_hw_config_dev_list` property value for this scenario is a
list containing the matched physical devices used to create the bonding
device on host1 and the matched ethernet device on host2.

| host1.eth0, host.eth1
| host2.eth0

For detailed explanation of this property see :any:`CoalescingHWConfigMixin`
class and :any:`CoalescingHWConfigMixin.coalescing_hw_config_dev_list`.
"""
return [self.matched.host1.eth0, self.matched.host1.eth1,
self.matched.host2.eth0]

@property
def dev_interrupt_hw_config_dev_list(self):
"""
Expand All @@ -222,7 +206,7 @@ def dev_interrupt_hw_config_dev_list(self):

For detailed explanation of this property see
:any:`DevInterruptHWConfigMixin` class and
:any:`CoalescingHWConfigMixin.coalescing_hw_config_dev_list`.
:any:`DevInterruptHWConfigMixin.dev_interrupt_hw_config_dev_list`.
"""
return [self.matched.host1.eth0, self.matched.host1.eth1,
self.matched.host2.eth0]
Expand Down
134 changes: 99 additions & 35 deletions lnst/Recipes/ENRT/ConfigMixins/CoalescingHWConfigMixin.py
Original file line number Diff line number Diff line change
@@ -1,61 +1,125 @@
from lnst.Common.Parameters import BoolParam
from copy import copy

from lnst.Common.Parameters import DictParam
from lnst.Recipes.ENRT.ConfigMixins.BaseHWConfigMixin import BaseHWConfigMixin


class CoalescingHWConfigMixin(BaseHWConfigMixin):
"""
This class is an extension to the :any:`BaseEnrtRecipe` class that enables
adaptive coalescing configuration on the devices defined by
:attr:`coalescing_hw_config_dev_list` property.

:param adaptive_tx_coalescing:
(optional test parameter) boolean to enable/disable TX adaptive
coalescing on the devices
:param adaptive_rx_coalescing:
(optional test parameter) boolean to enable/disable RX adaptive
coalescing on the devices
"""
interrupt coalescing configuration on any device defined in recipe's
device requirements.

Typically the user would disable adaptive interrupt coalescing and configure
specific values.

For example the SimpleNetworkRecipe defines `host1.eth0` and `host2.eth0`
device requirements, so to configure the interrupt coalescing you can do:

adaptive_rx_coalescing = BoolParam(mandatory=False)
adaptive_tx_coalescing = BoolParam(mandatory=False)
```python
recipe = SimpleNetworkRecipe(
coalescing_settings={
"host1": {
"eth0": {
"adaptive-rx": "off", "adaptive-tx": "off",
"rx-usecs": 16, "rx-frames": 32,
"tx-usecs": 128, "tx-frames": 128
}
},
"host2": {
"eth0": {
"adaptive-rx": "off", "adaptive-tx": "off",
"rx-usecs": 16, "rx-frames": 32,
"tx-usecs": 128, "tx-frames": 128
}
}
}
)
```

@property
def coalescing_hw_config_dev_list(self):
"""
The value of this property is a list of devices for which the
adaptive coalescing features should be configured. It has to be
defined by a derived class.
"""
return []
The keys in the coalescing settings match the `ethtool -C` command syntax.

:param coalescing_settings:
(optional test parameter) dictionary to specify coalescing settings
for individual devices, in 'ethtool -C ...' format
"""
coalescing_settings = DictParam(mandatory=False, default={})

def hw_config(self, config):
super().hw_config(config)

for param in ["adaptive_rx_coalescing", "adaptive_tx_coalescing"]:
param_value = getattr(self.params, param, None)
if param_value is not None:
device_settings = self._parse_device_settings(self.params.coalescing_settings)
for device, device_setting in device_settings.items():
device_setting_copy = copy(device_setting)
# first, fetch adaptive setting as it needs to be turned off before
# configuring individual coalescing settings
for param in ["adaptive-tx", "adaptive-rx"]:
if param_value := device_setting_copy.pop(param, None):
self._configure_dev_attribute(
config,
[device],
coalescing_param_to_device_attribute(param),
param_value == "on",
)

for param, param_value in device_setting_copy.items():
self._configure_dev_attribute(
config,
self.coalescing_hw_config_dev_list,
param,
param_value
[device],
coalescing_param_to_device_attribute(param),
param_value,
)

def hw_deconfig(self, config):
for feature in ['adaptive_rx_coalescing', 'adaptive_tx_coalescing']:
self._deconfigure_dev_attribute(
config,
self.coalescing_hw_config_dev_list,
feature,
)
device_settings = self._parse_device_settings(self.params.coalescing_settings)
for device, device_setting in device_settings.items():
device_setting_copy = copy(device_setting)
for param in device_setting:
if param in ["adaptive-tx", "adaptive-rx"]:
continue
device_setting_copy.pop(param)
self._deconfigure_dev_attribute(
config,
[device],
coalescing_param_to_device_attribute(param),
)

for param in device_setting_copy:
self._deconfigure_dev_attribute(
config,
[device],
coalescing_param_to_device_attribute(param),
)

super().hw_deconfig(config)

def describe_hw_config(self, config):
desc = super().describe_hw_config(config)
for param in ["adaptive_rx_coalescing", "adaptive_tx_coalescing"]:

device_settings = self._parse_device_settings(self.params.coalescing_settings)
coalescing_attrs = {
coalescing_param_to_device_attribute(key)
for setting in device_settings.values()
for key in setting.keys()
}
for attr in sorted(coalescing_attrs):
desc.extend(
self._describe_dev_attribute(config, param)
self._describe_dev_attribute(
config,
attr,
)
)

return desc


def coalescing_param_to_device_attribute(param):
"""
This mixin accepts the coalesce_settings keys in 'ethtool -C' format
The Device class uses more descriptive property names along with
underscores, so we need to translate the keys to property names
"""
if param in ["adaptive-tx", "adaptive-rx"]:
return param.replace("-", "_") + "_coalescing"

return "coalescing_" + param.replace("-", "_")
101 changes: 0 additions & 101 deletions lnst/Recipes/ENRT/ConfigMixins/MultiCoalescingHWConfigMixin.py

This file was deleted.

5 changes: 0 additions & 5 deletions lnst/Recipes/ENRT/DoubleBondRecipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,6 @@ def offload_nics(self):
def mtu_hw_config_dev_list(self):
return [self.matched.host1.bond0, self.matched.host2.bond0]

@property
def coalescing_hw_config_dev_list(self):
host1, host2 = self.matched.host1, self.matched.host2
return [host1.eth0, host1.eth1, host2.eth0, host2.eth1]

@property
def dev_interrupt_hw_config_dev_list(self):
host1, host2 = self.matched.host1, self.matched.host2
Expand Down
5 changes: 0 additions & 5 deletions lnst/Recipes/ENRT/DoubleTeamRecipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,6 @@ def offload_nics(self):
def mtu_hw_config_dev_list(self):
return [self.matched.host1.team0, self.matched.host2.team0]

@property
def coalescing_hw_config_dev_list(self):
host1, host2 = self.matched.host1, self.matched.host2
return [host1.eth0, host1.eth1, host2.eth0, host2.eth1]

@property
def dev_interrupt_hw_config_dev_list(self):
host1, host2 = self.matched.host1, self.matched.host2
Expand Down
4 changes: 0 additions & 4 deletions lnst/Recipes/ENRT/GeneveTunnelRecipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,6 @@ def pause_frames_dev_list(self):
def mtu_hw_config_dev_list(self):
return [self.matched.host1.gnv_tunnel, self.matched.host2.gnv_tunnel]

@property
def coalescing_hw_config_dev_list(self):
return [self.matched.host1.eth0, self.matched.host2.eth0]

@property
def dev_interrupt_hw_config_dev_list(self):
return [self.matched.host1.eth0, self.matched.host2.eth0]
Expand Down
4 changes: 0 additions & 4 deletions lnst/Recipes/ENRT/GreTunnelRecipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,6 @@ def pause_frames_dev_list(self):
def mtu_hw_config_dev_list(self):
return [self.matched.host1.gre_tunnel, self.matched.host2.gre_tunnel]

@property
def coalescing_hw_config_dev_list(self):
return [self.matched.host1.eth0, self.matched.host2.eth0]

@property
def dev_interrupt_hw_config_dev_list(self):
return [self.matched.host1.eth0, self.matched.host2.eth0]
Expand Down
5 changes: 0 additions & 5 deletions lnst/Recipes/ENRT/LinuxBridgeOverBondRecipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,6 @@ def offload_nics(self):
def mtu_hw_config_dev_list(self):
return [self.matched.host1.bond0, self.matched.host2.bond0]

@property
def coalescing_hw_config_dev_list(self):
host1, host2 = self.matched.host1, self.matched.host2
return [host1.eth0, host1.eth1, host2.eth0, host2.eth1]

@property
def dev_interrupt_hw_config_dev_list(self):
host1, host2 = self.matched.host1, self.matched.host2
Expand Down
4 changes: 0 additions & 4 deletions lnst/Recipes/ENRT/LinuxBridgeRecipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,6 @@ def offload_nics(self):
def mtu_hw_config_dev_list(self):
return [self.matched.host1.eth0, self.matched.host2.eth0]

@property
def coalescing_hw_config_dev_list(self):
return [self.matched.host1.eth0, self.matched.host2.eth0]

@property
def dev_interrupt_hw_config_dev_list(self):
return [self.matched.host1.eth0, self.matched.host2.eth0]
Expand Down
5 changes: 0 additions & 5 deletions lnst/Recipes/ENRT/MPTCPRecipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,6 @@ def mtu_hw_config_dev_list(self):
return [self.matched.host1.eth0, self.matched.host1.eth1,
self.matched.host2.eth0, self.matched.host2.eth1]

@property
def coalescing_hw_config_dev_list(self):
return [self.matched.host1.eth0, self.matched.host1.eth1,
self.matched.host2.eth0, self.matched.host2.eth1]

@property
def dev_interrupt_hw_config_dev_list(self):
return [self.matched.host1.eth0, self.matched.host1.eth1,
Expand Down
4 changes: 0 additions & 4 deletions lnst/Recipes/ENRT/SRIOVNetnsGeneveTcRecipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,6 @@ def offload_nics(self):
def mtu_hw_config_dev_list(self):
return [self.matched.host1.sriov_devices.vfs[0], self.matched.host2.sriov_devices.vfs[0]]

@property
def coalescing_hw_config_dev_list(self):
return [self.matched.host1.sriov_devices.vfs[0], self.matched.host2.sriov_devices.vfs[0]]

@property
def dev_interrupt_hw_config_dev_list(self):
return [self.matched.host1.sriov_devices.vfs[0], self.matched.host2.sriov_devices.vfs[0]]
Expand Down
Loading
Loading