Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 0e9c127729be ("ethtool: add interface to read Tx hardware timestamping statistics")
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Vadim Fedorenko <vadfed@meta.com>
Reviewed-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Link: https://lore.kernel.org/r/20240530040814.1014446-1-vadfed@meta.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Vadim Fedorenko and committed by
Jakub Kicinski
89e281eb 7679935b

+3 -3
+3 -3
net/ethtool/tsinfo.c
··· 38 38 ret = ethnl_ops_begin(dev); 39 39 if (ret < 0) 40 40 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) { 43 42 ethtool_stats_init((u64 *)&data->stats, 44 43 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); 46 46 } 47 47 ret = __ethtool_get_ts_info(dev, &data->ts_info); 48 48 ethnl_ops_complete(dev);