Skip to contentSkip to conversation

net: ethtool: coalesce: try to make user settings stick twice

PATCH Applied Jakub Kicinski 2 participants 2 messages Apr 20, 2023 – Apr 25, 2023

Subsystems (4)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/1 net: ethtool: coalesce: try to make user settings stick twice

SET_COALESCE may change operation mode and parameters in one call. Changing operation mode may cause the driver to reset the parameter values to what is a reasonable default for new operation mode.

Since driver does not know which parameters come from user and which are echoed back from ->get, driver may ignore the parameters when switching operation modes.

This used to be inevitable for ioctl() but in netlink we know which parameters are actually specified by the user.

We could inform which parameters were set by the user but this would lead to a lot of code duplication in the drivers. Instead try to call the drivers twice if both mode and params are changed. The set method already checks if any params need updating so in case the driver did the right thing the first time around - there will be no second call to it's ->set method (only an extra call to ->get()).

For mlx5 for example before this patch we'd see:

 # ethtool -C eth0 adaptive-rx on  adaptive-tx on
 # ethtool -C eth0 adaptive-rx off adaptive-tx off \
		   tx-usecs 123 rx-usecs 123
 Adaptive RX: off  TX: off
 rx-usecs: 3
 rx-frames: 32
 tx-usecs: 16
 tx-frames: 32
 [...]

After the change:

 # ethtool -C eth0 adaptive-rx on  adaptive-tx on
 # ethtool -C eth0 adaptive-rx off adaptive-tx off \
		   tx-usecs 123 rx-usecs 123
 Adaptive RX: off  TX: off
 rx-usecs: 123
 rx-frames: 32
 tx-usecs: 123
 tx-frames: 32
 [...]

This only works for netlink, so it's a small discrepancy between netlink and ioctl(). Since we anticipate most users to move to netlink I believe it's worth making their lives easier.

---
mlx5 folks, LMK if you have a good idea of fixing this in the driver instead, that may be cleaner, but I can't think of a good way :(

---
 Documentation/networking/ethtool-netlink.rst |  4 ++
 net/ethtool/coalesce.c                       | 54 ++++++++++++++++----
 2 files changed, 47 insertions(+), 11 deletions(-)
Documentation/networking/ethtool-netlink.rst +4 -0
index cd0973d4ba01..2540c70952ff 100644
@@ -1099,6 +1099,10 @@ such that the corresponding bit in ``ethtool_ops::supported_coalesce_params``
 is not set), regardless of their values. Driver may impose additional
 constraints on coalescing parameters and their values.
 
+Compared to requests issued via the ``ioctl()`` netlink version of this request
+will try harder to make sure that values specified by the user have been applied
+and may call the driver twice.
+
 
 PAUSE_GET
 =========
net/ethtool/coalesce.c +43 -11

95 lines not on this page · raw message

Signature · 1 line
2.39.2
#1 lore raw
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Thu, 20 Apr 2023 16:33:02 -0700 you wrote:

SET_COALESCE may change operation mode and parameters in one call. Changing operation mode may cause the driver to reset the parameter values to what is a reasonable default for new operation mode.

Since driver does not know which parameters come from user and which are echoed back from ->get, driver may ignore the parameters when switching operation modes.

[...]

Here is the summary with links:
- [net-next] net: ethtool: coalesce: try to make user settings stick twice

    https://git.kernel.org/netdev/net-next/c/00d0f31a1ec8

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html