ethtool: init tsinfo stats if requested
Subsystems (3)
PATCH 1/1 ethtool: init tsinfo stats if requested
Statistic values should be set to ETHTOOL_STAT_NOT_SET even if the device doesn't support statistics. Otherwise zeros will be returned as if they are proper values:
host# ethtool -I -T lo
Time stamping parameters for lo:
Capabilities:
software-transmit
software-receive
software-system-clock
PTP Hardware Clock: none
Hardware Transmit Timestamp Modes: none
Hardware Receive Filter Modes: none
Statistics:
tx_pkts: 0
tx_lost: 0
tx_err: 0
--- net/ethtool/tsinfo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/ethtool/tsinfo.c +3 -3
@@ -38,11 +38,11 @@ static int tsinfo_prepare_data(const struct ethnl_req_info *req_base, ret =ethnl_ops_begin (dev);if (ret <0 )return ret; -if (req_base->flags ÐTOOL_FLAG_STATS && - dev->ethtool_ops->get_ts_stats) { +if (req_base->flags ÐTOOL_FLAG_STATS ) {ethtool_stats_init ((u64 *)&data->stats,sizeof (data->stats) /sizeof (u64)); - dev->ethtool_ops->get_ts_stats (dev, &data->stats); +if (dev->ethtool_ops->get_ts_stats) + dev->ethtool_ops->get_ts_stats (dev, &data->stats); } ret =__ethtool_get_ts_info (dev, &data->ts_info);ethnl_ops_complete (dev);
Signature · 1 line
2.43.0
Quoted 34 lines · On Wed, 29 May, 2024 21:08:14 -0700 Vadim Fedorenko <[email protected]> wrote:
Statistic values should be set to
ETHTOOL_STAT_NOT_SETeven if the device doesn't support statistics. Otherwise zeros will be returned as if they are proper values:host# ethtool -I -T lo
Time stamping parameters for lo:
Capabilities:
software-transmit
software-receive
software-system-clock
PTP Hardware Clock: none
Hardware Transmit Timestamp Modes: none
Hardware Receive Filter Modes: none
Statistics:
tx_pkts: 0
tx_lost: 0
tx_err: 0Fixes 0e9c127729be ("ethtool: add interface to read Tx hardware timestamping statistics")Suggested-by Jakub Kicinski <[email protected]>Signed-off-by Vadim Fedorenko <[email protected]>--- net/ethtool/tsinfo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)net/ethtool/tsinfo.c +0
-1@@ -38,11 +38,11 @@ static int tsinfo_prepare_data(const struct ethnl_req_info *req_base, ret =ethnl_ops_begin (dev);if (ret <0 )return ret; - if (req_base->flags & ETHTOOL_FLAG_STATS &&
net/ethtool/tsinfo.c static int tsinfo_prepare_data(const struct ethnl_req_info *req_base, · line 48
Quoted 10 lines
net/ethtool/tsinfo.c +3
-2- dev->ethtool_ops->get_ts_stats) { +if (req_base->flags ÐTOOL_FLAG_STATS ) {ethtool_stats_init ((u64 *)&data->stats,sizeof (data->stats) /sizeof (u64)); - dev->ethtool_ops->get_ts_stats (dev, &data->stats); +if (dev->ethtool_ops->get_ts_stats) + dev->ethtool_ops->get_ts_stats (dev, &data->stats); } ret =__ethtool_get_ts_info (dev, &data->ts_info);ethnl_ops_complete (dev);
Thanks for this catch! I agree with the change. If stats are requested and the device does not support the statistics, the initial values need to be set to illustrate the device does not support advertising statistics. I think the patch should target "ethtool" instead of "net". Also added Michal, the ethtool maintainer.
Quoted 45 lines · On Wed, 29 May, 2024 21:42:05 -0700 Rahul Rameshbabu <[email protected]>…
Quoted 44 lines · On Wed, 29 May, 2024 21:08:14 -0700 Vadim Fedorenko <[email protected]> wrote:
Statistic values should be set to
ETHTOOL_STAT_NOT_SETeven if the device doesn't support statistics. Otherwise zeros will be returned as if they are proper values:host# ethtool -I -T lo
Time stamping parameters for lo:
Capabilities:
software-transmit
software-receive
software-system-clock
PTP Hardware Clock: none
Hardware Transmit Timestamp Modes: none
Hardware Receive Filter Modes: none
Statistics:
tx_pkts: 0
tx_lost: 0
tx_err: 0Fixes 0e9c127729be ("ethtool: add interface to read Tx hardware timestamping statistics")Suggested-by Jakub Kicinski <[email protected]>Signed-off-by Vadim Fedorenko <[email protected]>--- net/ethtool/tsinfo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)net/ethtool/tsinfo.c +3
-3@@ -38,11 +38,11 @@ static int tsinfo_prepare_data(const struct ethnl_req_info *req_base, ret =ethnl_ops_begin (dev);if (ret <0 )return ret; -if (req_base->flags ÐTOOL_FLAG_STATS && - dev->ethtool_ops->get_ts_stats) { +if (req_base->flags ÐTOOL_FLAG_STATS ) {ethtool_stats_init ((u64 *)&data->stats,sizeof (data->stats) /sizeof (u64)); - dev->ethtool_ops->get_ts_stats (dev, &data->stats); +if (dev->ethtool_ops->get_ts_stats) + dev->ethtool_ops->get_ts_stats (dev, &data->stats); } ret =__ethtool_get_ts_info (dev, &data->ts_info);ethnl_ops_complete (dev);
<snip>
Quoted 2 lines
I think the patch should target "ethtool" instead of "net". Also added Michal, the ethtool maintainer.
Ignore. Was thinking for some reason this would end up in the ethtool tree. The patch is correct in targeting net.
Quoted 2 lines
Reviewed-by Rahul Rameshbabu <[email protected]>
Signature · 3 lines
Thanks, Rahul Rameshbabu
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 18 lines · On Wed, 29 May 2024 21:08:14 -0700 you wrote:
Statistic values should be set to
ETHTOOL_STAT_NOT_SETeven if the device doesn't support statistics. Otherwise zeros will be returned as if they are proper values:host# ethtool -I -T lo
Time stamping parameters for lo:
Capabilities:
software-transmit
software-receive
software-system-clock
PTP Hardware Clock: none
Hardware Transmit Timestamp Modes: none
Hardware Receive Filter Modes: none
Statistics:
tx_pkts: 0
tx_lost: 0
tx_err: 0
Quoted 1 line
[...]
Here is the summary with links:
- [net] ethtool: init tsinfo stats if requested
https://git.kernel.org/netdev/net/c/89e281ebff72
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html