From: Rahul Rameshbabu <rrameshbabu@nvidia.com>
To: Vadim Fedorenko <vadfed@meta.com>
Cc: Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Jiri Pirko <jiri@resnulli.us>,
Vadim Fedorenko <vadim.fedorenko@linux.dev>,
netdev@vger.kernel.org, Michal Kubecek <mkubecek@suse.cz>
Subject: Re: [PATCH net] ethtool: init tsinfo stats if requested
Date: Wed, 29 May 2024 21:42:05 -0700 [thread overview]
Message-ID: <877cfbrjo5.fsf@nvidia.com> (raw)
In-Reply-To: <20240530040814.1014446-1-vadfed@meta.com>
On Wed, 29 May, 2024 21:08:14 -0700 Vadim Fedorenko <vadfed@meta.com> wrote:
> 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>
> ---
> net/ethtool/tsinfo.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/net/ethtool/tsinfo.c b/net/ethtool/tsinfo.c
> index be2755c8d8fd..57d496287e52 100644
> --- a/net/ethtool/tsinfo.c
> +++ b/net/ethtool/tsinfo.c
> @@ -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 &&
> - dev->ethtool_ops->get_ts_stats) {
> + if (req_base->flags & ETHTOOL_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.
Reviewed-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
next prev parent reply other threads:[~2024-05-30 4:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-30 4:08 [PATCH net] ethtool: init tsinfo stats if requested Vadim Fedorenko
2024-05-30 4:42 ` Rahul Rameshbabu [this message]
2024-05-30 4:47 ` Rahul Rameshbabu
2024-06-01 22:20 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877cfbrjo5.fsf@nvidia.com \
--to=rrameshbabu@nvidia.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=mkubecek@suse.cz \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vadfed@meta.com \
--cc=vadim.fedorenko@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).