Skip to content

Commit 89e281e

Browse files
vvfedorenkokuba-moo
authored andcommitted
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: 0e9c127 ("ethtool: add interface to read Tx hardware timestamping statistics") Suggested-by: Jakub Kicinski <[email protected]> Signed-off-by: Vadim Fedorenko <[email protected]> Reviewed-by: Rahul Rameshbabu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 7679935 commit 89e281e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

net/ethtool/tsinfo.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ static int tsinfo_prepare_data(const struct ethnl_req_info *req_base,
3838
ret = ethnl_ops_begin(dev);
3939
if (ret < 0)
4040
return ret;
41-
if (req_base->flags & ETHTOOL_FLAG_STATS &&
42-
dev->ethtool_ops->get_ts_stats) {
41+
if (req_base->flags & ETHTOOL_FLAG_STATS) {
4342
ethtool_stats_init((u64 *)&data->stats,
4443
sizeof(data->stats) / sizeof(u64));
45-
dev->ethtool_ops->get_ts_stats(dev, &data->stats);
44+
if (dev->ethtool_ops->get_ts_stats)
45+
dev->ethtool_ops->get_ts_stats(dev, &data->stats);
4646
}
4747
ret = __ethtool_get_ts_info(dev, &data->ts_info);
4848
ethnl_ops_complete(dev);

0 commit comments

Comments
 (0)