Commit 89e281eb authored by Vadim Fedorenko's avatar Vadim Fedorenko Committed by Jakub Kicinski

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

Fixes: 0e9c1277 ("ethtool: add interface to read Tx hardware timestamping statistics")
Suggested-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarVadim Fedorenko <vadfed@meta.com>
Reviewed-by: default avatarRahul Rameshbabu <rrameshbabu@nvidia.com>
Link: https://lore.kernel.org/r/20240530040814.1014446-1-vadfed@meta.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 7679935b
...@@ -38,10 +38,10 @@ static int tsinfo_prepare_data(const struct ethnl_req_info *req_base, ...@@ -38,10 +38,10 @@ static int tsinfo_prepare_data(const struct ethnl_req_info *req_base,
ret = ethnl_ops_begin(dev); ret = ethnl_ops_begin(dev);
if (ret < 0) if (ret < 0)
return ret; return ret;
if (req_base->flags & ETHTOOL_FLAG_STATS && if (req_base->flags & ETHTOOL_FLAG_STATS) {
dev->ethtool_ops->get_ts_stats) {
ethtool_stats_init((u64 *)&data->stats, ethtool_stats_init((u64 *)&data->stats,
sizeof(data->stats) / sizeof(u64)); sizeof(data->stats) / sizeof(u64));
if (dev->ethtool_ops->get_ts_stats)
dev->ethtool_ops->get_ts_stats(dev, &data->stats); dev->ethtool_ops->get_ts_stats(dev, &data->stats);
} }
ret = __ethtool_get_ts_info(dev, &data->ts_info); ret = __ethtool_get_ts_info(dev, &data->ts_info);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment