netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] ethtool: pause: make sure we init driver stats
@ 2021-04-14  3:46 Jakub Kicinski
  2021-04-14 20:10 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Kicinski @ 2021-04-14  3:46 UTC (permalink / raw)
  To: davem; +Cc: saeedm, netdev, mkubecek, andrew, Jakub Kicinski

The intention was for pause statistics to not be reported
when driver does not have the relevant callback (only
report an empty netlink nest). What happens currently
we report all 0s instead. Make sure statistics are
initialized to "not set" (which is -1) so the dumping
code skips them.

Fixes: 9a27a33027f2 ("ethtool: add standard pause stats")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 net/ethtool/pause.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/ethtool/pause.c b/net/ethtool/pause.c
index 09998dc5c185..d4ac02718b72 100644
--- a/net/ethtool/pause.c
+++ b/net/ethtool/pause.c
@@ -38,16 +38,16 @@ static int pause_prepare_data(const struct ethnl_req_info *req_base,
 	if (!dev->ethtool_ops->get_pauseparam)
 		return -EOPNOTSUPP;
 
+	ethtool_stats_init((u64 *)&data->pausestat,
+			   sizeof(data->pausestat) / 8);
+
 	ret = ethnl_ops_begin(dev);
 	if (ret < 0)
 		return ret;
 	dev->ethtool_ops->get_pauseparam(dev, &data->pauseparam);
 	if (req_base->flags & ETHTOOL_FLAG_STATS &&
-	    dev->ethtool_ops->get_pause_stats) {
-		ethtool_stats_init((u64 *)&data->pausestat,
-				   sizeof(data->pausestat) / 8);
+	    dev->ethtool_ops->get_pause_stats)
 		dev->ethtool_ops->get_pause_stats(dev, &data->pausestat);
-	}
 	ethnl_ops_complete(dev);
 
 	return 0;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] ethtool: pause: make sure we init driver stats
  2021-04-14  3:46 [PATCH net] ethtool: pause: make sure we init driver stats Jakub Kicinski
@ 2021-04-14 20:10 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-04-14 20:10 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: davem, saeedm, netdev, mkubecek, andrew

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Tue, 13 Apr 2021 20:46:14 -0700 you wrote:
> The intention was for pause statistics to not be reported
> when driver does not have the relevant callback (only
> report an empty netlink nest). What happens currently
> we report all 0s instead. Make sure statistics are
> initialized to "not set" (which is -1) so the dumping
> code skips them.
> 
> [...]

Here is the summary with links:
  - [net] ethtool: pause: make sure we init driver stats
    https://git.kernel.org/netdev/net/c/16756d3e77ad

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-14 20:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-14  3:46 [PATCH net] ethtool: pause: make sure we init driver stats Jakub Kicinski
2021-04-14 20:10 ` patchwork-bot+netdevbpf

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).