From patchwork Wed Apr 14 03:46:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 12201825 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6C3AC433ED for ; Wed, 14 Apr 2021 03:46:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6A158613BD for ; Wed, 14 Apr 2021 03:46:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243673AbhDNDqp (ORCPT ); Tue, 13 Apr 2021 23:46:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:34656 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232602AbhDNDqo (ORCPT ); Tue, 13 Apr 2021 23:46:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8BBB961132; Wed, 14 Apr 2021 03:46:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618371983; bh=w4gLOkKeqB/1DEk/NXSR9EPR1Sb2PqllrqPfKtrf3uI=; h=From:To:Cc:Subject:Date:From; b=qVbGGTZO9BQN5afrYhL6Ifbkumfe4ZSl4kEiyT/hPn310mGlAeSZyc1nPS5tdJxTh ShViboKzN0/ZUnIPgPG3QBAOa0FSV6uKt0CGaiFM8qTmD7TQwddY9B/OxHqJnsqB0B meIXKrfuzrYizfMP4fRIS3nS8hWdv0TUThwhp5r/MOQY1mYMFIuB66GhqZE0ZuPjlp YzgPvs/dqFEAlDHxNEwuxhypufxo6Db78qOtVyYb3WC+HHUBfLvyZoarROsHE8Qwoq 3ozbtyC+FEyClnxfNqG3fRCNFvYZLo9t6osQgAPsA5R8dpK8rRXPkXfI7Jod3fk4Y+ LKkqjRvFaCWOw== From: Jakub Kicinski To: davem@davemloft.net Cc: saeedm@nvidia.com, netdev@vger.kernel.org, mkubecek@suse.cz, andrew@lunn.ch, Jakub Kicinski Subject: [PATCH net] ethtool: pause: make sure we init driver stats Date: Tue, 13 Apr 2021 20:46:14 -0700 Message-Id: <20210414034614.1971597-1-kuba@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 --- 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;